staging: r8188eu: restructure mlme subfunction handling
authorMartin Kaiser <martin@kaiser.cx>
Mon, 24 Oct 2022 08:14:01 +0000 (10:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Oct 2022 17:19:37 +0000 (19:19 +0200)
Move some code around in rtw_mlme_ext.c to make it simpler.

mlme_sta_tbl is used only by mgt_dispatcher. Move the table inside the
function. Move mgt_dispatcher behind the handler functions. We can then
make the handler functions static.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Link: https://lore.kernel.org/r/20221024081417.66441-2-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_mlme_ext.c

index d146b94307b80f4143eaa0146e0baba85c9890f3..3435610ca4116677c30e3ec9355201c621e3ac8a 100644 (file)
 #include "../include/rtl8188e_xmit.h"
 #include "../include/rtl8188e_dm.h"
 
-/* response function for each management frame subtype, do not reorder */
-static mlme_handler mlme_sta_tbl[] = {
-       OnAssocReq,
-       OnAssocRsp,
-       OnAssocReq,
-       OnAssocRsp,
-       OnProbeReq,
-       OnProbeRsp,
-       NULL,
-       NULL,
-       OnBeacon,
-       NULL,
-       OnDisassoc,
-       OnAuthClient,
-       OnDeAuth,
-       OnAction,
-};
-
 static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
 
 /**************************************************
@@ -393,47 +375,6 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext)
        }
 }
 
-void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
-{
-       int index;
-       mlme_handler fct;
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
-       struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
-
-       if (!ieee80211_is_mgmt(hdr->frame_control))
-               return;
-
-       /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
-       if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
-           !is_broadcast_ether_addr(hdr->addr1))
-               return;
-
-       index = (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
-       if (index >= ARRAY_SIZE(mlme_sta_tbl))
-               return;
-       fct = mlme_sta_tbl[index];
-
-       if (psta) {
-               if (ieee80211_has_retry(hdr->frame_control)) {
-                       if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
-                               /* drop the duplicate management frame */
-                               return;
-               }
-               psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
-       }
-
-       if (ieee80211_is_auth(hdr->frame_control)) {
-               if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
-                       fct = OnAuth;
-               else
-                       fct = OnAuthClient;
-       }
-
-       if (fct)
-               fct(padapter, precv_frame);
-}
-
 static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da)
 {
        bool response = true;
@@ -4008,6 +3949,63 @@ struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv)
        return pmgntframe;
 }
 
+void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
+{
+       mlme_handler mlme_sta_tbl[] = {
+               OnAssocReq,
+               OnAssocRsp,
+               OnAssocReq,
+               OnAssocRsp,
+               OnProbeReq,
+               OnProbeRsp,
+               NULL,
+               NULL,
+               OnBeacon,
+               NULL,
+               OnDisassoc,
+               OnAuthClient,
+               OnDeAuth,
+               OnAction,
+       };
+       int index;
+       mlme_handler fct;
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)precv_frame->rx_data;
+       struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, hdr->addr2);
+
+       if (!ieee80211_is_mgmt(hdr->frame_control))
+               return;
+
+       /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
+       if (memcmp(hdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN) &&
+           !is_broadcast_ether_addr(hdr->addr1))
+               return;
+
+       index = (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
+       if (index >= ARRAY_SIZE(mlme_sta_tbl))
+               return;
+       fct = mlme_sta_tbl[index];
+
+       if (psta) {
+               if (ieee80211_has_retry(hdr->frame_control)) {
+                       if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum)
+                               /* drop the duplicate management frame */
+                               return;
+               }
+               psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
+       }
+
+       if (ieee80211_is_auth(hdr->frame_control)) {
+               if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
+                       fct = OnAuth;
+               else
+                       fct = OnAuthClient;
+       }
+
+       if (fct)
+               fct(padapter, precv_frame);
+}
+
 /****************************************************************************
 
 Following are some TX functions for WiFi MLME