Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/sociox - move sc_flowflags = 0 line at earlier ...



details:   https://anonhg.NetBSD.org/src/rev/c86cb73b8189
branches:  trunk
changeset: 746098:c86cb73b8189
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Sun Mar 22 00:05:17 2020 +0000

description:
- move sc_flowflags = 0 line at earlier place.
- handle a set of speed selection operations.

diffstat:

 sys/arch/arm/sociox/if_ave.c |  78 +++++++++++++++++++++----------------------
 1 files changed, 38 insertions(+), 40 deletions(-)

diffs (162 lines):

diff -r fda82a2c5188 -r c86cb73b8189 sys/arch/arm/sociox/if_ave.c
--- a/sys/arch/arm/sociox/if_ave.c      Sat Mar 21 23:25:53 2020 +0000
+++ b/sys/arch/arm/sociox/if_ave.c      Sun Mar 22 00:05:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ave.c,v 1.8 2020/03/21 11:46:36 nisimura Exp $      */
+/*     $NetBSD: if_ave.c,v 1.9 2020/03/22 00:05:17 nisimura Exp $      */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.8 2020/03/21 11:46:36 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.9 2020/03/22 00:05:17 nisimura Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -387,6 +387,9 @@
        aprint_normal_dev(self,
            "Ethernet address %s\n", ether_sprintf(enaddr));
 
+       sc->sc_flowflags = 0;
+       sc->sc_rxc = 0;
+
        mii->mii_ifp = ifp;
        mii->mii_readreg = mii_readreg;
        mii->mii_writereg = mii_writereg;
@@ -414,9 +417,6 @@
        ifp->if_stop = ave_stop;
        IFQ_SET_READY(&ifp->if_snd);
 
-       sc->sc_flowflags = 0;
-       sc->sc_rxc = 0;
-
        sc->sc_ethercom.ec_capabilities = ETHERCAP_VLAN_MTU;
        ifp->if_capabilities = IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx;
 
@@ -531,8 +531,12 @@
        sc->sc_txd32 =   (void *)((uintptr_t)sc->sc_sh + AVE32TDB);
        sc->sc_rxd32 =   (void *)((uintptr_t)sc->sc_sh + AVE32RDB);
 
-       /* build sane and loaded Tx/Rx descriptors */
-       memset(sc->sc_txdescs, 0, sizeof(struct tdes)*AVE_NTXDESC);
+       /* build sane Tx and loaded Rx descriptors */
+       for (i = 0; i < AVE_NTXDESC; i++) {
+               struct tdes *tdes = &sc->sc_txdescs[i];
+               tdes->t2 = tdes->t1 = 0;
+               tdes->t0 = T0_OWN;
+       }
        for (i = 0; i < AVE_NRXDESC; i++)
                (void)add_rxbuf(sc, i);
 
@@ -550,6 +554,8 @@
        /* accept multicast frame or run promisc mode */
        ave_set_rcvfilt(sc);
 
+       (void)ave_ifmedia_upd(ifp);
+
        csr = CSR_READ(sc, AVECFG);
        if (ifp->if_capenable & IFCAP_CSUM_IPv4_Tx) {
                sc->sc_t0csum = 0;
@@ -603,7 +609,7 @@
 {
        struct ave_softc *sc = ifp->if_softc;
        struct ifmedia *ifm = &sc->sc_mii.mii_media;
-       uint32_t txcr, rxcr;
+       uint32_t txcr, rxcr, csr;
 
        txcr = CSR_READ(sc, AVETXC);
        rxcr = CSR_READ(sc, AVERXC);
@@ -615,14 +621,25 @@
                ; /* advertise flow control pause */
                ; /* adv. 1000FDX,100FDX,100HDX,10FDX,10HDX */
        } else {
+#if 1 /* XXX not sure to belong here XXX */
                txcr &= ~(TXC_SPD1000 | TXC_SPD100);
                rxcr &= ~RXC_USEFDX;
-               if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T)
+               if ((sc->sc_phymode & CFG_MII) == 0 /* RGMII model */
+                    && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T)
                        txcr |= TXC_SPD1000;
                else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX)
                        txcr |= TXC_SPD100;
                if (ifm->ifm_media & IFM_FDX)
