CVS commit: src/sys/dev/pci

2018-01-21 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Jan 21 18:37:34 UTC 2018

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.1297 -r1.1298 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1296 -r1.1297 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.1297 src/sys/dev/pci/pcidevs.h:1.1298
--- src/sys/dev/pci/pcidevs.h:1.1297	Tue Jan  9 09:19:27 2018
+++ src/sys/dev/pci/pcidevs.h	Sun Jan 21 18:37:33 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1297 2018/01/09 09:19:27 msaitoh Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1298 2018/01/21 18:37:33 sevan Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1304 2018/01/09 09:19:05 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1305 2018/01/21 18:33:56 sevan Exp
  */
 
 /*
@@ -5512,6 +5512,7 @@
 #define	PCI_PRODUCT_NVIDIA_GEFORCE4_MX440	0x0171		/* GeForce4 MX 440 */
 #define	PCI_PRODUCT_NVIDIA_GEFORCE4_MX420	0x0172		/* GeForce4 MX 420 */
 #define	PCI_PRODUCT_NVIDIA_GF4_MX440_SE	0x0173		/* GeForce4 MX 440 SE */
+#define	PCI_PRODUCT_NVIDIA_GF4_MX440_GO	0x0174		/* GeForce4 MX 440 Go */
 #define	PCI_PRODUCT_NVIDIA_QUADRO4_500XGL	0x0178		/* Quadro4 500XGL */
 #define	PCI_PRODUCT_NVIDIA_QUADRO4_200NVS	0x017a		/* Quadro4 200/400NVS */
 #define	PCI_PRODUCT_NVIDIA_GF4_MX440_8X	0x0181		/* GeForce4 MX 440 (AGP8X) */

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1296 src/sys/dev/pci/pcidevs_data.h:1.1297
--- src/sys/dev/pci/pcidevs_data.h:1.1296	Tue Jan  9 09:19:27 2018
+++ src/sys/dev/pci/pcidevs_data.h	Sun Jan 21 18:37:33 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1296 2018/01/09 09:19:27 msaitoh Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1297 2018/01/21 18:37:33 sevan Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1304 2018/01/09 09:19:05 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1305 2018/01/21 18:33:56 sevan Exp
  */
 
 /*
@@ -9521,6 +9521,8 @@ static const uint16_t pci_products[] = {
 	26884, 26817, 26901, 0,
 	PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_SE, 
 	26884, 26817, 26897, 26905, 0,
+	PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_GF4_MX440_GO, 
+	26884, 26817, 26897, 26828, 0,
 	PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_500XGL, 
 	26774, 26908, 0,
 	PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_QUADRO4_200NVS, 
@@ -15861,9 +15863,9 @@ static const char pci_words[] = { "." 
 	"4300\0" /* 1 refs @ 26799 */
 	"256\0" /* 1 refs @ 26804 */
 	"GeForce2\0" /* 7 refs @ 26808 */
-	"MX\0" /* 10 refs @ 26817 */
+	"MX\0" /* 11 refs @ 26817 */
 	"100/200\0" /* 1 refs @ 26820 */
-	"Go\0" /* 5 refs @ 26828 */
+	"Go\0" /* 6 refs @ 26828 */
 	"Quadro2\0" /* 2 refs @ 26831 */
 	"MXR/EX\0" /* 1 refs @ 26839 */
 	"6600\0" /* 5 refs @ 26846 */
