mwifiex: rx path enhancement to derive priv only once
authorAvinash Patil <patila@marvell.com>
Sat, 20 Oct 2012 02:19:21 +0000 (19:19 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 29 Oct 2012 19:20:34 +0000 (15:20 -0400)
We derive mwifiex_private structure which is per interface from
received skb's rx_info. Once priv is derived, same priv can be
propagated to other functions instead of callee deriving priv
from rx_info again.

Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/11n_rxreorder.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/sta_rx.c
drivers/net/wireless/mwifiex/txrx.c
drivers/net/wireless/mwifiex/uap_txrx.c
drivers/net/wireless/mwifiex/util.c

index 9402b93b9a363b350545fb24aad6f67f06afc172..4a97acd170f7bfcb423db64307a113c4c55f6852 100644 (file)
@@ -58,8 +58,7 @@ mwifiex_11n_dispatch_pkt(struct mwifiex_private *priv,
                        if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP)
                                mwifiex_handle_uap_rx_forward(priv, rx_tmp_ptr);
                        else
-                               mwifiex_process_rx_packet(priv->adapter,
-                                                         rx_tmp_ptr);
+                               mwifiex_process_rx_packet(priv, rx_tmp_ptr);
                }
        }
 
@@ -106,7 +105,7 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv,
                if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP)
                        mwifiex_handle_uap_rx_forward(priv, rx_tmp_ptr);
                else
-                       mwifiex_process_rx_packet(priv->adapter, rx_tmp_ptr);
+                       mwifiex_process_rx_packet(priv, rx_tmp_ptr);
        }
 
        spin_lock_irqsave(&priv->rx_pkt_lock, flags);
@@ -442,8 +441,7 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
                        if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP)
                                mwifiex_handle_uap_rx_forward(priv, payload);
                        else
-                               mwifiex_process_rx_packet(priv->adapter,
-                                                         payload);
+                               mwifiex_process_rx_packet(priv, payload);
                }
                return 0;
        }
index 4ed46b694ced209d7535bf65f3886fa05b47325b..81f8772dcb07c00eff281ef0632f1025fe0009bb 100644 (file)
@@ -747,9 +747,9 @@ int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
 
 int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
 
-int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
+int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
 
-int mwifiex_process_mgmt_packet(struct mwifiex_adapter *adapter,
+int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
                                struct sk_buff *skb);
 
 int mwifiex_process_event(struct mwifiex_adapter *adapter);
@@ -806,7 +806,7 @@ void mwifiex_hs_activated_event(struct mwifiex_private *priv,
                                        u8 activated);
 int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
                              struct host_cmd_ds_command *resp);
-int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
+int mwifiex_process_rx_packet(struct mwifiex_private *priv,
                              struct sk_buff *skb);
 int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
                            u16 cmd_action, u32 cmd_oid,
@@ -816,9 +816,9 @@ int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
                            void *data_buf, void *cmd_buf);
 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
                                struct host_cmd_ds_command *resp);
-int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *,
+int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
                                  struct sk_buff *skb);
-int mwifiex_process_uap_rx_packet(struct mwifiex_adapter *adapter,
+int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
                                  struct sk_buff *skb);
 int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
                                  struct sk_buff *skb);
index 07d32b73783ea2cdd0859d80849eed1eb4a94804..b5c109504393d22a3bc5eae4a5510f47f4353b56 100644 (file)
  *
  * The completion callback is called after processing in complete.
  */
-int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
+int mwifiex_process_rx_packet(struct mwifiex_private *priv,
                              struct sk_buff *skb)
 {
        int ret;
-       struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);
-       struct mwifiex_private *priv =
-                       mwifiex_get_priv_by_id(adapter, rx_info->bss_num,
-                                              rx_info->bss_type);
        struct rx_packet_hdr *rx_pkt_hdr;
        struct rxpd *local_rx_pd;
        int hdr_chop;
@@ -98,9 +94,9 @@ int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
 
        priv->rxpd_htinfo = local_rx_pd->ht_info;
 
-       ret = mwifiex_recv_packet(adapter, skb);
+       ret = mwifiex_recv_packet(priv, skb);
        if (ret == -1)
-               dev_err(adapter->dev, "recv packet failed\n");
+               dev_err(priv->adapter->dev, "recv packet failed\n");
 
        return ret;
 }
@@ -117,21 +113,15 @@ int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
  *
  * The completion callback is called after processing in complete.
  */
-int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter,
+int mwifiex_process_sta_rx_packet(struct mwifiex_private *priv,
                                  struct sk_buff *skb)
 {
+       struct mwifiex_adapter *adapter = priv->adapter;
        int ret = 0;
        struct rxpd *local_rx_pd;
-       struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);
        struct rx_packet_hdr *rx_pkt_hdr;
        u8 ta[ETH_ALEN];
        u16 rx_pkt_type, rx_pkt_offset, rx_pkt_length, seq_num;
-       struct mwifiex_private *priv =
-                       mwifiex_get_priv_by_id(adapter, rx_info->bss_num,
-                                              rx_info->bss_type);
-
-       if (!priv)
-               return -1;
 
        local_rx_pd = (struct rxpd *) (skb->data);
        rx_pkt_type = le16_to_cpu(local_rx_pd->rx_pkt_type);
@@ -169,13 +159,13 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter,
 
                while (!skb_queue_empty(&list)) {
                        rx_skb = __skb_dequeue(&list);
-                       ret = mwifiex_recv_packet(adapter, rx_skb);
+                       ret = mwifiex_recv_packet(priv, rx_skb);
                        if (ret == -1)
                                dev_err(adapter->dev, "Rx of A-MSDU failed");
                }
                return 0;
        } else if (rx_pkt_type == PKT_TYPE_MGMT) {
-               ret = mwifiex_process_mgmt_packet(adapter, skb);
+               ret = mwifiex_process_mgmt_packet(priv, skb);
                if (ret)
                        dev_err(adapter->dev, "Rx of mgmt packet failed");
                dev_kfree_skb_any(skb);
@@ -188,7 +178,7 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter,
         */
        if (!IS_11N_ENABLED(priv) ||
            memcmp(priv->curr_addr, rx_pkt_hdr->eth803_hdr.h_dest, ETH_ALEN)) {
-               mwifiex_process_rx_packet(adapter, skb);
+               mwifiex_process_rx_packet(priv, skb);
                return ret;
        }
 
index 2af263992e83a23ff30bb6558f85204105bb4180..5cb3f7af87491a1cd7bd39d600f336dbd09b74d6 100644 (file)
@@ -48,13 +48,19 @@ int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
        if (!priv)
                priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
 
+       if (!priv) {
+               dev_err(adapter->dev, "data: priv not found. Drop RX packet\n");
+               dev_kfree_skb_any(skb);
+               return -1;
+       }
+
        rx_info->bss_num = priv->bss_num;
        rx_info->bss_type = priv->bss_type;
 
        if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP)
-               return mwifiex_process_uap_rx_packet(adapter, skb);
+               return mwifiex_process_uap_rx_packet(priv, skb);
 
-       return mwifiex_process_sta_rx_packet(adapter, skb);
+       return mwifiex_process_sta_rx_packet(priv, skb);
 }
 EXPORT_SYMBOL_GPL(mwifiex_handle_rx_packet);
 
index 0966ac24b3b422a83b31792c006752776f271344..a018e42d117eb49b9b89716e70910f299de2ef68 100644 (file)
@@ -146,7 +146,7 @@ int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
        }
 
        /* Forward unicat/Inter-BSS packets to kernel. */
-       return mwifiex_process_rx_packet(adapter, skb);
+       return mwifiex_process_rx_packet(priv, skb);
 }
 
 /*
@@ -159,24 +159,17 @@ int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
  *
  * The completion callback is called after processing is complete.
  */
-int mwifiex_process_uap_rx_packet(struct mwifiex_adapter *adapter,
+int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
                                  struct sk_buff *skb)
 {
+       struct mwifiex_adapter *adapter = priv->adapter;
        int ret;
        struct uap_rxpd *uap_rx_pd;
-       struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);
        struct rx_packet_hdr *rx_pkt_hdr;
        u16 rx_pkt_type;
        u8 ta[ETH_ALEN], pkt_type;
        struct mwifiex_sta_node *node;
 
-       struct mwifiex_private *priv =
-                       mwifiex_get_priv_by_id(adapter, rx_info->bss_num,
-                                              rx_info->bss_type);
-
-       if (!priv)
-               return -1;
-
        uap_rx_pd = (struct uap_rxpd *)(skb->data);
        rx_pkt_type = le16_to_cpu(uap_rx_pd->rx_pkt_type);
        rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset);
@@ -210,7 +203,7 @@ int mwifiex_process_uap_rx_packet(struct mwifiex_adapter *adapter,
 
                while (!skb_queue_empty(&list)) {
                        rx_skb = __skb_dequeue(&list);
-                       ret = mwifiex_recv_packet(adapter, rx_skb);
+                       ret = mwifiex_recv_packet(priv, rx_skb);
                        if (ret)
                                dev_err(adapter->dev,
                                        "AP:Rx A-MSDU failed");
@@ -218,7 +211,7 @@ int mwifiex_process_uap_rx_packet(struct mwifiex_adapter *adapter,
 
                return 0;
        } else if (rx_pkt_type == PKT_TYPE_MGMT) {
-               ret = mwifiex_process_mgmt_packet(adapter, skb);
+               ret = mwifiex_process_mgmt_packet(priv, skb);
                if (ret)
                        dev_err(adapter->dev, "Rx of mgmt packet failed");
                dev_kfree_skb_any(skb);
index ae88f80cf86b966238dff0544fa97ff7ca83e168..0982375ba3b14c6fbedee1cc6b74a0d2b6eaa9f9 100644 (file)
@@ -146,20 +146,16 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv,
  * to the kernel.
  */
 int
-mwifiex_process_mgmt_packet(struct mwifiex_adapter *adapter,
+mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
                            struct sk_buff *skb)
 {
        struct rxpd *rx_pd;
-       struct mwifiex_private *priv;
        u16 pkt_len;
 
        if (!skb)
                return -1;
 
        rx_pd = (struct rxpd *)skb->data;
-       priv = mwifiex_get_priv_by_id(adapter, rx_pd->bss_num, rx_pd->bss_type);
-       if (!priv)
-               return -1;
 
        skb_pull(skb, le16_to_cpu(rx_pd->rx_pkt_offset));
        skb_pull(skb, sizeof(pkt_len));
@@ -190,20 +186,11 @@ mwifiex_process_mgmt_packet(struct mwifiex_adapter *adapter,
  * the function creates a blank SKB, fills it with the data from the
  * received buffer and then sends this new SKB to the kernel.
  */
-int mwifiex_recv_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb)
+int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb)
 {
-       struct mwifiex_rxinfo *rx_info;
-       struct mwifiex_private *priv;
-
        if (!skb)
                return -1;
 
-       rx_info = MWIFIEX_SKB_RXCB(skb);
-       priv = mwifiex_get_priv_by_id(adapter, rx_info->bss_num,
-                                     rx_info->bss_type);
-       if (!priv)
-               return -1;
-
        skb->dev = priv->netdev;
        skb->protocol = eth_type_trans(skb, priv->netdev);
        skb->ip_summed = CHECKSUM_NONE;
@@ -225,7 +212,7 @@ int mwifiex_recv_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb)
         * fragments. Currently we fail the Filesndl-ht.scr script
         * for UDP, hence this fix
         */
-       if ((adapter->iface_type == MWIFIEX_USB) &&
+       if ((priv->adapter->iface_type == MWIFIEX_USB) &&
            (skb->truesize > MWIFIEX_RX_DATA_BUF_SIZE))
                skb->truesize += (skb->len - MWIFIEX_RX_DATA_BUF_SIZE);