Re: [PATCH FIX] brcmfmac: fix reporting support for 160 MHz channels

2018-11-09 Thread Rafał Miłecki

On 2018-11-09 15:05, Kalle Valo wrote:

Rafał Miłecki  writes:


From: Rafał Miłecki 

Driver can report IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ so it's
important to provide valid & complete info about supported bands for
each channel. By default no support for 160 MHz should be assumed 
unless

firmware reports it for a given channel later.

This fixes info passed to the userspace. Without that change userspace
could try to use invalid channel and fail to start an interface.

Signed-off-by: Rafał Miłecki 
Cc: sta...@vger.kernel.org


Should this be queued to 4.20?


That's my suggestion.

I try to mark fixes (patches for currently developed release) with an
extra FIX tag in a subject. Do you see those when using your patchwork
tool? Do you have any other method in mind that would be preferred by
you?


[PATCH] mt76: fix uninitialized mutex access setting rts threshold

2018-11-09 Thread Lorenzo Bianconi
Fix following crash due to a leftover uninitialized mutex access
in mt76x02_set_rts_threshold routine.

[   55.655884] CPU: 0 PID: 412 Comm: iw Not tainted 4.19.0-rc7+ #2493
[   55.661739] Call Trace:
[   55.662523]  register_lock_class+0x528/0x530
[   55.663806]  __lock_acquire+0x89/0x15d0
[   55.664841]  lock_acquire+0x9f/0x140
[   55.665794]  ? mt76x02_set_rts_threshold+0x28/0x50
[   55.667056]  ? noop_count+0x10/0x10
[   55.667981]  ? mt76x02_set_rts_threshold+0x28/0x50
[   55.669251]  __mutex_lock+0x4a/0x4f0
[   55.670199]  ? mt76x02_set_rts_threshold+0x28/0x50
[   55.671454]  ? find_held_lock+0x2d/0x90
[   55.672450]  ? nl80211_pre_doit+0xf9/0x1a0
[   55.673467]  ? mt76x02_set_rts_threshold+0x28/0x50
[   55.674637]  mt76x02_set_rts_threshold+0x28/0x50
[   55.675773]  ieee80211_set_wiphy_params+0x16d/0x4e0
[   55.676910]  nl80211_set_wiphy+0x72b/0xbc0
[   55.677927]  genl_family_rcv_msg+0x192/0x3a0
[   55.678919]  genl_rcv_msg+0x42/0x89
[   55.679742]  ? genl_family_rcv_msg+0x3a0/0x3a0
[   55.680600]  netlink_rcv_skb+0x38/0x100
[   55.681313]  genl_rcv+0x1f/0x30
[   55.681899]  netlink_unicast+0x16b/0x210
[   55.682628]  netlink_sendmsg+0x1ed/0x390
[   55.683373]  sock_sendmsg+0x31/0x40
[   55.684020]  ___sys_sendmsg+0x23c/0x280
[   55.684736]  ? __handle_mm_fault+0xce8/0x1000
[   55.685445]  ? _raw_spin_unlock+0x1f/0x30
[   55.686059]  ? find_held_lock+0x2d/0x90
[   55.686648]  ? __do_page_fault+0x207/0x440
[   55.687274]  __sys_sendmsg+0x42/0x80
[   55.687825]  do_syscall_64+0x50/0x190
[   55.688410]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[   55.689174] RIP: 0033:0x7fdeea227ba7
[   55.692157] RSP: 002b:7ffec2395b58 EFLAGS: 0246 ORIG_RAX: 
002e
[   55.693138] RAX: ffda RBX: 0066c350 RCX: 7fdeea227ba7
[   55.694059] RDX:  RSI: 7ffec2395b90 RDI: 0003
[   55.694966] RBP: 00671740 R08: 0002 R09: 
[   55.695773] R10: 0006 R11: 0246 R12: 00671880
[   55.696572] R13: 7ffec2395b90 R14: 7ffec2395e60 R15: 00671880

Fixes: 108a4861ef19 (" mt76: create new mt76x02-lib module for common
mt76x{0,2} code")

Reported-by: lorenzo.trisol...@fluidmesh.com
Reported-by: luca.bi...@fluidmesh.com
Signed-off-by: Lorenzo Bianconi 
---
I will post a fix based on wireless-drivers repo
---
 drivers/net/wireless/mediatek/mt76/mt76x02.h  | 1 -
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h 
b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index 65daa3d3c289..1d8bb426e772 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -69,7 +69,6 @@ struct mt76x02_dev {
struct mac_address macaddr_list[8];
 
struct mutex phy_mutex;
-   struct mutex mutex;
 
u8 txdone_seq;
DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 48f2f5382b57..bd0a879f7e7a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -481,9 +481,9 @@ int mt76x02_set_rts_threshold(struct ieee80211_hw *hw, u32 
val)
if (val != ~0 && val > 0x)
return -EINVAL;
 
-   mutex_lock(>mutex);
+   mutex_lock(>mt76.mutex);
mt76x02_mac_set_tx_protection(dev, val);
-   mutex_unlock(>mutex);
+   mutex_unlock(>mt76.mutex);
 
return 0;
 }
-- 
2.19.1



Re: [RFC/RFT 3/4] mt76x02: do not set protection on set_rts_threshold callback

2018-11-09 Thread Lorenzo Bianconi
> Use set_rts_threshold calback to enable/disable threshold only for
> legacy traffic. RTS/CTS threshold for HT TXOP make make no sense
> to me since used protection (RTS/CTS , CTS-to-self or none)
> should be determined by HT capabilities and applied to any HT
> frames.
> 
> Signed-off-by: Stanislaw Gruszka 
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c  | 16 +---
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.h  |  2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c |  2 +-
>  3 files changed, 3 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> index 59b336e34cb5..567a7ab47fab 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> @@ -737,7 +737,7 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, 
> struct mt76_queue *q,
>  }
>  EXPORT_SYMBOL_GPL(mt76x02_tx_complete_skb);
>  
> -void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val)
> +void mt76x02_mac_set_rts_thresh(struct mt76x02_dev *dev, u32 val)
>  {
>   u32 data = 0;
>  
> @@ -751,20 +751,6 @@ void mt76x02_mac_set_tx_protection(struct mt76x02_dev 
> *dev, u32 val)
>MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
>   mt76_rmw(dev, MT_OFDM_PROT_CFG,
>MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);

Do we need to configure MT_OFDM_PROT_CFG and MT_CCK_PROT_CFG here? (since they
are already configured in 4/4 (mt76x02: set protection according to ht
capabilities))

> - mt76_rmw(dev, MT_MM20_PROT_CFG,
> -  MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
> - mt76_rmw(dev, MT_MM40_PROT_CFG,
> -  MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
> - mt76_rmw(dev, MT_GF20_PROT_CFG,
> -  MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
> - mt76_rmw(dev, MT_GF40_PROT_CFG,
> -  MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
> - mt76_rmw(dev, MT_TX_PROT_CFG6,
> -  MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
> - mt76_rmw(dev, MT_TX_PROT_CFG7,
> -  MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
> - mt76_rmw(dev, MT_TX_PROT_CFG8,
> -  MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);

Removing these lines we are no longer able to configure protection for VHT
rates. Do we have an equivalent for them in vht_capab?

Regards,
Lorenzo

>  }


[PATCH 3/5] mt76x2u: use common mt76x02_add_interface

2018-11-09 Thread Stanislaw Gruszka
There is no need anymore to use custom add interface function
for mt76x02u.

Signed-off-by: Stanislaw Gruszka 
---
 drivers/net/wireless/mediatek/mt76/mt76x02.h |  2 --
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c|  6 +++---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c | 12 +---
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h 
b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index a8c5fdd903b9..f8e998ef8716 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -115,8 +115,6 @@ int mt76x02_sta_add(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 int mt76x02_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  struct ieee80211_sta *sta);
 
-void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
- unsigned int idx);
 int mt76x02_add_interface(struct ieee80211_hw *hw,
 struct ieee80211_vif *vif);
 void mt76x02_remove_interface(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 2aa3f4b15fd9..dbf9d89dd328 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -228,8 +228,9 @@ int mt76x02_sta_remove(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 }
 EXPORT_SYMBOL_GPL(mt76x02_sta_remove);
 
-void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
- unsigned int idx)
+static void
+mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
+unsigned int idx)
 {
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
 
@@ -238,7 +239,6 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct 
ieee80211_vif *vif,
mvif->group_wcid.hw_key_idx = -1;
mt76x02_txq_init(dev, vif->txq);
 }
-EXPORT_SYMBOL_GPL(mt76x02_vif_init);
 
 int
 mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c 
b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
index 977e74091a27..6b51dd749491 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
@@ -46,16 +46,6 @@ static void mt76x2u_stop(struct ieee80211_hw *hw)
mutex_unlock(>mt76.mutex);
 }
 
-static int mt76x2u_add_interface(struct ieee80211_hw *hw,
-struct ieee80211_vif *vif)
-{
-   struct mt76x02_dev *dev = hw->priv;
-   unsigned int idx = 8;
-
-   mt76x02_vif_init(dev, vif, idx);
-   return 0;
-}
-
 static int
 mt76x2u_set_channel(struct mt76x02_dev *dev,
struct cfg80211_chan_def *chandef)
@@ -122,7 +112,7 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
.tx = mt76x02_tx,
.start = mt76x2u_start,
.stop = mt76x2u_stop,
-   .add_interface = mt76x2u_add_interface,
+   .add_interface = mt76x02_add_interface,
.remove_interface = mt76x02_remove_interface,
.sta_add = mt76x02_sta_add,
.sta_remove = mt76x02_sta_remove,
-- 
1.9.3



[PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Stanislaw Gruszka
Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
setting BSSID for STA.

Signed-off-by: Stanislaw Gruszka 
---
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
index 59b336e34cb5..cfeae5586897 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
@@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
 
 void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr)
 {
+   u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
+get_unaligned_le16(addr + 4));
+   u32 bssid_l = get_unaligned_le32(addr);
+
+   if (idx > 7)
+   bssid_h |= MT_MAC_APC_BSSID0_H_EN;
+
idx &= 7;
-   mt76_wr(dev, MT_MAC_APC_BSSID_L(idx), get_unaligned_le32(addr));
-   mt76_rmw_field(dev, MT_MAC_APC_BSSID_H(idx), MT_MAC_APC_BSSID_H_ADDR,
-  get_unaligned_le16(addr + 4));
+   mt76_wr(dev, MT_MAC_APC_BSSID_L(idx), bssid_l);
+   mt76_wr(dev, MT_MAC_APC_BSSID_H(idx), bssid_h);
 }
 
 static int
-- 
1.9.3



[PATCH 2/5] mt76x02: initalize mutli bss mode by default

2018-11-09 Thread Stanislaw Gruszka
Configure multi bss mode by default on all devices. That mean we
use MAC address for MT_MAC_BSSID_DW and use MT_MAC_APC_BSSID
for configuree bssid for each vif.

This is separe from beaconing as we can have for example 2 STA vifs,
so do not mix bssid init and beacon init.

Signed-off-by: Stanislaw Gruszka 
---
 drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c   |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 17 +++--
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c| 13 ++---
 drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  4 +---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c |  3 ---
 7 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c 
b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
index 497e762978cc..5036b61b66f9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
@@ -347,7 +347,7 @@ int mt76x0_eeprom_init(struct mt76x02_dev *dev)
dev_info(dev->mt76.dev, "EEPROM ver:%02hhx fae:%02hhx\n",
 version, fae);
 
-   mt76x02_mac_setaddr(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
+   mt76x02_mac_init_mbss(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
mt76x0_set_chip_cap(dev);
mt76x0_set_freq_offset(dev);
mt76x0_set_temp_offset(dev);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
index cfeae5586897..b19f9f5b8b89 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
@@ -566,8 +566,11 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev,
return 0;
 }
 
-void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr)
+void mt76x02_mac_init_mbss(struct mt76x02_dev *dev, const u8 *addr)
 {
+   static const u8 null_addr[ETH_ALEN] = {};
+   int i;
+
ether_addr_copy(dev->mt76.macaddr, addr);
 
if (!is_valid_ether_addr(dev->mt76.macaddr)) {
@@ -581,8 +584,18 @@ void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr)
mt76_wr(dev, MT_MAC_ADDR_DW1,
get_unaligned_le16(dev->mt76.macaddr + 4) |
FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
+
+   mt76_wr(dev, MT_MAC_BSSID_DW0,
+   get_unaligned_le32(dev->mt76.macaddr));
+   mt76_wr(dev, MT_MAC_BSSID_DW1,
+   get_unaligned_le16(dev->mt76.macaddr + 4) |
+   FIELD_PREP(MT_MAC_BSSID_DW1_MBSS_MODE, 3) | /* 8 APs + 8 STAs */
+   MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT);
+
+   for (i = 0; i < 16; i++)
+   mt76x02_mac_set_bssid(dev, i, null_addr);
 }
-EXPORT_SYMBOL_GPL(mt76x02_mac_setaddr);
+EXPORT_SYMBOL_GPL(mt76x02_mac_init_mbss);
 
 static int
 mt76x02_mac_get_rssi(struct mt76x02_dev *dev, s8 rssi, int chain)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h 
b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
index b076c4305585..c09181f2da2e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
@@ -198,7 +198,7 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev,
 int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
   void *rxi);
 void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val);
-void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr);
+void mt76x02_mac_init_mbss(struct mt76x02_dev *dev, const u8 *addr);
 void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
struct sk_buff *skb, struct mt76_wcid *wcid,
struct ieee80211_sta *sta, int len);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 87ce6a51fb05..2aa3f4b15fd9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -631,16 +631,8 @@ static void mt76x02_set_beacon_offsets(struct mt76x02_dev 
*dev)
 
 void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
 {
-   static const u8 null_addr[ETH_ALEN] = {};
int i;
 
-   mt76_wr(dev, MT_MAC_BSSID_DW0,
-   get_unaligned_le32(dev->mt76.macaddr));
-   mt76_wr(dev, MT_MAC_BSSID_DW1,
-   get_unaligned_le16(dev->mt76.macaddr + 4) |
-   FIELD_PREP(MT_MAC_BSSID_DW1_MBSS_MODE, 3) | /* 8 beacons */
-   MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT);
-
/* Fire a pre-TBTT interrupt 8 ms before TBTT */
mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
   8 << 4);
@@ -650,10 +642,9 @@ void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
 
mt76_wr(dev, MT_BCN_BYPASS_MASK, 0x);
 
-   

[PATCH 5/5] mt76x02: remove no longer actual comment

2018-11-09 Thread Stanislaw Gruszka
Remove comment about one configurable BSSID registers since
we utilize AP-Client feature now.

Signed-off-by: Stanislaw Gruszka 
---
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 2bb79c6eb54b..9fd9b5f9d3f5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -250,17 +250,10 @@ int mt76x02_sta_remove(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
 
/*
-* Client mode typically only has one configurable BSSID register,
-* which is used for bssidx=0. This is linked to the MAC address.
-* Since mac80211 allows changing interface types, and we cannot
-* force the use of the primary MAC address for a station mode
-* interface, we need some other way of configuring a per-interface
-* remote BSSID.
 * The hardware provides an AP-Client feature, where bssidx 0-7 are
 * used for AP mode and bssidx 8-15 for client mode.
 * We shift the station interface bss index by 8 to force the
-* hardware to recognize the BSSID.
-* The resulting bssidx mismatch for unicast frames is ignored by hw.
+* hardware to recognize the BSSID as STA.
 */
if (vif->type == NL80211_IFTYPE_STATION)
idx += 8;
-- 
1.9.3



[PATCH 0/5] mt76x02: bssid setup corrections for STA

2018-11-09 Thread Stanislaw Gruszka
Minor MBSS and beaconing fixups. On top of:
"mt76x2u: init: remove mt76x2u_init_beacon_offsets routine"

Stanislaw Gruszka (5):
  mt76x02: correct set bssid for STA
  mt76x02: initalize mutli bss mode by default
  mt76x2u: use common mt76x02_add_interface
  mt76x02: minor beaconing init changes
  mt76x02: remove no longer actuall comment

 drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c|  7 
 drivers/net/wireless/mediatek/mt76/mt76x02.h   |  2 --
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c   | 29 +---
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h   |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c  | 39 ++
 .../net/wireless/mediatek/mt76/mt76x2/pci_init.c   | 12 +--
 .../net/wireless/mediatek/mt76/mt76x2/usb_init.c   |  2 +-
 .../net/wireless/mediatek/mt76/mt76x2/usb_main.c   | 15 +
 9 files changed, 54 insertions(+), 56 deletions(-)

-- 
1.9.3



[PATCH 4/5] mt76x02: minor beaconing init changes

2018-11-09 Thread Stanislaw Gruszka
Disable BEACON timer during init and remove interrupt registers
initalization form generic conde since they are PCIe specific.

Signed-off-by: Stanislaw Gruszka 
---
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c  |  7 +++
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c| 11 ---
 drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  8 
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c 
b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 757816d2b1ab..d1d3c5706c4d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -129,6 +129,13 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev)
if (err < 0)
return err;
 
+   /* Beaconing: fire a pre-TBTT interrupt 8 ms before TBTT */
+   mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
+  8 << 4);
+   mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
+  MT_DFS_GP_INTERVAL);
+   mt76_wr(dev, MT_INT_TIMER_EN, 0);
+
if (mt76_chip(>mt76) == 0x7610) {
u16 val;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index dbf9d89dd328..2bb79c6eb54b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -633,13 +633,10 @@ void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
 {
int i;
 
-   /* Fire a pre-TBTT interrupt 8 ms before TBTT */
-   mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
-  8 << 4);
-   mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
-  MT_DFS_GP_INTERVAL);
-   mt76_wr(dev, MT_INT_TIMER_EN, 0);
-
+   mt76_clear(dev, MT_BEACON_TIME_CFG, (MT_BEACON_TIME_CFG_TIMER_EN |
+MT_BEACON_TIME_CFG_SYNC_MODE |
+MT_BEACON_TIME_CFG_TBTT_EN |
+MT_BEACON_TIME_CFG_BEACON_TX));
mt76_wr(dev, MT_BCN_BYPASS_MASK, 0x);
 
for (i = 0; i < 8; i++)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c 
b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
index d2ef68c48ea5..89941aea8a88 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
@@ -121,6 +121,14 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool 
hard)
 
mt76x02_mac_init_mbss(dev, macaddr);
mt76x02_init_beacon_config(dev);
+
+   /* Fire a pre-TBTT interrupt 8 ms before TBTT */
+   mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
+  8 << 4);
+   mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
+  MT_DFS_GP_INTERVAL);
+   mt76_wr(dev, MT_INT_TIMER_EN, 0);
+
if (!hard)
return 0;
 
-- 
1.9.3



Re: [PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Lorenzo Bianconi
> Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
> setting BSSID for STA.
> 
> Signed-off-by: Stanislaw Gruszka 
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> index 59b336e34cb5..cfeae5586897 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> @@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
>  
>  void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr)
>  {
> + u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
> +  get_unaligned_le16(addr + 4));
> + u32 bssid_l = get_unaligned_le32(addr);
> +
> + if (idx > 7)
> + bssid_h |= MT_MAC_APC_BSSID0_H_EN;

This bit is to enable APClient mode and it is valid just for register 0x1094
(MT_MAC_APC_BSSID_{L,h}(0)). Moreover IIRC APClient has been disabled because
it causes a performance degradation.

> +
>   idx &= 7;
> - mt76_wr(dev, MT_MAC_APC_BSSID_L(idx), get_unaligned_le32(addr));
> - mt76_rmw_field(dev, MT_MAC_APC_BSSID_H(idx), MT_MAC_APC_BSSID_H_ADDR,
> -get_unaligned_le16(addr + 4));
> + mt76_wr(dev, MT_MAC_APC_BSSID_L(idx), bssid_l);
> + mt76_wr(dev, MT_MAC_APC_BSSID_H(idx), bssid_h);
>  }
>  
>  static int
> -- 
> 1.9.3
> 


Re: [PATCH 2/5] mt76x02: initalize mutli bss mode by default

2018-11-09 Thread Lorenzo Bianconi
> Configure multi bss mode by default on all devices. That mean we
> use MAC address for MT_MAC_BSSID_DW and use MT_MAC_APC_BSSID
> for configuree bssid for each vif.
> 
> This is separe from beaconing as we can have for example 2 STA vifs,
> so do not mix bssid init and beacon init.
> 
> Signed-off-by: Stanislaw Gruszka 
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c   |  2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 17 +++--
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.h |  2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c| 13 ++---
>  drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  4 +---
>  drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c |  2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c |  3 ---
>  7 files changed, 21 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
> index 497e762978cc..5036b61b66f9 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c

[snip]

> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
> index de0fbdb02c4d..4fb87deff261 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
> @@ -189,7 +189,7 @@ int mt76x2u_init_hardware(struct mt76x02_dev *dev)
>   if (err < 0)
>   return err;
>  
> - mt76x02_mac_setaddr(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
> + mt76x02_mac_init_mbss(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
>   dev->mt76.rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);
>  
>   if (!mt76x02_wait_for_txrx_idle(>mt76))
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> index a9ecc92875ae..977e74091a27 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> @@ -52,9 +52,6 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
>   struct mt76x02_dev *dev = hw->priv;
>   unsigned int idx = 8;
>  
> - if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
> - mt76x02_mac_setaddr(dev, vif->addr);
> -

I think this is a regression since you will able to change device mac address
in this way. Do you agree?

>   mt76x02_vif_init(dev, vif, idx);
>   return 0;
>  }
> -- 
> 1.9.3
> 


Re: [PATCH 3/5] mt76x2u: use common mt76x02_add_interface

2018-11-09 Thread Lorenzo Bianconi
> There is no need anymore to use custom add interface function
> for mt76x02u.
> 
> Signed-off-by: Stanislaw Gruszka 
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x02.h |  2 --
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c|  6 +++---
>  drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c | 12 +---
>  3 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h 
> b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> index a8c5fdd903b9..f8e998ef8716 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> @@ -115,8 +115,6 @@ int mt76x02_sta_add(struct ieee80211_hw *hw, struct 
> ieee80211_vif *vif,
>  int mt76x02_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> struct ieee80211_sta *sta);
>  
> -void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
> -   unsigned int idx);
>  int mt76x02_add_interface(struct ieee80211_hw *hw,
>struct ieee80211_vif *vif);
>  void mt76x02_remove_interface(struct ieee80211_hw *hw,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 2aa3f4b15fd9..dbf9d89dd328 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -228,8 +228,9 @@ int mt76x02_sta_remove(struct ieee80211_hw *hw, struct 
> ieee80211_vif *vif,
>  }
>  EXPORT_SYMBOL_GPL(mt76x02_sta_remove);
>  
> -void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
> -   unsigned int idx)
> +static void
> +mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
> +  unsigned int idx)
>  {
>   struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
>  
> @@ -238,7 +239,6 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct 
> ieee80211_vif *vif,
>   mvif->group_wcid.hw_key_idx = -1;
>   mt76x02_txq_init(dev, vif->txq);
>  }
> -EXPORT_SYMBOL_GPL(mt76x02_vif_init);
>  
>  int
>  mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> index 977e74091a27..6b51dd749491 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
> @@ -46,16 +46,6 @@ static void mt76x2u_stop(struct ieee80211_hw *hw)
>   mutex_unlock(>mt76.mutex);
>  }
>  
> -static int mt76x2u_add_interface(struct ieee80211_hw *hw,
> -  struct ieee80211_vif *vif)
> -{
> - struct mt76x02_dev *dev = hw->priv;
> - unsigned int idx = 8;
> -
> - mt76x02_vif_init(dev, vif, idx);
> - return 0;
> -}

This routines seems wrong since here we should have the possibility to change
the device mac address:
https://github.com/nbd168/wireless/blob/mt76/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c#L54

and IIRC I have not removed it in:
https://patchwork.kernel.org/patch/10670853/

Regards,
Lorenzo

> -
>  static int
>  mt76x2u_set_channel(struct mt76x02_dev *dev,
>   struct cfg80211_chan_def *chandef)
> @@ -122,7 +112,7 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
>   .tx = mt76x02_tx,
>   .start = mt76x2u_start,
>   .stop = mt76x2u_stop,
> - .add_interface = mt76x2u_add_interface,
> + .add_interface = mt76x02_add_interface,
>   .remove_interface = mt76x02_remove_interface,
>   .sta_add = mt76x02_sta_add,
>   .sta_remove = mt76x02_sta_remove,
> -- 
> 1.9.3
> 


Re: [PATCH] mac80211: allow hardware scan to fall back to software

2018-11-09 Thread Johannes Berg
On Fri, 2018-11-09 at 11:48 +0530, Siva Rebbagondla wrote:
> Hi,
> Gentle Remainder..!!!.
> Any update required for this patch?. If not, When can i expect this
> patch to be available in wireless-next?.

Sorry, I hadn't been merging things for a while due to the merge window.

I just put it into mac80211-next, so I guess the answer should be
"soon".

johannes



Re: [RFC/RFT 4/4] mt76x02: set protection according to ht capabilities

2018-11-09 Thread Lorenzo Bianconi
> Use information about protection that mac80211 provide to us.
> Used protection should be part of ht capabilites that either
> remote AP provde to us in STA mode or is set in hostapd.conf
> in ht_capab option.
> 
> Signed-off-by: Stanislaw Gruszka 
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c  | 58 
> +++
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.h  |  2 +
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c |  4 ++
>  3 files changed, 64 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> index 567a7ab47fab..6096efc4119b 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> @@ -753,6 +753,64 @@ void mt76x02_mac_set_rts_thresh(struct mt76x02_dev *dev, 
> u32 val)
>MT_PROT_CFG_CTRL | MT_PROT_CFG_RTS_THRESH, data);
>  }
>  
> +void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, bool legacy_prot,
> +int ht_mode)
> +{
> + int mode = ht_mode & IEEE80211_HT_OP_MODE_PROTECTION;
> + bool non_gf = !!(ht_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
> + u32 prot[6];
> + bool ht_rts[4] = {};
> + int i;
> +
> + for (i = 0; i < 6; i++) {

maybe better ARRAY_SIZE() here?

> + prot[i] = mt76_rr(dev, MT_CCK_PROT_CFG + i * 4);
> + if (i >= 2)
> + prot[i] &= ~(MT_PROT_CFG_CTRL | MT_PROT_CFG_RATE);
> + }
> +
> + if (legacy_prot) {
> + prot[1] &= ~MT_PROT_CFG_CTRL;
> + prot[1] |= MT_PROT_CTRL_CTS2SELF;
> +
> + prot[2] |= MT_PROT_RATE_CCK_11;
> + prot[3] |= MT_PROT_RATE_CCK_11;
> + prot[4] |= MT_PROT_RATE_CCK_11;
> + prot[5] |= MT_PROT_RATE_CCK_11;
> + } else {
> + prot[2] |= MT_PROT_RATE_OFDM_24;
> + prot[3] |= MT_PROT_RATE_DUP_OFDM_24;
> + prot[4] |= MT_PROT_RATE_OFDM_24;
> + prot[5] |= MT_PROT_RATE_DUP_OFDM_24;
> + }
> +
> + switch (mode) {
> + case IEEE80211_HT_OP_MODE_PROTECTION_NONE:

I think you can cover it with 'default' case

> + break;
> +
> + case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
> + ht_rts[0] = ht_rts[1] = ht_rts[2] = ht_rts[3] = true;
> + break;
> +
> + case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
> + ht_rts[1] = ht_rts[3] = true;
> + break;
> +
> + case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
> + ht_rts[0] = ht_rts[1] = ht_rts[2] = ht_rts[3] = true;
> + break;

this code is duplicated of 'IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER'.
maybe better to have:

case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
ht_rts[0] = ht_rts[1] = ht_rts[2] = ht_rts[3] = true;
break;

> + }
> +
> + if (non_gf)
> + ht_rts[2] = ht_rts[3] = true;
> +
> + for (i = 0; i < 4; i++)

ARRAY_SIZE() here?

> + if (ht_rts[i])
> + prot[i + 2] |= MT_PROT_CTRL_RTS_CTS;
> +
> + for (i = 0; i < 6; i++)

ARRAY_SIZE() here?

> + mt76_wr(dev, MT_CCK_PROT_CFG + i * 4, prot[i]);
> +}
> +
>  void mt76x02_update_channel(struct mt76_dev *mdev)
>  {
>   struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h 
> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
> index 34da8c600db8..9035397ae081 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
> @@ -197,6 +197,8 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev,
>   struct mt76x02_tx_status *stat, u8 *update);
>  int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
>  void *rxi);
> +void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, bool legacy_prot,
> +int ht_mode);
>  void mt76x02_mac_set_rts_thresh(struct mt76x02_dev *dev, u32 val);
>  void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr);
>  void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi 
> *txwi,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c 
> b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index fda67b0923a6..51db4d3dcc13 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -682,6 +682,10 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
>   tasklet_enable(>pre_tbtt_tasklet);
>   }
>  
> + if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
> + mt76x02_mac_set_tx_protection(dev, info->use_cts_prot,
> +   info->ht_operation_mode);
> 

[PATCH v2] mt76: remove wait argument from mt76x02_mcu_calibrate

2018-11-09 Thread Stanislaw Gruszka
We always wait for CMD_CALIBRATION_OP mcu message, but wait argument is used
for do additional MT_MCU_COM_REG0 register operations, which are needed
for mt76x2e devices and we can use appropriate check instead of wait argument.

Signed-off-by: Stanislaw Gruszka 
---
v2: use MT_MCU_COM_REG0 register only for mt76x2e

 drivers/net/wireless/mediatek/mt76/mt76x0/phy.c| 14 ++
 drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c   |  8 
 drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h   |  3 +--
 drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h |  2 +-
 .../net/wireless/mediatek/mt76/mt76x2/pci_phy.c| 22 +++---
 drivers/net/wireless/mediatek/mt76/mt76x2/phy.c|  4 ++--
 .../net/wireless/mediatek/mt76/mt76x2/usb_phy.c| 22 +++---
 7 files changed, 36 insertions(+), 39 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c 
b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 275458891ce4..1eb1a802ed20 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -868,9 +868,8 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool 
power_on)
return;
 
if (power_on) {
-   mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false);
-   mt76x02_mcu_calibrate(dev, MCU_CAL_VCO, chan->hw_value,
- false);
+   mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0);
+   mt76x02_mcu_calibrate(dev, MCU_CAL_VCO, chan->hw_value);
usleep_range(10, 20);
 
if (mt76x0_tssi_enabled(dev)) {
@@ -901,14 +900,14 @@ void mt76x0_phy_calibrate(struct mt76x02_dev *dev, bool 
power_on)
val = 0x600;
}
 
-   mt76x02_mcu_calibrate(dev, MCU_CAL_FULL, val, false);
+   mt76x02_mcu_calibrate(dev, MCU_CAL_FULL, val);
msleep(350);
-   mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz, false);
+   mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz);
usleep_range(15000, 2);
 
mt76_wr(dev, MT_BBP(IBI, 9), reg_val);
mt76_wr(dev, MT_TX_ALC_CFG_0, tx_alc);
-   mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false);
+   mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1);
 }
 EXPORT_SYMBOL_GPL(mt76x0_phy_calibrate);
 
@@ -1044,8 +1043,7 @@ static void mt76x0_phy_temp_sensor(struct mt76x02_dev 
*dev)
 
if (abs(val - dev->cal.temp_vco) > 20) {
mt76x02_mcu_calibrate(dev, MCU_CAL_VCO,
- dev->mt76.chandef.chan->hw_value,
- false);
+ dev->mt76.chandef.chan->hw_value);
dev->cal.temp_vco = val;
}
if (abs(val - dev->cal.temp) > 30) {
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c
index 6015ba9ffdac..b7f4edb729e3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c
@@ -165,8 +165,7 @@ int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, 
bool on)
 }
 EXPORT_SYMBOL_GPL(mt76x02_mcu_set_radio_state);
 
-int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
- u32 param, bool wait)
+int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param)
 {
struct {
__le32 id;
@@ -175,9 +174,10 @@ int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int 
type,
.id = cpu_to_le32(type),
.value = cpu_to_le32(param),
};
+   bool is_mt76x2e = mt76_is_mmio(dev) && is_mt76x2(dev);
int ret;
 
-   if (wait)
+   if (is_mt76x2e)
mt76_rmw(dev, MT_MCU_COM_REG0, BIT(31), 0);
 
ret = mt76_mcu_send_msg(dev, CMD_CALIBRATION_OP, , sizeof(msg),
@@ -185,7 +185,7 @@ int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
if (ret)
return ret;
 
-   if (wait &&
+   if (is_mt76x2e &&
WARN_ON(!mt76_poll_msec(dev, MT_MCU_COM_REG0,
BIT(31), BIT(31), 100)))
return -ETIMEDOUT;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h 
b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h
index 97025c31a986..7e4004120102 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h
@@ -97,8 +97,7 @@ struct mt76x02_patch_header {
 };
 
 int mt76x02_mcu_cleanup(struct mt76x02_dev *dev);
-int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
- u32 param, bool wait);
+int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param);
 int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
 int len, bool wait_resp);
 int mt76x02_mcu_function_select(struct mt76x02_dev *dev, enum mcu_function 
func,
diff --git 

Re: [PATCH 4/5] mt76x02: minor beaconing init changes

2018-11-09 Thread Lorenzo Bianconi
> Disable BEACON timer during init and remove interrupt registers
> initalization form generic conde since they are PCIe specific.
> 

Since the timer is actually disabled (MT_INT_TIMER_EN set to 0) and
we just set the timer timeout here, does it worth to copy/paste
the same code?

Regards,
Lorenzo

> Signed-off-by: Stanislaw Gruszka 
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x0/pci.c  |  7 +++
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c| 11 ---
>  drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  8 
>  3 files changed, 19 insertions(+), 7 deletions(-)
> 


[PATCH] wireless-regdb: delete outdated comment for DE

2018-11-09 Thread Xose Vazquez Perez
d46d731c made it obsolete.

Cc: Sven Eckelmann 
Cc: Seth Forshee 
Cc: WIRELESS ML 
Cc: REGDB ML 
Signed-off-by: Xose Vazquez Perez 
---
 db.txt | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/db.txt b/db.txt
index 8f356f7..fa5c0e0 100644
--- a/db.txt
+++ b/db.txt
@@ -359,13 +359,6 @@ country CZ: DFS-ETSI
 # Funkanwendungen zur breitbandigen Datenübertragung, WAS/WLAN („Wireless
 # Access Systems including Wireless Local Area Networks“).
 # 
https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Allgemeinzuteilungen/2010_07_WLAN_5GHz_pdf.pdf
-# The values for the 5 GHz have been reduced by a factor of 2 (3db) for non TPC
-# devices (in other words: devices with TPC can use twice the tx power of this
-# table). Note that the docs do not require TPC for 5150--5250; the reduction
-# to 100mW thus is not strictly required -- however the conservative 100mW
-# limit is used here as the non-interference with radar and satellite
-# apps relies on the attenuation by the building walls only in the
-# absence of DFS; the neighbour countries have 100mW limit here as well.
 #
 # The ETSI EN 300 440-1 standard for short range devices in the 5 GHz band has
 # been implemented in Germany:
-- 
2.19.1



Re: [PATCH FIX] brcmfmac: fix reporting support for 160 MHz channels

2018-11-09 Thread Kalle Valo
Rafał Miłecki  writes:

> From: Rafał Miłecki 
>
> Driver can report IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ so it's
> important to provide valid & complete info about supported bands for
> each channel. By default no support for 160 MHz should be assumed unless
> firmware reports it for a given channel later.
>
> This fixes info passed to the userspace. Without that change userspace
> could try to use invalid channel and fail to start an interface.
>
> Signed-off-by: Rafał Miłecki 
> Cc: sta...@vger.kernel.org

Should this be queued to 4.20?

-- 
Kalle Valo


[PATCH v2] mac80211: fix GFP_KERNEL under tasklet context

2018-11-09 Thread yhchuang
From: Yan-Hsuan Chuang 

cfg80211_sta_opmode_change_notify needs a gfp_t flag to hint the nl80211
stack when allocating new skb, but it is called under tasklet context
here with GFP_KERNEL and kernel will yield a warning about it.

Fixes: ff84e7bfe176 ("mac80211: Add support to notify ht/vht opmode 
modification.")
Cc: Stable  # v4.17+
Signed-off-by: Yan-Hsuan Chuang 
---
 net/mac80211/rx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 64742f2..03d3964f 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3028,7 +3028,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
cfg80211_sta_opmode_change_notify(sdata->dev,
  rx->sta->addr,
  _opmode,
- GFP_KERNEL);
+ GFP_ATOMIC);
goto handled;
}
case WLAN_HT_ACTION_NOTIFY_CHANWIDTH: {
@@ -3065,7 +3065,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
cfg80211_sta_opmode_change_notify(sdata->dev,
  rx->sta->addr,
  _opmode,
- GFP_KERNEL);
+ GFP_ATOMIC);
goto handled;
}
default:
-- 
2.7.4



Re: [PATCH 1/3] cfg80211: Add support to configure station specific RSSI threshold for AP mode

2018-11-09 Thread Johannes Berg
Hi,

Sorry for the delay in reviewing this.

> + int (*set_sta_mon_rssi_config)(struct wiphy *wiphy,
> +   struct net_device *dev,
> +   const u8 *addr,
> +   const s32 *rssi_tholds,
> +   u32 rssi_hyst, int rssi_n_tholds,
> +   bool fixed_thold);
>  };

I think it might be better to pass all the last 4 arguments (rssi
related ones) as a struct? That's a pattern we typically have elsewhere
too, and it makes things easier to extend and also easier to pass
around.

> + * @NL80211_CMD_SET_STA_MON: This command is used to configure station's
> + * connection monitoring notification trigger levels.
> + * @NL80211_CMD_NOTIFY_STA_MON: This is used as an event to notify
> + * the user space that a trigger level was reached for a station.

Please describe the attributes to use with this.


> + * @NL80211_ATTR_STA_MON_FIXED_THOLD: Flag attribute is used with
> + *   %NL80211_CMD_SET_STA_MON to indicate driver that the monitoring
> + *   configuration is fixed limit or a moving range threshold.

This isn't really clear to me, what does it mean?

> + if (!sta_mon || !(info->attrs[NL80211_ATTR_MAC]))

Don't really need the parentheses in !(info->...)

> + err = nla_parse_nested(attrs, NL80211_ATTR_CQM_MAX, sta_mon,
> +nl80211_attr_cqm_policy, info->extack);

I *think* I made that a proper nested policy, check and then you can
remove passing it here.

> +void
> +cfg80211_sta_mon_rssi_notify(struct net_device *dev, const u8 *peer,
> +  enum nl80211_cqm_rssi_threshold_event rssi_event,
> +  s32 rssi_level, gfp_t gfp)
> +{
> + struct sk_buff *msg;
> +
> + if (WARN_ON(!peer))
> + return;

Tracing for this might be nice too?

johannes



Re: [PATCH 3/5] brcmfmac: p2p cert 6.1.9-support GOUT handling p2p presence request

2018-11-09 Thread Arend van Spriel

+ Jouni

On 11/8/2018 4:48 AM, Chi-Hsien Lin wrote:

From: Madhan Mohan R 

Send p2p presence response from the p2p interface address instead
of the p2p device address. This is needed for p2p cert 6.1.9 to pass.


I am not really into the P2P spec, but if this is indeed a requirement 
(@Jouni: can you confirm?) I would expect wpa_supplicant to send the 
action frame over the correct netdevice (although there is no netdev for 
P2P_DEVICE interface so expect primary interface will be used).


So instead of looking at the action frame subtype it seems to be more 
appropriate to determine and pass the appropriate vif in 
brcmf_p2p_send_action_frame().


Regards,
Arend


Signed-off-by: Madhan Mohan R 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)




Re: [PATCH 5/5] brcmfmac: add vendor ie for association responses

2018-11-09 Thread Arend van Spriel

On 11/8/2018 4:48 AM, Chi-Hsien Lin wrote:

From: Ryohei Kondo 

Miracast Certification clause 6.1.2 may fail if there is no WFD IE in
p2p assoc response. This change allows WFD IE to be added to p2p assoc
response.

Related WFA certification:
6.1.2 P-SnUT operating as a Group Owner accepts a WFD Session with a
Reference Source


Reviewed-by: Arend van Spriel 

Signed-off-by: Ryohei Kondo 
Signed-off-by: Chi-Hsien Lin 
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c| 14 ++
 .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h|  4 
 2 files changed, 18 insertions(+)




Re: [PATCH 4/5] brcmfmac: only generate random p2p address when needed

2018-11-09 Thread Arend van Spriel

+ Hans

On 11/8/2018 4:48 AM, Chi-Hsien Lin wrote:

P2p spec mentioned that the p2p device address should be the globally
administered address with locally administered bit set. Therefore,
follow this guideline by default.

When the primary interface is set to a locally administered address, the
locally administered bit cannot be set again. Generate a random locally
administered address for this case.


We discussed this on the linux-wireless list a while ago. I have no 
problem with the approach in this patch.


Reviewed-by: Arend van Spriel 

Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)




Re: [PATCH 1/5] brcmfmac: set apsta to 1 when AP start on primary interface.

2018-11-09 Thread Arend van Spriel

On 11/8/2018 4:48 AM, Chi-Hsien Lin wrote:

From: Wright Feng 

APSTA can work on two band concurrently with using VSDB(Virtual
Simultaneous Dual-Band) or RSDB(Real Simultaneous Dual-Band) features.
In this case, we have to keep apsta is 1 in firmware side. However, if
we start wpa_supplicant on wlan0 and then start hostapd on wlan 1, the
apsta will be set to 0, and we will see data stall on wlan0(station)
So that, we only set apsta to 1 when AP start on primary interface.


The description makes my head spin. From reading the commit message I 
think the code should add a !VSDB check instead of dropping the !RSDB 
check. Would you agree?


Regards,
Arend


Signed-off-by: Wright Feng 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)




Re: [PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Stanislaw Gruszka
On Fri, Nov 09, 2018 at 01:50:51PM +0100, Lorenzo Bianconi wrote:
> > On 2018-11-09 12:09, Lorenzo Bianconi wrote:
> > >> Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
> > >> setting BSSID for STA.
> > >> 
> > >> Signed-off-by: Stanislaw Gruszka 
> > >> ---
> > >>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
> > >>  1 file changed, 9 insertions(+), 3 deletions(-)
> > >> 
> > >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
> > >> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > >> index 59b336e34cb5..cfeae5586897 100644
> > >> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > >> @@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
> > >>  
> > >>  void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 
> > >> *addr)
> > >>  {
> > >> +u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
> > >> + get_unaligned_le16(addr + 4));
> > >> +u32 bssid_l = get_unaligned_le32(addr);
> > >> +
> > >> +if (idx > 7)
> > >> +bssid_h |= MT_MAC_APC_BSSID0_H_EN;
> > > 
> > > This bit is to enable APClient mode and it is valid just for register 
> > > 0x1094
> > > (MT_MAC_APC_BSSID_{L,h}(0)). Moreover IIRC APClient has been disabled 
> > > because
> > > it causes a performance degradation.
> > The performance degradation was with MAC_ADDR_EXT, not AP-Client.
> > This patch should be fine.
> 
> Ah, now I remember sorry, you are right :)
> Anyway IIRC MT_MAC_APC_BSSID0_H_EN is just for AP_CLIENT_BSSID0 (at least for
> 76x2), for others we need to use BIT(31) but just if APClient is disabled, 
> right?
> Moreover BSSID filter is currently disabled (BIT(3) in RX_FILTER_CFG).
> 
> # echo 0x1400 > /sys/kernel/debug/ieee80211/phy0/mt76/regidx
> # cat /sys/kernel/debug/ieee80211/phy0/mt76/regval
> 0x00017f97
> 
> Have you tried to enabled it?