-                       rxcr |= RXC_USEFDX;
+                       rxcr |= RXC_USEFDX;     
+
+               /* adjust LINKSEL when MII/RMII too */
+               if (sc->sc_phymode & CFG_MII) {
+                       csr = CSR_READ(sc, AVELINKSEL) &~ LINKSEL_SPD100;;
+                       if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX)
+                               csr |= LINKSEL_SPD100;
+                       CSR_WRITE(sc, AVELINKSEL, csr);
+               }
+#endif
        }
        sc->sc_rxc = rxcr;
        CSR_WRITE(sc, AVETXC, txcr);
@@ -647,10 +664,9 @@
 {
        struct ave_softc *sc = ifp->if_softc;
        struct mii_data *mii = &sc->sc_mii;
-       struct ifmedia * const ifm = &mii->mii_media;
-       uint32_t txcr, rxcr, csr;
+       uint32_t txcr, rxcr;
 
-       /* get flow control negotiation result */
+       /* Get flow control negotiation result. */
        if (IFM_SUBTYPE(mii->mii_media.ifm_cur->ifm_media) == IFM_AUTO &&
            (mii->mii_media_active & IFM_ETH_FMASK) != sc->sc_flowflags)
                sc->sc_flowflags = mii->mii_media_active & IFM_ETH_FMASK;
@@ -659,32 +675,14 @@
        rxcr = CSR_READ(sc, AVERXC);
        CSR_WRITE(sc, AVERXC, rxcr &~ RXC_EN); /* stop Rx first */
 
-       /* adjust 802.3x PAUSE flow control */
-       if ((mii->mii_media_active & IFM_FDX)
-           && (sc->sc_flowflags & IFM_ETH_TXPAUSE))
-               txcr |= TXC_FCE;
-       else
-               txcr &= ~TXC_FCE;
-       if ((mii->mii_media_active & IFM_FDX)
-           && (sc->sc_flowflags & IFM_ETH_RXPAUSE))
-               rxcr |= RXC_FCE;
-       else
-               rxcr &= ~RXC_FCE;
-
-       /* HW does not handle automatic speed adjustment */
-       txcr &= ~(TXC_SPD1000 | TXC_SPD100);
-       if ((sc->sc_phymode & CFG_MII) == 0 /* RGMII model */
-            && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T)
-               txcr |= TXC_SPD1000;
-       else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX)
-               txcr |= TXC_SPD100;
-
-       /* adjust LINKSEL when MII/RMII too */
-       if (sc->sc_phymode & CFG_MII) {
-               csr = CSR_READ(sc, AVELINKSEL) &~ LINKSEL_SPD100;;
-               if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX)
-                       csr |= LINKSEL_SPD100;
-               CSR_WRITE(sc, AVELINKSEL, csr);
+       /* Adjust 802.3x PAUSE flow control. */
+       txcr &= ~TXC_FCE;
+       rxcr &= ~RXC_FCE;
+       if (mii->mii_media_active & IFM_FDX) {
+               if (sc->sc_flowflags & IFM_ETH_TXPAUSE)
+                       txcr |= TXC_FCE;
+               if (sc->sc_flowflags & IFM_ETH_RXPAUSE)
+                       rxcr |= RXC_FCE;
        }
 
        sc->sc_rxc = rxcr;
@@ -811,7 +809,7 @@
 
        /* pick v4mcast or v6mcast length */
        n = (en[0] == 0x01) ? 3 : (en[0] == 0x33) ? 2 : ETHER_ADDR_LEN;
-       /* entry 0 is reserved for promisc mode */
+       /* slot 0 is reserved for promisc mode */
        mskbyte0 = (i > 0) ? genmask0(n) : MSKBYTE0;
 
        /* set frame address first */



Home | Main Index | Thread Index | Old Index