mwifiex: add P2P interface
authorStone Piao <piaoyun@marvell.com>
Wed, 26 Sep 2012 03:23:40 +0000 (20:23 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 28 Sep 2012 17:54:05 +0000 (13:54 -0400)
Due to firmware design, driver needs to add a default P2P interface
to implement find phase and action frame handshake.

Signed-off-by: Stone Piao <piaoyun@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/decl.h
drivers/net/wireless/mwifiex/main.c

index 1f4bd67dffa7a8cd4c95819507f44723766e71b8..ece267a363804405c31ac8febda38397ba196c4f 100644 (file)
@@ -22,7 +22,7 @@
 
 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = {
        {
-               .max = 1, .types = BIT(NL80211_IFTYPE_STATION),
+               .max = 2, .types = BIT(NL80211_IFTYPE_STATION),
        },
        {
                .max = 1, .types = BIT(NL80211_IFTYPE_AP),
@@ -1917,6 +1917,41 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
                priv->bss_num = 0;
                priv->bss_mode = type;
 
+               break;
+       case NL80211_IFTYPE_P2P_CLIENT:
+               priv = adapter->priv[MWIFIEX_BSS_TYPE_P2P];
+
+               if (priv->bss_mode) {
+                       wiphy_err(wiphy, "Can't create multiple P2P ifaces");
+                       return ERR_PTR(-EINVAL);
+               }
+
+               wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
+               if (!wdev)
+                       return ERR_PTR(-ENOMEM);
+
+               priv->wdev = wdev;
+               wdev->wiphy = wiphy;
+
+               /* At start-up, wpa_supplicant tries to change the interface
+                * to NL80211_IFTYPE_STATION if it is not managed mode.
+                * So, we initialize it to STA mode.
+                */
+               wdev->iftype = NL80211_IFTYPE_STATION;
+               priv->bss_mode = NL80211_IFTYPE_STATION;
+
+               /* Setting bss_type to P2P tells firmware that this interface
+                * is receiving P2P peers found during find phase and doing
+                * action frame handshake.
+                */
+               priv->bss_type = MWIFIEX_BSS_TYPE_P2P;
+
+               priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II;
+               priv->bss_priority = MWIFIEX_BSS_ROLE_STA;
+               priv->bss_role = MWIFIEX_BSS_ROLE_STA;
+               priv->bss_started = 0;
+               priv->bss_num = 0;
+
                break;
        default:
                wiphy_err(wiphy, "type not supported\n");
@@ -2069,6 +2104,8 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
        wiphy->max_remain_on_channel_duration = 5000;
        wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
                                 BIT(NL80211_IFTYPE_ADHOC) |
+                                BIT(NL80211_IFTYPE_P2P_CLIENT) |
+                                BIT(NL80211_IFTYPE_P2P_GO) |
                                 BIT(NL80211_IFTYPE_AP);
 
        wiphy->bands[IEEE80211_BAND_2GHZ] = &mwifiex_band_2ghz;
index d21bcc146f4bec604fa154fd7964948f82866961..e9357d87d3279f7ba1d19c8246347f44ca46a269 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/ieee80211.h>
 
 
-#define MWIFIEX_MAX_BSS_NUM         (2)
+#define MWIFIEX_MAX_BSS_NUM         (3)
 
 #define MWIFIEX_MIN_DATA_HEADER_LEN 36 /* sizeof(mwifiex_txpd)
                                         *   + 4 byte alignment
@@ -70,6 +70,7 @@
 enum mwifiex_bss_type {
        MWIFIEX_BSS_TYPE_STA = 0,
        MWIFIEX_BSS_TYPE_UAP = 1,
+       MWIFIEX_BSS_TYPE_P2P = 2,
        MWIFIEX_BSS_TYPE_ANY = 0xff,
 };
 
index 3bb3417932d00c0488a0679dd207634490d8ebc3..eb22dd248d5491e0644a7b60225216faeae7ad1a 100644 (file)
@@ -369,6 +369,13 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
                dev_err(adapter->dev, "cannot create default AP interface\n");
                goto err_add_intf;
        }
+
+       /* Create P2P interface by default */
+       if (!mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d",
+                                     NL80211_IFTYPE_P2P_CLIENT, NULL, NULL)) {
+               dev_err(adapter->dev, "cannot create default P2P interface\n");
+               goto err_add_intf;
+       }
        rtnl_unlock();
 
        mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1);