I didn't try this yet, but I think it should be enabled to support
mulit BSS and MAC address change. 

However I still don't know how to set multiple bssid for STA,
Use BIT(31) or BIT(16) as indicator or maybe 
just write BSSID to MT_MAC_APC_BSSID_{H,L} and hardware will
recognize this is not AP BSSID ?

Thanks
Stanislaw


Re: [PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Felix Fietkau
On 2018-11-09 14:42, Lorenzo Bianconi wrote:
>> On Fri, Nov 09, 2018 at 01:50:51PM +0100, Lorenzo Bianconi wrote:
>> > > On 2018-11-09 12:09, Lorenzo Bianconi wrote:
>> > > >> Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
>> > > >> setting BSSID for STA.
>> > > >> 
>> > > >> Signed-off-by: Stanislaw Gruszka 
>> > > >> ---
>> > > >>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
>> > > >>  1 file changed, 9 insertions(+), 3 deletions(-)
>> > > >> 
>> > > >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
>> > > >> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
>> > > >> index 59b336e34cb5..cfeae5586897 100644
>> > > >> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
>> > > >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
>> > > >> @@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
>> > > >>  
>> > > >>  void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 
>> > > >> *addr)
>> > > >>  {
>> > > >> + u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
>> > > >> +  get_unaligned_le16(addr + 4));
>> > > >> + u32 bssid_l = get_unaligned_le32(addr);
>> > > >> +
>> > > >> + if (idx > 7)
>> > > >> + bssid_h |= MT_MAC_APC_BSSID0_H_EN;
>> > > > 
>> > > > This bit is to enable APClient mode and it is valid just for register 
>> > > > 0x1094
>> > > > (MT_MAC_APC_BSSID_{L,h}(0)). Moreover IIRC APClient has been disabled 
>> > > > because
>> > > > it causes a performance degradation.
>> > > The performance degradation was with MAC_ADDR_EXT, not AP-Client.
>> > > This patch should be fine.
>> > 
>> > Ah, now I remember sorry, you are right :)
>> > Anyway IIRC MT_MAC_APC_BSSID0_H_EN is just for AP_CLIENT_BSSID0 (at least 
>> > for
>> > 76x2), for others we need to use BIT(31) but just if APClient is disabled, 
>> > right?
>> > Moreover BSSID filter is currently disabled (BIT(3) in RX_FILTER_CFG).
>> > 
>> > # echo 0x1400 > /sys/kernel/debug/ieee80211/phy0/mt76/regidx
>> > # cat /sys/kernel/debug/ieee80211/phy0/mt76/regval
>> > 0x00017f97
>> > 
>> > Have you tried to enabled it?
>> 
>> I didn't try this yet, but I think it should be enabled to support
>> mulit BSS and MAC address change. 
> 
> I agree we can use multi-BSS for mac filtering in AP mode but my gut feeling 
> in
> STA the hw uses the value in MT_MAC_ADDR_DW{0,1} for unicast packet filtering
> (BIT(2) in RX_FILTER_CFG). Moreover I think there is a relation between
> MT_MAC_ADDR_DW and BSSID values in multiAP mode.
I'm pretty sure that value also gets used for local ACK/BA filtering. We
definitely need to set it up properly.
In the past, I observed cases where a misconfigured MAC address led to
no tx status being reported anymore.

- Felix


Re: [PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Stanislaw Gruszka
On Fri, Nov 09, 2018 at 12:09:50PM +0100, Lorenzo Bianconi wrote:
> > Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
> > setting BSSID for STA.
> > 
> > Signed-off-by: Stanislaw Gruszka 
> > ---
> >  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
> > b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > index 59b336e34cb5..cfeae5586897 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > @@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
> >  
> >  void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr)
> >  {
> > +   u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
> > +get_unaligned_le16(addr + 4));
> > +   u32 bssid_l = get_unaligned_le32(addr);
> > +
> > +   if (idx > 7)
> > +   bssid_h |= MT_MAC_APC_BSSID0_H_EN;
> 
> This bit is to enable APClient mode and it is valid just for register 0x1094
> (MT_MAC_APC_BSSID_{L,h}(0)). Moreover IIRC APClient has been disabled because
> it causes a performance degradation.

IIRC MT_MAC_APC_BSSID0_H_EN bit enable BSSID8-15 for STA usage, how we then
can program to device those BSSIDs ?

And if this bit is disabled, shouldn't we use MAC_BSSID_DW for setting BSSID
in STA mode ?

Thanks
Stanislaw


Re: [PATCH 2/3] mac80211: Implement API to configure station specific rssi threshold

