aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-11-14 09:17:28 -0500
committerJohannes Berg <johannes.berg@intel.com>2012-11-27 05:56:18 -0500
commit53cabad70ecf0c245b41285de64a74a6c3ee9933 (patch)
treefcbae0f72a3afaf57844b8181c87e63914408c89
parent5164892184d1b9ce19e45e97e9ca405ea8b9ceb2 (diff)
nl80211: support P2P GO powersave configuration
If a driver supports P2P GO powersave, allow it to set the new feature flags for it and allow userspace to configure the parameters for it. This can be done at GO startup and later changed with SET_BSS. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--include/net/cfg80211.h7
-rw-r--r--include/uapi/linux/nl80211.h16
-rw-r--r--net/wireless/nl80211.c56
3 files changed, 79 insertions, 0 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index a238f41e55c2..731b48fa238b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -538,6 +538,8 @@ struct cfg80211_beacon_data {
538 * @privacy: the BSS uses privacy 538 * @privacy: the BSS uses privacy
539 * @auth_type: Authentication type (algorithm) 539 * @auth_type: Authentication type (algorithm)
540 * @inactivity_timeout: time in seconds to determine station's inactivity. 540 * @inactivity_timeout: time in seconds to determine station's inactivity.
541 * @p2p_ctwindow: P2P CT Window
542 * @p2p_opp_ps: P2P opportunistic PS
541 */ 543 */
542struct cfg80211_ap_settings { 544struct cfg80211_ap_settings {
543 struct cfg80211_chan_def chandef; 545 struct cfg80211_chan_def chandef;
@@ -552,6 +554,8 @@ struct cfg80211_ap_settings {
552 bool privacy; 554 bool privacy;
553 enum nl80211_auth_type auth_type; 555 enum nl80211_auth_type auth_type;
554 int inactivity_timeout; 556 int inactivity_timeout;
557 u8 p2p_ctwindow;
558 bool p2p_opp_ps;
555}; 559};
556 560
557/** 561/**
@@ -913,6 +917,8 @@ struct mpath_info {
913 * @ap_isolate: do not forward packets between connected stations 917 * @ap_isolate: do not forward packets between connected stations
914 * @ht_opmode: HT Operation mode 918 * @ht_opmode: HT Operation mode
915 * (u16 = opmode, -1 = do not change) 919 * (u16 = opmode, -1 = do not change)
920 * @p2p_ctwindow: P2P CT Window (-1 = no change)
921 * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
916 */ 922 */
917struct bss_parameters { 923struct bss_parameters {
918 int use_cts_prot; 924 int use_cts_prot;
@@ -922,6 +928,7 @@ struct bss_parameters {
922 u8 basic_rates_len; 928 u8 basic_rates_len;
923 int ap_isolate; 929 int ap_isolate;
924 int ht_opmode; 930 int ht_opmode;
931 s8 p2p_ctwindow, p2p_opp_ps;
925}; 932};
926 933
927/** 934/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 33a417481ad8..e3e19f8b16f2 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1303,6 +1303,13 @@ enum nl80211_commands {
1303 * 1303 *
1304 * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32) 1304 * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32)
1305 * 1305 *
1306 * @NL80211_ATTR_P2P_CTWINDOW: P2P GO Client Traffic Window (u8), used with
1307 * the START_AP and SET_BSS commands
1308 * @NL80211_ATTR_P2P_OPPPS: P2P GO opportunistic PS (u8), used with the
1309 * START_AP and SET_BSS commands. This can have the values 0 or 1;
1310 * if not given in START_AP 0 is assumed, if not given in SET_BSS
1311 * no change is made.
1312 *
1306 * @NL80211_ATTR_MAX: highest attribute number currently defined 1313 * @NL80211_ATTR_MAX: highest attribute number currently defined
1307 * @__NL80211_ATTR_AFTER_LAST: internal use 1314 * @__NL80211_ATTR_AFTER_LAST: internal use
1308 */ 1315 */
@@ -1570,6 +1577,9 @@ enum nl80211_attrs {
1570 NL80211_ATTR_CENTER_FREQ1, 1577 NL80211_ATTR_CENTER_FREQ1,
1571 NL80211_ATTR_CENTER_FREQ2, 1578 NL80211_ATTR_CENTER_FREQ2,
1572 1579
1580 NL80211_ATTR_P2P_CTWINDOW,
1581 NL80211_ATTR_P2P_OPPPS,
1582
1573 /* add attributes here, update the policy in nl80211.c */ 1583 /* add attributes here, update the policy in nl80211.c */
1574 1584
1575 __NL80211_ATTR_AFTER_LAST, 1585 __NL80211_ATTR_AFTER_LAST,
@@ -3126,6 +3136,10 @@ enum nl80211_ap_sme_features {
3126 * @NL80211_FEATURE_NEED_OBSS_SCAN: The driver expects userspace to perform 3136 * @NL80211_FEATURE_NEED_OBSS_SCAN: The driver expects userspace to perform
3127 * OBSS scans and generate 20/40 BSS coex reports. This flag is used only 3137 * OBSS scans and generate 20/40 BSS coex reports. This flag is used only
3128 * for drivers implementing the CONNECT API, for AUTH/ASSOC it is implied. 3138 * for drivers implementing the CONNECT API, for AUTH/ASSOC it is implied.
3139 * @NL80211_FEATURE_P2P_GO_CTWIN: P2P GO implementation supports CT Window
3140 * setting
3141 * @NL80211_FEATURE_P2P_GO_OPPPS: P2P GO implementation supports opportunistic
3142 * powersave
3129 */ 3143 */
3130enum nl80211_feature_flags { 3144enum nl80211_feature_flags {
3131 NL80211_FEATURE_SK_TX_STATUS = 1 << 0, 3145 NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
@@ -3139,6 +3153,8 @@ enum nl80211_feature_flags {
3139 NL80211_FEATURE_AP_SCAN = 1 << 8, 3153 NL80211_FEATURE_AP_SCAN = 1 << 8,
3140 NL80211_FEATURE_VIF_TXPOWER = 1 << 9, 3154 NL80211_FEATURE_VIF_TXPOWER = 1 << 9,
3141 NL80211_FEATURE_NEED_OBSS_SCAN = 1 << 10, 3155 NL80211_FEATURE_NEED_OBSS_SCAN = 1 << 10,
3156 NL80211_FEATURE_P2P_GO_CTWIN = 1 << 11,
3157 NL80211_FEATURE_P2P_GO_OPPPS = 1 << 12,
3142}; 3158};
3143 3159
3144/** 3160/**
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index eb0aa71a02b3..7f53aafd47f7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -363,6 +363,8 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
363 [NL80211_ATTR_SAE_DATA] = { .type = NLA_BINARY, }, 363 [NL80211_ATTR_SAE_DATA] = { .type = NLA_BINARY, },
364 [NL80211_ATTR_VHT_CAPABILITY] = { .len = NL80211_VHT_CAPABILITY_LEN }, 364 [NL80211_ATTR_VHT_CAPABILITY] = { .len = NL80211_VHT_CAPABILITY_LEN },
365 [NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 }, 365 [NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 },
366 [NL80211_ATTR_P2P_CTWINDOW] = { .type = NLA_U8 },
367 [NL80211_ATTR_P2P_OPPPS] = { .type = NLA_U8 },
366}; 368};
367 369
368/* policy for the key attributes */ 370/* policy for the key attributes */
@@ -2702,6 +2704,32 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
2702 info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]); 2704 info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]);
2703 } 2705 }
2704 2706
2707 if (info->attrs[NL80211_ATTR_P2P_CTWINDOW]) {
2708 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
2709 return -EINVAL;
2710 params.p2p_ctwindow =
2711 nla_get_u8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]);
2712 if (params.p2p_ctwindow > 127)
2713 return -EINVAL;
2714 if (params.p2p_ctwindow != 0 &&
2715 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN))
2716 return -EINVAL;
2717 }
2718
2719 if (info->attrs[NL80211_ATTR_P2P_OPPPS]) {
2720 u8 tmp;
2721
2722 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
2723 return -EINVAL;
2724 tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]);
2725 if (tmp > 1)
2726 return -EINVAL;
2727 params.p2p_opp_ps = tmp;
2728 if (params.p2p_opp_ps != 0 &&
2729 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS))
2730 return -EINVAL;
2731 }
2732
2705 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { 2733 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
2706 err = nl80211_parse_chandef(rdev, info, &params.chandef); 2734 err = nl80211_parse_chandef(rdev, info, &params.chandef);
2707 if (err) 2735 if (err)
@@ -3668,6 +3696,8 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
3668 params.use_short_slot_time = -1; 3696 params.use_short_slot_time = -1;
3669 params.ap_isolate = -1; 3697 params.ap_isolate = -1;
3670 params.ht_opmode = -1; 3698 params.ht_opmode = -1;
3699 params.p2p_ctwindow = -1;
3700 params.p2p_opp_ps = -1;
3671 3701
3672 if (info->attrs[NL80211_ATTR_BSS_CTS_PROT]) 3702 if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
3673 params.use_cts_prot = 3703 params.use_cts_prot =
@@ -3690,6 +3720,32 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
3690 params.ht_opmode = 3720 params.ht_opmode =
3691 nla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]); 3721 nla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]);
3692 3722
3723 if (info->attrs[NL80211_ATTR_P2P_CTWINDOW]) {
3724 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
3725 return -EINVAL;
3726 params.p2p_ctwindow =
3727 nla_get_s8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]);
3728 if (params.p2p_ctwindow < 0)
3729 return -EINVAL;
3730 if (params.p2p_ctwindow != 0 &&
3731 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN))
3732 return -EINVAL;
3733 }
3734
3735 if (info->attrs[NL80211_ATTR_P2P_OPPPS]) {
3736 u8 tmp;
3737
3738 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
3739 return -EINVAL;
3740 tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]);
3741 if (tmp > 1)
3742 return -EINVAL;
3743 params.p2p_opp_ps = tmp;
3744 if (params.p2p_opp_ps &&
3745 !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS))
3746 return -EINVAL;
3747 }
3748
3693 if (!rdev->ops->change_bss) 3749 if (!rdev->ops->change_bss)
3694 return -EOPNOTSUPP; 3750 return -EOPNOTSUPP;
3695 3751