The commit 05278af8b3df ("eth: asix88179: packet drop when receiving
large fragmented packets") adjusted the URB buffer size to allow large
fragmented packets. However, this change result in use of a large URB
buffer size for slow speed connections, e.g. 10/100M use 26 KiB.

Using a ASIX AX88179B USB 3.0 or ASIX AX88772E USB 2.0 Ethernet adapter
on a Rockchip RK3528 with a DWC2 USB controller this large URB buffer
size result in invalid rx_hdr and result in unusable Ethernet.

The data read back from AX_RX_BULKIN_QCTRL after being configured also
does not match the values in the AX88179_BULKIN_SIZE array.

Change to use a fixed URB buffer size of 16 KiB to fix use of Ethernet,
anything larger seem to result in unusable Ethernet. With the 16 KiB URB
buffer size use of TFTP_BLOCKSIZE=15360 seem to work okay.

Signed-off-by: Jonas Karlman <[email protected]>
---
Please note that the vendor driver 3.5.0 seems to use a different
BULKIN_SIZE array for the AX88179A/88772D variants, see [1].

[1] 
https://github.com/mmoya/asix-usb-nic-linux-driver/blob/main/ax88179a_772d.c#L24-L30
---
 drivers/usb/eth/asix88179.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index 8915ef1fdc36..6da509175480 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -173,7 +173,7 @@
 #define USB_BULK_SEND_TIMEOUT 5000
 #define USB_BULK_RECV_TIMEOUT 5000
 
-#define AX_RX_URB_SIZE 1024 * 0x1a
+#define AX_RX_URB_SIZE 16384
 #define BLK_FRAME_SIZE 0x200
 #define PHY_CONNECT_TIMEOUT 5000
 #define PHY_RESET_TIMEOUT 500
@@ -206,7 +206,6 @@ struct asix_private {
        uint8_t *pkt_data;
        uint32_t *pkt_hdr;
        int flags;
-       int rx_urb_size;
        int maxpacketsize;
 };
 
@@ -333,8 +332,6 @@ static int asix_basic_reset(struct ueth_data *dev,
        memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5);
        asix_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp);
 
-       dev_priv->rx_urb_size = 1024 * 20;
-
        /* Water Level configuration */
        *tmp = 0x34;
        asix_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp);
@@ -476,7 +473,6 @@ static int asix_init_common(struct ueth_data *dev,
        /* RX bulk configuration */
        asix_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp);
 
-       dev_priv->rx_urb_size = (1024 * (tmp[3] + 2));
        if (*tmp16 & GMII_PHY_PHYSR_FULL)
                mode |= AX_MEDIUM_FULL_DUPLEX;
        asix_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
@@ -574,7 +570,7 @@ int ax88179_eth_recv(struct udevice *dev, int flags, uchar 
**packetp)
                        if (!(flags & ETH_RECV_CHECK_DEVICE))
                                return -EAGAIN;
 
-                       ret = usb_ether_receive(ueth, priv->rx_urb_size);
+                       ret = usb_ether_receive(ueth, AX_RX_URB_SIZE);
                        if (ret < 0)
                                return ret;
 
-- 
2.52.0

Reply via email to