Skip to contentSkip to conversation

wil6210 patches

PATCH In review Maya Erez 2 participants 13 messages Dec 18, 2019 – Dec 19, 2019 Wilocity WIL6210 wireless driver

lore
Share & tools
lore

Maya Erez

author
#0 lore raw

cover wil6210 patches

The following patches include wil6210 fixes

Ahmad Masri (2):
wil6210: dump Rx status message on errors
wil6210: support set_multicast_to_unicast cfg80211 operation

Alexei Avshalom Lazar (3):
wil6210: minimize the time that mem_lock is held
wil6210: take mem_lock for writing in crash dump collection
wil6210: add verification for cid upper bound

Dedy Lansky (3):
wil6210: reduce ucode_debug memory region
wil6210: fix MID valid bits in Rx status message
wil6210: add support for set_cqm_rssi_config

 drivers/net/wireless/ath/wil6210/cfg80211.c   | 34 ++++++++
 drivers/net/wireless/ath/wil6210/main.c       | 10 ++-
 drivers/net/wireless/ath/wil6210/txrx.c       | 32 +++++++-
 drivers/net/wireless/ath/wil6210/txrx_edma.c  | 10 +++
 drivers/net/wireless/ath/wil6210/txrx_edma.h  |  8 +-
 drivers/net/wireless/ath/wil6210/wil6210.h    |  6 +-
 .../net/wireless/ath/wil6210/wil_crash_dump.c | 17 ++--
 drivers/net/wireless/ath/wil6210/wmi.c        | 80 ++++++++++++++++++-
 drivers/net/wireless/ath/wil6210/wmi.h        | 33 ++++++++
 9 files changed, 213 insertions(+), 17 deletions(-)
Signature · 1 line
2.23.0
author
#1 lore raw

PATCH 1/8 wil6210: dump Rx status message on errors

From: Ahmad Masri <[email protected]>

Dump all the Rx status message on different errors to allow more visibility of the case.

---
 drivers/net/wireless/ath/wil6210/txrx_edma.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/ath/wil6210/txrx_edma.c +10 -0
index 02548d40253c..6a1671c3a2be 100644
@@ -903,6 +903,11 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 	if (unlikely(!wil_val_in_range(buff_id, 1, wil->rx_buff_mgmt.size))) {
 		wil_err(wil, "Corrupt buff_id=%d, sring->swhead=%d\n",
 			buff_id, sring->swhead);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?
+			       sizeof(struct wil_rx_status_compressed) :
+			       sizeof(struct wil_rx_status_extended), false);
+
 		wil_rx_status_reset_buff_id(sring);
 		wil_sring_advance_swhead(sring);
 		sring->invalid_buff_id_cnt++;
@@ -963,6 +968,11 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 
 	if (unlikely(dmalen > sz)) {
 		wil_err(wil, "Rx size too large: %d bytes!\n", dmalen);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?
+			       sizeof(struct wil_rx_status_compressed) :
+			       sizeof(struct wil_rx_status_extended), false);
+
 		stats->rx_large_frame++;
 		rxdata->skipping = true;
 	}
Signature · 1 line
2.23.0
#2 lore raw

Re: [PATCH 1/8] wil6210: dump Rx status message on errors

Quoted 16 lines · Maya Erez

From: Ahmad Masri <[email protected]>

Dump all the Rx status message on different errors to allow more visibility of the case.

---
 drivers/net/wireless/ath/wil6210/txrx_edma.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/ath/wil6210/txrx_edma.c +0 -0
index 02548d40253c..6a1671c3a2be 100644

drivers/net/wireless/ath/wil6210/txrx_edma.c static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil, · line 907

