Hi,

I'm currently investigating crashes that occur when using an ASIX
88179 USB 3.0 adapter. I'm comparing axen(4) with FreeBSD and Linux
drivers. There is a bigger patch to clean up axen(4) in the pipeline,
but there's still a bit of work to be done.

The following patch was sent by sc.dying to tech@ in 2017, but was
never comitted.

It fixes missing spaces in the diagram to align bits in receive
header and sets the L3 type mask to the correct value.

AXEN_RXHDR_L3_TYPE_MASK is currently not used, but I will want to
check it in the future.

- source: sc.dying's patch
  https://marc.info/?l=openbsd-tech&m=150012119607284&w=4

- This matches FreeBSD's #define, the diagram (L3_type, bits 5 and
  6 of receive header), and Linux
  
https://github.com/freebsd/freebsd/blob/5385d2813017f54e4091cfc28d89974abc69beeb/sys/dev/usb/net/if_axgereg.h#L184
  
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/net/usb/ax88179_178a.c

- L3/4_err must have slipped by 1 bit in diagram on yuo@' commit
  when fixing drop/mii/crc_err (FreeBSD's driver shows the same bit
  masks)
  https://github.com/openbsd/src/commit/29ef1ec31eeeec0315fbf760dd223695935daf23

- L3 type mask now also matches the diagram and L3 type offset
  value

Index: sys/dev/usb/if_axenreg.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_axenreg.h,v
retrieving revision 1.6
diff -u -r1.6 if_axenreg.h
--- sys/dev/usb/if_axenreg.h    14 Sep 2016 12:41:09 -0000      1.6
+++ sys/dev/usb/if_axenreg.h    27 Nov 2018 13:11:54 -0000
@@ -26,8 +26,8 @@
  *                     |    |     ++-----L3_type (1:ipv4, 0/2:ipv6)
  *        pkt_len(13)  |    |     ||+ ++-L4_type(0: icmp, 1: UDP, 4: TCP)
  * |765|43210 76543210|7654 3210 7654 3210|
- *  ||+-crc_err              |+-L4_err |+-L4_CSUM_ERR
- *  |+-mii_err               +--L3_err +--L3_CSUM_ERR
+ *  ||+-crc_err               |+-L4_err |+-L4_CSUM_ERR
+ *  |+-mii_err                +--L3_err +--L3_CSUM_ERR
  *  +-drop_err
  *
  * ex) pkt_hdr 0x00680820
@@ -70,7 +70,7 @@
 #define   AXEN_RXHDR_L4_TYPE_TCP       0x4
 
 /* L3 packet type (2bit) */
-#define AXEN_RXHDR_L3_TYPE_MASK        0x00000600
+#define AXEN_RXHDR_L3_TYPE_MASK        0x00000060
 #define AXEN_RXHDR_L3_TYPE_OFFSET      5
 #define   AXEN_RXHDR_L3_TYPE_UNDEF     0x0
 #define   AXEN_RXHDR_L3_TYPE_IPV4      0x1

Reply via email to