ref: 31f9e0bcd7442552d251cdf98b14c9feb1443839
parent: 19f749f359ad1ea12315c6f0fc2b76644ee64f96
	author: Aidan K. Wiggins <akw@oneiri.one>
	date: Sun Oct 26 21:34:57 EDT 2025
	
nusb/ether/asix.c: add support for the AX88179A variant We can tell the 88179A variant from the 88179 by inspecting the USB device release numbers. The 88179A by default uses a different firmware, so we have to set it to use the 88179 compatibility firmware. These chips use a slightly different structure for the receive buffers, where there are "dummy" headers interwoven, each with pktlen == 0. Also, use ushorts when assigning a value from a GET2().
--- a/sys/src/cmd/nusb/ether/asix.c
+++ b/sys/src/cmd/nusb/ether/asix.c
@@ -29,7 +29,6 @@
Munk = 0x8000,
Mall772 = Mfd|Mrfc|Mtfc|Mps|Mac|Mre,
Mall178 = Mps|Mfd|Mac|Mrfc|Mtfc|Mjfe|Mre,
- Mall179 = Mgm|Mfd|Mmhz|Mrfc|Mtfc|Mjfe|Munk|Mre,
Rxctldce = 0x0100, /* drop crcerr */
Rxctlso = 0x80, /* start operation */
@@ -427,9 +426,12 @@
Physr = 0x11,
/* Control */
+ Cfwmd = 0x08, /* firmware mode */
+ Fwmd179 = 0x00,
+ Fwmd179a = 0x01,
Crxctl = 0x0b,
Cmed = 0x22, /* medium status register */
- Cmmsr = 0x24, /* control monitor */
+ Cmmsr = 0x24, /* control monitor */
Mrwmp = 0x04,
Mpmepol = 0x20,
Mpmetyp = 0x40,
@@ -447,6 +449,10 @@
Cpwtrh = 0x55,
Capo = 0x91, /* auto-power off phy */
+ /* USB device release numbers */
+ Dno179 = 0x100,
+ Dno179a = 0x200,
+
/* Phy link */
Linkup = 0x0400,
Linkfd = 0x2000,
@@ -540,7 +546,7 @@
 {Block *b;
uchar *hdr;
- uint pktlen, npkt;
+ ushort pktlen, npkt;
int n;
b = allocb(a179bufsz);
@@ -549,16 +555,18 @@
return -1;
}
b->wp += n;
- npkt = GET2(b->wp-4);
hdr = b->base + GET2(b->wp-2);
+ npkt = GET2(b->wp-4);
b->wp -= 4;
 	while(npkt-- > 0){pktlen = GET2(hdr+2) & 0x1FFF;
+ hdr += 4;
+ if(pktlen == 0)
+ continue;
if(pktlen < ETHERHDRSIZE || pktlen > BLEN(b))
break;
- etheriq(copyblock(b, pktlen-4));
+ etheriq(copyblock(b, pktlen));
b->rp += (pktlen+7) & 0xFFF8;
- hdr += 4;
}
freeb(b);
return 0;
@@ -672,6 +680,14 @@
sleep(200);
a179set1(d, Csclk, Sclkacs|Sclkbcs);
sleep(100);
+
+ /*
+ * 88179 & 88179a differ by release number
+ */
+ if(d->usb->dno & Dno179a)
+ /* Make 88179a use 88179 firmware compat. */
+ a179set1(d, Cfwmd, Fwmd179);
+
a179set1(d, Cpwtrl, 0x34);
a179set1(d, Cpwtrh, 0x52);
 	if(setmac){--
⑨