Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 2010 20:49:44 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r213625 - stable/7/sys/dev/sis
Message-ID:  <201010082049.o98KniYi013696@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Fri Oct  8 20:49:44 2010
New Revision: 213625
URL: http://svn.freebsd.org/changeset/base/213625

Log:
  MFC r212121,212156:
  r212121:
    Move sis_reset() to sis_initl(). This ensures driver starts with
    known good state of controller.
  
  r212156:
    Fix the last endianness issue on handling station address which
    prevented driver from working on big-endian machines. Also rewrite
    station address programming to make it work on strict-alignment
    architectures. With this change, sis(4) now works on sparc64 and
    performance number looks good even though sis(4) have to apply
    fixup code to align received frames on 2 bytes boundary on sparc64.

Modified:
  stable/7/sys/dev/sis/if_sis.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/dev/sis/if_sis.c
==============================================================================
--- stable/7/sys/dev/sis/if_sis.c	Fri Oct  8 20:48:09 2010	(r213624)
+++ stable/7/sys/dev/sis/if_sis.c	Fri Oct  8 20:49:44 2010	(r213625)
@@ -1057,7 +1057,12 @@ sis_attach(device_t dev)
 			tmp[2] = sis_reverse(tmp[2]);
 			tmp[1] = sis_reverse(tmp[1]);
 
-			bcopy((char *)&tmp[1], eaddr, ETHER_ADDR_LEN);
+			eaddr[0] = (tmp[1] >> 0) & 0xFF;
+			eaddr[1] = (tmp[1] >> 8) & 0xFF;
+			eaddr[2] = (tmp[2] >> 0) & 0xFF;
+			eaddr[3] = (tmp[2] >> 8) & 0xFF;
+			eaddr[4] = (tmp[3] >> 0) & 0xFF;
+			eaddr[5] = (tmp[3] >> 8) & 0xFF;
 		}
 		break;
 	case SIS_VENDORID:
@@ -1205,7 +1210,6 @@ sis_detach(device_t dev)
 	/* These should only be active if attach succeeded. */
 	if (device_is_attached(dev)) {
 		SIS_LOCK(sc);
-		sis_reset(sc);
 		sis_stop(sc);
 		SIS_UNLOCK(sc);
 		callout_drain(&sc->sis_stat_ch);
@@ -1737,7 +1741,6 @@ sis_poll(struct ifnet *ifp, enum poll_cm
 			SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE);
 
 		if (status & SIS_ISR_SYSERR) {
-			sis_reset(sc);
 			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 			sis_initl(sc);
 		}
@@ -1792,7 +1795,6 @@ sis_intr(void *arg)
 			SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE);
 
 		if (status & SIS_ISR_SYSERR) {
-			sis_reset(sc);
 			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 			sis_initl(sc);
 			SIS_UNLOCK(sc);
@@ -1966,6 +1968,7 @@ sis_initl(struct sis_softc *sc)
 {
 	struct ifnet		*ifp = sc->sis_ifp;
 	struct mii_data		*mii;
+	uint8_t			*eaddr;
 
 	SIS_LOCK_ASSERT(sc);
 
@@ -1976,7 +1979,10 @@ sis_initl(struct sis_softc *sc)
 	 * Cancel pending I/O and free all RX/TX buffers.
 	 */
 	sis_stop(sc);
-
+	/*
+	 * Reset the chip to a known state.
+	 */
+	sis_reset(sc);
 #ifdef notyet
 	if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr >= NS_SRR_16A) {
 		/*
@@ -1990,26 +1996,21 @@ sis_initl(struct sis_softc *sc)
 	mii = device_get_softc(sc->sis_miibus);
 
 	/* Set MAC address */
+	eaddr = IF_LLADDR(sc->sis_ifp);
 	if (sc->sis_type == SIS_TYPE_83815) {
 		CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR0);
-		CSR_WRITE_4(sc, SIS_RXFILT_DATA,
-		    ((uint16_t *)IF_LLADDR(sc->sis_ifp))[0]);
+		CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[0] | eaddr[1] << 8);
 		CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR1);
-		CSR_WRITE_4(sc, SIS_RXFILT_DATA,
-		    ((uint16_t *)IF_LLADDR(sc->sis_ifp))[1]);
+		CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[2] | eaddr[3] << 8);
 		CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR2);
-		CSR_WRITE_4(sc, SIS_RXFILT_DATA,
-		    ((uint16_t *)IF_LLADDR(sc->sis_ifp))[2]);
+		CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[4] | eaddr[5] << 8);
 	} else {
 		CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR0);
-		CSR_WRITE_4(sc, SIS_RXFILT_DATA,
-		    ((uint16_t *)IF_LLADDR(sc->sis_ifp))[0]);
+		CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[0] | eaddr[1] << 8);
 		CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR1);
-		CSR_WRITE_4(sc, SIS_RXFILT_DATA,
-		    ((uint16_t *)IF_LLADDR(sc->sis_ifp))[1]);
+		CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[2] | eaddr[3] << 8);
 		CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR2);
-		CSR_WRITE_4(sc, SIS_RXFILT_DATA,
-		    ((uint16_t *)IF_LLADDR(sc->sis_ifp))[2]);
+		CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[4] | eaddr[5] << 8);
 	}
 
 	/* Init circular TX/RX lists. */
@@ -2264,8 +2265,7 @@ sis_watchdog(struct sis_softc *sc)
 	device_printf(sc->sis_dev, "watchdog timeout\n");
 	sc->sis_ifp->if_oerrors++;
 
-	sis_stop(sc);
-	sis_reset(sc);
+	sc->sis_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 	sis_initl(sc);
 
 	if (!IFQ_DRV_IS_EMPTY(&sc->sis_ifp->if_snd))
@@ -2342,7 +2342,6 @@ sis_shutdown(device_t dev)
 
 	sc = device_get_softc(dev);
 	SIS_LOCK(sc);
-	sis_reset(sc);
 	sis_stop(sc);
 	SIS_UNLOCK(sc);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010082049.o98KniYi013696>