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.
Use read-modify-write for the changes to rxctrl on AX88179A/AX88279.
Fixes: 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips")
Signed-off-by: Birger Koblitz <ma…@birger-koblitz.de>
---
drivers/net/usb/ax88179_lib.c | 14 +++++++++++---
drivers/net/usb/ax88179a_devices.c | 3 +--
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
index 821ee9cd8ded1b8f1e425bcef493fb175ed30376..273c5946e16a159f5f392b822942e0d393d5075f 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; /* Do not remove FCS from frame */
if (net->flags & IFF_PROMISC) {
rxctl |= AX_RX_CTL_PRO;
} else if (net->flags & IFF_ALLMULTI ||
diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
index 69095110e70435806a99274c50d79e86016ec9a0..78a804203202f7741eb62efd10c19253043a3708 100644
--- a/drivers/net/usb/ax88179a_devices.c
+++ b/drivers/net/usb/ax88179a_devices.c
@@ -1216,8 +1216,7 @@ 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)
--
2.47.3