[RFC] mac80211: add stop/start logic for software TXQs

2018-05-18 Thread Manikanta Pubbisetty
Sometimes, it is required to stop the transmissions momentarily and
resume it later; stopping the txqs becomes very critical in scenarios where
the packet transmission has to be ceased completely. For example, during
the hardware restart, during off channel operations,
when initiating CSA(upon detecting a radar on the DFS channel), etc.

The TX queue stop/start logic in mac80211 works well in stopping the TX
when drivers make use of netdev queues, i.e, when Qdiscs in network layer
take care of traffic scheduling. Since the devices implementing
wake_tx_queue run without Qdiscs, packets will be handed to mac80211
directly without queueing them in the netdev queues. Also, mac80211
does not invoke any of the netif_stop_*/netif_wake_* APIs to stop the
transmissions and this might very well lead to undesirabled things.

For example,
During hardware restart, we stop the netdev queues so that packets are
not sent to the driver. Since ath10k implements wake_tx_queue,
TX queues will not be stopped and packets might reach the hardware while
it is restarting; this can make hardware unresponsive and can be
recovered only by rebooting the system.

There is another problem to this, it is observed that the packets
were sent on the DFS channel for a prolonged duration after radar detection
impacting the channel closing times.

We can still invoke netif stop/wake APIs when wake_tx_queue is implemented
but this could lead to packet drops in network layer; adding stop/start
logic for software TXQs in mac80211 instead makes more sense; the change
proposed adds the same in mac80211.

Signed-off-by: Manikanta Pubbisetty 
---
 net/mac80211/agg-tx.c  | 4 
 net/mac80211/ieee80211_i.h | 5 +
 net/mac80211/sta_info.c| 3 +++
 net/mac80211/tx.c  | 3 +++
 net/mac80211/util.c| 7 ++-
 5 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 595c662..7cfec25 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -213,11 +213,15 @@ static void
 ieee80211_agg_start_txq(struct sta_info *sta, int tid, bool enable)
 {
struct ieee80211_txq *txq = sta->sta.txq[tid];
+   struct ieee80211_local *local = sta->local;
struct txq_info *txqi;
 
if (!txq)
return;
 
+   if (local->txqs_stopped)
+   return;
+
txqi = to_txq_info(txq);
 
if (enable)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index d1978aa..dd64e8c 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1137,6 +1137,11 @@ struct ieee80211_local {
/* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
spinlock_t queue_stop_reason_lock;
 
+   /* pause/resume logic for intermediate software queues,
+* applicable when wake_tx_queue is defined.
+*/
+   unsigned long txqs_stopped;
+
int open_count;
int monitors, cooked_mntrs;
/* number of interfaces with corresponding FIF_ flags */
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 6428f1a..03ea152 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1244,6 +1244,9 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
if (!txq_has_queue(sta->sta.txq[i]))
continue;
 
+   if (local->txqs_stopped)
+   continue;
+
drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
}
}
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 8275a58..67156cb 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1559,6 +1559,9 @@ static bool ieee80211_queue_skb(struct ieee80211_local 
*local,
sdata->vif.type == NL80211_IFTYPE_MONITOR)
return false;
 
+   if (local->txqs_stopped)
+   return false;
+
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
 struct ieee80211_sub_if_data, u.ap);
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 2d82c88..da7ae8b 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -298,6 +298,9 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, 
int queue,
if (local->q_stop_reasons[queue][reason] == 0)
__clear_bit(reason, >queue_stop_reasons[queue]);
 
+   if (local->ops->wake_tx_queue)
+   __clear_bit(reason, >txqs_stopped);
+
if (local->queue_stop_reasons[queue] != 0)
/* someone still has this queue stopped */
return;
@@ -351,8 +354,10 @@ static void __ieee80211_stop_queue(struct ieee80211_hw 
*hw, int queue,
if (__test_and_set_bit(reason, >queue_stop_reasons[queue]))
return;
 
-   if (local->ops->wake_tx_queue)
+   if (local->ops->wake_tx_queue) {
+ 

Re: [PATCH] cfg80211: Fix support for flushing old scan results

2018-05-18 Thread Denis Kenzior

Hi Arend,

On 05/18/2018 01:54 PM, Arend van Spriel wrote:

On 5/18/2018 6:47 PM, Denis Kenzior wrote:

Hi Johannes,

On 05/18/2018 03:13 AM, Johannes Berg wrote:

On Fri, 2018-05-11 at 09:48 -0700, Tim Kourt wrote:

__cfg80211_bss_expire function was incorrectly used to flush the BSS
entries from the previous scan results, causing NL80211_SCAN_FLAG_FLUSH
flag to have no effect.


Hmm. I guess I'm not convinced - what's the bug?

We flush anything that's older than our start, so that should work just
fine?



Just FYI, there's definitely something funny with the scanning code:

denkenz@iwd-test ~ $ sudo iw dev wlp2s0 scan flush
BSS 10:c3:7b:54:74:d4(on wlp2s0)
 last seen: 274.815s [boottime]
 freq: 5765
 beacon interval: 100 TUs
 signal: -35.00 dBm
 last seen: 349 ms ago
 Information elements from Probe Response frame:
 SSID: \x00\x00\x00\x00\x00\x00\x00\x00\x00


Then if I try:
denkenz@iwd-test ~ $ sudo iw dev wlp2s0 scan flush ssid myssid
BSS 10:c3:7b:54:74:d4(on wlp2s0)
 last seen: 319.667s [boottime]
 freq: 5765
 beacon interval: 100 TUs
 signal: -42.00 dBm
 last seen: 350 ms ago
 Information elements from Probe Response frame:
 SSID: \x00\x00\x00\x00\x00\x00\x00\x00\x00

BSS 10:c3:7b:54:74:d4(on wlp2s0)
 last seen: 319.662s [boottime]
 freq: 5765
 beacon interval: 100 TUs
 signal: -37.00 dBm
 last seen: 355 ms ago
 Information elements from Probe Response frame:
 SSID: myssid

Shouldn't the second scan give a single result from that one BSS?


Looking at the 'last seen' values it does look ok. Both results have the 
same BSSID, but the first one shows the broadcast ssid (or so it seems). 


Are you saying the first result is from the Beacon and the other is from 
the Probe Response?  Then why are the 'Information elements from Probe 
Response frame' the way they are?


Neither iw nor nl80211 on the kernel side add the broadcast ssid. So 
question is what device are you using and does it use mac80211 software 


Intel 7260.  We're seeing the same results with hwsim as well though. 
This was just a quick test to illustrate.


scanning or hardware scanning. I did not dive into mac80211 to see if 
the broadcast ssid is added there.


By the way, if you're interested.  The same tests with a Broadcom based 
device wouldn't even find the hidden network.  It would always come back 
with a single 'x00' SSID regardless of whether I added 'ssid myssid' at 
the end.


Regards,
-Denis


Re: [PATCH] cfg80211: Fix support for flushing old scan results

2018-05-18 Thread Arend van Spriel

On 5/18/2018 6:47 PM, Denis Kenzior wrote:

Hi Johannes,

On 05/18/2018 03:13 AM, Johannes Berg wrote:

On Fri, 2018-05-11 at 09:48 -0700, Tim Kourt wrote:

__cfg80211_bss_expire function was incorrectly used to flush the BSS
entries from the previous scan results, causing NL80211_SCAN_FLAG_FLUSH
flag to have no effect.


Hmm. I guess I'm not convinced - what's the bug?

We flush anything that's older than our start, so that should work just
fine?



Just FYI, there's definitely something funny with the scanning code:

denkenz@iwd-test ~ $ sudo iw dev wlp2s0 scan flush
BSS 10:c3:7b:54:74:d4(on wlp2s0)
 last seen: 274.815s [boottime]
 freq: 5765
 beacon interval: 100 TUs
 signal: -35.00 dBm
 last seen: 349 ms ago
 Information elements from Probe Response frame:
 SSID: \x00\x00\x00\x00\x00\x00\x00\x00\x00


Then if I try:
denkenz@iwd-test ~ $ sudo iw dev wlp2s0 scan flush ssid myssid
BSS 10:c3:7b:54:74:d4(on wlp2s0)
 last seen: 319.667s [boottime]
 freq: 5765
 beacon interval: 100 TUs
 signal: -42.00 dBm
 last seen: 350 ms ago
 Information elements from Probe Response frame:
 SSID: \x00\x00\x00\x00\x00\x00\x00\x00\x00

BSS 10:c3:7b:54:74:d4(on wlp2s0)
 last seen: 319.662s [boottime]
 freq: 5765
 beacon interval: 100 TUs
 signal: -37.00 dBm
 last seen: 355 ms ago
 Information elements from Probe Response frame:
 SSID: myssid

Shouldn't the second scan give a single result from that one BSS?


Looking at the 'last seen' values it does look ok. Both results have the 
same BSSID, but the first one shows the broadcast ssid (or so it seems). 
Neither iw nor nl80211 on the kernel side add the broadcast ssid. So 
question is what device are you using and does it use mac80211 software 
scanning or hardware scanning. I did not dive into mac80211 to see if 
the broadcast ssid is added there.


Regards,
Arend


[PATCH] wireless-regdb: Fix iteration in create_wmms() for python 3

2018-05-18 Thread Seth Forshee
The iteration in this function is over countries.itervalues(),
which is not compatible with python 3. Switch to iterating over
contries.values() instead.

Signed-off-by: Seth Forshee 
---
 db2fw.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/db2fw.py b/db2fw.py
index 269325604ea3..0c0f030c0c63 100755
--- a/db2fw.py
+++ b/db2fw.py
@@ -29,7 +29,7 @@ def create_collections(countries):
 
 def create_wmms(countries):
 result = {}
-for c in countries.itervalues():
+for c in countries.values():
 for rule in c.permissions:
 if rule.wmmrule is not None:
 result[rule.wmmrule] = 1
-- 
2.17.0



Re: [PATCH] cfg80211: Fix support for flushing old scan results

2018-05-18 Thread Denis Kenzior

Hi Johannes,

On 05/18/2018 03:13 AM, Johannes Berg wrote:

On Fri, 2018-05-11 at 09:48 -0700, Tim Kourt wrote:

__cfg80211_bss_expire function was incorrectly used to flush the BSS
entries from the previous scan results, causing NL80211_SCAN_FLAG_FLUSH
flag to have no effect.


Hmm. I guess I'm not convinced - what's the bug?

We flush anything that's older than our start, so that should work just
fine?



Just FYI, there's definitely something funny with the scanning code:

denkenz@iwd-test ~ $ sudo iw dev wlp2s0 scan flush
BSS 10:c3:7b:54:74:d4(on wlp2s0)
last seen: 274.815s [boottime]
freq: 5765
beacon interval: 100 TUs
signal: -35.00 dBm
last seen: 349 ms ago
Information elements from Probe Response frame:
SSID: \x00\x00\x00\x00\x00\x00\x00\x00\x00


Then if I try:
denkenz@iwd-test ~ $ sudo iw dev wlp2s0 scan flush ssid myssid
BSS 10:c3:7b:54:74:d4(on wlp2s0)
last seen: 319.667s [boottime]
freq: 5765
beacon interval: 100 TUs
signal: -42.00 dBm
last seen: 350 ms ago
Information elements from Probe Response frame:
SSID: \x00\x00\x00\x00\x00\x00\x00\x00\x00

BSS 10:c3:7b:54:74:d4(on wlp2s0)
last seen: 319.662s [boottime]
freq: 5765
beacon interval: 100 TUs
signal: -37.00 dBm
last seen: 355 ms ago
Information elements from Probe Response frame:
SSID: myssid

Shouldn't the second scan give a single result from that one BSS?

Regards,
-Denis


[PATCH 2/3] MAINTAINERS: change Kalle as ath.ko maintainer

2018-05-18 Thread Kalle Valo
Luis hasn't worked on ath.ko for some time now.

Acked-by: Luis R. Rodriguez 
Signed-off-by: Kalle Valo 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4be9ff892ec0..5dace1734086 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2330,7 +2330,7 @@ F:drivers/gpio/gpio-ath79.c
 F: Documentation/devicetree/bindings/gpio/gpio-ath79.txt
 
 ATHEROS ATH GENERIC UTILITIES
-M: "Luis R. Rodriguez" 
+M: Kalle Valo 
 L: linux-wireless@vger.kernel.org
 S: Supported
 F: drivers/net/wireless/ath/*
-- 
2.7.4



[PATCH 1/3] MAINTAINERS: update Kalle's email address

2018-05-18 Thread Kalle Valo
I switched to use my codeaurora.org address.

Signed-off-by: Kalle Valo 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6d21f2f74578..4be9ff892ec0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2345,7 +2345,7 @@ S:Maintained
 F: drivers/net/wireless/ath/ath5k/
 
 ATHEROS ATH6KL WIRELESS DRIVER
-M: Kalle Valo 
+M: Kalle Valo 
 L: linux-wireless@vger.kernel.org
 W: http://wireless.kernel.org/en/users/Drivers/ath6kl
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
@@ -11651,7 +11651,7 @@ S:  Maintained
 F: drivers/media/tuners/qt1010*
 
 QUALCOMM ATHEROS ATH10K WIRELESS DRIVER
-M: Kalle Valo 
+M: Kalle Valo 
 L: ath...@lists.infradead.org
 W: http://wireless.kernel.org/en/users/Drivers/ath10k
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
-- 
2.7.4



[PATCH 3/3] MAINTAINERS: change Kalle as wcn36xx maintainer

2018-05-18 Thread Kalle Valo
Eugene hasn't worked on wcn36xx for some time now.

Signed-off-by: Kalle Valo 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5dace1734086..c1b15dde5a46 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11702,7 +11702,7 @@ S:  Maintained
 F: drivers/media/platform/qcom/venus/
 
 QUALCOMM WCN36XX WIRELESS DRIVER
-M: Eugene Krasnikov 
+M: Kalle Valo 
 L: wcn3...@lists.infradead.org
 W: http://wireless.kernel.org/en/users/Drivers/wcn36xx
 T: git git://github.com/KrasnikovEugene/wcn36xx.git
-- 
2.7.4



Re: [PATCH v3] NFC: pn533: don't send USB data off of the stack

2018-05-18 Thread Johan Hovold
On Fri, May 18, 2018 at 12:38:11PM +0200, Greg Kroah-Hartman wrote:
> It's amazing that this driver ever worked, but now that x86 doesn't
> allow USB data to be sent off of the stack, it really does not work at
> all.  Fix this up by properly allocating the data for the small
> "commands" that get sent to the device.
> 
> The USB stack will free the buffer when the data has been transmitted,
> that is why there is no kfree() to mirror the call to kmalloc().

It looks like you're now leaking all but the final transfer buffer that
is allocated for outgoing commands, as the URBs themselves are not freed
until disconnect() (and that's when core would free the buffers along
with the URBs if URB_FREE_BUFFER is set).

Johan


[mac80211-next:master 20/20] net/wireless/nl80211.c:4802:48: sparse: incorrect type in argument 1 (different base types)

2018-05-18 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 
master
head:   7ea3e110f2f8ba23f330c2f702f556acd539bcb8
commit: 7ea3e110f2f8ba23f330c2f702f556acd539bcb8 [20/20] cfg80211: release 
station info tidstats where needed
reproduce:
# apt-get install sparse
git checkout 7ea3e110f2f8ba23f330c2f702f556acd539bcb8
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> net/wireless/nl80211.c:4802:48: sparse: incorrect type in argument 1 
>> (different base types) @@expected struct station_info *sinfo @@got 
>> struct statiostruct station_info *sinfo @@
   net/wireless/nl80211.c:4802:48:expected struct station_info *sinfo
   net/wireless/nl80211.c:4802:48:got struct station_info [addressable] 
sinfo
   net/wireless/nl80211.c:7587:33: sparse: expression using sizeof(void)
   net/wireless/nl80211.c:7587:33: sparse: expression using sizeof(void)
   net/wireless/nl80211.c: In function 'nl80211_get_station':
   net/wireless/nl80211.c:4802:34: error: incompatible type for argument 1 of 
'cfg80211_sinfo_release_content'
  cfg80211_sinfo_release_content(sinfo);
 ^
   In file included from net/wireless/nl80211.c:24:0:
   include/net/cfg80211.h:5721:20: note: expected 'struct station_info *' but 
argument is of type 'struct station_info'
static inline void cfg80211_sinfo_release_content(struct station_info 
*sinfo)
   ^~

vim +4802 net/wireless/nl80211.c

  4776  
  4777  static int nl80211_get_station(struct sk_buff *skb, struct genl_info 
*info)
  4778  {
  4779  struct cfg80211_registered_device *rdev = info->user_ptr[0];
  4780  struct net_device *dev = info->user_ptr[1];
  4781  struct station_info sinfo;
  4782  struct sk_buff *msg;
  4783  u8 *mac_addr = NULL;
  4784  int err;
  4785  
  4786  memset(, 0, sizeof(sinfo));
  4787  
  4788  if (!info->attrs[NL80211_ATTR_MAC])
  4789  return -EINVAL;
  4790  
  4791  mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
  4792  
  4793  if (!rdev->ops->get_station)
  4794  return -EOPNOTSUPP;
  4795  
  4796  err = rdev_get_station(rdev, dev, mac_addr, );
  4797  if (err)
  4798  return err;
  4799  
  4800  msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  4801  if (!msg) {
> 4802  cfg80211_sinfo_release_content(sinfo);
  4803  return -ENOMEM;
  4804  }
  4805  
  4806  if (nl80211_send_station(msg, NL80211_CMD_NEW_STATION,
  4807   info->snd_portid, info->snd_seq, 0,
  4808   rdev, dev, mac_addr, ) < 0) {
  4809  nlmsg_free(msg);
  4810  return -ENOBUFS;
  4811  }
  4812  
  4813  return genlmsg_reply(msg, info);
  4814  }
  4815  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


[PATCH] wireless-regdb: Fix comparison of WmmRule with NoneType in python 3

2018-05-18 Thread Seth Forshee
Python 3 gives errors as a result of the changes to add wmm
rules since Permission.wmmrule can be set to None:

 TypeError: '<' not supported between instances of 'WmmRule' and 'NoneType'

To fix this, supply compairson methods for WmmRule instead of
using the ones provided by attrs. Doing this means we also need
to supply a __hash__ method.

Signed-off-by: Seth Forshee 
---
 dbparse.py | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/dbparse.py b/dbparse.py
index 5cb8b3f13266..5fe752b4ff31 100755
--- a/dbparse.py
+++ b/dbparse.py
@@ -32,7 +32,7 @@ dfs_regions = {
 
 @total_ordering
 
-@attr.s(frozen=True)
+@attr.s(frozen=True, cmp=False)
 class WmmRule(object):
 vo_c = attr.ib()
 vi_c = attr.ib()
@@ -47,6 +47,22 @@ class WmmRule(object):
 return (self.vo_c, self.vi_c, self.be_c, self.bk_c,
 self.vo_ap, self.vi_ap, self.be_ap, self.bk_ap)
 
+def __eq__(self, other):
+if other is None:
+return False
+return (self._as_tuple() == other._as_tuple())
+
+def __ne__(self, other):
+return not (self == other)
+
+def __lt__(self, other):
+if other is None:
+return False
+return (self._as_tuple() < other._as_tuple())
+
+def __hash__(self):
+return hash(self._as_tuple())
+
 class FreqBand(object):
 def __init__(self, start, end, bw, comments=None):
 self.start = start
-- 
2.17.0



[PATCH] wireless-regdb: Update rules for Panama (PA) and add 60 GHz rule

2018-05-18 Thread Seth Forshee
Updates are based on the information in
http://www.asep.gob.pa/images/telecomunicaciones/Anexos/PNAF-dic2015.pdf.

Signed-off-by: Seth Forshee 
---
 db.txt | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/db.txt b/db.txt
index ed461a35b770..e3bbd374d096 100644
--- a/db.txt
+++ b/db.txt
@@ -963,11 +963,15 @@ country OM: DFS-ETSI
(5250 - 5330 @ 80), (20), DFS, AUTO-BW
(5490 - 5710 @ 160), (27), DFS
 
+# Source:
+# http://www.asep.gob.pa/images/telecomunicaciones/Anexos/PNAF-dic2015.pdf
 country PA: DFS-FCC
-   (2402 - 2472 @ 40), (30)
-   (5170 - 5250 @ 80), (17), AUTO-BW
-   (5250 - 5330 @ 80), (23), DFS, AUTO-BW
-   (5735 - 5835 @ 80), (30)
+   (2400 - 2483.5 @ 40), (36)
+   (5150 - 5250 @ 80), (36), AUTO-BW
+   (5250 - 5350 @ 80), (30), AUTO-BW
+   (5470 - 5725 @ 160), (30)
+   (5725 - 5850 @ 80), (36)
+   (57000 - 64000 @ 2160), (43)
 
 country PE: DFS-FCC
(2402 - 2482 @ 40), (20)
-- 
2.17.0



[RFC 2/3] radiotap: add structs for HE

2018-05-18 Thread Luca Coelho
From: Luca Coelho 

Add radiotap structures for HE.

Signed-off-by: Liad Kaufman 
Signed-off-by: Johannes Berg 
Signed-off-by: Ilan Peer 
Signed-off-by: Ido Yariv 
Signed-off-by: Luca Coelho 
---
 include/net/ieee80211_radiotap.h | 111 +++
 1 file changed, 111 insertions(+)

diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index 960236fb1681..2117b2cea598 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 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
@@ -72,6 +73,8 @@ enum ieee80211_radiotap_presence {
IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
IEEE80211_RADIOTAP_VHT = 21,
IEEE80211_RADIOTAP_TIMESTAMP = 22,
+   IEEE80211_RADIOTAP_HE = 23,
+   IEEE80211_RADIOTAP_HE_MU = 24,
 
/* valid in every it_present bitmap, even vendor namespaces */
IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
@@ -202,6 +205,114 @@ enum ieee80211_radiotap_timestamp_flags {
IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY = 0x02,
 };
 
+struct ieee80211_radiotap_he {
+   __le16 data1, data2, data3, data4, data5, data6;
+};
+
+enum ieee80211_radiotap_he_bits {
+   IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MASK = 3,
+   IEEE80211_RADIOTAP_HE_DATA1_FORMAT_SU   = 0,
+   IEEE80211_RADIOTAP_HE_DATA1_FORMAT_EXT_SU   = 1,
+   IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MU   = 2,
+   IEEE80211_RADIOTAP_HE_DATA1_FORMAT_TRIG = 3,
+
+   IEEE80211_RADIOTAP_HE_DATA1_BSS_COLOR_KNOWN = 0x0004,
+   IEEE80211_RADIOTAP_HE_DATA1_BEAM_CHANGE_KNOWN   = 0x0008,
+   IEEE80211_RADIOTAP_HE_DATA1_UL_DL_KNOWN = 0x0010,
+   IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN  = 0x0020,
+   IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN  = 0x0040,
+   IEEE80211_RADIOTAP_HE_DATA1_CODING_KNOWN= 0x0080,
+   IEEE80211_RADIOTAP_HE_DATA1_LDPC_XSYMSEG_KNOWN  = 0x0100,
+   IEEE80211_RADIOTAP_HE_DATA1_STBC_KNOWN  = 0x0200,
+   IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN= 0x0400,
+   IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE2_KNOWN   = 0x0800,
+   IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE3_KNOWN   = 0x1000,
+   IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE4_KNOWN   = 0x2000,
+   IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN   = 0x4000,
+   IEEE80211_RADIOTAP_HE_DATA1_DOPPLER_KNOWN   = 0x8000,
+
+   IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_KNOWN = 0x0001,
+   IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN= 0x0002,
+   IEEE80211_RADIOTAP_HE_DATA2_NUM_LTF_SYMS_KNOWN  = 0x0004,
+   IEEE80211_RADIOTAP_HE_DATA2_PRE_FEC_PAD_KNOWN   = 0x0008,
+   IEEE80211_RADIOTAP_HE_DATA2_TXBF_KNOWN  = 0x0010,
+   IEEE80211_RADIOTAP_HE_DATA2_PE_DISAMBIG_KNOWN   = 0x0020,
+   IEEE80211_RADIOTAP_HE_DATA2_TXOP_KNOWN  = 0x0040,
+   IEEE80211_RADIOTAP_HE_DATA2_MIDAMBLE_KNOWN  = 0x0080,
+   IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET   = 0x3f00,
+   IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET_KNOWN = 0x4000,
+   IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_SEC   = 0x8000,
+
+   IEEE80211_RADIOTAP_HE_DATA3_BSS_COLOR   = 0x003f,
+   IEEE80211_RADIOTAP_HE_DATA3_BEAM_CHANGE = 0x0040,
+   IEEE80211_RADIOTAP_HE_DATA3_UL_DL   = 0x0080,
+   IEEE80211_RADIOTAP_HE_DATA3_DATA_MCS= 0x0f00,
+   IEEE80211_RADIOTAP_HE_DATA3_DATA_DCM= 0x1000,
+   IEEE80211_RADIOTAP_HE_DATA3_CODING  = 0x2000,
+   IEEE80211_RADIOTAP_HE_DATA3_LDPC_XSYMSEG= 0x4000,
+   IEEE80211_RADIOTAP_HE_DATA3_STBC= 0x8000,
+
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC= 0x000f,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_20MHZ  = 0,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_40MHZ  = 1,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_80MHZ  = 2,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_160MHZ = 3,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_26T= 4,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_52T= 5,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_106T   = 6,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_242T   = 7,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_484T   = 8,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_996T   = 9,
+   IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_2x996T = 10,
+
+   

[RFC 3/3] mac80211: add support for HE

2018-05-18 Thread Luca Coelho
From: Luca Coelho 

Add support for HE in mac80211 conforming with P802.11ax_D1.4.

Signed-off-by: Liad Kaufman 
Signed-off-by: Johannes Berg 
Signed-off-by: Ilan Peer 
Signed-off-by: Ido Yariv 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/realtek/rtlwifi/base.c |   2 +-
 include/net/mac80211.h  |  64 -
 net/mac80211/Makefile   |   1 +
 net/mac80211/agg-rx.c   |   8 +-
 net/mac80211/agg-tx.c   |  19 +-
 net/mac80211/cfg.c  |   5 +
 net/mac80211/he.c   |  55 
 net/mac80211/ieee80211_i.h  |  16 ++
 net/mac80211/main.c |  19 +-
 net/mac80211/mlme.c | 277 +++-
 net/mac80211/rx.c   | 127 -
 net/mac80211/sta_info.c |  15 +-
 net/mac80211/sta_info.h |  20 +-
 net/mac80211/trace.h|   2 +-
 net/mac80211/util.c | 120 -
 15 files changed, 709 insertions(+), 41 deletions(-)
 create mode 100644 net/mac80211/he.c

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 762a29cdf7ad..32b5aa754c24 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1859,7 +1859,7 @@ void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv)
 reject_agg, ctrl_agg_size, agg_size);
 
rtlpriv->hw->max_rx_aggregation_subframes =
-   (ctrl_agg_size ? agg_size : IEEE80211_MAX_AMPDU_BUF);
+   (ctrl_agg_size ? agg_size : IEEE80211_MAX_AMPDU_BUF_HT);
 }
 EXPORT_SYMBOL(rtl_rx_ampdu_apply);
 
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 52f36c43f35f..55fd3a574682 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /**
@@ -162,6 +163,8 @@ enum ieee80211_ac_numbers {
  * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
  * @acm: is mandatory admission control required for the access category
  * @uapsd: is U-APSD mode enabled for the queue
+ * @mu_edca: is the MU EDCA configured
+ * @mu_edca_param_rec: MU EDCA Parameter Record for HE
  */
 struct ieee80211_tx_queue_params {
u16 txop;
@@ -170,6 +173,8 @@ struct ieee80211_tx_queue_params {
u8 aifs;
bool acm;
bool uapsd;
+   bool mu_edca;
+   struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec;
 };
 
 struct ieee80211_low_level_stats {
@@ -463,6 +468,15 @@ struct ieee80211_mu_group_data {
  * This structure keeps information about a BSS (and an association
  * to that BSS) that can change during the lifetime of the BSS.
  *
+ * @bss_color: 6-bit value to mark inter-BSS frame, if BSS supports HE
+ * @htc_trig_based_pkt_ext: default PE in 4us units, if BSS supports HE
+ * @multi_sta_back_32bit: supports BA bitmap of 32-bits in Multi-STA BACK
+ * @uora_exists: is the UORA element advertised by AP
+ * @ack_enabled_multitid: indicates support to receive a multi-TID that 
solicits
+ * either ACK, BACK or both
+ * @uora_ocw_range: UORA element's OCW Range field
+ * @frame_time_rts_th: HE duration RTS threshold, in units of 32us
+ * @he_support: does this BSS support HE
  * @assoc: association status
  * @ibss_joined: indicates whether this station is part of an IBSS
  * or not
@@ -550,6 +564,14 @@ struct ieee80211_mu_group_data {
  */
 struct ieee80211_bss_conf {
const u8 *bssid;
+   u8 bss_color;
+   u8 htc_trig_based_pkt_ext;
+   bool multi_sta_back_32bit;
+   bool uora_exists;
+   bool ack_enabled_multitid;
+   u8 uora_ocw_range;
+   u16 frame_time_rts_th;
+   bool he_support;
/* association related data */
bool assoc, ibss_joined;
bool ibss_creator;
@@ -1106,6 +1128,18 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info 
*info)
  * @RX_FLAG_AMPDU_EOF_BIT: Value of the EOF bit in the A-MPDU delimiter for 
this
  * frame
  * @RX_FLAG_AMPDU_EOF_BIT_KNOWN: The EOF value is known
+ * @RX_FLAG_RADIOTAP_HE: HE radiotap data is present
+ * ( ieee80211_radiotap_he, mac80211 will fill in
+ *  - DATA3_DATA_MCS
+ *  - DATA3_DATA_DCM
+ *  - DATA3_CODING
+ *  - DATA5_GI
+ *  - DATA5_DATA_BW_RU_ALLOC
+ *  - DATA6_NSTS
+ *  - DATA3_STBC
+ * from the RX info data, so leave those zeroed when building this data)
+ * @RX_FLAG_RADIOTAP_HE_MU: HE MU radiotap data is present
+ * ( ieee80211_radiotap_he_mu)
  */
 enum mac80211_rx_flags {
RX_FLAG_MMIC_ERROR  = BIT(0),
@@ -1134,6 +1168,8 @@ enum mac80211_rx_flags {
RX_FLAG_ICV_STRIPPED= BIT(23),

[RFC 1/3] cfg80211: Add support for HE

2018-05-18 Thread Luca Coelho
From: Luca Coelho 

Add support for the HE in cfg80211 and also add userspace API to
nl80211 to send rate information out, conforming with P802.11ax_D1.4.

Additionally, remove the IEEE80211_MAX_AMPDU_BUF definition from some
realtek drivers in staging because they are now conflicting with the
new definitions and are not used anyway.

Signed-off-by: Liad Kaufman 
Signed-off-by: Johannes Berg 
Signed-off-by: Ilan Peer 
Signed-off-by: Ido Yariv 
Signed-off-by: Luca Coelho 
---
 drivers/staging/rtl8188eu/include/wifi.h |   1 -
 drivers/staging/rtl8712/wifi.h   |   1 -
 drivers/staging/rtl8723bs/include/wifi.h |   1 -
 include/linux/ieee80211.h| 431 ++-
 include/net/cfg80211.h   | 102 +-
 include/uapi/linux/nl80211.h |  87 -
 net/wireless/core.c  |  21 +-
 net/wireless/nl80211.c   |  99 +-
 net/wireless/util.c  |  82 +
 9 files changed, 813 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/wifi.h 
b/drivers/staging/rtl8188eu/include/wifi.h
index 084a246eec19..6790b7c8cfb1 100644
--- a/drivers/staging/rtl8188eu/include/wifi.h
+++ b/drivers/staging/rtl8188eu/include/wifi.h
@@ -575,7 +575,6 @@ enum ht_cap_ampdu_factor {
  * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
  */
 #define IEEE80211_MIN_AMPDU_BUF 0x8
-#define IEEE80211_MAX_AMPDU_BUF 0x40
 
 
 #define OP_MODE_PURE0
diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h
index 0ed2f44ab4e9..00a4302e9983 100644
--- a/drivers/staging/rtl8712/wifi.h
+++ b/drivers/staging/rtl8712/wifi.h
@@ -574,7 +574,6 @@ struct ieee80211_ht_addt_info {
  * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
  */
 #define IEEE80211_MIN_AMPDU_BUF 0x8
-#define IEEE80211_MAX_AMPDU_BUF 0x40
 
 
 /* Spatial Multiplexing Power Save Modes */
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 530d698f50d9..e6477acfa961 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -807,7 +807,6 @@ enum HT_CAP_AMPDU_FACTOR {
  * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
  */
 #define IEEE80211_MIN_AMPDU_BUF 0x8
-#define IEEE80211_MAX_AMPDU_BUF 0x40
 
 
 /* Spatial Multiplexing Power Save Modes */
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 8fe7e4306816..7e1a650be329 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1433,11 +1433,13 @@ struct ieee80211_ht_operation {
 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
 
 /*
- * A-PMDU buffer sizes
- * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
+ * A-MPDU buffer sizes
+ * According to HT size varies from 8 to 64 frames
+ * HE adds the ability to have up to 256 frames.
  */
-#define IEEE80211_MIN_AMPDU_BUF 0x8
-#define IEEE80211_MAX_AMPDU_BUF 0x40
+#define IEEE80211_MIN_AMPDU_BUF0x8
+#define IEEE80211_MAX_AMPDU_BUF_HT 0x40
+#define IEEE80211_MAX_AMPDU_BUF0x100
 
 
 /* Spatial Multiplexing Power Save Modes (for capability) */
@@ -1539,6 +1541,106 @@ struct ieee80211_vht_operation {
__le16 basic_mcs_set;
 } __packed;
 
+/**
+ * struct ieee80211_he_cap_elem - HE capabilities element
+ *
+ * This structure is the "HE capabilities element" fixed fields as
+ * described in P802.11ax_D1.4 section 9.4.2.237.1
+ */
+struct ieee80211_he_cap_elem {
+   u8 mac_cap_info[5];
+   u8 phy_cap_info[9];
+} __packed;
+
+#define IEEE80211_TX_RX_MCS_NSS_DESC_MAX_LEN   5
+
+/**
+ * enum ieee80211_he_mcs_support - HE MCS support definitions
+ * @IEEE80211_HE_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
+ * number of streams
+ * @IEEE80211_HE_MCS_SUPPORT_0_9: MCSes 0-9 are supported
+ * @IEEE80211_HE_MCS_SUPPORT_0_11: MCSes 0-11 are supported
+ * @IEEE80211_HE_MCS_NOT_SUPPORTED: This number of streams isn't supported
+ *
+ * These definitions are used in each 2-bit subfield of the rx_mcs_*
+ * and tx_mcs_* fields of  ieee80211_he_mcs_nss_supp, which are
+ * both split into 8 subfields by number of streams. These values indicate
+ * which MCSes are supported for the number of streams the value appears
+ * for.
+ */
+enum ieee80211_he_mcs_support {
+   IEEE80211_HE_MCS_SUPPORT_0_7= 0,
+   IEEE80211_HE_MCS_SUPPORT_0_9= 1,
+   IEEE80211_HE_MCS_SUPPORT_0_11   = 2,
+   IEEE80211_HE_MCS_NOT_SUPPORTED  = 3,
+};
+
+/**
+ * struct ieee80211_he_mcs_nss_supp - HE Tx/Rx HE MCS NSS Support Field
+ *
+ * This structure holds the data required for the Tx/Rx HE MCS NSS Support 
Field
+ * described in P802.11ax_D1.4 section 9.4.2.237.4
+ *
+ * @rx_msc_80: Rx MCS map 2 bits for each 

[RFC 0/3] cfg80211/mac80211: add support for IEEE802.11ax

2018-05-18 Thread Luca Coelho
From: Luca Coelho 

Hi,

This series contain a squashed version of our internal series of
patches that add support for IEEE802.11ax draft v1.4.  It is a
combination of over 40 patches, so I may have made some mistakes when
squashing and splitting parts of to the right place, thus I'm sending
as an RFC.

I split it into 3 different patches, as you can see, one with cfg80211
changes, one with radiotap changes and one with mac80211 changes.

Please review them and let me know if anything needs to be changed.
I've been rather sparse in the commit logs, so suggestions for
improvements are welcome.

Cheers,
Luca.


Luca Coelho (3):
  cfg80211: Add support for HE
  radiotap: add structs for HE
  mac80211: add support for HE

 drivers/net/wireless/realtek/rtlwifi/base.c |   2 +-
 drivers/staging/rtl8188eu/include/wifi.h|   1 -
 drivers/staging/rtl8712/wifi.h  |   1 -
 drivers/staging/rtl8723bs/include/wifi.h|   1 -
 include/linux/ieee80211.h   | 431 +++-
 include/net/cfg80211.h  | 102 -
 include/net/ieee80211_radiotap.h| 111 +
 include/net/mac80211.h  |  64 ++-
 include/uapi/linux/nl80211.h|  87 +++-
 net/mac80211/Makefile   |   1 +
 net/mac80211/agg-rx.c   |   8 +-
 net/mac80211/agg-tx.c   |  19 +-
 net/mac80211/cfg.c  |   5 +
 net/mac80211/he.c   |  55 +++
 net/mac80211/ieee80211_i.h  |  16 +
 net/mac80211/main.c |  19 +-
 net/mac80211/mlme.c | 277 -
 net/mac80211/rx.c   | 127 +-
 net/mac80211/sta_info.c |  15 +-
 net/mac80211/sta_info.h |  20 +-
 net/mac80211/trace.h|   2 +-
 net/mac80211/util.c | 120 +-
 net/wireless/core.c |  21 +-
 net/wireless/nl80211.c  |  99 -
 net/wireless/util.c |  82 
 25 files changed, 1633 insertions(+), 53 deletions(-)
 create mode 100644 net/mac80211/he.c

-- 
2.17.0



[mac80211-next:master 20/20] net/wireless/nl80211.c:4802:34: error: incompatible type for argument 1 of 'cfg80211_sinfo_release_content'

2018-05-18 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 
master
head:   7ea3e110f2f8ba23f330c2f702f556acd539bcb8
commit: 7ea3e110f2f8ba23f330c2f702f556acd539bcb8 [20/20] cfg80211: release 
station info tidstats where needed
config: x86_64-randconfig-x004-201819 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
git checkout 7ea3e110f2f8ba23f330c2f702f556acd539bcb8
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   net/wireless/nl80211.c: In function 'nl80211_get_station':
>> net/wireless/nl80211.c:4802:34: error: incompatible type for argument 1 of 
>> 'cfg80211_sinfo_release_content'
  cfg80211_sinfo_release_content(sinfo);
 ^
   In file included from net/wireless/nl80211.c:24:0:
   include/net/cfg80211.h:5721:20: note: expected 'struct station_info *' but 
argument is of type 'struct station_info'
static inline void cfg80211_sinfo_release_content(struct station_info 
*sinfo)
   ^~

vim +/cfg80211_sinfo_release_content +4802 net/wireless/nl80211.c

  4776  
  4777  static int nl80211_get_station(struct sk_buff *skb, struct genl_info 
*info)
  4778  {
  4779  struct cfg80211_registered_device *rdev = info->user_ptr[0];
  4780  struct net_device *dev = info->user_ptr[1];
  4781  struct station_info sinfo;
  4782  struct sk_buff *msg;
  4783  u8 *mac_addr = NULL;
  4784  int err;
  4785  
  4786  memset(, 0, sizeof(sinfo));
  4787  
  4788  if (!info->attrs[NL80211_ATTR_MAC])
  4789  return -EINVAL;
  4790  
  4791  mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
  4792  
  4793  if (!rdev->ops->get_station)
  4794  return -EOPNOTSUPP;
  4795  
  4796  err = rdev_get_station(rdev, dev, mac_addr, );
  4797  if (err)
  4798  return err;
  4799  
  4800  msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  4801  if (!msg) {
> 4802  cfg80211_sinfo_release_content(sinfo);
  4803  return -ENOMEM;
  4804  }
  4805  
  4806  if (nl80211_send_station(msg, NL80211_CMD_NEW_STATION,
  4807   info->snd_portid, info->snd_seq, 0,
  4808   rdev, dev, mac_addr, ) < 0) {
  4809  nlmsg_free(msg);
  4810  return -ENOBUFS;
  4811  }
  4812  
  4813  return genlmsg_reply(msg, info);
  4814  }
  4815  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH v3 00/19] rtlwifi: halmac: Add new module halmac

2018-05-18 Thread Pkshih
On Wed, 2018-05-16 at 15:36 +0300, Kalle Valo wrote:
> Pkshih  writes:
> 
> > On Mon, 2018-04-30 at 14:03 +0530, Krishna Chaitanya wrote:
> >> On Mon, Apr 30, 2018 at 8:10 AM, Pkshih  wrote:
> >> >
> >> >
> >> > > -Original Message-
> >> > > From: Barry Day [mailto:brise...@gmail.com]
> >> > > Sent: Saturday, April 28, 2018 6:42 AM
> >> > > To: Pkshih
> >> > > Cc: Kalle Valo; larry.fin...@lwfinger.net; 
> >> > > linux-wireless@vger.kernel.org
> >> > > Subject: Re: [PATCH v3 00/19] rtlwifi: halmac: Add new module halmac
> >> > >
> >> > > On Fri, Apr 27, 2018 at 05:44:16AM +, Pkshih wrote:
> >> > > >
> >> > > > The registers reside in driver causes error frequently, because MAC 
> >> > > > register
> >> > > > is maintained by Realtek's MAC team so they create this module to 
> >> > > > avoid mistakes.
> >> > > > Another benefit is to make it possible to become a thin driver, 
> >> > > > because many
> >> > > > common functions are provided, so duplicate code will be reduced.
> >> > >
> >> > > How is it possible to create a thin driver by adding lots more code 
> >> > > and layers
> >> > > of indirection ??? and writing it in a way that it won't compile 
> >> > > without the
> >> > > code for every type of bus interface even though most modules only use 
> >> > > one ?
> >> > >
> >> > As I mentioned in first paragraph "(I use 'driver' in this mail 
> >> > indicates part of
> >> > rtlwifi excluded from this module.)". If this module was seen as a 
> >> > 'lib', rtl8822be
> >> > would be a "thin driver". For bus interface code, I need to add a way to 
> >> > compile
> >> > type of bus interface according to selected chip.
> >> >
> >> > > It's a horrible pile of garbage slapped together by an inexperienced
> >> > > programmer. Its a major deterrent for anyone looking at working on one 
> >> > > of
> >> > > the latest realtek drivers.
> >> > >
> >> > This module is designed to support multiple OS including Windows and 
> >> > Linux, and
> >> > many products have used this module and worked well. We hope Linux user 
> >> > can also
> >> > use Realtek's WiFi without additional installation if driver was built.
> >> > In order to submit this module to kernel upstream, we take a lot of 
> >> > effort
> >> > to fit Linux coding conventions (e.g. coding style), and explicit
> >> > suggestions will be helpful for us to continuously improve this module.
> >> 
> >> IMHO, this is a common use case for most organizations. I understand
> >> that Linux cannot
> >> accommodate other OSes requirements but is there an approved/recommended 
> >> way
> >> to upstream an OS agnostic driver? Agnostic drivers are generally
> >> bulkier compared to
> >> Linux-only drivers and also code organization is also different (to
> >> handle other OSes).
> >> 
> >
> > Hi Kalle,
> >
> > The state of this patchset was changed to RFC in patchwork, and I look at 
> > RFC's
> > meaning in wireless wiki. Do you expect that I will send v4?
> 
> Yes, I was expecting that you will submit v4 with proper documentation.
> I was supposed to send an email but forgot, sorry.
> 
> > If so, what do I need to fix in v4? Or, you need more description
> > about this module, please let me know. 
> 
> The biggest problem is that rtlwifi patches are way too big and which I
> don't think are ready for upstream, most of the time code quality is
> closer to the infamous "vendor drivers". This is causing me too much
> burden, even just reviewing and providing initial comments to rtlwifi
> patches take too much of my time. For example, I still haven't been able
> to check the rtlwifi btcoex patches from a month ago.
> 
> In principle I can use a minute or two per patch, anything longer than
> that and I can't keep up with the incoming patch flow. And with huge
> rtlwifi patchsets I usually need something more like an hour than few
> minutes.
> 
> I have said this also before, but more and more I'm thinking that
> rtlwifi is not really a proper upstream driver. I think staging would be
> a much better place for it and maybe a proper upstream realtek driver
> would be something based on rtl8xxxu? I dunno.
> 
> But we really need to find a solution for this as the current way with
> rtlwifi patches won't work in the long run.
> 

If we remove unused code and do proper modification (e.g. remove abstraction 
layer)
and submit to staging, but still remain the directory levels.
Will you accept halmac and submit it into upstream after being reviewed in 
staging?
Or, the only way you can accept is to remove the halmac directory and rearrange
the code and split it into the top level directory?

Regards,
PK


Re: [PATCH 00/10] Some more patches for wcn36xx

2018-05-18 Thread Kalle Valo
Daniel Mack  writes:

> On Wednesday, May 16, 2018 04:08 PM, Daniel Mack wrote:
>> Hence I believe that some sort of firmware internal buffer is overrun if
>> too many SMD requests fly in in a short amount of time. The firmware
>> does, however, still ack all packets just fine on the SMD channels, and
>> also the DXE communication flows are all healthy. No errors are reported
>> anywhere, but nothing is being put on the ether anymore.
>
> And FTR, there is a commit in the prima repository that caught my
> attention a while back:
>
>   https://source.codeaurora.org/external/wlan/prima/commit/?id=93cd8f3c
>
> What this does (through an remarkable number of indirection layers) is
> sending the DUMP_COMMAND_REQ command with args = (274, 0, 0, 0, 0)
> when management frames get stuck, which smells pretty much like the
> issue I'm seeing. Doing the same with the mainline driver and the
> debugfs interface it exposes doesn't have any effect though.
>
> But even if it did work, I wouldn't see a way to detect the situation
> in which this is needed reliably.

The firmware version might make a difference so I recommend always
mentioning the firmware version as well. For example, what if your
firmware does not support that command or parameter?

Also I would recommend to file a bug to bugzilla.kernel.org so that all
the information is one place and it can be easily updated. Now it's
pretty difficult to get the big picture from various emails on the list.

-- 
Kalle Valo


Re: [PATCH] ath10k: add dynamic vlan support

2018-05-18 Thread Sebastian Gottschall


Am 18.05.2018 um 11:54 schrieb Johannes Berg:

On Fri, 2018-05-04 at 12:20 +0530, Manikanta Pubbisetty wrote:

Johannes,

It seems like commit db3bdcb9c3ff ("mac80211: allow AP_VLAN operation on
crypto controlled devices") has broken 4-addr operation on crypto
controlled devices as reported by sebastian.
The commit was mainly focused in addressing the problem in supporting
VLANs on crypto controlled devices but since 4-addr mode is also
dependent on AP_VLAN interface, this commit breaks the 4-addr AP mode.

Ok.

Do you know why it actually broke it? I mean, we should've turned off
the strict requirement for sw crypto control only for the GTK, and that
shouldn't matter so much?


I have couple of ideas on how to address the problem,

1) Add a new hw_flag and based on the hardware flag, allow/disallow the
creation of AP_VLAN interface.

+ * @IEEE80211_HW_SUPPORTS_SW_ENCRYPT: Device is capable of transmitting
+ * frames encrypted in software, only valid when SW_CRYPTO_CONTROL
+ * is enabled. Based on this flag, mac80211 can allow/disallow VLAN
+ * operations in the BSS.

Based on the name and initial description, this sounds equivalent to
just turning off SW_CRYPTO_CONTROL. I think that's not the intent, but
would need some renaming.


2) Allow mac80211 to call set_key for GTKs on AP_VLAN interfaces for
crypto controlled devices, let the driver decide whether to return '1'
or some error code based on their support for transmitting sw encrypted
frames. I am little skeptical with this approach as drivers are totally
unaware of AP_VLAN interfaces.

No, that won't work.

I'm unsure how 4-addr VLAN can work with ath10k either way?

Maybe it just doesn't normally need a GTK, so nothing broke before, but
your other patch changed things to remove VLAN and then of course it's
no longer available?

But then I don't understand the complaint that

So maybe the solution should be to add a separate flag for whether or
not 4-addr VLAN is supported?

johannes


let me explain. the vlan mode is used to create local interfaces in 
4addr mode


like wlan0.sta0, wlan0.sta1 per peer. this is required to put these 
peers into the local linux bridge since the local ap interface cannot


handle the bridging capabilities like correct forwarding, stp or even 
filtering. this is a long term behaviour since the beginning of ath9k.


so the ap_vlan feature is used to pass the frames per peer in a 
indepenened way. you may ask felix fietkau, since he developed it 
originally in madwifi


and later in mac80211 / ath9k. so ap_vlan capability is a requiredment 
for all 4addr capable wireless drivers.



example of a 4addr capable ap in ath10k with 2 connected 4addr stations

root@apreithalle:~# brctl show
bridge name bridge id   STP enabled interfaces
br0 8000.dcef09e4ce07   no  ath0
    ath0.1
    ath0.2
    ath0.sta1
    ath0.sta4
    ath1
    ath1.2
    eth0
    eth1







Re: [PATCH 00/10] Some more patches for wcn36xx

2018-05-18 Thread Daniel Mack

On Wednesday, May 16, 2018 04:08 PM, Daniel Mack wrote:

Hence I believe that some sort of firmware internal buffer is overrun if
too many SMD requests fly in in a short amount of time. The firmware
does, however, still ack all packets just fine on the SMD channels, and
also the DXE communication flows are all healthy. No errors are reported
anywhere, but nothing is being put on the ether anymore.


And FTR, there is a commit in the prima repository that caught my 
attention a while back:


  https://source.codeaurora.org/external/wlan/prima/commit/?id=93cd8f3c

What this does (through an remarkable number of indirection layers) is 
sending the DUMP_COMMAND_REQ command with args = (274, 0, 0, 0, 0) when 
management frames get stuck, which smells pretty much like the issue I'm 
seeing. Doing the same with the mainline driver and the debugfs 
interface it exposes doesn't have any effect though.


But even if it did work, I wouldn't see a way to detect the situation in 
which this is needed reliably.



Daniel


Re: [PATCH] ath10k: add dynamic vlan support

2018-05-18 Thread Sebastian Gottschall



Am 18.05.2018 um 11:53 schrieb Johannes Berg:

On Mon, 2018-04-23 at 21:18 +0200, Sebastian Gottschall wrote:

this patch makes no sense at some points. AP_VLAN must be enabled always
(it is enabled by mac80211 by default, but is now disabled in very
latest git version for drivers which announce sw_crypto support)
if its disabled wds ap / wds sta operation will not work anymore since
mac80211 uses AP_VLAN for the local wds sta interfaces

You'd do you well to learn the correct terminology used in Linux if you
try to communicate with us...

What you say there makes no sense, WDS is a separate mode. Maybe you
mean 4-addr mode?
yes 4-addr mode which is common known as WDS mode. (terminology used by 
all sorts of vendors)


Sebastian


johannes





[PATCH v3] NFC: pn533: don't send USB data off of the stack

2018-05-18 Thread Greg Kroah-Hartman
It's amazing that this driver ever worked, but now that x86 doesn't
allow USB data to be sent off of the stack, it really does not work at
all.  Fix this up by properly allocating the data for the small
"commands" that get sent to the device.

The USB stack will free the buffer when the data has been transmitted,
that is why there is no kfree() to mirror the call to kmalloc().

Reported-by: Carlos Manuel Santos 
Cc: Samuel Ortiz 
Cc: Stephen Hemminger 
Cc: stable 
Signed-off-by: Greg Kroah-Hartman 
---
v3: actually use the correct buffer (thanks to Arend van Spriel)
use kmemdup (thanks to Johannes Berg and Julia Lawall)
v2: set the urb flags correctly

 drivers/nfc/pn533/usb.c |   17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -150,10 +150,16 @@ static int pn533_usb_send_ack(struct pn5
struct pn533_usb_phy *phy = dev->phy;
static const u8 ack[6] = {0x00, 0x00, 0xff, 0x00, 0xff, 0x00};
/* spec 7.1.1.3:  Preamble, SoPC (2), ACK Code (2), Postamble */
+   char *buffer;
int rc;
 
-   phy->out_urb->transfer_buffer = (u8 *)ack;
+   buffer = kmemdup(ack, sizeof(ack), GFP_KERNEL);
+   if (!buffer)
+   return -ENOMEM;
+
+   phy->out_urb->transfer_buffer = buffer;
phy->out_urb->transfer_buffer_length = sizeof(ack);
+   phy->out_urb->transfer_flags |= URB_FREE_BUFFER;
rc = usb_submit_urb(phy->out_urb, flags);
 
return rc;
@@ -170,6 +176,7 @@ static int pn533_usb_send_frame(struct p
 
phy->out_urb->transfer_buffer = out->data;
phy->out_urb->transfer_buffer_length = out->len;
+   phy->out_urb->transfer_flags &= ~URB_FREE_BUFFER;
 
print_hex_dump_debug("PN533 TX: ", DUMP_PREFIX_NONE, 16, 1,
 out->data, out->len, false);
@@ -375,20 +382,26 @@ static int pn533_acr122_poweron_rdr(stru
/* Power on th reader (CCID cmd) */
u8 cmd[10] = {PN533_ACR122_PC_TO_RDR_ICCPOWERON,
  0, 0, 0, 0, 0, 0, 3, 0, 0};
+   char *buffer;
int rc;
void *cntx;
struct pn533_acr122_poweron_rdr_arg arg;
 
dev_dbg(>udev->dev, "%s\n", __func__);
 
+   buffer = kmemdup(cmd, sizeof(cmd), GFP_KERNEL);
+   if (!buffer)
+   return -ENOMEM;
+
init_completion();
cntx = phy->in_urb->context;  /* backup context */
 
phy->in_urb->complete = pn533_acr122_poweron_rdr_resp;
phy->in_urb->context = 
 
-   phy->out_urb->transfer_buffer = cmd;
+   phy->out_urb->transfer_buffer = buffer;
phy->out_urb->transfer_buffer_length = sizeof(cmd);
+   phy->out_urb->transfer_flags |= URB_FREE_BUFFER;
 
print_hex_dump_debug("ACR122 TX: ", DUMP_PREFIX_NONE, 16, 1,
   cmd, sizeof(cmd), false);


Re: [PATCH 2/2] cfg80211: release station info tidstats where needed

2018-05-18 Thread Johannes Berg
On Fri, 2018-05-18 at 12:25 +0200, Arend van Spriel wrote:
> On 5/18/2018 11:47 AM, Johannes Berg wrote:
> > From: Johannes Berg 
> > 
> > This fixes memory leaks in cases where we got the station
> > info but failed sending it out properly.
> 
> Reviewed-by: Arend van Spriel 
> > Fixes: 8689c051a201 ("cfg80211: dynamically allocate per-tid stats for 
> > station info")
> > Signed-off-by: Johannes Berg 
> > ---
> >   include/net/cfg80211.h | 13 +
> >   net/wireless/nl80211.c | 11 ---
> >   2 files changed, 21 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> > index 8984d24d68b7..1c6364591856 100644
> > --- a/include/net/cfg80211.h
> > +++ b/include/net/cfg80211.h
> > @@ -5710,6 +5710,19 @@ void cfg80211_remain_on_channel_expired(struct 
> > wireless_dev *wdev, u64 cookie,
> >*/
> >   int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);
> > 
> > +/**
> > + * cfg80211_sinfo_release_sinfo - release contents of station info
> 
> Maybe drop one '_sinfo' from the function name? Or 
> cfg80211_sinfo_release_contents?

Heh. I guess I wasn't paying attention, I like _content()

johannes


[PATCH v2] wcn36xx: Add support for Factory Test Mode (FTM)

2018-05-18 Thread Ramon Fried
From: Eyal Ilsar 

Introduce infrastructure for supporting Factory Test Mode (FTM) of the
wireless LAN subsystem. In order for the user space to access the
firmware in test mode the relevant netlink channel needs to be exposed
from the kernel driver.

The above is achieved as follows:
1) Register wcn36xx driver to testmode callback from netlink
2) Add testmode callback implementation to handle incoming FTM commands
3) Add FTM command packet structure
4) Add handling for GET_BUILD_RELEASE_NUMBER (msgid=0x32A2)
5) Add generic handling for all PTT_MSG packets

Signed-off-by: Eyal Ilsar 
Signed-off-by: Ramon Fried 
---
v2:
* check for NULL after kmalloc
* don't assign value to ret.

 drivers/net/wireless/ath/wcn36xx/Makefile |   2 +
 drivers/net/wireless/ath/wcn36xx/hal.h|  16 ++
 drivers/net/wireless/ath/wcn36xx/main.c   |   3 +
 drivers/net/wireless/ath/wcn36xx/smd.c|  81 ++
 drivers/net/wireless/ath/wcn36xx/smd.h|   4 +
 drivers/net/wireless/ath/wcn36xx/testmode.c   | 151 ++
 drivers/net/wireless/ath/wcn36xx/testmode.h   |  46 ++
 drivers/net/wireless/ath/wcn36xx/testmode_i.h |  29 
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h|   2 +
 9 files changed, 334 insertions(+)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/testmode.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/testmode.h
 create mode 100644 drivers/net/wireless/ath/wcn36xx/testmode_i.h

diff --git a/drivers/net/wireless/ath/wcn36xx/Makefile 
b/drivers/net/wireless/ath/wcn36xx/Makefile
index 3b09435104eb..582049f65735 100644
--- a/drivers/net/wireless/ath/wcn36xx/Makefile
+++ b/drivers/net/wireless/ath/wcn36xx/Makefile
@@ -6,3 +6,5 @@ wcn36xx-y +=   main.o \
smd.o \
pmc.o \
debug.o
+
+wcn36xx-$(CONFIG_NL80211_TESTMODE) += testmode.o
diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h 
b/drivers/net/wireless/ath/wcn36xx/hal.h
index 182963522941..8491b3cb3206 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -2230,6 +2230,22 @@ struct wcn36xx_hal_switch_channel_rsp_msg {
 
 } __packed;
 
+struct wcn36xx_hal_process_ptt_msg_req_msg {
+   struct wcn36xx_hal_msg_header header;
+
+   /* Actual FTM Command body */
+   u8 ptt_msg[0];
+} __packed;
+
+struct wcn36xx_hal_process_ptt_msg_rsp_msg {
+   struct wcn36xx_hal_msg_header header;
+
+   /* FTM Command response status */
+   u32 ptt_msg_resp_status;
+   /* Actual FTM Command body */
+   u8 ptt_msg[0];
+} __packed;
+
 struct update_edca_params_req_msg {
struct wcn36xx_hal_msg_header header;
 
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index 69d6be59d97f..ea14f87d11ff 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include "wcn36xx.h"
+#include "testmode.h"
 
 unsigned int wcn36xx_dbg_mask;
 module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
@@ -1116,6 +1117,8 @@ static const struct ieee80211_ops wcn36xx_ops = {
.sta_add= wcn36xx_sta_add,
.sta_remove = wcn36xx_sta_remove,
.ampdu_action   = wcn36xx_ampdu_action,
+
+   CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd)
 };
 
 static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c 
b/drivers/net/wireless/ath/wcn36xx/smd.c
index 8932af5e4d8d..fb0192b7ee99 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -292,12 +292,26 @@ static void init_hal_msg(struct wcn36xx_hal_msg_header 
*hdr,
msg_body.header.len = sizeof(msg_body); \
} while (0) \
 
+#define INIT_HAL_PTT_MSG(p_msg_body, ppt_msg_len) \
+   do { \
+   memset(p_msg_body, 0, sizeof(*p_msg_body) + ppt_msg_len); \
+   p_msg_body->header.msg_type = WCN36XX_HAL_PROCESS_PTT_REQ; \
+   p_msg_body->header.msg_version = WCN36XX_HAL_MSG_VERSION0; \
+   p_msg_body->header.len = sizeof(*p_msg_body) + ppt_msg_len; \
+   } while (0)
+
 #define PREPARE_HAL_BUF(send_buf, msg_body) \
do {\
memset(send_buf, 0, msg_body.header.len);   \
memcpy(send_buf, _body, sizeof(msg_body));  \
} while (0) \
 
+#define PREPARE_HAL_PTT_MSG_BUF(send_buf, p_msg_body) \
+   do {\
+   memset(send_buf, 0, p_msg_body->header.len); \
+   memcpy(send_buf, p_msg_body, p_msg_body->header.len); \
+   } while (0)
+
 static int wcn36xx_smd_rsp_status_check(void *buf, size_t len)
 

Re: [PATCH 2/2] cfg80211: release station info tidstats where needed

2018-05-18 Thread Arend van Spriel

On 5/18/2018 11:47 AM, Johannes Berg wrote:

From: Johannes Berg 

This fixes memory leaks in cases where we got the station
info but failed sending it out properly.


Reviewed-by: Arend van Spriel 

Fixes: 8689c051a201 ("cfg80211: dynamically allocate per-tid stats for station 
info")
Signed-off-by: Johannes Berg 
---
  include/net/cfg80211.h | 13 +
  net/wireless/nl80211.c | 11 ---
  2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8984d24d68b7..1c6364591856 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5710,6 +5710,19 @@ void cfg80211_remain_on_channel_expired(struct 
wireless_dev *wdev, u64 cookie,
   */
  int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);

+/**
+ * cfg80211_sinfo_release_sinfo - release contents of station info


Maybe drop one '_sinfo' from the function name? Or 
cfg80211_sinfo_release_contents?


Regards,
Arend


Re: [PATCH] wcn36xx: Add support for Factory Test Mode (FTM)

2018-05-18 Thread Ramon Fried
On 17 May 2018 at 21:37, Jeff Johnson  wrote:
> On 2018-05-17 04:32, Ramon Fried wrote:
>>
>> From: Eyal Ilsar 
>
> ...
>>
>> +int wcn36xx_smd_process_ptt_msg(struct wcn36xx *wcn,
>> +   struct ieee80211_vif *vif, void *ptt_msg,
>> size_t len,
>> +   void **ptt_rsp_msg)
>> +{
>> +   struct wcn36xx_hal_process_ptt_msg_req_msg *p_msg_body;
>> +   int ret = 0;
>> +
>> +   mutex_lock(>hal_mutex);
>> +   p_msg_body = kmalloc(
>> +   sizeof(struct wcn36xx_hal_process_ptt_msg_req_msg) + len,
>> +   GFP_ATOMIC);
>
>
> NULL check required?
>
>> +   INIT_HAL_PTT_MSG(p_msg_body, len);
>> +

Thanks Jeff. will fix it and send again :)


Re: [PATCH] ath10k: add dynamic vlan support

2018-05-18 Thread Johannes Berg
On Fri, 2018-05-04 at 12:20 +0530, Manikanta Pubbisetty wrote:
> Johannes,
> 
> It seems like commit db3bdcb9c3ff ("mac80211: allow AP_VLAN operation on 
> crypto controlled devices") has broken 4-addr operation on crypto 
> controlled devices as reported by sebastian.
> The commit was mainly focused in addressing the problem in supporting 
> VLANs on crypto controlled devices but since 4-addr mode is also 
> dependent on AP_VLAN interface, this commit breaks the 4-addr AP mode.

Ok.

Do you know why it actually broke it? I mean, we should've turned off
the strict requirement for sw crypto control only for the GTK, and that
shouldn't matter so much?

> I have couple of ideas on how to address the problem,
> 
> 1) Add a new hw_flag and based on the hardware flag, allow/disallow the 
> creation of AP_VLAN interface.
> 
> + * @IEEE80211_HW_SUPPORTS_SW_ENCRYPT: Device is capable of transmitting
> + * frames encrypted in software, only valid when SW_CRYPTO_CONTROL
> + * is enabled. Based on this flag, mac80211 can allow/disallow VLAN
> + * operations in the BSS.

Based on the name and initial description, this sounds equivalent to
just turning off SW_CRYPTO_CONTROL. I think that's not the intent, but
would need some renaming.

> 2) Allow mac80211 to call set_key for GTKs on AP_VLAN interfaces for 
> crypto controlled devices, let the driver decide whether to return '1' 
> or some error code based on their support for transmitting sw encrypted 
> frames. I am little skeptical with this approach as drivers are totally 
> unaware of AP_VLAN interfaces.

No, that won't work.

I'm unsure how 4-addr VLAN can work with ath10k either way?

Maybe it just doesn't normally need a GTK, so nothing broke before, but
your other patch changed things to remove VLAN and then of course it's
no longer available?

But then I don't understand the complaint that 

So maybe the solution should be to add a separate flag for whether or
not 4-addr VLAN is supported?

johannes


Re: [PATCH] ath10k: add dynamic vlan support

2018-05-18 Thread Johannes Berg
On Mon, 2018-04-23 at 21:18 +0200, Sebastian Gottschall wrote:
> this patch makes no sense at some points. AP_VLAN must be enabled always 
> (it is enabled by mac80211 by default, but is now disabled in very 
> latest git version for drivers which announce sw_crypto support)
> if its disabled wds ap / wds sta operation will not work anymore since 
> mac80211 uses AP_VLAN for the local wds sta interfaces

You'd do you well to learn the correct terminology used in Linux if you
try to communicate with us...

What you say there makes no sense, WDS is a separate mode. Maybe you
mean 4-addr mode?

johannes


[PATCH 1/2] mac80211: allocate and fill tidstats only when needed

2018-05-18 Thread Johannes Berg
From: Johannes Berg 

This fixes memory leaks in the case where we just have the
station info on the stack for internal usage without sending
it to cfg80211.

Fixes: 8689c051a201 ("cfg80211: dynamically allocate per-tid stats for station 
info")
Signed-off-by: Johannes Berg 
---
 net/mac80211/cfg.c  | 4 ++--
 net/mac80211/ethtool.c  | 4 ++--
 net/mac80211/sta_info.c | 7 ---
 net/mac80211/sta_info.h | 3 ++-
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 5ce9d121af2b..bdf6fa78d0d2 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -695,7 +695,7 @@ static int ieee80211_dump_station(struct wiphy *wiphy, 
struct net_device *dev,
if (sta) {
ret = 0;
memcpy(mac, sta->sta.addr, ETH_ALEN);
-   sta_set_sinfo(sta, sinfo);
+   sta_set_sinfo(sta, sinfo, true);
}
 
mutex_unlock(>sta_mtx);
@@ -724,7 +724,7 @@ static int ieee80211_get_station(struct wiphy *wiphy, 
struct net_device *dev,
sta = sta_info_get_bss(sdata, mac);
if (sta) {
ret = 0;
-   sta_set_sinfo(sta, sinfo);
+   sta_set_sinfo(sta, sinfo, true);
}
 
mutex_unlock(>sta_mtx);
diff --git a/net/mac80211/ethtool.c b/net/mac80211/ethtool.c
index 2ba5686cbcab..690c142a7a44 100644
--- a/net/mac80211/ethtool.c
+++ b/net/mac80211/ethtool.c
@@ -108,7 +108,7 @@ static void ieee80211_get_stats(struct net_device *dev,
goto do_survey;
 
memset(, 0, sizeof(sinfo));
-   sta_set_sinfo(sta, );
+   sta_set_sinfo(sta, , false);
 
i = 0;
ADD_STA_STATS(sta);
@@ -135,7 +135,7 @@ static void ieee80211_get_stats(struct net_device *dev,
continue;
 
memset(, 0, sizeof(sinfo));
-   sta_set_sinfo(sta, );
+   sta_set_sinfo(sta, , false);
i = 0;
ADD_STA_STATS(sta);
}
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 04d47689b557..6428f1ac37b6 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1008,7 +1008,7 @@ static void __sta_info_destroy_part2(struct sta_info *sta)
 
sinfo = kzalloc(sizeof(*sinfo), GFP_KERNEL);
if (sinfo)
-   sta_set_sinfo(sta, sinfo);
+   sta_set_sinfo(sta, sinfo, true);
cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL);
kfree(sinfo);
 
@@ -2079,7 +2079,8 @@ static inline u64 sta_get_stats_bytes(struct 
ieee80211_sta_rx_stats *rxstats)
return value;
 }
 
-void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
+void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
+  bool tidstats)
 {
struct ieee80211_sub_if_data *sdata = sta->sdata;
struct ieee80211_local *local = sdata->local;
@@ -2233,7 +2234,7 @@ void sta_set_sinfo(struct sta_info *sta, struct 
station_info *sinfo)
sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
}
 
-   if (!cfg80211_sinfo_alloc_tid_stats(sinfo, GFP_KERNEL)) {
+   if (tidstats && !cfg80211_sinfo_alloc_tid_stats(sinfo, GFP_KERNEL)) {
for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) {
struct cfg80211_tid_stats *tidstats = >pertid[i];
 
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index d79bd6eeb549..81b35f623792 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -744,7 +744,8 @@ static inline int sta_info_flush(struct 
ieee80211_sub_if_data *sdata)
 void sta_set_rate_info_tx(struct sta_info *sta,
  const struct ieee80211_tx_rate *rate,
  struct rate_info *rinfo);
-void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo);
+void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
+  bool tidstats);
 
 u32 sta_get_expected_throughput(struct sta_info *sta);
 
-- 
2.14.3



[PATCH 2/2] cfg80211: release station info tidstats where needed

2018-05-18 Thread Johannes Berg
From: Johannes Berg 

This fixes memory leaks in cases where we got the station
info but failed sending it out properly.

Fixes: 8689c051a201 ("cfg80211: dynamically allocate per-tid stats for station 
info")
Signed-off-by: Johannes Berg 
---
 include/net/cfg80211.h | 13 +
 net/wireless/nl80211.c | 11 ---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8984d24d68b7..1c6364591856 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5710,6 +5710,19 @@ void cfg80211_remain_on_channel_expired(struct 
wireless_dev *wdev, u64 cookie,
  */
 int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);
 
+/**
+ * cfg80211_sinfo_release_sinfo - release contents of station info
+ * @sinfo: the station information
+ *
+ * Releases any potentially allocated sub-information of the station
+ * information, but not the struct itself (since it's typically on
+ * the stack.)
+ */
+static inline void cfg80211_sinfo_release_sinfo(struct station_info *sinfo)
+{
+   kfree(sinfo->pertid);
+}
+
 /**
  * cfg80211_new_sta - notify userspace about station
  *
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 7daceb1f253d..0996fdc002e0 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4702,7 +4702,6 @@ static int nl80211_send_station(struct sk_buff *msg, u32 
cmd, u32 portid,
}
 
nla_nest_end(msg, tidsattr);
-   kfree(sinfo->pertid);
}
 
nla_nest_end(msg, sinfoattr);
@@ -4712,10 +4711,12 @@ static int nl80211_send_station(struct sk_buff *msg, 
u32 cmd, u32 portid,
sinfo->assoc_req_ies))
goto nla_put_failure;
 
+   cfg80211_sinfo_release_sinfo(sinfo);
genlmsg_end(msg, hdr);
return 0;
 
  nla_put_failure:
+   cfg80211_sinfo_release_sinfo(sinfo);
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
 }
@@ -4797,8 +4798,10 @@ static int nl80211_get_station(struct sk_buff *skb, 
struct genl_info *info)
return err;
 
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-   if (!msg)
+   if (!msg) {
+   cfg80211_sinfo_release_sinfo(sinfo);
return -ENOMEM;
+   }
 
if (nl80211_send_station(msg, NL80211_CMD_NEW_STATION,
 info->snd_portid, info->snd_seq, 0,
@@ -14624,8 +14627,10 @@ void cfg80211_del_sta_sinfo(struct net_device *dev, 
const u8 *mac_addr,
trace_cfg80211_del_sta(dev, mac_addr);
 
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
-   if (!msg)
+   if (!msg) {
+   cfg80211_sinfo_release_sinfo(sinfo);
return;
+   }
 
if (nl80211_send_station(msg, NL80211_CMD_DEL_STATION, 0, 0, 0,
 rdev, dev, mac_addr, sinfo) < 0) {
-- 
2.14.3



Re: [PATCH V3 0/5] Update brcm firmware files

2018-05-18 Thread Hans de Goede

Hi,

On 18-05-18 11:00, Arend van Spriel wrote:

On 5/18/2018 9:04 AM, Hans de Goede wrote:

Hi,

On 15-05-18 10:43, Arend van Spriel wrote:

On 5/14/2018 2:05 PM, Josh Boyer wrote:

n Mon, May 14, 2018 at 6:11 AM Arend van Spriel <
arend.vanspr...@broadcom.com> wrote:


On 3/16/2018 3:08 PM, Chi-Hsien Lin wrote:

Update brcm firmware files and WHENCE accordingly.



Hi firmware-maintainers,



It seems this series somehow got lost. Can these still be applied. They
can be found in the linux-wireless patchwork database. I provided links
below.


All 5 of these move the respective firmware files under the Cypress
license.  It has been pointed out that the Cypress license has some
questionable language in it and that people have been in touch to try
and
get this resolved.  I'm personally waiting on applying them until the
licence issue is sorted out.


Thanks, Josh

I could not find any such response. Has it been taken off-list? Seems
like 2 months is quite some time, but maybe there are lawyers involved
;-)


Yes the discussion about this has been happening off-list. IANAL but
the gist of it is (AFAIK) that:

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENCE.cypress


has a clause which allows Cypress to retro-actively revoke the LICENSE:

"either party may terminate this Agreement at any time with or without
cause."
...
"Upon termination, you must destroy all copies of Software in your
possession or
control."

So upon revokation we would have to remove the files from linux-firmware
(rewrite git history?) and since distros get their redistribution rights
from this license too they would also need to remove it from their packages
including all mirrors and archives of older versions. Which simply is not
feasible and no other license in linux-firmware has such a clause.


Check again. From LICENCE.broadcom_bcm43xx:

"""
2.  Restrictions. Licensee shall distribute Software with a copy of this
Agreement. Licensee shall not remove, efface or obscure any copyright or
trademark notices from the Software. Reproductions of the Broadcom copyright
notice shall be included with each copy of the Software, except where such
Software is embedded in a manner not readily accessible to the end user.
Licensee shall not: (i) use, license, sell or otherwise distribute the Software
except as provided in this Agreement; (ii) attempt to modify in any way,
reverse engineer, decompile or disassemble any portion of the Software; or
(iii) use the Software or other material in violation of any applicable law or
regulation, including but not limited to any regulatory agency. This Agreement
shall automatically terminate upon Licensee\u2019s failure to comply with any 
of the
terms of this Agreement. In such event, Licensee will destroy all copies of the
Software and its component parts.
"""


That has the "destroy all copies of (the) Software" language, but the entire
file does not have anything equivalent to: "either party may terminate this 
Agreement
at any time with or without cause.". So as long as we abide by the license 
terms,
the LICENCE.broadcom_bcm43xx license will never terminate and the
"destroy all copies of (the) Software" language is not a problem.

The main problem is the "either party may terminate this Agreement at any time
with or without cause." language in the Cypress license. Note IANAL and TINLA.

Regards,

Hans


Re: [RESEND PATCH] cfg80211: dynamically allocate per-tid stats for station info

2018-05-18 Thread Johannes Berg
On Fri, 2018-05-18 at 11:37 +0200, Arend van Spriel wrote:
> On 5/18/2018 11:25 AM, Johannes Berg wrote:
> > On Thu, 2018-05-10 at 13:50 +0200, Arend van Spriel wrote:
> > > 
> > > Here an alternative approach. Currently the only cfg80211-based driver
> > > providing per-tid stats is mac80211. This patch only changes mac80211
> > > and the other driver can keep using stack allocation. Even mac80211 could
> > > if wanted, but I left that part as is.
> > 
> > I decided to take this and remove the BIT() thing entirely (you had a
> > bug there anyway)
> 
> I figured you would drop this one. The error paths may need to do kfree 
> here and there. Kalle took dynamic alloc fixes in driver already so my 
> patch is not really needed right now.

Heh. I asked Kalle if he wanted to revert, but I decided that for the
single user in mac80211 it wasn't worth the hassle of doing the dynamic
allocations all over the place.

I'll look at the error paths I guess.

johannes


Re: [RESEND PATCH] cfg80211: dynamically allocate per-tid stats for station info

2018-05-18 Thread Arend van Spriel

On 5/18/2018 11:25 AM, Johannes Berg wrote:

On Thu, 2018-05-10 at 13:50 +0200, Arend van Spriel wrote:


Here an alternative approach. Currently the only cfg80211-based driver
providing per-tid stats is mac80211. This patch only changes mac80211
and the other driver can keep using stack allocation. Even mac80211 could
if wanted, but I left that part as is.


I decided to take this and remove the BIT() thing entirely (you had a
bug there anyway)


I figured you would drop this one. The error paths may need to do kfree 
here and there. Kalle took dynamic alloc fixes in driver already so my 
patch is not really needed right now.


Gr. AvS



[PATCH 02/14] rtlwifi: remove CONNECTION_MONITOR flag

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

To use keep-alive mechanism in mac80211 stack, since driver supports
reporting accurate nullfunc frame tx ack now.

Signed-off-by: Tzu-En Huang 
Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 6620c6842b91..759a802ccbee 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -396,7 +396,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
ieee80211_hw_set(hw, SIGNAL_DBM);
ieee80211_hw_set(hw, RX_INCLUDES_FCS);
ieee80211_hw_set(hw, AMPDU_AGGREGATION);
-   ieee80211_hw_set(hw, CONNECTION_MONITOR);
ieee80211_hw_set(hw, MFP_CAPABLE);
ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
-- 
2.15.1



[PATCH 01/14] rtlwifi: support accurate nullfunc frame tx ack report

2018-05-18 Thread pkshih
From: Tzu-En Huang 

In order to realize the keep-alive mechanism in mac80211 stack, reporting
accurate tx ack status for nullfunc frame is added in this commit.

If current frame is nullfunc frame, we ask firmware to report by filling
TX report bit in TX descriptor. After this frame DMA done, TX interrupt is
triggered but TX status is unknown at this moment, so enqueue this skb
into tx_report->queue. Finally, C2H report will be received if the frame
is transmitted successfully or retried over, and then we report to mac80211
with IEEE80211_TX_STAT_ACK flag only if it's successful. Otherwise, if
failure or timeout (one second), we report to mac80211 without this flag.

Signed-off-by: Tzu-En Huang 
Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/base.c| 84 +++---
 drivers/net/wireless/realtek/rtlwifi/base.h|  5 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c | 13 ++--
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   |  5 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   |  5 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   |  5 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h| 16 +
 7 files changed, 112 insertions(+), 21 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 762a29cdf7ad..6620c6842b91 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -574,6 +574,7 @@ int rtl_init_core(struct ieee80211_hw *hw)
INIT_LIST_HEAD(>entry_list);
INIT_LIST_HEAD(>c2hcmd_list);
INIT_LIST_HEAD(>scan_list.list);
+   skb_queue_head_init(>tx_report.queue);
 
rtlmac->link_state = MAC80211_NOLINK;
 
@@ -585,11 +586,14 @@ int rtl_init_core(struct ieee80211_hw *hw)
 EXPORT_SYMBOL_GPL(rtl_init_core);
 
 static void rtl_free_entries_from_scan_list(struct ieee80211_hw *hw);
+static void rtl_free_entries_from_ack_queue(struct ieee80211_hw *hw,
+   bool timeout);
 
 void rtl_deinit_core(struct ieee80211_hw *hw)
 {
rtl_c2hcmd_launcher(hw, 0);
rtl_free_entries_from_scan_list(hw);
+   rtl_free_entries_from_ack_queue(hw, false);
 }
 EXPORT_SYMBOL_GPL(rtl_deinit_core);
 
@@ -1575,22 +1579,52 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct 
sk_buff *skb, u8 is_tx,
 }
 EXPORT_SYMBOL_GPL(rtl_is_special_data);
 
+void rtl_tx_ackqueue(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_tx_report *tx_report = >tx_report;
+
+   __skb_queue_tail(_report->queue, skb);
+}
+EXPORT_SYMBOL_GPL(rtl_tx_ackqueue);
+
+static void rtl_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
+ bool ack)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct ieee80211_tx_info *info;
+
+   info = IEEE80211_SKB_CB(skb);
+   ieee80211_tx_info_clear_status(info);
+   if (ack) {
+   RT_TRACE(rtlpriv, COMP_TX_REPORT, DBG_LOUD,
+"tx report: ack\n");
+   info->flags |= IEEE80211_TX_STAT_ACK;
+   } else {
+   RT_TRACE(rtlpriv, COMP_TX_REPORT, DBG_LOUD,
+"tx report: not ack\n");
+   info->flags &= ~IEEE80211_TX_STAT_ACK;
+   }
+   ieee80211_tx_status_irqsafe(hw, skb);
+}
+
 bool rtl_is_tx_report_skb(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
u16 ether_type;
const u8 *ether_type_ptr;
+   __le16 fc = rtl_get_fc(skb);
 
ether_type_ptr = rtl_skb_ether_type_ptr(hw, skb, true);
ether_type = be16_to_cpup((__be16 *)ether_type_ptr);
 
-   /* EAPOL */
-   if (ether_type == ETH_P_PAE)
+   if (ether_type == ETH_P_PAE || ieee80211_is_nullfunc(fc))
return true;
 
return false;
 }
 
-static u16 rtl_get_tx_report_sn(struct ieee80211_hw *hw)
+static u16 rtl_get_tx_report_sn(struct ieee80211_hw *hw,
+   struct rtlwifi_tx_info *tx_info)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_tx_report *tx_report = >tx_report;
@@ -1604,29 +1638,33 @@ static u16 rtl_get_tx_report_sn(struct ieee80211_hw *hw)
 
tx_report->last_sent_sn = sn;
tx_report->last_sent_time = jiffies;
-
+   tx_info->sn = sn;
+   tx_info->send_time = tx_report->last_sent_time;
RT_TRACE(rtlpriv, COMP_TX_REPORT, DBG_DMESG,
 "Send TX-Report sn=0x%X\n", sn);
 
return sn;
 }
 
-void rtl_get_tx_report(struct rtl_tcb_desc *ptcb_desc, u8 *pdesc,
-  struct ieee80211_hw *hw)
+void rtl_set_tx_report(struct rtl_tcb_desc *ptcb_desc, u8 *pdesc,
+  struct ieee80211_hw *hw, struct rtlwifi_tx_info *tx_info)
 {
if (ptcb_desc->use_spe_rpt) {
-   u16 sn = rtl_get_tx_report_sn(hw);
+   u16 sn 

[PATCH 07/14] rtlwifi: remove dummy hal_op rx_command_packet from rtl8188ee and rtl8723ae

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

The caller of hal_op rx_command_packet will assert function pointer
before calling, so we can remove dummy functions safely.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c  | 2 --
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c | 7 ---
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h | 4 
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c  | 1 -
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c | 7 ---
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.h | 3 ---
 6 files changed, 24 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
index 82681b96ef93..8c15ffd3568b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
@@ -263,8 +263,6 @@ static struct rtl_hal_ops rtl8188ee_hal_ops = {
.get_rfreg = rtl88e_phy_query_rf_reg,
.set_rfreg = rtl88e_phy_set_rf_reg,
.get_btc_status = rtl88e_get_btc_status,
-   .rx_command_packet = rtl88ee_rx_command_packet,
-
 };
 
 static struct rtl_mod_params rtl88ee_mod_params = {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c
index 9670732b2bc6..4c1f8b08fc10 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c
@@ -850,10 +850,3 @@ void rtl88ee_tx_polling(struct ieee80211_hw *hw, u8 
hw_queue)
   BIT(0) << (hw_queue));
}
 }
-
-u32 rtl88ee_rx_command_packet(struct ieee80211_hw *hw,
- const struct rtl_stats *status,
- struct sk_buff *skb)
-{
-   return 0;
-}
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h
index f902d6769aa8..127ba977206f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h
@@ -790,8 +790,4 @@ void rtl88ee_tx_polling(struct ieee80211_hw *hw, u8 
hw_queue);
 void rtl88ee_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
 bool firstseg, bool lastseg,
 struct sk_buff *skb);
-u32 rtl88ee_rx_command_packet(struct ieee80211_hw *hw,
- const struct rtl_stats *status,
- struct sk_buff *skb);
-
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
index a545ea317323..07b82700d1de 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
@@ -260,7 +260,6 @@ static struct rtl_hal_ops rtl8723e_hal_ops = {
.bt_coex_off_before_lps =
rtl8723e_dm_bt_turn_off_bt_coexist_before_enter_lps,
.get_btc_status = rtl8723e_get_btc_status,
-   .rx_command_packet = rtl8723e_rx_command_packet,
.is_fw_header = is_fw_header,
 };
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c
index 23485602a9a1..d461d0c9631f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c
@@ -709,10 +709,3 @@ void rtl8723e_tx_polling(struct ieee80211_hw *hw, u8 
hw_queue)
   BIT(0) << (hw_queue));
}
 }
-
-u32 rtl8723e_rx_command_packet(struct ieee80211_hw *hw,
-  const struct rtl_stats *status,
-  struct sk_buff *skb)
-{
-   return 0;
-}
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.h
index 985ce0b77ea5..d592b08d4ac8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.h
@@ -716,7 +716,4 @@ void rtl8723e_tx_polling(struct ieee80211_hw *hw, u8 
hw_queue);
 void rtl8723e_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
  bool firstseg, bool lastseg,
  struct sk_buff *skb);
-u32 rtl8723e_rx_command_packet(struct ieee80211_hw *hw,
-  const struct rtl_stats *status,
-  struct sk_buff *skb);
 #endif
-- 
2.15.1



[PATCH 09/14] rtlwifi: remove duplicate C2H handler

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

Merge duplicate C2H handler and implement the handler in base.c.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/base.c| 72 +
 drivers/net/wireless/realtek/rtlwifi/base.h|  3 +
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c| 75 --
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|  3 -
 .../net/wireless/realtek/rtlwifi/rtl8192ee/sw.c|  2 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   |  2 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c| 69 
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h|  3 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c|  2 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   |  3 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c| 68 
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h|  5 --
 .../net/wireless/realtek/rtlwifi/rtl8821ae/sw.c|  2 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   |  2 +-
 14 files changed, 81 insertions(+), 230 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 759a802ccbee..0d03e98f9cb4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -2306,6 +2306,78 @@ void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, 
u8 len, u8 *val)
 }
 EXPORT_SYMBOL(rtl_c2hcmd_enqueue);
 
+void rtl_c2h_content_parsing(struct ieee80211_hw *hw, u8 cmd_id,
+u8 cmd_len, u8 *cmd_buf)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_hal_ops *hal_ops = rtlpriv->cfg->ops;
+   const struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
+
+   switch (cmd_id) {
+   case C2H_DBG:
+   RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "[C2H], C2H_DBG!!\n");
+   break;
+   case C2H_TXBF:
+   RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
+"[C2H], C2H_TXBF!!\n");
+   break;
+   case C2H_TX_REPORT:
+   rtl_tx_report_handler(hw, cmd_buf, cmd_len);
+   break;
+   case C2H_RA_RPT:
+   if (hal_ops->c2h_ra_report_handler)
+   hal_ops->c2h_ra_report_handler(hw, cmd_buf, cmd_len);
+   break;
+   case C2H_BT_INFO:
+   RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
+"[C2H], C2H_BT_INFO!!\n");
+   if (rtlpriv->cfg->ops->get_btc_status())
+   btc_ops->btc_btinfo_notify(rtlpriv, cmd_buf, cmd_len);
+   break;
+   case C2H_BT_MP:
+   RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
+"[C2H], C2H_BT_MP!!\n");
+   if (rtlpriv->cfg->ops->get_btc_status())
+   btc_ops->btc_btmpinfo_notify(rtlpriv, cmd_buf, cmd_len);
+   break;
+   default:
+   RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
+"[C2H], Unknown packet!! cmd_id(%#X)!\n", cmd_id);
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(rtl_c2h_content_parsing);
+
+void rtl_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len)
+{
+   struct rtl_priv *rtlpriv = rtl_priv(hw);
+   u8 c2h_cmd_id = 0, c2h_cmd_seq = 0, c2h_cmd_len = 0;
+   u8 *tmp_buf = NULL;
+
+   c2h_cmd_id = buffer[0];
+   c2h_cmd_seq = buffer[1];
+   c2h_cmd_len = len - 2;
+   tmp_buf = buffer + 2;
+
+   RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
+"[C2H packet], c2hCmdId=0x%x, c2hCmdSeq=0x%x, c2hCmdLen=%d\n",
+c2h_cmd_id, c2h_cmd_seq, c2h_cmd_len);
+
+   RT_PRINT_DATA(rtlpriv, COMP_FW, DBG_TRACE,
+ "[C2H packet], Content Hex:\n", tmp_buf, c2h_cmd_len);
+
+   switch (c2h_cmd_id) {
+   case C2H_BT_INFO:
+   case C2H_BT_MP:
+   rtl_c2hcmd_enqueue(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf);
+   break;
+   default:
+   rtl_c2h_content_parsing(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf);
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(rtl_c2h_packet_handler);
+
 void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
b/drivers/net/wireless/realtek/rtlwifi/base.h
index 19e7477839e4..3bf174e5b07e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -162,6 +162,9 @@ void rtl_fwevt_wq_callback(void *data);
 void rtl_c2hcmd_wq_callback(void *data);
 void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec);
 void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val);
+void rtl_c2h_content_parsing(struct ieee80211_hw *hw, u8 c2h_cmd_id,
+u8 c2h_cmd_len, u8 *tmp_buf);
+void rtl_c2h_packet_handler(struct ieee80211_hw 

[PATCH 10/14] rtlwifi: remove hal_op rx_command_packet

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

Because the hal_op rx_command_packet does C2H handler if rx packet type
is C2H, and the handler have been moved to base.c so we can call the
handler directly.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/pci.c |  4 ++--
 .../net/wireless/realtek/rtlwifi/rtl8192ee/sw.c|  1 -
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   | 24 
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.h   |  3 ---
 .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c|  1 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   | 24 
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.h   |  3 ---
 .../net/wireless/realtek/rtlwifi/rtl8821ae/sw.c|  1 -
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   | 26 --
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.h   |  3 ---
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  2 --
 11 files changed, 2 insertions(+), 90 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c 
b/drivers/net/wireless/realtek/rtlwifi/pci.c
index d0c509ef790e..dd51c67c09fa 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -830,8 +830,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
goto new_trx_end;
}
/* handle command packet here */
-   if (rtlpriv->cfg->ops->rx_command_packet &&
-   rtlpriv->cfg->ops->rx_command_packet(hw, , skb)) {
+   if (stats.packet_report_type == C2H_PACKET) {
+   rtl_c2h_packet_handler(hw, skb->data, (u8)skb->len);
dev_kfree_skb_any(skb);
goto new_trx_end;
}
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index fd028274c593..5b67ad748d67 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -250,7 +250,6 @@ static struct rtl_hal_ops rtl8192ee_hal_ops = {
.set_rfreg = rtl92ee_phy_set_rf_reg,
.fill_h2c_cmd = rtl92ee_fill_h2c_cmd,
.get_btc_status = rtl92ee_get_btc_status,
-   .rx_command_packet = rtl92ee_rx_command_packet,
.c2h_content_parsing = rtl_c2h_content_parsing,
.c2h_ra_report_handler = rtl92ee_c2h_ra_report_handler,
 };
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
index e525c2bb4457..14d6e3fc5767 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
@@ -1072,27 +1072,3 @@ bool rtl92ee_is_tx_desc_closed(struct ieee80211_hw *hw, 
u8 hw_queue, u16 index)
 void rtl92ee_tx_polling(struct ieee80211_hw *hw, u8 hw_queue)
 {
 }
-
-u32 rtl92ee_rx_command_packet(struct ieee80211_hw *hw,
- const struct rtl_stats *status,
- struct sk_buff *skb)
-{
-   u32 result = 0;
-   struct rtl_priv *rtlpriv = rtl_priv(hw);
-
-   switch (status->packet_report_type) {
-   case NORMAL_RX:
-   result = 0;
-   break;
-   case C2H_PACKET:
-   rtl_c2h_packet_handler(hw, skb->data, (u8)skb->len);
-   result = 1;
-   break;
-   default:
-   RT_TRACE(rtlpriv, COMP_RECV, DBG_TRACE,
-"Unknown packet type %d\n", 
status->packet_report_type);
-   break;
-   }
-
-   return result;
-}
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h
index 48c16fff20c6..45df3e79f490 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h
@@ -762,7 +762,4 @@ void rtl92ee_tx_polling(struct ieee80211_hw *hw, u8 
hw_queue);
 void rtl92ee_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
 bool firstseg, bool lastseg,
 struct sk_buff *skb);
-u32 rtl92ee_rx_command_packet(struct ieee80211_hw *hw,
- const struct rtl_stats *status,
- struct sk_buff *skb);
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
index 9df994965c4a..a41e67b3f38b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
@@ -261,7 +261,6 @@ static struct rtl_hal_ops rtl8723be_hal_ops = {
.set_rfreg = rtl8723be_phy_set_rf_reg,
.fill_h2c_cmd = rtl8723be_fill_h2c_cmd,
.get_btc_status = rtl8723be_get_btc_status,
-   .rx_command_packet = rtl8723be_rx_command_packet,
.is_fw_header = is_fw_header,

[PATCH 06/14] rtlwifi: remove unused fw C2H command ID

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

The IDs are defined by driver and map to the fw C2H IDs, but they aren't
used now result in removal.

Signed-off-by: Ping-Ke Shih 
---
 .../net/wireless/realtek/rtlwifi/rtl8188ee/def.h   | 25 --
 .../net/wireless/realtek/rtlwifi/rtl8192ce/def.h   | 25 --
 .../net/wireless/realtek/rtlwifi/rtl8723ae/def.h   | 25 --
 .../net/wireless/realtek/rtlwifi/rtl8821ae/def.h   | 25 --
 4 files changed, 100 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h
index 32492d64d685..45c866d3ca88 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h
@@ -176,31 +176,6 @@ enum interface_select_pci {
INTF_SEL3_RSV = 3,
 };
 
-enum hal_fw_c2h_cmd_id {
-   HAL_FW_C2H_CMD_READ_MACREG = 0,
-   HAL_FW_C2H_CMD_READ_BBREG = 1,
-   HAL_FW_C2H_CMD_READ_RFREG = 2,
-   HAL_FW_C2H_CMD_READ_EEPROM = 3,
-   HAL_FW_C2H_CMD_READ_EFUSE = 4,
-   HAL_FW_C2H_CMD_READ_CAM = 5,
-   HAL_FW_C2H_CMD_GET_BASICRATE = 6,
-   HAL_FW_C2H_CMD_GET_DATARATE = 7,
-   HAL_FW_C2H_CMD_SURVEY = 8,
-   HAL_FW_C2H_CMD_SURVEYDONE = 9,
-   HAL_FW_C2H_CMD_JOINBSS = 10,
-   HAL_FW_C2H_CMD_ADDSTA = 11,
-   HAL_FW_C2H_CMD_DELSTA = 12,
-   HAL_FW_C2H_CMD_ATIMDONE = 13,
-   HAL_FW_C2H_CMD_TX_REPORT = 14,
-   HAL_FW_C2H_CMD_CCX_REPORT = 15,
-   HAL_FW_C2H_CMD_DTM_REPORT = 16,
-   HAL_FW_C2H_CMD_TX_RATE_STATISTICS = 17,
-   HAL_FW_C2H_CMD_C2HLBK = 18,
-   HAL_FW_C2H_CMD_C2HDBG = 19,
-   HAL_FW_C2H_CMD_C2HFEEDBACK = 20,
-   HAL_FW_C2H_CMD_MAX
-};
-
 enum rtl_desc_qsel {
QSLT_BK = 0x2,
QSLT_BE = 0x0,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/def.h
index b90aaf128072..d2005d7e9ad2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/def.h
@@ -142,31 +142,6 @@ enum interface_select_pci {
INTF_SEL3_RSV = 3,
 };
 
-enum hal_fw_c2h_cmd_id {
-   HAL_FW_C2H_CMD_Read_MACREG = 0,
-   HAL_FW_C2H_CMD_Read_BBREG = 1,
-   HAL_FW_C2H_CMD_Read_RFREG = 2,
-   HAL_FW_C2H_CMD_Read_EEPROM = 3,
-   HAL_FW_C2H_CMD_Read_EFUSE = 4,
-   HAL_FW_C2H_CMD_Read_CAM = 5,
-   HAL_FW_C2H_CMD_Get_BasicRate = 6,
-   HAL_FW_C2H_CMD_Get_DataRate = 7,
-   HAL_FW_C2H_CMD_Survey = 8,
-   HAL_FW_C2H_CMD_SurveyDone = 9,
-   HAL_FW_C2H_CMD_JoinBss = 10,
-   HAL_FW_C2H_CMD_AddSTA = 11,
-   HAL_FW_C2H_CMD_DelSTA = 12,
-   HAL_FW_C2H_CMD_AtimDone = 13,
-   HAL_FW_C2H_CMD_TX_Report = 14,
-   HAL_FW_C2H_CMD_CCX_Report = 15,
-   HAL_FW_C2H_CMD_DTM_Report = 16,
-   HAL_FW_C2H_CMD_TX_Rate_Statistics = 17,
-   HAL_FW_C2H_CMD_C2HLBK = 18,
-   HAL_FW_C2H_CMD_C2HDBG = 19,
-   HAL_FW_C2H_CMD_C2HFEEDBACK = 20,
-   HAL_FW_C2H_CMD_MAX
-};
-
 enum rtl_desc_qsel {
QSLT_BK = 0x2,
QSLT_BE = 0x0,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/def.h
index bcdf2273688e..847544817549 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/def.h
@@ -152,31 +152,6 @@ enum interface_select_pci {
INTF_SEL3_RSV = 3,
 };
 
-enum hal_fw_c2h_cmd_id {
-   HAL_FW_C2H_CMD_Read_MACREG = 0,
-   HAL_FW_C2H_CMD_Read_BBREG = 1,
-   HAL_FW_C2H_CMD_Read_RFREG = 2,
-   HAL_FW_C2H_CMD_Read_EEPROM = 3,
-   HAL_FW_C2H_CMD_Read_EFUSE = 4,
-   HAL_FW_C2H_CMD_Read_CAM = 5,
-   HAL_FW_C2H_CMD_Get_BasicRate = 6,
-   HAL_FW_C2H_CMD_Get_DataRate = 7,
-   HAL_FW_C2H_CMD_Survey = 8,
-   HAL_FW_C2H_CMD_SurveyDone = 9,
-   HAL_FW_C2H_CMD_JoinBss = 10,
-   HAL_FW_C2H_CMD_AddSTA = 11,
-   HAL_FW_C2H_CMD_DelSTA = 12,
-   HAL_FW_C2H_CMD_AtimDone = 13,
-   HAL_FW_C2H_CMD_TX_Report = 14,
-   HAL_FW_C2H_CMD_CCX_Report = 15,
-   HAL_FW_C2H_CMD_DTM_Report = 16,
-   HAL_FW_C2H_CMD_TX_Rate_Statistics = 17,
-   HAL_FW_C2H_CMD_C2HLBK = 18,
-   HAL_FW_C2H_CMD_C2HDBG = 19,
-   HAL_FW_C2H_CMD_C2HFEEDBACK = 20,
-   HAL_FW_C2H_CMD_MAX
-};
-
 enum rtl_desc_qsel {
QSLT_BK = 0x2,
QSLT_BE = 0x0,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h
index 498f716bfc73..3fe3aaa5fe3c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h
@@ -296,31 +296,6 @@ enum interface_select_pci {
INTF_SEL3_RSV = 3,
 };
 
-enum hal_fw_c2h_cmd_id {
-   HAL_FW_C2H_CMD_READ_MACREG = 0,
-   HAL_FW_C2H_CMD_READ_BBREG = 1,
-   HAL_FW_C2H_CMD_READ_RFREG = 2,
-   

[PATCH 08/14] rtlwifi: Add hal_op c2h_ra_report_handler for special process

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

We're going to merge C2H handler into one, but one special case is to
handle RA_REPORT that implements in individual IC folder. So this commit
adds a hal_op for caller in common code.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c | 7 ---
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c | 1 +
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c | 5 +++--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.h | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 1 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h | 2 ++
 7 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
index 25d6c32f66c3..a2d9e217bc65 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
@@ -876,8 +876,8 @@ void rtl92ee_set_p2p_ps_offload_cmd(struct ieee80211_hw 
*hw, u8 p2p_ps_state)
 (u8 *)p2p_ps_offload);
 }
 
-static void _rtl92ee_c2h_ra_report_handler(struct ieee80211_hw *hw,
-  u8 *cmd_buf, u8 cmd_len)
+void rtl92ee_c2h_ra_report_handler(struct ieee80211_hw *hw,
+  u8 *cmd_buf, u8 cmd_len)
 {
u8 rate = cmd_buf[0] & 0x3F;
bool collision_state = cmd_buf[3] & BIT(0);
@@ -889,6 +889,7 @@ void rtl92ee_c2h_content_parsing(struct ieee80211_hw *hw, 
u8 c2h_cmd_id,
 u8 c2h_cmd_len, u8 *tmp_buf)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_hal_ops *hal_ops = rtlpriv->cfg->ops;
struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 
switch (c2h_cmd_id) {
@@ -920,7 +921,7 @@ void rtl92ee_c2h_content_parsing(struct ieee80211_hw *hw, 
u8 c2h_cmd_id,
 c2h_cmd_len);
break;
case C2H_RA_RPT:
-   _rtl92ee_c2h_ra_report_handler(hw, tmp_buf, c2h_cmd_len);
+   hal_ops->c2h_ra_report_handler(hw, tmp_buf, c2h_cmd_len);
break;
default:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
index 8325adaa9663..e5fae0a86a27 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
@@ -182,4 +182,6 @@ void rtl92ee_set_p2p_ps_offload_cmd(struct ieee80211_hw 
*hw, u8 p2p_ps_state);
 void rtl92ee_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len);
 void rtl92ee_c2h_content_parsing(struct ieee80211_hw *hw, u8 c2h_cmd_id,
 u8 c2h_cmd_len, u8 *tmp_buf);
+void rtl92ee_c2h_ra_report_handler(struct ieee80211_hw *hw,
+  u8 *cmd_buf, u8 cmd_len);
 #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index ef92a789871d..c5c26b537cd2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -252,6 +252,7 @@ static struct rtl_hal_ops rtl8192ee_hal_ops = {
.get_btc_status = rtl92ee_get_btc_status,
.rx_command_packet = rtl92ee_rx_command_packet,
.c2h_content_parsing = rtl92ee_c2h_content_parsing,
+   .c2h_ra_report_handler = rtl92ee_c2h_ra_report_handler,
 };
 
 static struct rtl_mod_params rtl92ee_mod_params = {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
index 5c7e58fbc07e..bf37c428c682 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
@@ -1907,7 +1907,7 @@ void rtl8821ae_set_p2p_ps_offload_cmd(struct ieee80211_hw 
*hw, u8 p2p_ps_state)
H2C_8821AE_P2P_PS_OFFLOAD, 1, (u8 *)p2p_ps_offload);
 }
 
-static void rtl8821ae_c2h_ra_report_handler(struct ieee80211_hw *hw,
+void rtl8821ae_c2h_ra_report_handler(struct ieee80211_hw *hw,
 u8 *cmd_buf, u8 cmd_len)
 {
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -1923,6 +1923,7 @@ void rtl8821ae_c2h_content_parsing(struct ieee80211_hw 
*hw,
   u8 *tmp_buf)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct rtl_hal_ops *hal_ops = rtlpriv->cfg->ops;
struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 
switch (c2h_cmd_id) {
@@ -1933,7 +1934,7 @@ void rtl8821ae_c2h_content_parsing(struct ieee80211_hw 
*hw,
rtl_tx_report_handler(hw, tmp_buf, c2h_cmd_len);
break;
case C2H_RA_RPT:
-   

[PATCH 05/14] rtlwifi: remove duplicate C2H definition

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

Move C2H definition to wifi.h, because the definitions of 8192ee, 8723be
and 8821ae are the same.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c | 16 
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h | 11 ---
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c | 12 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.h | 10 --
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c | 12 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.h | 14 --
 drivers/net/wireless/realtek/rtlwifi/wifi.h | 19 +++
 7 files changed, 39 insertions(+), 55 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
index f9563ae301ad..25d6c32f66c3 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
@@ -892,34 +892,34 @@ void rtl92ee_c2h_content_parsing(struct ieee80211_hw *hw, 
u8 c2h_cmd_id,
struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 
switch (c2h_cmd_id) {
-   case C2H_8192E_DBG:
+   case C2H_DBG:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
 "[C2H], C2H_8723BE_DBG!!\n");
break;
-   case C2H_8192E_TXBF:
+   case C2H_TXBF:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
 "[C2H], C2H_8192E_TXBF!!\n");
break;
-   case C2H_8192E_TX_REPORT:
+   case C2H_TX_REPORT:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE ,
 "[C2H], C2H_8723BE_TX_REPORT!\n");
rtl_tx_report_handler(hw, tmp_buf, c2h_cmd_len);
break;
-   case C2H_8192E_BT_INFO:
+   case C2H_BT_INFO:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
 "[C2H], C2H_8723BE_BT_INFO!!\n");
if (rtlpriv->cfg->ops->get_btc_status())
btc_ops->btc_btinfo_notify(rtlpriv, tmp_buf,
   c2h_cmd_len);
break;
-   case C2H_8192E_BT_MP:
+   case C2H_BT_MP:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
 "[C2H], C2H_8723BE_BT_MP!!\n");
if (rtlpriv->cfg->ops->get_btc_status())
btc_ops->btc_btmpinfo_notify(rtlpriv, tmp_buf,
 c2h_cmd_len);
break;
-   case C2H_8192E_RA_RPT:
+   case C2H_RA_RPT:
_rtl92ee_c2h_ra_report_handler(hw, tmp_buf, c2h_cmd_len);
break;
default:
@@ -948,8 +948,8 @@ void rtl92ee_c2h_packet_handler(struct ieee80211_hw *hw, u8 
*buffer, u8 len)
  "[C2H packet], Content Hex:\n", tmp_buf, c2h_cmd_len);
 
switch (c2h_cmd_id) {
-   case C2H_8192E_BT_INFO:
-   case C2H_8192E_BT_MP:
+   case C2H_BT_INFO:
+   case C2H_BT_MP:
rtl_c2hcmd_enqueue(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf);
break;
default:
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
index b770f722daa6..8325adaa9663 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.h
@@ -128,17 +128,6 @@ enum rtl8192e_h2c_cmd {
MAX_92E_H2CCMD
 };
 
-enum rtl8192e_c2h_evt {
-   C2H_8192E_DBG = 0,
-   C2H_8192E_LB = 1,
-   C2H_8192E_TXBF = 2,
-   C2H_8192E_TX_REPORT = 3,
-   C2H_8192E_BT_INFO = 9,
-   C2H_8192E_BT_MP = 11,
-   C2H_8192E_RA_RPT = 12,
-   MAX_8192E_C2HEVENT
-};
-
 #define pagenum_128(_len)  \
(u32)(((_len) >> 7) + ((_len) & 0x7F ? 1 : 0))
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
index 4b963fd27d64..34703b9cf5e8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
@@ -712,23 +712,23 @@ void rtl8723be_c2h_content_parsing(struct ieee80211_hw 
*hw,
struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 
switch (c2h_cmd_id) {
-   case C2H_8723B_DBG:
+   case C2H_DBG:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
 "[C2H], C2H_8723BE_DBG!!\n");
break;
-   case C2H_8723B_TX_REPORT:
+   case C2H_TX_REPORT:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
 "[C2H], C2H_8723BE_TX_REPORT!\n");
rtl_tx_report_handler(hw, tmp_buf, c2h_cmd_len);
break;
-   case C2H_8723B_BT_INFO:
+   case C2H_BT_INFO:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
 "[C2H], 

[PATCH 11/14] rtlwifi: remove hal_op c2h_content_parsing

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

Similar to rx_command_packet, we can call rtl_c2h_content_parsing so the
hal_op isn't necessary.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 7 +++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c | 1 -
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 1 -
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 1 -
 drivers/net/wireless/realtek/rtlwifi/wifi.h | 2 --
 5 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 0d03e98f9cb4..927b7d231576 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -2346,7 +2346,6 @@ void rtl_c2h_content_parsing(struct ieee80211_hw *hw, u8 
cmd_id,
break;
}
 }
-EXPORT_SYMBOL_GPL(rtl_c2h_content_parsing);
 
 void rtl_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len)
 {
@@ -2401,9 +2400,9 @@ void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int 
exec)
if (!c2hcmd)
break;
 
-   if (rtlpriv->cfg->ops->c2h_content_parsing && exec)
-   rtlpriv->cfg->ops->c2h_content_parsing(hw,
-   c2hcmd->tag, c2hcmd->len, c2hcmd->val);
+   if (exec)
+   rtl_c2h_content_parsing(hw, c2hcmd->tag,
+   c2hcmd->len, c2hcmd->val);
 
/* free */
kfree(c2hcmd->val);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index 5b67ad748d67..9ea62599ecbb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -250,7 +250,6 @@ static struct rtl_hal_ops rtl8192ee_hal_ops = {
.set_rfreg = rtl92ee_phy_set_rf_reg,
.fill_h2c_cmd = rtl92ee_fill_h2c_cmd,
.get_btc_status = rtl92ee_get_btc_status,
-   .c2h_content_parsing = rtl_c2h_content_parsing,
.c2h_ra_report_handler = rtl92ee_c2h_ra_report_handler,
 };
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
index a41e67b3f38b..c9f7b042d9c6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
@@ -262,7 +262,6 @@ static struct rtl_hal_ops rtl8723be_hal_ops = {
.fill_h2c_cmd = rtl8723be_fill_h2c_cmd,
.get_btc_status = rtl8723be_get_btc_status,
.is_fw_header = is_fw_header,
-   .c2h_content_parsing = rtl_c2h_content_parsing,
 };
 
 static struct rtl_mod_params rtl8723be_mod_params = {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
index 8ff8a406db52..77f6401021c9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
@@ -303,7 +303,6 @@ static struct rtl_hal_ops rtl8821ae_hal_ops = {
.set_rfreg = rtl8821ae_phy_set_rf_reg,
.fill_h2c_cmd = rtl8821ae_fill_h2c_cmd,
.get_btc_status = rtl8821ae_get_btc_status,
-   .c2h_content_parsing = rtl_c2h_content_parsing,
.c2h_ra_report_handler = rtl8821ae_c2h_ra_report_handler,
.add_wowlan_pattern = rtl8821ae_add_wowlan_pattern,
 };
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index b40d8f5bbdce..930e1ec2280f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2344,8 +2344,6 @@ struct rtl_hal_ops {
   struct rtl_wow_pattern *rtl_pattern,
   u8 index);
u16 (*get_available_desc)(struct ieee80211_hw *hw, u8 q_idx);
-   void (*c2h_content_parsing)(struct ieee80211_hw *hw, u8 tag, u8 len,
-   u8 *val);
void (*c2h_ra_report_handler)(struct ieee80211_hw *hw,
  u8 *cmd_buf, u8 cmd_len);
 };
-- 
2.15.1



[PATCH 00/14] rtlwifi: remove duplicate C2H handlers

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

The goal of patch 1/14 and 2/14 is to use keep-alive mechanism in mac80211
stack that needs accurate TX ack status for null frame reported by firmware
through C2H.
The remaining patches are step by step to remove duplicate C2H handlers
that widely distributed in IC specific files. An example of calling flow
before this patchset is:
_rtl_pci_rx_interrupt() -> 
rtlpriv->cfg->ops->rx_command_packet() =
rtl8723be_rx_command_packet() -->
rtl8723be_c2h_packet_handler() -->
case 1: rtl_c2hcmd_enqueue()
case 2: rtl8723be_c2h_content_parsing()

if case 1:
rtl_c2hcmd_launcher() ->
rtlpriv->cfg->ops->c2h_content_parsing() =
rtl8723be_c2h_content_parsing()

This patchset remove two ops:
rtlpriv->cfg->ops->rx_command_packet()
rtlpriv->cfg->ops->c2h_content_parsing()

But a special C2H is still existing, so add one op for RA report:
rtlpriv->cfg->ops->c2h_ra_report_handler()

Finally, calling flow becomes:
_rtl_pci_rx_interrupt() -->
rtl_c2hcmd_enqueue() -->
case 1: enqueue
case 2: rtl_c2h_content_parsing() if fast_cmd

if case 1:
rtl_c2hcmd_launcher() ->
rtl_c2h_content_parsing() ->
hal_ops->c2h_ra_report_handler() =
rtl8821ae_c2h_ra_report_handler() if C2H_RA_RPT


Ping-Ke Shih (13):
  rtlwifi: remove CONNECTION_MONITOR flag
  rtlwifi: remove duplicate rx_packet_type definition
  rtlwifi: rename register-based C2H command IDs to V0
  rtlwifi: remove duplicate C2H definition
  rtlwifi: remove unused fw C2H command ID
  rtlwifi: remove dummy hal_op rx_command_packet from rtl8188ee and
rtl8723ae
  rtlwifi: Add hal_op c2h_ra_report_handler for special process
  rtlwifi: remove duplicate C2H handler
  rtlwifi: remove hal_op rx_command_packet
  rtlwifi: remove hal_op c2h_content_parsing
  rtlwifi: use sk_buff to queue C2H commands
  rtlwifi: access skb->data to get C2H data by macro
  rtlwifi: fix btmpinfo timeout while processing C2H_BT_INFO

Tzu-En Huang (1):
  rtlwifi: support accurate nullfunc frame tx ack report

 drivers/net/wireless/realtek/rtlwifi/base.c| 208 -
 drivers/net/wireless/realtek/rtlwifi/base.h|   7 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c |  18 +-
 .../net/wireless/realtek/rtlwifi/rtl8188ee/def.h   |  32 
 .../net/wireless/realtek/rtlwifi/rtl8188ee/sw.c|   2 -
 .../net/wireless/realtek/rtlwifi/rtl8188ee/trx.c   |   7 -
 .../net/wireless/realtek/rtlwifi/rtl8188ee/trx.h   |   4 -
 .../net/wireless/realtek/rtlwifi/rtl8192ce/def.h   |  25 ---
 .../net/wireless/realtek/rtlwifi/rtl8192ee/def.h   |   8 -
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.c|  78 +---
 .../net/wireless/realtek/rtlwifi/rtl8192ee/fw.h|  16 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/sw.c|   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   |  29 +--
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.h   |   3 -
 .../net/wireless/realtek/rtlwifi/rtl8723ae/def.h   |  25 ---
 .../wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c   |   6 +-
 .../wireless/realtek/rtlwifi/rtl8723ae/hal_btc.h   |  20 +-
 .../net/wireless/realtek/rtlwifi/rtl8723ae/sw.c|   1 -
 .../net/wireless/realtek/rtlwifi/rtl8723ae/trx.c   |   7 -
 .../net/wireless/realtek/rtlwifi/rtl8723ae/trx.h   |   3 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/def.h   |   8 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.c|  69 ---
 .../net/wireless/realtek/rtlwifi/rtl8723be/fw.h|  13 --
 .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c|   2 -
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.c   |  30 +--
 .../net/wireless/realtek/rtlwifi/rtl8723be/trx.h   |   3 -
 .../net/wireless/realtek/rtlwifi/rtl8821ae/def.h   |  33 
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c|  69 +--
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.h|  21 +--
 .../net/wireless/realtek/rtlwifi/rtl8821ae/sw.c|   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.c   |  31 +--
 .../net/wireless/realtek/rtlwifi/rtl8821ae/trx.h   |   3 -
 drivers/net/wireless/realtek/rtlwifi/wifi.h|  56 +-
 33 files changed, 254 insertions(+), 589 deletions(-)

-- 
2.15.1



[PATCH 12/14] rtlwifi: use sk_buff to queue C2H commands

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

We use 'struct rtl_c2hcmd' to store C2H commands originally, and the code
is slightly complex to enqueue and dequeue and also wastes time to
allocate and memcpy data. Since C2H commands are asynchronous events,
they can be processed in work queue, so RX ISR enqueues C2H result in
removal of rtl_c2h_packet_handler().

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 96 +++--
 drivers/net/wireless/realtek/rtlwifi/base.h |  5 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c  |  3 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h |  2 +-
 4 files changed, 25 insertions(+), 81 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 927b7d231576..61f12f86fcd4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -571,9 +571,9 @@ int rtl_init_core(struct ieee80211_hw *hw)
spin_lock_init(>locks.iqk_lock);
/* <5> init list */
INIT_LIST_HEAD(>entry_list);
-   INIT_LIST_HEAD(>c2hcmd_list);
INIT_LIST_HEAD(>scan_list.list);
skb_queue_head_init(>tx_report.queue);
+   skb_queue_head_init(>c2hcmd_queue);
 
rtlmac->link_state = MAC80211_NOLINK;
 
@@ -2262,56 +2262,36 @@ void rtl_fwevt_wq_callback(void *data)
rtlpriv->cfg->ops->c2h_command_handle(hw);
 }
 
-void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val)
+void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
unsigned long flags;
-   struct rtl_c2hcmd *c2hcmd;
-
-   c2hcmd = kmalloc(sizeof(*c2hcmd),
-in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
-
-   if (!c2hcmd)
-   goto label_err;
-
-   c2hcmd->val = kmalloc(len,
- in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
-
-   if (!c2hcmd->val)
-   goto label_err2;
-
-   /* fill data */
-   c2hcmd->tag = tag;
-   c2hcmd->len = len;
-   memcpy(c2hcmd->val, val, len);
 
/* enqueue */
spin_lock_irqsave(>locks.c2hcmd_lock, flags);
 
-   list_add_tail(>list, >c2hcmd_list);
+   __skb_queue_tail(>c2hcmd_queue, skb);
 
spin_unlock_irqrestore(>locks.c2hcmd_lock, flags);
 
/* wake up wq */
queue_delayed_work(rtlpriv->works.rtl_wq, >works.c2hcmd_wq, 0);
-
-   return;
-
-label_err2:
-   kfree(c2hcmd);
-
-label_err:
-   RT_TRACE(rtlpriv, COMP_CMD, DBG_WARNING,
-"C2H cmd enqueue fail.\n");
 }
 EXPORT_SYMBOL(rtl_c2hcmd_enqueue);
 
-void rtl_c2h_content_parsing(struct ieee80211_hw *hw, u8 cmd_id,
-u8 cmd_len, u8 *cmd_buf)
+static void rtl_c2h_content_parsing(struct ieee80211_hw *hw,
+   struct sk_buff *skb)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal_ops *hal_ops = rtlpriv->cfg->ops;
const struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
+   u8 cmd_id, cmd_seq, cmd_len;
+   u8 *cmd_buf = NULL;
+
+   cmd_id = skb->data[0];
+   cmd_seq = skb->data[1];
+   cmd_len = skb->len - 2;
+   cmd_buf = skb->data + 2;
 
switch (cmd_id) {
case C2H_DBG:
@@ -2347,67 +2327,35 @@ void rtl_c2h_content_parsing(struct ieee80211_hw *hw, 
u8 cmd_id,
}
 }
 
-void rtl_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len)
-{
-   struct rtl_priv *rtlpriv = rtl_priv(hw);
-   u8 c2h_cmd_id = 0, c2h_cmd_seq = 0, c2h_cmd_len = 0;
-   u8 *tmp_buf = NULL;
-
-   c2h_cmd_id = buffer[0];
-   c2h_cmd_seq = buffer[1];
-   c2h_cmd_len = len - 2;
-   tmp_buf = buffer + 2;
-
-   RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
-"[C2H packet], c2hCmdId=0x%x, c2hCmdSeq=0x%x, c2hCmdLen=%d\n",
-c2h_cmd_id, c2h_cmd_seq, c2h_cmd_len);
-
-   RT_PRINT_DATA(rtlpriv, COMP_FW, DBG_TRACE,
- "[C2H packet], Content Hex:\n", tmp_buf, c2h_cmd_len);
-
-   switch (c2h_cmd_id) {
-   case C2H_BT_INFO:
-   case C2H_BT_MP:
-   rtl_c2hcmd_enqueue(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf);
-   break;
-   default:
-   rtl_c2h_content_parsing(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf);
-   break;
-   }
-}
-EXPORT_SYMBOL_GPL(rtl_c2h_packet_handler);
-
 void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
