Commit 7845af35 authored by Eliad Peller's avatar Eliad Peller Committed by Kalle Valo

wlcore: add p2p device support

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: default avatarArik Nemtsov <arik@wizery.com>
Signed-off-by: default avatarEliad Peller <eliad@wizery.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent c32e35f2
...@@ -118,6 +118,10 @@ static int wl1271_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif, ...@@ -118,6 +118,10 @@ static int wl1271_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
if (passive) if (passive)
scan_options |= WL1271_SCAN_OPT_PASSIVE; scan_options |= WL1271_SCAN_OPT_PASSIVE;
/* 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; cmd->params.role_id = wlvif->role_id;
if (WARN_ON(cmd->params.role_id == WL12XX_INVALID_ROLE_ID)) { if (WARN_ON(cmd->params.role_id == WL12XX_INVALID_ROLE_ID)) {
......
...@@ -1804,7 +1804,7 @@ static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = { ...@@ -1804,7 +1804,7 @@ static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = {
static const struct ieee80211_iface_limit wl18xx_iface_limits[] = { static const struct ieee80211_iface_limit wl18xx_iface_limits[] = {
{ {
.max = 3, .max = 2,
.types = BIT(NL80211_IFTYPE_STATION), .types = BIT(NL80211_IFTYPE_STATION),
}, },
{ {
...@@ -1813,6 +1813,10 @@ static const struct ieee80211_iface_limit wl18xx_iface_limits[] = { ...@@ -1813,6 +1813,10 @@ static const struct ieee80211_iface_limit wl18xx_iface_limits[] = {
BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_GO) |
BIT(NL80211_IFTYPE_P2P_CLIENT), BIT(NL80211_IFTYPE_P2P_CLIENT),
}, },
{
.max = 1,
.types = BIT(NL80211_IFTYPE_P2P_DEVICE),
},
}; };
static const struct ieee80211_iface_limit wl18xx_iface_ap_limits[] = { static const struct ieee80211_iface_limit wl18xx_iface_ap_limits[] = {
...@@ -1820,6 +1824,48 @@ 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, .max = 2,
.types = BIT(NL80211_IFTYPE_AP), .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 static const struct ieee80211_iface_combination
......
...@@ -51,6 +51,10 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif, ...@@ -51,6 +51,10 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
goto out; goto out;
} }
/* 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; cmd->role_id = wlvif->role_id;
if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) { if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
......
...@@ -2003,12 +2003,15 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif, ...@@ -2003,12 +2003,15 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif,
wlvif->bss_type == BSS_TYPE_IBSS))) wlvif->bss_type == BSS_TYPE_IBSS)))
return -EINVAL; return -EINVAL;
/* the dev role is already started for p2p mgmt interfaces */
if (!wlcore_is_p2p_mgmt(wlvif)) {
ret = wl12xx_cmd_role_enable(wl, ret = wl12xx_cmd_role_enable(wl,
wl12xx_wlvif_to_vif(wlvif)->addr, wl12xx_wlvif_to_vif(wlvif)->addr,
WL1271_ROLE_DEVICE, WL1271_ROLE_DEVICE,
&wlvif->dev_role_id); &wlvif->dev_role_id);
if (ret < 0) if (ret < 0)
goto out; goto out;
}
ret = wl12xx_cmd_role_start_dev(wl, wlvif, band, channel); ret = wl12xx_cmd_role_start_dev(wl, wlvif, band, channel);
if (ret < 0) if (ret < 0)
...@@ -2023,6 +2026,7 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif, ...@@ -2023,6 +2026,7 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif,
out_stop: out_stop:
wl12xx_cmd_role_stop_dev(wl, wlvif); wl12xx_cmd_role_stop_dev(wl, wlvif);
out_disable: out_disable:
if (!wlcore_is_p2p_mgmt(wlvif))
wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id); wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
out: out:
return ret; return ret;
...@@ -2052,9 +2056,11 @@ int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) ...@@ -2052,9 +2056,11 @@ int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif)
if (ret < 0) if (ret < 0)
goto out; goto out;
if (!wlcore_is_p2p_mgmt(wlvif)) {
ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id); ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
if (ret < 0) if (ret < 0)
goto out; goto out;
}
out: out:
return ret; return ret;
......
...@@ -348,7 +348,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl) ...@@ -348,7 +348,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl)
} }
/* generic sta initialization (non vif-specific) */ /* 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; int ret;
......
...@@ -35,5 +35,6 @@ int wl1271_hw_init(struct wl1271 *wl); ...@@ -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_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif);
int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif); 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_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif);
int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif);
#endif #endif
...@@ -1792,6 +1792,9 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, ...@@ -1792,6 +1792,9 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
wl->wow_enabled = true; wl->wow_enabled = true;
wl12xx_for_each_wlvif(wl, wlvif) { wl12xx_for_each_wlvif(wl, wlvif) {
if (wlcore_is_p2p_mgmt(wlvif))
continue;
ret = wl1271_configure_suspend(wl, wlvif, wow); ret = wl1271_configure_suspend(wl, wlvif, wow);
if (ret < 0) { if (ret < 0) {
mutex_unlock(&wl->mutex); mutex_unlock(&wl->mutex);
...@@ -1901,6 +1904,9 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) ...@@ -1901,6 +1904,9 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)
goto out; goto out;
wl12xx_for_each_wlvif(wl, wlvif) { wl12xx_for_each_wlvif(wl, wlvif) {
if (wlcore_is_p2p_mgmt(wlvif))
continue;
wl1271_configure_resume(wl, wlvif); wl1271_configure_resume(wl, wlvif);
} }
...@@ -2256,6 +2262,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) ...@@ -2256,6 +2262,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif)
wlvif->p2p = 1; wlvif->p2p = 1;
/* fall-through */ /* fall-through */
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_P2P_DEVICE:
wlvif->bss_type = BSS_TYPE_STA_BSS; wlvif->bss_type = BSS_TYPE_STA_BSS;
break; break;
case NL80211_IFTYPE_ADHOC: case NL80211_IFTYPE_ADHOC:
...@@ -2477,7 +2484,8 @@ static void wlcore_hw_queue_iter(void *data, u8 *mac, ...@@ -2477,7 +2484,8 @@ static void wlcore_hw_queue_iter(void *data, u8 *mac,
{ {
struct wlcore_hw_queue_iter_data *iter_data = data; 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; return;
if (iter_data->cur_running || vif == iter_data->vif) { if (iter_data->cur_running || vif == iter_data->vif) {
...@@ -2495,6 +2503,11 @@ static int wlcore_allocate_hw_queue_base(struct wl1271 *wl, ...@@ -2495,6 +2503,11 @@ static int wlcore_allocate_hw_queue_base(struct wl1271 *wl,
struct wlcore_hw_queue_iter_data iter_data = {}; struct wlcore_hw_queue_iter_data iter_data = {};
int i, q_base; int i, q_base;
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
return 0;
}
iter_data.vif = vif; iter_data.vif = vif;
/* mark all bits taken by active interfaces */ /* mark all bits taken by active interfaces */
...@@ -2618,6 +2631,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ...@@ -2618,6 +2631,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
goto out; goto out;
} }
if (!wlcore_is_p2p_mgmt(wlvif)) {
ret = wl12xx_cmd_role_enable(wl, vif->addr, ret = wl12xx_cmd_role_enable(wl, vif->addr,
role_type, &wlvif->role_id); role_type, &wlvif->role_id);
if (ret < 0) if (ret < 0)
...@@ -2627,6 +2641,18 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ...@@ -2627,6 +2641,18 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
if (ret < 0) if (ret < 0)
goto out; 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); list_add(&wlvif->list, &wl->wlvif_list);
set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags); set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags);
...@@ -2696,9 +2722,15 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, ...@@ -2696,9 +2722,15 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
wl12xx_stop_dev(wl, wlvif); wl12xx_stop_dev(wl, wlvif);
} }
if (!wlcore_is_p2p_mgmt(wlvif)) {
ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id); ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id);
if (ret < 0) if (ret < 0)
goto deinit; goto deinit;
} else {
ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
if (ret < 0)
goto deinit;
}
wl1271_ps_elp_sleep(wl); wl1271_ps_elp_sleep(wl);
} }
...@@ -3088,6 +3120,9 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, ...@@ -3088,6 +3120,9 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif,
{ {
int ret; int ret;
if (wlcore_is_p2p_mgmt(wlvif))
return 0;
if (conf->power_level != wlvif->power_level) { if (conf->power_level != wlvif->power_level) {
ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level);
if (ret < 0) if (ret < 0)
...@@ -3207,6 +3242,9 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, ...@@ -3207,6 +3242,9 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw,
goto out; goto out;
wl12xx_for_each_wlvif(wl, wlvif) { wl12xx_for_each_wlvif(wl, wlvif) {
if (wlcore_is_p2p_mgmt(wlvif))
continue;
if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (wlvif->bss_type != BSS_TYPE_AP_BSS) {
if (*total & FIF_ALLMULTI) if (*total & FIF_ALLMULTI)
ret = wl1271_acx_group_address_tbl(wl, wlvif, ret = wl1271_acx_group_address_tbl(wl, wlvif,
...@@ -4837,6 +4875,9 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw, ...@@ -4837,6 +4875,9 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw,
u8 ps_scheme; u8 ps_scheme;
int ret = 0; int ret = 0;
if (wlcore_is_p2p_mgmt(wlvif))
return 0;
mutex_lock(&wl->mutex); mutex_lock(&wl->mutex);
wl1271_debug(DEBUG_MAC80211, "mac80211 conf tx %d", queue); wl1271_debug(DEBUG_MAC80211, "mac80211 conf tx %d", queue);
...@@ -6078,8 +6119,10 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) ...@@ -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->n_cipher_suites = ARRAY_SIZE(cipher_suites);
wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_AP) |
BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO); 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_scan_ssids = 1;
wl->hw->wiphy->max_sched_scan_ssids = 16; wl->hw->wiphy->max_sched_scan_ssids = 16;
wl->hw->wiphy->max_match_sets = 16; wl->hw->wiphy->max_match_sets = 16;
......
...@@ -503,6 +503,11 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) ...@@ -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); 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) \ #define wl12xx_for_each_wlvif(wl, wlvif) \
list_for_each_entry(wlvif, &wl->wlvif_list, list) list_for_each_entry(wlvif, &wl->wlvif_list, list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment