Hi,

On 2018/08/05 15:31, Denis wrote:
Can not patch original files in /usr/src/sys/dev/usb/ despite that
if_axenreg.h and if_axen.c files fetched directly from current CVS repo.

Previous patch is for -current, but perhaps your source version is 6.3.
Please try the new patch below for 6.3.

The dmesg in the report says "OpenBSD 6.3", I missed it.
Sorry about that.


# patch -p0 < axen.patch
Hmm.. Lookd like a unified diff to me...
The text leading up to this was:
-------------------------
|--- sys/dev/usb/if_axenreg.h Fri Sep 16 22:17:07 2016
|+++ sys/dev/usb/if_axenreg.h Mon Jun 19 10:54:28 2017
-------------------------
Patching file sys/dev/usb/if_axenreg.h using Plan A...
Hunk #1 succeeded at 26.
Hunk #2 failed at 70.
1 out of 2 hunks failed--saving rejects to sys/dev/usb/if_axenreg.h.rej
Hmm... The next patch look like a unified diff to me...
The text leading up to this was:
-------------------------
|--- sys/dev/usb/if_axen.c.orig Tue Jun 12 15:36:59 2018
|+++ sys/dev/usb/if_axen.c Sun Jul 29 01:53:43 2018
-------------------------
Patching file sys/dev/usb/if_axen.c using Plan A...
Hunk #1 succeeded at 53.
Hunk #2 succeeded at 122 with fuzz 2.
Hunk #3 failed at 246.
Hunk #4 failed at 275.
Hunk #5 failed at 440.
Hunk #6 failed at 502.
Hunk #7 failed at 515.
Hunk #8 failed at 637.
Hunk #9 failed at 711.
Hunk #10 succeeded at 810 with fuzz 1.
Hunk #11 failed at 846.
Hunk #12 failed at 877.
Hunk #13 failed at 907.
Hunk #14 failed at 932.
Hunk #15 failed at 955.
Hunk #16 failed at 975.
Hunk #17 failed at 996.
Hunk #18 failed at 1029.
Hunk #19 failed at 1054.
16 out of 19 hunks failed--saving rejects to sys/dev/usb/if_axen.c.rej
done

 - Only qctrl and buffer allocation are changed.
   (Omit some non-essential parts. It should work.)


--- sys/dev/usb/if_axen.c.orig  Sun Jan 22 10:17:39 2017
+++ sys/dev/usb/if_axen.c       Mon Aug  6 23:20:25 2018
@@ -53,6 +53,7 @@
 #include <dev/usb/usbdi_util.h>
 #include <dev/usb/usbdivar.h>
 #include <dev/usb/usbdevs.h>
+#include <dev/usb/usb_mem.h>
#include <dev/usb/if_axenreg.h> @@ -121,6 +122,13 @@ void axen_unlock_mii(struct axen_softc *sc); void axen_ax88179_init(struct axen_softc *); +struct axen_qctrl axen_bulk_size[] = {
+       { 7, 0x4f, 0x00, 0x12, 0xff },
+       { 7, 0x20, 0x03, 0x16, 0xff },
+       { 7, 0xae, 0x07, 0x18, 0xff },
+       { 7, 0xcc, 0x4c, 0x18, 0x08 }
+};
+
 /* Get exclusive access to the MII registers */
 void
 axen_lock_mii(struct axen_softc *sc)
@@ -238,6 +246,8 @@ axen_miibus_statchg(struct device *dev)
        int                     err;
        uint16_t                val;
        uWord                   wval;
+       uint8_t                 linkstat = 0;
+       int                     qctrl;
ifp = GET_IFP(sc);
        if (mii == NULL || ifp == NULL ||
@@ -265,27 +275,49 @@ axen_miibus_statchg(struct device *dev)
                return;
val = 0;
-       if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0)
+       if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) {
                val |= AXEN_MEDIUM_FDX;
+               if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0)
+                       val |= AXEN_MEDIUM_TXFLOW_CTRL_EN;
+               if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0)
+                       val |= AXEN_MEDIUM_RXFLOW_CTRL_EN;
+       }
- val |= (AXEN_MEDIUM_RECV_EN | AXEN_MEDIUM_ALWAYS_ONE);
-       val |= (AXEN_MEDIUM_RXFLOW_CTRL_EN | AXEN_MEDIUM_TXFLOW_CTRL_EN);
+       val |= AXEN_MEDIUM_RECV_EN;
+ /* bulkin queue setting */
+       axen_lock_mii(sc);
+       axen_cmd(sc, AXEN_CMD_MAC_READ, 1, AXEN_USB_UPLINK, &linkstat);
+       axen_unlock_mii(sc);
+
        switch (IFM_SUBTYPE(mii->mii_media_active)) {
        case IFM_1000_T:
                val |= AXEN_MEDIUM_GIGA | AXEN_MEDIUM_EN_125MHZ;
+               if (linkstat & AXEN_USB_SS)
+                       qctrl = 0;
+               else if (linkstat & AXEN_USB_HS)
+                       qctrl = 1;
+               else
+                       qctrl = 3;
                break;
        case IFM_100_TX:
                val |= AXEN_MEDIUM_PS;
+               if (linkstat & (AXEN_USB_SS | AXEN_USB_HS))
+                       qctrl = 2;
+               else
+                       qctrl = 3;
                break;
        case IFM_10_T:
-               /* doesn't need to be handled */
+       default:
+               qctrl = 3;
                break;
        }
DPRINTF(("axen_miibus_statchg: val=0x%x\n", val));
        USETW(wval, val);
        axen_lock_mii(sc);
+       axen_cmd(sc, AXEN_CMD_MAC_SET_RXSR, 5, AXEN_RX_BULKIN_QCTRL,
+           &axen_bulk_size[qctrl]);
        err = axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MEDIUM_STATUS, &wval);
        axen_unlock_mii(sc);
        if (err) {
@@ -408,7 +440,6 @@ axen_ax88179_init(struct axen_softc *sc)
        uWord           wval;
        uByte           val;
        u_int16_t       ctl, temp;
-       struct axen_qctrl qctrl;
axen_lock_mii(sc); @@ -470,34 +501,18 @@ axen_ax88179_init(struct axen_softc *sc)
        switch (val) {
        case AXEN_USB_FS:
                DPRINTF(("uplink: USB1.1\n"));
-               qctrl.ctrl      = 0x07;
-               qctrl.timer_low = 0xcc;
-               qctrl.timer_high= 0x4c;
-               qctrl.bufsize   = AXEN_BUFSZ_LS - 1;
-               qctrl.ifg       = 0x08;
                break;
        case AXEN_USB_HS:
                DPRINTF(("uplink: USB2.0\n"));
-               qctrl.ctrl      = 0x07;
-               qctrl.timer_low = 0x02;
-               qctrl.timer_high= 0xa0;
-               qctrl.bufsize   = AXEN_BUFSZ_HS - 1;
-               qctrl.ifg       = 0xff;
                break;
        case AXEN_USB_SS:
                DPRINTF(("uplink: USB3.0\n"));
-               qctrl.ctrl      = 0x07;
-               qctrl.timer_low = 0x4f;
-               qctrl.timer_high= 0x00;
-               qctrl.bufsize   = AXEN_BUFSZ_SS - 1;
-               qctrl.ifg       = 0xff;
                break;
        default:
                printf("unknown uplink bus:0x%02x\n", val);
                axen_unlock_mii(sc);
                return;
        }
-       axen_cmd(sc, AXEN_CMD_MAC_SET_RXSR, 5, AXEN_RX_BULKIN_QCTRL, &qctrl);
/* Set MAC address. */
        axen_cmd(sc, AXEN_CMD_MAC_WRITE_ETHER, ETHER_ADDR_LEN,
@@ -620,22 +635,8 @@ axen_attach(struct device *parent, struct device *self
id = usbd_get_interface_descriptor(sc->axen_iface); - /* decide on what our bufsize will be */
-       switch (sc->axen_udev->speed) {
-       case USB_SPEED_FULL:
-               sc->axen_bufsz = AXEN_BUFSZ_LS * 1024;
-               break;
-       case USB_SPEED_HIGH:
-               sc->axen_bufsz = AXEN_BUFSZ_HS * 1024;
-               break;
-       case USB_SPEED_SUPER:
-               sc->axen_bufsz = AXEN_BUFSZ_SS * 1024;
-               break;
-       default:
-               printf("%s: not supported usb bus type", sc->axen_dev.dv_xname);
-               return;
-       }
-               
+       sc->axen_bufsz = 64 * 1024;
+
        /* Find endpoints. */
        for (i = 0; i < id->bNumEndpoints; i++) {
                ed = usbd_interface2endpoint_descriptor(sc->axen_iface, i);
@@ -708,7 +709,8 @@ axen_attach(struct device *parent, struct device *self
        mii->mii_flags = MIIF_AUTOTSLEEP;
ifmedia_init(&mii->mii_media, 0, axen_ifmedia_upd, axen_ifmedia_sts);
-       mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0);
+       mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY,
+           MIIF_DOPAUSE);
if (LIST_FIRST(&mii->mii_phys) == NULL) {
                ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
@@ -806,6 +808,23 @@ axen_newbuf(void)
        return m;
 }
+static void *
+axen_alloc_buffer(struct usbd_xfer *xfer, u_int32_t size)
+{
+       struct usbd_bus *bus = xfer->device->bus;
+       usbd_status err;
+
+#ifdef DIAGNOSTIC
+       if (xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))
+               printf("axen_alloc_buffer: xfer already has a buffer\n");
+#endif
+       err = usb_allocmem(bus, size, 65536, &xfer->dmabuf);
+       if (err)
+               return (NULL);
+       xfer->rqflags |= URQ_DEV_DMABUF;
+       return (KERNADDR(&xfer->dmabuf, 0));
+}
+
 int
 axen_rx_list_init(struct axen_softc *sc)
 {
@@ -825,7 +844,7 @@ axen_rx_list_init(struct axen_softc *sc)
                        c->axen_xfer = usbd_alloc_xfer(sc->axen_udev);
                        if (c->axen_xfer == NULL)
                                return ENOBUFS;
-                       c->axen_buf = usbd_alloc_buffer(c->axen_xfer,
+                       c->axen_buf = axen_alloc_buffer(c->axen_xfer,
                            sc->axen_bufsz);
                        if (c->axen_buf == NULL) {
                                usbd_free_xfer(c->axen_xfer);
@@ -856,7 +875,7 @@ axen_tx_list_init(struct axen_softc *sc)
                        c->axen_xfer = usbd_alloc_xfer(sc->axen_udev);
                        if (c->axen_xfer == NULL)
                                return ENOBUFS;
-                       c->axen_buf = usbd_alloc_buffer(c->axen_xfer,
+                       c->axen_buf = axen_alloc_buffer(c->axen_xfer,
                            sc->axen_bufsz);
                        if (c->axen_buf == NULL) {
                                usbd_free_xfer(c->axen_xfer);

Reply via email to