On Tue, Oct 30, 2018 at 09:43:08AM +0100, Patrick Wildt wrote: > > Hi, > > I recently wanted to use VLANs on ure(4) but failed. As it turns out, > hardmtu is set to 1500 which apparently does not leave enough space > for the VLAN tag. It looks like the Gigabit Version does even support > Jumbo frames. Thus we can set the maximum framelen on the RX path > to something bigger and enable Jumbo frames. > > I tried this on a Winyao USB1000F. Would be nice if people tested this > change who have those ure(4)s in active use. > > Thanks, > Patrick > > diff --git a/sys/dev/usb/if_ure.c b/sys/dev/usb/if_ure.c > index b6c6c99ef34..637fd5eca5f 100644 > --- a/sys/dev/usb/if_ure.c > +++ b/sys/dev/usb/if_ure.c > @@ -695,6 +695,9 @@ ure_rtl8152_init(struct ure_softc *sc) > > ure_init_fifo(sc); > > + /* Set allowed frame size. */ > + ure_write_2(sc, URE_PLA_RMS, URE_MCU_TYPE_PLA, URE_MAX_FRAMELEN_8152); > + > ure_write_1(sc, URE_USB_TX_AGG, URE_MCU_TYPE_USB, > URE_TX_AGG_MAX_THRESHOLD); > ure_write_4(sc, URE_USB_RX_BUF_TH, URE_MCU_TYPE_USB, URE_RX_THR_HIGH); > @@ -835,6 +838,10 @@ ure_rtl8153_init(struct ure_softc *sc) > > ure_init_fifo(sc); > > + /* Set allowed frame size. */ > + ure_write_2(sc, URE_PLA_RMS, URE_MCU_TYPE_PLA, URE_MAX_FRAMELEN_8153); > + ure_write_2(sc, URE_PLA_MTPS, URE_MCU_TYPE_PLA, URE_MTPS_JUMBO); > + > /* 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) & > @@ -1147,6 +1154,12 @@ ure_attach(struct device *parent, struct device *self, > void *aux) > ifp->if_start = ure_start; > ifp->if_capabilities = 0; > > + if (sc->ure_flags & URE_FLAG_8152) > + ifp->ifp_hardmtu = URE_MAX_FRAMELEN_8152; > + else > + ifp->ifp_hardmtu = URE_MAX_FRAMELEN_8153; > + ifp->ifp_hardmtu -= (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
Typo. Should be ifp->if_hardmtu, not ifp->ifp_hardmtu. > + > mii = &sc->ure_mii; > mii->mii_ifp = ifp; > mii->mii_readreg = ure_miibus_readreg; > diff --git a/sys/dev/usb/if_urereg.h b/sys/dev/usb/if_urereg.h > index 2260ec37890..8963d2753ed 100644 > --- a/sys/dev/usb/if_urereg.h > +++ b/sys/dev/usb/if_urereg.h > @@ -41,7 +41,8 @@ > #define URE_BYTE_EN_BYTE 0x11 > #define URE_BYTE_EN_SIX_BYTES 0x3f > > -#define URE_MAX_FRAMELEN (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN) > +#define URE_MAX_FRAMELEN_8152 (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN) > +#define URE_MAX_FRAMELEN_8153 (9 * 1024) > > #define URE_PLA_IDR 0xc000 > #define URE_PLA_RCR 0xc010 > @@ -186,6 +187,10 @@ > /* PLA_TCR1 */ > #define URE_VERSION_MASK 0x7cf0 > > +/* PLA_MTPS */ > +#define URE_MTPS_JUMBO (12 * 1024 / 64) > +#define URE_MTPS_DEFAULT (6 * 1024 / 64) > + > /* PLA_CR */ > #define URE_CR_RST 0x10 > #define URE_CR_RE 0x08 Tested on RTL8152 and RTL8153, seems to be working fine. ok kevlo@
