summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArif Hussain <arifhussain@codeaurora.org>2017-02-08 14:35:00 -0800
committerqcabuildsw <qcabuildsw@localhost>2017-02-09 00:15:11 -0800
commitd2cb1670646df4c47f03cc78ad07f194bfd6b0fe (patch)
tree10ab3a54221432f6e0350adf059fe250cf09fb72
parent70f4bc317b5092055f51b66b0f8ed4b048bbc838 (diff)
qcacld-3.0: Refactor code use to search vdev using MAC address
In LIM, move functionality to find session for a given MAC address in separate function so that this code can be reused by other functions if needed. In HDD, remove logic added to find adaptor for a given MAC, instead use existing function hdd_get_adapter_by_macaddr. Change-Id: I989f09ffcbee3a717c22c267a01dafd1b404da64 CRs-Fixed: 2004223
-rw-r--r--core/hdd/src/wlan_hdd_cfg80211.c21
-rw-r--r--core/mac/src/pe/lim/lim_process_auth_frame.c18
-rw-r--r--core/mac/src/pe/lim/lim_utils.c31
-rw-r--r--core/mac/src/pe/lim/lim_utils.h12
4 files changed, 48 insertions, 34 deletions
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 78db8a9a8266..d855e505a3fc 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -13048,8 +13048,6 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy,
#else
const u8 *bssid_hint = NULL;
#endif
- hdd_adapter_list_node_t *adapter_node = NULL, *next_adapter = NULL;
- hdd_adapter_t *adapter;
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev);
hdd_context_t *pHddCtx;
@@ -13095,21 +13093,10 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy,
else if (bssid_hint)
bssid = bssid_hint;
- if (bssid) {
- status = hdd_get_front_adapter(pHddCtx, &adapter_node);
- while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) {
- adapter = adapter_node->pAdapter;
- if (!qdf_mem_cmp(adapter->macAddressCurrent.bytes,
- bssid, QDF_MAC_ADDR_SIZE)) {
- hdd_err("Vdev %d exist with same MAC address "
- MAC_ADDRESS_STR, adapter->sessionId,
- MAC_ADDR_ARRAY(bssid));
- return -EINVAL;
- }
- status = hdd_get_next_adapter(pHddCtx, adapter_node,
- &next_adapter);
- adapter_node = next_adapter;
- }
+ if (bssid && hdd_get_adapter_by_macaddr(pHddCtx, (uint8_t *)bssid)) {
+ hdd_err("adapter exist with same mac address " MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(bssid));
+ return -EINVAL;
}
if (true == wlan_hdd_reassoc_bssid_hint(pAdapter, req, &status))
diff --git a/core/mac/src/pe/lim/lim_process_auth_frame.c b/core/mac/src/pe/lim/lim_process_auth_frame.c
index 2d172ad9be25..4cb0205354f2 100644
--- a/core/mac/src/pe/lim/lim_process_auth_frame.c
+++ b/core/mac/src/pe/lim/lim_process_auth_frame.c
@@ -437,24 +437,8 @@ static void lim_process_auth_frame_type1(tpAniSirGlobal mac_ctx,
if (lim_is_auth_algo_supported(mac_ctx,
(tAniAuthType) rx_auth_frm_body->authAlgoNumber,
pe_session)) {
- int i = 0;
- tCsrRoamSession *session;
- for (i = 0; i < mac_ctx->sme.max_intf_count; i++) {
-
- if (!CSR_IS_SESSION_VALID(mac_ctx, i))
- continue;
-
- session = CSR_GET_SESSION(mac_ctx, i);
- if (!session || qdf_mem_cmp(&session->selfMacAddr,
- mac_hdr->sa, sizeof(tSirMacAddr))) {
- continue;
- }
-
- lim_log(mac_ctx, LOGE,
- FL("vdev with id %d exist with same MAC "
- MAC_ADDRESS_STR), session->sessionId,
- MAC_ADDR_ARRAY(mac_hdr->sa));
+ if (lim_get_session_by_macaddr(mac_ctx, mac_hdr->sa)) {
auth_frame->authAlgoNumber =
rx_auth_frm_body->authAlgoNumber;
diff --git a/core/mac/src/pe/lim/lim_utils.c b/core/mac/src/pe/lim/lim_utils.c
index 283d5c29b76c..c252796fc6e1 100644
--- a/core/mac/src/pe/lim/lim_utils.c
+++ b/core/mac/src/pe/lim/lim_utils.c
@@ -7308,3 +7308,34 @@ void lim_update_last_processed_frame(last_processed_msg *last_processed_frm,
qdf_mem_copy(last_processed_frm->sa, pHdr->sa, ETH_ALEN);
last_processed_frm->seq_num = seq_num;
}
+
+tCsrRoamSession *lim_get_session_by_macaddr(tpAniSirGlobal mac_ctx,
+ tSirMacAddr self_mac)
+{
+ int i = 0;
+ tCsrRoamSession *session;
+
+ if (!mac_ctx || !self_mac) {
+ QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
+ FL("Invalid arguments"));
+ return NULL;
+ }
+
+ for (i = 0; i < mac_ctx->sme.max_intf_count; i++) {
+ session = CSR_GET_SESSION(mac_ctx, i);
+ if (!session)
+ continue;
+ else if (!qdf_mem_cmp(&session->selfMacAddr,
+ self_mac, sizeof(tSirMacAddr))) {
+
+ QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
+ FL("session %d exists with mac address "
+ MAC_ADDRESS_STR), session->sessionId,
+ MAC_ADDR_ARRAY(self_mac));
+
+ return session;
+ }
+ }
+
+ return NULL;
+}
diff --git a/core/mac/src/pe/lim/lim_utils.h b/core/mac/src/pe/lim/lim_utils.h
index c6f66a209c87..275c82df88cd 100644
--- a/core/mac/src/pe/lim/lim_utils.h
+++ b/core/mac/src/pe/lim/lim_utils.h
@@ -256,6 +256,18 @@ void lim_prepare_for11h_channel_switch(tpAniSirGlobal pMac,
void lim_switch_channel_cback(tpAniSirGlobal pMac, QDF_STATUS status,
uint32_t *data, tpPESession psessionEntry);
+/**
+ * lim_get_session_by_macaddr() - api to find session based on MAC
+ * @mac_ctx: Pointer to global mac structure.
+ * @self_mac: MAC address.
+ *
+ * This function is used to get session for given MAC address.
+ *
+ * Return: session pointer if exists, NULL otherwise.
+ */
+tCsrRoamSession *lim_get_session_by_macaddr(tpAniSirGlobal mac_ctx,
+ tSirMacAddr self_mac);
+
static inline tSirRFBand lim_get_rf_band(uint8_t channel)
{
if ((channel >= SIR_11A_CHANNEL_BEGIN) &&