CVS commit: src/sys/dev/mii

2020-11-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov  4 09:15:10 UTC 2020

Modified Files:
src/sys/dev/mii: igphy.c ihphy.c makphy.c

Log Message:
 Fix a bug that "ifconfig xx0 media none" set LINK_STATE_UNKNOWN instead of
LINK_STATE_DOWN.

XXX We should check for other PHY drivers, too.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/mii/igphy.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/mii/ihphy.c
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/mii/makphy.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/mii/igphy.c
diff -u src/sys/dev/mii/igphy.c:1.36 src/sys/dev/mii/igphy.c:1.37
--- src/sys/dev/mii/igphy.c:1.36	Mon Aug  3 07:25:59 2020
+++ src/sys/dev/mii/igphy.c	Wed Nov  4 09:15:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: igphy.c,v 1.36 2020/08/03 07:25:59 msaitoh Exp $	*/
+/*	$NetBSD: igphy.c,v 1.37 2020/11/04 09:15:10 msaitoh Exp $	*/
 
 /*
  * The Intel copyright applies to the analog register setup, and the
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.36 2020/08/03 07:25:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.37 2020/11/04 09:15:10 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mii.h"
@@ -437,7 +437,6 @@ igphy_status(struct mii_softc *sc)
 	PHY_READ(sc, MII_BMCR, &bmcr);
 	if (bmcr & BMCR_ISO) {
 		mii->mii_media_active |= IFM_NONE;
-		mii->mii_media_status = 0;
 		return;
 	}
 

Index: src/sys/dev/mii/ihphy.c
diff -u src/sys/dev/mii/ihphy.c:1.18 src/sys/dev/mii/ihphy.c:1.19
--- src/sys/dev/mii/ihphy.c:1.18	Sat Mar 28 18:37:18 2020
+++ src/sys/dev/mii/ihphy.c	Wed Nov  4 09:15:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ihphy.c,v 1.18 2020/03/28 18:37:18 thorpej Exp $	*/
+/*	$NetBSD: ihphy.c,v 1.19 2020/11/04 09:15:10 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.18 2020/03/28 18:37:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.19 2020/11/04 09:15:10 msaitoh Exp $");
 
 #include 
 #include 
@@ -242,7 +242,6 @@ ihphy_status(struct mii_softc *sc)
 	PHY_READ(sc, MII_BMCR, &bmcr);
 	if (bmcr & (BMCR_ISO | BMCR_PDOWN)) {
 		mii->mii_media_active |= IFM_NONE;
-		mii->mii_media_status = 0;
 		return;
 	}
 

Index: src/sys/dev/mii/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.67 src/sys/dev/mii/makphy.c:1.68
--- src/sys/dev/mii/makphy.c:1.67	Tue Oct 20 08:53:34 2020
+++ src/sys/dev/mii/makphy.c	Wed Nov  4 09:15:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: makphy.c,v 1.67 2020/10/20 08:53:34 msaitoh Exp $	*/
+/*	$NetBSD: makphy.c,v 1.68 2020/11/04 09:15:10 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.67 2020/10/20 08:53:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.68 2020/11/04 09:15:10 msaitoh Exp $");
 
 #include 
 #include 
@@ -436,9 +436,8 @@ makphy_status(struct mii_softc *sc)
 	if (bmcr & BMCR_LOOP)
 		mii->mii_media_active |= IFM_LOOP;
 
-	if (bmcr & BMCR_ISO) {
+	if (bmcr & (BMCR_ISO | BMCR_PDOWN)) {
 		mii->mii_media_active |= IFM_NONE;
-		mii->mii_media_status = 0;
 		return;
 	}
 



CVS commit: src/sys/dev/pci/ixgbe

2020-11-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 13 04:12:38 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe_x540.c

Log Message:
Fix typo in a debug message.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/ixgbe/ixgbe_x540.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/pci/ixgbe/ixgbe_x540.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.16 src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.17
--- src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.16	Mon Jun 11 10:34:18 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_x540.c	Fri Nov 13 04:12:38 2020
@@ -824,7 +824,7 @@ s32 ixgbe_acquire_swfw_sync_X540(struct 
 	 * bits in the SW_FW_SYNC register.
 	 */
 	if (ixgbe_get_swfw_sync_semaphore(hw)) {
-		DEBUGOUT("Failed to get NVM sempahore and register semaphore while forcefully ignoring FW sempahore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n");
+		DEBUGOUT("Failed to get NVM semaphore and register semaphore while forcefully ignoring FW semaphore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n");
 		return IXGBE_ERR_SWFW_SYNC;
 	}
 	swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));



CVS commit: src/sys/dev/pci/ixgbe

2020-11-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 13 05:53:36 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Fix a bug that some advertise speeds can't be set with hw.ixgN.advertise_speed
if both 2.5G and 5G are set. Fix the error message, too.


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.258 src/sys/dev/pci/ixgbe/ixgbe.c:1.259
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.258	Mon Sep  7 09:14:53 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Nov 13 05:53:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.258 2020/09/07 09:14:53 knakahara Exp $ */
+/* $NetBSD: ixgbe.c,v 1.259 2020/11/13 05:53:36 msaitoh Exp $ */
 
 /**
 
@@ -5542,9 +5542,9 @@ ixgbe_set_advertise(struct adapter *adap
 		return (EINVAL);
 	}
 
-	if (advertise < 0x0 || advertise > 0x2f) {
+	if (advertise < 0x0 || advertise > 0x3f) {
 		device_printf(dev,
-		"Invalid advertised speed; valid modes are 0x0 through 0x7\n");
+		"Invalid advertised speed; valid modes are 0x0 through 0x3f\n");
 		return (EINVAL);
 	}
 



CVS commit: src/sys/dev/ic

2020-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 16 00:12:13 UTC 2020

Modified Files:
src/sys/dev/ic: ath.c atppc.c

Log Message:
s/reseting/resetting/


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/dev/ic/ath.c
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/ic/atppc.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/ath.c
diff -u src/sys/dev/ic/ath.c:1.132 src/sys/dev/ic/ath.c:1.133
--- src/sys/dev/ic/ath.c:1.132	Wed Jul 22 01:24:40 2020
+++ src/sys/dev/ic/ath.c	Mon Nov 16 00:12:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ath.c,v 1.132 2020/07/22 01:24:40 msaitoh Exp $	*/
+/*	$NetBSD: ath.c,v 1.133 2020/11/16 00:12:13 msaitoh 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.132 2020/07/22 01:24:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.133 2020/11/16 00:12:13 msaitoh Exp $");
 #endif
 
 /*
@@ -4551,7 +4551,7 @@ ath_dfswait(void *arg)
 
 /*
  * Set/change channels.  If the channel is really being changed,
- * it's done by reseting the chip.  To accomplish this we must
+ * it's done by resetting the chip.  To accomplish this we must
  * first cleanup any pending DMA, then restart stuff after a la
  * ath_init.
  */
@@ -5226,7 +5226,7 @@ ath_setcurmode(struct ath_softc *sc, enu
 	/* XXX layering violation */
 	sc->sc_mcastrix = ath_tx_findrix(rt, sc->sc_ic.ic_mcast_rate);
 	sc->sc_mcastrate = sc->sc_ic.ic_mcast_rate;
-	/* NB: caller is responsible for reseting rate control state */
+	/* NB: caller is responsible for resetting rate control state */
 #undef N
 }
 

Index: src/sys/dev/ic/atppc.c
diff -u src/sys/dev/ic/atppc.c:1.36 src/sys/dev/ic/atppc.c:1.37
--- src/sys/dev/ic/atppc.c:1.36	Wed Jul 22 01:24:40 2020
+++ src/sys/dev/ic/atppc.c	Mon Nov 16 00:12:13 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atppc.c,v 1.36 2020/07/22 01:24:40 msaitoh Exp $ */
+/* $NetBSD: atppc.c,v 1.37 2020/11/16 00:12:13 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2001 Alcove - Nicolas Souchu
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: atppc.c,v 1.36 2020/07/22 01:24:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atppc.c,v 1.37 2020/11/16 00:12:13 msaitoh Exp $");
 
 #include "opt_atppc.h"
 
@@ -2310,7 +2310,7 @@ atppc_fifo_write_error(struct atppc_soft
 		atppc->sc_outbstart += worklen;
 	}
 
-	ATPPC_DPRINTF(("%s: reseting FIFO.\n", __func__));
+	ATPPC_DPRINTF(("%s: resetting FIFO.\n", __func__));
 	atppc_w_ecr(atppc, ATPPC_ECR_PS2);
 	atppc_barrier_w(atppc);
 }



CVS commit: src/sys/dev/pci/ixgbe

2020-11-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 19 02:23:24 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.h

Log Message:
 Add comment.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.72 src/sys/dev/pci/ixgbe/ixgbe.h:1.73
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.72	Tue Nov 17 04:50:29 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Thu Nov 19 02:23:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.72 2020/11/17 04:50:29 knakahara Exp $ */
+/* $NetBSD: ixgbe.h,v 1.73 2020/11/19 02:23:24 msaitoh Exp $ */
 
 /**
   SPDX-License-Identifier: BSD-3-Clause
@@ -331,8 +331,8 @@ struct ix_queue {
 	struct evcnt irqs;		/* Hardware interrupt */
 	struct evcnt handleq;	/* software_interrupt */
 	struct evcnt req;		/* deferred */
-	char namebuf[32];
-	char evnamebuf[32];
+	char namebuf[32];	/* Name for sysctl */
+	char evnamebuf[32];	/* Name for evcnt */
 
 	/* Lock for disabled_count and this queue's EIMS/EIMC bit */
 	kmutex_t dc_mtx;



CVS commit: src/sys/dev/pci

2020-11-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 19 02:36:30 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Add some sysctl values for debugging TX/RX queues.


To generate a diff of this commit:
cvs rdiff -u -r1.696 -r1.697 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.696 src/sys/dev/pci/if_wm.c:1.697
--- src/sys/dev/pci/if_wm.c:1.696	Mon Nov 16 11:54:10 2020
+++ src/sys/dev/pci/if_wm.c	Thu Nov 19 02:36:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.696 2020/11/16 11:54:10 rin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.697 2020/11/19 02:36:30 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.696 2020/11/16 11:54:10 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.697 2020/11/19 02:36:30 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -481,6 +481,7 @@ struct wm_queue {
 
 	struct wm_txqueue wmq_txq;
 	struct wm_rxqueue wmq_rxq;
+	char sysctlname[32];		/* Name for sysctl */
 
 	bool wmq_txrx_use_workqueue;
 	struct work wmq_cookie;
@@ -5886,8 +5887,8 @@ static void
 wm_init_sysctls(struct wm_softc *sc)
 {
 	struct sysctllog **log;
-	const struct sysctlnode *rnode, *cnode;
-	int rv;
+	const struct sysctlnode *rnode, *qnode, *cnode;
+	int i, rv;
 	const char *dvname;
 
 	log = &sc->sc_sysctllog;
@@ -5906,6 +5907,40 @@ wm_init_sysctls(struct wm_softc *sc)
 	if (rv != 0)
 		goto teardown;
 
+	for (i = 0; i < sc->sc_nqueues; i++) {
+		struct wm_queue *wmq = &sc->sc_queue[i];
+		struct wm_txqueue *txq = &wmq->wmq_txq;
+		struct wm_rxqueue *rxq = &wmq->wmq_rxq;
+
+		snprintf(sc->sc_queue[i].sysctlname,
+		sizeof(sc->sc_queue[i].sysctlname), "q%d", i);
+
+		if (sysctl_createv(log, 0, &rnode, &qnode,
+		0, CTLTYPE_NODE,
+		sc->sc_queue[i].sysctlname, SYSCTL_DESCR("Queue Name"),
+		NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txq_free", SYSCTL_DESCR("TX queue free"),
+		NULL, 0, &txq->txq_free,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"txq_next", SYSCTL_DESCR("TX queue next"),
+		NULL, 0, &txq->txq_next,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		CTLFLAG_READONLY, CTLTYPE_INT,
+		"rxq_ptr", SYSCTL_DESCR("RX queue pointer"),
+		NULL, 0, &rxq->rxq_ptr,
+		0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+	}
+
 #ifdef WM_DEBUG
 	rv = sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_READWRITE,
 	CTLTYPE_INT, "debug_flags",



CVS commit: src/sys/dev/pci

2020-11-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 20 01:29:12 UTC 2020

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
 Add newer Intel PCH internal devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1420 -r1.1421 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1420 src/sys/dev/pci/pcidevs:1.1421
--- src/sys/dev/pci/pcidevs:1.1420	Thu Nov 19 21:59:07 2020
+++ src/sys/dev/pci/pcidevs	Fri Nov 20 01:29:12 2020
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1420 2020/11/19 21:59:07 reinoud Exp $
+$NetBSD: pcidevs,v 1.1421 2020/11/20 01:29:12 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3139,9 +3139,59 @@ product INTEL IVYBRIDGE_PCIE_3	0x015d	Iv
 product INTEL IVYBRIDGE_IGD_1	0x0162	Ivy Bridge Integrated Graphics Device
 product INTEL IVYBRIDGE_M_IGD_1	0x0166	Ivy Bridge Integrated Graphics Device
 product INTEL IVYBRIDGE_S_IGD_1	0x016a	Ivy Bridge Integrated Graphics Device
-product INTEL CMTLK_U_LPC	0x0284	Comet Lake U LPC or eSPI
+product INTEL CMTLK_U_P_LPC	0x0284	Comet Lake U (Premium) LPC or eSPI
+product INTEL CMTLK_U_LPC	0x0285	Comet Lake U LPC or eSPI
+product INTEL CMTLK_P2SB	0x02a0	Comet Lake P2SB
+product INTEL CMTLK_PMC		0x02a1	Comet Lake PMC
 product INTEL CMTLK_SMB		0x02a3	Comet Lake SMBus
 product INTEL CMTLK_SPI		0x02a4	Comet Lake SPI (FLASH)
+product INTEL CMTLK_TRACE	0x02a6	Comet Lake Trace Hub
+product INTEL CMTLK_UART_0	0x02a8	Comet Lake UART 0
+product INTEL CMTLK_UART_1	0x02a9	Comet Lake UART 1
+product INTEL CMTLK_SPI_0	0x02aa	Comet Lake SPI 0
+product INTEL CMTLK_SPI_1	0x02ab	Comet Lake SPI 1
+product INTEL CMTLK_PCIE_9	0x02b0	Comet Lake PCIe Root Port 9
+product INTEL CMTLK_PCIE_10	0x02b1	Comet Lake PCIe Root Port 10
+product INTEL CMTLK_PCIE_11	0x02b2	Comet Lake PCIe Root Port 11
+product INTEL CMTLK_PCIE_12	0x02b3	Comet Lake PCIe Root Port 12
+product INTEL CMTLK_PCIE_13	0x02b4	Comet Lake PCIe Root Port 13
+product INTEL CMTLK_PCIE_14	0x02b5	Comet Lake PCIe Root Port 14
+product INTEL CMTLK_PCIE_15	0x02b6	Comet Lake PCIe Root Port 15
+product INTEL CMTLK_PCIE_16	0x02b7	Comet Lake PCIe Root Port 16
+product INTEL CMTLK_PCIE_1	0x02b8	Comet Lake PCIe Root Port 1
+product INTEL CMTLK_PCIE_2	0x02b9	Comet Lake PCIe Root Port 2
+product INTEL CMTLK_PCIE_3	0x02ba	Comet Lake PCIe Root Port 3
+product INTEL CMTLK_PCIE_4	0x02bb	Comet Lake PCIe Root Port 4
+product INTEL CMTLK_PCIE_5	0x02bc	Comet Lake PCIe Root Port 5
+product INTEL CMTLK_PCIE_6	0x02bd	Comet Lake PCIe Root Port 6
+product INTEL CMTLK_PCIE_7	0x02be	Comet Lake PCIe Root Port 7
+product INTEL CMTLK_PCIE_8	0x02bf	Comet Lake PCIe Root Port 8
+product INTEL CMTLK_EMMC	0x02c4	Comet Lake eMMC
+product INTEL CMTLK_I2C_4	0x02c5	Comet Lake I2C 4
+product INTEL CMTLK_I2C_5	0x02c6	Comet Lake I2C 5
+product INTEL CMTLK_UART_2	0x02c7	Comet Lake UART 2
+product INTEL CMTLK_HDA		0x02c8	Comet Lake HD Audio
+product INTEL CMTLK_AHCI	0x02d3	Comet Lake SATA (AHCI)
+product INTEL CMTLK_RAID	0x02d5	Comet Lake SATA (RAID)
+product INTEL CMTLK_RAID_P	0x02d7	Comet Lake SATA (RAID) premium
+product INTEL CMTLK_MEI_1	0x02e0	Comet Lake MEI 1
+product INTEL CMTLK_MEI_2	0x02e1	Comet Lake MEI 2
+product INTEL CMTLK_IDER	0x02e2	Comet Lake IDE-R
+product INTEL CMTLK_KT		0x02e3	Comet Lake KT
+product INTEL CMTLK_MEI_3	0x02e4	Comet Lake MEI 3
+product INTEL CMTLK_MEI_4	0x02e5	Comet Lake MEI 4
+product INTEL CMTLK_I2C_0	0x02e8	Comet Lake I2C 0
+product INTEL CMTLK_I2C_1	0x02e9	Comet Lake I2C 1
+product INTEL CMTLK_I2C_2	0x02ea	Comet Lake I2C 2
+product INTEL CMTLK_I2C_3	0x02eb	Comet Lake I2C 3
+product INTEL CMTLK_XHCI	0x02ed	Comet Lake USB 3.2 Gen 2x1 xHCI
+product INTEL CMTLK_XDCI	0x02ee	Comet Lake USB 3.2 Gen 1x1 xDCI
+product INTEL CMTLK_SSRAM	0x02ef	Comet Lake Shared SRAM
+product INTEL CMTLK_CNVI_WIFI	0x02f0	Comet Lake CNVi WiFi
+product INTEL CMTLK_SDXC	0x02f5	Comet Lake SDXC
+product INTEL CMTLK_THERM	0x02f9	Comet Lake Thermal
+product INTEL CMTLK_SPI_2	0x02fb	Comet Lake SPI 2
+product INTEL CMTLK_ISH		0x02fc	Comet Lake Integrated Sensor Hub
 product INTEL CMTLK_PCIE_9	0x02b0	Comet Lake PCIe Root Port 9
 product INTEL CMTLK_PCIE_10	0x02b1	Comet Lake PCIe Root Port 10
 product INTEL CMTLK_PCIE_11	0x02b2	Comet Lake PCIe Root Port 11
@@ -3207,6 +3257,70 @@ product INTEL 82426EX		0x0486	82426EX PC
 product INTEL PCMC		0x04a3	82434LX/NX PCI, Cache and Memory Controller (PCMC)
 product INTEL GDT_RAID1		0x0600	GDT RAID
 product INTEL GDT_RAID2		0x061f	GDT RAID
+product INTEL 4HS_LPC_H470	0x0684	H470 LPC
+product INTEL 4HS_LPC_Z490	0x0685	Z490 LPC
+product INTEL 4HS_LPC_Q470	0x0687	Q470 LPC
+product INTEL 4HS_LPC_QM480	0x068c	QM480 LPC
+product INTEL 4HS_LPC_HM470	0x068d	HM470 LPC
+product INTEL 4HS_LPC_WM490	0x068e	WM490 LPC
+product INTEL 4HS_LPC_W480	0x0697	W480 LPC
+product INTEL 4HS_H_P2SB	0x06a0	400 Series P2SB
+product INTE

CVS commit: src/sys/arch/x86/include

2020-11-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Nov 24 00:46:28 UTC 2020

Modified Files:
src/sys/arch/x86/include: specialreg.h

Log Message:
Add some definitions from the latest Intel SDM:

 - Add CPUID leaf 7 %edx bit 23 "KL" (Key Locker).
 - Add CPUID leaf 7 subleaf 1 %eax bit 5 "AVX512_BF16".


To generate a diff of this commit:
cvs rdiff -u -r1.175 -r1.176 src/sys/arch/x86/include/specialreg.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/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.175 src/sys/arch/x86/include/specialreg.h:1.176
--- src/sys/arch/x86/include/specialreg.h:1.175	Mon Sep  7 13:19:20 2020
+++ src/sys/arch/x86/include/specialreg.h	Tue Nov 24 00:46:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.175 2020/09/07 13:19:20 jakllsch Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.176 2020/11/24 00:46:28 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
@@ -395,9 +395,12 @@
  *	%ebx: Feature bits.
  *	%ecx: Feature bits.
  *	%edx: Feature bits.
+ *
+ * %ecx == 1: Structure Extendede Feature Enumeration Sub-leaf
+ *	%eax: See below.
  */
 
-/* %ebx */
+/* %ecx = 0, %ebx */
 #define CPUID_SEF_FSGSBASE	__BIT(0)  /* {RD,WR}{FS,GS}BASE */
 #define CPUID_SEF_TSC_ADJUST	__BIT(1)  /* IA32_TSC_ADJUST MSR support */
 #define CPUID_SEF_SGX		__BIT(2)  /* Software Guard Extensions */
@@ -441,7 +444,7 @@
 	"\31" "CLWB"	"\32" "PT"	"\33" "AVX512PF" "\34" "AVX512ER" \
 	"\35" "AVX512CD""\36" "SHA"	"\37" "AVX512BW" "\40" "AVX512VL"
 
-/* %ecx */
+/* %ecx = 0, %ecx */
 #define CPUID_SEF_PREFETCHWT1	__BIT(0)  /* PREFETCHWT1 instruction */
 #define CPUID_SEF_AVX512_VBMI	__BIT(1)  /* AVX-512 Vector Byte Manipulation */
 #define CPUID_SEF_UMIP		__BIT(2)  /* User-Mode Instruction prevention */
@@ -459,6 +462,7 @@
 #define CPUID_SEF_LA57		__BIT(16) /* 57bit linear addr & 5LVL paging */
 #define CPUID_SEF_MAWAU		__BITS(21, 17) /* MAWAU for BND{LD,ST}X */
 #define CPUID_SEF_RDPID		__BIT(22) /* RDPID and IA32_TSC_AUX */
+#define CPUID_SEF_KL		__BIT(23) /* Key Locker */
 #define CPUID_SEF_CLDEMOTE	__BIT(25) /* Cache line demote */
 #define CPUID_SEF_MOVDIRI	__BIT(27) /* MOVDIRI instruction */
 #define CPUID_SEF_MOVDIR64B	__BIT(28) /* MOVDIR64B instruction */
@@ -471,12 +475,11 @@
 	"b\10GFNI\0"	"b\11VAES\0"	"b\12VPCLMULQDQ\0" "b\13AVX512_VNNI\0"\
 	"b\14AVX512_BITALG\0"		"b\16AVX512_VPOPCNTDQ\0"	\
 	"b\20LA57\0"			\
-	"f\21\5MAWAU\0"			\
-	"b\26RDPID\0"			\
+	"f\21\5MAWAU\0"			"b\26RDPID\0"	"b\27KL\0"	\
 			"b\31CLDEMOTE\0"		"b\33MOVDIRI\0"	\
 	"b\34MOVDIR64B\0"		"b\36SGXLC\0"	"b\37PKS\0"
 
-/* %edx */
+/* %ecx = 0, %edx */
 #define CPUID_SEF_AVX512_4VNNIW	__BIT(2)
 #define CPUID_SEF_AVX512_4FMAPS	__BIT(3)
 #define CPUID_SEF_FSREP_MOV	__BIT(4)  /* Fast Short REP MOV */
@@ -505,6 +508,10 @@
 	"\33" "IBRS"	"\34" "STIBP"	\
 	"\35" "L1D_FLUSH" "\36" "ARCH_CAP" "\37CORE_CAP"	"\40" "SSBD"
 
+/* %ecx = 1, %eax */
+#define CPUID_SEF_AVX512_BF16	__BIT(5)
+#define CPUID_SEF1_FLAGS_A	"\20" \
+"\6" "AVX512_BF16"
 /*
  * Intel CPUID Architectural Performance Monitoring Fn000a
  *



CVS commit: src/usr.sbin/cpuctl/arch

2020-11-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Nov 24 00:48:39 UTC 2020

Modified Files:
src/usr.sbin/cpuctl/arch: i386.c

Log Message:
- Print CPUID 0x808 %ebx on Intel, too. Intel now supports WBNOINVD.
- Print CPUID leaf 7 subleaf 1.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/usr.sbin/cpuctl/arch/i386.c

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

Modified files:

Index: src/usr.sbin/cpuctl/arch/i386.c
diff -u src/usr.sbin/cpuctl/arch/i386.c:1.114 src/usr.sbin/cpuctl/arch/i386.c:1.115
--- src/usr.sbin/cpuctl/arch/i386.c:1.114	Sat Sep  5 07:45:44 2020
+++ src/usr.sbin/cpuctl/arch/i386.c	Tue Nov 24 00:48:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386.c,v 1.114 2020/09/05 07:45:44 maxv Exp $	*/
+/*	$NetBSD: i386.c,v 1.115 2020/11/24 00:48:39 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.114 2020/09/05 07:45:44 maxv Exp $");
+__RCSID("$NetBSD: i386.c,v 1.115 2020/11/24 00:48:39 msaitoh Exp $");
 #endif /* not lint */
 
 #include 
@@ -351,6 +351,8 @@ const struct cpu_cpuid_nameclass i386_cp
 [0x7e] = "10th gen Core (Ice Lake)",
 [0x85] = "Xeon Phi 7215, 7285, 7295 (Knights Mill)",
 [0x86] = "Atom (Tremont)",
+[0x8c] = "11th gen Core (Tiger Lake)",
+[0x8d] = "11th gen Core (Tiger Lake)",
 [0x8e] = "7th or 8th gen Core (Kaby Lake, Coffee Lake) or Xeon E (Coffee Lake)",
 [0x9e] = "7th or 8th gen Core (Kaby Lake, Coffee Lake) or Xeon E (Coffee Lake)",
 [0xa5] = "10th gen Core (Comet Lake)",
@@ -2250,19 +2252,25 @@ identifycpu(int fd, const char *cpuname)
 		x86_cpuid(7, descs);
 		aprint_verbose("%s: SEF highest subleaf %08x\n",
 		cpuname, descs[0]);
+		if (descs[0] >= 1) {
+			x86_cpuid2(7, 1, descs);
+			print_bits(cpuname, "SEF-subleaf1-eax",
+			CPUID_SEF1_FLAGS_A, descs[0]);
+		}
 	}
 
-	if ((cpu_vendor == CPUVENDOR_INTEL) || (cpu_vendor == CPUVENDOR_AMD))
+	if ((cpu_vendor == CPUVENDOR_INTEL) || (cpu_vendor == CPUVENDOR_AMD)) {
 		if (ci->ci_max_ext_cpuid >= 0x8007)
 			powernow_probe(ci);
 
-	if (cpu_vendor == CPUVENDOR_AMD) {
 		if (ci->ci_max_ext_cpuid >= 0x8008) {
 			x86_cpuid(0x8008, descs);
 			print_bits(cpuname, "AMD Extended features",
 			CPUID_CAPEX_FLAGS, descs[1]);
 		}
+	}
 
+	if (cpu_vendor == CPUVENDOR_AMD) {
 		if ((ci->ci_max_ext_cpuid >= 0x800a)
 		&& (ci->ci_feat_val[3] & CPUID_SVM) != 0) {
 			x86_cpuid(0x800a, descs);



CVS commit: src/sys/arch/x86/x86

2020-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 30 00:04:03 UTC 2020

Modified Files:
src/sys/arch/x86/x86: procfs_machdep.c

Log Message:
 Add sgx, sgx_lc, serialize and tsxldtrk.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/x86/x86/procfs_machdep.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/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.39 src/sys/arch/x86/x86/procfs_machdep.c:1.40
--- src/sys/arch/x86/x86/procfs_machdep.c:1.39	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/x86/procfs_machdep.c	Mon Nov 30 00:04:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.39 2020/04/25 15:26:18 bouyer Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.40 2020/11/30 00:04:02 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.39 2020/04/25 15:26:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.40 2020/11/30 00:04:02 msaitoh Exp $");
 
 #include 
 #include 
@@ -126,7 +126,7 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (9) Intel-defined: 0007 ebx */
-	"fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep",
+	"fsgsbase", "tsc_adjust", "sgx", "bmi1", "hle", "avx2", NULL, "smep",
 	"bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", "rdt_a",
 	"avx512f", "avx512dq", "rdseed", "adx",
 	"smap", "avx512ifma", NULL, "clflushopt",
@@ -179,7 +179,7 @@ static const char * const x86_features[]
 	"gfni", "vaes", "vpclmulqdq", "avx512_vnni",
 	"avx512_bitalg", "tme", "avx512_vpopcntdq", NULL,
 	"la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL,
-	NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, NULL, NULL},
+	NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, "sgx_lc", NULL},
 
 	{ /* (17) 0x8007 ebx */
 	"overflow_recov", "succor", NULL, "smca", NULL, NULL, NULL, NULL,
@@ -189,8 +189,8 @@ static const char * const x86_features[]
 
 	{ /* (18) Intel 0x0007 edx */
 	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL,
-	"vp2intersect", NULL, "md_clear", NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, "pconfig", NULL, NULL, NULL, NULL, NULL,
+	"vp2intersect", NULL, "md_clear", NULL, NULL, NULL, "serialize", NULL,
+	"tsxldtrk", NULL, "pconfig", NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL,
 	"flush_l1d", "arch_capabilities", NULL, "ssbd"},
 };



CVS commit: src/sys/dev/pci/ixgbe

2020-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 30 05:30:56 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe_vf.c

Log Message:
s/ we we / we /


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/ixgbe/ixgbe_vf.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/pci/ixgbe/ixgbe_vf.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.24 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.25
--- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.24	Wed Jul 22 01:24:40 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.c	Mon Nov 30 05:30:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.c,v 1.24 2020/07/22 01:24:40 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.c,v 1.25 2020/11/30 05:30:56 msaitoh Exp $ */
 
 /**
   SPDX-License-Identifier: BSD-3-Clause
@@ -784,7 +784,7 @@ int ixgbevf_get_queues(struct ixgbe_hw *
 		msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;
 
 		/*
-		 * if we we didn't get an ACK there must have been
+		 * if we didn't get an ACK there must have been
 		 * some sort of mailbox error so we should treat it
 		 * as such
 		 */



CVS commit: src

2020-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 30 05:33:32 UTC 2020

Modified Files:
src/sys/arch/sh3/sh3: vm_machdep.c
src/sys/arch/x86/x86: vm_machdep.c
src/sys/dev/usb: ehci.c
src/sys/net80211: ieee80211_node.c
src/tests/dev/raidframe: t_raid.sh

Log Message:
s/ we we / we /


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sh3/sh3/vm_machdep.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/x86/vm_machdep.c
cvs rdiff -u -r1.282 -r1.283 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.80 -r1.81 src/sys/net80211/ieee80211_node.c
cvs rdiff -u -r1.14 -r1.15 src/tests/dev/raidframe/t_raid.sh

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

Modified files:

Index: src/sys/arch/sh3/sh3/vm_machdep.c
diff -u src/sys/arch/sh3/sh3/vm_machdep.c:1.80 src/sys/arch/sh3/sh3/vm_machdep.c:1.81
--- src/sys/arch/sh3/sh3/vm_machdep.c:1.80	Sat Apr  6 11:54:20 2019
+++ src/sys/arch/sh3/sh3/vm_machdep.c	Mon Nov 30 05:33:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.80 2019/04/06 11:54:20 kamil Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.80 2019/04/06 11:54:20 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $");
 
 #include "opt_kstack_debug.h"
 
@@ -340,7 +340,7 @@ vmapbuf(struct buf *bp, vsize_t len)
 	 * the pmap_extract().
 	 *
 	 * no need to flush TLB since we expect nothing to be mapped
-	 * where we we just allocated (TLB will be flushed when our
+	 * where we just allocated (TLB will be flushed when our
 	 * mapping is removed).
 	 */
 	upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map);

Index: src/sys/arch/x86/x86/vm_machdep.c
diff -u src/sys/arch/x86/x86/vm_machdep.c:1.43 src/sys/arch/x86/x86/vm_machdep.c:1.44
--- src/sys/arch/x86/x86/vm_machdep.c:1.43	Fri Jul  3 16:17:24 2020
+++ src/sys/arch/x86/x86/vm_machdep.c	Mon Nov 30 05:33:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.43 2020/07/03 16:17:24 maxv Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.44 2020/11/30 05:33:32 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.43 2020/07/03 16:17:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.44 2020/11/30 05:33:32 msaitoh Exp $");
 
 #include "opt_mtrr.h"
 
@@ -312,7 +312,7 @@ vmapbuf(struct buf *bp, vsize_t len)
 	 * the pmap_extract().
 	 *
 	 * no need to flush TLB since we expect nothing to be mapped
-	 * where we we just allocated (TLB will be flushed when our
+	 * where we just allocated (TLB will be flushed when our
 	 * mapping is removed).
 	 */
 	while (len) {

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.282 src/sys/dev/usb/ehci.c:1.283
--- src/sys/dev/usb/ehci.c:1.282	Sun Sep 20 09:08:01 2020
+++ src/sys/dev/usb/ehci.c	Mon Nov 30 05:33:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.282 2020/09/20 09:08:01 gson Exp $ */
+/*	$NetBSD: ehci.c,v 1.283 2020/11/30 05:33:32 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.282 2020/09/20 09:08:01 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.283 2020/11/30 05:33:32 msaitoh Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -3770,7 +3770,7 @@ ehci_device_ctrl_close(struct usbd_pipe 
 /*
  * Some EHCI chips from VIA seem to trigger interrupts before writing back the
  * qTD status, or miss signalling occasionally under heavy load.  If the host
- * machine is too fast, we we can miss transaction completion - when we scan
+ * machine is too fast, we can miss transaction completion - when we scan
  * the active list the transaction still seems to be active.  This generally
  * exhibits itself as a umass stall that never recovers.
  *

Index: src/sys/net80211/ieee80211_node.c
diff -u src/sys/net80211/ieee80211_node.c:1.80 src/sys/net80211/ieee80211_node.c:1.81
--- src/sys/net80211/ieee80211_node.c:1.80	Mon Feb 24 12:20:30 2020
+++ src/sys/net80211/ieee80211_node.c	Mon Nov 30 05:33:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_node.c,v 1.80 2020/02/24 12:20:30 rin Exp $	*/
+/*	$NetBSD: ieee80211_node.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Atsushi Onoe
@@ -37,7 +37,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.65 2005/08/13 17:50:21 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.80 2020/02/24 12:20:30 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -1381,7 +1381,7 @@ ieee80211_init_neighbor(struct ieee80211
 /*
  * Do node 

CVS commit: src/sys/dev/pci/ixgbe

2020-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 30 07:53:42 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Apply ixgbe.c rev. 1.204 which was for ixgbe_msix_admin() to
ixgbe_legacy_irq(), too.

 >  An interrupt might not arrive when a module is inserted. When an link
 > status change interrupt occurred and the driver still regard SFP as
 > unplugged, issue the module softint before issuing LSC interrupt.

TODO: Reduce duplicated code.


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.260 src/sys/dev/pci/ixgbe/ixgbe.c:1.261
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.260	Tue Nov 17 04:50:29 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Nov 30 07:53:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.260 2020/11/17 04:50:29 knakahara Exp $ */
+/* $NetBSD: ixgbe.c,v 1.261 2020/11/30 07:53:42 msaitoh Exp $ */
 
 /**
 
@@ -5220,10 +5220,6 @@ ixgbe_legacy_irq(void *arg)
 		IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
 	}
 
-	/* Link status change */
-	if (eicr & IXGBE_EICR_LSC)
-		task_requests |= IXGBE_REQUEST_TASK_LSC;
-
 	if (ixgbe_is_sfp(hw)) {
 		/* Pluggable optics-related interrupt */
 		if (hw->mac.type >= ixgbe_mac_X540)
@@ -5231,7 +5227,15 @@ ixgbe_legacy_irq(void *arg)
 		else
 			eicr_mask = IXGBE_EICR_GPI_SDP2_BY_MAC(hw);
 
-		if (eicr & eicr_mask) {
+		/*
+		 *  An interrupt might not arrive when a module is inserted.
+		 * When an link status change interrupt occurred and the driver
+		 * still regard SFP as unplugged, issue the module softint
+		 * and then issue LSC interrupt.
+		 */
+		if ((eicr & eicr_mask)
+		|| ((hw->phy.sfp_type == ixgbe_sfp_type_not_present)
+			&& (eicr & IXGBE_EICR_LSC))) {
 			IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr_mask);
 			task_requests |= IXGBE_REQUEST_TASK_MOD;
 		}
@@ -5244,6 +5248,10 @@ ixgbe_legacy_irq(void *arg)
 		}
 	}
 
+	/* Link status change */
+	if (eicr & IXGBE_EICR_LSC)
+		task_requests |= IXGBE_REQUEST_TASK_LSC;
+
 	/* External PHY interrupt */
 	if ((hw->phy.type == ixgbe_phy_x550em_ext_t) &&
 	(eicr & IXGBE_EICR_GPI_SDP0_X540))



CVS commit: src/sys/dev/pci/ixgbe

2020-12-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 11 05:01:19 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_type.h

Log Message:
 Don't use EIMC_OTHER bit because it's read only other than 82598.

 Documents say:

  82598:
 All of bit 31(OTHER bit) of EIxx are reserved. In reality, at least
EIMS_OTHER and EIMC_OTHER exist and the OTHER interrupt doesn't work
without EIMS_OTHER.

  Other than 82598:
 EIMS_OTHER is read only and EIMC_OTHER doesn't exist. If one of
bit 29..16 is set, EIMS_OTHER is set to 1 (Note that bit 30(TCP timer
isn't included)). Even if write bit 31 of EIMC to 1, it's ignored
(EIMS_OTHER doesn't set).

 We introduced new spin mutex in ixgbe.c rev. 1.260, so it's OK to remove
EIMC_OTHER stuff. We already set EIMS_OTHER in if_init(), so keep it for
82598. No functional change other than 82598.

 Another solution is to control bit 30..16 directly to mask/unmask interrupt
instead of the mutex.

TODO:
  Some MSI-X interrupt(LSC, module insertion/removal etc.)'s mask/unmask
  code between ixgbe_msix_admin() and ixgbe_handle_admin() may be wrong.
  It'll be fixed later.


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/ixgbe/ixgbe_type.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.261 src/sys/dev/pci/ixgbe/ixgbe.c:1.262
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.261	Mon Nov 30 07:53:42 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Dec 11 05:01:19 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.261 2020/11/30 07:53:42 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.262 2020/12/11 05:01:19 msaitoh Exp $ */
 
 /**
 
@@ -3095,9 +3095,6 @@ ixgbe_msix_admin(void *arg)
 
 	++adapter->admin_irqev.ev_count;
 
-	/* Pause other interrupts */
-	IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER);
-
 	/* First get the cause */
 	/*
 	 * The specifications of 82598, 82599, X540 and X550 say EICS register
@@ -3219,9 +3216,6 @@ ixgbe_msix_admin(void *arg)
 		adapter->task_requests |= task_requests;
 		ixgbe_schedule_admin_tasklet(adapter);
 		mutex_exit(&adapter->admin_mtx);
-	} else {
-		/* Re-enable other interrupts */
-		IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
 	}
 
 	return 1;
@@ -4809,7 +4803,6 @@ ixgbe_handle_admin(struct work *wk, void
 {
 	struct adapter	*adapter = context;
 	struct ifnet	*ifp = adapter->ifp;
-	struct ixgbe_hw	*hw = &adapter->hw;
 	u32		task_requests;
 
 	mutex_enter(&adapter->admin_mtx);
@@ -4848,11 +4841,12 @@ ixgbe_handle_admin(struct work *wk, void
 	}
 #endif
 	if ((task_requests & IXGBE_REQUEST_TASK_NEED_ACKINTR) != 0) {
-		if ((adapter->feat_en & IXGBE_FEATURE_MSIX) != 0) {
-			/* Re-enable other interrupts */
-			IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
-		} else
-			ixgbe_enable_intr(adapter);
+		/*
+		 * XXX FIXME.
+		 * ixgbe_enable_intr() enables all interrupts. It might enable
+		 * an interrupt which should not be enabled.
+		 */
+		ixgbe_enable_intr(adapter);
 	}
 
 	IXGBE_CORE_UNLOCK(adapter);

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.45 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.46
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.45	Mon Aug 31 11:19:54 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Fri Dec 11 05:01:19 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.45 2020/08/31 11:19:54 msaitoh Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.46 2020/12/11 05:01:19 msaitoh Exp $ */
 
 /**
   SPDX-License-Identifier: BSD-3-Clause
@@ -1998,6 +1998,13 @@ enum {
 #define IXGBE_EIMS_PBUR		IXGBE_EICR_PBUR /* Pkt Buf Handler Err */
 #define IXGBE_EIMS_DHER		IXGBE_EICR_DHER /* Descr Handler Error */
 #define IXGBE_EIMS_TCP_TIMER	IXGBE_EICR_TCP_TIMER /* TCP Timer */
+/*
+ * EIMS_OTHER is R/W on 82598 though the document says it's reserved.
+ * It MUST be required to set this bit to get OTHER interrupt.
+ *
+ * On other chips, it's read only. It's set if any bits of 29..16 is not zero.
+ * Bit 30 (TCP_TIMER) doesn't affect to EIMS_OTHER.
+ */
 #define IXGBE_EIMS_OTHER	IXGBE_EICR_OTHER /* INT Cause Active */
 
 /* Extended Interrupt Mask Clear */
@@ -2019,6 +2026,7 @@ enum {
 #define IXGBE_EIMC_PBUR		IXGBE_EICR_PBUR /* Pkt Buf Handler Err */
 #define IXGBE_EIMC_DHER		IXGBE_EICR_DHER /* Desc Handler Err */
 #define IXGBE_EIMC_TCP_TIMER	IXGBE_EICR_TCP_TIMER /* TCP Timer */
+/* EIMC_OTHER works only on 82598. See EIMS_OTHER's comment */
 #define IXGBE_EIMC_OTHER	IXGBE_EICR_OTHER /* INT Cause Active */
 
 #define IXGBE_EIMS_ENABLE_MASK ( \



CVS commit: src/sys/dev/pci/ixgbe

2020-12-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 22 07:16:23 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Correctly ACK the fan failure interrupt in ixgbe_legacy_irq().


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.262 src/sys/dev/pci/ixgbe/ixgbe.c:1.263
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.262	Fri Dec 11 05:01:19 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Tue Dec 22 07:16:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.262 2020/12/11 05:01:19 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.263 2020/12/22 07:16:23 msaitoh Exp $ */
 
 /**
 
@@ -5211,7 +5211,7 @@ ixgbe_legacy_irq(void *arg)
 	/* Check for fan failure */
 	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
 		ixgbe_check_fan_failure(adapter, eicr, true);
-		IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
+		IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
 	}
 
 	if (ixgbe_is_sfp(hw)) {



CVS commit: src/sys/dev/pci/ixgbe

2020-12-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 24 06:14:42 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Remove strange ixgbe_enable_intr() in ixgbe_legacy_irq().

 If the interface is UP and the INTx line is shared with other devices,
it result in enabling all interrupt sources even if some of them are
disabled for the workqueue. Delete ixgbe_enable_intr() in ixgbe_legacy_irq().


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.263 src/sys/dev/pci/ixgbe/ixgbe.c:1.264
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.263	Tue Dec 22 07:16:23 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 24 06:14:41 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.263 2020/12/22 07:16:23 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.264 2020/12/24 06:14:41 msaitoh Exp $ */
 
 /**
 
@@ -5181,8 +5181,6 @@ ixgbe_legacy_irq(void *arg)
 	++que->irqs.ev_count;
 	if (eicr == 0) {
 		adapter->stats.pf.intzero.ev_count++;
-		if ((ifp->if_flags & IFF_UP) != 0)
-			ixgbe_enable_intr(adapter);
 		return 0;
 	}
 



CVS commit: src/sys/dev/pci/ixgbe

2020-12-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 24 10:00:36 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
Add some debug printf()s and modify comments.


To generate a diff of this commit:
cvs rdiff -u -r1.264 -r1.265 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.264 src/sys/dev/pci/ixgbe/ixgbe.c:1.265
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.264	Thu Dec 24 06:14:41 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 24 10:00:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.264 2020/12/24 06:14:41 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.265 2020/12/24 10:00:36 msaitoh Exp $ */
 
 /**
 
@@ -3105,7 +3105,7 @@ ixgbe_msix_admin(void *arg)
 	eicr = IXGBE_READ_REG(hw, IXGBE_EICS);
 	/* Be sure the queue bits are not cleared */
 	eicr &= ~IXGBE_EICR_RTX_QUEUE;
-	/* Clear interrupt with write */
+	/* Clear all OTHER interrupts with write */
 	IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
 
 	if (ixgbe_is_sfp(hw)) {
@@ -5172,7 +5172,7 @@ ixgbe_legacy_irq(void *arg)
 	u32		eicr, eicr_mask;
 	u32		task_requests = 0;
 
-	/* Silicon errata #26 on 82598 */
+	/* Silicon errata #26 on 82598. Disable all interrupts */
 	IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK);
 
 	eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
@@ -5186,7 +5186,8 @@ ixgbe_legacy_irq(void *arg)
 
 	if ((ifp->if_flags & IFF_RUNNING) != 0) {
 		/*
-		 * The same as ixgbe_msix_que() about "que->txrx_use_workqueue".
+		 * The same as ixgbe_msix_que() about
+		 * "que->txrx_use_workqueue".
 		 */
 		que->txrx_use_workqueue = adapter->txrx_use_workqueue;
 
@@ -6142,6 +6143,8 @@ ixgbe_print_debug_info(struct adapter *a
 		device_printf(dev, "EIMS_EX(1):\t%08x\n",
 			  IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1)));
 	}
+	device_printf(dev, "EIAM:\t%08x\n", IXGBE_READ_REG(hw, IXGBE_EIAM));
+	device_printf(dev, "EIAC:\t%08x\n", IXGBE_READ_REG(hw, IXGBE_EIAC));
 } /* ixgbe_print_debug_info */
 
 /
@@ -6566,10 +6569,12 @@ ixgbe_handle_que(void *context)
 		que->req.ev_count++;
 		ixgbe_sched_handle_que(adapter, que);
 	} else if (que->res != NULL) {
-		/* Re-enable this interrupt */
+		/* MSIX: Re-enable this interrupt */
 		ixgbe_enable_queue(adapter, que->msix);
-	} else
+	} else {
+		/* INTx or MSI */
 		ixgbe_enable_intr(adapter);
+	}
 
 	return;
 } /* ixgbe_handle_que */



CVS commit: src/sys/dev/pci/ixgbe

2020-12-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 24 10:37:47 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Reorder some code to reduce diff between ixgbe_legacy_irq() and
ixgbe_msix_admin. No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.266 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.265 src/sys/dev/pci/ixgbe/ixgbe.c:1.266
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.265	Thu Dec 24 10:00:36 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 24 10:37:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.265 2020/12/24 10:00:36 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.266 2020/12/24 10:37:47 msaitoh Exp $ */
 
 /**
 
@@ -3108,6 +3108,12 @@ ixgbe_msix_admin(void *arg)
 	/* Clear all OTHER interrupts with write */
 	IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
 
+	/* Link status change */
+	if (eicr & IXGBE_EICR_LSC) {
+		IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC);
+		task_requests |= IXGBE_REQUEST_TASK_LSC;
+	}
+
 	if (ixgbe_is_sfp(hw)) {
 		/* Pluggable optics-related interrupt */
 		if (hw->mac.type >= ixgbe_mac_X540)
@@ -3136,12 +3142,6 @@ ixgbe_msix_admin(void *arg)
 		}
 	}
 
-	/* Link status change */
-	if (eicr & IXGBE_EICR_LSC) {
-		IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC);
-		task_requests |= IXGBE_REQUEST_TASK_LSC;
-	}
-
 	if (adapter->hw.mac.type != ixgbe_mac_82598EB) {
 		if ((adapter->feat_en & IXGBE_FEATURE_FDIR) &&
 		(eicr & IXGBE_EICR_FLOW_DIR)) {
@@ -5207,11 +5207,9 @@ ixgbe_legacy_irq(void *arg)
 		IXGBE_TX_UNLOCK(txr);
 	}
 
-	/* Check for fan failure */
-	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
-		ixgbe_check_fan_failure(adapter, eicr, true);
-		IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
-	}
+	/* Link status change */
+	if (eicr & IXGBE_EICR_LSC)
+		task_requests |= IXGBE_REQUEST_TASK_LSC;
 
 	if (ixgbe_is_sfp(hw)) {
 		/* Pluggable optics-related interrupt */
@@ -5241,9 +5239,11 @@ ixgbe_legacy_irq(void *arg)
 		}
 	}
 
-	/* Link status change */
-	if (eicr & IXGBE_EICR_LSC)
-		task_requests |= IXGBE_REQUEST_TASK_LSC;
+	/* Check for fan failure */
+	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
+		ixgbe_check_fan_failure(adapter, eicr, true);
+		IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
+	}
 
 	/* External PHY interrupt */
 	if ((hw->phy.type == ixgbe_phy_x550em_ext_t) &&



CVS commit: src/sys/dev/pci/ixgbe

2020-12-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 24 15:51:04 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 The EICR register's all OTHER interrupt bits are cleared in the beginning of
the ixgbe_msix_admin(), so it's not required to clear each bit later in the
function.


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.266 src/sys/dev/pci/ixgbe/ixgbe.c:1.267
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.266	Thu Dec 24 10:37:47 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 24 15:51:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.266 2020/12/24 10:37:47 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.267 2020/12/24 15:51:04 msaitoh Exp $ */
 
 /**
 
@@ -3130,14 +3130,11 @@ ixgbe_msix_admin(void *arg)
 		if ((eicr & eicr_mask)
 		|| ((hw->phy.sfp_type == ixgbe_sfp_type_not_present)
 			&& (eicr & IXGBE_EICR_LSC))) {
-			IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr_mask);
 			task_requests |= IXGBE_REQUEST_TASK_MOD;
 		}
 
 		if ((hw->mac.type == ixgbe_mac_82599EB) &&
 		(eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) {
-			IXGBE_WRITE_REG(hw, IXGBE_EICR,
-			IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
 			task_requests |= IXGBE_REQUEST_TASK_MSF;
 		}
 	}
@@ -3156,7 +3153,6 @@ ixgbe_msix_admin(void *arg)
 		if (eicr & IXGBE_EICR_ECC) {
 			device_printf(adapter->dev,
 			"CRITICAL: ECC ERROR!! Please Reboot!!\n");
-			IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
 		}
 
 		/* Check for over temp condition */
@@ -3167,8 +3163,6 @@ ixgbe_msix_admin(void *arg)
 	break;
 IXGBE_WRITE_REG(hw, IXGBE_EIMC,
 IXGBE_EICR_GPI_SDP0_X550EM_a);
-IXGBE_WRITE_REG(hw, IXGBE_EICR,
-IXGBE_EICR_GPI_SDP0_X550EM_a);
 retval = hw->phy.ops.check_overtemp(hw);
 if (retval != IXGBE_ERR_OVERTEMP)
 	break;
@@ -3183,7 +3177,6 @@ ixgbe_msix_admin(void *arg)
 	break;
 device_printf(adapter->dev, "CRITICAL: OVER TEMP!! PHY IS SHUT DOWN!!\n");
 device_printf(adapter->dev, "System shutdown required!\n");
-IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_TS);
 break;
 			}
 		}
@@ -3198,13 +3191,11 @@ ixgbe_msix_admin(void *arg)
 	/* Check for fan failure */
 	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
 		ixgbe_check_fan_failure(adapter, eicr, TRUE);
-		IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
 	}
 
 	/* External PHY interrupt */
 	if ((hw->phy.type == ixgbe_phy_x550em_ext_t) &&
 	(eicr & IXGBE_EICR_GPI_SDP0_X540)) {
-		IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP0_X540);
 		task_requests |= IXGBE_REQUEST_TASK_PHY;
 	}
 



CVS commit: src/sys/dev/pci/ixgbe

2020-12-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 24 15:51:33 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 The EICR register are cleared in the beginning of the ixgbe_legacy_irq(),
so it's not required to clear each bit later in the function.


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.267 src/sys/dev/pci/ixgbe/ixgbe.c:1.268
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.267	Thu Dec 24 15:51:04 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 24 15:51:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.267 2020/12/24 15:51:04 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.268 2020/12/24 15:51:33 msaitoh Exp $ */
 
 /**
 
@@ -5166,6 +5166,7 @@ ixgbe_legacy_irq(void *arg)
 	/* Silicon errata #26 on 82598. Disable all interrupts */
 	IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK);
 
+	/* Read and clear EICR */
 	eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
 
 	adapter->stats.pf.legint.ev_count++;
@@ -5218,14 +5219,11 @@ ixgbe_legacy_irq(void *arg)
 		if ((eicr & eicr_mask)
 		|| ((hw->phy.sfp_type == ixgbe_sfp_type_not_present)
 			&& (eicr & IXGBE_EICR_LSC))) {
-			IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr_mask);
 			task_requests |= IXGBE_REQUEST_TASK_MOD;
 		}
 
 		if ((hw->mac.type == ixgbe_mac_82599EB) &&
 		(eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) {
-			IXGBE_WRITE_REG(hw, IXGBE_EICR,
-			IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
 			task_requests |= IXGBE_REQUEST_TASK_MSF;
 		}
 	}
@@ -5233,7 +5231,6 @@ ixgbe_legacy_irq(void *arg)
 	/* Check for fan failure */
 	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
 		ixgbe_check_fan_failure(adapter, eicr, true);
-		IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
 	}
 
 	/* External PHY interrupt */



CVS commit: src/sys/dev/pci/ixgbe

2020-12-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 24 18:32:53 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Fix a bug that INTx is disabled if the INTx line is shared with other device.
ixgbe.c rev. 1.264 was not correct.

 Restore EIMS before return. To read ECIR, clearing EIMC is required for
an errata, so
0) save the original EIMS value
1) clear EIMS
2) read EICR
3) restore with the saved value.


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.268 src/sys/dev/pci/ixgbe/ixgbe.c:1.269
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.268	Thu Dec 24 15:51:33 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 24 18:32:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.268 2020/12/24 15:51:33 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.269 2020/12/24 18:32:53 msaitoh Exp $ */
 
 /**
 
@@ -5161,9 +5161,14 @@ ixgbe_legacy_irq(void *arg)
 	bool		more = false;
 	bool		reenable_intr = true;
 	u32		eicr, eicr_mask;
+	u32		eims_orig;
 	u32		task_requests = 0;
 
-	/* Silicon errata #26 on 82598. Disable all interrupts */
+	eims_orig = IXGBE_READ_REG(hw, IXGBE_EIMS);
+	/*
+	 * Silicon errata #26 on 82598. Disable all interrupts before reading
+	 * EICR.
+	 */
 	IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK);
 
 	/* Read and clear EICR */
@@ -5173,6 +5178,7 @@ ixgbe_legacy_irq(void *arg)
 	++que->irqs.ev_count;
 	if (eicr == 0) {
 		adapter->stats.pf.intzero.ev_count++;
+		IXGBE_WRITE_REG(hw, IXGBE_EIMS, eims_orig);
 		return 0;
 	}
 



CVS commit: src/sys/dev/pci/ixgbe

2020-12-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 24 22:36:43 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Simplify setting of EIAC register. No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.269 src/sys/dev/pci/ixgbe/ixgbe.c:1.270
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.269	Thu Dec 24 18:32:53 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 24 22:36:43 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.269 2020/12/24 18:32:53 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.270 2020/12/24 22:36:43 msaitoh Exp $ */
 
 /**
 
@@ -5085,13 +5085,11 @@ ixgbe_enable_intr(struct adapter *adapte
 
 	/* With MSI-X we use auto clear */
 	if (adapter->msix_mem) {
-		mask = IXGBE_EIMS_ENABLE_MASK;
-		/* Don't autoclear Link */
-		mask &= ~IXGBE_EIMS_OTHER;
-		mask &= ~IXGBE_EIMS_LSC;
-		if (adapter->feat_cap & IXGBE_FEATURE_SRIOV)
-			mask &= ~IXGBE_EIMS_MAILBOX;
-		IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
+		/*
+		 * It's not required to set TCP_TIMER because we don't use
+		 * it.
+		 */
+		IXGBE_WRITE_REG(hw, IXGBE_EIAC, IXGBE_EIMS_RTX_QUEUE);
 	}
 
 	/*



CVS commit: src/sys/dev/pci/ixgbe

2020-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Dec 26 06:01:22 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Don't use "more" flag for simplify in ixgbe_legacy_irq().
No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.270 src/sys/dev/pci/ixgbe/ixgbe.c:1.271
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.270	Thu Dec 24 22:36:43 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Dec 26 06:01:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.270 2020/12/24 22:36:43 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.271 2020/12/26 06:01:22 msaitoh Exp $ */
 
 /**
 
@@ -5156,7 +5156,6 @@ ixgbe_legacy_irq(void *arg)
 	struct ixgbe_hw	*hw = &adapter->hw;
 	struct ifnet	*ifp = adapter->ifp;
 	struct		tx_ring *txr = adapter->tx_rings;
-	bool		more = false;
 	bool		reenable_intr = true;
 	u32		eicr, eicr_mask;
 	u32		eims_orig;
@@ -5187,13 +5186,6 @@ ixgbe_legacy_irq(void *arg)
 		 */
 		que->txrx_use_workqueue = adapter->txrx_use_workqueue;
 
-#ifdef __NetBSD__
-		/* Don't run ixgbe_rxeof in interrupt context */
-		more = true;
-#else
-		more = ixgbe_rxeof(que);
-#endif
-
 		IXGBE_TX_LOCK(txr);
 		ixgbe_txeof(txr);
 #ifdef notyet
@@ -5201,6 +5193,10 @@ ixgbe_legacy_irq(void *arg)
 			ixgbe_start_locked(ifp, txr);
 #endif
 		IXGBE_TX_UNLOCK(txr);
+
+		que->req.ev_count++;
+		ixgbe_sched_handle_que(adapter, que);
+		reenable_intr = false;
 	}
 
 	/* Link status change */
@@ -5242,11 +5238,6 @@ ixgbe_legacy_irq(void *arg)
 	(eicr & IXGBE_EICR_GPI_SDP0_X540))
 		task_requests |= IXGBE_REQUEST_TASK_PHY;
 
-	if (more) {
-		que->req.ev_count++;
-		ixgbe_sched_handle_que(adapter, que);
-		reenable_intr = false;
-	}
 	if (task_requests != 0) {
 		/* Re-enabling other interrupts is done in the admin task */
 		task_requests |= IXGBE_REQUEST_TASK_NEED_ACKINTR;



CVS commit: src/sys/dev/pci/ixgbe

2020-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Dec 26 06:02:42 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Check EICR's queue bit instead of IFF_RUNNING. This change fixes a bug that
it might incorrectly enable interrupt when IFF_RUNNING is not set. It also
changes that the TX/RX is not processed if a queue interrupt isn't occurred.


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.271 src/sys/dev/pci/ixgbe/ixgbe.c:1.272
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.271	Sat Dec 26 06:01:22 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Dec 26 06:02:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.271 2020/12/26 06:01:22 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.272 2020/12/26 06:02:42 msaitoh Exp $ */
 
 /**
 
@@ -5154,7 +5154,6 @@ ixgbe_legacy_irq(void *arg)
 	struct ix_queue *que = arg;
 	struct adapter	*adapter = que->adapter;
 	struct ixgbe_hw	*hw = &adapter->hw;
-	struct ifnet	*ifp = adapter->ifp;
 	struct		tx_ring *txr = adapter->tx_rings;
 	bool		reenable_intr = true;
 	u32		eicr, eicr_mask;
@@ -5172,14 +5171,16 @@ ixgbe_legacy_irq(void *arg)
 	eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
 
 	adapter->stats.pf.legint.ev_count++;
-	++que->irqs.ev_count;
 	if (eicr == 0) {
 		adapter->stats.pf.intzero.ev_count++;
 		IXGBE_WRITE_REG(hw, IXGBE_EIMS, eims_orig);
 		return 0;
 	}
 
-	if ((ifp->if_flags & IFF_RUNNING) != 0) {
+	/* Queue (0) intr */
+	if ((eicr & IXGBE_EIMC_RTX_QUEUE) != 0) {
+		++que->irqs.ev_count;
+
 		/*
 		 * The same as ixgbe_msix_que() about
 		 * "que->txrx_use_workqueue".



CVS commit: src/sys/dev/pci/ixgbe

2020-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Dec 26 06:07:16 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h ixgbe_type.h

Log Message:
Disable/enable the OTHER interrupts correctly.

 The OTHER interrupt was not blocked correctly when MSI-X is used.
ixgbe.c rev. 1.260 added new mutex to avoid the race but it didn't
disable the interrupt itself.

 Calling ixgbe_enable_intr() enables all interrupts, so it's not good to
call it when some interrupt sources should not be enabled (e.g.:
calling ixgbe_enable_intr() in ixgbe_handle_admin() enables queue
interrupt).

 IXGBE_REQUEST_TASK_NEED_ACKINTR doesn't work as expected because
ixgbe_handle_admin() can't know which task is enqueued from the
interrupt context and can't re-enable a specific EIMS bit.

 Solve the above three problems by the following two changes:

  - MSI-X: Disable the OTHER interrupts in the biginning of
ixgbe_msix_admin().

  - Set mask bits correctly at the end of ixgbe_legacy_irq() and
ixgbe_msix_admin() using with eim_orig, eims_enable and eims_disable.

  - Remove IXGBE_REQUEST_TASK_NEED_ACKINTR and add
IXGBE_REQUEST_TASK_{MOD,MSF}_WOI.


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pci/ixgbe/ixgbe_type.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.272 src/sys/dev/pci/ixgbe/ixgbe.c:1.273
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.272	Sat Dec 26 06:02:42 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Dec 26 06:07:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.272 2020/12/26 06:02:42 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.273 2020/12/26 06:07:16 msaitoh Exp $ */
 
 /**
 
@@ -269,7 +269,7 @@ static int	ixgbe_msix_admin(void *);
 static void	ixgbe_handle_que(void *);
 static void	ixgbe_handle_link(void *);
 static void	ixgbe_handle_msf(void *);
-static void	ixgbe_handle_mod(void *);
+static void	ixgbe_handle_mod(void *, bool);
 static void	ixgbe_handle_phy(void *);
 
 /* Deferred workqueue handlers */
@@ -1566,9 +1566,9 @@ ixgbe_config_link(struct adapter *adapte
 	if (sfp) {
 		if (hw->phy.multispeed_fiber) {
 			ixgbe_enable_tx_laser(hw);
-			task_requests |= IXGBE_REQUEST_TASK_MSF;
+			task_requests |= IXGBE_REQUEST_TASK_MSF_WOI;
 		}
-		task_requests |= IXGBE_REQUEST_TASK_MOD;
+		task_requests |= IXGBE_REQUEST_TASK_MOD_WOI;
 
 		mutex_enter(&adapter->admin_mtx);
 		adapter->task_requests |= task_requests;
@@ -3090,17 +3090,24 @@ ixgbe_msix_admin(void *arg)
 	struct adapter	*adapter = arg;
 	struct ixgbe_hw *hw = &adapter->hw;
 	u32		eicr, eicr_mask;
+	u32		eims_orig;
+	u32		eims_disable = 0;
 	u32		task_requests = 0;
 	s32		retval;
 
 	++adapter->admin_irqev.ev_count;
 
-	/* First get the cause */
+	eims_orig = IXGBE_READ_REG(hw, IXGBE_EIMS);
+	/* Pause other interrupts */
+	IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_MSIX_OTHER_CLEAR_MASK);
+
 	/*
+	 * First get the cause.
+	 *
 	 * The specifications of 82598, 82599, X540 and X550 say EICS register
 	 * is write only. However, Linux says it is a workaround for silicon
-	 * errata to read EICS instead of EICR to get interrupt cause. It seems
-	 * there is a problem about read clear mechanism for EICR register.
+	 * errata to read EICS instead of EICR to get interrupt cause.
+	 * At least, reading EICR clears lower 16bits of EIMS on 82598.
 	 */
 	eicr = IXGBE_READ_REG(hw, IXGBE_EICS);
 	/* Be sure the queue bits are not cleared */
@@ -3110,8 +3117,8 @@ ixgbe_msix_admin(void *arg)
 
 	/* Link status change */
 	if (eicr & IXGBE_EICR_LSC) {
-		IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC);
 		task_requests |= IXGBE_REQUEST_TASK_LSC;
+		eims_disable |= IXGBE_EIMS_LSC;
 	}
 
 	if (ixgbe_is_sfp(hw)) {
@@ -3131,11 +3138,13 @@ ixgbe_msix_admin(void *arg)
 		|| ((hw->phy.sfp_type == ixgbe_sfp_type_not_present)
 			&& (eicr & IXGBE_EICR_LSC))) {
 			task_requests |= IXGBE_REQUEST_TASK_MOD;
+			eims_disable |= IXGBE_EIMS_LSC;
 		}
 
 		if ((hw->mac.type == ixgbe_mac_82599EB) &&
 		(eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) {
 			task_requests |= IXGBE_REQUEST_TASK_MSF;
+			eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
 		}
 	}
 
@@ -3145,9 +3154,9 @@ ixgbe_msix_admin(void *arg)
 			/* This is probably overkill :) */
 			if (!atomic_cas_uint(&adapter->fdir_reinit, 0, 1))
 return 1;
-			/* Disable the interrupt */
-			IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_FLOW_DIR);
 			task_requests |= IXGBE_REQUEST_TASK_FDIR;
+			/* Disable the interrupt */
+			eims_disable |= IXGBE_EIMS_FLOW_DIR;
 		}
 
 		if (eicr & IXGBE_EICR_ECC) {
@@ -3161,8 +3170,7 @@ ixgbe_msix_admin(void *arg)
 			case ixgbe_mac_X550EM

CVS commit: src/sys/dev/pci/ixgbe

2020-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Dec 26 06:10:17 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_type.h

Log Message:
Disable some interrupt in ixgbe_{legacy_irq,msix_admin}() to prevent log spam.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/ixgbe/ixgbe_type.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.273 src/sys/dev/pci/ixgbe/ixgbe.c:1.274
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.273	Sat Dec 26 06:07:16 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Dec 26 06:10:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.273 2020/12/26 06:07:16 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.274 2020/12/26 06:10:17 msaitoh Exp $ */
 
 /**
 
@@ -175,7 +175,7 @@ static void	ixgbe_init_locked(struct ada
 static void	ixgbe_ifstop(struct ifnet *, int);
 static void	ixgbe_stop_locked(void *);
 static void	ixgbe_init_device_features(struct adapter *);
-static void	ixgbe_check_fan_failure(struct adapter *, u32, bool);
+static int	ixgbe_check_fan_failure(struct adapter *, u32, bool);
 static void	ixgbe_add_media_types(struct adapter *);
 static void	ixgbe_media_status(struct ifnet *, struct ifmediareq *);
 static int	ixgbe_media_change(struct ifnet *);
@@ -3162,6 +3162,8 @@ ixgbe_msix_admin(void *arg)
 		if (eicr & IXGBE_EICR_ECC) {
 			device_printf(adapter->dev,
 			"CRITICAL: ECC ERROR!! Please Reboot!!\n");
+			/* Disable interrupt to prevent log spam */
+			eims_disable |= IXGBE_EICR_ECC;
 		}
 
 		/* Check for over temp condition */
@@ -3170,6 +3172,8 @@ ixgbe_msix_admin(void *arg)
 			case ixgbe_mac_X550EM_a:
 if (!(eicr & IXGBE_EICR_GPI_SDP0_X550EM_a))
 	break;
+/* Disable interrupt to prevent log spam */
+eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a;
 
 retval = hw->phy.ops.check_overtemp(hw);
 if (retval != IXGBE_ERR_OVERTEMP)
@@ -3180,6 +3184,8 @@ ixgbe_msix_admin(void *arg)
 			default:
 if (!(eicr & IXGBE_EICR_TS))
 	break;
+/* Disable interrupt to prevent log spam */
+eims_disable |= IXGBE_EIMS_TS;
 
 retval = hw->phy.ops.check_overtemp(hw);
 if (retval != IXGBE_ERR_OVERTEMP)
@@ -3200,7 +3206,11 @@ ixgbe_msix_admin(void *arg)
 
 	/* Check for fan failure */
 	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
-		ixgbe_check_fan_failure(adapter, eicr, true);
+		retval = ixgbe_check_fan_failure(adapter, eicr, true);
+		if (retval == IXGBE_ERR_FAN_FAILURE) {
+			/* Disable interrupt to prevent log spam */
+			eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
+		}
 	}
 
 	/* External PHY interrupt */
@@ -5185,6 +5195,7 @@ ixgbe_legacy_irq(void *arg)
 	u32		eims_enable = 0;
 	u32		eims_disable = 0;
 	u32		task_requests = 0;
+	s32		retval;
 
 	eims_orig = IXGBE_READ_REG(hw, IXGBE_EIMS);
 	/*
@@ -5264,7 +5275,11 @@ ixgbe_legacy_irq(void *arg)
 
 	/* Check for fan failure */
 	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
-		ixgbe_check_fan_failure(adapter, eicr, true);
+		retval = ixgbe_check_fan_failure(adapter, eicr, true);
+		if (retval == IXGBE_ERR_FAN_FAILURE) {
+			/* Disable interrupt to prevent log spam */
+			eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
+		}
 	}
 
 	/* External PHY interrupt */
@@ -6539,7 +6554,7 @@ ixgbe_ioctl(struct ifnet *ifp, u_long co
 /
  * ixgbe_check_fan_failure
  /
-static void
+static int
 ixgbe_check_fan_failure(struct adapter *adapter, u32 reg, bool in_interrupt)
 {
 	u32 mask;
@@ -6547,8 +6562,12 @@ ixgbe_check_fan_failure(struct adapter *
 	mask = (in_interrupt) ? IXGBE_EICR_GPI_SDP1_BY_MAC(&adapter->hw) :
 	IXGBE_ESDP_SDP1;
 
-	if (reg & mask)
+	if (reg & mask) {
 		device_printf(adapter->dev, "\nCRITICAL: FAN FAILURE!! REPLACE IMMEDIATELY!!\n");
+		return IXGBE_ERR_FAN_FAILURE;
+	}
+
+	return IXGBE_SUCCESS;
 } /* ixgbe_check_fan_failure */
 
 /

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.47 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.48
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.47	Sat Dec 26 06:07:16 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Sat Dec 26 06:10:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.47 2020/12/26 06:07:16 msaitoh Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.48 2020/12/26 06:10:17 msaitoh Exp $ */
 
 /**
   SPDX-License-Identifier: BSD-3-Clause
@@ -4324,7 +4324,7 @@ struct ixgbe_hw {
 
 #define IXGBE_ERR_NOT_TRUSTED			-50 /* XXX NetBSD */
 #define IXGBE_ERR_NOT_IN_PROMISC		-51 /* XXX NetBSD */
-
+#define IXG

CVS commit: src/sys/dev/pci/ixgbe

2020-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Dec 26 06:17:55 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Don't return in the middle of ixgbe_msix_admin() when an flow director reinit
failed. NetBSD currently doesn't support flow director, so this is not a real
bug.


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.274 src/sys/dev/pci/ixgbe/ixgbe.c:1.275
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.274	Sat Dec 26 06:10:17 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Dec 26 06:17:55 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.274 2020/12/26 06:10:17 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.275 2020/12/26 06:17:55 msaitoh Exp $ */
 
 /**
 
@@ -3151,12 +3151,11 @@ ixgbe_msix_admin(void *arg)
 	if (adapter->hw.mac.type != ixgbe_mac_82598EB) {
 		if ((adapter->feat_en & IXGBE_FEATURE_FDIR) &&
 		(eicr & IXGBE_EICR_FLOW_DIR)) {
-			/* This is probably overkill :) */
-			if (!atomic_cas_uint(&adapter->fdir_reinit, 0, 1))
-return 1;
-			task_requests |= IXGBE_REQUEST_TASK_FDIR;
-			/* Disable the interrupt */
-			eims_disable |= IXGBE_EIMS_FLOW_DIR;
+			if (!atomic_cas_uint(&adapter->fdir_reinit, 0, 1)) {
+task_requests |= IXGBE_REQUEST_TASK_FDIR;
+/* Disable the interrupt */
+eims_disable |= IXGBE_EIMS_FLOW_DIR;
+			}
 		}
 
 		if (eicr & IXGBE_EICR_ECC) {



CVS commit: src/sys/dev/pci/ixgbe

2020-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Dec 26 06:27:38 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Copy & paste some missing part (flow director, ECC and temp sensor) from
ixgbe_msix_admin() to ixgbe_legacy_irq(). Now it's ready to make a new
function to share the common part. It'll be done in near future.


To generate a diff of this commit:
cvs rdiff -u -r1.275 -r1.276 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.275 src/sys/dev/pci/ixgbe/ixgbe.c:1.276
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.275	Sat Dec 26 06:17:55 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Dec 26 06:27:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.275 2020/12/26 06:17:55 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.276 2020/12/26 06:27:38 msaitoh Exp $ */
 
 /**
 
@@ -5272,6 +5272,61 @@ ixgbe_legacy_irq(void *arg)
 		}
 	}
 
+	if (adapter->hw.mac.type != ixgbe_mac_82598EB) {
+		if ((adapter->feat_en & IXGBE_FEATURE_FDIR) &&
+		(eicr & IXGBE_EICR_FLOW_DIR)) {
+			if (!atomic_cas_uint(&adapter->fdir_reinit, 0, 1)) {
+task_requests |= IXGBE_REQUEST_TASK_FDIR;
+/* Disable the interrupt */
+eims_disable |= IXGBE_EIMS_FLOW_DIR;
+			}
+		}
+
+		if (eicr & IXGBE_EICR_ECC) {
+			device_printf(adapter->dev,
+			"CRITICAL: ECC ERROR!! Please Reboot!!\n");
+			/* Disable interrupt to prevent log spam */
+			eims_disable |= IXGBE_EICR_ECC;
+		}
+
+		/* Check for over temp condition */
+		if (adapter->feat_en & IXGBE_FEATURE_TEMP_SENSOR) {
+			switch (adapter->hw.mac.type) {
+			case ixgbe_mac_X550EM_a:
+if (!(eicr & IXGBE_EICR_GPI_SDP0_X550EM_a))
+	break;
+/* Disable interrupt to prevent log spam */
+eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a;
+
+retval = hw->phy.ops.check_overtemp(hw);
+if (retval != IXGBE_ERR_OVERTEMP)
+	break;
+device_printf(adapter->dev, "CRITICAL: OVER TEMP!! PHY IS SHUT DOWN!!\n");
+device_printf(adapter->dev, "System shutdown required!\n");
+break;
+			default:
+if (!(eicr & IXGBE_EICR_TS))
+	break;
+/* Disable interrupt to prevent log spam */
+eims_disable |= IXGBE_EIMS_TS;
+
+retval = hw->phy.ops.check_overtemp(hw);
+if (retval != IXGBE_ERR_OVERTEMP)
+	break;
+device_printf(adapter->dev, "CRITICAL: OVER TEMP!! PHY IS SHUT DOWN!!\n");
+device_printf(adapter->dev, "System shutdown required!\n");
+break;
+			}
+		}
+
+		/* Check for VF message */
+		if ((adapter->feat_en & IXGBE_FEATURE_SRIOV) &&
+		(eicr & IXGBE_EICR_MAILBOX)) {
+			task_requests |= IXGBE_REQUEST_TASK_MBX;
+			eims_disable |= IXGBE_EIMS_MAILBOX;
+		}
+	}
+
 	/* Check for fan failure */
 	if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) {
 		retval = ixgbe_check_fan_failure(adapter, eicr, true);



CVS commit: src/sys/dev/pci/ixgbe

2020-12-31 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 31 12:34:33 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
Reduce code duplication. No functional change.

   Add new ixgbe_intr_admin_common() and use it in both ixgbe_msix_admin()
  and ixgbe_legacy_irq().


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.276 src/sys/dev/pci/ixgbe/ixgbe.c:1.277
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.276	Sat Dec 26 06:27:38 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 31 12:34:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.276 2020/12/26 06:27:38 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.277 2020/12/31 12:34:33 msaitoh Exp $ */
 
 /**
 
@@ -258,12 +258,11 @@ static int	ixgbe_sysctl_debug(SYSCTLFN_P
 static int	ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_wufc(SYSCTLFN_PROTO);
 
-/* Legacy (single vector) interrupt handler */
-static int	ixgbe_legacy_irq(void *);
-
-/* The MSI/MSI-X Interrupt handlers */
+/* Interrupt functions */
 static int	ixgbe_msix_que(void *);
 static int	ixgbe_msix_admin(void *);
+static void	ixgbe_intr_admin_common(struct adapter *, u32, u32 *);
+static int	ixgbe_legacy_irq(void *);
 
 /* Event handlers running on workqueue */
 static void	ixgbe_handle_que(void *);
@@ -3089,11 +3088,9 @@ ixgbe_msix_admin(void *arg)
 {
 	struct adapter	*adapter = arg;
 	struct ixgbe_hw *hw = &adapter->hw;
-	u32		eicr, eicr_mask;
+	u32		eicr;
 	u32		eims_orig;
 	u32		eims_disable = 0;
-	u32		task_requests = 0;
-	s32		retval;
 
 	++adapter->admin_irqev.ev_count;
 
@@ -3115,10 +3112,26 @@ ixgbe_msix_admin(void *arg)
 	/* Clear all OTHER interrupts with write */
 	IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
 
+	ixgbe_intr_admin_common(adapter, eicr, &eims_disable);
+
+	/* Re-enable some OTHER interrupts */
+	IXGBE_WRITE_REG(hw, IXGBE_EIMS, eims_orig & ~eims_disable);
+
+	return 1;
+} /* ixgbe_msix_admin */
+
+static void
+ixgbe_intr_admin_common(struct adapter *adapter, u32 eicr, u32 *eims_disable)
+{
+	struct ixgbe_hw *hw = &adapter->hw;
+	u32		eicr_mask;
+	u32		task_requests = 0;
+	s32		retval;
+
 	/* Link status change */
 	if (eicr & IXGBE_EICR_LSC) {
 		task_requests |= IXGBE_REQUEST_TASK_LSC;
-		eims_disable |= IXGBE_EIMS_LSC;
+		*eims_disable |= IXGBE_EIMS_LSC;
 	}
 
 	if (ixgbe_is_sfp(hw)) {
@@ -3138,13 +3151,13 @@ ixgbe_msix_admin(void *arg)
 		|| ((hw->phy.sfp_type == ixgbe_sfp_type_not_present)
 			&& (eicr & IXGBE_EICR_LSC))) {
 			task_requests |= IXGBE_REQUEST_TASK_MOD;
-			eims_disable |= IXGBE_EIMS_LSC;
+			*eims_disable |= IXGBE_EIMS_LSC;
 		}
 
 		if ((hw->mac.type == ixgbe_mac_82599EB) &&
 		(eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) {
 			task_requests |= IXGBE_REQUEST_TASK_MSF;
-			eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
+			*eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
 		}
 	}
 
@@ -3154,7 +3167,7 @@ ixgbe_msix_admin(void *arg)
 			if (!atomic_cas_uint(&adapter->fdir_reinit, 0, 1)) {
 task_requests |= IXGBE_REQUEST_TASK_FDIR;
 /* Disable the interrupt */
-eims_disable |= IXGBE_EIMS_FLOW_DIR;
+*eims_disable |= IXGBE_EIMS_FLOW_DIR;
 			}
 		}
 
@@ -3162,7 +3175,7 @@ ixgbe_msix_admin(void *arg)
 			device_printf(adapter->dev,
 			"CRITICAL: ECC ERROR!! Please Reboot!!\n");
 			/* Disable interrupt to prevent log spam */
-			eims_disable |= IXGBE_EICR_ECC;
+			*eims_disable |= IXGBE_EICR_ECC;
 		}
 
 		/* Check for over temp condition */
@@ -3172,7 +3185,7 @@ ixgbe_msix_admin(void *arg)
 if (!(eicr & IXGBE_EICR_GPI_SDP0_X550EM_a))
 	break;
 /* Disable interrupt to prevent log spam */
-eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a;
+*eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a;
 
 retval = hw->phy.ops.check_overtemp(hw);
 if (retval != IXGBE_ERR_OVERTEMP)
@@ -3184,7 +3197,7 @@ ixgbe_msix_admin(void *arg)
 if (!(eicr & IXGBE_EICR_TS))
 	break;
 /* Disable interrupt to prevent log spam */
-eims_disable |= IXGBE_EIMS_TS;
+*eims_disable |= IXGBE_EIMS_TS;
 
 retval = hw->phy.ops.check_overtemp(hw);
 if (retval != IXGBE_ERR_OVERTEMP)
@@ -3199,7 +3212,7 @@ ixgbe_msix_admin(void *arg)
 		if ((adapter->feat_en & IXGBE_FEATURE_SRIOV) &&
 		(eicr & IXGBE_EICR_MAILBOX)) {
 			task_requests |= IXGBE_REQUEST_TASK_MBX;
-			eims_disable |= IXGBE_EIMS_MAILBOX;
+			*eims_disable |= IXGBE_EIMS_MAILBOX;
 		}
 	}
 
@@ -3208,7 +3221,7 @@ ixgbe_msix_admin(void *arg)
 		retval = ixgbe_check_fan_failure(adapter, eicr, true);
 		if (retval == IXGBE_ERR_FAN_FAILURE) {
 			/* Disable interrupt to prevent log spam */
-			eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
+			*eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
 		}
 	}
 
@@ -3216,7 +3229,

CVS commit: src/sys/dev/pci

2009-07-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul 13 23:31:19 UTC 2009

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Check PCI-X mode as e1000 driver.


To generate a diff of this commit:
cvs rdiff -u -r1.175 -r1.176 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.175 src/sys/dev/pci/if_wm.c:1.176
--- src/sys/dev/pci/if_wm.c:1.175	Fri May 29 04:57:04 2009
+++ src/sys/dev/pci/if_wm.c	Mon Jul 13 23:31:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.175 2009/05/29 04:57:04 darran Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.176 2009/07/13 23:31:19 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.175 2009/05/29 04:57:04 darran Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.176 2009/07/13 23:31:19 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -1129,8 +1129,7 @@
 		reg = CSR_READ(sc, WMREG_STATUS);
 		if (reg & STATUS_BUS64)
 			sc->sc_flags |= WM_F_BUS64;
-		if (sc->sc_type >= WM_T_82544 &&
-		(reg & STATUS_PCIX_MODE) != 0) {
+		if ((reg & STATUS_PCIX_MODE) != 0) {
 			pcireg_t pcix_cmd, pcix_sts, bytecnt, maxb;
 
 			sc->sc_flags |= WM_F_PCIX;



CVS commit: src/sys/dev/pci

2009-07-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jul 14 00:00:44 UTC 2009

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
Some fixes for i80003 and ICH{8,9,10) from e1000 driver and document:

Add setting for KABGTXD register for ICH{8,9,10}.

ICH9 and ICH10 has no FCAL, FCAH and FCT like ICH8.

Add special setting for FCTTV and TCTL_EXT register for i80003

The special setting fopr TIPG is only for i80003.

Some of kumeran settings are only for i80003's bugs.

Add some ICH10 fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/if_wmreg.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.176 src/sys/dev/pci/if_wm.c:1.177
--- src/sys/dev/pci/if_wm.c:1.176	Mon Jul 13 23:31:19 2009
+++ src/sys/dev/pci/if_wm.c	Tue Jul 14 00:00:44 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.176 2009/07/13 23:31:19 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.177 2009/07/14 00:00:44 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.176 2009/07/13 23:31:19 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.177 2009/07/14 00:00:44 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -3264,7 +3264,8 @@
 	 *
 	 * XXX Values could probably stand some tuning.
 	 */
-	if (sc->sc_type != WM_T_ICH8) {
+	if ((sc->sc_type != WM_T_ICH8) && (sc->sc_type != WM_T_ICH9)
+	&& (sc->sc_type != WM_T_ICH10)) {
 		CSR_WRITE(sc, WMREG_FCAL, FCAL_CONST);
 		CSR_WRITE(sc, WMREG_FCAH, FCAH_CONST);
 		CSR_WRITE(sc, WMREG_FCT, ETHERTYPE_FLOWCONTROL);
@@ -3278,7 +3279,11 @@
 		CSR_WRITE(sc, WMREG_FCRTH, FCRTH_DFLT);
 		CSR_WRITE(sc, WMREG_FCRTL, sc->sc_fcrtl);
 	}
-	CSR_WRITE(sc, WMREG_FCTTV, FCTTV_DFLT);
+
+	if (sc->sc_type == WM_T_80003)
+		CSR_WRITE(sc, WMREG_FCTTV, 0x);
+	else
+		CSR_WRITE(sc, WMREG_FCTTV, FCTTV_DFLT);
 
 	/* Deal with VLAN enables. */
 	if (VLAN_ATTACHED(&sc->sc_ethercom))
@@ -3288,29 +3293,47 @@
 
 	/* Write the control registers. */
 	CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
-	if (sc->sc_type >= WM_T_80003 && (sc->sc_flags & WM_F_HAS_MII)) {
+
+	if (sc->sc_flags & WM_F_HAS_MII) {
 		int val;
-		val = CSR_READ(sc, WMREG_CTRL_EXT);
-		val &= ~CTRL_EXT_LINK_MODE_MASK;
-		CSR_WRITE(sc, WMREG_CTRL_EXT, val);
-
-		/* Bypass RX and TX FIFO's */
-		wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_FIFO_CTRL,
-		KUMCTRLSTA_FIFO_CTRL_RX_BYPASS | 
-		KUMCTRLSTA_FIFO_CTRL_TX_BYPASS);
+
+		switch (sc->sc_type) {
+		case WM_T_80003:
+		case WM_T_ICH8:
+		case WM_T_ICH9:
+		case WM_T_ICH10:
+			/*
+			 * Set the mac to wait the maximum time between each
+			 * iteration and increase the max iterations when
+			 * polling the phy; this fixes erroneous timeouts at
+			 * 10Mbps.
+			 */
+			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_TIMEOUTS,
+			0x);
+			val = wm_kmrn_i80003_readreg(sc,
+			KUMCTRLSTA_OFFSET_INB_PARAM);
+			val |= 0x3F;
+			wm_kmrn_i80003_writereg(sc,
+			KUMCTRLSTA_OFFSET_INB_PARAM, val);
+			break;
+		default:
+			break;
+		}
+
+		if (sc->sc_type == WM_T_80003) {
+			val = CSR_READ(sc, WMREG_CTRL_EXT);
+			val &= ~CTRL_EXT_LINK_MODE_MASK;
+			CSR_WRITE(sc, WMREG_CTRL_EXT, val);
+
+			/* Bypass RX and TX FIFO's */
+			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_FIFO_CTRL,
+			KUMCTRLSTA_FIFO_CTRL_RX_BYPASS | 
+			KUMCTRLSTA_FIFO_CTRL_TX_BYPASS);
 		
-		wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_INB_CTRL,
-		KUMCTRLSTA_INB_CTRL_DIS_PADDING |
-		KUMCTRLSTA_INB_CTRL_LINK_TMOUT_DFLT);
-		/*
-		 * Set the mac to wait the maximum time between each
-		 * iteration and increase the max iterations when
-		 * polling the phy; this fixes erroneous timeouts at 10Mbps.
-		 */
-		wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_TIMEOUTS, 0x);
-		val = wm_kmrn_i80003_readreg(sc, KUMCTRLSTA_OFFSET_INB_PARAM);
-		val |= 0x3F;
-		wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_INB_PARAM, val);
+			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_INB_CTRL,
+			KUMCTRLSTA_INB_CTRL_DIS_PADDING |
+			KUMCTRLSTA_INB_CTRL_LINK_TMOUT_DFLT);
+		}
 	}
 #if 0
 	CSR_WRITE(sc, WMREG_CTRL_EXT, sc->sc_ctrl_ext);
@@ -3342,6 +3365,13 @@
 		sc->sc_icr |= ICR_RXCFG;
 	CSR_WRITE(sc, WMREG_IMS, sc->sc_icr);
 
+	if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
+	|| (sc->sc_type == WM_T_ICH10)) {
+		reg = CSR_READ(sc, WMREG_KABGTXD);
+		reg |= KABGTXD_BGSQLBIAS;
+		CSR_WRITE(sc, WMREG_KABGTXD, reg);
+	}
+
 	/* Set up the inter-packet gap. */
 	CSR_WRITE(sc, WMREG_TIPG, sc->sc_tipg);
 
@@ -3385,6 +3415,13 @@
 		sc->sc_tctl |= TCTL_RTLC;
 	CSR_WRITE(sc, WMREG_TCTL, sc->sc_tctl);
 
+	if (sc->sc_type == WM_T_80003) {
+		reg = CSR_READ(sc, WMREG_TCTL_EXT);
+		reg &= ~TCTL_EXT_GCEX_MASK;
+

CVS commit: src/sys/dev/pci

2009-07-22 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 23 05:05:13 UTC 2009

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
Reduce the difference against FreeBSD and OpenBSD

  Define BGE_IS_JUMBO_CAPABLE and use it. No functional change.

  Cleanup the code for BGE_PCI_DMA_RW_CTL regster setting. No functional
  change.

  Fix a printf message.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/dev/pci/if_bge.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.165 src/sys/dev/pci/if_bge.c:1.166
--- src/sys/dev/pci/if_bge.c:1.165	Tue May  5 18:08:28 2009
+++ src/sys/dev/pci/if_bge.c	Thu Jul 23 05:05:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.165 2009/05/05 18:08:28 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.166 2009/07/23 05:05:13 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.165 2009/05/05 18:08:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.166 2009/07/23 05:05:13 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "vlan.h"
@@ -499,6 +499,13 @@
 	(BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5705 || \
 	(BGE_IS_5750_OR_BEYOND(sc)))
 
+#define BGE_IS_JUMBO_CAPABLE(sc)  \
+	(BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5700|| \
+	 BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5701|| \
+	 BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5703|| \
+	 BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5704)
+
+
 static const struct bge_revision {
 	uint32_t		br_chipid;
 	const char		*br_name;
@@ -576,7 +583,7 @@
 	{ BGE_ASICREV_BCM5755, "unknown BCM5755" },
 	{ BGE_ASICREV_BCM5780, "unknown BCM5780" },
 	/* 5754 and 5787 share the same ASIC ID */
-	{ BGE_ASICREV_BCM5787, "unknown BCM5787/5787" },
+	{ BGE_ASICREV_BCM5787, "unknown BCM5754/5787" },
 	{ BGE_ASICREV_BCM5906, "unknown BCM5906" }, 
 	{ 0, NULL }
 };
@@ -1559,43 +1566,17 @@
 		BGE_MEMWIN_WRITE(sc->sc_pc, sc->sc_pcitag, i, 0);
 
 	/* Set up the PCI DMA control register. */
+	dma_rw_ctl = BGE_PCI_READ_CMD | BGE_PCI_WRITE_CMD;
 	if (sc->bge_flags & BGE_PCIE) {
-	  u_int32_t device_ctl;
-
-		/* From FreeBSD */
+		/* Read watermark not used, 128 bytes for write. */
 		DPRINTFN(4, ("(%s: PCI-Express DMA setting)\n",
 		device_xname(sc->bge_dev)));
-		dma_rw_ctl = (BGE_PCI_READ_CMD | BGE_PCI_WRITE_CMD |
-		(0xf << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
-		(0x2 << BGE_PCIDMARWCTL_WR_WAT_SHIFT));
-
-		/* jonathan: alternative from Linux driver */
-#define DMA_CTRL_WRITE_PCIE_H20MARK_128 0x0018
-#define DMA_CTRL_WRITE_PCIE_H20MARK_256 0x0038
-
-		dma_rw_ctl =   0x7600; /* XXX XXX XXX */;
-		device_ctl = pci_conf_read(sc->sc_pc, sc->sc_pcitag,
-	   BGE_PCI_CONF_DEV_CTRL);
-		aprint_debug_dev(sc->bge_dev, "pcie mode=0x%x\n", device_ctl);
-
-		if ((device_ctl & 0x00e0) && 0) {
-			/*
-			 * XXX jonat...@netbsd.org:
-			 * This clause is exactly what the Broadcom-supplied
-			 * Linux does; but given overall register programming
-			 * by if_bge(4), this larger DMA-write watermark
-			 * value causes bcm5721 chips to totally wedge.
-			 */
-			dma_rw_ctl |= BGE_PCIDMA_RWCTL_PCIE_WRITE_WATRMARK_256;
-		} else {
-			dma_rw_ctl |= BGE_PCIDMA_RWCTL_PCIE_WRITE_WATRMARK_128;
-		}
+		dma_rw_ctl |= (0x3 << BGE_PCIDMARWCTL_WR_WAT_SHIFT);
 	} else if (sc->bge_flags & BGE_PCIX){
 	  	DPRINTFN(4, ("(:%s: PCI-X DMA setting)\n",
 		device_xname(sc->bge_dev)));
 		/* PCI-X bus */
-		dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
-		(0x3 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
+		dma_rw_ctl |= (0x3 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
 		(0x3 << BGE_PCIDMARWCTL_WR_WAT_SHIFT) |
 		(0x0F);
 		/*
@@ -1629,9 +1610,8 @@
 		/* Conventional PCI bus */
 	  	DPRINTFN(4, ("(%s: PCI 2.2 DMA setting)\n",
 		device_xname(sc->bge_dev)));
-		dma_rw_ctl = (BGE_PCI_READ_CMD | BGE_PCI_WRITE_CMD |
-		   (0x7 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
-		   (0x7 << BGE_PCIDMARWCTL_WR_WAT_SHIFT));
+		dma_rw_ctl = (0x7 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
+		   (0x7 << BGE_PCIDMARWCTL_WR_WAT_SHIFT);
 		if (BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5705 &&
 		BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5750)
 			dma_rw_ctl |= 0x0F;
@@ -1829,7 +1809,7 @@
 	 * using this ring (i.e. once we set the MTU
 	 * high enough to require it).
 	 */
-	if (!BGE_IS_5705_OR_BEYOND(sc)) {
+	if (BGE_IS_JUMBO_CAPABLE(sc)) {
 		rcb = &sc->bge_rdata->bge_info.bge_jumbo_rx_rcb;
 		bge_set_hostaddr(&rcb->bge_hostaddr,
 		BGE_RING_DMA_ADDR(sc, bge_rx_jumbo_ring));
@@ -2495,7 +2475,7 @@
 	memset(sc->bge_rdata, 0, sizeof(struct bge_ring_data));
 
 	/* Try to allocate memory for jumbo buffers. */
-	if (!(BGE_IS_5705_OR_BEYOND(sc))) {
+	if (BGE_IS_JUMBO_CAPABLE(sc)) {
 		if (bge_alloc_jumbo_mem(sc)) {
 			aprint_error_dev(sc->bge_dev,
 			"jumbo 

CVS commit: src/sys/dev/pci

2009-07-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 25 13:52:47 UTC 2009

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
Call prop_dictionary_set_uint32() before mii_init() so that brgphy
can do prop_dictionary_get_uint32() correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/pci/if_bge.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.166 src/sys/dev/pci/if_bge.c:1.167
--- src/sys/dev/pci/if_bge.c:1.166	Thu Jul 23 05:05:13 2009
+++ src/sys/dev/pci/if_bge.c	Sat Jul 25 13:52:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.166 2009/07/23 05:05:13 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.167 2009/07/25 13:52:47 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.166 2009/07/23 05:05:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.167 2009/07/25 13:52:47 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "vlan.h"
@@ -2559,6 +2559,10 @@
 		sc->bge_flags |= BGE_PHY_FIBER_TBI;
 	}
 
+	/* set phyflags before mii_attach() */
+	dict = device_properties(self);
+	prop_dictionary_set_uint32(dict, "phyflags", sc->bge_flags);
+
 	if (sc->bge_flags & BGE_PHY_FIBER_TBI) {
 		ifmedia_init(&sc->bge_ifmedia, IFM_IMASK, bge_ifmedia_upd,
 		bge_ifmedia_sts);
@@ -2647,9 +2651,6 @@
 		aprint_error_dev(self, "couldn't establish power handler\n");
 	else
 		pmf_class_network_register(self, ifp);
-
-	dict = device_properties(self);
-	prop_dictionary_set_uint32(dict, "phyflags", sc->bge_flags);
 }
 
 static void



CVS commit: src/sys/dev/pci

2009-07-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 30 03:46:49 UTC 2009

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Fix the bug that another lock mechanism is used to access Kumeran registers
on i80003 and ICHs.

Fix yet another i80003 ONLY workaround. The code to modifing TIPG register
is only for i80003.

Set the Re-Transmit on Late Collision(RTLC) flag for all devices.

Fix a typo in a printf message.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.177 src/sys/dev/pci/if_wm.c:1.178
--- src/sys/dev/pci/if_wm.c:1.177	Tue Jul 14 00:00:44 2009
+++ src/sys/dev/pci/if_wm.c	Thu Jul 30 03:46:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.177 2009/07/14 00:00:44 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.178 2009/07/30 03:46:48 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.177 2009/07/14 00:00:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.178 2009/07/30 03:46:48 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -566,8 +566,8 @@
 static int	wm_gmii_mediachange(struct ifnet *);
 static void	wm_gmii_mediastatus(struct ifnet *, struct ifmediareq *);
 
-static int	wm_kmrn_i80003_readreg(struct wm_softc *, int);
-static void	wm_kmrn_i80003_writereg(struct wm_softc *, int, int);
+static int	wm_kmrn_readreg(struct wm_softc *, int);
+static void	wm_kmrn_writereg(struct wm_softc *, int, int);
 
 static int	wm_match(device_t, cfdata_t, void *);
 static void	wm_attach(device_t, device_t, void *);
@@ -3308,12 +3308,12 @@
 			 * polling the phy; this fixes erroneous timeouts at
 			 * 10Mbps.
 			 */
-			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_TIMEOUTS,
+			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_TIMEOUTS,
 			0x);
-			val = wm_kmrn_i80003_readreg(sc,
+			val = wm_kmrn_readreg(sc,
 			KUMCTRLSTA_OFFSET_INB_PARAM);
 			val |= 0x3F;
-			wm_kmrn_i80003_writereg(sc,
+			wm_kmrn_writereg(sc,
 			KUMCTRLSTA_OFFSET_INB_PARAM, val);
 			break;
 		default:
@@ -3326,11 +3326,11 @@
 			CSR_WRITE(sc, WMREG_CTRL_EXT, val);
 
 			/* Bypass RX and TX FIFO's */
-			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_FIFO_CTRL,
+			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_FIFO_CTRL,
 			KUMCTRLSTA_FIFO_CTRL_RX_BYPASS | 
 			KUMCTRLSTA_FIFO_CTRL_TX_BYPASS);
 		
-			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_INB_CTRL,
+			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_INB_CTRL,
 			KUMCTRLSTA_INB_CTRL_DIS_PADDING |
 			KUMCTRLSTA_INB_CTRL_LINK_TMOUT_DFLT);
 		}
@@ -3407,12 +3407,11 @@
 	 * a collision distance suitable for FDX, but update it whe
 	 * we resolve the media type.
 	 */
-	sc->sc_tctl = TCTL_EN | TCTL_PSP | TCTL_CT(TX_COLLISION_THRESHOLD) |
-	TCTL_COLD(TX_COLLISION_DISTANCE_FDX);
+	sc->sc_tctl = TCTL_EN | TCTL_PSP | TCTL_RTLC
+	| TCTL_CT(TX_COLLISION_THRESHOLD)
+	| TCTL_COLD(TX_COLLISION_DISTANCE_FDX);
 	if (sc->sc_type >= WM_T_82571)
 		sc->sc_tctl |= TCTL_MULR;
-	if (sc->sc_type >= WM_T_80003)
-		sc->sc_tctl |= TCTL_RTLC;
 	CSR_WRITE(sc, WMREG_TCTL, sc->sc_tctl);
 
 	if (sc->sc_type == WM_T_80003) {
@@ -5001,15 +5000,15 @@
 	CSR_WRITE(sc, WMREG_TCTL, sc->sc_tctl);
 	CSR_WRITE(sc, (sc->sc_type < WM_T_82543) ? WMREG_OLD_FCRTL
 		 : WMREG_FCRTL, sc->sc_fcrtl);
-	if (sc->sc_type >= WM_T_80003) {
+	if (sc->sc_type == WM_T_80003) {
 		switch(IFM_SUBTYPE(sc->sc_mii.mii_media_active)) {
 		case IFM_1000_T:
-			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_HD_CTRL,
+			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_HD_CTRL,
 			KUMCTRLSTA_HD_CTRL_1000_DEFAULT);
 			sc->sc_tipg =  TIPG_1000T_80003_DFLT;
 			break;
 		default:
-			wm_kmrn_i80003_writereg(sc, KUMCTRLSTA_OFFSET_HD_CTRL,
+			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_HD_CTRL,
 			KUMCTRLSTA_HD_CTRL_10_100_DEFAULT);
 			sc->sc_tipg =  TIPG_10_100_80003_DFLT;
 			break;
@@ -5019,20 +5018,27 @@
 }
 
 /*
- * wm_kmrn_i80003_readreg:
+ * wm_kmrn_readreg:
  *
  *	Read a kumeran register
  */
 static int
-wm_kmrn_i80003_readreg(struct wm_softc *sc, int reg)
+wm_kmrn_readreg(struct wm_softc *sc, int reg)
 {
-	int func = ((CSR_READ(sc, WMREG_STATUS) >> STATUS_FUNCID_SHIFT) & 1);
 	int rv;
 
-	if (wm_get_swfw_semaphore(sc, func ? SWFW_PHY1_SM : SWFW_PHY0_SM)) {
-		aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
-		__func__);
-		return 0;
+	if (sc->sc_flags == WM_F_SWFW_SYNC) {
+		if (wm_get_swfw_semaphore(sc, SWFW_MAC_CSR_SM)) {
+			aprint_error_dev(sc->sc_dev,
+			"%s: failed to get semaphore\n", __func__);
+			return 0;
+		}
+	} else 	if (sc->sc_flags == WM_F_SWFWHW_SYNC) {
+		if (wm_get_swfwhw_semaphore(sc)) {
+			aprint_error_dev(sc->sc_dev,
+			"%s: failed to get semaphore\n", __func__);
+			return 0;
+		}
 	}
 

CVS commit: src/sys/dev/pci

2009-08-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug  6 03:03:46 UTC 2009

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 If the difference bettween last flag and new flag is only IFF_PROMISC or
IFF_ALLMULTI, set multicast filter only to prevent link down. Tested by
Mark Davies and me. Fixes PR#29126 for wm.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.178 src/sys/dev/pci/if_wm.c:1.179
--- src/sys/dev/pci/if_wm.c:1.178	Thu Jul 30 03:46:48 2009
+++ src/sys/dev/pci/if_wm.c	Thu Aug  6 03:03:46 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.178 2009/07/30 03:46:48 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.179 2009/08/06 03:03:46 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.178 2009/07/30 03:46:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.179 2009/08/06 03:03:46 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -274,6 +274,7 @@
 
 	wm_chip_type sc_type;		/* chip type */
 	int sc_flags;			/* flags; see below */
+	int sc_if_flags;		/* last if_flags */
 	int sc_bus_speed;		/* PCI/PCIX bus speed */
 	int sc_pcix_offset;		/* PCIX capability register offset */
 	int sc_flowflags;		/* 802.3x flow control flags */
@@ -2367,11 +2368,40 @@
 	struct ifreq *ifr = (struct ifreq *) data;
 	struct ifaddr *ifa = (struct ifaddr *)data;
 	struct sockaddr_dl *sdl;
-	int s, error;
+	int diff, s, error;
 
 	s = splnet();
 
 	switch (cmd) {
+	case SIOCSIFFLAGS:
+		if ((error = ifioctl_common(ifp, cmd, data)) != 0)
+			break;
+		if (ifp->if_flags & IFF_UP) {
+			diff = (ifp->if_flags ^ sc->sc_if_flags)
+			& (IFF_PROMISC | IFF_ALLMULTI);
+			if ((diff & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+/*
+ * If the difference bettween last flag and
+ * new flag is only IFF_PROMISC or
+ * IFF_ALLMULTI, set multicast filter only
+ * (don't reset to prevent link down).
+ */
+wm_set_filter(sc);
+			} else {
+/*
+ * Reset the interface to pick up changes in
+ * any other flags that affect the hardware
+ * state.
+ */
+wm_init(ifp);
+			}
+		} else {
+			if (ifp->if_flags & IFF_RUNNING)
+wm_stop(ifp, 1);
+		}
+		sc->sc_if_flags = ifp->if_flags;
+		error = 0;
+		break;
 	case SIOCSIFMEDIA:
 	case SIOCGIFMEDIA:
 		/* Flow control requires full-duplex mode. */



CVS commit: src/sys/arch/mips

2009-08-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug  6 04:34:51 UTC 2009

Modified Files:
src/sys/arch/mips/include: mips_opcode.h
src/sys/arch/mips/mips: db_disasm.c

Log Message:
Add disassemble code for DMT, DMF, MTH and MFH.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/include/mips_opcode.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/mips/mips/db_disasm.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/arch/mips/include/mips_opcode.h
diff -u src/sys/arch/mips/include/mips_opcode.h:1.12 src/sys/arch/mips/include/mips_opcode.h:1.13
--- src/sys/arch/mips/include/mips_opcode.h:1.12	Sun Dec 11 12:18:09 2005
+++ src/sys/arch/mips/include/mips_opcode.h	Thu Aug  6 04:34:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_opcode.h,v 1.12 2005/12/11 12:18:09 christos Exp $	*/
+/*	$NetBSD: mips_opcode.h,v 1.13 2009/08/06 04:34:50 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -281,12 +281,14 @@
  */
 #define OP_MF		000
 #define OP_DMF		001		/* MIPS-II, for r4000 port */
+#define OP_CF		002
+#define OP_MFH		003
 #define OP_MT		004
 #define OP_DMT		005		/* MIPS-II, for r4000 port */
+#define OP_CT		006
+#define OP_MTH		007
 #define OP_BCx		010
 #define OP_BCy		014
-#define OP_CF		002
-#define OP_CT		006
 
 /*
  * Values for the 'rt' field when 'op' == OP_COPz.

Index: src/sys/arch/mips/mips/db_disasm.c
diff -u src/sys/arch/mips/mips/db_disasm.c:1.19 src/sys/arch/mips/mips/db_disasm.c:1.20
--- src/sys/arch/mips/mips/db_disasm.c:1.19	Wed Feb 28 04:21:53 2007
+++ src/sys/arch/mips/mips/db_disasm.c	Thu Aug  6 04:34:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.19 2007/02/28 04:21:53 thorpej Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.20 2009/08/06 04:34:50 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.19 2007/02/28 04:21:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.20 2009/08/06 04:34:50 msaitoh Exp $");
 
 #include 
 #include 
@@ -397,6 +397,30 @@
 			i.RType.rd);
 			break;
 
+		case OP_DMT:
+			db_printf("dmtc1\t%s,f%d",
+			reg_name[i.RType.rt],
+			i.RType.rd);
+			break;
+
+		case OP_DMF:
+			db_printf("dmfc1\t%s,f%d",
+			reg_name[i.RType.rt],
+			i.RType.rd);
+			break;
+
+		case OP_MTH:
+			db_printf("mthc1\t%s,f%d",
+			reg_name[i.RType.rt],
+			i.RType.rd);
+			break;
+
+		case OP_MFH:
+			db_printf("mfhc1\t%s,f%d",
+			reg_name[i.RType.rt],
+			i.RType.rd);
+			break;
+
 		default:
 			db_printf("%s.%s\tf%d,f%d,f%d",
 			cop1_name[i.FRType.func],



CVS commit: src/sys/net

2009-08-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Aug 12 11:17:17 UTC 2009

Modified Files:
src/sys/net: if_media.h

Log Message:
Add 1000BASE-BX10.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/net/if_media.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/net/if_media.h
diff -u src/sys/net/if_media.h:1.51 src/sys/net/if_media.h:1.52
--- src/sys/net/if_media.h:1.51	Tue Sep  9 20:12:18 2008
+++ src/sys/net/if_media.h	Wed Aug 12 11:17:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_media.h,v 1.51 2008/09/09 20:12:18 mhitch Exp $	*/
+/*	$NetBSD: if_media.h,v 1.52 2009/08/12 11:17:17 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -179,6 +179,7 @@
 #define	IFM_10G_SR	19		/* 10GBase-SR 850nm Multi-mode */
 #define	IFM_10G_CX4	20		/* 10GBase CX4 copper */
 #define	IFM_2500_SX	21		/* 2500baseSX - multi-mode fiber */
+#define	IFM_1000_BX10	22		/* 1000base-BX10 */
 
 #define	IFM_ETH_MASTER	0x0100	/* master mode (1000baseT) */
 #define	IFM_ETH_RXPAUSE	0x0200	/* receive PAUSE frames */
@@ -410,6 +411,7 @@
 	{ IFM_ETHER | IFM_1000_CX,	"1000baseCX" },			\
 	{ IFM_ETHER | IFM_1000_CX,	"1000CX" },			\
 	{ IFM_ETHER | IFM_1000_CX,	"1000BASE-CX" },		\
+	{ IFM_ETHER | IFM_1000_BX10,	"1000BASE-BX10" },		\
 	{ IFM_ETHER | IFM_1000_T,	"1000baseT" },			\
 	{ IFM_ETHER | IFM_1000_T,	"1000T" },			\
 	{ IFM_ETHER | IFM_1000_T,	"1000BASE-T" },			\



CVS commit: src/sys/dev

2009-12-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec 16 04:50:36 UTC 2009

Modified Files:
src/sys/dev/mii: igphy.c
src/sys/dev/pci: if_wm.c
Added Files:
src/sys/dev/pci: if_wmvar.h

Log Message:
Ee-enable igphy's 82566 support.
 - Patch for the DSP code is only for 8254[17] and we have to apply the
   different patches between rev. 1 and rev. 2.
 - The workaround for analog fuse is only for 82547 rev. 1.
 - The workaround for smartspeed is only for 8254[17]

see http://mail-index.netbsd.org/tech-net/2009/08/05/msg001546.html


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/mii/igphy.c
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r0 -r1.3 src/sys/dev/pci/if_wmvar.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/mii/igphy.c
diff -u src/sys/dev/mii/igphy.c:1.18 src/sys/dev/mii/igphy.c:1.19
--- src/sys/dev/mii/igphy.c:1.18	Thu Aug  6 04:58:48 2009
+++ src/sys/dev/mii/igphy.c	Wed Dec 16 04:50:35 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: igphy.c,v 1.18 2009/08/06 04:58:48 kml Exp $	*/
+/*	$NetBSD: igphy.c,v 1.19 2009/12/16 04:50:35 msaitoh Exp $	*/
 
 /*
  * The Intel copyright applies to the analog register setup, and the
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.18 2009/08/06 04:58:48 kml Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.19 2009/12/16 04:50:35 msaitoh Exp $");
 
 #include "opt_mii.h"
 
@@ -87,12 +87,13 @@
 #include 
 #include 
 #include 
-
 #include 
+#include 
 
 struct igphy_softc {
 	struct mii_softc sc_mii;
 	int sc_smartspeed;
+	uint32_t sc_mactype;
 };
 
 static void igphy_reset(struct mii_softc *);
@@ -116,6 +117,9 @@
 	{ MII_OUI_yyINTEL,		MII_MODEL_yyINTEL_IGP01E1000,
 	  MII_STR_yyINTEL_IGP01E1000 },
 
+	{ MII_OUI_yyINTEL,		MII_MODEL_yyINTEL_I82566,
+	  MII_STR_yyINTEL_I82566 },
+
 	{0,0,
 	 NULL },
 };
@@ -138,11 +142,17 @@
 	struct mii_attach_args *ma = aux;
 	struct mii_data *mii = ma->mii_data;
 	const struct mii_phydesc *mpd;
+	struct igphy_softc *igsc = (struct igphy_softc *) sc;
+	prop_dictionary_t dict;
 
 	mpd = mii_phy_match(ma, igphys);
 	aprint_naive(": Media interface\n");
 	aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
 
+	dict = device_properties(parent);
+	if (!prop_dictionary_get_uint32(dict, "mactype", &igsc->sc_mactype))
+		aprint_error("WARNING! Failed to get mactype\n");
+
 	sc->mii_dev = self;
 	sc->mii_inst = mii->mii_instance;
 	sc->mii_phy = ma->mii_phyno;
@@ -169,6 +179,7 @@
 static void
 igphy_load_dspcode(struct mii_softc *sc)
 {
+	struct igphy_softc *igsc = (struct igphy_softc *) sc;
 	static const struct {
 		int reg;
 		uint16_t val;
@@ -186,6 +197,18 @@
 	};
 	int i;
 
+	/* This workaround is only for 82541 and 82547 */
+	switch (igsc->sc_mactype) {
+	case WM_T_82541:
+	case WM_T_82547:
+	case WM_T_82541_2:
+	case WM_T_82547_2:
+		break;
+	default:
+		/* byebye */
+		return;
+	}
+
 	delay(10);
 
 	PHY_WRITE(sc, MII_IGPHY_PAGE_SELECT, 0x);
@@ -193,8 +216,19 @@
 
 	delay(5);
 
-	for (i = 0; dspcode[i].reg != 0; i++)
-		IGPHY_WRITE(sc, dspcode[i].reg, dspcode[i].val);
+	switch (igsc->sc_mactype) {
+	case WM_T_82541:
+	case WM_T_82547:
+		for (i = 0; dspcode[i].reg != 0; i++)
+			IGPHY_WRITE(sc, dspcode[i].reg, dspcode[i].val);
+		break;
+	case WM_T_82541_2:
+	case WM_T_82547_2:
+		IGPHY_WRITE(sc, 0x1f73, 0x0099);
+		break;
+	default:
+		break;
+	}
 
 	PHY_WRITE(sc, MII_IGPHY_PAGE_SELECT,0x);
 	PHY_WRITE(sc, 0x, 0x3300);
@@ -203,31 +237,34 @@
 static void
 igphy_reset(struct mii_softc *sc)
 {
+	struct igphy_softc *igsc = (struct igphy_softc *) sc;
 	uint16_t fused, fine, coarse;
 
 	mii_phy_reset(sc);
 	igphy_load_dspcode(sc);
 
-	fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_SPARE_FUSE_STATUS);
-	if ((fused & ANALOG_SPARE_FUSE_ENABLED) == 0) {
-		fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_FUSE_STATUS);
-
-		fine = fused & ANALOG_FUSE_FINE_MASK;
-		coarse = fused & ANALOG_FUSE_COARSE_MASK;
-
-		if (coarse > ANALOG_FUSE_COARSE_THRESH) {
-			coarse -= ANALOG_FUSE_COARSE_10;
-			fine -= ANALOG_FUSE_FINE_1;
-		} else if (coarse == ANALOG_FUSE_COARSE_THRESH)
-			fine -= ANALOG_FUSE_FINE_10;
-
-		fused = (fused & ANALOG_FUSE_POLY_MASK) |
-			(fine & ANALOG_FUSE_FINE_MASK) |
-			(coarse & ANALOG_FUSE_COARSE_MASK);
-
-		IGPHY_WRITE(sc, MII_IGPHY_ANALOG_FUSE_CONTROL, fused);
-		IGPHY_WRITE(sc, MII_IGPHY_ANALOG_FUSE_BYPASS,
-		ANALOG_FUSE_ENABLE_SW_CONTROL);
+	if (igsc->sc_mactype == WM_T_82547) {
+		fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_SPARE_FUSE_STATUS);
+		if ((fused & ANALOG_SPARE_FUSE_ENABLED) == 0) {
+			fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_FUSE_STATUS);
+
+			fine = fused & ANALOG_FUSE_FINE_MASK;
+			coarse = fused & ANALOG_FUSE_COARSE_MASK;
+
+			if (coarse > ANALOG_FUSE_COARSE_THRESH) {
+coarse -= ANALOG_FUSE_COARSE_10;
+fine -= ANALOG_FUSE_FINE_1;
+			} else if (coarse == ANALOG_FUSE_COARSE_THR

CVS commit: src/sys/dev

2009-12-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec 16 14:37:26 UTC 2009

Modified Files:
src/sys/dev/mii: igphy.c
src/sys/dev/pci: if_wm.c if_wmvar.h

Log Message:
Sync with Intel's original em driver:
- Add dspcode for igp3 and use it when the EEPROM isn't available.
- Add some delays.
- Stop the PHY transmitter before patching the DSP code and restart it after 
wrote.
- Save and restore register 0x2f5b.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/mii/igphy.c
cvs rdiff -u -r1.182 -r1.183 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_wmvar.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/mii/igphy.c
diff -u src/sys/dev/mii/igphy.c:1.19 src/sys/dev/mii/igphy.c:1.20
--- src/sys/dev/mii/igphy.c:1.19	Wed Dec 16 04:50:35 2009
+++ src/sys/dev/mii/igphy.c	Wed Dec 16 14:37:26 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: igphy.c,v 1.19 2009/12/16 04:50:35 msaitoh Exp $	*/
+/*	$NetBSD: igphy.c,v 1.20 2009/12/16 14:37:26 msaitoh Exp $	*/
 
 /*
  * The Intel copyright applies to the analog register setup, and the
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.19 2009/12/16 04:50:35 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.20 2009/12/16 14:37:26 msaitoh Exp $");
 
 #include "opt_mii.h"
 
@@ -94,10 +94,12 @@
 	struct mii_softc sc_mii;
 	int sc_smartspeed;
 	uint32_t sc_mactype;
+	uint32_t sc_macflags;
 };
 
 static void igphy_reset(struct mii_softc *);
 static void igphy_load_dspcode(struct mii_softc *);
+static void igphy_load_dspcode_igp3(struct mii_softc *);
 static void igphy_smartspeed_workaround(struct mii_softc *sc);
 
 static int	igphymatch(device_t, cfdata_t, void *);
@@ -152,6 +154,8 @@
 	dict = device_properties(parent);
 	if (!prop_dictionary_get_uint32(dict, "mactype", &igsc->sc_mactype))
 		aprint_error("WARNING! Failed to get mactype\n");
+	if (!prop_dictionary_get_uint32(dict, "macflags", &igsc->sc_macflags))
+		aprint_error("WARNING! Failed to get macflags\n");
 
 	sc->mii_dev = self;
 	sc->mii_inst = mii->mii_instance;
@@ -176,62 +180,127 @@
 	aprint_normal("\n");
 }
 
+typedef struct {
+	int reg;
+	uint16_t val;
+} dspcode;
+
+static const dspcode igp1code[] = {
+	{ 0x1f95, 0x0001 },
+	{ 0x1f71, 0xbd21 },
+	{ 0x1f79, 0x0018 },
+	{ 0x1f30, 0x1600 },
+	{ 0x1f31, 0x0014 },
+	{ 0x1f32, 0x161c },
+	{ 0x1f94, 0x0003 },
+	{ 0x1f96, 0x003f },
+	{ 0x2010, 0x0008 },
+	{ 0, 0 },
+};
+
+static const dspcode igp1code_r2[] = {
+	{ 0x1f73, 0x0099 },
+	{ 0, 0 },
+};
+
+static const dspcode igp3code[] = {
+	{ 0x2f5b, 0x9018},
+	{ 0x2f52, 0x},
+	{ 0x2fb1, 0x8b24},
+	{ 0x2fb2, 0xf8f0},
+	{ 0x2010, 0x10b0},
+	{ 0x2011, 0x},
+	{ 0x20dd, 0x249a},
+	{ 0x20de, 0x00d3},
+	{ 0x28b4, 0x04ce},
+	{ 0x2f70, 0x29e4},
+	{ 0x, 0x0140},
+	{ 0x1f30, 0x1606},
+	{ 0x1f31, 0xb814},
+	{ 0x1f35, 0x002a},
+	{ 0x1f3e, 0x0067},
+	{ 0x1f54, 0x0065},
+	{ 0x1f55, 0x002a},
+	{ 0x1f56, 0x002a},
+	{ 0x1f72, 0x3fb0},
+	{ 0x1f76, 0xc0ff},
+	{ 0x1f77, 0x1dec},
+	{ 0x1f78, 0xf9ef},
+	{ 0x1f79, 0x0210},
+	{ 0x1895, 0x0003},
+	{ 0x1796, 0x0008},
+	{ 0x1798, 0xd008},
+	{ 0x1898, 0xd918},
+	{ 0x187a, 0x0800},
+	{ 0x0019, 0x008d},
+	{ 0x001b, 0x2080},
+	{ 0x0014, 0x0045},
+	{ 0x, 0x1340},
+	{ 0, 0 },
+};
+
+/* DSP patch for igp1 and igp2 */
 static void
 igphy_load_dspcode(struct mii_softc *sc)
 {
 	struct igphy_softc *igsc = (struct igphy_softc *) sc;
-	static const struct {
-		int reg;
-		uint16_t val;
-	} dspcode[] = {
-		{ 0x1f95, 0x0001 },
-		{ 0x1f71, 0xbd21 },
-		{ 0x1f79, 0x0018 },
-		{ 0x1f30, 0x1600 },
-		{ 0x1f31, 0x0014 },
-		{ 0x1f32, 0x161c },
-		{ 0x1f94, 0x0003 },
-		{ 0x1f96, 0x003f },
-		{ 0x2010, 0x0008 },
-		{ 0, 0 },
-	};
+	const dspcode *code;
+	uint16_t reg;
 	int i;
 
 	/* This workaround is only for 82541 and 82547 */
 	switch (igsc->sc_mactype) {
 	case WM_T_82541:
 	case WM_T_82547:
+		code = igp1code;
+		break;
 	case WM_T_82541_2:
 	case WM_T_82547_2:
+		code = igp1code_r2;
 		break;
 	default:
-		/* byebye */
-		return;
+		return;	/* byebye */
 	}
 
-	delay(10);
+	/* Delay after phy reset to enable NVM configuration to load */
+	delay(2);
+
+	/*
+	 * Save off the current value of register 0x2F5B to be restored at
+	 * the end of this routine.
+	 */
+	reg = IGPHY_READ(sc, 0x2f5b);
+
+	/* Disabled the PHY transmitter */
+	IGPHY_WRITE(sc, 0x2f5b, 0x0003);
+
+	delay(2);
 
 	PHY_WRITE(sc, MII_IGPHY_PAGE_SELECT, 0x);
 	PHY_WRITE(sc, 0x, 0x0140);
 
-	delay(5);
+	delay(5000);
 
-	switch (igsc->sc_mactype) {
-	case WM_T_82541:
-	case WM_T_82547:
-		for (i = 0; dspcode[i].reg != 0; i++)
-			IGPHY_WRITE(sc, dspcode[i].reg, dspcode[i].val);
-		break;
-	case WM_T_82541_2:
-	case WM_T_82547_2:
-		IGPHY_WRITE(sc, 0x1f73, 0x0099);
-		break;
-	default:
-		break;
-	}
+	for (i = 0; !((code[i].reg == 0) && (code[i].val == 0)); i++)
+		IGPHY_WRITE(sc, code[i].reg, code[i].val);
 
 	PHY_WRITE(sc, M

CVS commit: src/sys/dev/pci

2009-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Dec 27 20:36:38 UTC 2009

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Fix the bug that ICH9 can't found a PHY. This fix is not good, but it's
the same as e1000 driver... Fixes PR#42237


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.183 src/sys/dev/pci/if_wm.c:1.184
--- src/sys/dev/pci/if_wm.c:1.183	Wed Dec 16 14:37:26 2009
+++ src/sys/dev/pci/if_wm.c	Sun Dec 27 20:36:38 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.183 2009/12/16 14:37:26 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.184 2009/12/27 20:36:38 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.183 2009/12/16 14:37:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.184 2009/12/27 20:36:38 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -965,7 +965,7 @@
 			sc->sc_type = WM_T_82542_2_0;
 	}
 
-	/* Set device properties (mactype)*/
+	/* Set device properties (mactype) */
 	dict = device_properties(sc->sc_dev);
 	prop_dictionary_set_uint32(dict, "mactype", sc->sc_type);
 
@@ -1353,7 +1353,7 @@
 sc->sc_flags |= WM_F_EEPROM_INVALID;
 		}
 	}
-	/* Set device properties (macflags)*/
+	/* Set device properties (macflags) */
 	prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags);
 
 	if (sc->sc_flags & WM_F_EEPROM_INVALID)
@@ -4540,10 +4540,7 @@
 	/* Initialize our media structures and probe the GMII. */
 	sc->sc_mii.mii_ifp = ifp;
 
-	if (sc->sc_type == WM_T_ICH10) {
-		sc->sc_mii.mii_readreg = wm_gmii_bm_readreg;
-		sc->sc_mii.mii_writereg = wm_gmii_bm_writereg;
-	} else if (sc->sc_type >= WM_T_80003) {
+	if (sc->sc_type >= WM_T_80003) {
 		sc->sc_mii.mii_readreg = wm_gmii_i80003_readreg;
 		sc->sc_mii.mii_writereg = wm_gmii_i80003_writereg;
 	} else if (sc->sc_type >= WM_T_82544) {
@@ -4563,11 +4560,35 @@
 
 	mii_attach(sc->sc_dev, &sc->sc_mii, 0x, MII_PHY_ANY,
 	MII_OFFSET_ANY, MIIF_DOPAUSE);
+
+	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+		/* if failed, retry with *_bm_* */
+		sc->sc_mii.mii_readreg = wm_gmii_bm_readreg;
+		sc->sc_mii.mii_writereg = wm_gmii_bm_writereg;
+
+		mii_attach(sc->sc_dev, &sc->sc_mii, 0x, MII_PHY_ANY,
+		MII_OFFSET_ANY, MIIF_DOPAUSE);
+	}
 	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
 		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
 		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
-	} else
+	} else {
+		if (sc->sc_type >= WM_T_82574) {
+			struct mii_softc *child;
+
+			child = LIST_FIRST(&sc->sc_mii.mii_phys);
+			/* fix read/write functions as e1000 driver */
+			if (device_is_a(child->mii_dev, "igphy")) {
+sc->sc_mii.mii_readreg = wm_gmii_i80003_readreg;
+sc->sc_mii.mii_writereg = wm_gmii_i80003_writereg;
+			} else {
+sc->sc_mii.mii_readreg = wm_gmii_bm_readreg;
+sc->sc_mii.mii_writereg = wm_gmii_bm_writereg;
+			}
+		}
+
 		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
+	}
 }
 
 /*



CVS commit: src/sys/dev/pci

2009-12-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 29 15:52:18 UTC 2009

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
add entry for i82583V


To generate a diff of this commit:
cvs rdiff -u -r1.1005 -r1.1006 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1005 src/sys/dev/pci/pcidevs:1.1006
--- src/sys/dev/pci/pcidevs:1.1005	Sun Dec 13 19:19:47 2009
+++ src/sys/dev/pci/pcidevs	Tue Dec 29 15:52:18 2009
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1005 2009/12/13 19:19:47 matt Exp $
+$NetBSD: pcidevs,v 1.1006 2009/12/29 15:52:18 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2332,6 +2332,7 @@
 product INTEL 82870P2_PPB	0x1460	82870P2 P64H2 PCI-PCI Bridge
 product INTEL 82870P2_IOxAPIC	0x1461	82870P2 P64H2 IOxAPIC
 product INTEL 82870P2_HPLUG	0x1462	82870P2 P64H2 Hot Plug Controller
+product INTEL 82583V		0x150c	i82583V 1000baseT Ethernet
 product INTEL 80960_RP		0x1960	ROB-in i960RP Microprocessor
 product INTEL 80960RM_2		0x1962	i960 RM PCI-PCI
 product INTEL 82840_HB		0x1a21	82840 Host



CVS commit: src/sys/dev/pci

2009-12-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 29 16:01:22 UTC 2009

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h if_wmvar.h

Log Message:
- Fix an incorrect test for WM_F_EEPROM_INALID since rev. 1.183. Some old
  chips don't set EECD_EE_PRES.
- Fix a bug that WM_F_EEPROM_SPI and WM_F_FLASH are set.
- Add an missing decrement for a timeout reported by Wolfgang Stukenbrock
  in PR#42422.
- Add support for i82583V.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/if_wmvar.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.184 src/sys/dev/pci/if_wm.c:1.185
--- src/sys/dev/pci/if_wm.c:1.184	Sun Dec 27 20:36:38 2009
+++ src/sys/dev/pci/if_wm.c	Tue Dec 29 16:01:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.184 2009/12/27 20:36:38 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.185 2009/12/29 16:01:21 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.184 2009/12/27 20:36:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.185 2009/12/29 16:01:21 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -530,6 +530,7 @@
 static int	wm_kmrn_readreg(struct wm_softc *, int);
 static void	wm_kmrn_writereg(struct wm_softc *, int, int);
 
+static void	wm_set_spiaddrsize(struct wm_softc *);
 static int	wm_match(device_t, cfdata_t, void *);
 static void	wm_attach(device_t, device_t, void *);
 static int	wm_is_onboard_nvm_eeprom(struct wm_softc *);
@@ -547,14 +548,12 @@
 static int32_t	wm_ich8_flash_cycle(struct wm_softc *, uint32_t);
 static int32_t	wm_read_ich8_data(struct wm_softc *, uint32_t,
 		 uint32_t, uint16_t *);
-static int32_t	wm_read_ich8_byte(struct wm_softc *sc, uint32_t, uint8_t *);
-static int32_t	wm_read_ich8_word(struct wm_softc *sc, uint32_t, uint16_t *);
+static int32_t	wm_read_ich8_byte(struct wm_softc *, uint32_t, uint8_t *);
+static int32_t	wm_read_ich8_word(struct wm_softc *, uint32_t, uint16_t *);
 static void	wm_82547_txfifo_stall(void *);
 static int	wm_check_mng_mode(struct wm_softc *);
 static int	wm_check_mng_mode_ich8lan(struct wm_softc *);
-#if 0
 static int	wm_check_mng_mode_82574(struct wm_softc *);
-#endif
 static int	wm_check_mng_mode_generic(struct wm_softc *);
 static void	wm_get_hw_control(struct wm_softc *);
 static int	wm_check_for_link(struct wm_softc *);
@@ -562,7 +561,6 @@
 CFATTACH_DECL_NEW(wm, sizeof(struct wm_softc),
 wm_match, wm_attach, NULL, NULL);
 
-
 /*
  * Devices supported by this driver.
  */
@@ -772,6 +770,10 @@
 	  "Intel i82574L",
 	  WM_T_82574,		WMP_F_1000T },
 
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82583V,
+	  "Intel i82583V",
+	  WM_T_82583,		WMP_F_1000T },
+
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_80K3LAN_CPR_DPT,
 	  "i80003 dual 1000baseT Ethernet",
 	  WM_T_80003,		WMP_F_1000T },
@@ -884,6 +886,16 @@
 		wa->wa_high = 0;
 }
 
+static void
+wm_set_spiaddrsize(struct wm_softc *sc)
+{
+	uint32_t reg;
+
+	sc->sc_flags |= WM_F_EEPROM_SPI;
+	reg = CSR_READ(sc, WMREG_EECD);
+	sc->sc_ee_addrbits = (reg & EECD_EE_ABITS) ? 16 : 8;
+}
+
 static const struct wm_product *
 wm_lookup(const struct pci_attach_args *pa)
 {
@@ -1214,7 +1226,6 @@
 		goto fail_3;
 	}
 
-
 	/*
 	 * Create the transmit buffer DMA maps.
 	 */
@@ -1261,6 +1272,7 @@
 	case WM_T_82572:
 	case WM_T_82573:
 	case WM_T_82574:
+	case WM_T_82583:
 	case WM_T_80003:
 	case WM_T_ICH8:
 	case WM_T_ICH9:
@@ -1275,10 +1287,75 @@
 	/*
 	 * Get some information about the EEPROM.
 	 */
-	if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
-	|| (sc->sc_type == WM_T_ICH10)) {
-		uint32_t flash_size;
-		sc->sc_flags |= WM_F_SWFWHW_SYNC | WM_F_EEPROM_FLASH;
+	switch (sc->sc_type) {
+	case WM_T_82542_2_0:
+	case WM_T_82542_2_1:
+	case WM_T_82543:
+	case WM_T_82544:
+		/* Microwire */
+		sc->sc_ee_addrbits = 6;
+		break;
+	case WM_T_82540:
+	case WM_T_82545:
+	case WM_T_82545_3:
+	case WM_T_82546:
+	case WM_T_82546_3:
+		/* Microwire */
+		reg = CSR_READ(sc, WMREG_EECD);
+		if (reg & EECD_EE_SIZE)
+			sc->sc_ee_addrbits = 8;
+		else
+			sc->sc_ee_addrbits = 6;
+		sc->sc_flags |= WM_F_EEPROM_HANDSHAKE;
+		break;
+	case WM_T_82541:
+	case WM_T_82541_2:
+	case WM_T_82547:
+	case WM_T_82547_2:
+		reg = CSR_READ(sc, WMREG_EECD);
+		if (reg & EECD_EE_TYPE) {
+			/* SPI */
+			wm_set_spiaddrsize(sc);
+		} else
+			/* Microwire */
+			sc->sc_ee_addrbits = (reg & EECD_EE_ABITS) ? 8 : 6;
+		sc->sc_flags |= WM_F_EEPROM_HANDSHAKE;
+		break;
+	case WM_T_82571:
+	case WM_T_82572:
+		/* SPI */
+		wm_set_spiaddrsize(sc);
+		sc->sc_flags |= WM_F_EEPROM_HANDSHAKE;
+		break;
+	case WM_T_82

CVS commit: src/doc

2009-12-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 29 17:26:50 UTC 2009

Modified Files:
src/doc: CHANGES

Log Message:
mention i82583V support in wm(4).


To generate a diff of this commit:
cvs rdiff -u -r1.1337 -r1.1338 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1337 src/doc/CHANGES:1.1338
--- src/doc/CHANGES:1.1337	Tue Dec 29 07:06:36 2009
+++ src/doc/CHANGES	Tue Dec 29 17:26:50 2009
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1337 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1338 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -511,3 +511,4 @@
 	openssh: Import 5.3. [christos 20091226]
 	gfb: Add a driver for Sun XVR-1000 graphics boards
 		[macallan 20091229]
+	wm(4): Add support for i82583V	[msaitoh 20091230]



CVS commit: src/sys/dev/pci

2010-01-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  5 09:31:21 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Fix the length of the delay() in wm_gmii_init(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.185 src/sys/dev/pci/if_wm.c:1.186
--- src/sys/dev/pci/if_wm.c:1.185	Tue Dec 29 16:01:21 2009
+++ src/sys/dev/pci/if_wm.c	Tue Jan  5 09:31:21 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.185 2009/12/29 16:01:21 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.186 2010/01/05 09:31:21 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.185 2009/12/29 16:01:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.186 2010/01/05 09:31:21 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -4517,13 +4517,13 @@
 			return;
 		}
 	}
-	if (sc->sc_type >= WM_T_82544) {
-		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_PHY_RESET);
-		delay(2);
 
-		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
-		delay(2);
-	} else {
+	switch (sc->sc_type) {
+	case WM_T_82542_2_0:
+	case WM_T_82542_2_1:
+		/* null ? */
+		break;
+	case WM_T_82543:
 		/*
 		 * With 82543, we need to force speed and duplex on the MAC
 		 * equal to what the PHY speed and duplex configuration is.
@@ -4543,14 +4543,64 @@
 		delay(10);
 
 		CSR_WRITE(sc, WMREG_CTRL_EXT, reg);
-		delay(1);
+		delay(10*1000);
 
 		CSR_WRITE(sc, WMREG_CTRL_EXT, reg | CTRL_EXT_SWDPIN(4));
-		delay(10);
+		delay(150);
 #if 0
 		sc->sc_ctrl_ext = reg | CTRL_EXT_SWDPIN(4);
 #endif
+		delay(20*1000);	/* extra delay to get PHY ID? */
+		break;
+	case WM_T_82544:	/* reset 1us */
+	case WM_T_82540:
+	case WM_T_82545:
+	case WM_T_82545_3:
+	case WM_T_82546:
+	case WM_T_82546_3:
+	case WM_T_82541:
+	case WM_T_82541_2:
+	case WM_T_82547:
+	case WM_T_82547_2:
+	case WM_T_82571:	/* reset 100us */
+	case WM_T_82572:
+	case WM_T_82573:
+	case WM_T_82574:
+	case WM_T_82583:
+	case WM_T_80003:
+		/* generic reset */
+		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_PHY_RESET);
+		delay((sc->sc_type >= WM_T_82571) ? 100 : 10*1000);
+		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
+		delay(150*1000);
+
+		if ((sc->sc_type == WM_T_82541)
+		|| (sc->sc_type == WM_T_82541_2)
+		|| (sc->sc_type == WM_T_82547)
+		|| (sc->sc_type == WM_T_82547_2)) {
+			/* workaround for igp are done in igp_reset() */
+			/* XXX add code to set LED after phy reset */
+		}
+		break;
+	case WM_T_ICH8:
+	case WM_T_ICH9:
+	case WM_T_ICH10:
+		/* generic reset */
+		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_PHY_RESET);
+		delay(100);
+		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
+		delay(150*1000);
+
+		/* Allow time for h/w to get to a quiescent state afer reset */
+		delay(10*1000);
+
+		/* XXX add code to set LED after phy reset */
+		break;
+	default:
+		panic("unknown sc_type\n");
+		break;
 	}
+
 	if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
 	|| (sc->sc_type == WM_T_ICH10))
 		wm_put_swfwhw_semaphore(sc);



CVS commit: src/sys/dev/pci

2010-01-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  5 10:02:01 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
 Fix the checking of jumbo frame function though I don't know whether
the function wokrs or not...

 Remove the extra macro definition for the offset 0x1a in EEPROM.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/if_wmreg.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.186 src/sys/dev/pci/if_wm.c:1.187
--- src/sys/dev/pci/if_wm.c:1.186	Tue Jan  5 09:31:21 2010
+++ src/sys/dev/pci/if_wm.c	Tue Jan  5 10:02:01 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.186 2010/01/05 09:31:21 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.187 2010/01/05 10:02:01 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.186 2010/01/05 09:31:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.187 2010/01/05 10:02:01 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -941,7 +941,7 @@
 	prop_data_t ea;
 	prop_number_t pn;
 	uint8_t enaddr[ETHER_ADDR_LEN];
-	uint16_t myea[ETHER_ADDR_LEN / 2], cfg1, cfg2, swdpin;
+	uint16_t myea[ETHER_ADDR_LEN / 2], cfg1, cfg2, swdpin, io3;
 	pcireg_t preg, memtype;
 	uint32_t reg;
 
@@ -1576,9 +1576,34 @@
 	IFQ_SET_MAXLEN(&ifp->if_snd, max(WM_IFQUEUELEN, IFQ_MAXLEN));
 	IFQ_SET_READY(&ifp->if_snd);
 
-	if (sc->sc_type != WM_T_82573 && sc->sc_type != WM_T_82574 &&
-	sc->sc_type != WM_T_82583 && sc->sc_type != WM_T_ICH8)
+	/* Check for jumbo frame */
+	switch (sc->sc_type) {
+	case WM_T_82573:
+		/* XXX limited to 9234 if ASPM is disabled */
+		wm_read_eeprom(sc, EEPROM_INIT_3GIO_3, 1, &io3);
+		if ((io3 & EEPROM_3GIO_3_ASPM_MASK) != 0)
+			sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
+		break;
+	case WM_T_82571:
+	case WM_T_82572:
+	case WM_T_82574:
+	case WM_T_80003:
+	case WM_T_ICH9:
+	case WM_T_ICH10:
+		/* XXX limited to 9234 */
 		sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
+		break;
+	case WM_T_82542_2_0:
+	case WM_T_82542_2_1:
+	case WM_T_82583:
+	case WM_T_ICH8:
+		/* No support for jumbo frame */
+		break;
+	default:
+		/* ETHER_MAX_LEN_JUMBO */
+		sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
+		break;
+	}
 
 	/*
 	 * If we're a i82543 or greater, we can support VLANs.
@@ -3483,10 +3508,9 @@
 	sc->sc_rctl = RCTL_EN | RCTL_LBM_NONE | RCTL_RDMTS_1_2 | RCTL_DPF
 	| RCTL_MO(sc->sc_mchash_type);
 
-	/* 82573 doesn't support jumbo frame */
-	if (sc->sc_type != WM_T_82573 && sc->sc_type != WM_T_82574 &&
-	sc->sc_type != WM_T_82583 && sc->sc_type != WM_T_ICH8)
-		sc->sc_rctl |= RCTL_LPE;
+	if (((sc->sc_ethercom.ec_capabilities & ETHERCAP_JUMBO_MTU) != 0)
+	&& (ifp->if_mtu > ETHERMTU))
+			sc->sc_rctl |= RCTL_LPE;
 
 	if (MCLBYTES == 2048) {
 		sc->sc_rctl |= RCTL_2k;
@@ -5689,9 +5713,9 @@
 {
 	uint16_t data;
 
-	wm_read_eeprom(sc, NVM_INIT_CONTROL2_REG, 1, &data);
+	wm_read_eeprom(sc, EEPROM_OFF_CFG2, 1, &data);
 
-	if ((data & NVM_INIT_CTRL2_MNGM) != 0)
+	if ((data & EEPROM_CFG2_MNGM_MASK) != 0)
 		return 1;
 
 	return 0;

Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.29 src/sys/dev/pci/if_wmreg.h:1.30
--- src/sys/dev/pci/if_wmreg.h:1.29	Tue Dec 29 16:01:21 2009
+++ src/sys/dev/pci/if_wmreg.h	Tue Jan  5 10:02:01 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.29 2009/12/29 16:01:21 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.30 2010/01/05 10:02:01 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -273,6 +273,7 @@
 #define	EEPROM_OFF_MACADDR	0x00	/* MAC address offset */
 #define	EEPROM_OFF_CFG1		0x0a	/* config word 1 */
 #define	EEPROM_OFF_CFG2		0x0f	/* config word 2 */
+#define	EEPROM_INIT_3GIO_3	0x1a	/* PCIe Initial Configuration Word 3 */ 
 #define	EEPROM_OFF_SWDPIN	0x20	/* SWD Pins (Cordova) */
 
 #define	EEPROM_CFG1_LVDID	(1U << 0)
@@ -304,11 +305,14 @@
 #define	EEPROM_CFG2_APM_PME	(1U << 15)
 #define	EEPROM_CFG2_SWDPIO_SHIFT 4
 #define	EEPROM_CFG2_SWDPIO_MASK	(0xf << EEPROM_CFG2_SWDPIO_SHIFT)
+#define	EEPROM_CFG2_MNGM_MASK	(3U << 13) /* Manageability Operation mode */
 
 #define	EEPROM_SWDPIN_MASK	0xdf
 #define	EEPROM_SWDPIN_SWDPIN_SHIFT 0
 #define	EEPROM_SWDPIN_SWDPIO_SHIFT 8
 
+#define EEPROM_3GIO_3_ASPM_MASK	(0x3 << 2)	/* Active State PM Support */
+
 #define	WMREG_EERD	0x0014	/* EEPROM read */
 #define	EERD_DONE	0x02/* done bit */
 #define	EERD_START	0x01	/* First bit for telling part to start operation */
@@ -750,6 +754,3 @@
 
 #define ICH_NVM_SIG_WORD	0x13
 #define ICH_NVM_SIG_MASK	0xc000
-
-#define	NVM_INIT_CONTROL2_REG	0x000f
-#define	NVM_INIT_CTRL2_MNGM	0x6000



CVS commit: src/sys/dev/pci

2010-01-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan  7 17:34:38 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
bugfixes:
 - add missing break in wm_reset()...
 - fix the offset of WMREG_PBS...
 - fix length of some delay()s in wm_gmii_reset()


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/if_wmreg.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.187 src/sys/dev/pci/if_wm.c:1.188
--- src/sys/dev/pci/if_wm.c:1.187	Tue Jan  5 10:02:01 2010
+++ src/sys/dev/pci/if_wm.c	Thu Jan  7 17:34:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.187 2010/01/05 10:02:01 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.188 2010/01/07 17:34:38 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.187 2010/01/05 10:02:01 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.188 2010/01/07 17:34:38 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -3121,7 +3121,7 @@
 		wm_get_swfwhw_semaphore(sc);
 		CSR_WRITE(sc, WMREG_CTRL, CTRL_RST | CTRL_PHY_RESET);
 		delay(1);
-
+		break;
 	default:
 		/* Everything else can safely use the documented method. */
 		CSR_WRITE(sc, WMREG_CTRL, CTRL_RST);
@@ -4596,7 +4596,7 @@
 		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_PHY_RESET);
 		delay((sc->sc_type >= WM_T_82571) ? 100 : 10*1000);
 		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
-		delay(150*1000);
+		delay(150);
 
 		if ((sc->sc_type == WM_T_82541)
 		|| (sc->sc_type == WM_T_82541_2)
@@ -4613,7 +4613,7 @@
 		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_PHY_RESET);
 		delay(100);
 		CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
-		delay(150*1000);
+		delay(150);
 
 		/* Allow time for h/w to get to a quiescent state afer reset */
 		delay(10*1000);

Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.30 src/sys/dev/pci/if_wmreg.h:1.31
--- src/sys/dev/pci/if_wmreg.h:1.30	Tue Jan  5 10:02:01 2010
+++ src/sys/dev/pci/if_wmreg.h	Thu Jan  7 17:34:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.30 2010/01/05 10:02:01 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.31 2010/01/07 17:34:38 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -610,7 +610,7 @@
 #define	PBA_40K		0x0028
 #define	PBA_48K		0x0030		/* 48K, default Rx allocation */
 
-#define	WMREG_PBS	0x1000	/* Packet Buffer Size (ICH8 only ?) */
+#define	WMREG_PBS	0x1008	/* Packet Buffer Size (ICH) */
 
 #define	WMREG_TXDMAC	0x3000	/* Transfer DMA Control */
 #define	TXDMAC_DPP	(1U << 0)	/* disable packet prefetch */



CVS commit: src/sys/dev/pci

2010-01-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan  7 17:45:58 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h if_wmvar.h

Log Message:
Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() be stable on ICH9.


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/if_wmvar.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.188 src/sys/dev/pci/if_wm.c:1.189
--- src/sys/dev/pci/if_wm.c:1.188	Thu Jan  7 17:34:38 2010
+++ src/sys/dev/pci/if_wm.c	Thu Jan  7 17:45:58 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.188 2010/01/07 17:34:38 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.189 2010/01/07 17:45:58 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.188 2010/01/07 17:34:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.189 2010/01/07 17:45:58 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -535,6 +535,8 @@
 static void	wm_attach(device_t, device_t, void *);
 static int	wm_is_onboard_nvm_eeprom(struct wm_softc *);
 static void	wm_get_auto_rd_done(struct wm_softc *);
+static void	wm_lan_init_done(struct wm_softc *);
+static void	wm_get_cfg_done(struct wm_softc *);
 static int	wm_get_swsm_semaphore(struct wm_softc *);
 static void	wm_put_swsm_semaphore(struct wm_softc *);
 static int	wm_poll_eerd_eewr_done(struct wm_softc *, int);
@@ -555,6 +557,7 @@
 static int	wm_check_mng_mode_ich8lan(struct wm_softc *);
 static int	wm_check_mng_mode_82574(struct wm_softc *);
 static int	wm_check_mng_mode_generic(struct wm_softc *);
+static int	wm_check_reset_block(struct wm_softc *);
 static void	wm_get_hw_control(struct wm_softc *);
 static int	wm_check_for_link(struct wm_softc *);
 
@@ -994,6 +997,7 @@
 		break;
 	default:
 		memh_valid = 0;
+		break;
 	}
 
 	if (memh_valid) {
@@ -1171,6 +1175,7 @@
 "unknown PCIXSPD %d; assuming 66MHz\n",
 reg & STATUS_PCIXSPD_MASK);
 sc->sc_bus_speed = 66;
+break;
 			}
 		} else
 			sc->sc_bus_speed = (reg & STATUS_PCI66) ? 66 : 33;
@@ -3013,7 +3018,9 @@
 static void
 wm_reset(struct wm_softc *sc)
 {
-	uint32_t reg;
+	int phy_reset = 0;
+	uint32_t reg, func, mask;
+	int i;
 
 	/*
 	 * Allocate on-chip memory according to the MTU size.
@@ -3074,6 +3081,37 @@
 	/* clear interrupt */
 	CSR_WRITE(sc, WMREG_IMC, 0xU);
 
+	/* Stop the transmit and receive processes. */
+	CSR_WRITE(sc, WMREG_RCTL, 0);
+	CSR_WRITE(sc, WMREG_TCTL, TCTL_PSP);
+
+	/* set_tbi_sbp_82543() */
+
+	delay(10*1000);
+
+	/* Must acquire the MDIO ownership before MAC reset */
+	switch(sc->sc_type) {
+	case WM_T_82573:
+	case WM_T_82574:
+	case WM_T_82583:
+		i = 0;
+		reg = CSR_READ(sc, WMREG_EXTCNFCTR)
+		| EXTCNFCTR_MDIO_SW_OWNERSHIP;
+		do {
+			CSR_WRITE(sc, WMREG_EXTCNFCTR,
+			reg | EXTCNFCTR_MDIO_SW_OWNERSHIP);
+			reg = CSR_READ(sc, WMREG_EXTCNFCTR);
+			if ((reg & EXTCNFCTR_MDIO_SW_OWNERSHIP) != 0)
+break;
+			reg |= EXTCNFCTR_MDIO_SW_OWNERSHIP;
+			delay(2*1000);
+			i++;
+		} while (i < WM_MDIO_OWNERSHIP_TIMEOUT);
+		break;
+	default:
+		break;
+	}
+
 	/*
 	 * 82541 Errata 29? & 82547 Errata 28?
 	 * See also the description about PHY_RST bit in CTRL register
@@ -3086,12 +3124,11 @@
 	}
 
 	switch (sc->sc_type) {
-	case WM_T_82544:
-	case WM_T_82540:
-	case WM_T_82545:
-	case WM_T_82546:
+	case WM_T_82544: /* XXX check whether WM_F_IOH_VALID is set */
 	case WM_T_82541:
 	case WM_T_82541_2:
+	case WM_T_82547:
+	case WM_T_82547_2:
 		/*
 		 * On some chipsets, a reset through a memory-mapped write
 		 * cycle can cause the chip to reset before completing the
@@ -3108,26 +3145,51 @@
 		else
 			CSR_WRITE(sc, WMREG_CTRL, CTRL_RST);
 		break;
-
 	case WM_T_82545_3:
 	case WM_T_82546_3:
 		/* Use the shadow control register on these chips. */
 		CSR_WRITE(sc, WMREG_CTRL_SHADOW, CTRL_RST);
 		break;
-
+	case WM_T_80003:
+		func = (CSR_READ(sc, WMREG_STATUS) >> STATUS_FUNCID_SHIFT) & 1;
+		mask = func ? SWFW_PHY1_SM : SWFW_PHY0_SM;
+		reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST;
+		wm_get_swfw_semaphore(sc, mask);
+		CSR_WRITE(sc, WMREG_CTRL, reg);
+		wm_put_swfw_semaphore(sc, mask);
+		break;
 	case WM_T_ICH8:
 	case WM_T_ICH9:
 	case WM_T_ICH10:
+		reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST;
+		if (wm_check_reset_block(sc) == 0) {
+			reg |= CTRL_PHY_RESET;
+			phy_reset = 1;
+		}
 		wm_get_swfwhw_semaphore(sc);
-		CSR_WRITE(sc, WMREG_CTRL, CTRL_RST | CTRL_PHY_RESET);
-		delay(1);
+		CSR_WRITE(sc, WMREG_CTRL, reg);
+		delay(20*1000);
+		wm_put_swfwhw_semaphore(sc);
 		break;
+	case WM_T_82542_2_0:
+	case WM_T_82542_2_1:
+	case WM_T_82543:
+	case WM_T_82540:
+	case WM_T_82545:
+	case WM_T_82

CVS commit: src/sys/dev/pci

2010-01-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan  7 18:57:10 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add PCH LAN and i82575


To generate a diff of this commit:
cvs rdiff -u -r1.1008 -r1.1009 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1008 src/sys/dev/pci/pcidevs:1.1009
--- src/sys/dev/pci/pcidevs:1.1008	Thu Jan  7 09:27:16 2010
+++ src/sys/dev/pci/pcidevs	Thu Jan  7 18:57:10 2010
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1008 2010/01/07 09:27:16 jdc Exp $
+$NetBSD: pcidevs,v 1.1009 2010/01/07 18:57:10 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2274,16 +2274,18 @@
 product INTEL PRO_100_VE_6	0x1092	PRO/100 VE Network Controller
 product INTEL PRO_100_VE_8	0x1093	PRO/100 VE Network Controller
 product INTEL PRO_100_VE_7	0x1094	PRO/100 VE Network Controller w/ 82562G PHY
-product INTEL 80K3LAN_CPR_DPT 0x1096	i80003 Dual 1000baseT Ethernet
-product INTEL 80K3LAN_FIB_DPT 0x1097	i80003 Dual 1000baseX Ethernet
-product INTEL 80K3LAN_SDS_DPT 0x1098	i80003 Dual Gigabit Ethernet (SERDES)
+product INTEL 80K3LAN_CPR_DPT	0x1096	i80003 Dual 1000baseT Ethernet
+product INTEL 80K3LAN_FIB_DPT	0x1097	i80003 Dual 1000baseX Ethernet
+product INTEL 80K3LAN_SDS_DPT	0x1098	i80003 Dual Gigabit Ethernet (SERDES)
 product INTEL 82546GB_QUAD_COPPER 0x1099 i82546GB Quad Port Gigabit Ethernet
 product INTEL 82573L		0x109a	i82573L Gigabit Ethernet
 product INTEL 82571EB_QUAD_COPPER 0x10a4 i82571EB Quad Port Gigabit Ethernet
+product INTEL 82575EB_COPPER	0x10a7 i82575EB dual-1000baseT Ethernet
+product INTEL 82575EB_FIBER_SERDES 0x10a9 i82575EB dual-1000baseX Ethernet (SERDES)
 product INTEL 82546GB_QUAD_COPPER_KSP3 0x10b5 i82546GB Quad Port Gigabit Ethernet (KSP3)
 product INTEL 82572EI		0x10b9	i82572EI 1000baseT Ethernet
-product INTEL 80K3LAN_CPR_SPT 0x10ba	i80003 1000baseT Ethernet
-product INTEL 80K3LAN_SDS_SPT 0x10bb	i80003 Gigabit Ethernet (SERDES)
+product INTEL 80K3LAN_CPR_SPT	0x10ba	i80003 1000baseT Ethernet
+product INTEL 80K3LAN_SDS_SPT	0x10bb	i80003 Gigabit Ethernet (SERDES)
 product	INTEL 82571GB_QUAD_COPPER 0x10bc i82571GB Quad 1000baseT Ethernet
 product INTEL 82801I_IGP_AMT	0x10bd	82801I (AMT) LAN Controller
 product INTEL 82801I_IGP_M	0x10bf  82801I Mobile LAN Controller
@@ -2296,8 +2298,14 @@
 product INTEL 82801J_D_BM_LF	0x10cd	i82801J (LF) LAN Controller
 product INTEL 82567V		0x10ce	i82567V LAN Controller
 product INTEL 82574L		0x10d3	i82574L 1000baseT Ethernet
+product INTEL 82575GB_QUAD_COPPER 0x10d6 i82575GB quad-1000baseT Ethernet
 product INTEL 82567LM_3		0x10de	i82567LM-3 LAN Controller
 product INTEL 82567LF_3		0x10df	i82567LF-3 LAN Controller
+product INTEL 82575GB_QUAD_COPPER_PM 0x10e2 i82575GB Quad-1000baseT Ethernet (PM)
+product INTEL PCH_M_LM		0x10ea	PCH LAN (82578LM) Controller
+product INTEL PCH_M_LC		0x10eb	PCH LAN (82578LC) Controller
+product INTEL PCH_D_DM		0x10ef	PCH LAN (82578DM) Controller
+product INTEL PCH_D_DC		0x10f0	PCH LAN (82578DC) Controller
 product INTEL 82801I_IGP_M_AMT	0x10f5  82801I Mobile (AMT) LAN Controller
 product INTEL 82815_DC100_HUB	0x1100	82815 Hub
 product INTEL 82815_DC100_AGP	0x1101	82815 AGP



CVS commit: src/sys/dev/pci

2010-01-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jan 11 12:29:29 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h if_wmvar.h

Log Message:
 Add partial support for PCH. We have to do more work for PCH. Especially
I don't know what driver i82578 should be attached to. makephy? or atphy?
MII_OUI() says that the PHY is from Attansic (== Atheros). Intel's e1000
driver says that it's close to makphy...

 I can't link up at 1000BaseT yet...


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_wmvar.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.189 src/sys/dev/pci/if_wm.c:1.190
--- src/sys/dev/pci/if_wm.c:1.189	Thu Jan  7 17:45:58 2010
+++ src/sys/dev/pci/if_wm.c	Mon Jan 11 12:29:28 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.189 2010/01/07 17:45:58 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.190 2010/01/11 12:29:28 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.189 2010/01/07 17:45:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.190 2010/01/11 12:29:28 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -852,6 +852,18 @@
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801J_D_BM_LF,
 	  "i82801J (LF) LAN Controller",
 	  WM_T_ICH10,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_PCH_M_LM,
+	  "PCH LAN (82578LM) Controller",
+	  WM_T_PCH,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_PCH_M_LC,
+	  "PCH LAN (82578LC) Controller",
+	  WM_T_PCH,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_PCH_D_DM,
+	  "PCH LAN (82578DM) Controller",
+	  WM_T_PCH,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_PCH_D_DC,
+	  "PCH LAN (82578DC) Controller",
+	  WM_T_PCH,		WMP_F_1000T },
 	{ 0,			0,
 	  NULL,
 	  0,			0 },
@@ -1104,7 +1116,8 @@
 	} else if (sc->sc_type >= WM_T_82571) {
 		sc->sc_flags |= WM_F_PCIE;
 		if ((sc->sc_type != WM_T_ICH8) && (sc->sc_type != WM_T_ICH9)
-			&& (sc->sc_type != WM_T_ICH10))
+		&& (sc->sc_type != WM_T_ICH10)
+		&& (sc->sc_type != WM_T_PCH))
 			sc->sc_flags |= WM_F_EEPROM_SEMAPHORE;
 		aprint_verbose_dev(sc->sc_dev, "PCI-Express bus\n");
 	} else {
@@ -1282,6 +1295,7 @@
 	case WM_T_ICH8:
 	case WM_T_ICH9:
 	case WM_T_ICH10:
+	case WM_T_PCH:
 		if (wm_check_mng_mode(sc) != 0)
 			wm_get_hw_control(sc);
 		break;
@@ -1359,6 +1373,7 @@
 		}
 		/* FALLTHROUGH */
 	case WM_T_ICH10:
+	case WM_T_PCH:
 		/* FLASH */
 		sc->sc_flags |= WM_F_EEPROM_FLASH | WM_F_SWFWHW_SYNC;
 		memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, WM_ICH8_FLASH);
@@ -1551,7 +1566,8 @@
 	 * media structures accordingly.
 	 */
 	if (sc->sc_type == WM_T_ICH8 || sc->sc_type == WM_T_ICH9
-	|| sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_82573
+	|| sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_PCH
+	|| sc->sc_type == WM_T_82573
 	|| sc->sc_type == WM_T_82574 || sc->sc_type == WM_T_82583) {
 		/* STATUS_TBIMODE reserved/reused, can't rely on it */
 		wm_gmii_mediainit(sc);
@@ -1598,6 +1614,10 @@
 		/* XXX limited to 9234 */
 		sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
 		break;
+	case WM_T_PCH:
+		/* XXX limited to 4096 */
+		sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
+		break;
 	case WM_T_82542_2_0:
 	case WM_T_82542_2_1:
 	case WM_T_82583:
@@ -2929,6 +2949,7 @@
 		return;
 	}
 
+	/* TBI mode */
 	status = CSR_READ(sc, WMREG_STATUS);
 	if (icr & ICR_LSC) {
 		if (status & STATUS_LU) {
@@ -3056,6 +3077,7 @@
 		break;
 	case WM_T_ICH9:
 	case WM_T_ICH10:
+	case WM_T_PCH:
 		sc->sc_pba = PBA_10K;
 		break;
 	default:
@@ -3123,6 +3145,10 @@
 		delay(5000);
 	}
 
+	if (sc->sc_type == WM_T_PCH) {
+		/* Save K1 */
+	}
+
 	switch (sc->sc_type) {
 	case WM_T_82544: /* XXX check whether WM_F_IOH_VALID is set */
 	case WM_T_82541:
@@ -3161,8 +3187,17 @@
 	case WM_T_ICH8:
 	case WM_T_ICH9:
 	case WM_T_ICH10:
+	case WM_T_PCH:
 		reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST;
 		if (wm_check_reset_block(sc) == 0) {
+			if (sc->sc_type >= WM_T_PCH) {
+uint32_t status;
+
+status = CSR_READ(sc, WMREG_STATUS);
+CSR_WRITE(sc, WMREG_STATUS,
+status & ~STATUS_PHYRA);
+			}
+
 			reg |= CTRL_PHY_RESET;
 			phy_reset = 1;
 		}
@@ -3243,7 +3278,8 @@
 		/* check EECD_EE_AUTORD */
 		wm_get_auto_rd_done(sc);
 		break;
-	case WM_T_ICH10: /* & PCH */
+	case WM_T_ICH10:
+	case WM_T_PCH:
 		wm_lan_init_done(sc);
 		break;
 	default:
@@ -3253,6 +3289,14 @@
 	/* reload sc_ctrl */
 	sc->sc_ctrl = CSR_READ(sc, WMREG_CTRL);
 
+	/*
+	 * For PCH, this write will make sure that any noise will be detected
+	 * as a CRC error and be dropped rather than show up as a bad packet
+	 * to the DMA engine
+	 */
+	if (sc->sc_ty

CVS commit: src/sys/dev/pci

2010-01-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jan 11 12:54:55 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
fix for i82577


To generate a diff of this commit:
cvs rdiff -u -r1.1009 -r1.1010 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1009 src/sys/dev/pci/pcidevs:1.1010
--- src/sys/dev/pci/pcidevs:1.1009	Thu Jan  7 18:57:10 2010
+++ src/sys/dev/pci/pcidevs	Mon Jan 11 12:54:54 2010
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1009 2010/01/07 18:57:10 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1010 2010/01/11 12:54:54 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2302,8 +2302,8 @@
 product INTEL 82567LM_3		0x10de	i82567LM-3 LAN Controller
 product INTEL 82567LF_3		0x10df	i82567LF-3 LAN Controller
 product INTEL 82575GB_QUAD_COPPER_PM 0x10e2 i82575GB Quad-1000baseT Ethernet (PM)
-product INTEL PCH_M_LM		0x10ea	PCH LAN (82578LM) Controller
-product INTEL PCH_M_LC		0x10eb	PCH LAN (82578LC) Controller
+product INTEL PCH_M_LM		0x10ea	PCH LAN (82577LM) Controller
+product INTEL PCH_M_LC		0x10eb	PCH LAN (82577LC) Controller
 product INTEL PCH_D_DM		0x10ef	PCH LAN (82578DM) Controller
 product INTEL PCH_D_DC		0x10f0	PCH LAN (82578DC) Controller
 product INTEL 82801I_IGP_M_AMT	0x10f5  82801I Mobile (AMT) LAN Controller



CVS commit: src/sys/dev/pci

2010-01-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jan 11 12:55:29 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.1007 -r1.1008 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1006 -r1.1007 src/sys/dev/pci/pcidevs_data.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/pci/pcidevs.h
diff -u src/sys/dev/pci/pcidevs.h:1.1007 src/sys/dev/pci/pcidevs.h:1.1008
--- src/sys/dev/pci/pcidevs.h:1.1007	Thu Jan  7 18:57:38 2010
+++ src/sys/dev/pci/pcidevs.h	Mon Jan 11 12:55:29 2010
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1007 2010/01/07 18:57:38 msaitoh Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1008 2010/01/11 12:55:29 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1009 2010/01/07 18:57:10 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1010 2010/01/11 12:54:54 msaitoh Exp
  */
 
 /*
@@ -2309,8 +2309,8 @@
 #define	PCI_PRODUCT_INTEL_82567LM_3	0x10de		/* i82567LM-3 LAN Controller */
 #define	PCI_PRODUCT_INTEL_82567LF_3	0x10df		/* i82567LF-3 LAN Controller */
 #define	PCI_PRODUCT_INTEL_82575GB_QUAD_COPPER_PM	0x10e2		/* i82575GB Quad-1000baseT Ethernet (PM) */
-#define	PCI_PRODUCT_INTEL_PCH_M_LM	0x10ea		/* PCH LAN (82578LM) Controller */
-#define	PCI_PRODUCT_INTEL_PCH_M_LC	0x10eb		/* PCH LAN (82578LC) Controller */
+#define	PCI_PRODUCT_INTEL_PCH_M_LM	0x10ea		/* PCH LAN (82577LM) Controller */
+#define	PCI_PRODUCT_INTEL_PCH_M_LC	0x10eb		/* PCH LAN (82577LC) Controller */
 #define	PCI_PRODUCT_INTEL_PCH_D_DM	0x10ef		/* PCH LAN (82578DM) Controller */
 #define	PCI_PRODUCT_INTEL_PCH_D_DC	0x10f0		/* PCH LAN (82578DC) Controller */
 #define	PCI_PRODUCT_INTEL_82801I_IGP_M_AMT	0x10f5		/* 82801I Mobile (AMT) LAN Controller */

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1006 src/sys/dev/pci/pcidevs_data.h:1.1007
--- src/sys/dev/pci/pcidevs_data.h:1.1006	Thu Jan  7 18:57:38 2010
+++ src/sys/dev/pci/pcidevs_data.h	Mon Jan 11 12:55:29 2010
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1006 2010/01/07 18:57:38 msaitoh Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1007 2010/01/11 12:55:29 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1009 2010/01/07 18:57:10 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1010 2010/01/11 12:54:54 msaitoh Exp
  */
 
 /*
@@ -9194,8 +9194,8 @@
 	"Quad-1000baseT\0" /* 1 refs @ 15523 */
 	"(PM)\0" /* 1 refs @ 15538 */
 	"PCH\0" /* 4 refs @ 15543 */
-	"(82578LM)\0" /* 1 refs @ 15547 */
-	"(82578LC)\0" /* 1 refs @ 15557 */
+	"(82577LM)\0" /* 1 refs @ 15547 */
+	"(82577LC)\0" /* 1 refs @ 15557 */
 	"(82578DM)\0" /* 1 refs @ 15567 */
 	"(82578DC)\0" /* 1 refs @ 15577 */
 	"82815\0" /* 10 refs @ 15587 */



CVS commit: src/sys/dev/pci

2010-01-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan 12 21:23:38 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
rename some wm devices to know PHY type


To generate a diff of this commit:
cvs rdiff -u -r1.1011 -r1.1012 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1011 src/sys/dev/pci/pcidevs:1.1012
--- src/sys/dev/pci/pcidevs:1.1011	Tue Jan 12 10:11:32 2010
+++ src/sys/dev/pci/pcidevs	Tue Jan 12 21:23:38 2010
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1011 2010/01/12 10:11:32 nonaka Exp $
+$NetBSD: pcidevs,v 1.1012 2010/01/12 21:23:38 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2296,12 +2296,12 @@
 product INTEL 82801H_IFE_GT 	0x10c4	i82801H IFE (GT) LAN Controller
 product INTEL 82801H_IFE_G 	0x10c5	i82801H IFE (G) LAN Controller
 product INTEL 82801H_IGP_M_V 	0x10cb	i82801H IGP (MV) LAN Controller
-product INTEL 82801J_D_BM_LF	0x10cd	i82801J (LF) LAN Controller
-product INTEL 82567V		0x10ce	i82567V LAN Controller
+product INTEL 82801J_R_BM_LF	0x10cd	i82567LF-2 LAN Controller
+product INTEL 82801J_R_BM_V	0x10ce	i82567V-2 LAN Controller
 product INTEL 82574L		0x10d3	i82574L 1000baseT Ethernet
 product INTEL 82575GB_QUAD_COPPER 0x10d6 i82575GB quad-1000baseT Ethernet
-product INTEL 82567LM_3		0x10de	i82567LM-3 LAN Controller
-product INTEL 82567LF_3		0x10df	i82567LF-3 LAN Controller
+product INTEL 82801J_D_BM_LM	0x10de	i82567LM-3 LAN Controller
+product INTEL 82801J_D_BM_LF	0x10df	i82567LF-3 LAN Controller
 product INTEL 82575GB_QUAD_COPPER_PM 0x10e2 i82575GB Quad-1000baseT Ethernet (PM)
 product INTEL PCH_M_LM		0x10ea	PCH LAN (82577LM) Controller
 product INTEL PCH_M_LC		0x10eb	PCH LAN (82577LC) Controller



CVS commit: src/sys/dev/pci

2010-01-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan 12 21:24:39 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
add i82567LM-2 i82567LM-4 i82567V-3 LAN controller


To generate a diff of this commit:
cvs rdiff -u -r1.1012 -r1.1013 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1012 src/sys/dev/pci/pcidevs:1.1013
--- src/sys/dev/pci/pcidevs:1.1012	Tue Jan 12 21:23:38 2010
+++ src/sys/dev/pci/pcidevs	Tue Jan 12 21:24:39 2010
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1012 2010/01/12 21:23:38 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1013 2010/01/12 21:24:39 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2296,6 +2296,7 @@
 product INTEL 82801H_IFE_GT 	0x10c4	i82801H IFE (GT) LAN Controller
 product INTEL 82801H_IFE_G 	0x10c5	i82801H IFE (G) LAN Controller
 product INTEL 82801H_IGP_M_V 	0x10cb	i82801H IGP (MV) LAN Controller
+product INTEL 82801J_R_BM_LM	0x10cc	i82567LM-2 LAN Controller
 product INTEL 82801J_R_BM_LF	0x10cd	i82567LF-2 LAN Controller
 product INTEL 82801J_R_BM_V	0x10ce	i82567V-2 LAN Controller
 product INTEL 82574L		0x10d3	i82574L 1000baseT Ethernet
@@ -2303,6 +2304,7 @@
 product INTEL 82801J_D_BM_LM	0x10de	i82567LM-3 LAN Controller
 product INTEL 82801J_D_BM_LF	0x10df	i82567LF-3 LAN Controller
 product INTEL 82575GB_QUAD_COPPER_PM 0x10e2 i82575GB Quad-1000baseT Ethernet (PM)
+product INTEL 82801I_BM		0x10e5	i82567LM-4 LAN Controller
 product INTEL PCH_M_LM		0x10ea	PCH LAN (82577LM) Controller
 product INTEL PCH_M_LC		0x10eb	PCH LAN (82577LC) Controller
 product INTEL PCH_D_DM		0x10ef	PCH LAN (82578DM) Controller
@@ -2341,6 +2343,7 @@
 product INTEL 82870P2_PPB	0x1460	82870P2 P64H2 PCI-PCI Bridge
 product INTEL 82870P2_IOxAPIC	0x1461	82870P2 P64H2 IOxAPIC
 product INTEL 82870P2_HPLUG	0x1462	82870P2 P64H2 Hot Plug Controller
+product INTEL 82801I_82567V_3	0x1501	i82567V-3 LAN Controller
 product INTEL 82583V		0x150c	i82583V 1000baseT Ethernet
 product INTEL 80960_RP		0x1960	ROB-in i960RP Microprocessor
 product INTEL 80960RM_2		0x1962	i960 RM PCI-PCI



CVS commit: src/sys/dev/mii

2010-01-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan 12 21:48:26 UTC 2010

Modified Files:
src/sys/dev/mii: igphyreg.h

Log Message:
Add some macros


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/mii/igphyreg.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/mii/igphyreg.h
diff -u src/sys/dev/mii/igphyreg.h:1.4 src/sys/dev/mii/igphyreg.h:1.5
--- src/sys/dev/mii/igphyreg.h:1.4	Sun Dec 11 12:22:42 2005
+++ src/sys/dev/mii/igphyreg.h	Tue Jan 12 21:48:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: igphyreg.h,v 1.4 2005/12/11 12:22:42 christos Exp $	*/
+/*	$NetBSD: igphyreg.h,v 1.5 2010/01/12 21:48:26 msaitoh Exp $	*/
 
 /***
 
@@ -103,6 +103,8 @@
 #define MSE_CHANNEL_A			0xF000
 
 #define MII_IGPHY_PAGE_SELECT		0x1F
+#define IGPHY_MAXREGADDR		0x1F
+#define IGPHY_PAGEMASK			(~IGPHY_MAXREGADDR)
 
 /* IGP01E1000 AGC Registers - stores the cable length values*/
 #define MII_IGPHY_AGC_A			0x1172



CVS commit: src/sys/dev/pci

2010-01-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan 12 22:26:30 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
- Add i82567LM-2 i82567LM-4 i82567V-3 LAN controller.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
  the PHY.
- Add code about LPLU(Low Power Link Up) function. Now we can linkup 1000BaseT
  on PCH. It seems that we have to do the same work for ICH9.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/if_wmreg.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.190 src/sys/dev/pci/if_wm.c:1.191
--- src/sys/dev/pci/if_wm.c:1.190	Mon Jan 11 12:29:28 2010
+++ src/sys/dev/pci/if_wm.c	Tue Jan 12 22:26:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.190 2010/01/11 12:29:28 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.191 2010/01/12 22:26:30 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.190 2010/01/11 12:29:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.191 2010/01/12 22:26:30 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -123,6 +123,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -517,13 +518,14 @@
 
 static int	wm_gmii_i80003_readreg(device_t, int, int);
 static void	wm_gmii_i80003_writereg(device_t, int, int, int);
-
 static int	wm_gmii_bm_readreg(device_t, int, int);
 static void	wm_gmii_bm_writereg(device_t, int, int, int);
+static int	wm_gmii_kv_readreg(device_t, int, int);
+static void	wm_gmii_kv_writereg(device_t, int, int, int);
 
 static void	wm_gmii_statchg(device_t);
 
-static void	wm_gmii_mediainit(struct wm_softc *);
+static void	wm_gmii_mediainit(struct wm_softc *, pci_product_id_t);
 static int	wm_gmii_mediachange(struct ifnet *);
 static void	wm_gmii_mediastatus(struct ifnet *, struct ifmediareq *);
 
@@ -843,14 +845,26 @@
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801I_IGP_M_AMT,
 	  "82801I mobile (AMT) LAN Controller",
 	  WM_T_ICH9,		WMP_F_1000T },
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82567LM_3,
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801I_BM,
+	  "82567LM-4 LAN Controller",
+	  WM_T_ICH9,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801I_82567V_3,
+	  "82567V-3 LAN Controller",
+	  WM_T_ICH9,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801J_R_BM_LM,
+	  "82567LM-2 LAN Controller",
+	  WM_T_ICH10,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801J_R_BM_LF,
+	  "82567LF-2 LAN Controller",
+	  WM_T_ICH10,		WMP_F_1000T },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801J_D_BM_LM,
 	  "82567LM-3 LAN Controller",
 	  WM_T_ICH10,		WMP_F_1000T },
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82567LF_3,
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801J_D_BM_LF,
 	  "82567LF-3 LAN Controller",
 	  WM_T_ICH10,		WMP_F_1000T },
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801J_D_BM_LF,
-	  "i82801J (LF) LAN Controller",
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82801J_R_BM_V,
+	  "82567V-2 LAN Controller",
 	  WM_T_ICH10,		WMP_F_1000T },
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_PCH_M_LM,
 	  "PCH LAN (82578LM) Controller",
@@ -1570,7 +1584,7 @@
 	|| sc->sc_type == WM_T_82573
 	|| sc->sc_type == WM_T_82574 || sc->sc_type == WM_T_82583) {
 		/* STATUS_TBIMODE reserved/reused, can't rely on it */
-		wm_gmii_mediainit(sc);
+		wm_gmii_mediainit(sc, wmp->wmp_product);
 	} else if (sc->sc_type < WM_T_82543 ||
 	(CSR_READ(sc, WMREG_STATUS) & STATUS_TBIMODE) != 0) {
 		if (wmp->wmp_flags & WMP_F_1000T)
@@ -1581,7 +1595,7 @@
 		if (wmp->wmp_flags & WMP_F_1000X)
 			aprint_error_dev(sc->sc_dev,
 			"WARNING: TBIMODE clear on 1000BASE-X product!\n");
-		wm_gmii_mediainit(sc);
+		wm_gmii_mediainit(sc, wmp->wmp_product);
 	}
 
 	ifp = &sc->sc_ethercom.ec_if;
@@ -3372,6 +3386,10 @@
 		break;
 	}
 
+	/* Reset the PHY. */
+	if (sc->sc_flags & WM_F_HAS_MII)
+		wm_gmii_reset(sc);
+
 	/* Initialize the transmit descriptor ring. */
 	memset(sc->sc_txdescs, 0, WM_TXDESCSIZE(sc));
 	WM_CDTXSYNC(sc, 0, WM_NTXDESC(sc),
@@ -4936,6 +4954,25 @@
 
 		if (sc->sc_type == WM_T_PCH) {
 			/* XXX Configure the LCD with the OEM bits in NVM */
+
+#if 1
+			/*
+			 * We shlould make the new driver for 8257[78] and
+			 * move these code into it.
+			 */
+#define HV_OEM_BITS	((0 << 5) | 25)
+#define HV_OEM_BITS_LPLU	(1 << 2)
+#define HV_OEM_BITS_A1KDIS	(1 << 6)
+#define HV_OEM_BITS_ANEGNOW	(1 << 10)
+#endif
+			/*
+			 * Disable LPLU.
+			 * XXX It seems that 82567 has LPLU, too.
+			 */
+			reg = wm_gmii_kv_readreg(sc->sc_dev, 1, HV_OEM_BITS);
+			reg &= ~(HV_OEM_BITS_A1KDIS| HV_OEM_BITS_LPLU);
+			reg |= HV_OEM_BITS_ANEGNOW;
+			wm_gmii_kv_writereg(sc->sc_dev, 1,

CVS commit: src/sys/dev

2010-01-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 14 18:56:02 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h if_wmvar.h
Added Files:
src/sys/dev/mii: inbmphyreg.h

Log Message:
Fixes the rx stall problem on 82578 by MANY workaround code.
We need more work for 82577.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/mii/inbmphyreg.h
cvs rdiff -u -r1.191 -r1.192 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/if_wmvar.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.191 src/sys/dev/pci/if_wm.c:1.192
--- src/sys/dev/pci/if_wm.c:1.191	Tue Jan 12 22:26:30 2010
+++ src/sys/dev/pci/if_wm.c	Thu Jan 14 18:56:02 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.191 2010/01/12 22:26:30 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.192 2010/01/14 18:56:02 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.191 2010/01/12 22:26:30 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.192 2010/01/14 18:56:02 msaitoh Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -124,6 +124,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -249,7 +250,9 @@
 	pci_chipset_tag_t sc_pc;
 	pcitag_t sc_pcitag;
 
-	wm_chip_type sc_type;		/* chip type */
+	wm_chip_type sc_type;		/* MAC type */
+	int sc_rev;			/* MAC revision */
+	wm_phy_type sc_phytype;		/* PHY type */
 	int sc_flags;			/* flags; see below */
 	int sc_if_flags;		/* last if_flags */
 	int sc_bus_speed;		/* PCI/PCIX bus speed */
@@ -366,6 +369,7 @@
 #endif
 	int sc_ich8_flash_base;
 	int sc_ich8_flash_bank_size;
+	int sc_nvm_k1_enabled;
 };
 
 #define	WM_RXCHAIN_RESET(sc)		\
@@ -520,8 +524,8 @@
 static void	wm_gmii_i80003_writereg(device_t, int, int, int);
 static int	wm_gmii_bm_readreg(device_t, int, int);
 static void	wm_gmii_bm_writereg(device_t, int, int, int);
-static int	wm_gmii_kv_readreg(device_t, int, int);
-static void	wm_gmii_kv_writereg(device_t, int, int, int);
+static int	wm_gmii_hv_readreg(device_t, int, int);
+static void	wm_gmii_hv_writereg(device_t, int, int, int);
 
 static void	wm_gmii_statchg(device_t);
 
@@ -562,6 +566,9 @@
 static int	wm_check_reset_block(struct wm_softc *);
 static void	wm_get_hw_control(struct wm_softc *);
 static int	wm_check_for_link(struct wm_softc *);
+static void	wm_hv_phy_workaround_ich8lan(struct wm_softc *);
+static void	wm_k1_gig_workaround_hv(struct wm_softc *, int);
+static void	wm_configure_k1_ich8lan(struct wm_softc *, int);
 
 CFATTACH_DECL_NEW(wm, sizeof(struct wm_softc),
 wm_match, wm_attach, NULL, NULL);
@@ -991,18 +998,18 @@
 	else
 		sc->sc_dmat = pa->pa_dmat;
 
-	preg = PCI_REVISION(pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG));
+	sc->sc_rev = PCI_REVISION(pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG));
 	aprint_naive(": Ethernet controller\n");
-	aprint_normal(": %s, rev. %d\n", wmp->wmp_name, preg);
+	aprint_normal(": %s, rev. %d\n", wmp->wmp_name, sc->sc_rev);
 
 	sc->sc_type = wmp->wmp_type;
 	if (sc->sc_type < WM_T_82543) {
-		if (preg < 2) {
+		if (sc->sc_rev < 2) {
 			aprint_error_dev(sc->sc_dev,
 			"i82542 must be at least rev. 2\n");
 			return;
 		}
-		if (preg < 3)
+		if (sc->sc_rev < 3)
 			sc->sc_type = WM_T_82542_2_0;
 	}
 
@@ -1575,6 +1582,18 @@
 		sc->sc_tdt_reg = WMREG_TDT;
 	}
 
+	if (sc->sc_type == WM_T_PCH) {
+		uint16_t val;
+
+		/* Save the NVM K1 bit setting */
+		wm_read_eeprom(sc, EEPROM_OFF_K1_CONFIG, 1, &val);
+
+		if ((val & EEPROM_K1_CONFIG_ENABLE) != 0)
+			sc->sc_nvm_k1_enabled = 1;
+		else
+			sc->sc_nvm_k1_enabled = 0;
+	}
+
 	/*
 	 * Determine if we're TBI or GMII mode, and initialize the
 	 * media structures accordingly.
@@ -2896,74 +2915,101 @@
 }
 
 /*
- * wm_linkintr:
+ * wm_linkintr_gmii:
  *
- *	Helper; handle link interrupts.
+ *	Helper; handle link interrupts for GMII.
  */
 static void
-wm_linkintr(struct wm_softc *sc, uint32_t icr)
+wm_linkintr_gmii(struct wm_softc *sc, uint32_t icr)
 {
-	uint32_t status;
 
 	DPRINTF(WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev),
 		__func__));
-	/*
-	 * If we get a link status interrupt on a 1000BASE-T
-	 * device, just fall into the normal MII tick path.
-	 */
-	if (sc->sc_flags & WM_F_HAS_MII) {
-		if (icr & ICR_LSC) {
-			DPRINTF(WM_DEBUG_LINK,
-			("%s: LINK: LSC -> mii_tick\n",
-			device_xname(sc->sc_dev)));
-			mii_tick(&sc->sc_mii);
-			if (sc->sc_type == WM_T_82543) {
-int miistatus, active;
 
-/*
- * With 82543, we need to force speed and
- * duplex on the MAC equal to what the PHY
- * speed and duplex configuration is.
- */
-miistatus = sc->sc_mii.mii_media_status;
+	if (icr & ICR_LSC) {
+		DPRINTF(WM_DEBUG_LINK,
+		("%s: LINK: LSC -> mii_tick\n",

CVS commit: src/sys/dev/pci

2010-01-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 21 08:52:20 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Remove an extra debug printf(). KNF.
No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.193 src/sys/dev/pci/if_wm.c:1.194
--- src/sys/dev/pci/if_wm.c:1.193	Tue Jan 19 22:07:02 2010
+++ src/sys/dev/pci/if_wm.c	Thu Jan 21 08:52:20 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.193 2010/01/19 22:07:02 pooka Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.194 2010/01/21 08:52:20 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.193 2010/01/19 22:07:02 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.194 2010/01/21 08:52:20 msaitoh Exp $");
 
 #include "rnd.h"
 
@@ -937,9 +937,9 @@
 	for (wmp = wm_products; wmp->wmp_name != NULL; wmp++) {
 		if (PCI_VENDOR(pa->pa_id) == wmp->wmp_vendor &&
 		PCI_PRODUCT(pa->pa_id) == wmp->wmp_product)
-			return (wmp);
+			return wmp;
 	}
-	return (NULL);
+	return NULL;
 }
 
 static int
@@ -948,9 +948,9 @@
 	struct pci_attach_args *pa = aux;
 
 	if (wm_lookup(pa) != NULL)
-		return (1);
+		return 1;
 
-	return (0);
+	return 0;
 }
 
 static void
@@ -1229,8 +1229,7 @@
 	sizeof(struct wm_control_data_82542) :
 	sizeof(struct wm_control_data_82544);
 	if ((error = bus_dmamem_alloc(sc->sc_dmat, cdata_size, PAGE_SIZE,
-  (bus_size_t) 0x1ULL,
-  &seg, 1, &rseg, 0)) != 0) {
+		(bus_size_t) 0x1ULL, &seg, 1, &rseg, 0)) != 0) {
 		aprint_error_dev(sc->sc_dev,
 		"unable to allocate control data, error = %d\n",
 		error);
@@ -1238,15 +1237,14 @@
 	}
 
 	if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, cdata_size,
-(void **)&sc->sc_control_data, 
-BUS_DMA_COHERENT)) != 0) {
+		(void **)&sc->sc_control_data, BUS_DMA_COHERENT)) != 0) {
 		aprint_error_dev(sc->sc_dev,
 		"unable to map control data, error = %d\n", error);
 		goto fail_1;
 	}
 
 	if ((error = bus_dmamap_create(sc->sc_dmat, cdata_size, 1, cdata_size,
-   0, 0, &sc->sc_cddmamap)) != 0) {
+		0, 0, &sc->sc_cddmamap)) != 0) {
 		aprint_error_dev(sc->sc_dev,
 		"unable to create control data DMA map, error = %d\n",
 		error);
@@ -1254,8 +1252,7 @@
 	}
 
 	if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_cddmamap,
- sc->sc_control_data, cdata_size, NULL,
- 0)) != 0) {
+		sc->sc_control_data, cdata_size, NULL, 0)) != 0) {
 		aprint_error_dev(sc->sc_dev,
 		"unable to load control data DMA map, error = %d\n",
 		error);
@@ -1270,8 +1267,8 @@
 	WM_TXQUEUELEN_MAX_82547 : WM_TXQUEUELEN_MAX;
 	for (i = 0; i < WM_TXQUEUELEN(sc); i++) {
 		if ((error = bus_dmamap_create(sc->sc_dmat, WM_MAXTXDMA,
-	   WM_NTXSEGS, WTX_MAX_LEN, 0, 0,
-	  &sc->sc_txsoft[i].txs_dmamap)) != 0) {
+			WM_NTXSEGS, WTX_MAX_LEN, 0, 0,
+			&sc->sc_txsoft[i].txs_dmamap)) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"unable to create Tx DMA map %d, error = %d\n",
 			i, error);
@@ -1284,8 +1281,8 @@
 	 */
 	for (i = 0; i < WM_NRXDESC; i++) {
 		if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1,
-	   MCLBYTES, 0, 0,
-	  &sc->sc_rxsoft[i].rxs_dmamap)) != 0) {
+			MCLBYTES, 0, 0,
+			&sc->sc_rxsoft[i].rxs_dmamap)) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"unable to create Rx DMA map %d error = %d\n",
 			i, error);
@@ -1846,7 +1843,7 @@
 		 */
 		*fieldsp = 0;
 		*cmdp = 0;
-		return (0);
+		return 0;
 	}
 
 	if ((m0->m_pkthdr.csum_flags &
@@ -1998,7 +1995,7 @@
 	*cmdp = cmd;
 	*fieldsp = fields;
 
-	return (0);
+	return 0;
 }
 
 static void
@@ -2086,7 +2083,7 @@
 
 	/* Just return if already stalled. */
 	if (sc->sc_txfifo_stall)
-		return (1);
+		return 1;
 
 	if (sc->sc_mii.mii_media_active & IFM_FDX) {
 		/* Stall only occurs in half-duplex mode. */
@@ -2096,7 +2093,7 @@
 	if (len >= WM_82547_PAD_LEN + space) {
 		sc->sc_txfifo_stall = 1;
 		callout_schedule(&sc->sc_txfifo_ch, 1);
-		return (1);
+		return 1;
 	}
 
  send_packet:
@@ -2104,7 +2101,7 @@
 	if (sc->sc_txfifo_head >= sc->sc_txfifo_size)
 		sc->sc_txfifo_head -= sc->sc_txfifo_size;
 
-	return (0);
+	return 0;
 }
 
 /*
@@ -2544,7 +2541,7 @@
 	wm_start(ifp);
 
 	splx(s);
-	return (error);
+	return error;
 }
 
 /*
@@ -2611,7 +2608,7 @@
 		wm_start(ifp);
 	}
 
-	return (handled);
+	return handled;
 }
 
 /*
@@ -2970,7 +2967,6 @@
 			== IFM_1000_T)) {
 
 			if ((sc->sc_mii.mii_media_status & IFM_ACTIVE) != 0) {
-printf("XXX link sall wa\n");
 delay(200*1000); /* XXX too big */
 
 /* Link stall fix for link up */
@@ -3180,7 +3176,7 @@
 	delay(10*1000);
 
 	/* Must acquire the MDIO ownership before MAC rese

CVS commit: src/sys/dev/pci

2010-01-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jan 24 14:10:00 UTC 2010

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
KNF & fix typo in comment.
No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/dev/pci/if_bge.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.169 src/sys/dev/pci/if_bge.c:1.170
--- src/sys/dev/pci/if_bge.c:1.169	Tue Jan 19 22:07:00 2010
+++ src/sys/dev/pci/if_bge.c	Sun Jan 24 14:10:00 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.169 2010/01/19 22:07:00 pooka Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.170 2010/01/24 14:10:00 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.169 2010/01/19 22:07:00 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.170 2010/01/24 14:10:00 msaitoh Exp $");
 
 #include "vlan.h"
 #include "rnd.h"
@@ -185,7 +185,7 @@
 
 static int	bge_rxthresh_nodenum;
 
-typedef int (*bge_eaddr_fcn_t)(struct bge_softc *, u_int8_t[]);
+typedef int (*bge_eaddr_fcn_t)(struct bge_softc *, uint8_t[]);
 
 static int	bge_probe(device_t, cfdata_t, void *);
 static void	bge_attach(device_t, device_t, void *);
@@ -193,14 +193,14 @@
 static void	bge_txeof(struct bge_softc *);
 static void	bge_rxeof(struct bge_softc *);
 
-static int 	bge_get_eaddr_mem(struct bge_softc *, u_int8_t[]);
-static int 	bge_get_eaddr_nvram(struct bge_softc *, u_int8_t[]);
-static int 	bge_get_eaddr_eeprom(struct bge_softc *, u_int8_t[]);
-static int 	bge_get_eaddr(struct bge_softc *, u_int8_t[]);
+static int 	bge_get_eaddr_mem(struct bge_softc *, uint8_t[]);
+static int 	bge_get_eaddr_nvram(struct bge_softc *, uint8_t[]);
+static int 	bge_get_eaddr_eeprom(struct bge_softc *, uint8_t[]);
+static int 	bge_get_eaddr(struct bge_softc *, uint8_t[]);
 
 static void	bge_tick(void *);
 static void	bge_stats_update(struct bge_softc *);
-static int	bge_encap(struct bge_softc *, struct mbuf *, u_int32_t *);
+static int	bge_encap(struct bge_softc *, struct mbuf *, uint32_t *);
 
 static int	bge_intr(void *);
 static void	bge_start(struct ifnet *);
@@ -588,7 +588,7 @@
 CFATTACH_DECL_NEW(bge, sizeof(struct bge_softc),
 bge_probe, bge_attach, NULL, NULL);
 
-static u_int32_t
+static uint32_t
 bge_readmem_ind(struct bge_softc *sc, int off)
 {
 	pcireg_t val;
@@ -606,7 +606,7 @@
 }
 
 #ifdef notdef
-static u_int32_t
+static uint32_t
 bge_readreg_ind(struct bge_softc *sc, int off)
 {
 	pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_REG_BASEADDR, off);
@@ -636,10 +636,10 @@
 	CSR_WRITE_4(sc, off, val);
 }
 
-static u_int8_t
-bge_nvram_getbyte(struct bge_softc *sc, int addr, u_int8_t *dest)
+static uint8_t
+bge_nvram_getbyte(struct bge_softc *sc, int addr, uint8_t *dest)
 {
-	u_int32_t access, byte = 0;
+	uint32_t access, byte = 0;
 	int i;
 
 	/* Lock. */
@@ -650,7 +650,7 @@
 		DELAY(20);
 	}
 	if (i == 8000)
-		return (1);
+		return 1;
 
 	/* Enable access. */
 	access = CSR_READ_4(sc, BGE_NVRAM_ACCESS);
@@ -668,7 +668,7 @@
 
 	if (i == BGE_TIMEOUT * 10) {
 		aprint_error_dev(sc->bge_dev, "nvram read timed out\n");
-		return (1);
+		return 1;
 	}
 
 	/* Get result. */
@@ -683,20 +683,20 @@
 	CSR_WRITE_4(sc, BGE_NVRAM_SWARB, BGE_NVRAMSWARB_CLR1);
 	CSR_READ_4(sc, BGE_NVRAM_SWARB);
 
-	return (0);
+	return 0;
 }
 
 /*
  * Read a sequence of bytes from NVRAM.
  */
 static int
-bge_read_nvram(struct bge_softc *sc, u_int8_t *dest, int off, int cnt)
+bge_read_nvram(struct bge_softc *sc, uint8_t *dest, int off, int cnt)
 {
 	int err = 0, i;
-	u_int8_t byte = 0;
+	uint8_t byte = 0;
 
 	if (BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5906)
-		return (1);
+		return 1;
 
 	for (i = 0; i < cnt; i++) {
 		err = bge_nvram_getbyte(sc, off + i, &byte);
@@ -714,11 +714,11 @@
  * auto access interface for reading the EEPROM. We use the auto
  * access method.
  */
-static u_int8_t
-bge_eeprom_getbyte(struct bge_softc *sc, int addr, u_int8_t *dest)
+static uint8_t
+bge_eeprom_getbyte(struct bge_softc *sc, int addr, uint8_t *dest)
 {
 	int i;
-	u_int32_t byte = 0;
+	uint32_t byte = 0;
 
 	/*
 	 * Enable use of auto EEPROM access so we can avoid
@@ -735,7 +735,7 @@
 	CSR_WRITE_4(sc, BGE_EE_ADDR, BGE_EE_READCMD | addr);
 
 	/* Wait for completion */
-	for(i = 0; i < BGE_TIMEOUT * 10; i++) {
+	for (i = 0; i < BGE_TIMEOUT * 10; i++) {
 		DELAY(10);
 		if (CSR_READ_4(sc, BGE_EE_ADDR) & BGE_EEADDR_DONE)
 			break;
@@ -743,7 +743,7 @@
 
 	if (i == BGE_TIMEOUT) {
 		aprint_error_dev(sc->bge_dev, "eeprom read timed out\n");
-		return (0);
+		return 0;
 	}
 
 	/* Get result. */
@@ -751,7 +751,7 @@
 
 	*dest = (byte >> ((addr % 4) * 8)) & 0xFF;
 
-	return (0);
+	return 0;
 }
 
 /*
@@ -761,7 +761,7 @@
 bge_read_eeprom(struct bge_softc *sc, void *destv, int off, int cnt)
 {
 	int err = 0, i;
-	u_int8_t byte = 0;
+	uint8_t byte = 0;
 	cha

CVS commit: src/sys/dev/pci

2010-01-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jan 24 15:29:10 UTC 2010

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
Fix the bug that both BGE_PCIE and BGE_PCIX are set on PCI-Express devices.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/dev/pci/if_bge.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.170 src/sys/dev/pci/if_bge.c:1.171
--- src/sys/dev/pci/if_bge.c:1.170	Sun Jan 24 14:10:00 2010
+++ src/sys/dev/pci/if_bge.c	Sun Jan 24 15:29:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.170 2010/01/24 14:10:00 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.171 2010/01/24 15:29:10 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.170 2010/01/24 14:10:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.171 2010/01/24 15:29:10 msaitoh Exp $");
 
 #include "vlan.h"
 #include "rnd.h"
@@ -2357,20 +2357,15 @@
 	pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MISC_CTL) &
 	BGE_PCIMISCCTL_ASICREV;
 
-	/*
-	 * Detect PCI-Express devices
-	 * XXX: guessed from Linux/FreeBSD; no documentation
-	 */
 	if (pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_PCIEXPRESS,
-	NULL, NULL) != 0)
+	NULL, NULL) != 0) {
+		/* PCIe */
 		sc->bge_flags |= BGE_PCIE;
-
-	/*
-	 * PCI-X check.
-	 */
-	if ((pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_PCISTATE) &
-		BGE_PCISTATE_PCI_BUSMODE) == 0)
+	} else if ((pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_PCISTATE) &
+		BGE_PCISTATE_PCI_BUSMODE) == 0) {
+		/* PCI-X */
 		sc->bge_flags |= BGE_PCIX;
+	}
 
 	if (sc->bge_chipid == BGE_CHIPID_BCM5701_A0 ||
 	sc->bge_chipid == BGE_CHIPID_BCM5701_B0)



CVS commit: src/sys/dev/pci

2010-01-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jan 24 15:53:29 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add BCM5717,5718,5723,5724,5787F,5761,5761E,5764,5761S,5761SE,5760,57788,
57780,57790,5784M,5785F,5785G,57761,57781,57791,57765,57785 and 57795.


To generate a diff of this commit:
cvs rdiff -u -r1.1016 -r1.1017 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1016 src/sys/dev/pci/pcidevs:1.1017
--- src/sys/dev/pci/pcidevs:1.1016	Thu Jan 21 23:23:44 2010
+++ src/sys/dev/pci/pcidevs	Sun Jan 24 15:53:29 2010
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1016 2010/01/21 23:23:44 hubertf Exp $
+$NetBSD: pcidevs,v 1.1017 2010/01/24 15:53:29 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1470,9 +1470,13 @@
 product BROADCOM BCM5702FE	0x164d	BCM5702FE 10/100 Ethernet
 product BROADCOM BCM5705	0x1653	BCM5705 10/100/1000 Ethernet
 product BROADCOM BCM5705K	0x1654	BCM5705K 10/100/1000 Ethernet
+product BROADCOM BCM5717	0x1655	BCM5717
+product BROADCOM BCM5718	0x1656	BCM5718
 product BROADCOM BCM5720	0x1658	BCM5720 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5721	0x1659	BCM5721 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5722	0x165a	BCM5722 NetXtreme 1000baseT Ethernet
+product BROADCOM BCM5723	0x165b	BCM5723
+product BROADCOM BCM5724	0x165c	BCM5724
 product BROADCOM BCM5705M	0x165d	BCM5705M 10/100/1000 Ethernet
 product BROADCOM BCM5705M_ALT	0x165e	BCM5705M 10/100/1000 Ethernet
 product BROADCOM BCM5714	0x1668	BCM5714 1000baseT Ethernet
@@ -1492,17 +1496,36 @@
 product BROADCOM BCM5750M	0x167c	BCM5750M 10/100/1000 Ethernet
 product BROADCOM BCM5751M	0x167d	BCM5751M 10/100/1000 Ethernet
 product BROADCOM BCM5751F	0x167e	BCM5751F 10/100/1000 Ethernet
+product BROADCOM BCM5787F	0x167f	BCM5787F
+product BROADCOM BCM5761E	0x1680	BCM5761E
+product BROADCOM BCM5761	0x1681	BCM5761
+product BROADCOM BCM5764	0x1684	BCM5764
+product BROADCOM BCM5761S	0x1688	BCM5761S
+product BROADCOM BCM5761SE	0x1689	BCM5761SE
+product BROADCOM BCM57760	0x1690	BCM57760
+product BROADCOM BCM57788	0x1691	BCM57788
+product BROADCOM BCM57780	0x1692	BCM57780
 product BROADCOM BCM5787M	0x1693	BCM5787M 10/100/1000 Ethernet
+product BROADCOM BCM57790	0x1694	BCM57790
 product BROADCOM BCM5782	0x1696	BCM5782 10/100/1000 Ethernet
+product BROADCOM BCM5784M	0x1698	BCM5784M NetLink 1000baseT Ethernet
+product BROADCOM BCM5785G	0x1699	BCM5785G
 product BROADCOM BCM5786	0x169a	BCM5786 NetLink 1000baseT Ethernet
 product BROADCOM BCM5787	0x169b	BCM5787 NetLink 1000baseT Ethernet
 product BROADCOM BCM5788	0x169c	BCM5788 10/100/1000 Ethernet
 product BROADCOM BCM5789	0x169d	BCM5789 10/100/1000 Ethernet
+product BROADCOM BCM5785F	0x16a0	BCM5785F
 product BROADCOM BCM5702X	0x16a6	BCM5702X 10/100/1000 Ethernet
 product BROADCOM BCM5703X	0x16a7	BCM5703X 10/100/1000 Ethernet
 product BROADCOM BCM5704S	0x16a8	BCM5704S 1000baseSX Ethernet
 product BROADCOM BCM5706S	0x16aa	BCM5706 NetXtreme II 1000baseSX
 product BROADCOM BCM5708S	0x16ac	BCM5708 NetXtreme II 1000baseSX
+product BROADCOM BCM57761	0x16b0	BCM57761
+product BROADCOM BCM57781	0x16b1	BCM57781
+product BROADCOM BCM57791	0x16b2	BCM57791
+product BROADCOM BCM57765	0x16b4	BCM57765
+product BROADCOM BCM57785	0x16b5	BCM57785
+product BROADCOM BCM57795	0x16b6	BCM57795
 product BROADCOM BCM5702_ALT	0x16c6	BCM5702 10/100/1000 Ethernet
 product BROADCOM BCM5703_ALT	0x16c7	BCM5703 10/100/1000 Ethernet
 product BROADCOM BCM5781	0x16dd	BCM5781 10/100/1000 Ethernet



CVS commit: src/sys/dev/mii

2010-01-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jan 24 16:22:41 UTC 2010

Modified Files:
src/sys/dev/mii: miidevs

Log Message:
Add BCM5461,BCM5784 and BCM5761.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/mii/miidevs

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/mii/miidevs
diff -u src/sys/dev/mii/miidevs:1.92 src/sys/dev/mii/miidevs:1.93
--- src/sys/dev/mii/miidevs:1.92	Thu Jan  7 09:31:19 2010
+++ src/sys/dev/mii/miidevs	Sun Jan 24 16:22:40 2010
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.92 2010/01/07 09:31:19 jdc Exp $
+$NetBSD: miidevs,v 1.93 2010/01/24 16:22:40 msaitoh Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -149,6 +149,7 @@
 model BROADCOM BCM5401		0x0005 BCM5401 1000BASE-T media interface
 model BROADCOM BCM5411		0x0007 BCM5411 1000BASE-T media interface
 model BROADCOM BCM5464		0x000b BCM5464 1000BASE-T media interface
+model BROADCOM BCM5461		0x000c BCM5461 1000BASE-T media interface
 model BROADCOM BCM5462		0x000d BCM5462 1000BASE-T media interface
 model BROADCOM BCM5421		0x000e BCM5421 1000BASE-T media interface
 model BROADCOM BCM5752		0x0010 BCM5752 1000BASE-T media interface
@@ -166,7 +167,9 @@
 model BROADCOM2 BCM5754		0x000e BCM5754/5787 1000BASE-T media interface
 model BROADCOM2 BCM5709CAX	0x002c BCM5709CAX 10/100/1000baseT PHY
 model BROADCOM2 BCM5722		0x002d BCM5722 1000BASE-T media interface
+model BROADCOM2 BCM5784		0x003a BCM5784 10/100/1000baseT PHY
 model BROADCOM2 BCM5709C	0x003c BCM5709 10/100/1000baseT PHY
+model BROADCOM2 BCM5761		0x003d BCM5761 10/100/1000baseT PHY
 model xxBROADCOM_ALT1 BCM5906	0x0004 BCM5906 10/100baseTX media interface
  
 /* Cicada Semiconductor PHYs (now owned by Vitesse?) */



CVS commit: src/sys/dev/mii

2010-01-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jan 24 16:23:16 UTC 2010

Modified Files:
src/sys/dev/mii: miidevs.h miidevs_data.h

Log Message:
regen.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/mii/miidevs_data.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/mii/miidevs.h
diff -u src/sys/dev/mii/miidevs.h:1.94 src/sys/dev/mii/miidevs.h:1.95
--- src/sys/dev/mii/miidevs.h:1.94	Thu Jan  7 09:31:44 2010
+++ src/sys/dev/mii/miidevs.h	Sun Jan 24 16:23:16 2010
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.94 2010/01/07 09:31:44 jdc Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.95 2010/01/24 16:23:16 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.92 2010/01/07 09:31:19 jdc Exp
+ *	NetBSD: miidevs,v 1.93 2010/01/24 16:22:40 msaitoh Exp
  */
 
 /*-
@@ -181,6 +181,8 @@
 #define	MII_STR_BROADCOM_BCM5411	"BCM5411 1000BASE-T media interface"
 #define	MII_MODEL_BROADCOM_BCM5464	0x000b
 #define	MII_STR_BROADCOM_BCM5464	"BCM5464 1000BASE-T media interface"
+#define	MII_MODEL_BROADCOM_BCM5461	0x000c
+#define	MII_STR_BROADCOM_BCM5461	"BCM5461 1000BASE-T media interface"
 #define	MII_MODEL_BROADCOM_BCM5462	0x000d
 #define	MII_STR_BROADCOM_BCM5462	"BCM5462 1000BASE-T media interface"
 #define	MII_MODEL_BROADCOM_BCM5421	0x000e
@@ -215,8 +217,12 @@
 #define	MII_STR_BROADCOM2_BCM5709CAX	"BCM5709CAX 10/100/1000baseT PHY"
 #define	MII_MODEL_BROADCOM2_BCM5722	0x002d
 #define	MII_STR_BROADCOM2_BCM5722	"BCM5722 1000BASE-T media interface"
+#define	MII_MODEL_BROADCOM2_BCM5784	0x003a
+#define	MII_STR_BROADCOM2_BCM5784	"BCM5784 10/100/1000baseT PHY"
 #define	MII_MODEL_BROADCOM2_BCM5709C	0x003c
 #define	MII_STR_BROADCOM2_BCM5709C	"BCM5709 10/100/1000baseT PHY"
+#define	MII_MODEL_BROADCOM2_BCM5761	0x003d
+#define	MII_STR_BROADCOM2_BCM5761	"BCM5761 10/100/1000baseT PHY"
 #define	MII_MODEL_xxBROADCOM_ALT1_BCM5906	0x0004
 #define	MII_STR_xxBROADCOM_ALT1_BCM5906	"BCM5906 10/100baseTX media interface"
  

Index: src/sys/dev/mii/miidevs_data.h
diff -u src/sys/dev/mii/miidevs_data.h:1.83 src/sys/dev/mii/miidevs_data.h:1.84
--- src/sys/dev/mii/miidevs_data.h:1.83	Mon Dec 14 01:48:34 2009
+++ src/sys/dev/mii/miidevs_data.h	Sun Jan 24 16:23:16 2010
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs_data.h,v 1.83 2009/12/14 01:48:34 enami Exp $	*/
+/*	$NetBSD: miidevs_data.h,v 1.84 2010/01/24 16:23:16 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.91 2009/12/13 19:20:17 matt Exp
+ *	NetBSD: miidevs,v 1.93 2010/01/24 16:22:40 msaitoh Exp
  */
 
 /*-
@@ -62,6 +62,7 @@
  { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5401, MII_STR_BROADCOM_BCM5401 },
  { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5411, MII_STR_BROADCOM_BCM5411 },
  { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5464, MII_STR_BROADCOM_BCM5464 },
+ { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5461, MII_STR_BROADCOM_BCM5461 },
  { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5462, MII_STR_BROADCOM_BCM5462 },
  { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5421, MII_STR_BROADCOM_BCM5421 },
  { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5752, MII_STR_BROADCOM_BCM5752 },
@@ -79,7 +80,9 @@
  { MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5754, MII_STR_BROADCOM2_BCM5754 },
  { MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5709CAX, MII_STR_BROADCOM2_BCM5709CAX },
  { MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5722, MII_STR_BROADCOM2_BCM5722 },
+ { MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5784, MII_STR_BROADCOM2_BCM5784 },
  { MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5709C, MII_STR_BROADCOM2_BCM5709C },
+ { MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5761, MII_STR_BROADCOM2_BCM5761 },
  { MII_OUI_xxBROADCOM_ALT1, MII_MODEL_xxBROADCOM_ALT1_BCM5906, MII_STR_xxBROADCOM_ALT1_BCM5906 },
  { MII_OUI_CICADA, MII_MODEL_CICADA_CS8201, MII_STR_CICADA_CS8201 },
  { MII_OUI_CICADA, MII_MODEL_CICADA_CS8204, MII_STR_CICADA_CS8204 },
@@ -130,6 +133,7 @@
  { MII_OUI_xxNATSEMI, MII_MODEL_xxNATSEMI_DP83847, MII_STR_xxNATSEMI_DP83847 },
  { MII_OUI_xxNATSEMI, MII_MODEL_xxNATSEMI_DP83891, MII_STR_xxNATSEMI_DP83891 },
  { MII_OUI_xxNATSEMI, MII_MODEL_xxNATSEMI_DP83861, MII_STR_xxNATSEMI_DP83861 },
+ { MII_OUI_xxNATSEMI, MII_MODEL_xxNATSEMI_DP83865, MII_STR_xxNATSEMI_DP83865 },
  { MII_OUI_xxPMCSIERRA, MII_MODEL_xxPMCSIERRA_PM8351, MII_STR_xxPMCSIERRA_PM8351 },
  { MII_OUI_xxPMCSIERRA2, MII_MODEL_xxPMCSIERRA2_PM8352, MII_STR_xxPMCSIERRA2_PM8352 },
  { MII_OUI_xxPMCSIERRA2, MII_MODEL_xxPMCSIERRA2_PM8353, MII_STR_xxPMCSIERRA2_PM8353 },



CVS commit: src/sys/dev/mii

2010-01-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jan 24 16:26:09 UTC 2010

Modified Files:
src/sys/dev/mii: brgphy.c

Log Message:
Add support for BCM5461,BCM5784 and BCM5761.
Enable brgphy_jumbo_settings().
Enable the ether...@wirespeed function.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/mii/brgphy.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/mii/brgphy.c
diff -u src/sys/dev/mii/brgphy.c:1.51 src/sys/dev/mii/brgphy.c:1.52
--- src/sys/dev/mii/brgphy.c:1.51	Wed Nov 18 23:02:12 2009
+++ src/sys/dev/mii/brgphy.c	Sun Jan 24 16:26:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: brgphy.c,v 1.51 2009/11/18 23:02:12 bouyer Exp $	*/
+/*	$NetBSD: brgphy.c,v 1.52 2010/01/24 16:26:09 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.51 2009/11/18 23:02:12 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.52 2010/01/24 16:26:09 msaitoh Exp $");
 
 #include 
 #include 
@@ -113,6 +113,8 @@
 static void	brgphy_5704_a0_bug(struct mii_softc *);
 static void	brgphy_ber_bug(struct mii_softc *);
 static void	brgphy_crc_bug(struct mii_softc *);
+static void	brgphy_jumbo_settings(struct mii_softc *);
+static void	brgphy_eth_wirespeed(struct mii_softc *);
 
 
 static const struct mii_phy_funcs brgphy_funcs = {
@@ -135,12 +137,15 @@
 	{ MII_OUI_BROADCOM,		MII_MODEL_BROADCOM_BCM54K2,
 	  MII_STR_BROADCOM_BCM54K2 },
 
-	{ MII_OUI_BROADCOM,		MII_MODEL_BROADCOM_BCM5464,
-	  MII_STR_BROADCOM_BCM5464 },
+	{ MII_OUI_BROADCOM,		MII_MODEL_BROADCOM_BCM5461,
+	  MII_STR_BROADCOM_BCM5461 },
 
 	{ MII_OUI_BROADCOM,		MII_MODEL_BROADCOM_BCM5462,
 	  MII_STR_BROADCOM_BCM5462 },
 
+	{ MII_OUI_BROADCOM,		MII_MODEL_BROADCOM_BCM5464,
+	  MII_STR_BROADCOM_BCM5464 },
+
 	{ MII_OUI_BROADCOM,		MII_MODEL_BROADCOM_BCM5701,
 	  MII_STR_BROADCOM_BCM5701 },
 
@@ -180,9 +185,15 @@
 	{ MII_OUI_BROADCOM2,		MII_MODEL_BROADCOM2_BCM5755,
 	  MII_STR_BROADCOM2_BCM5755 },
 
+	{ MII_OUI_BROADCOM2,		MII_MODEL_BROADCOM2_BCM5761,
+	  MII_STR_BROADCOM2_BCM5761 },
+
 	{ MII_OUI_BROADCOM2,		MII_MODEL_BROADCOM2_BCM5754,
 	  MII_STR_BROADCOM2_BCM5754 },
 
+	{ MII_OUI_BROADCOM2,		MII_MODEL_BROADCOM2_BCM5784,
+	  MII_STR_BROADCOM2_BCM5784 },
+
 	{ MII_OUI_xxBROADCOM_ALT1,	MII_MODEL_xxBROADCOM_ALT1_BCM5906,
 	  MII_STR_xxBROADCOM_ALT1_BCM5906 },
 
@@ -243,8 +254,9 @@
 	if (device_is_a(parent, "bge")) {
 		bsc->sc_isbge = 1;
 		dict = device_properties(parent);
-		prop_dictionary_get_uint32(dict, "phyflags",
-		&bsc->sc_bge_flags);
+		if (!prop_dictionary_get_uint32(dict, "phyflags",
+			&bsc->sc_bge_flags))
+			aprint_error("failed to get phyflags");
 	} else if (device_is_a(parent, "bnx")) {
 		bsc->sc_isbnx = 1;
 		dict = device_properties(parent);
@@ -554,21 +566,19 @@
 			if (bsc->sc_bge_flags & BGE_PHY_CRC_BUG)
 brgphy_crc_bug(sc);
 
-#if 0
 			/* Set Jumbo frame settings in the PHY. */
-			if (bsc->sc_bge_flags & BGE_JUMBO_CAP)
+			if (bsc->sc_bge_flags & BGE_JUMBO_CAPABLE)
 brgphy_jumbo_settings(sc);
-#endif
 
 			/* Adjust output voltage */
 			if (sc->mii_mpd_model == MII_MODEL_BROADCOM2_BCM5906)
 PHY_WRITE(sc, BRGPHY_MII_EPHY_PTEST, 0x12);
 
-#if 0
 			/* Enable ether...@wirespeed */
 			if (!(bsc->sc_bge_flags & BGE_NO_ETH_WIRE_SPEED))
 brgphy_eth_wirespeed(sc);
 
+#if 0
 			/* Enable Link LED on Dell boxes */
 			if (bsc->sc_bge_flags & BGE_NO_3LED) {
 PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, 
@@ -807,3 +817,36 @@
 	for (i = 0; dspcode[i].reg != 0; i++)
 		PHY_WRITE(sc, dspcode[i].reg, dspcode[i].val);
 }
+
+static void
+brgphy_jumbo_settings(struct mii_softc *sc)
+{
+	u_int32_t val;
+
+	/* Set Jumbo frame settings in the PHY. */
+	if (sc->mii_mpd_model == MII_MODEL_BROADCOM_BCM5401) {
+		/* Cannot do read-modify-write on the BCM5401 */
+		PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x4c20);
+	} else {
+		PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7);
+		val = PHY_READ(sc, BRGPHY_MII_AUXCTL);
+		PHY_WRITE(sc, BRGPHY_MII_AUXCTL,
+			val & ~(BRGPHY_AUXCTL_LONG_PKT | 0x7));
+	}
+
+	val = PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL);
+	PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL,
+		val & ~BRGPHY_PHY_EXTCTL_HIGH_LA);
+}
+
+static void
+brgphy_eth_wirespeed(struct mii_softc *sc)
+{
+	u_int32_t val;
+
+	/* Enable ether...@wirespeed */
+	PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7007);
+	val = PHY_READ(sc, BRGPHY_MII_AUXCTL);
+	PHY_WRITE(sc, BRGPHY_MII_AUXCTL,
+		(val | (1 << 15) | (1 << 4)));
+}



CVS commit: src/sys/dev/pci

2010-01-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jan 24 17:56:54 UTC 2010

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
Fix a printf() message in debug code reported by Bert Kiers.


To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 src/sys/dev/pci/if_bge.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.172 src/sys/dev/pci/if_bge.c:1.173
--- src/sys/dev/pci/if_bge.c:1.172	Sun Jan 24 16:21:09 2010
+++ src/sys/dev/pci/if_bge.c	Sun Jan 24 17:56:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.172 2010/01/24 16:21:09 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.173 2010/01/24 17:56:54 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.172 2010/01/24 16:21:09 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.173 2010/01/24 17:56:54 msaitoh Exp $");
 
 #include "vlan.h"
 #include "rnd.h"
@@ -4669,7 +4669,7 @@
 	if (sc->bge_flags & BGE_JUMBO_CAPABLE)
 		printf(" - Supports Jumbo Frames\n");
 	if (sc->bge_flags & BGE_NO_EEPROM)
-		printf(" - Supports Jumbo Frames\n");
+		printf(" - No EEPROM\n");
 	if (sc->bge_flags & BGE_PCIX)
 		printf(" - PCI-X Bus\n");
 	if (sc->bge_flags & BGE_PCIE)



CVS commit: src/sys/dev/pci

2010-01-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 28 02:55:31 UTC 2010

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
Add some register definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/pcireg.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/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.61 src/sys/dev/pci/pcireg.h:1.62
--- src/sys/dev/pci/pcireg.h:1.61	Fri Sep 11 01:28:20 2009
+++ src/sys/dev/pci/pcireg.h	Thu Jan 28 02:55:31 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.61 2009/09/11 01:28:20 christos Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.62 2010/01/28 02:55:31 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -551,7 +551,9 @@
 #define PCI_PCIE_XCAP_SI	0x0100
 #define PCI_PCIE_DCAP		0x04
 #define PCI_PCIE_DCSR		0x08
+#define PCI_PCIE_DCSR_MAX_READ_REQ	0x7000
 #define PCI_PCIE_DCSR_ENA_NO_SNOOP	0x0800
+#define PCI_PCIE_DSR		0x0a
 #define PCI_PCIE_LCAP		0x0c
 #define PCI_PCIE_LCSR		0x10
 #define PCI_PCIE_LCSR_ASPM_L0S	0x0001



CVS commit: src/sys/dev/pci

2010-01-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 28 03:09:13 UTC 2010

Modified Files:
src/sys/dev/pci: if_bge.c if_bgereg.h if_bgevar.h

Log Message:
- Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
  which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
  driver.
- fix the return value of bge_eeprom_getbyte().
- remove an unused structure.
- KNF


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/pci/if_bgereg.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/if_bgevar.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.176 src/sys/dev/pci/if_bge.c:1.177
--- src/sys/dev/pci/if_bge.c:1.176	Mon Jan 25 10:25:30 2010
+++ src/sys/dev/pci/if_bge.c	Thu Jan 28 03:09:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.176 2010/01/25 10:25:30 martin Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.177 2010/01/28 03:09:13 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.176 2010/01/25 10:25:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.177 2010/01/28 03:09:13 msaitoh Exp $");
 
 #include "vlan.h"
 #include "rnd.h"
@@ -180,64 +180,87 @@
 #define NBGE_RX_THRESH (sizeof(bge_rx_threshes) / sizeof(bge_rx_threshes[0]))
 
 /* XXX patchable; should be sysctl'able */
-static int	bge_auto_thresh = 1;
-static int	bge_rx_thresh_lvl;
+static int bge_auto_thresh = 1;
+static int bge_rx_thresh_lvl;
 
-static int	bge_rxthresh_nodenum;
+static int bge_rxthresh_nodenum;
 
 typedef int (*bge_eaddr_fcn_t)(struct bge_softc *, uint8_t[]);
 
-static int	bge_probe(device_t, cfdata_t, void *);
-static void	bge_attach(device_t, device_t, void *);
-static void	bge_release_resources(struct bge_softc *);
-static void	bge_txeof(struct bge_softc *);
-static void	bge_rxeof(struct bge_softc *);
-
-static int	bge_get_eaddr_fw(struct bge_softc *, uint8_t[]);
-static int 	bge_get_eaddr_mem(struct bge_softc *, uint8_t[]);
-static int 	bge_get_eaddr_nvram(struct bge_softc *, uint8_t[]);
-static int 	bge_get_eaddr_eeprom(struct bge_softc *, uint8_t[]);
-static int 	bge_get_eaddr(struct bge_softc *, uint8_t[]);
-
-static void	bge_tick(void *);
-static void	bge_stats_update(struct bge_softc *);
-static void	bge_stats_update_regs(struct bge_softc *);
-static int	bge_encap(struct bge_softc *, struct mbuf *, uint32_t *);
-
-static int	bge_intr(void *);
-static void	bge_start(struct ifnet *);
-static int	bge_ioctl(struct ifnet *, u_long, void *);
-static int	bge_init(struct ifnet *);
-static void	bge_stop(struct ifnet *, int);
-static void	bge_watchdog(struct ifnet *);
-static int	bge_ifmedia_upd(struct ifnet *);
-static void	bge_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int bge_probe(device_t, cfdata_t, void *);
+static void bge_attach(device_t, device_t, void *);
+static void bge_release_resources(struct bge_softc *);
+
+static int bge_get_eaddr_fw(struct bge_softc *, uint8_t[]);
+static int bge_get_eaddr_mem(struct bge_softc *, uint8_t[]);
+static int bge_get_eaddr_nvram(struct bge_softc *, uint8_t[]);
+static int bge_get_eaddr_eeprom(struct bge_softc *, uint8_t[]);
+static int bge_get_eaddr(struct bge_softc *, uint8_t[]);
+
+static void bge_txeof(struct bge_softc *);
+static void bge_rxeof(struct bge_softc *);
+
+static void bge_asf_driver_up (struct bge_softc *);
+static void bge_tick(void *);
+static void bge_stats_update(struct bge_softc *);
+static void bge_stats_update_regs(struct bge_softc *);
+static int bge_encap(struct bge_softc *, struct mbuf *, uint32_t *);
+
+static int bge_intr(void *);
+static void bge_start(struct ifnet *);
+static int bge_ioctl(struct ifnet *, u_long, void *);
+static int bge_init(struct ifnet *);
+static void bge_stop(struct ifnet *, int);
+static void bge_watchdog(struct ifnet *);
+static int bge_ifmedia_upd(struct ifnet *);
+static void bge_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+
+static uint8_t bge_nvram_getbyte(struct bge_softc *, int, uint8_t *);
+static int bge_read_nvram(struct bge_softc *, uint8_t *, int, int);
+
+static uint8_t bge_eeprom_getbyte(struct bge_softc *, int, uint8_t *);
+static int bge_read_eeprom(struct bge_softc *, void *, int, int);
+static void bge_setmulti(struct bge_softc *);
 
-static void	bge_setmulti(struct bge_softc *);
-
-static void	bge_handle_events(struct bge_softc *);
-static int	bge_alloc_jumbo_mem(struct bge_softc *);
+static void bge_handle_events(struct bge_softc *);
+static int bge_alloc_jumbo_mem(struct bge_softc *);
 #if 0 /* XXX */
-static void	bge_free_jumbo_mem(struct bge_softc *);
+static void bge_free_jumbo_mem(struct bge_softc *);
 #endif
-static void	*bge_jalloc(struct bge_softc *);
-static void	bge_jfree(struct mbuf *, 

CVS commit: src/sys/dev/pci

2010-01-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 28 07:34:12 UTC 2010

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
ANSI C, KNF and tabify


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/dev/pci/if_bge.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.177 src/sys/dev/pci/if_bge.c:1.178
--- src/sys/dev/pci/if_bge.c:1.177	Thu Jan 28 03:09:13 2010
+++ src/sys/dev/pci/if_bge.c	Thu Jan 28 07:34:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.177 2010/01/28 03:09:13 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.178 2010/01/28 07:34:12 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.177 2010/01/28 03:09:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.178 2010/01/28 07:34:12 msaitoh Exp $");
 
 #include "vlan.h"
 #include "rnd.h"
@@ -343,31 +343,31 @@
 	  PCI_PRODUCT_BROADCOM_BCM5703_ALT,
 	  "Broadcom BCM5703 Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5704C,
 	  "Broadcom BCM5704C Dual Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5704S,
 	  "Broadcom BCM5704S Dual Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5705,
 	  "Broadcom BCM5705 Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5705F,
 	  "Broadcom BCM5705F Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5705K,
 	  "Broadcom BCM5705K Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5705M,
 	  "Broadcom BCM5705M Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5705M_ALT,
 	  "Broadcom BCM5705M Gigabit Ethernet",
 	  },
@@ -491,23 +491,23 @@
 	  PCI_PRODUCT_BROADCOM_BCM5761SE,
 	  "Broadcom BCM5761SE Gigabit Ethernet",
 	},
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5764,
 	  "Broadcom BCM5764 Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5780,
 	  "Broadcom BCM5780 Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5780S,
 	  "Broadcom BCM5780S Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5781,
 	  "Broadcom BCM5781 Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5782,
 	  "Broadcom BCM5782 Gigabit Ethernet",
 	},
@@ -527,23 +527,23 @@
 	  PCI_PRODUCT_BROADCOM_BCM5787M,
 	  "Broadcom BCM5787M Gigabit Ethernet",
 	},
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5788,
 	  "Broadcom BCM5788 Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5789,
 	  "Broadcom BCM5789 Gigabit Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5901,
 	  "Broadcom BCM5901 Fast Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5901A2,
 	  "Broadcom BCM5901A2 Fast Ethernet",
 	  },
-   	{ PCI_VENDOR_BROADCOM,
+	{ PCI_VENDOR_BROADCOM,
 	  PCI_PRODUCT_BROADCOM_BCM5903M,
 	  "Broadcom BCM5903M Fast Ethernet",
 	  },
@@ -1304,7 +1304,8 @@
  * Intialize a standard receive ring descriptor.
  */
 static int
-bge_newbuf_std(struct bge_softc *sc, int i, struct mbuf *m, bus_dmamap_t dmamap)
+bge_newbuf_std(struct bge_softc *sc, int i, struct mbuf *m,
+bus_dmamap_t dmamap)
 {
 	struct mbuf		*m_new = NULL;
 	struct bge_rx_bd	*r;
@@ -1341,7 +1342,7 @@
 	if (bus_dmamap_load_mbuf(sc->bge_dmatag, dmamap, m_new,
 	BUS_DMA_READ|BUS_DMA_NOWAIT))
 		return ENOBUFS;
-	bus_dmamap_sync(sc->bge_dmatag, dmamap, 0, dmamap->dm_mapsize, 
+	bus_dmamap_sync(sc->bge_dmatag, dmamap, 0, dmamap->dm_mapsize,
 	BUS_DMASYNC_PREREAD);
 
 	sc->bge_cdata.bge_rx_std_chain[i] = m_new;
@@ -1648,9 +1649,7 @@
 }
 
 static void
-bge_sig_pre_reset(sc, type)
-	struct bge_softc *sc;
-	int type;
+bge_sig_pre_reset(struct bge_softc *sc, int type)
 {
 	/*
 	 * Some chips don't like this so only do this if ASF is enabled
@@ -1671,10 +1670,9 @@
 }
 
 static void
-bge_sig_post_reset(sc, type)
-	struct bge_softc *sc;
-	int type;
+bge_sig_post_reset(struct bge_softc *sc, int type)
 {
+
 	if (sc->bge_asf_mode & ASF_NEW_HANDSHAKE) {
 		switch (type) {
 		case BGE_RESET_START:
@@ -1689,10 +1687,9 @@
 }
 
 static void
-bge_sig_legacy(sc, type)
-	struct bge_softc *sc;
-	int type;
+bge_sig_legacy(struct bge_softc *sc, int type)
 {
+
 	if (sc->bge_a

CVS commit: src/sys/dev/pci

2010-01-31 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Feb  1 05:38:36 UTC 2010

Modified Files:
src/sys/dev/pci: if_bge.c pcireg.h

Log Message:
Fix the bug that unaligned access occurs on amd64. It also fixes the bug
that error bits aren't cleard because these bit are W2C (in other words W1C).

Reported by Michael van Elst.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/pcireg.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.178 src/sys/dev/pci/if_bge.c:1.179
--- src/sys/dev/pci/if_bge.c:1.178	Thu Jan 28 07:34:12 2010
+++ src/sys/dev/pci/if_bge.c	Mon Feb  1 05:38:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.178 2010/01/28 07:34:12 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.179 2010/02/01 05:38:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.178 2010/01/28 07:34:12 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.179 2010/02/01 05:38:36 msaitoh Exp $");
 
 #include "vlan.h"
 #include "rnd.h"
@@ -3113,10 +3113,11 @@
 		devctl &= ~(0x0010 | PCI_PCIE_DCSR_ENA_NO_SNOOP);
 		/* Set PCIE max payload size to 128. */
 		devctl &= ~(0x00e0);
+		/* Clear device status register. Write 1b to clear */
+		devctl |= PCI_PCIE_DCSR_URD | PCI_PCIE_DCSR_FED
+		| PCI_PCIE_DCSR_NFED | PCI_PCIE_DCSR_CED;
 		pci_conf_write(sc->sc_pc, sc->sc_pcitag,
 		sc->bge_expcap + PCI_PCIE_DCSR, devctl);
-		pci_conf_write(sc->sc_pc, sc->sc_pcitag,
-		sc->bge_expcap + PCI_PCIE_DSR, 0);
 	}
 
 	/* Reset some of the PCI state that got zapped by reset */

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.62 src/sys/dev/pci/pcireg.h:1.63
--- src/sys/dev/pci/pcireg.h:1.62	Thu Jan 28 02:55:31 2010
+++ src/sys/dev/pci/pcireg.h	Mon Feb  1 05:38:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.62 2010/01/28 02:55:31 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.63 2010/02/01 05:38:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -553,7 +553,10 @@
 #define PCI_PCIE_DCSR		0x08
 #define PCI_PCIE_DCSR_MAX_READ_REQ	0x7000
 #define PCI_PCIE_DCSR_ENA_NO_SNOOP	0x0800
-#define PCI_PCIE_DSR		0x0a
+#define PCI_PCIE_DCSR_CED	0x0001
+#define PCI_PCIE_DCSR_NFED	0x0002
+#define PCI_PCIE_DCSR_FED	0x0004
+#define PCI_PCIE_DCSR_URD	0x0008
 #define PCI_PCIE_LCAP		0x0c
 #define PCI_PCIE_LCSR		0x10
 #define PCI_PCIE_LCSR_ASPM_L0S	0x0001



CVS commit: src/sys/dev/pci

2010-02-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Feb  3 15:36:36 UTC 2010

Modified Files:
src/sys/dev/pci: if_bge.c if_bgereg.h if_bgevar.h

Log Message:
- Make the initialize sequence close to the document.
- Fix ASF heartbeat sending bug (FreeBSD rev. 1.271 (r202821))
- Use new handshake command for BCM5750 or new controllers (FreeBSD rev. 1.272
  (r202822))


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/pci/if_bgereg.h
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_bgevar.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/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.179 src/sys/dev/pci/if_bge.c:1.180
--- src/sys/dev/pci/if_bge.c:1.179	Mon Feb  1 05:38:36 2010
+++ src/sys/dev/pci/if_bge.c	Wed Feb  3 15:36:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.179 2010/02/01 05:38:36 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.180 2010/02/03 15:36:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.179 2010/02/01 05:38:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.180 2010/02/03 15:36:36 msaitoh Exp $");
 
 #include "vlan.h"
 #include "rnd.h"
@@ -753,7 +753,7 @@
 
 	dev = sc->bge_dev;
 
-	val = pci_conf_read(sc->sc_pc, sc->sc_pcitag, sc->bge_expcap
+	val = pci_conf_read(sc->sc_pc, sc->sc_pcitag, sc->bge_pciecap
 	+ PCI_PCIE_DCSR);
 	if ((val & PCI_PCIE_DCSR_MAX_READ_REQ) !=
 	BGE_PCIE_DEVCTL_MAX_READRQ_4096) {
@@ -761,7 +761,7 @@
 			val);
 		val &= ~PCI_PCIE_DCSR_MAX_READ_REQ;
 		val |= BGE_PCIE_DEVCTL_MAX_READRQ_4096;
-		pci_conf_write(sc->sc_pc, sc->sc_pcitag, sc->bge_expcap
+		pci_conf_write(sc->sc_pc, sc->sc_pcitag, sc->bge_pciecap
 		+ PCI_PCIE_DCSR, val);
 			printf("-> 0x%04x\n", val);
 	}
@@ -1720,6 +1720,48 @@
 	}
 }
 
+static int
+bge_poll_fw(struct bge_softc *sc)
+{
+	uint32_t val;
+	int i;
+
+	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) {
+		for (i = 0; i < BGE_TIMEOUT; i++) {
+			val = CSR_READ_4(sc, BGE_VCPU_STATUS);
+			if (val & BGE_VCPU_STATUS_INIT_DONE)
+break;
+			DELAY(100);
+		}
+		if (i >= BGE_TIMEOUT) {
+			aprint_error_dev(sc->bge_dev, "reset timed out\n");
+			return -1;
+		}
+	} else if ((sc->bge_flags & BGE_NO_EEPROM) == 0) {
+		/*
+		 * Poll the value location we just wrote until
+		 * we see the 1's complement of the magic number.
+		 * This indicates that the firmware initialization
+		 * is complete.
+		 * XXX 1000ms for Flash and 1ms for SEEPROM.
+		 */
+		for (i = 0; i < BGE_TIMEOUT; i++) {
+			val = bge_readmem_ind(sc, BGE_SOFTWARE_GENCOMM);
+			if (val == ~BGE_MAGIC_NUMBER)
+break;
+			DELAY(10);
+		}
+
+		if (i >= BGE_TIMEOUT) {
+			aprint_error_dev(sc->bge_dev,
+			"firmware handshake timed out, val = %x\n", val);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
 /*
  * Do endian, PCI and DMA initialization. Also check the on-board ROM
  * self-test results.
@@ -1894,7 +1936,7 @@
 
 	pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, 0);
 
-	/* Configure mbuf memory pool */
+	/* Step 33: Configure mbuf memory pool */
 	if (BGE_IS_5700_FAMILY(sc)) {
 		CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_BASEADDR,
 		BGE_BUFFPOOL_1);
@@ -1910,7 +1952,7 @@
 		CSR_WRITE_4(sc, BGE_BMAN_DMA_DESCPOOL_LEN, 0x2000);
 	}
 
-	/* Configure mbuf pool watermarks */
+	/* Step 35: Configure mbuf pool watermarks */
 #ifdef ORIG_WPAUL_VALUES
 	CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 24);
 	CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 24);
@@ -1939,15 +1981,15 @@
 	}
 #endif
 
-	/* Configure DMA resource watermarks */
+	/* Step 36: Configure DMA resource watermarks */
 	CSR_WRITE_4(sc, BGE_BMAN_DMA_DESCPOOL_LOWAT, 5);
 	CSR_WRITE_4(sc, BGE_BMAN_DMA_DESCPOOL_HIWAT, 10);
 
-	/* Enable buffer manager */
+	/* Step 38: Enable buffer manager */
 	CSR_WRITE_4(sc, BGE_BMAN_MODE,
 	BGE_BMANMODE_ENABLE | BGE_BMANMODE_LOMBUF_ATTN);
 
-	/* Poll for buffer manager start indication */
+	/* Step 39: Poll for buffer manager start indication */
 	for (i = 0; i < BGE_TIMEOUT * 2; i++) {
 		if (CSR_READ_4(sc, BGE_BMAN_MODE) & BGE_BMANMODE_ENABLE)
 			break;
@@ -1960,7 +2002,7 @@
 		return ENXIO;
 	}
 
-	/* Enable flow-through queues */
+	/* Step 40: Enable flow-through queues */
 	CSR_WRITE_4(sc, BGE_FTQ_RESET, 0x);
 	CSR_WRITE_4(sc, BGE_FTQ_RESET, 0);
 
@@ -1977,7 +2019,7 @@
 		return ENXIO;
 	}
 
-	/* Initialize the standard RX ring control block */
+	/* Step 41: Initialize the standard RX ring control block */
 	rcb = &sc->bge_rdata->bge_info.bge_std_rx_rcb;
 	BGE_HOSTADDR(rcb->bge_hostaddr, BGE_RING_DMA_ADDR(sc, bge_rx_std_ring));
 	if (BGE_IS_5705_PLUS(sc))
@@ -1992,7 +2034,7 @@
 	CSR_WRITE_4(sc, BGE_RX_STD_RCB_NICADDR, rcb->bge_nicaddr);
 
 	/*
-	 * Initialize the jumbo RX ring control block
+	 * Step 42: Initialize the jumbo RX ring

CVS commit: src/sys/dev/pci

2010-02-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Feb  3 15:37:51 UTC 2010

Modified Files:
src/sys/dev/pci: if_bgevar.h

Log Message:
s/u_int/uint/


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/if_bgevar.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/pci/if_bgevar.h
diff -u src/sys/dev/pci/if_bgevar.h:1.4 src/sys/dev/pci/if_bgevar.h:1.5
--- src/sys/dev/pci/if_bgevar.h:1.4	Wed Feb  3 15:36:36 2010
+++ src/sys/dev/pci/if_bgevar.h	Wed Feb  3 15:37:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgevar.h,v 1.4 2010/02/03 15:36:36 msaitoh Exp $	*/
+/*	$NetBSD: if_bgevar.h,v 1.5 2010/02/03 15:37:51 msaitoh Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -74,7 +74,7 @@
 	do {\
 		(x).bge_addr_lo = ((uint64_t) (y) & 0x);	\
 		if (sizeof (bus_addr_t) == 8)\
-			(x).bge_addr_hi = ((u_int64_t) (y) >> 32);	\
+			(x).bge_addr_hi = ((uint64_t) (y) >> 32);	\
 		else			\
 			(x).bge_addr_hi = 0;\
 	} while(0)
@@ -121,8 +121,8 @@
 #define BGE_RSLOTS	256
 
 #define BGE_JRAWLEN (BGE_JUMBO_FRAMELEN + ETHER_ALIGN)
-#define BGE_JLEN (BGE_JRAWLEN + (sizeof(u_int64_t) - \
-	(BGE_JRAWLEN % sizeof(u_int64_t
+#define BGE_JLEN (BGE_JRAWLEN + (sizeof(uint64_t) - \
+	(BGE_JRAWLEN % sizeof(uint64_t
 #define BGE_JPAGESZ PAGE_SIZE
 #define BGE_RESID (BGE_JPAGESZ - (BGE_JLEN * BGE_JSLOTS) % BGE_JPAGESZ)
 #define BGE_JMEM ((BGE_JLEN * BGE_JSLOTS) + BGE_RESID)
@@ -194,8 +194,8 @@
 	 (mtod((m), char *) - (char *)(sc)->bge_cdata.bge_jumbo_buf))
 
 struct bge_type {
-	u_int16_t		bge_vid;
-	u_int16_t		bge_did;
+	uint16_t		bge_vid;
+	uint16_t		bge_did;
 	char			*bge_name;
 };
 
@@ -223,7 +223,7 @@
 
 struct bge_softc {
 	device_t		bge_dev;
-	struct ethercom		ethercom;		/* interface info */
+	struct ethercom		ethercom;	/* interface info */
 	bus_space_handle_t	bge_bhandle;
 	bus_space_tag_t		bge_btag;
 	void			*bge_intrhand;
@@ -232,31 +232,31 @@
 
 	struct mii_data		bge_mii;
 	struct ifmedia		bge_ifmedia;	/* media info */
-	u_int32_t		bge_return_ring_cnt;
-	u_int32_t		bge_tx_prodidx;
+	uint32_t		bge_return_ring_cnt;
+	uint32_t		bge_tx_prodidx;
 	bus_dma_tag_t		bge_dmatag;
 	uint32_t		bge_pcixcap;
 	uint32_t		bge_pciecap;
-	u_int32_t		bge_chipid;
-	u_int32_t		bge_local_ctrl_reg;
+	uint32_t		bge_chipid;
+	uint32_t		bge_local_ctrl_reg;
 	uint8_t			bge_asf_mode;
 	uint8_t			bge_asf_count;
 	struct bge_ring_data	*bge_rdata;	/* rings */
 	struct bge_chain_data	bge_cdata;	/* mbufs */
 	bus_dmamap_t		bge_ring_map;
-	u_int16_t		bge_tx_saved_considx;
-	u_int16_t		bge_rx_saved_considx;
-	u_int16_t		bge_ev_saved_considx;
-	u_int16_t		bge_std;	/* current std ring head */
-	u_int16_t		bge_jumbo;	/* current jumo ring head */
+	uint16_t		bge_tx_saved_considx;
+	uint16_t		bge_rx_saved_considx;
+	uint16_t		bge_ev_saved_considx;
+	uint16_t		bge_std;	/* current std ring head */
+	uint16_t		bge_jumbo;	/* current jumo ring head */
 	SLIST_HEAD(__bge_jfreehead, bge_jpool_entry)	bge_jfree_listhead;
 	SLIST_HEAD(__bge_jinusehead, bge_jpool_entry)	bge_jinuse_listhead;
-	u_int32_t		bge_stat_ticks;
-	u_int32_t		bge_rx_coal_ticks;
-	u_int32_t		bge_tx_coal_ticks;
-	u_int32_t		bge_rx_max_coal_bds;
-	u_int32_t		bge_tx_max_coal_bds;
-	u_int32_t		bge_tx_buf_ratio;
+	uint32_t		bge_stat_ticks;
+	uint32_t		bge_rx_coal_ticks;
+	uint32_t		bge_tx_coal_ticks;
+	uint32_t		bge_rx_max_coal_bds;
+	uint32_t		bge_tx_max_coal_bds;
+	uint32_t		bge_tx_buf_ratio;
 	uint32_t		bge_sts;
 #define BGE_STS_LINK		0x0001	/* MAC link status */
 #define BGE_STS_LINK_EVT	0x0002	/* pending link event */



CVS commit: src/sys/dev/pci

2010-02-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Feb  4 09:13:23 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
- Count Receive error, CRC error, Alignment error, Symbol error, Sequence
  error, Carrier extension error and Receive length error into ierror.
  Fixes PR#30349 reported by UMEZAWA Takeshi.
- Count Missed packet (rx fifo overflow) and Receive no buffers (rx ring full)
  into iqdrops.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_wmreg.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.195 src/sys/dev/pci/if_wm.c:1.196
--- src/sys/dev/pci/if_wm.c:1.195	Fri Jan 22 08:56:06 2010
+++ src/sys/dev/pci/if_wm.c	Thu Feb  4 09:13:23 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.195 2010/01/22 08:56:06 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.196 2010/02/04 09:13:23 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.195 2010/01/22 08:56:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.196 2010/02/04 09:13:23 msaitoh Exp $");
 
 #include "rnd.h"
 
@@ -2830,7 +2830,6 @@
 		 */
 		if (errors &
 		 (WRX_ER_CE|WRX_ER_SE|WRX_ER_SEQ|WRX_ER_CXE|WRX_ER_RXE)) {
-			ifp->if_ierrors++;
 			if (errors & WRX_ER_SE)
 log(LOG_WARNING, "%s: symbol error\n",
 device_xname(sc->sc_dev));
@@ -3083,7 +3082,15 @@
 	}
 
 	ifp->if_collisions += CSR_READ(sc, WMREG_COLC);
-	ifp->if_ierrors += CSR_READ(sc, WMREG_RXERRC);
+	ifp->if_ierrors += 0ULL + /* ensure quad_t */
+	+ CSR_READ(sc, WMREG_CRCERRS)
+	+ CSR_READ(sc, WMREG_ALGNERRC)
+	+ CSR_READ(sc, WMREG_SYMERRC)
+	+ CSR_READ(sc, WMREG_RXERRC)
+	+ CSR_READ(sc, WMREG_SEC)
+	+ CSR_READ(sc, WMREG_CEXTERR)
+	+ CSR_READ(sc, WMREG_RLEC);
+	ifp->if_iqdrops += CSR_READ(sc, WMREG_MPC) + CSR_READ(sc, WMREG_RNBC);
 
 	if (sc->sc_flags & WM_F_HAS_MII)
 		mii_tick(&sc->sc_mii);

Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.35 src/sys/dev/pci/if_wmreg.h:1.36
--- src/sys/dev/pci/if_wmreg.h:1.35	Thu Jan 14 18:56:02 2010
+++ src/sys/dev/pci/if_wmreg.h	Thu Feb  4 09:13:23 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.35 2010/01/14 18:56:02 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.36 2010/02/04 09:13:23 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -642,13 +642,21 @@
 #define	RXCSUM_TUOFL	(1U << 9)	/* TCP/UDP checksum offload */
 #define	RXCSUM_IPV6OFL	(1U << 10)	/* IPv6 checksum offload */
 
-#define	WMREG_RXERRC	0x400C	/* receive error Count - R/clr */
+#define	WMREG_CRCERRS	0x4000	/* CRC Error Count */
+#define	WMREG_ALGNERRC	0x4004	/* Alignment Error Count */
+#define	WMREG_SYMERRC	0x4008	/* Symbol Error Count */
+#define	WMREG_RXERRC	0x400c	/* receive error Count - R/clr */
+#define	WMREG_MPC	0x4010	/* Missed Packets Count - R/clr */
 #define	WMREG_COLC	0x4028	/* collision Count - R/clr */
+#define	WMREG_SEC	0x4038	/* Sequence Error Count */
+#define	WMREG_CEXTERR	0x403c	/* Carrier Extension Error Count */
+#define	WMREG_RLEC	0x4040	/* Receive Length Error Count */
 #define	WMREG_XONRXC	0x4048	/* XON Rx Count - R/clr */
 #define	WMREG_XONTXC	0x404c	/* XON Tx Count - R/clr */
 #define	WMREG_XOFFRXC	0x4050	/* XOFF Rx Count - R/clr */
 #define	WMREG_XOFFTXC	0x4054	/* XOFF Tx Count - R/clr */
 #define	WMREG_FCRUC	0x4058	/* Flow Control Rx Unsupported Count - R/clr */
+#define WMREG_RNBC	0x40a0	/* Receive No Buffers Count */
 
 #define	WMREG_KUMCTRLSTA 0x0034	/* MAC-PHY interface - RW */
 #define	KUMCTRLSTA_MASK			0x



CVS commit: src/sys/dev/pci

2010-02-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Feb  4 10:20:54 UTC 2010

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Don't increment when ICR_RXO is set because we count them by WMREG_MPC
counter.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.196 src/sys/dev/pci/if_wm.c:1.197
--- src/sys/dev/pci/if_wm.c:1.196	Thu Feb  4 09:13:23 2010
+++ src/sys/dev/pci/if_wm.c	Thu Feb  4 10:20:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.196 2010/02/04 09:13:23 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.197 2010/02/04 10:20:54 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.196 2010/02/04 09:13:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.197 2010/02/04 10:20:54 msaitoh Exp $");
 
 #include "rnd.h"
 
@@ -2595,7 +2595,6 @@
 		}
 
 		if (icr & ICR_RXO) {
-			ifp->if_ierrors++;
 #if defined(WM_DEBUG)
 			log(LOG_WARNING, "%s: Receive overrun\n",
 			device_xname(sc->sc_dev));



CVS commit: src/sys/dev/ic

2010-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Feb  8 23:54:33 UTC 2010

Modified Files:
src/sys/dev/ic: mfi.c

Log Message:
 Fix a bug that the system which has no logical volume panics in shutdown
hook. Without any logical volume, sysmon_envsys_register() fails. On such
case, sc->sc_sme must be NULL for the detach. Reviewed by dyoung and bouyer.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/sys/dev/ic/mfi.c:1.32
--- src/sys/dev/ic/mfi.c:1.31	Tue Jan 19 20:54:32 2010
+++ src/sys/dev/ic/mfi.c	Mon Feb  8 23:54:33 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.31 2010/01/19 20:54:32 bouyer Exp $ */
+/* $NetBSD: mfi.c,v 1.32 2010/02/08 23:54:33 msaitoh Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.31 2010/01/19 20:54:32 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.32 2010/02/08 23:54:33 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -1990,6 +1990,7 @@
 {
 	int i;
 	int nsensors = sc->sc_ld_cnt;
+	int rv;
 
 	sc->sc_sme = sysmon_envsys_create();
 	sc->sc_sensor = malloc(sizeof(envsys_data_t) * nsensors,
@@ -2017,9 +2018,10 @@
 	sc->sc_sme->sme_name = DEVNAME(sc);
 	sc->sc_sme->sme_cookie = sc;
 	sc->sc_sme->sme_refresh = mfi_sensor_refresh;
-	if (sysmon_envsys_register(sc->sc_sme)) {
-		aprint_error("%s: unable to register with sysmon\n",
-		DEVNAME(sc));
+	rv = sysmon_envsys_register(sc->sc_sme);
+	if (rv != 0) {
+		aprint_error("%s: unable to register with sysmon (rv = %d)\n",
+		DEVNAME(sc), rv);
 		goto out;
 	}
 	return 0;
@@ -2027,6 +2029,7 @@
 out:
 	free(sc->sc_sensor, M_DEVBUF);
 	sysmon_envsys_destroy(sc->sc_sme);
+	sc->sc_sme = NULL;
 	return EINVAL;
 }
 



CVS commit: src/sys/dev/pci

2010-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Feb  8 23:58:39 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add some MegaRAID Entries


To generate a diff of this commit:
cvs rdiff -u -r1.1019 -r1.1020 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1019 src/sys/dev/pci/pcidevs:1.1020
--- src/sys/dev/pci/pcidevs:1.1019	Wed Feb  3 19:27:24 2010
+++ src/sys/dev/pci/pcidevs	Mon Feb  8 23:58:38 2010
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1019 2010/02/03 19:27:24 macallan Exp $
+$NetBSD: pcidevs,v 1.1020 2010/02/08 23:58:38 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3102,6 +3102,10 @@
 product SYMBIOS SAS1066			0x005E	SAS1066
 product SYMBIOS SAS1078			0x0060	SAS1078 PCI
 product SYMBIOS SAS1078_PCIE		0x0062	SAS1078 PCI Express
+product SYMBIOS SAS2008			0x0072	SAS2008
+product SYMBIOS SAS2108_1		0x0078	MegaRAID SAS2108 CRYPTO GEN2
+product SYMBIOS SAS2108_2		0x0079	MegaRAID SAS2108 GEN2
+product SYMBIOS SAS1078DE		0x007c	SAS1078DE
 product SYMBIOS 875J			0x008f	53c875J
 product SYMBIOS FC909			0x0620	FC909
 product SYMBIOS FC909A			0x0621	FC909A



CVS commit: src/sys/dev

2010-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Feb  9 00:05:18 UTC 2010

Modified Files:
src/sys/dev/ic: mfi.c mfireg.h mfivar.h
src/sys/dev/pci: mfi_pci.c

Log Message:
Add newer cars supports. Tested on MegaRAID SAS 9260-8i.
 - Add MFI gen2 support from OpenBSD.
 - Add entry for MegaRAID SAS 9260-8i


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/ic/mfi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/mfireg.h
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/mfivar.h
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/mfi_pci.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.32 src/sys/dev/ic/mfi.c:1.33
--- src/sys/dev/ic/mfi.c:1.32	Mon Feb  8 23:54:33 2010
+++ src/sys/dev/ic/mfi.c	Tue Feb  9 00:05:18 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.32 2010/02/08 23:54:33 msaitoh Exp $ */
+/* $NetBSD: mfi.c,v 1.33 2010/02/09 00:05:18 msaitoh Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.32 2010/02/08 23:54:33 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.33 2010/02/09 00:05:18 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -137,6 +137,20 @@
 	mfi_ppc_post
 };
 
+uint32_t	mfi_gen2_fw_state(struct mfi_softc *sc);
+void		mfi_gen2_intr_ena(struct mfi_softc *sc);
+void		mfi_gen2_intr_dis(struct mfi_softc *sc);
+int		mfi_gen2_intr(struct mfi_softc *sc);
+void		mfi_gen2_post(struct mfi_softc *sc, struct mfi_ccb *ccb);
+
+static const struct mfi_iop_ops mfi_iop_gen2 = {
+	mfi_gen2_fw_state,
+	mfi_gen2_intr_dis,
+	mfi_gen2_intr_ena,
+	mfi_gen2_intr,
+	mfi_gen2_post
+};
+
 #define mfi_fw_state(_s) 	((_s)->sc_iop->mio_fw_state(_s))
 #define mfi_intr_enable(_s) 	((_s)->sc_iop->mio_intr_ena(_s))
 #define mfi_intr_disable(_s) 	((_s)->sc_iop->mio_intr_dis(_s))
@@ -709,6 +723,9 @@
 	case MFI_IOP_PPC:
 		sc->sc_iop = &mfi_iop_ppc;
 		break;
+	case MFI_IOP_GEN2:
+		sc->sc_iop = &mfi_iop_gen2;
+		break;
 	default:
 		 panic("%s: unknown iop %d", DEVNAME(sc), iop);
 	}
@@ -1299,7 +1316,8 @@
 
 static int
 mfi_mgmt_internal(struct mfi_softc *sc, uint32_t opc, uint32_t dir,
-uint32_t len, void *buf, uint8_t *mbox) {
+uint32_t len, void *buf, uint8_t *mbox)
+{
 	struct mfi_ccb		*ccb;
 	int			rv = 1;
 
@@ -2168,3 +2186,45 @@
 	mfi_write(sc, MFI_IQP, 0x1 | ccb->ccb_pframe |
 	(ccb->ccb_extra_frames << 1));
 }
+
+u_int32_t
+mfi_gen2_fw_state(struct mfi_softc *sc)
+{
+	return (mfi_read(sc, MFI_OSP));
+}
+
+void
+mfi_gen2_intr_dis(struct mfi_softc *sc)
+{
+	mfi_write(sc, MFI_OMSK, 0x);
+	mfi_write(sc, MFI_ODC, 0x);
+}
+
+void
+mfi_gen2_intr_ena(struct mfi_softc *sc)
+{
+	mfi_write(sc, MFI_ODC, 0x);
+	mfi_write(sc, MFI_OMSK, ~MFI_OSTS_GEN2_INTR_VALID);
+}
+
+int
+mfi_gen2_intr(struct mfi_softc *sc)
+{
+	u_int32_t status;
+
+	status = mfi_read(sc, MFI_OSTS);
+	if (!ISSET(status, MFI_OSTS_GEN2_INTR_VALID))
+		return (0);
+
+	/* write status back to acknowledge interrupt */
+	mfi_write(sc, MFI_ODC, status);
+
+	return (1);
+}
+
+void
+mfi_gen2_post(struct mfi_softc *sc, struct mfi_ccb *ccb)
+{
+	mfi_write(sc, MFI_IQP, 0x1 | ccb->ccb_pframe |
+	(ccb->ccb_extra_frames << 1));
+}

Index: src/sys/dev/ic/mfireg.h
diff -u src/sys/dev/ic/mfireg.h:1.3 src/sys/dev/ic/mfireg.h:1.4
--- src/sys/dev/ic/mfireg.h:1.3	Mon Feb 25 10:46:02 2008
+++ src/sys/dev/ic/mfireg.h	Tue Feb  9 00:05:18 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mfireg.h,v 1.3 2008/02/25 10:46:02 xtraeme Exp $ */
+/* $NetBSD: mfireg.h,v 1.4 2010/02/09 00:05:18 msaitoh Exp $ */
 /* $OpenBSD: mfireg.h,v 1.24 2006/06/19 19:05:45 marco Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom 
@@ -25,6 +25,7 @@
 #define MFI_SENSE_SIZE128
 #define MFI_OSTS_INTR_VALID			0x0002 /* valid interrupt */
 #define MFI_OSTS_PPC_INTR_VALID			0x8000
+#define MFI_OSTS_GEN2_INTR_VALID		(0x0001 | 0x0004)
 #define MFI_INVALID_CTX0x
 #define MFI_ENABLE_INTR0x01
 #define MFI_MAXFERMAXPHYS	/* XXX bogus */

Index: src/sys/dev/ic/mfivar.h
diff -u src/sys/dev/ic/mfivar.h:1.13 src/sys/dev/ic/mfivar.h:1.14
--- src/sys/dev/ic/mfivar.h:1.13	Thu Jul 16 18:58:38 2009
+++ src/sys/dev/ic/mfivar.h	Tue Feb  9 00:05:18 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mfivar.h,v 1.13 2009/07/16 18:58:38 dyoung Exp $ */
+/* $NetBSD: mfivar.h,v 1.14 2010/02/09 00:05:18 msaitoh Exp $ */
 /* $OpenBSD: mfivar.h,v 1.28 2006/08/31 18:18:46 marco Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom 
@@ -98,7 +98,8 @@
 
 enum mfi_iop {
 	MFI_IOP_XSCALE,
-	MFI_IOP_PPC
+	MFI_IOP_PPC,
+	MFI_IOP_GEN2
 };
 
 struct mfi_iop_ops {

Index: src/sys/dev/pci/mfi_pci.c
diff -u src/sys/dev/pci/mfi_pci.c:1.11 src/sys/dev/pci/mfi_pci.c:1.12
--- src/sys/dev/pci/mfi_pci.c:1.11	Thu Jul 16 18:58:38 2009
+++ src/sys/dev/pci/mfi_pci.c	Tue Feb  9 00:05:18 2010
@@ -1,4 +1,4 @@
-/* $NetBS

CVS commit: src/share/man/man4

2010-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Feb  9 00:21:27 UTC 2010

Modified Files:
src/share/man/man4: mfi.4

Log Message:
Update the manual for mfi GEN2.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/share/man/man4/mfi.4

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

Modified files:

Index: src/share/man/man4/mfi.4
diff -u src/share/man/man4/mfi.4:1.8 src/share/man/man4/mfi.4:1.9
--- src/share/man/man4/mfi.4:1.8	Mon May  4 19:18:49 2009
+++ src/share/man/man4/mfi.4	Tue Feb  9 00:21:27 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mfi.4,v 1.8 2009/05/04 19:18:49 wiz Exp $
+.\"	$NetBSD: mfi.4,v 1.9 2010/02/09 00:21:27 msaitoh Exp $
 .\"	$OpenBSD: mfi.4,v 1.7 2006/09/01 09:58:09 jmc Exp $
 .\"
 .\" Written by Marco Peereboom 
@@ -55,12 +55,14 @@
 MegaRAID SAS 8344ELP,
 MegaRAID SAS 8408E,
 MegaRAID SAS 8480E,
+MegaRAID SAS 8708ELP,
 MegaRAID SAS ELP,
-MegaRAID SAS 8880EM2
+MegaRAID SAS 8880EM2,
+MegaRAID SAS 9260-8i
 .El
 .Pp
-These controllers support RAID 0, RAID 1, RAID 5, RAID 10, and RAID 50
-using either SAS or SATA II drives.
+These controllers support RAID 0, RAID 1, RAID 5, RAID 6, RAID 10, RAID 50 and
+RAID 60 using either SAS or SATA II drives.
 .Pp
 Although the controllers are actual RAID controllers,
 the driver makes them look just like SCSI controllers.



CVS commit: src/doc

2010-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Feb  9 01:48:29 UTC 2010

Modified Files:
src/doc: CHANGES

Log Message:
mention about mfi(4)'s GEN2 support.


To generate a diff of this commit:
cvs rdiff -u -r1.1356 -r1.1357 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1356 src/doc/CHANGES:1.1357
--- src/doc/CHANGES:1.1356	Mon Feb  8 19:11:18 2010
+++ src/doc/CHANGES	Tue Feb  9 01:48:29 2010
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1356 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1357 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -538,7 +538,7 @@
 		linkage is now always the same.  [pooka 20100119]
 	dhcpcd(8): Import dhcpcd-5.1.5. [roy 20100131]
 	terminfo(3): Import my terminfo implementation to replace termcap.
-		roy [20100203]
+		[roy 20100203]
 	acpismbus(4): Add my experimental ACPI SMBus Control Method
 		Interface driver. [pgoyette 20100206]
 	uthum(4): Add a driver for TEMPer and TEMPerHUM usb thermometers.
@@ -546,3 +546,5 @@
 	network: Derive the mbuf cluster (NMBCLUSTERS) at boot time from
 		the available memory.  The default can be raised by changing
 		kern.mbuf.nmbclusters. [joerg 20100208]
+	mfi(4): Add support for LSI's newer (GEN2) RAID controller from
+		OpenBSD. [msaitoh 20100209]



CVS commit: src/sys/dev/pci

2010-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Feb  9 04:40:22 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Make some bge's name close to the real product names.


To generate a diff of this commit:
cvs rdiff -u -r1.1020 -r1.1021 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1020 src/sys/dev/pci/pcidevs:1.1021
--- src/sys/dev/pci/pcidevs:1.1020	Mon Feb  8 23:58:38 2010
+++ src/sys/dev/pci/pcidevs	Tue Feb  9 04:40:21 2010
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1020 2010/02/08 23:58:38 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1021 2010/02/09 04:40:21 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1455,8 +1455,8 @@
 product BLUESTEEL 5601		0x5601	5601
 
 /* Broadcom products */
-product BROADCOM BCM5752	0x1600	BCM5752 10/100/1000 Ethernet
-product BROADCOM BCM5752M	0x1601	BCM5752M 10/100/1000 Ethernet
+product BROADCOM BCM5752	0x1600	BCM5752 NetXtreme 1000baseT Ethernet
+product BROADCOM BCM5752M	0x1601	BCM5752M NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5709	0x1639	BCM5709 NetXtreme II 1000baseT Ethernet
 product BROADCOM BCM5709S	0x163a	BCM5709 NetXtreme II 1000baseSX Ethernet
 product BROADCOM BCM5716	0x163b	BCM5716 NetXtreme II 1000baseT Ethernet
@@ -1472,13 +1472,13 @@
 product BROADCOM BCM5702FE	0x164d	BCM5702FE 10/100 Ethernet
 product BROADCOM BCM5705	0x1653	BCM5705 10/100/1000 Ethernet
 product BROADCOM BCM5705K	0x1654	BCM5705K 10/100/1000 Ethernet
-product BROADCOM BCM5717	0x1655	BCM5717
-product BROADCOM BCM5718	0x1656	BCM5718
+product BROADCOM BCM5717	0x1655	BCM5717 10/100/1000 Ethernet
+product BROADCOM BCM5718	0x1656	BCM5718 10/100/1000 Ethernet
 product BROADCOM BCM5720	0x1658	BCM5720 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5721	0x1659	BCM5721 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5722	0x165a	BCM5722 NetXtreme 1000baseT Ethernet
-product BROADCOM BCM5723	0x165b	BCM5723
-product BROADCOM BCM5724	0x165c	BCM5724
+product BROADCOM BCM5723	0x165b	BCM5723 NetXtreme 1000baseT Ethernet
+product BROADCOM BCM5724	0x165c	BCM5724 10/100/1000 Ethernet
 product BROADCOM BCM5705M	0x165d	BCM5705M 10/100/1000 Ethernet
 product BROADCOM BCM5705M_ALT	0x165e	BCM5705M 10/100/1000 Ethernet
 product BROADCOM BCM5714	0x1668	BCM5714 1000baseT Ethernet
@@ -1497,40 +1497,40 @@
 product BROADCOM BCM5755	0x167b	BCM5755 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5750M	0x167c	BCM5750M 10/100/1000 Ethernet
 product BROADCOM BCM5751M	0x167d	BCM5751M 10/100/1000 Ethernet
-product BROADCOM BCM5751F	0x167e	BCM5751F 10/100/1000 Ethernet
-product BROADCOM BCM5787F	0x167f	BCM5787F
-product BROADCOM BCM5761E	0x1680	BCM5761E
-product BROADCOM BCM5761	0x1681	BCM5761
-product BROADCOM BCM5764	0x1684	BCM5764
-product BROADCOM BCM5761S	0x1688	BCM5761S
-product BROADCOM BCM5761SE	0x1689	BCM5761SE
-product BROADCOM BCM57760	0x1690	BCM57760
-product BROADCOM BCM57788	0x1691	BCM57788
-product BROADCOM BCM57780	0x1692	BCM57780
+product BROADCOM BCM5751F	0x167e	BCM5751F 10/100 Ethernet
+product BROADCOM BCM5787F	0x167f	BCM5787F 10/100 Ethernet
+product BROADCOM BCM5761E	0x1680	BCM5761E 10/100/1000 Ethernet
+product BROADCOM BCM5761	0x1681	BCM5761 10/100/1000 Ethernet
+product BROADCOM BCM5764	0x1684	BCM5764 NetXtreme 1000baseT Ethernet
+product BROADCOM BCM5761S	0x1688	BCM5761S 10/100/1000 Ethernet
+product BROADCOM BCM5761SE	0x1689	BCM5761SE 10/100/1000 Ethernet
+product BROADCOM BCM57760	0x1690	BCM57760 NetXtreme 1000baseT Ethernet
+product BROADCOM BCM57788	0x1691	BCM57788 NetLink 1000baseT Ethernet
+product BROADCOM BCM57780	0x1692	BCM57780 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5787M	0x1693	BCM5787M 10/100/1000 Ethernet
-product BROADCOM BCM57790	0x1694	BCM57790
+product BROADCOM BCM57790	0x1694	BCM57790 10/100 Ethernet
 product BROADCOM BCM5782	0x1696	BCM5782 10/100/1000 Ethernet
 product BROADCOM BCM5784M	0x1698	BCM5784M NetLink 1000baseT Ethernet
-product BROADCOM BCM5785G	0x1699	BCM5785G
+product BROADCOM BCM5785G	0x1699	BCM5785G 10/100/1000 Ethernet
 product BROADCOM BCM5786	0x169a	BCM5786 NetLink 1000baseT Ethernet
 product BROADCOM BCM5787	0x169b	BCM5787 NetLink 1000baseT Ethernet
 product BROADCOM BCM5788	0x169c	BCM5788 10/100/1000 Ethernet
-product BROADCOM BCM5789	0x169d	BCM5789 10/100/1000 Ethernet
-product BROADCOM BCM5785F	0x16a0	BCM5785F
+product BROADCOM BCM5789	0x169d	BCM5789 NetLink 1000baseT Ethernet
+product BROADCOM BCM5785F	0x16a0	BCM5785F 10/100/1000 Ethernet
 product BROADCOM BCM5702X	0x16a6	BCM5702X 10/100/1000 Ethernet
 product BROADCOM BCM5703X	0x16a7	BCM5703X 10/100/1000 Ethernet
 product BROADCOM BCM5704S	0x16a8	BCM5704S 1000baseSX Ethernet
 product BROADCOM BCM5706S	0x16aa	BCM5706 NetXtreme II 1000baseSX
 product BROADCOM BCM5708S	0x16ac	BCM5708 NetXtreme II 1000baseSX
-product BROADCOM BCM57761	0x16b0	BCM57761
-product BROADC

CVS commit: src/sys/dev/pci

2010-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Feb  9 04:40:52 UTC 2010

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1017 -r1.1018 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1016 -r1.1017 src/sys/dev/pci/pcidevs_data.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/pci/pcidevs.h
diff -u src/sys/dev/pci/pcidevs.h:1.1017 src/sys/dev/pci/pcidevs.h:1.1018
--- src/sys/dev/pci/pcidevs.h:1.1017	Mon Feb  8 23:59:09 2010
+++ src/sys/dev/pci/pcidevs.h	Tue Feb  9 04:40:52 2010
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1017 2010/02/08 23:59:09 msaitoh Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1018 2010/02/09 04:40:52 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1020 2010/02/08 23:58:38 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1021 2010/02/09 04:40:21 msaitoh Exp
  */
 
 /*
@@ -1462,8 +1462,8 @@
 #define	PCI_PRODUCT_BLUESTEEL_5601	0x5601		/* 5601 */
 
 /* Broadcom products */
-#define	PCI_PRODUCT_BROADCOM_BCM5752	0x1600		/* BCM5752 10/100/1000 Ethernet */
-#define	PCI_PRODUCT_BROADCOM_BCM5752M	0x1601		/* BCM5752M 10/100/1000 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5752	0x1600		/* BCM5752 NetXtreme 1000baseT Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5752M	0x1601		/* BCM5752M NetXtreme 1000baseT Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5709	0x1639		/* BCM5709 NetXtreme II 1000baseT Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5709S	0x163a		/* BCM5709 NetXtreme II 1000baseSX Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5716	0x163b		/* BCM5716 NetXtreme II 1000baseT Ethernet */
@@ -1479,13 +1479,13 @@
 #define	PCI_PRODUCT_BROADCOM_BCM5702FE	0x164d		/* BCM5702FE 10/100 Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5705	0x1653		/* BCM5705 10/100/1000 Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5705K	0x1654		/* BCM5705K 10/100/1000 Ethernet */
-#define	PCI_PRODUCT_BROADCOM_BCM5717	0x1655		/* BCM5717 */
-#define	PCI_PRODUCT_BROADCOM_BCM5718	0x1656		/* BCM5718 */
+#define	PCI_PRODUCT_BROADCOM_BCM5717	0x1655		/* BCM5717 10/100/1000 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5718	0x1656		/* BCM5718 10/100/1000 Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5720	0x1658		/* BCM5720 NetXtreme 1000baseT Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5721	0x1659		/* BCM5721 NetXtreme 1000baseT Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5722	0x165a		/* BCM5722 NetXtreme 1000baseT Ethernet */
-#define	PCI_PRODUCT_BROADCOM_BCM5723	0x165b		/* BCM5723 */
-#define	PCI_PRODUCT_BROADCOM_BCM5724	0x165c		/* BCM5724 */
+#define	PCI_PRODUCT_BROADCOM_BCM5723	0x165b		/* BCM5723 NetXtreme 1000baseT Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5724	0x165c		/* BCM5724 10/100/1000 Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5705M	0x165d		/* BCM5705M 10/100/1000 Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5705M_ALT	0x165e		/* BCM5705M 10/100/1000 Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5714	0x1668		/* BCM5714 1000baseT Ethernet */
@@ -1504,40 +1504,40 @@
 #define	PCI_PRODUCT_BROADCOM_BCM5755	0x167b		/* BCM5755 NetXtreme 1000baseT Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5750M	0x167c		/* BCM5750M 10/100/1000 Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5751M	0x167d		/* BCM5751M 10/100/1000 Ethernet */
-#define	PCI_PRODUCT_BROADCOM_BCM5751F	0x167e		/* BCM5751F 10/100/1000 Ethernet */
-#define	PCI_PRODUCT_BROADCOM_BCM5787F	0x167f		/* BCM5787F */
-#define	PCI_PRODUCT_BROADCOM_BCM5761E	0x1680		/* BCM5761E */
-#define	PCI_PRODUCT_BROADCOM_BCM5761	0x1681		/* BCM5761 */
-#define	PCI_PRODUCT_BROADCOM_BCM5764	0x1684		/* BCM5764 */
-#define	PCI_PRODUCT_BROADCOM_BCM5761S	0x1688		/* BCM5761S */
-#define	PCI_PRODUCT_BROADCOM_BCM5761SE	0x1689		/* BCM5761SE */
-#define	PCI_PRODUCT_BROADCOM_BCM57760	0x1690		/* BCM57760 */
-#define	PCI_PRODUCT_BROADCOM_BCM57788	0x1691		/* BCM57788 */
-#define	PCI_PRODUCT_BROADCOM_BCM57780	0x1692		/* BCM57780 */
+#define	PCI_PRODUCT_BROADCOM_BCM5751F	0x167e		/* BCM5751F 10/100 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5787F	0x167f		/* BCM5787F 10/100 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5761E	0x1680		/* BCM5761E 10/100/1000 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5761	0x1681		/* BCM5761 10/100/1000 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5764	0x1684		/* BCM5764 NetXtreme 1000baseT Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5761S	0x1688		/* BCM5761S 10/100/1000 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM5761SE	0x1689		/* BCM5761SE 10/100/1000 Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM57760	0x1690		/* BCM57760 NetXtreme 1000baseT Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM57788	0x1691		/* BCM57788 NetLink 1000baseT Ethernet */
+#define	PCI_PRODUCT_BROADCOM_BCM57780	0x1692		/* BCM57780 NetXtreme 1000baseT Ethernet */
 #define	PCI_PRODUCT_BROADCOM_BCM5787M	0x1693		/* BCM5787M 10/100/1000 Ethernet */
-#define	

CVS commit: src/sys/dev/pci

2010-02-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Feb 12 04:01:07 UTC 2010

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
- Add some PCIe config registers.
- The register at 0x1c is not Control Status register. It contains Control
  bits only. Rename it.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/pcireg.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/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.63 src/sys/dev/pci/pcireg.h:1.64
--- src/sys/dev/pci/pcireg.h:1.63	Mon Feb  1 05:38:36 2010
+++ src/sys/dev/pci/pcireg.h	Fri Feb 12 04:01:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.63 2010/02/01 05:38:36 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.64 2010/02/12 04:01:07 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -584,7 +584,14 @@
 #define PCI_PCIE_SLCSR_MS	0x0020
 #define PCI_PCIE_SLCSR_PDS	0x0040
 #define PCI_PCIE_SLCSR_LACS	0x0100
-#define PCI_PCIE_RCSR		0x1c
+#define PCI_PCIE_RCR		0x1c
+#define PCI_PCIE_RSR		0x20
+#define PCI_PCIE_DCAP2		0x24
+#define PCI_PCIE_DCSR2		0x28
+#define PCI_PCIE_LCAP2		0x2c
+#define PCI_PCIE_LCSR2		0x30
+#define PCI_PCIE_SLCAP2		0x34
+#define PCI_PCIE_SLCSR2		0x38
 
 /*
  * Interrupt Configuration Register; contains interrupt pin and line.



CVS commit: src/sys/arch/x86/include

2020-09-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep  7 03:03:09 UTC 2020

Modified Files:
src/sys/arch/x86/include: specialreg.h

Log Message:
 Add CPUID(EAX=07H, ECX=0) ECX bit 16 LA57 from maxv.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/x86/include/specialreg.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/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.173 src/sys/arch/x86/include/specialreg.h:1.174
--- src/sys/arch/x86/include/specialreg.h:1.173	Sat Sep  5 07:45:44 2020
+++ src/sys/arch/x86/include/specialreg.h	Mon Sep  7 03:03:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.173 2020/09/05 07:45:44 maxv Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.174 2020/09/07 03:03:09 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
@@ -456,6 +456,7 @@
 #define CPUID_SEF_AVX512_VNNI	__BIT(11) /* Vector neural Network Instruction */
 #define CPUID_SEF_AVX512_BITALG	__BIT(12)
 #define CPUID_SEF_AVX512_VPOPCNTDQ __BIT(14)
+#define CPUID_SEF_LA57		__BIT(16) /* 57bit linear addr & 5LVL paging */
 #define CPUID_SEF_MAWAU		__BITS(21, 17) /* MAWAU for BND{LD,ST}X */
 #define CPUID_SEF_RDPID		__BIT(22) /* RDPID and IA32_TSC_AUX */
 #define CPUID_SEF_CLDEMOTE	__BIT(25) /* Cache line demote */
@@ -469,6 +470,7 @@
 	"b\4OSPKE\0"	"b\5WAITPKG\0"	"b\6AVX512_VBMI2\0" "b\7CET_SS\0" \
 	"b\10GFNI\0"	"b\11VAES\0"	"b\12VPCLMULQDQ\0" "b\13AVX512_VNNI\0"\
 	"b\14AVX512_BITALG\0"		"b\16AVX512_VPOPCNTDQ\0"	\
+	"b\20\LA57\0"			\
 	"f\21\5MAWAU\0"			\
 	"b\26RDPID\0"			\
 			"b\31CLDEMOTE\0"		"b\33MOVDIRI\0"	\



CVS commit: src/sys/dev/pci/ixgbe

2020-09-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep  7 03:57:28 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
 Don't schedule admin work while shutdown like the recovery mode timer.

 The admin workqueue also runs while !IFF_UP like the recovery mode timer.
Apply the same change of ixgbe.c 1.254 to ixgbe_schedule_admin_tasklet()
to prevent panic. Found by ozaki-r@.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.254 src/sys/dev/pci/ixgbe/ixgbe.c:1.255
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.254	Tue Sep  1 04:19:16 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Sep  7 03:57:27 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.254 2020/09/01 04:19:16 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.255 2020/09/07 03:57:27 msaitoh Exp $ */
 
 /**
 
@@ -1538,9 +1538,11 @@ static void
 ixgbe_schedule_admin_tasklet(struct adapter *adapter)
 {
 
-	if (atomic_cas_uint(&adapter->admin_pending, 0, 1) == 0)
-		workqueue_enqueue(adapter->admin_wq,
-		&adapter->admin_wc, NULL);
+	if (__predict_false(adapter->osdep.detaching == false)) {
+		if (atomic_cas_uint(&adapter->admin_pending, 0, 1) == 0)
+			workqueue_enqueue(adapter->admin_wq,
+			&adapter->admin_wc, NULL);
+	}
 }
 
 /



CVS commit: src/sys/dev/pci/ixgbe

2020-09-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep  7 04:15:12 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c

Log Message:
__predict_false() should be __predict_true() for adapter->osdep.detaching
== false check.


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.255 src/sys/dev/pci/ixgbe/ixgbe.c:1.256
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.255	Mon Sep  7 03:57:27 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Sep  7 04:15:12 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.255 2020/09/07 03:57:27 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.256 2020/09/07 04:15:12 msaitoh Exp $ */
 
 /**
 
@@ -1538,7 +1538,7 @@ static void
 ixgbe_schedule_admin_tasklet(struct adapter *adapter)
 {
 
-	if (__predict_false(adapter->osdep.detaching == false)) {
+	if (__predict_true(adapter->osdep.detaching == false)) {
 		if (atomic_cas_uint(&adapter->admin_pending, 0, 1) == 0)
 			workqueue_enqueue(adapter->admin_wq,
 			&adapter->admin_wc, NULL);
@@ -4627,7 +4627,7 @@ ixgbe_recovery_mode_timer(void *arg)
 {
 	struct adapter *adapter = arg;
 
-	if (__predict_false(adapter->osdep.detaching == false)) {
+	if (__predict_true(adapter->osdep.detaching == false)) {
 		if (atomic_cas_uint(&adapter->recovery_mode_timer_pending,
 			0, 1) == 0) {
 			workqueue_enqueue(adapter->recovery_mode_timer_wq,



CVS commit: src/sys/dev/pci/ixgbe

2020-09-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep  7 05:50:58 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe: if_fdir.c if_sriov.c ixgbe.c ixv.c

Log Message:
- Remove extra callout_stop() in ixgbe_detach(). Found by knakahara@.
- Rename ix{gbe,v}_free_workqueue() to ix{gbe,v}_free_deferred_handlers().
- Add KASSERT() to functions who are called from ixgbe_handle_admin().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/ixgbe/if_fdir.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/if_sriov.c
cvs rdiff -u -r1.256 -r1.257 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.153 -r1.154 src/sys/dev/pci/ixgbe/ixv.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/pci/ixgbe/if_fdir.c
diff -u src/sys/dev/pci/ixgbe/if_fdir.c:1.2 src/sys/dev/pci/ixgbe/if_fdir.c:1.3
--- src/sys/dev/pci/ixgbe/if_fdir.c:1.2	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/if_fdir.c	Mon Sep  7 05:50:58 2020
@@ -55,6 +55,8 @@ ixgbe_reinit_fdir(void *context)
 	struct adapter *adapter = context;
 	struct ifnet   *ifp = adapter->ifp;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
+
 	if (!(adapter->feat_en & IXGBE_FEATURE_FDIR))
 		return;
 	if (adapter->fdir_reinit != 1) /* Shouldn't happen */

Index: src/sys/dev/pci/ixgbe/if_sriov.c
diff -u src/sys/dev/pci/ixgbe/if_sriov.c:1.7 src/sys/dev/pci/ixgbe/if_sriov.c:1.8
--- src/sys/dev/pci/ixgbe/if_sriov.c:1.7	Thu Jun 25 07:53:01 2020
+++ src/sys/dev/pci/ixgbe/if_sriov.c	Mon Sep  7 05:50:58 2020
@@ -643,6 +643,8 @@ ixgbe_handle_mbx(void *context, int pend
 	struct ixgbe_vf *vf;
 	int i;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
+
 	hw = &adapter->hw;
 
 	for (i = 0; i < adapter->num_vfs; i++) {

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.256 src/sys/dev/pci/ixgbe/ixgbe.c:1.257
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.256	Mon Sep  7 04:15:12 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Sep  7 05:50:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.256 2020/09/07 04:15:12 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.257 2020/09/07 05:50:58 msaitoh Exp $ */
 
 /**
 
@@ -181,7 +181,7 @@ static void	ixgbe_media_status(struct if
 static int	ixgbe_media_change(struct ifnet *);
 static int	ixgbe_allocate_pci_resources(struct adapter *,
 		const struct pci_attach_args *);
-static void	ixgbe_free_workqueue(struct adapter *);
+static void	ixgbe_free_deferred_handlers(struct adapter *);
 static void	ixgbe_get_slot_info(struct adapter *);
 static int	ixgbe_allocate_msix(struct adapter *,
 		const struct pci_attach_args *);
@@ -1279,7 +1279,7 @@ err_out:
 	ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
 	ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD;
 	IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, ctrl_ext);
-	ixgbe_free_workqueue(adapter);
+	ixgbe_free_deferred_handlers(adapter);
 	ixgbe_free_pci_resources(adapter);
 	if (adapter->mta != NULL)
 		free(adapter->mta, M_DEVBUF);
@@ -3518,7 +3518,7 @@ map_err:
 } /* ixgbe_allocate_pci_resources */
 
 static void
-ixgbe_free_workqueue(struct adapter *adapter)
+ixgbe_free_deferred_handlers(struct adapter *adapter)
 {
 	struct ix_queue *que = adapter->queues;
 	struct tx_ring *txr = adapter->tx_rings;
@@ -3558,7 +3558,7 @@ ixgbe_free_workqueue(struct adapter *ada
 		workqueue_destroy(adapter->recovery_mode_timer_wq);
 		adapter->recovery_mode_timer_wq = NULL;
 	}
-} /* ixgbe_free_workqueue */
+} /* ixgbe_free_deferred_handlers */
 
 /
  * ixgbe_detach - Device removal routine
@@ -3610,10 +3610,8 @@ ixgbe_detach(device_t dev, int flags)
 	ixgbe_setup_low_power_mode(adapter);
 
 	callout_halt(&adapter->timer, NULL);
-	if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) {
-		callout_stop(&adapter->recovery_mode_timer);
+	if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE)
 		callout_halt(&adapter->recovery_mode_timer, NULL);
-	}
 
 	workqueue_wait(adapter->admin_wq, &adapter->admin_wc);
 	atomic_store_relaxed(&adapter->admin_pending, 0);
@@ -3624,7 +3622,7 @@ ixgbe_detach(device_t dev, int flags)
 
 	ether_ifdetach(adapter->ifp);
 
-	ixgbe_free_workqueue(adapter);
+	ixgbe_free_deferred_handlers(adapter);
 
 	/* let hardware know driver is unloading */
 	ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
@@ -4673,6 +4671,8 @@ ixgbe_handle_mod(void *context)
 	u32		err;
 	bool		last_unsupported_sfp_recovery;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
+
 	last_sfp_type = hw->phy.sfp_type;
 	last_unsupported_sfp_recovery = hw->need_unsupported_sfp_recovery;
 	++adapter->mod_workev.ev_count;
@@ -4754,6 +4754,8 @@ ixgbe_handle_msf(void *context)
 	u32		autoneg;
 	bool		negotiate;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
+
 	++adapter->msf_workev.ev_count;
 
 	autoneg = hw->phy.autoneg_advertised;
@@ -4773,6 +4775,8 @@ ixgbe_han

CVS commit: src/sys/dev/pci

2020-09-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 15 08:39:04 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c if_wmvar.h

Log Message:
 Add new flag named WM_F_CRC_STRIP and use it. No functional change.

 This change also sets the RCTL_SECRC bit on I211 but it doesn't change
the behavior because I211 always strips CRC like I35[04] and I210.


To generate a diff of this commit:
cvs rdiff -u -r1.686 -r1.687 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/if_wmvar.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.686 src/sys/dev/pci/if_wm.c:1.687
--- src/sys/dev/pci/if_wm.c:1.686	Mon Aug 24 05:34:00 2020
+++ src/sys/dev/pci/if_wm.c	Tue Sep 15 08:39:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.686 2020/08/24 05:34:00 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.687 2020/09/15 08:39:04 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.686 2020/08/24 05:34:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.687 2020/09/15 08:39:04 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2887,6 +2887,14 @@ alloc_retry:
 			sc->sc_flags |= WM_F_EEE;
 	}
 
+	/*
+	 * The I350 has a bug where it always strips the CRC whether
+	 * asked to or not. So ask for stripped CRC here and cope in rxeof
+	 */
+	if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354)
+	|| (sc->sc_type == WM_T_I210) || (sc->sc_type == WM_T_I211))
+		sc->sc_flags |= WM_F_CRC_STRIP;
+
 	/* Set device properties (macflags) */
 	prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags);
 
@@ -6311,12 +6319,7 @@ wm_init_locked(struct ifnet *ifp)
 	if (sc->sc_type == WM_T_82574)
 		sc->sc_rctl |= RCTL_DTYP_ONEBUF;
 
-	/*
-	 * The I350 has a bug where it always strips the CRC whether
-	 * asked to or not. So ask for stripped CRC here and cope in rxeof
-	 */
-	if ((sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354)
-	|| (sc->sc_type == WM_T_I210))
+	if ((sc->sc_flags & WM_F_CRC_STRIP) != 0)
 		sc->sc_rctl |= RCTL_SECRC;
 
 	if (((ec->ec_capabilities & ETHERCAP_JUMBO_MTU) != 0)
@@ -9057,17 +9060,16 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
 
 		/*
 		 * Okay, we have the entire packet now. The chip is
-		 * configured to include the FCS except I350 and I21[01]
-		 * (not all chips can be configured to strip it),
-		 * so we need to trim it.
+		 * configured to include the FCS except I35[05], I21[01].
+		 * (not all chips can be configured to strip it), so we need
+		 * to trim it. Those chips have an eratta, the RCTL_SECRC bit
+		 * in RCTL register is always set, so we don't trim it.
+		 * PCH2 and newer chip also not include FCS when jumbo
+		 * frame is used to do workaround an errata.
 		 * May need to adjust length of previous mbuf in the
 		 * chain if the current mbuf is too short.
-		 * For an eratta, the RCTL_SECRC bit in RCTL register
-		 * is always set in I350, so we don't trim it.
 		 */
-		if ((sc->sc_type != WM_T_I350) && (sc->sc_type != WM_T_I354)
-		&& (sc->sc_type != WM_T_I210)
-		&& (sc->sc_type != WM_T_I211)) {
+		if ((sc->sc_flags & WM_F_CRC_STRIP) == 0) {
 			if (m->m_len < ETHER_CRC_LEN) {
 rxq->rxq_tail->m_len
 -= (ETHER_CRC_LEN - m->m_len);

Index: src/sys/dev/pci/if_wmvar.h
diff -u src/sys/dev/pci/if_wmvar.h:1.45 src/sys/dev/pci/if_wmvar.h:1.46
--- src/sys/dev/pci/if_wmvar.h:1.45	Wed Dec 11 10:28:19 2019
+++ src/sys/dev/pci/if_wmvar.h	Tue Sep 15 08:39:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmvar.h,v 1.45 2019/12/11 10:28:19 msaitoh Exp $	*/
+/*	$NetBSD: if_wmvar.h,v 1.46 2020/09/15 08:39:04 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -99,6 +99,7 @@
 #define	WM_F_WA_I210_CLSEM	0x0800 /* I21[01] Semaphore workaround */
 #define	WM_F_SFP		0x1000 /* SFP */
 #define	WM_F_MAS		0x2000 /* Media Auto Sense */
+#define	WM_F_CRC_STRIP		0x4000 /* CRC strip */
 
 #define WM_FLAGS "\20" \
 	"\1" "HAS_MII"	"\2" "LOCK_EECD" "\3" "_B02"	"\4" "_B03"	\
@@ -108,7 +109,7 @@
 	"\21" "NEWQUEUE" "\22" "ASF_FIRM" "\23" "ARC_SUBSYS" "\24" "AMT" \
 	"\25" "MANAGE"	"\26" "WOL"	"\27" "EEE"	"\30" "ATTACHED" \
 	"\31" "MDIC_WA"	"\32" "PCS_DIS_AUTONEGO" "\33" "PLLWA" "\34" "CLSEMWA" \
-	"\35" "SFP"	"\36" "MAS"
+	"\35" "SFP"	"\36" "MAS"	"\37" "CRC_STRIP"
 
 /*
  * Variations of Intel gigabit Ethernet controller:



CVS commit: src/sys/dev

2020-09-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep 16 15:04:02 UTC 2020

Modified Files:
src/sys/dev/mii: inbmphyreg.h
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
 Add a workaround for jumbo frame on PCH2 and newer. Tested by chs@.

- Add wm_lv_jumbo_workaround_ich8lan() and use it. From FreeBSD.

  XXX For KUMCTRLSTA_OFFSET_HD_CTRL register modification, it's doubtful.
  FreeBSD and Linux do the same thing that they set the same value on both
  jumbo frame's enable case and the disable case. It seems the default value
  is 0x0b0c and it's not changed on the enable case, so it might be a bug
  on the enable case or the modification is not required.

- Rename I219_UNKNOWN1 to I82579_UNKNOWN1.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/mii/inbmphyreg.h
cvs rdiff -u -r1.687 -r1.688 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/pci/if_wmreg.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/mii/inbmphyreg.h
diff -u src/sys/dev/mii/inbmphyreg.h:1.19 src/sys/dev/mii/inbmphyreg.h:1.20
--- src/sys/dev/mii/inbmphyreg.h:1.19	Wed Dec 11 07:33:55 2019
+++ src/sys/dev/mii/inbmphyreg.h	Wed Sep 16 15:04:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: inbmphyreg.h,v 1.19 2019/12/11 07:33:55 msaitoh Exp $	*/
+/*	$NetBSD: inbmphyreg.h,v 1.20 2020/09/16 15:04:01 msaitoh Exp $	*/
 /***
 Copyright (c) 2001-2015, Intel Corporation 
 All rights reserved.
@@ -136,6 +136,8 @@ POSSIBILITY OF SUCH DAMAGE.
 
 #define	BM_PORT_GEN_CFG		BME1000_REG(BM_PORT_CTRL_PAGE, 17)
 
+#define	I82579_DFT_CTRL		BME1000_REG(BM_PORT_CTRL_PAGE, 20)
+
 #define	CV_SMB_CTRL		BME1000_REG(BM_PORT_CTRL_PAGE, 23)
 #define	CV_SMB_CTRL_FORCE_SMBUS	__BIT(0)
 
@@ -180,7 +182,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define HV_MUX_DATA_CTRL_FORCE_SPEED	(1 << 2)
 #define HV_MUX_DATA_CTRL_GEN_TO_MAC	(1 << 10)
 
-#define I219_UNKNOWN1		BME1000_REG(776, 20)
+#define I82579_UNKNOWN1		BME1000_REG(776, 20)
+#define I82579_TX_PTR_GAP	0x1f
 
 #define I218_ULP_CONFIG1	BME1000_REG(779, 16)
 #define I218_ULP_CONFIG1_START		__BIT(0)

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.687 src/sys/dev/pci/if_wm.c:1.688
--- src/sys/dev/pci/if_wm.c:1.687	Tue Sep 15 08:39:04 2020
+++ src/sys/dev/pci/if_wm.c	Wed Sep 16 15:04:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.687 2020/09/15 08:39:04 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.688 2020/09/16 15:04:01 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.687 2020/09/15 08:39:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.688 2020/09/16 15:04:01 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1016,6 +1016,8 @@ static int	wm_kmrn_lock_loss_workaround_
 static void	wm_gig_downshift_workaround_ich8lan(struct wm_softc *);
 static int	wm_hv_phy_workarounds_ich8lan(struct wm_softc *);
 static void	wm_copy_rx_addrs_to_phy_ich8lan(struct wm_softc *);
+static void	wm_copy_rx_addrs_to_phy_ich8lan_locked(struct wm_softc *);
+static int	wm_lv_jumbo_workaround_ich8lan(struct wm_softc *, bool);
 static int	wm_lv_phy_workarounds_ich8lan(struct wm_softc *);
 static int	wm_k1_workaround_lpt_lp(struct wm_softc *, bool);
 static int	wm_k1_gig_workaround_hv(struct wm_softc *, int);
@@ -3802,7 +3804,7 @@ wm_set_filter(struct wm_softc *sc)
 	struct ether_multistep step;
 	bus_addr_t mta_reg;
 	uint32_t hash, reg, bit;
-	int i, size, ralmax;
+	int i, size, ralmax, rv;
 
 	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
@@ -3928,6 +3930,17 @@ wm_set_filter(struct wm_softc *sc)
 	sc->sc_rctl |= RCTL_MPE;
 
  setit:
+	if (sc->sc_type >= WM_T_PCH2) {
+		if (((ec->ec_capabilities & ETHERCAP_JUMBO_MTU) != 0)
+		&& (ifp->if_mtu > ETHERMTU))
+			rv = wm_lv_jumbo_workaround_ich8lan(sc, true);
+		else
+			rv = wm_lv_jumbo_workaround_ich8lan(sc, false);
+		if (rv != 0)
+			device_printf(sc->sc_dev,
+			"Failed to do workaround for jumbo frame.\n");
+	}
+
 	CSR_WRITE(sc, WMREG_RCTL, sc->sc_rctl);
 }
 
@@ -9312,7 +9325,7 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
 	return;
 
 rv = sc->phy.readreg_locked(dev, 2,
-I219_UNKNOWN1, &data);
+I82579_UNKNOWN1, &data);
 if (rv) {
 	sc->phy.release(sc);
 	return;
@@ -9323,7 +9336,7 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
 	data &= ~(0x3ff << 2);
 	data |= (0x18 << 2);
 	rv = sc->phy.writereg_locked(dev,
-	2, I219_UNKNOWN1, data);
+	2, I82579_UNKNOWN1, data);
 }
 sc->phy.release(sc);
 if (rv)
@@ -9334,7 +9347,7 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
 	return;
 
 rv = sc->phy.writereg_locked(dev, 2,
-I219_UNKNOWN1, 0xc023);
+I82579_UNKNOWN1, 0xc023);
 sc->phy.relea

CVS commit: src/sys/dev/pci

2020-09-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep 16 15:04:58 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Use 12K for packet buffer for jumbo frame on PCH2 and newer.

XXX Note that Linux Use 14K.


To generate a diff of this commit:
cvs rdiff -u -r1.688 -r1.689 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.688 src/sys/dev/pci/if_wm.c:1.689
--- src/sys/dev/pci/if_wm.c:1.688	Wed Sep 16 15:04:01 2020
+++ src/sys/dev/pci/if_wm.c	Wed Sep 16 15:04:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.688 2020/09/16 15:04:01 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.689 2020/09/16 15:04:57 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.688 2020/09/16 15:04:01 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.689 2020/09/16 15:04:57 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4873,7 +4873,8 @@ wm_reset(struct wm_softc *sc)
 	case WM_T_PCH_LPT:
 	case WM_T_PCH_SPT:
 	case WM_T_PCH_CNP:
-		sc->sc_pba = PBA_26K;
+		sc->sc_pba = sc->sc_ethercom.ec_if.if_mtu > 1500 ?
+		PBA_12K : PBA_26K;
 		break;
 	default:
 		sc->sc_pba = sc->sc_ethercom.ec_if.if_mtu > 8192 ?



CVS commit: src/sys/dev/ic

2020-09-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep 21 06:57:00 UTC 2020

Modified Files:
src/sys/dev/ic: rtl8169.c rtl81x9reg.h rtl81x9var.h

Log Message:
- Print chip revision. From OpenBSD.
- Rename RTK_HWREV_8168_SPIN[123] to RTK_HWREV_8168'B'_SPIN[123].
  Same as other *BSDs.
- Rename RTK_HWREV_8168G_SPIN4 to RTK_HWREV_8411B. Same as other *BSDs.
- Add definition of RTK_HWREV_8169_8110SCE.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.57 -r1.58 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.166 src/sys/dev/ic/rtl8169.c:1.167
--- src/sys/dev/ic/rtl8169.c:1.166	Fri Mar 13 04:08:07 2020
+++ src/sys/dev/ic/rtl8169.c	Mon Sep 21 06:57:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.166 2020/03/13 04:08:07 thorpej Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.167 2020/09/21 06:57:00 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.166 2020/03/13 04:08:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.167 2020/09/21 06:57:00 msaitoh Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -172,6 +172,54 @@ static void re_miibus_statchg(struct ifn
 
 static void re_reset(struct rtk_softc *);
 
+static const struct re_revision {
+	uint32_t		re_chipid;
+	const char		*re_name;
+} re_revisions[] = {
+	{ RTK_HWREV_8100,	"RTL8100" },
+	{ RTK_HWREV_8100E,	"RTL8100E" },
+	{ RTK_HWREV_8100E_SPIN2, "RTL8100E 2" },
+	{ RTK_HWREV_8101,	"RTL8101" },
+	{ RTK_HWREV_8101E,	"RTL8101E" },
+	{ RTK_HWREV_8102E,	"RTL8102E" },
+	{ RTK_HWREV_8106E,	"RTL8106E" },
+	{ RTK_HWREV_8401E,	"RTL8401E" },
+	{ RTK_HWREV_8402,	"RTL8402" },
+	{ RTK_HWREV_8411,	"RTL8411" },
+	{ RTK_HWREV_8411B,	"RTL8411B" },
+	{ RTK_HWREV_8102EL,	"RTL8102EL" },
+	{ RTK_HWREV_8102EL_SPIN1, "RTL8102EL 1" },
+	{ RTK_HWREV_8103E,   "RTL8103E" },
+	{ RTK_HWREV_8110S,	"RTL8110S" },
+	{ RTK_HWREV_8139CPLUS,	"RTL8139C+" },
+	{ RTK_HWREV_8168B_SPIN1, "RTL8168 1" },
+	{ RTK_HWREV_8168B_SPIN2, "RTL8168 2" },
+	{ RTK_HWREV_8168B_SPIN3, "RTL8168 3" },
+	{ RTK_HWREV_8168C,	"RTL8168C/8111C" },
+	{ RTK_HWREV_8168C_SPIN2, "RTL8168C/8111C" },
+	{ RTK_HWREV_8168CP,	"RTL8168CP/8111CP" },
+	{ RTK_HWREV_8168F,	"RTL8168F/8111F" },
+	{ RTK_HWREV_8168G,	"RTL8168G/8111G" },
+	{ RTK_HWREV_8168GU,	"RTL8168GU/8111GU" },
+	{ RTK_HWREV_8168H,	"RTL8168H/8111H" },
+	{ RTK_HWREV_8105E,	"RTL8105E" },
+	{ RTK_HWREV_8105E_SPIN1, "RTL8105E" },
+	{ RTK_HWREV_8168D,	"RTL8168D/8111D" },
+	{ RTK_HWREV_8168DP,	"RTL8168DP/8111DP" },
+	{ RTK_HWREV_8168E,	"RTL8168E/8111E" },
+	{ RTK_HWREV_8168E_VL,	"RTL8168E/8111E-VL" },
+	{ RTK_HWREV_8168EP,	"RTL8168EP/8111EP" },
+	{ RTK_HWREV_8168FP,	"RTL8168FP/8117" },
+	{ RTK_HWREV_8169,	"RTL8169" },
+	{ RTK_HWREV_8169_8110SB, "RTL8169/8110SB" },
+	{ RTK_HWREV_8169_8110SBL, "RTL8169SBL" },
+	{ RTK_HWREV_8169_8110SC, "RTL8169/8110SCd" },
+	{ RTK_HWREV_8169_8110SCE, "RTL8169/8110SCe" },
+	{ RTK_HWREV_8169S,	"RTL8169S" },
+
+	{ 0, NULL }
+};
+
 static inline void
 re_set_bufaddr(struct re_desc *d, bus_addr_t addr)
 {
@@ -559,13 +607,26 @@ re_attach(struct rtk_softc *sc)
 	struct ifnet *ifp;
 	struct mii_data *mii = &sc->mii;
 	int error = 0, i;
+	const struct re_revision *rr;
+	const char *re_name = NULL;
 
 	if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) {
-		uint32_t hwrev;
-
 		/* Revision of 8169/8169S/8110s in bits 30..26, 23 */
-		hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
-		switch (hwrev) {
+		sc->sc_hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
+
+		for (rr = re_revisions; rr->re_name != NULL; rr++) {
+			if (rr->re_chipid == sc->sc_hwrev)
+re_name = rr->re_name;
+		}
+
+		if (re_name == NULL)
+			aprint_normal_dev(sc->sc_dev,
+			"unknown ASIC (0x%04x)\n", sc->sc_hwrev >> 16);
+		else
+			aprint_normal_dev(sc->sc_dev,
+			"%s (0x%04x)\n", re_name, sc->sc_hwrev >> 16);
+
+		switch (sc->sc_hwrev) {
 		case RTK_HWREV_8169:
 			sc->sc_quirk |= RTKQ_8169NONS;
 			break;
@@ -576,9 +637,9 @@ re_attach(struct rtk_softc *sc)
 		case RTK_HWREV_8169_8110SC:
 			sc->sc_quirk |= RTKQ_MACLDPS;
 			break;
-		case RTK_HWREV_8168_SPIN1:
-		case RTK_HWREV_8168_SPIN2:
-		case RTK_HWREV_8168_SPIN3:
+		case RTK_HWREV_8168B_SPIN1:
+		case RTK_HWREV_8168B_SPIN2:
+		case RTK_HWREV_8168B_SPIN3:
 			sc->sc_quirk |= RTKQ_MACSTAT;
 			break;
 		case RTK_HWREV_8168C:
@@ -625,7 +686,7 @@ re_attach(struct rtk_softc *sc)
 		case RTK_HWREV_8168G:
 		case RTK_HWREV_8168G_SPIN1:
 		case RTK_HWREV_8168G_SPIN2:
-		case RTK_HWREV_8168G_SPIN4:
+		case RTK_HWREV_8411B:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO | 
 			RTKQ_RXDV_GATED;
@@ -647,7 +708,7 @@ re_a

CVS commit: src/sys/dev/pci

2020-09-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Sep 24 08:00:59 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
Small fixes from knakahara:

- Check return value correctly in wm_lv_jumbo_workaround_ich8lan().
- Fix comment.


To generate a diff of this commit:
cvs rdiff -u -r1.689 -r1.690 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.689 src/sys/dev/pci/if_wm.c:1.690
--- src/sys/dev/pci/if_wm.c:1.689	Wed Sep 16 15:04:57 2020
+++ src/sys/dev/pci/if_wm.c	Thu Sep 24 08:00:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.689 2020/09/16 15:04:57 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.690 2020/09/24 08:00:59 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.689 2020/09/16 15:04:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.690 2020/09/24 08:00:59 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -9074,7 +9074,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
 
 		/*
 		 * Okay, we have the entire packet now. The chip is
-		 * configured to include the FCS except I35[05], I21[01].
+		 * configured to include the FCS except I35[04], I21[01].
 		 * (not all chips can be configured to strip it), so we need
 		 * to trim it. Those chips have an eratta, the RCTL_SECRC bit
 		 * in RCTL register is always set, so we don't trim it.
@@ -15969,7 +15969,7 @@ wm_lv_jumbo_workaround_ich8lan(struct wm
 		return rv;
 
 	/* Disable Rx path while enabling/disabling workaround */
-	sc->phy.readreg_locked(dev, 2, I82579_DFT_CTRL, &dft_ctrl);
+	rv = sc->phy.readreg_locked(dev, 2, I82579_DFT_CTRL, &dft_ctrl);
 	if (rv != 0)
 		goto out;
 	rv = sc->phy.writereg_locked(dev, 2, I82579_DFT_CTRL,



CVS commit: src

2020-09-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 29 02:49:56 UTC 2020

Modified Files:
src/distrib/alpha/instkernel/ramdisk: install.sh
src/doc: CHANGES.prev
src/etc/defaults: rc.conf
src/sbin/disklabel: main.c
src/sys/arch/atari/stand/ahdilabel: privahdi.h
src/sys/arch/hp300/dev: rd.c
src/sys/compat/ultrix: ultrix_fs.c
src/sys/dev/gpib: rd.c
src/sys/dev/scsipi: cd.c
src/sys/uvm: uvm_swap.c
src/usr.sbin/sysinst/arch/ews4800mips: md.c
src/usr.sbin/timed: CHANGES
src/usr.sbin/timed/timed: CHANGES

Log Message:
s/parition/partition/


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/distrib/alpha/instkernel/ramdisk/install.sh
cvs rdiff -u -r1.156 -r1.157 src/doc/CHANGES.prev
cvs rdiff -u -r1.159 -r1.160 src/etc/defaults/rc.conf
cvs rdiff -u -r1.53 -r1.54 src/sbin/disklabel/main.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/atari/stand/ahdilabel/privahdi.h
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/hp300/dev/rd.c
cvs rdiff -u -r1.58 -r1.59 src/sys/compat/ultrix/ultrix_fs.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/gpib/rd.c
cvs rdiff -u -r1.344 -r1.345 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.198 -r1.199 src/sys/uvm/uvm_swap.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/sysinst/arch/ews4800mips/md.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/timed/CHANGES
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/timed/timed/CHANGES

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

Modified files:

Index: src/distrib/alpha/instkernel/ramdisk/install.sh
diff -u src/distrib/alpha/instkernel/ramdisk/install.sh:1.6 src/distrib/alpha/instkernel/ramdisk/install.sh:1.7
--- src/distrib/alpha/instkernel/ramdisk/install.sh:1.6	Sun Sep 20 22:44:06 2009
+++ src/distrib/alpha/instkernel/ramdisk/install.sh	Tue Sep 29 02:49:55 2020
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: install.sh,v 1.6 2009/09/20 22:44:06 abs Exp $
+# $NetBSD: install.sh,v 1.7 2020/09/29 02:49:55 msaitoh Exp $
 #
 # Copyright (c) 1997 Perry E. Metzger
 # Copyright (c) 1994 Christopher G. Demetriou
@@ -339,7 +339,7 @@ while [ $part_used -lt $partition ]; do
 			[1-9]*)
 total=$(( $part_used + $resp ))
 if [ $total -gt $partition ]; then
-	echo -n	"That would make the parition"
+	echo -n	"That would make the partition"
 	echo	"too large to fit!"
 else
 	part_size=$resp

Index: src/doc/CHANGES.prev
diff -u src/doc/CHANGES.prev:1.156 src/doc/CHANGES.prev:1.157
--- src/doc/CHANGES.prev:1.156	Sat Jun 27 14:03:39 2020
+++ src/doc/CHANGES.prev	Tue Sep 29 02:49:55 2020
@@ -1,4 +1,4 @@
-LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.156 $>
+LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.157 $>
 
 
 Changes from 386bsd 0.1 + patchkit 0.2.2 to NetBSD 0.8:
@@ -1759,7 +1759,7 @@ Changes from NetBSD 1.0 to NetBSD 1.1:
 	scsi: Made the SCSI disk drivers wait for the disc to spin up on open.
 		[mycroft 19950126]
 	add sysctl() variable kern.maxpartitions, so one can easily get
-		the value of MAXPARITIONS w/o compiling it in. (cgd)
+		the value of MAXPARTITIONS w/o compiling it in. (cgd)
 	remove ability to export null and umap file systems, by having
 		their fhtovp and vptofh functions return EOPNOTSUPP. (cgd)
 	config(8): fix config.new to handle differing values of MAXPARTITIONS.
@@ -2684,7 +2684,7 @@ Changes from NetBSD 1.1 to NetBSD 1.2:
 		scripts have been rewritten to deal with this. Also added
 		an option to install from a 'normal' (== hd/mo/...) disk
 		partition to allow people to gather the sets using the
-		native OS and mount that parition from the installer.
+		native OS and mount that partition from the installer.
 		XXX: All of the above changes can (and should) be merged
 		XXX: into the MI-miniroot.
 		[leo 19960519]

Index: src/etc/defaults/rc.conf
diff -u src/etc/defaults/rc.conf:1.159 src/etc/defaults/rc.conf:1.160
--- src/etc/defaults/rc.conf:1.159	Fri Sep 11 09:59:35 2020
+++ src/etc/defaults/rc.conf	Tue Sep 29 02:49:55 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: rc.conf,v 1.159 2020/09/11 09:59:35 kim Exp $
+#	$NetBSD: rc.conf,v 1.160 2020/09/29 02:49:55 msaitoh Exp $
 #
 # /etc/defaults/rc.conf --
 #	default configuration of /etc/rc.conf
@@ -101,7 +101,7 @@ swapoff=YES		# Remove block-type swap pa
 			# This defaults to yes, so that raids shutdown cleanly
 swapoff_umount=auto	# Set to 'manual' to umount the tmpfs partitions listed
 			# in swapoff_umount_fs before removing swap. Set to
-			# 'auto' to umount all tmpfs paritions that contain
+			# 'auto' to umount all tmpfs partitions that contain
 			# no device nodes.
 swapoff_umount_fs=	# space-separated list of tmpfs mount points to umount
 			# before removing swap if swapoff_umount=manual

Index: src/sbin/disklabel/main.c
diff -u src/sbin/disklabel/main.c:1.53 src/sbin/disklabel/main.c:1.54
--- src/sbin/disklabel/main.c:1.53	Sat Aug  3 04:21:37 2019
+++ src/sbin/disklabel/main.c	Tue Sep 29 02:49:55 2

CVS commit: src

2020-09-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 29 02:58:53 UTC 2020

Modified Files:
src/bin/csh: file.c
src/distrib/utils/more: more.help prim.c
src/lib/libc/arch/vax/string: index.S
src/sbin/disklabel: main.c
src/sys/arch/acorn32/stand/lib: riscospart.c
src/sys/arch/arm/arm: disksubr_acorn.c
src/sys/arch/hp300/dev: fhpib.c
src/sys/arch/mips/alchemy/dev: if_aumac.c
src/sys/dev/pci/cxgb: cxgb_t3_hw.c
src/sys/dev/ppbus: ppbus_base.c
src/sys/dev/scsipi: cd.c if_se.c ss.c
src/sys/fs/filecorefs: filecore_utils.c
src/sys/kern: makesyscalls.sh
src/sys/netinet: tcp_input.c
src/usr.sbin/sysinst/arch/acorn32: md.c

Log Message:
s/occurence/occurrence/


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/bin/csh/file.c
cvs rdiff -u -r1.2 -r1.3 src/distrib/utils/more/more.help
cvs rdiff -u -r1.10 -r1.11 src/distrib/utils/more/prim.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/arch/vax/string/index.S
cvs rdiff -u -r1.54 -r1.55 src/sbin/disklabel/main.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/acorn32/stand/lib/riscospart.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/arm/disksubr_acorn.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/hp300/dev/fhpib.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/mips/alchemy/dev/if_aumac.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/cxgb/cxgb_t3_hw.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ppbus/ppbus_base.c
cvs rdiff -u -r1.345 -r1.346 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.111 -r1.112 src/sys/dev/scsipi/if_se.c
cvs rdiff -u -r1.89 -r1.90 src/sys/dev/scsipi/ss.c
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/filecorefs/filecore_utils.c
cvs rdiff -u -r1.181 -r1.182 src/sys/kern/makesyscalls.sh
cvs rdiff -u -r1.423 -r1.424 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/sysinst/arch/acorn32/md.c

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

Modified files:

Index: src/bin/csh/file.c
diff -u src/bin/csh/file.c:1.32 src/bin/csh/file.c:1.33
--- src/bin/csh/file.c:1.32	Sat Jan  5 16:54:00 2019
+++ src/bin/csh/file.c	Tue Sep 29 02:58:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: file.c,v 1.32 2019/01/05 16:54:00 christos Exp $ */
+/* $NetBSD: file.c,v 1.33 2020/09/29 02:58:51 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)file.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: file.c,v 1.32 2019/01/05 16:54:00 christos Exp $");
+__RCSID("$NetBSD: file.c,v 1.33 2020/09/29 02:58:51 msaitoh Exp $");
 #endif
 #endif /* not lint */
 
@@ -670,7 +670,7 @@ tenex(Char *inputline, size_t inputline_
 	--str_end;		/* wipeout trailing cmd Char */
 	*str_end = '\0';
 	/*
-	 * Find LAST occurence of a delimiter in the inputline. The word start
+	 * Find LAST occurrence of a delimiter in the inputline. The word start
 	 * is one Character past it.
 	 */
 	for (word_start = str_end; word_start > inputline; --word_start)

Index: src/distrib/utils/more/more.help
diff -u src/distrib/utils/more/more.help:1.2 src/distrib/utils/more/more.help:1.3
--- src/distrib/utils/more/more.help:1.2	Mon Aug 20 12:00:47 2001
+++ src/distrib/utils/more/more.help	Tue Sep 29 02:58:51 2020
@@ -24,7 +24,7 @@
   /!pattern* Search forward  for N-th line NOT containing the pattern.
   ?pattern * Search backward for N-th line containing the pattern.
   ?!pattern* Search backward for N-th line NOT containing the pattern.
-  n* Repeat previous search (for N-th occurence).
+  n* Repeat previous search (for N-th occurrence).
 
   :a  Display the list of files.
   E [file]Examine a new file.

Index: src/distrib/utils/more/prim.c
diff -u src/distrib/utils/more/prim.c:1.10 src/distrib/utils/more/prim.c:1.11
--- src/distrib/utils/more/prim.c:1.10	Sat Jan 24 13:58:21 2009
+++ src/distrib/utils/more/prim.c	Tue Sep 29 02:58:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: prim.c,v 1.10 2009/01/24 13:58:21 tsutsui Exp $	*/
+/*	$NetBSD: prim.c,v 1.11 2020/09/29 02:58:51 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1988 Mark Nudelman
@@ -35,7 +35,7 @@
 #if 0
 static char sccsid[] = "@(#)prim.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: prim.c,v 1.10 2009/01/24 13:58:21 tsutsui Exp $");
+__RCSID("$NetBSD: prim.c,v 1.11 2020/09/29 02:58:51 msaitoh Exp $");
 #endif
 #endif /* not lint */
 
@@ -604,7 +604,7 @@ get_back_scroll()
 }
 
 /*
- * Search for the n-th occurence of a specified pattern, 
+ * Search for the n-th occurrence of a specified pattern, 
  * either forward or backward.
  */
 int

Index: src/lib/libc/arch/vax/string/index.S
diff -u src/lib/libc/arch/vax/string/index.S:1.5 src/lib/libc/arch/vax/string/index.S:1.6
--- src/lib/libc/arch/vax/string/index.S:1.5	Thu Jan 23 16:34:12 2020
+++ src/lib/libc/arch/vax/string/index.S	Tue Sep 29 02:58:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: index.S,v 1.5 2020/01/23 16:34:12 pgoyette Exp $	*/
+

CVS commit: src

2020-09-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 29 03:02:19 UTC 2020

Modified Files:
src/sys/arch/atari/dev: ncr5380.c
src/sys/arch/mac68k/dev: ncr5380.c
src/sys/dev/scsipi: cd.c
src/sys/fs/nfs/client: nfs_clbio.c
src/usr.bin/config: config.5

Log Message:
s/implicitely/implicitly/


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/atari/dev/ncr5380.c
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/mac68k/dev/ncr5380.c
cvs rdiff -u -r1.346 -r1.347 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/nfs/client/nfs_clbio.c
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/config/config.5

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

Modified files:

Index: src/sys/arch/atari/dev/ncr5380.c
diff -u src/sys/arch/atari/dev/ncr5380.c:1.73 src/sys/arch/atari/dev/ncr5380.c:1.74
--- src/sys/arch/atari/dev/ncr5380.c:1.73	Sat Jun 29 16:41:19 2019
+++ src/sys/arch/atari/dev/ncr5380.c	Tue Sep 29 03:02:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ncr5380.c,v 1.73 2019/06/29 16:41:19 tsutsui Exp $	*/
+/*	$NetBSD: ncr5380.c,v 1.74 2020/09/29 03:02:18 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ncr5380.c,v 1.73 2019/06/29 16:41:19 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ncr5380.c,v 1.74 2020/09/29 03:02:18 msaitoh Exp $");
 
 /*
  * Bit mask of targets you want debugging to be shown
@@ -1218,7 +1218,7 @@ handle_message(SC_REQ *reqp, u_int msg)
 	case MSG_SAVEDATAPOINTER:
 	case MSG_RESTOREPOINTERS:
 		/*
-		 * We save pointers implicitely at disconnect.
+		 * We save pointers implicitly at disconnect.
 		 * So we can ignore these messages.
 		 */
 		ack_message();

Index: src/sys/arch/mac68k/dev/ncr5380.c
diff -u src/sys/arch/mac68k/dev/ncr5380.c:1.67 src/sys/arch/mac68k/dev/ncr5380.c:1.68
--- src/sys/arch/mac68k/dev/ncr5380.c:1.67	Sat Oct 18 08:33:25 2014
+++ src/sys/arch/mac68k/dev/ncr5380.c	Tue Sep 29 03:02:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ncr5380.c,v 1.67 2014/10/18 08:33:25 snj Exp $	*/
+/*	$NetBSD: ncr5380.c,v 1.68 2020/09/29 03:02:18 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ncr5380.c,v 1.67 2014/10/18 08:33:25 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ncr5380.c,v 1.68 2020/09/29 03:02:18 msaitoh Exp $");
 
 /*
  * Bit mask of targets you want debugging to be shown
@@ -1194,7 +1194,7 @@ handle_message(SC_REQ *reqp, u_int msg)
 		case MSG_SAVEDATAPOINTER:
 		case MSG_RESTOREPOINTERS:
 			/*
-			 * We save pointers implicitely at disconnect.
+			 * We save pointers implicitly at disconnect.
 			 * So we can ignore these messages.
 			 */
 			ack_message();

Index: src/sys/dev/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.346 src/sys/dev/scsipi/cd.c:1.347
--- src/sys/dev/scsipi/cd.c:1.346	Tue Sep 29 02:58:52 2020
+++ src/sys/dev/scsipi/cd.c	Tue Sep 29 03:02:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.346 2020/09/29 02:58:52 msaitoh Exp $	*/
+/*	$NetBSD: cd.c,v 1.347 2020/09/29 03:02:19 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.346 2020/09/29 02:58:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.347 2020/09/29 03:02:19 msaitoh Exp $");
 
 #include 
 #include 
@@ -758,7 +758,7 @@ bad:
 /*
  * Issue single I/O command
  *
- * Called from dk_start and implicitely from dk_strategy
+ * Called from dk_start and implicitly from dk_strategy
  */
 static int
 cd_diskstart(device_t dev, struct buf *bp)

Index: src/sys/fs/nfs/client/nfs_clbio.c
diff -u src/sys/fs/nfs/client/nfs_clbio.c:1.5 src/sys/fs/nfs/client/nfs_clbio.c:1.6
--- src/sys/fs/nfs/client/nfs_clbio.c:1.5	Mon Sep  3 16:29:34 2018
+++ src/sys/fs/nfs/client/nfs_clbio.c	Tue Sep 29 03:02:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clbio.c,v 1.5 2018/09/03 16:29:34 riastradh Exp $	*/
+/*	$NetBSD: nfs_clbio.c,v 1.6 2020/09/29 03:02:19 msaitoh Exp $	*/
 /*-
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -35,7 +35,7 @@
 
 #include 
 /* __FBSDID("FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 304026 2016-08-12 22:44:59Z rmacklem "); */
-__RCSID("$NetBSD: nfs_clbio.c,v 1.5 2018/09/03 16:29:34 riastradh Exp $");
+__RCSID("$NetBSD: nfs_clbio.c,v 1.6 2020/09/29 03:02:19 msaitoh Exp $");
 
 #include 
 #include 
@@ -1231,7 +1231,7 @@ again:
 		if (ioflag & IO_UNIT) {
 			VATTR_NULL(&vattr);
 			vattr.va_size = orig_size;
-			/* IO_SYNC is handled implicitely */
+			/* IO_SYNC is handled implicitly */
 			(void)VOP_SETATTR(vp, &vattr, cred);
 			uio->uio_offset -= orig_resid - uio->uio_resid;
 			uio->uio_resid = orig_resid;

Index: src/usr.bin/config/config.5
diff -u src/usr.bin/config/config.5:1.44 src/usr.bin/config/config.5:1.45
--- src/usr.bin/config/config.5:1.44	Fri Jul 31 23:55:57 2

CVS commit: src/sys/dev/scsipi

2020-09-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 29 03:04:03 UTC 2020

Modified Files:
src/sys/dev/scsipi: cd.c

Log Message:
s/settng/setting/


To generate a diff of this commit:
cvs rdiff -u -r1.347 -r1.348 src/sys/dev/scsipi/cd.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/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.347 src/sys/dev/scsipi/cd.c:1.348
--- src/sys/dev/scsipi/cd.c:1.347	Tue Sep 29 03:02:19 2020
+++ src/sys/dev/scsipi/cd.c	Tue Sep 29 03:04:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.347 2020/09/29 03:02:19 msaitoh Exp $	*/
+/*	$NetBSD: cd.c,v 1.348 2020/09/29 03:04:03 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.347 2020/09/29 03:02:19 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.348 2020/09/29 03:04:03 msaitoh Exp $");
 
 #include 
 #include 
@@ -1030,7 +1030,7 @@ cdminphys(struct buf *bp)
 	 *
 	 * XXX Note that the SCSI-I spec says that 256-block transfers
 	 * are allowed in a 6-byte read/write, and are specified
-	 * by settng the "length" to 0.  However, we're conservative
+	 * by setting the "length" to 0.  However, we're conservative
 	 * here, allowing only 255-block transfers in case an
 	 * ancient device gets confused by length == 0.  A length of 0
 	 * in a 10-byte read/write actually means 0 blocks.



CVS commit: src/sbin/ifconfig

2020-09-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 29 08:52:11 UTC 2020

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Add [-]eee and [-]vlan-hwfilter.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sbin/ifconfig/ifconfig.8

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.120 src/sbin/ifconfig/ifconfig.8:1.121
--- src/sbin/ifconfig/ifconfig.8:1.120	Wed Sep 23 02:09:18 2020
+++ src/sbin/ifconfig/ifconfig.8	Tue Sep 29 08:52:11 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.120 2020/09/23 02:09:18 roy Exp $
+.\"	$NetBSD: ifconfig.8,v 1.121 2020/09/29 08:52:11 msaitoh Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd September 23, 2020
+.Dd September 29, 2020
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -614,6 +614,10 @@ Remove
 from the
 .Xr agr 4
 interface.
+.It Cm eee
+Enable IEEE 802.3az Energy Efficiency Ethernet function.
+.It Cm -eee
+Disable IEEE 802.3az Energy Efficiency Ethernet function.
 .It Cm vltime Ar n
 .Pq inet6 only
 Set valid lifetime for the address.
@@ -699,6 +703,10 @@ support it.
 .It Cm -tso6
 Disable hardware-assisted TCP/IPv6 segmentation on interfaces that
 support it.
+.It Cm vlan-hwfilter
+Enable hardware-assisted VLAN frame filter on interfaces that support it.
+.It Cm -vlan-hwfilter
+Disable hardware-assisted VLAN frame filter on interfaces that support it.
 .It Cm vlan-hwtagging
 Enable hardware-assisted VLAN tag insertion/removal on interfaces that
 support it.



CVS commit: src/sys/dev/pci

2020-10-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 16 05:53:40 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Fixes a problem that the attach function reported
"wm_gmii_setup_phytype: Unknown PHY model. OUI=00, model=" and
"PHY type is still unknown." Don't call wm_gmii_setup_phytype() three times if
the interface uses SGMII with internal MDIO.

 Tested with I354(Rangeley(SGMII(MDIO))) and I350(SERDES(SFP), SGMII(SFP)).


To generate a diff of this commit:
cvs rdiff -u -r1.690 -r1.691 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.690 src/sys/dev/pci/if_wm.c:1.691
--- src/sys/dev/pci/if_wm.c:1.690	Thu Sep 24 08:00:59 2020
+++ src/sys/dev/pci/if_wm.c	Fri Oct 16 05:53:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.690 2020/09/24 08:00:59 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.691 2020/10/16 05:53:39 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.690 2020/09/24 08:00:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.691 2020/10/16 05:53:39 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2862,7 +2862,8 @@ alloc_retry:
 			reg &= ~CTRL_EXT_I2C_ENA;
 		CSR_WRITE(sc, WMREG_CTRL_EXT, reg);
 		if ((sc->sc_flags & WM_F_SGMII) != 0) {
-			wm_gmii_setup_phytype(sc, 0, 0);
+			if (!wm_sgmii_uses_mdio(sc))
+wm_gmii_setup_phytype(sc, 0, 0);
 			wm_reset_mdicnfg_82580(sc);
 		}
 	} else if (sc->sc_type < WM_T_82543 ||



CVS commit: src/sys/dev/mii

2020-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Oct 20 08:53:34 UTC 2020

Modified Files:
src/sys/dev/mii: makphy.c

Log Message:
Add Intel I347-AT4.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/mii/makphy.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/mii/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.66 src/sys/dev/mii/makphy.c:1.67
--- src/sys/dev/mii/makphy.c:1.66	Mon Aug  3 07:25:59 2020
+++ src/sys/dev/mii/makphy.c	Tue Oct 20 08:53:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: makphy.c,v 1.66 2020/08/03 07:25:59 msaitoh Exp $	*/
+/*	$NetBSD: makphy.c,v 1.67 2020/10/20 08:53:34 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.66 2020/08/03 07:25:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.67 2020/10/20 08:53:34 msaitoh Exp $");
 
 #include 
 #include 
@@ -117,6 +117,7 @@ static const struct mii_phydesc makphys[
 	MII_PHY_DESC(xxMARVELL, E3016),
 	MII_PHY_DESC(xxMARVELL, E3082),
 	MII_PHY_DESC(xxMARVELL, PHYG65G),
+	MII_PHY_DESC(xxMARVELL, I347),
 	MII_PHY_END,
 };
 



CVS commit: src/sys/dev/pci

2020-10-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 28 07:08:08 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Add missing drain for pcq in wm_stop_locked(). OK'd by knakahara.

This change fixes two problems:
 1. If the pcq is full and watchdog timer is fired, the full state of the
pcq is kept and wm_transmit() returns with ENOBUFS.
 2. ifconfig down doesn't free mbufs in the pcq.


To generate a diff of this commit:
cvs rdiff -u -r1.691 -r1.692 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.691 src/sys/dev/pci/if_wm.c:1.692
--- src/sys/dev/pci/if_wm.c:1.691	Fri Oct 16 05:53:39 2020
+++ src/sys/dev/pci/if_wm.c	Wed Oct 28 07:08:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.691 2020/10/16 05:53:39 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.692 2020/10/28 07:08:08 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.691 2020/10/16 05:53:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.692 2020/10/28 07:08:08 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -6523,6 +6523,8 @@ wm_stop_locked(struct ifnet *ifp, bool d
 	for (qidx = 0; qidx < sc->sc_nqueues; qidx++) {
 		struct wm_queue *wmq = &sc->sc_queue[qidx];
 		struct wm_txqueue *txq = &wmq->wmq_txq;
+		struct mbuf *m;
+
 		mutex_enter(txq->txq_lock);
 		txq->txq_sending = false; /* Ensure watchdog disabled */
 		for (i = 0; i < WM_TXQUEUELEN(txq); i++) {
@@ -6533,6 +6535,9 @@ wm_stop_locked(struct ifnet *ifp, bool d
 txs->txs_mbuf = NULL;
 			}
 		}
+		/* Drain txq_interq */
+		while ((m = pcq_get(txq->txq_interq)) != NULL)
+			m_freem(m);
 		mutex_exit(txq->txq_lock);
 	}
 



CVS commit: src/sys/dev/pci

2020-10-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 30 06:23:39 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Add new sysctl hw.wmN.debug_flags. This sysctl can be used if WM_DEBUG is set.
OK'd by knakahara.

% sysctl -d hw.wm0.debug_flags
hw.wm0.debug_flags: Debug flags:
0x01 LINK
0x02 TX
0x04 RX
0x08 GMII
0x10 MANAGE
0x20 NVM
0x40 INIT
0x80 LOCK


To generate a diff of this commit:
cvs rdiff -u -r1.692 -r1.693 src/sys/dev/pci/if_wm.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.692 src/sys/dev/pci/if_wm.c:1.693
--- src/sys/dev/pci/if_wm.c:1.692	Wed Oct 28 07:08:08 2020
+++ src/sys/dev/pci/if_wm.c	Fri Oct 30 06:23:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.692 2020/10/28 07:08:08 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.693 2020/10/30 06:23:39 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.692 2020/10/28 07:08:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.693 2020/10/30 06:23:39 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -157,11 +157,20 @@ __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.
 #define	WM_DEBUG_NVM		__BIT(5)
 #define	WM_DEBUG_INIT		__BIT(6)
 #define	WM_DEBUG_LOCK		__BIT(7)
-int	wm_debug = WM_DEBUG_TX | WM_DEBUG_RX | WM_DEBUG_LINK | WM_DEBUG_GMII
-| WM_DEBUG_MANAGE | WM_DEBUG_NVM | WM_DEBUG_INIT | WM_DEBUG_LOCK;
-#define	DPRINTF(x, y)	do { if (wm_debug & (x)) printf y; } while (0)
+
+#if 0
+#define WM_DEBUG_DEFAULT	WM_DEBUG_TX | WM_DEBUG_RX | WM_DEBUG_LINK | \
+	WM_DEBUG_GMII | WM_DEBUG_MANAGE | WM_DEBUG_NVM | WM_DEBUG_INIT |\
+	WM_DEBUG_LOCK
+#endif
+
+#define	DPRINTF(sc, x, y)			  \
+	do {	  \
+		if ((sc)->sc_debug & (x))	  \
+			printf y;		  \
+	} while (0)
 #else
-#define	DPRINTF(x, y)	__nothing
+#define	DPRINTF(sc, x, y)	__nothing
 #endif /* WM_DEBUG */
 
 #ifdef NET_MPSAFE
@@ -624,6 +633,9 @@ struct wm_softc {
 
 	struct wm_phyop phy;
 	struct wm_nvmop nvm;
+#ifdef WM_DEBUG
+	uint32_t sc_debug;
+#endif
 };
 
 #define WM_CORE_LOCK(_sc)		\
@@ -1033,6 +1045,10 @@ static int	wm_platform_pm_pch_lpt(struct
 static int	wm_pll_workaround_i210(struct wm_softc *);
 static void	wm_legacy_irq_quirk_spt(struct wm_softc *);
 
+#ifdef WM_DEBUG
+static int	wm_sysctl_debug(SYSCTLFN_PROTO);
+#endif
+
 CFATTACH_DECL3_NEW(wm, sizeof(struct wm_softc),
 wm_match, wm_attach, wm_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
 
@@ -1844,6 +1860,9 @@ wm_attach(device_t parent, device_t self
 	uint32_t link_mode;
 	uint32_t reg;
 
+#if defined(WM_DEBUG) && defined(WM_DEBUG_DEFAULT)
+	sc->sc_debug = WM_DEBUG_DEFAULT;
+#endif
 	sc->sc_dev = self;
 	callout_init(&sc->sc_tick_ch, WM_CALLOUT_FLAGS);
 	callout_setfunc(&sc->sc_tick_ch, wm_tick, sc);
@@ -3422,7 +3441,7 @@ wm_ifflags_cb(struct ethercom *ec)
 	bool needreset = false;
 	int rc = 0;
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
 	WM_CORE_LOCK(sc);
@@ -3478,7 +3497,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 	struct sockaddr_dl *sdl;
 	int s, error;
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
 #ifndef WM_MPSAFE
@@ -3807,7 +3826,7 @@ wm_set_filter(struct wm_softc *sc)
 	uint32_t hash, reg, bit;
 	int i, size, ralmax, rv;
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
 	if (sc->sc_type >= WM_T_82544)
@@ -3951,7 +3970,7 @@ static void
 wm_set_vlan(struct wm_softc *sc)
 {
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
 	/* Deal with VLAN enables. */
@@ -4037,7 +4056,7 @@ wm_lan_init_done(struct wm_softc *sc)
 	uint32_t reg = 0;
 	int i;
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
 	/* Wait for eeprom to reload */
@@ -4076,7 +4095,7 @@ wm_get_cfg_done(struct wm_softc *sc)
 	uint32_t reg;
 	int i;
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
 	/* Wait for eeprom to reload */
@@ -4123,7 +4142,7 @@ wm_get_cfg_done(struct wm_softc *sc)
 			delay(1000);
 		}
 		if (i >= WM_PHY_CFG_TIMEOUT)
-			DPRINTF(WM_DEBUG_GMII, ("%s: %s failed\n",
+			DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s failed\n",
 device_xname(sc->sc_dev), __func__));
 		break;
 	case WM_T_ICH8:
@@ -4220,7 +4239,7 @@ wm_write_smbus_addr(struct wm_softc *sc)
 	uint16_t phy_data;
 	int rv;
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n

CVS commit: src/sys/dev/pci

2020-10-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 30 06:29:47 UTC 2020

Modified Files:
src/sys/dev/pci: if_wm.c if_wmvar.h

Log Message:
Add WMPHY_I350. Not used yet.


To generate a diff of this commit:
cvs rdiff -u -r1.693 -r1.694 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pci/if_wmvar.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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.693 src/sys/dev/pci/if_wm.c:1.694
--- src/sys/dev/pci/if_wm.c:1.693	Fri Oct 30 06:23:39 2020
+++ src/sys/dev/pci/if_wm.c	Fri Oct 30 06:29:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.693 2020/10/30 06:23:39 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.694 2020/10/30 06:29:47 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.693 2020/10/30 06:23:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.694 2020/10/30 06:29:47 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -10267,9 +10267,12 @@ wm_gmii_setup_phytype(struct wm_softc *s
 new_phytype = WMPHY_I217;
 break;
 			case MII_MODEL_INTEL_I82580:
-			case MII_MODEL_INTEL_I350:
 new_phytype = WMPHY_82580;
 break;
+			case MII_MODEL_INTEL_I350:
+new_phytype = WMPHY_I350;
+break;
+break;
 			default:
 break;
 			}

Index: src/sys/dev/pci/if_wmvar.h
diff -u src/sys/dev/pci/if_wmvar.h:1.46 src/sys/dev/pci/if_wmvar.h:1.47
--- src/sys/dev/pci/if_wmvar.h:1.46	Tue Sep 15 08:39:04 2020
+++ src/sys/dev/pci/if_wmvar.h	Fri Oct 30 06:29:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmvar.h,v 1.46 2020/09/15 08:39:04 msaitoh Exp $	*/
+/*	$NetBSD: if_wmvar.h,v 1.47 2020/10/30 06:29:47 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -198,9 +198,10 @@ typedef enum {
 	WMPHY_BM,	/* 82567: ICH8 ICH9 ICH10 */
 	WMPHY_82578,	/* 82578: PCH */
 	WMPHY_82577,	/* 82577: PCH (NOTE: functionality newer than 82578) */
-	WMPHY_82579,	/* 82579 : PCH2 */
+	WMPHY_82579,	/* 82579: PCH2 */
 	WMPHY_I217,	/* I217:  _LPT, I218: _LPT, I219: _SPT _CNP */
-	WMPHY_82580,	/* 82580: 82580 or I350 */
+	WMPHY_82580,	/* 82580 */
+	WMPHY_I350,	/* I350 */
 	WMPHY_VF,
 	WMPHY_I210	/* I210: I210 I211 */
 } wm_phy_type;



CVS commit: src/sys/dev/ic

2020-07-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 15 01:42:27 UTC 2020

Modified Files:
src/sys/dev/ic: gem.c

Log Message:
G.C. comment.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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.130 src/sys/dev/ic/gem.c:1.131
--- src/sys/dev/ic/gem.c:1.130	Sun Mar 15 22:19:00 2020
+++ src/sys/dev/ic/gem.c	Wed Jul 15 01:42:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.130 2020/03/15 22:19:00 thorpej Exp $ */
+/*	$NetBSD: gem.c,v 1.131 2020/07/15 01:42:27 msaitoh Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.130 2020/03/15 22:19:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.131 2020/07/15 01:42:27 msaitoh Exp $");
 
 #include "opt_inet.h"
 
@@ -880,7 +880,7 @@ gem_reset_tx(struct gem_softc *sc)
 	bus_space_barrier(t, h, GEM_TX_CONFIG, 4, BUS_SPACE_BARRIER_WRITE);
 	/* Wait till it finishes */
 	if (!gem_bitwait(sc, h, GEM_TX_CONFIG, 1, 0))
-		aprint_error_dev(sc->sc_dev, "cannot disable tx dma\n"); /* OpenBSD 1.34 */
+		aprint_error_dev(sc->sc_dev, "cannot disable tx dma\n");
 	/* Wait 5ms extra. */
 	delay(5000);
 
@@ -889,7 +889,7 @@ gem_reset_tx(struct gem_softc *sc)
 	bus_space_barrier(t, h, GEM_RESET, 4, BUS_SPACE_BARRIER_WRITE);
 	/* Wait till it finishes */
 	if (!gem_bitwait(sc, h2, GEM_RESET, GEM_RESET_TX, 0)) {
-		aprint_error_dev(sc->sc_dev, "cannot reset transmitter\n"); /* OpenBSD 1.34 */
+		aprint_error_dev(sc->sc_dev, "cannot reset transmitter\n");
 		return (1);
 	}
 	return (0);



  1   2   3   4   5   6   7   8   9   10   >