Re: [PATCH] cfg80211: Add support for user configurable beacon data rate

2016-08-26 Thread Johannes Berg
On Wed, 2016-08-24 at 12:30 +, Undekari, Sunil Dutt wrote:

> > It also doesn't check that you specified exactly one rate, but it's
> > not clear how else this would work?
> I can think of the following options here . 
> 1. Consider these rates as only the preference ( in order ) to the
> host driver , but the User space would have no way of knowing what
> the driver has selected.
> 2. Limit this beacon rate to only one . cfg80211 to verify that there
> is exactly one rate to be specified. 
> 
> Is option 2 a viable option ?
> 
Yeah, I think option 1 doesn't make much sense.

johannes


RE: [PATCH] cfg80211: Add support for user configurable beacon data rate

2016-08-24 Thread Undekari, Sunil Dutt
>It checks that everything matches up with capabilities, but it doesn't check 
>that if you specified NL80211_ATTR_TX_RATES you didn't do something stupid 
>like specifying it for 2.4GHz while your AP is >starting up on 5GHz.
Thanks for the suggestion . We shall ensure to consider the beacon rates 
configured on the specific band corresponding to the Channel on which the AP is 
getting started. nl80211_parse_tx_bitrate_mask shall anyways validate the 
beacon rates configured with the ones supported / advertised on a specific 
band. 

>It also doesn't check that you specified exactly one rate, but it's not clear 
>how else this would work?
I can think of the following options here . 
1. Consider these rates as only the preference ( in order ) to the host driver 
, but the User space would have no way of knowing what the driver has selected.
2. Limit this beacon rate to only one . cfg80211 to verify that there is 
exactly one rate to be specified. 

Is option 2 a viable option ?

Regards,
Sunil

-Original Message-
From: Johannes Berg [mailto:johan...@sipsolutions.net] 
Sent: Sunday, August 7, 2016 1:28 AM
To: Undekari, Sunil Dutt ; Kushwaha, Purushottam 

Cc: linux-wireless@vger.kernel.org; Malinen, Jouni ; 
Kondabattini, Ganesh ; Kalikot Veetil, Mahesh Kumar 
; Hullur Subramanyam, Amarnath 

Subject: Re: [PATCH] cfg80211: Add support for user configurable beacon data 
rate

On Sat, 2016-08-06 at 04:38 +, Undekari, Sunil Dutt wrote:
> > 
> > Doesn't this have to check that it actually got information for the 
> > right band?
> Hi Johannes ,
> nl80211_parse_tx_bitrate_mask ( a new wrapper to the existing 
> functionality in nl80211_set_tx_bitrate_mask ) does this , isn't ?
> 
It checks that everything matches up with capabilities, but it doesn't check 
that if you specified NL80211_ATTR_TX_RATES you didn't do something stupid like 
specifying it for 2.4GHz while your AP is starting up on 5GHz.

It also doesn't check that you specified exactly one rate, but it's not clear 
how else this would work?

johannes


RE: [PATCH] cfg80211: Add support for user configurable beacon data rate

2016-08-06 Thread Undekari, Sunil Dutt
> Doesn't this have to check that it actually got information for the right 
> band?
Hi Johannes ,
nl80211_parse_tx_bitrate_mask ( a new wrapper to the existing functionality in 
nl80211_set_tx_bitrate_mask ) does this , isn't ? 

Regards,
Sunil



-Original Message-
From: Johannes Berg [mailto:johan...@sipsolutions.net] 
Sent: Friday, August 5, 2016 2:33 PM
To: Kushwaha, Purushottam 
Cc: linux-wireless@vger.kernel.org; Malinen, Jouni ; 
Undekari, Sunil Dutt ; Kondabattini, Ganesh 
; Kalikot Veetil, Mahesh Kumar 
; Hullur Subramanyam, Amarnath 

Subject: Re: [PATCH] cfg80211: Add support for user configurable beacon data 
rate

On Fri, 2016-08-05 at 10:05 +0530, Purushottam Kushwaha wrote:
> 
> +static int nl80211_parse_tx_bitrate_mask(struct genl_info *info,
> +  struct cfg80211_bitrate_mask *mask);

I think you should move the function instead.

> @@ -3457,6 +3459,11 @@ static int nl80211_start_ap(struct sk_buff 
> *skb, struct genl_info *info)
>   err = cfg80211_validate_beacon_int(rdev,
> params.beacon_interval);
>   if (err)
>   return err;
> + if (info->attrs[NL80211_ATTR_TX_RATES]) {
> + err = nl80211_parse_tx_bitrate_mask(info,
> ¶ms.beacon_rate);
> + if (err)
> + return err;
> + }

Doesn't this have to check that it actually got information for the right band?

