diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index b838c9f8f902..3d69ac5f6315 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -6132,7 +6132,8 @@ int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, if (hdd_ctx->config->enable_change_channel_bandwidth && (!sme_find_session_by_bssid(hal_hdl, adapter->mac_addr.bytes))) { status = sme_create_mon_session(hal_hdl, - adapter->mac_addr.bytes); + adapter->mac_addr.bytes, + adapter->session_id); if (status != QDF_STATUS_SUCCESS) { hdd_err("Status: %d Failed to create session.", status); diff --git a/core/hdd/src/wlan_hdd_tx_rx.c b/core/hdd/src/wlan_hdd_tx_rx.c index 92c04ca6d823..d9acb7d0e7f8 100644 --- a/core/hdd/src/wlan_hdd_tx_rx.c +++ b/core/hdd/src/wlan_hdd_tx_rx.c @@ -2417,7 +2417,8 @@ int hdd_set_mon_rx_cb(struct net_device *dev) } qdf_status = sme_create_mon_session(hdd_ctx->mac_handle, - adapter->mac_addr.bytes); + adapter->mac_addr.bytes, + adapter->session_id); if (QDF_STATUS_SUCCESS != qdf_status) { hdd_err("sme_create_mon_session() failed to register. Status= %d [0x%08X]", qdf_status, qdf_status); diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index dad036609c63..5ee913d448dd 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -2332,6 +2332,7 @@ struct sir_set_he_bss_color { struct sir_create_session { uint16_t type; uint16_t msg_len; + uint8_t vdev_id; struct qdf_mac_addr bss_id; }; diff --git a/core/mac/src/pe/include/lim_session.h b/core/mac/src/pe/include/lim_session.h index e94a99ba83ff..f126993f1c5e 100644 --- a/core/mac/src/pe/include/lim_session.h +++ b/core/mac/src/pe/include/lim_session.h @@ -123,6 +123,7 @@ typedef struct sPESession /* Added to Support BT-AMP */ uint8_t available; uint16_t peSessionId; uint8_t smeSessionId; + struct wlan_objmgr_vdev *vdev; uint16_t transactionId; /* In AP role: BSSID and selfMacAddr will be the same. */ @@ -596,13 +597,13 @@ static inline void pe_free_dph_node_array_buffer(void) #endif /* WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY */ /** - * pe_create_session() - creates a new PE session given the BSSID - * - * @pMac: pointer to global adapter context - * @bssid: BSSID of the new session - * @sessionId: session ID is returned here, if session is created. - * @numSta: number of stations - * @bssType: bss type of new session to do conditional memory allocation. + * pe_create_session() - Creates a new PE session given the BSSID + * @pMac: pointer to global adapter context + * @bssid: BSSID of the new session + * @sessionId: PE session ID is returned here, if PE session is created. + * @numSta: number of stations + * @bssType: bss type of new session to do conditional memory allocation. + * @sme_session_id: sme session identifier * * This function returns the session context and the session ID if the session * corresponding to the passed BSSID is found in the PE session table. @@ -612,7 +613,8 @@ static inline void pe_free_dph_node_array_buffer(void) tpPESession pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId, - uint16_t numSta, tSirBssType bssType); + uint16_t numSta, tSirBssType bssType, + uint8_t sme_session_id); /** * pe_find_session_by_bssid() - looks up the PE session given the BSSID. diff --git a/core/mac/src/pe/lim/lim_api.c b/core/mac/src/pe/lim/lim_api.c index 8b4ceb9f0217..4b8b149e028d 100644 --- a/core/mac/src/pe/lim/lim_api.c +++ b/core/mac/src/pe/lim/lim_api.c @@ -2358,9 +2358,10 @@ QDF_STATUS pe_roam_synch_callback(tpAniSirGlobal mac_ctx, } status = QDF_STATUS_E_FAILURE; ft_session_ptr = pe_create_session(mac_ctx, bss_desc->bssId, - &session_id, mac_ctx->lim.maxStation, - eSIR_INFRASTRUCTURE_MODE); - if (ft_session_ptr == NULL) { + &session_id, mac_ctx->lim.maxStation, + eSIR_INFRASTRUCTURE_MODE, + session_ptr->smeSessionId); + if (!ft_session_ptr) { pe_err("LFR3:Cannot create PE Session"); lim_print_mac_addr(mac_ctx, bss_desc->bssId, LOGE); return status; @@ -2757,7 +2758,8 @@ void lim_mon_init_session(tpAniSirGlobal mac_ptr, psession_entry = pe_create_session(mac_ptr, msg->bss_id.bytes, &session_id, mac_ptr->lim.maxStation, - eSIR_MONITOR_MODE); + eSIR_MONITOR_MODE, + msg->vdev_id); if (psession_entry == NULL) { pe_err("Monitor mode: Session Can not be created"); lim_print_mac_addr(mac_ptr, msg->bss_id.bytes, LOGE); diff --git a/core/mac/src/pe/lim/lim_ft_preauth.c b/core/mac/src/pe/lim/lim_ft_preauth.c index 973535a3c196..7e6565e9c208 100644 --- a/core/mac/src/pe/lim/lim_ft_preauth.c +++ b/core/mac/src/pe/lim/lim_ft_preauth.c @@ -440,16 +440,16 @@ void lim_handle_ft_pre_auth_rsp(tpAniSirGlobal pMac, QDF_STATUS status, psessionEntry->ftPEContext.pFTPreAuthReq->pbssDescription; pftSessionEntry = pe_create_session(pMac, pbssDescription->bssId, - &sessionId, pMac->lim.maxStation, - psessionEntry->bssType); - if (pftSessionEntry == NULL) { + &sessionId, pMac->lim.maxStation, + psessionEntry->bssType, + psessionEntry->smeSessionId); + if (!pftSessionEntry) { pe_err("Session not created for pre-auth 11R AP"); status = QDF_STATUS_E_FAILURE; psessionEntry->ftPEContext.ftPreAuthStatus = status; goto send_rsp; } - pftSessionEntry->smeSessionId = psessionEntry->smeSessionId; sir_copy_mac_addr(pftSessionEntry->selfMacAddr, psessionEntry->selfMacAddr); sir_copy_mac_addr(pftSessionEntry->limReAssocbssId, diff --git a/core/mac/src/pe/lim/lim_process_sme_req_messages.c b/core/mac/src/pe/lim/lim_process_sme_req_messages.c index 8e106b552ce6..358b08186ed0 100644 --- a/core/mac/src/pe/lim/lim_process_sme_req_messages.c +++ b/core/mac/src/pe/lim/lim_process_sme_req_messages.c @@ -630,8 +630,9 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) session = pe_create_session(mac_ctx, sme_start_bss_req->bssid.bytes, &session_id, mac_ctx->lim.maxStation, - sme_start_bss_req->bssType); - if (session == NULL) { + sme_start_bss_req->bssType, + sme_start_bss_req->sessionId); + if (!session) { pe_warn("Session Can not be created"); ret_code = eSIR_SME_RESOURCES_UNAVAILABLE; goto free; @@ -674,9 +675,6 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) /* Store the session related params in newly created session */ session->pLimStartBssReq = sme_start_bss_req; - /* Store SME session Id in sessionTable */ - session->smeSessionId = sme_start_bss_req->sessionId; - session->transactionId = sme_start_bss_req->transactionId; qdf_mem_copy(&(session->htConfig), @@ -1321,7 +1319,8 @@ __lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) */ session = pe_create_session(mac_ctx, bss_desc->bssId, &session_id, mac_ctx->lim.maxStation, - eSIR_INFRASTRUCTURE_MODE); + eSIR_INFRASTRUCTURE_MODE, + sme_join_req->sessionId); if (session == NULL) { pe_err("Session Can not be created"); ret_code = eSIR_SME_RESOURCES_UNAVAILABLE; @@ -1345,9 +1344,6 @@ __lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) /* store the smejoin req handle in session table */ session->pLimJoinReq = sme_join_req; - /* Store SME session Id in sessionTable */ - session->smeSessionId = sme_join_req->sessionId; - /* Store SME transaction Id in session Table */ session->transactionId = sme_join_req->transactionId; diff --git a/core/mac/src/pe/lim/lim_session.c b/core/mac/src/pe/lim/lim_session.c index a2420a964128..d641c5a1bbbd 100644 --- a/core/mac/src/pe/lim/lim_session.c +++ b/core/mac/src/pe/lim/lim_session.c @@ -563,27 +563,16 @@ void lim_update_bcn_probe_filter(tpAniSirGlobal mac_ctx, filter->num_sap_sessions); } -/** - * pe_create_session() creates a new PE session given the BSSID - * @param pMac: pointer to global adapter context - * @param bssid: BSSID of the new session - * @param sessionId: session ID is returned here, if session is created. - * @param bssType: station or a - * - * This function returns the session context and the session ID if the session - * corresponding to the passed BSSID is found in the PE session table. - * - * Return: tpPESession: pointer to the session context or NULL if session - * can not be created. - */ - -tpPESession -pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId, - uint16_t numSta, tSirBssType bssType) +tpPESession pe_create_session(tpAniSirGlobal pMac, + uint8_t *bssid, + uint8_t *sessionId, + uint16_t numSta, tSirBssType bssType, + uint8_t sme_session_id) { QDF_STATUS status; uint8_t i; tpPESession session_ptr; + struct wlan_objmgr_vdev *vdev; for (i = 0; i < pMac->lim.maxBssId; i++) { /* Find first free room in session table */ @@ -614,16 +603,11 @@ pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId, session_ptr->gpLimPeerIdxpool = qdf_mem_malloc( sizeof(*(session_ptr->gpLimPeerIdxpool)) * lim_get_peer_idxpool_size(numSta, bssType)); - if (NULL == session_ptr->gpLimPeerIdxpool) { + if (!session_ptr->gpLimPeerIdxpool) { pe_err("memory allocate failed!"); - qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable); - qdf_mem_zero(session_ptr->dph.dphHashTable.pDphNodeArray, - sizeof(struct sDphHashNode) * - (SIR_SAP_MAX_NUM_PEERS + 1)); - session_ptr->dph.dphHashTable.pHashTable = NULL; - session_ptr->dph.dphHashTable.pDphNodeArray = NULL; - return NULL; + goto free_dp_hash_table; } + session_ptr->freePeerIdxHead = 0; session_ptr->freePeerIdxTail = 0; session_ptr->gLimNumOfCurrentSTAs = 0; @@ -677,25 +661,24 @@ pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId, || (NULL == session_ptr->pSchBeaconFrameBegin) || (NULL == session_ptr->pSchBeaconFrameEnd)) { pe_err("memory allocate failed!"); - qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable); - qdf_mem_zero( - session_ptr->dph.dphHashTable.pDphNodeArray, - sizeof(struct sDphHashNode) * - (SIR_SAP_MAX_NUM_PEERS + 1)); - qdf_mem_free(session_ptr->gpLimPeerIdxpool); - qdf_mem_free(session_ptr->pSchProbeRspTemplate); - qdf_mem_free(session_ptr->pSchBeaconFrameBegin); - qdf_mem_free(session_ptr->pSchBeaconFrameEnd); - - session_ptr->dph.dphHashTable.pHashTable = NULL; - session_ptr->dph.dphHashTable.pDphNodeArray = NULL; - session_ptr->gpLimPeerIdxpool = NULL; - session_ptr->pSchProbeRspTemplate = NULL; - session_ptr->pSchBeaconFrameBegin = NULL; - session_ptr->pSchBeaconFrameEnd = NULL; - return NULL; + goto free_session_attrs; } } + + /* + * Get vdev object from soc which automatically increments + * reference count. + */ + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(pMac->psoc, + sme_session_id, + WLAN_LEGACY_MAC_ID); + if (!vdev) { + pe_err("vdev is NULL for vdev_id: %u", sme_session_id); + goto free_session_attrs; + } + session_ptr->vdev = vdev; + session_ptr->smeSessionId = sme_session_id; + if (eSIR_INFRASTRUCTURE_MODE == bssType) lim_ft_open(pMac, &pMac->lim.gpSession[i]); @@ -733,6 +716,27 @@ pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId, session_ptr->prev_auth_seq_num = 0xFFFF; return &pMac->lim.gpSession[i]; + +free_session_attrs: + qdf_mem_free(session_ptr->gpLimPeerIdxpool); + qdf_mem_free(session_ptr->pSchProbeRspTemplate); + qdf_mem_free(session_ptr->pSchBeaconFrameBegin); + qdf_mem_free(session_ptr->pSchBeaconFrameEnd); + + session_ptr->gpLimPeerIdxpool = NULL; + session_ptr->pSchProbeRspTemplate = NULL; + session_ptr->pSchBeaconFrameBegin = NULL; + session_ptr->pSchBeaconFrameEnd = NULL; + +free_dp_hash_table: + qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable); + qdf_mem_zero(session_ptr->dph.dphHashTable.pDphNodeArray, + sizeof(struct sDphHashNode) * (SIR_SAP_MAX_NUM_PEERS + 1)); + + session_ptr->dph.dphHashTable.pHashTable = NULL; + session_ptr->dph.dphHashTable.pDphNodeArray = NULL; + + return NULL; } /*-------------------------------------------------------------------------- @@ -873,6 +877,7 @@ void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session) uint16_t i = 0; uint16_t n; TX_TIMER *timer_ptr; + struct wlan_objmgr_vdev *vdev; if (!session || (session && !session->valid)) { pe_err("session is not valid"); @@ -1039,7 +1044,10 @@ void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session) if (LIM_IS_AP_ROLE(session)) lim_check_and_reset_protection_params(mac_ctx); - return; + vdev = session->vdev; + session->vdev = NULL; + if (vdev) + wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID); } /*-------------------------------------------------------------------------- diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 5a6e3bf70b1b..dd0f30ebdb3d 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -1558,7 +1558,8 @@ sme_apf_read_work_memory(tHalHandle hal, #endif /* FEATURE_WLAN_APF */ uint32_t sme_get_wni_dot11_mode(tHalHandle hal); -QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, uint8_t *bssid); +QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, uint8_t *bssid, + uint8_t vdev_id); QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal, struct adaptive_dwelltime_params *dwelltime_params); diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 94ce661c55ac..1ba5af25e0b1 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -14111,10 +14111,12 @@ uint32_t sme_get_wni_dot11_mode(tHalHandle hal) * operation * @hal_handle: Handle to the HAL * @bssid: pointer to bssid + * @vdev_id: sme session id * * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure. */ -QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id) +QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id, + uint8_t vdev_id) { QDF_STATUS status = QDF_STATUS_E_FAILURE; struct sir_create_session *msg; @@ -14122,6 +14124,7 @@ QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id) msg = qdf_mem_malloc(sizeof(*msg)); if (NULL != msg) { msg->type = eWNI_SME_MON_INIT_SESSION; + msg->vdev_id = vdev_id; msg->msg_len = sizeof(*msg); qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE); status = umac_send_mb_message_to_mac(msg);