CVS commit: [netbsd-5] src/sys/dev/ic

2014-12-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Dec 21 20:49:43 UTC 2014

Modified Files:
src/sys/dev/ic [netbsd-5]: rtl8169.c

Log Message:
Pull up following revision(s) (requested by uwe in ticket #1936):
sys/dev/ic/rtl8169.c: revision 1.142
RealTek 8139C+ incorrectly identifies UDP checksum 0x as bad.
Force software recalculation of UDP checksum if bad checksum is
reported by the hardware.


To generate a diff of this commit:
cvs rdiff -u -r1.105.4.9 -r1.105.4.10 src/sys/dev/ic/rtl8169.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.105.4.9 src/sys/dev/ic/rtl8169.c:1.105.4.10
--- src/sys/dev/ic/rtl8169.c:1.105.4.9	Wed Jan 25 18:02:44 2012
+++ src/sys/dev/ic/rtl8169.c	Sun Dec 21 20:49:43 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.105.4.9 2012/01/25 18:02:44 riz Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.105.4.10 2014/12/21 20:49:43 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.9 2012/01/25 18:02:44 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.10 2014/12/21 20:49:43 msaitoh Exp $);
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -1276,9 +1276,19 @@ re_rxeof(struct rtk_softc *sc)
 		M_CSUM_TCP_UDP_BAD;
 } else if (RE_UDPPKT(rxstat)) {
 	m-m_pkthdr.csum_flags |= M_CSUM_UDPv4;
-	if (rxstat  RE_RDESC_STAT_UDPSUMBAD)
-		m-m_pkthdr.csum_flags |=
-		M_CSUM_TCP_UDP_BAD;
+	if (rxstat  RE_RDESC_STAT_UDPSUMBAD) {
+		/*
+		 * XXX: 8139C+ thinks UDP csum
+		 * 0x is bad, force software
+		 * calculation.
+		 */
+		if (sc-sc_quirk  RTKQ_8139CPLUS)
+			m-m_pkthdr.csum_flags
+			= ~M_CSUM_UDPv4;
+		else
+			m-m_pkthdr.csum_flags
+			|= M_CSUM_TCP_UDP_BAD;
+	}
 }
 			}
 		} else {



CVS commit: [netbsd-5] src/sys/dev/ic

2012-09-15 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Sep 15 09:32:36 UTC 2012

Modified Files:
src/sys/dev/ic [netbsd-5]: gem.c gemreg.h gemvar.h

Log Message:
Pull up following revision(s) (requested by jdc in ticket #1789):
sys/dev/ic/gem.c: revision 1.99 via patch
sys/dev/ic/gemvar.h: revision 1.24 via patch
sys/dev/ic/gemreg.h: revision 1.15 via patch
Apply lockup fixes from Havard Eidnes/OpenBSD in PR port-sparc64/46260:
- add an additional watchdog for RX overflow
- re-initialise the chip on device timeout
Also alter the interrupt blanking rate to 8 packets, as per OpenSolaris.


To generate a diff of this commit:
cvs rdiff -u -r1.78.4.2 -r1.78.4.3 src/sys/dev/ic/gem.c
cvs rdiff -u -r1.14 -r1.14.4.1 src/sys/dev/ic/gemreg.h
cvs rdiff -u -r1.18 -r1.18.20.1 src/sys/dev/ic/gemvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/gem.c
diff -u src/sys/dev/ic/gem.c:1.78.4.2 src/sys/dev/ic/gem.c:1.78.4.3
--- src/sys/dev/ic/gem.c:1.78.4.2	Sat Jun 18 16:40:31 2011
+++ src/sys/dev/ic/gem.c	Sat Sep 15 09:32:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.78.4.2 2011/06/18 16:40:31 bouyer Exp $ */
+/*	$NetBSD: gem.c,v 1.78.4.3 2012/09/15 09:32:36 bouyer Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gem.c,v 1.78.4.2 2011/06/18 16:40:31 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: gem.c,v 1.78.4.3 2012/09/15 09:32:36 bouyer Exp $);
 
 #include opt_inet.h
 #include bpfilter.h
@@ -93,6 +93,8 @@ static void	gem_stop(struct ifnet *, int
 int		gem_ioctl(struct ifnet *, u_long, void *);
 void		gem_tick(void *);
 void		gem_watchdog(struct ifnet *);
+void		gem_rx_watchdog(void *);
+void		gem_pcs_start(struct gem_softc *sc);
 void		gem_shutdown(void *);
 void		gem_pcs_start(struct gem_softc *sc);
 void		gem_pcs_stop(struct gem_softc *sc, int);
@@ -504,6 +506,8 @@ gem_attach(sc, enaddr)
 #endif
 
 	callout_init(sc-sc_tick_ch, 0);
+	callout_init(sc-sc_rx_watchdog, 0);
+	callout_setfunc(sc-sc_rx_watchdog, gem_rx_watchdog, sc);
 	return;
 
 	/*
@@ -691,6 +695,8 @@ gem_reset_rx(struct gem_softc *sc)
 	/* Wait till it finishes */
 	if (!gem_bitwait(sc, h, GEM_RX_CONFIG, 1, 0))
 		aprint_error_dev(sc-sc_dev, cannot disable read dma\n);
+	/* Wait 5ms extra. */
+	delay(5000);
 
 	/* Finally, reset the ERX */
 	bus_space_write_4(t, h2, GEM_RESET, GEM_RESET_RX);
@@ -775,7 +781,7 @@ gem_rx_common(struct gem_softc *sc)
 	(3 * sc-sc_rxfifosize / 256) |
 	((sc-sc_rxfifosize / 256)  12));
 	bus_space_write_4(t, h, GEM_RX_BLANKING,
-	(6  GEM_RX_BLANKING_TIME_SHIFT) | 6);
+	(6  GEM_RX_BLANKING_TIME_SHIFT) | 8);
 }
 
 /*
@@ -1762,6 +1768,8 @@ gem_rint(sc)
 		if (gem_add_rxbuf(sc, i) != 0) {
 			GEM_COUNTER_INCR(sc, sc_ev_rxnobuf);
 			ifp-if_ierrors++;
+			aprint_error_dev(sc-sc_dev,
+			receive error: RX no buffer space\n);
 			GEM_INIT_RXDESC(sc, i);
 			bus_dmamap_sync(sc-sc_dmatag, rxs-rxs_dmamap, 0,
 			rxs-rxs_dmamap-dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -2143,12 +2151,20 @@ gem_intr(v)
 		/*
 		 * At least with GEM_SUN_GEM and some GEM_SUN_ERI
 		 * revisions GEM_MAC_RX_OVERFLOW happen often due to a
-		 * silicon bug so handle them silently. Moreover, it's
-		 * likely that the receiver has hung so we reset it.
+		 * silicon bug so handle them silently.  So if we detect
+		 * an RX FIFO overflow, we fire off a timer, and check
+		 * whether we're still making progress by looking at the
+		 * RX FIFO write and read pointers.
 		 */
 		if (rxstat  GEM_MAC_RX_OVERFLOW) {
 			ifp-if_ierrors++;
-			gem_reset_rxdma(sc);
+			aprint_error_dev(sc-sc_dev,
+			receive error: RX overflow sc-rxptr %d, complete %d\n, sc-sc_rxptr, bus_space_read_4(t, h, GEM_RX_COMPLETION));
+			sc-sc_rx_fifo_wr_ptr =
+bus_space_read_4(t, h, GEM_RX_FIFO_WR_PTR);
+			sc-sc_rx_fifo_rd_ptr =
+bus_space_read_4(t, h, GEM_RX_FIFO_RD_PTR);
+			callout_schedule(sc-sc_rx_watchdog, 400);
 		} else if (rxstat  ~(GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT))
 			printf(%s: MAC rx fault, status 0x%02x\n,
 			device_xname(sc-sc_dev), rxstat);
@@ -2177,6 +2193,61 @@ gem_intr(v)
 	return (r);
 }
 
+void
+gem_rx_watchdog(void *arg)
+{
+	struct gem_softc *sc = arg;
+	struct ifnet *ifp = sc-sc_ethercom.ec_if;
+	bus_space_tag_t t = sc-sc_bustag;
+	bus_space_handle_t h = sc-sc_h1;
+	u_int32_t rx_fifo_wr_ptr;
+	u_int32_t rx_fifo_rd_ptr;
+	u_int32_t state;
+
+	if ((ifp-if_flags  IFF_RUNNING) == 0) {
+		aprint_error_dev(sc-sc_dev, receiver not running\n);
+		return;
+	}
+
+	rx_fifo_wr_ptr = bus_space_read_4(t, h, GEM_RX_FIFO_WR_PTR);
+	rx_fifo_rd_ptr = bus_space_read_4(t, h, GEM_RX_FIFO_RD_PTR);
+	state = bus_space_read_4(t, h, GEM_MAC_MAC_STATE);
+	if ((state  GEM_MAC_STATE_OVERFLOW) == GEM_MAC_STATE_OVERFLOW 
+	((rx_fifo_wr_ptr == rx_fifo_rd_ptr) ||
+	 ((sc-sc_rx_fifo_wr_ptr == rx_fifo_wr_ptr) 
+	  (sc-sc_rx_fifo_rd_ptr == rx_fifo_rd_ptr
+	{
+		/*
+		

CVS commit: [netbsd-5] src/sys/dev/ic

2012-02-04 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Feb  4 17:05:56 UTC 2012

Modified Files:
src/sys/dev/ic [netbsd-5]: mpt_netbsd.c

Log Message:
Pull up following revision(s) (requested by mhitch in ticket #1720):
sys/dev/ic/mpt_netbsd.c: revision 1.17
Allow adapters with SAS/SATA or FC devices to use tagged queuing by the scsipi
layer.  Can improve write performance on SAS adapters under certain conditions
when the logical drive does not have write caching enabled.  Also need to
reserver a couple of slots for commands for the driver to use - stops the
adapter shortage messages.  Multiple commands can now cause QUEUE_FULL events,
so add that to the events handled, currently just ignoring it.  Changes
based on the thread 
http://mail-index.netbsd.org/tech-kern/2011/02/08/msg009946.html.
cvs: --


To generate a diff of this commit:
cvs rdiff -u -r1.14.14.1 -r1.14.14.2 src/sys/dev/ic/mpt_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/mpt_netbsd.c
diff -u src/sys/dev/ic/mpt_netbsd.c:1.14.14.1 src/sys/dev/ic/mpt_netbsd.c:1.14.14.2
--- src/sys/dev/ic/mpt_netbsd.c:1.14.14.1	Thu Dec  2 23:45:59 2010
+++ src/sys/dev/ic/mpt_netbsd.c	Sat Feb  4 17:05:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt_netbsd.c,v 1.14.14.1 2010/12/02 23:45:59 snj Exp $	*/
+/*	$NetBSD: mpt_netbsd.c,v 1.14.14.2 2012/02/04 17:05:56 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mpt_netbsd.c,v 1.14.14.1 2010/12/02 23:45:59 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: mpt_netbsd.c,v 1.14.14.2 2012/02/04 17:05:56 bouyer Exp $);
 
 #include dev/ic/mpt.h			/* pulls in all headers */
 
@@ -112,8 +112,8 @@ mpt_scsipi_attach(mpt_softc_t *mpt)
 	memset(adapt, 0, sizeof(*adapt));
 	adapt-adapt_dev = mpt-sc_dev;
 	adapt-adapt_nchannels = 1;
-	adapt-adapt_openings = maxq;
-	adapt-adapt_max_periph = maxq;
+	adapt-adapt_openings = maxq - 2;	/* Reserve 2 for driver use*/
+	adapt-adapt_max_periph = maxq - 2;
 	adapt-adapt_request = mpt_scsipi_request;
 	adapt-adapt_minphys = mpt_minphys;
 
@@ -939,14 +939,6 @@ mpt_set_xfer_mode(mpt_softc_t *mpt, stru
 {
 	fCONFIG_PAGE_SCSI_DEVICE_1 tmp;
 
-	if (!mpt-is_scsi) {
-		/*
-		 * SCSI transport settings don't make any sense for
-		 * Fibre Channel; silently ignore the request.
-		 */
-		return;
-	}
-
 	/*
 	 * Always allow disconnect; we don't have a way to disable
 	 * it right now, in any case.
@@ -958,64 +950,71 @@ mpt_set_xfer_mode(mpt_softc_t *mpt, stru
 	else
 		mpt-mpt_tag_enable = ~(1  xm-xm_target);
 
-	tmp = mpt-mpt_dev_page1[xm-xm_target];
+	if (mpt-is_scsi) {
+		/*
+		 * SCSI transport settings only make any sense for
+		 * SCSI
+		 */
 
-	/*
-	 * Set the wide/narrow parameter for the target.
-	 */
-	if (xm-xm_mode  PERIPH_CAP_WIDE16)
-		tmp.RequestedParameters |= MPI_SCSIDEVPAGE1_RP_WIDE;
-	else
-		tmp.RequestedParameters = ~MPI_SCSIDEVPAGE1_RP_WIDE;
+		tmp = mpt-mpt_dev_page1[xm-xm_target];
 
-	/*
-	 * Set the synchronous parameters for the target.
-	 *
-	 * XXX If we request sync transfers, we just go ahead and
-	 * XXX request the maximum available.  We need finer control
-	 * XXX in order to implement Domain Validation.
-	 */
-	tmp.RequestedParameters = ~(MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK |
-	MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK |
-	MPI_SCSIDEVPAGE1_RP_DT | MPI_SCSIDEVPAGE1_RP_QAS |
-	MPI_SCSIDEVPAGE1_RP_IU);
-	if (xm-xm_mode  PERIPH_CAP_SYNC) {
-		int factor, offset, np;
-
-		factor = (mpt-mpt_port_page0.Capabilities  8)  0xff;
-		offset = (mpt-mpt_port_page0.Capabilities  16)  0xff;
-		np = 0;
-		if (factor  0x9) {
-			/* Ultra320 */
-			np |= MPI_SCSIDEVPAGE1_RP_QAS | MPI_SCSIDEVPAGE1_RP_IU;
-		}
-		if (factor  0xa) {
-			/* at least Ultra160 */
-			np |= MPI_SCSIDEVPAGE1_RP_DT;
+		/*
+		 * Set the wide/narrow parameter for the target.
+		 */
+		if (xm-xm_mode  PERIPH_CAP_WIDE16)
+			tmp.RequestedParameters |= MPI_SCSIDEVPAGE1_RP_WIDE;
+		else
+			tmp.RequestedParameters = ~MPI_SCSIDEVPAGE1_RP_WIDE;
+
+		/*
+		 * Set the synchronous parameters for the target.
+		 *
+		 * XXX If we request sync transfers, we just go ahead and
+		 * XXX request the maximum available.  We need finer control
+		 * XXX in order to implement Domain Validation.
+		 */
+		tmp.RequestedParameters = ~(MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK |
+		MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK |
+		MPI_SCSIDEVPAGE1_RP_DT | MPI_SCSIDEVPAGE1_RP_QAS |
+		MPI_SCSIDEVPAGE1_RP_IU);
+		if (xm-xm_mode  PERIPH_CAP_SYNC) {
+			int factor, offset, np;
+
+			factor = (mpt-mpt_port_page0.Capabilities  8)  0xff;
+			offset = (mpt-mpt_port_page0.Capabilities  16)  0xff;
+			np = 0;
+			if (factor  0x9) {
+/* Ultra320 */
+np |= MPI_SCSIDEVPAGE1_RP_QAS | MPI_SCSIDEVPAGE1_RP_IU;
+			}
+			if (factor  0xa) {
+/* 

CVS commit: [netbsd-5] src/sys/dev/ic

2012-01-25 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Jan 25 18:02:45 UTC 2012

Modified Files:
src/sys/dev/ic [netbsd-5]: rtl8169.c rtl81x9reg.h rtl81x9var.h

Log Message:
Pull up following revision(s) (requested by garbled in ticket #1698):
sys/dev/ic/rtl81x9var.h: revision 1.52
sys/dev/ic/rtl8169.c: revision 1.134
sys/dev/ic/rtl81x9reg.h: revision 1.42
Add support to recognize the 8168E model of this chip.  Taken from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.105.4.8 -r1.105.4.9 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.32.4.4 -r1.32.4.5 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.41.12.5 -r1.41.12.6 src/sys/dev/ic/rtl81x9var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.105.4.8 src/sys/dev/ic/rtl8169.c:1.105.4.9
--- src/sys/dev/ic/rtl8169.c:1.105.4.8	Fri Jun 19 21:51:43 2009
+++ src/sys/dev/ic/rtl8169.c	Wed Jan 25 18:02:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.105.4.8 2009/06/19 21:51:43 snj Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.105.4.9 2012/01/25 18:02:44 riz Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.8 2009/06/19 21:51:43 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.9 2012/01/25 18:02:44 riz Exp $);
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -603,6 +603,11 @@ re_attach(struct rtk_softc *sc)
 			 */
 			sc-sc_quirk |= RTKQ_NOJUMBO;
 			break;
+		case RTK_HWREV_8168E:
+			sc-sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
+			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM |
+			RTKQ_NOJUMBO;
+			break;
 		case RTK_HWREV_8100E:
 		case RTK_HWREV_8100E_SPIN2:
 		case RTK_HWREV_8101E:
@@ -661,6 +666,10 @@ re_attach(struct rtk_softc *sc)
 		}
 	}
 
+	/* Take PHY out of power down mode. */
+	if ((sc-sc_quirk  RTKQ_PHYWAKE_PM) != 0)
+		CSR_WRITE_1(sc, RTK_PMCH, CSR_READ_1(sc, RTK_PMCH) | 0x80);
+
 	aprint_normal_dev(sc-sc_dev, Ethernet address %s\n,
 	ether_sprintf(eaddr));
 

Index: src/sys/dev/ic/rtl81x9reg.h
diff -u src/sys/dev/ic/rtl81x9reg.h:1.32.4.4 src/sys/dev/ic/rtl81x9reg.h:1.32.4.5
--- src/sys/dev/ic/rtl81x9reg.h:1.32.4.4	Fri Jun 19 21:51:43 2009
+++ src/sys/dev/ic/rtl81x9reg.h	Wed Jan 25 18:02:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9reg.h,v 1.32.4.4 2009/06/19 21:51:43 snj Exp $	*/
+/*	$NetBSD: rtl81x9reg.h,v 1.32.4.5 2012/01/25 18:02:45 riz Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -130,6 +130,7 @@
 #define RTK_CSIAR		0x0068  
 #define RTK_TBI_LPAR		0x006A
 #define RTK_GMEDIASTAT		0x006C	/* 8 bits */
+#define RTK_PMCH		0x006F	/* 8 bits */
 #define RTK_EPHYAR		0x0080
 #define RTK_LDPS		0x0082	/* Link Down Power Saving */
 #define RTK_DBG_REG		0x00D1
@@ -161,6 +162,7 @@
 #define RTK_HWREV_8103E		0x24C0
 #define RTK_HWREV_8168D		0x2800
 #define RTK_HWREV_8168DP	0x2880
+#define RTK_HWREV_8168E		0x2C00
 #define RTK_HWREV_8168_SPIN1	0x3000
 #define RTK_HWREV_8100E		0x3080
 #define RTK_HWREV_8101E		0x3400

Index: src/sys/dev/ic/rtl81x9var.h
diff -u src/sys/dev/ic/rtl81x9var.h:1.41.12.5 src/sys/dev/ic/rtl81x9var.h:1.41.12.6
--- src/sys/dev/ic/rtl81x9var.h:1.41.12.5	Fri Jun 19 21:51:43 2009
+++ src/sys/dev/ic/rtl81x9var.h	Wed Jan 25 18:02:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9var.h,v 1.41.12.5 2009/06/19 21:51:43 snj Exp $	*/
+/*	$NetBSD: rtl81x9var.h,v 1.41.12.6 2012/01/25 18:02:44 riz Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -194,6 +194,7 @@ struct rtk_softc {
 #define RTKQ_NOEECMD		0x0080	/* unusable EEPROM command */
 #define RTKQ_MACSTAT		0x0100	/* set MACSTAT_DIS on init */
 #define RTKQ_CMDSTOP		0x0200	/* set STOPREQ on stop */
+#define RTKQ_PHYWAKE_PM		0x0400	/* wake PHY from power down */
 
 	bus_dma_tag_t 		sc_dmat;
 



CVS commit: [netbsd-5] src/sys/dev/ic

2011-11-02 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Nov  2 19:39:43 UTC 2011

Modified Files:
src/sys/dev/ic [netbsd-5]: ciss.c

Log Message:
Pull up following revision(s) (requested by mhitch in ticket #1674):
sys/dev/ic/ciss.c: revision 1.25
I was allowing adapt_max_periph to use all available command slots, which
easily exceeds the maximum of 256 tags used by the scsipi layer because
the tag information from the scsipi layer was ignored and all the tagging
is handled implicitly internal to ciss(4).  But with the DIAGNOSTIC option,
the scsipi layer does a check for  256 tags and will panic.  So, lets just
limit the adapt_max_periph to 256 so the scsipi layer won't try to user more.


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.2 -r1.14.4.3 src/sys/dev/ic/ciss.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ciss.c
diff -u src/sys/dev/ic/ciss.c:1.14.4.2 src/sys/dev/ic/ciss.c:1.14.4.3
--- src/sys/dev/ic/ciss.c:1.14.4.2	Sun Nov 21 21:02:49 2010
+++ src/sys/dev/ic/ciss.c	Wed Nov  2 19:39:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ciss.c,v 1.14.4.2 2010/11/21 21:02:49 riz Exp $	*/
+/*	$NetBSD: ciss.c,v 1.14.4.3 2011/11/02 19:39:43 riz Exp $	*/
 /*	$OpenBSD: ciss.c,v 1.14 2006/03/13 16:02:23 mickey Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ciss.c,v 1.14.4.2 2010/11/21 21:02:49 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: ciss.c,v 1.14.4.3 2011/11/02 19:39:43 riz Exp $);
 
 #include bio.h
 
@@ -375,7 +375,7 @@ ciss_attach(struct ciss_softc *sc)
 
 	sc-sc_adapter.adapt_dev = (struct device *) sc;
 	sc-sc_adapter.adapt_openings = sc-sc_channel.chan_openings;
-	sc-sc_adapter.adapt_max_periph = sc-sc_channel.chan_openings;
+	sc-sc_adapter.adapt_max_periph = min(sc-sc_adapter.adapt_openings, 256);
 	sc-sc_adapter.adapt_request = ciss_scsi_cmd;
 	sc-sc_adapter.adapt_minphys = cissminphys;
 	sc-sc_adapter.adapt_ioctl = ciss_scsi_ioctl;



CVS commit: [netbsd-5] src/sys/dev/ic

2011-06-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jun 18 16:40:31 UTC 2011

Modified Files:
src/sys/dev/ic [netbsd-5]: gem.c

Log Message:
Pull up following revision(s) (requested by jdc in ticket #1632):
sys/dev/ic/gem.c: revision 1.97
Fix corrupted packet problem on 100Mb/s half duplex links.
We need to set echo disable on the internal phy too, not just on the
external phy.
Tested on:
SUNW,Sun-Blade-2000
gem0 at pci0 dev 5 function 1: Sun Microsystems ERI Ethernet (rev. 0x01)
ukphy0 at gem0 phy 1: OUI 0x0006b8, model 0x000c, rev. 1
Setting pointed out by bad@.


To generate a diff of this commit:
cvs rdiff -u -r1.78.4.1 -r1.78.4.2 src/sys/dev/ic/gem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/gem.c
diff -u src/sys/dev/ic/gem.c:1.78.4.1 src/sys/dev/ic/gem.c:1.78.4.2
--- src/sys/dev/ic/gem.c:1.78.4.1	Fri May  1 01:56:16 2009
+++ src/sys/dev/ic/gem.c	Sat Jun 18 16:40:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.78.4.1 2009/05/01 01:56:16 snj Exp $ */
+/*	$NetBSD: gem.c,v 1.78.4.2 2011/06/18 16:40:31 bouyer Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gem.c,v 1.78.4.1 2009/05/01 01:56:16 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: gem.c,v 1.78.4.2 2011/06/18 16:40:31 bouyer Exp $);
 
 #include opt_inet.h
 #include bpfilter.h
@@ -2385,14 +2385,6 @@
 	sc-sc_mif_config = bus_space_read_4(t, mac, GEM_MIF_CONFIG);
 	if ((sc-sc_flags (GEM_SERDES | GEM_SERIAL)) == 0) {
 		if ((sc-sc_mif_config  GEM_MIF_CONFIG_MDI1) != 0) {
-			/* External MII needs echo disable if half duplex. */
-			if ((IFM_OPTIONS(sc-sc_mii.mii_media_active) 
-			IFM_FDX) != 0)
-/* turn on full duplex LED */
-v |= GEM_MAC_XIF_FDPLX_LED;
-			else
-/* half duplex -- disable echo */
-v |= GEM_MAC_XIF_ECHO_DISABL;
 			if (gigabit)
 v |= GEM_MAC_XIF_GMII_MODE;
 			else
@@ -2400,6 +2392,13 @@
 		} else
 			/* Internal MII needs buf enable */
 			v |= GEM_MAC_XIF_MII_BUF_ENA;
+		/* MII needs echo disable if half duplex. */
+		if ((IFM_OPTIONS(sc-sc_mii.mii_media_active)  IFM_FDX) != 0)
+			/* turn on full duplex LED */
+			v |= GEM_MAC_XIF_FDPLX_LED;
+		else
+			/* half duplex -- disable echo */
+			v |= GEM_MAC_XIF_ECHO_DISABL;
 	} else {
 		if ((IFM_OPTIONS(sc-sc_mii.mii_media_active)  IFM_FDX) != 0)
 			v |= GEM_MAC_XIF_FDPLX_LED;



CVS commit: [netbsd-5] src/sys/dev/ic

2011-01-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 16 13:06:49 UTC 2011

Modified Files:
src/sys/dev/ic [netbsd-5]: ahcisata_core.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1530):
sys/dev/ic/ahcisata_core.c: revision 1.31
Don't call bus_dmamap_load(9) and bus_dmamap_sync(9) on command xfers
if (AT_READ|AT_WRITE) in ata_c-flags is set but ata_c-bcount is zero.
Someone actually tries to put such a command and it causes
DIAGNOSTIC panic in x86/bus_dma.c:_bus_dmamap_sync().
I think bus_dma(9) API itself may allow calls with mapsize==0
but there are many MD code that asserts offset=mapsize or len==0.
The problem is reported and fix is confirmed by Takuro KUBOTA
with XEN DOM0 kernel (which has options DIAGNOSTIC).


To generate a diff of this commit:
cvs rdiff -u -r1.18.4.4 -r1.18.4.5 src/sys/dev/ic/ahcisata_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.18.4.4 src/sys/dev/ic/ahcisata_core.c:1.18.4.5
--- src/sys/dev/ic/ahcisata_core.c:1.18.4.4	Sun Mar 28 16:21:18 2010
+++ src/sys/dev/ic/ahcisata_core.c	Sun Jan 16 13:06:49 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.18.4.4 2010/03/28 16:21:18 snj Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.18.4.5 2011/01/16 13:06:49 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ahcisata_core.c,v 1.18.4.4 2010/03/28 16:21:18 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: ahcisata_core.c,v 1.18.4.5 2011/01/16 13:06:49 bouyer Exp $);
 
 #include sys/types.h
 #include sys/malloc.h
@@ -729,7 +729,8 @@
 	AHCIDEBUG_PRINT((%s port %d header %p\n, AHCINAME(sc),
 	chp-ch_channel, cmd_h), DEBUG_XFERS);
 	if (ahci_dma_setup(chp, slot,
-	(ata_c-flags  (AT_READ|AT_WRITE)) ? ata_c-data : NULL,
+	(ata_c-flags  (AT_READ|AT_WRITE)  ata_c-bcount  0) ?
+	ata_c-data : NULL,
 	ata_c-bcount,
 	(ata_c-flags  AT_READ) ? BUS_DMA_READ : BUS_DMA_WRITE)) {
 		ata_c-flags |= AT_DF;
@@ -862,7 +863,7 @@
 	/* this comamnd is not active any more */
 	achp-ahcic_cmds_active = ~(1  slot);
 
-	if (ata_c-flags  (AT_READ|AT_WRITE)) {
+	if (ata_c-flags  (AT_READ|AT_WRITE)  ata_c-bcount  0) {
 		bus_dmamap_sync(sc-sc_dmat, achp-ahcic_datad[slot], 0,
 		achp-ahcic_datad[slot]-dm_mapsize,
 		(ata_c-flags  AT_READ) ? BUS_DMASYNC_POSTREAD :



CVS commit: [netbsd-5] src/sys/dev/ic

2010-12-02 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Dec  2 23:42:37 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: iavc.c

Log Message:
Pull up following revision(s) (requested by riz in ticket #1418):
sys/dev/ic/iavc.c: revision 1.8
Make this compile foo[0] does not work for void * :-) Wojciech Galazka


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.14.1 src/sys/dev/ic/iavc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/iavc.c
diff -u src/sys/dev/ic/iavc.c:1.7 src/sys/dev/ic/iavc.c:1.7.14.1
--- src/sys/dev/ic/iavc.c:1.7	Tue Apr  8 12:07:26 2008
+++ src/sys/dev/ic/iavc.c	Thu Dec  2 23:42:37 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: iavc.c,v 1.7 2008/04/08 12:07:26 cegger Exp $	*/
+/*	$NetBSD: iavc.c,v 1.7.14.1 2010/12/02 23:42:37 snj Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Cubical Solutions Ltd. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: iavc.c,v 1.7 2008/04/08 12:07:26 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: iavc.c,v 1.7.14.1 2010/12/02 23:42:37 snj Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -892,7 +892,7 @@
 u_int8_t *dmabuf = 0, cmd;
 
 if (sc-sc_dma) {
-	dmabuf = amcc_get_byte(sc-sc_recvbuf[0], cmd);
+	dmabuf = amcc_get_byte(sc-sc_recvbuf, cmd);
 } else {
 	cmd = iavc_get_byte(sc);
 }
@@ -1004,9 +1004,9 @@
 	/* Copy message to DMA buffer. */
 
 	if (m-m_next)
-	dmabuf = amcc_put_byte(sc-sc_sendbuf[0], SEND_DATA_B3_REQ);
+	dmabuf = amcc_put_byte(sc-sc_sendbuf, SEND_DATA_B3_REQ);
 	else
-	dmabuf = amcc_put_byte(sc-sc_sendbuf[0], SEND_MESSAGE);
+	dmabuf = amcc_put_byte(sc-sc_sendbuf, SEND_MESSAGE);
 
 	dmabuf = amcc_put_word(dmabuf, m-m_len);
 	memcpy(dmabuf, m-m_data, m-m_len);
@@ -1061,7 +1061,7 @@
 uint8_t *dmabuf;
 
 if (sc-sc_dma) {
-	memcpy(sc-sc_sendbuf[0], m-m_data + 2, m-m_len - 2);
+	memcpy(sc-sc_sendbuf, m-m_data + 2, m-m_len - 2);
 	txlen = m-m_len - 2;
 } else {
 



CVS commit: [netbsd-5] src/sys/dev/ic

2010-12-02 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Dec  2 23:45:59 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: mpt.c mpt.h mpt_debug.c mpt_netbsd.c

Log Message:
Pull up following revision(s) (requested by riz in ticket #1487):
sys/dev/ic/mpt.c: revision 1.14
sys/dev/ic/mpt.h: revision 1.7
sys/dev/ic/mpt_debug.c: revision 1.7
sys/dev/ic/mpt_netbsd.c: revision 1.15
add byte-swapping so that this works on BE platforms.
the logic is based on the current freebsd driver.
fixes PR 42870.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.42.1 src/sys/dev/ic/mpt.c
cvs rdiff -u -r1.6 -r1.6.42.1 src/sys/dev/ic/mpt.h
cvs rdiff -u -r1.4 -r1.4.86.1 src/sys/dev/ic/mpt_debug.c
cvs rdiff -u -r1.14 -r1.14.14.1 src/sys/dev/ic/mpt_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/mpt.c
diff -u src/sys/dev/ic/mpt.c:1.10 src/sys/dev/ic/mpt.c:1.10.42.1
--- src/sys/dev/ic/mpt.c:1.10	Fri Jul 27 18:38:13 2007
+++ src/sys/dev/ic/mpt.c	Thu Dec  2 23:45:59 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt.c,v 1.10 2007/07/27 18:38:13 tron Exp $	*/
+/*	$NetBSD: mpt.c,v 1.10.42.1 2010/12/02 23:45:59 snj Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -27,6 +27,75 @@
 /*
  * Additional Copyright (c) 2002 by Matthew Jacob under same license.
  */
+/*-
+ * Copyright (c) 2002, 2006 by Matthew Jacob
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *substantially similar to the NO WARRANTY disclaimer below
+ *(Disclaimer) and any redistribution must be conditioned upon including
+ *a substantially similar Disclaimer requirement for further binary
+ *redistribution.
+ * 3. Neither the names of the above listed copyright holders nor the names
+ *of any contributors may be used to endorse or promote products derived
+ *from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
+ * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Support from Chris Ellsworth in order to make SAS adapters work
+ * is gratefully acknowledged.
+ *
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
+ */
+/*-
+ * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
+ * Copyright (c) 2005, WHEEL Sp. z o.o.
+ * Copyright (c) 2004, 2005 Justin T. Gibbs
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *substantially similar to the NO WARRANTY disclaimer below
+ *(Disclaimer) and any redistribution must be conditioned upon including
+ *a substantially similar Disclaimer requirement for further binary
+ *redistribution.
+ * 3. Neither the names of the above listed copyright holders nor the names
+ *of any contributors may be used to endorse or promote products derived
+ *from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) 

CVS commit: [netbsd-5] src/sys/dev/ic

2010-11-21 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Nov 21 21:02:49 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: ciss.c

Log Message:
Pull up following revision(s) (requested by pettai in ticket #1452):
sys/dev/ic/ciss.c: revision 1.23
Fix a performance problem with the ciss(4) driver.  NetBSD does common
queueing at the scsipi midlayer, and if the midlayer is not requested to
enable tagged queueing, the midlayer will only queue one command to the
adapter driver for each device.  The SmartArray adapter is capable of
handling multiple commands, and in the rather common case where there is
no battery backup and no write cache, doing single write commands is very
slow.  The SmartArray adapter runs much better when several commands can
be issued to a device.
This has been observed and discussed in several list threads, notably:
http://mail-index.NetBSD.org/netbsd-users/2008/10/01/msg002083.html
http://mail-index.NetBSD.org/tech-kern/2008/11/30/msg003704.html
This also addresses PR kern/39686.
To enable tagged queueing, the adapter driver responds to the midlayer
request to set the transfer mode.  However, the SmartArray does not respond
to the SCSI INQUIRY command with an ANSII field of 2 or more, so the
scsipi midlayer will ignore the CmdQue bit in the flags3 field of the
inquiry data.  This fix will patch the inquiry data so set the ANSII field
to 2, and responds to the midlayer request to set the transfer mode by
requesting tagged queueing.
In addition, the original port of the driver did not set up the adapter
parameters correctly as mentioned in the second list thread mentioned
above.  The adapt_openings is the total number of commands that the
adapter will accept rather than the number of commands divided by the
number of logical drives.  Also, the adapt_max_periph is the maximum number
of commands which can be queued per peripheral device, not the number of
logical drives [which in the case of a single logical drive limited the
number of commands queued to 1].
I'm also suppressing an error message for invalid commands if the error
was due to the SCSI_SYNCHRONIZE_CACHE_10 command, since that command is
not supported by the SmartArray adapter, but used with wapbl(4) meta-data
journaling.  Setting the ANSII version to 2 to allow enabling tagged queueing
also enables the use of the SCSI_SYNCHRONIZE_CACHE_10 command.


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.1 -r1.14.4.2 src/sys/dev/ic/ciss.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ciss.c
diff -u src/sys/dev/ic/ciss.c:1.14.4.1 src/sys/dev/ic/ciss.c:1.14.4.2
--- src/sys/dev/ic/ciss.c:1.14.4.1	Sun Jul 26 18:33:35 2009
+++ src/sys/dev/ic/ciss.c	Sun Nov 21 21:02:49 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ciss.c,v 1.14.4.1 2009/07/26 18:33:35 snj Exp $	*/
+/*	$NetBSD: ciss.c,v 1.14.4.2 2010/11/21 21:02:49 riz Exp $	*/
 /*	$OpenBSD: ciss.c,v 1.14 2006/03/13 16:02:23 mickey Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ciss.c,v 1.14.4.1 2009/07/26 18:33:35 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: ciss.c,v 1.14.4.2 2010/11/21 21:02:49 riz Exp $);
 
 #include bio.h
 
@@ -41,6 +41,7 @@
 #include dev/scsipi/scsi_all.h
 #include dev/scsipi/scsi_disk.h
 #include dev/scsipi/scsiconf.h
+#include dev/scsipi/scsipi_all.h
 
 #include dev/ic/cissreg.h
 #include dev/ic/cissvar.h
@@ -363,7 +364,7 @@
 	sc-sc_channel.chan_channel = 0;
 	sc-sc_channel.chan_ntargets = sc-maxunits;
 	sc-sc_channel.chan_nluns = 1;	/* ciss doesn't really have SCSI luns */
-	sc-sc_channel.chan_openings = sc-maxcmd / (sc-maxunits? sc-maxunits : 1);
+	sc-sc_channel.chan_openings = sc-maxcmd;
 #if NBIO  0
 	/* XXX Reserve some ccb's for sensor and bioctl. */
 	if (sc-sc_channel.chan_openings  2)
@@ -374,7 +375,7 @@
 
 	sc-sc_adapter.adapt_dev = (struct device *) sc;
 	sc-sc_adapter.adapt_openings = sc-sc_channel.chan_openings;
-	sc-sc_adapter.adapt_max_periph = sc-maxunits;
+	sc-sc_adapter.adapt_max_periph = sc-sc_channel.chan_openings;
 	sc-sc_adapter.adapt_request = ciss_scsi_cmd;
 	sc-sc_adapter.adapt_minphys = cissminphys;
 	sc-sc_adapter.adapt_ioctl = ciss_scsi_ioctl;
@@ -618,6 +619,14 @@
 	if (xs) {
 		xs-resid = 0;
 		CISS_DPRINTF(CISS_D_CMD, (scsipi_done(%p) , xs));
+		if (xs-cmd-opcode == INQUIRY) {
+			struct scsipi_inquiry_data *inq;
+			inq = (struct scsipi_inquiry_data *)xs-data;
+			if ((inq-version  SID_ANSII) == 0 
+			(inq-flags3  SID_CmdQue) != 0) {
+inq-version |= 2;
+			}
+		}
 		scsipi_done(xs);
 	}
 
@@ -637,9 +646,11 @@
 		break;
 
 	case CISS_ERR_INVCMD:
-		printf(%s: invalid cmd 0x%x: 0x%x is not valid @ 0x%x[%d]\n,
-		device_xname(sc-sc_dev), ccb-ccb_cmd.id,
-		err-err_info, err-err_type[3], err-err_type[2]);
+		if (xs == NULL ||
+		xs-cmd-opcode != SCSI_SYNCHRONIZE_CACHE_10)
+			printf(%s: invalid cmd 0x%x: 0x%x is not valid @ 0x%x[%d]\n,
+			

CVS commit: [netbsd-5] src/sys/dev/ic

2010-11-20 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Nov 20 18:20:49 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: esiop.c siop.c

Log Message:
Pull up following revision(s) (requested by mhitch in ticket #1390):
sys/dev/ic/siop.c: revision 1.95
sys/dev/ic/esiop.c: revision 1.52
Improve error paths in (e)siop_scsipi_request():
  - When terminating the adapter request after the cmd has been removed
from the free list, put that cmd back on the free list before returing.
  - Correctly indicate which bus_dma_load() failed.
Analysis and fix from Michael L. Hitch in PR/42844.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.14.1 src/sys/dev/ic/esiop.c
cvs rdiff -u -r1.87 -r1.87.14.1 src/sys/dev/ic/siop.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/esiop.c
diff -u src/sys/dev/ic/esiop.c:1.42 src/sys/dev/ic/esiop.c:1.42.14.1
--- src/sys/dev/ic/esiop.c:1.42	Tue Apr  8 12:07:26 2008
+++ src/sys/dev/ic/esiop.c	Sat Nov 20 18:20:49 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: esiop.c,v 1.42 2008/04/08 12:07:26 cegger Exp $	*/
+/*	$NetBSD: esiop.c,v 1.42.14.1 2010/11/20 18:20:49 riz Exp $	*/
 
 /*
  * Copyright (c) 2002 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: esiop.c,v 1.42 2008/04/08 12:07:26 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: esiop.c,v 1.42.14.1 2010/11/20 18:20:49 riz Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1556,6 +1556,8 @@
 target %d\n, target);
 xs-error = XS_RESOURCE_SHORTAGE;
 scsipi_done(xs);
+TAILQ_INSERT_TAIL(sc-free_list,
+esiop_cmd, next);
 splx(s);
 return;
 			}
@@ -1582,6 +1584,8 @@
 target, lun);
 xs-error = XS_RESOURCE_SHORTAGE;
 scsipi_done(xs);
+TAILQ_INSERT_TAIL(sc-free_list,
+esiop_cmd, next);
 splx(s);
 return;
 			}
@@ -1598,8 +1602,11 @@
 		if (error) {
 			aprint_error_dev(sc-sc_c.sc_dev, unable to load cmd DMA map: %d\n,
 			error);
-			xs-error = XS_DRIVER_STUFFUP;
+			xs-error = (error == EAGAIN) ?
+			XS_RESOURCE_SHORTAGE : XS_DRIVER_STUFFUP;
 			scsipi_done(xs);
+			esiop_cmd-cmd_c.status = CMDST_FREE;
+			TAILQ_INSERT_TAIL(sc-free_list, esiop_cmd, next);
 			splx(s);
 			return;
 		}
@@ -1610,12 +1617,17 @@
 			((xs-xs_control  XS_CTL_DATA_IN) ?
 			 BUS_DMA_READ : BUS_DMA_WRITE));
 			if (error) {
-aprint_error_dev(sc-sc_c.sc_dev, unable to load cmd DMA map: %d,
+aprint_error_dev(sc-sc_c.sc_dev,
+unable to load data DMA map: %d,
 error);
-xs-error = XS_DRIVER_STUFFUP;
+xs-error = (error == EAGAIN) ?
+XS_RESOURCE_SHORTAGE : XS_DRIVER_STUFFUP;
 scsipi_done(xs);
 bus_dmamap_unload(sc-sc_c.sc_dmat,
 esiop_cmd-cmd_c.dmamap_cmd);
+esiop_cmd-cmd_c.status = CMDST_FREE;
+TAILQ_INSERT_TAIL(sc-free_list,
+esiop_cmd, next);
 splx(s);
 return;
 			}

Index: src/sys/dev/ic/siop.c
diff -u src/sys/dev/ic/siop.c:1.87 src/sys/dev/ic/siop.c:1.87.14.1
--- src/sys/dev/ic/siop.c:1.87	Tue Apr  8 12:07:27 2008
+++ src/sys/dev/ic/siop.c	Sat Nov 20 18:20:49 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: siop.c,v 1.87 2008/04/08 12:07:27 cegger Exp $	*/
+/*	$NetBSD: siop.c,v 1.87.14.1 2010/11/20 18:20:49 riz Exp $	*/
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: siop.c,v 1.87 2008/04/08 12:07:27 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: siop.c,v 1.87.14.1 2010/11/20 18:20:49 riz Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1282,6 +1282,8 @@
 target %d\n, target);
 xs-error = XS_RESOURCE_SHORTAGE;
 scsipi_done(xs);
+TAILQ_INSERT_TAIL(sc-free_list,
+siop_cmd, next);
 splx(s);
 return;
 			}
@@ -1301,6 +1303,8 @@
 target);
 xs-error = XS_RESOURCE_SHORTAGE;
 scsipi_done(xs);
+TAILQ_INSERT_TAIL(sc-free_list,
+siop_cmd, next);
 splx(s);
 return;
 			}
@@ -1318,6 +1322,8 @@
 target, lun);
 xs-error = XS_RESOURCE_SHORTAGE;
 scsipi_done(xs);
+TAILQ_INSERT_TAIL(sc-free_list,
+siop_cmd, next);
 splx(s);
 return;
 			}
@@ -1334,8 +1340,11 @@
 		if (error) {
 			aprint_error_dev(sc-sc_c.sc_dev, unable to load cmd DMA map: %d\n,
 			error);
-			xs-error = XS_DRIVER_STUFFUP;
+			xs-error = (error == EAGAIN) ?
+			XS_RESOURCE_SHORTAGE : XS_DRIVER_STUFFUP;
 			scsipi_done(xs);
+			siop_cmd-cmd_c.status = CMDST_FREE;
+			TAILQ_INSERT_TAIL(sc-free_list, siop_cmd, next);
 			splx(s);
 			return;
 		}
@@ -1346,12 +1355,17 @@
 			((xs-xs_control  XS_CTL_DATA_IN) ?
 			 BUS_DMA_READ : BUS_DMA_WRITE));
 			if (error) {
-aprint_error_dev(sc-sc_c.sc_dev, unable to load cmd DMA map: %d,
+aprint_error_dev(sc-sc_c.sc_dev,
+unable to load data DMA map: 

CVS commit: [netbsd-5] src/sys/dev/ic

2010-11-20 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Nov 20 20:12:57 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: esiop.c siop.c

Log Message:
Fix patch from ticket 1390; bad merge from -current to netbsd-5.


To generate a diff of this commit:
cvs rdiff -u -r1.42.14.1 -r1.42.14.2 src/sys/dev/ic/esiop.c
cvs rdiff -u -r1.87.14.1 -r1.87.14.2 src/sys/dev/ic/siop.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/esiop.c
diff -u src/sys/dev/ic/esiop.c:1.42.14.1 src/sys/dev/ic/esiop.c:1.42.14.2
--- src/sys/dev/ic/esiop.c:1.42.14.1	Sat Nov 20 18:20:49 2010
+++ src/sys/dev/ic/esiop.c	Sat Nov 20 20:12:56 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: esiop.c,v 1.42.14.1 2010/11/20 18:20:49 riz Exp $	*/
+/*	$NetBSD: esiop.c,v 1.42.14.2 2010/11/20 20:12:56 riz Exp $	*/
 
 /*
  * Copyright (c) 2002 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: esiop.c,v 1.42.14.1 2010/11/20 18:20:49 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: esiop.c,v 1.42.14.2 2010/11/20 20:12:56 riz Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1617,7 +1617,7 @@
 			((xs-xs_control  XS_CTL_DATA_IN) ?
 			 BUS_DMA_READ : BUS_DMA_WRITE));
 			if (error) {
-aprint_error_dev(sc-sc_c.sc_dev,
+aprint_error_dev(sc-sc_c.sc_dev,
 unable to load data DMA map: %d,
 error);
 xs-error = (error == EAGAIN) ?

Index: src/sys/dev/ic/siop.c
diff -u src/sys/dev/ic/siop.c:1.87.14.1 src/sys/dev/ic/siop.c:1.87.14.2
--- src/sys/dev/ic/siop.c:1.87.14.1	Sat Nov 20 18:20:49 2010
+++ src/sys/dev/ic/siop.c	Sat Nov 20 20:12:56 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: siop.c,v 1.87.14.1 2010/11/20 18:20:49 riz Exp $	*/
+/*	$NetBSD: siop.c,v 1.87.14.2 2010/11/20 20:12:56 riz Exp $	*/
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -33,7 +33,7 @@
 /* SYM53c7/8xx PCI-SCSI I/O Processors driver */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: siop.c,v 1.87.14.1 2010/11/20 18:20:49 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: siop.c,v 1.87.14.2 2010/11/20 20:12:56 riz Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1355,7 +1355,7 @@
 			((xs-xs_control  XS_CTL_DATA_IN) ?
 			 BUS_DMA_READ : BUS_DMA_WRITE));
 			if (error) {
-aprint_error_dev(sc-sc_c.sc_dev,
+aprint_error_dev(sc-sc_c.sc_dev,
 unable to load data DMA map: %d,
 error);
 xs-error = (error == EAGAIN) ?



CVS commit: [netbsd-5] src/sys/dev/ic

2010-03-28 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Mar 28 16:21:18 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: ahcisata_core.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1317):
sys/dev/ic/ahcisata_core.c: revision 1.23, 1.24
Move ahci_channel_start() after BSY has cleared (what seems to matter
here is not touching SError while BSY is asserted). Fix random
behavior (serial console corruption/misfunction, misbehavior of USB
controllers, crasy interrupts crashing the Xen hypervisor, ...)
of Intel ESB2 controller with some brand of hitachi drives.
--
ahcisata_core.c 1.23 cause long drive probe (31s, reported by
Roy Marples), or other devices misbehavior probably due to interrupts issues
(reported by Jukka Ruohonen). Back it out and do the following changes:
- clear port interrupt register before ahci_channel_start() which enables
  interrupts
- wait 500ms after sata_reset_interface() before touching SERROR register.
  This is what seems to fix the issue I'm seeming on ESB2 controller.
- The 31s delay didn't cause the probe to fail because of a mismatch
  in loop index comparison; use a #define for delay after reset
  instead of numeric values, to avoid this kind of bugs in the
  future.


To generate a diff of this commit:
cvs rdiff -u -r1.18.4.3 -r1.18.4.4 src/sys/dev/ic/ahcisata_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.18.4.3 src/sys/dev/ic/ahcisata_core.c:1.18.4.4
--- src/sys/dev/ic/ahcisata_core.c:1.18.4.3	Sun Mar  7 08:52:21 2010
+++ src/sys/dev/ic/ahcisata_core.c	Sun Mar 28 16:21:18 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.18.4.3 2010/03/07 08:52:21 sborrill Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.18.4.4 2010/03/28 16:21:18 snj Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ahcisata_core.c,v 1.18.4.3 2010/03/07 08:52:21 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: ahcisata_core.c,v 1.18.4.4 2010/03/28 16:21:18 snj Exp $);
 
 #include sys/types.h
 #include sys/malloc.h
@@ -102,6 +102,8 @@
 #endif /* NATAPIBUS */
 
 #define ATA_DELAY 1 /* 10s for a drive I/O */
+#define ATA_RESET_DELAY 31000 /* 31s for a drive reset */
+#define AHCI_RST_WAIT (ATA_RESET_DELAY / 10)
 
 const struct ata_bustype ahci_ata_bustype = {
 	SCSIPI_BUSTYPE_ATA,
@@ -510,16 +512,20 @@
 		chp-ch_queue-active_xfer-c_kill_xfer(chp,
 		chp-ch_queue-active_xfer, KILL_RESET);
 	}
+	tsleep(sc, PRIBIO, ahcirst, mstohz(500));
+	/* clear port interrupt register */
+	AHCI_WRITE(sc, AHCI_P_IS(chp-ch_channel), 0x);
+	/* clear SErrors and start operations */
 	ahci_channel_start(sc, chp);
 	/* wait 31s for BSY to clear */
-	for (i = 0; i 3100; i++) {
+	for (i = 0; i AHCI_RST_WAIT; i++) {
 		tfd = AHCI_READ(sc, AHCI_P_TFD(chp-ch_channel));
 		if tfd  AHCI_P_TFD_ST)  AHCI_P_TFD_ST_SHIFT)
 		 WDCS_BSY) == 0)
 			break;
 		tsleep(sc, PRIBIO, ahcid2h, mstohz(10));
 	}
-	if (i == 1500)
+	if (i == AHCI_RST_WAIT)
 		aprint_error(%s: BSY never cleared, TD 0x%x\n,
 		AHCINAME(sc), tfd);
 	AHCIDEBUG_PRINT((%s: BSY took %d ms\n, AHCINAME(sc), i * 10),
@@ -570,19 +576,24 @@
 	switch (sata_reset_interface(chp, sc-sc_ahcit, achp-ahcic_scontrol,
 	achp-ahcic_sstatus)) {
 	case SStatus_DET_DEV:
+		tsleep(sc, PRIBIO, ahcidv, mstohz(500));
+		/* clear port interrupt register */
+		AHCI_WRITE(sc, AHCI_P_IS(chp-ch_channel), 0x);
 		/* clear SErrors and start operations */
 		ahci_channel_start(sc, chp);
 		/* wait 31s for BSY to clear */
-		for (i = 0; i 3100; i++) {
+		for (i = 0; i AHCI_RST_WAIT; i++) {
 			sig = AHCI_READ(sc, AHCI_P_TFD(chp-ch_channel));
 			if sig  AHCI_P_TFD_ST)  AHCI_P_TFD_ST_SHIFT)
 			 WDCS_BSY) == 0)
 break;
 			tsleep(sc, PRIBIO, ahcid2h, mstohz(10));
 		}
-		if (i == 1500)
+		if (i == AHCI_RST_WAIT) {
 			aprint_error(%s: BSY never cleared, TD 0x%x\n,
 			AHCINAME(sc), sig);
+			return;
+		}
 		AHCIDEBUG_PRINT((%s: BSY took %d ms\n, AHCINAME(sc), i * 10),
 		DEBUG_PROBE);
 		sig = AHCI_READ(sc, AHCI_P_SIG(chp-ch_channel));
@@ -599,7 +610,9 @@
 		} else
 			chp-ch_drive[0].drive_flags |= DRIVE_ATA;
 		splx(s);
-		/* enable interrupts */
+		/* clear port interrupt register */
+		AHCI_WRITE(sc, AHCI_P_IS(chp-ch_channel), 0x);
+		/* and enable interrupts */
 		AHCI_WRITE(sc, AHCI_P_IE(chp-ch_channel),
 		AHCI_P_IX_TFES | AHCI_P_IX_HBFS | AHCI_P_IX_IFS |
 		AHCI_P_IX_OFS | AHCI_P_IX_DPS | AHCI_P_IX_UFS |



CVS commit: [netbsd-5] src/sys/dev/ic

2010-01-27 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Wed Jan 27 21:33:36 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: mfi.c

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1256):
sys/dev/ic/mfi.c:   revision 1.21

Don't release CCB twice. Found by code inspection.


To generate a diff of this commit:
cvs rdiff -u -r1.19.4.1 -r1.19.4.2 src/sys/dev/ic/mfi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/mfi.c
diff -u src/sys/dev/ic/mfi.c:1.19.4.1 src/sys/dev/ic/mfi.c:1.19.4.2
--- src/sys/dev/ic/mfi.c:1.19.4.1	Thu Sep 10 07:06:34 2009
+++ src/sys/dev/ic/mfi.c	Wed Jan 27 21:33:36 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.19.4.1 2009/09/10 07:06:34 snj Exp $ */
+/* $NetBSD: mfi.c,v 1.19.4.2 2010/01/27 21:33:36 sborrill Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom ma...@peereboom.us
@@ -17,7 +17,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mfi.c,v 1.19.4.1 2009/09/10 07:06:34 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: mfi.c,v 1.19.4.2 2010/01/27 21:33:36 sborrill Exp $);
 
 #include bio.h
 
@@ -1106,7 +1106,6 @@
 			/* XXX check for sense in ccb-ccb_sense? */
 			printf(%s: mfi_scsipi_request poll failed\n,
 			DEVNAME(sc));
-			mfi_put_ccb(ccb);
 			bzero(xs-sense, sizeof(xs-sense));
 			xs-sense.scsi_sense.response_code =
 			SSD_RCODE_VALID | SSD_RCODE_CURRENT;



CVS commit: [netbsd-5] src/sys/dev/ic

2010-01-27 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Wed Jan 27 21:40:25 UTC 2010

Modified Files:
src/sys/dev/ic [netbsd-5]: mfi.c

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1257):
sys/dev/ic/mfi.c:   revision 1.31

bio(4) is MP-safe but mfi(4) is not. So get the kernel_lock at
mfi_ioctl() entry and release it on exit.


To generate a diff of this commit:
cvs rdiff -u -r1.19.4.2 -r1.19.4.3 src/sys/dev/ic/mfi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/mfi.c
diff -u src/sys/dev/ic/mfi.c:1.19.4.2 src/sys/dev/ic/mfi.c:1.19.4.3
--- src/sys/dev/ic/mfi.c:1.19.4.2	Wed Jan 27 21:33:36 2010
+++ src/sys/dev/ic/mfi.c	Wed Jan 27 21:40:25 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.19.4.2 2010/01/27 21:33:36 sborrill Exp $ */
+/* $NetBSD: mfi.c,v 1.19.4.3 2010/01/27 21:40:25 sborrill Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom ma...@peereboom.us
@@ -17,7 +17,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mfi.c,v 1.19.4.2 2010/01/27 21:33:36 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: mfi.c,v 1.19.4.3 2010/01/27 21:40:25 sborrill Exp $);
 
 #include bio.h
 
@@ -1320,7 +1320,10 @@
 {
 	struct mfi_softc	*sc = (struct mfi_softc *)dev;
 	int error = 0;
-	int s = splbio();
+	int s;
+
+	KERNEL_LOCK(1, curlwp);
+	s = splbio();
 
 	DNPRINTF(MFI_D_IOCTL, %s: mfi_ioctl , DEVNAME(sc));
 
@@ -1360,6 +1363,7 @@
 		error = EINVAL;
 	}
 	splx(s);
+	KERNEL_UNLOCK_ONE(curlwp);
 
 	DNPRINTF(MFI_D_IOCTL, %s: mfi_ioctl return %x\n, DEVNAME(sc), error);
 	return error;



CVS commit: [netbsd-5] src/sys/dev/ic

2009-11-13 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Nov 13 20:57:27 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: hme.c

Log Message:
Pull up the following revisions(s) (requested by jakllsch in ticket #1133):
sys/dev/ic/hme.c:   revision 1.84 via patch

Use hme_init() to provide a non-NULL ifp-if_init.


To generate a diff of this commit:
cvs rdiff -u -r1.66.10.3 -r1.66.10.4 src/sys/dev/ic/hme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/hme.c
diff -u src/sys/dev/ic/hme.c:1.66.10.3 src/sys/dev/ic/hme.c:1.66.10.4
--- src/sys/dev/ic/hme.c:1.66.10.3	Fri May  1 01:56:16 2009
+++ src/sys/dev/ic/hme.c	Fri Nov 13 20:57:27 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hme.c,v 1.66.10.3 2009/05/01 01:56:16 snj Exp $	*/
+/*	$NetBSD: hme.c,v 1.66.10.4 2009/11/13 20:57:27 sborrill Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66.10.3 2009/05/01 01:56:16 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66.10.4 2009/11/13 20:57:27 sborrill Exp $);
 
 /* #define HMEDEBUG */
 
@@ -91,7 +91,7 @@
 void		hme_tick(void *);
 void		hme_watchdog(struct ifnet *);
 void		hme_shutdown(void *);
-int		hme_init(struct hme_softc *);
+int		hme_init(struct ifnet *);
 void		hme_meminit(struct hme_softc *);
 void		hme_mifinit(struct hme_softc *);
 void		hme_reset(struct hme_softc *);
@@ -238,6 +238,7 @@
 	ifp-if_softc = sc;
 	ifp-if_start = hme_start;
 	ifp-if_ioctl = hme_ioctl;
+	ifp-if_init = hme_init;
 	ifp-if_watchdog = hme_watchdog;
 	ifp-if_flags =
 	IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
@@ -338,7 +339,7 @@
 	int s;
 
 	s = splnet();
-	(void)hme_init(sc);
+	(void)hme_init(sc-sc_ethercom.ec_if);
 	splx(s);
 }
 
@@ -453,10 +454,10 @@
  * and transmit/receive descriptor rings.
  */
 int
-hme_init(sc)
-	struct hme_softc *sc;
+hme_init(ifp)
+	struct ifnet *ifp;
 {
-	struct ifnet *ifp = sc-sc_ethercom.ec_if;
+	struct hme_softc *sc = (struct hme_softc *)ifp-if_softc;
 	bus_space_tag_t t = sc-sc_bustag;
 	bus_space_handle_t seb = sc-sc_seb;
 	bus_space_handle_t etx = sc-sc_etx;
@@ -1402,14 +1403,14 @@
 hme_setladrf(sc);
 			else {
 ifp-if_flags |= IFF_UP;
-error = hme_init(sc);
+error = hme_init(ifp);
 			}
 			arp_ifinit(ifp, ifa);
 			break;
 #endif
 		default:
 			ifp-if_flags |= IFF_UP;
-			error = hme_init(sc);
+			error = hme_init(ifp);
 			break;
 		}
 		break;
@@ -1433,7 +1434,7 @@
 			 * If interface is marked up and it is stopped, then
 			 * start it.
 			 */
-			error = hme_init(sc);
+			error = hme_init(ifp);
 		} else if ((ifp-if_flags  IFF_UP) != 0) {
 			/*
 			 * If setting debug or promiscuous mode, do not reset
@@ -1446,13 +1447,13 @@
 == (sc-sc_if_flags  (~RESETIGN)))
 	hme_setladrf(sc);
 else
-	error = hme_init(sc);
+	error = hme_init(ifp);
 			}
 #undef RESETIGN
 		}
 
 		if (sc-sc_ec_capenable != sc-sc_ethercom.ec_capenable)
-			error = hme_init(sc);
+			error = hme_init(ifp);
 
 		break;
 



CVS commit: [netbsd-5] src/sys/dev/ic

2009-10-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Oct 18 16:39:13 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: wdc.c

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1074):
sys/dev/ic/wdc.c: revision 1.258
Commit patch from PR#41926. Confirmed to work by PR submitter on two
controllers as well myself and another on viaide.
Stops errors such as the following when probing SATA drives through
controllers that offer the legacy pciide interface:
viaide1 channel 0: reset failed for drive 0
OK bouyer@


To generate a diff of this commit:
cvs rdiff -u -r1.255.4.1 -r1.255.4.2 src/sys/dev/ic/wdc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/wdc.c
diff -u src/sys/dev/ic/wdc.c:1.255.4.1 src/sys/dev/ic/wdc.c:1.255.4.2
--- src/sys/dev/ic/wdc.c:1.255.4.1	Thu Nov 20 02:45:36 2008
+++ src/sys/dev/ic/wdc.c	Sun Oct 18 16:39:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc.c,v 1.255.4.1 2008/11/20 02:45:36 snj Exp $ */
+/*	$NetBSD: wdc.c,v 1.255.4.2 2009/10/18 16:39:13 bouyer Exp $ */
 
 /*
  * Copyright (c) 1998, 2001, 2003 Manuel Bouyer.  All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: wdc.c,v 1.255.4.1 2008/11/20 02:45:36 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: wdc.c,v 1.255.4.2 2009/10/18 16:39:13 bouyer Exp $);
 
 #include opt_ata.h
 
@@ -209,7 +209,7 @@
 wdc_sataprobe(struct ata_channel *chp)
 {
 	struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
-	uint16_t scnt, sn, cl, ch;
+	uint8_t st = 0, sc, sn, cl, ch;
 	int i, s;
 
 	/* XXX This should be done by other code. */
@@ -222,23 +222,34 @@
 	switch (sata_reset_interface(chp, wdr-sata_iot, wdr-sata_control,
 	wdr-sata_status)) {
 	case SStatus_DET_DEV:
-		bus_space_write_1(wdr-cmd_iot, wdr-cmd_iohs[wd_sdh], 0,
-		WDSD_IBM);
-		delay(10);	/* 400ns delay */
-		scnt = bus_space_read_2(wdr-cmd_iot,
+		/* wait 5s for BSY to clear */
+		for (i = 0; i  WDC_PROBE_WAIT * hz; i++) {
+			bus_space_write_1(wdr-cmd_iot,
+			wdr-cmd_iohs[wd_sdh], 0, WDSD_IBM);
+			delay(10);  /* 400ns delay */
+			st = bus_space_read_1(wdr-cmd_iot,
+			wdr-cmd_iohs[wd_status], 0);
+			if ((st  WDCS_BSY) == 0)
+break;
+			tsleep(chp, PRIBIO, sataprb, 1);
+		}
+		if (i == WDC_PROBE_WAIT * hz)
+			aprint_error_dev(chp-ch_atac-atac_dev,
+			BSY never cleared, status 0x%02x\n, st);
+		sc = bus_space_read_1(wdr-cmd_iot,
 		wdr-cmd_iohs[wd_seccnt], 0);
-		sn = bus_space_read_2(wdr-cmd_iot,
+		sn = bus_space_read_1(wdr-cmd_iot,
 		wdr-cmd_iohs[wd_sector], 0);
-		cl = bus_space_read_2(wdr-cmd_iot,
+		cl = bus_space_read_1(wdr-cmd_iot,
 		wdr-cmd_iohs[wd_cyl_lo], 0);
-		ch = bus_space_read_2(wdr-cmd_iot,
+		ch = bus_space_read_1(wdr-cmd_iot,
 		wdr-cmd_iohs[wd_cyl_hi], 0);
-		ATADEBUG_PRINT((%s: port %d: scnt=0x%x sn=0x%x 
+		ATADEBUG_PRINT((%s: port %d: sc=0x%x sn=0x%x 
 		cl=0x%x ch=0x%x\n,
 		device_xname(chp-ch_atac-atac_dev), chp-ch_channel,
-		scnt, sn, cl, ch), DEBUG_PROBE);
+		sc, sn, cl, ch), DEBUG_PROBE);
 		/*
-		 * scnt and sn are supposed to be 0x1 for ATAPI, but in some
+		 * sc and sn are supposed to be 0x1 for ATAPI, but in some
 		 * cases we get wrong values here, so ignore it.
 		 */
 		s = splbio();



CVS commit: [netbsd-5] src/sys/dev/ic

2009-09-27 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Sep 28 00:18:39 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: siisata.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.4
make this build w/o SIISATA_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.2.4.1 -r1.2.4.2 src/sys/dev/ic/siisata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/siisata.c
diff -u src/sys/dev/ic/siisata.c:1.2.4.1 src/sys/dev/ic/siisata.c:1.2.4.2
--- src/sys/dev/ic/siisata.c:1.2.4.1	Mon Sep 28 00:17:28 2009
+++ src/sys/dev/ic/siisata.c	Mon Sep 28 00:18:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.2.4.1 2009/09/28 00:17:28 snj Exp $ */
+/* $NetBSD: siisata.c,v 1.2.4.2 2009/09/28 00:18:39 snj Exp $ */
 
 /* from ahcisata_core.c */
 
@@ -876,8 +876,10 @@
 int
 siisata_cmd_complete(struct ata_channel *chp, struct ata_xfer *xfer, int slot)
 {
-	struct siisata_softc *sc = (struct siisata_softc *)chp-ch_atac;
 	struct ata_command *ata_c = xfer-c_cmd;
+#ifdef SIISATA_DEBUG
+	struct siisata_softc *sc = (struct siisata_softc *)chp-ch_atac;
+#endif
 	
 	SIISATA_DEBUG_PRINT(
 	(%s: %s\n, SIISATANAME(sc), __func__), DEBUG_FUNCS);



CVS commit: [netbsd-5] src/sys/dev/ic

2009-09-27 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Sep 28 00:19:37 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: siisata.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.5
Use PRO_PS and PRO_PCS correctly.
From Wolfgang Stukenbrock as part of kern/41579.
While here, remove a line of whitespace, and add an else case to
the ATAPI command length toggle.


To generate a diff of this commit:
cvs rdiff -u -r1.2.4.2 -r1.2.4.3 src/sys/dev/ic/siisata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/siisata.c
diff -u src/sys/dev/ic/siisata.c:1.2.4.2 src/sys/dev/ic/siisata.c:1.2.4.3
--- src/sys/dev/ic/siisata.c:1.2.4.2	Mon Sep 28 00:18:39 2009
+++ src/sys/dev/ic/siisata.c	Mon Sep 28 00:19:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.2.4.2 2009/09/28 00:18:39 snj Exp $ */
+/* $NetBSD: siisata.c,v 1.2.4.3 2009/09/28 00:19:37 snj Exp $ */
 
 /* from ahcisata_core.c */
 
@@ -524,7 +524,7 @@
 	wait = wait ? wait : 1;
 
 	/* wait for ready */
-	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PCS))  PR_PS_PORT_READY))
+	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PS))  PR_PS_PORT_READY))
 		DELAY(10);
 
 	prb = schp-sch_prb[slot];
@@ -593,7 +593,7 @@
 		/* XXX and then ? */
 	}
 	/* wait for ready */
-	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PCS))  PR_PS_PORT_READY))
+	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PS))  PR_PS_PORT_READY))
 		DELAY(10);
 	PRWRITE(sc, PRX(chp-ch_channel, PRO_SERROR),
 	PRREAD(sc, PRX(chp-ch_channel, PRO_SERROR)));
@@ -656,7 +656,7 @@
 		schp-sch_sstatus)) {
 	case SStatus_DET_DEV:
 		/* wait for ready */
-		while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PCS))
+		while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PS))
 		 PR_PS_PORT_READY))
 			DELAY(10);
 
@@ -890,7 +890,6 @@
 	else
 		callout_stop(chp-ch_callout);
 
-
 	if (chp-ch_drive[xfer-c_drive].drive_flags  DRIVE_WAITDRAIN) {
 		siisata_cmd_kill_xfer(chp, xfer, KILL_GONE);
 		chp-ch_drive[xfer-c_drive].drive_flags = ~DRIVE_WAITDRAIN;
@@ -1254,9 +1253,8 @@
 {
 	struct siisata_softc *sc = (struct siisata_softc *)chp-ch_atac;
 
-	PRWRITE(sc, PRX(chp-ch_channel, PRO_PCS),
-	PRREAD(sc, PRX(chp-ch_channel, PRO_PCS)) | PR_PC_PORT_INITIALIZE);
-	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PCS))  PR_PS_PORT_READY))
+	PRWRITE(sc, PRX(chp-ch_channel, PRO_PCS), PR_PC_PORT_INITIALIZE);
+	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PS))  PR_PS_PORT_READY))
 		DELAY(10);
 }
 
@@ -1265,9 +1263,8 @@
 {
 	struct siisata_softc *sc = (struct siisata_softc *)chp-ch_atac;
 
-	PRWRITE(sc, PRX(chp-ch_channel, PRO_PCS),
-	PRREAD(sc, PRX(chp-ch_channel, PRO_PCS)) | PR_PC_DEVICE_RESET);
-	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PCS))  PR_PS_PORT_READY))
+	PRWRITE(sc, PRX(chp-ch_channel, PRO_PCS), PR_PC_DEVICE_RESET);
+	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PS))  PR_PS_PORT_READY))
 		DELAY(10);
 }
 
@@ -1441,9 +1438,12 @@
 		
 			/* configure port for packet length */
 			PRWRITE(siic, PRX(chp-ch_channel, PRO_PCS),
-			PRREAD(siic, PRX(chp-ch_channel, PRO_PCS)) |
+			PR_PC_PACKET_LENGTH);
+		} else {
+			PRWRITE(siic, PRX(chp-ch_channel, PRO_PCC),
 			PR_PC_PACKET_LENGTH);
 		}
+
 		/* XXX This is gross. */
 		periph-periph_cap |= (id-atap_config  ATAPI_CFG_DRQ_MASK);
 



CVS commit: [netbsd-5] src/sys/dev/ic

2009-09-27 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Sep 28 00:21:13 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: siisata.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.6
Correct various siisata bugs, some old, some new.
 - Move clearing of interrupts to before atastart() is called in the
   xfer interrupt handler.  Should fix kern/41579.
 - Using cv_timedwait(9) is not possible in code that can be called from
   interrupt context, fall back to DELAY(9).
 - Correctly poll Port Slot Status register for soft reset PRBs.
 - Only use the Recive Transfer Count register on reads, when it is valid.
 - Activate PRBs in a way that takes the whole physical address into account,
   even when the PRB is beyond 4GiB.
 - consistently use DELAY(9)
 - Use DELAY() constants in completion polling loops that are consistent with
   the loop count limit. (i.e. timeout in 10 rather than 100 seconds)


To generate a diff of this commit:
cvs rdiff -u -r1.2.4.3 -r1.2.4.4 src/sys/dev/ic/siisata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/siisata.c
diff -u src/sys/dev/ic/siisata.c:1.2.4.3 src/sys/dev/ic/siisata.c:1.2.4.4
--- src/sys/dev/ic/siisata.c:1.2.4.3	Mon Sep 28 00:19:37 2009
+++ src/sys/dev/ic/siisata.c	Mon Sep 28 00:21:13 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.2.4.3 2009/09/28 00:19:37 snj Exp $ */
+/* $NetBSD: siisata.c,v 1.2.4.4 2009/09/28 00:21:13 snj Exp $ */
 
 /* from ahcisata_core.c */
 
@@ -494,13 +494,13 @@
 		}
 	}
 
+	/* clear some (ok, all) ints */
+	PRWRITE(sc, PRX(chp-ch_channel, PRO_PIS), 0x);
+
 	KASSERT(xfer != NULL);
 	KASSERT(xfer-c_intr != NULL);
 	xfer-c_intr(chp, xfer, slot);
 
-	/* clear some (ok, all) ints */
-	PRWRITE(sc, PRX(chp-ch_channel, PRO_PIS), 0x);
-
 	return;
 }
 
@@ -511,17 +511,8 @@
 	struct siisata_softc *sc = (struct siisata_softc *)chp-ch_atac;
 	struct siisata_channel *schp = (struct siisata_channel *)chp;
 	struct siisata_prb *prb;
-	kmutex_t mtx;
-	kcondvar_t cv;
 	int slot = SIISATA_NON_NCQ_SLOT;
 	int i;
-	int wait;
-
-	mutex_init(mtx, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(cv, siipd);
-
-	wait = mstohz(10);
-	wait = wait ? wait : 1;
 
 	/* wait for ready */
 	while (!(PRREAD(sc, PRX(chp-ch_channel, PRO_PS))  PR_PS_PORT_READY))
@@ -534,18 +525,18 @@
 
 	siisata_activate_prb(schp, slot);
 
-	for(i = 0; i  (31000/(1000/(wait*hz))); i++) {
+	for(i = 0; i  31000; i++) {
 		if (PRREAD(sc, PRX(chp-ch_channel, PRO_PSS)) 
 		PR_PXSS(slot))
-			break;
+			DELAY(1000);
 		else
-			cv_timedwait(cv, mtx, wait);
+			break;
 	}
 
 	siisata_deactivate_prb(schp, slot);
 
-	log(LOG_DEBUG, %s: ch_status %x ch_error %x\n,
-	__func__, chp-ch_status, chp-ch_error);
+	log(LOG_DEBUG, %s: port %d: ch_status %x ch_error %x\n,
+	__func__, chp-ch_channel, chp-ch_status, chp-ch_error);
 
 #if 1
 	/* attempt to downgrade signaling in event of CRC error */
@@ -571,9 +562,6 @@
 	chp-ch_error = 0;
 #endif
 
-	cv_destroy(cv);
-	mutex_destroy(mtx);
-
 	return;
 }
 
@@ -633,9 +621,6 @@
 	uint32_t sig;
 	int slot = SIISATA_NON_NCQ_SLOT;
 	struct siisata_prb *prb;
-	kmutex_t mtx;
-	kcondvar_t cv;
-	int wait;
 
 	SIISATA_DEBUG_PRINT((%s: %s: port %d start\n, SIISATANAME(sc),
 	__func__, chp-ch_channel), DEBUG_FUNCS);
@@ -646,12 +631,6 @@
 		chp-ch_drive[i].drive = i;
 	}
 
-	mutex_init(mtx, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(cv, siipd);
-
-	wait = mstohz(10);
-	wait = wait ? wait : 1;
-
 	switch (sata_reset_interface(chp, sc-sc_prt, schp-sch_scontrol,
 		schp-sch_sstatus)) {
 	case SStatus_DET_DEV:
@@ -667,12 +646,12 @@
 
 		siisata_activate_prb(schp, slot);
 
-		for(i = 0; i  (31000/(1000/(wait*hz))); i++) {
+		for(i = 0; i  31000; i++) {
 			if (PRREAD(sc, PRX(chp-ch_channel, PRO_PSS)) 
 			PR_PXSS(slot))
-break;
+DELAY(1000);
 			else
-cv_timedwait(cv, mtx, wait);
+break;
 		}
 
 		siisata_deactivate_prb(schp, slot);
@@ -714,9 +693,6 @@
 		break;
 	}
 
-	cv_destroy(cv);
-	mutex_destroy(mtx);
-
 	SIISATA_DEBUG_PRINT((%s: %s: port %d done\n, SIISATANAME(sc),
 	__func__, chp-ch_channel), DEBUG_PROBE);
 	return;
@@ -836,7 +812,7 @@
 		if (ata_c-flags  AT_DONE)
 			break;
 		siisata_intr_port(schp);
-		DELAY(1);
+		DELAY(1000);
 	}
 
 	if ((ata_c-flags  AT_DONE) == 0) {
@@ -1038,7 +1014,7 @@
 		if (ata_bio-flags  ATA_ITSDONE)
 			break;
 		siisata_intr_port(schp);
-		DELAY(1);
+		DELAY(1000);
 	}
 
 	GRWRITE(sc, GR_GC, GRREAD(sc, GR_GC) | GR_GC_PXIE(chp-ch_channel));
@@ -1123,9 +1099,13 @@
 
 	SIISATA_DEBUG_PRINT((%s: %s bcount: %ld, SIISATANAME(sc),
 	__func__, ata_bio-bcount), DEBUG_XFERS); 
-	if ((ata_bio-flags  ATA_READ) || (ata_bio-error == NOERROR))
-		ata_bio-bcount -= PRREAD(sc,
-		PRSX(chp-ch_channel, slot, PRSO_RTC));
+	if (ata_bio-error == NOERROR) {
+		if (ata_bio-flags  ATA_READ)
+			ata_bio-bcount -=
+			PRREAD(sc, 

CVS commit: [netbsd-5] src/sys/dev/ic

2009-09-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Sep 10 07:06:34 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: mfi.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #931):
sys/dev/ic/mfi.c: revision 1.28 via patch
mfi.c still uses the spl() synchronisation scheme and so needs the kernel lock.
The sysmon subsystem is marked MPSAFE and so runs without the kernel lock.
So get the kernel lock in mfi_sensor_refresh() before calling mfi_ioctl_vol().
This fixes command list corruption seen on heavy I/O load on the mfi driver(4).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/dev/ic/mfi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/mfi.c
diff -u src/sys/dev/ic/mfi.c:1.19 src/sys/dev/ic/mfi.c:1.19.4.1
--- src/sys/dev/ic/mfi.c:1.19	Thu Oct 23 21:00:06 2008
+++ src/sys/dev/ic/mfi.c	Thu Sep 10 07:06:34 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.19 2008/10/23 21:00:06 bouyer Exp $ */
+/* $NetBSD: mfi.c,v 1.19.4.1 2009/09/10 07:06:34 snj Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom ma...@peereboom.us
@@ -17,7 +17,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mfi.c,v 1.19 2008/10/23 21:00:06 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: mfi.c,v 1.19.4.1 2009/09/10 07:06:34 snj Exp $);
 
 #include bio.h
 
@@ -1930,18 +1930,20 @@
 	struct mfi_softc	*sc = sme-sme_cookie;
 	struct bioc_vol		bv;
 	int s;
+	int error;
 
 	if (edata-sensor = sc-sc_ld_cnt)
 		return;
 
 	bzero(bv, sizeof(bv));
 	bv.bv_volid = edata-sensor;
+	KERNEL_LOCK(1, curlwp);
 	s = splbio();
-	if (mfi_ioctl_vol(sc, bv)) {
-		splx(s);
-		return;
-	}
+	error = mfi_ioctl_vol(sc, bv);
 	splx(s);
+	KERNEL_UNLOCK_ONE(curlwp);
+	if (error)
+		return;
 
 	switch(bv.bv_status) {
 	case BIOC_SVOFFLINE:



CVS commit: [netbsd-5] src/sys/dev/ic

2009-08-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Aug 14 21:37:03 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: i82365.c

Log Message:
Pull up following revision(s) (requested by jun in ticket #899):
sys/dev/ic/i82365.c: revision 1.108
fix pcic kthread creation timing.
see http://mail-index.netbsd.org/current-users/2008/07/15/msg003526.html
fix kern/41791  port-hpcmips/41164.
ok by uwe  tsutsui


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.102.14.1 src/sys/dev/ic/i82365.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/i82365.c
diff -u src/sys/dev/ic/i82365.c:1.102 src/sys/dev/ic/i82365.c:1.102.14.1
--- src/sys/dev/ic/i82365.c:1.102	Tue Apr  8 12:07:26 2008
+++ src/sys/dev/ic/i82365.c	Fri Aug 14 21:37:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82365.c,v 1.102 2008/04/08 12:07:26 cegger Exp $	*/
+/*	$NetBSD: i82365.c,v 1.102.14.1 2009/08/14 21:37:03 snj Exp $	*/
 
 /*
  * Copyright (c) 2004 Charles M. Hannum.  All rights reserved.
@@ -49,7 +49,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: i82365.c,v 1.102 2008/04/08 12:07:26 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: i82365.c,v 1.102.14.1 2009/08/14 21:37:03 snj Exp $);
 
 #define	PCICDEBUG
 
@@ -397,7 +397,6 @@
 	struct pcmciabus_attach_args paa;
 	struct pcic_softc *sc = (struct pcic_softc *)h-ph_parent;
 	int locs[PCMCIABUSCF_NLOCS];
-	char cs[4];
 
 	/* initialize the rest of the handle */
 
@@ -424,21 +423,6 @@
 		return;
 	}
 
-	/*
-	 * queue creation of a kernel thread to handle insert/removal events.
-	 */
-#ifdef DIAGNOSTIC
-	if (h-event_thread != NULL)
-		panic(pcic_attach_socket: event thread);
-#endif
-	config_pending_incr();
-	snprintf(cs, sizeof(cs), %d,%d, h-chip, h-socket);
-
-	if (kthread_create(PRI_NONE, 0, NULL, pcic_event_thread, h,
-	h-event_thread, %s,%s, device_xname(h-ph_parent), cs)) {
-		aprint_error_dev(h-ph_parent, unable to create event thread for sock 0x%02x\n, h-sock);
-		panic(pcic_attach_socket);
-	}
 }
 
 /*
@@ -466,6 +450,7 @@
 {
 	struct pcic_softc *sc = (struct pcic_softc *)h-ph_parent;
 	int reg;
+	char cs[4];
 
 	DPRINTF((%s: attach finish socket %ld\n, device_xname(h-ph_parent),
 	(long) (h - sc-handle[0])));
@@ -520,6 +505,22 @@
 	} else {
 		h-laststate = PCIC_LASTSTATE_EMPTY;
 	}
+
+	/*
+	 * queue creation of a kernel thread to handle insert/removal events.
+	 */
+#ifdef DIAGNOSTIC
+	if (h-event_thread != NULL)
+		panic(pcic_attach_socket: event thread);
+#endif
+	config_pending_incr();
+	snprintf(cs, sizeof(cs), %d,%d, h-chip, h-socket);
+
+	if (kthread_create(PRI_NONE, 0, NULL, pcic_event_thread, h,
+	h-event_thread, %s,%s, device_xname(h-ph_parent), cs)) {
+		aprint_error_dev(h-ph_parent, unable to create event thread for sock 0x%02x\n, h-sock);
+		panic(pcic_attach_socket);
+	}
 }
 
 void



