* [PATCH net-next v2 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
@ 2026-11-29 7:40 Birger Koblitz
2026-11-29 7:40 ` [PATCH net-next v2 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
2026-11-29 7:40 ` [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
0 siblings, 2 replies; 5+ messages in thread
From: Birger Koblitz @ 2026-11-29 7:40 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-usb, Benjamin Larsson, Birger Koblitz
The AX88179A-Chip family supports reception of the FCS
at the host. This is configured by enabling the AX_RX_CTL_DROPCRCERR
flag in the USB-adapters RX-controls. For AX88279-based adapters,
the flag has already been always set in order to receive
complete frames, however, the FCS is not necessarily usable, as it
is only part of the transferred up-to 8-byte padding area, and for
some frame-lengths only 2 of the 4 bytes of the FCS are transferred
to the host.
Note, that the AX_RX_CTL_DROPCRCERR flag has no influence on dropping
of corrupt frames already by the USB adapter, even corrupt frames
are always transferred to the host.
Add Add NETIF_F_RXFCS and NETIF_F_RXALL features for
the AX88179A and take a trailing FCS into account for MTU
verification when checking packet length in rx_fixup().
Also add code rx_fixup() in order to Count dropped packets and those
with incorrect checksum.
Suggested-by: Benjamin Larsson <benjamin.larsson@genexis.eu>
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
Changes in v2:
- Do not clobber rxctl in ax88179_set_multicast(): read and update it
- Use netdev_features_t for features in rx_fixup()
- Do not include FCS trailer when NETIF_F_RXFCS not set
- Count rx_errors together with crc_errors as per definition
- Link to v1: https://lore.kernel.org/r/20261127-fcs-v1-0-0c4ede015bf5@birger-koblitz.de
---
Birger Koblitz (2):
net: usb: ax88179: Make receiving FCS on AX88179A configurable
net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
drivers/net/usb/ax88179_lib.c | 11 ++++++---
drivers/net/usb/ax88179a_devices.c | 50 +++++++++++++++++++++++++++++++++-----
2 files changed, 52 insertions(+), 9 deletions(-)
---
base-commit: eb6d6c80d35449c27471b1874f13066c09a8964d
change-id: 20261126-fcs-afccb4a76dd1
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next v2 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable
2026-11-29 7:40 [PATCH net-next v2 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
@ 2026-11-29 7:40 ` Birger Koblitz
2026-11-30 8:35 ` netdev-bot+sashiko
2026-11-29 7:40 ` [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
1 sibling, 1 reply; 5+ messages in thread
From: Birger Koblitz @ 2026-11-29 7:40 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-usb, Benjamin Larsson, Birger Koblitz
Make reception of FCS on AX88179A configuration-dependent.
In contrast to what the name suggests, AX_RX_CTL_DROPCRCERR
actually instructs the MAC to leave the FCS attached to the end of the
Ethernet frame when sent by the USB-adapter to the host. This was
tested for AX88179A as well as on the AX88772D, which behaves the same
as the AX88179A in respect of this flag, as this refers to MAC
functionality and the AX88772D is merely a AX88179A with a different
integrated 100Mbit PHY.
For the older AX88179, the behaviour does not change.
For AX88279-based adapters, the flag must be set in order to receive
complete frames, however, the FCS is not necessarily usable, as it
is only part of the transferred up-to 8-byte padding area, and for
some frame-lengths only 2 of the 4 bytes of the FCS are transferred
to the host.
The AX_RX_CTL_DROPCRCERR flag has no influence on dropping of corrupt
frames already by the USB adapter.
Fixes: 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips")
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179_lib.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
index 821ee9cd8ded1b8f1e425bcef493fb175ed30376..6a0023e6153dc9286b49c3c6b5fe41532faa7a53 100644
--- a/drivers/net/usb/ax88179_lib.c
+++ b/drivers/net/usb/ax88179_lib.c
@@ -352,14 +352,19 @@ void ax88179_set_multicast(struct net_device *net)
struct usbnet *dev = netdev_priv(net);
u8 *m_filter = ((u8 *)dev->data);
struct ax88179_data *data;
- u16 rxctl = 0;
+ u16 rxctl;
data = dev->driver_priv;
- rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
+ rxctl = READ_ONCE(data->rxctl);
+ rxctl &= ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO |
+ AX_RX_CTL_AMALL | AX_RX_CTL_AM);
+
if (data->ip_align)
rxctl |= AX_RX_CTL_IPE;
-
+ if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
+ data->chip_version != AX_VERSION_AX88179A)
+ rxctl |= AX_RX_CTL_DROPCRCERR;
if (net->flags & IFF_PROMISC) {
rxctl |= AX_RX_CTL_PRO;
} else if (net->flags & IFF_ALLMULTI ||
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
2026-11-29 7:40 [PATCH net-next v2 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-11-29 7:40 ` [PATCH net-next v2 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
@ 2026-11-29 7:40 ` Birger Koblitz
2026-11-30 8:35 ` netdev-bot+sashiko
1 sibling, 1 reply; 5+ messages in thread
From: Birger Koblitz @ 2026-11-29 7:40 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-usb, Benjamin Larsson, Birger Koblitz
Add NETIF_F_RXFCS and NETIF_F_RXALL features for
the AX88179A and take a trailing FCS into account for MTU
verification when checking packet length in rx_fixup().
Count dropped packets and those with incorrect FCS.
Suggested-by: Benjamin Larsson <benjamin.larsson@genexis.eu>
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179a_devices.c | 50 +++++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
index 69095110e70435806a99274c50d79e86016ec9a0..21cf90d69f502ec2c5473b7fc1565290851bfeaf 100644
--- a/drivers/net/usb/ax88179a_devices.c
+++ b/drivers/net/usb/ax88179a_devices.c
@@ -717,10 +717,12 @@ static int ax88179a_mii_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
static int ax88179a_set_features(struct net_device *net, netdev_features_t features)
{
struct usbnet *dev = netdev_priv(net);
+ struct ax88179_data *ax179_data;
netdev_features_t changed;
int ret;
u8 tmp;
+ ax179_data = dev->driver_priv;
changed = net->features ^ features;
ret = ax88179_set_features(net, features);
@@ -780,6 +782,18 @@ static int ax88179a_set_features(struct net_device *net, netdev_features_t featu
if (ret < 0)
return ret;
}
+
+ if (changed & (NETIF_F_RXFCS | NETIF_F_RXALL)) {
+ u16 rxctl = READ_ONCE(ax179_data->rxctl);
+
+ if (features & (NETIF_F_RXFCS | NETIF_F_RXALL))
+ rxctl |= AX_RX_CTL_DROPCRCERR;
+ else
+ rxctl &= ~AX_RX_CTL_DROPCRCERR;
+ WRITE_ONCE(ax179_data->rxctl, rxctl);
+ ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
+ }
+
return 0;
}
@@ -852,8 +866,8 @@ static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf)
ax179_data->fw_version[2], ax179_data->fw_version[3]);
/* The AX88279 requires both the AX_RX_CTL_IPE and AX_RX_CTL_DROPCRCERR
- * bits set in AX_RX_CTL for creating correct RX-URBs. AX_RX_CTL_DROPCRCERR
- * is anyway set for all chips, make sure AX_RX_CTL_IPE is set via ip_align.
+ * bits set in AX_RX_CTL for creating correct RX-URBs. Make sure
+ * AX_RX_CTL_IPE is set via ip_align.
* Also configure eeprom access parameters.
*/
if (ax179_data->chip_version == AX_VERSION_AX88279) {
@@ -894,6 +908,11 @@ static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf)
dev->net->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM |
NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO;
+ if (ax179_data->chip_version == AX_VERSION_AX88179A) {
+ dev->net->hw_features |= NETIF_F_RXFCS | NETIF_F_RXALL;
+ dev->net->vlan_features |= NETIF_F_RXFCS | NETIF_F_RXALL;
+ }
+
netif_set_tso_max_size(dev->net, 16384);
/* Enable Transmission of Link Speed byte in interrupt URB */
@@ -1039,9 +1058,14 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
pkt_end = 0;
while (pkt_cnt--) {
u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr);
+ netdev_features_t features = dev->net->features;
u32 pkt_len_plus_padd;
+ u32 fcs_trailer = 0;
u32 pkt_len;
+ if (features & (NETIF_F_RXFCS | NETIF_F_RXALL))
+ fcs_trailer = ETH_FCS_LEN;
+
pkt_len = FIELD_GET(AX179A_RX_PD_LEN, pkt_desc);
pkt_len -= (ax179_data->ip_align ? 2 : 0);
pkt_len_plus_padd = ((pkt_len + 7 + (ax179_data->ip_align ? 2 : 0)) & 0x7FFF8);
@@ -1050,10 +1074,19 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
if (pkt_end > hdr_off || (pkt_cnt == 0 && pkt_end != hdr_off))
goto err;
- if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) ||
- pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD) || pkt_len < 2 + ETH_HLEN) {
+ if (((pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK)) &&
+ !(features & NETIF_F_RXALL)) ||
+ pkt_len > dev->hard_mtu + AX179A_RX_HW_PAD + fcs_trailer ||
+ pkt_len < 2 + ETH_HLEN) {
skb_pull(skb, pkt_len_plus_padd);
+ if (pkt_desc & AX179A_RX_PD_DROP)
+ dev->net->stats.rx_dropped++;
+
+ if (!(pkt_desc & AX179A_RX_PD_RX_OK)) {
+ dev->net->stats.rx_crc_errors++;
+ dev->net->stats.rx_errors++;
+ }
/* Next RX Packet Descriptor */
pkt_desc_ptr++;
continue;
@@ -1063,6 +1096,9 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
if (!ax_skb)
goto err;
+ if (!(features & NETIF_F_RXFCS))
+ pkt_len -= fcs_trailer;
+
skb_put(ax_skb, pkt_len);
memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_PAD : 0),
pkt_len);
@@ -1216,12 +1252,14 @@ static int ax88179a_reset(struct usbnet *dev)
ax88179_write_u8(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, *tmp);
/* Configure RX control register => start operation */
- rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
- AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+ rxctl = AX_RX_CTL_START | AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
if (ax179_data->ip_align)
rxctl |= AX_RX_CTL_IPE;
if (dev->net->flags & IFF_PROMISC)
rxctl |= AX_RX_CTL_PRO;
+ if (dev->net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
+ ax179_data->chip_version == AX_VERSION_AX88279)
+ rxctl |= AX_RX_CTL_DROPCRCERR;
WRITE_ONCE(ax179_data->rxctl, rxctl);
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable
2026-11-29 7:40 ` [PATCH net-next v2 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
@ 2026-11-30 8:35 ` netdev-bot+sashiko
0 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-11-30 8:35 UTC (permalink / raw)
To: mail
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-usb,
benjamin.larsson
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 4 (1)
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] Legacy AX88179/AX88178A adapters
(drivers/net/usb/ax88179_178a.c) stop receiving after ifup.
- [Low] In this patch alone, the new `net->features & (NETIF_F_RXFCS |
NETIF_F_RXALL)` test in `ax88179_set_multicast()` can never be true.
- [Low] In this patch, `ax88179a_reset()` still sets AX_RX_CTL_DROPCRCERR
unconditionally in `data->rxctl` and in the hardware.
- [Low] The comment in `ax88179a_bind()` says 'AX_RX_CTL_DROPCRCERR is
anyway set for all chips'.
- [Low] Moving `ax88179_set_multicast()` from rebuilding rxctl to a read-
modify-write of `data->rxctl` also silently keeps AX_RX_CTL_AP…
Pre-existing issues:
- [Low] Three writers of AX_RX_CTL do not share a lock.
--
net: usb: ax88179: Make receiving FCS on AX88179A configurable
This commit changes ax88179_set_multicast() to start from the cached
data->rxctl value. Before, it built the value from a fixed
START | AB | DROPCRCERR seed. With this patch, AX_RX_CTL_DROPCRCERR is
set on AX88179A only when NETIF_F_RXFCS or NETIF_F_RXALL is enabled, and
is always set on the other chips.
> diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
> index 821ee9cd8ded1..6a0023e6153dc 100644
> --- a/drivers/net/usb/ax88179_lib.c
> +++ b/drivers/net/usb/ax88179_lib.c
> @@ -352,14 +352,19 @@ void ax88179_set_multicast(struct net_device *net)
> struct usbnet *dev = netdev_priv(net);
> u8 *m_filter = ((u8 *)dev->data);
> struct ax88179_data *data;
> - u16 rxctl = 0;
> + u16 rxctl;
>
> data = dev->driver_priv;
>
> - rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
> + rxctl = READ_ONCE(data->rxctl);
> + rxctl &= ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO |
> + AX_RX_CTL_AMALL | AX_RX_CTL_AM);
[Severity: High]
Does this stop RX on the legacy AX88179/AX88178A devices handled by
ax88179_178a.c?
The new code assumes data->rxctl already holds AX_RX_CTL_START and
AX_RX_CTL_AB. The legacy driver never stores anything in that field.
ax88179_bind() allocates ax179_data with kzalloc_obj(), so rxctl starts
at 0. ax88179_reset() programs the register only from a stack buffer:
drivers/net/usb/ax88179_178a.c:ax88179_reset() {
...
*tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START |
AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);
...
}
On ifup the sequence is:
__dev_open()
usbnet_open()
ax88179_reset() /* START written to hardware only */
dev_set_rx_mode()
ax88179_set_multicast() /* starts from data->rxctl == 0 */
The value written to AX_RX_CTL and cached in data->rxctl then has
neither AX_RX_CTL_START nor AX_RX_CTL_AB set.
ax88179_link_reset() writes that cached value again on every link-up:
drivers/net/usb/ax88179_178a.c:ax88179_link_reset() {
...
mode = 0;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &mode);
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2,
&ax179_data->rxctl);
...
}
Wouldn't the receiver then stay disabled?
If so, this statement in the commit message would not hold:
"For the older AX88179, the behaviour does not change."
The follow-up patch "net: usb: ax88179: Support NETIF_F_RXFCS and
NETIF_F_RXALL on AX88179A" does not touch ax88179_178a.c, so this
appears to remain at the end of the series.
[Severity: Low]
Is it intended that AX_RX_CTL_AP now survives every rx_mode update on
AX88179A/AX88772D/AX88279?
ax88179a_reset() puts AP into data->rxctl:
drivers/net/usb/ax88179a_devices.c:ax88179a_reset() {
...
rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
AX_RX_CTL_AMALL | AX_RX_CTL_AB;
...
WRITE_ONCE(ax179_data->rxctl, rxctl);
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
}
Before this patch, the first ndo_set_rx_mode call rebuilt the value,
which cleared AP. The new clear mask leaves AP set, and
ax88179a_mac_link_up() writes it again on each link-up.
This changes the RX filter programming beyond the FCS change, and the
commit message does not mention it. At the end of the series,
ax88179a_reset() still sets AP and the mask is the same.
> +
> if (data->ip_align)
> rxctl |= AX_RX_CTL_IPE;
> -
> + if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
> + data->chip_version != AX_VERSION_AX88179A)
> + rxctl |= AX_RX_CTL_DROPCRCERR;
[Severity: Low]
Can the NETIF_F_RXFCS | NETIF_F_RXALL test ever be true with only this
patch applied?
ax88179a_bind() does not add either feature to hw_features. Neither
ax88179a_set_features() nor ax88179_set_features() reprograms AX_RX_CTL
when these features change. ax88179a_rx_fixup() also still drops
errored frames, so RXALL would not deliver them.
The follow-up patch "net: usb: ax88179: Support NETIF_F_RXFCS and
NETIF_F_RXALL on AX88179A" adds the hw_features bits, the set_features
handling and the rx_fixup changes. This only affects this patch when
applied on its own.
[Severity: Low]
ax88179a_reset() still sets AX_RX_CTL_DROPCRCERR unconditionally, in
both data->rxctl and the hardware (see the ax88179a_reset() snippet
above).
Nothing calls ndo_set_rx_mode after ax88179a_resume()->ax88179a_reset().
Wouldn't AX88179A/AX88772D go back to appending the FCS after a resume?
ax88179a_mac_link_up() would then write that value again on each
link-up.
The follow-up patch "net: usb: ax88179: Support NETIF_F_RXFCS and
NETIF_F_RXALL on AX88179A" makes DROPCRCERR conditional in
ax88179a_reset(). That makes the reset/resume path match
ax88179_set_multicast().
[Severity: Low]
This isn't a bug, but this change makes the comment in ax88179a_bind()
stale:
/* The AX88279 requires both the AX_RX_CTL_IPE and AX_RX_CTL_DROPCRCERR
* bits set in AX_RX_CTL for creating correct RX-URBs. AX_RX_CTL_DROPCRCERR
* is anyway set for all chips, make sure AX_RX_CTL_IPE is set via ip_align.
DROPCRCERR is no longer set on AX88179A unless RXFCS or RXALL is
enabled. The follow-up patch in the series rewrites this comment.
> if (net->flags & IFF_PROMISC) {
> rxctl |= AX_RX_CTL_PRO;
> } else if (net->flags & IFF_ALLMULTI ||
[Severity: Low]
This is a pre-existing issue and was not introduced by this patch.
ax88179_set_multicast() ends with:
WRITE_ONCE(data->rxctl, rxctl);
ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,
2, 2, &data->rxctl);
It runs under netif_addr_lock only. There are two other writers of
AX_RX_CTL:
ax88179a_mac_link_up() writes a READ_ONCE() snapshot synchronously,
under medium_status_mutex.
ax88179a_reset() on the resume path does its own WRITE_ONCE() and a
synchronous write.
These three writers don't share a lock. Can AX_RX_CTL end up holding an
older value than the cached data->rxctl?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129-fcs-v2-0-f60d6b105a15%40birger-koblitz.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
2026-11-29 7:40 ` [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
@ 2026-11-30 8:35 ` netdev-bot+sashiko
0 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-11-30 8:35 UTC (permalink / raw)
To: mail
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-usb,
benjamin.larsson
Thank you for your contribution! Sashiko AI review found 9 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 6 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch contains the second half of the FCS-leak fix but has
no Fixes: tag, and its commit message does not mention the change to…
- [Medium] ax88179a_rx_fixup() checks the minimum length (`pkt_len < 2 +
ETH_HLEN`, line 1079) before it strips the FCS (`pkt_len -=…
- [Medium] The new error counting in ax88179a_rx_fixup() (lines
1081-1088) gives misleading uAPI statistics.
- [Medium] ax88179a_rx_fixup() decides whether a frame carries a 4-byte
FCS trailer from dev->net->features (read per packet at line 1061),…
- [Medium] The new RXFCS/RXALL branch in ax88179a_set_features() (lines
786-795) ignores the return value of ax88179_write_u16(dev,…
- [Medium] Across this series ax179_data->rxctl has become a shared read-
modify-write variable, and no common lock covers its writers.
- [Low] When RXFCS or RXALL changes, the new block in
ax88179a_set_features() (lines 786-795) writes the cached…
- [Low] The two writers of ax179_data->rxctl in the AX88179A driver now
use different chip-version tests to decide on AX_RX_CTL_DROPCRCERR.
- [Low] The new counters in ax88179a_rx_fixup()
(dev->net->stats.rx_dropped++, rx_crc_errors++, rx_errors++ at lines…
--
net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
This patch adds NETIF_F_RXFCS and NETIF_F_RXALL support for the AX88179A.
It accounts for a trailing FCS in the rx_fixup() length checks and counts
dropped and bad-FCS frames. It also makes AX_RX_CTL_DROPCRCERR in
ax88179a_reset() conditional on the new features, or on the AX88279.
> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> index 69095110e7043..21cf90d69f502 100644
> --- a/drivers/net/usb/ax88179a_devices.c
> +++ b/drivers/net/usb/ax88179a_devices.c
[ ... ]
> @@ -780,6 +782,18 @@ static int ax88179a_set_features(struct net_device *net, netdev_features_t featu
> if (ret < 0)
> return ret;
> }
> +
> + if (changed & (NETIF_F_RXFCS | NETIF_F_RXALL)) {
> + u16 rxctl = READ_ONCE(ax179_data->rxctl);
> +
> + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL))
> + rxctl |= AX_RX_CTL_DROPCRCERR;
> + else
> + rxctl &= ~AX_RX_CTL_DROPCRCERR;
> + WRITE_ONCE(ax179_data->rxctl, rxctl);
[Severity: Medium]
Can this read-modify-write of ax179_data->rxctl race with the other rxctl
writers? This path runs under RTNL only.
After the earlier patch in this series, ax88179_set_multicast() also does
a read-modify-write of the same field. It holds only netif_addr_lock_bh(),
and RTNL is not guaranteed on the __dev_set_rx_mode() path:
drivers/net/usb/ax88179_lib.c:ax88179_set_multicast() {
...
rxctl = READ_ONCE(data->rxctl);
rxctl &= ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO |
AX_RX_CTL_AMALL | AX_RX_CTL_AM);
...
}
ax88179a_mac_link_up() writes the cached value under medium_status_mutex.
Neither of the other writers takes that mutex:
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl));
Suppose set_multicast sets AX_RX_CTL_AM between the READ_ONCE() and the
WRITE_ONCE() here. The stale copy then goes to both the cache and the
hardware, and the multicast hash filter stays off until the next rx-mode
event. IPv6 solicited-node multicast, for example, would not be received.
The reverse interleaving loses the DROPCRCERR change instead.
Does rxctl need one lock shared by all of its writers?
> + ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
> + }
> +
> return 0;
> }
[Severity: Medium]
Should the return value of ax88179_write_u16() be checked here? The VLAN
branches above return ret on failure, but this branch always reaches
return 0.
WRITE_ONCE() has already updated the cache. If the control transfer fails,
ax179_data->rxctl and the soon-to-be-committed dev->features have the new
DROPCRCERR setting, while the hardware keeps the old one.
ax88179a_rx_fixup() would then parse every frame with the wrong FCS
assumption until mac_link_up() or reset() rewrites AX_RX_CTL from the
cache. One example is enabling rx-all with rx-fcs off: 4 bytes of payload
would be stripped from every frame.
[Severity: Low]
Can this write restart RX on an interface that is down? After
ax88179a_stop() has done this:
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 0);
ax179_data->rxctl still holds AX_RX_CTL_START, AP, AMALL and AB.
ndo_set_features is not gated on IFF_UP, so ethtool -K rx-fcs or rx-all
on a down interface writes START back to the MAC.
This write is also not serialized against ax88179a_mac_link_up(). That
function runs from phylink's resolve work and does a stop, reconfigure,
restart sequence:
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, AX_RX_CTL_STOP);
ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, 0);
...
Could a set_features call landing in that window restart RX before the
bulk-in and MAC path setup is finished?
[ ... ]
> @@ -1039,9 +1058,14 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> pkt_end = 0;
> while (pkt_cnt--) {
> u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr);
> + netdev_features_t features = dev->net->features;
[Severity: Medium]
Is dev->net->features a reliable way to tell whether the hardware
appended an FCS to this frame? In __netdev_update_features(),
ndo_set_features() runs before dev->features is assigned:
net/core/dev.c:__netdev_update_features() {
...
err = dev->netdev_ops->ndo_set_features(dev, features);
...
}
So ax88179a_set_features() changes DROPCRCERR in hardware while
dev->features still holds the old flags. Some frames were formatted under
the old setting: those already aggregated into outstanding bulk-in URBs,
or queued on dev->done. They are then parsed with whatever features value
is current at the time.
Take turning rx-all off while rx-fcs is off. The MAC stops appending the
FCS right away, but this loop can still see NETIF_F_RXALL and strip 4
bytes of real payload. Turning it on can leave an FCS attached to frames
treated as having none.
There is a second path. ax88179_set_multicast() rebuilds DROPCRCERR from
net->features and writes both the cache and the hardware. If it runs in
the set_features window before the features are committed, it stores the
old DROPCRCERR value. mac_link_up() later writes that value back from the
cache. Could hardware and dev->features then disagree until the next
rx-mode event or reset?
Would resetting the RX path on these toggles help, as e1000e and igb do?
> u32 pkt_len_plus_padd;
> + u32 fcs_trailer = 0;
> u32 pkt_len;
>
> + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL))
> + fcs_trailer = ETH_FCS_LEN;
> +
[ ... ]
> @@ -1050,10 +1074,19 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> if (pkt_end > hdr_off || (pkt_cnt == 0 && pkt_end != hdr_off))
> goto err;
>
> - if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) ||
> - pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD) || pkt_len < 2 + ETH_HLEN) {
> + if (((pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK)) &&
> + !(features & NETIF_F_RXALL)) ||
> + pkt_len > dev->hard_mtu + AX179A_RX_HW_PAD + fcs_trailer ||
> + pkt_len < 2 + ETH_HLEN) {
> skb_pull(skb, pkt_len_plus_padd);
>
> + if (pkt_desc & AX179A_RX_PD_DROP)
> + dev->net->stats.rx_dropped++;
> +
> + if (!(pkt_desc & AX179A_RX_PD_RX_OK)) {
> + dev->net->stats.rx_crc_errors++;
> + dev->net->stats.rx_errors++;
> + }
[Severity: Medium]
Is it intended that these counters stop counting when rx-all is enabled?
With NETIF_F_RXALL set, frames without AX179A_RX_PD_RX_OK no longer take
this branch. They are delivered and counted as rx_packets by
usbnet_skb_return(), so rx_crc_errors and rx_errors stay flat.
Some frames have RX_OK set and DROP clear but are rejected only by the
length checks (pkt_len > hard_mtu + pad + fcs_trailer, or
pkt_len < 2 + ETH_HLEN). Those are not counted in rx_length_errors,
rx_errors or rx_dropped. Does that match the commit message?
Count dropped packets and those with incorrect FCS.
Also, AX179A_RX_PD_RX_OK is defined as a general RX status bit:
#define AX179A_RX_PD_RX_OK BIT(11)
Is it known that a missing RX_OK always means a CRC error, and not a
runt, oversize or PHY error? These counters reach user space through
dev_get_tstats64() -> netdev_stats_to_stats64().
[Severity: Low]
These are plain increments on dev->net->stats. ax88179a_rx_fixup() runs
from usbnet_bh(), which is both the dev->delay timer callback and the body
of bh_work. usbnet's rx_complete() also increments
dev->net->stats.rx_errors from URB completion context.
Can concurrent updates lose increments here? For rx_dropped,
dev_core_stats_rx_dropped_inc() would avoid the race.
> /* Next RX Packet Descriptor */
> pkt_desc_ptr++;
> continue;
> @@ -1063,6 +1096,9 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> if (!ax_skb)
> goto err;
>
> + if (!(features & NETIF_F_RXFCS))
> + pkt_len -= fcs_trailer;
> +
> skb_put(ax_skb, pkt_len);
> memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_PAD : 0),
> pkt_len);
[Severity: Medium]
Can this subtraction produce an skb shorter than ETH_HLEN? The minimum
length check above runs before it:
pkt_len < 2 + ETH_HLEN) {
With rx-all on and rx-fcs off, fcs_trailer is 4. A descriptor reporting a
16 or 17 byte frame passes the check and is then cut to 12 or 13 bytes.
rx-all lets runt frames through, so such a descriptor can come from a
runt frame or from a crafted USB device. ax_skb was allocated with the
longer length, so its remaining bytes are uninitialized.
ax88179a_info uses FLAG_MULTI_PACKET, so rx_process() returns before its
own ETH_HLEN check:
drivers/net/usb/usbnet.c:rx_process() {
...
if (dev->driver_info->flags & FLAG_MULTI_PACKET)
return -EALREADY;
if (skb->len < ETH_HLEN) {
...
}
The short skb goes to usbnet_skb_return() -> eth_type_trans(). There
eth_skb_pull_mac() fails without reporting it, and eth->h_proto is read
from uninitialized bytes past skb->len.
Should the lower bound include fcs_trailer, for example
pkt_len < 2 + ETH_HLEN + fcs_trailer?
[ ... ]
> @@ -1216,12 +1252,14 @@ static int ax88179a_reset(struct usbnet *dev)
> ax88179_write_u8(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, *tmp);
>
> /* Configure RX control register => start operation */
> - rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
> - AX_RX_CTL_AMALL | AX_RX_CTL_AB;
> + rxctl = AX_RX_CTL_START | AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
> if (ax179_data->ip_align)
> rxctl |= AX_RX_CTL_IPE;
> if (dev->net->flags & IFF_PROMISC)
> rxctl |= AX_RX_CTL_PRO;
> + if (dev->net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
> + ax179_data->chip_version == AX_VERSION_AX88279)
> + rxctl |= AX_RX_CTL_DROPCRCERR;
[Severity: Medium]
This hunk stops setting AX_RX_CTL_DROPCRCERR unconditionally. That
changes the default AX_RX_CTL value for every AX88179A/AX88772D user, not
only those who enable the new features. The commit message does not
mention this.
The previous patch in the series, "net: usb: ax88179: Make receiving FCS
on AX88179A configurable" (Fixes: 7d573278f9a5), says DROPCRCERR makes
the MAC keep the 4-byte FCS on frames passed to the host. That patch only
changed ax88179_set_multicast().
With only that patch applied, ax88179a_reset() still sets DROPCRCERR.
ax88179a_resume() calls ax88179a_reset() without re-running
ndo_set_rx_mode, so the FCS comes back on every received frame after
resume. The same happens in the window between reset() on open and the
next set_multicast().
Max-size jumbo frames would also be dropped in that configuration. The
earlier patch does not account for the FCS in the rx_fixup() length
check.
This hunk completes that fix. Should it carry the same Fixes: tag, or be
folded into the earlier patch, so a stable backport of the Fixes-tagged
patch alone is not incomplete?
[Severity: Low]
This test uses chip_version == AX_VERSION_AX88279. ax88179_set_multicast()
in ax88179_lib.c decides the same bit for the same rxctl shadow with a
different test:
if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
data->chip_version != AX_VERSION_AX88179A)
rxctl |= AX_RX_CTL_DROPCRCERR;
The two only agree for AX_VERSION_AX88179A and AX_VERSION_AX88279, and
ax88179a_bind() does not reject other chip_version values. For any other
value, reset() leaves DROPCRCERR clear and the next set_rx_mode sets it.
Before this patch, reset() set the bit unconditionally, so both paths
agreed. Could both paths use the same condition?
> WRITE_ONCE(ax179_data->rxctl, rxctl);
> ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129-fcs-v2-0-f60d6b105a15%40birger-koblitz.de
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-30 8:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 7:40 [PATCH net-next v2 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-11-29 7:40 ` [PATCH net-next v2 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
2026-11-30 8:35 ` netdev-bot+sashiko
2026-11-29 7:40 ` [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-11-30 8:35 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox