nl80211: move scan API to wdev
authorJohannes Berg <johannes.berg@intel.com>
Mon, 18 Jun 2012 17:17:03 +0000 (19:17 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 12 Jul 2012 10:10:41 +0000 (12:10 +0200)
The new P2P Device will have to be able to scan for
P2P search, so move scanning to use struct wireless_dev
instead of struct net_device.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
14 files changed:
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
drivers/net/wireless/iwmc3200wifi/cfg80211.c
drivers/net/wireless/libertas/cfg.c
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/orinoco/cfg.c
drivers/net/wireless/rndis_wlan.c
include/net/cfg80211.h
net/mac80211/cfg.c
net/wireless/core.c
net/wireless/nl80211.c
net/wireless/nl80211.h
net/wireless/scan.c
net/wireless/sme.c

index 88bed02f752112834a6322fff4e50e3523152084..86aeef4b9d7ee9295fe04c5533d3959a19474c9c 100644 (file)
@@ -966,11 +966,11 @@ static int ath6kl_set_probed_ssids(struct ath6kl *ar,
        return 0;
 }
 
-static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
+static int ath6kl_cfg80211_scan(struct wiphy *wiphy,
                                struct cfg80211_scan_request *request)
 {
-       struct ath6kl *ar = ath6kl_priv(ndev);
-       struct ath6kl_vif *vif = netdev_priv(ndev);
+       struct ath6kl_vif *vif = ath6kl_vif_from_wdev(request->wdev);
+       struct ath6kl *ar = ath6kl_priv(vif->ndev);
        s8 n_channels = 0;
        u16 *channels = NULL;
        int ret = 0;
index d13ae9c299f21db0f09182e3a509876c47938162..c6a10caec79fb94f6d0b9630f29424ea66445828 100644 (file)
@@ -691,9 +691,10 @@ scan_out:
 }
 
 static s32
-brcmf_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
+brcmf_cfg80211_scan(struct wiphy *wiphy,
                 struct cfg80211_scan_request *request)
 {
+       struct net_device *ndev = request->wdev->netdev;
        s32 err = 0;
 
        WL_TRACE("Enter\n");
index 48e8218fd23bc32ad79f56c007b10fbb49109ff9..523dd646f05290278682c97642fc463fb3a1c59f 100644 (file)
@@ -353,9 +353,10 @@ static int iwm_cfg80211_change_iface(struct wiphy *wiphy,
        return 0;
 }
 
-static int iwm_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
+static int iwm_cfg80211_scan(struct wiphy *wiphy,
                             struct cfg80211_scan_request *request)
 {
+       struct net_device *ndev = request->wdev->netdev;
        struct iwm_priv *iwm = ndev_to_iwm(ndev);
        int ret;
 
index f4a203049fb470d59d5beb2064208ab82d5734e4..706781316195a9b897f73313ffbe4b44ebefb50f 100644 (file)
@@ -805,7 +805,6 @@ void lbs_scan_done(struct lbs_private *priv)
 }
 
 static int lbs_cfg_scan(struct wiphy *wiphy,
-       struct net_device *dev,
        struct cfg80211_scan_request *request)
 {
        struct lbs_private *priv = wiphy_priv(wiphy);
index 1e8024ea69108ded9448f4d4fa4a40fb113a8653..6ca571a1b8e2ecbd171b9540a4b47ee1c558c508 100644 (file)
@@ -1376,9 +1376,10 @@ mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
  * it also informs the results.
  */
 static int
-mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
+mwifiex_cfg80211_scan(struct wiphy *wiphy,
                      struct cfg80211_scan_request *request)
 {
+       struct net_device *dev = request->wdev->netdev;
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
        int i;
        struct ieee80211_channel *chan;
index e15675585fb10ae21a16ba7c9210fb3f703911c2..7b751fba7e1f90176d797ab1a2bc88ce72e5f6ac 100644 (file)
@@ -138,7 +138,7 @@ static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev,
        return err;
 }
 
-static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev,
+static int orinoco_scan(struct wiphy *wiphy,
                        struct cfg80211_scan_request *request)
 {
        struct orinoco_private *priv = wiphy_priv(wiphy);
index dfcd02ab6cae5add70a2eb47c703d54b32c324ce..241162e8111d2584f0fca6f47819cf924cdf1157 100644 (file)
@@ -484,7 +484,7 @@ static int rndis_change_virtual_intf(struct wiphy *wiphy,
                                        enum nl80211_iftype type, u32 *flags,
                                        struct vif_params *params);
 
-static int rndis_scan(struct wiphy *wiphy, struct net_device *dev,
+static int rndis_scan(struct wiphy *wiphy,
                        struct cfg80211_scan_request *request);
 
 static int rndis_set_wiphy_params(struct wiphy *wiphy, u32 changed);
@@ -1941,9 +1941,10 @@ static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm)
 }
 
 #define SCAN_DELAY_JIFFIES (6 * HZ)
-static int rndis_scan(struct wiphy *wiphy, struct net_device *dev,
+static int rndis_scan(struct wiphy *wiphy,
                        struct cfg80211_scan_request *request)
 {
+       struct net_device *dev = request->wdev->netdev;
        struct usbnet *usbdev = netdev_priv(dev);
        struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
        int ret;
index aaaa3a255ed5fed91efe5203460ebae0ece74b63..5a67165f3b190e61b682a4868b73295dee720bcb 100644 (file)
@@ -999,7 +999,7 @@ struct cfg80211_ssid {
  * @ie_len: length of ie in octets
  * @rates: bitmap of rates to advertise for each band
  * @wiphy: the wiphy this was for
- * @dev: the interface
+ * @wdev: the wireless device to scan for
  * @aborted: (internal) scan request was notified as aborted
  * @no_cck: used to send probe requests at non CCK rate in 2GHz band
  */
@@ -1012,9 +1012,10 @@ struct cfg80211_scan_request {
 
        u32 rates[IEEE80211_NUM_BANDS];
 
+       struct wireless_dev *wdev;
+
        /* internal */
        struct wiphy *wiphy;
-       struct net_device *dev;
        bool aborted;
        bool no_cck;
 
@@ -1700,7 +1701,7 @@ struct cfg80211_ops {
                                       struct ieee80211_channel *chan,
                                       enum nl80211_channel_type channel_type);
 
-       int     (*scan)(struct wiphy *wiphy, struct net_device *dev,
+       int     (*scan)(struct wiphy *wiphy,
                        struct cfg80211_scan_request *request);
 
        int     (*auth)(struct wiphy *wiphy, struct net_device *dev,
index a752c7341d62a5f33f3e1f5373b5ab41cb08af92..cfdc03f59e27200443d02c5a650335d1fb038896 100644 (file)
@@ -1763,10 +1763,11 @@ static int ieee80211_resume(struct wiphy *wiphy)
 #endif
 
 static int ieee80211_scan(struct wiphy *wiphy,
-                         struct net_device *dev,
                          struct cfg80211_scan_request *req)
 {
-       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       struct ieee80211_sub_if_data *sdata;
+
+       sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
 
        switch (ieee80211_vif_type_p2p(&sdata->vif)) {
        case NL80211_IFTYPE_STATION:
index 2781a411cecc379b2fe9807ee6bb3bc70886c9ac..0557bb159025e0679966a468a5ada227ee54e9c7 100644 (file)
@@ -708,7 +708,7 @@ static void wdev_cleanup_work(struct work_struct *work)
 
        cfg80211_lock_rdev(rdev);
 
-       if (WARN_ON(rdev->scan_req && rdev->scan_req->dev == wdev->netdev)) {
+       if (WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev)) {
                rdev->scan_req->aborted = true;
                ___cfg80211_scan_done(rdev, true);
        }
index 6a9a1d7f51d104c6eb6a761e4a4ca126d61382dd..6472c7f928dc1330a2d7e1d368a012eef78ae48b 100644 (file)
@@ -4130,7 +4130,7 @@ static int validate_scan_freqs(struct nlattr *freqs)
 static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 {
        struct cfg80211_registered_device *rdev = info->user_ptr[0];
-       struct net_device *dev = info->user_ptr[1];
+       struct wireless_dev *wdev = info->user_ptr[1];
        struct cfg80211_scan_request *request;
        struct nlattr *attr;
        struct wiphy *wiphy;
@@ -4290,15 +4290,16 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
        request->no_cck =
                nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
 
-       request->dev = dev;
+       request->wdev = wdev;
        request->wiphy = &rdev->wiphy;
 
        rdev->scan_req = request;
-       err = rdev->ops->scan(&rdev->wiphy, dev, request);
+       err = rdev->ops->scan(&rdev->wiphy, request);
 
        if (!err) {
-               nl80211_send_scan_start(rdev, dev);
-               dev_hold(dev);
+               nl80211_send_scan_start(rdev, wdev);
+               if (wdev->netdev)
+                       dev_hold(wdev->netdev);
        } else {
  out_free:
                rdev->scan_req = NULL;
@@ -7066,7 +7067,7 @@ static struct genl_ops nl80211_ops[] = {
                .doit = nl80211_trigger_scan,
                .policy = nl80211_policy,
                .flags = GENL_ADMIN_PERM,
-               .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
+               .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
        {
@@ -7458,7 +7459,7 @@ static int nl80211_add_scan_req(struct sk_buff *msg,
 
 static int nl80211_send_scan_msg(struct sk_buff *msg,
                                 struct cfg80211_registered_device *rdev,
-                                struct net_device *netdev,
+                                struct wireless_dev *wdev,
                                 u32 pid, u32 seq, int flags,
                                 u32 cmd)
 {
@@ -7469,7 +7470,9 @@ static int nl80211_send_scan_msg(struct sk_buff *msg,
                return -1;
 
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
-           nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex))
+           (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
+                                        wdev->netdev->ifindex)) ||
+           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
                goto nla_put_failure;
 
        /* ignore errors and send incomplete event anyway */
@@ -7506,7 +7509,7 @@ nl80211_send_sched_scan_msg(struct sk_buff *msg,
 }
 
 void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
-                            struct net_device *netdev)
+                            struct wireless_dev *wdev)
 {
        struct sk_buff *msg;
 
@@ -7514,7 +7517,7 @@ void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
        if (!msg)
                return;
 
-       if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
+       if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
                                  NL80211_CMD_TRIGGER_SCAN) < 0) {
                nlmsg_free(msg);
                return;
@@ -7525,7 +7528,7 @@ void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
 }
 
 void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
-                           struct net_device *netdev)
+                           struct wireless_dev *wdev)
 {
        struct sk_buff *msg;
 
@@ -7533,7 +7536,7 @@ void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
        if (!msg)
                return;
 
-       if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
+       if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
                                  NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
                nlmsg_free(msg);
                return;
@@ -7544,7 +7547,7 @@ void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
 }
 
 void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
-                              struct net_device *netdev)
+                              struct wireless_dev *wdev)
 {
        struct sk_buff *msg;
 
@@ -7552,7 +7555,7 @@ void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
        if (!msg)
                return;
 
-       if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
+       if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
                                  NL80211_CMD_SCAN_ABORTED) < 0) {
                nlmsg_free(msg);
                return;
index 0469303b5c3ce2459fb657586869856dd11286ab..89ce99675e61352236c32a56cfc0ba0138339496 100644 (file)
@@ -7,11 +7,11 @@ int nl80211_init(void);
 void nl80211_exit(void);
 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
 void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
-                            struct net_device *netdev);
+                            struct wireless_dev *wdev);
 void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
-                           struct net_device *netdev);
+                           struct wireless_dev *wdev);
 void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
-                              struct net_device *netdev);
+                              struct wireless_dev *wdev);
 void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
                             struct net_device *netdev, u32 cmd);
 void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
index af2b1caa37fab51adc699f0ce13ddbefa0d64e83..848523a2b22f02c9a8975ff942073c0794671b54 100644 (file)
@@ -23,7 +23,7 @@
 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
 {
        struct cfg80211_scan_request *request;
-       struct net_device *dev;
+       struct wireless_dev *wdev;
 #ifdef CONFIG_CFG80211_WEXT
        union iwreq_data wrqu;
 #endif
@@ -35,29 +35,31 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
        if (!request)
                return;
 
-       dev = request->dev;
+       wdev = request->wdev;
 
        /*
         * This must be before sending the other events!
         * Otherwise, wpa_supplicant gets completely confused with
         * wext events.
         */
-       cfg80211_sme_scan_done(dev);
+       if (wdev->netdev)
+               cfg80211_sme_scan_done(wdev->netdev);
 
        if (request->aborted)
-               nl80211_send_scan_aborted(rdev, dev);
+               nl80211_send_scan_aborted(rdev, wdev);
        else
-               nl80211_send_scan_done(rdev, dev);
+               nl80211_send_scan_done(rdev, wdev);
 
 #ifdef CONFIG_CFG80211_WEXT
-       if (!request->aborted) {
+       if (wdev->netdev && !request->aborted) {
                memset(&wrqu, 0, sizeof(wrqu));
 
-               wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
+               wireless_send_event(wdev->netdev, SIOCGIWSCAN, &wrqu, NULL);
        }
 #endif
 
-       dev_put(dev);
+       if (wdev->netdev)
+               dev_put(wdev->netdev);
 
        rdev->scan_req = NULL;
 
@@ -955,7 +957,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
        }
 
        creq->wiphy = wiphy;
-       creq->dev = dev;
+       creq->wdev = dev->ieee80211_ptr;
        /* SSIDs come after channels */
        creq->ssids = (void *)&creq->channels[n_channels];
        creq->n_channels = n_channels;
@@ -1024,12 +1026,12 @@ int cfg80211_wext_siwscan(struct net_device *dev,
                        creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1;
 
        rdev->scan_req = creq;
-       err = rdev->ops->scan(wiphy, dev, creq);
+       err = rdev->ops->scan(wiphy, creq);
        if (err) {
                rdev->scan_req = NULL;
                /* creq will be freed below */
        } else {
-               nl80211_send_scan_start(rdev, dev);
+               nl80211_send_scan_start(rdev, dev->ieee80211_ptr);
                /* creq now owned by driver */
                creq = NULL;
                dev_hold(dev);
index dec97981e68999cfc22ba09e7a0cc3e6b7a7fc35..6f39cb808302380e05fa70d9a68925f7a35dcae3 100644 (file)
@@ -136,15 +136,15 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
                wdev->conn->params.ssid_len);
        request->ssids[0].ssid_len = wdev->conn->params.ssid_len;
 
-       request->dev = wdev->netdev;
+       request->wdev = wdev;
        request->wiphy = &rdev->wiphy;
 
        rdev->scan_req = request;
 
-       err = rdev->ops->scan(wdev->wiphy, wdev->netdev, request);
+       err = rdev->ops->scan(wdev->wiphy, request);
        if (!err) {
                wdev->conn->state = CFG80211_CONN_SCANNING;
-               nl80211_send_scan_start(rdev, wdev->netdev);
+               nl80211_send_scan_start(rdev, wdev);
                dev_hold(wdev->netdev);
        } else {
                rdev->scan_req = NULL;