Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 2010 20:48:09 +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-8@freebsd.org
Subject:   svn commit: r213624 - stable/8/sys/dev/sis
Message-ID:  <201010082048.o98Km9A9013605@svn.freebsd.org>

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

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/8/sys/dev/sis/if_sis.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/sis/if_sis.c
==============================================================================
--- stable/8/sys/dev/sis/if_sis.c	Fri Oct  8 20:44:35 2010	(r213623)
+++ stable/8/sys/dev/sis/if_sis.c	Fri Oct  8 20:48:09 2010	(r213624)
@@ -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);
@@ -1740,7 +1744,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);
 		}
@@ -1796,7 +1799,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);
@@ -1970,6 +1972,7 @@ sis_initl(struct sis_softc *sc)
 {
 	struct ifnet		*ifp = sc->sis_ifp;
 	struct mii_data		*mii;
+	uint8_t			*eaddr;
 
 	SIS_LOCK_ASSERT(sc);
 
@@ -1980,7 +1983,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) {
 		/*
@@ -1994,26 +2000,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. */
@@ -2268,8 +2269,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))
@@ -2346,7 +2346,6 @@ sis_shutdown(device_t dev)
 
 	sc = device_get_softc(dev);
 	SIS_LOCK(sc);
-	sis_reset(sc);
 	sis_stop(sc);
 	SIS_UNLOCK(sc);
 	return (0);



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