2018-11-09 Thread Johannes Berg
On Mon, 2018-10-15 at 23:27 +0530, Tamizh chelvam wrote:
> 
> + sta_mon_rssi_config_free(sta);
> + sta->rssi_hyst = rssi_hyst;
> + if (fixed_thold) {
> + if (n_rssi_tholds > 2) {
> + ret = -EINVAL;
> + goto out;
> + }

This might be slightly wrong, you free and then can still return an
error.

> + if (n_rssi_tholds == 1) {
> + sta->rssi_low = rssi_tholds[0];
> + sta->rssi_high = rssi_tholds[0];
> + } else {
> + sta->rssi_low = rssi_tholds[0];
> + sta->rssi_high = rssi_tholds[1];
> + }
> + } else {
> + const s32 *rssi_tholds;
> +
> + rssi_tholds = kmemdup(rssi_tholds,
> +   n_rssi_tholds * sizeof(s32),
> +   GFP_KERNEL);
> + if (!rssi_tholds) {
> + ret = -ENOMEM;
> + goto out;
> + }

Similarly here, I guess you should do the allocation (and other error
checking) before freeing.

> + sta->rssi_tholds = rssi_tholds;
> + sta->n_rssi_tholds = n_rssi_tholds;
> + ieee80211_update_rssi_config(sta);



> +struct sta_mon_rssi_config {
> +};

Huh?


The commit log also makes it sounds like mac80211 actually *supports*
this, but clearly that's not the case. However you don't give any data
to the driver either, did you lose a patch along the way? Previously you
had patch 5 ("mac80211: Implement functionality to monitor station's
rssi cross event") and if I remember correctly I said you should squash
some, but now that's not here?

johannes



Re: [PATCH 3/3] mac80211: Implement functionality to monitor station's signal stregnth

2018-11-09 Thread Johannes Berg
Oh, umm, that patch is still here ...

I guess we can combine 2 and 3 too.


> + if (sta->rssi_low && bss_conf->enable_beacon) {
> + int last_event =
> + sta->last_rssi_event_value;
> + int sig = -ewma_signal_read(>rx_stats_avg.signal);
> + int low = sta->rssi_low;
> + int high = sta->rssi_high;

This doesn't really support a list, like in patch 2 where you store
sta_info::rssi_tholds?

> + if (sig < low &&
> + (last_event == 0 || last_event >= low)) {
> + sta->last_rssi_event_value = sig;
> + cfg80211_sta_mon_rssi_notify(
> + rx->sdata->dev, sta->addr,
> + NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
> + sig, GFP_ATOMIC);
> + rssi_cross = true;
> + } else if (sig > high &&
> +(last_event == 0 || last_event <= high)) {
> + sta->last_rssi_event_value = sig;
> + cfg80211_sta_mon_rssi_notify(
> + rx->sdata->dev, sta->addr,
> + NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
> + sig, GFP_ATOMIC);
> + rssi_cross = true;
> + }
> + }
> +
> + if (rssi_cross) {
> + ieee80211_update_rssi_config(sta);
> + rssi_cross = false;
> + }
> +}

Ah, but it does, just hard to understand.

However, this does mean what I suspected on the other patch is true -
you're calling ieee80211_update_rssi_config() here, and that uses the
sta->rssi_tholds array without any protection, while a concurrent change
of configuration can free the data.

You need to sort that out. I would suggest to stick all the sta->rssi_*
fields you add into a new struct (you even had an empty one), and
protect that struct using RCU. That also saves the memory in case it's
not assigned at all. Something like

struct sta_mon_rssi_config {
struct rcu_head rcu_head;
int n_thresholds;
s32 low, high;
u32 hyst;
s32 last_value;
s32 thresholds[];
};

then you can kfree_rcu() it, and just do a single allocation using
struct_size() for however many entries you need.

> + * @count_rx_signal: Number of data frames used in averaging station signal.
> + *   This can be used to avoid generating less reliable station rssi cross
> + *   events that would be based only on couple of received frames.
>   */
>  struct sta_info {
>   /* General information, mostly static */
> @@ -600,6 +603,7 @@ struct sta_info {
>   s32 rssi_high;
>   u32 rssi_hyst;
>   s32 last_rssi_event_value;
> + unsigned int count_rx_signal;

I guess that would also move into the new struct.

johannes



Re: [PATCH] mac80211: Improve connection-loss probing.

2018-11-09 Thread Johannes Berg
Hi Ben,

Apologies for taking so long to look at this.

This looks good to me, but for some reason it doesn't apply on my
(mac80211-next) tree, and basically all of the patch fails. I'm not sure
I dare try to fix that up, could you resend?

johannes



Re: [PATCH] nl80211: Add support to notify radar event info received from STA

2018-11-09 Thread Johannes Berg
On Fri, 2018-10-19 at 14:42 +0530, Sriram R wrote:
[...]

This looks fine, but I think it would be nice to have some extended
netlink error reporting for at least some of these errors:

> + dfs_region = reg_get_dfs_region(wiphy);
> + if (dfs_region == NL80211_DFS_UNSET)
> + return -EINVAL;
> +
> + err = nl80211_parse_chandef(rdev, info, );
> + if (err)
> + return err;
> +
> + err = cfg80211_chandef_dfs_required(wiphy, , wdev->iftype);
> + if (err < 0)
> + return err;
> +
> + if (err == 0)
> + return -EINVAL;
> +
> + /* Do not process this notification if radar is already detected
> +  * by kernel on this channel
> +  */
> + if (chandef.chan->dfs_state == NL80211_DFS_UNAVAILABLE)
> + return -EINVAL;

And maybe that last one should just return 0?

johannes



Re: [PATCH 03/11] brcmfmac: set SDIO F1 MesBusyCtrl for CYW4373

2018-11-09 Thread Arend van Spriel

On 11/9/2018 8:34 AM, Chi-Hsien Lin wrote:



On 11/08/2018 7:53, Arend van Spriel wrote:

On 11/6/2018 4:50 AM, Chi-Hsien Lin wrote:

From: Madhan Mohan R 

Along with F2 watermark (existing) configuration, F1 MesBusyCtrl
should be enabled & configured to avoid overflow errors.


Reviewed-by: Arend van Spriel 

Signed-off-by: Madhan Mohan R 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 3 +++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 541d54661c9e..34a838fcc319 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -51,6 +51,7 @@

 #define DEFAULT_F2_WATERMARK0x8
 #define CY_4373_F2_WATERMARK0x40
+#define CY_4373_F1_MESBUSYCTRL  (CY_4373_F2_WATERMARK |
SBSDIO_MESBUSYCTRL_ENAB)


I don't see much value for this define. It is use once below so just or
it there. That way you can "directly" see what is written to the register.


 #ifdef DEBUG

@@ -4118,6 +4119,8 @@ static void brcmf_sdio_firmware_callback(struct
device *dev, int err,
 devctl |= SBSDIO_DEVCTL_F2WM_ENAB;
 brcmf_sdiod_writeb(sdiod, SBSDIO_DEVICE_CTL, devctl,
);
+brcmf_sdiod_writeb(sdiod, SBSDIO_FUNC1_MESBUSYCTRL,
+   CY_4373_F1_MESBUSYCTRL, );


just use 'CY_4373_F2_WATERMARK | SBSDIO_MESBUSYCTRL_ENAB' here. No
braces needed.


Thanks for the input. The biggest difference is to prevent a 4-line
function call like below so it's more readable. I'll make this change in
V2. Please let me know if below looks too messy then I'll move back to V1:

 brcmf_sdiod_writeb(sdiod, CY_4373_F2_WATERMARK |
SBSDIO_MESBUSYCTRL_ENAB,
CY_4373_F2_WATERMARK |
SBSDIO_MESBUSYCTRL_ENAB, );



The second argument should just be SBSDIO_FUNC1_MESBUSYCTRL so that will 
make it a bit less messy. Look okay to me.


Regards,
Arend



Re: [iw] [patch] Please support CPPFLAGS in Makefile

2018-11-09 Thread Johannes Berg


> > So I guess attachment is fine, but you need to add the s-o-b and a
> > commit message in the patch itself.

So, actually, that didn't work. I've applied the patch anyway, but in
the future better submit patches inline in the email so patchwork picks
them up and I can track them (and don't lose them).

johannes



Re: [PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Lorenzo Bianconi
> On 2018-11-09 12:09, Lorenzo Bianconi wrote:
> >> Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
> >> setting BSSID for STA.
> >> 
> >> Signed-off-by: Stanislaw Gruszka 
> >> ---
> >>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
> >>  1 file changed, 9 insertions(+), 3 deletions(-)
> >> 
> >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
> >> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> >> index 59b336e34cb5..cfeae5586897 100644
> >> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> >> @@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
> >>  
> >>  void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 
> >> *addr)
> >>  {
> >> +  u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
> >> +   get_unaligned_le16(addr + 4));
> >> +  u32 bssid_l = get_unaligned_le32(addr);
> >> +
> >> +  if (idx > 7)
> >> +  bssid_h |= MT_MAC_APC_BSSID0_H_EN;
> > 
> > This bit is to enable APClient mode and it is valid just for register 0x1094
> > (MT_MAC_APC_BSSID_{L,h}(0)). Moreover IIRC APClient has been disabled 
> > because
> > it causes a performance degradation.
> The performance degradation was with MAC_ADDR_EXT, not AP-Client.
> This patch should be fine.

Ah, now I remember sorry, you are right :)
Anyway IIRC MT_MAC_APC_BSSID0_H_EN is just for AP_CLIENT_BSSID0 (at least for
76x2), for others we need to use BIT(31) but just if APClient is disabled, 
right?
Moreover BSSID filter is currently disabled (BIT(3) in RX_FILTER_CFG).

# echo 0x1400 > /sys/kernel/debug/ieee80211/phy0/mt76/regidx
# cat /sys/kernel/debug/ieee80211/phy0/mt76/regval
0x00017f97

Have you tried to enabled it?

Regards,
Lorenzo

> 
> - Felix


Re: [PATCH 2/5] mt76x02: initalize mutli bss mode by default

2018-11-09 Thread Stanislaw Gruszka
On Fri, Nov 09, 2018 at 12:26:51PM +0100, Lorenzo Bianconi wrote:
> > @@ -52,9 +52,6 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
> > struct mt76x02_dev *dev = hw->priv;
> > unsigned int idx = 8;
> >  
> > -   if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
> > -   mt76x02_mac_setaddr(dev, vif->addr);
> > -
> 
> I think this is a regression since you will able to change device mac address
> in this way. Do you agree?

I don't think it works currently, because we have already created
vif interface when set mac address via ieee80211_change_mac().

The only thing, I suppose could work is set MAC, del vif and
add vif. But this does not seems to work either , below is
example from unpached kernel:

[root@dhcp-27-155 ~]# iw dev
phy#1
Interface wlan1
ifindex 10
wdev 0x10001
addr 2c:4d:54:cb:d8:04
type managed
[root@dhcp-27-155 ~]# ip link set addres  b0:6e:bf:a5:31:90  wlan1
[root@dhcp-27-155 ~]# iw dev wlan1 del
[root@dhcp-27-155 ~]# iw phy phy0 interface  add wlan0 type station
command failed: No such file or directory (-2)
[root@dhcp-27-155 ~]# iw phy phy1 interface  add wlan0 type station
[root@dhcp-27-155 ~]# iw dev 
phy#1
Interface wlan0
ifindex 11
wdev 0x10002
addr 2c:4d:54:cb:d8:04
type managed
[root@dhcp-27-155 ~]# ethtool -i wlan0
driver: mt76x2u
version: 4.20.0-rc1+
firmware-version: 0.0.00-b1
bus-info: 1-1.2:1.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

Anyway I think, to support MAC address change, we should not filter
based on MAC address, but maybe only on BSSID ? 

Thanks
Stanislaw


Re: [PATCH 2/5] mt76x02: initalize mutli bss mode by default

2018-11-09 Thread Lorenzo Bianconi
> [root@dhcp-27-155 ~]# iw dev
> phy#1
>   Interface wlan1
>   ifindex 10
>   wdev 0x10001
>   addr 2c:4d:54:cb:d8:04
>   type managed
> [root@dhcp-27-155 ~]# ip link set addres  b0:6e:bf:a5:31:90  wlan1
> [root@dhcp-27-155 ~]# iw dev wlan1 del
> [root@dhcp-27-155 ~]# iw phy phy0 interface  add wlan0 type station
> command failed: No such file or directory (-2)
> [root@dhcp-27-155 ~]# iw phy phy1 interface  add wlan0 type station
> [root@dhcp-27-155 ~]# iw dev 
> phy#1
>   Interface wlan0
>   ifindex 11
>   wdev 0x10002
>   addr 2c:4d:54:cb:d8:04
>   type managed
> [root@dhcp-27-155 ~]# ethtool -i wlan0
> driver: mt76x2u
> version: 4.20.0-rc1+
> firmware-version: 0.0.00-b1
> bus-info: 1-1.2:1.0
> supports-statistics: yes
> supports-test: no
> supports-eeprom-access: no
> supports-register-dump: no
> supports-priv-flags: no
> 
> Anyway I think, to support MAC address change, we should not filter
> based on MAC address, but maybe only on BSSID ? 
> 
> Thanks
> Stanislaw

You can create the interface with a given mac address

# iw phy phy0 interface add wlp0s4u1 type managed addr 00:11:22:33:44:55
# iw dev
phy#0
Interface wlp0s4u1
ifindex 9
wdev 0x2
addr 00:11:22:33:44:55
type managed
txpower 3.00 dBm

# ip link show dev wlp0s4u1
9: wlp0s4u1:  mtu 1500 qdisc noqueue state UP 
mode DORMANT group default qlen 1000
link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

Regards,
Lorenzo



Re: [PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Lorenzo Bianconi
> On Fri, Nov 09, 2018 at 01:50:51PM +0100, Lorenzo Bianconi wrote:
> > > On 2018-11-09 12:09, Lorenzo Bianconi wrote:
> > > >> Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
> > > >> setting BSSID for STA.
> > > >> 
> > > >> Signed-off-by: Stanislaw Gruszka 
> > > >> ---
> > > >>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
> > > >>  1 file changed, 9 insertions(+), 3 deletions(-)
> > > >> 
> > > >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
> > > >> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > > >> index 59b336e34cb5..cfeae5586897 100644
> > > >> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > > >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
> > > >> @@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
> > > >>  
> > > >>  void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 
> > > >> *addr)
> > > >>  {
> > > >> +  u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
> > > >> +   get_unaligned_le16(addr + 4));
> > > >> +  u32 bssid_l = get_unaligned_le32(addr);
> > > >> +
> > > >> +  if (idx > 7)
> > > >> +  bssid_h |= MT_MAC_APC_BSSID0_H_EN;
> > > > 
> > > > This bit is to enable APClient mode and it is valid just for register 
> > > > 0x1094
> > > > (MT_MAC_APC_BSSID_{L,h}(0)). Moreover IIRC APClient has been disabled 
> > > > because
> > > > it causes a performance degradation.
> > > The performance degradation was with MAC_ADDR_EXT, not AP-Client.
> > > This patch should be fine.
> > 
> > Ah, now I remember sorry, you are right :)
> > Anyway IIRC MT_MAC_APC_BSSID0_H_EN is just for AP_CLIENT_BSSID0 (at least 
> > for
> > 76x2), for others we need to use BIT(31) but just if APClient is disabled, 
> > right?
> > Moreover BSSID filter is currently disabled (BIT(3) in RX_FILTER_CFG).
> > 
> > # echo 0x1400 > /sys/kernel/debug/ieee80211/phy0/mt76/regidx
> > # cat /sys/kernel/debug/ieee80211/phy0/mt76/regval
> > 0x00017f97
> > 
> > Have you tried to enabled it?
> 
> I didn't try this yet, but I think it should be enabled to support
> mulit BSS and MAC address change. 

I agree we can use multi-BSS for mac filtering in AP mode but my gut feeling in
STA the hw uses the value in MT_MAC_ADDR_DW{0,1} for unicast packet filtering
(BIT(2) in RX_FILTER_CFG). Moreover I think there is a relation between
MT_MAC_ADDR_DW and BSSID values in multiAP mode.

Regards,
Lorenzo

> 
> However I still don't know how to set multiple bssid for STA,
> Use BIT(31) or BIT(16) as indicator or maybe 
> just write BSSID to MT_MAC_APC_BSSID_{H,L} and hardware will
> recognize this is not AP BSSID ?
> 
> Thanks
> Stanislaw


Re: [PATCH 4/5] mt76x02: minor beaconing init changes

2018-11-09 Thread Lorenzo Bianconi
> On Fri, Nov 09, 2018 at 12:33:32PM +0100, Lorenzo Bianconi wrote:
> > > Disable BEACON timer during init and remove interrupt registers
> > > initalization form generic conde since they are PCIe specific.
> > > 
> > 
> > Since the timer is actually disabled (MT_INT_TIMER_EN set to 0) and
> > we just set the timer timeout here, does it worth to copy/paste
> > the same code?
> 
> As I pointed somwhere else I have some random, not easy to reproduce
> performance drops on MT7610U sta mode, starting when AP mode support
> was added. I'm can not be sure if this is by this setting this
> timer, but I would rather accept slight code duplication, than 
> do something that (even with very low probability) can cause
> troubles and for sure is not necessary.

I am fine with this patch but I do not see how original code can cause issues 
since
MT_INT_TIMER_EN is already set it to 0 (comment mt76_wr(dev, MT_INT_TIMER_EN, 
0) out
in the original code)

Regards,
Lorenzo

> 
> Thanks
> Stanislaw


Re: [PATCH 1/5] mt76x02: correct set bssid for STA

2018-11-09 Thread Felix Fietkau
On 2018-11-09 12:09, Lorenzo Bianconi wrote:
>> Use MT_MAC_APC_BSSID0_H_EN bit to indicatate we are
>> setting BSSID for STA.
>> 
>> Signed-off-by: Stanislaw Gruszka 
>> ---
>>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 12 +---
>>  1 file changed, 9 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c 
>> b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
>> index 59b336e34cb5..cfeae5586897 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
>> @@ -826,10 +826,16 @@ void mt76x02_mac_work(struct work_struct *work)
>>  
>>  void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr)
>>  {
>> +u32 bssid_h = FIELD_PREP(MT_MAC_APC_BSSID_H_ADDR,
>> + get_unaligned_le16(addr + 4));
>> +u32 bssid_l = get_unaligned_le32(addr);
>> +
>> +if (idx > 7)
>> +bssid_h |= MT_MAC_APC_BSSID0_H_EN;
> 
> This bit is to enable APClient mode and it is valid just for register 0x1094
> (MT_MAC_APC_BSSID_{L,h}(0)). Moreover IIRC APClient has been disabled because
> it causes a performance degradation.
The performance degradation was with MAC_ADDR_EXT, not AP-Client.
This patch should be fine.

- Felix


Re: [PATCH] mac80211: allow hardware scan to fall back to software

2018-11-09 Thread Siva Rebbagondla
On Fri, Nov 9, 2018 at 4:49 PM Johannes Berg  wrote:
>
> On Fri, 2018-11-09 at 11:48 +0530, Siva Rebbagondla wrote:
> > Hi,
> > Gentle Remainder..!!!.
> > Any update required for this patch?. If not, When can i expect this
> > patch to be available in wireless-next?.
>
> Sorry, I hadn't been merging things for a while due to the merge window.
>
> I just put it into mac80211-next, so I guess the answer should be
> "soon".
Thank you. I was waiting for a long time for this patch.

Best Regards,
Siva Rebbagondla
>
> johannes
>


Re: [PATCH 4/5] mt76x02: minor beaconing init changes

2018-11-09 Thread Stanislaw Gruszka
On Fri, Nov 09, 2018 at 12:33:32PM +0100, Lorenzo Bianconi wrote:
> > Disable BEACON timer during init and remove interrupt registers
> > initalization form generic conde since they are PCIe specific.
> > 
> 
> Since the timer is actually disabled (MT_INT_TIMER_EN set to 0) and
> we just set the timer timeout here, does it worth to copy/paste
> the same code?

As I pointed somwhere else I have some random, not easy to reproduce
performance drops on MT7610U sta mode, starting when AP mode support
was added. I'm can not be sure if this is by this setting this
timer, but I would rather accept slight code duplication, than 
do something that (even with very low probability) can cause
troubles and for sure is not necessary.

Thanks
Stanislaw


Re: [PATCH v2] mt76: remove wait argument from mt76x02_mcu_calibrate

2018-11-09 Thread Lorenzo Bianconi
> We always wait for CMD_CALIBRATION_OP mcu message, but wait argument is used
> for do additional MT_MCU_COM_REG0 register operations, which are needed
> for mt76x2e devices and we can use appropriate check instead of wait argument.
> 
> Signed-off-by: Stanislaw Gruszka 
> ---

Reviewed-by: Lorenzo Bianconi 


[PATCH v2] brcmfmac: support STA info struct v7

2018-11-09 Thread Dan Haab
The newest firmwares provide STA info using v7 of the struct. As v7
isn't backward compatible, a union is needed.

Even though brcmfmac does not use any of the new info it's important to
provide the proper struct buffer. Without this change new firmwares will
fallback to the very limited v3 instead of something in between such as
v4.

Signed-off-by: Dan Haab 
Reviewed-by: Rafał Miłecki 
---
 .../broadcom/brcm80211/brcmfmac/fwil_types.h   | 40 ++
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
index d5bb81e..39ac1bb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
@@ -176,6 +176,8 @@
 
 #define BRCMF_VHT_CAP_MCS_MAP_NSS_MAX  8
 
+#define BRCMF_HE_CAP_MCS_MAP_NSS_MAX   8
+
 /* MAX_CHUNK_LEN is the maximum length for data passing to firmware in each
  * ioctl. It is relatively small because firmware has small maximum size input
  * playload restriction for ioctls.
@@ -601,13 +603,37 @@ struct brcmf_sta_info_le {
__le32 rx_pkts_retried;/* # rx with retry bit set */
__le32 tx_rate_fallback;   /* lowest fallback TX rate */
 
-   /* Fields valid for ver >= 5 */
-   struct {
-   __le32 count;   /* # rates in 
this set */
-   u8 rates[BRCMF_MAXRATES_IN_SET];/* rates in 
500kbps units w/hi bit set if basic */
-   u8 mcs[BRCMF_MCSSET_LEN];   /* supported 
mcs index bit map */
-   __le16 vht_mcs[BRCMF_VHT_CAP_MCS_MAP_NSS_MAX];  /* supported 
mcs index bit map per nss */
-   } rateset_adv;
+   union {
+   struct {
+   struct {
+   __le32 count;   
/* # rates in this set */
+   u8 rates[BRCMF_MAXRATES_IN_SET];
/* rates in 500kbps units w/hi bit set if basic */
+   u8 mcs[BRCMF_MCSSET_LEN];   
/* supported mcs index bit map */
+   __le16 vht_mcs[BRCMF_VHT_CAP_MCS_MAP_NSS_MAX];  
/* supported mcs index bit map per nss */
+   } rateset_adv;
+   } v5;
+
+   struct {
+   __le32 rx_dur_total;/* total user RX duration 
(estimated) */
+   __le16 chanspec;/** chanspec this sta is on */
+   __le16 pad_1;
+   struct {
+   __le16 version; 
/* version */
+   __le16 len; 
/* length */
+   __le32 count;   
/* # rates in this set */
+   u8 rates[BRCMF_MAXRATES_IN_SET];
/* rates in 500kbps units w/hi bit set if basic */
+   u8 mcs[BRCMF_MCSSET_LEN];   
/* supported mcs index bit map */
+   __le16 vht_mcs[BRCMF_VHT_CAP_MCS_MAP_NSS_MAX];  
/* supported mcs index bit map per nss */
+   __le16 he_mcs[BRCMF_HE_CAP_MCS_MAP_NSS_MAX];
/* supported he mcs index bit map per nss */
+   } rateset_adv;  /* rateset along with mcs index 
bitmap */
+   __le16 wpauth;  /* authentication type */
+   u8 algo;/* crypto algorithm */
+   u8 pad_2;
+   __le32 tx_rspec;/* Rate of last successful tx 
frame */
+   __le32 rx_rspec;/* Rate of last successful rx 
frame */
+   __le32 wnm_cap; /* wnm capabilities */
+   } v7;
+   };
 };
 
 struct brcmf_chanspec_list {
-- 
1.9.1



[PATCH] crda: add URLs to README

2018-11-09 Thread Xose Vazquez Perez
Cc: Luis R. Rodriguez 
Cc: WIRELESS ML 
Cc: REGDB ML 
Signed-off-by: Xose Vazquez Perez 
---
 README | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README b/README
index 5d89b83..88f2623 100644
--- a/README
+++ b/README
@@ -1,5 +1,6 @@
  Central Regulatory Domain Agent (CRDA)
 
+
 
 This is the Central Regulatory Domain Agent for Linux. It serves one
 purpose: tell Linux kernel what to enforce. In essence it is a udev
@@ -46,6 +47,7 @@ with this package as regulatory.rules
 
  OVERVIEW
 ==
+
 
 The database is maintained on the wireless-regdb.git tree. This git
 tree maintains a binary regulatory database file which is produced
-- 
2.19.1



Re: [PATCH 2/5] mt76x02: initalize mutli bss mode by default

2018-11-09 Thread Stanislaw Gruszka
On Fri, Nov 09, 2018 at 02:31:31PM +0100, Lorenzo Bianconi wrote:
> > 
> > Anyway I think, to support MAC address change, we should not filter
> > based on MAC address, but maybe only on BSSID ? 
> > 
> > Thanks
> > Stanislaw
> 
> You can create the interface with a given mac address
> 
> # iw phy phy0 interface add wlp0s4u1 type managed addr 00:11:22:33:44:55

I realized I have ancient version of iw :-)

Ok, so to do not break that we can add it to common function like this:

+   if (vif->type == NL80211_IFTYPE_STATION) {
+   if (idx == 0)
+   mt76x02_mac_init_mbss(dev, vif->addr);
idx += 8;
+   }

Thanks
Stanislaw
 


Re: [PATCH 2/5] mt76x02: initalize mutli bss mode by default

2018-11-09 Thread Lorenzo Bianconi
> On Fri, Nov 09, 2018 at 02:31:31PM +0100, Lorenzo Bianconi wrote:
> > > 
> > > Anyway I think, to support MAC address change, we should not filter
> > > based on MAC address, but maybe only on BSSID ? 
> > > 
> > > Thanks
> > > Stanislaw
> > 
> > You can create the interface with a given mac address
> > 
> > # iw phy phy0 interface add wlp0s4u1 type managed addr 00:11:22:33:44:55
> 
> I realized I have ancient version of iw :-)
> 
> Ok, so to do not break that we can add it to common function like this:
> 
> + if (vif->type == NL80211_IFTYPE_STATION) {
> + if (idx == 0)
> + mt76x02_mac_init_mbss(dev, vif->addr);
>   idx += 8;
> + }
> 
> Thanks
> Stanislaw
>  

