Re: [PATCH v2 11/13] cfg80211: read wmm rules from regulatory database

2018-02-28 Thread Johannes Berg
On Tue, 2018-02-27 at 16:19 -0600, Seth Forshee wrote:
> 
> I think it looks okay, but I guess there will be new patches so I will
> take another look then. Is there an example of the db.txt updates for
> the WMM rules?

I'm not sure we have a full db.txt update yet, but Haim definitely has
a patch for the parser, and will send them out soon :)

johannes


Re: [PATCH v2 11/13] cfg80211: read wmm rules from regulatory database

2018-02-27 Thread Seth Forshee
On Mon, Feb 19, 2018 at 02:30:33PM +0100, Johannes Berg wrote:
> On Mon, 2018-02-19 at 14:48 +0200, Luca Coelho wrote:
> > From: Haim Dreyfuss 
> > 
> > ETSI EN 301 893 v211 (2017-05) standard defines a new channel access
> > mechanism that all devices (WLAN and LAA) need to comply with.
> > The regulatory database can now be loaded into the kernel and also
> > has the option to load optional data.
> > In order to be able to comply with ETSI standard, we add wmm_rule into
> > regulatory rule and add the option to read its value from the regulatory
> > database.
> 
> Seth, this is going to come with an update to the regdb as well. I'd
> appreciate if you could take a look.

I think it looks okay, but I guess there will be new patches so I will
take another look then. Is there an example of the db.txt updates for
the WMM rules?

Seth


Re: [PATCH v2 11/13] cfg80211: read wmm rules from regulatory database

2018-02-19 Thread Johannes Berg
On Mon, 2018-02-19 at 14:48 +0200, Luca Coelho wrote:
> From: Haim Dreyfuss 
> 
> ETSI EN 301 893 v211 (2017-05) standard defines a new channel access
> mechanism that all devices (WLAN and LAA) need to comply with.
> The regulatory database can now be loaded into the kernel and also
> has the option to load optional data.
> In order to be able to comply with ETSI standard, we add wmm_rule into
> regulatory rule and add the option to read its value from the regulatory
> database.

Seth, this is going to come with an update to the regdb as well. I'd
appreciate if you could take a look.

Thanks,
johannes


[PATCH v2 11/13] cfg80211: read wmm rules from regulatory database

2018-02-19 Thread Luca Coelho
From: Haim Dreyfuss 

ETSI EN 301 893 v211 (2017-05) standard defines a new channel access
mechanism that all devices (WLAN and LAA) need to comply with.
The regulatory database can now be loaded into the kernel and also
has the option to load optional data.
In order to be able to comply with ETSI standard, we add wmm_rule into
regulatory rule and add the option to read its value from the regulatory
database.

Signed-off-by: Haim Dreyfuss 
Signed-off-by: Luca Coelho 
---
 include/net/regulatory.h |  28 +
 net/wireless/reg.c   | 146 ---
 2 files changed, 167 insertions(+), 7 deletions(-)

diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index ebc5a2ed8631..355b23ad146c 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -4,6 +4,7 @@
  * regulatory support structures
  *
  * Copyright 2008-2009 Luis R. Rodriguez 
+ * Copyright (C) 2018 Intel Corporation
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -188,9 +189,35 @@ struct ieee80211_power_rule {
u32 max_eirp;
 };
 
+/**
+ * struct ieee80211_wmm_ac - used to store per ac wmm regulatory limitation
+ *
+ * The information provided in this structure is required for QoS
+ * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
+ *
+ * @cw_min: minimum contention window [a value of the form
+ *  2^n-1 in the range 1..32767]
+ * @cw_max: maximum contention window [like @cw_min]
+ * @cot: maximum burst time in units of 32 usecs, 0 meaning disabled
+ * @aifsn: arbitration interframe space [0..255]
+ *
+ */
+struct ieee80211_wmm_ac {
+   u16 cw_min;
+   u16 cw_max;
+   u16 cot;
+   u8 aifsn;
+};
+
+struct ieee80211_wmm_rule {
+   struct ieee80211_wmm_ac client[IEEE80211_NUM_ACS];
+   struct ieee80211_wmm_ac ap[IEEE80211_NUM_ACS];
+};
+
 struct ieee80211_reg_rule {
struct ieee80211_freq_range freq_range;
struct ieee80211_power_rule power_rule;
+   struct ieee80211_wmm_rule *wmm_rule;
u32 flags;
u32 dfs_cac_ms;
 };
@@ -198,6 +225,7 @@ struct ieee80211_reg_rule {
 struct ieee80211_regdomain {
struct rcu_head rcu_head;
u32 n_reg_rules;
+   u32 n_wmm_rules;
char alpha2[3];
enum nl80211_dfs_regions dfs_region;
struct ieee80211_reg_rule reg_rules[];
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 7b42f0bacfd8..7c7c0e0f8d9d 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -5,6 +5,7 @@
  * Copyright 2008-2011 Luis R. Rodriguez 
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright  2017  Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -424,23 +425,36 @@ static const struct ieee80211_regdomain *
 reg_copy_regd(const struct ieee80211_regdomain *src_regd)
 {
struct ieee80211_regdomain *regd;
-   int size_of_regd;
+   int size_of_regd, size_of_wmms;
unsigned int i;
+   struct ieee80211_wmm_rule *d_wmm, *s_wmm;
 
size_of_regd =
sizeof(struct ieee80211_regdomain) +
src_regd->n_reg_rules * sizeof(struct ieee80211_reg_rule);
+   size_of_wmms = src_regd->n_wmm_rules *
+   sizeof(struct ieee80211_wmm_rule);
 
-   regd = kzalloc(size_of_regd, GFP_KERNEL);
+   regd = kzalloc(size_of_regd + size_of_wmms, GFP_KERNEL);
if (!regd)
return ERR_PTR(-ENOMEM);
 
memcpy(regd, src_regd, sizeof(struct ieee80211_regdomain));
 
-   for (i = 0; i < src_regd->n_reg_rules; i++)
+   d_wmm = (struct ieee80211_wmm_rule *)((u8 *)regd + size_of_regd);
+   s_wmm = (struct ieee80211_wmm_rule *)((u8 *)src_regd + size_of_regd);
+   memcpy(d_wmm, s_wmm, size_of_wmms);
+
+   for (i = 0; i < src_regd->n_reg_rules; i++) {
memcpy(>reg_rules[i], _regd->reg_rules[i],
   sizeof(struct ieee80211_reg_rule));
+   if (!src_regd->reg_rules[i].wmm_rule)
+   continue;
 
+   regd->reg_rules[i].wmm_rule = d_wmm +
+   (src_regd->reg_rules[i].wmm_rule - s_wmm) /
+   sizeof(struct ieee80211_wmm_rule);
+   }
return regd;
 }
 
@@ -595,6 +609,17 @@ enum fwdb_flags {
FWDB_FLAG_AUTO_BW   = BIT(4),
 };
 
+struct fwdb_wmm_ac {
+   u8 ecw;
+   u8 aifsn;
+   __be16 cot;
+} __packed;
+
+struct fwdb_wmm_rule {
+   struct fwdb_wmm_ac client[IEEE80211_NUM_ACS];
+   struct fwdb_wmm_ac ap[IEEE80211_NUM_ACS];
+} __packed;
+
 struct fwdb_rule {
u8 len;
u8 flags;
@@ -602,6