Quoted 5 lines
drivers/net/wireless/ath/wil6210/txrx_edma.c +2 -0
@@ -903,6 +903,11 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 	if (unlikely(!wil_val_in_range(buff_id, 1, wil->rx_buff_mgmt.size))) {
 		wil_err(wil, "Corrupt buff_id=%d, sring->swhead=%d\n",
 			buff_id, sring->swhead);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?

Isn't the cast unnecessary? Please avoid casting as much as possible.

drivers/net/wireless/ath/wil6210/txrx_edma.c static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil, · line 972

Quoted 6 lines
drivers/net/wireless/ath/wil6210/txrx_edma.c +2 -0
@@ -963,6 +968,11 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 
 	if (unlikely(dmalen > sz)) {
 		wil_err(wil, "Rx size too large: %d bytes!\n", dmalen);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?

Same here.

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw

Re: [PATCH 1/8] wil6210: dump Rx status message on errors

Quoted 26 lines · Kalle Valo
Quoted 16 lines · Maya Erez

From: Ahmad Masri <[email protected]>

Dump all the Rx status message on different errors to allow more visibility of the case.

---
 drivers/net/wireless/ath/wil6210/txrx_edma.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/ath/wil6210/txrx_edma.c +0 -0
index 02548d40253c..6a1671c3a2be 100644

drivers/net/wireless/ath/wil6210/txrx_edma.c static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil, · line 907

Quoted 5 lines
drivers/net/wireless/ath/wil6210/txrx_edma.c +2 -0
@@ -903,6 +903,11 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 	if (unlikely(!wil_val_in_range(buff_id, 1, wil->rx_buff_mgmt.size))) {
 		wil_err(wil, "Corrupt buff_id=%d, sring->swhead=%d\n",
 			buff_id, sring->swhead);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?

Isn't the cast unnecessary? Please avoid casting as much as possible.

Quoted 8 lines

drivers/net/wireless/ath/wil6210/txrx_edma.c static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil, · line 972

Quoted 6 lines
drivers/net/wireless/ath/wil6210/txrx_edma.c +2 -0
@@ -963,6 +968,11 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 
 	if (unlikely(dmalen > sz)) {
 		wil_err(wil, "Rx size too large: %d bytes!\n", dmalen);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?

Same here.

I fixed these in the pending branch, please double check:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=51d652cdee36051bdb83809adb91951f41c7a456

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#4 lore raw

Re: [PATCH 1/8] wil6210: dump Rx status message on errors

Quoted 40 lines · Kalle Valo
Quoted 31 lines · Kalle Valo
Quoted 16 lines · Maya Erez

From: Ahmad Masri <[email protected]>

Dump all the Rx status message on different errors to allow more visibility of the case.

---
 drivers/net/wireless/ath/wil6210/txrx_edma.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/ath/wil6210/txrx_edma.c +0 -0
index 02548d40253c..6a1671c3a2be 100644

drivers/net/wireless/ath/wil6210/txrx_edma.c static struct sk_buff · line 909

Quoted 7 lines
drivers/net/wireless/ath/wil6210/txrx_edma.c +2 -0
@@ -903,6 +903,11 @@ static struct sk_buff 
 *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 	if (unlikely(!wil_val_in_range(buff_id, 1, 
 wil->rx_buff_mgmt.size))) {
 		wil_err(wil, "Corrupt buff_id=%d, sring->swhead=%d\n",
 			buff_id, sring->swhead);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?

Isn't the cast unnecessary? Please avoid casting as much as possible.

Quoted 3 lines
drivers/net/wireless/ath/wil6210/txrx_edma.c +0 -0
@@ -963,6 +968,11 @@ static struct sk_buff 
 *wil_sring_reap_rx_edma(struct wil6210_priv *wil,
 
Quoted 6 lines

drivers/net/wireless/ath/wil6210/txrx_edma.c static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil, · line 972

Quoted 4 lines
drivers/net/wireless/ath/wil6210/txrx_edma.c +2 -0
 	if (unlikely(dmalen > sz)) {
 		wil_err(wil, "Rx size too large: %d bytes!\n", dmalen);
+		print_hex_dump(KERN_ERR, "RxS ", DUMP_PREFIX_OFFSET, 16, 1,
+			       (void *)msg, wil->use_compressed_rx_status ?

Same here.

Quoted 3 lines

I fixed these in the pending branch, please double check:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=51d652cdee36051bdb83809adb91951f41c7a456

Thanks for fixing it. The fix looks good.

#5 lore raw

Re: [PATCH 1/8] wil6210: dump Rx status message on errors

In reply to Maya Erez
Quoted 6 lines · Maya Erez

Dump all the Rx status message on different errors to allow more visibility of the case.

8 patches applied to ath-next branch of ath.git, thanks.

7be3c2331d50 wil6210: dump Rx status message on errors d3214d428066 wil6210: minimize the time that mem_lock is held c715b38473c8 wil6210: take mem_lock for writing in crash dump collection 5c5d88a29dd4 wil6210: add verification for cid upper bound c99d5f8d6178 wil6210: reduce ucode_debug memory region 18beb61d848d wil6210: fix MID valid bits in Rx status message 5e5f069c30cc wil6210: support set_multicast_to_unicast cfg80211 operation 4315a74a482f wil6210: add support for set_cqm_rssi_config

Signature · 3 lines
https://patchwork.kernel.org/patch/11300815/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
author
#6 lore raw

PATCH 2/8 wil6210: minimize the time that mem_lock is held

In reply to Maya Erez

From: Alexei Avshalom Lazar <[email protected]>

mem_lock is taken for the entire wil_reset(). Optimize this by taking mem_lock just before device is being reset and release the lock after FW download.

---
 drivers/net/wireless/ath/wil6210/main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/wil6210/main.c +6 -4
index 06091d8a9e23..6d39547e20fd 100644
@@ -1654,6 +1654,8 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
 	/* Disable device led before reset*/
 	wmi_led_cfg(wil, false);
 
+	down_write(&wil->mem_lock);
+
 	/* prevent NAPI from being scheduled and prevent wmi commands */
 	mutex_lock(&wil->wmi_mutex);
 	if (test_bit(wil_status_suspending, wil->status))
@@ -1702,6 +1704,7 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
 
 		if  (wil->secured_boot) {
 			wil_err(wil, "secured boot is not supported\n");
+			up_write(&wil->mem_lock);
 			return -ENOTSUPP;
 		}
 
@@ -1737,6 +1740,8 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
 
 	clear_bit(wil_status_resetting, wil->status);
 
+	up_write(&wil->mem_lock);
+
 	if (load_fw) {
 		wil_unmask_irq(wil);
 
@@ -1786,6 +1791,7 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
 	return rc;
 
 out:
+	up_write(&wil->mem_lock);
 	clear_bit(wil_status_resetting, wil->status);
 	return rc;
 }
@@ -1811,9 +1817,7 @@ int __wil_up(struct wil6210_priv *wil)
 
 	WARN_ON(!mutex_is_locked(&wil->mutex));
 
-	down_write(&wil->mem_lock);
 	rc = wil_reset(wil, true);
-	up_write(&wil->mem_lock);
 	if (rc)
 		return rc;
 
@@ -1905,9 +1909,7 @@ int __wil_down(struct wil6210_priv *wil)
 	wil_abort_scan_all_vifs(wil, false);
 	mutex_unlock(&wil->vif_mutex);
 
-	down_write(&wil->mem_lock);
 	rc = wil_reset(wil, false);
-	up_write(&wil->mem_lock);
 
 	return rc;
 }
Signature · 1 line
2.23.0
author
#7 lore raw

PATCH 3/8 wil6210: take mem_lock for writing in crash dump collection

In reply to Maya Erez

From: Alexei Avshalom Lazar <[email protected]>

On some crash dump cases mem_lock is already taken, error returns and crash dump copy fails.
In this case wait until mem_lock available instead of failing the operation.
Also take the mem_lock for writing to prevent other threads from altering the state of the device while collecting crash dump.

---
 .../net/wireless/ath/wil6210/wil_crash_dump.c   | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/wil6210/wil_crash_dump.c +12 -5
index 1332eb8c831f..89c12cb2aaab 100644
@@ -46,7 +46,7 @@ static int wil_fw_get_crash_dump_bounds(struct wil6210_priv *wil,
 
 int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size)
 {
-	int i, rc;
+	int i;
 	const struct fw_map *map;
 	void *data;
 	u32 host_min, dump_size, offset, len;
@@ -62,9 +62,15 @@ int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size)
 		return -EINVAL;
 	}
 
-	rc = wil_mem_access_lock(wil);
-	if (rc)
-		return rc;
+	down_write(&wil->mem_lock);
+
+	if (test_bit(wil_status_suspending, wil->status) ||
+	    test_bit(wil_status_suspended, wil->status)) {
+		wil_err(wil,
+			"suspend/resume in progress. cannot copy crash dump\n");
+		up_write(&wil->mem_lock);
+		return -EBUSY;
+	}
 
 	/* copy to crash dump area */
 	for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) {
@@ -84,7 +90,8 @@ int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size)
 		wil_memcpy_fromio_32((void * __force)(dest + offset),
 				     (const void __iomem * __force)data, len);
 	}
-	wil_mem_access_unlock(wil);
+
+	up_write(&wil->mem_lock);
 
 	return 0;
 }
Signature · 1 line
2.23.0
author
#8 lore raw

PATCH 4/8 wil6210: add verification for cid upper bound

In reply to Maya Erez

From: Alexei Avshalom Lazar <[email protected]>

max_assoc_sta can receive values (from the user or from the FW) that are higher than WIL6210_MAX_CID.
Verify that cid doesn't exceed the upper bound of WIL6210_MAX_CID.

---
 drivers/net/wireless/ath/wil6210/wil6210.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/wil6210/wil6210.h +1 -1
index 97626bfd4dac..bf00f0693a3d 100644
@@ -1148,7 +1148,7 @@ static inline void wil_c(struct wil6210_priv *wil, u32 reg, u32 val)
  */
 static inline bool wil_cid_valid(struct wil6210_priv *wil, int cid)
 {
-	return (cid >= 0 && cid < wil->max_assoc_sta);
+	return (cid >= 0 && cid < wil->max_assoc_sta && cid < WIL6210_MAX_CID);
 }
 
 void wil_get_board_file(struct wil6210_priv *wil, char *buf, size_t len);
Signature · 1 line
2.23.0
author
#9 lore raw

PATCH 5/8 wil6210: reduce ucode_debug memory region

In reply to Maya Erez

From: Dedy Lansky <[email protected]>

ucode_debug memory region defined as 4K bytes. Fix this according to Talyn device memory map.

---
 drivers/net/wireless/ath/wil6210/wmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/wil6210/wmi.c +2 -2
index 7a0d934eb271..3aca86b3071d 100644
@@ -196,8 +196,8 @@ const struct fw_map talyn_mb_fw_mapping[] = {
 	{0x8c0000, 0x8c0210, 0x8c0000, "dum_user_rgf", true, true},
 	/* DMA OFU 296b */
 	{0x8c2000, 0x8c2128, 0x8c2000, "dma_ofu", true, true},
-	/* ucode debug 4k */
-	{0x8c3000, 0x8c4000, 0x8c3000, "ucode_debug", true, true},
+	/* ucode debug 256b */
+	{0x8c3000, 0x8c3100, 0x8c3000, "ucode_debug", true, true},
 	/* upper area 1536k */
 	{0x900000, 0xa80000, 0x900000, "upper", true, true},
 	/* UCODE areas - accessible by debugfs blobs but not by
Signature · 1 line
2.23.0
author
#10 lore raw

PATCH 6/8 wil6210: fix MID valid bits in Rx status message

In reply to Maya Erez

From: Dedy Lansky <[email protected]>

Fix incorrect definitions of MAC ID bits inside Rx status message.

---
 drivers/net/wireless/ath/wil6210/txrx_edma.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/wil6210/txrx_edma.h +4 -4
index c744c65225da..c736f7413a35 100644
@@ -46,7 +46,7 @@
 
 #define WIL_RX_EDMA_DLPF_LU_MISS_TID_POS	5
 
-#define WIL_RX_EDMA_MID_VALID_BIT		BIT(22)
+#define WIL_RX_EDMA_MID_VALID_BIT		BIT(20)
 
 #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS 16
 #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_LEN 6
@@ -244,8 +244,8 @@ struct wil_ring_tx_status {
  *		     calculated, Bit1- L4Err - TCP/UDP Checksum Error
  *	bit      7 : Reserved:1
  *	bit  8..19 : Flow ID:12 - MSDU flow ID
- *	bit 20..21 : MID:2 - The MAC ID
- *	bit     22 : MID_V:1 - The MAC ID field is valid
+ *	bit     20 : MID_V:1 - The MAC ID field is valid
+ *	bit 21..22 : MID:2 - The MAC ID
  *	bit     23 : L3T:1 - IP types: 0-IPv6, 1-IPv4
  *	bit     24 : L4T:1 - Layer 4 Type: 0-UDP, 1-TCP
  *	bit     25 : BC:1 - The received MPDU is broadcast
@@ -479,7 +479,7 @@ static inline int wil_rx_status_get_mid(void *msg)
 		return 0; /* use the default MID */
 
 	return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
-			    20, 21);
+			    21, 22);
 }
 
 static inline int wil_rx_status_get_error(void *msg)
Signature · 1 line
2.23.0
author
#11 lore raw

PATCH 7/8 wil6210: support set_multicast_to_unicast cfg80211 operation

In reply to Maya Erez

From: Ahmad Masri <[email protected]>

Wil6210 AP has a separate ring for transmitting multicast packets, multicast packets are transmitted without an ack from the receiver side. Therefore, 802.11 spec defines some low MCS rates for multicat packets. However, there is no guarantee that these packets were really received and handled on the client side.

Some applications that rely on multicast packets, may prefer to transmit these packets as a unicast to ensure reliability, and also to ensure better performance with high MCS rates. multicast to unicast is done by duplicating multicast packets to all clients and changing the DA (multicast) to the MAC address of the client.
see NL80211_CMD_SET_MULTICAST_TO_UNICAST for more info.

---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 16 +++++++++++
 drivers/net/wireless/ath/wil6210/txrx.c     | 32 ++++++++++++++++++++-
 drivers/net/wireless/ath/wil6210/wil6210.h  |  1 +
 3 files changed, 48 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/wil6210/cfg80211.c +16 -0
index 7d6f14420855..5a3aff131472 100644
@@ -2579,6 +2579,21 @@ wil_cfg80211_update_ft_ies(struct wiphy *wiphy, struct net_device *dev,
 	return rc;
 }
 
+static int wil_cfg80211_set_multicast_to_unicast(struct wiphy *wiphy,
+						 struct net_device *dev,
+						 const bool enabled)
+{
+	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+
+	if (wil->multicast_to_unicast == enabled)
+		return 0;
+
+	wil_info(wil, "set multicast to unicast, enabled=%d\n", enabled);
+	wil->multicast_to_unicast = enabled;
+
+	return 0;
+}
+
 static const struct cfg80211_ops wil_cfg80211_ops = {
 	.add_virtual_intf = wil_cfg80211_add_iface,
 	.del_virtual_intf = wil_cfg80211_del_iface,
@@ -2615,6 +2630,7 @@ static const struct cfg80211_ops wil_cfg80211_ops = {
 	.sched_scan_start = wil_cfg80211_sched_scan_start,
 	.sched_scan_stop = wil_cfg80211_sched_scan_stop,
 	.update_ft_ies = wil_cfg80211_update_ft_ies,
+	.set_multicast_to_unicast = wil_cfg80211_set_multicast_to_unicast,
 };
 
 static void wil_wiphy_init(struct wiphy *wiphy)
drivers/net/wireless/ath/wil6210/txrx.c +31 -1
index 8ebc6d59aa74..17118d643d7e 100644
@@ -10,6 +10,7 @@
 #include <linux/moduleparam.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
+#include <linux/if_vlan.h>
 #include <net/ipv6.h>
 #include <linux/prefetch.h>
 
@@ -1529,6 +1530,35 @@ static struct wil_ring *wil_find_tx_bcast_1(struct wil6210_priv *wil,
 	return v;
 }
 
+/* apply multicast to unicast only for ARP and IP packets
+ * (see NL80211_CMD_SET_MULTICAST_TO_UNICAST for more info)
+ */
+static bool wil_check_multicast_to_unicast(struct wil6210_priv *wil,
+					   struct sk_buff *skb)
+{
+	const struct ethhdr *eth = (void *)skb->data;
+	const struct vlan_ethhdr *ethvlan = (void *)skb->data;
+	__be16 ethertype;
+
+	if (!wil->multicast_to_unicast)
+		return false;
+
+	/* multicast to unicast conversion only for some payload */
+	ethertype = eth->h_proto;
+	if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN)
+		ethertype = ethvlan->h_vlan_encapsulated_proto;
+	switch (ethertype) {
+	case htons(ETH_P_ARP):
+	case htons(ETH_P_IP):
+	case htons(ETH_P_IPV6):
+		break;
+	default:
+		return false;
+	}
+
+	return true;
+}
+
 static void wil_set_da_for_vring(struct wil6210_priv *wil,
 				 struct sk_buff *skb, int vring_index)
 {
@@ -2336,7 +2366,7 @@ netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 		/* in STA mode (ESS), all to same VRING (to AP) */
 		ring = wil_find_tx_ring_sta(wil, vif, skb);
 	} else if (bcast) {
-		if (vif->pbss)
+		if (vif->pbss || wil_check_multicast_to_unicast(wil, skb))
 			/* in pbss, no bcast VRING - duplicate skb in
 			 * all stations VRINGs
 			 */
drivers/net/wireless/ath/wil6210/wil6210.h +1 -0
index bf00f0693a3d..21399ced2a5d 100644
@@ -1059,6 +1059,7 @@ struct wil6210_priv {
 
 	u32 max_agg_wsize;
 	u32 max_ampdu_size;
+	u8 multicast_to_unicast;
 };
 
 #define wil_to_wiphy(i) (i->wiphy)
Signature · 1 line
2.23.0
author
#12 lore raw

PATCH 8/8 wil6210: add support for set_cqm_rssi_config

In reply to Maya Erez

From: Dedy Lansky <[email protected]>

set_cqm_rssi_config() is used by the kernel to configure connection quality monitor RSSI threshold.
wil6210 uses WMI_SET_LINK_MONITOR_CMDID to set the RSSI threshold to FW which in turn reports RSSI threshold changes with WMI_LINK_MONITOR_EVENTID.

---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 18 +++++
 drivers/net/wireless/ath/wil6210/wil6210.h  |  3 +
 drivers/net/wireless/ath/wil6210/wmi.c      | 76 +++++++++++++++++++++
 drivers/net/wireless/ath/wil6210/wmi.h      | 33 +++++++++
 4 files changed, 130 insertions(+)
drivers/net/wireless/ath/wil6210/cfg80211.c +18 -0
index 5a3aff131472..0851d2bede89 100644
@@ -2594,6 +2594,23 @@ static int wil_cfg80211_set_multicast_to_unicast(struct wiphy *wiphy,
 	return 0;
 }
 
+static int wil_cfg80211_set_cqm_rssi_config(struct wiphy *wiphy,
+					    struct net_device *dev,
+					    s32 rssi_thold, u32 rssi_hyst)
+{
+	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+	int rc;
+
+	wil->cqm_rssi_thold = rssi_thold;
+
+	rc = wmi_set_cqm_rssi_config(wil, rssi_thold, rssi_hyst);
+	if (rc)
+		/* reset stored value upon failure */
+		wil->cqm_rssi_thold = 0;
+
+	return rc;
+}
+
 static const struct cfg80211_ops wil_cfg80211_ops = {
 	.add_virtual_intf = wil_cfg80211_add_iface,
 	.del_virtual_intf = wil_cfg80211_del_iface,
@@ -2625,6 +2642,7 @@ static const struct cfg80211_ops wil_cfg80211_ops = {
 	.start_p2p_device = wil_cfg80211_start_p2p_device,
 	.stop_p2p_device = wil_cfg80211_stop_p2p_device,
 	.set_power_mgmt = wil_cfg80211_set_power_mgmt,
+	.set_cqm_rssi_config = wil_cfg80211_set_cqm_rssi_config,
 	.suspend = wil_cfg80211_suspend,
 	.resume = wil_cfg80211_resume,
 	.sched_scan_start = wil_cfg80211_sched_scan_start,
drivers/net/wireless/ath/wil6210/wil6210.h +3 -0
index 21399ced2a5d..5dc881d3c057 100644
@@ -1060,6 +1060,7 @@ struct wil6210_priv {
 	u32 max_agg_wsize;
 	u32 max_ampdu_size;
 	u8 multicast_to_unicast;
+	s32 cqm_rssi_thold;
 };
 
 #define wil_to_wiphy(i) (i->wiphy)
@@ -1441,4 +1442,6 @@ int wmi_addba_rx_resp_edma(struct wil6210_priv *wil, u8 mid, u8 cid,
 void update_supported_bands(struct wil6210_priv *wil);
 
 void wil_clear_fw_log_addr(struct wil6210_priv *wil);
+int wmi_set_cqm_rssi_config(struct wil6210_priv *wil,
+			    s32 rssi_thold, u32 rssi_hyst);
 #endif /* __WIL6210_H__ */
drivers/net/wireless/ath/wil6210/wmi.c +76 -0

103 lines not on this page · raw message

drivers/net/wireless/ath/wil6210/wmi.h +33 -0
index 6bd4ccee28ab..e3558136e0c4 100644
@@ -192,6 +192,7 @@ enum wmi_command_id {
 	WMI_RCP_ADDBA_RESP_EDMA_CMDID			= 0x83B,
 	WMI_LINK_MAINTAIN_CFG_WRITE_CMDID		= 0x842,
 	WMI_LINK_MAINTAIN_CFG_READ_CMDID		= 0x843,
+	WMI_SET_LINK_MONITOR_CMDID			= 0x845,
 	WMI_SET_SECTORS_CMDID				= 0x849,
 	WMI_MAINTAIN_PAUSE_CMDID			= 0x850,
 	WMI_MAINTAIN_RESUME_CMDID			= 0x851,
@@ -1973,6 +1974,7 @@ enum wmi_event_id {
 	WMI_REPORT_STATISTICS_EVENTID			= 0x100B,
 	WMI_FT_AUTH_STATUS_EVENTID			= 0x100C,
 	WMI_FT_REASSOC_STATUS_EVENTID			= 0x100D,
+	WMI_LINK_MONITOR_EVENTID			= 0x100E,
 	WMI_RADAR_GENERAL_CONFIG_EVENTID		= 0x1100,
 	WMI_RADAR_CONFIG_SELECT_EVENTID			= 0x1101,
 	WMI_RADAR_PARAMS_CONFIG_EVENTID			= 0x1102,
@@ -2024,6 +2026,7 @@ enum wmi_event_id {
 	WMI_TX_MGMT_PACKET_EVENTID			= 0x1841,
 	WMI_LINK_MAINTAIN_CFG_WRITE_DONE_EVENTID	= 0x1842,
 	WMI_LINK_MAINTAIN_CFG_READ_DONE_EVENTID		= 0x1843,
+	WMI_SET_LINK_MONITOR_EVENTID			= 0x1845,
 	WMI_RF_XPM_READ_RESULT_EVENTID			= 0x1856,
 	WMI_RF_XPM_WRITE_RESULT_EVENTID			= 0x1857,
 	WMI_LED_CFG_DONE_EVENTID			= 0x1858,
@@ -3312,6 +3315,36 @@ struct wmi_link_maintain_cfg_read_cmd {
 	__le32 cid;
 } __packed;
 
+/* WMI_SET_LINK_MONITOR_CMDID */
+struct wmi_set_link_monitor_cmd {
+	u8 rssi_hyst;
+	u8 reserved[12];
+	u8 rssi_thresholds_list_size;
+	s8 rssi_thresholds_list[0];
+} __packed;
+
+/* wmi_link_monitor_event_type */
+enum wmi_link_monitor_event_type {
+	WMI_LINK_MONITOR_NOTIF_RSSI_THRESHOLD_EVT	= 0x00,
+	WMI_LINK_MONITOR_NOTIF_TX_ERR_EVT		= 0x01,
+	WMI_LINK_MONITOR_NOTIF_THERMAL_EVT		= 0x02,
+};
+
+/* WMI_SET_LINK_MONITOR_EVENTID */
+struct wmi_set_link_monitor_event {
+	/* wmi_fw_status */
+	u8 status;
+	u8 reserved[3];
+} __packed;
+
+/* WMI_LINK_MONITOR_EVENTID */
+struct wmi_link_monitor_event {
+	/* link_monitor_event_type */
+	u8 type;
+	s8 rssi_level;
+	u8 reserved[2];
+} __packed;
+
 /* WMI_LINK_MAINTAIN_CFG_WRITE_DONE_EVENTID */
 struct wmi_link_maintain_cfg_write_done_event {
 	/* requested connection ID */
Signature · 1 line
2.23.0