From 188be4589ccfeafa843cbb07eeafd3ace5ada0cb Mon Sep 17 00:00:00 2001 From: nomdetom Date: Sun, 11 Oct 2026 03:07:34 +0100 Subject: [PATCH 1/2] fix(usb): the firmware patch table and overheard 4-address frames logged at debug level --- drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c | 2 +- drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c | 2 +- drivers/aic8800/aic8800_fdrv/rwnx_rx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c index c737b37..2d7f978 100644 --- a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c +++ b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c @@ -180,7 +180,7 @@ int aicwf_plat_patch_table_load_8800d80n(struct rwnx_hw *rwnx_hw) if ((dst[i] == 0x0) || (dst[i] == 0xFFFFFFFF)) { break; // end of tbl } - AICWFDBG(LOGERROR, "patch_tbl: %x %x\n", dst[i], dst[i+1]); + AICWFDBG(LOGDEBUG, "patch_tbl: %x %x\n", dst[i], dst[i+1]); err = rwnx_send_dbg_mem_write_req(rwnx_hw, dst[i], dst[i+1]); } if (err) { diff --git a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c index 8cfd915..bdc7a04 100644 --- a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c +++ b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c @@ -2749,7 +2749,7 @@ int aicwf_patch_table_load(struct rwnx_hw *rwnx_hw, char *filename) if (!err && (i < size)) { for (i =(128/4); i < (size/4); i +=2) { - AICWFDBG(LOGERROR, "patch_tbl: %x %x\n", dst[i], dst[i+1]); + AICWFDBG(LOGDEBUG, "patch_tbl: %x %x\n", dst[i], dst[i+1]); err = rwnx_send_dbg_mem_write_req(rwnx_hw, dst[i], dst[i+1]); } if (err) { diff --git a/drivers/aic8800/aic8800_fdrv/rwnx_rx.c b/drivers/aic8800/aic8800_fdrv/rwnx_rx.c index 6287682..1ecfee0 100644 --- a/drivers/aic8800/aic8800_fdrv/rwnx_rx.c +++ b/drivers/aic8800/aic8800_fdrv/rwnx_rx.c @@ -2427,8 +2427,8 @@ check_len_update: #ifndef CONFIG_SUPPORT_4ADDR if (hw_rxhdr->flags_is_4addr) { - dev_err(rwnx_hw->dev, "4addr Frame received (%d), skb->len:%u\n", hw_rxhdr->flags_vif_idx, skb->len); - print_hex_dump(KERN_ERR,"4addr ",DUMP_PREFIX_NONE, 16, 1, skb->data, skb->len, false); + dev_dbg(rwnx_hw->dev, "4addr Frame received (%d), skb->len:%u\n", hw_rxhdr->flags_vif_idx, skb->len); + print_hex_dump_debug("4addr ", DUMP_PREFIX_NONE, 16, 1, skb->data, skb->len, false); dev_kfree_skb(skb); goto end; } From 97f8077fd754d2f21c2f359c0698ec1999037d2f Mon Sep 17 00:00:00 2001 From: nomdetom Date: Fri, 23 Oct 2026 09:33:40 +0100 Subject: [PATCH 2/2] fix(usb): a short summary by default, the detail at debug level, both by aicwf_dbg_level From review (shenmintao/aic8800d80#115): the default log keeps enough to read a first bug report. - The patch table: each entry at LOGDEBUG, as before this series' first change; one line at LOGINFO (the default) with the file and the number of entries written; a failure at LOGERROR, as before. - 4-address frames dropped by a build without CONFIG_SUPPORT_4ADDR: counted per device and said at LOGINFO, the first at once and then at most once a minute; each frame and its dump at LOGDEBUG, by aicwf_dbg_level, in place of dev_dbg() and print_hex_dump_debug(), which need dynamic debug or DEBUG and were compiled out otherwise. - The README says how to turn the detail on and off, at run time and before the driver loads (the patch table is written when the adapter starts). --- README.md | 29 +++++++++++++++++++ .../aic8800_fdrv/aicwf_compat_8800d80n.c | 5 ++++ .../aic8800_fdrv/aicwf_compat_8800dc.c | 5 ++++ drivers/aic8800/aic8800_fdrv/rwnx_defs.h | 4 +++ drivers/aic8800/aic8800_fdrv/rwnx_rx.c | 13 +++++++-- 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4124302..d5d3f72 100644 --- a/README.md +++ b/README.md @@ -229,3 +229,32 @@ The Wi-Fi-reset recovery behavior tracked in limitation: after an airplane-mode or hotspot reset, Bluetooth may require a physical unplug/replug of the adapter. + +### Debug Logging + +The Wi-Fi driver's log is set by its `aicwf_dbg_level` parameter, a mask. The default, `0x203`, logs errors +(`0x1`), information (`0x2`) and firmware messages (`0x200`). Add `0x8` for debug detail: `0x20b`. + +At the default level the log keeps a summary of what is routine: + +- the firmware patch table: one line with the number of entries written, and any failure; +- 4-address frames that a build without `CONFIG_SUPPORT_4ADDR` drops: the first at once, then a count at most + once a minute. + +With `0x8` it also logs each patch-table entry, and each dropped 4-address frame with a dump of it. + +To set it for the running driver (back to the default with `0x203`): + +```bash +echo 0x20b | sudo tee /sys/module/aic8800_fdrv/parameters/aicwf_dbg_level +``` + +The patch table is written when the adapter starts, so to log its entries, set the level before the driver loads, +then load it or plug the adapter in: + +```bash +echo 'options aic8800_fdrv aicwf_dbg_level=0x20b' | sudo tee /etc/modprobe.d/aic8800-debug.conf +sudo modprobe -r aic8800_fdrv && sudo modprobe aic8800_fdrv +``` + +Remove that file to go back to the default at the next load. diff --git a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c index 2d7f978..9995af3 100644 --- a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c +++ b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800d80n.c @@ -176,16 +176,21 @@ int aicwf_plat_patch_table_load_8800d80n(struct rwnx_hw *rwnx_hw) AICWFDBG(LOGINFO, "tbl size = %d \n", size); if (!err) { + int written = 0; + for (i = 0; i < (size / 4); i += 2) { if ((dst[i] == 0x0) || (dst[i] == 0xFFFFFFFF)) { break; // end of tbl } AICWFDBG(LOGDEBUG, "patch_tbl: %x %x\n", dst[i], dst[i+1]); err = rwnx_send_dbg_mem_write_req(rwnx_hw, dst[i], dst[i+1]); + if (!err) + written++; } if (err) { AICWFDBG(LOGERROR, "tbl bin upload fail: %x, err:%d\r\n", dst[i], err); } + AICWFDBG(LOGINFO, "patch_tbl: %s: %d entries written (each at debug level)\n", filename, written); } if (dst) { diff --git a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c index bdc7a04..b622382 100644 --- a/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c +++ b/drivers/aic8800/aic8800_fdrv/aicwf_compat_8800dc.c @@ -2748,13 +2748,18 @@ int aicwf_patch_table_load(struct rwnx_hw *rwnx_hw, char *filename) } if (!err && (i < size)) { + int written = 0; + for (i =(128/4); i < (size/4); i +=2) { AICWFDBG(LOGDEBUG, "patch_tbl: %x %x\n", dst[i], dst[i+1]); err = rwnx_send_dbg_mem_write_req(rwnx_hw, dst[i], dst[i+1]); + if (!err) + written++; } if (err) { AICWFDBG(LOGERROR, "bin upload fail: %x, err:%d\r\n", dst[i], err); } + AICWFDBG(LOGINFO, "patch_tbl: %s: %d entries written (each at debug level)\n", filename, written); } if (dst) { diff --git a/drivers/aic8800/aic8800_fdrv/rwnx_defs.h b/drivers/aic8800/aic8800_fdrv/rwnx_defs.h index 3363bcc..1a38654 100644 --- a/drivers/aic8800/aic8800_fdrv/rwnx_defs.h +++ b/drivers/aic8800/aic8800_fdrv/rwnx_defs.h @@ -935,6 +935,10 @@ struct rwnx_hw { ktime_t last_time; char last_alpha2[3]; + /* 4-address frames dropped (a build without CONFIG_SUPPORT_4ADDR): counted, and said at most once a minute. */ + unsigned int fouraddr_dropped; + unsigned long fouraddr_said; + }; u8 *rwnx_build_bcn(struct rwnx_bcn *bcn, struct cfg80211_beacon_data *new); diff --git a/drivers/aic8800/aic8800_fdrv/rwnx_rx.c b/drivers/aic8800/aic8800_fdrv/rwnx_rx.c index 1ecfee0..2e6bd64 100644 --- a/drivers/aic8800/aic8800_fdrv/rwnx_rx.c +++ b/drivers/aic8800/aic8800_fdrv/rwnx_rx.c @@ -2427,8 +2427,17 @@ check_len_update: #ifndef CONFIG_SUPPORT_4ADDR if (hw_rxhdr->flags_is_4addr) { - dev_dbg(rwnx_hw->dev, "4addr Frame received (%d), skb->len:%u\n", hw_rxhdr->flags_vif_idx, skb->len); - print_hex_dump_debug("4addr ", DUMP_PREFIX_NONE, 16, 1, skb->data, skb->len, false); + rwnx_hw->fouraddr_dropped++; + if (!rwnx_hw->fouraddr_said || time_after(jiffies, rwnx_hw->fouraddr_said + 60 * HZ)) { + AICWFDBG(LOGINFO, "4addr frames dropped (this build has no CONFIG_SUPPORT_4ADDR): %u since the last count; " + "aicwf_dbg_level with 0x8 (debug) logs each one\n", rwnx_hw->fouraddr_dropped); + rwnx_hw->fouraddr_dropped = 0; + rwnx_hw->fouraddr_said = jiffies ? jiffies : 1; + } + if (aicwf_dbg_level & LOGDEBUG) { + AICWFDBG(LOGDEBUG, "4addr Frame received (%d), skb->len:%u\n", hw_rxhdr->flags_vif_idx, skb->len); + print_hex_dump(KERN_DEBUG, "4addr ", DUMP_PREFIX_NONE, 16, 1, skb->data, skb->len, false); + } dev_kfree_skb(skb); goto end; }