mwifiex: report received management frames to cfg80211
authorStone Piao <piaoyun@marvell.com>
Wed, 26 Sep 2012 03:23:35 +0000 (20:23 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 28 Sep 2012 17:54:04 +0000 (13:54 -0400)
Process the management frames received from firmware and report
them to cfg80211.

Signed-off-by: Stone Piao <piaoyun@marvell.com>
Signed-off-by: Kiran Divekar <dkiran@marvell.com>
Signed-off-by: Kevin Gan <ganhy@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/fw.h
drivers/net/wireless/mwifiex/init.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/sta_rx.c
drivers/net/wireless/mwifiex/uap_txrx.c
drivers/net/wireless/mwifiex/util.c

index 41b304a33a073c8a1dfde1f506f0e6fcbf9eab2a..b587ea3feffa40a3ef3c5f1de55dfc004ed7d695 100644 (file)
@@ -94,6 +94,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
 };
 
 #define CAL_SNR(RSSI, NF)              ((s16)((s16)(RSSI)-(s16)(NF)))
+#define CAL_RSSI(SNR, NF)              ((s16)((s16)(SNR)+(s16)(NF)))
 
 #define UAP_BSS_PARAMS_I                       0
 #define UAP_CUSTOM_IE_I                                1
index b2ba262f8a139774d94432bc2f64855630856020..105a5c5d7d5dc97c708e714cb6c50e3cd9ebfc61 100644 (file)
@@ -214,6 +214,7 @@ static int mwifiex_init_priv(struct mwifiex_private *priv)
        priv->wps_ie = NULL;
        priv->wps_ie_len = 0;
        priv->ap_11n_enabled = 0;
+       priv->mgmt_rx_freq = 2437;
 
        priv->scan_block = false;
 
index 6e0806244b82094cb52366eca909460c8bf3c198..ec5794ef4366b73168db094d182f996147882f94 100644 (file)
@@ -497,6 +497,7 @@ struct mwifiex_private {
        struct timer_list scan_delay_timer;
        u8 ap_11n_enabled;
        u32 mgmt_frame_mask;
+       u32 mgmt_rx_freq;
 };
 
 enum mwifiex_ba_status {
@@ -741,6 +742,9 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
 
 int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
 
+int mwifiex_process_mgmt_packet(struct mwifiex_adapter *adapter,
+                               struct sk_buff *skb);
+
 int mwifiex_process_event(struct mwifiex_adapter *adapter);
 
 int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
index d91d5c08c73adbb1c6cfd31c69f27366de1c7a21..07d32b73783ea2cdd0859d80849eed1eb4a94804 100644 (file)
@@ -174,6 +174,12 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter,
                                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);
+               if (ret)
+                       dev_err(adapter->dev, "Rx of mgmt packet failed");
+               dev_kfree_skb_any(skb);
+               return ret;
        }
 
        /*
index df17d08715fe58836a4ed349cb4ea54adabaebe1..012c1433d126915d5d376902b6e3636a9a558e2e 100644 (file)
@@ -217,6 +217,12 @@ 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);
+               if (ret)
+                       dev_err(adapter->dev, "Rx of mgmt packet failed");
+               dev_kfree_skb_any(skb);
+               return ret;
        }
 
        memcpy(ta, rx_pkt_hdr->eth803_hdr.h_source, ETH_ALEN);
index 2864c74bdb6fc8b264815a57c039564fe9cbf0a0..e1dc3e41c65db7689dac81dfa438b5e1d3c98cac 100644 (file)
@@ -141,6 +141,46 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv,
        return 0;
 }
 
+/*
+ * This function processes the received management packet and send it
+ * to the kernel.
+ */
+int
+mwifiex_process_mgmt_packet(struct mwifiex_adapter *adapter,
+                           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));
+
+       pkt_len = le16_to_cpu(rx_pd->rx_pkt_length);
+
+       /* Remove address4 */
+       memmove(skb->data + sizeof(struct ieee80211_hdr_3addr),
+               skb->data + sizeof(struct ieee80211_hdr),
+               pkt_len - sizeof(struct ieee80211_hdr));
+
+       pkt_len -= ETH_ALEN + sizeof(pkt_len);
+       rx_pd->rx_pkt_length = cpu_to_le16(pkt_len);
+
+       cfg80211_rx_mgmt(priv->wdev, priv->mgmt_rx_freq,
+                        CAL_RSSI(rx_pd->snr, rx_pd->nf),
+                        skb->data, pkt_len, GFP_ATOMIC);
+
+       return 0;
+}
+
 /*
  * This function processes the received packet before sending it to the
  * kernel.