Hi, This patch does:
- Enable RX aggregation. - Fix RX packet buffer alignment, using roundup() macro in sys/params.h. - Call usbd_set_config before configuring endpoints in ure_init to fix an error when re-opening pipes. I grabbed the code from if_kue.c. - Make the chip recognize given MAC address. - Remove ure_reset in ure_init, becasue its already called from ure_stop. Regards, --- sys/dev/usb/if_ure.c Wed May 3 22:20:15 2017 +++ sys/dev/usb/if_ure.c Mon Jun 19 09:11:09 2017 @@ -470,8 +470,6 @@ ure_init(void *xsc) /* Cancel pending I/O. */ ure_stop(sc); - ure_reset(sc); - if (ure_rx_list_init(sc) == ENOBUFS) { printf("%s: rx list init failed\n", sc->ure_dev.dv_xname); splx(s); @@ -484,9 +482,18 @@ ure_init(void *xsc) return; } +#define URE_CONFIG_NO 1 + if (usbd_set_config_no(sc->ure_udev, URE_CONFIG_NO, 1) || + usbd_device2interface_handle(sc->ure_udev, URE_IFACE_IDX, + &sc->ure_iface)) + printf("%s: set_config failed\n", sc->ure_dev.dv_xname); + usbd_delay_ms(sc->ure_udev, 10); + /* Set MAC address. */ + ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG); ure_write_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES, sc->ure_ac.ac_enaddr, 8); + ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML); /* Reset the packet filter. */ ure_write_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA, @@ -683,10 +690,10 @@ ure_rtl8152_init(struct ure_softc *sc) URE_GPHY_STS_MSK | URE_SPEED_DOWN_MSK | URE_SPDWN_RXDV_MSK | URE_SPDWN_LINKCHG_MSK); - /* Disable Rx aggregation. */ + /* Enable Rx aggregation. */ ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, - ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) | - URE_RX_AGG_DISABLE); + ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) & + ~URE_RX_AGG_DISABLE); /* Disable ALDPS. */ ure_ocp_reg_write(sc, URE_OCP_ALDPS_CONFIG, URE_ENPDNPS | URE_LINKENA | @@ -835,10 +842,10 @@ ure_rtl8153_init(struct ure_softc *sc) ure_init_fifo(sc); - /* Disable Rx aggregation. */ + /* Enable Rx aggregation. */ ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, - ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) | - URE_RX_AGG_DISABLE); + ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) & + ~URE_RX_AGG_DISABLE); val = ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB); if (!(sc->ure_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10))) @@ -1289,7 +1296,7 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_sta goto done; } - buf += pktlen; + buf += roundup(pktlen, 8); memcpy(&rxhdr, buf, sizeof(rxhdr)); total_len -= sizeof(rxhdr); @@ -1302,7 +1309,7 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_sta goto done; } - total_len -= pktlen; + total_len -= roundup(pktlen, 8); buf += sizeof(rxhdr); m = m_devget(buf, pktlen, ETHER_ALIGN);