Does this patch break AP + STA configuration (since we are changing 
MT_MAC_ADDR_DW{0,1}
regs with a possible complete different value)? I think (but not 100% sure)
MT_MAC_ADDR_DW is linked to BSSID used.
Maybe it is safer to maintain mt76x2u_add_interface routine since it is just a 
static
function used in mt76x2u module

Regards,
Lorenzo


[PATCH v5 3/3] staging: wilc1000: Remove unused mutex cfg_values_lock

2018-11-09 Thread Adham.Abozaeid
From: Adham Abozaeid 

After removing cfg_values member, cfg_values_lock that was used to protect
it can also be removed.

Signed-off-by: Adham Abozaeid 
---
 drivers/staging/wilc1000/host_interface.c | 9 -
 drivers/staging/wilc1000/host_interface.h | 2 --
 2 files changed, 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 8d1142776310..2bf91df1ded1 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -369,11 +369,8 @@ static void handle_cfg_param(struct work_struct *work)
struct cfg_param_attr *param = >body.cfg_info;
int ret;
struct wid wid_list[32];
-   struct host_if_drv *hif_drv = vif->hif_drv;
int i = 0;
 
-   mutex_lock(_drv->cfg_values_lock);
-
if (param->flag & RETRY_SHORT) {
wid_list[i].id = WID_SHORT_RETRY_LIMIT;
wid_list[i].val = (s8 *)>short_retry_limit;
@@ -409,7 +406,6 @@ static void handle_cfg_param(struct work_struct *work)
if (ret)
netdev_err(vif->ndev, "Error in setting CFG params\n");
 
-   mutex_unlock(_drv->cfg_values_lock);
kfree(msg);
 }
 
