Message ID | 1541758814-2046-3-git-send-email-sgruszka@redhat.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Kalle Valo |
Headers | show |
Series | mt76x02: bssid setup corrections for STA | expand |
> 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 <sgruszka@redhat.com> > --- > 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(&dev->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 >
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 0x100000001 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 0x100000002 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
> [root@dhcp-27-155 ~]# iw dev > phy#1 > Interface wlan1 > ifindex 10 > wdev 0x100000001 > 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 0x100000002 > 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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
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
> 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
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, 0xffff); - for (i = 0; i < 8; i++) { - mt76x02_mac_set_bssid(dev, i, null_addr); + for (i = 0; i < 8; i++) mt76x02_mac_set_beacon(dev, i, NULL); - } + mt76x02_set_beacon_offsets(dev); } EXPORT_SYMBOL_GPL(mt76x02_init_beacon_config); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c index 076b7479ba99..d2ef68c48ea5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c @@ -119,9 +119,7 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard) mt76_wr(dev, MT_MCU_CLOCK_CTL, 0x1401); mt76_clear(dev, MT_FCE_L2_STUFF, MT_FCE_L2_STUFF_WR_MPDU_LEN_EN); - mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(macaddr)); - mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(macaddr + 4)); - + mt76x02_mac_init_mbss(dev, macaddr); mt76x02_init_beacon_config(dev); if (!hard) return 0; 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(&dev->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); - mt76x02_vif_init(dev, vif, idx); return 0; }
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 <sgruszka@redhat.com> --- 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(-)