diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index ffa86e6c1376..39fe7e1a7d97 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -627,29 +627,6 @@ typedef struct hdd_cfg80211_state_s { eP2PActionFrameState actionFrmState; } hdd_cfg80211_state_t; - -/*--------------------------------------------------------------------------- - hdd_ibss_peer_info_params_t - ---------------------------------------------------------------------------*/ -typedef struct { - uint8_t staIdx; /* StaIdx */ - uint32_t txRate; /* Current Tx Rate */ - uint32_t mcsIndex; /* MCS Index */ - uint32_t txRateFlags; /* TxRate Flags */ - int8_t rssi; /* RSSI */ -} hdd_ibss_peer_info_params_t; - -typedef struct { - /** Request status */ - uint32_t status; - - /** Number of peers */ - uint8_t numIBSSPeers; - - /** Peer Info parameters */ - hdd_ibss_peer_info_params_t ibssPeerList[MAX_IBSS_PEERS]; -} hdd_ibss_peer_info_t; - struct hdd_station_ctx { /** Handle to the Wireless Extension State */ hdd_wext_state_t WextState; @@ -676,7 +653,7 @@ struct hdd_station_ctx { /*Save the wep/wpa-none keys */ tCsrRoamSetKey ibss_enc_key; - hdd_ibss_peer_info_t ibss_peer_info; + tSirPeerInfoRspParams ibss_peer_info; bool hdd_ReassocScenario; @@ -1658,4 +1635,7 @@ static inline bool roaming_offload_enabled(hdd_context_t *hdd_ctx) } #endif +void hdd_get_ibss_peer_info_cb(void *pUserData, + tSirPeerInfoRspParams *pPeerInfo); + #endif /* end #if !defined(WLAN_HDD_MAIN_H) */ diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index d98a6cf6adf9..fc3f3d1d6ff0 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -423,21 +423,20 @@ static int hdd_parse_setrmcrate_command(uint8_t *pValue, } /** - * hdd_cfg80211_get_ibss_peer_info_cb() - Callback function for IBSS - * Peer Info request - * @pUserData: Adapter private data - * @pPeerInfoRsp: Peer info response + * hdd_get_ibss_peer_info_cb() - IBSS peer Info request callback + * @UserData: Adapter private data + * @pPeerInfoRsp: Peer info response * * This is an asynchronous callback function from SME when the peer info * is received * * Return: 0 for success non-zero for failure */ -static void -hdd_cfg80211_get_ibss_peer_info_cb(void *pUserData, void *pPeerInfoRsp) +void +hdd_get_ibss_peer_info_cb(void *pUserData, + tSirPeerInfoRspParams *pPeerInfo) { hdd_adapter_t *adapter = (hdd_adapter_t *) pUserData; - hdd_ibss_peer_info_t *pPeerInfo = (hdd_ibss_peer_info_t *)pPeerInfoRsp; hdd_station_ctx_t *pStaCtx; uint8_t i; @@ -451,21 +450,19 @@ hdd_cfg80211_get_ibss_peer_info_cb(void *pUserData, void *pPeerInfoRsp) pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); if (NULL != pPeerInfo && QDF_STATUS_SUCCESS == pPeerInfo->status) { - pStaCtx->ibss_peer_info.status = pPeerInfo->status; - pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numIBSSPeers; + /* validate number of peers */ + if (pPeerInfo->numPeers < SIR_MAX_NUM_STA_IN_IBSS) { + pStaCtx->ibss_peer_info.status = pPeerInfo->status; + pStaCtx->ibss_peer_info.numPeers = pPeerInfo->numPeers; - /* Paranoia check */ - if (pPeerInfo->numIBSSPeers < MAX_IBSS_PEERS) { - for (i = 0; i < pPeerInfo->numIBSSPeers; i++) { - memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i], - &pPeerInfo->ibssPeerList[i], - sizeof(hdd_ibss_peer_info_params_t)); + for (i = 0; i < pPeerInfo->numPeers; i++) { + pStaCtx->ibss_peer_info.peerInfoParams[i] = + pPeerInfo->peerInfoParams[i]; } - hddLog(LOG1, FL("Peer Info copied in HDD")); + hdd_info("Peer Info copied in HDD"); } else { - hddLog(LOG1, - FL("Number of peers %d returned is more than limit %d"), - pPeerInfo->numIBSSPeers, MAX_IBSS_PEERS); + hdd_info("Number of peers %d returned is more than limit %d", + pPeerInfo->numPeers, SIR_MAX_NUM_STA_IN_IBSS); } } else { hddLog(LOG1, FL("peerInfo returned is NULL")); @@ -492,7 +489,7 @@ QDF_STATUS hdd_cfg80211_get_ibss_peer_info_all(hdd_adapter_t *adapter) INIT_COMPLETION(adapter->ibss_peer_info_comp); retStatus = sme_request_ibss_peer_info(hHal, adapter, - hdd_cfg80211_get_ibss_peer_info_cb, + hdd_get_ibss_peer_info_cb, true, 0xFF); if (QDF_STATUS_SUCCESS == retStatus) { @@ -536,7 +533,7 @@ hdd_cfg80211_get_ibss_peer_info(hdd_adapter_t *adapter, uint8_t staIdx) INIT_COMPLETION(adapter->ibss_peer_info_comp); retStatus = sme_request_ibss_peer_info(hHal, adapter, - hdd_cfg80211_get_ibss_peer_info_cb, + hdd_get_ibss_peer_info_cb, false, staIdx); if (QDF_STATUS_SUCCESS == retStatus) { @@ -5328,8 +5325,7 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter, char *extra = NULL; int idx = 0; int length = 0; - struct qdf_mac_addr *macAddr; - uint32_t txRateMbps = 0; + uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; uint32_t numOfBytestoPrint = 0; if (QDF_IBSS_MODE != adapter->device_mode) { @@ -5366,51 +5362,34 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter, /* Copy number of stations */ length = scnprintf(extra, WLAN_MAX_BUF_SIZE, "%d ", - pHddStaCtx->ibss_peer_info. - numIBSSPeers); + pHddStaCtx->ibss_peer_info.numPeers); numOfBytestoPrint = length; - for (idx = 0; idx < pHddStaCtx->ibss_peer_info.numIBSSPeers; - idx++) { - macAddr = hdd_wlan_get_ibss_mac_addr_from_staid - (adapter, - pHddStaCtx->ibss_peer_info. - ibssPeerList[idx].staIdx); - if (NULL != macAddr) { - txRateMbps = ((pHddStaCtx-> - ibss_peer_info. - ibssPeerList[idx].txRate) - * 500 * 1000) / 1000000; - length += scnprintf((extra + length), - WLAN_MAX_BUF_SIZE - length, - "%02x:%02x:%02x:%02x:%02x:%02x %d %d ", - macAddr->bytes[0], - macAddr->bytes[1], - macAddr->bytes[2], - macAddr->bytes[3], - macAddr->bytes[4], - macAddr->bytes[5], - (int)txRateMbps, - (int)pHddStaCtx-> - ibss_peer_info. - ibssPeerList[idx]. - rssi); - } else { - QDF_TRACE(QDF_MODULE_ID_HDD, - QDF_TRACE_LEVEL_ERROR, - "%s: MAC ADDR is NULL for staIdx: %d", - __func__, - pHddStaCtx-> - ibss_peer_info. - ibssPeerList[idx]. - staIdx); - } + for (idx = 0; idx < pHddStaCtx->ibss_peer_info.numPeers; + idx++) { + int8_t rssi; + uint32_t tx_rate; + qdf_mem_copy(mac_addr, + pHddStaCtx->ibss_peer_info.peerInfoParams[idx]. + mac_addr, sizeof(mac_addr)); + + tx_rate = + pHddStaCtx->ibss_peer_info.peerInfoParams[idx]. + txRate; + rssi = pHddStaCtx->ibss_peer_info.peerInfoParams[idx]. + rssi; + + length += scnprintf((extra + length), + WLAN_MAX_BUF_SIZE - length, + "%02x:%02x:%02x:%02x:%02x:%02x %d %d ", + mac_addr[0], mac_addr[1], mac_addr[2], + mac_addr[3], mac_addr[4], mac_addr[5], + tx_rate, rssi); /* - * QDF_TRACE() macro has limitation of 512 bytes - * for the print buffer. Hence printing the data - * in two chunks. The first chunk will have the data - * for 16 devices and the second chunk will - * have the rest. + * cdf_trace_msg has limitation of 512 bytes for the + * print buffer. Hence printing the data in two chunks. + * The first chunk will have the data for 16 devices + * and the second chunk will have the rest. */ if (idx < NUM_OF_STA_DATA_TO_PRINT) numOfBytestoPrint = length; @@ -5484,8 +5463,6 @@ static int drv_cmd_get_ibss_peer_info(hdd_adapter_t *adapter, char extra[128] = { 0 }; uint32_t length = 0; uint8_t staIdx = 0; - uint32_t txRateMbps = 0; - uint32_t txRate; struct qdf_mac_addr peerMacAddr; if (QDF_IBSS_MODE != adapter->device_mode) { @@ -5523,7 +5500,7 @@ static int drv_cmd_get_ibss_peer_info(hdd_adapter_t *adapter, goto exit; } - /* Get station index for the peer mac address */ + /* Get station index for the peer mac address and sanitize it */ hdd_ibss_get_sta_id(pHddStaCtx, &peerMacAddr, &staIdx); if (staIdx > MAX_IBSS_PEERS) { @@ -5538,13 +5515,13 @@ static int drv_cmd_get_ibss_peer_info(hdd_adapter_t *adapter, /* Handle the command */ status = hdd_cfg80211_get_ibss_peer_info(adapter, staIdx); if (QDF_STATUS_SUCCESS == status) { - txRate = pHddStaCtx->ibss_peer_info.ibssPeerList[0].txRate; - txRateMbps = (txRate * 500 * 1000) / 1000000; + uint32_t txRate = + pHddStaCtx->ibss_peer_info.peerInfoParams[0].txRate; length = scnprintf(extra, sizeof(extra), "%d %d", - (int)txRateMbps, - (int)pHddStaCtx->ibss_peer_info. - ibssPeerList[0].rssi); + (int)txRate, + (int)pHddStaCtx->ibss_peer_info. + peerInfoParams[0].rssi); /* Copy the data back into buffer */ if (copy_to_user(priv_data->buf, &extra, length + 1)) { diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index a3bbc3f9efdb..124d601a2cdb 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -765,36 +765,6 @@ error: return; } -/** - * hdd_get_ibss_peer_info_cb() - IBSS Peer Info Callback - * @pUserData: user context originally passed to SME; we pass hdd adapter - * @pPeerInfoRsp: IBSS Peer information - * - * Return: None - */ -void hdd_get_ibss_peer_info_cb(void *pUserData, void *pPeerInfoRsp) -{ - hdd_adapter_t *pAdapter = (hdd_adapter_t *) pUserData; - hdd_ibss_peer_info_t *pPeerInfo = (hdd_ibss_peer_info_t *) pPeerInfoRsp; - hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); - uint8_t i; - - if (NULL != pPeerInfo && QDF_STATUS_SUCCESS == pPeerInfo->status) { - pStaCtx->ibss_peer_info.status = pPeerInfo->status; - pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numIBSSPeers; - for (i = 0; i < pPeerInfo->numIBSSPeers; i++) { - memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i], - &pPeerInfo->ibssPeerList[i], - sizeof(hdd_ibss_peer_info_params_t)); - } - } else { - QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, - "%s] PEER_INFO_CMD_STATUS is not SUCCESS", __func__); - } - - complete(&pAdapter->ibss_peer_info_comp); -} - /** * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address * @pAdapter: Adapter upon which the IBSS client is active @@ -832,7 +802,7 @@ QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, uint8_t staIdx) QDF_STATUS status = QDF_STATUS_E_FAILURE; tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); - hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info; + tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info; status = sme_request_ibss_peer_info(hHal, pAdapter, hdd_get_ibss_peer_info_cb, @@ -852,29 +822,16 @@ QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, uint8_t staIdx) } /** Print the peer info */ - pr_info("pPeerInfo->numIBSSPeers = %d ", - pPeerInfo->numIBSSPeers); - pr_info - ("============================================================"); + hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers); { - struct qdf_mac_addr *macAddr = - hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter, - staIdx); - uint32_t txRateMbps = - ((pPeerInfo->ibssPeerList[0].txRate) * 500 * 1000) / - 1000000; + uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; + uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate; - if (NULL != macAddr) { - pr_info("PEER ADDR :" MAC_ADDRESS_STR - " TxRate: %d Mbps RSSI: %d", - MAC_ADDR_ARRAY(macAddr->bytes), - (int)txRateMbps, - (int)pPeerInfo->ibssPeerList[0].rssi); - } else { - QDF_TRACE(QDF_MODULE_ID_HDD, - QDF_TRACE_LEVEL_ERROR, - " ERROR: PEER MAC ADDRESS NOT FOUND "); - } + qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0]. + mac_addr, sizeof(mac_addr)); + hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d", + mac_addr, (int)tx_rate, + (int)pPeerInfo->peerInfoParams[0].rssi); } } else { hddLog(QDF_TRACE_LEVEL_WARN, @@ -897,7 +854,7 @@ QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter) QDF_STATUS status = QDF_STATUS_E_FAILURE; tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); - hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info; + tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info; int i; status = @@ -917,32 +874,20 @@ QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter) } /** Print the peer info */ - pr_info("pPeerInfo->numIBSSPeers = %d ", - (int)pPeerInfo->numIBSSPeers); - pr_info - ("============================================================"); - for (i = 0; i < pPeerInfo->numIBSSPeers; i++) { - uint8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx; - struct qdf_mac_addr *macAddr = - hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter, - staIdx); - uint32_t txRateMbps = - ((pPeerInfo->ibssPeerList[0].txRate) * 500 * 1000) / - 1000000; + hdd_info("pPeerInfo->numIBSSPeers = %d ", + (int)pPeerInfo->numPeers); + for (i = 0; i < pPeerInfo->numPeers; i++) { + uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; + uint32_t tx_rate; - pr_info("STAIDX:%d ", - (int)pPeerInfo->ibssPeerList[i].staIdx); - if (NULL != macAddr) { - pr_info(" PEER ADDR :" MAC_ADDRESS_STR - " TxRate: %d Mbps RSSI: %d", - MAC_ADDR_ARRAY(macAddr->bytes), - (int)txRateMbps, - (int)pPeerInfo->ibssPeerList[i].rssi); - } else { - QDF_TRACE(QDF_MODULE_ID_HDD, - QDF_TRACE_LEVEL_ERROR, - " ERROR: PEER MAC ADDRESS NOT FOUND "); - } + tx_rate = pPeerInfo->peerInfoParams[i].txRate; + qdf_mem_copy(mac_addr, + pPeerInfo->peerInfoParams[i].mac_addr, + sizeof(mac_addr)); + + hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d", + mac_addr, (int)tx_rate, + (int)pPeerInfo->peerInfoParams[i].rssi); } } else { hddLog(QDF_TRACE_LEVEL_WARN, diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 0a9b8a92a714..cf0870c5f891 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -3744,15 +3744,20 @@ typedef struct { /* of peer with staIdx is reported */ } tSirIbssGetPeerInfoReqParams, *tpSirIbssGetPeerInfoReqParams; -/*--------------------------------------------------------------------------- -* tSirIbssGetPeerInfoParams -*--------------------------------------------------------------------------*/ +/** + * typedef struct - tSirIbssGetPeerInfoParams + * @mac_addr: mac address received from target + * @txRate: TX rate + * @mcsIndex: MCS index + * @txRateFlags: TX rate flags + * @rssi: RSSI + */ typedef struct { - uint8_t staIdx; /* StaIdx */ - uint32_t txRate; /* Tx Rate */ - uint32_t mcsIndex; /* MCS Index */ - uint32_t txRateFlags; /* TxRate Flags */ - int8_t rssi; /* RSSI */ + uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; + uint32_t txRate; + uint32_t mcsIndex; + uint32_t txRateFlags; + int8_t rssi; } tSirIbssPeerInfoParams; typedef struct { diff --git a/core/sme/inc/sme_internal.h b/core/sme/inc/sme_internal.h index cca91d596243..9e27ba2d2307 100644 --- a/core/sme/inc/sme_internal.h +++ b/core/sme/inc/sme_internal.h @@ -105,7 +105,8 @@ typedef enum eSmeState { #define SME_IS_READY(pMac) (SME_STATE_READY == (pMac)->sme.state) /* HDD Callback function */ -typedef void (*pIbssPeerInfoCb)(void *pUserData, void *infoParam); +typedef void (*pIbssPeerInfoCb)(void *pUserData, + tSirPeerInfoRspParams *infoParam); /* Peer info */ typedef struct tagSmePeerInfoHddCbkInfo { diff --git a/core/wma/src/wma_data.c b/core/wma/src/wma_data.c index 2442aaad320b..42ca332a8646 100644 --- a/core/wma/src/wma_data.c +++ b/core/wma/src/wma_data.c @@ -2002,13 +2002,12 @@ int wma_ibss_peer_info_event_handler(void *handle, uint8_t *data, cds_msg_t cds_msg; wmi_peer_info *peer_info; ol_txrx_pdev_handle pdev; - struct ol_txrx_peer_t *peer; tSirIbssPeerInfoParams *pSmeRsp; uint32_t count, num_peers, status; tSirIbssGetPeerInfoRspParams *pRsp; WMI_PEER_INFO_EVENTID_param_tlvs *param_tlvs; wmi_peer_info_event_fixed_param *fix_param; - uint8_t peer_mac[IEEE80211_ADDR_LEN], staIdx; + uint8_t peer_mac[IEEE80211_ADDR_LEN]; pdev = cds_get_context(QDF_MODULE_ID_TXRX); if (NULL == pdev) { @@ -2044,27 +2043,16 @@ int wma_ibss_peer_info_event_handler(void *handle, uint8_t *data, WMI_MAC_ADDR_TO_CHAR_ARRAY(&peer_info->peer_mac_address, peer_mac); - peer = ol_txrx_find_peer_by_addr(pdev, peer_mac, &staIdx); - if (NULL == peer) { - WMA_LOGE("%s: peer 0x:%2x:0x%2x:0x%2x:0x%2x:0x%2x:0x%2x does not" - " exist could not populate response", __func__, - peer_mac[0], peer_mac[1], peer_mac[2], - peer_mac[3], peer_mac[4], peer_mac[5]); - - pSmeRsp->staIdx = 0xff; /*fill invalid staIdx */ - peer_info++; - continue; - } - pSmeRsp->staIdx = staIdx; + qdf_mem_copy(pSmeRsp->mac_addr, peer_mac, + sizeof(pSmeRsp->mac_addr)); pSmeRsp->mcsIndex = 0; pSmeRsp->rssi = peer_info->rssi + WMA_TGT_NOISE_FLOOR_DBM; pSmeRsp->txRate = peer_info->data_rate; pSmeRsp->txRateFlags = 0; - WMA_LOGE("%s: peer 0x:%2x:0x%2x:0x%2x:0x%2x:0x%2x:0x%2x staIdx %d " - "rssi %d txRate %d", __func__, peer_mac[0], peer_mac[1], - peer_mac[2], peer_mac[3], peer_mac[4], peer_mac[5], - staIdx, pSmeRsp->rssi, pSmeRsp->txRate); + WMA_LOGE("peer " MAC_ADDRESS_STR "rssi %d txRate %d", + MAC_ADDR_ARRAY(peer_mac), + pSmeRsp->rssi, pSmeRsp->txRate); peer_info++; }