diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 45935579f5dc..c2085d7dfdc3 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -672,7 +672,7 @@ struct hdd_station_ctx { /* STA ctx debug variables */ int staDebugState; - uint8_t broadcast_ibss_staid; + uint8_t broadcast_staid; struct hdd_mon_set_ch_info ch_info; #ifdef WLAN_FEATURE_NAN_DATAPATH diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index 8877d04b8ced..e6e1de141e5d 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -1691,7 +1691,7 @@ static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter, if (eCSR_ROAM_IBSS_LEAVE == roamStatus) { uint8_t i; - sta_id = pHddStaCtx->broadcast_ibss_staid; + sta_id = pHddStaCtx->broadcast_staid; vstatus = hdd_roam_deregister_sta(pAdapter, sta_id); if (!QDF_IS_STATUS_SUCCESS(vstatus)) { hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]", @@ -3014,7 +3014,7 @@ static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter, hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS); - hdd_sta_ctx->broadcast_ibss_staid = pRoamInfo->staId; + hdd_sta_ctx->broadcast_staid = pRoamInfo->staId; pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter; diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index 9e639de41079..7df7521700d7 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -369,6 +369,7 @@ static int hdd_ndi_delete_req_handler(hdd_context_t *hdd_ctx, uint16_t transaction_id; struct nan_datapath_ctx *ndp_ctx; int ret; + hdd_station_ctx_t *sta_ctx; ENTER(); @@ -406,6 +407,12 @@ static int hdd_ndi_delete_req_handler(hdd_context_t *hdd_ctx, return -EINVAL; } + sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); + if (!sta_ctx) { + hdd_err("sta_ctx is NULL"); + return -EINVAL; + } + /* check if there are active peers on the adapter */ if (ndp_ctx->active_ndp_peers > 0) { hdd_err("NDP peers active: %d, cannot delete NDI", @@ -413,6 +420,13 @@ static int hdd_ndi_delete_req_handler(hdd_context_t *hdd_ctx, return -EINVAL; } + /* + * Since, the interface is being deleted, remove the + * broadcast id. + */ + hdd_ctx->sta_to_adapter[sta_ctx->broadcast_staid] = 0; + sta_ctx->broadcast_staid = HDD_WLAN_INVALID_STA_ID; + ndp_ctx->ndp_delete_transaction_id = transaction_id; ndp_ctx->state = NAN_DATA_NDI_DELETING_STATE; @@ -734,6 +748,10 @@ static void hdd_ndp_iface_create_rsp_handler(hdd_adapter_t *adapter, uint8_t create_transaction_id = 0; uint32_t create_status = NDP_RSP_STATUS_ERROR; uint32_t create_reason = NDP_NAN_DATA_IFACE_CREATE_FAILED; + hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); + struct qdf_mac_addr bc_mac_addr = QDF_MAC_ADDR_BROADCAST_INITIALIZER; + tCsrRoamInfo roam_info = {0}; + tSirBssDescription tmp_bss_descp = {0}; ENTER(); @@ -756,6 +774,11 @@ static void hdd_ndp_iface_create_rsp_handler(hdd_adapter_t *adapter, create_fail = true; } + if (!sta_ctx) { + hdd_err("sta_ctx is NULL"); + create_fail = true; + } + /* notify response to the upper layer */ vendor_event = cfg80211_vendor_event_alloc(hdd_ctx->wiphy, NULL, @@ -826,6 +849,14 @@ static void hdd_ndp_iface_create_rsp_handler(hdd_adapter_t *adapter, if (create_fail) goto close_ndi; + sta_ctx->broadcast_staid = ndi_rsp->sta_id; + hdd_save_peer(sta_ctx, sta_ctx->broadcast_staid, &bc_mac_addr); + hdd_roam_register_sta(adapter, &roam_info, + sta_ctx->broadcast_staid, + &bc_mac_addr, &tmp_bss_descp); + hdd_ctx->sta_to_adapter[sta_ctx->broadcast_staid] = adapter; + + EXIT(); return; @@ -1074,7 +1105,6 @@ static void hdd_ndp_new_peer_ind_handler(hdd_adapter_t *adapter, tCsrRoamInfo roam_info = {0}; struct nan_datapath_ctx *ndp_ctx = WLAN_HDD_GET_NDP_CTX_PTR(adapter); hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); - struct qdf_mac_addr bc_mac_addr = QDF_MAC_ADDR_BROADCAST_INITIALIZER; ENTER(); @@ -1103,10 +1133,6 @@ static void hdd_ndp_new_peer_ind_handler(hdd_adapter_t *adapter, hdd_ctx->sta_to_adapter[new_peer_ind->sta_id] = adapter; /* perform following steps for first new peer ind */ if (ndp_ctx->active_ndp_peers == 1) { - hdd_ctx->sta_to_adapter[NDP_BROADCAST_STAID] = adapter; - hdd_save_peer(sta_ctx, NDP_BROADCAST_STAID, &bc_mac_addr); - hdd_roam_register_sta(adapter, &roam_info, NDP_BROADCAST_STAID, - &bc_mac_addr, &tmp_bss_descp); hdd_info("Set ctx connection state to connected"); sta_ctx->conn_info.connState = eConnectionState_NdiConnected; hdd_wmm_connect(adapter, &roam_info, eCSR_BSS_TYPE_NDI); diff --git a/core/hdd/src/wlan_hdd_tx_rx.c b/core/hdd/src/wlan_hdd_tx_rx.c index ac1257633d35..2262395905cb 100644 --- a/core/hdd/src/wlan_hdd_tx_rx.c +++ b/core/hdd/src/wlan_hdd_tx_rx.c @@ -370,20 +370,14 @@ static void hdd_get_transmit_sta_id(hdd_adapter_t *adapter, } } - if (adapter->device_mode == QDF_IBSS_MODE) { + 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 mode + * overwritten for UC traffic in IBSS or NDI mode */ if (mcbc_addr) - *station_id = sta_ctx->broadcast_ibss_staid; - } else if (adapter->device_mode == QDF_NDI_MODE) { - /* - * This check is necessary to make sure station id is not - * overwritten for UC traffic in NAN data mode - */ - if (mcbc_addr) - *station_id = NDP_BROADCAST_STAID; + *station_id = sta_ctx->broadcast_staid; } else { /* For the rest, traffic is directed to AP/P2P GO */ if (eConnectionState_Associated == sta_ctx->conn_info.connState) diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index fda605742933..3f281c74aa03 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -6120,6 +6120,7 @@ struct ndi_create_req { struct ndi_create_rsp { uint32_t status; uint32_t reason; + uint8_t sta_id; }; /** diff --git a/core/mac/src/pe/nan/nan_datapath.c b/core/mac/src/pe/nan/nan_datapath.c index 706f22ed76f9..1bfe381aafef 100644 --- a/core/mac/src/pe/nan/nan_datapath.c +++ b/core/mac/src/pe/nan/nan_datapath.c @@ -737,6 +737,7 @@ void lim_process_ndi_mlm_add_bss_rsp(tpAniSirGlobal mac_ctx, tpSirMsgQ lim_msgq, session_entry->bssIdx = (uint8_t) add_bss_params->bssIdx; session_entry->limSystemRole = eLIM_NDI_ROLE; session_entry->statypeForBss = STA_ENTRY_SELF; + session_entry->staId = add_bss_params->staContext.staIdx; /* Apply previously set configuration at HW */ lim_apply_configuration(mac_ctx, session_entry); mlm_start_cnf.resultCode = eSIR_SME_SUCCESS; diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index a40e7bf8ac03..48429162003f 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -6437,6 +6437,7 @@ static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx, roam_status = eCSR_ROAM_INFRA_IND; roam_result = eCSR_ROAM_RESULT_INFRA_STARTED; } + roam_info.staId = (uint8_t) start_bss_rsp->staId; if (CSR_IS_NDI(profile)) { csr_roam_update_ndp_return_params(mac_ctx, eCsrStartBssSuccess, @@ -6454,7 +6455,6 @@ static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx, roam_info.reasonCode = session->joinFailStatusCode.reasonCode; /* We start the IBSS (didn't find any matched IBSS out there) */ roam_info.pBssDesc = bss_desc; - roam_info.staId = (uint8_t) start_bss_rsp->staId; if (bss_desc) qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId, sizeof(struct qdf_mac_addr)); diff --git a/core/sme/src/nan/nan_datapath_api.c b/core/sme/src/nan/nan_datapath_api.c index 87c1b8a3e473..bae1285b4be3 100644 --- a/core/sme/src/nan/nan_datapath_api.c +++ b/core/sme/src/nan/nan_datapath_api.c @@ -360,6 +360,7 @@ void csr_roam_update_ndp_return_params(tpAniSirGlobal mac_ctx, roam_info->ndp.ndi_create_params.reason = 0; roam_info->ndp.ndi_create_params.status = NDP_RSP_STATUS_SUCCESS; + roam_info->ndp.ndi_create_params.sta_id = roam_info->staId; *roam_status = eCSR_ROAM_NDP_STATUS_UPDATE; *roam_result = eCSR_ROAM_RESULT_NDI_CREATE_RSP; break;