From a3cf12aee4bf1a76ab7606b41a4e1d46b795538b Mon Sep 17 00:00:00 2001 From: Sourav Mohapatra Date: Mon, 19 Aug 2019 15:40:49 +0530 Subject: [PATCH] qcacld-3.0: Remove sta_id from hdd_connection_info As a part of the sta_id clean up, remove the usage of the sta_id from struct hdd_connection_info. Instead of the station id, use peer mac address to interact with the protocol and DP layers. Change-Id: I60b939c37ff49b50579791f45e3e81ed81b86967 CRs-Fixed: 2524514 --- core/hdd/inc/wlan_hdd_assoc.h | 6 +- core/hdd/inc/wlan_hdd_tx_rx.h | 12 -- core/hdd/src/wlan_hdd_assoc.c | 141 ++++++++--------------- core/hdd/src/wlan_hdd_ioctl.c | 16 +-- core/hdd/src/wlan_hdd_main.c | 9 +- core/hdd/src/wlan_hdd_nan_datapath.c | 28 ++--- core/hdd/src/wlan_hdd_ocb.c | 6 - core/hdd/src/wlan_hdd_tx_rx.c | 161 +++++++++++++-------------- core/hdd/src/wlan_hdd_wext.c | 44 ++++---- core/hdd/src/wlan_hdd_wmm.c | 25 +---- core/sme/inc/sme_api.h | 9 +- core/sme/src/common/sme_api.c | 7 +- 12 files changed, 174 insertions(+), 290 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_assoc.h b/core/hdd/inc/wlan_hdd_assoc.h index e62524027cf7..f9f7de090c73 100644 --- a/core/hdd/inc/wlan_hdd_assoc.h +++ b/core/hdd/inc/wlan_hdd_assoc.h @@ -141,7 +141,6 @@ struct hdd_conn_flag { * @conn_state: connection state of the NIC * @bssid: BSSID * @SSID: SSID Info - * @sta_id: Station ID * @peer_macaddr:Peer Mac Address of the IBSS Stations * @auth_type: Auth Type * @uc_encrypt_type: Unicast Encryption Type @@ -177,7 +176,6 @@ struct hdd_connection_info { eConnectionState conn_state; struct qdf_mac_addr bssid; tCsrSSIDInfo ssid; - uint8_t sta_id[MAX_PEERS]; struct qdf_mac_addr peer_macaddr[MAX_PEERS]; enum csr_akm_type auth_type; eCsrEncryptionType uc_encrypt_type; @@ -426,12 +424,10 @@ QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data, QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter, struct csr_roam_info *roam_info, - uint8_t sta_id, struct bss_description *bss_desc); -bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id, +bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, struct qdf_mac_addr *peer_mac_addr); -void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id); /** * hdd_roam_deregister_sta() - deregister station diff --git a/core/hdd/inc/wlan_hdd_tx_rx.h b/core/hdd/inc/wlan_hdd_tx_rx.h index f358c41dac84..3206aa4e76ab 100644 --- a/core/hdd/inc/wlan_hdd_tx_rx.h +++ b/core/hdd/inc/wlan_hdd_tx_rx.h @@ -168,18 +168,6 @@ void hdd_disable_rx_ol_in_concurrency(bool disable); */ void hdd_disable_rx_ol_for_low_tput(struct hdd_context *hdd_ctx, bool disable); -/** - * hdd_get_peer_sta_id() - Get the StationID using the Peer Mac address - * @sta_ctx: pointer to HDD Station Context - * @mac_address: pointer to Peer Mac address - * @sta_id: pointer to returned Station Index - * - * Return: QDF_STATUS_SUCCESS/QDF_STATUS_E_FAILURE - */ -QDF_STATUS hdd_get_peer_sta_id(struct hdd_station_ctx *sta_ctx, - struct qdf_mac_addr *mac_address, - uint8_t *sta_id); - /** * hdd_reset_all_adapters_connectivity_stats() - reset connectivity stats * @hdd_ctx: pointer to HDD Station Context diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index 7a52148a671e..4a5c8af73dfc 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -970,17 +970,6 @@ hdd_conn_save_connect_info(struct hdd_adapter *adapter, qdf_copy_macaddr(&sta_ctx->conn_info.bssid, &roam_info->bssid); - /* - * Save the Station ID for this station from - * the 'Roam Info'. For IBSS mode, sta_id is - * assigned in NEW_PEER_IND. For reassoc, the - * sta_id doesn't change and it may be invalid - * in this structure so no change here. - */ - if (!roam_info->fReassocReq) { - sta_ctx->conn_info.sta_id[0] = - roam_info->staId; - } } else if (eCSR_BSS_TYPE_IBSS == bss_type) { qdf_copy_macaddr(&sta_ctx->conn_info.bssid, &roam_info->bssid); @@ -1522,8 +1511,7 @@ static void hdd_send_association_event(struct net_device *dev, */ static void hdd_conn_remove_connect_info(struct hdd_station_ctx *sta_ctx) { - /* Remove sta_id, bssid and peer_macaddr */ - sta_ctx->conn_info.sta_id[0] = HDD_WLAN_INVALID_STA_ID; + /* Remove bssid and peer_macaddr */ qdf_mem_zero(&sta_ctx->conn_info.bssid, QDF_MAC_ADDR_SIZE); qdf_mem_zero(&sta_ctx->conn_info.peer_macaddr[0], QDF_MAC_ADDR_SIZE); @@ -1704,7 +1692,6 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter, struct net_device *dev = adapter->dev; struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); - uint8_t sta_id; bool sendDisconInd = true; mac_handle_t mac_handle; struct wlan_ies disconnect_ies = {0}; @@ -1720,7 +1707,7 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter, WLAN_CONTROL_PATH); if (ucfg_ipa_is_enabled() && - (sta_ctx->conn_info.sta_id[0] != HDD_WLAN_INVALID_STA_ID)) + (hdd_is_valid_mac_address(sta_ctx->conn_info.bssid.bytes))) ucfg_ipa_wlan_evt(hdd_ctx->pdev, adapter->dev, adapter->device_mode, adapter->vdev_id, @@ -1825,40 +1812,45 @@ static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter, if (eCSR_ROAM_IBSS_LEAVE == roam_status) { uint8_t i; - sta_id = sta_ctx->broadcast_sta_id; vstatus = hdd_roam_deregister_sta(adapter, sta_ctx->conn_info.bssid); if (!QDF_IS_STATUS_SUCCESS(vstatus)) { - hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]", - sta_id, status, status); + hdd_err("hdd_roam_deregister_sta() failed for sta" + QDF_MAC_ADDR_STR " Status: %d [0x%x]", + QDF_MAC_ADDR_ARRAY( + sta_ctx->conn_info.bssid.bytes), + status, status); status = QDF_STATUS_E_FAILURE; } + /* Clear all the peer sta register with TL. */ for (i = 0; i < MAX_PEERS; i++) { - if (HDD_WLAN_INVALID_STA_ID == - sta_ctx->conn_info.sta_id[i]) + struct qdf_mac_addr mac_addr = + sta_ctx->conn_info.peer_macaddr[i]; + + if (!hdd_is_valid_mac_address(mac_addr.bytes)) continue; - sta_id = sta_ctx->conn_info.sta_id[i]; - hdd_debug("Deregister StaID %d", sta_id); - vstatus = hdd_roam_deregister_sta( - adapter, - sta_ctx->conn_info.peer_macaddr[i]); + + hdd_debug("Deregister Sta " QDF_MAC_ADDR_STR, + QDF_MAC_ADDR_ARRAY(mac_addr.bytes)); + + vstatus = hdd_roam_deregister_sta(adapter, mac_addr); + if (!QDF_IS_STATUS_SUCCESS(vstatus)) { - hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]", - sta_id, status, status); + hdd_err("hdd_roam_deregister_sta() failed sta " + QDF_MAC_ADDR_STR " Status: %d [0x%x]", + QDF_MAC_ADDR_ARRAY(mac_addr.bytes), + status, status); status = QDF_STATUS_E_FAILURE; } - /* set the sta_id and peer mac as 0, all other - * reset are done in hdd_connRemoveConnectInfo. + /* set the peer mac as 0, all other + * reset are done in hdd_conn_remove_connect_info. */ - sta_ctx->conn_info.sta_id[i] = - HDD_WLAN_INVALID_STA_ID; qdf_mem_zero(&sta_ctx->conn_info.peer_macaddr[i], sizeof(struct qdf_mac_addr)); } } else { - sta_id = sta_ctx->conn_info.sta_id[0]; hdd_debug("roam_result: %d", roam_result); /* clear scan cache for Link Lost */ @@ -2084,12 +2076,10 @@ static QDF_STATUS hdd_conn_change_peer_state(struct hdd_adapter *adapter, */ QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter, struct csr_roam_info *roam_info, - uint8_t sta_id, struct bss_description *bss_desc) { QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; struct ol_txrx_desc_type txrx_desc = {0}; - struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); struct ol_txrx_ops txrx_ops; void *soc = cds_get_context(QDF_MODULE_ID_SOC); void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); @@ -2098,7 +2088,6 @@ QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter, return QDF_STATUS_E_FAILURE; /* Get the Station ID from the one saved during the association */ - txrx_desc.sta_id = sta_id; if (!QDF_IS_ADDR_BROADCAST(roam_info->bssid.bytes)) WLAN_ADDR_COPY(txrx_desc.peer_addr.bytes, roam_info->bssid.bytes); @@ -2172,8 +2161,9 @@ QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter, hdd_conn_set_authenticated(adapter, true); hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, true); } else { - hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", - sta_ctx->conn_info.sta_id[0]); + hdd_debug("ULA auth Sta: " QDF_MAC_ADDR_STR + " Changing TL state to CONNECTED at Join time", + QDF_MAC_ADDR_ARRAY(txrx_desc.peer_addr.bytes)); qdf_status = hdd_conn_change_peer_state( adapter, roam_info, @@ -2480,9 +2470,6 @@ static void hdd_roam_ibss_indication_handler(struct hdd_adapter *adapter, case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS: case eCSR_ROAM_RESULT_IBSS_COALESCED: { - struct hdd_station_ctx *hdd_sta_ctx = - WLAN_HDD_GET_STATION_CTX_PTR(adapter); - if (!roam_info) { QDF_ASSERT(0); return; @@ -2498,11 +2485,7 @@ static void hdd_roam_ibss_indication_handler(struct hdd_adapter *adapter, hdd_wmm_connect(adapter, roam_info, eCSR_BSS_TYPE_IBSS); - hdd_sta_ctx->broadcast_sta_id = roam_info->staId; - - hdd_roam_register_sta(adapter, roam_info, - roam_info->staId, - roam_info->bss_desc); + hdd_roam_register_sta(adapter, roam_info, roam_info->bss_desc); if (roam_info->bss_desc) { struct cfg80211_bss *bss; @@ -3394,7 +3377,6 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, */ qdf_status = hdd_roam_register_sta(adapter, roam_info, - sta_ctx->conn_info.sta_id[0], roam_info->bss_desc); hdd_debug("Enabling queues"); wlan_hdd_netif_queue_control(adapter, @@ -3436,8 +3418,10 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, adapter->vdev, false); } else { - hdd_debug("sta_id: %d Changing TL state to AUTHENTICATED", - sta_ctx->conn_info.sta_id[0]); + hdd_debug("sta: " QDF_MAC_ADDR_STR + "Changing TL state to AUTHENTICATED", + QDF_MAC_ADDR_ARRAY( + roam_info->bssid.bytes)); qdf_status = hdd_change_peer_state(adapter, roam_info->bssid.bytes, @@ -3695,16 +3679,16 @@ hdd_association_completion_handler(struct hdd_adapter *adapter, * Return: true if success, false otherwise */ -bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id, +bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, struct qdf_mac_addr *peer_mac_addr) { int idx; for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) { - if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.sta_id[idx]) { - hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d", - peer_mac_addr, sta_id, idx); - sta_ctx->conn_info.sta_id[idx] = sta_id; + if (hdd_is_valid_mac_address( + sta_ctx->conn_info.peer_macaddr[idx].bytes)) { + hdd_debug("adding peer: %pM at idx: %d", + peer_mac_addr, idx); qdf_copy_macaddr( &sta_ctx->conn_info.peer_macaddr[idx], peer_mac_addr); @@ -3714,25 +3698,6 @@ bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id, return false; } -/** - * hdd_delete_peer() - removes peer from hdd station context peer table - * @sta_ctx: pointer to hdd station context - * @sta_id: station ID - * - * Return: None - */ -void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id) -{ - int i; - - for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) { - if (sta_id == sta_ctx->conn_info.sta_id[i]) { - sta_ctx->conn_info.sta_id[i] = HDD_WLAN_INVALID_STA_ID; - return; - } - } -} - /** * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter * @adapter: pointer to adapter @@ -3743,7 +3708,7 @@ void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id) * false otherwise. */ static bool roam_remove_ibss_station(struct hdd_adapter *adapter, - uint8_t sta_id) + uint8_t *mac_addr) { bool successful = false; int idx = 0; @@ -3753,12 +3718,9 @@ static bool roam_remove_ibss_station(struct hdd_adapter *adapter, struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); for (idx = 0; idx < MAX_PEERS; idx++) { - if (sta_id == sta_ctx->conn_info.sta_id[idx]) { - sta_ctx->conn_info.sta_id[idx] = - HDD_WLAN_INVALID_STA_ID; - - qdf_zero_macaddr(&sta_ctx->conn_info. - peer_macaddr[idx]); + if (WLAN_ADDR_EQ(mac_addr, + sta_ctx->conn_info.peer_macaddr[idx].bytes)) { + qdf_zero_macaddr(&sta_ctx->conn_info.peer_macaddr[idx]); successful = true; @@ -3770,13 +3732,11 @@ static bool roam_remove_ibss_station(struct hdd_adapter *adapter, empty_slots++; } else { - if (sta_ctx->conn_info.sta_id[idx] != - HDD_WLAN_INVALID_STA_ID) { + if (hdd_is_valid_mac_address( + sta_ctx->conn_info.peer_macaddr[idx].bytes)) valid_idx = idx; - } else { - /* Found an empty slot */ + else empty_slots++; - } } } @@ -3789,17 +3749,13 @@ static bool roam_remove_ibss_station(struct hdd_adapter *adapter, /* Find next active sta_id, to have a valid sta trigger for TL. */ if (successful) { if (del_idx == 0) { - if (sta_ctx->conn_info.sta_id[valid_idx] != - HDD_WLAN_INVALID_STA_ID) { - sta_ctx->conn_info.sta_id[0] = - sta_ctx->conn_info.sta_id[valid_idx]; + if (hdd_is_valid_mac_address( + sta_ctx->conn_info.peer_macaddr[idx].bytes)) { qdf_copy_macaddr(&sta_ctx->conn_info. peer_macaddr[0], &sta_ctx->conn_info. peer_macaddr[valid_idx]); - sta_ctx->conn_info.sta_id[valid_idx] = - HDD_WLAN_INVALID_STA_ID; qdf_zero_macaddr(&sta_ctx->conn_info. peer_macaddr[valid_idx]); } @@ -3953,7 +3909,6 @@ roam_roam_connect_status_update_handler(struct hdd_adapter *adapter, if (!hdd_save_peer (WLAN_HDD_GET_STATION_CTX_PTR(adapter), - roam_info->staId, &roam_info->peerMac)) { hdd_warn("Max reached: Can't register new IBSS peer"); break; @@ -3965,7 +3920,6 @@ roam_roam_connect_status_update_handler(struct hdd_adapter *adapter, /* Register the Station with datapath for the new peer. */ qdf_status = hdd_roam_register_sta(adapter, roam_info, - roam_info->staId, roam_info->bss_desc); if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { hdd_err("Cannot register STA for IBSS. qdf_status: %d [%08X]", @@ -4024,7 +3978,8 @@ roam_roam_connect_status_update_handler(struct hdd_adapter *adapter, struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); - if (!roam_remove_ibss_station(adapter, roam_info->staId)) + if (!roam_remove_ibss_station(adapter, + roam_info->peerMac.bytes)) hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL"); hdd_debug("IBSS Peer Departed from SME " diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index e75d56c34d7c..6d108b29995b 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -337,7 +337,7 @@ QDF_STATUS hdd_cfg80211_get_ibss_peer_info_all(struct hdd_adapter *adapter) * Return: 0 for success non-zero for failure */ static QDF_STATUS -hdd_cfg80211_get_ibss_peer_info(struct hdd_adapter *adapter, uint8_t sta_id) +hdd_cfg80211_get_ibss_peer_info(struct hdd_adapter *adapter, uint8_t *mac_addr) { unsigned long rc; QDF_STATUS status; @@ -347,7 +347,7 @@ hdd_cfg80211_get_ibss_peer_info(struct hdd_adapter *adapter, uint8_t sta_id) status = sme_request_ibss_peer_info(adapter->hdd_ctx->mac_handle, adapter, hdd_get_ibss_peer_info_cb, - false, sta_id); + false, mac_addr); if (QDF_STATUS_SUCCESS == status) { rc = wait_for_completion_timeout( @@ -832,7 +832,6 @@ static int drv_cmd_get_ibss_peer_info(struct hdd_adapter *adapter, struct hdd_station_ctx *sta_ctx = NULL; char extra[128] = { 0 }; uint32_t length = 0; - uint8_t sta_id = 0; struct qdf_mac_addr peer_macaddr; if (QDF_IBSS_MODE != adapter->device_mode) { @@ -862,17 +861,8 @@ static int drv_cmd_get_ibss_peer_info(struct hdd_adapter *adapter, goto exit; } - /* Get station index for the peer mac address and sanitize it */ - hdd_get_peer_sta_id(sta_ctx, &peer_macaddr, &sta_id); - - if (sta_id > MAX_PEERS) { - hdd_err("Invalid StaIdx %d returned", sta_id); - ret = -EINVAL; - goto exit; - } - /* Handle the command */ - status = hdd_cfg80211_get_ibss_peer_info(adapter, sta_id); + status = hdd_cfg80211_get_ibss_peer_info(adapter, peer_macaddr.bytes); if (QDF_STATUS_SUCCESS == status) { uint32_t tx_rate = sta_ctx->ibss_peer_info.peerInfoParams[0].txRate; diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 460c48599578..4f5fcf378a2f 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -4214,9 +4214,8 @@ hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, qdf_mem_zero(adapter, sizeof(*adapter)); sta_ctx = &adapter->session.station; - qdf_mem_set(sta_ctx->conn_info.sta_id, - sizeof(sta_ctx->conn_info.sta_id), - HDD_WLAN_INVALID_STA_ID); + qdf_mem_zero(sta_ctx->conn_info.peer_macaddr, + sizeof(sta_ctx->conn_info.peer_macaddr)); adapter->dev = dev; adapter->hdd_ctx = hdd_ctx; adapter->magic = WLAN_HDD_ADAPTER_MAGIC; @@ -4691,10 +4690,6 @@ QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); - qdf_mem_set(sta_ctx->conn_info.sta_id, - sizeof(sta_ctx->conn_info.sta_id), - HDD_WLAN_INVALID_STA_ID); - /* set fast roaming capability in sme session */ status = sme_config_fast_roaming(mac_handle, adapter->vdev_id, true); diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index 3878a6b00a1b..a1c697aa325e 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -706,7 +706,6 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id, struct bss_description tmp_bss_descp = {0}; uint16_t ndp_inactivity_timeout = 0; struct qdf_mac_addr bc_mac_addr = QDF_MAC_ADDR_BCAST_INIT; - uint8_t sta_id; hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); if (!hdd_ctx) { @@ -726,12 +725,6 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id, return; } - sta_id = ndi_rsp->sta_id; - if (sta_id >= HDD_MAX_ADAPTERS) { - hdd_err("Error: Invalid sta id %u", sta_id); - return; - } - roam_info = qdf_mem_malloc(sizeof(*roam_info)); if (!roam_info) return; @@ -757,10 +750,9 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id, ndi_rsp->reason /* create_reason */); } - sta_ctx->broadcast_sta_id = sta_id; - hdd_save_peer(sta_ctx, sta_id, &bc_mac_addr); + hdd_save_peer(sta_ctx, &bc_mac_addr); qdf_copy_macaddr(&roam_info->bssid, &bc_mac_addr); - hdd_roam_register_sta(adapter, roam_info, sta_id, &tmp_bss_descp); + hdd_roam_register_sta(adapter, roam_info, &tmp_bss_descp); qdf_mem_free(roam_info); } @@ -790,7 +782,6 @@ void hdd_ndi_drv_ndi_delete_rsp_handler(uint8_t vdev_id) struct hdd_context *hdd_ctx; struct hdd_adapter *adapter; struct hdd_station_ctx *sta_ctx; - uint8_t sta_id; hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); if (!hdd_ctx) { @@ -810,12 +801,7 @@ void hdd_ndi_drv_ndi_delete_rsp_handler(uint8_t vdev_id) return; } - sta_id = sta_ctx->broadcast_sta_id; - if (sta_id < HDD_MAX_ADAPTERS) { - hdd_roam_deregister_sta(adapter, adapter->mac_addr); - hdd_delete_peer(sta_ctx, sta_id); - sta_ctx->broadcast_sta_id = HDD_WLAN_INVALID_STA_ID; - } + hdd_roam_deregister_sta(adapter, adapter->mac_addr); wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, @@ -871,7 +857,7 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id, } /* save peer in ndp ctx */ - if (false == hdd_save_peer(sta_ctx, sta_id, peer_mac_addr)) { + if (!hdd_save_peer(sta_ctx, peer_mac_addr)) { hdd_err("Ndp peer table full. cannot save new peer"); return -EPERM; } @@ -881,7 +867,10 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id, return -ENOMEM; /* this function is called for each new peer */ - hdd_roam_register_sta(adapter, roam_info, sta_id, &tmp_bss_descp); + hdd_roam_register_sta(adapter, roam_info, &tmp_bss_descp); + + qdf_copy_macaddr(&roam_info->bssid, peer_mac_addr); + /* perform following steps for first new peer ind */ if (fist_peer) { hdd_info("Set ctx connection state to connected"); @@ -937,7 +926,6 @@ void hdd_ndp_peer_departed_handler(uint8_t vdev_id, uint16_t sta_id, } hdd_roam_deregister_sta(adapter, *peer_mac_addr); - hdd_delete_peer(sta_ctx, sta_id); if (last_peer) { hdd_info("No more ndp peers."); diff --git a/core/hdd/src/wlan_hdd_ocb.c b/core/hdd/src/wlan_hdd_ocb.c index 9b83c9e1cc9d..a1aa087c406e 100644 --- a/core/hdd/src/wlan_hdd_ocb.c +++ b/core/hdd/src/wlan_hdd_ocb.c @@ -265,12 +265,6 @@ static int hdd_ocb_register_sta(struct hdd_adapter *adapter) return -EINVAL; } - if (sta_ctx->conn_info.sta_id[0] != HDD_WLAN_INVALID_STA_ID && - sta_ctx->conn_info.sta_id[0] != peer_id) { - hdd_err("The ID for the OCB station has changed."); - } - - sta_ctx->conn_info.sta_id[0] = peer_id; qdf_copy_macaddr(&sta_ctx->conn_info.peer_macaddr[0], &adapter->mac_addr); diff --git a/core/hdd/src/wlan_hdd_tx_rx.c b/core/hdd/src/wlan_hdd_tx_rx.c index f488166938c2..5c907d7660fb 100644 --- a/core/hdd/src/wlan_hdd_tx_rx.c +++ b/core/hdd/src/wlan_hdd_tx_rx.c @@ -63,6 +63,8 @@ #include "cfg_ucfg_api.h" #include "target_type.h" #include "wlan_hdd_object_manager.h" +#include "nan_public_structs.h" +#include "nan_ucfg_api.h" #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(QCA_LL_PDEV_TX_FLOW_CONTROL) /* @@ -501,50 +503,6 @@ void wlan_hdd_classify_pkt(struct sk_buff *skb) QDF_NBUF_CB_PACKET_TYPE_ICMPv6; } -/** - * hdd_get_transmit_sta_id() - function to retrieve station id to be used for - * sending traffic towards a particular destination address. The destination - * address can be unicast, multicast or broadcast - * - * @adapter: Handle to adapter context - * @dst_addr: Destination address - * @station_id: station id - * - * Returns: None - */ -static void hdd_get_transmit_sta_id(struct hdd_adapter *adapter, - struct sk_buff *skb, uint8_t *station_id) -{ - bool mcbc_addr = false; - QDF_STATUS status; - struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); - struct qdf_mac_addr *dst_addr = NULL; - - dst_addr = (struct qdf_mac_addr *)skb->data; - status = hdd_get_peer_sta_id(sta_ctx, dst_addr, station_id); - if (QDF_IS_STATUS_ERROR(status)) { - if (QDF_NBUF_CB_GET_IS_BCAST(skb) || - QDF_NBUF_CB_GET_IS_MCAST(skb)) { - hdd_debug("Received MC/BC packet for transmission"); - mcbc_addr = true; - } - } - - if (adapter->device_mode == QDF_IBSS_MODE || - adapter->device_mode == QDF_NDI_MODE) { - /* - * This check is necessary to make sure station id is not - * overwritten for UC traffic in IBSS or NDI mode - */ - if (mcbc_addr) - *station_id = sta_ctx->broadcast_sta_id; - } else { - /* For the rest, traffic is directed to AP/P2P GO */ - if (eConnectionState_Associated == sta_ctx->conn_info.conn_state) - *station_id = sta_ctx->conn_info.sta_id[0]; - } -} - /** * hdd_clear_tx_rx_connectivity_stats() - clear connectivity stats * @hdd_ctx: pointer to HDD Station Context @@ -601,20 +559,24 @@ void hdd_reset_all_adapters_connectivity_stats(struct hdd_context *hdd_ctx) * * Return: true if Tx is allowed and false otherwise. */ -static inline bool hdd_is_tx_allowed(struct sk_buff *skb, uint8_t peer_id) +static inline bool hdd_is_tx_allowed(struct sk_buff *skb, uint8_t *peer_mac) { enum ol_txrx_peer_state peer_state; void *soc = cds_get_context(QDF_MODULE_ID_SOC); void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); void *peer; + /* Will be removed in Phase 3 cleanup */ + uint8_t peer_id; QDF_BUG(soc); QDF_BUG(pdev); - peer = cdp_peer_find_by_local_id(soc, pdev, peer_id); + peer = cdp_peer_find_by_addr(soc, pdev, peer_mac, &peer_id); if (!peer) { - hdd_err_rl("Unable to find peer entry for sta_id: %d", peer_id); + hdd_err_rl("Unable to find peer entry for sta: " + QDF_MAC_ADDR_STR, + QDF_MAC_ADDR_ARRAY(peer_mac)); return false; } @@ -893,6 +855,64 @@ void hdd_tx_rx_collect_connectivity_stats_info(struct sk_buff *skb, } } +/** + * hdd_is_xmit_allowed_on_ndi() - Verify if xmit is allowed on NDI + * @adapter: The adapter structure + * + * Return: True if xmit is allowed on NDI and false otherwise + */ +static bool hdd_is_xmit_allowed_on_ndi(struct hdd_adapter *adapter) +{ + enum nan_datapath_state state; + + state = ucfg_nan_get_ndi_state(adapter->vdev); + return (state == NAN_DATA_NDI_CREATED_STATE || + state == NAN_DATA_CONNECTED_STATE || + state == NAN_DATA_CONNECTING_STATE || + state == NAN_DATA_PEER_CREATE_STATE); +} + +/** + * hdd_get_transmit_mac_addr() - Get the mac address to validate the xmit + * @adapter: The adapter structure + * @skb: The network buffer + * @mac_addr_tx_allowed: The mac address to be filled + * + * Return: None + */ +static +void hdd_get_transmit_mac_addr(struct hdd_adapter *adapter, struct sk_buff *skb, + struct qdf_mac_addr *mac_addr_tx_allowed) +{ + struct hdd_station_ctx *sta_ctx = &adapter->session.station; + bool is_mc_bc_addr = false; + + if (QDF_NBUF_CB_GET_IS_BCAST(skb) || QDF_NBUF_CB_GET_IS_MCAST(skb)) + is_mc_bc_addr = true; + + if (adapter->device_mode == QDF_IBSS_MODE) { + if (is_mc_bc_addr) + qdf_copy_macaddr(mac_addr_tx_allowed, + &adapter->mac_addr); + else + qdf_copy_macaddr(mac_addr_tx_allowed, + (struct qdf_mac_addr *)skb->data); + } else if (adapter->device_mode == QDF_NDI_MODE && + hdd_is_xmit_allowed_on_ndi(adapter)) { + if (is_mc_bc_addr) + qdf_copy_macaddr(mac_addr_tx_allowed, + &adapter->mac_addr); + else + qdf_copy_macaddr(mac_addr_tx_allowed, + (struct qdf_mac_addr *)skb->data); + } else { + if (sta_ctx->conn_info.conn_state == + eConnectionState_Associated) + qdf_copy_macaddr(mac_addr_tx_allowed, + &sta_ctx->conn_info.bssid); + } +} + /** * __hdd_hard_start_xmit() - Transmit a frame * @skb: pointer to OS packet (sk_buff) @@ -914,9 +934,9 @@ static void __hdd_hard_start_xmit(struct sk_buff *skb, enum sme_qos_wmmuptype up; struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); bool granted; - uint8_t STAId; struct hdd_station_ctx *sta_ctx = &adapter->session.station; struct qdf_mac_addr *mac_addr; + struct qdf_mac_addr mac_addr_tx_allowed = QDF_MAC_ADDR_ZERO_INIT; uint8_t pkt_type = 0; bool is_arp = false; struct wlan_objmgr_vdev *vdev; @@ -963,18 +983,10 @@ static void __hdd_hard_start_xmit(struct sk_buff *skb, hdd_tx_rx_collect_connectivity_stats_info(skb, adapter, PKT_TYPE_REQ, &pkt_type); - if (cds_is_driver_recovering()) { - QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_WARN, - "Recovery in progress, dropping the packet"); - goto drop_pkt; - } - - STAId = HDD_WLAN_INVALID_STA_ID; - - hdd_get_transmit_sta_id(adapter, skb, &STAId); - if (STAId >= WLAN_MAX_STA_COUNT) { + hdd_get_transmit_mac_addr(adapter, skb, &mac_addr_tx_allowed); + if (qdf_is_macaddr_zero(&mac_addr_tx_allowed)) { QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_INFO_HIGH, - "Invalid station id, transmit operation suspended"); + "tx not allowed, transmit operation suspended"); goto drop_pkt; } @@ -1098,9 +1110,12 @@ static void __hdd_hard_start_xmit(struct sk_buff *skb, sizeof(qdf_nbuf_data(skb)), QDF_TX)); - if (!hdd_is_tx_allowed(skb, STAId)) { - QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_INFO_HIGH, - FL("Tx not allowed for sta_id: %d"), STAId); + if (!hdd_is_tx_allowed(skb, mac_addr_tx_allowed.bytes)) { + QDF_TRACE(QDF_MODULE_ID_HDD_DATA, + QDF_TRACE_LEVEL_INFO_HIGH, + FL("Tx not allowed for sta: " + QDF_MAC_ADDR_STR), QDF_MAC_ADDR_ARRAY( + mac_addr_tx_allowed.bytes)); ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac]; goto drop_pkt_and_release_skb; } @@ -1129,8 +1144,9 @@ static void __hdd_hard_start_xmit(struct sk_buff *skb, if (adapter->tx_fn(adapter->txrx_vdev, (qdf_nbuf_t)skb) != NULL) { QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_INFO_HIGH, - "%s: Failed to send packet to txrx for sta_id: %d", - __func__, STAId); + "%s: Failed to send packet to txrx for sta_id: " + QDF_MAC_ADDR_STR, + __func__, QDF_MAC_ADDR_ARRAY(mac_addr->bytes)); ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac]; goto drop_pkt_and_release_skb; } @@ -1188,23 +1204,6 @@ netdev_tx_t hdd_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev) return NETDEV_TX_OK; } -QDF_STATUS hdd_get_peer_sta_id(struct hdd_station_ctx *sta_ctx, - struct qdf_mac_addr *mac_address, - uint8_t *sta_id) -{ - uint8_t idx; - - for (idx = 0; idx < MAX_PEERS; idx++) { - if (!qdf_mem_cmp(&sta_ctx->conn_info.peer_macaddr[idx], - mac_address, QDF_MAC_ADDR_SIZE)) { - *sta_id = sta_ctx->conn_info.sta_id[idx]; - return QDF_STATUS_SUCCESS; - } - } - - return QDF_STATUS_E_FAILURE; -} - /** * __hdd_tx_timeout() - TX timeout handler * @dev: pointer to network device diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index 7745532f820b..3756cc26c82d 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -7199,28 +7199,28 @@ static int __iw_get_char_setnone(struct net_device *dev, int length = 0, buf = 0; for (idx = 0; idx < MAX_PEERS; idx++) { - if (HDD_WLAN_INVALID_STA_ID != - sta_ctx->conn_info.sta_id[idx]) { - buf = snprintf - ((extra + length), - WE_MAX_STR_LEN - length, - "\n%d ."QDF_MAC_ADDR_STR"\n", - sta_ctx->conn_info.sta_id[idx], - sta_ctx->conn_info. - peer_macaddr[idx].bytes[0], - sta_ctx->conn_info. - peer_macaddr[idx].bytes[1], - sta_ctx->conn_info. - peer_macaddr[idx].bytes[2], - sta_ctx->conn_info. - peer_macaddr[idx].bytes[3], - sta_ctx->conn_info. - peer_macaddr[idx].bytes[4], - sta_ctx->conn_info. - peer_macaddr[idx].bytes[5] - ); - length += buf; - } + if (!hdd_is_valid_mac_address( + sta_ctx->conn_info.peer_macaddr[idx].bytes)) + continue; + + buf = snprintf + ((extra + length), + WE_MAX_STR_LEN - length, + "\n" QDF_MAC_ADDR_STR "\n", + sta_ctx->conn_info. + peer_macaddr[idx].bytes[0], + sta_ctx->conn_info. + peer_macaddr[idx].bytes[1], + sta_ctx->conn_info. + peer_macaddr[idx].bytes[2], + sta_ctx->conn_info. + peer_macaddr[idx].bytes[3], + sta_ctx->conn_info. + peer_macaddr[idx].bytes[4], + sta_ctx->conn_info. + peer_macaddr[idx].bytes[5] + ); + length += buf; } wrqu->data.length = strlen(extra) + 1; break; diff --git a/core/hdd/src/wlan_hdd_wmm.c b/core/hdd/src/wlan_hdd_wmm.c index 37cdc25f641f..34f13d1b3e80 100644 --- a/core/hdd/src/wlan_hdd_wmm.c +++ b/core/hdd/src/wlan_hdd_wmm.c @@ -162,13 +162,11 @@ static void hdd_wmm_enable_tl_uapsd(struct hdd_wmm_qos_context *qos_context) &delayed_trgr_frm_int); /* everything is in place to notify TL */ status = - sme_enable_uapsd_for_ac((WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> - conn_info.sta_id[0], ac_type, - ac->tspec.ts_info.tid, - ac->tspec.ts_info.up, - service_interval, suspension_interval, - direction, psb, adapter->vdev_id, - delayed_trgr_frm_int); + sme_enable_uapsd_for_ac(ac_type, ac->tspec.ts_info.tid, + ac->tspec.ts_info.up, + service_interval, suspension_interval, + direction, psb, adapter->vdev_id, + delayed_trgr_frm_int); if (!QDF_IS_STATUS_SUCCESS(status)) { hdd_err("Failed to enable U-APSD for AC=%d", ac_type); @@ -203,10 +201,7 @@ static void hdd_wmm_disable_tl_uapsd(struct hdd_wmm_qos_context *qos_context) /* have we previously enabled UAPSD? */ if (ac->is_uapsd_info_valid == true) { - status = - sme_disable_uapsd_for_ac((WLAN_HDD_GET_STATION_CTX_PTR - (adapter))->conn_info.sta_id[0], - ac_type, adapter->vdev_id); + status = sme_disable_uapsd_for_ac(ac_type, adapter->vdev_id); if (!QDF_IS_STATUS_SUCCESS(status)) { hdd_err("Failed to disable U-APSD for AC=%d", ac_type); @@ -2063,8 +2058,6 @@ QDF_STATUS hdd_wmm_assoc(struct hdd_adapter *adapter, } status = sme_enable_uapsd_for_ac( - (WLAN_HDD_GET_STATION_CTX_PTR( - adapter))->conn_info.sta_id[0], SME_AC_VO, 7, 7, srv_value, sus_value, SME_QOS_WMM_TS_DIR_BOTH, 1, adapter->vdev_id, @@ -2088,8 +2081,6 @@ QDF_STATUS hdd_wmm_assoc(struct hdd_adapter *adapter, } status = sme_enable_uapsd_for_ac( - (WLAN_HDD_GET_STATION_CTX_PTR( - adapter))->conn_info.sta_id[0], SME_AC_VI, 5, 5, srv_value, sus_value, SME_QOS_WMM_TS_DIR_BOTH, 1, adapter->vdev_id, @@ -2113,8 +2104,6 @@ QDF_STATUS hdd_wmm_assoc(struct hdd_adapter *adapter, } status = sme_enable_uapsd_for_ac( - (WLAN_HDD_GET_STATION_CTX_PTR( - adapter))->conn_info.sta_id[0], SME_AC_BK, 2, 2, srv_value, sus_value, SME_QOS_WMM_TS_DIR_BOTH, 1, adapter->vdev_id, @@ -2138,8 +2127,6 @@ QDF_STATUS hdd_wmm_assoc(struct hdd_adapter *adapter, } status = sme_enable_uapsd_for_ac( - (WLAN_HDD_GET_STATION_CTX_PTR( - adapter))->conn_info.sta_id[0], SME_AC_BE, 3, 3, srv_value, sus_value, SME_QOS_WMM_TS_DIR_BOTH, 1, adapter->vdev_id, diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index d781e8f33cac..247f2d475f14 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -1625,7 +1625,6 @@ QDF_STATUS sme_send_flush_logs_cmd_to_fw(void); /** * sme_enable_uapsd_for_ac() - enable uapsd for access category request to WMA - * @sta_id: station id * @ac: access category * @tid: tid value * @pri: user priority @@ -1638,8 +1637,7 @@ QDF_STATUS sme_send_flush_logs_cmd_to_fw(void); * * Return: QDF status */ -QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id, - sme_ac_enum_type ac, uint8_t tid, +QDF_STATUS sme_enable_uapsd_for_ac(sme_ac_enum_type ac, uint8_t tid, uint8_t pri, uint32_t srvc_int, uint32_t sus_int, enum sme_qos_wmm_dir_type dir, @@ -1648,15 +1646,12 @@ QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id, /** * sme_disable_uapsd_for_ac() - disable uapsd access category request to WMA - * @sta_id: station id * @ac: access category * @sessionId: session id * * Return: QDF status */ -QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id, - sme_ac_enum_type ac, - uint32_t sessionId); +QDF_STATUS sme_disable_uapsd_for_ac(sme_ac_enum_type ac, uint32_t sessionId); #ifdef FEATURE_RSSI_MONITOR QDF_STATUS sme_set_rssi_monitoring(mac_handle_t mac_handle, diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 4e51894de302..ca617bdee8b1 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -11250,8 +11250,7 @@ QDF_STATUS sme_send_flush_logs_cmd_to_fw(void) return status; } -QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id, - sme_ac_enum_type ac, uint8_t tid, +QDF_STATUS sme_enable_uapsd_for_ac(sme_ac_enum_type ac, uint8_t tid, uint8_t pri, uint32_t srvc_int, uint32_t sus_int, enum sme_qos_wmm_dir_type dir, @@ -11308,9 +11307,7 @@ QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id, return QDF_STATUS_SUCCESS; } -QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id, - sme_ac_enum_type ac, - uint32_t sessionId) +QDF_STATUS sme_disable_uapsd_for_ac(sme_ac_enum_type ac, uint32_t sessionId) { void *wma_handle; enum uapsd_ac access_category;