wlcore: add p2p device support
authorEliad Peller <eliad@wizery.com>
Thu, 30 Jul 2015 19:38:22 +0000 (22:38 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 10 Aug 2015 19:16:34 +0000 (22:16 +0300)
When starting a p2p mgmt interface, enable its device role. This
allows us to keep the sta role disabled and scan on the dev role.

In general, p2p management interfaces cannot send vif-specific commands
to FW, as the vif role id is invalid. Only off-channel data and scans
happen on this vif, so most ops are not relevant.

If the vif is a p2p mgmt vif, block some mac80211 ops.

Configure rate policies for p2p mgmt interface, as
otherwise p2p packets come out with arbitrary rates.

Since wpa_supplicant currently doesn't support standalone
p2p device mode (without another attached managed interface),
add p2p device to the allowed interface combinations without
decreasing the allowed station count.

Moreover, increase the station count in some cases, as AP
mode usually starts as station interface, and the AP interface
is now different from the p2p management one).

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ti/wl12xx/scan.c
drivers/net/wireless/ti/wl18xx/main.c
drivers/net/wireless/ti/wl18xx/scan.c
drivers/net/wireless/ti/wlcore/cmd.c
drivers/net/wireless/ti/wlcore/init.c
drivers/net/wireless/ti/wlcore/init.h
drivers/net/wireless/ti/wlcore/main.c
drivers/net/wireless/ti/wlcore/wlcore_i.h

index 0c0d5cd98514207c25b3faf804573f13af78976e..7c355fff2c5ea50616407545639b32aa7d558d8f 100644 (file)
@@ -118,7 +118,11 @@ static int wl1271_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
        if (passive)
                scan_options |= WL1271_SCAN_OPT_PASSIVE;
 
-       cmd->params.role_id = wlvif->role_id;
+       /* scan on the dev role if the regular one is not started */
+       if (wlcore_is_p2p_mgmt(wlvif))
+               cmd->params.role_id = wlvif->dev_role_id;
+       else
+               cmd->params.role_id = wlvif->role_id;
 
        if (WARN_ON(cmd->params.role_id == WL12XX_INVALID_ROLE_ID)) {
                ret = -EINVAL;
index f9c9d5cf0854dc24a224447ae26b882423810e61..abbf054fb6da892bee387e18345c41e842c01bd2 100644 (file)
@@ -1804,7 +1804,7 @@ static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = {
 
 static const struct ieee80211_iface_limit wl18xx_iface_limits[] = {
        {
-               .max = 3,
+               .max = 2,
                .types = BIT(NL80211_IFTYPE_STATION),
        },
        {
@@ -1813,6 +1813,10 @@ static const struct ieee80211_iface_limit wl18xx_iface_limits[] = {
                         BIT(NL80211_IFTYPE_P2P_GO) |
                         BIT(NL80211_IFTYPE_P2P_CLIENT),
        },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
+       },
 };
 
 static const struct ieee80211_iface_limit wl18xx_iface_ap_limits[] = {
@@ -1820,6 +1824,48 @@ static const struct ieee80211_iface_limit wl18xx_iface_ap_limits[] = {
                .max = 2,
                .types = BIT(NL80211_IFTYPE_AP),
        },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
+       },
+};
+
+static const struct ieee80211_iface_limit wl18xx_iface_ap_cl_limits[] = {
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_STATION),
+       },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_AP),
+       },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_P2P_CLIENT),
+       },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
+       },
+};
+
+static const struct ieee80211_iface_limit wl18xx_iface_ap_go_limits[] = {
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_STATION),
+       },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_AP),
+       },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_P2P_GO),
+       },
+       {
+               .max = 1,
+               .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
+       },
 };
 
 static const struct ieee80211_iface_combination
index ec2eb147add3b3afe800083a7eabc7e687633612..c938c494c785703b6f3b4a6a1fed48530028627c 100644 (file)
@@ -51,7 +51,11 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
                goto out;
        }
 
-       cmd->role_id = wlvif->role_id;
+       /* scan on the dev role if the regular one is not started */
+       if (wlcore_is_p2p_mgmt(wlvif))
+               cmd->role_id = wlvif->dev_role_id;
+       else
+               cmd->role_id = wlvif->role_id;
 
        if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
                ret = -EINVAL;
