Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Birger Koblitz
Tue, 01 Dec 2026 17:17
[PATCH net-next v3 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
Author: Birger Koblitz
Date: Tue, 01 Dec 2026 17:17
Date: Tue, 01 Dec 2026 17:17
54 lines
11967 bytes
11967 bytes
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 v3:
- In ax88179_set_multicast() make sure the behaviour for the older
AX88179 devices is not changed
- Improve error checking in set_features()
- Improve lower packet length check to take FCS into account
- Link to v2: https://lore.kernel.org/r/20261129-fcs-v2-0-f60d6b105a15@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 | 14 +++++++---
drivers/net/usb/ax88179a_devices.c | 52 +++++++++++++++++++++++++++++++++-----
2 files changed, 57 insertions(+), 9 deletions(-)
---
base-commit: eb6d6c80d35449c27471b1874f13066c09a8964d
change-id: 20261126-fcs-afccb4a76dd1
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
[PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable
Author: Birger Koblitz
Date: Tue, 01 Dec 2026 17:17
Date: Tue, 01 Dec 2026 17:17
60 lines
11872 bytes
11872 bytes
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 | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
index 821ee9cd8ded1b8f1e425bcef493fb175ed30376..353b3a74793084085c42c1068caf5922e0681ad3 100644
--- a/drivers/net/usb/ax88179_lib.c
+++ b/drivers/net/usb/ax88179_lib.c
@@ -352,14 +352,22 @@ 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);
+ if (data->chip_version >= AX_VERSION_AX88179A) {
+ 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);
+ } else {
+ rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
+ }
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
[PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
Author: Birger Koblitz
Date: Tue, 01 Dec 2026 17:17
Date: Tue, 01 Dec 2026 17:17
142 lines
15118 bytes
15118 bytes
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.
Fixes: 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips")
Suggested-by: Benjamin Larsson <benjamin.larsson@genexis.eu>
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/net/usb/ax88179a_devices.c | 52 +++++++++++++++++++++++++++++++++-----
1 file changed, 46 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
index 69095110e70435806a99274c50d79e86016ec9a0..04d8f37bc7ebef3f2e530cb41f403dca9d0dd7d7 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,20 @@ 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);
+ ret = ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
+ if (ret < 0)
+ return ret;
+ }
+
return 0;
}
@@ -852,8 +868,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 +910,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 +1060,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 +1076,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 + fcs_trailer) {
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 +1098,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 +1254,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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads