From 2f5727960b1b084ac3f093fb23a5de4a29703f66 Mon Sep 17 00:00:00 2001 From: Chaithanya Garrepalli Date: Wed, 11 Apr 2018 17:49:28 +0530 Subject: [PATCH] qcacmn: Initialize dp peer map memory after WMI service ready Initialize the peer map and peer hash memory based on the config received from target in service ready event Change-Id: I8e1b62cd9586f5b2be7acb863a106d2486be1b35 CRs-Fixed: 2223428 --- dp/inc/cdp_txrx_cmn.h | 8 ++++++++ dp/inc/cdp_txrx_ops.h | 3 +++ dp/wifi3.0/dp_main.c | 20 +++++++++++++++---- dp/wifi3.0/dp_peer.c | 9 ++++----- dp/wifi3.0/dp_types.h | 2 +- .../init_deinit/src/init_event_handler.c | 12 +++++++++++ 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/dp/inc/cdp_txrx_cmn.h b/dp/inc/cdp_txrx_cmn.h index 00b20c82d2f2..d82ec741e6b5 100644 --- a/dp/inc/cdp_txrx_cmn.h +++ b/dp/inc/cdp_txrx_cmn.h @@ -1558,4 +1558,12 @@ void cdp_if_mgmt_drain(ol_txrx_soc_handle soc, if (soc->ops->cmn_drv_ops->txrx_if_mgmt_drain) soc->ops->cmn_drv_ops->txrx_if_mgmt_drain(ni, force); } + +static inline void +cdp_peer_map_attach(ol_txrx_soc_handle soc, uint32_t max_peers) +{ + if (soc && soc->ops && soc->ops->cmn_drv_ops && + soc->ops->cmn_drv_ops->txrx_peer_map_attach) + soc->ops->cmn_drv_ops->txrx_peer_map_attach(soc, max_peers); +} #endif /* _CDP_TXRX_CMN_H_ */ diff --git a/dp/inc/cdp_txrx_ops.h b/dp/inc/cdp_txrx_ops.h index e12617159534..c1311f42598b 100644 --- a/dp/inc/cdp_txrx_ops.h +++ b/dp/inc/cdp_txrx_ops.h @@ -303,6 +303,9 @@ struct cdp_cmn_ops { void (*txrx_peer_flush_ast_table)(ol_txrx_soc_handle soc); + QDF_STATUS (*txrx_peer_map_attach)(ol_txrx_soc_handle soc, + uint32_t num_peers); + ol_txrx_tx_fp tx_send; }; diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index 4bb907e0c14e..ee31b16d78f6 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -2060,9 +2060,6 @@ static int dp_soc_cmn_setup(struct dp_soc *soc) if (qdf_atomic_read(&soc->cmn_init_done)) return 0; - if (dp_peer_find_attach(soc)) - goto fail0; - if (dp_hw_link_desc_pool_setup(soc)) goto fail1; @@ -2269,7 +2266,6 @@ fail1: * Cleanup will be done as part of soc_detach, which will * be called on pdev attach failure */ -fail0: return QDF_STATUS_E_FAILURE; } @@ -6832,6 +6828,21 @@ static QDF_STATUS dp_config_for_nac_rssi(struct cdp_vdev *vdev_handle, } #endif +static QDF_STATUS dp_peer_map_attach_wifi3(struct cdp_soc_t *soc_hdl, + uint32_t max_peers) +{ + struct dp_soc *soc = (struct dp_soc *)soc_hdl; + + soc->max_peers = max_peers; + + qdf_print ("%s max_peers %u\n", __func__, max_peers); + + if (dp_peer_find_attach(soc)) + return QDF_STATUS_E_FAILURE; + + return QDF_STATUS_SUCCESS; +} + static struct cdp_cmn_ops dp_ops_cmn = { .txrx_soc_attach_target = dp_soc_attach_target_wifi3, .txrx_vdev_attach = dp_vdev_attach_wifi3, @@ -6896,6 +6907,7 @@ static struct cdp_cmn_ops dp_ops_cmn = { .txrx_peer_reset_ast = dp_wds_reset_ast_wifi3, .txrx_peer_reset_ast_table = dp_wds_reset_ast_table_wifi3, .txrx_peer_flush_ast_table = dp_wds_flush_ast_table_wifi3, + .txrx_peer_map_attach = dp_peer_map_attach_wifi3, }; static struct cdp_ctrl_ops dp_ops_ctrl = { diff --git a/dp/wifi3.0/dp_peer.c b/dp/wifi3.0/dp_peer.c index e40a77ff61e6..f62d24c52644 100644 --- a/dp/wifi3.0/dp_peer.c +++ b/dp/wifi3.0/dp_peer.c @@ -69,9 +69,8 @@ static int dp_peer_find_map_attach(struct dp_soc *soc) { uint32_t max_peers, peer_map_size; + max_peers = soc->max_peers; /* allocate the peer ID -> peer object map */ - max_peers = wlan_cfg_max_peer_id(soc->wlan_cfg_ctx) + 1; - soc->max_peers = max_peers; QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO, "\n<=== cfg max peer id %d ====>\n", max_peers); peer_map_size = max_peers * sizeof(soc->peer_id_to_obj_map[0]); @@ -133,7 +132,7 @@ static int dp_peer_find_hash_attach(struct dp_soc *soc) int i, hash_elems, log2; /* allocate the peer MAC address -> peer object hash table */ - hash_elems = wlan_cfg_max_peer_id(soc->wlan_cfg_ctx) + 1; + hash_elems = soc->max_peers; hash_elems *= DP_PEER_HASH_LOAD_MULT; hash_elems >>= DP_PEER_HASH_LOAD_SHIFT; log2 = dp_log2_ceil(hash_elems); @@ -201,7 +200,7 @@ static int dp_peer_ast_hash_attach(struct dp_soc *soc) { int i, hash_elems, log2; - hash_elems = ((WLAN_UMAC_PSOC_MAX_PEERS * DP_AST_HASH_LOAD_MULT) >> + hash_elems = ((soc->max_peers * DP_AST_HASH_LOAD_MULT) >> DP_AST_HASH_LOAD_SHIFT); log2 = dp_log2_ceil(hash_elems); @@ -902,7 +901,7 @@ static inline struct dp_peer *dp_peer_find_add_id(struct dp_soc *soc, { struct dp_peer *peer; - QDF_ASSERT(peer_id <= wlan_cfg_max_peer_id(soc->wlan_cfg_ctx) + 1); + QDF_ASSERT(peer_id <= soc->max_peers); /* check if there's already a peer object with this MAC address */ peer = dp_peer_find_hash_find(soc, peer_mac_addr, 0 /* is aligned */, vdev_id); diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h index aa29419437e5..99adf72beec2 100644 --- a/dp/wifi3.0/dp_types.h +++ b/dp/wifi3.0/dp_types.h @@ -789,7 +789,7 @@ struct dp_soc { DP_MUTEX_TYPE peer_ref_mutex; /* maximum value for peer_id */ - int max_peers; + uint32_t max_peers; /* SoC level data path statistics */ struct dp_soc_stats stats; diff --git a/target_if/init_deinit/src/init_event_handler.c b/target_if/init_deinit/src/init_event_handler.c index 4dc66bb2eef6..1948b09c1a2a 100644 --- a/target_if/init_deinit/src/init_event_handler.c +++ b/target_if/init_deinit/src/init_event_handler.c @@ -31,6 +31,7 @@ #include #include #include +#include static int init_deinit_service_ready_event_handler(ol_scn_t scn_handle, uint8_t *event, @@ -309,6 +310,7 @@ static int init_deinit_ready_event_handler(ol_scn_t scn_handle, struct wmi_host_ready_ev_param ready_ev; wmi_legacy_service_ready_callback legacy_callback; uint8_t num_radios, i; + uint32_t max_peers; if (!scn_handle) { target_if_err("scn handle NULL"); @@ -359,6 +361,16 @@ static int init_deinit_ready_event_handler(ol_scn_t scn_handle, info->wlan_res_cfg.num_peers = ready_ev.num_total_peer; } + /* for non legacy num_total_peer will be non zero + * allocate peer memory in this case + */ + if (ready_ev.num_total_peer != 0) { + max_peers = info->wlan_res_cfg.num_peers + + ready_ev.num_extra_peer + 1; + + cdp_peer_map_attach(wlan_psoc_get_dp_handle(psoc), max_peers); + } + /* Indicate to the waiting thread that the ready * event was received */