johannes
N�r��yb�X��ǧv�^�)޺{.n�+{��*ޕ�,�{ay�ʇڙ�,j��f���h���z��w���
���j:+v���w�j�mzZ+�ݢj"��!�i

Re: [PATCH] cfg80211: Add support for user configurable beacon data rate

2016-08-06 Thread Johannes Berg
On Sat, 2016-08-06 at 04:38 +, Undekari, Sunil Dutt wrote:
> > 
> > Doesn't this have to check that it actually got information for the
> > right band?
> Hi Johannes ,
> nl80211_parse_tx_bitrate_mask ( a new wrapper to the existing
> functionality in nl80211_set_tx_bitrate_mask ) does this , isn't ? 
> 
It checks that everything matches up with capabilities, but it doesn't
check that if you specified NL80211_ATTR_TX_RATES you didn't do
something stupid like specifying it for 2.4GHz while your AP is
starting up on 5GHz.

It also doesn't check that you specified exactly one rate, but it's not
clear how else this would work?

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cfg80211: Add support for user configurable beacon data rate

2016-08-05 Thread Johannes Berg
On Fri, 2016-08-05 at 10:05 +0530, Purushottam Kushwaha wrote:
> 
> +static int nl80211_parse_tx_bitrate_mask(struct genl_info *info,
> +  struct cfg80211_bitrate_mask *mask);

I think you should move the function instead.

> @@ -3457,6 +3459,11 @@ static int nl80211_start_ap(struct sk_buff
> *skb, struct genl_info *info)
>   err = cfg80211_validate_beacon_int(rdev,
> params.beacon_interval);
>   if (err)
>   return err;
> + if (info->attrs[NL80211_ATTR_TX_RATES]) {
> + err = nl80211_parse_tx_bitrate_mask(info,
> ¶ms.beacon_rate);
> + if (err)
> + return err;
> + }

Doesn't this have to check that it actually got information for the
right band?

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cfg80211: Add support for user configurable beacon data rate

2016-08-04 Thread Purushottam Kushwaha
This will allow user to configure beacon tx rate (u8) from userspace.

Signed-off-by: Purushottam Kushwaha 
---
 include/net/cfg80211.h | 25 +++-
 net/wireless/nl80211.c | 62 +-
 2 files changed, 55 insertions(+), 32 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9c23f4d3..dd900de 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -676,6 +676,18 @@ struct cfg80211_acl_data {
struct mac_address mac_addrs[];
 };
 
+/*
+ * cfg80211_bitrate_mask - masks for bitrate control
+ */
+struct cfg80211_bitrate_mask {
+   struct {
+   u32 legacy;
+   u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
+   u16 vht_mcs[NL80211_VHT_NSS_MAX];
+   enum nl80211_txrate_gi gi;
+   } control[NUM_NL80211_BANDS];
+};
+
 /**
  * struct cfg80211_ap_settings - AP configuration
  *
@@ -700,6 +712,7 @@ struct cfg80211_acl_data {
  * MAC address based access control
  * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
  * networks.
+ * @beacon_rate: masks for setting user configured beacon tx rate.
  */
 struct cfg80211_ap_settings {
struct cfg80211_chan_def chandef;
@@ -719,6 +732,7 @@ struct cfg80211_ap_settings {
bool p2p_opp_ps;
const struct cfg80211_acl_data *acl;
bool pbss;
+   struct cfg80211_bitrate_mask beacon_rate;
 };
 
 /**
@@ -2001,17 +2015,6 @@ enum wiphy_params_flags {
WIPHY_PARAM_DYN_ACK = 1 << 5,
 };
 
-/*
- * cfg80211_bitrate_mask - masks for bitrate control
- */
-struct cfg80211_bitrate_mask {
-   struct {
-   u32 legacy;
-   u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
-   u16 vht_mcs[NL80211_VHT_NSS_MAX];
-   enum nl80211_txrate_gi gi;
-   } control[NUM_NL80211_BANDS];
-};
 /**
  * struct cfg80211_pmksa - PMK Security Association
  *
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 46417f9..53e7bf5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -36,6 +36,8 @@ static int nl80211_pre_doit(const struct genl_ops *ops, 
struct sk_buff *skb,
struct genl_info *info);
 static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
  struct genl_info *info);
+static int nl80211_parse_tx_bitrate_mask(struct genl_info *info,
+struct cfg80211_bitrate_mask *mask);
 
 /* the netlink family */
 static struct genl_family nl80211_fam = {
@@ -3457,6 +3459,11 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
genl_info *info)
err = cfg80211_validate_beacon_int(rdev, params.beacon_interval);
if (err)
return err;
+   if (info->attrs[NL80211_ATTR_TX_RATES]) {
+   err = nl80211_parse_tx_bitrate_mask(info, ¶ms.beacon_rate);
+   if (err)
+   return err;
+   }
 
/*
 * In theory, some of these attributes should be required here
@@ -8696,22 +8703,17 @@ static const struct nla_policy 
nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = {
[NL80211_TXRATE_GI] = { .type = NLA_U8 },
 };
 
-static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
-  struct genl_info *info)
+static int nl80211_parse_tx_bitrate_mask(struct genl_info *info,
+struct cfg80211_bitrate_mask *mask)
 {
struct nlattr *tb[NL80211_TXRATE_MAX + 1];
struct cfg80211_registered_device *rdev = info->user_ptr[0];
-   struct cfg80211_bitrate_mask mask;
int rem, i;
-   struct net_device *dev = info->user_ptr[1];
struct nlattr *tx_rates;
struct ieee80211_supported_band *sband;
u16 vht_tx_mcs_map;
 
-   if (!rdev->ops->set_bitrate_mask)
-   return -EOPNOTSUPP;
-
-   memset(&mask, 0, sizeof(mask));
+   memset(mask, 0, sizeof(*mask));
/* Default to all rates enabled */
for (i = 0; i < NUM_NL80211_BANDS; i++) {
sband = rdev->wiphy.bands[i];
@@ -8719,16 +8721,16 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff 
*skb,
if (!sband)
continue;
 
-   mask.control[i].legacy = (1 << sband->n_bitrates) - 1;
-   memcpy(mask.control[i].ht_mcs,
+   mask->control[i].legacy = (1 << sband->n_bitrates) - 1;
+   memcpy(mask->control[i].ht_mcs,
   sband->ht_cap.mcs.rx_mask,
-  sizeof(mask.control[i].ht_mcs));
+  sizeof(mask->control[i].ht_mcs));
 
if (!sband->vht_cap.vht_supported)
continue;
 
vht_tx_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map);
-   vht_build_mcs_mask(vht_tx_mcs_map, mask.control[i].vht_mcs);
+   vht_build_mcs_mask(v

Re: [PATCH] cfg80211: Add support for user configurable beacon data rate

2016-07-08 Thread Johannes Berg
On Fri, 2016-07-08 at 15:58 +0530, Purushottam Kushwaha wrote:
> 
>   *
> + * @NL80211_ATTR_BEACON_TXRATE: User configurable beacon data rate
> (u32). This is
> + *   used to set beacon tx rate.
> 
It seems this should be nested from enum nl80211_tx_rate_attributes, to
perhaps allow HT/VHT beacons in the future.

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cfg80211: Add support for user configurable beacon data rate

2016-07-08 Thread Purushottam Kushwaha
This will allow user to configure beacon tx rate from userspace. This adds
new nl80211 attribute as NL80211_ATTR_BEACON_RATE.

Signed-off-by: Purushottam Kushwaha 
---
 include/net/cfg80211.h   | 3 ++-
 include/uapi/linux/nl80211.h | 5 +
 net/wireless/nl80211.c   | 5 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9c23f4d3..ad0200b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -685,6 +685,7 @@ struct cfg80211_acl_data {
  * @beacon: beacon data
  * @beacon_interval: beacon interval
  * @dtim_period: DTIM period
+ * @beacon_txrate: beacon tx rate
  * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
  * user space)
  * @ssid_len: length of @ssid
@@ -706,7 +707,7 @@ struct cfg80211_ap_settings {
 
struct cfg80211_beacon_data beacon;
 
-   int beacon_interval, dtim_period;
+   int beacon_interval, dtim_period, beacon_txrate;
const u8 *ssid;
size_t ssid_len;
enum nl80211_hidden_ssid hidden_ssid;
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 2206941..f338909 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1867,6 +1867,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_MESH_PEER_AID: Association ID for the mesh peer (u16). This is
  * used to pull the stored data for mesh peer in power save state.
  *
+ * @NL80211_ATTR_BEACON_TXRATE: User configurable beacon data rate (u32). This 
is
+ * used to set beacon tx rate.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2261,6 +2264,8 @@ enum nl80211_attrs {
 
NL80211_ATTR_MESH_PEER_AID,
 
+   NL80211_ATTR_BEACON_TXRATE,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5782f71..020b753 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -409,6 +409,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {
.len = VHT_MUMIMO_GROUPS_DATA_LEN
},
[NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR] = { .len = ETH_ALEN },
+   [NL80211_ATTR_BEACON_TXRATE] = { .type = NLA_U32 },
 };
 
 /* policy for the key attributes */
@@ -3568,6 +3569,10 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
genl_info *info)
params.smps_mode = NL80211_SMPS_OFF;
}
 
+   if (info->attrs[NL80211_ATTR_BEACON_TXRATE])
+   params.beacon_txrate =
+   nla_get_u32(info->attrs[NL80211_ATTR_BEACON_TXRATE]);
+
if (info->attrs[NL80211_ATTR_ACL_POLICY]) {
params.acl = parse_acl_data(&rdev->wiphy, info);
if (IS_ERR(params.acl))
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html