ath6kl: Report received Probe Request frames to cfg80211
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 30 Aug 2011 18:58:01 +0000 (21:58 +0300)
committerKalle Valo <kvalo@qca.qualcomm.com>
Wed, 31 Aug 2011 07:13:01 +0000 (10:13 +0300)
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/ath/ath6kl/core.h
drivers/net/wireless/ath/ath6kl/init.c
drivers/net/wireless/ath/ath6kl/wmi.c

index 78b1788..6033959 100644 (file)
@@ -1740,6 +1740,24 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
                                          buf, len);
 }
 
+static void ath6kl_mgmt_frame_register(struct wiphy *wiphy,
+                                      struct net_device *dev,
+                                      u16 frame_type, bool reg)
+{
+       struct ath6kl *ar = ath6kl_priv(dev);
+
+       ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: frame_type=0x%x reg=%d\n",
+                  __func__, frame_type, reg);
+       if (frame_type == IEEE80211_STYPE_PROBE_REQ) {
+               /*
+                * Note: This notification callback is not allowed to sleep, so
+                * we cannot send WMI_PROBE_REQ_REPORT_CMD here. Instead, we
+                * hardcode target to report Probe Request frames all the time.
+                */
+               ar->probe_req_report = reg;
+       }
+}
+
 static struct cfg80211_ops ath6kl_cfg80211_ops = {
        .change_virtual_intf = ath6kl_cfg80211_change_iface,
        .scan = ath6kl_cfg80211_scan,
@@ -1770,6 +1788,7 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = {
        .remain_on_channel = ath6kl_remain_on_channel,
        .cancel_remain_on_channel = ath6kl_cancel_remain_on_channel,
        .mgmt_tx = ath6kl_mgmt_tx,
+       .mgmt_frame_register = ath6kl_mgmt_frame_register,
 };
 
 struct wireless_dev *ath6kl_cfg80211_init(struct device *dev)
index 3872edb..99cabd2 100644 (file)
@@ -457,6 +457,7 @@ struct ath6kl {
        struct dentry *debugfs_phy;
 
        u32 send_action_id;
+       bool probe_req_report;
        u16 next_chan;
 };
 
index 48c82e9..3b99ae2 100644 (file)
@@ -471,6 +471,13 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar)
                           ret);
        }
 
+       /* Enable Probe Request reporting for P2P */
+       ret = ath6kl_wmi_probe_report_req_cmd(ar->wmi, true);
+       if (ret) {
+               ath6kl_dbg(ATH6KL_DBG_TRC, "failed to enable Probe Request "
+                          "reporting (%d)\n", ret);
+       }
+
        return status;
 }
 
index bbe3e8d..9b2a182 100644 (file)
@@ -499,18 +499,30 @@ static int ath6kl_wmi_tx_status_event_rx(u8 *datap, int len)
        return 0;
 }
 
-static int ath6kl_wmi_rx_probe_req_event_rx(u8 *datap, int len)
+static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len)
 {
        struct wmi_p2p_rx_probe_req_event *ev;
+       u32 freq;
        u16 dlen;
+       struct ath6kl *ar = wmi->parent_dev;
 
        if (len < sizeof(*ev))
                return -EINVAL;
 
        ev = (struct wmi_p2p_rx_probe_req_event *) datap;
+       freq = le32_to_cpu(ev->freq);
        dlen = le16_to_cpu(ev->len);
-       ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u\n",
-                  dlen);
+       if (datap + len < ev->data + dlen) {
+               ath6kl_err("invalid wmi_p2p_rx_probe_req_event: "
+                          "len=%d dlen=%u\n", len, dlen);
+               return -EINVAL;
+       }
+       ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u "
+                  "probe_req_report=%d\n",
+                  dlen, freq, ar->probe_req_report);
+
+       if (ar->probe_req_report || ar->nw_type == AP_NETWORK)
+               cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC);
 
        return 0;
 }
@@ -3045,7 +3057,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
                break;
        case WMI_RX_PROBE_REQ_EVENTID:
                ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
-               ret = ath6kl_wmi_rx_probe_req_event_rx(datap, len);
+               ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len);
                break;
        case WMI_P2P_CAPABILITIES_EVENTID:
                ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");