On Wed, 21 Jul 2021 13:46:54 -0300
Adrian Ali <adrian...@fortix.com.ar> wrote:

> On Wed, 21 Jul 2021 08:40:34 +0200
> Marcus Glocker <mar...@nazgul.ch> wrote:
> 
> > Does this diff fix the issue?
> >
> >
> > Index: if_ure.c
> > ===============================================================
> > RCS file: /cvs/src/sys/dev/usb/if_ure.c,v
> > retrieving revision 1.24
> > diff -u -p -u -p -r1.24 if_ure.c
> > --- if_ure.c    15 Apr 2021 02:23:17 -0000    1.24
> > +++ if_ure.c    21 Jul 2021 14:15:10 -0000
> > @@ -435,6 +435,9 @@ ure_miibus_statchg(struct device *dev)
> >       /* Lost link, do nothing. */
> >       if ((sc->ure_flags & URE_FLAG_LINK) == 0)
> >           return;
> > +
> > +    /* Enable transmit and receive. */
> > +    URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE | 
> > URE_CR_TE);
> >  }
> >
> > int  
> 
> No, test steps:
> 
> Start computer:
> 
> # dmesg | grep ure0
> ure0 at uhub0 port 2 configuration 1 interface 0 "TP-LINK USB 10/100 
> LAN" rev 2.10/20.00 addr 3
> ure0: RTL8152 (0x4c10), address 7c:c2:c6:1a:37:01
> rlphy0 at ure0 phy 0: RTL8201E 10/100 PHY, rev. 2
> 
> # ifconfig ure0
> ure0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
>          lladdr 7c:c2:c6:1a:37:01
>          index 5 priority 0 llprio 3
>          media: Ethernet autoselect (100baseTX full-duplex)
>          status: active
> 
> Add IP configuration in device:
> 
> # ifconfig ure0 debug
> # ifconfig ure0 192.168.47.1/24
> 
> # ifconfig ure0
> ure0: flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST> mtu
> 1500 lladdr 7c:c2:c6:1a:37:01
>          index 5 priority 0 llprio 3
>          media: Ethernet autoselect (100baseTX full-duplex)
>          status: active
>          inet 192.168.47.1 netmask 0xffffff00 broadcast 192.168.47.255
> 
> Test ping, it works:
> 
> # ping -c3 192.168.47.2
> PING 192.168.47.2 (192.168.47.2): 56 data bytes
> 64 bytes from 192.168.47.2: icmp_seq=0 ttl=255 time=0.749 ms
> 64 bytes from 192.168.47.2: icmp_seq=1 ttl=255 time=0.779 ms
> 64 bytes from 192.168.47.2: icmp_seq=2 ttl=255 time=0.836 ms
> 
> --- 192.168.47.2 ping statistics ---
> 3 packets transmitted, 3 packets received, 0.0% packet loss
> round-trip min/avg/max/std-dev = 0.749/0.788/0.836/0.036 ms
> 
> unplug cable:
> 
> # ifconfig ure0
> ure0: flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST> mtu
> 1500 lladdr 7c:c2:c6:1a:37:01
>          index 5 priority 0 llprio 3
>          media: Ethernet autoselect (none)
>          status: no carrier
>          inet 192.168.47.1 netmask 0xffffff00 broadcast 192.168.47.255
> 
> plug in cable:
> 
> # ifconfig ure0
> ure0: flags=8847<UP,BROADCAST,DEBUG,RUNNING,SIMPLEX,MULTICAST> mtu
> 1500 lladdr 7c:c2:c6:1a:37:01
>          index 5 priority 0 llprio 3
>          media: Ethernet autoselect (100baseTX full-duplex)
>          status: active
>          inet 192.168.47.1 netmask 0xffffff00 broadcast 192.168.47.255
> 
> Test ping, does not work:
> 
> # ping -c3 192.168.47.2
> PING 192.168.47.2 (192.168.47.2): 56 data bytes
> 
> --- 192.168.47.2 ping statistics ---
> 3 packets transmitted, 0 packets received, 100.0% packet loss
> 
> log:
> 
> Jul 21 13:10:02 neurus /bsd: ure0: usb error on tx: IN_PROGRESS
> Jul 21 13:10:02 neurus /bsd: usb_insert_transfer: 
> xfer=0xfffffd821eeb6c08 not free

Um, interesting.  I could get my hands on a RTL8153 in the meantime,
and there the diff fixes the issue.  With the RTL8153 I can see that
after the cable gets unplugged, RX/TX is getting disabled on the
chip.  I have assumed that would also apply to the other RTL815x chip
sets.

If you want to run this diff (it does basically the same but with more
debug output), and send back the dmesg, then we could at least see the
RTL8152 behaviour related to the RX/TX register.


Index: if_ure.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_ure.c,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 if_ure.c
--- if_ure.c    15 Apr 2021 02:23:17 -0000      1.24
+++ if_ure.c    21 Jul 2021 20:23:43 -0000
@@ -200,6 +200,8 @@ void                ure_rtl8153_phy_status(struct ure_
 void           ure_reset_bmu(struct ure_softc *);
 void           ure_disable_teredo(struct ure_softc *);
 
+void           ure_check_trx_enabled(struct ure_softc *);
+
 #define URE_SETBIT_1(sc, reg, index, x) \
        ure_write_1(sc, reg, index, ure_read_1(sc, reg, index) | (x))
 #define URE_SETBIT_2(sc, reg, index, x) \
@@ -435,6 +437,13 @@ ure_miibus_statchg(struct device *dev)
        /* Lost link, do nothing. */
        if ((sc->ure_flags & URE_FLAG_LINK) == 0)
                return;
+
+       ure_check_trx_enabled(sc);
+
+       /* Enable transmit and receive. */
+       URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE | URE_CR_TE);
+
+       ure_check_trx_enabled(sc);
 }
 
 int
@@ -796,6 +805,7 @@ ure_init(void *xsc)
 
        /* Enable transmit and receive. */
        URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE | URE_CR_TE);
+       ure_check_trx_enabled(sc);
 
        if (sc->ure_flags & (URE_FLAG_8153B | URE_FLAG_8156)) {
                ure_write_1(sc, URE_USB_UPT_RXDMA_OWN, URE_MCU_TYPE_USB,
@@ -2049,3 +2059,21 @@ ure_encap_xfer(struct ifnet *ifp, struct
 
        return (0);
 }
+
+void
+ure_check_trx_enabled(struct ure_softc *sc)
+{
+       uint8_t val = 0;
+
+       val = ure_read_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA);
+
+       printf("%s: val=0x%x: ", __func__, val);
+
+       if (val & URE_CR_RE)
+               printf("RX-ON ");
+       if (val & URE_CR_TE)
+               printf("TX-ON ");
+
+       printf("\n");
+}
+

Reply via email to