index dbc55a0aa9058a3597a7a094fedf247b09fbff5a..f01d24baff7cf00712cf07667f9b046b3d00dab2 100644 (file)
@@ -2003,12 +2003,15 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif,
                      wlvif->bss_type == BSS_TYPE_IBSS)))
                return -EINVAL;
 
-       ret = wl12xx_cmd_role_enable(wl,
-                                    wl12xx_wlvif_to_vif(wlvif)->addr,
-                                    WL1271_ROLE_DEVICE,
-                                    &wlvif->dev_role_id);
-       if (ret < 0)
-               goto out;
+       /* the dev role is already started for p2p mgmt interfaces */
+       if (!wlcore_is_p2p_mgmt(wlvif)) {
+               ret = wl12xx_cmd_role_enable(wl,
+                                            wl12xx_wlvif_to_vif(wlvif)->addr,
+                                            WL1271_ROLE_DEVICE,
+                                            &wlvif->dev_role_id);
+               if (ret < 0)
+                       goto out;
+       }
 
        ret = wl12xx_cmd_role_start_dev(wl, wlvif, band, channel);
        if (ret < 0)
@@ -2023,7 +2026,8 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif,
 out_stop:
        wl12xx_cmd_role_stop_dev(wl, wlvif);
 out_disable:
-       wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
+       if (!wlcore_is_p2p_mgmt(wlvif))
+               wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
 out:
        return ret;
 }
@@ -2052,9 +2056,11 @@ int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif)
        if (ret < 0)
                goto out;
 
-       ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
-       if (ret < 0)
-               goto out;
+       if (!wlcore_is_p2p_mgmt(wlvif)) {
+               ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
+               if (ret < 0)
+                       goto out;
+       }
 
 out:
        return ret;
index 5ca1fb161a50c8bbc612d859891fb9a3c8a441cf..e92f2639af2c8835d5c2faddd2c5630e99f89067 100644 (file)
@@ -348,7 +348,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl)
 }
 
 /* generic sta initialization (non vif-specific) */
-static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
+int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
 {
        int ret;
 
index a45fbfddec192e67791be7cb23ac419c2b3a82ba..fd1cdb6bc3e4d1e6ee972a09728e7dde0a8217d3 100644 (file)
@@ -35,5 +35,6 @@ int wl1271_hw_init(struct wl1271 *wl);
 int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif);
 int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif);
 int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif);
+int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif);
 
 #endif
index 337223b9f6f89aab54ae4c3cd93421e1ebb404fe..e819369d8f8f43a2ce37a5260c3c8c017c7ad5eb 100644 (file)
@@ -1792,6 +1792,9 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
 
        wl->wow_enabled = true;
        wl12xx_for_each_wlvif(wl, wlvif) {
+               if (wlcore_is_p2p_mgmt(wlvif))
+                       continue;
+
                ret = wl1271_configure_suspend(wl, wlvif, wow);
                if (ret < 0) {
                        mutex_unlock(&wl->mutex);
@@ -1901,6 +1904,9 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)
                goto out;
 
        wl12xx_for_each_wlvif(wl, wlvif) {
+               if (wlcore_is_p2p_mgmt(wlvif))
+                       continue;
+
                wl1271_configure_resume(wl, wlvif);
        }
 
@@ -2256,6 +2262,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif)
                wlvif->p2p = 1;
                /* fall-through */
        case NL80211_IFTYPE_STATION:
+       case NL80211_IFTYPE_P2P_DEVICE:
                wlvif->bss_type = BSS_TYPE_STA_BSS;
                break;
        case NL80211_IFTYPE_ADHOC:
@@ -2477,7 +2484,8 @@ static void wlcore_hw_queue_iter(void *data, u8 *mac,
 {
        struct wlcore_hw_queue_iter_data *iter_data = data;
 
-       if (WARN_ON_ONCE(vif->hw_queue[0] == IEEE80211_INVAL_HW_QUEUE))
+       if (vif->type == NL80211_IFTYPE_P2P_DEVICE ||
+           WARN_ON_ONCE(vif->hw_queue[0] == IEEE80211_INVAL_HW_QUEUE))
                return;
 
        if (iter_data->cur_running || vif == iter_data->vif) {
@@ -2495,6 +2503,11 @@ static int wlcore_allocate_hw_queue_base(struct wl1271 *wl,
        struct wlcore_hw_queue_iter_data iter_data = {};
        int i, q_base;
 
+       if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
+               vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
+               return 0;
+       }
+
        iter_data.vif = vif;
 
        /* mark all bits taken by active interfaces */
@@ -2618,14 +2631,27 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
                        goto out;
        }
 
-       ret = wl12xx_cmd_role_enable(wl, vif->addr,
-                                    role_type, &wlvif->role_id);
-       if (ret < 0)
-               goto out;
+       if (!wlcore_is_p2p_mgmt(wlvif)) {
+               ret = wl12xx_cmd_role_enable(wl, vif->addr,
+                                            role_type, &wlvif->role_id);
+               if (ret < 0)
+                       goto out;
 
-       ret = wl1271_init_vif_specific(wl, vif);
-       if (ret < 0)
-               goto out;
+               ret = wl1271_init_vif_specific(wl, vif);
+               if (ret < 0)
+                       goto out;
+
+       } else {
+               ret = wl12xx_cmd_role_enable(wl, vif->addr, WL1271_ROLE_DEVICE,
+                                            &wlvif->dev_role_id);
+               if (ret < 0)
+                       goto out;
+
+               /* needed mainly for configuring rate policies */
+               ret = wl1271_sta_hw_init(wl, wlvif);
+               if (ret < 0)
+                       goto out;
+       }
 
        list_add(&wlvif->list, &wl->wlvif_list);
        set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags);
@@ -2696,9 +2722,15 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
                                wl12xx_stop_dev(wl, wlvif);
                }
 
-               ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id);
-               if (ret < 0)
-                       goto deinit;
+               if (!wlcore_is_p2p_mgmt(wlvif)) {
+                       ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id);
+                       if (ret < 0)
+                               goto deinit;
+               } else {
+                       ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
+                       if (ret < 0)
+                               goto deinit;
+               }
 
                wl1271_ps_elp_sleep(wl);
        }
@@ -3088,6 +3120,9 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif,
 {
        int ret;
 
+       if (wlcore_is_p2p_mgmt(wlvif))
+               return 0;
+
        if (conf->power_level != wlvif->power_level) {
                ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level);
                if (ret < 0)
@@ -3207,6 +3242,9 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw,
                goto out;
 
        wl12xx_for_each_wlvif(wl, wlvif) {
+               if (wlcore_is_p2p_mgmt(wlvif))
+                       continue;
+
                if (wlvif->bss_type != BSS_TYPE_AP_BSS) {
                        if (*total & FIF_ALLMULTI)
                                ret = wl1271_acx_group_address_tbl(wl, wlvif,
@@ -4837,6 +4875,9 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw,
        u8 ps_scheme;
        int ret = 0;
 
+       if (wlcore_is_p2p_mgmt(wlvif))
+               return 0;
+
        mutex_lock(&wl->mutex);
 
        wl1271_debug(DEBUG_MAC80211, "mac80211 conf tx %d", queue);
@@ -6078,8 +6119,10 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
        wl->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
 
        wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
-               BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP) |
-               BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO);
+                                        BIT(NL80211_IFTYPE_AP) |
+                                        BIT(NL80211_IFTYPE_P2P_DEVICE) |
+                                        BIT(NL80211_IFTYPE_P2P_CLIENT) |
+                                        BIT(NL80211_IFTYPE_P2P_GO);
        wl->hw->wiphy->max_scan_ssids = 1;
        wl->hw->wiphy->max_sched_scan_ssids = 16;
        wl->hw->wiphy->max_match_sets = 16;
index 39efc6d78b10dd743f65c0b96dfe72f86747afe3..27c56876b2c13821606a662a3d06a6ae4e24ccdb 100644 (file)
@@ -503,6 +503,11 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif)
        return container_of((void *)wlvif, struct ieee80211_vif, drv_priv);
 }
 
+static inline bool wlcore_is_p2p_mgmt(struct wl12xx_vif *wlvif)
+{
+       return wl12xx_wlvif_to_vif(wlvif)->type == NL80211_IFTYPE_P2P_DEVICE;
+}
+
 #define wl12xx_for_each_wlvif(wl, wlvif) \
                list_for_each_entry(wlvif, &wl->wlvif_list, list)