From 11ce564288345ac4acb5dde2caa71e6b8d9e8b49 Mon Sep 17 00:00:00 2001 From: Amarnath Hullur Subramanyam Date: Fri, 29 May 2015 20:55:17 +0530 Subject: Wi-Fi HAL: Fix misc diag event processing issues. Fix issues found during reviews in processing diag events. Change-Id: I85777d08237cdae824aec746a9944a84369b19de --- qcwcn/wifi_hal/ring_buffer.cpp | 2 +- qcwcn/wifi_hal/wifilogger.cpp | 13 ++- qcwcn/wifi_hal/wifilogger_diag.cpp | 186 ++++++++++++++++++--------------- qcwcn/wifi_hal/wifilogger_diag.h | 30 +++--- qcwcn/wifi_hal/wifilogger_event_defs.h | 4 +- 5 files changed, 131 insertions(+), 104 deletions(-) diff --git a/qcwcn/wifi_hal/ring_buffer.cpp b/qcwcn/wifi_hal/ring_buffer.cpp index 344809d..771de1a 100644 --- a/qcwcn/wifi_hal/ring_buffer.cpp +++ b/qcwcn/wifi_hal/ring_buffer.cpp @@ -406,7 +406,7 @@ u8 *rb_get_read_buf(void *ctx, size_t *length) /* Move to the next buffer */ rbc->rd_buf_no++; if (rbc->rd_buf_no == rbc->max_num_bufs) { - ALOGD("Write rolling over to the start of ring buffer"); + ALOGD("Read rolling over to the start of ring buffer"); rbc->rd_buf_no = 0; } } else { diff --git a/qcwcn/wifi_hal/wifilogger.cpp b/qcwcn/wifi_hal/wifilogger.cpp index 2f9994b..21a89d1 100644 --- a/qcwcn/wifi_hal/wifilogger.cpp +++ b/qcwcn/wifi_hal/wifilogger.cpp @@ -652,24 +652,31 @@ wifi_error wifi_logger_ring_buffers_init(hal_info *info) POWER_EVENTS_RB_BUF_SIZE, POWER_EVENTS_NUM_BUFS, power_events_ring_name); - if (ret != WIFI_SUCCESS) + if (ret != WIFI_SUCCESS) { + ALOGE("Failed to initialize power events ring buffer"); goto cleanup; + } ret = rb_init(info, &info->rb_infos[CONNECTIVITY_EVENTS_RB_ID], CONNECTIVITY_EVENTS_RB_ID, CONNECTIVITY_EVENTS_RB_BUF_SIZE, CONNECTIVITY_EVENTS_NUM_BUFS, connectivity_events_ring_name); - if (ret != WIFI_SUCCESS) + if (ret != WIFI_SUCCESS) { + ALOGE("Failed to initialize connectivity events ring buffer"); goto cleanup; + } ret = rb_init(info, &info->rb_infos[PKT_STATS_RB_ID], PKT_STATS_RB_ID, PKT_STATS_RB_BUF_SIZE, PKT_STATS_NUM_BUFS, pkt_stats_ring_name); - if (ret != WIFI_SUCCESS) + if (ret != WIFI_SUCCESS) { + ALOGE("Failed to initialize per packet stats ring buffer"); goto cleanup; + } + return ret; cleanup: diff --git a/qcwcn/wifi_hal/wifilogger_diag.cpp b/qcwcn/wifi_hal/wifilogger_diag.cpp index 7aff7c4..4cdb0cd 100644 --- a/qcwcn/wifi_hal/wifilogger_diag.cpp +++ b/qcwcn/wifi_hal/wifilogger_diag.cpp @@ -99,9 +99,12 @@ static wifi_error update_connectivity_ring_buf(hal_info *info, /* Write if verbose level and handler are set */ if (info->rb_infos[CONNECTIVITY_EVENTS_RB_ID].verbose_level >= 1 && - info->on_ring_buffer_data) + info->on_ring_buffer_data) { return ring_buffer_write(&info->rb_infos[CONNECTIVITY_EVENTS_RB_ID], (u8*)rbe, total_length, 1); + } else { + return WIFI_ERROR_NOT_AVAILABLE; + } return WIFI_SUCCESS; } @@ -209,7 +212,7 @@ static wifi_error process_bt_coex_event(hal_info *info, u32 id, pConnectEvent->event = WIFI_EVENT_BT_COEX_BT_SCO_STOP; } break; - case EVENT_WIFI_BT_COEX_BT_HID_START: + case EVENT_WLAN_BT_COEX_BT_HID_START: { wlan_bt_coex_bt_hid_start_payload_type *pBtCoexHidStartPL; pBtCoexHidStartPL = (wlan_bt_coex_bt_hid_start_payload_type *)buf; @@ -223,7 +226,7 @@ static wifi_error process_bt_coex_event(hal_info *info, u32 id, pConnectEvent->event = WIFI_EVENT_BT_COEX_BT_HID_START; } break; - case EVENT_WIFI_BT_COEX_BT_HID_STOP: + case EVENT_WLAN_BT_COEX_BT_HID_STOP: { wlan_bt_coex_bt_hid_stop_payload_type *pBtCoexHidStopPL; pBtCoexHidStopPL = (wlan_bt_coex_bt_hid_stop_payload_type *)buf; @@ -264,8 +267,8 @@ static wifi_error process_bt_coex_event(hal_info *info, u32 id, pTlv = addLoggerTlv(WIFI_TAG_RSCO, sizeof(Rsco), &Rsco, pTlv); tot_len += sizeof(tlv_log) + sizeof(Rsco); - } else if ((pConnectEvent->event == EVENT_WLAN_BT_COEX_BT_SCO_START) || - (pConnectEvent->event == EVENT_WLAN_BT_COEX_BT_SCO_STOP)) { + } else if ((pConnectEvent->event == EVENT_WLAN_BT_COEX_BT_HID_START) || + (pConnectEvent->event == EVENT_WLAN_BT_COEX_BT_HID_STOP)) { pTlv = addLoggerTlv(WIFI_TAG_VENDOR_SPECIFIC, sizeof(bt_coex_hid_vendor_data_t), (u8 *)&btCoexHidVenData, pTlv); @@ -636,10 +639,10 @@ static wifi_error process_roam_event(hal_info *info, u32 id, sizeof(roamScanConfigVenData.roam_scan_config)); pTlv = addLoggerTlv(WIFI_TAG_VENDOR_SPECIFIC, - sizeof(wlan_roam_scan_config_payload_type), - (u8 *)pRoamScanConfig, pTlv); + sizeof(roam_scan_config_vendor_data_t), + (u8 *)&roamScanConfigVenData, pTlv); tot_len += sizeof(tlv_log) + - sizeof(wlan_roam_scan_config_payload_type); + sizeof(roam_scan_config_vendor_data_t); } break; } @@ -656,26 +659,27 @@ static wifi_error process_fw_diag_msg(hal_info *info, u8* buf, u16 length) { u16 count = 0, id, payloadlen; wifi_error status; - fw_diag_msg_hdr_t *dmh; + fw_diag_msg_hdr_t *diag_msg_hdr; buf += 4; length -= 4; while (length > (count + sizeof(fw_diag_msg_hdr_t))) { - dmh = (fw_diag_msg_hdr_t *)(buf + count); + diag_msg_hdr = (fw_diag_msg_hdr_t *)(buf + count); - id = dmh->diag_id; - payloadlen = dmh->payload_len; + id = diag_msg_hdr->diag_id; + payloadlen = diag_msg_hdr->u.payload_len; - switch (dmh->diag_event_type) { + switch (diag_msg_hdr->diag_event_type) { case WLAN_DIAG_TYPE_EVENT: { switch (id) { case EVENT_WLAN_BT_COEX_BT_SCO_START: case EVENT_WLAN_BT_COEX_BT_SCO_STOP: - case EVENT_WIFI_BT_COEX_BT_HID_START: - case EVENT_WIFI_BT_COEX_BT_HID_STOP: - status = process_bt_coex_event(info, id, dmh->payload, + case EVENT_WLAN_BT_COEX_BT_HID_START: + case EVENT_WLAN_BT_COEX_BT_HID_STOP: + status = process_bt_coex_event(info, id, + diag_msg_hdr->payload, payloadlen); if (status != WIFI_SUCCESS) { ALOGE("Failed to process bt_coex event"); @@ -685,8 +689,8 @@ static wifi_error process_fw_diag_msg(hal_info *info, u8* buf, u16 length) case EVENT_WLAN_BT_COEX_BT_SCAN_START: case EVENT_WLAN_BT_COEX_BT_SCAN_STOP: status = process_bt_coex_scan_event(info, id, - dmh->payload, - payloadlen); + diag_msg_hdr->payload, + payloadlen); if (status != WIFI_SUCCESS) { ALOGE("Failed to process bt_coex_scan event"); return status; @@ -698,7 +702,8 @@ static wifi_error process_fw_diag_msg(hal_info *info, u8* buf, u16 length) case EVENT_WLAN_EXTSCAN_BUCKET_COMPLETED: case EVENT_WLAN_EXTSCAN_FEATURE_STOP: case EVENT_WLAN_EXTSCAN_RESULTS_AVAILABLE: - status = process_extscan_event(info, id, dmh->payload, + status = process_extscan_event(info, id, + diag_msg_hdr->payload, payloadlen); if (status != WIFI_SUCCESS) { ALOGE("Failed to process extscan event"); @@ -709,7 +714,8 @@ static wifi_error process_fw_diag_msg(hal_info *info, u8* buf, u16 length) case EVENT_WLAN_ROAM_SCAN_COMPLETE: case EVENT_WLAN_ROAM_CANDIDATE_FOUND: case EVENT_WLAN_ROAM_SCAN_CONFIG: - status = process_roam_event(info, id, dmh->payload, + status = process_roam_event(info, id, + diag_msg_hdr->payload, payloadlen); if (status != WIFI_SUCCESS) { ALOGE("Failed to process roam event"); @@ -717,16 +723,18 @@ static wifi_error process_fw_diag_msg(hal_info *info, u8* buf, u16 length) } break; case EVENT_WLAN_ADD_BLOCK_ACK_SUCCESS: - status = process_addba_success_event(info, dmh->payload, - payloadlen); + status = process_addba_success_event(info, + diag_msg_hdr->payload, + payloadlen); if (status != WIFI_SUCCESS) { ALOGE("Failed to process addba success event"); return status; } break; case EVENT_WLAN_ADD_BLOCK_ACK_FAILED: - status = process_addba_failed_event(info, dmh->payload, - payloadlen); + status = process_addba_failed_event(info, + diag_msg_hdr->payload, + payloadlen); if (status != WIFI_SUCCESS) { ALOGE("Failed to process addba failed event"); return status; @@ -743,6 +751,8 @@ static wifi_error process_fw_diag_msg(hal_info *info, u8* buf, u16 length) break; case WLAN_DIAG_TYPE_MSG: { + /* Length field is only one byte for WLAN_DIAG_TYPE_MSG */ + payloadlen = diag_msg_hdr->u.msg_hdr.payload_len; } break; default: @@ -923,10 +933,13 @@ static wifi_error process_wakelock_event(hal_info *info, u8* buf, int length) /* Write if verbose and handler is set */ if (info->rb_infos[POWER_EVENTS_RB_ID].verbose_level >= 1 && - info->on_ring_buffer_data) + info->on_ring_buffer_data) { status = ring_buffer_write(&info->rb_infos[POWER_EVENTS_RB_ID], (u8*)pRingBufferEntry, len_ring_buffer_entry, 1); + } else { + status = WIFI_ERROR_NOT_AVAILABLE; + } if ((u8 *)pRingBufferEntry != wl_ring_buffer) { ALOGI("Message with more than RING_BUF_ENTRY_SIZE"); @@ -970,11 +983,14 @@ static wifi_error update_stats_to_ring_buf(hal_info *info, // Write if verbose and handler is set if ((info->rb_infos[PKT_STATS_RB_ID].verbose_level >= VERBOSE_DEBUG_PROBLEM) - && info->on_ring_buffer_data) + && info->on_ring_buffer_data) { ring_buffer_write(&info->rb_infos[PKT_STATS_RB_ID], (u8*)pRingBufferEntry, size, num_records); + } else { + return WIFI_ERROR_NOT_AVAILABLE; + } return WIFI_SUCCESS; } @@ -1362,69 +1378,73 @@ wifi_error diag_message_handler(hal_info *info, nl_msg *msg) tAniNlHdr *wnl = (tAniNlHdr *)nlmsg_hdr(msg); u8 *buf; wifi_error status; - if (wnl->wmsg.type == ANI_NL_MSG_LOG_HOST_EVENT_LOG_TYPE) { - uint32_t diag_host_type; - - buf = (uint8_t *)(wnl + 1); - diag_host_type = *(uint32_t *)(buf); - ALOGV("diag type = %d", diag_host_type); - - buf += sizeof(uint32_t); //diag_type - if (diag_host_type == DIAG_TYPE_HOST_EVENTS) { - host_event_hdr_t *event_hdr = - (host_event_hdr_t *)(buf); - ALOGV("diag event_id = %d length %d", - event_hdr->event_id, event_hdr->length); - buf += sizeof(host_event_hdr_t); - switch (event_hdr->event_id) { - case EVENT_WLAN_WAKE_LOCK: - process_wakelock_event(info, buf, event_hdr->length); - break; - case EVENT_WLAN_PE: - process_wlan_pe_event(info, buf, event_hdr->length); - break; - case EVENT_WLAN_EAPOL: - process_wlan_eapol_event(info, buf, event_hdr->length); - break; - case EVENT_WLAN_LOG_COMPLETE: - process_wlan_log_complete_event(info, buf, event_hdr->length); - break; - default: - return WIFI_SUCCESS; - } - } else if (diag_host_type == DIAG_TYPE_HOST_LOG_MSGS) { - drv_msg_t *drv_msg = (drv_msg_t *) (buf); - ALOGV("diag event_type = %0x length = %d", - drv_msg->event_type, drv_msg->length); - if (drv_msg->event_type == WLAN_PKT_LOG_STATS) { - if ((info->pkt_stats->prev_seq_no + 1) != - drv_msg->u.pkt_stats_event.msg_seq_no) { - ALOGE("Few pkt stats messages missed: rcvd = %d, prev = %d", - drv_msg->u.pkt_stats_event.msg_seq_no, - info->pkt_stats->prev_seq_no); - if (info->pkt_stats->tx_stats_events) { - info->pkt_stats->tx_stats_events = 0; - memset(&info->pkt_stats->tx_stats, 0, - sizeof(wifi_ring_per_packet_status_entry)); - } + + /* Check nlmsg_type also to avoid processing unintended msgs */ + if (wnl->nlh.nlmsg_type == ANI_NL_MSG_PUMAC) { + if (wnl->wmsg.type == ANI_NL_MSG_LOG_HOST_EVENT_LOG_TYPE) { + uint32_t diag_host_type; + + buf = (uint8_t *)(wnl + 1); + diag_host_type = *(uint32_t *)(buf); + ALOGV("diag type = %d", diag_host_type); + + buf += sizeof(uint32_t); //diag_type + if (diag_host_type == DIAG_TYPE_HOST_EVENTS) { + host_event_hdr_t *event_hdr = + (host_event_hdr_t *)(buf); + ALOGV("diag event_id = %x length %d", + event_hdr->event_id, event_hdr->length); + buf += sizeof(host_event_hdr_t); + switch (event_hdr->event_id) { + case EVENT_WLAN_WAKE_LOCK: + process_wakelock_event(info, buf, event_hdr->length); + break; + case EVENT_WLAN_PE: + process_wlan_pe_event(info, buf, event_hdr->length); + break; + case EVENT_WLAN_EAPOL: + process_wlan_eapol_event(info, buf, event_hdr->length); + break; + case EVENT_WLAN_LOG_COMPLETE: + process_wlan_log_complete_event(info, buf, event_hdr->length); + break; + default: + return WIFI_SUCCESS; } + } else if (diag_host_type == DIAG_TYPE_HOST_LOG_MSGS) { + drv_msg_t *drv_msg = (drv_msg_t *) (buf); + ALOGV("diag event_type = %0x length = %d", + drv_msg->event_type, drv_msg->length); + if (drv_msg->event_type == WLAN_PKT_LOG_STATS) { + if ((info->pkt_stats->prev_seq_no + 1) != + drv_msg->u.pkt_stats_event.msg_seq_no) { + ALOGE("Few pkt stats messages missed: rcvd = %d, prev = %d", + drv_msg->u.pkt_stats_event.msg_seq_no, + info->pkt_stats->prev_seq_no); + if (info->pkt_stats->tx_stats_events) { + info->pkt_stats->tx_stats_events = 0; + memset(&info->pkt_stats->tx_stats, 0, + sizeof(wifi_ring_per_packet_status_entry)); + } + } - info->pkt_stats->prev_seq_no = - drv_msg->u.pkt_stats_event.msg_seq_no; - status = parse_stats(info, - drv_msg->u.pkt_stats_event.payload, - drv_msg->u.pkt_stats_event.payload_len); - if (status != WIFI_SUCCESS) { - ALOGE("%s: Failed to parse Tx-Rx stats", __FUNCTION__); - ALOGE("Received msg Seq_num : %d", - drv_msg->u.pkt_stats_event.msg_seq_no); - hexdump((char *)drv_msg->u.pkt_stats_event.payload, + info->pkt_stats->prev_seq_no = + drv_msg->u.pkt_stats_event.msg_seq_no; + status = parse_stats(info, + drv_msg->u.pkt_stats_event.payload, drv_msg->u.pkt_stats_event.payload_len); - return status; + if (status != WIFI_SUCCESS) { + ALOGE("%s: Failed to parse Tx-Rx stats", __FUNCTION__); + ALOGE("Received msg Seq_num : %d", + drv_msg->u.pkt_stats_event.msg_seq_no); + hexdump((char *)drv_msg->u.pkt_stats_event.payload, + drv_msg->u.pkt_stats_event.payload_len); + return status; + } } } } - } else { + } else if (wnl->nlh.nlmsg_type == ANI_NL_MSG_CNSS_DIAG) { uint16_t diag_fw_type; uint32_t event_id; buf = (uint8_t *)NLMSG_DATA(wnl); diff --git a/qcwcn/wifi_hal/wifilogger_diag.h b/qcwcn/wifi_hal/wifilogger_diag.h index 9597b68..e61767c 100644 --- a/qcwcn/wifi_hal/wifilogger_diag.h +++ b/qcwcn/wifi_hal/wifilogger_diag.h @@ -76,9 +76,9 @@ enum wifilogger_host_diag_type { enum wlan_diag_frame_type { WLAN_DIAG_TYPE_CONFIG, - WLAN_DIAG_TYPE_EVENT, - WLAN_DIAG_TYPE_LOG, - WLAN_DIAG_TYPE_MSG, + WLAN_DIAG_TYPE_EVENT, /* Diag Events */ + WLAN_DIAG_TYPE_LOG, /* Diag Logs */ + WLAN_DIAG_TYPE_MSG, /* F3 messages */ WLAN_DIAG_TYPE_LEGACY_MSG, }; @@ -102,17 +102,9 @@ typedef struct { }__attribute__((packed)) dbglog_slot; typedef enum eAniNlModuleTypes { - ANI_NL_MSG_NETSIM = ANI_NL_MSG_BASE,// NetSim Messages (to the server) - ANI_NL_MSG_PUMAC, // Messages for/from the Upper MAC driver - ANI_NL_MSG_WNS, // Messages for the Wireless Networking - // Services module(s) - ANI_NL_MSG_MACSW, // Messages from MAC - ANI_NL_MSG_ES, // Messages from ES - ANI_NL_MSG_WSM, // Message from the WSM in user space - ANI_NL_MSG_DVT, // Message from the DVT application - ANI_NL_MSG_PTT, // Message from the PTT application - ANI_NL_MSG_MAC_CLONE, //Message from the Mac clone App - ANI_NL_MSG_LOG = ANI_NL_MSG_BASE + 0x0C, // Message for WLAN logging + ANI_NL_MSG_PUMAC = ANI_NL_MSG_BASE + 0x01, + ANI_NL_MSG_CNSS_DIAG = ANI_NL_MSG_BASE + 0x0B, + ANI_NL_MSG_LOG, ANI_NL_MSG_MAX } tAniNlModTypes; @@ -158,7 +150,15 @@ typedef struct { u32 timestamp:24; u32 diag_event_type:8; - u16 payload_len; + /* Below 16-bit field has different formats based on event type */ + union { + u16 payload_len; + struct { + u8 payload_len; + u8 vdev_level:3; + u8 vdev_id:5; + }__attribute__((packed)) msg_hdr; + }__attribute__((packed)) u; u16 diag_id; u8 payload[0]; }__attribute__((packed)) fw_diag_msg_hdr_t; diff --git a/qcwcn/wifi_hal/wifilogger_event_defs.h b/qcwcn/wifi_hal/wifilogger_event_defs.h index 5b386c8..a02fdad 100644 --- a/qcwcn/wifi_hal/wifilogger_event_defs.h +++ b/qcwcn/wifi_hal/wifilogger_event_defs.h @@ -55,8 +55,8 @@ typedef enum { EVENT_WLAN_BT_COEX_BT_SCO_STOP = 0xA99, EVENT_WLAN_BT_COEX_BT_SCAN_START = 0xA9A, EVENT_WLAN_BT_COEX_BT_SCAN_STOP = 0xA9B, - EVENT_WIFI_BT_COEX_BT_HID_START = 0xA9C, - EVENT_WIFI_BT_COEX_BT_HID_STOP = 0xA9D, + EVENT_WLAN_BT_COEX_BT_HID_START = 0xA9C, + EVENT_WLAN_BT_COEX_BT_HID_STOP = 0xA9D, EVENT_WLAN_WAKE_LOCK = 0xAA2, /* 96 bytes payload */ EVENT_WLAN_EAPOL = 0xA8D, /* 96 bytes payload */ EVENT_WLAN_EXTSCAN_FEATURE_STOP = 0xAA3, -- cgit v1.2.3