@@ -3240,15 +3236,10 @@ int wilc_init(struct net_device *dev, struct 
host_if_drv **hif_drv_handler)
timer_setup(_drv->connect_timer, timer_connect_cb, 0);
timer_setup(_drv->remain_on_ch_timer, listen_timer_cb, 0);
 
-   mutex_init(_drv->cfg_values_lock);
-   mutex_lock(_drv->cfg_values_lock);
-
hif_drv->hif_state = HOST_IF_IDLE;
 
hif_drv->p2p_timeout = 0;
 
-   mutex_unlock(_drv->cfg_values_lock);
-
wilc->clients_count++;
 
return 0;
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 1e2e50e91f76..523b46bfb488 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -293,8 +293,6 @@ struct host_if_drv {
enum host_if_state hif_state;
 
u8 assoc_bssid[ETH_ALEN];
-   /*lock to protect concurrent setting of cfg params*/
-   struct mutex cfg_values_lock;
 
struct timer_list scan_timer;
struct wilc_vif *scan_timer_vif;
-- 
2.17.1



[PATCH v5 0/3] staging: wilc1000: validate input to set_wiphy_param and return proper

2018-11-09 Thread Adham.Abozaeid
From: Adham Abozaeid 

Validate input parameters to set_wiphy_param before scheduling
handle_cfg_param() to validate them.
This way proper errors can be returned to caller.
Also cleaned up unused code in handle_cfg_param.

Changes since v1:
- Correction spelling in subject of patch#2
- Added From: tag to have correct email from value

Changes since v2:
- Reverted unnecessary file permission changes

Changes since v3:
- Fixed 0-day bot warnings for always true conditions for retry_short and
retry_long
- Fixed typo in From: tag

Changes since v4:
- Fixed duplicate From: tag

Adham Abozaeid (3):
  staging: wilc1000: validate cfg parameters before scheduling the work
  staging: wilc1000: Don't keep a copy of wiphy parameters in the driver
  staging: wilc1000: Remove unused mutex cfg_values_lock

 drivers/staging/wilc1000/host_interface.c | 75 ---
 drivers/staging/wilc1000/host_interface.h |  3 -
 .../staging/wilc1000/wilc_wfi_cfgoperations.c | 32 +++-
 3 files changed, 44 insertions(+), 66 deletions(-)

-- 
2.17.1



[PATCH v5 2/3] staging: wilc1000: Don't keep a copy of wiphy parameters in the driver

2018-11-09 Thread Adham.Abozaeid
From: Adham Abozaeid 

host_if_drv.cfg_values is a write only member, and can be removed

Signed-off-by: Adham Abozaeid 
---
 drivers/staging/wilc1000/host_interface.c | 13 -
 drivers/staging/wilc1000/host_interface.h |  1 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c1215c194907..8d1142776310 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -375,43 +375,31 @@ static void handle_cfg_param(struct work_struct *work)
mutex_lock(_drv->cfg_values_lock);
 
if (param->flag & RETRY_SHORT) {
-   u16 retry_limit = param->short_retry_limit;
-
wid_list[i].id = WID_SHORT_RETRY_LIMIT;
wid_list[i].val = (s8 *)>short_retry_limit;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.short_retry_limit = retry_limit;
i++;
}
if (param->flag & RETRY_LONG) {
-   u16 limit = param->long_retry_limit;
-
wid_list[i].id = WID_LONG_RETRY_LIMIT;
wid_list[i].val = (s8 *)>long_retry_limit;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.long_retry_limit = limit;
i++;
}
if (param->flag & FRAG_THRESHOLD) {
-   u16 frag_th = param->frag_threshold;
-
wid_list[i].id = WID_FRAG_THRESHOLD;
wid_list[i].val = (s8 *)>frag_threshold;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.frag_threshold = frag_th;
i++;
}
if (param->flag & RTS_THRESHOLD) {
-   u16 rts_th = param->rts_threshold;
-
wid_list[i].id = WID_RTS_THRESHOLD;
wid_list[i].val = (s8 *)>rts_threshold;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.rts_threshold = rts_th;
i++;
}
 
@@ -3256,7 +3244,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
mutex_lock(_drv->cfg_values_lock);
 
hif_drv->hif_state = HOST_IF_IDLE;
-   hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
 
hif_drv->p2p_timeout = 0;
 
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index df9fc33be094..1e2e50e91f76 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -293,7 +293,6 @@ struct host_if_drv {
enum host_if_state hif_state;
 
u8 assoc_bssid[ETH_ALEN];
-   struct cfg_param_attr cfg_values;
/*lock to protect concurrent setting of cfg params*/
struct mutex cfg_values_lock;
 
-- 
2.17.1



[PATCH v5 1/3] staging: wilc1000: validate cfg parameters before scheduling the work

2018-11-09 Thread Adham.Abozaeid
From: Adham Abozaeid 

Validate cfg parameters after being called by cfg80211 in set_wiphy_params
before scheduling the work executed in handle_cfg_param

Signed-off-by: Adham Abozaeid 
---
 drivers/staging/wilc1000/host_interface.c | 61 ++-
 .../staging/wilc1000/wilc_wfi_cfgoperations.c | 32 --
 2 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index b89116c57064..c1215c194907 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -377,61 +377,41 @@ static void handle_cfg_param(struct work_struct *work)
if (param->flag & RETRY_SHORT) {
u16 retry_limit = param->short_retry_limit;
 
-   if (retry_limit > 0 && retry_limit < 256) {
-   wid_list[i].id = WID_SHORT_RETRY_LIMIT;
-   wid_list[i].val = (s8 *)>short_retry_limit;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.short_retry_limit = retry_limit;
-   } else {
-   netdev_err(vif->ndev, "Range(1~256) over\n");
-   goto unlock;
-   }
+   wid_list[i].id = WID_SHORT_RETRY_LIMIT;
+   wid_list[i].val = (s8 *)>short_retry_limit;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   hif_drv->cfg_values.short_retry_limit = retry_limit;
i++;
}
if (param->flag & RETRY_LONG) {
u16 limit = param->long_retry_limit;
 
-   if (limit > 0 && limit < 256) {
-   wid_list[i].id = WID_LONG_RETRY_LIMIT;
-   wid_list[i].val = (s8 *)>long_retry_limit;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.long_retry_limit = limit;
-   } else {
-   netdev_err(vif->ndev, "Range(1~256) over\n");
-   goto unlock;
-   }
+   wid_list[i].id = WID_LONG_RETRY_LIMIT;
+   wid_list[i].val = (s8 *)>long_retry_limit;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   hif_drv->cfg_values.long_retry_limit = limit;
i++;
}
if (param->flag & FRAG_THRESHOLD) {
u16 frag_th = param->frag_threshold;
 
-   if (frag_th > 255 && frag_th < 7937) {
-   wid_list[i].id = WID_FRAG_THRESHOLD;
-   wid_list[i].val = (s8 *)>frag_threshold;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.frag_threshold = frag_th;
-   } else {
-   netdev_err(vif->ndev, "Threshold Range fail\n");
-   goto unlock;
-   }
+   wid_list[i].id = WID_FRAG_THRESHOLD;
+   wid_list[i].val = (s8 *)>frag_threshold;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   hif_drv->cfg_values.frag_threshold = frag_th;
i++;
}
if (param->flag & RTS_THRESHOLD) {
u16 rts_th = param->rts_threshold;
 
-   if (rts_th > 255) {
-   wid_list[i].id = WID_RTS_THRESHOLD;
-   wid_list[i].val = (s8 *)>rts_threshold;
-   wid_list[i].type = WID_SHORT;
-   wid_list[i].size = sizeof(u16);
-   hif_drv->cfg_values.rts_threshold = rts_th;
-   } else {
-   netdev_err(vif->ndev, "Threshold Range fail\n");
-   goto unlock;
-   }
+   wid_list[i].id = WID_RTS_THRESHOLD;
+   wid_list[i].val = (s8 *)>rts_threshold;
+   wid_list[i].type = WID_SHORT;
+   wid_list[i].size = sizeof(u16);
+   hif_drv->cfg_values.rts_threshold = rts_th;
i++;
}
 
@@ -441,7 +421,6 @@ static void handle_cfg_param(struct work_struct *work)
if (ret)
netdev_err(vif->ndev, "Error in setting CFG params\n");
 
-unlock:
mutex_unlock(_drv->cfg_values_lock);
kfree(msg);
 }
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 4fd5a64b..a6f4fad43bf7 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1149,21 +1149,45 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 
changed)
cfg_param_val.flag = 0;
 
if (changed & 

[PATCH] wireless-regdb: add URLs in README

2018-11-09 Thread Xose Vazquez Perez
Cc: Seth Forshee 
Cc: WIRELESS ML 
Cc: REGDB ML 
Signed-off-by: Xose Vazquez Perez 
---
 README | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/README b/README
index 4028223..4a059de 100644
--- a/README
+++ b/README
@@ -1,3 +1,7 @@
+ wireless-regdb
+
+
+
 This repository contains the plain text version of the regulatory
 database file I maintain for use with Central Regulatory Database
 Agent daemon.  Also included is the compiled binary version of this
@@ -9,6 +13,7 @@ either expressed or implied.
 Also included are the tools used to compile and sign the regulatory.bin
 file as well as a MoinMoin macro used for viewing the database.
 
+
  TECHNICAL INFORMATION
 ===
 
@@ -21,9 +26,13 @@ to allow viewing the database for verification.
 The dbparse module is also used by db2bin.py and db2fw.py, the `compilers'
 that compile the database to its binary formats.
 
-For more information, please see the CRDA git repository:
+For more information, please see the CRDA page:
+
+   https://wireless.wiki.kernel.org/en/developers/regulatory/crda
+
+and the full description of the Linux regulatory stack:
 
-   git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/crda.git
+   https://wireless.wiki.kernel.org/en/developers/regulatory
 
 John W. Linville
 17 November 2008
-- 
2.19.1