@@ -15873,9 +15875,9 @@ static const char pci_words[] = { "." 
 	"(DDR)\0" /* 1 refs @ 26864 */
 	"6200TC\0" /* 1 refs @ 26870 */
 	"6200LE\0" /* 1 refs @ 26877 */
-	"GeForce4\0" /* 15 refs @ 26884 */
+	"GeForce4\0" /* 16 refs @ 26884 */
 	"460\0" /* 1 refs @ 26893 */
-	"440\0" /* 4 refs @ 26897 */
+	"440\0" /* 5 refs @ 26897 */
 	"420\0" /* 3 refs @ 26901 */
 	"SE\0" /* 4 refs @ 26905 */
 	"500XGL\0" /* 1 refs @ 26908 */



CVS commit: src/sys/dev/pci

2018-01-21 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Jan 21 18:37:34 UTC 2018

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.1297 -r1.1298 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1296 -r1.1297 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.



CVS commit: src/sys/dev/pci

2018-01-21 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Jan 21 18:33:56 UTC 2018

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

Log Message:
Add the GeForce4 MX440 Go, as found on the 17" flat panel G4 iMac (PowerMac4,5).

Thanks to Jasper Wallace  for the loan of the 
hardware.


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

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



CVS commit: src/sys/dev/pci

2018-01-21 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Jan 21 18:33:56 UTC 2018

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

Log Message:
Add the GeForce4 MX440 Go, as found on the 17" flat panel G4 iMac (PowerMac4,5).

Thanks to Jasper Wallace  for the loan of the 
hardware.


To generate a diff of this commit:
cvs rdiff -u -r1.1304 -r1.1305 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.1304 src/sys/dev/pci/pcidevs:1.1305
--- src/sys/dev/pci/pcidevs:1.1304	Tue Jan  9 09:19:05 2018
+++ src/sys/dev/pci/pcidevs	Sun Jan 21 18:33:56 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1304 2018/01/09 09:19:05 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1305 2018/01/21 18:33:56 sevan Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -5505,6 +5505,7 @@ product NVIDIA	GEFORCE4_MX460	0x0170	GeF
 product NVIDIA	GEFORCE4_MX440	0x0171	GeForce4 MX 440
 product NVIDIA	GEFORCE4_MX420	0x0172	GeForce4 MX 420
 product NVIDIA	GF4_MX440_SE	0x0173	GeForce4 MX 440 SE
+product NVIDIA	GF4_MX440_GO	0x0174	GeForce4 MX 440 Go
 product NVIDIA	QUADRO4_500XGL	0x0178	Quadro4 500XGL
 product NVIDIA	QUADRO4_200NVS	0x017a	Quadro4 200/400NVS
 product NVIDIA	GF4_MX440_8X	0x0181	GeForce4 MX 440 (AGP8X)



CVS commit: src/sys/dev/pci

2018-01-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 21 18:12:37 UTC 2018

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

Log Message:
CID-1427736: Appease coverity using KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/pci/if_iwm.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_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.77 src/sys/dev/pci/if_iwm.c:1.78
--- src/sys/dev/pci/if_iwm.c:1.77	Wed Jan 10 13:39:50 2018
+++ src/sys/dev/pci/if_iwm.c	Sun Jan 21 13:12:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.77 2018/01/10 18:39:50 mlelstv Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.78 2018/01/21 18:12:37 christos Exp $	*/
 /*	OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp	*/
 #define IEEE80211_NO_HT
 /*
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.77 2018/01/10 18:39:50 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.78 2018/01/21 18:12:37 christos Exp $");
 
 #include 
 #include 
@@ -5248,6 +5248,7 @@ iwm_fill_probe_req(struct iwm_softc *sc,
 
 	memset(preq, 0, sizeof(*preq));
 
+	KASSERT(ic->ic_des_esslen < sizeof(ic->ic_des_essid));
 	if (remain < sizeof(*wh) + 2 + ic->ic_des_esslen)
 		return ENOBUFS;
 



CVS commit: src/sys/dev/pci

2018-01-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 21 18:12:37 UTC 2018

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

Log Message:
CID-1427736: Appease coverity using KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/pci/if_iwm.c

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



CVS commit: src/sys/dev/pci

2018-01-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 21 04:07:49 UTC 2018

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

Log Message:
CID-1427779: Fix uninitialized variables


To generate a diff of this commit:
cvs rdiff -u -r1.557 -r1.558 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.



CVS commit: src/sys/dev/pci

2018-01-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 21 04:07:49 UTC 2018

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

Log Message:
CID-1427779: Fix uninitialized variables


To generate a diff of this commit:
cvs rdiff -u -r1.557 -r1.558 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.557 src/sys/dev/pci/if_wm.c:1.558
--- src/sys/dev/pci/if_wm.c:1.557	Thu Jan 18 04:36:26 2018
+++ src/sys/dev/pci/if_wm.c	Sat Jan 20 23:07:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.557 2018/01/18 09:36:26 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.558 2018/01/21 04:07:49 christos Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.557 2018/01/18 09:36:26 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.558 2018/01/21 04:07:49 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -12589,7 +12589,7 @@ wm_nvm_version(struct wm_softc *sc)
 	case WM_T_82575:
 	case WM_T_82576:
 	case WM_T_82580:
-		if ((uid1 & NVM_MAJOR_MASK) != NVM_UID_VALID)
+		if (have_uid && (uid1 & NVM_MAJOR_MASK) != NVM_UID_VALID)
 			check_version = true;
 		break;
 	case WM_T_I211:



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

2018-01-19 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jan 19 23:37:36 UTC 2018

Modified Files:
src/sys/dev/pci/voyager: voyagerfb.c

Log Message:
enable font loading


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/voyager/voyagerfb.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/voyager/voyagerfb.c
diff -u src/sys/dev/pci/voyager/voyagerfb.c:1.28 src/sys/dev/pci/voyager/voyagerfb.c:1.29
--- src/sys/dev/pci/voyager/voyagerfb.c:1.28	Wed Jan 13 15:56:05 2016
+++ src/sys/dev/pci/voyager/voyagerfb.c	Fri Jan 19 23:37:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: voyagerfb.c,v 1.28 2016/01/13 15:56:05 macallan Exp $	*/
+/*	$NetBSD: voyagerfb.c,v 1.29 2018/01/19 23:37:36 macallan Exp $	*/
 
 /*
  * Copyright (c) 2009, 2011 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.28 2016/01/13 15:56:05 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.29 2018/01/19 23:37:36 macallan Exp $");
 
 #include 
 #include 
@@ -287,7 +287,8 @@ voyagerfb_attach(device_t parent, device
 		0, 0,
 		NULL,
 		8, 16,
-		WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
+		WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
+		WSSCREEN_RESIZE,
 		NULL
 	};
 	sc->sc_screens[0] = >sc_defaultscreen_descr;
@@ -298,6 +299,8 @@ voyagerfb_attach(device_t parent, device
 	vcons_init(>vd, sc, >sc_defaultscreen_descr,
 	_accessops);
 	sc->vd.init_screen = voyagerfb_init_screen;
+	sc->vd.show_screen_cookie = >sc_gc;
+	sc->vd.show_screen_cb = glyphcache_adapt;
 
 	/* backlight control */
 	voyagerfb_setup_backlight(sc);
@@ -586,7 +589,7 @@ voyagerfb_init_screen(void *cookie, stru
 	if (sc->sc_depth == 8) {
 		ri->ri_flg |= RI_8BIT_IS_RGB;
 #ifdef VOYAGERFB_ANTIALIAS
-		ri->ri_flg |= RI_ENABLE_ALPHA;
+		ri->ri_flg |= RI_ENABLE_ALPHA | RI_PREFER_ALPHA;
 #endif
 	}
 	if (sc->sc_depth == 32) {
@@ -602,8 +605,11 @@ voyagerfb_init_screen(void *cookie, stru
 		ri->ri_bpos = 0;
 	}
 
+	scr->scr_flags |= VCONS_LOADFONT;
+
 	rasops_init(ri, 0, 0);
-	ri->ri_caps = WSSCREEN_WSCOLORS;
+	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
+		  WSSCREEN_RESIZE;
 
 	rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
 		sc->sc_width / ri->ri_font->fontwidth);



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

2018-01-19 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jan 19 23:37:36 UTC 2018

Modified Files:
src/sys/dev/pci/voyager: voyagerfb.c

Log Message:
enable font loading


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/voyager/voyagerfb.c

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



CVS commit: src/sys/dev/pci

2018-01-18 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Jan 18 09:36:26 UTC 2018

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

Log Message:
wm_txeof() can limit the loop count the same as wm_rxeof() now.


To generate a diff of this commit:
cvs rdiff -u -r1.556 -r1.557 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.



CVS commit: src/sys/dev/pci

2018-01-18 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Jan 18 09:36:26 UTC 2018

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

Log Message:
wm_txeof() can limit the loop count the same as wm_rxeof() now.


To generate a diff of this commit:
cvs rdiff -u -r1.556 -r1.557 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.556 src/sys/dev/pci/if_wm.c:1.557
--- src/sys/dev/pci/if_wm.c:1.556	Wed Jan 17 02:16:07 2018
+++ src/sys/dev/pci/if_wm.c	Thu Jan 18 09:36:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.556 2018/01/17 02:16:07 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.557 2018/01/18 09:36:26 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.556 2018/01/17 02:16:07 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.557 2018/01/18 09:36:26 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -213,6 +213,13 @@ int wm_disable_msix = WM_DISABLE_MSIX;
 
 #define	WM_TXINTERQSIZE		256
 
+#ifndef WM_TX_PROCESS_LIMIT_DEFAULT
+#define	WM_TX_PROCESS_LIMIT_DEFAULT		100U
+#endif
+#ifndef WM_TX_INTR_PROCESS_LIMIT_DEFAULT
+#define	WM_TX_INTR_PROCESS_LIMIT_DEFAULT	0U
+#endif
+
 /*
  * Receive descriptor list size.  We have one Rx buffer for normal
  * sized packets.  Jumbo packets consume 5 Rx buffers for a full-sized
@@ -519,6 +526,8 @@ struct wm_softc {
 
 	int sc_nqueues;
 	struct wm_queue *sc_queue;
+	u_int sc_tx_process_limit;	/* Tx processing repeat limit in softint */
+	u_int sc_tx_intr_process_limit;	/* Tx processing repeat limit in H/W intr */
 	u_int sc_rx_process_limit;	/* Rx processing repeat limit in softint */
 	u_int sc_rx_intr_process_limit;	/* Rx processing repeat limit in H/W intr */
 
@@ -758,7 +767,7 @@ static void	wm_nq_send_common_locked(str
 static void	wm_deferred_start_locked(struct wm_txqueue *);
 static void	wm_handle_queue(void *);
 /* Interrupt */
-static int	wm_txeof(struct wm_softc *, struct wm_txqueue *);
+static int	wm_txeof(struct wm_txqueue *, u_int);
 static void	wm_rxeof(struct wm_rxqueue *, u_int);
 static void	wm_linkintr_gmii(struct wm_softc *, uint32_t);
 static void	wm_linkintr_tbi(struct wm_softc *, uint32_t);
@@ -2764,6 +2773,8 @@ alloc_retry:
 		ifp->if_capabilities |= IFCAP_TSOv6;
 	}
 
+	sc->sc_tx_process_limit = WM_TX_PROCESS_LIMIT_DEFAULT;
+	sc->sc_tx_intr_process_limit = WM_TX_INTR_PROCESS_LIMIT_DEFAULT;
 	sc->sc_rx_process_limit = WM_RX_PROCESS_LIMIT_DEFAULT;
 	sc->sc_rx_intr_process_limit = WM_RX_INTR_PROCESS_LIMIT_DEFAULT;
 
@@ -2972,7 +2983,9 @@ wm_watchdog_txq_locked(struct ifnet *ifp
 	 * Since we're using delayed interrupts, sweep up
 	 * before we report an error.
 	 */
-	wm_txeof(sc, txq);
+	mutex_enter(txq->txq_lock);
+	wm_txeof(txq, UINT_MAX);
+	mutex_exit(txq->txq_lock);
 
 	if (txq->txq_free != WM_NTXDESC(txq)) {
 #ifdef WM_DEBUG
@@ -7140,7 +7153,7 @@ wm_send_common_locked(struct ifnet *ifp,
 
 		/* Get a work queue entry. */
 		if (txq->txq_sfree < WM_TXQUEUE_GC(txq)) {
-			wm_txeof(sc, txq);
+			wm_txeof(txq, UINT_MAX);
 			if (txq->txq_sfree == 0) {
 DPRINTF(WM_DEBUG_TX,
 ("%s: TX: no free job descriptors\n",
@@ -7739,7 +7752,7 @@ wm_nq_send_common_locked(struct ifnet *i
 
 		/* Get a work queue entry. */
 		if (txq->txq_sfree < WM_TXQUEUE_GC(txq)) {
-			wm_txeof(sc, txq);
+			wm_txeof(txq, UINT_MAX);
 			if (txq->txq_sfree == 0) {
 DPRINTF(WM_DEBUG_TX,
 ("%s: TX: no free job descriptors\n",
@@ -8028,8 +8041,9 @@ wm_deferred_start_locked(struct wm_txque
  *	Helper; handle transmit interrupts.
  */
 static int
-wm_txeof(struct wm_softc *sc, struct wm_txqueue *txq)
+wm_txeof(struct wm_txqueue *txq, u_int limit)
 {
+	struct wm_softc *sc = txq->txq_sc;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct wm_txsoft *txs;
 	bool processed = false;
@@ -8054,6 +8068,9 @@ wm_txeof(struct wm_softc *sc, struct wm_
 	 */
 	for (i = txq->txq_sdirty; txq->txq_sfree != WM_TXQUEUELEN(txq);
 	 i = WM_NEXTTXS(txq, i), txq->txq_sfree++) {
+		if (limit-- == 0)
+			break;
+
 		txs = >txq_soft[i];
 
 		DPRINTF(WM_DEBUG_TX, ("%s: TX: checking job %d\n",
@@ -8890,7 +8907,7 @@ wm_intr_legacy(void *arg)
 			WM_Q_EVCNT_INCR(txq, txdw);
 		}
 #endif
-		wm_txeof(sc, txq);
+		wm_txeof(txq, UINT_MAX);
 
 		mutex_exit(txq->txq_lock);
 		WM_CORE_LOCK(sc);
@@ -8960,7 +8977,8 @@ wm_txrxintr_msix(void *arg)
 	struct wm_txqueue *txq = >wmq_txq;
 	struct wm_rxqueue *rxq = >wmq_rxq;
 	struct wm_softc *sc = txq->txq_sc;
-	u_int limit = sc->sc_rx_intr_process_limit;
+	u_int txlimit = sc->sc_tx_intr_process_limit;
+	u_int rxlimit = sc->sc_rx_intr_process_limit;
 
 	KASSERT(wmq->wmq_intr_idx == wmq->wmq_id);
 
@@ -8977,7 +8995,7 @@ wm_txrxintr_msix(void *arg)
 	}
 
 	WM_Q_EVCNT_INCR(txq, txdw);
-	wm_txeof(sc, txq);
+	wm_txeof(txq, txlimit);
 	/* 

CVS commit: src/sys/dev/pci

2018-01-16 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Jan 17 02:16:07 UTC 2018

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

Log Message:
Fix duplicated "rxintr" evcnt counting. Pointed out by ozaki-r@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.555 -r1.556 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.



CVS commit: src/sys/dev/pci

2018-01-16 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Jan 17 02:16:07 UTC 2018

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

Log Message:
Fix duplicated "rxintr" evcnt counting. Pointed out by ozaki-r@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.555 -r1.556 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.555 src/sys/dev/pci/if_wm.c:1.556
--- src/sys/dev/pci/if_wm.c:1.555	Tue Jan 16 07:23:13 2018
+++ src/sys/dev/pci/if_wm.c	Wed Jan 17 02:16:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.555 2018/01/16 07:23:13 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.556 2018/01/17 02:16:07 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.555 2018/01/16 07:23:13 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.556 2018/01/17 02:16:07 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -417,6 +417,7 @@ struct wm_rxqueue {
 	uint32_t rxq_bytes;		/* for AIM */
 #ifdef WM_EVENT_COUNTERS
 	WM_Q_EVCNT_DEFINE(rxq, rxintr);		/* Rx interrupts */
+	WM_Q_EVCNT_DEFINE(rxq, rxdefer);	/* Rx deferred processing */
 
 	WM_Q_EVCNT_DEFINE(rxq, rxipsum);	/* IP checksums checked in-bound */
 	WM_Q_EVCNT_DEFINE(rxq, rxtusum);	/* TCP/UDP cksums checked in-bound */
@@ -6456,6 +6457,7 @@ wm_alloc_txrx_queues(struct wm_softc *sc
 		xname = device_xname(sc->sc_dev);
 
 		WM_Q_INTR_EVCNT_ATTACH(rxq, rxintr, rxq, i, xname);
+		WM_Q_INTR_EVCNT_ATTACH(rxq, rxdefer, rxq, i, xname);
 
 		WM_Q_INTR_EVCNT_ATTACH(rxq, rxipsum, rxq, i, xname);
 		WM_Q_INTR_EVCNT_ATTACH(rxq, rxtusum, rxq, i, xname);
@@ -6506,6 +6508,7 @@ wm_free_txrx_queues(struct wm_softc *sc)
 
 #ifdef WM_EVENT_COUNTERS
 		WM_Q_EVCNT_DETACH(rxq, rxintr, rxq, i);
+		WM_Q_EVCNT_DETACH(rxq, rxdefer, rxq, i);
 		WM_Q_EVCNT_DETACH(rxq, rxipsum, rxq, i);
 		WM_Q_EVCNT_DETACH(rxq, rxtusum, rxq, i);
 #endif /* WM_EVENT_COUNTERS */
@@ -9021,7 +9024,7 @@ wm_handle_queue(void *arg)
 		mutex_exit(rxq->rxq_lock);
 		return;
 	}
-	WM_Q_EVCNT_INCR(rxq, rxintr);
+	WM_Q_EVCNT_INCR(rxq, rxdefer);
 	wm_rxeof(rxq, limit);
 	mutex_exit(rxq->rxq_lock);
 



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

2018-01-16 Thread maya
Hi maxv,

there is a similar code fragment in ic/bwfm.c:bwfm_scan_node.
I am not sure what I'm looking at. Could it be wrong too?

Thanks.

On Tue, Jan 16, 2018 at 07:05:25AM +, Maxime Villard wrote:
> Module Name:  src
> Committed By: maxv
> Date: Tue Jan 16 07:05:25 UTC 2018
> 
> Modified Files:
>   src/sys/dev/pci: if_ipw.c if_iwi.c if_iwn.c
> 
> Log Message:
> Fix overflow.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/if_ipw.c
> cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/if_iwi.c
> cvs rdiff -u -r1.86 -r1.87 src/sys/dev/pci/if_iwn.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_ipw.c
> diff -u src/sys/dev/pci/if_ipw.c:1.66 src/sys/dev/pci/if_ipw.c:1.67
> --- src/sys/dev/pci/if_ipw.c:1.66 Mon Oct 23 09:31:18 2017
> +++ src/sys/dev/pci/if_ipw.c  Tue Jan 16 07:05:24 2018
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: if_ipw.c,v 1.66 2017/10/23 09:31:18 msaitoh Exp $  */
> +/*   $NetBSD: if_ipw.c,v 1.67 2018/01/16 07:05:24 maxv Exp $ */
>  /*   FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp 
> */
>  
>  /*-
> @@ -29,7 +29,7 @@
>   */
>  
>  #include 
> -__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.66 2017/10/23 09:31:18 msaitoh Exp 
> $");
> +__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.67 2018/01/16 07:05:24 maxv Exp $");
>  
>  /*-
>   * Intel(R) PRO/Wireless 2100 MiniPCI driver
> @@ -1001,12 +1001,13 @@ ipw_fix_channel(struct ieee80211com *ic,
>   efrm = mtod(m, uint8_t *) + m->m_len;
>  
>   frm += 12;  /* skip tstamp, bintval and capinfo fields */
> - while (frm < efrm) {
> - if (*frm == IEEE80211_ELEMID_DSPARMS)
> + while (frm + 2 < efrm) {
> + if (*frm == IEEE80211_ELEMID_DSPARMS) {
>  #if IEEE80211_CHAN_MAX < 255
> - if (frm[2] <= IEEE80211_CHAN_MAX)
> + if (frm[2] <= IEEE80211_CHAN_MAX)
>  #endif
> - ic->ic_curchan = >ic_channels[frm[2]];
> + ic->ic_curchan = >ic_channels[frm[2]];
> + }
>  
>   frm += frm[1] + 2;
>   }
> 
> Index: src/sys/dev/pci/if_iwi.c
> diff -u src/sys/dev/pci/if_iwi.c:1.104 src/sys/dev/pci/if_iwi.c:1.105
> --- src/sys/dev/pci/if_iwi.c:1.104Mon Oct 23 09:28:13 2017
> +++ src/sys/dev/pci/if_iwi.c  Tue Jan 16 07:05:24 2018
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh Exp $  */
> +/*   $NetBSD: if_iwi.c,v 1.105 2018/01/16 07:05:24 maxv Exp $  */
>  /*   $OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $ */
>  
>  /*-
> @@ -19,7 +19,7 @@
>   */
>  
>  #include 
> -__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh Exp 
> $");
> +__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.105 2018/01/16 07:05:24 maxv Exp 
> $");
>  
>  /*-
>   * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver
> @@ -1126,12 +1126,13 @@ iwi_fix_channel(struct ieee80211com *ic,
>   efrm = mtod(m, uint8_t *) + m->m_len;
>  
>   frm += 12;  /* skip tstamp, bintval and capinfo fields */
> - while (frm < efrm) {
> - if (*frm == IEEE80211_ELEMID_DSPARMS)
> + while (frm + 2 < efrm) {
> + if (*frm == IEEE80211_ELEMID_DSPARMS) {
>  #if IEEE80211_CHAN_MAX < 255
> - if (frm[2] <= IEEE80211_CHAN_MAX)
> + if (frm[2] <= IEEE80211_CHAN_MAX)
>  #endif
> - ic->ic_curchan = >ic_channels[frm[2]];
> + ic->ic_curchan = >ic_channels[frm[2]];
> + }
>  
>   frm += frm[1] + 2;
>   }
> 
> Index: src/sys/dev/pci/if_iwn.c
> diff -u src/sys/dev/pci/if_iwn.c:1.86 src/sys/dev/pci/if_iwn.c:1.87
> --- src/sys/dev/pci/if_iwn.c:1.86 Mon Oct 23 09:31:18 2017
> +++ src/sys/dev/pci/if_iwn.c  Tue Jan 16 07:05:24 2018
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: if_iwn.c,v 1.86 2017/10/23 09:31:18 msaitoh Exp $  */
> +/*   $NetBSD: if_iwn.c,v 1.87 2018/01/16 07:05:24 maxv Exp $ */
>  /*   $OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $ */
>  
>  /*-
> @@ -22,7 +22,7 @@
>   * adapters.
>   */
>  #include 
> -__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.86 2017/10/23 09:31:18 msaitoh Exp 
> $");
> +__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.87 2018/01/16 07:05:24 maxv Exp $");
>  
>  #define IWN_USE_RBUF /* Use local storage for RX */
>  #undef IWN_HWCRYPTO  /* XXX does not even compile yet */
> @@ -6607,12 +6607,13 @@ iwn_fix_channel(struct ieee80211com *ic,
>   efrm = mtod(m, uint8_t *) + m->m_len;
>  
>   frm += 12;  /* skip tstamp, bintval and capinfo fields */
> - while (frm < efrm) {
> - if (*frm == IEEE80211_ELEMID_DSPARMS)
> + while (frm + 2 < efrm) {
> + if (*frm == IEEE80211_ELEMID_DSPARMS) {
>  #if IEEE80211_CHAN_MAX < 255
> - if (frm[2] <= IEEE80211_CHAN_MAX)
> + if (frm[2] <= 

CVS commit: src/sys/dev/pci

2018-01-15 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Jan 16 07:23:13 UTC 2018

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

Log Message:
Fix wm_watchdog_txq() lock region.

Not only wm_txeof() but also wm_watchdog_txq() itself requires txq_lock
as it reads Tx descriptor management variables such as "txq_free".

There is almost no influence on performance.


To generate a diff of this commit:
cvs rdiff -u -r1.554 -r1.555 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.554 src/sys/dev/pci/if_wm.c:1.555
--- src/sys/dev/pci/if_wm.c:1.554	Mon Jan 15 04:25:48 2018
+++ src/sys/dev/pci/if_wm.c	Tue Jan 16 07:23:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.554 2018/01/15 04:25:48 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.555 2018/01/16 07:23:13 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.554 2018/01/15 04:25:48 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.555 2018/01/16 07:23:13 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -671,6 +671,7 @@ static bool	wm_suspend(device_t, const p
 static bool	wm_resume(device_t, const pmf_qual_t *);
 static void	wm_watchdog(struct ifnet *);
 static void	wm_watchdog_txq(struct ifnet *, struct wm_txqueue *);
+static void	wm_watchdog_txq_locked(struct ifnet *, struct wm_txqueue *);
 static void	wm_tick(void *);
 static int	wm_ifflags_cb(struct ethercom *);
 static int	wm_ioctl(struct ifnet *, u_long, void *);
@@ -2953,15 +2954,24 @@ wm_watchdog(struct ifnet *ifp)
 static void
 wm_watchdog_txq(struct ifnet *ifp, struct wm_txqueue *txq)
 {
+
+	mutex_enter(txq->txq_lock);
+	wm_watchdog_txq_locked(ifp, txq);
+	mutex_exit(txq->txq_lock);
+}
+
+static void
+wm_watchdog_txq_locked(struct ifnet *ifp, struct wm_txqueue *txq)
+{
 	struct wm_softc *sc = ifp->if_softc;
 
+	KASSERT(mutex_owned(txq->txq_lock));
+
 	/*
 	 * Since we're using delayed interrupts, sweep up
 	 * before we report an error.
 	 */
-	mutex_enter(txq->txq_lock);
 	wm_txeof(sc, txq);
-	mutex_exit(txq->txq_lock);
 
 	if (txq->txq_free != WM_NTXDESC(txq)) {
 #ifdef WM_DEBUG



CVS commit: src/sys/dev/pci

2018-01-15 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Jan 16 07:23:13 UTC 2018

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

Log Message:
Fix wm_watchdog_txq() lock region.

Not only wm_txeof() but also wm_watchdog_txq() itself requires txq_lock
as it reads Tx descriptor management variables such as "txq_free".

There is almost no influence on performance.


To generate a diff of this commit:
cvs rdiff -u -r1.554 -r1.555 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.



CVS commit: src/sys/dev/pci

2018-01-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Jan 16 07:05:25 UTC 2018

Modified Files:
src/sys/dev/pci: if_ipw.c if_iwi.c if_iwn.c

Log Message:
Fix overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/if_ipw.c
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/if_iwi.c
cvs rdiff -u -r1.86 -r1.87 src/sys/dev/pci/if_iwn.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_ipw.c
diff -u src/sys/dev/pci/if_ipw.c:1.66 src/sys/dev/pci/if_ipw.c:1.67
--- src/sys/dev/pci/if_ipw.c:1.66	Mon Oct 23 09:31:18 2017
+++ src/sys/dev/pci/if_ipw.c	Tue Jan 16 07:05:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ipw.c,v 1.66 2017/10/23 09:31:18 msaitoh Exp $	*/
+/*	$NetBSD: if_ipw.c,v 1.67 2018/01/16 07:05:24 maxv Exp $	*/
 /*	FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp 	*/
 
 /*-
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.66 2017/10/23 09:31:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.67 2018/01/16 07:05:24 maxv Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2100 MiniPCI driver
@@ -1001,12 +1001,13 @@ ipw_fix_channel(struct ieee80211com *ic,
 	efrm = mtod(m, uint8_t *) + m->m_len;
 
 	frm += 12;	/* skip tstamp, bintval and capinfo fields */
-	while (frm < efrm) {
-		if (*frm == IEEE80211_ELEMID_DSPARMS)
+	while (frm + 2 < efrm) {
+		if (*frm == IEEE80211_ELEMID_DSPARMS) {
 #if IEEE80211_CHAN_MAX < 255
-		if (frm[2] <= IEEE80211_CHAN_MAX)
+			if (frm[2] <= IEEE80211_CHAN_MAX)
 #endif
-			ic->ic_curchan = >ic_channels[frm[2]];
+ic->ic_curchan = >ic_channels[frm[2]];
+		}
 
 		frm += frm[1] + 2;
 	}

Index: src/sys/dev/pci/if_iwi.c
diff -u src/sys/dev/pci/if_iwi.c:1.104 src/sys/dev/pci/if_iwi.c:1.105
--- src/sys/dev/pci/if_iwi.c:1.104	Mon Oct 23 09:28:13 2017
+++ src/sys/dev/pci/if_iwi.c	Tue Jan 16 07:05:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh Exp $  */
+/*	$NetBSD: if_iwi.c,v 1.105 2018/01/16 07:05:24 maxv Exp $  */
 /*	$OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $	*/
 
 /*-
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.105 2018/01/16 07:05:24 maxv Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver
@@ -1126,12 +1126,13 @@ iwi_fix_channel(struct ieee80211com *ic,
 	efrm = mtod(m, uint8_t *) + m->m_len;
 
 	frm += 12;	/* skip tstamp, bintval and capinfo fields */
-	while (frm < efrm) {
-		if (*frm == IEEE80211_ELEMID_DSPARMS)
+	while (frm + 2 < efrm) {
+		if (*frm == IEEE80211_ELEMID_DSPARMS) {
 #if IEEE80211_CHAN_MAX < 255
-		if (frm[2] <= IEEE80211_CHAN_MAX)
+			if (frm[2] <= IEEE80211_CHAN_MAX)
 #endif
-			ic->ic_curchan = >ic_channels[frm[2]];
+ic->ic_curchan = >ic_channels[frm[2]];
+		}
 
 		frm += frm[1] + 2;
 	}

Index: src/sys/dev/pci/if_iwn.c
diff -u src/sys/dev/pci/if_iwn.c:1.86 src/sys/dev/pci/if_iwn.c:1.87
--- src/sys/dev/pci/if_iwn.c:1.86	Mon Oct 23 09:31:18 2017
+++ src/sys/dev/pci/if_iwn.c	Tue Jan 16 07:05:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwn.c,v 1.86 2017/10/23 09:31:18 msaitoh Exp $	*/
+/*	$NetBSD: if_iwn.c,v 1.87 2018/01/16 07:05:24 maxv Exp $	*/
 /*	$OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $	*/
 
 /*-
@@ -22,7 +22,7 @@
  * adapters.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.86 2017/10/23 09:31:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.87 2018/01/16 07:05:24 maxv Exp $");
 
 #define IWN_USE_RBUF	/* Use local storage for RX */
 #undef IWN_HWCRYPTO	/* XXX does not even compile yet */
@@ -6607,12 +6607,13 @@ iwn_fix_channel(struct ieee80211com *ic,
 	efrm = mtod(m, uint8_t *) + m->m_len;
 
 	frm += 12;  /* skip tstamp, bintval and capinfo fields */
-	while (frm < efrm) {
-		if (*frm == IEEE80211_ELEMID_DSPARMS)
+	while (frm + 2 < efrm) {
+		if (*frm == IEEE80211_ELEMID_DSPARMS) {
 #if IEEE80211_CHAN_MAX < 255
-		if (frm[2] <= IEEE80211_CHAN_MAX)
+			if (frm[2] <= IEEE80211_CHAN_MAX)
 #endif
-			ic->ic_curchan = >ic_channels[frm[2]];
+ic->ic_curchan = >ic_channels[frm[2]];
+		}
 
 		frm += frm[1] + 2;
 	}



CVS commit: src/sys/dev/pci

2018-01-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Jan 16 07:05:25 UTC 2018

Modified Files:
src/sys/dev/pci: if_ipw.c if_iwi.c if_iwn.c

Log Message:
Fix overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/if_ipw.c
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/if_iwi.c
cvs rdiff -u -r1.86 -r1.87 src/sys/dev/pci/if_iwn.c

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



CVS commit: src/sys/dev/pci

2018-01-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jan 15 12:58:06 UTC 2018

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

Log Message:
indent to magic logic


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/mpii.c

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



CVS commit: src/sys/dev/pci

2018-01-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jan 15 12:58:06 UTC 2018

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

Log Message:
indent to magic logic


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/mpii.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/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.10 src/sys/dev/pci/mpii.c:1.11
--- src/sys/dev/pci/mpii.c:1.10	Mon Oct  9 23:24:22 2017
+++ src/sys/dev/pci/mpii.c	Mon Jan 15 12:58:06 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.10 2017/10/09 23:24:22 maya Exp $ */
+/* $NetBSD: mpii.c,v 1.11 2018/01/15 12:58:06 maya Exp $ */
 /*	OpenBSD: mpii.c,v 1.51 2012/04/11 13:29:14 naddy Exp 	*/
 /*
  * Copyright (c) 2010 Mike Belopuhov 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.10 2017/10/09 23:24:22 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.11 2018/01/15 12:58:06 maya Exp $");
 
 #include "bio.h"
 
@@ -4043,7 +4043,7 @@ mpii_dmamem_alloc(struct mpii_softc *sc,
 
 	mdm = malloc(sizeof(*mdm), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (mdm == NULL)
-	return (NULL);
+		return (NULL);
 
 	mdm->mdm_size = size;
 



CVS commit: src/sys/dev/pci

2018-01-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jan 15 12:43:43 UTC 2018

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

Log Message:
malloc+memset zero to malloc(, |M_ZERO);

ok rkujawa


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/ahd_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/pci/ahd_pci.c
diff -u src/sys/dev/pci/ahd_pci.c:1.35 src/sys/dev/pci/ahd_pci.c:1.36
--- src/sys/dev/pci/ahd_pci.c:1.35	Sat Mar 29 19:28:24 2014
+++ src/sys/dev/pci/ahd_pci.c	Mon Jan 15 12:43:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahd_pci.c,v 1.35 2014/03/29 19:28:24 christos Exp $	*/
+/*	$NetBSD: ahd_pci.c,v 1.36 2018/01/15 12:43:42 maya Exp $	*/
 
 /*
  * Product specific probe and attach routines for:
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahd_pci.c,v 1.35 2014/03/29 19:28:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahd_pci.c,v 1.36 2018/01/15 12:43:42 maya Exp $");
 
 #define AHD_PCI_IOADDR	PCI_MAPREG_START	/* I/O Address */
 #define AHD_PCI_MEMADDR	(PCI_MAPREG_START + 4)	/* Mem I/O Address */
@@ -337,13 +337,12 @@ ahd_pci_attach(device_t parent, device_t
 		return;
 
 	/* Keep information about the PCI bus */
-	bd = malloc(sizeof (struct ahd_pci_busdata), M_DEVBUF, M_NOWAIT);
+	bd = malloc(sizeof (struct ahd_pci_busdata), M_DEVBUF, M_NOWAIT|M_ZERO);
 	if (bd == NULL) {
 		aprint_error("%s: unable to allocate bus-specific data\n",
 		ahd_name(ahd));
 		return;
 	}
-	memset(bd, 0, sizeof(struct ahd_pci_busdata));
 
 	bd->pc = pa->pa_pc;
 	bd->tag = pa->pa_tag;
@@ -355,12 +354,11 @@ ahd_pci_attach(device_t parent, device_t
 	ahd->description = entry->name;
 
 	ahd->seep_config = malloc(sizeof(*ahd->seep_config),
-  M_DEVBUF, M_NOWAIT);
+  M_DEVBUF, M_NOWAIT|M_ZERO);
 	if (ahd->seep_config == NULL) {
 		aprint_error("%s: cannot malloc seep_config!\n", ahd_name(ahd));
 		return;
 	}
-	memset(ahd->seep_config, 0, sizeof(*ahd->seep_config));
 
 	LIST_INIT(>pending_scbs);
 	ahd_timer_init(>reset_timer);



CVS commit: src/sys/dev/pci

2018-01-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jan 15 12:43:43 UTC 2018

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

Log Message:
malloc+memset zero to malloc(, |M_ZERO);

ok rkujawa


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/ahd_pci.c

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



CVS commit: src/sys/dev/pci

2018-01-14 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jan 15 04:25:48 UTC 2018

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

Log Message:
improve comments


To generate a diff of this commit:
cvs rdiff -u -r1.553 -r1.554 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.



CVS commit: src/sys/dev/pci

2018-01-14 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jan 15 04:25:48 UTC 2018

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

Log Message:
improve comments


To generate a diff of this commit:
cvs rdiff -u -r1.553 -r1.554 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.553 src/sys/dev/pci/if_wm.c:1.554
--- src/sys/dev/pci/if_wm.c:1.553	Mon Jan 15 04:09:58 2018
+++ src/sys/dev/pci/if_wm.c	Mon Jan 15 04:25:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.553 2018/01/15 04:09:58 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.554 2018/01/15 04:25:48 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.553 2018/01/15 04:09:58 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.554 2018/01/15 04:25:48 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4210,6 +4210,10 @@ wm_reset_phy(struct wm_softc *sc)
 	wm_phy_post_reset(sc);
 }
 
+/*
+ * Only used by WM_T_PCH_SPT which does not use multiqueue,
+ * so it is enough to check sc->sc_queue[0] only.
+ */
 static void
 wm_flush_desc_rings(struct wm_softc *sc)
 {



CVS commit: src/sys/dev/pci

2018-01-14 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jan 15 04:09:58 UTC 2018

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

Log Message:
Fix legacy Tx descriptors printing when WM_DEBUG is enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.552 -r1.553 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.552 src/sys/dev/pci/if_wm.c:1.553
--- src/sys/dev/pci/if_wm.c:1.552	Thu Jan  4 09:43:27 2018
+++ src/sys/dev/pci/if_wm.c	Mon Jan 15 04:09:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.552 2018/01/04 09:43:27 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.553 2018/01/15 04:09:58 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.552 2018/01/04 09:43:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.553 2018/01/15 04:09:58 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2981,11 +2981,22 @@ wm_watchdog_txq(struct ifnet *ifp, struc
 			i, txs->txs_firstdesc, txs->txs_lastdesc);
 		for (j = txs->txs_firstdesc; ;
 			j = WM_NEXTTX(txq, j)) {
-			printf("\tdesc %d: 0x%" PRIx64 "\n", j,
-			txq->txq_nq_descs[j].nqtx_data.nqtxd_addr);
-			printf("\t %#08x%08x\n",
-			txq->txq_nq_descs[j].nqtx_data.nqtxd_fields,
-			txq->txq_nq_descs[j].nqtx_data.nqtxd_cmdlen);
+			if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
+printf("\tdesc %d: 0x%" PRIx64 "\n", j,
+	txq->txq_nq_descs[j].nqtx_data.nqtxd_addr);
+printf("\t %#08x%08x\n",
+	txq->txq_nq_descs[j].nqtx_data.nqtxd_fields,
+	txq->txq_nq_descs[j].nqtx_data.nqtxd_cmdlen);
+			} else {
+printf("\tdesc %d: 0x%" PRIx64 "\n", j,
+	(uint64_t)txq->txq_descs[j].wtx_addr.wa_high << 32 |
+	txq->txq_descs[j].wtx_addr.wa_low);
+printf("\t %#04x%02x%02x%08x\n",
+	txq->txq_descs[j].wtx_fields.wtxu_vlan,
+	txq->txq_descs[j].wtx_fields.wtxu_options,
+	txq->txq_descs[j].wtx_fields.wtxu_status,
+	txq->txq_descs[j].wtx_cmdlen);
+			}
 			if (j == txs->txs_lastdesc)
 break;
 			}



CVS commit: src/sys/dev/pci

2018-01-14 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jan 15 04:09:58 UTC 2018

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

Log Message:
Fix legacy Tx descriptors printing when WM_DEBUG is enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.552 -r1.553 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.



CVS commit: src/sys/dev/pci

2018-01-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jan 14 17:43:55 UTC 2018

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

Log Message:
Dedup. m_defrag is already a common function, no need to reimplement it
there. Meanwhile this should fix two bugs (that I couldn't investigate
more than that since I don't have this hardware): the mbuf passed to
vge_m_defrag was leaked, and the tags were not copied in the returned
mbuf.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/if_vge.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_vge.c
diff -u src/sys/dev/pci/if_vge.c:1.61 src/sys/dev/pci/if_vge.c:1.62
--- src/sys/dev/pci/if_vge.c:1.61	Tue Sep 26 07:42:06 2017
+++ src/sys/dev/pci/if_vge.c	Sun Jan 14 17:43:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.61 2017/09/26 07:42:06 knakahara Exp $ */
+/* $NetBSD: if_vge.c,v 1.62 2018/01/14 17:43:55 maxv Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.61 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.62 2018/01/14 17:43:55 maxv Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -358,64 +358,6 @@ vge_set_rxaddr(struct vge_rxdesc *rxd, b
 }
 
 /*
- * Defragment mbuf chain contents to be as linear as possible.
- * Returns new mbuf chain on success, NULL on failure. Old mbuf
- * chain is always freed.
- * XXX temporary until there would be generic function doing this.
- */
-#define m_defrag	vge_m_defrag
-struct mbuf * vge_m_defrag(struct mbuf *, int);
-
-struct mbuf *
-vge_m_defrag(struct mbuf *mold, int flags)
-{
-	struct mbuf *m0, *mn, *n;
-	size_t sz = mold->m_pkthdr.len;
-
-#ifdef DIAGNOSTIC
-	if ((mold->m_flags & M_PKTHDR) == 0)
-		panic("m_defrag: not a mbuf chain header");
-#endif
-
-	MGETHDR(m0, flags, MT_DATA);
-	if (m0 == NULL)
-		return NULL;
-	m0->m_pkthdr.len = mold->m_pkthdr.len;
-	mn = m0;
-
-	do {
-		if (sz > MHLEN) {
-			MCLGET(mn, M_DONTWAIT);
-			if ((mn->m_flags & M_EXT) == 0) {
-m_freem(m0);
-return NULL;
-			}
-		}
-
-		mn->m_len = MIN(sz, MCLBYTES);
-
-		m_copydata(mold, mold->m_pkthdr.len - sz, mn->m_len,
-		 mtod(mn, void *));
-
-		sz -= mn->m_len;
-
-		if (sz > 0) {
-			/* need more mbufs */
-			MGET(n, M_NOWAIT, MT_DATA);
-			if (n == NULL) {
-m_freem(m0);
-return NULL;
-			}
-
-			mn->m_next = n;
-			mn = n;
-		}
-	} while (sz > 0);
-
-	return m0;
-}
-
-/*
  * Read a word of data stored in the EEPROM at address 'addr.'
  */
 static uint16_t



CVS commit: src/sys/dev/pci

2018-01-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jan 14 17:43:55 UTC 2018

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

Log Message:
Dedup. m_defrag is already a common function, no need to reimplement it
there. Meanwhile this should fix two bugs (that I couldn't investigate
more than that since I don't have this hardware): the mbuf passed to
vge_m_defrag was leaked, and the tags were not copied in the returned
mbuf.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/if_vge.c

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



CVS commit: src/sys/dev/pci

2018-01-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Jan 10 18:39:50 UTC 2018

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

Log Message:
Match Intel Dual Band Wireless AC 3168. The code already supports it.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/if_iwm.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_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.76 src/sys/dev/pci/if_iwm.c:1.77
--- src/sys/dev/pci/if_iwm.c:1.76	Mon Oct 23 09:28:38 2017
+++ src/sys/dev/pci/if_iwm.c	Wed Jan 10 18:39:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.76 2017/10/23 09:28:38 msaitoh Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.77 2018/01/10 18:39:50 mlelstv Exp $	*/
 /*	OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp	*/
 #define IEEE80211_NO_HT
 /*
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.76 2017/10/23 09:28:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.77 2018/01/10 18:39:50 mlelstv Exp $");
 
 #include 
 #include 
@@ -7701,6 +7701,7 @@ static const pci_product_id_t iwm_device
 	PCI_PRODUCT_INTEL_WIFI_LINK_7265_2,
 	PCI_PRODUCT_INTEL_WIFI_LINK_3165_1,
 	PCI_PRODUCT_INTEL_WIFI_LINK_3165_2,
+	PCI_PRODUCT_INTEL_WIFI_LINK_3168,
 	PCI_PRODUCT_INTEL_WIFI_LINK_8260_1,
 	PCI_PRODUCT_INTEL_WIFI_LINK_8260_2,
 	PCI_PRODUCT_INTEL_WIFI_LINK_4165_1,



CVS commit: src/sys/dev/pci

2018-01-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Jan 10 18:39:50 UTC 2018

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

Log Message:
Match Intel Dual Band Wireless AC 3168. The code already supports it.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/if_iwm.c

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



CVS commit: src/sys/dev/pci

2018-01-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  9 09:19:05 UTC 2018

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

Log Message:
 Add Intel Apollo Lake devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1303 -r1.1304 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.1303 src/sys/dev/pci/pcidevs:1.1304
--- src/sys/dev/pci/pcidevs:1.1303	Tue Jan  9 08:17:27 2018
+++ src/sys/dev/pci/pcidevs	Tue Jan  9 09:19:05 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1303 2018/01/09 08:17:27 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1304 2018/01/09 09:19:05 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -4356,6 +4356,45 @@ product INTEL CORE7G_S_Q_HOST_DRAM 0x591
 product INTEL CORE7G_U_GT3	0x5923	HD Graphics (GT3)
 product INTEL CORE7G_U_GT3E_15W	0x5926	Iris Plus Graphics 640 (GT3e, 15W)
 product INTEL CORE7G_U_GT3E_28W	0x5927	Iris Plus Graphics 650 (GT3e, 28W)
+product INTEL APL_IGD_1		0x5a84	Apollo Lake Graphics (18EU)
+product INTEL APL_IGD_2		0x5a85	Apollo Lake Graphics (12EU)
+product INTEL APL_IU		0x5a88	Apollo Lake Imaging Control Uint
+product INTEL APL_DPTF		0x5a8c	Apollo Lake DPTF
+product INTEL APL_P2SB		0x5a92	Apollo Lake Primary to SideBand Bridge
+product INTEL APL_PMC		0x5a94	Apollo Lake PMC
+product INTEL APL_FASTSPI	0x5a96	Apollo Lake Fast SPI
+product INTEL APL_HDA		0x5a98	Apollo Lake HD Audio
+product INTEL APL_ISH		0x5aa2	Apollo Lake Integrated Sensor Hub
+product INTEL APL_XHCI		0x5aa8	Apollo Lake USB Host (xHCI)
+product INTEL APL_XDCI		0x5aaa	Apollo Lake USB Device (xDCI)
+product INTEL APL_I2C_0		0x5aac	Apollo Lake I2C 0
+product INTEL APL_I2C_1		0x5aae	Apollo Lake I2C 1
+product INTEL APL_I2C_2		0x5ab0	Apollo Lake I2C 2
+product INTEL APL_I2C_3		0x5ab2	Apollo Lake I2C 3
+product INTEL APL_I2C_4		0x5ab4	Apollo Lake I2C 4
+product INTEL APL_I2C_5		0x5ab6	Apollo Lake I2C 5
+product INTEL APL_I2C_6		0x5ab8	Apollo Lake I2C 6
+product INTEL APL_I2C_7		0x5aba	Apollo Lake I2C 7
+product INTEL APL_UART_0	0x5abc	Apollo Lake UART 0
+product INTEL APL_UART_1	0x5abe	Apollo Lake UART 1
+product INTEL APL_UART_2	0x5ac0	Apollo Lake UART 2
+product INTEL APL_SPI_0		0x5ac2	Apollo Lake SPI 0
+product INTEL APL_SPI_1		0x5ac4	Apollo Lake SPI 1
+product INTEL APL_SPI_2		0x5ac6	Apollo Lake SPI 2
+product INTEL APL_SD		0x5aca	Apollo Lake SD Card
+product INTEL APL_EMMC		0x5acc	Apollo Lake eMMC
+product INTEL APL_SMB		0x5ad4	Apollo Lake SMBus
+product INTEL APL_PCIE_B0	0x5ad6	Apollo Lake PCIe B0
+product INTEL APL_PCIE_B1	0x5ad7	Apollo Lake PCIe B1
+product INTEL APL_PCIE_A0	0x5ad8	Apollo Lake PCIe A0
+product INTEL APL_PCIE_A1	0x5ad9	Apollo Lake PCIe A1
+product INTEL APL_PCIE_A2	0x5ada	Apollo Lake PCIe A2
+product INTEL APL_PCIE_A3	0x5adb	Apollo Lake PCIe A3
+product INTEL APL_SATA		0x5ae0	Apollo Lake SATA
+product INTEL APL_LPC		0x5ae8	Apollo Lake LPC
+product INTEL APL_SSRAM		0x5aec	Apollo Lake Shared SRAM
+product INTEL APL_UART_3	0x5aee	Apollo Lake UART 3
+product INTEL APL_HB		0x5af0	Apollo Lake Host Bridge
 product INTEL XEOND_HB_DMI2	0x6f00	Core i7-6xxxK/Xeon-D Host Bridge (DMI2)
 product INTEL XEOND_HB_PCIE	0x6f01	Xeon-D Host Bridge (PCIe)
 product INTEL XEOND_PCIE_1	0x6f02	Xeon-D PCIe Root Port (x8 or x4 max)



CVS commit: src/sys/dev/pci

2018-01-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  9 09:19:28 UTC 2018

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.1296 -r1.1297 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1295 -r1.1296 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.



CVS commit: src/sys/dev/pci

2018-01-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  9 09:19:05 UTC 2018

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

Log Message:
 Add Intel Apollo Lake devices.


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

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



CVS commit: src/sys/dev/pci

2018-01-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  9 08:24:42 UTC 2018

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.1295 -r1.1296 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1294 -r1.1295 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.



CVS commit: src/sys/dev/pci

2018-01-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  9 08:17:28 UTC 2018

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

Log Message:
- s/MMC/eMMC/ for Intel 0x0f14 (Bay Trail)
- Add Atom E3800 (Bay Trail) eMMC 4.5


To generate a diff of this commit:
cvs rdiff -u -r1.1302 -r1.1303 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.1302 src/sys/dev/pci/pcidevs:1.1303
--- src/sys/dev/pci/pcidevs:1.1302	Mon Dec 18 07:57:36 2017
+++ src/sys/dev/pci/pcidevs	Tue Jan  9 08:17:27 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1302 2017/12/18 07:57:36 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1303 2018/01/09 08:17:27 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2901,7 +2901,7 @@ product INTEL BAYTRAIL_SIO2_UART1 0x0f0a
 product INTEL BAYTRAIL_SIO2_UART2 0x0f0c Bay Trail Serial IO (HSUART)
 product INTEL BAYTRAIL_SIO2_SPI	0x0f0e	Bay Trail Serial IO (SPI)
 product INTEL BAYTRAIL_PCU_SMB	0x0f12	Bay Trail PCU SMBus
-product INTEL BAYTRAIL_SCC_MMC	0x0f14	Bay Trail Storage Control Cluster(MMC)
+product INTEL BAYTRAIL_SCC_MMC	0x0f14	Bay Trail Storage Control Cluster(eMMC)
 product INTEL BAYTRAIL_SCC_SDIO	0x0f15	Bay Trail Storage Control Cluster(SDIO)
 product INTEL BAYTRAIL_SCC	0x0f16	Bay Trail Storage Control Cluster(SD)
 product INTEL BAYTRAIL_TXE	0x0f18	Bay Trail Trusted Execution Engine
@@ -2928,6 +2928,7 @@ product INTEL BAYTRAIL_PCIE_1	0x0f48	Bay
 product INTEL BAYTRAIL_PCIE_2	0x0f4a	Bay Trail PCIE Root Port
 product INTEL BAYTRAIL_PCIE_3	0x0f4c	Bay Trail PCIE Root Port
 product INTEL BAYTRAIL_PCIE_4	0x0f4e	Bay Trail PCIE Root Port
+product INTEL BAYTRAIL_SCC_MMC2	0x0f50	Bay Trail Storage Control Cluster(eMMC 4.5)
 product INTEL 82542		0x1000	i82542 Gigabit Ethernet
 product INTEL 82543GC_FIBER	0x1001	i82453GC 1000baseX Ethernet
 product INTEL MODEM56		0x1002	56k Modem



CVS commit: src/sys/dev/pci

2018-01-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan  9 08:17:28 UTC 2018

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

Log Message:
- s/MMC/eMMC/ for Intel 0x0f14 (Bay Trail)
- Add Atom E3800 (Bay Trail) eMMC 4.5


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

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



CVS commit: src/sys/dev/pci

2018-01-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan  4 09:43:28 UTC 2018

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

Log Message:
 Add ASPM workaround for 8257[1234] and 82583 to prevent device timeout or
hangup. Fixes PR#52818 reported by Shinichi Doyashiki.


To generate a diff of this commit:
cvs rdiff -u -r1.551 -r1.552 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.



CVS commit: src/sys/dev/pci

2018-01-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan  4 09:43:28 UTC 2018

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

Log Message:
 Add ASPM workaround for 8257[1234] and 82583 to prevent device timeout or
hangup. Fixes PR#52818 reported by Shinichi Doyashiki.


To generate a diff of this commit:
cvs rdiff -u -r1.551 -r1.552 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.551 src/sys/dev/pci/if_wm.c:1.552
--- src/sys/dev/pci/if_wm.c:1.551	Mon Jan  1 08:33:28 2018
+++ src/sys/dev/pci/if_wm.c	Thu Jan  4 09:43:27 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.551 2018/01/01 08:33:28 jnemeth Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.552 2018/01/04 09:43:27 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.551 2018/01/01 08:33:28 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.552 2018/01/04 09:43:27 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -921,6 +921,7 @@ static void	wm_ulp_disable(struct wm_sof
 static void	wm_enable_phy_wakeup(struct wm_softc *);
 static void	wm_igp3_phy_powerdown_workaround_ich8lan(struct wm_softc *);
 static void	wm_enable_wakeup(struct wm_softc *);
+static void	wm_disable_aspm(struct wm_softc *);
 /* LPLU (Low Power Link Up) */
 static void	wm_lplu_d0_disable(struct wm_softc *);
 /* EEE */
@@ -2048,6 +2049,9 @@ alloc_retry:
 		(sc->sc_flags & WM_F_PCIX) ? "PCIX" : "PCI");
 	}
 
+	/* Disable ASPM L0s and/or L1 for workaround */
+	wm_disable_aspm(sc);
+
 	/* clear interesting stat counters */
 	CSR_READ(sc, WMREG_COLC);
 	CSR_READ(sc, WMREG_RXERRC);
@@ -2911,6 +2915,8 @@ wm_resume(device_t self, const pmf_qual_
 {
 	struct wm_softc *sc = device_private(self);
 
+	/* Disable ASPM L0s and/or L1 for workaround */
+	wm_disable_aspm(sc);
 	wm_init_manageability(sc);
 
 	return true;
@@ -13806,6 +13812,66 @@ wm_enable_wakeup(struct wm_softc *sc)
 	pci_conf_write(sc->sc_pc, sc->sc_pcitag, pmreg + PCI_PMCSR, pmode);
 }
 
+/* Disable ASPM L0s and/or L1 for workaround */
+static void
+wm_disable_aspm(struct wm_softc *sc)
+{
+	pcireg_t reg, mask = 0;
+	unsigned const char *str = "";
+
+	/*
+	 *  Only for PCIe device which has PCIe capability in the PCI config
+	 * space.
+	 */
+	if (((sc->sc_flags & WM_F_PCIE) == 0) || (sc->sc_pcixe_capoff == 0))
+		return;
+
+	switch (sc->sc_type) {
+	case WM_T_82571:
+	case WM_T_82572:
+		/*
+		 * 8257[12] Errata 13: Device Does Not Support PCIe Active
+		 * State Power management L1 State (ASPM L1).
+		 */
+		mask = PCIE_LCSR_ASPM_L1;
+		str = "L1 is";
+		break;
+	case WM_T_82573:
+	case WM_T_82574:
+	case WM_T_82583:
+		/*
+		 * The 82573 disappears when PCIe ASPM L0s is enabled.
+		 *
+		 * The 82574 and 82583 does not support PCIe ASPM L0s with
+		 * some chipset.  The document of 82574 and 82583 says that
+		 * disabling L0s with some specific chipset is sufficient,
+		 * but we follow as of the Intel em driver does.
+		 *
+		 * References:
+		 * Errata 8 of the Specification Update of i82573.
+		 * Errata 20 of the Specification Update of i82574.
+		 * Errata 9 of the Specification Update of i82583.
+		 */
+		mask = PCIE_LCSR_ASPM_L1 | PCIE_LCSR_ASPM_L0S;
+		str = "L0s and L1 are";
+		break;
+	default:
+		return;
+	}
+
+	reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag,
+	sc->sc_pcixe_capoff + PCIE_LCSR);
+	reg &= ~mask;
+	pci_conf_write(sc->sc_pc, sc->sc_pcitag,
+	sc->sc_pcixe_capoff + PCIE_LCSR, reg);
+
+	/* Print only in wm_attach() */
+	if ((sc->sc_flags & WM_F_ATTACHED) == 0)
+		aprint_verbose_dev(sc->sc_dev,
+		"ASPM %s disabled to workaround the errata.\n",
+			str);
+}
+
 /* LPLU */
 
 static void



CVS commit: src/sys/dev/pci

2018-01-01 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Mon Jan  1 08:33:28 UTC 2018

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

Log Message:
PR/52885 - Shinichi Doyashiki -- typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.550 -r1.551 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.550 src/sys/dev/pci/if_wm.c:1.551
--- src/sys/dev/pci/if_wm.c:1.550	Thu Dec 28 06:13:50 2017
+++ src/sys/dev/pci/if_wm.c	Mon Jan  1 08:33:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.551 2018/01/01 08:33:28 jnemeth Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.551 2018/01/01 08:33:28 jnemeth Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -7870,7 +7870,7 @@ wm_nq_send_common_locked(struct ifnet *i
 		lasttx = nexttx;
 		nexttx = WM_NEXTTX(txq, nexttx);
 		/*
-		 * fill in the next descriptors. legacy or adcanced format
+		 * fill in the next descriptors. legacy or advanced format
 		 * is the same here
 		 */
 		for (seg = 1; seg < dmamap->dm_nsegs;



CVS commit: src/sys/dev/pci

2018-01-01 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Mon Jan  1 08:33:28 UTC 2018

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

Log Message:
PR/52885 - Shinichi Doyashiki -- typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.550 -r1.551 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.



CVS commit: src/sys/dev/pci

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 06:13:50 UTC 2017

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

Log Message:
 Don't use MSI-X if we can use only one queue to save interrupt resource.
Written by knakahara and tested by me.


To generate a diff of this commit:
cvs rdiff -u -r1.549 -r1.550 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.549 src/sys/dev/pci/if_wm.c:1.550
--- src/sys/dev/pci/if_wm.c:1.549	Fri Dec  8 05:22:23 2017
+++ src/sys/dev/pci/if_wm.c	Thu Dec 28 06:13:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.549 2017/12/08 05:22:23 ozaki-r Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.549 2017/12/08 05:22:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1850,16 +1850,25 @@ wm_attach(device_t parent, device_t self
 	}
 
 	wm_adjust_qnum(sc, pci_msix_count(pa->pa_pc, pa->pa_tag));
-
-	/* Allocation settings */
-	max_type = PCI_INTR_TYPE_MSIX;
 	/*
-	 * 82583 has a MSI-X capability in the PCI configuration space but
-	 * it doesn't support it. At least the document doesn't say anything
-	 * about MSI-X.
+	 *  Don't use MSI-X if we can use only one queue to save interrupt
+	 * resource.
 	 */
-	counts[PCI_INTR_TYPE_MSIX]
-	= (sc->sc_type == WM_T_82583) ? 0 : sc->sc_nqueues + 1;
+	if (sc->sc_nqueues > 1) {
+		max_type = PCI_INTR_TYPE_MSIX;
+		/*
+		 *  82583 has a MSI-X capability in the PCI configuration space
+		 * but it doesn't support it. At least the document doesn't
+		 * say anything about MSI-X.
+		 */
+		counts[PCI_INTR_TYPE_MSIX]
+		= (sc->sc_type == WM_T_82583) ? 0 : sc->sc_nqueues + 1;
+	} else {
+		max_type = PCI_INTR_TYPE_MSI;
+		counts[PCI_INTR_TYPE_MSIX] = 0;
+	}
+
+	/* Allocation settings */
 	counts[PCI_INTR_TYPE_MSI] = 1;
 	counts[PCI_INTR_TYPE_INTX] = 1;
 	/* overridden by disable flags */



CVS commit: src/sys/dev/pci

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 06:13:50 UTC 2017

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

Log Message:
 Don't use MSI-X if we can use only one queue to save interrupt resource.
Written by knakahara and tested by me.


To generate a diff of this commit:
cvs rdiff -u -r1.549 -r1.550 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.



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

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 06:10:01 UTC 2017

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

Log Message:
 Fallback from MSI-X to MSI or INTx if MSI-X setup failed.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 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.118 src/sys/dev/pci/ixgbe/ixgbe.c:1.119
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.118	Thu Dec 21 09:24:45 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 28 06:10:01 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.118 2017/12/21 09:24:45 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.119 2017/12/28 06:10:01 msaitoh Exp $ */
 
 /**
 
@@ -172,12 +172,14 @@ static void ixgbe_media_status(struc
 static int  ixgbe_media_change(struct ifnet *);
 static int  ixgbe_allocate_pci_resources(struct adapter *,
 		const struct pci_attach_args *);
+static void  ixgbe_free_softint(struct adapter *);
 static void	ixgbe_get_slot_info(struct adapter *);
 static int  ixgbe_allocate_msix(struct adapter *,
 		const struct pci_attach_args *);
 static int  ixgbe_allocate_legacy(struct adapter *,
 		const struct pci_attach_args *);
 static int  ixgbe_configure_interrupts(struct adapter *);
+static void	ixgbe_free_pciintr_resources(struct adapter *);
 static void	ixgbe_free_pci_resources(struct adapter *);
 static void	ixgbe_local_timer(void *);
 static void	ixgbe_local_timer1(void *);
@@ -1043,13 +1045,54 @@ ixgbe_attach(device_t parent, device_t d
 	hw->eeprom.ops.read(hw, IXGBE_ETRACKID_L, );
 	aprint_normal(" ETrackID %08x\n", ((uint32_t)high << 16) | low);
 
-	if (adapter->feat_en & IXGBE_FEATURE_MSIX)
+	if (adapter->feat_en & IXGBE_FEATURE_MSIX) {
 		error = ixgbe_allocate_msix(adapter, pa);
-	else
+		if (error) {
+			/* Free allocated queue structures first */
+			ixgbe_free_transmit_structures(adapter);
+			ixgbe_free_receive_structures(adapter);
+			free(adapter->queues, M_DEVBUF);
+
+			/* Fallback to legacy interrupt */
+			adapter->feat_en &= ~IXGBE_FEATURE_MSIX;
+			if (adapter->feat_cap & IXGBE_FEATURE_MSI)
+adapter->feat_en |= IXGBE_FEATURE_MSI;
+			adapter->num_queues = 1;
+
+			/* Allocate our TX/RX Queues again */
+			if (ixgbe_allocate_queues(adapter)) {
+error = ENOMEM;
+goto err_out;
+			}
+		}
+	}
+	if ((adapter->feat_en & IXGBE_FEATURE_MSIX) == 0)
 		error = ixgbe_allocate_legacy(adapter, pa);
 	if (error) 
 		goto err_late;
 
+	/* Tasklets for Link, SFP, Multispeed Fiber and Flow Director */
+	adapter->link_si = softint_establish(SOFTINT_NET |IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_link, adapter);
+	adapter->mod_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_mod, adapter);
+	adapter->msf_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_msf, adapter);
+	adapter->phy_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+	ixgbe_handle_phy, adapter);
+	if (adapter->feat_en & IXGBE_FEATURE_FDIR)
+		adapter->fdir_si =
+		softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS,
+			ixgbe_reinit_fdir, adapter);
+	if ((adapter->link_si == NULL) || (adapter->mod_si == NULL)
+	|| (adapter->msf_si == NULL) || (adapter->phy_si == NULL)
+	|| ((adapter->feat_en & IXGBE_FEATURE_FDIR)
+		&& (adapter->fdir_si == NULL))) {
+		aprint_error_dev(dev,
+		"could not establish software interrupts ()\n");
+		goto err_out;
+	}
+
 	error = ixgbe_start_hw(hw);
 	switch (error) {
 	case IXGBE_ERR_EEPROM_VERSION:
@@ -1158,6 +1201,7 @@ err_out:
 	ctrl_ext = IXGBE_READ_REG(>hw, IXGBE_CTRL_EXT);
 	ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD;
 	IXGBE_WRITE_REG(>hw, IXGBE_CTRL_EXT, ctrl_ext);
+	ixgbe_free_softint(adapter);
 	ixgbe_free_pci_resources(adapter);
 	if (adapter->mta != NULL)
 		free(adapter->mta, M_DEVBUF);
@@ -3113,6 +3157,53 @@ map_err:
 	return (0);
 } /* ixgbe_allocate_pci_resources */
 
+static void
+ixgbe_free_softint(struct adapter *adapter)
+{
+	struct ix_queue *que = adapter->queues;
+	struct tx_ring *txr = adapter->tx_rings;
+	int i;
+
+	for (i = 0; i < adapter->num_queues; i++, que++, txr++) {
+		if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) {
+			if (txr->txr_si != NULL)
+softint_disestablish(txr->txr_si);
+		}
+		if (que->que_si != NULL)
+			softint_disestablish(que->que_si);
+	}
+
+	/* Drain the Link queue */
+	if (adapter->link_si != NULL) {
+		softint_disestablish(adapter->link_si);
+		adapter->link_si = NULL;
+	}
+	if (adapter->mod_si != NULL) {
+		softint_disestablish(adapter->mod_si);
+		adapter->mod_si = NULL;
+	}
+	if (adapter->msf_si != NULL) {
+		softint_disestablish(adapter->msf_si);
+		adapter->msf_si = NULL;
+	}
+	if (adapter->phy_si != NULL) {
+		softint_disestablish(adapter->phy_si);
+		

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

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 06:10:01 UTC 2017

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

Log Message:
 Fallback from MSI-X to MSI or INTx if MSI-X setup failed.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 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.



CVS commit: src/sys/dev/pci

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 05:43:42 UTC 2017

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

Log Message:
- Fix panic in xhci_pci_detach() if xhci_pci_attach() failed.
- Fallback from MSI to INTx correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/xhci_pci.c

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



CVS commit: src/sys/dev/pci

2017-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 28 05:43:42 UTC 2017

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

Log Message:
- Fix panic in xhci_pci_detach() if xhci_pci_attach() failed.
- Fallback from MSI to INTx correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/xhci_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/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.10 src/sys/dev/pci/xhci_pci.c:1.11
--- src/sys/dev/pci/xhci_pci.c:1.10	Mon Dec 25 08:39:38 2017
+++ src/sys/dev/pci/xhci_pci.c	Thu Dec 28 05:43:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.10 2017/12/25 08:39:38 msaitoh Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.11 2017/12/28 05:43:42 msaitoh Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.10 2017/12/25 08:39:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.11 2017/12/28 05:43:42 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -204,6 +204,7 @@ alloc_retry:
 		case PCI_INTR_TYPE_MSI:
 			/* The next try is for INTx: Disable MSI */
 			counts[PCI_INTR_TYPE_MSI] = 0;
+			counts[PCI_INTR_TYPE_INTX] = 1;
 			goto alloc_retry;
 		case PCI_INTR_TYPE_INTX:
 		default:
@@ -273,15 +274,15 @@ xhci_pci_detach(device_t self, int flags
 	struct xhci_softc * const sc = >sc_xhci;
 	int rv;
 
-	rv = xhci_detach(sc, flags);
-	if (rv)
-		return rv;
+	if (sc->sc_ios != 0) {
+		rv = xhci_detach(sc, flags);
+		if (rv)
+			return rv;
 
-	pmf_device_deregister(self);
+		pmf_device_deregister(self);
 
-	xhci_shutdown(self, flags);
+		xhci_shutdown(self, flags);
 
-	if (sc->sc_ios) {
 #if 0
 		/* Disable interrupts, so we don't get any spurious ones. */
 		bus_space_write_4(sc->sc_iot, sc->sc_ioh,



CVS commit: src/sys/dev/pci

2017-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 27 20:27:02 UTC 2017

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

Log Message:
PR/52868: Petar Bogdanovic: Add support for Manhattan 158220 card


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/pci/pucdata.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/pucdata.c
diff -u src/sys/dev/pci/pucdata.c:1.99 src/sys/dev/pci/pucdata.c:1.100
--- src/sys/dev/pci/pucdata.c:1.99	Sat Jan 14 23:45:39 2017
+++ src/sys/dev/pci/pucdata.c	Wed Dec 27 15:27:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pucdata.c,v 1.99 2017/01/15 04:45:39 msaitoh Exp $	*/
+/*	$NetBSD: pucdata.c,v 1.100 2017/12/27 20:27:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.99 2017/01/15 04:45:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.100 2017/12/27 20:27:02 christos Exp $");
 
 #include 
 #include 
@@ -879,6 +879,15 @@ const struct puc_device_description puc_
 	},
 	},
 
+	/* NetMos PCI NM9865 : 1P */
+	{   "NetMos NM9865 Single LPT",
+	{	PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9865, 0xa000, 0x2000 },
+	{	0x,	0x,	0x,	0x	},
+	{
+		{ PUC_PORT_TYPE_LPT, PCI_BAR0, 0x00, 0x00 },
+	},
+	},
+
 	/* NetMos 2S PCI NM9865 : 2S */
 	{   "NetMos NM9865 2 UART",
 	{	PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9865, 0xa000, 0x3002 },



CVS commit: src/sys/dev/pci

2017-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 27 20:27:02 UTC 2017

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

Log Message:
PR/52868: Petar Bogdanovic: Add support for Manhattan 158220 card


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/pci/pucdata.c

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



CVS commit: src/sys/dev/pci

2017-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 25 08:39:38 UTC 2017

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

Log Message:
- Fix a panic while cleaning PCI interrupt.
- Fallback to INTx if MSI allocation succeeded but the establish failed.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/xhci_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/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.9 src/sys/dev/pci/xhci_pci.c:1.10
--- src/sys/dev/pci/xhci_pci.c:1.9	Tue Sep  5 08:01:43 2017
+++ src/sys/dev/pci/xhci_pci.c	Mon Dec 25 08:39:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.9 2017/09/05 08:01:43 skrll Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.10 2017/12/25 08:39:38 msaitoh Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.9 2017/09/05 08:01:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.10 2017/12/25 08:39:38 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -123,6 +123,7 @@ xhci_pci_attach(device_t parent, device_
 	struct pci_attach_args *const pa = (struct pci_attach_args *)aux;
 	const pci_chipset_tag_t pc = pa->pa_pc;
 	const pcitag_t tag = pa->pa_tag;
+	pci_intr_type_t intr_type;
 	char const *intrstr;
 	pcireg_t csr, memtype;
 	int err;
@@ -185,6 +186,7 @@ xhci_pci_attach(device_t parent, device_
 #endif
 	};
 
+alloc_retry:
 	/* Allocate and establish the interrupt. */
 	if (pci_intr_alloc(pa, >sc_pihp, counts, PCI_INTR_TYPE_MSIX)) {
 		aprint_error_dev(self, "can't allocate handler\n");
@@ -195,11 +197,22 @@ xhci_pci_attach(device_t parent, device_
 	psc->sc_ih = pci_intr_establish_xname(pc, psc->sc_pihp[0], IPL_USB,
 	xhci_intr, sc, device_xname(sc->sc_dev));
 	if (psc->sc_ih == NULL) {
-		aprint_error_dev(self, "couldn't establish interrupt");
-		if (intrstr != NULL)
-			aprint_error(" at %s", intrstr);
-		aprint_error("\n");
-		goto fail;
+		intr_type = pci_intr_type(pc, psc->sc_pihp[0]);
+		pci_intr_release(pc, psc->sc_pihp, 1);
+		psc->sc_ih = NULL;
+		switch (intr_type) {
+		case PCI_INTR_TYPE_MSI:
+			/* The next try is for INTx: Disable MSI */
+			counts[PCI_INTR_TYPE_MSI] = 0;
+			goto alloc_retry;
+		case PCI_INTR_TYPE_INTX:
+		default:
+			aprint_error_dev(self, "couldn't establish interrupt");
+			if (intrstr != NULL)
+aprint_error(" at %s", intrstr);
+			aprint_error("\n");
+			goto fail;
+		}
 	}
 	aprint_normal_dev(self, "interrupting at %s\n", intrstr);
 
@@ -238,10 +251,14 @@ xhci_pci_attach(device_t parent, device_
 	return;
 
 fail:
-	if (psc->sc_ih) {
-		pci_intr_release(psc->sc_pc, psc->sc_pihp, 1);
+	if (psc->sc_ih != NULL) {
+		pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
 		psc->sc_ih = NULL;
 	}
+	if (psc->sc_pihp != NULL) {
+		pci_intr_release(psc->sc_pc, psc->sc_pihp, 1);
+		psc->sc_pihp = NULL;
+	}
 	if (sc->sc_ios) {
 		bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
 		sc->sc_ios = 0;
@@ -273,9 +290,13 @@ xhci_pci_detach(device_t self, int flags
 	}
 
 	if (psc->sc_ih != NULL) {
-		pci_intr_release(psc->sc_pc, psc->sc_pihp, 1);
+		pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
 		psc->sc_ih = NULL;
 	}
+	if (psc->sc_pihp != NULL) {
+		pci_intr_release(psc->sc_pc, psc->sc_pihp, 1);
+		psc->sc_pihp = NULL;
+	}
 	if (sc->sc_ios) {
 		bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
 		sc->sc_ios = 0;



CVS commit: src/sys/dev/pci

2017-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 25 08:39:38 UTC 2017

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

Log Message:
- Fix a panic while cleaning PCI interrupt.
- Fallback to INTx if MSI allocation succeeded but the establish failed.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/xhci_pci.c

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



CVS commit: src/sys/dev/pci

2017-12-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Dec 22 13:58:12 UTC 2017

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

Log Message:
Update a URL of Am53c974A technical manual.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/pcscp.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/pcscp.c
diff -u src/sys/dev/pci/pcscp.c:1.47 src/sys/dev/pci/pcscp.c:1.48
--- src/sys/dev/pci/pcscp.c:1.47	Sat Mar 29 19:28:25 2014
+++ src/sys/dev/pci/pcscp.c	Fri Dec 22 13:58:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcscp.c,v 1.47 2014/03/29 19:28:25 christos Exp $	*/
+/*	$NetBSD: pcscp.c,v 1.48 2017/12/22 13:58:11 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -35,11 +35,11 @@
  * written by Izumi Tsutsui 
  *
  * Technical manual available at
- * http://www.amd.com/files/connectivitysolutions/networking/archivednetworking/19113.pdf
+ * http://support.amd.com/TechDocs/19113.pdf
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcscp.c,v 1.47 2014/03/29 19:28:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcscp.c,v 1.48 2017/12/22 13:58:11 tsutsui Exp $");
 
 #include 
 #include 



CVS commit: src/sys/dev/pci

2017-12-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Dec 22 13:58:12 UTC 2017

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

Log Message:
Update a URL of Am53c974A technical manual.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/pcscp.c

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



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

2017-12-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 21 09:24:45 UTC 2017

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

Log Message:
- If MSI can't be used on some environment, fallback to INTx correctly.
- Use single vector MSI when number of CPU is 1 to save interrupt slot.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 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.



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

2017-12-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 21 09:24:45 UTC 2017

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

Log Message:
- If MSI can't be used on some environment, fallback to INTx correctly.
- Use single vector MSI when number of CPU is 1 to save interrupt slot.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 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.117 src/sys/dev/pci/ixgbe/ixgbe.c:1.118
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.117	Thu Dec 21 06:49:26 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 21 09:24:45 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.117 2017/12/21 06:49:26 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.118 2017/12/21 09:24:45 msaitoh Exp $ */
 
 /**
 
@@ -5666,8 +5666,9 @@ ixgbe_allocate_legacy(struct adapter *ad
 	counts[PCI_INTR_TYPE_MSIX] = 0;
 	counts[PCI_INTR_TYPE_MSI] =
 	(adapter->feat_en & IXGBE_FEATURE_MSI) ? 1 : 0;
+	/* Check not feat_en but feat_cap to fallback to INTx */
 	counts[PCI_INTR_TYPE_INTX] =
-	(adapter->feat_en & IXGBE_FEATURE_LEGACY_IRQ) ? 1 : 0;
+	(adapter->feat_cap & IXGBE_FEATURE_LEGACY_IRQ) ? 1 : 0;
 
 alloc_retry:
 	if (pci_intr_alloc(pa, >osdep.intrs, counts, max_type) != 0) {
@@ -5691,7 +5692,12 @@ alloc_retry:
 			/* The next try is for INTx: Disable MSI */
 			max_type = PCI_INTR_TYPE_INTX;
 			counts[PCI_INTR_TYPE_INTX] = 1;
-			goto alloc_retry;
+			adapter->feat_en &= ~IXGBE_FEATURE_MSI;
+			if (adapter->feat_cap & IXGBE_FEATURE_LEGACY_IRQ) {
+adapter->feat_en |= IXGBE_FEATURE_LEGACY_IRQ;
+goto alloc_retry;
+			} else
+break;
 		case PCI_INTR_TYPE_INTX:
 		default:
 			/* See below */
@@ -5958,6 +5964,13 @@ ixgbe_configure_interrupts(struct adapte
 	if (!(adapter->feat_cap & IXGBE_FEATURE_MSIX))
 		goto msi;
 
+	/*
+	 *  NetBSD only: Use single vector MSI when number of CPU is 1 to save
+	 * interrupt slot.
+	 */
+	if (ncpu == 1)
+		goto msi;
+	
 	/* First try MSI-X */
 	msgs = pci_msix_count(adapter->osdep.pc, adapter->osdep.tag);
 	msgs = MIN(msgs, IXG_MAX_NINTR);



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

2017-12-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 21 06:49:26 UTC 2017

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

Log Message:
 Fix panic when only link interrupt can't be established.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.76 -r1.77 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/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.116 src/sys/dev/pci/ixgbe/ixgbe.c:1.117
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.116	Wed Dec 20 08:51:42 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 21 06:49:26 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.116 2017/12/20 08:51:42 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.117 2017/12/21 06:49:26 msaitoh Exp $ */
 
 /**
 
@@ -5886,6 +5886,7 @@ ixgbe_allocate_msix(struct adapter *adap
 	/* and Link */
 	cpu_id++;
 	snprintf(intr_xname, sizeof(intr_xname), "%s link", device_xname(dev));
+	adapter->vector = vector;
 	intrstr = pci_intr_string(pc, adapter->osdep.intrs[vector], intrbuf,
 	sizeof(intrbuf));
 #ifdef IXGBE_MPSAFE
@@ -5914,7 +5915,6 @@ ixgbe_allocate_msix(struct adapter *adap
 	else
 		aprint_normal("\n");
 
-	adapter->vector = vector;
 	/* Tasklets for Link, SFP and Multispeed Fiber */
 	adapter->link_si = softint_establish(SOFTINT_NET |IXGBE_SOFTINFT_FLAGS,
 	ixgbe_handle_link, adapter);

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.76 src/sys/dev/pci/ixgbe/ixv.c:1.77
--- src/sys/dev/pci/ixgbe/ixv.c:1.76	Thu Dec 21 06:43:17 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Thu Dec 21 06:49:26 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.76 2017/12/21 06:43:17 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.77 2017/12/21 06:49:26 msaitoh Exp $*/
 
 /**
 
@@ -2696,6 +2696,7 @@ ixv_allocate_msix(struct adapter *adapte
 	/* and Mailbox */
 	cpu_id++;
 	snprintf(intr_xname, sizeof(intr_xname), "%s link", device_xname(dev));
+	adapter->vector = vector;
 	intrstr = pci_intr_string(pc, adapter->osdep.intrs[vector], intrbuf,
 	sizeof(intrbuf));
 #ifdef IXGBE_MPSAFE
@@ -2724,7 +2725,6 @@ ixv_allocate_msix(struct adapter *adapte
 	else
 		aprint_normal("\n");
 
-	adapter->vector = vector;
 	/* Tasklets for Mailbox */
 	adapter->link_si = softint_establish(SOFTINT_NET |IXGBE_SOFTINFT_FLAGS,
 	ixv_handle_link, adapter);



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

2017-12-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 21 06:49:26 UTC 2017

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

Log Message:
 Fix panic when only link interrupt can't be established.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.76 -r1.77 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.



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

2017-12-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 21 06:43:17 UTC 2017

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

Log Message:
 Don't panic when resource shortage occured. Like ixgbe.c rev. 1.116.
 - Move location of {ixgbe,ixv}_setup_interface() call at a position that
   any error don't occur. One of the reason is that it should be. Another
   reason is that it's hard to call ether_ifdetach() and if_detach() when
   cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
   and maybe more).


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 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/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.75 src/sys/dev/pci/ixgbe/ixv.c:1.76
--- src/sys/dev/pci/ixgbe/ixv.c:1.75	Wed Dec  6 04:08:50 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Thu Dec 21 06:43:17 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.75 2017/12/06 04:08:50 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.76 2017/12/21 06:43:17 msaitoh Exp $*/
 
 /**
 
@@ -496,6 +496,12 @@ ixv_attach(device_t parent, device_t dev
 	/* hw.ix defaults init */
 	adapter->enable_aim = ixv_enable_aim;
 
+	error = ixv_allocate_msix(adapter, pa);
+	if (error) {
+		device_printf(dev, "ixv_allocate_msix() failed!\n");
+		goto err_late;
+	}
+
 	/* Setup OS specific network interface */
 	error = ixv_setup_interface(dev, adapter);
 	if (error != 0) {
@@ -503,12 +509,6 @@ ixv_attach(device_t parent, device_t dev
 		goto err_late;
 	}
 
-	error = ixv_allocate_msix(adapter, pa);
-	if (error) {
-		device_printf(dev, "ixv_allocate_msix() failed!\n");
-		goto err_late;
-	}
-
 	/* Do the stats setup */
 	ixv_save_stats(adapter);
 	ixv_init_stats(adapter);



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

2017-12-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec 21 06:43:17 UTC 2017

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

Log Message:
 Don't panic when resource shortage occured. Like ixgbe.c rev. 1.116.
 - Move location of {ixgbe,ixv}_setup_interface() call at a position that
   any error don't occur. One of the reason is that it should be. Another
   reason is that it's hard to call ether_ifdetach() and if_detach() when
   cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
   and maybe more).


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 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.



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

2017-12-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec 20 08:51:43 UTC 2017

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

Log Message:
 Don't panic when resource shortage occured. Fixes PR#52820 reported by
kardel@:
 - Don't use if_free() because ixgbe(4) don't use if_alloc().
 - Move location of {ixgbe,ixv}_setup_interface() call at a position that
   any error don't occur. One of the reason is that it should be. Another
   reason is that it's hard to call ether_ifdetach() and if_detach() when
   cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
   and maybe more).


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 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.115 src/sys/dev/pci/ixgbe/ixgbe.c:1.116
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.115	Wed Dec  6 04:08:50 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Dec 20 08:51:42 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.115 2017/12/06 04:08:50 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.116 2017/12/20 08:51:42 msaitoh Exp $ */
 
 /**
 
@@ -1043,10 +1043,6 @@ ixgbe_attach(device_t parent, device_t d
 	hw->eeprom.ops.read(hw, IXGBE_ETRACKID_L, );
 	aprint_normal(" ETrackID %08x\n", ((uint32_t)high << 16) | low);
 
-	/* Setup OS specific network interface */
-	if (ixgbe_setup_interface(dev, adapter) != 0)
-		goto err_late;
-
 	if (adapter->feat_en & IXGBE_FEATURE_MSIX)
 		error = ixgbe_allocate_msix(adapter, pa);
 	else
@@ -1074,6 +1070,10 @@ ixgbe_attach(device_t parent, device_t d
 		break;
 	}
 
+	/* Setup OS specific network interface */
+	if (ixgbe_setup_interface(dev, adapter) != 0)
+		goto err_late;
+
 	/*
 	 *  Print PHY ID only for copper PHY. On device which has SFP(+) cage
 	 * and a module is inserted, phy.id is not MII PHY id but SFF 8024 ID.
@@ -1155,8 +1155,6 @@ err_late:
 	ixgbe_free_receive_structures(adapter);
 	free(adapter->queues, M_DEVBUF);
 err_out:
-	if (adapter->ifp != NULL)
-		if_free(adapter->ifp);
 	ctrl_ext = IXGBE_READ_REG(>hw, IXGBE_CTRL_EXT);
 	ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD;
 	IXGBE_WRITE_REG(>hw, IXGBE_CTRL_EXT, ctrl_ext);



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

2017-12-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec 20 08:51:43 UTC 2017

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

Log Message:
 Don't panic when resource shortage occured. Fixes PR#52820 reported by
kardel@:
 - Don't use if_free() because ixgbe(4) don't use if_alloc().
 - Move location of {ixgbe,ixv}_setup_interface() call at a position that
   any error don't occur. One of the reason is that it should be. Another
   reason is that it's hard to call ether_ifdetach() and if_detach() when
   cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
   and maybe more).


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 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.



CVS commit: src/sys/dev/pci

2017-12-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 18 07:57:36 UTC 2017

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

Log Message:
 Add some Chelsio devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1301 -r1.1302 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.1301 src/sys/dev/pci/pcidevs:1.1302
--- src/sys/dev/pci/pcidevs:1.1301	Thu Nov  9 03:07:10 2017
+++ src/sys/dev/pci/pcidevs	Mon Dec 18 07:57:36 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1301 2017/11/09 03:07:10 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1302 2017/12/18 07:57:36 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1920,6 +1920,7 @@ product C4T GPPCI		0x6773	GPPCI
 product CAVIUM NITROX		0x0001	Nitrox XL
 
 /* Chelsio products */
+product CHELSIO PE9000		0x0020	PE9000 10GbE
 product CHELSIO T302E		0x0021	T302e
 product CHELSIO	T310E		0x0022	T310e
 product CHELSIO	T320X		0x0023	T320x
@@ -1929,6 +1930,57 @@ product CHELSIO	T310X		0x0026	T310x
 product CHELSIO	T3B10		0x0030	T3B10
 product CHELSIO	T3B20		0x0031	T3B20
 product CHELSIO	T3B02		0x0032	T3B02
+product CHELSIO	T3B04		0x0033	T3B04
+product CHELSIO	T3C10		0x0035	T3C10
+product CHELSIO	S320E_CR	0x0036	S320E-CR
+product CHELSIO	N320E_G2	0x0037	N320E-G2
+product CHELSIO	T440_DBG	0x4400	T440-dbg
+product CHELSIO	T420_CR		0x4401	T420-CR
+product CHELSIO	T422_CR		0x4402	T422-CR
+product CHELSIO	T440_CR		0x4403	T440-CR
+product CHELSIO	T420_BCH	0x4404	T420-BCH
+product CHELSIO	T440_BCH	0x4405	T440-BCH
+product CHELSIO	T440_CH		0x4406	T440-CH
+product CHELSIO	T420_SO		0x4407	T420-SO
+product CHELSIO	T420_CX		0x4408	T420-CX
+product CHELSIO	T420_BT		0x4409	T420-BT
+product CHELSIO	T404_BT		0x440a	T404-BT
+product CHELSIO	T440_LP_CR	0x440e	T440-LP-CR
+product CHELSIO	T580_DBG	0x5400	T580-dbg
+product CHELSIO	T520_CR		0x5401	T520-CR
+product CHELSIO	T522_CR		0x5402	T522-CR
+product CHELSIO	T540_CR		0x5403	T540-CR
+product CHELSIO	T520_SO		0x5407	T520-SO
+product CHELSIO	T520_BT		0x5409	T520-BT
+product CHELSIO	T504_BT		0x540a	T504-BT
+product CHELSIO	T580_CR		0x540d	T580-CR
+product CHELSIO	T540_LP_CR	0x540e	T540-LP-CR
+product CHELSIO	T580_LP_CR	0x5410	T580-LP-CR
+product CHELSIO	T520_LL_CR	0x5411	T520-LL-CR
+product CHELSIO	T560_CR		0x5412	T560-CR
+product CHELSIO	T580_LP_SO_CR	0x5414	T580-LP-SO-CR
+product CHELSIO	T502_BT		0x5415	T502-BT
+product CHELSIO	T6_DBG_25	0x6400	T6-DBG-25
+product CHELSIO	T6225_CR	0x6401	T6225-CR
+product CHELSIO	T6225_SO_CR	0x6402	T6225-SO-CR
+product CHELSIO	T6425_CR	0x6403	T6425-CR
+product CHELSIO	T6425_SO_CR	0x6404	T6425-SO-CR
+product CHELSIO	T6225_OCP_SO	0x6405	T6225-OCP-SO
+product CHELSIO	T62100_OCP_SO	0x6406	T62100-OCP-SO
+product CHELSIO	T62100_LP_CR	0x6407	T62100-LP-CR
+product CHELSIO	T62100_SO_CR	0x6408	T62100-SO-CR
+product CHELSIO	T6210_BT	0x6409	T6210-BT
+product CHELSIO	T62100_CR	0x640d	T62100-CR
+product CHELSIO	T6_DBG_100	0x6410	T6-DBG-100
+product CHELSIO	T6225_LL_CR	0x6411	T6225-LL-CR
+product CHELSIO	T61100_OCP_SO	0x6414	T61100-OCP-SO
+product CHELSIO	T6201_BT	0x6415	T6201-BT
+product CHELSIO	T6225_80	0x6480	T6225 80
+product CHELSIO	T62100_81	0x6481	T62100 81
+product CHELSIO	T62100_84	0x6484	T62100 84
+product CHELSIO	T4_FPGA		0xa000	Terminator 4 FPGA
+product CHELSIO	T5_FPGA		0xb000	Terminator 5 FPGA
+product CHELSIO	T6_FPGA		0xc006	Terminator 6 FPGA
 
 /* Chips and Technologies products */
 product CHIPS 64310		0x00b8	64310



CVS commit: src/sys/dev/pci

2017-12-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 18 07:57:55 UTC 2017

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.1294 -r1.1295 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1293 -r1.1294 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.



CVS commit: src/sys/dev/pci

2017-12-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 18 07:57:36 UTC 2017

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

Log Message:
 Add some Chelsio devices.


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

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



CVS commit: src/sys/dev/pci

2017-12-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 18 04:48:28 UTC 2017

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

Log Message:
 Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.

 NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.135 -r1.136 src/sys/dev/pci/pcireg.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ppbreg.h

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



CVS commit: src/sys/dev/pci

2017-12-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 18 04:48:28 UTC 2017

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

Log Message:
 Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.

 NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.135 -r1.136 src/sys/dev/pci/pcireg.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ppbreg.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.196 src/sys/dev/pci/pci_subr.c:1.197
--- src/sys/dev/pci/pci_subr.c:1.196	Wed Oct 25 08:21:41 2017
+++ src/sys/dev/pci/pci_subr.c	Mon Dec 18 04:48:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.196 2017/10/25 08:21:41 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.197 2017/12/18 04:48:28 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.196 2017/10/25 08:21:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.197 2017/12/18 04:48:28 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -4290,7 +4290,7 @@ pci_conf_print_type1(
 const pcireg_t *regs)
 {
 	int off, width;
-	pcireg_t rval;
+	pcireg_t rval, csreg;
 	uint32_t base, limit;
 	uint32_t base_h, limit_h;
 	uint64_t pbase, plimit;
@@ -4407,7 +4407,8 @@ pci_conf_print_type1(
 	} else
 		printf("  range: not set\n");
 
-	if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT)
+	csreg = regs[o2i(PCI_COMMAND_STATUS_REG)];
+	if (csreg & PCI_STATUS_CAPLIST_SUPPORT)
 		printf("Capability list pointer: 0x%02x\n",
 		PCI_CAPLIST_PTR(regs[o2i(PCI_CAPLISTPTR_REG)]));
 	else
@@ -4449,6 +4450,13 @@ pci_conf_print_type1(
 	onoff("Secondary SERR forwarding", rval, PCI_BRIDGE_CONTROL_SERR);
 	onoff("ISA enable", rval, PCI_BRIDGE_CONTROL_ISA);
 	onoff("VGA enable", rval, PCI_BRIDGE_CONTROL_VGA);
+	/*
+	 * VGA 16bit decode bit has meaning if the VGA enable bit or the
+	 * VGA Palette Snoop Enable bit is set.
+	 */
+	if (((rval & PCI_BRIDGE_CONTROL_VGA) != 0)
+	|| ((csreg & PCI_COMMAND_PALETTE_ENABLE) != 0))
+		onoff("VGA 16bit enable", rval, PCI_BRIDGE_CONTROL_VGA16);
 	onoff("Master abort reporting", rval, PCI_BRIDGE_CONTROL_MABRT);
 	onoff("Secondary bus reset", rval, PCI_BRIDGE_CONTROL_SECBR);
 	onoff("Fast back-to-back capable", rval,PCI_BRIDGE_CONTROL_SECFASTB2B);

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.135 src/sys/dev/pci/pcireg.h:1.136
--- src/sys/dev/pci/pcireg.h:1.135	Thu Oct 19 05:52:57 2017
+++ src/sys/dev/pci/pcireg.h	Mon Dec 18 04:48:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.135 2017/10/19 05:52:57 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.136 2017/12/18 04:48:28 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -1327,7 +1327,7 @@ typedef u_int8_t pci_intr_line_t;
 #define   PCI_BRIDGE_CONTROL_SERR		(1 <<  1)
 #define   PCI_BRIDGE_CONTROL_ISA		(1 <<  2)
 #define   PCI_BRIDGE_CONTROL_VGA		(1 <<  3)
-/* Reserved	(1 <<  4) */
+#define   PCI_BRIDGE_CONTROL_VGA16		(1 <<  3)
 #define   PCI_BRIDGE_CONTROL_MABRT		(1 <<  5)
 #define   PCI_BRIDGE_CONTROL_SECBR		(1 <<  6)
 #define   PCI_BRIDGE_CONTROL_SECFASTB2B		(1 <<  7)

Index: src/sys/dev/pci/ppbreg.h
diff -u src/sys/dev/pci/ppbreg.h:1.7 src/sys/dev/pci/ppbreg.h:1.8
--- src/sys/dev/pci/ppbreg.h:1.7	Wed May 10 03:24:31 2017
+++ src/sys/dev/pci/ppbreg.h	Mon Dec 18 04:48:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ppbreg.h,v 1.7 2017/05/10 03:24:31 msaitoh Exp $	*/
+/*	$NetBSD: ppbreg.h,v 1.8 2017/12/18 04:48:28 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -100,6 +100,7 @@
 #define PPB_BC_SERR_ENABLE (1U << (1 + PPB_BC_BITBASE))
 #define PPB_BC_ISA_ENABLE  (1U << (2 + PPB_BC_BITBASE))
 #define PPB_BC_VGA_ENABLE  (1U << (3 + PPB_BC_BITBASE))
+#define PPB_BC_VGA16_ENABLE(1U << (3 + PPB_BC_BITBASE))
 #define PPB_BC_MASTER_ABORT_MODE   (1U << (5 + PPB_BC_BITBASE))
 #define PPB_BC_SECONDARY_RESET (1U << (6 + PPB_BC_BITBASE))
 #define	PPB_BC_FAST_B2B_ENABLE		   (1U << (7 + PPB_BC_BITBASE))



CVS commit: src/sys/dev/pci

2017-12-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  7 00:38:38 UTC 2017

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

Log Message:
 Fix a bug that 8257[56] can't receive packet reported by Bert Kiers in
PR#52717. For 82575 and 82576, the RX descriptors must be initialized after
the setting of RCTL.EN in wm_set_filter(). This bug was added in if_wm.c
rev. 1.515.


To generate a diff of this commit:
cvs rdiff -u -r1.547 -r1.548 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.



CVS commit: src/sys/dev/pci

2017-12-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  7 00:38:38 UTC 2017

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

Log Message:
 Fix a bug that 8257[56] can't receive packet reported by Bert Kiers in
PR#52717. For 82575 and 82576, the RX descriptors must be initialized after
the setting of RCTL.EN in wm_set_filter(). This bug was added in if_wm.c
rev. 1.515.


To generate a diff of this commit:
cvs rdiff -u -r1.547 -r1.548 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.547 src/sys/dev/pci/if_wm.c:1.548
--- src/sys/dev/pci/if_wm.c:1.547	Wed Dec  6 09:03:12 2017
+++ src/sys/dev/pci/if_wm.c	Thu Dec  7 00:38:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.547 2017/12/06 09:03:12 ozaki-r Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.548 2017/12/07 00:38:38 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.547 2017/12/06 09:03:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.548 2017/12/07 00:38:38 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -5814,6 +5814,14 @@ wm_init_locked(struct ifnet *ifp)
 		break;
 	}
 
+	/*
+	 * Set the receive filter.
+	 *
+	 * For 82575 and 82576, the RX descriptors must be initialized after
+	 * the setting of RCTL.EN in wm_set_filter()
+	 */
+	wm_set_filter(sc);
+
 	/* On 575 and later set RDT only if RX enabled */
 	if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
 		int qidx;
@@ -5828,9 +5836,6 @@ wm_init_locked(struct ifnet *ifp)
 		}
 	}
 
-	/* Set the receive filter. */
-	wm_set_filter(sc);
-
 	wm_unset_stopping_flags(sc);
 
 	/* Start the one second link check clock. */
@@ -6688,13 +6693,13 @@ wm_init_rx_buffer(struct wm_softc *sc, s
 return ENOMEM;
 			}
 		} else {
-			if ((sc->sc_flags & WM_F_NEWQUEUE) == 0)
-wm_init_rxdesc(rxq, i);
 			/*
-			 * For 82575 and newer device, the RX descriptors
-			 * must be initialized after the setting of RCTL.EN in
+			 * For 82575 and 82576, the RX descriptors must be
+			 * initialized after the setting of RCTL.EN in
 			 * wm_set_filter()
 			 */
+			if ((sc->sc_flags & WM_F_NEWQUEUE) == 0)
+wm_init_rxdesc(rxq, i);
 		}
 	}
 	rxq->rxq_ptr = 0;



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

2017-12-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec  6 04:08:50 UTC 2017

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h ixgbe_82598.c ixgbe_82598.h
ixgbe_82599.c ixgbe_82599.h ixgbe_api.c ixgbe_api.h ixgbe_common.c
ixgbe_common.h ixgbe_dcb.c ixgbe_dcb.h ixgbe_dcb_82598.c
ixgbe_dcb_82598.h ixgbe_dcb_82599.c ixgbe_dcb_82599.h ixgbe_mbx.c
ixgbe_mbx.h ixgbe_osdep.h ixgbe_phy.c ixgbe_phy.h ixgbe_rss.h
ixgbe_type.h ixgbe_vf.c ixgbe_vf.h ixgbe_x540.c ixgbe_x540.h ixv.c

Log Message:
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
  has no influence to netbsd because it's enabled by default and NetBSD has
  no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/ixgbe/ixgbe_82598.c \
src/sys/dev/pci/ixgbe/ixgbe_phy.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/ixgbe_82598.h \
src/sys/dev/pci/ixgbe/ixgbe_x540.h
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/ixgbe/ixgbe_82599.c \
src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/ixgbe_82599.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/ixgbe/ixgbe_api.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/ixgbe/ixgbe_api.h \
src/sys/dev/pci/ixgbe/ixgbe_vf.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/ixgbe/ixgbe_common.h \
src/sys/dev/pci/ixgbe/ixgbe_mbx.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/ixgbe/ixgbe_dcb.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/ixgbe/ixgbe_mbx.h \
src/sys/dev/pci/ixgbe/ixgbe_x540.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ixgbe/ixgbe_rss.h
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.74 -r1.75 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/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.114 src/sys/dev/pci/ixgbe/ixgbe.c:1.115
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.114	Fri Nov 24 08:36:22 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Dec  6 04:08:50 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.114 2017/11/24 08:36:22 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.115 2017/12/06 04:08:50 msaitoh Exp $ */
 
 /**
 
@@ -272,6 +272,9 @@ DRIVER_MODULE(ix, pci, ix_driver, ix_dev
 
 MODULE_DEPEND(ix, pci, 1, 1, 1);
 MODULE_DEPEND(ix, ether, 1, 1, 1);
+#ifdef DEV_NETMAP
+MODULE_DEPEND(ix, netmap, 1, 1, 1);
+#endif
 #endif
 
 /*
@@ -498,9 +501,6 @@ ixgbe_initialize_rss_mapping(struct adap
 		mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP;
 	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
 		mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP;
-	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4_EX)
-		device_printf(adapter->dev, "%s: RSS_HASHTYPE_RSS_UDP_IPV4_EX defined, but not supported\n",
-		__func__);
 	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
 		mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
 	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6_EX)
@@ -2185,15 +2185,17 @@ ixgbe_setup_vlan_hw_support(struct adapt
 		return;
 
 	/* Setup the queues for vlans */
-	for (i = 0; i < adapter->num_queues; i++) {
-		rxr = >rx_rings[i];
-		/* On 82599 the VLAN enable is per/queue in RXDCTL */
-		if (hw->mac.type != ixgbe_mac_82598EB) {
-			ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
-			ctrl |= IXGBE_RXDCTL_VME;
-			IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
+	if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) {
+		for (i = 0; i < adapter->num_queues; i++) {
+			rxr = >rx_rings[i];
+			/* On 82599 the VLAN enable is per/queue in RXDCTL */
+			if (hw->mac.type != ixgbe_mac_82598EB) {
+ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
+ctrl |= IXGBE_RXDCTL_VME;
+IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
+			}
+			rxr->vtag_strip = TRUE;
 		}
-		rxr->vtag_strip = TRUE;
 	}
 
 	if ((ec->ec_capenable & ETHERCAP_VLAN_HWFILTER) == 0)

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.28 src/sys/dev/pci/ixgbe/ixgbe.h:1.29
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.28	Wed Nov 22 15:15:09 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Wed Dec  6 04:08:50 2017
@@ -1,6 +1,7 @@
-/* $NetBSD: ixgbe.h,v 1.28 

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

2017-12-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec  6 04:08:50 UTC 2017

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h ixgbe_82598.c ixgbe_82598.h
ixgbe_82599.c ixgbe_82599.h ixgbe_api.c ixgbe_api.h ixgbe_common.c
ixgbe_common.h ixgbe_dcb.c ixgbe_dcb.h ixgbe_dcb_82598.c
ixgbe_dcb_82598.h ixgbe_dcb_82599.c ixgbe_dcb_82599.h ixgbe_mbx.c
ixgbe_mbx.h ixgbe_osdep.h ixgbe_phy.c ixgbe_phy.h ixgbe_rss.h
ixgbe_type.h ixgbe_vf.c ixgbe_vf.h ixgbe_x540.c ixgbe_x540.h ixv.c

Log Message:
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
  has no influence to netbsd because it's enabled by default and NetBSD has
  no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/ixgbe/ixgbe_82598.c \
src/sys/dev/pci/ixgbe/ixgbe_phy.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/ixgbe_82598.h \
src/sys/dev/pci/ixgbe/ixgbe_x540.h
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/ixgbe/ixgbe_82599.c \
src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/ixgbe_82599.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/ixgbe/ixgbe_api.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/ixgbe/ixgbe_api.h \
src/sys/dev/pci/ixgbe/ixgbe_vf.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/ixgbe/ixgbe_common.h \
src/sys/dev/pci/ixgbe/ixgbe_mbx.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/ixgbe/ixgbe_dcb.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/ixgbe/ixgbe_mbx.h \
src/sys/dev/pci/ixgbe/ixgbe_x540.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ixgbe/ixgbe_rss.h
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.74 -r1.75 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.



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

2017-12-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec  4 09:29:42 UTC 2017

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

Log Message:
- Fixes two problem:
  1) RX may accesses freed area.
  2) if_init() takes long time on many core machine.
  Call ixgbe_jcl_reinit() not in ixgbe_setup_receive_ring() but in the
  biginning of ixgbe_setup_receive_structures(). It was OK for pre multiqueue,
  but it's not OK now because we support multiqueue.
- Fix comment of ixgbe_free_receive_ring().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/ixgbe/ix_txrx.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/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.29 src/sys/dev/pci/ixgbe/ix_txrx.c:1.30
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.29	Tue Sep 26 07:42:06 2017
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Mon Dec  4 09:29:42 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.29 2017/09/26 07:42:06 knakahara Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.30 2017/12/04 09:29:42 msaitoh Exp $ */
 
 /**
 
@@ -1355,9 +1355,7 @@ fail:
 } /* ixgbe_allocate_receive_buffers */
 
 /
- * ixgbe_setup_receive_ring
- *
- *   Initialize a receive ring and its buffers.
+ * ixgbe_free_receive_ring
  /
 static void
 ixgbe_free_receive_ring(struct rx_ring *rxr)
@@ -1409,17 +1407,6 @@ ixgbe_setup_receive_ring(struct rx_ring 
 	/* Free current RX buffer structs and their mbufs */
 	ixgbe_free_receive_ring(rxr);
 
-	IXGBE_RX_UNLOCK(rxr);
-
-	/* Now reinitialize our supply of jumbo mbufs.  The number
-	 * or size of jumbo mbufs may have changed.
-	 */
-	ixgbe_jcl_reinit(>jcl_head, rxr->ptag->dt_dmat,
-	(2 * adapter->num_rx_desc) * adapter->num_queues,
-	adapter->rx_mbuf_sz);
-
-	IXGBE_RX_LOCK(rxr);
-
 	/* Now replenish the mbufs */
 	for (int j = 0; j != rxr->num_desc; ++j) {
 		struct mbuf *mp;
@@ -1526,6 +1513,15 @@ ixgbe_setup_receive_structures(struct ad
 	struct rx_ring *rxr = adapter->rx_rings;
 	intj;
 
+	/*
+	 * Now reinitialize our supply of jumbo mbufs.  The number
+	 * or size of jumbo mbufs may have changed.
+	 * Assume all of rxr->ptag are the same.
+	 */
+	ixgbe_jcl_reinit(>jcl_head, rxr->ptag->dt_dmat,
+	(2 * adapter->num_rx_desc) * adapter->num_queues,
+	adapter->rx_mbuf_sz);
+
 	for (j = 0; j < adapter->num_queues; j++, rxr++)
 		if (ixgbe_setup_receive_ring(rxr))
 			goto fail;



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

2017-12-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec  4 09:29:42 UTC 2017

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

Log Message:
- Fixes two problem:
  1) RX may accesses freed area.
  2) if_init() takes long time on many core machine.
  Call ixgbe_jcl_reinit() not in ixgbe_setup_receive_ring() but in the
  biginning of ixgbe_setup_receive_structures(). It was OK for pre multiqueue,
  but it's not OK now because we support multiqueue.
- Fix comment of ixgbe_free_receive_ring().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/ixgbe/ix_txrx.c

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



CVS commit: src/sys/dev/pci

2017-12-03 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Dec  3 14:26:38 UTC 2017

Modified Files:
src/sys/dev/pci: files.pci
Added Files:
src/sys/dev/pci: ips.c

Log Message:
port ips(4) driver from OpenBSD; needs a lot more work, right now just 
compilable


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/sys/dev/pci/files.pci
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/ips.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/files.pci
diff -u src/sys/dev/pci/files.pci:1.391 src/sys/dev/pci/files.pci:1.392
--- src/sys/dev/pci/files.pci:1.391	Tue Sep  5 08:01:43 2017
+++ src/sys/dev/pci/files.pci	Sun Dec  3 14:26:38 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.391 2017/09/05 08:01:43 skrll Exp $
+#	$NetBSD: files.pci,v 1.392 2017/12/03 14:26:38 jdolecek Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -107,6 +107,11 @@ file	dev/pci/icp_pci.c		icp_pci
 attach	aac at pci with aac_pci
 file	dev/pci/aac_pci.c		aac_pci
 
+# IBM ServeRAID RAID controllers
+device  ips: scsi
+attach  ips at pci
+filedev/pci/ips.c   ips
+
 # DPT EATA SCSI controllers
 attach	dpt at pci with dpt_pci
 file	dev/pci/dpt_pci.c		dpt_pci

Added files:

Index: src/sys/dev/pci/ips.c
diff -u /dev/null src/sys/dev/pci/ips.c:1.1
--- /dev/null	Sun Dec  3 14:26:38 2017
+++ src/sys/dev/pci/ips.c	Sun Dec  3 14:26:38 2017
@@ -0,0 +1,2013 @@
+/*	$NetBSD: ips.c,v 1.1 2017/12/03 14:26:38 jdolecek Exp $	*/
+/*	$OpenBSD: ips.c,v 1.113 2016/08/14 04:08:03 dlg Exp $	*/
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 2006, 2007, 2009 Alexander Yurchenko 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * IBM (Adaptec) ServeRAID controllers driver.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: ips.c,v 1.1 2017/12/03 14:26:38 jdolecek Exp $");
+
+#include "bio.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/* Debug levels */
+#define IPS_D_ERR	0x0001	/* errors */
+#define IPS_D_INFO	0x0002	/* information */
+#define IPS_D_XFER	0x0004	/* transfers */
+
+#ifdef IPS_DEBUG
+#define DPRINTF(a, b)	do { if (ips_debug & (a)) printf b; } while (0)
+int ips_debug = IPS_D_ERR;
+#else
+#define DPRINTF(a, b)
+#endif
+
+#define IPS_MAXDRIVES		8
+#define IPS_MAXCHANS		4
+#define IPS_MAXTARGETS		16
+#define IPS_MAXCHUNKS		16
+#define IPS_MAXCMDS		128
+
+#define IPS_MAXFER		(64 * 1024)
+#define IPS_MAXSGS		16
+#define IPS_MAXCDB		12
+
+#define IPS_SECSZ		512
+#define IPS_NVRAMPGSZ		128
+#define IPS_SQSZ		

CVS commit: src/sys/dev/pci

2017-12-03 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Dec  3 14:26:38 UTC 2017

Modified Files:
src/sys/dev/pci: files.pci
Added Files:
src/sys/dev/pci: ips.c

Log Message:
port ips(4) driver from OpenBSD; needs a lot more work, right now just 
compilable


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/sys/dev/pci/files.pci
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/ips.c

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



CVS commit: src/sys/dev/pci

2017-11-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 30 09:24:18 UTC 2017

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

Log Message:
- 82583 supports jumbo frame. Fixes PR#52773 reported by Shinichi Doyashiki.
- Cleanup comment.


To generate a diff of this commit:
cvs rdiff -u -r1.545 -r1.546 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.



CVS commit: src/sys/dev/pci

2017-11-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 30 09:24:18 UTC 2017

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

Log Message:
- 82583 supports jumbo frame. Fixes PR#52773 reported by Shinichi Doyashiki.
- Cleanup comment.


To generate a diff of this commit:
cvs rdiff -u -r1.545 -r1.546 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.545 src/sys/dev/pci/if_wm.c:1.546
--- src/sys/dev/pci/if_wm.c:1.545	Thu Nov 30 03:53:24 2017
+++ src/sys/dev/pci/if_wm.c	Thu Nov 30 09:24:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.545 2017/11/30 03:53:24 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.546 2017/11/30 09:24:18 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.545 2017/11/30 03:53:24 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.546 2017/11/30 09:24:18 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2676,11 +2676,12 @@ alloc_retry:
 	case WM_T_82571:
 	case WM_T_82572:
 	case WM_T_82574:
+	case WM_T_82583:
 	case WM_T_82575:
 	case WM_T_82576:
 	case WM_T_82580:
 	case WM_T_I350:
-	case WM_T_I354: /*  ok? */
+	case WM_T_I354:
 	case WM_T_I210:
 	case WM_T_I211:
 	case WM_T_80003:
@@ -2698,7 +2699,6 @@ alloc_retry:
 		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;



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

2017-11-30 Thread Masanobu SAITOH

On 2017/11/30 12:53, SAITOH Masanobu wrote:

Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 30 03:53:24 UTC 2017

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

Log Message:
  Don't allocate MSI-X interrupt on 82583. 82583 chip has a MSI-X capability in
the PCI configuration space but it doesn't support it. At least the document
doesn't say anything about MSI-X. Fixes PR#57262 reported by


s/57262/52767/


Shinichi Doyashiki.

XXX pullup-8.


To generate a diff of this commit:
cvs rdiff -u -r1.544 -r1.545 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.




--
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


CVS commit: src/sys/dev/pci

2017-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 30 03:53:24 UTC 2017

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

Log Message:
 Don't allocate MSI-X interrupt on 82583. 82583 chip has a MSI-X capability in
the PCI configuration space but it doesn't support it. At least the document
doesn't say anything about MSI-X. Fixes PR#57262 reported by
Shinichi Doyashiki.

XXX pullup-8.


To generate a diff of this commit:
cvs rdiff -u -r1.544 -r1.545 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.544 src/sys/dev/pci/if_wm.c:1.545
--- src/sys/dev/pci/if_wm.c:1.544	Wed Nov 22 02:36:52 2017
+++ src/sys/dev/pci/if_wm.c	Thu Nov 30 03:53:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.544 2017/11/22 02:36:52 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.545 2017/11/30 03:53:24 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.544 2017/11/22 02:36:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.545 2017/11/30 03:53:24 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1853,7 +1853,13 @@ wm_attach(device_t parent, device_t self
 
 	/* Allocation settings */
 	max_type = PCI_INTR_TYPE_MSIX;
-	counts[PCI_INTR_TYPE_MSIX] = sc->sc_nqueues + 1;
+	/*
+	 * 82583 has a MSI-X capability in the PCI configuration space but
+	 * it doesn't support it. At least the document doesn't say anything
+	 * about MSI-X.
+	 */
+	counts[PCI_INTR_TYPE_MSIX]
+	= (sc->sc_type == WM_T_82583) ? 0 : sc->sc_nqueues + 1;
 	counts[PCI_INTR_TYPE_MSI] = 1;
 	counts[PCI_INTR_TYPE_INTX] = 1;
 	/* overridden by disable flags */



CVS commit: src/sys/dev/pci

2017-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov 30 03:53:24 UTC 2017

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

Log Message:
 Don't allocate MSI-X interrupt on 82583. 82583 chip has a MSI-X capability in
the PCI configuration space but it doesn't support it. At least the document
doesn't say anything about MSI-X. Fixes PR#57262 reported by
Shinichi Doyashiki.

XXX pullup-8.


To generate a diff of this commit:
cvs rdiff -u -r1.544 -r1.545 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.



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

2017-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 24 08:36:22 UTC 2017

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

Log Message:
 On X540, print PHY FW Revision with %u.%x. 0x04000300 will be printed
as "Revision 4.3 ID 0x0"


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 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.



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

2017-11-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 24 08:36:22 UTC 2017

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

Log Message:
 On X540, print PHY FW Revision with %u.%x. 0x04000300 will be printed
as "Revision 4.3 ID 0x0"


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 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.113 src/sys/dev/pci/ixgbe/ixgbe.c:1.114
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.113	Wed Nov 22 15:15:09 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Nov 24 08:36:22 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.113 2017/11/22 15:15:09 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.114 2017/11/24 08:36:22 msaitoh Exp $ */
 
 /**
 
@@ -1003,8 +1003,13 @@ ixgbe_attach(device_t parent, device_t d
 		high = (nvmreg >> 12) & 0x0f;
 		low = (nvmreg >> 4) & 0xff;
 		id = nvmreg & 0x000f;
-		aprint_normal(" PHY FW Revision %u.%02x ID 0x%x,", high, low,
-		id);
+		aprint_normal(" PHY FW Revision %u.", high);
+		if (hw->mac.type == ixgbe_mac_X540)
+			str = "%x";
+		else
+			str = "%02x";
+		aprint_normal(str, low);
+		aprint_normal(" ID 0x%x,", id);
 		break;
 	default:
 		break;



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

2017-11-23 Thread Masanobu SAITOH

On 2017/11/23 0:15, SAITOH Masanobu wrote:

Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 22 15:15:09 UTC 2017

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

Log Message:
Fix a bug that bypass adapter's sysctls aren't set. Tested with non-genuine
X550-T2 bypass adapter:


 s/X550/X540/


- Call ixgbe_sysctl_instance() in ixgbe_bypass_init() to get sysctl's top node
   correctly.
- ixgbe_init_device_features() refers adapter->hw.bus.func for bypass adapter.
   Call set_lan_id() to set adapter->hw.bus.func before calling
   ixgbe_init_device_features(). Without this, bypass sysctl's are added to
   both the first and second port.
- Initalize node.sysctl_data before calling sysctl_lookup() to read correct
   value.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ixgbe/if_bypass.c
cvs rdiff -u -r1.112 -r1.113 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.27 -r1.28 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.




--
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


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

2017-11-22 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 22 15:15:09 UTC 2017

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

Log Message:
Fix a bug that bypass adapter's sysctls aren't set. Tested with non-genuine
X550-T2 bypass adapter:
- Call ixgbe_sysctl_instance() in ixgbe_bypass_init() to get sysctl's top node
  correctly.
- ixgbe_init_device_features() refers adapter->hw.bus.func for bypass adapter.
  Call set_lan_id() to set adapter->hw.bus.func before calling
  ixgbe_init_device_features(). Without this, bypass sysctl's are added to
  both the first and second port.
- Initalize node.sysctl_data before calling sysctl_lookup() to read correct
  value.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ixgbe/if_bypass.c
cvs rdiff -u -r1.112 -r1.113 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.27 -r1.28 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/if_bypass.c
diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.1 src/sys/dev/pci/ixgbe/if_bypass.c:1.2
--- src/sys/dev/pci/ixgbe/if_bypass.c:1.1	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/if_bypass.c	Wed Nov 22 15:15:09 2017
@@ -134,6 +134,7 @@ ixgbe_bp_version(SYSCTLFN_ARGS)
 		goto err;
 	ixgbe_bypass_mutex_clear(adapter);
 	featversion &= BYPASS_CTL2_DATA_M;
+	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	return (error);
 err:
@@ -171,6 +172,7 @@ ixgbe_bp_set_state(SYSCTLFN_ARGS)
 		return (error);
 	state = (state >> BYPASS_STATUS_OFF_SHIFT) & 0x3;
 
+	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -233,6 +235,7 @@ ixgbe_bp_timeout(SYSCTLFN_ARGS)
 		return (error);
 	timeout = (timeout >> BYPASS_WDTIMEOUT_SHIFT) & 0x3;
 
+	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -276,6 +279,7 @@ ixgbe_bp_main_on(SYSCTLFN_ARGS)
 	if (error)
 		return (error);
 
+	node.sysctl_data = _on;
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -319,6 +323,7 @@ ixgbe_bp_main_off(SYSCTLFN_ARGS)
 		return (error);
 	main_off = (main_off >> BYPASS_MAIN_OFF_SHIFT) & 0x3;
 
+	node.sysctl_data = _off;
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -362,6 +367,7 @@ ixgbe_bp_aux_on(SYSCTLFN_ARGS)
 		return (error);
 	aux_on = (aux_on >> BYPASS_AUX_ON_SHIFT) & 0x3;
 
+	node.sysctl_data = _on;
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -405,6 +411,7 @@ ixgbe_bp_aux_off(SYSCTLFN_ARGS)
 		return (error);
 	aux_off = (aux_off >> BYPASS_AUX_OFF_SHIFT) & 0x3;
 
+	node.sysctl_data = _off;
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -460,6 +467,7 @@ ixgbe_bp_wd_set(SYSCTLFN_ARGS)
 	if ((tmp & (0x1 << BYPASS_WDT_ENABLE_SHIFT)) == 0)
 		timeout = 0;
 
+	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -529,6 +537,7 @@ ixgbe_bp_wd_reset(SYSCTLFN_ARGS)
 	int cmd, count = 0, error = 0;
 	int reset_wd = 0;
 
+	node.sysctl_data = _wd;
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -579,6 +588,7 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
 	struct ixgbe_bypass_eeprom eeprom[BYPASS_MAX_LOGS];
 	inti, error = 0;
 
+	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if ((error) || (newp == NULL))
 		return (error);
@@ -759,7 +769,7 @@ ixgbe_bypass_init(struct adapter *adapte
 
 	/* Now set up the SYSCTL infrastructure */
 	log = >sysctllog;
-	if ((rnode = adapter->sysctltop) == NULL) {
+	if ((rnode = ixgbe_sysctl_instance(adapter)) == NULL) {
 		aprint_error_dev(dev, "could not create sysctl root\n");
 		return;
 	}

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.112 src/sys/dev/pci/ixgbe/ixgbe.c:1.113
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.112	Thu Nov 16 03:07:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Nov 22 15:15:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.112 2017/11/16 03:07:18 ozaki-r Exp $ */
+/* $NetBSD: ixgbe.c,v 1.113 2017/11/22 15:15:09 msaitoh Exp $ */
 
 /**
 
@@ -257,7 +257,6 @@ static void	ixgbe_handle_msf(void *);
 static void	ixgbe_handle_mod(void *);
 static void	ixgbe_handle_phy(void *);
 
-const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
 static ixgbe_vendor_info_t *ixgbe_lookup(const struct pci_attach_args *);
 
 /
@@ -853,6 +852,7 @@ ixgbe_attach(device_t parent, device_t d
 	} else
 		adapter->num_segs = IXGBE_82598_SCATTER;
 
+	

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

2017-11-22 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 22 15:15:09 UTC 2017

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

Log Message:
Fix a bug that bypass adapter's sysctls aren't set. Tested with non-genuine
X550-T2 bypass adapter:
- Call ixgbe_sysctl_instance() in ixgbe_bypass_init() to get sysctl's top node
  correctly.
- ixgbe_init_device_features() refers adapter->hw.bus.func for bypass adapter.
  Call set_lan_id() to set adapter->hw.bus.func before calling
  ixgbe_init_device_features(). Without this, bypass sysctl's are added to
  both the first and second port.
- Initalize node.sysctl_data before calling sysctl_lookup() to read correct
  value.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ixgbe/if_bypass.c
cvs rdiff -u -r1.112 -r1.113 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.27 -r1.28 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.



CVS commit: src/sys/dev/pci

2017-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 22 02:36:52 UTC 2017

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

Log Message:
 Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.


To generate a diff of this commit:
cvs rdiff -u -r1.543 -r1.544 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.104 -r1.105 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.543 src/sys/dev/pci/if_wm.c:1.544
--- src/sys/dev/pci/if_wm.c:1.543	Thu Nov 16 03:07:18 2017
+++ src/sys/dev/pci/if_wm.c	Wed Nov 22 02:36:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.543 2017/11/16 03:07:18 ozaki-r Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.544 2017/11/22 02:36:52 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.543 2017/11/16 03:07:18 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.544 2017/11/22 02:36:52 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -8108,11 +8108,11 @@ wm_rxdesc_get_vlantag(struct wm_rxqueue 
 	struct wm_softc *sc = rxq->rxq_sc;
 
 	if (sc->sc_type == WM_T_82574)
-		return EXTRXC_VLAN_ID(rxq->rxq_ext_descs[idx].erx_ctx.erxc_vlan);
+		return rxq->rxq_ext_descs[idx].erx_ctx.erxc_vlan;
 	else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
-		return NQRXC_VLAN_ID(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_vlan);
+		return rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_vlan;
 	else
-		return WRX_VLAN_ID(rxq->rxq_descs[idx].wrx_special);
+		return rxq->rxq_descs[idx].wrx_special;
 }
 
 static inline int

Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.104 src/sys/dev/pci/if_wmreg.h:1.105
--- src/sys/dev/pci/if_wmreg.h:1.104	Mon Oct 23 23:29:38 2017
+++ src/sys/dev/pci/if_wmreg.h	Wed Nov 22 02:36:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.104 2017/10/23 23:29:38 knakahara Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.105 2017/11/22 02:36:52 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -208,12 +208,6 @@ typedef union ext_rxdesc {
 #define EXTRXC_STATUS_PKTTYPE_MASK	__BITS(19,16)
 #define EXTRXC_STATUS_PKTTYPE(status)	__SHIFTOUT(status,EXTRXC_STATUS_PKTTYPE_MASK)
 
-#define	EXTRXC_VLAN_ID_MASK	__BITS(11,0)	/* VLAN identifier mask */
-#define	EXTRXC_VLAN_ID(x)	((x) & EXTRXC_VLAN_ID_MASK) /* VLAN identifier */
-#define	EXTRXC_VLAN_CFI		__BIT(12)	/* Canonical Form Indicator */
-#define	EXTRXC_VLAN_PRI_MASK	__BITS(15,13)	/* VLAN priority mask */
-#define	EXTRXC_VLAN_PRI(x)	__SHIFTOUT((x),EXTRXC_VLAN_PRI_MASK) /* VLAN priority */
-
 /* advanced RX descriptor for 82575 and newer */
 typedef union nq_rxdesc {
 	struct {
@@ -336,12 +330,6 @@ typedef union nq_rxdesc {
 #define NQRXC_STATUS_MC		__BIT(19) /* Packet received from Manageability Controller */
 	  /* "MBC" in i350 spec */
 
-#define	NQRXC_VLAN_ID_MASK	__BITS(11,0)	/* VLAN identifier mask */
-#define	NQRXC_VLAN_ID(x)	((x) & NQRXC_VLAN_ID_MASK) /* VLAN identifier */
-#define	NQRXC_VLAN_CFI		__BIT(12)	/* Canonical Form Indicator */
-#define	NQRXC_VLAN_PRI_MASK	__BITS(15,13)	/* VLAN priority mask */
-#define	NQRXC_VLAN_PRI(x)	__SHIFTOUT((x),NQRXC_VLAN_PRI_MASK) /* VLAN priority */
-
 /*
  * The Wiseman transmit descriptor.
  *



CVS commit: src/sys/dev/pci

2017-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 22 02:36:52 UTC 2017

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

Log Message:
 Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.


To generate a diff of this commit:
cvs rdiff -u -r1.543 -r1.544 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.104 -r1.105 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.



CVS commit: src/sys/dev/pci

2017-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 22 02:35:54 UTC 2017

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

Log Message:
 Revert part of if_bge.c 1.312. It's not reqired to mask other than VLAN ID
bits in VLAN tag.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 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.312 src/sys/dev/pci/if_bge.c:1.313
--- src/sys/dev/pci/if_bge.c:1.312	Thu Sep 28 16:24:39 2017
+++ src/sys/dev/pci/if_bge.c	Wed Nov 22 02:35:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.312 2017/09/28 16:24:39 christos Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.313 2017/11/22 02:35:54 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.312 2017/09/28 16:24:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.313 2017/11/22 02:35:54 msaitoh Exp $");
 
 #include 
 #include 
@@ -4607,7 +4607,7 @@ bge_rxeof(struct bge_softc *sc)
 		 * to vlan_input() instead of ether_input().
 		 */
 		if (cur_rx->bge_flags & BGE_RXBDFLAG_VLAN_TAG) {
-			vlan_set_tag(m, cur_rx->bge_vlan_tag & ETHER_VLAN_MASK);
+			vlan_set_tag(m, cur_rx->bge_vlan_tag);
 		}
 
 		if_percpuq_enqueue(ifp->if_percpuq, m);



CVS commit: src/sys/dev/pci

2017-11-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 22 02:35:54 UTC 2017

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

Log Message:
 Revert part of if_bge.c 1.312. It's not reqired to mask other than VLAN ID
bits in VLAN tag.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 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.



CVS commit: src/sys/dev/pci

2017-11-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 21 10:55:23 UTC 2017

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

Log Message:
Mmh, surprising bug. It's __packed, not __packed__. Here the structure is
not packed for real, but instead a global __packed__ symbol is declared.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/mlyreg.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/mlyreg.h
diff -u src/sys/dev/pci/mlyreg.h:1.5 src/sys/dev/pci/mlyreg.h:1.6
--- src/sys/dev/pci/mlyreg.h:1.5	Mon Sep  8 23:36:54 2008
+++ src/sys/dev/pci/mlyreg.h	Tue Nov 21 10:55:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mlyreg.h,v 1.5 2008/09/08 23:36:54 gmcgarry Exp $	*/
+/*	$NetBSD: mlyreg.h,v 1.6 2017/11/21 10:55:23 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -286,7 +286,7 @@ struct mly_param_controller {
 #define	MLY_STARTUP_ALWAYS		0x5
 
 	u_int8_t	res15[62];
-} __packed__;
+} __packed;
 
 /*
  * 10.2 Physical Device Parameters



CVS commit: src/sys/dev/pci

2017-11-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 21 10:55:23 UTC 2017

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

Log Message:
Mmh, surprising bug. It's __packed, not __packed__. Here the structure is
not packed for real, but instead a global __packed__ symbol is declared.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/mlyreg.h

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



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

2017-11-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Nov 12 05:11:36 UTC 2017

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

Log Message:
 Remove obsoleted comment. This comment should have been removed in rev. 1.97.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 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.110 src/sys/dev/pci/ixgbe/ixgbe.c:1.111
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.110	Thu Nov  9 09:33:28 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sun Nov 12 05:11:36 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.110 2017/11/09 09:33:28 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.111 2017/11/12 05:11:36 msaitoh Exp $ */
 
 /**
 
@@ -5976,7 +5976,6 @@ ixgbe_configure_interrupts(struct adapte
 
 	if (ixgbe_num_queues != 0)
 		queues = ixgbe_num_queues;
-	/* Set max queues to 8 when autoconfiguring */
 	else
 		queues = min(queues,
 		min(mac->max_tx_queues, mac->max_rx_queues));



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

2017-11-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Nov 12 05:11:36 UTC 2017

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

Log Message:
 Remove obsoleted comment. This comment should have been removed in rev. 1.97.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 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.



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

2017-11-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  9 09:33:28 UTC 2017

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

Log Message:
 On device which has SFP(+) cage and a module is inserted, hw->phy.id is not
MII PHY id but SFF 8024 ID. So checking hw->phy.id with 0 doesn't work.
Print PHY ID only for copper PHY.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 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.109 src/sys/dev/pci/ixgbe/ixgbe.c:1.110
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.109	Thu Nov  2 08:41:15 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Nov  9 09:33:28 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.109 2017/11/02 08:41:15 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.110 2017/11/09 09:33:28 msaitoh Exp $ */
 
 /**
 
@@ -1069,7 +1069,11 @@ ixgbe_attach(device_t parent, device_t d
 		break;
 	}
 
-	if (hw->phy.id != 0) {
+	/*
+	 *  Print PHY ID only for copper PHY. On device which has SFP(+) cage
+	 * and a module is inserted, phy.id is not MII PHY id but SFF 8024 ID.
+	 */
+	if (hw->phy.media_type == ixgbe_media_type_copper) {
 		uint16_t id1, id2;
 		int oui, model, rev;
 		const char *descr;



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

2017-11-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  9 09:33:28 UTC 2017

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

Log Message:
 On device which has SFP(+) cage and a module is inserted, hw->phy.id is not
MII PHY id but SFF 8024 ID. So checking hw->phy.id with 0 doesn't work.
Print PHY ID only for copper PHY.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 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.



CVS commit: src/sys/dev/pci

2017-11-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  9 03:08:13 UTC 2017

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.1293 -r1.1294 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1292 -r1.1293 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.



CVS commit: src/sys/dev/pci

2017-11-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  9 03:07:10 UTC 2017

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

Log Message:
 Add PEX 8605 4port 4lane PCIe Gen 2 switch.


To generate a diff of this commit:
cvs rdiff -u -r1.1300 -r1.1301 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.1300 src/sys/dev/pci/pcidevs:1.1301
--- src/sys/dev/pci/pcidevs:1.1300	Mon Oct 30 01:24:47 2017
+++ src/sys/dev/pci/pcidevs	Thu Nov  9 03:07:10 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1300 2017/10/30 01:24:47 sevan Exp $
+$NetBSD: pcidevs,v 1.1301 2017/11/09 03:07:10 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -5804,6 +5804,7 @@ product PLX 9656FPBGA	0x5601	9656 I/O Ac
 product PLX PEX_8111	0x8111	PEX 8111 PCIe-to-PCI Bridge
 product PLX PEX_8112	0x8112	PEX 8112 PCIe-to-PCI Bridge
 product PLX PEX_8114	0x8114	PEX 8114 PCIe-to-PCI/PCI-X Bridge
+product PLX PEX_8605	0x8605	PEX 8605 4port 4lane PCIe Gen 2 switch
 product PLX 9030	0x9030	9030 I/O Accelrator
 product PLX 9050	0x9050	9050 I/O Accelrator
 product PLX 9054	0x9054	9054 I/O Accelerator



CVS commit: src/sys/dev/pci

2017-11-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  9 03:07:10 UTC 2017

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

Log Message:
 Add PEX 8605 4port 4lane PCIe Gen 2 switch.


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

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



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

2017-11-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov  8 08:41:13 UTC 2017

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

Log Message:
 Fix a bug that Denverton which uses firmware don't linkup if the media is
forced to 100baseTX-FDX or 10baseT-FDX. As I wrote in ixgbe_phy.c rev. 1.13,
popular switches and OSes don't use auto-negotiation if the media is forced to
100BASE-TX or 10BASE-T. Do the same thing. But, if we don't set
FW_PHY_ACT_SETUP_LINK_AN in ixgbe_setup_fw_link(), the firmware wrongly set
BMCR register. Two problems are observed:

a) FDX may not be set.
b) BMCR_SPEED1 (bit 6) is always cleard.

+ ---+--+---+-+
|request | BMCR | BMCR spd | BMCR |
|| (HEX)| (in bits)|  FDX |
++--+--+--+
|   10M  |  |  10M(00) |0 |
|   10M  | 2100 | 100M(01) |1 |
|  100M  |  |  10M(00) |0 |
|  100M  | 0100 |  10M(00) |1 |
+--+--+

 To avoid this problem, after sending request to firmware, check BMCR register
and fix the setting if it's required.

 Before this change:

+--+-+
|  |denverton|
|  +-++-++
|  |   auto  | 1G FDX | 100 FDX | 10 FDX |
+-++-++-++
| |   auto |  1G FDX | 1G FDX | 100 FDX | 10FDX/down(NG) |
| ++-++-++
| | 1G FDX |  1G FDX | 1G FDX |down |   down |
| link++-++-++
| partner |100 FDX | down(*1)|   down | down(NG)|   down |
| ++-++-++
| | 10 FDX | down(*1)|   down |down |   down(NG) |
+-++-++-++
(Observed on: NVM Image Version 0.05 ID 0x8, NVM Map version 1.16,
OEM NVM Image version 0.06, ETrackID 887c)

 After this change:

+--+-+
|  |denverton|
|  +-++-++
|  |   auto  | 1G FDX | 100 FDX | 10 FDX |
+-++-++-++
| |   auto |  1G FDX | 1G FDX | 100 FDX | 10 FDX |
| ++-++-++
| | 1G FDX |  1G FDX | 1G FDX |down |   down |
| link++-++-++
| partner |100 FDX | down(*1)|   down | 100 FDX |   down |
| ++-++-++
| | 10 FDX | down(*1)|   down |down | 10 FDX |
+-++-++-++
*1): may be correct because ixg doesn't support half duplex.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/ixgbe_x550.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_x550.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.6 src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.7
--- src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.6	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_x550.c	Wed Nov  8 08:41:13 2017
@@ -38,6 +38,7 @@
 #include "ixgbe_api.h"
 #include "ixgbe_common.h"
 #include "ixgbe_phy.h"
+#include 
 
 static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
 static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
@@ -788,6 +789,8 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_h
 	return ret_val;
 }
 
+#define IXGBE_DENVERTON_WA 1
+
 /**
  * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
  * @hw: pointer to hardware structure
@@ -796,6 +799,10 @@ static s32 ixgbe_setup_fw_link(struct ix
 {
 	u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
 	s32 rc;
+#ifdef IXGBE_DENVERTON_WA
+	s32 ret_val;
+	u16 phydata;
+#endif
 	u16 i;
 
 	if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
@@ -833,9 +840,67 @@ static s32 ixgbe_setup_fw_link(struct ix
 	if (hw->phy.eee_speeds_advertised)
 		setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
 
+#ifdef IXGBE_DENVERTON_WA
+	/* Don't use auto-nego for 10/100Mbps */
+	if ((hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_100_FULL)
+	|| (hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_10_FULL)) {
+		setup[0] &= ~FW_PHY_ACT_SETUP_LINK_AN;
+		setup[0] &= 

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

2017-11-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov  8 08:41:13 UTC 2017

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

Log Message:
 Fix a bug that Denverton which uses firmware don't linkup if the media is
forced to 100baseTX-FDX or 10baseT-FDX. As I wrote in ixgbe_phy.c rev. 1.13,
popular switches and OSes don't use auto-negotiation if the media is forced to
100BASE-TX or 10BASE-T. Do the same thing. But, if we don't set
FW_PHY_ACT_SETUP_LINK_AN in ixgbe_setup_fw_link(), the firmware wrongly set
BMCR register. Two problems are observed:

a) FDX may not be set.
b) BMCR_SPEED1 (bit 6) is always cleard.

+ ---+--+---+-+
|request | BMCR | BMCR spd | BMCR |
|| (HEX)| (in bits)|  FDX |
++--+--+--+
|   10M  |  |  10M(00) |0 |
|   10M  | 2100 | 100M(01) |1 |
|  100M  |  |  10M(00) |0 |
|  100M  | 0100 |  10M(00) |1 |
+--+--+

 To avoid this problem, after sending request to firmware, check BMCR register
and fix the setting if it's required.

 Before this change:

+--+-+
|  |denverton|
|  +-++-++
|  |   auto  | 1G FDX | 100 FDX | 10 FDX |
+-++-++-++
| |   auto |  1G FDX | 1G FDX | 100 FDX | 10FDX/down(NG) |
| ++-++-++
| | 1G FDX |  1G FDX | 1G FDX |down |   down |
| link++-++-++
| partner |100 FDX | down(*1)|   down | down(NG)|   down |
| ++-++-++
| | 10 FDX | down(*1)|   down |down |   down(NG) |
+-++-++-++
(Observed on: NVM Image Version 0.05 ID 0x8, NVM Map version 1.16,
OEM NVM Image version 0.06, ETrackID 887c)

 After this change:

+--+-+
|  |denverton|
|  +-++-++
|  |   auto  | 1G FDX | 100 FDX | 10 FDX |
+-++-++-++
| |   auto |  1G FDX | 1G FDX | 100 FDX | 10 FDX |
| ++-++-++
| | 1G FDX |  1G FDX | 1G FDX |down |   down |
| link++-++-++
| partner |100 FDX | down(*1)|   down | 100 FDX |   down |
| ++-++-++
| | 10 FDX | down(*1)|   down |down | 10 FDX |
+-++-++-++
*1): may be correct because ixg doesn't support half duplex.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/ixgbe_x550.c

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



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

2017-11-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Nov  7 05:41:54 UTC 2017

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

Log Message:
 Fix a bug that X550T(1) didn't linkup if it forces 100BaseTX-FDX.
Popular switches and OSes don't use auto-negotiation if the media is
100BASE-TX (and 10BASE-T). Do the same thig.

 Another fix is required for Denverton's _T device which use firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/ixgbe/ixgbe_phy.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_phy.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.12 src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.13
--- src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.12	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_phy.c	Tue Nov  7 05:41:54 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_phy.c,v 1.12 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe_phy.c,v 1.13 2017/11/07 05:41:54 msaitoh Exp $ */
 
 /**
 
@@ -38,6 +38,8 @@
 #include "ixgbe_common.h"
 #include "ixgbe_phy.h"
 
+#include 
+
 static void ixgbe_i2c_start(struct ixgbe_hw *hw);
 static void ixgbe_i2c_stop(struct ixgbe_hw *hw);
 static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data);
@@ -855,18 +857,39 @@ s32 ixgbe_setup_phy_link_generic(struct 
 			  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
 			  autoneg_reg);
 
-	/* Blocked by MNG FW so don't reset PHY */
-	if (ixgbe_check_reset_blocked(hw))
-		return status;
+	if (hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_100_FULL) {
+		u16 ctrl;
 
-	/* Restart PHY auto-negotiation. */
-	hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+		/* Force 100Mbps */
+		hw->phy.ops.read_reg(hw, MDIO_PMAPMD_CTRL1, MDIO_MMD_PMAPMD,
+		);
+		ctrl &= ~PMAPMD_CTRL1_SPEED_MASK;
+		ctrl |= PMAPMD_CTRL1_SPEED_100;
+		hw->phy.ops.write_reg(hw, MDIO_PMAPMD_CTRL1,MDIO_MMD_PMAPMD,
+		ctrl);
+
+		/* Don't use auto-nego for 100Mbps */
+		hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
 			 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, _reg);
 
-	autoneg_reg |= IXGBE_MII_RESTART;
+		autoneg_reg &= ~AN_CTRL1_AUTOEN;	
 
-	hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+		hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
 			  IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
+	} else {
+		/* Blocked by MNG FW so don't reset PHY */
+		if (ixgbe_check_reset_blocked(hw))
+			return status;
+
+		/* Restart PHY auto-negotiation. */
+		hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+		IXGBE_MDIO_AUTO_NEG_DEV_TYPE, _reg);
+
+		autoneg_reg |= IXGBE_MII_RESTART | AN_CTRL1_AUTOEN;
+
+		hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+		IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
+	}
 
 	return status;
 }



  1   2   3   4   5   6   7   8   9   10   >