+   struct sk_buff *skb;
unsigned long flags;
-   struct rtl_c2hcmd *c2hcmd;
int i;
 
for (i = 0; i < 200; i++) {
/* dequeue a task */
spin_lock_irqsave(>locks.c2hcmd_lock, flags);
 
-   c2hcmd = list_first_entry_or_null(>c2hcmd_list,
- struct rtl_c2hcmd, list);
-
- 

[PATCH 03/14] rtlwifi: remove duplicate rx_packet_type definition

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

Move duplicate definitions from def.h of ic folder to wifi.h

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h | 7 ---
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/def.h | 8 
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/def.h | 8 
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h | 8 
 drivers/net/wireless/realtek/rtlwifi/wifi.h  | 8 
 5 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h
index 0532b9852444..32492d64d685 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h
@@ -137,13 +137,6 @@ enum version_8188e {
VERSION_UNKNOWN = 0xFF,
 };
 
-enum rx_packet_type {
-   NORMAL_RX,
-   TX_REPORT1,
-   TX_REPORT2,
-   HIS_REPORT,
-};
-
 enum rtl819x_loopback_e {
RTL819X_NO_LOOPBACK = 0,
RTL819X_MAC_LOOPBACK = 1,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/def.h
index 60f5728b4e2d..9f7e7bb8610b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/def.h
@@ -47,14 +47,6 @@ enum version_8192e {
VERSION_UNKNOWN = 0xFF,
 };
 
-enum rx_packet_type {
-   NORMAL_RX,
-   TX_REPORT1,
-   TX_REPORT2,
-   HIS_REPORT,
-   C2H_PACKET,
-};
-
 enum rtl_desc_qsel {
QSLT_BK = 0x2,
QSLT_BE = 0x0,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/def.h
index 025ea5c0f3f6..5e5403d69220 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/def.h
@@ -38,14 +38,6 @@
 /* Currently only for RTL8723B */
 #define EXT_VENDOR_ID  (BIT(18) | BIT(19))
 
-enum rx_packet_type {
-   NORMAL_RX,
-   TX_REPORT1,
-   TX_REPORT2,
-   HIS_REPORT,
-   C2H_PACKET,
-};
-
 enum rtl_desc_qsel {
QSLT_BK = 0x2,
QSLT_BE = 0x0,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h
index dfbdf539de1a..498f716bfc73 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/def.h
@@ -332,14 +332,6 @@ enum rtl_desc_qsel {
QSLT_CMD = 0x13,
 };
 
-enum rx_packet_type {
-   NORMAL_RX,
-   TX_REPORT1,
-   TX_REPORT2,
-   HIS_REPORT,
-   C2H_PACKET,
-};
-
 struct phy_sts_cck_8821ae_t {
u8 adc_pwdb_X[4];
u8 sq_rpt;
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 1259d2b66d17..81ac036760fc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -1010,6 +1010,14 @@ enum dm_info_query {
DM_INFO_SIZE,
 };
 
+enum rx_packet_type {
+   NORMAL_RX,
+   TX_REPORT1,
+   TX_REPORT2,
+   HIS_REPORT,
+   C2H_PACKET,
+};
+
 struct rtlwifi_tx_info {
int sn;
unsigned long send_time;
-- 
2.15.1



[PATCH 13/14] rtlwifi: access skb->data to get C2H data by macro

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

The format of C2H data is ID(1 byte) + Length(1 byte) + value, and it is
more readable to use macros to access C2H data.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 8 
 drivers/net/wireless/realtek/rtlwifi/wifi.h | 5 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 61f12f86fcd4..a5939ddfa9cb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -2288,10 +2288,10 @@ static void rtl_c2h_content_parsing(struct ieee80211_hw 
*hw,
u8 cmd_id, cmd_seq, cmd_len;
u8 *cmd_buf = NULL;
 
-   cmd_id = skb->data[0];
-   cmd_seq = skb->data[1];
-   cmd_len = skb->len - 2;
-   cmd_buf = skb->data + 2;
+   cmd_id = GET_C2H_CMD_ID(skb->data);
+   cmd_seq = GET_C2H_SEQ(skb->data);
+   cmd_len = skb->len - C2H_DATA_OFFSET;
+   cmd_buf = GET_C2H_DATA_PTR(skb->data);
 
switch (cmd_id) {
case C2H_DBG:
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 9e620b943f8c..0f3b98c5227f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -177,6 +177,11 @@ enum rtl_c2h_evt_v2 {
C2H_V2_CCX_RPT = 0x0F,
 };
 
+#define GET_C2H_CMD_ID(c2h)({u8 *__c2h = c2h; __c2h[0]; })
+#define GET_C2H_SEQ(c2h)   ({u8 *__c2h = c2h; __c2h[1]; })
+#define C2H_DATA_OFFSET2
+#define GET_C2H_DATA_PTR(c2h)  ({u8 *__c2h = c2h; &__c2h[C2H_DATA_OFFSET]; })
+
 #define GET_TX_REPORT_SN_V1(c2h)   (c2h[6])
 #define GET_TX_REPORT_ST_V1(c2h)   (c2h[0] & 0xC0)
 #define GET_TX_REPORT_RETRY_V1(c2h)(c2h[2] & 0x3F)
-- 
2.15.1



[PATCH 04/14] rtlwifi: rename register-based C2H command IDs to V0

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

Current chips use packet-based C2H commands whose IDs differ from old
ones, so this commit simply gives C2H_V0_ as prefix of command IDs.

Signed-off-by: Ping-Ke Shih 
---
 .../net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c |  6 +++---
 .../net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.h | 20 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c
index ec9bcf32f0ab..788de88ab1ee 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c
@@ -1749,13 +1749,13 @@ void rtl_8723e_c2h_command_handle(struct ieee80211_hw 
*hw)
 
 
switch (c2h_event.cmd_id) {
-   case C2H_BT_RSSI:
+   case C2H_V0_BT_RSSI:
break;
 
-   case C2H_BT_OP_MODE:
+   case C2H_V0_BT_OP_MODE:
break;
 
-   case BT_INFO:
+   case C2H_V0_BT_INFO:
RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
"BT info Byte[0] (ID) is 0x%x\n",
c2h_event.cmd_id);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.h
index 3723d7476717..756868897d8b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.h
@@ -130,17 +130,17 @@ enum bt_state {
BT_INFO_STATE_MAX = 7
 };
 
-enum rtl8723e_c2h_evt {
-   C2H_DBG = 0,
-   C2H_TSF = 1,
-   C2H_AP_RPT_RSP = 2,
+enum rtl8723e_c2h_evt_v0 {
+   C2H_V0_DBG = 0,
+   C2H_V0_TSF = 1,
+   C2H_V0_AP_RPT_RSP = 2,
/* The FW notify the report of the specific tx packet. */
-   C2H_CCX_TX_RPT = 3,
-   C2H_BT_RSSI = 4,
-   C2H_BT_OP_MODE = 5,
-   C2H_HW_INFO_EXCH = 10,
-   C2H_C2H_H2C_TEST = 11,
-   BT_INFO = 12,
+   C2H_V0_CCX_TX_RPT = 3,
+   C2H_V0_BT_RSSI = 4,
+   C2H_V0_BT_OP_MODE = 5,
+   C2H_V0_HW_INFO_EXCH = 10,
+   C2H_V0_C2H_H2C_TEST = 11,
+   C2H_V0_BT_INFO = 12,
MAX_C2HEVENT
 };
 
-- 
2.15.1



[PATCH 14/14] rtlwifi: fix btmpinfo timeout while processing C2H_BT_INFO

2018-05-18 Thread pkshih
From: Ping-Ke Shih 

In former patch, I enqueu all C2H commands and processed by a workqueue.
In case C2H_BT_INFO will issue a H2C command to set BT reg, and wait for
a C2H ack. But it is totally impossible that C2H workqueue waits for a
C2H command, so kernel log warn
rtlwifi: :<0> btmpinfo wait (req_num=0) timeout

Since the C2H ack command C2H_BT_MP can be safely processed in interrupt
context, add a fast command path to deal with the command.

Signed-off-by: Ping-Ke Shih 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index a5939ddfa9cb..39c817eddd78 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -2262,11 +2262,33 @@ void rtl_fwevt_wq_callback(void *data)
rtlpriv->cfg->ops->c2h_command_handle(hw);
 }
 
+static void rtl_c2h_content_parsing(struct ieee80211_hw *hw,
+   struct sk_buff *skb);
+
+static bool rtl_c2h_fast_cmd(struct ieee80211_hw *hw, struct sk_buff *skb)
+{
+   u8 cmd_id = GET_C2H_CMD_ID(skb->data);
+
+   switch (cmd_id) {
+   case C2H_BT_MP:
+   return true;
+   default:
+   break;
+   }
+
+   return false;
+}
+
 void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
unsigned long flags;
 
+   if (rtl_c2h_fast_cmd(hw, skb)) {
+   rtl_c2h_content_parsing(hw, skb);
+   return;
+   }
+
/* enqueue */
spin_lock_irqsave(>locks.c2hcmd_lock, flags);
 
-- 
2.15.1



Re: [RFC 0/2] nl80211/mac80211 Add support for per-rate rx statistics

2018-05-18 Thread Johannes Berg
On Wed, 2018-05-16 at 10:04 +0530, Sriram R wrote:

> But, I wanted to avoid,
>   1. Static indexing and memory allocation based on MCS count((8x3)24 
> entries for HT and (10x3)30 for VHT within allocated 36 entries) so that 
> it's scalable.

Do you expect that the rate control on the other side flips through
MCSes so fast that this little cache will need to be flushed
significantly?

>   2. Remote chance of dropping a stats(Though it does not have much 
> impact)

Yeah this doesn't seem like a concern either way. How many packets and
how little time ... :)

> And to allow,
>   1. A 'station dump' kind of interface to dump the complete collected 
> stats instead of returning only current snapshot of the stats within 
> kernel.

This *completely* contradict keeping limits on the kernel memory
consumed, so basically I don't think this is feasible.

> Also, do you feel it would be good to have both ,i.e complete stats 
> collection within kernel(this approach) and dump+clear of stats on 
> reaching threshold(your approach) and have one of these two modes 
> selected based on the requirement.

No, honestly, I don't. If an application wants these statistics, then I
feel that we can impose *some* requirements and not leave it at "let me
just enable it and have the kernel do all the work for me".

johannes


Re: [RESEND PATCH] cfg80211: dynamically allocate per-tid stats for station info

2018-05-18 Thread Johannes Berg
On Thu, 2018-05-10 at 13:50 +0200, Arend van Spriel wrote:
> 
> Here an alternative approach. Currently the only cfg80211-based driver
> providing per-tid stats is mac80211. This patch only changes mac80211
> and the other driver can keep using stack allocation. Even mac80211 could
> if wanted, but I left that part as is.

I decided to take this and remove the BIT() thing entirely (you had a
bug there anyway)

johannes


Re: ACS ACR122U not working: pn533_usb 1-1:1.0: NFC: Couldn't poweron...

2018-05-18 Thread Greg KH
On Fri, May 18, 2018 at 10:56:25AM +0200, Arend van Spriel wrote:
> On 5/17/2018 6:46 PM, Greg KH wrote:
> > On Thu, May 17, 2018 at 06:40:04PM +0200, Greg KH wrote:
> > > Adding the network and NFC developers as this really is a NFC driver
> > > bug, not a USB core issue...
> > > 
> > > On Thu, May 17, 2018 at 04:12:17PM +0200, Greg KH wrote:
> > > > On Thu, May 17, 2018 at 02:10:57PM +0100, Carlos Manuel Santos wrote:
> > > > > Hello.
> > > > > I'm having troubles with this NFC card reader. It seems kernel driver
> > > > > pn533 is not working properly.
> > > > > At this moment I have my work stalled. I need to add NFC support to a
> > > > > software product and I can't get the device to work. NFC tools won't
> > > > > work, the device is not detected.
> > > > > 
> > > > > This is what I get from "dmesg":
> > > > > 
> > > > > [4.182300] nfc: nfc_init: NFC Core ver 0.1
> > > > > [4.182318] NET: Registered protocol family 39
> > > > > [4.184676] hidraw: raw HID events driver (C) Jiri Kosina
> > > > > [4.193366] [ cut here ]
> > > > > [4.193366] transfer buffer not dma capable
> > > > > [4.193398] WARNING: CPU: 2 PID: 259 at drivers/usb/core/hcd.c:1584
> > > > > usb_hcd_map_urb_for_dma+0x413/0x570 [usbcore]
> > > > > [4.193399] Modules linked in: usbhid(+) pn533_usb(+) pn533 hid nfc
> > > > > snd_soc_skl(+) rtsx_usb_ms snd_soc_skl_ipc memstick snd_hda_ext_core
> > > > > snd_soc_sst_dsp snd_soc_sst_ipc ecdh_generic snd_soc_acpi snd_soc_core
> > > > > snd_hda_codec_realtek(+) snd_hda_codec_generic snd_compress ac97_bus
> > > > > snd_pcm_dmaengine arc4 intel_rapl x86_pkg_temp_thermal
> > > > > intel_powerclamp coretemp kvm_intel snd_hda_intel kvm iTCO_wdt
> > > > > snd_hda_codec iTCO_vendor_support iwlmvm i915 nls_iso8859_1 nls_cp437
> > > > > mac80211 vfat fat ppdev irqbypass crct10dif_pclmul crc32_pclmul
> > > > > ghash_clmulni_intel uvcvideo pcbc snd_hda_core iwlwifi
> > > > > videobuf2_vmalloc videobuf2_memops aesni_intel videobuf2_v4l2
> > > > > snd_hwdep aes_x86_64 crypto_simd glue_helper cryptd snd_pcm
> > > > > intel_cstate videobuf2_common e1000e intel_uncore snd_timer cfg80211
> > > > > intel_rapl_perf tpm_crb psmouse
> > > > > [4.193427]  videodev pcspkr input_leds intel_wmi_thunderbolt
> > > > > wmi_bmof ptp snd pps_core i2c_i801 soundcore toshiba_acpi mei_me media
> > > > > sparse_keymap toshiba_bluetooth mei intel_gtt industrialio
> > > > > intel_pch_thermal shpchp parport_pc tpm_tis tpm_tis_core battery
> > > > > rfkill parport evdev rtc_cmos mac_hid tpm rng_core ac sg crypto_user
> > > > > ip_tables x_tables rtsx_usb_sdmmc mmc_core rtsx_usb ext4
> > > > > crc32c_generic crc16 mbcache jbd2 fscrypto sr_mod cdrom sd_mod
> > > > > serio_raw atkbd libps2 ahci libahci xhci_pci xhci_hcd crc32c_intel
> > > > > libata usbcore scsi_mod usb_common i8042 serio nouveau led_class
> > > > > mxm_wmi wmi i2c_algo_bit drm_kms_helper syscopyarea sysfillrect
> > > > > sysimgblt fb_sys_fops ttm drm agpgart
> > > > > [4.193458] CPU: 2 PID: 259 Comm: systemd-udevd Not tainted 
> > > > > 4.16.8-1-ARCH #1
> > > > > [4.193459] Hardware name: TOSHIBA SATELLITE PRO A50-C/SATELLITE
> > > > > PRO A50-C, BIOS Version 7.50   09/26/2016
> > > > > [4.193467] RIP: 0010:usb_hcd_map_urb_for_dma+0x413/0x570 [usbcore]
> > > > > [4.193468] RSP: 0018:a3b44282f9f8 EFLAGS: 00010282
> > > > > [4.193469] RAX:  RBX: 981fc9e320c0 RCX: 
> > > > > 0001
> > > > > [4.193470] RDX: 8001 RSI: 0002 RDI: 
> > > > > 
> > > > > [4.193471] RBP: 981fd42f R08: 000713ed01d2 R09: 
> > > > > 001f
> > > > > [4.193472] R10: 0344 R11: f300 R12: 
> > > > > 014000c0
> > > > > [4.193473] R13: fff5 R14: 981fd2592b98 R15: 
> > > > > c0410280
> > > > > [4.193475] FS:  7f4fb98d0d40() GS:981fe6d0()
> > > > > knlGS:
> > > > > [4.193476] CS:  0010 DS:  ES:  CR0: 80050033
> > > > > [4.193477] CR2: 562b4a68f6e8 CR3: 0004532d6004 CR4: 
> > > > > 003606e0
> > > > > [4.193478] Call Trace:
> > > > > [4.193488]  usb_hcd_submit_urb+0x38d/0xb20 [usbcore]
> > > > > [4.193492]  ? pn533_usb_probe+0x61/0x4d0 [pn533_usb]
> > > > > [4.193495]  ? __kmalloc+0x19e/0x220
> > > > > [4.193498]  pn533_usb_probe+0x397/0x4d0 [pn533_usb]
> > > > > [4.193507]  usb_probe_interface+0xe4/0x2f0 [usbcore]
> > > > > [4.193511]  driver_probe_device+0x2b9/0x460
> > > > > [4.193514]  ? __driver_attach+0xb6/0xe0
> > > > > [4.193516]  ? driver_probe_device+0x460/0x460
> > > > > [4.193518]  ? bus_for_each_dev+0x76/0xc0
> > > > > [4.193520]  ? bus_add_driver+0x152/0x230
> > > > > [4.193522]  ? driver_register+0x6b/0xb0
> > > > > [4.193530]  ? usb_register_driver+0x7a/0x130 [usbcore]
> > > > > [4.193531]  ? 0xc13b6000
> > > 

Re: ACS ACR122U not working: pn533_usb 1-1:1.0: NFC: Couldn't poweron...

2018-05-18 Thread Johannes Berg
On Fri, 2018-05-18 at 10:56 +0200, Arend van Spriel wrote:
> 
> > +   buffer = kmalloc(sizeof(cmd), GFP_KERNEL);
> > +   if (!buffer)
> > +   return -ENOMEM;
> > +   memcpy(buffer, cmd, sizeof(cmd));

It should also use kmemdup() ;-)

johannes


Re: [PATCH V3 0/5] Update brcm firmware files

2018-05-18 Thread Arend van Spriel

On 5/18/2018 9:04 AM, Hans de Goede wrote:

Hi,

On 15-05-18 10:43, Arend van Spriel wrote:

On 5/14/2018 2:05 PM, Josh Boyer wrote:

n Mon, May 14, 2018 at 6:11 AM Arend van Spriel <
arend.vanspr...@broadcom.com> wrote:


On 3/16/2018 3:08 PM, Chi-Hsien Lin wrote:

Update brcm firmware files and WHENCE accordingly.



Hi firmware-maintainers,



It seems this series somehow got lost. Can these still be applied. They
can be found in the linux-wireless patchwork database. I provided links
below.


All 5 of these move the respective firmware files under the Cypress
license.  It has been pointed out that the Cypress license has some
questionable language in it and that people have been in touch to try
and
get this resolved.  I'm personally waiting on applying them until the
licence issue is sorted out.


Thanks, Josh

I could not find any such response. Has it been taken off-list? Seems
like 2 months is quite some time, but maybe there are lawyers involved
;-)


Yes the discussion about this has been happening off-list. IANAL but
the gist of it is (AFAIK) that:

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENCE.cypress


has a clause which allows Cypress to retro-actively revoke the LICENSE:

"either party may terminate this Agreement at any time with or without
cause."
...
"Upon termination, you must destroy all copies of Software in your
possession or
control."

So upon revokation we would have to remove the files from linux-firmware
(rewrite git history?) and since distros get their redistribution rights
from this license too they would also need to remove it from their packages
including all mirrors and archives of older versions. Which simply is not
feasible and no other license in linux-firmware has such a clause.


Check again. From LICENCE.broadcom_bcm43xx:

"""
2.  Restrictions. Licensee shall distribute Software with a copy of this
Agreement. Licensee shall not remove, efface or obscure any copyright or
trademark notices from the Software. Reproductions of the Broadcom copyright
notice shall be included with each copy of the Software, except where such
Software is embedded in a manner not readily accessible to the end user.
Licensee shall not: (i) use, license, sell or otherwise distribute the 
Software

except as provided in this Agreement; (ii) attempt to modify in any way,
reverse engineer, decompile or disassemble any portion of the Software; or
(iii) use the Software or other material in violation of any applicable 
law or
regulation, including but not limited to any regulatory agency. This 
Agreement
shall automatically terminate upon Licensee\u2019s failure to comply 
with any of the
terms of this Agreement. In such event, Licensee will destroy all copies 
of the

Software and its component parts.
"""

Regards,
Arend



Re: ACS ACR122U not working: pn533_usb 1-1:1.0: NFC: Couldn't poweron...

2018-05-18 Thread Arend van Spriel

On 5/17/2018 6:46 PM, Greg KH wrote:

On Thu, May 17, 2018 at 06:40:04PM +0200, Greg KH wrote:

Adding the network and NFC developers as this really is a NFC driver
bug, not a USB core issue...

On Thu, May 17, 2018 at 04:12:17PM +0200, Greg KH wrote:

On Thu, May 17, 2018 at 02:10:57PM +0100, Carlos Manuel Santos wrote:

Hello.
I'm having troubles with this NFC card reader. It seems kernel driver
pn533 is not working properly.
At this moment I have my work stalled. I need to add NFC support to a
software product and I can't get the device to work. NFC tools won't
work, the device is not detected.

This is what I get from "dmesg":

[4.182300] nfc: nfc_init: NFC Core ver 0.1
[4.182318] NET: Registered protocol family 39
[4.184676] hidraw: raw HID events driver (C) Jiri Kosina
[4.193366] [ cut here ]
[4.193366] transfer buffer not dma capable
[4.193398] WARNING: CPU: 2 PID: 259 at drivers/usb/core/hcd.c:1584
usb_hcd_map_urb_for_dma+0x413/0x570 [usbcore]
[4.193399] Modules linked in: usbhid(+) pn533_usb(+) pn533 hid nfc
snd_soc_skl(+) rtsx_usb_ms snd_soc_skl_ipc memstick snd_hda_ext_core
snd_soc_sst_dsp snd_soc_sst_ipc ecdh_generic snd_soc_acpi snd_soc_core
snd_hda_codec_realtek(+) snd_hda_codec_generic snd_compress ac97_bus
snd_pcm_dmaengine arc4 intel_rapl x86_pkg_temp_thermal
intel_powerclamp coretemp kvm_intel snd_hda_intel kvm iTCO_wdt
snd_hda_codec iTCO_vendor_support iwlmvm i915 nls_iso8859_1 nls_cp437
mac80211 vfat fat ppdev irqbypass crct10dif_pclmul crc32_pclmul
ghash_clmulni_intel uvcvideo pcbc snd_hda_core iwlwifi
videobuf2_vmalloc videobuf2_memops aesni_intel videobuf2_v4l2
snd_hwdep aes_x86_64 crypto_simd glue_helper cryptd snd_pcm
intel_cstate videobuf2_common e1000e intel_uncore snd_timer cfg80211
intel_rapl_perf tpm_crb psmouse
[4.193427]  videodev pcspkr input_leds intel_wmi_thunderbolt
wmi_bmof ptp snd pps_core i2c_i801 soundcore toshiba_acpi mei_me media
sparse_keymap toshiba_bluetooth mei intel_gtt industrialio
intel_pch_thermal shpchp parport_pc tpm_tis tpm_tis_core battery
rfkill parport evdev rtc_cmos mac_hid tpm rng_core ac sg crypto_user
ip_tables x_tables rtsx_usb_sdmmc mmc_core rtsx_usb ext4
crc32c_generic crc16 mbcache jbd2 fscrypto sr_mod cdrom sd_mod
serio_raw atkbd libps2 ahci libahci xhci_pci xhci_hcd crc32c_intel
libata usbcore scsi_mod usb_common i8042 serio nouveau led_class
mxm_wmi wmi i2c_algo_bit drm_kms_helper syscopyarea sysfillrect
sysimgblt fb_sys_fops ttm drm agpgart
[4.193458] CPU: 2 PID: 259 Comm: systemd-udevd Not tainted 4.16.8-1-ARCH #1
[4.193459] Hardware name: TOSHIBA SATELLITE PRO A50-C/SATELLITE
PRO A50-C, BIOS Version 7.50   09/26/2016
[4.193467] RIP: 0010:usb_hcd_map_urb_for_dma+0x413/0x570 [usbcore]
[4.193468] RSP: 0018:a3b44282f9f8 EFLAGS: 00010282
[4.193469] RAX:  RBX: 981fc9e320c0 RCX: 0001
[4.193470] RDX: 8001 RSI: 0002 RDI: 
[4.193471] RBP: 981fd42f R08: 000713ed01d2 R09: 001f
[4.193472] R10: 0344 R11: f300 R12: 014000c0
[4.193473] R13: fff5 R14: 981fd2592b98 R15: c0410280
[4.193475] FS:  7f4fb98d0d40() GS:981fe6d0()
knlGS:
[4.193476] CS:  0010 DS:  ES:  CR0: 80050033
[4.193477] CR2: 562b4a68f6e8 CR3: 0004532d6004 CR4: 003606e0
[4.193478] Call Trace:
[4.193488]  usb_hcd_submit_urb+0x38d/0xb20 [usbcore]
[4.193492]  ? pn533_usb_probe+0x61/0x4d0 [pn533_usb]
[4.193495]  ? __kmalloc+0x19e/0x220
[4.193498]  pn533_usb_probe+0x397/0x4d0 [pn533_usb]
[4.193507]  usb_probe_interface+0xe4/0x2f0 [usbcore]
[4.193511]  driver_probe_device+0x2b9/0x460
[4.193514]  ? __driver_attach+0xb6/0xe0
[4.193516]  ? driver_probe_device+0x460/0x460
[4.193518]  ? bus_for_each_dev+0x76/0xc0
[4.193520]  ? bus_add_driver+0x152/0x230
[4.193522]  ? driver_register+0x6b/0xb0
[4.193530]  ? usb_register_driver+0x7a/0x130 [usbcore]
[4.193531]  ? 0xc13b6000
[4.193534]  ? do_one_initcall+0x48/0x13b
[4.193537]  ? free_unref_page_commit+0x6a/0x100
[4.193539]  ? kmem_cache_alloc_trace+0xdc/0x1c0
[4.193542]  ? do_init_module+0x5a/0x210
[4.193544]  ? load_module+0x247a/0x29f0
[4.193549]  ? SyS_init_module+0x139/0x180
[4.193550]  ? SyS_init_module+0x139/0x180
[4.193554]  ? do_syscall_64+0x74/0x190
[4.193556]  ? entry_SYSCALL_64_after_hwframe+0x3d/0xa2
[4.193559] Code: 49 39 c9 73 30 80 3d 7d b5 02 00 00 41 bd f5 ff
ff ff 0f 85 57 ff ff ff 48 c7 c7 88 9d 6e c0 c6 05 63 b5 02 00 01 e8
97 85 9a ec <0f> 0b 8b 53 64 e9 3a ff ff ff 65 48 8b 0c 25 00 5c 01 00
48 8b
[4.193589] ---[ end trace 37ff3cbaf04a5b5d ]---
[4.193612] usb 1-1: NFC: Reader power on cmd error -11
[4.193614] pn533_usb 1-1:1.0: NFC: Couldn't poweron the reader (error -11)
[4.193618] pn533_usb: 

Re: [PATCH] cfg80211: Fix support for flushing old scan results

2018-05-18 Thread Johannes Berg
On Fri, 2018-05-11 at 09:48 -0700, Tim Kourt wrote:
> __cfg80211_bss_expire function was incorrectly used to flush the BSS
> entries from the previous scan results, causing NL80211_SCAN_FLAG_FLUSH
> flag to have no effect.

Hmm. I guess I'm not convinced - what's the bug?

We flush anything that's older than our start, so that should work just
fine?

johannes


Re: [bug report] mwifiex: add rx histogram statistics support

2018-05-18 Thread Xinming Hu
Hi Dan,

Thanks for the report!
We also notice it recently, and have already fix it.
Just upstream the below fix
https://patchwork.kernel.org/patch/10408353/

Regards,
Simon

From: Dan Carpenter 
Sent: Thursday, May 17, 2018 17:27
To: Xinming Hu
Cc: linux-wireless@vger.kernel.org
Subject: [EXT] [bug report] mwifiex: add rx histogram statistics support

External Email

--
Hello Xinming Hu,

The patch cbf6e05527a7: "mwifiex: add rx histogram statistics
support" from Dec 23, 2014, leads to the following static checker
warning:

drivers/net/wireless/marvell/mwifiex/util.c:714 mwifiex_hist_data_set()
error: buffer underflow 'phist_data->snr' '(-128)-127'

drivers/net/wireless/marvell/mwifiex/util.c
   706  /* function to add histogram record */
   707  void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 
snr,
 
^^
   708 s8 nflr)
   709  {
   710  struct mwifiex_histogram_data *phist_data = priv->hist_data;
   711
   712  atomic_inc(_data->num_samples);
   713  atomic_inc(_data->rx_rate[rx_rate]);
   714  atomic_inc(_data->snr[snr]);
   715  atomic_inc(_data->noise_flr[128 + nflr]);
   716  atomic_inc(_data->sig_str[nflr - snr]);

Smatch complains that "snr" comes from skb->data so it's untrusted and
it can be less than zero and underflow the ->snr array.

->snr, ->noise_flr and ->sig_str all have 256 elements.  Obviously it
seems like "snr" should be declared as a u8 instead of an s8.  But I'm
not totally sure what to do about the ->noise_flr and ->sig_str[]
arrays.

   717  }

regards,
dan carpenter


[PATCH] mwifiex: correct histogram data with appropriate index

2018-05-18 Thread Xinming Hu
Correct snr/nr/rssi data index to avoid possible buffer underflow.

Signed-off-by: Xinming Hu 
---
 drivers/net/wireless/marvell/mwifiex/util.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/util.c 
b/drivers/net/wireless/marvell/mwifiex/util.c
index 0cd68ff..51ccf10 100644
--- a/drivers/net/wireless/marvell/mwifiex/util.c
+++ b/drivers/net/wireless/marvell/mwifiex/util.c
@@ -708,12 +708,14 @@ void mwifiex_hist_data_set(struct mwifiex_private *priv, 
u8 rx_rate, s8 snr,
   s8 nflr)
 {
struct mwifiex_histogram_data *phist_data = priv->hist_data;
+   s8 nf   = -nflr;
+   s8 rssi = snr - nflr;
 
atomic_inc(_data->num_samples);
atomic_inc(_data->rx_rate[rx_rate]);
-   atomic_inc(_data->snr[snr]);
-   atomic_inc(_data->noise_flr[128 + nflr]);
-   atomic_inc(_data->sig_str[nflr - snr]);
+   atomic_inc(_data->snr[snr + 128]);
+   atomic_inc(_data->noise_flr[nf + 128]);
+   atomic_inc(_data->sig_str[rssi + 128]);
 }
 
 /* function to reset histogram data during init/reset */
-- 
1.9.1



Re: [PATCH V3 0/5] Update brcm firmware files

2018-05-18 Thread Hans de Goede

Hi,

On 15-05-18 10:43, Arend van Spriel wrote:

On 5/14/2018 2:05 PM, Josh Boyer wrote:

n Mon, May 14, 2018 at 6:11 AM Arend van Spriel <
arend.vanspr...@broadcom.com> wrote:


On 3/16/2018 3:08 PM, Chi-Hsien Lin wrote:

Update brcm firmware files and WHENCE accordingly.



Hi firmware-maintainers,



It seems this series somehow got lost. Can these still be applied. They
can be found in the linux-wireless patchwork database. I provided links
below.


All 5 of these move the respective firmware files under the Cypress
license.  It has been pointed out that the Cypress license has some
questionable language in it and that people have been in touch to try and
get this resolved.  I'm personally waiting on applying them until the
licence issue is sorted out.


Thanks, Josh

I could not find any such response. Has it been taken off-list? Seems like 2 
months is quite some time, but maybe there are lawyers involved ;-)


Yes the discussion about this has been happening off-list. IANAL but
the gist of it is (AFAIK) that:

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENCE.cypress

has a clause which allows Cypress to retro-actively revoke the LICENSE:

"either party may terminate this Agreement at any time with or without cause."
...
"Upon termination, you must destroy all copies of Software in your possession or
control."

So upon revokation we would have to remove the files from linux-firmware
(rewrite git history?) and since distros get their redistribution rights
from this license too they would also need to remove it from their packages
including all mirrors and archives of older versions. Which simply is not
feasible and no other license in linux-firmware has such a clause.

Regards,

Hans


[PATCH] ACS ACR122U not working: pn533_usb 1-1:1.0: NFC: fix memdup.cocci warnings

2018-05-18 Thread Julia Lawall

From: kbuild test robot <fengguang...@intel.com>

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: fe1c559e1567 ("ACS ACR122U not working: pn533_usb 1-1:1.0: NFC: Couldn't 
poweron...")
CC: Greg KH <gre...@linuxfoundation.org>
Signed-off-by: kbuild test robot <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---

url:
https://github.com/0day-ci/linux/commits/Greg-KH/NFC-pn533-don-t-send-USB-data-off-of-the-stack/20180518-100416
:: branch date: 54 minutes ago
:: commit date: 54 minutes ago

 usb.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -153,10 +153,9 @@ static int pn533_usb_send_ack(struct pn5
char *buffer;
int rc;

-   buffer = kmalloc(sizeof(ack), GFP_KERNEL);
+   buffer = kmemdup(ack, sizeof(ack), GFP_KERNEL);
if (!buffer)
return -ENOMEM;
-   memcpy(buffer, ack, sizeof(ack));

phy->out_urb->transfer_buffer = (u8 *)ack;
phy->out_urb->transfer_buffer_length = sizeof(ack);
@@ -390,10 +389,9 @@ static int pn533_acr122_poweron_rdr(stru

dev_dbg(>udev->dev, "%s\n", __func__);

-   buffer = kmalloc(sizeof(cmd), GFP_KERNEL);
+   buffer = kmemdup(cmd, sizeof(cmd), GFP_KERNEL);
if (!buffer)
return -ENOMEM;
-   memcpy(buffer, cmd, sizeof(cmd));

init_completion();
cntx = phy->in_urb->context;  /* backup context */