CVS commit: [netbsd-5] src/sys/dev/ic

2009-08-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Aug  7 06:48:10 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: ath.c athvar.h

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #775):
sys/dev/ic/ath.c: revision 1.106
sys/dev/ic/athvar.h: revision 1.28
- fix TKIP, changes adapted from FreeBSD
- reduce diffs between FreeBSD and NetBSD athvar.h


To generate a diff of this commit:
cvs rdiff -u -r1.102.4.1 -r1.102.4.2 src/sys/dev/ic/ath.c
cvs rdiff -u -r1.25.4.1 -r1.25.4.2 src/sys/dev/ic/athvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ath.c
diff -u src/sys/dev/ic/ath.c:1.102.4.1 src/sys/dev/ic/ath.c:1.102.4.2
--- src/sys/dev/ic/ath.c:1.102.4.1	Fri Aug  7 06:43:27 2009
+++ src/sys/dev/ic/ath.c	Fri Aug  7 06:48:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ath.c,v 1.102.4.1 2009/08/07 06:43:27 snj Exp $	*/
+/*	$NetBSD: ath.c,v 1.102.4.2 2009/08/07 06:48:09 snj Exp $	*/
 
 /*-
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -41,7 +41,7 @@
 __FBSDID($FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $);
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, $NetBSD: ath.c,v 1.102.4.1 2009/08/07 06:43:27 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: ath.c,v 1.102.4.2 2009/08/07 06:48:09 snj Exp $);
 #endif
 
 /*
@@ -520,28 +520,40 @@
 		 * separate key cache entries are required to
 		 * handle both tx+rx MIC keys.
 		 */
-		if (ath_hal_ciphersupported(ah, HAL_CIPHER_MIC)) {
+		if (ath_hal_ciphersupported(ah, HAL_CIPHER_MIC))
 			ic-ic_caps |= IEEE80211_C_TKIPMIC;
-			/*
-			 * Check if h/w does MIC correctly when
-			 * WMM is turned on.
-			 */
-			if (ath_hal_wmetkipmic(ah))
-ic-ic_caps |= IEEE80211_C_WME_TKIPMIC;
-		}
 
 		/*
 		 * If the h/w supports storing tx+rx MIC keys
 		 * in one cache slot automatically enable use.
 		 */
-		if (ath_hal_tkipsplit(ah) ||
+		if (ath_hal_hastkipsplit(ah) ||
 		!ath_hal_settkipsplit(ah, AH_FALSE))
 			sc-sc_splitmic = 1;
+
+		/*
+		 * If the h/w can do TKIP MIC together with WME then
+		 * we use it; otherwise we force the MIC to be done
+		 * in software by the net80211 layer.
+		 */
+		if (ath_hal_haswmetkipmic(ah))
+			ic-ic_caps |= IEEE80211_C_WME_TKIPMIC;
 	}
 	sc-sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR);
-#if 0
 	sc-sc_mcastkey = ath_hal_getmcastkeysearch(ah);
-#endif
+	/*
+	 * Mark key cache slots associated with global keys
+	 * as in use.  If we knew TKIP was not to be used we
+	 * could leave the +32, +64, and +32+64 slots free.
+	 */
+	for (i = 0; i  IEEE80211_WEP_NKID; i++) {
+		setbit(sc-sc_keymap, i);
+		setbit(sc-sc_keymap, i+64);
+		if (sc-sc_splitmic) {
+			setbit(sc-sc_keymap, i+32);
+			setbit(sc-sc_keymap, i+32+64);
+		}
+	}
 	/*
 	 * TPC support can be done either with a global cap or
 	 * per-packet support.  The latter is not available on
@@ -948,6 +960,24 @@
 	return ath_init(sc);
 }
 
+static void
+ath_settkipmic(struct ath_softc *sc)
+{
+	struct ieee80211com *ic = sc-sc_ic;
+	struct ath_hal *ah = sc-sc_ah;
+
+	if ((ic-ic_caps  IEEE80211_C_TKIP) 
+	!(ic-ic_caps  IEEE80211_C_WME_TKIPMIC)) {
+		if (ic-ic_flags  IEEE80211_F_WME) {
+			(void)ath_hal_settkipmic(ah, AH_FALSE);
+			ic-ic_caps = ~IEEE80211_C_TKIPMIC;
+		} else {
+			(void)ath_hal_settkipmic(ah, AH_TRUE);
+			ic-ic_caps |= IEEE80211_C_TKIPMIC;
+		}
+	}
+}
+
 static int
 ath_init(struct ath_softc *sc)
 {
@@ -973,17 +1003,6 @@
 	 */
 	ath_stop_locked(ifp, 0);
 
-	int dummy;	/* XXX: gcc */
-	/* Whether we should enable h/w TKIP MIC */
-	if ((ic-ic_caps  IEEE80211_C_WME) 
-	((ic-ic_caps  IEEE80211_C_WME_TKIPMIC) ||
-	!(ic-ic_flags  IEEE80211_F_WME))) {
-		dummy = ath_hal_settkipmic(ah, AH_TRUE);
-	} else {
-		dummy = ath_hal_settkipmic(ah, AH_FALSE);
-	}
-
-
 	/*
 	 * The basic interface to setting the hardware in a good
 	 * state is ``reset''.  On return the hardware is known to
@@ -991,6 +1010,7 @@
 	 * be followed by initialization of the appropriate bits
 	 * and then setup of the interrupt mask.
 	 */
+	ath_settkipmic(sc);
 	sc-sc_curchan.channel = ic-ic_curchan-ic_freq;
 	sc-sc_curchan.channelFlags = ath_chan2flags(ic, ic-ic_curchan);
 	if (!ath_hal_reset(ah, ic-ic_opmode, sc-sc_curchan, AH_FALSE, status)) {
@@ -1170,6 +1190,7 @@
 	ath_hal_intrset(ah, 0);		/* disable interrupts */
 	ath_draintxq(sc);		/* stop xmit side */
 	ath_stoprecv(sc);		/* stop recv side */
+	ath_settkipmic(sc);		/* configure TKIP MIC handling */
 	/* NB: indicate channel change so we do a full reset */
 	if (!ath_hal_reset(ah, ic-ic_opmode, sc-sc_curchan, AH_TRUE, status))
 		if_printf(ifp, %s: unable to reset hardware; hal status %u\n,
@@ -1512,21 +1533,25 @@
 			 * will handle the reset.
 			 */
 			memcpy(hk-kv_mic, k-wk_rxmic, sizeof(hk-kv_mic));
-#if HAL_ABI_VERSION  0x06052200
 			memcpy(hk-kv_txmic, k-wk_txmic, sizeof(hk-kv_txmic));
-#endif
 			KEYPRINTF(sc, k-wk_keyix, hk, mac);
 			

CVS commit: [netbsd-5] src/sys/dev/ic

2009-05-03 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun May  3 13:34:25 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: ncr53c9x.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #734):
sys/dev/ic/ncr53c9x.c: revision 1.138
Add missing braces - patch from Kurt Lidl in PR port-vax/41314.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.137.8.1 src/sys/dev/ic/ncr53c9x.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ncr53c9x.c
diff -u src/sys/dev/ic/ncr53c9x.c:1.137 src/sys/dev/ic/ncr53c9x.c:1.137.8.1
--- src/sys/dev/ic/ncr53c9x.c:1.137	Tue May 13 22:16:27 2008
+++ src/sys/dev/ic/ncr53c9x.c	Sun May  3 13:34:25 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ncr53c9x.c,v 1.137 2008/05/13 22:16:27 christos Exp $	*/
+/*	$NetBSD: ncr53c9x.c,v 1.137.8.1 2009/05/03 13:34:25 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ncr53c9x.c,v 1.137 2008/05/13 22:16:27 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: ncr53c9x.c,v 1.137.8.1 2009/05/03 13:34:25 bouyer Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -469,13 +469,14 @@
 ecb-xs-error = result;
 ncr53c9x_done(sc, ecb);
 			}
-			for (i = 0; i  256; i++)
+			for (i = 0; i  256; i++) {
 ecb = li-queued[i];
 if (ecb != NULL) {
 	li-queued[i] = NULL;
 	ecb-xs-error = result;
 	ncr53c9x_done(sc, ecb);
 }
+			}
 			li-used = 0;
 		}
 	}



CVS commit: [netbsd-5] src/sys/dev/ic

2009-04-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May  1 01:52:56 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: hme.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #595):
sys/dev/ic/hme.c: revision 1.69
Add an `else' missed in rev 1.49 otherwise RX hardware checksum on hme(4)
is not activated at all. Ok'ed by christos@, tested on macppc.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.66.10.1 src/sys/dev/ic/hme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/hme.c
diff -u src/sys/dev/ic/hme.c:1.66 src/sys/dev/ic/hme.c:1.66.10.1
--- src/sys/dev/ic/hme.c:1.66	Sun May  4 17:06:09 2008
+++ src/sys/dev/ic/hme.c	Fri May  1 01:52:56 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hme.c,v 1.66 2008/05/04 17:06:09 xtraeme Exp $	*/
+/*	$NetBSD: hme.c,v 1.66.10.1 2009/05/01 01:52:56 snj Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66 2008/05/04 17:06:09 xtraeme Exp $);
+__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66.10.1 2009/05/01 01:52:56 snj Exp $);
 
 /* #define HMEDEBUG */
 
@@ -836,7 +836,7 @@
 		}
 
 		m0-m_pkthdr.csum_flags |= M_CSUM_DATA | M_CSUM_NO_PSEUDOHDR;
-	}
+	} else
 swcsum:
 		m0-m_pkthdr.csum_flags = 0;
 #endif



CVS commit: [netbsd-5] src/sys/dev/ic

2009-04-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May  1 01:54:09 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: hme.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #595):
sys/dev/ic/hme.c: revision 1.70
Replace incorrect local ether_cmp() function with memcmp(9)
on checking multicast addresses, which is not so critical.
Noticed by FUKAUMI Naoki.


To generate a diff of this commit:
cvs rdiff -u -r1.66.10.1 -r1.66.10.2 src/sys/dev/ic/hme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/hme.c
diff -u src/sys/dev/ic/hme.c:1.66.10.1 src/sys/dev/ic/hme.c:1.66.10.2
--- src/sys/dev/ic/hme.c:1.66.10.1	Fri May  1 01:52:56 2009
+++ src/sys/dev/ic/hme.c	Fri May  1 01:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hme.c,v 1.66.10.1 2009/05/01 01:52:56 snj Exp $	*/
+/*	$NetBSD: hme.c,v 1.66.10.2 2009/05/01 01:54:09 snj Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66.10.1 2009/05/01 01:52:56 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66.10.2 2009/05/01 01:54:09 snj Exp $);
 
 /* #define HMEDEBUG */
 
@@ -111,8 +111,6 @@
 int		hme_rint(struct hme_softc *);
 int		hme_tint(struct hme_softc *);
 
-static int	ether_cmp(u_char *, u_char *);
-
 /* Default buffer copy routines */
 void	hme_copytobuf_contig(struct hme_softc *, void *, int, int);
 void	hme_copyfrombuf_contig(struct hme_softc *, void *, int, int);
@@ -642,22 +640,6 @@
 }
 
 /*
- * Compare two Ether/802 addresses for equality, inlined and unrolled for
- * speed.
- */
-static inline int
-ether_cmp(a, b)
-	u_char *a, *b;
-{
-
-	if (a[5] != b[5] || a[4] != b[4] || a[3] != b[3] ||
-	a[2] != b[2] || a[1] != b[1] || a[0] != b[0])
-		return (0);
-	return (1);
-}
-
-
-/*
  * Routine to copy from mbuf chain to transmit buffer in
  * network buffer memory.
  * Returns the amount of data copied.
@@ -1553,7 +1535,7 @@
 
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
-		if (ether_cmp(enm-enm_addrlo, enm-enm_addrhi)) {
+		if (memcmp(enm-enm_addrlo, enm-enm_addrhi, ETHER_ADDR_LEN)) {
 			/*
 			 * We must listen to a range of multicast addresses.
 			 * For now, just accept all multicasts, rather than



CVS commit: [netbsd-5] src/sys/dev/ic

2009-04-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May  1 01:56:16 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: gem.c hme.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #595):
sys/dev/ic/gem.c: revision 1.83
sys/dev/ic/hme.c: revision 1.73
Fix a bug in calculation of checksum deduction:
- To get 16 bit one's complement value from uint32_t variable,
  higher 16 bits should be ignored.
- RFC 1624 describes methods to recalculate checksum field in headers,
  i.e. one's complement of one's complement sum that could be 0x,
  but we don't have to use the strategy to deduct one's complement sum
  itself which won't be zero but should be 0x.
Found on debugging mec(4) on sgimips O2.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.4.1 src/sys/dev/ic/gem.c
cvs rdiff -u -r1.66.10.2 -r1.66.10.3 src/sys/dev/ic/hme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/gem.c
diff -u src/sys/dev/ic/gem.c:1.78 src/sys/dev/ic/gem.c:1.78.4.1
--- src/sys/dev/ic/gem.c:1.78	Mon Sep 15 19:50:28 2008
+++ src/sys/dev/ic/gem.c	Fri May  1 01:56:16 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.78 2008/09/15 19:50:28 jdc Exp $ */
+/*	$NetBSD: gem.c,v 1.78.4.1 2009/05/01 01:56:16 snj Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gem.c,v 1.78 2008/09/15 19:50:28 jdc Exp $);
+__KERNEL_RCSID(0, $NetBSD: gem.c,v 1.78.4.1 2009/05/01 01:56:16 snj Exp $);
 
 #include opt_inet.h
 #include bpfilter.h
@@ -1853,9 +1853,8 @@
 	optsum = (optsum  16) +
 		 (optsum  0x);
 
-/* Deduct ip opts sum from hwsum (rfc 1624). */
-m-m_pkthdr.csum_data =
-	~((~m-m_pkthdr.csum_data) - ~optsum);
+/* Deduct ip opts sum from hwsum. */
+m-m_pkthdr.csum_data += (uint16_t)~optsum;
 
 while (m-m_pkthdr.csum_data  16)
 	m-m_pkthdr.csum_data =

Index: src/sys/dev/ic/hme.c
diff -u src/sys/dev/ic/hme.c:1.66.10.2 src/sys/dev/ic/hme.c:1.66.10.3
--- src/sys/dev/ic/hme.c:1.66.10.2	Fri May  1 01:54:09 2009
+++ src/sys/dev/ic/hme.c	Fri May  1 01:56:16 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hme.c,v 1.66.10.2 2009/05/01 01:54:09 snj Exp $	*/
+/*	$NetBSD: hme.c,v 1.66.10.3 2009/05/01 01:56:16 snj Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66.10.2 2009/05/01 01:54:09 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: hme.c,v 1.66.10.3 2009/05/01 01:56:16 snj Exp $);
 
 /* #define HMEDEBUG */
 
@@ -807,9 +807,8 @@
 			while (optsum  16)
 optsum = (optsum  16) + (optsum  0x);
 
-			/* Deduct the ip opts sum from the hwsum (rfc 1624). */
-			m0-m_pkthdr.csum_data = ~((~m0-m_pkthdr.csum_data) -
-		   ~optsum);
+			/* Deduct the ip opts sum from the hwsum. */
+			m0-m_pkthdr.csum_data += (uint16_t)~optsum;
 
 			while (m0-m_pkthdr.csum_data  16)
 m0-m_pkthdr.csum_data =



CVS commit: [netbsd-5] src/sys/dev/ic

2009-04-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May  1 02:07:04 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: rtl8169.c rtl81x9var.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.110
sys/dev/ic/rtl81x9var.h: revision 1.44
Add and use a new quirk flag to disable JUMBO MTU,
rather than checking sc_rev values.


To generate a diff of this commit:
cvs rdiff -u -r1.105.4.3 -r1.105.4.4 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.41.12.2 -r1.41.12.3 src/sys/dev/ic/rtl81x9var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.105.4.3 src/sys/dev/ic/rtl8169.c:1.105.4.4
--- src/sys/dev/ic/rtl8169.c:1.105.4.3	Fri May  1 02:03:44 2009
+++ src/sys/dev/ic/rtl8169.c	Fri May  1 02:07:04 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.105.4.3 2009/05/01 02:03:44 snj Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.105.4.4 2009/05/01 02:07:04 snj Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.3 2009/05/01 02:03:44 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.4 2009/05/01 02:07:04 snj Exp $);
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -589,33 +589,52 @@
 			break;
 		case RTK_HWREV_8101E:
 			sc-sc_rev = 11;
+			sc-sc_quirk |= RTKQ_NOJUMBO;
 			break;
 		case RTK_HWREV_8168_SPIN1:
 			sc-sc_rev = 21;
 			sc-sc_quirk |= RTKQ_DESCV2;
+			/*
+			 * From FreeBSD driver:
+			 * 
+			 * These (8168/8111) controllers support jumbo frame
+			 * but it seems that enabling it requires touching
+			 * additional magic registers. Depending on MAC
+			 * revisions some controllers need to disable
+			 * checksum offload. So disable jumbo frame until
+			 * I have better idea what it really requires to
+			 * make it support.
+			 * RTL8168C/CP : supports up to 6KB jumbo frame.
+			 * RTL8111C/CP : supports up to 9KB jumbo frame.
+			 */
+			sc-sc_quirk |= RTKQ_NOJUMBO;
 			break;
 		case RTK_HWREV_8168_SPIN2:
 			sc-sc_rev = 22;
 			sc-sc_quirk |= RTKQ_DESCV2;
+			sc-sc_quirk |= RTKQ_NOJUMBO;	/* see above */
 			break;
 		case RTK_HWREV_8168_SPIN3:
 			sc-sc_rev = 23;
 			sc-sc_quirk |= RTKQ_DESCV2;
+			sc-sc_quirk |= RTKQ_NOJUMBO;	/* see above */
 			break;
 		case RTK_HWREV_8168C:
 		case RTK_HWREV_8168C_SPIN2:
 			sc-sc_rev = 24;
 			sc-sc_quirk |= RTKQ_DESCV2;
+			sc-sc_quirk |= RTKQ_NOJUMBO;	/* see above */
 			break;
 		case RTK_HWREV_8102E:
 		case RTK_HWREV_8102EL:
 			sc-sc_rev = 25;
-			sc-sc_quirk |= RTKQ_DESCV2;
+			sc-sc_quirk |= RTKQ_DESCV2 | RTKQ_NOJUMBO;
 			break;
 		case RTK_HWREV_8100E:
 		case RTK_HWREV_8100E_SPIN2:
 			/* XXX not in the Realtek driver */
 			sc-sc_rev = 0;
+			sc-sc_quirk |= RTKQ_NOJUMBO;
 			break;
 		default:
 			aprint_normal_dev(sc-sc_dev,
@@ -627,6 +646,8 @@
 		sc-re_rxlenmask = RE_RDESC_STAT_GFRAGLEN;
 		sc-re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8169;
 	} else {
+		sc-sc_quirk |= RTKQ_NOJUMBO;
+
 		/* Set RX length mask */
 		sc-re_rxlenmask = RE_RDESC_STAT_FRAGLEN;
 		sc-re_ldata.re_tx_desc_cnt = RE_TX_DESC_CNT_8139;
@@ -1892,13 +1913,9 @@
 	switch (command) {
 	case SIOCSIFMTU:
 		/*
-		 * According to FreeBSD, 8102E/8102EL use a different DMA
-		 * descriptor format. 8168C/8111C requires touching additional
-		 * magic registers.
-		 *
-		 * Disable jumbo frames for those parts.
+		 * Disable jumbo frames if it's not supported.
 		 */
-		if ((sc-sc_rev == 24 || sc-sc_rev == 25) 
+		if ((sc-sc_quirk  RTKQ_NOJUMBO) != 0 
 		ifr-ifr_mtu  ETHERMTU) {
 			error = EINVAL;
 			break;

Index: src/sys/dev/ic/rtl81x9var.h
diff -u src/sys/dev/ic/rtl81x9var.h:1.41.12.2 src/sys/dev/ic/rtl81x9var.h:1.41.12.3
--- src/sys/dev/ic/rtl81x9var.h:1.41.12.2	Fri May  1 02:03:44 2009
+++ src/sys/dev/ic/rtl81x9var.h	Fri May  1 02:07:04 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9var.h,v 1.41.12.2 2009/05/01 02:03:44 snj Exp $	*/
+/*	$NetBSD: rtl81x9var.h,v 1.41.12.3 2009/05/01 02:07:04 snj Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -190,6 +190,7 @@
 #define RTKQ_PCIE		0x0008	/* PCIe variants */
 #define RTKQ_MACLDPS		0x0010	/* has LDPS register */
 #define RTKQ_DESCV2		0x0020	/* has V2 TX/RX descriptor */
+#define RTKQ_NOJUMBO		0x0040	/* no jumbo MTU support */
 
 	bus_dma_tag_t 		sc_dmat;
 



CVS commit: [netbsd-5] src/sys/dev/ic

2009-04-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May  1 02:10:03 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: rtl8169.c rtl81x9reg.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.112
sys/dev/ic/rtl81x9reg.h: revision 1.35
Check a correct bit for ip4csum-rx.  Reported privately on PR kern/40955.


To generate a diff of this commit:
cvs rdiff -u -r1.105.4.5 -r1.105.4.6 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.32.4.2 -r1.32.4.3 src/sys/dev/ic/rtl81x9reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.105.4.5 src/sys/dev/ic/rtl8169.c:1.105.4.6
--- src/sys/dev/ic/rtl8169.c:1.105.4.5	Fri May  1 02:08:29 2009
+++ src/sys/dev/ic/rtl8169.c	Fri May  1 02:10:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.105.4.5 2009/05/01 02:08:29 snj Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.105.4.6 2009/05/01 02:10:03 snj Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.5 2009/05/01 02:08:29 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.6 2009/05/01 02:10:03 snj Exp $);
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -1276,7 +1276,7 @@
 		/* Check IP header checksum */
 		if ((rxstat  RE_RDESC_STAT_PROTOID) != 0 
 		((sc-sc_quirk  RTKQ_DESCV2) == 0 ||
-		 (rxvlan  RE_PROTOID_IP) != 0)) {
+		 (rxvlan  RE_RDESC_VLANCTL_IPV4) != 0)) {
 			m-m_pkthdr.csum_flags |= M_CSUM_IPv4;
 			if (rxstat  RE_RDESC_STAT_IPSUMBAD)
 m-m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD;

Index: src/sys/dev/ic/rtl81x9reg.h
diff -u src/sys/dev/ic/rtl81x9reg.h:1.32.4.2 src/sys/dev/ic/rtl81x9reg.h:1.32.4.3
--- src/sys/dev/ic/rtl81x9reg.h:1.32.4.2	Fri May  1 02:03:44 2009
+++ src/sys/dev/ic/rtl81x9reg.h	Fri May  1 02:10:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9reg.h,v 1.32.4.2 2009/05/01 02:03:44 snj Exp $	*/
+/*	$NetBSD: rtl81x9reg.h,v 1.32.4.3 2009/05/01 02:10:03 snj Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -524,6 +524,8 @@
 #define RE_RDESC_VLANCTL_TAG	0x0001	/* VLAN tag available
 		   (re_vlandata valid)*/
 #define RE_RDESC_VLANCTL_DATA	0x	/* TAG data */
+#define RE_RDESC_VLANCTL_IPV6	0x8000	/* DESCV2 IPV6 packet */
+#define RE_RDESC_VLANCTL_IPV4	0x4000	/* DESCV2 IPV4 packet */
 
 #define RE_PROTOID_NONIP	0x
 #define RE_PROTOID_TCPIP	0x0001



CVS commit: [netbsd-5] src/sys/dev/ic

2009-04-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May  1 02:11:15 UTC 2009

Modified Files:
src/sys/dev/ic [netbsd-5]: rtl8169.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #597):
sys/dev/ic/rtl8169.c: revision 1.113
Fix another botch in hwcsum changes for PR kern/40955:
8168/8111/8168B/8111B doesn't have DESCV2.
Problem reported by Arto Huusko on current-us...@.


To generate a diff of this commit:
cvs rdiff -u -r1.105.4.6 -r1.105.4.7 src/sys/dev/ic/rtl8169.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.105.4.6 src/sys/dev/ic/rtl8169.c:1.105.4.7
--- src/sys/dev/ic/rtl8169.c:1.105.4.6	Fri May  1 02:10:03 2009
+++ src/sys/dev/ic/rtl8169.c	Fri May  1 02:11:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.105.4.6 2009/05/01 02:10:03 snj Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.105.4.7 2009/05/01 02:11:15 snj Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.6 2009/05/01 02:10:03 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: rtl8169.c,v 1.105.4.7 2009/05/01 02:11:15 snj Exp $);
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -593,7 +593,17 @@
 			break;
 		case RTK_HWREV_8168_SPIN1:
 			sc-sc_rev = 21;
-			sc-sc_quirk |= RTKQ_DESCV2;
+			break;
+		case RTK_HWREV_8168_SPIN2:
+			sc-sc_rev = 22;
+			break;
+		case RTK_HWREV_8168_SPIN3:
+			sc-sc_rev = 23;
+			break;
+		case RTK_HWREV_8168C:
+		case RTK_HWREV_8168C_SPIN2:
+			sc-sc_rev = 24;
+			sc-sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD;
 			/*
 			 * From FreeBSD driver:
 			 * 
@@ -609,22 +619,6 @@
 			 */
 			sc-sc_quirk |= RTKQ_NOJUMBO;
 			break;
-		case RTK_HWREV_8168_SPIN2:
-			sc-sc_rev = 22;
-			sc-sc_quirk |= RTKQ_DESCV2;
-			sc-sc_quirk |= RTKQ_NOJUMBO;	/* see above */
-			break;
-		case RTK_HWREV_8168_SPIN3:
-			sc-sc_rev = 23;
-			sc-sc_quirk |= RTKQ_DESCV2;
-			sc-sc_quirk |= RTKQ_NOJUMBO;	/* see above */
-			break;
-		case RTK_HWREV_8168C:
-		case RTK_HWREV_8168C_SPIN2:
-			sc-sc_rev = 24;
-			sc-sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD;
-			sc-sc_quirk |= RTKQ_NOJUMBO;	/* see above */
-			break;
 		case RTK_HWREV_8102E:
 		case RTK_HWREV_8102EL:
 			sc-sc_rev = 25;