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-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

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/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-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;
 }



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

2017-11-02 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Nov  2 08:41:15 UTC 2017

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

Log Message:
- Handle hw.ixgN.advertise_speed correctly.
- Fix hw.ixgN.advertise_speed sysctl's description.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/ixgbe/ixgbe.h

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.108 src/sys/dev/pci/ixgbe/ixgbe.c:1.109
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.108	Thu Oct 26 01:40:33 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Nov  2 08:41:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.108 2017/10/26 01:40:33 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.109 2017/11/02 08:41:15 msaitoh Exp $ */
 
 /**
 
@@ -2689,9 +2689,8 @@ ixgbe_media_change(struct ifnet *ifp)
 
 	hw->mac.autotry_restart = TRUE;
 	hw->mac.ops.setup_link(hw, speed, TRUE);
-	if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) {
-		adapter->advertise = 0;
-	} else {
+	adapter->advertise = 0;
+	if (IFM_SUBTYPE(ifm->ifm_media) != IFM_AUTO) {
 		if ((speed & IXGBE_LINK_SPEED_10GB_FULL) != 0)
 			adapter->advertise |= 1 << 2;
 		if ((speed & IXGBE_LINK_SPEED_1GB_FULL) != 0)
@@ -4783,7 +4782,7 @@ ixgbe_set_advertise(struct adapter *adap
 		return (EINVAL);
 	}
 
-	if (advertise < 0x0 || advertise > 0xF) {
+	if (advertise < 0x0 || advertise > 0x2f) {
 		device_printf(dev,
 		"Invalid advertised speed; valid modes are 0x0 through 0x7\n");
 		return (EINVAL);

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.26 src/sys/dev/pci/ixgbe/ixgbe.h:1.27
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.26	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Thu Nov  2 08:41:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.26 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.27 2017/11/02 08:41:15 msaitoh Exp $ */
 
 /**
 
@@ -631,11 +631,13 @@ struct adapter {
 /* Sysctl help messages; displayed with sysctl -d */
 #define IXGBE_SYSCTL_DESC_ADV_SPEED \
 	"\nControl advertised link speed using these flags:\n" \
-	"\t0x1 - advertise 100M\n" \
-	"\t0x2 - advertise 1G\n" \
-"\t0x4 - advertise 10G\n\n" \
-"\t0x8 - advertise 10M\n\n" \
-"\t100M and 10M are only supported on certain adapters."
+	"\t0x01 - advertise 100M\n" \
+	"\t0x02 - advertise 1G\n" \
+"\t0x04 - advertise 10G\n" \
+"\t0x08 - advertise 10M\n" \
+"\t0x10 - advertise 2.5G\n" \
+"\t0x20 - advertise 5G\n\n" \
+"\t5G, 2.5G, 100M and 10M are only supported on certain adapters."
 
 #define IXGBE_SYSCTL_DESC_SET_FC \
 	"\nSet flow control mode using these values:\n" \



CVS commit: src/sys/dev/pci

2017-10-29 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Oct 30 01:24:47 UTC 2017

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

Log Message:
Add Areca ARC1214 & ARC1880.
>From OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1299 -r1.1300 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.1299 src/sys/dev/pci/pcidevs:1.1300
--- src/sys/dev/pci/pcidevs:1.1299	Fri Oct 20 12:01:43 2017
+++ src/sys/dev/pci/pcidevs	Mon Oct 30 01:24:47 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1299 2017/10/20 12:01:43 christos Exp $
+$NetBSD: pcidevs,v 1.1300 2017/10/30 01:24:47 sevan Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1216,6 +1216,7 @@ product ARECA ARC1200		0x1200	ARC-1200
 product ARECA ARC1200_B		0x1201	ARC-1200 rev B
 product ARECA ARC1202		0x1202	ARC-1202
 product ARECA ARC1210		0x1210	ARC-1210
+product ARECA ARC1214 		0x1214	ARC-1214
 product ARECA ARC1220		0x1220	ARC-1220
 product ARECA ARC1230		0x1230	ARC-1230
 product ARECA ARC1260		0x1260	ARC-1260
@@ -1225,6 +1226,7 @@ product ARECA ARC1380		0x1380	ARC-1380
 product ARECA ARC1381		0x1381	ARC-1381
 product ARECA ARC1680		0x1680	ARC-1680
 product ARECA ARC1681		0x1681	ARC-1681
+product ARECA ARC1880 		0x1880	ARC-1880
 
 /* ASIX Electronics products */
 product ASIX AX88140A	0x1400	AX88140A 10/100 Ethernet



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

2017-10-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 26 01:40:33 UTC 2017

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

Log Message:
- Remove all half duplex setting.
- Remove special handling of IXGBE_DEV_ID_82598AT's 1000BaseT. The PHY is
  compliant with clause 45, so the media is added in the beginning of
  ixgbe_add_media_types().


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 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.107 src/sys/dev/pci/ixgbe/ixgbe.c:1.108
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.107	Wed Oct 25 04:45:41 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Oct 26 01:40:33 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.107 2017/10/25 04:45:41 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.108 2017/10/26 01:40:33 msaitoh Exp $ */
 
 /**
 
@@ -1316,15 +1316,12 @@ ixgbe_add_media_types(struct adapter *ad
 		ADD(IFM_10G_T | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_T) {
-		ADD(IFM_1000_T, 0);
 		ADD(IFM_1000_T | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_100BASE_TX) {
-		ADD(IFM_100_TX, 0);
 		ADD(IFM_100_TX | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_10BASE_T) {
-		ADD(IFM_10_T, 0);
 		ADD(IFM_10_T | IFM_FDX, 0);
 	}
 
@@ -1371,7 +1368,6 @@ ixgbe_add_media_types(struct adapter *ad
 	}
 #endif
 	if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_KX) {
-		ADD(IFM_1000_KX, 0);
 		ADD(IFM_1000_KX | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_2500BASE_KX) {
@@ -1387,11 +1383,6 @@ ixgbe_add_media_types(struct adapter *ad
 		device_printf(dev, "Media supported: 1000baseBX\n");
 	/* XXX no ifmedia_set? */
 	
-	if (hw->device_id == IXGBE_DEV_ID_82598AT) {
-		ADD(IFM_1000_T | IFM_FDX, 0);
-		ADD(IFM_1000_T, 0);
-	}
-
 	ADD(IFM_AUTO, 0);
 
 #undef ADD



CVS commit: src/sys/dev/pci

2017-10-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 25 08:21:41 UTC 2017

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

Log Message:
 Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/sys/dev/pci/pci_subr.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.195 src/sys/dev/pci/pci_subr.c:1.196
--- src/sys/dev/pci/pci_subr.c:1.195	Tue Oct 24 08:32:41 2017
+++ src/sys/dev/pci/pci_subr.c	Wed Oct 25 08:21:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.195 2017/10/24 08:32:41 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.196 2017/10/25 08:21:41 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.195 2017/10/24 08:32:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.196 2017/10/25 08:21:41 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -4349,9 +4349,9 @@ pci_conf_print_type1(
 	}
 	if (base < limit) {
 		if (use_upper == 1)
-			printf("  range:  0x%08x-0x%08x\n", base, limit);
+			printf("  range: 0x%08x-0x%08x\n", base, limit);
 		else
-			printf("  range:  0x%04x-0x%04x\n", base, limit);
+			printf("  range: 0x%04x-0x%04x\n", base, limit);
 	} else
 		printf("  range:  not set\n");
 
@@ -4367,9 +4367,9 @@ pci_conf_print_type1(
 	limit = (((rval >> PCI_BRIDGE_MEMORY_LIMIT_SHIFT)
 		& PCI_BRIDGE_MEMORY_LIMIT_MASK) << 20) | 0x000f;
 	if (base < limit)
-		printf("  range:  0x%08x-0x%08x\n", base, limit);
+		printf("  range: 0x%08x-0x%08x\n", base, limit);
 	else
-		printf("  range:  not set\n");
+		printf("  range: not set\n");
 
 	/* Prefetchable memory region */
 	rval = regs[o2i(PCI_BRIDGE_PREFETCHMEM_REG)];
@@ -4399,13 +4399,13 @@ pci_conf_print_type1(
 	}
 	if (pbase < plimit) {
 		if (use_upper == 1)
-			printf("  range:  0x%016" PRIx64 "-0x%016" PRIx64
+			printf("  range: 0x%016" PRIx64 "-0x%016" PRIx64
 			"\n", pbase, plimit);
 		else
-			printf("  range:  0x%08x-0x%08x\n",
+			printf("  range: 0x%08x-0x%08x\n",
 			(uint32_t)pbase, (uint32_t)plimit);
 	} else
-		printf("  range:  not set\n");
+		printf("  range: not set\n");
 
 	if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT)
 		printf("Capability list pointer: 0x%02x\n",



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

2017-10-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 25 04:45:41 UTC 2017

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

Log Message:
- For X550 and newer, print NVM Image Version with %u.%02x (e.g. "0.05").
- Fix value check of OEM_NVM_IMAGE_VER.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 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.106 src/sys/dev/pci/ixgbe/ixgbe.c:1.107
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.106	Mon Oct 23 09:31:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Oct 25 04:45:41 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.106 2017/10/23 09:31:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.107 2017/10/25 04:45:41 msaitoh Exp $ */
 
 /**
 
@@ -972,8 +972,13 @@ ixgbe_attach(device_t parent, device_t d
 		high = (nvmreg >> 12) & 0x0f;
 		low = (nvmreg >> 4) & 0xff;
 		id = nvmreg & 0x0f;
-		aprint_normal(" NVM Image Version %u.%u ID 0x%x,", high, low,
-		id);
+		aprint_normal(" NVM Image Version %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;
 	case ixgbe_mac_X550EM_x:
 	case ixgbe_mac_X550:
@@ -982,7 +987,7 @@ ixgbe_attach(device_t parent, device_t d
 			break;
 		high = (nvmreg >> 12) & 0x0f;
 		low = nvmreg & 0xff;
-		aprint_normal(" NVM Image Version %u.%u,", high, low);
+		aprint_normal(" NVM Image Version %u.%02x,", high, low);
 		break;
 	default:
 		break;
@@ -998,7 +1003,7 @@ 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.%u ID 0x%x,", high, low,
+		aprint_normal(" PHY FW Revision %u.%02x ID 0x%x,", high, low,
 		id);
 		break;
 	default:
@@ -1017,7 +1022,7 @@ ixgbe_attach(device_t parent, device_t d
 			aprint_normal(" NVM Map version %u.%02x,", high, low);
 		}
 		hw->eeprom.ops.read(hw, IXGBE_OEM_NVM_IMAGE_VER, );
-		if (nvmreg == 0x) {
+		if (nvmreg != 0x) {
 			high = (nvmreg >> 12) & 0x0f;
 			low = nvmreg & 0x00ff;
 			aprint_verbose(" OEM NVM Image version %u.%02x,", high,



CVS commit: src/sys/dev/pci

2017-10-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Oct 24 08:32:42 UTC 2017

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

Log Message:
 Print Error Source Identification register correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/sys/dev/pci/pci_subr.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.194 src/sys/dev/pci/pci_subr.c:1.195
--- src/sys/dev/pci/pci_subr.c:1.194	Thu Oct 19 05:52:57 2017
+++ src/sys/dev/pci/pci_subr.c	Tue Oct 24 08:32:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.194 2017/10/19 05:52:57 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.195 2017/10/24 08:32:41 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.194 2017/10/19 05:52:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.195 2017/10/24 08:32:41 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -2692,7 +2692,8 @@ pci_conf_print_aer_cap(const pcireg_t *r
 		pci_conf_print_aer_cap_rooterr_status(reg);
 
 		reg = regs[o2i(extcapoff + PCI_AER_ERRSRC_ID)];
-		printf("Error Source Identification: 0x%04x\n", reg);
+		printf("Error Source Identification register: 0x%08x\n",
+		reg);
 		pci_conf_print_aer_cap_errsrc_id(reg);
 		break;
 	}



CVS commit: src/sys/dev/pci

2017-10-23 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 23 23:29:38 UTC 2017

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

Log Message:
fix wm(4) vlan panic. Reported and tested by Tom Ivar Helbekkmo, thanks.

wm(4) used PRI bits and CFI bit as vlantag by mistake. It is found out
by if_ether.h:r1.67.

XXX need pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.541 -r1.542 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.103 -r1.104 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.541 src/sys/dev/pci/if_wm.c:1.542
--- src/sys/dev/pci/if_wm.c:1.541	Mon Oct 23 09:27:21 2017
+++ src/sys/dev/pci/if_wm.c	Mon Oct 23 23:29:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.541 2017/10/23 09:27:21 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.542 2017/10/23 23:29:38 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.541 2017/10/23 09:27:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.542 2017/10/23 23:29:38 knakahara 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 rxq->rxq_ext_descs[idx].erx_ctx.erxc_vlan;
+		return EXTRXC_VLAN_ID(rxq->rxq_ext_descs[idx].erx_ctx.erxc_vlan);
 	else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
-		return rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_vlan;
+		return NQRXC_VLAN_ID(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_vlan);
 	else
-		return rxq->rxq_descs[idx].wrx_special;
+		return WRX_VLAN_ID(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.103 src/sys/dev/pci/if_wmreg.h:1.104
--- src/sys/dev/pci/if_wmreg.h:1.103	Wed Jul 26 06:48:49 2017
+++ src/sys/dev/pci/if_wmreg.h	Mon Oct 23 23:29:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.103 2017/07/26 06:48:49 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.104 2017/10/23 23:29:38 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -208,6 +208,12 @@ 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 {
@@ -330,6 +336,12 @@ 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-10-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 23 09:28:38 UTC 2017

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

Log Message:
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 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.75 src/sys/dev/pci/if_iwm.c:1.76
--- src/sys/dev/pci/if_iwm.c:1.75	Sun Jul 23 10:55:00 2017
+++ src/sys/dev/pci/if_iwm.c	Mon Oct 23 09:28:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.75 2017/07/23 10:55:00 para Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.76 2017/10/23 09:28:38 msaitoh 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.75 2017/07/23 10:55:00 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.76 2017/10/23 09:28:38 msaitoh Exp $");
 
 #include 
 #include 
@@ -8037,7 +8037,7 @@ iwm_attach(device_t parent, device_t sel
 	err = iwm_alloc_rx_ring(sc, >rxq);
 	if (err) {
 		aprint_error_dev(sc->sc_dev, "could not allocate RX ring\n");
-		goto fail4;
+		goto fail5;
 	}
 
 	/* Clear pending interrupts. */
@@ -8122,7 +8122,12 @@ iwm_attach(device_t parent, device_t sel
 	IFQ_SET_READY(>if_snd);
 	memcpy(ifp->if_xname, DEVNAME(sc), IFNAMSIZ);
 
-	if_initialize(ifp);
+	err = if_initialize(ifp);
+	if (err != 0) {
+		aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+		err);
+		goto fail6;
+	}
 #if 0
 	ieee80211_ifattach(ic);
 #else
@@ -8168,10 +8173,10 @@ iwm_attach(device_t parent, device_t sel
 
 	return;
 
-fail4:	while (--txq_i >= 0)
+fail6:	iwm_free_rx_ring(sc, >rxq);
+fail5:	while (--txq_i >= 0)
 		iwm_free_tx_ring(sc, >txq[txq_i]);
-	iwm_free_rx_ring(sc, >rxq);
-	iwm_dma_contig_free(>sched_dma);
+fail4:	iwm_dma_contig_free(>sched_dma);
 fail3:	if (sc->ict_dma.vaddr != NULL)
 		iwm_dma_contig_free(>ict_dma);
 fail2:	iwm_dma_contig_free(>kw_dma);



CVS commit: src/sys/dev/pci

2017-10-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 23 09:28:13 UTC 2017

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

Log Message:
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/pci/if_iwi.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_iwi.c
diff -u src/sys/dev/pci/if_iwi.c:1.103 src/sys/dev/pci/if_iwi.c:1.104
--- src/sys/dev/pci/if_iwi.c:1.103	Tue May 23 02:19:14 2017
+++ src/sys/dev/pci/if_iwi.c	Mon Oct 23 09:28:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwi.c,v 1.103 2017/05/23 02:19:14 ozaki-r Exp $  */
+/*	$NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh 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.103 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.104 2017/10/23 09:28:13 msaitoh Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver
@@ -367,7 +367,13 @@ iwi_attach(device_t parent, device_t sel
 	IFQ_SET_READY(>if_snd);
 	memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
 
-	if_initialize(ifp);
+	error = if_initialize(ifp);
+	if (error != 0) {
+		ifp->if_softc = NULL; /* For iwi_detach() */
+		aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+		error);
+		goto fail;
+	}
 	ieee80211_ifattach(ic);
 	/* Use common softint-based if_input */
 	ifp->if_percpuq = if_percpuq_create(ifp);
@@ -454,16 +460,13 @@ iwi_detach(device_t self, int flags)
 	struct iwi_softc *sc = device_private(self);
 	struct ifnet *ifp = >sc_if;
 
-	pmf_device_deregister(self);
-
-	if (ifp != NULL)
+	if (ifp->if_softc != NULL) {
+		pmf_device_deregister(self);
 		iwi_stop(ifp, 1);
-
-	iwi_free_firmware(sc);
-
-	ieee80211_ifdetach(>sc_ic);
-	if (ifp != NULL)
+		iwi_free_firmware(sc);
+		ieee80211_ifdetach(>sc_ic);
 		if_detach(ifp);
+	}
 
 	iwi_free_cmd_ring(sc, >cmdq);
 	iwi_free_tx_ring(sc, >txq[0]);



CVS commit: src/sys/dev/pci

2017-10-22 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Oct 22 13:13:55 UTC 2017

Modified Files:
src/sys/dev/pci: cmdide.c pciidevar.h

Log Message:
do not share queue between the non-indepedant channels; instead make
sure only one of the channels is ever active on the same controller

fixes PR kern/52606 by Martin Husemann, thanks for report and testing


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/cmdide.c
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/pci/pciidevar.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/cmdide.c
diff -u src/sys/dev/pci/cmdide.c:1.42 src/sys/dev/pci/cmdide.c:1.43
--- src/sys/dev/pci/cmdide.c:1.42	Fri Oct 20 21:51:29 2017
+++ src/sys/dev/pci/cmdide.c	Sun Oct 22 13:13:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmdide.c,v 1.42 2017/10/20 21:51:29 jdolecek Exp $	*/
+/*	$NetBSD: cmdide.c,v 1.43 2017/10/22 13:13:55 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@@ -25,10 +25,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.42 2017/10/20 21:51:29 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.43 2017/10/22 13:13:55 jdolecek Exp $");
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -36,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1
 #include 
 #include 
 
+#define CMDIDE_ACT_CHANNEL_NONE	0xff
 
 static int  cmdide_match(device_t, cfdata_t, void *);
 static void cmdide_attach(device_t, device_t, void *);
@@ -49,6 +51,8 @@ static void cmd0643_9_chip_map(struct pc
 static void cmd0643_9_setup_channel(struct ata_channel*);
 static void cmd_channel_map(const struct pci_attach_args *,
 			struct pciide_softc *, int);
+static int cmd064x_claim_hw(struct ata_channel *, int);
+static void cmd064x_free_hw(struct ata_channel *);
 static int  cmd_pci_intr(void *);
 static void cmd646_9_irqack(struct ata_channel *);
 static void cmd680_chip_map(struct pciide_softc*,
@@ -151,11 +155,10 @@ cmd_channel_map(const struct pci_attach_
 	cp->ata_channel.ch_atac = >sc_wdcdev.sc_atac;
 
 	if (channel > 0 && one_channel) {
-		cp->ata_channel.ch_queue =
-		sc->pciide_channels[0].ata_channel.ch_queue;
-	} else {
-		/* XXX */
-		cp->ata_channel.ch_queue = ata_queue_alloc(1);
+		/* Channels are not independant, need synchronization */
+		sc->sc_wdcdev.sc_atac.atac_claim_hw = cmd064x_claim_hw;
+		sc->sc_wdcdev.sc_atac.atac_free_hw  = cmd064x_free_hw;
+		sc->sc_cmd_act_channel = CMDIDE_ACT_CHANNEL_NONE;
 	}
 
 	aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev,
@@ -181,6 +184,45 @@ cmd_channel_map(const struct pci_attach_
 	pciide_mapchan(pa, cp, interface, cmd_pci_intr);
 }
 
+/*
+ * Check if we can execute next xfer on the channel.
+ * Called with chp channel lock held.
+ */
+static int
+cmd064x_claim_hw(struct ata_channel *chp, int maysleep)
+{
+	struct pciide_softc *sc = CHAN_TO_PCIIDE(chp);
+
+	return atomic_cas_uint(>sc_cmd_act_channel,
+	CMDIDE_ACT_CHANNEL_NONE, chp->ch_channel)
+	== CMDIDE_ACT_CHANNEL_NONE;
+}
+
+/* Allow another channel to run. Called with ochp channel lock held. */
+static void
+cmd064x_free_hw(struct ata_channel *ochp)
+{
+	struct pciide_softc *sc = CHAN_TO_PCIIDE(ochp);
+	uint oact = atomic_cas_uint(>sc_cmd_act_channel,
+	ochp->ch_channel, CMDIDE_ACT_CHANNEL_NONE);
+	struct ata_channel *nchp;
+
+	KASSERT(oact == ochp->ch_channel);
+
+	/* Start the other channel(s) */
+	for(uint i = 0; i < sc->sc_wdcdev.sc_atac.atac_nchannels; i++) {
+		/* Skip the current channel */
+		if (i == oact)
+			continue;
+
+		nchp = >pciide_channels[i].ata_channel;
+		if (nchp->ch_ndrives == 0)
+			continue;
+
+		atastart(nchp);
+	}
+}
+
 static int
 cmd_pci_intr(void *arg)
 {

Index: src/sys/dev/pci/pciidevar.h
diff -u src/sys/dev/pci/pciidevar.h:1.48 src/sys/dev/pci/pciidevar.h:1.49
--- src/sys/dev/pci/pciidevar.h:1.48	Thu Oct 19 20:11:38 2017
+++ src/sys/dev/pci/pciidevar.h	Sun Oct 22 13:13:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciidevar.h,v 1.48 2017/10/19 20:11:38 jdolecek Exp $	*/
+/*	$NetBSD: pciidevar.h,v 1.49 2017/10/22 13:13:55 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -122,6 +122,9 @@ struct pciide_softc {
 	int sc_ba5_en;
 #endif	/* NATA_DMA */
 
+	/* for CMD Technology 064x */
+	uint sc_cmd_act_channel;
+
 	/* Vendor info (for interpreting Chip description) */
 	pcireg_t sc_pci_id;
 	/* Chip description */



CVS commit: src/sys/dev/pci

2017-10-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Oct 20 21:51:29 UTC 2017

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

Log Message:
actually 0680 uses different chip map func, which doesn't call the function
handing non-independant channels, so don't set IDE_SHARED_CHANNELS for it


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/cmdide.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/cmdide.c
diff -u src/sys/dev/pci/cmdide.c:1.41 src/sys/dev/pci/cmdide.c:1.42
--- src/sys/dev/pci/cmdide.c:1.41	Fri Oct 20 07:06:08 2017
+++ src/sys/dev/pci/cmdide.c	Fri Oct 20 21:51:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmdide.c,v 1.41 2017/10/20 07:06:08 jdolecek Exp $	*/
+/*	$NetBSD: cmdide.c,v 1.42 2017/10/20 21:51:29 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.41 2017/10/20 07:06:08 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.42 2017/10/20 21:51:29 jdolecek Exp $");
 
 #include 
 #include 
@@ -85,7 +85,7 @@ static const struct pciide_product_desc 
 	  cmd0643_9_chip_map,
 	},
 	{ PCI_PRODUCT_CMDTECH_680,
-	  IDE_SHARED_CHANNELS,
+	  0,
 	  "Silicon Image 0680",
 	  cmd680_chip_map,
 	},



CVS commit: src/sys/dev/pci

2017-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 20 12:03:16 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.1291 -r1.1292 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1290 -r1.1291 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.1291 src/sys/dev/pci/pcidevs.h:1.1292
--- src/sys/dev/pci/pcidevs.h:1.1291	Fri Sep 15 10:25:24 2017
+++ src/sys/dev/pci/pcidevs.h	Fri Oct 20 08:03:15 2017
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1291 2017/09/15 14:25:24 hikaru Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1292 2017/10/20 12:03:15 christos Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1297 2017/08/17 01:05:22 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1299 2017/10/20 12:01:43 christos Exp
  */
 
 /*
@@ -41,7 +41,7 @@
 /*
  * NOTE: a fairly complete list of PCI codes can be found at:
  *
- *	http://www.pcidatabase.com/
+ *	https://pci-ids.ucw.cz/
  *
  * (but it doesn't always seem to match vendor documentation)
  *
@@ -2455,7 +2455,7 @@
 #define	PCI_PRODUCT_MARVELL_YUKON_C032	0x4367		/* Yukon 88EC032 */
 #define	PCI_PRODUCT_MARVELL_YUKON_C034	0x4368		/* Yukon 88EC034 */
 #define	PCI_PRODUCT_MARVELL_YUKON_C042	0x4369		/* Yukon 88EC042 */
-#define	PCI_PRODUCT_MARVELL_YUKON_C055	0x436a		/* Yukon 88EC055 */
+#define	PCI_PRODUCT_MARVELL_YUKON_8058	0x436a		/* Yukon 88E8058 */
 #define	PCI_PRODUCT_MARVELL_GT64120	0x4620		/* GT-64120 System Controller */
 #define	PCI_PRODUCT_MARVELL_BELKIN	0x5005		/* Belkin Gigabit Ethernet */
 #define	PCI_PRODUCT_MARVELL_88SX5040	0x5040		/* 88SX5040 SATA */

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1290 src/sys/dev/pci/pcidevs_data.h:1.1291
--- src/sys/dev/pci/pcidevs_data.h:1.1290	Fri Sep 15 10:25:24 2017
+++ src/sys/dev/pci/pcidevs_data.h	Fri Oct 20 08:03:15 2017
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1290 2017/09/15 14:25:24 hikaru Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1291 2017/10/20 12:03:15 christos Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1297 2017/08/17 01:05:22 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1299 2017/10/20 12:01:43 christos Exp
  */
 
 /*
@@ -3721,7 +3721,7 @@ static const uint16_t pci_products[] = {
 	15898, 16008, 0,
 	PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_C042, 
 	15898, 16016, 0,
-	PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_C055, 
+	PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_YUKON_8058, 
 	15898, 16024, 0,
 	PCI_VENDOR_MARVELL, PCI_PRODUCT_MARVELL_GT64120, 
 	16032, 6, 6300, 0,
@@ -14182,7 +14182,7 @@ static const char pci_words[] = { "." 
 	"88EC032\0" /* 1 refs @ 16000 */
 	"88EC034\0" /* 1 refs @ 16008 */
 	"88EC042\0" /* 1 refs @ 16016 */
-	"88EC055\0" /* 1 refs @ 16024 */
+	"88E8058\0" /* 1 refs @ 16024 */
 	"GT-64120\0" /* 1 refs @ 16032 */
 	"88SX5040\0" /* 1 refs @ 16041 */
 	"88SX5041\0" /* 1 refs @ 16050 */



CVS commit: src/sys/dev/pci

2017-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 20 12:01:43 UTC 2017

Modified Files:
src/sys/dev/pci: if_msk.c pcidevs

Log Message:
update entry for Marvel Yukon 8058, and fix URL for pci ids (Rocky Hotas)


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.1298 -r1.1299 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/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.54 src/sys/dev/pci/if_msk.c:1.55
--- src/sys/dev/pci/if_msk.c:1.54	Thu Dec 15 04:28:05 2016
+++ src/sys/dev/pci/if_msk.c	Fri Oct 20 08:01:43 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.54 2016/12/15 09:28:05 ozaki-r Exp $ */
+/* $NetBSD: if_msk.c,v 1.55 2017/10/20 12:01:43 christos Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.42 2007/01/17 02:43:02 krw Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.54 2016/12/15 09:28:05 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.55 2017/10/20 12:01:43 christos Exp $");
 
 #include 
 #include 
@@ -160,7 +160,6 @@ static const struct msk_product {
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_C034 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_C036 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_C042 },
-	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_C055 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_8035 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_8036 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_8038 },
@@ -171,6 +170,7 @@ static const struct msk_product {
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_8053 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_8055 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_8056 },
+	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKON_8058 },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKONII_8021CU },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKONII_8021X },
 	{ PCI_VENDOR_MARVELL,		PCI_PRODUCT_MARVELL_YUKONII_8022CU },

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1298 src/sys/dev/pci/pcidevs:1.1299
--- src/sys/dev/pci/pcidevs:1.1298	Fri Sep 15 10:24:32 2017
+++ src/sys/dev/pci/pcidevs	Fri Oct 20 08:01:43 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1298 2017/09/15 14:24:32 hikaru Exp $
+$NetBSD: pcidevs,v 1.1299 2017/10/20 12:01:43 christos Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -34,7 +34,7 @@ $NetBSD: pcidevs,v 1.1298 2017/09/15 14:
 /*
  * NOTE: a fairly complete list of PCI codes can be found at:
  *
- *	http://www.pcidatabase.com/
+ *	https://pci-ids.ucw.cz/
  *
  * (but it doesn't always seem to match vendor documentation)
  *
@@ -2448,7 +2448,7 @@ product MARVELL YUKON_C036	0x4366	Yukon 
 product MARVELL YUKON_C032	0x4367	Yukon 88EC032
 product MARVELL YUKON_C034	0x4368	Yukon 88EC034
 product MARVELL YUKON_C042	0x4369	Yukon 88EC042
-product MARVELL YUKON_C055	0x436a	Yukon 88EC055
+product MARVELL YUKON_8058	0x436a	Yukon 88E8058
 product MARVELL GT64120		0x4620	GT-64120 System Controller
 product MARVELL BELKIN		0x5005	Belkin Gigabit Ethernet
 product MARVELL 88SX5040	0x5040	88SX5040 SATA



CVS commit: src/sys/dev/pci

2017-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 20 09:26:13 UTC 2017

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

Log Message:
 On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).


To generate a diff of this commit:
cvs rdiff -u -r1.539 -r1.540 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.539 src/sys/dev/pci/if_wm.c:1.540
--- src/sys/dev/pci/if_wm.c:1.539	Tue Sep 26 08:25:56 2017
+++ src/sys/dev/pci/if_wm.c	Fri Oct 20 09:26:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.539 2017/09/26 08:25:56 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.540 2017/10/20 09:26:13 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.539 2017/09/26 08:25:56 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.540 2017/10/20 09:26:13 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4022,10 +4022,18 @@ wm_initialize_hardware_bits(struct wm_so
 		case WM_T_PCH_LPT:
 		case WM_T_PCH_SPT:
 			/* TARC0 */
-			if ((sc->sc_type == WM_T_ICH8)
-			|| (sc->sc_type == WM_T_PCH_SPT)) {
+			if (sc->sc_type == WM_T_ICH8) {
 /* Set TARC0 bits 29 and 28 */
 tarc0 |= __BITS(29, 28);
+			} else if (sc->sc_type == WM_T_PCH_SPT) {
+tarc0 |= __BIT(29);
+/*
+ *  Drop bit 28. From Linux.
+ * See I218/I219 spec update
+ * "5. Buffer Overrun While the I219 is
+ * Processing DMA Transactions"
+ */
+tarc0 &= ~__BIT(28);
 			}
 			/* Set TARC0 bits 23,24,26,27 */
 			tarc0 |= __BITS(27, 26) | __BITS(24, 23);



CVS commit: src/sys/dev/pci

2017-10-19 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Oct 19 20:11:38 UTC 2017

Modified Files:
src/sys/dev/pci: cmdide.c pciidevar.h

Log Message:
replace the chek for the shared channel of cmdide(4) a flag of the
product array, rather than switch inside attach routine

XXX judging from product name, Silicon Image 0680 might be newer than 0649
XXX and hence have actually independant channels, but I don't have the hw
XXX so keeping as-is

no functional change, just to improve visibility in course of fixing
PR kern/52606


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/cmdide.c
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/pciidevar.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/cmdide.c
diff -u src/sys/dev/pci/cmdide.c:1.39 src/sys/dev/pci/cmdide.c:1.40
--- src/sys/dev/pci/cmdide.c:1.39	Sat Oct  7 16:05:33 2017
+++ src/sys/dev/pci/cmdide.c	Thu Oct 19 20:11:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmdide.c,v 1.39 2017/10/07 16:05:33 jdolecek Exp $	*/
+/*	$NetBSD: cmdide.c,v 1.40 2017/10/19 20:11:38 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.39 2017/10/07 16:05:33 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmdide.c,v 1.40 2017/10/19 20:11:38 jdolecek Exp $");
 
 #include 
 #include 
@@ -57,24 +57,25 @@ static void cmd680_setup_channel(struct 
 static void cmd680_channel_map(const struct pci_attach_args *,
 			   struct pciide_softc *, int);
 
+/* Older CMD64X doesn't have independent channels */
 static const struct pciide_product_desc pciide_cmd_products[] =  {
 	{ PCI_PRODUCT_CMDTECH_640,
-	  0,
+	  IDE_SHARED_CHANNELS,
 	  "CMD Technology PCI0640",
 	  cmd_chip_map
 	},
 	{ PCI_PRODUCT_CMDTECH_643,
-	  0,
+	  IDE_SHARED_CHANNELS,
 	  "CMD Technology PCI0643",
 	  cmd0643_9_chip_map,
 	},
 	{ PCI_PRODUCT_CMDTECH_646,
-	  0,
+	  IDE_SHARED_CHANNELS,
 	  "CMD Technology PCI0646",
 	  cmd0643_9_chip_map,
 	},
 	{ PCI_PRODUCT_CMDTECH_648,
-	  0,
+	  IDE_SHARED_CHANNELS,
 	  "CMD Technology PCI0648",
 	  cmd0643_9_chip_map,
 	},
@@ -84,7 +85,7 @@ static const struct pciide_product_desc 
 	  cmd0643_9_chip_map,
 	},
 	{ PCI_PRODUCT_CMDTECH_680,
-	  0,
+	  IDE_SHARED_CHANNELS,
 	  "Silicon Image 0680",
 	  cmd680_chip_map,
 	},
@@ -126,7 +127,8 @@ cmd_channel_map(const struct pci_attach_
 {
 	struct pciide_channel *cp = >pciide_channels[channel];
 	u_int8_t ctrl = pciide_pci_read(sc->sc_pc, sc->sc_tag, CMD_CTRL);
-	int interface, one_channel;
+	int interface;
+	bool one_channel = ISSET(sc->sc_pp->ide_flags, IDE_SHARED_CHANNELS);
 
 	/*
 	 * The 0648/0649 can be told to identify as a RAID controller.
@@ -148,18 +150,6 @@ cmd_channel_map(const struct pci_attach_
 	cp->ata_channel.ch_channel = channel;
 	cp->ata_channel.ch_atac = >sc_wdcdev.sc_atac;
 
-	/*
-	 * Older CMD64X doesn't have independent channels
-	 */
-	switch (sc->sc_pp->ide_product) {
-	case PCI_PRODUCT_CMDTECH_649:
-		one_channel = 0;
-		break;
-	default:
-		one_channel = 1;
-		break;
-	}
-
 	if (channel > 0 && one_channel) {
 		cp->ata_channel.ch_queue =
 		sc->pciide_channels[0].ata_channel.ch_queue;
@@ -174,11 +164,12 @@ cmd_channel_map(const struct pci_attach_
 	}
 
 	aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev,
-	"%s channel %s to %s mode\n", cp->name,
+	"%s channel %s to %s mode%s\n", cp->name,
 	(interface & PCIIDE_INTERFACE_SETTABLE(channel)) ?
 	"configured" : "wired",
 	(interface & PCIIDE_INTERFACE_PCI(channel)) ?
-	"native-PCI" : "compatibility");
+	"native-PCI" : "compatibility",
+	one_channel ? ", channel non-independant" : "");
 
 	/*
 	 * with a CMD PCI64x, if we get here, the first channel is enabled:

Index: src/sys/dev/pci/pciidevar.h
diff -u src/sys/dev/pci/pciidevar.h:1.47 src/sys/dev/pci/pciidevar.h:1.48
--- src/sys/dev/pci/pciidevar.h:1.47	Mon Aug 24 23:55:04 2015
+++ src/sys/dev/pci/pciidevar.h	Thu Oct 19 20:11:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciidevar.h,v 1.47 2015/08/24 23:55:04 pooka Exp $	*/
+/*	$NetBSD: pciidevar.h,v 1.48 2017/10/19 20:11:38 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -176,6 +176,7 @@ struct pciide_product_desc {
 
 /* Flags for ide_flags */
 #define	IDE_16BIT_IOSPACE	0x0002 /* I/O space BARS ignore upper word */
+#define	IDE_SHARED_CHANNELS	0x0004 /* channels are not independant */
 
 
 /* inlines for reading/writing 8-bit PCI registers */



CVS commit: src/sys/dev/pci

2017-10-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 19 05:52:57 UTC 2017

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

Log Message:
 Fix a bug that the TPH ST table is decoded even if it's not in the TPH
Requester extended capability structure.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.134 -r1.135 src/sys/dev/pci/pcireg.h

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.193 src/sys/dev/pci/pci_subr.c:1.194
--- src/sys/dev/pci/pci_subr.c:1.193	Thu Oct 12 02:40:34 2017
+++ src/sys/dev/pci/pci_subr.c	Thu Oct 19 05:52:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.193 2017/10/12 02:40:34 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.194 2017/10/19 05:52:57 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.193 2017/10/12 02:40:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.194 2017/10/19 05:52:57 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -3499,15 +3499,15 @@ pci_conf_print_dpa_cap(const pcireg_t *r
 }
 
 static const char *
-pci_conf_print_tph_req_cap_sttabloc(unsigned char val)
+pci_conf_print_tph_req_cap_sttabloc(uint8_t val)
 {
 
 	switch (val) {
-	case 0x0:
+	case PCI_TPH_REQ_STTBLLOC_NONE:
 		return "Not Present";
-	case 0x1:
+	case PCI_TPH_REQ_STTBLLOC_TPHREQ:
 		return "in the TPH Requester Capability Structure";
-	case 0x2:
+	case PCI_TPH_REQ_STTBLLOC_MSIX:
 		return "in the MSI-X Table";
 	default:
 		return "Unknown";
@@ -3519,6 +3519,7 @@ pci_conf_print_tph_req_cap(const pcireg_
 {
 	pcireg_t reg;
 	int size, i, j;
+	uint8_t sttbloc;
 
 	printf("\n  TPH Requester Extended Capability\n");
 
@@ -3528,9 +3529,9 @@ pci_conf_print_tph_req_cap(const pcireg_
 	onoff("Interrupt Vector Mode Supported", reg, PCI_TPH_REQ_CAP_INTVEC);
 	onoff("Device Specific Mode Supported", reg, PCI_TPH_REQ_CAP_DEVSPEC);
 	onoff("Extend TPH Reqester Supported", reg, PCI_TPH_REQ_CAP_XTPHREQ);
+	sttbloc = __SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLLOC);
 	printf("  ST Table Location: %s\n",
-	pci_conf_print_tph_req_cap_sttabloc(
-		(unsigned char)__SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLLOC)));
+	pci_conf_print_tph_req_cap_sttabloc(sttbloc));
 	size = __SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLSIZ) + 1;
 	printf("  ST Table Size: %d\n", size);
 
@@ -3566,7 +3567,10 @@ pci_conf_print_tph_req_cap(const pcireg_
 		printf("(reserved vaule)\n");
 		break;
 	}
-	
+
+	if (sttbloc != PCI_TPH_REQ_STTBLLOC_TPHREQ)
+		return;
+
 	for (i = 0; i < size ; i += 2) {
 		reg = regs[o2i(extcapoff + PCI_TPH_REQ_STTBL + i / 2)];
 		for (j = 0; j < 2 ; j++) {

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.134 src/sys/dev/pci/pcireg.h:1.135
--- src/sys/dev/pci/pcireg.h:1.134	Tue Oct 10 03:11:01 2017
+++ src/sys/dev/pci/pcireg.h	Thu Oct 19 05:52:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.134 2017/10/10 03:11:01 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.135 2017/10/19 05:52:57 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -1904,6 +1904,9 @@ struct pci_rom {
 #define	PCI_TPH_REQ_CAP_DEVSPEC	__BIT(2)   /* Device Specific Mode Supported */
 #define	PCI_TPH_REQ_CAP_XTPHREQ	__BIT(8)/* Extend TPH Reqester Supported */
 #define	PCI_TPH_REQ_CAP_STTBLLOC __BITS(10, 9)	/* ST Table Location */
+#define	PCI_TPH_REQ_STTBLLOC_NONE 	0	/* not present */
+#define	PCI_TPH_REQ_STTBLLOC_TPHREQ 	1	/* in the TPHREQ cap */
+#define	PCI_TPH_REQ_STTBLLOC_MSIX 	2	/* in the MSI-X table */
 #define	PCI_TPH_REQ_CAP_STTBLSIZ __BITS(26, 16)	/* ST Table Size */
 #define	PCI_TPH_REQ_CTL	0x08	/* TPH Requester Control */
 #define	PCI_TPH_REQ_CTL_STSEL	__BITS(2, 0)	/* ST Mode Select */



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

2017-10-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 18 10:43:32 UTC 2017

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

Log Message:
 Protect ec_multi* with mutex like other MP safe Ethernet drivers.
See if_ether.h rev. 1.66 and related stuff:
http://mail-index.netbsd.org/source-changes/2016/12/28/msg080289.html


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.71 -r1.72 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.104 src/sys/dev/pci/ixgbe/ixgbe.c:1.105
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.104	Fri Oct 13 04:52:40 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Oct 18 10:43:32 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.104 2017/10/13 04:52:40 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.105 2017/10/18 10:43:32 msaitoh Exp $ */
 
 /**
 
@@ -2726,11 +2726,13 @@ ixgbe_set_promisc(struct adapter *adapte
 	struct ether_multistep step;
 	struct ethercom *ec = >osdep.ec;
 
+	KASSERT(mutex_owned(>core_mtx));
 	rctl = IXGBE_READ_REG(>hw, IXGBE_FCTRL);
 	rctl &= (~IXGBE_FCTRL_UPE);
 	if (ifp->if_flags & IFF_ALLMULTI)
 		mcnt = MAX_NUM_MULTICAST_ADDRESSES;
 	else {
+		ETHER_LOCK(ec);
 		ETHER_FIRST_MULTI(step, ec, enm);
 		while (enm != NULL) {
 			if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
@@ -2738,6 +2740,7 @@ ixgbe_set_promisc(struct adapter *adapte
 			mcnt++;
 			ETHER_NEXT_MULTI(step, enm);
 		}
+		ETHER_UNLOCK(ec);
 	}
 	if (mcnt < MAX_NUM_MULTICAST_ADDRESSES)
 		rctl &= (~IXGBE_FCTRL_MPE);
@@ -3906,12 +3909,14 @@ ixgbe_set_multi(struct adapter *adapter)
 	struct ether_multi	*enm;
 	struct ether_multistep	step;
 
+	KASSERT(mutex_owned(>core_mtx));
 	IOCTL_DEBUGOUT("ixgbe_set_multi: begin");
 
 	mta = adapter->mta;
 	bzero(mta, sizeof(*mta) * MAX_NUM_MULTICAST_ADDRESSES);
 
 	ifp->if_flags &= ~IFF_ALLMULTI;
+	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if ((mcnt == MAX_NUM_MULTICAST_ADDRESSES) ||
@@ -3926,6 +3931,7 @@ ixgbe_set_multi(struct adapter *adapter)
 		mcnt++;
 		ETHER_NEXT_MULTI(step, enm);
 	}
+	ETHER_UNLOCK(ec);
 
 	fctrl = IXGBE_READ_REG(>hw, IXGBE_FCTRL);
 	fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.71 src/sys/dev/pci/ixgbe/ixv.c:1.72
--- src/sys/dev/pci/ixgbe/ixv.c:1.71	Fri Oct 13 08:17:44 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Oct 18 10:43:32 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.71 2017/10/13 08:17:44 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.72 2017/10/18 10:43:32 msaitoh Exp $*/
 
 /**
 
@@ -1048,8 +1048,10 @@ ixv_set_multi(struct adapter *adapter)
 	u8 *update_ptr;
 	intmcnt = 0;
 
+	KASSERT(mutex_owned(>core_mtx));
 	IOCTL_DEBUGOUT("ixv_set_multi: begin");
 
+	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		bcopy(enm->enm_addrlo,
@@ -1061,6 +1063,7 @@ ixv_set_multi(struct adapter *adapter)
 			break;
 		ETHER_NEXT_MULTI(step, enm);
 	}
+	ETHER_UNLOCK(ec);
 
 	update_ptr = mta;
 



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

2017-10-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 13 08:17:44 UTC 2017

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

Log Message:
 Show 2.5GBASE-T and 5GBASE-T correctly on ixv(4). Tested on a virtual function
on X550 T1.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.70 -r1.71 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_common.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.14 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.15
--- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.14	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_common.c	Fri Oct 13 08:17:44 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_common.c,v 1.14 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe_common.c,v 1.15 2017/10/13 08:17:44 msaitoh Exp $ */
 
 /**
 
@@ -4248,7 +4248,7 @@ s32 ixgbe_check_mac_link_generic(struct 
 		break;
 	case IXGBE_LINKS_SPEED_100_82599:
 		*speed = IXGBE_LINK_SPEED_100_FULL;
-		if (hw->mac.type == ixgbe_mac_X550) {
+		if (hw->mac.type >= ixgbe_mac_X550) {
 			if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
 *speed = IXGBE_LINK_SPEED_5GB_FULL;
 		}

Index: src/sys/dev/pci/ixgbe/ixgbe_vf.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.13 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.14
--- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.13	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.c	Fri Oct 13 08:17:44 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.c,v 1.13 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.c,v 1.14 2017/10/13 08:17:44 msaitoh Exp $ */
 
 /**
 
@@ -630,7 +630,7 @@ s32 ixgbe_check_mac_link_vf(struct ixgbe
 		break;
 	case IXGBE_LINKS_SPEED_100_82599:
 		*speed = IXGBE_LINK_SPEED_100_FULL;
-		if (hw->mac.type == ixgbe_mac_X550) {
+		if (hw->mac.type >= ixgbe_mac_X550) {
 			if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
 *speed = IXGBE_LINK_SPEED_5GB_FULL;
 		}

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.70 src/sys/dev/pci/ixgbe/ixv.c:1.71
--- src/sys/dev/pci/ixgbe/ixv.c:1.70	Fri Oct 13 04:52:40 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Fri Oct 13 08:17:44 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.70 2017/10/13 04:52:40 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.71 2017/10/13 08:17:44 msaitoh Exp $*/
 
 /**
 
@@ -955,6 +955,12 @@ ixv_media_status(struct ifnet *ifp, stru
 		case IXGBE_LINK_SPEED_10GB_FULL:
 			ifmr->ifm_active |= IFM_10G_T | IFM_FDX;
 			break;
+		case IXGBE_LINK_SPEED_5GB_FULL:
+			ifmr->ifm_active |= IFM_5000_T | IFM_FDX;
+			break;
+		case IXGBE_LINK_SPEED_2_5GB_FULL:
+			ifmr->ifm_active |= IFM_2500_T | IFM_FDX;
+			break;
 		case IXGBE_LINK_SPEED_1GB_FULL:
 			ifmr->ifm_active |= IFM_1000_T | IFM_FDX;
 			break;



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

2017-10-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 13 04:52:40 UTC 2017

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

Log Message:
 Set baudrate correctly. A device which use mii(4) interface can set
if_baudrate atomatically by mii_phy_statusmsg(). ixg(4) and ixv(4) don't
use mii(4), so calling ifmedia_baudrate() directly is required.

 XXX need the same same work for wm(4)'s TBI and SERDEV devices.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.69 -r1.70 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.103 src/sys/dev/pci/ixgbe/ixgbe.c:1.104
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.103	Wed Oct  4 07:13:00 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Oct 13 04:52:40 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.103 2017/10/04 07:13:00 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.104 2017/10/13 04:52:40 msaitoh Exp $ */
 
 /**
 
@@ -2594,6 +2594,8 @@ ixgbe_media_status(struct ifnet *ifp, st
 		ifmr->ifm_active |= IFM_UNKNOWN;
 #endif
 
+	ifp->if_baudrate = ifmedia_baudrate(ifmr->ifm_active);
+
 	/* Display current flow control setting used on link */
 	if (hw->fc.current_mode == ixgbe_fc_rx_pause ||
 	hw->fc.current_mode == ixgbe_fc_full)

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.69 src/sys/dev/pci/ixgbe/ixv.c:1.70
--- src/sys/dev/pci/ixgbe/ixv.c:1.69	Wed Oct  4 11:03:20 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Fri Oct 13 04:52:40 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.69 2017/10/04 11:03:20 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.70 2017/10/13 04:52:40 msaitoh Exp $*/
 
 /**
 
@@ -966,6 +966,8 @@ ixv_media_status(struct ifnet *ifp, stru
 			break;
 	}
 
+	ifp->if_baudrate = ifmedia_baudrate(ifmr->ifm_active);
+
 	IXGBE_CORE_UNLOCK(adapter);
 
 	return;



CVS commit: src/sys/dev/pci

2017-10-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct 12 02:40:34 UTC 2017

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

Log Message:
IOMMU cap dump fixes:
- Print Capability Register's value.
- Indent output correctly.
- s/cahced/cached/
- Print MSI Message number with 0x%02x


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/sys/dev/pci/pci_subr.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.192 src/sys/dev/pci/pci_subr.c:1.193
--- src/sys/dev/pci/pci_subr.c:1.192	Tue Oct 10 03:11:01 2017
+++ src/sys/dev/pci/pci_subr.c	Thu Oct 12 02:40:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.192 2017/10/10 03:11:01 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.193 2017/10/12 02:40:34 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.192 2017/10/10 03:11:01 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.193 2017/10/12 02:40:34 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1538,8 +1538,9 @@ pci_conf_print_secure_cap(const pcireg_t
 
 	printf("\n  Secure Capability Register\n");
 	reg = regs[o2i(capoff + PCI_SECURE_CAP)];
+	printf("Capability Register: 0x%04x\n", reg >> 16);
 	val = __SHIFTOUT(reg, PCI_SECURE_CAP_TYPE);
-	printf("Capability block type: ");
+	printf("  Capability block type: ");
 	/* I know IOMMU Only */
 	if (val == PCI_SECURE_CAP_TYPE_IOMMU)
 		printf("IOMMU\n");
@@ -1549,9 +1550,9 @@ pci_conf_print_secure_cap(const pcireg_t
 	}
 
 	val = __SHIFTOUT(reg, PCI_SECURE_CAP_REV);
-	printf("Capability revision: 0x%02x", val);
+	printf("  Capability revision: 0x%02x ", val);
 	if (val == PCI_SECURE_CAP_REV_IOMMU)
-		printf("IOMMU\n");
+		printf("(IOMMU)\n");
 	else {
 		printf("(unknown)\n");
 		return;
@@ -1559,7 +1560,7 @@ pci_conf_print_secure_cap(const pcireg_t
 	onoff("IOTLB support", reg, PCI_SECURE_CAP_IOTLBSUP);
 	onoff("HyperTransport tunnel translation support", reg,
 	PCI_SECURE_CAP_HTTUNNEL);
-	onoff("Not present table entries cahced", reg, PCI_SECURE_CAP_NPCACHE);
+	onoff("Not present table entries cached", reg, PCI_SECURE_CAP_NPCACHE);
 	onoff("IOMMU Extended Feature Register support", reg,
 	PCI_SECURE_CAP_EFRSUP);
 	onoff("IOMMU Miscellaneous Information Register 1", reg,
@@ -1589,7 +1590,7 @@ pci_conf_print_secure_cap(const pcireg_t
 
 	reg = regs[o2i(capoff + PCI_SECURE_IOMMU_MISC0)];
 	printf("Miscellaneous Information Register 0: 0x%08x\n", reg);
-	printf("  MSI Message number: 0x%04x\n",
+	printf("  MSI Message number: 0x%02x\n",
 	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC0_MSINUM));
 	val = __SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC0_GVASIZE);
 	printf("  Guest Virtual Address size: ");



CVS commit: src/sys/dev/pci

2017-10-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Oct 11 17:08:32 UTC 2017

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

Log Message:
add missing break;s


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/pci/radeonfb.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/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.92 src/sys/dev/pci/radeonfb.c:1.93
--- src/sys/dev/pci/radeonfb.c:1.92	Fri Aug 25 22:45:33 2017
+++ src/sys/dev/pci/radeonfb.c	Wed Oct 11 17:08:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.92 2017/08/25 22:45:33 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.93 2017/10/11 17:08:32 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.92 2017/08/25 22:45:33 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.93 2017/10/11 17:08:32 macallan Exp $");
 
 #include 
 #include 
@@ -710,6 +710,7 @@ radeonfb_attach(device_t parent, device_
   RADEON_FP_SEL_CRTC1,
 ~RADEON_FP_SEL_MASK);
 			}
+			break;
 		case RADEON_TMDS_EXT:
 			/* point FP2 at the CRTC this port uses */
 			DPRINTF(("%s: plugging external TMDS into CRTC %d\n",
@@ -727,6 +728,7 @@ radeonfb_attach(device_t parent, device_
   RADEON_FP2_SRC_SEL_CRTC1,
 ~RADEON_FP2_SRC_SEL_CRTC2);
 			}
+			break;
 		}
 	}
 	PRINTREG(RADEON_DAC_CNTL2);



CVS commit: src/sys/dev/pci

2017-10-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Oct 10 03:11:01 UTC 2017

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

Log Message:
 Decode IOMMU capability of PCI secure device capability. From "AMD I/O
Virtualization Technology(IOMMU) Specification (#48882) Revision 3.00".


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.133 -r1.134 src/sys/dev/pci/pcireg.h

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.191 src/sys/dev/pci/pci_subr.c:1.192
--- src/sys/dev/pci/pci_subr.c:1.191	Thu Oct  5 06:14:30 2017
+++ src/sys/dev/pci/pci_subr.c	Tue Oct 10 03:11:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.191 2017/10/05 06:14:30 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.192 2017/10/10 03:11:01 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.191 2017/10/05 06:14:30 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.192 2017/10/10 03:11:01 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1530,7 +1530,90 @@ pci_conf_print_subsystem_cap(const pcire
 }
 
 /* XXX pci_conf_print_agp8_cap */
-/* XXX pci_conf_print_secure_cap */
+static void
+pci_conf_print_secure_cap(const pcireg_t *regs, int capoff)
+{
+	pcireg_t reg, reg2, val;
+	bool havemisc1;
+
+	printf("\n  Secure Capability Register\n");
+	reg = regs[o2i(capoff + PCI_SECURE_CAP)];
+	val = __SHIFTOUT(reg, PCI_SECURE_CAP_TYPE);
+	printf("Capability block type: ");
+	/* I know IOMMU Only */
+	if (val == PCI_SECURE_CAP_TYPE_IOMMU)
+		printf("IOMMU\n");
+	else {
+		printf("0x%x(unknown)\n", val);
+		return;
+	}
+
+	val = __SHIFTOUT(reg, PCI_SECURE_CAP_REV);
+	printf("Capability revision: 0x%02x", val);
+	if (val == PCI_SECURE_CAP_REV_IOMMU)
+		printf("IOMMU\n");
+	else {
+		printf("(unknown)\n");
+		return;
+	}
+	onoff("IOTLB support", reg, PCI_SECURE_CAP_IOTLBSUP);
+	onoff("HyperTransport tunnel translation support", reg,
+	PCI_SECURE_CAP_HTTUNNEL);
+	onoff("Not present table entries cahced", reg, PCI_SECURE_CAP_NPCACHE);
+	onoff("IOMMU Extended Feature Register support", reg,
+	PCI_SECURE_CAP_EFRSUP);
+	onoff("IOMMU Miscellaneous Information Register 1", reg,
+	PCI_SECURE_CAP_EXT);
+	havemisc1 = reg & PCI_SECURE_CAP_EXT;
+	
+	reg = regs[o2i(capoff + PCI_SECURE_IOMMU_BAL)];
+	printf("Base Address Low Register: 0x%08x\n", reg);
+	onoff("Enable", reg, PCI_SECURE_IOMMU_BAL_EN);
+	reg2 = regs[o2i(capoff + PCI_SECURE_IOMMU_BAH)];
+	printf("Base Address High Register: 0x%08x\n", reg2);
+	printf("  Base Address : 0x%016" PRIx64 "\n",
+	((uint64_t)reg2 << 32)
+	| (reg & (PCI_SECURE_IOMMU_BAL_H | PCI_SECURE_IOMMU_BAL_L)));
+	
+	reg = regs[o2i(capoff + PCI_SECURE_IOMMU_RANGE)];
+	printf("IOMMU Range Register: 0x%08x\n", reg);
+	printf("  HyperTransport UnitID: 0x%02x\n",
+	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_RANGE_UNITID));
+	onoff("Range valid", reg, PCI_SECURE_IOMMU_RANGE_RNGVALID);
+	printf("  Device range bus number: 0x%02x\n",
+	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_RANGE_BUSNUM));
+	printf("  First device: 0x%04x\n",
+	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_RANGE_FIRSTDEV));
+	printf("  Last device: 0x%04x\n",
+	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_RANGE_LASTDEV));
+
+	reg = regs[o2i(capoff + PCI_SECURE_IOMMU_MISC0)];
+	printf("Miscellaneous Information Register 0: 0x%08x\n", reg);
+	printf("  MSI Message number: 0x%04x\n",
+	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC0_MSINUM));
+	val = __SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC0_GVASIZE);
+	printf("  Guest Virtual Address size: ");
+	if (val == PCI_SECURE_IOMMU_MISC0_GVASIZE_48B)
+		printf("48bits\n");
+	else
+		printf("0x%x(unknown)\n", val);
+	val = __SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC0_PASIZE);
+	printf("  Physical Address size: %dbits\n", val);
+	val = __SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC0_VASIZE);
+	printf("  Virtual Address size: %dbits\n", val);
+	onoff("ATS response address range reserved", reg,
+	PCI_SECURE_IOMMU_MISC0_ATSRESV);
+	printf("  Peripheral Page Request MSI Message number: 0x%02x\n",
+	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC0_MISNPPR));
+
+	if (!havemisc1)
+		return;
+	
+	reg = regs[o2i(capoff + PCI_SECURE_IOMMU_MISC1)];
+	printf("Miscellaneous Information Register 1: 0x%08x\n", reg);
+	printf("  MSI Message number (GA): 0x%02x\n",
+	(uint32_t)__SHIFTOUT(reg, PCI_SECURE_IOMMU_MISC1_MSINUM));
+}
 
 static void
 pci_print_pcie_L0s_latency(uint32_t val)
@@ -2352,7 +2435,7 @@ static struct {
 	{ PCI_CAP_SUBVENDOR,	"Subsystem vendor ID",
 	  pci_conf_print_subsystem_cap },
 	{ PCI_CAP_AGP8,		"AGP 8x",	NULL },
-	{ PCI_CAP_SECURE,	"Secure Device", NULL },
+	{ 

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

2017-10-09 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Oct  9 23:42:40 UTC 2017

Modified Files:
src/sys/dev/pci/n8: nsp.c

Log Message:
Delete bogus NULL test.

We deref session just above, and all callers already have session != NULL
already.

suggested by riastradh, spotted by coccinelle


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/n8/nsp.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/n8/nsp.c
diff -u src/sys/dev/pci/n8/nsp.c:1.12 src/sys/dev/pci/n8/nsp.c:1.13
--- src/sys/dev/pci/n8/nsp.c:1.12	Mon Apr 13 16:33:25 2015
+++ src/sys/dev/pci/n8/nsp.c	Mon Oct  9 23:42:40 2017
@@ -701,12 +701,6 @@ n8_session_free(struct nsp_softc *sc, ns
 	}
 
 	mutex_enter(>sc_intrlock);
-	if (session == NULL) {
-		DBG(("n8_session_free: attempt to free NULL\n"));
-		mutex_exit(>sc_intrlock);
-		return;
-	}
-
 	session->next = sc->freesession;
 	sc->freesession = session;
 	session->magic = 0xFEED;



CVS commit: src/sys/dev/pci

2017-10-09 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Oct  9 23:24:22 UTC 2017

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

Log Message:
Reorder to avoid null deref before null test


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/sys/dev/pci/mpii.c:1.10
--- src/sys/dev/pci/mpii.c:1.9	Sun Jun 25 15:56:32 2017
+++ src/sys/dev/pci/mpii.c	Mon Oct  9 23:24:22 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.9 2017/06/25 15:56:32 christos Exp $ */
+/* $NetBSD: mpii.c,v 1.10 2017/10/09 23:24:22 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.9 2017/06/25 15:56:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.10 2017/10/09 23:24:22 maya Exp $");
 
 #include "bio.h"
 
@@ -4108,10 +4108,12 @@ mpii_alloc_dev(struct mpii_softc *sc)
 static int
 mpii_insert_dev(struct mpii_softc *sc, struct mpii_device *dev)
 {
-	int slot = dev->slot; 	/* initial hint */
 
-	if (!dev || slot < 0)
+	if (!dev || dev->slot < 0)
 		return (1);
+
+	int slot = dev->slot; 	/* initial hint */
+
 	while (slot < sc->sc_max_devices && sc->sc_devs[slot] != NULL)
 		slot++;
 	if (slot >= sc->sc_max_devices)



CVS commit: src/sys/dev/pci

2017-10-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct  5 06:37:45 UTC 2017

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

Log Message:
 Use pcireg.h's macro. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/sti_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/sti_pci.c
diff -u src/sys/dev/pci/sti_pci.c:1.1 src/sys/dev/pci/sti_pci.c:1.2
--- src/sys/dev/pci/sti_pci.c:1.1	Tue Nov  9 12:24:48 2010
+++ src/sys/dev/pci/sti_pci.c	Thu Oct  5 06:37:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti_pci.c,v 1.1 2010/11/09 12:24:48 skrll Exp $	*/
+/*	$NetBSD: sti_pci.c,v 1.2 2017/10/05 06:37:45 msaitoh Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -71,12 +71,8 @@ void	sti_pci_disable_rom_internal(struct
 
 int	sti_pci_is_console(struct pci_attach_args *, bus_addr_t *);
 
-#define PCI_ROM_ENABLE  0x0001
-#define PCI_ROM_ADDR_MASK   0xf800
-#define PCI_ROM_ADDR(mr)\
-((mr) & PCI_ROM_ADDR_MASK)
 #define PCI_ROM_SIZE(mr)\
-(PCI_ROM_ADDR(mr) & -PCI_ROM_ADDR(mr))
+(PCI_MAPREG_ROM_ADDR(mr) & -PCI_MAPREG_ROM_ADDR(mr))
 
 int
 sti_pci_match(device_t parent, cfdata_t cf, void *aux)
@@ -154,9 +150,10 @@ sti_check_rom(struct sti_pci_softc *spc,
 
 	/* sort of inline sti_pci_enable_rom(sc) */
 	address = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_MAPREG_ROM);
-	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_MAPREG_ROM, ~PCI_ROM_ENABLE);
+	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_MAPREG_ROM,
+	~PCI_MAPREG_ROM_ENABLE);
 	mask = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_MAPREG_ROM);
-	address |= PCI_ROM_ENABLE;
+	address |= PCI_MAPREG_ROM_ENABLE;
 	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_MAPREG_ROM, address);
 	sc->sc_flags |= STI_ROM_ENABLED;
 	/*
@@ -165,9 +162,9 @@ sti_check_rom(struct sti_pci_softc *spc,
 
 	romsize = PCI_ROM_SIZE(mask);
 	DPRINTF(("%s: mapping rom @ %lx for %lx\n", __func__,
-	(long)PCI_ROM_ADDR(address), (long)romsize));
+	(long)PCI_MAPREG_ROM_ADDR(address), (long)romsize));
 
-	rc = bus_space_map(pa->pa_memt, PCI_ROM_ADDR(address), romsize,
+	rc = bus_space_map(pa->pa_memt, PCI_MAPREG_ROM_ADDR(address), romsize,
 	0, );
 	if (rc != 0) {
 		aprint_error_dev(sc->sc_dev, "can't map PCI ROM (%d)\n", rc);
@@ -313,9 +310,9 @@ sti_check_rom(struct sti_pci_softc *spc,
 	 */
 
 	DPRINTF(("remapping rom @ %lx for %lx\n",
-	(long)(PCI_ROM_ADDR(address) + offs), (long)stiromsize));
+	(long)(PCI_MAPREG_ROM_ADDR(address) + offs), (long)stiromsize));
 	bus_space_unmap(pa->pa_memt, romh, romsize);
-	rc = bus_space_map(pa->pa_memt, PCI_ROM_ADDR(address) + offs,
+	rc = bus_space_map(pa->pa_memt, PCI_MAPREG_ROM_ADDR(address) + offs,
 	stiromsize, 0, >sc_romh);
 	if (rc != 0) {
 		aprint_error_dev(sc->sc_dev, "can't map STI ROM (%d)\n",
@@ -389,7 +386,7 @@ sti_pci_enable_rom_internal(struct sti_p
 	KASSERT(spc != NULL);
 
 	address = pci_conf_read(spc->sc_pc, spc->sc_tag, PCI_MAPREG_ROM);
-	address |= PCI_ROM_ENABLE;
+	address |= PCI_MAPREG_ROM_ENABLE;
 	pci_conf_write(spc->sc_pc, spc->sc_tag, PCI_MAPREG_ROM, address);
 }
 
@@ -415,7 +412,7 @@ sti_pci_disable_rom_internal(struct sti_
 	KASSERT(spc != NULL);
 
 	address = pci_conf_read(spc->sc_pc, spc->sc_tag, PCI_MAPREG_ROM);
-	address &= ~PCI_ROM_ENABLE;
+	address &= ~PCI_MAPREG_ROM_ENABLE;
 	pci_conf_write(spc->sc_pc, spc->sc_tag, PCI_MAPREG_ROM, address);
 }
 



CVS commit: src/sys/dev/pci

2017-10-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Oct  5 06:14:30 UTC 2017

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

Log Message:
- Add PCI_MAPREG_ROM_ADDR_MASK macro and PCI_MAPREG_ROM_ADDR() macro.
- print PCI_MAPREG_ROM_ENABLE bit.
- Decode Expansion ROM Validation ECN.
- Add Native PCIe Enclosure Management ECN's extended capability type.
  Not decoded yet.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.132 -r1.133 src/sys/dev/pci/pcireg.h

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.190 src/sys/dev/pci/pci_subr.c:1.191
--- src/sys/dev/pci/pci_subr.c:1.190	Thu Jul 13 08:41:19 2017
+++ src/sys/dev/pci/pci_subr.c	Thu Oct  5 06:14:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.190 2017/07/13 08:41:19 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.191 2017/10/05 06:14:30 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.190 2017/07/13 08:41:19 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.191 2017/10/05 06:14:30 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -3873,6 +3873,7 @@ pci_conf_print_ptm_cap(const pcireg_t *r
 /* XXX pci_conf_print_desigvndsp_cap */
 /* XXX pci_conf_print_vf_resizbar_cap */
 /* XXX pci_conf_print_hierarchyid_cap */
+/* XXX pci_conf_print_npem_cap */
 
 #undef	MS
 #undef	SM
@@ -3959,6 +3960,8 @@ static struct {
 	  NULL },
 	{ PCI_EXTCAP_HIERARCHYID, "Hierarchy ID",
 	  NULL },
+	{ PCI_EXTCAP_NPEM,	"Native PCIe Enclosure Management",
+	  NULL },
 };
 
 static int
@@ -4099,6 +4102,7 @@ pci_conf_print_type0(
 {
 	int off, width;
 	pcireg_t rval;
+	const char *str;
 
 	for (off = PCI_MAPREG_START; off < PCI_MAPREG_END; off += width) {
 #ifdef _KERNEL
@@ -4115,9 +4119,43 @@ pci_conf_print_type0(
 	printf("Subsystem vendor ID: 0x%04x\n", PCI_VENDOR(rval));
 	printf("Subsystem ID: 0x%04x\n", PCI_PRODUCT(rval));
 
-	/* XXX */
-	printf("Expansion ROM Base Address: 0x%08x\n",
-	regs[o2i(PCI_MAPREG_ROM)]);
+	rval = regs[o2i(PCI_MAPREG_ROM)];
+	printf("Expansion ROM Base Address Register: 0x%08x\n", rval);
+	printf("  base: 0x%08x\n", (uint32_t)PCI_MAPREG_ROM_ADDR(rval));
+	onoff("Expansion ROM Enable", rval, PCI_MAPREG_ROM_ENABLE);
+	printf("  Validation Status: ");
+	switch (__SHIFTOUT(rval, PCI_MAPREG_ROM_VALID_STAT)) {
+	case PCI_MAPREG_ROM_VSTAT_NOTSUPP:
+		str = "Validation not supported";
+		break;
+	case PCI_MAPREG_ROM_VSTAT_INPROG:
+		str = "Validation in Progress";
+		break;
+	case PCI_MAPREG_ROM_VSTAT_VPASS:
+		str = "Validation Pass. "
+		"Valid contents, trust test was not performed";
+		break;
+	case PCI_MAPREG_ROM_VSTAT_VPASSTRUST:
+		str = "Validation Pass. Valid and trusted contents";
+		break;
+	case PCI_MAPREG_ROM_VSTAT_VFAIL:
+		str = "Validation Fail. Invalid contents";
+		break;
+	case PCI_MAPREG_ROM_VSTAT_VFAILUNTRUST:
+		str = "Validation Fail. Valid but untrusted contents";
+		break;
+	case PCI_MAPREG_ROM_VSTAT_WPASS:
+		str = "Warning Pass. Validation passed with warning. "
+		"Valid contents, trust test was not performed";
+		break;
+	case PCI_MAPREG_ROM_VSTAT_WPASSTRUST:
+		str = "Warning Pass. Validation passed with warning. "
+		"Valid and trusted contents";
+		break;
+	}
+	printf("%s\n", str);
+	printf("  Validation Details: 0x%x\n",
+	(uint32_t)__SHIFTOUT(rval, PCI_MAPREG_ROM_VALID_DETAIL));
 
 	if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT)
 		printf("Capability list pointer: 0x%02x\n",

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.132 src/sys/dev/pci/pcireg.h:1.133
--- src/sys/dev/pci/pcireg.h:1.132	Thu Jul 13 08:41:19 2017
+++ src/sys/dev/pci/pcireg.h	Thu Oct  5 06:14:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.132 2017/07/13 08:41:19 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.133 2017/10/05 06:14:30 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -485,6 +485,20 @@ typedef u_int8_t pci_revision_t;
 	(PCI_MAPREG_IO_ADDR(mr) & -PCI_MAPREG_IO_ADDR(mr))
 #define	PCI_MAPREG_IO_ADDR_MASK		0xfffc
 
+#define	PCI_MAPREG_ROM_ADDR(mr)		\
+	((mr) & PCI_MAPREG_ROM_ADDR_MASK)
+#define	PCI_MAPREG_ROM_VALID_STAT   __BITS(3, 1) /* Validation Status */
+#define	PCI_MAPREG_ROM_VSTAT_NOTSUPP	0x0 /* Validation not supported */
+#define	PCI_MAPREG_ROM_VSTAT_INPROG	0x1 /* Validation in Progress */
+#define	PCI_MAPREG_ROM_VSTAT_VPASS	0x2 /* Valid contnt, trust test nperf*/
+#define	PCI_MAPREG_ROM_VSTAT_VPASSTRUST	0x3 /* Valid and trusted contents */
+#define	PCI_MAPREG_ROM_VSTAT_VFAIL	0x4 /* Invaild contents */
+#define	PCI_MAPREG_ROM_VSTAT_VFAILUNTRUST 0x5 /* Vaild but untrusted contents*/
+#define	PCI_MAPREG_ROM_VSTAT_WPASS	0x6 /* VPASS + warning */

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

2017-10-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct  4 11:03:21 UTC 2017

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

Log Message:
- ixv_enableintr(): Fix a bug that ixv_enable_queue() is called with incorrect
  argument. This bug was added in rev. 1.68.
- Don't check neither VTEICR nor VTEICS same as Linux. It seems that both
  registers can't be used to check which MSI-X vector is triggered. A bit is
  set on very low probability and the bit location is incorrect. Is this an
  errata?


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 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.68 src/sys/dev/pci/ixgbe/ixv.c:1.69
--- src/sys/dev/pci/ixgbe/ixv.c:1.68	Tue Oct  3 03:12:29 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Oct  4 11:03:20 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.68 2017/10/03 03:12:29 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.69 2017/10/04 11:03:20 msaitoh Exp $*/
 
 /**
 
@@ -912,20 +912,13 @@ ixv_msix_mbx(void *arg)
 {
 	struct adapter	*adapter = arg;
 	struct ixgbe_hw *hw = >hw;
-	u32		reg;
 
 	++adapter->link_irq.ev_count;
-
-	/* First get the cause */
-	reg = IXGBE_READ_REG(hw, IXGBE_VTEICR);
-#if 0	/* NetBSD: We use auto-clear, so it's not required to write VTEICR */
-	/* Clear interrupt with write */
-	IXGBE_WRITE_REG(hw, IXGBE_VTEICR, (1 << adapter->vector));
-#endif
+	/* NetBSD: We use auto-clear, so it's not required to write VTEICR */
 
 	/* Link status change */
-	if (reg & (1 << adapter->vector))
-		softint_schedule(adapter->link_si);
+	hw->mac.get_link_status = TRUE;
+	softint_schedule(adapter->link_si);
 
 	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, (1 << adapter->vector));
 
@@ -1865,6 +1858,7 @@ ixv_enable_intr(struct adapter *adapter)
 
 	/* For VTEIMS */
 	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, (1 << adapter->vector));
+	que = adapter->queues;
 	for (i = 0; i < adapter->num_queues; i++, que++)
 		ixv_enable_queue(adapter, que->msix);
 



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

2017-10-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct  4 08:47:26 UTC 2017

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

Log Message:
 Add 2.5GBASE-T and 5GBASE-T support. (forgotten in the last commit)


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/ixgbe/ixgbe_x540.c

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.28 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.29
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.28	Tue Oct  3 02:55:37 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Wed Oct  4 08:47:26 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.28 2017/10/03 02:55:37 msaitoh Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.29 2017/10/04 08:47:26 msaitoh Exp $ */
 
 /**
 
@@ -3424,6 +3424,8 @@ typedef u64 ixgbe_physical_layer;
 #define IXGBE_PHYSICAL_LAYER_1000BASE_SX	0x04000
 #define IXGBE_PHYSICAL_LAYER_10BASE_T		0x08000
 #define IXGBE_PHYSICAL_LAYER_2500BASE_KX	0x1
+#define IXGBE_PHYSICAL_LAYER_2500BASE_T		0x2
+#define IXGBE_PHYSICAL_LAYER_5GBASE_T		0x4
 
 /* Flow Control Data Sheet defined values
  * Calculation and defines taken from 802.1bb Annex O

Index: src/sys/dev/pci/ixgbe/ixgbe_x540.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.10 src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.11
--- src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.10	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_x540.c	Wed Oct  4 08:47:26 2017
@@ -350,6 +350,11 @@ u64 ixgbe_get_supported_physical_layer_X
 	if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY)
 		physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
 
+	if (hw->mac.type == ixgbe_mac_X550) {
+		physical_layer |= IXGBE_PHYSICAL_LAYER_2500BASE_T
+		| IXGBE_PHYSICAL_LAYER_5GBASE_T;
+	}
+
 	return physical_layer;
 }
 



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

2017-10-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct  4 07:13:00 UTC 2017

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

Log Message:
- Remove half-duplex setting for more than 1000Mbps in ixgbe_add_media_types()
  because those medias are not in the spec.
- Add 2.5GBASE-T and 5GBASE-T support. Tested with X550-T1.

Example:
ixg0: flags=0x8843 mtu 1500
capabilities=fff80
capabilities=fff80
capabilities=fff80
enabled=7ff80
enabled=7ff80
enabled=7ff80
ec_capabilities=7
ec_enabled=7
address: a0:36:9f:b0:f5:b0
media: Ethernet 2.5GBASE-T full-duplex
status: active
supported Ethernet media:
media 10Gbase-T
media 10Gbase-T mediaopt full-duplex
media 1000baseT
media 1000baseT mediaopt full-duplex
media 100baseTX
media 100baseTX mediaopt full-duplex
media 2.5GBASE-T mediaopt full-duplex
media 5GBASE-T mediaopt full-duplex
media autoselect
inet 172.16.0.1/24 broadcast 172.16.0.255 flags 0x0
inet6 fe80::a236:9fff:feb0:f5b0%ixg0/64 flags 0x0 scopeid 0x1


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 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.102 src/sys/dev/pci/ixgbe/ixgbe.c:1.103
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.102	Wed Oct  4 06:19:47 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Oct  4 07:13:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.102 2017/10/04 06:19:47 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.103 2017/10/04 07:13:00 msaitoh Exp $ */
 
 /**
 
@@ -1303,7 +1303,6 @@ ixgbe_add_media_types(struct adapter *ad
 
 	/* Media types with matching NetBSD media defines */
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_T) {
-		ADD(IFM_10G_T, 0);
 		ADD(IFM_10G_T | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_T) {
@@ -1321,54 +1320,43 @@ ixgbe_add_media_types(struct adapter *ad
 
 	if (layer & IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU ||
 	layer & IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA) {
-		ADD(IFM_10G_TWINAX, 0);
 		ADD(IFM_10G_TWINAX | IFM_FDX, 0);
 	}
 
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_LR) {
-		ADD(IFM_10G_LR, 0);
 		ADD(IFM_10G_LR | IFM_FDX, 0);
 		if (hw->phy.multispeed_fiber) {
-			ADD(IFM_1000_LX, 0);
 			ADD(IFM_1000_LX | IFM_FDX, 0);
 		}
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_SR) {
-		ADD(IFM_10G_SR, 0);
 		ADD(IFM_10G_SR | IFM_FDX, 0);
 		if (hw->phy.multispeed_fiber) {
-			ADD(IFM_1000_SX, 0);
 			ADD(IFM_1000_SX | IFM_FDX, 0);
 		}
 	} else if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_SX) {
-		ADD(IFM_1000_SX, 0);
 		ADD(IFM_1000_SX | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_CX4) {
-		ADD(IFM_10G_CX4, 0);
 		ADD(IFM_10G_CX4 | IFM_FDX, 0);
 	}
 
 #ifdef IFM_ETH_XTYPE
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KR) {
-		ADD(IFM_10G_KR, 0);
 		ADD(IFM_10G_KR | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KX4) {
-		ADD(AIFM_10G_KX4, 0);
 		ADD(AIFM_10G_KX4 | IFM_FDX, 0);
 	}
 #else
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KR) {
 		device_printf(dev, "Media supported: 10GbaseKR\n");
 		device_printf(dev, "10GbaseKR mapped to 10GbaseSR\n");
-		ADD(IFM_10G_SR, 0);
 		ADD(IFM_10G_SR | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KX4) {
 		device_printf(dev, "Media supported: 10GbaseKX4\n");
 		device_printf(dev, "10GbaseKX4 mapped to 10GbaseCX4\n");
-		ADD(IFM_10G_CX4, 0);
 		ADD(IFM_10G_CX4 | IFM_FDX, 0);
 	}
 #endif
@@ -1377,9 +1365,14 @@ ixgbe_add_media_types(struct adapter *ad
 		ADD(IFM_1000_KX | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_2500BASE_KX) {
-		ADD(IFM_2500_KX, 0);
 		ADD(IFM_2500_KX | IFM_FDX, 0);
 	}
+	if (layer & IXGBE_PHYSICAL_LAYER_2500BASE_T) {
+		ADD(IFM_2500_T | IFM_FDX, 0);
+	}
+	if (layer & IXGBE_PHYSICAL_LAYER_5GBASE_T) {
+		ADD(IFM_5000_T | IFM_FDX, 0);
+	}
 	if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_BX)
 		device_printf(dev, "Media supported: 1000baseBX\n");
 	/* XXX no ifmedia_set? */
@@ -2490,6 +2483,8 @@ ixgbe_media_status(struct ifnet *ifp, st
 	layer = adapter->phy_layer;
 
 	if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_T ||
+	layer & IXGBE_PHYSICAL_LAYER_5GBASE_T ||
+	layer & IXGBE_PHYSICAL_LAYER_2500BASE_T ||
 	layer & IXGBE_PHYSICAL_LAYER_1000BASE_T ||
 	

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

2017-10-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct  4 06:19:47 UTC 2017

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

Log Message:
 Fix a bug that X550EM (Denverton) can't force 10BaseT.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 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.101 src/sys/dev/pci/ixgbe/ixgbe.c:1.102
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.101	Wed Sep 27 10:31:29 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Oct  4 06:19:47 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.101 2017/09/27 10:31:29 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.102 2017/10/04 06:19:47 msaitoh Exp $ */
 
 /**
 
@@ -2691,7 +2691,7 @@ ixgbe_media_change(struct ifnet *ifp)
 		if ((speed & IXGBE_LINK_SPEED_100_FULL) != 0)
 			adapter->advertise |= 1 << 0;
 		if ((speed & IXGBE_LINK_SPEED_10_FULL) != 0)
-			adapter->advertise |= 1 << 4;
+			adapter->advertise |= 1 << 3;
 	}
 
 	return (0);



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

2017-10-02 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Oct  3 03:12:29 UTC 2017

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

Log Message:
 Fix a problem that mailbox interrupt never occured. Bit definitions of PF's
interrupt related registers and VF's interrupt registers a completely
different. VF's registers (VF{EICR, EICS, EIMS, EIMC, EIAC, EIAM})'s bits are
just MSI-X vector bitmask, so read/write correctly. Read VTEICR instead of
VTEICS in ixv_msix_mbx (note that "PF" has a errata that EICS is required to
read the cause). Don't write IXGBE_VTEICR in ixv_msix_mbx() because we use
auto-clear for mailbox interrupt.

 We have gotten link status change by timer instead of interrupt before
this fix...


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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.67 src/sys/dev/pci/ixgbe/ixv.c:1.68
--- src/sys/dev/pci/ixgbe/ixv.c:1.67	Tue Oct  3 02:55:37 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Tue Oct  3 03:12:29 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.67 2017/10/03 02:55:37 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.68 2017/10/03 03:12:29 msaitoh Exp $*/
 
 /**
 
@@ -682,7 +682,10 @@ ixv_init_locked(struct adapter *adapter)
 	struct ifnet	*ifp = adapter->ifp;
 	device_t 	dev = adapter->dev;
 	struct ixgbe_hw *hw = >hw;
+	struct ix_queue	*que = adapter->queues;
 	int error = 0;
+	uint32_t mask;
+	int i;
 
 	INIT_DEBUGOUT("ixv_init_locked: begin");
 	KASSERT(mutex_owned(>core_mtx));
@@ -756,7 +759,10 @@ ixv_init_locked(struct adapter *adapter)
 	ixv_configure_ivars(adapter);
 
 	/* Set up auto-mask */
-	IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_EICS_RTX_QUEUE);
+	mask = (1 << adapter->vector);
+	for (i = 0; i < adapter->num_queues; i++, que++)
+		mask |= (1 << que->msix);
+	IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, mask);
 
 	/* Set moderation on the Link interrupt */
 	IXGBE_WRITE_REG(hw, IXGBE_VTEITR(adapter->vector), IXGBE_LINK_ITR);
@@ -911,15 +917,17 @@ ixv_msix_mbx(void *arg)
 	++adapter->link_irq.ev_count;
 
 	/* First get the cause */
-	reg = IXGBE_READ_REG(hw, IXGBE_VTEICS);
+	reg = IXGBE_READ_REG(hw, IXGBE_VTEICR);
+#if 0	/* NetBSD: We use auto-clear, so it's not required to write VTEICR */
 	/* Clear interrupt with write */
-	IXGBE_WRITE_REG(hw, IXGBE_VTEICR, reg);
+	IXGBE_WRITE_REG(hw, IXGBE_VTEICR, (1 << adapter->vector));
+#endif
 
 	/* Link status change */
-	if (reg & IXGBE_EICR_LSC)
+	if (reg & (1 << adapter->vector))
 		softint_schedule(adapter->link_si);
 
-	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_EIMS_OTHER);
+	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, (1 << adapter->vector));
 
 	return 1;
 } /* ixv_msix_mbx */
@@ -1846,16 +1854,18 @@ ixv_enable_intr(struct adapter *adapter)
 {
 	struct ixgbe_hw *hw = >hw;
 	struct ix_queue *que = adapter->queues;
-	u32 mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE);
-
-
-	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
+	u32 mask;
+	int i;
 
-	mask = IXGBE_EIMS_ENABLE_MASK;
-	mask &= ~(IXGBE_EIMS_OTHER | IXGBE_EIMS_LSC);
+	/* For VTEIAC */
+	mask = (1 << adapter->vector);
+	for (i = 0; i < adapter->num_queues; i++, que++)
+		mask |= (1 << que->msix);
 	IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, mask);
 
-	for (int i = 0; i < adapter->num_queues; i++, que++)
+	/* For VTEIMS */
+	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, (1 << adapter->vector));
+	for (i = 0; i < adapter->num_queues; i++, que++)
 		ixv_enable_queue(adapter, que->msix);
 
 	IXGBE_WRITE_FLUSH(hw);



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

2017-10-02 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Oct  3 02:55:37 UTC 2017

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

Log Message:
 Make mailbox statistic counters evcnt(9).
Example:
 > ixv0 message TXs230 misc
 > ixv0 message RXs  29110 misc
 > ixv0 ACKs   230 misc
 > ixv0 REQs   220 misc
 > ixv0 RSTs00 misc


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/ixgbe_mbx.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.66 -r1.67 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_mbx.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.7 src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.8
--- src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.7	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_mbx.c	Tue Oct  3 02:55:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_mbx.c,v 1.7 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe_mbx.c,v 1.8 2017/10/03 02:55:37 msaitoh Exp $ */
 
 /**
 
@@ -231,7 +231,7 @@ static s32 ixgbe_check_for_msg_vf(struct
 
 	if (!ixgbe_check_for_bit_vf(hw, IXGBE_VFMAILBOX_PFSTS)) {
 		ret_val = IXGBE_SUCCESS;
-		hw->mbx.stats.reqs++;
+		hw->mbx.stats.reqs.ev_count++;
 	}
 
 	return ret_val;
@@ -253,7 +253,7 @@ static s32 ixgbe_check_for_ack_vf(struct
 
 	if (!ixgbe_check_for_bit_vf(hw, IXGBE_VFMAILBOX_PFACK)) {
 		ret_val = IXGBE_SUCCESS;
-		hw->mbx.stats.acks++;
+		hw->mbx.stats.acks.ev_count++;
 	}
 
 	return ret_val;
@@ -276,7 +276,7 @@ static s32 ixgbe_check_for_rst_vf(struct
 	if (!ixgbe_check_for_bit_vf(hw, (IXGBE_VFMAILBOX_RSTD |
 	IXGBE_VFMAILBOX_RSTI))) {
 		ret_val = IXGBE_SUCCESS;
-		hw->mbx.stats.rsts++;
+		hw->mbx.stats.rsts.ev_count++;
 	}
 
 	return ret_val;
@@ -337,7 +337,7 @@ static s32 ixgbe_write_mbx_vf(struct ixg
 		IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]);
 
 	/* update stats */
-	hw->mbx.stats.msgs_tx++;
+	hw->mbx.stats.msgs_tx.ev_count++;
 
 	/* Drop VFU and interrupt the PF to tell it a message has been sent */
 	IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_REQ);
@@ -377,7 +377,7 @@ static s32 ixgbe_read_mbx_vf(struct ixgb
 	IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_ACK);
 
 	/* update stats */
-	hw->mbx.stats.msgs_rx++;
+	hw->mbx.stats.msgs_rx.ev_count++;
 
 out_no_read:
 	return ret_val;
@@ -408,11 +408,11 @@ void ixgbe_init_mbx_params_vf(struct ixg
 	mbx->ops.check_for_ack = ixgbe_check_for_ack_vf;
 	mbx->ops.check_for_rst = ixgbe_check_for_rst_vf;
 
-	mbx->stats.msgs_tx = 0;
-	mbx->stats.msgs_rx = 0;
-	mbx->stats.reqs = 0;
-	mbx->stats.acks = 0;
-	mbx->stats.rsts = 0;
+	mbx->stats.msgs_tx.ev_count = 0;
+	mbx->stats.msgs_rx.ev_count = 0;
+	mbx->stats.reqs.ev_count = 0;
+	mbx->stats.acks.ev_count = 0;
+	mbx->stats.rsts.ev_count = 0;
 }
 
 static s32 ixgbe_check_for_bit_pf(struct ixgbe_hw *hw, u32 mask, s32 index)
@@ -446,7 +446,7 @@ static s32 ixgbe_check_for_msg_pf(struct
 	if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFREQ_VF1 << vf_bit,
 index)) {
 		ret_val = IXGBE_SUCCESS;
-		hw->mbx.stats.reqs++;
+		hw->mbx.stats.reqs.ev_count++;
 	}
 
 	return ret_val;
@@ -470,7 +470,7 @@ static s32 ixgbe_check_for_ack_pf(struct
 	if (!ixgbe_check_for_bit_pf(hw, IXGBE_MBVFICR_VFACK_VF1 << vf_bit,
 index)) {
 		ret_val = IXGBE_SUCCESS;
-		hw->mbx.stats.acks++;
+		hw->mbx.stats.acks.ev_count++;
 	}
 
 	return ret_val;
@@ -509,7 +509,7 @@ static s32 ixgbe_check_for_rst_pf(struct
 	if (vflre & (1 << vf_shift)) {
 		ret_val = IXGBE_SUCCESS;
 		IXGBE_WRITE_REG(hw, IXGBE_VFLREC(reg_offset), (1 << vf_shift));
-		hw->mbx.stats.rsts++;
+		hw->mbx.stats.rsts.ev_count++;
 	}
 
 	return ret_val;
@@ -578,7 +578,7 @@ static s32 ixgbe_write_mbx_pf(struct ixg
 	IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_STS);
 
 	/* update stats */
-	hw->mbx.stats.msgs_tx++;
+	hw->mbx.stats.msgs_tx.ev_count++;
 
 out_no_write:
 	return ret_val;
@@ -617,7 +617,7 @@ static s32 ixgbe_read_mbx_pf(struct ixgb
 	IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_number), IXGBE_PFMAILBOX_ACK);
 
 	/* update stats */
-	hw->mbx.stats.msgs_rx++;
+	hw->mbx.stats.msgs_rx.ev_count++;
 
 out_no_read:
 	return ret_val;
@@ -653,9 +653,9 @@ void ixgbe_init_mbx_params_pf(struct ixg
 	mbx->ops.check_for_ack = ixgbe_check_for_ack_pf;
 	mbx->ops.check_for_rst = ixgbe_check_for_rst_pf;
 
-	mbx->stats.msgs_tx = 0;
-	mbx->stats.msgs_rx = 0;
-	mbx->stats.reqs = 0;
-	mbx->stats.acks = 0;
-	mbx->stats.rsts = 0;
+	mbx->stats.msgs_tx.ev_count = 0;
+	mbx->stats.msgs_rx.ev_count = 0;
+	mbx->stats.reqs.ev_count = 0;
+	

CVS commit: src/sys/dev/pci

2017-09-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 28 16:24:39 UTC 2017

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

Log Message:
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 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.311 src/sys/dev/pci/if_bge.c:1.312
--- src/sys/dev/pci/if_bge.c:1.311	Tue Sep 26 03:42:06 2017
+++ src/sys/dev/pci/if_bge.c	Thu Sep 28 12:24:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.311 2017/09/26 07:42:06 knakahara Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.312 2017/09/28 16:24:39 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.311 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.312 2017/09/28 16:24:39 christos 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);
+			vlan_set_tag(m, cur_rx->bge_vlan_tag & ETHER_VLAN_MASK);
 		}
 
 		if_percpuq_enqueue(ifp->if_percpuq, m);
@@ -5332,7 +5332,8 @@ doit:
 	}
 
 	have_vtag = vlan_has_tag(m_head);
-	vtag = vlan_get_tag(m_head);
+	if (have_vtag)
+		vtag = vlan_get_tag(m_head);
 
 	/* Iterate over dmap-map fragments. */
 	for (i = 0; i < dmamap->dm_nsegs; i++) {



CVS commit: src/sys/dev/pci

2017-09-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 28 16:23:57 UTC 2017

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

Log Message:
only get vtag when we have vtag like the other drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/if_stge.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_stge.c
diff -u src/sys/dev/pci/if_stge.c:1.63 src/sys/dev/pci/if_stge.c:1.64
--- src/sys/dev/pci/if_stge.c:1.63	Tue Sep 26 03:42:06 2017
+++ src/sys/dev/pci/if_stge.c	Thu Sep 28 12:23:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_stge.c,v 1.63 2017/09/26 07:42:06 knakahara Exp $	*/
+/*	$NetBSD: if_stge.c,v 1.64 2017/09/28 16:23:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.63 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.64 2017/09/28 16:23:57 christos Exp $");
 
 
 #include 
@@ -829,7 +829,8 @@ stge_start(struct ifnet *ifp)
 		 * See if we have any VLAN stuff.
 		 */
 		have_vtag = vlan_has_tag(m0);
-		vtag = vlan_get_tag(m0);
+		if (have_vtag)
+			vtag = vlan_get_tag(m0);
 
 		/*
 		 * Get the last and next available transmit descriptor.



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

2017-09-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep 27 10:31:29 UTC 2017

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

Log Message:
 Print device name in ixv_attach().


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.65 -r1.66 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.100 src/sys/dev/pci/ixgbe/ixgbe.c:1.101
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.100	Thu Aug 31 02:48:55 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Sep 27 10:31:29 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.100 2017/08/31 02:48:55 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.101 2017/09/27 10:31:29 msaitoh Exp $ */
 
 /**
 
@@ -823,15 +823,9 @@ ixgbe_attach(device_t parent, device_t d
 	case ixgbe_mac_82599EB:
 		str = "82599EB";
 		break;
-	case ixgbe_mac_82599_vf:
-		str = "82599 VF";
-		break;
 	case ixgbe_mac_X540:
 		str = "X540";
 		break;
-	case ixgbe_mac_X540_vf:
-		str = "X540 VF";
-		break;
 	case ixgbe_mac_X550:
 		str = "X550";
 		break;
@@ -841,15 +835,6 @@ ixgbe_attach(device_t parent, device_t d
 	case ixgbe_mac_X550EM_a:
 		str = "X550EM A";
 		break;
-	case ixgbe_mac_X550_vf:
-		str = "X550 VF";
-		break;
-	case ixgbe_mac_X550EM_x_vf:
-		str = "X550EM X VF";
-		break;
-	case ixgbe_mac_X550EM_a_vf:
-		str = "X550EM A VF";
-		break;
 	default:
 		str = "Unknown";
 		break;

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.65 src/sys/dev/pci/ixgbe/ixv.c:1.66
--- src/sys/dev/pci/ixgbe/ixv.c:1.65	Fri Sep 15 08:31:32 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Sep 27 10:31:29 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.65 2017/09/15 08:31:32 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.66 2017/09/27 10:31:29 msaitoh Exp $*/
 
 /**
 
@@ -284,6 +284,7 @@ ixv_attach(device_t parent, device_t dev
 	ixgbe_vendor_info_t *ent;
 	const struct pci_attach_args *pa = aux;
 	const char *apivstr;
+	const char *str;
 	char buf[256];
 
 	INIT_DEBUGOUT("ixv_attach: begin");
@@ -348,18 +349,23 @@ ixv_attach(device_t parent, device_t dev
 	switch (hw->device_id) {
 	case IXGBE_DEV_ID_82599_VF:
 		hw->mac.type = ixgbe_mac_82599_vf;
+		str = "82599 VF";
 		break;
 	case IXGBE_DEV_ID_X540_VF:
 		hw->mac.type = ixgbe_mac_X540_vf;
+		str = "X540 VF";
 		break;
 	case IXGBE_DEV_ID_X550_VF:
 		hw->mac.type = ixgbe_mac_X550_vf;
+		str = "X550 VF";
 		break;
 	case IXGBE_DEV_ID_X550EM_X_VF:
 		hw->mac.type = ixgbe_mac_X550EM_x_vf;
+		str = "X550EM X VF";
 		break;
 	case IXGBE_DEV_ID_X550EM_A_VF:
 		hw->mac.type = ixgbe_mac_X550EM_a_vf;
+		str = "X550EM A VF";
 		break;
 	default:
 		/* Shouldn't get here since probe succeeded */
@@ -368,6 +374,7 @@ ixv_attach(device_t parent, device_t dev
 		goto err_out;
 		break;
 	}
+	aprint_normal_dev(dev, "device %s\n", str);
 
 	ixv_init_device_features(adapter);
 



CVS commit: src/sys/dev/pci

2017-09-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 26 08:25:56 UTC 2017

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

Log Message:
- Correct NVM word size check in wm_nvm_version() to prevent
  "EERD polling failed" error on attach. if_wm.c rev. 1.534 was not perfect.
  Reported by ozaki-r@.
- Print NVM offset and word count when EERD polling failed.

XXX pullup-8.


To generate a diff of this commit:
cvs rdiff -u -r1.538 -r1.539 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.538 src/sys/dev/pci/if_wm.c:1.539
--- src/sys/dev/pci/if_wm.c:1.538	Tue Sep 26 07:42:06 2017
+++ src/sys/dev/pci/if_wm.c	Tue Sep 26 08:25:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.538 2017/09/26 07:42:06 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.539 2017/09/26 08:25:56 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.538 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.539 2017/09/26 08:25:56 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -11768,7 +11768,8 @@ wm_nvm_read_eerd(struct wm_softc *sc, in
 		CSR_WRITE(sc, WMREG_EERD, eerd);
 		rv = wm_poll_eerd_eewr_done(sc, WMREG_EERD);
 		if (rv != 0) {
-			aprint_error_dev(sc->sc_dev, "EERD polling failed\n");
+			aprint_error_dev(sc->sc_dev, "EERD polling failed: "
+			"offset=%d. wordcnt=%d\n", offset, wordcnt);
 			break;
 		}
 		data[i] = (CSR_READ(sc, WMREG_EERD) >> EERD_DATA_SHIFT);
@@ -12549,7 +12550,7 @@ printver:
 	}
 
 	/* Assume the Option ROM area is at avove NVM_SIZE */
-	if ((sc->sc_nvm_wordsize >= NVM_SIZE) && check_optionrom
+	if ((sc->sc_nvm_wordsize > NVM_SIZE) && check_optionrom
 	&& (wm_nvm_read(sc, NVM_OFF_COMB_VER_PTR, 1, ) == 0)) {
 		/* Option ROM Version */
 		if ((off != 0x) && (off != 0x)) {



CVS commit: src/sys/dev/pci

2017-09-15 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Fri Sep 15 14:24:32 UTC 2017

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

Log Message:
Add Intel QuickAssist devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1297 -r1.1298 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.1297 src/sys/dev/pci/pcidevs:1.1298
--- src/sys/dev/pci/pcidevs:1.1297	Thu Aug 17 01:05:22 2017
+++ src/sys/dev/pci/pcidevs	Fri Sep 15 14:24:32 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1297 2017/08/17 01:05:22 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1298 2017/09/15 14:24:32 hikaru Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3264,6 +3264,7 @@ product INTEL C3K_SMBUS_LEGACY	0x19df	C3
 product INTEL C3K_SPI		0x19e0	C3000 SPI
 product INTEL C3K_TRACE		0x19e1	C3000 Trace Hub
 product INTEL C3K_QAT		0x19e2	C3000 QAT
+product INTEL C3K_QAT_VF	0x19e3	C3000 QAT Virtual Function
 product INTEL C3K_IE_HECI_1	0x19e5	C3000 IE HECI 1
 product INTEL C3K_IE_HECI_2	0x19e6	C3000 IE HECI 2
 product INTEL C3K_IE_KT		0x19e8	C3000 IE KT
@@ -4087,6 +4088,8 @@ product INTEL E7520_PCIE_B1	0x3598	E7520
 product INTEL E7520_PCIE_C	0x3599	E7520 PCI Express Port C
 product INTEL E7520_PCIE_C1	0x359a	E7520 PCI Express Port C1
 product INTEL E7520_CFG		0x359b	E7520 Extended Configuration
+product INTEL C620_QAT		0x37c8	C620 QAT
+product INTEL C620_QAT_VF	0x37c9	C620 QAT Virtual Function
 product INTEL 82801JD_SATA_IDE	0x3a00	82801JD SATA Controller (IDE mode)
 product INTEL 82801JD_SATA_AHCI	0x3a02	82801JD SATA Controller (AHCI mode)
 product INTEL 82801JD_SATA_RAID	0x3a05	82801JD SATA Controller (RAID mode)
@@ -4341,6 +4344,8 @@ product INTEL XEOND_QD_1	0x6f50	Xeon-D Q
 product INTEL XEOND_QD_2	0x6f51	Xeon-D QuickData DMA Channel 1
 product INTEL XEOND_QD_3	0x6f52	Xeon-D QuickData DMA Channel 2
 product INTEL XEOND_QD_4	0x6f53	Xeon-D QuickData DMA Channel 3
+product INTEL XEOND_QAT		0x6f54	Xeon-D QAT
+product INTEL XEOND_QAT_VF	0x6f55	Xeon-D QAT Virtual Function
 product INTEL COREI76K_IMC_0	0x6f68	Core i7-6xxxK IMC
 product INTEL XEOND_HA0_DEBUG	0x6f70	Xeon-D Home Agent 0 Debug
 product INTEL XEOND_MEM_0_TTR_0	0x6f71	Core i7-6xxxK/Xeon-D Memory Controller (Target Address, Thermal, RAS)



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

2017-09-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Sep 15 08:31:32 UTC 2017

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

Log Message:
xv(4) VLAN fixes:
- Dirty hack for VID mask bits. On ixg(4), VLAN filter is disabled. So any
  vlan ID's packet passes RX filter. On ixv(4), usually, PF driver uses
  VLAN filter enabled. There is no way to disable PF's VLAN filter function
  itself. NetBSD's Ethernet driver has currently no API to know which VLAN ID
  should be accepted. To avoid this proble, enable all VIDs... Yes, I know
  this is dirty hack. We should rethink.
- Call ixv_setup_vlan_support() in ixv_ifflags_cb().
- Don't use global ixv_shadow_vfta[].
- Use local variable (rxr->) to reduce diff against ixgbe.c. No functional
  change.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 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.64 src/sys/dev/pci/ixgbe/ixv.c:1.65
--- src/sys/dev/pci/ixgbe/ixv.c:1.64	Fri Sep 15 04:52:32 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Fri Sep 15 08:31:32 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.64 2017/09/15 04:52:32 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.65 2017/09/15 08:31:32 msaitoh Exp $*/
 
 /**
 
@@ -204,13 +204,6 @@ TUNABLE_INT("hw.ixv.rxd", _rxd);
 static int ixv_enable_legacy_tx = 0;
 TUNABLE_INT("hw.ixv.enable_legacy_tx", _enable_legacy_tx);
 
-/*
- * Shadow VFTA table, this is needed because
- * the real filter table gets cleared during
- * a soft reset and we need to repopulate it.
- */
-static u32 ixv_shadow_vfta[IXGBE_VFTA_SIZE];
-
 #ifdef NET_MPSAFE
 #define IXGBE_MPSAFE		1
 #define IXGBE_CALLOUT_FLAGS	CALLOUT_MPSAFE
@@ -1713,7 +1706,9 @@ ixv_initialize_receive_units(struct adap
 static void
 ixv_setup_vlan_support(struct adapter *adapter)
 {
+	struct ethercom *ec = >osdep.ec;
 	struct ixgbe_hw *hw = >hw;
+	struct rx_ring  *rxr;
 	u32		ctrl, vid, vfta, retry;
 
 	/*
@@ -1722,29 +1717,35 @@ ixv_setup_vlan_support(struct adapter *a
 	 * the VFTA and other state, so if there
 	 * have been no vlan's registered do nothing.
 	 */
-	if (!VLAN_ATTACHED(>osdep.ec))
+	if (!VLAN_ATTACHED(ec))
 		return;
 
 	/* Enable the queues */
 	for (int i = 0; i < adapter->num_queues; i++) {
-		ctrl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
+		rxr = >rx_rings[i];
+		ctrl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(rxr->me));
 		ctrl |= IXGBE_RXDCTL_VME;
-		IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), ctrl);
+		IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(rxr->me), ctrl);
 		/*
 		 * Let Rx path know that it needs to store VLAN tag
 		 * as part of extra mbuf info.
 		 */
-		adapter->rx_rings[i].vtag_strip = TRUE;
+		rxr->vtag_strip = TRUE;
 	}
 
+#if 1
+	/* XXX dirty hack. Enable all VIDs */
+	for (int i = 0; i < IXGBE_VFTA_SIZE; i++)
+	  adapter->shadow_vfta[i] = 0x;
+#endif
 	/*
 	 * A soft reset zero's out the VFTA, so
 	 * we need to repopulate it now.
 	 */
 	for (int i = 0; i < IXGBE_VFTA_SIZE; i++) {
-		if (ixv_shadow_vfta[i] == 0)
+		if (adapter->shadow_vfta[i] == 0)
 			continue;
-		vfta = ixv_shadow_vfta[i];
+		vfta = adapter->shadow_vfta[i];
 		/*
 		 * Reconstruct the vlan id's
 		 * based on the bits set in each
@@ -1788,7 +1789,7 @@ ixv_register_vlan(void *arg, struct ifne
 	IXGBE_CORE_LOCK(adapter);
 	index = (vtag >> 5) & 0x7F;
 	bit = vtag & 0x1F;
-	ixv_shadow_vfta[index] |= (1 << bit);
+	adapter->shadow_vfta[index] |= (1 << bit);
 	/* Re-init to load the changes */
 	ixv_init_locked(adapter);
 	IXGBE_CORE_UNLOCK(adapter);
@@ -1815,7 +1816,7 @@ ixv_unregister_vlan(void *arg, struct if
 	IXGBE_CORE_LOCK(adapter);
 	index = (vtag >> 5) & 0x7F;
 	bit = vtag & 0x1F;
-	ixv_shadow_vfta[index] &= ~(1 << bit);
+	adapter->shadow_vfta[index] &= ~(1 << bit);
 	/* Re-init to load the changes */
 	ixv_init_locked(adapter);
 	IXGBE_CORE_UNLOCK(adapter);
@@ -2414,6 +2415,9 @@ ixv_ifflags_cb(struct ethercom *ec)
 	if ((change & ~(IFF_CANTCHANGE | IFF_DEBUG)) != 0)
 		rc = ENETRESET;
 
+	/* Set up VLAN support and filter */
+	ixv_setup_vlan_support(adapter);
+
 	IXGBE_CORE_UNLOCK(adapter);
 
 	return rc;



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

2017-09-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Sep 15 04:52:32 UTC 2017

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

Log Message:
 Make ixv(4) TX/RX descriptors size the same as ixg(4).


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 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.63 src/sys/dev/pci/ixgbe/ixv.c:1.64
--- src/sys/dev/pci/ixgbe/ixv.c:1.63	Wed Sep 13 04:50:50 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Fri Sep 15 04:52:32 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.63 2017/09/13 04:50:50 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.64 2017/09/15 04:52:32 msaitoh Exp $*/
 
 /**
 
@@ -193,11 +193,11 @@ TUNABLE_INT("hw.ixv.tx_process_limit", &
  * setting higher than RX as this seems
  * the better performing choice.
  */
-static int ixv_txd = DEFAULT_TXD;
+static int ixv_txd = PERFORM_TXD;
 TUNABLE_INT("hw.ixv.txd", _txd);
 
 /* Number of RX descriptors per ring */
-static int ixv_rxd = DEFAULT_RXD;
+static int ixv_rxd = PERFORM_RXD;
 TUNABLE_INT("hw.ixv.rxd", _rxd);
 
 /* Legacy Transmit (single queue) */



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

2017-09-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Sep 14 09:25:58 UTC 2017

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

Log Message:
 Quick hack to fix ixv(4)'s hardware counter. ixgbe_rx_checksum() passes
"struct ixgbe_hw_stats *" even if its a virtual function. The layout between
ixgbe_hw_stats and ixgbevf_hw_stats are different, so ixgbe_rx_checksum()
wrote wrong area if a device is a virtual function. To fix this problem with
small change, move the location of ipcs, ipcs_bad, l4cs and l4cs_bad of
struct ixgbe(vf)_hw_stats to the same location at the biggining of the struct.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/ixgbe/ixgbe_vf.h

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.26 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.27
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.26	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Thu Sep 14 09:25:58 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.26 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.27 2017/09/14 09:25:58 msaitoh Exp $ */
 
 /**
 
@@ -3799,6 +3799,11 @@ struct ixgbe_fc_info {
 /* Statistics counters collected by the MAC */
 struct ixgbe_hw_stats {
 	char namebuf[32];
+	struct evcnt ipcs;
+	struct evcnt ipcs_bad;
+	struct evcnt l4cs;
+	struct evcnt l4cs_bad;
+
 	struct evcnt crcerrs;
 	struct evcnt illerrc;
 	struct evcnt errbc;
@@ -3878,10 +3883,6 @@ struct ixgbe_hw_stats {
 	struct evcnt o2bspc;
 	struct evcnt legint;	/* legacy interrupts */
 	struct evcnt intzero;	/* no legacy interrupt conditions */
-	struct evcnt ipcs;
-	struct evcnt ipcs_bad;
-	struct evcnt l4cs;
-	struct evcnt l4cs_bad;
 };
 
 /* forward declaration */

Index: src/sys/dev/pci/ixgbe/ixgbe_vf.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.9 src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.10
--- src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.9	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.h	Thu Sep 14 09:25:58 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.h,v 1.9 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.h,v 1.10 2017/09/14 09:25:58 msaitoh Exp $ */
 
 /**
 
@@ -93,6 +93,11 @@
 
 struct ixgbevf_hw_stats {
 	char namebuf[32];
+	struct evcnt ipcs;
+	struct evcnt ipcs_bad;
+	struct evcnt l4cs;
+	struct evcnt l4cs_bad;
+
 	u64 base_vfgprc;
 	u64 base_vfgptc;
 	u64 base_vfgorc;
@@ -116,11 +121,6 @@ struct ixgbevf_hw_stats {
 	u64 saved_reset_vfgorc;
 	u64 saved_reset_vfgotc;
 	u64 saved_reset_vfmprc;
-
-	struct evcnt ipcs;
-	struct evcnt ipcs_bad;
-	struct evcnt l4cs;
-	struct evcnt l4cs_bad;
 };
 
 s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw);



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

2017-09-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep 13 04:50:50 UTC 2017

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

Log Message:
- Print driver feature capabilities and enable bits when verbose boot as
  ixgbe.c rev. 1.99.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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.62 src/sys/dev/pci/ixgbe/ixv.c:1.63
--- src/sys/dev/pci/ixgbe/ixv.c:1.62	Wed Sep 13 04:48:40 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Sep 13 04:50:50 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.62 2017/09/13 04:48:40 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.63 2017/09/13 04:50:50 msaitoh Exp $*/
 
 /**
 
@@ -291,6 +291,8 @@ ixv_attach(device_t parent, device_t dev
 	ixgbe_vendor_info_t *ent;
 	const struct pci_attach_args *pa = aux;
 	const char *apivstr;
+	char buf[256];
+
 	INIT_DEBUGOUT("ixv_attach: begin");
 
 	/*
@@ -408,7 +410,7 @@ ixv_attach(device_t parent, device_t dev
 		error = EIO;
 		goto err_out;
 	}
-	
+
 	/* Negotiate mailbox API version */
 	error = ixv_negotiate_api(adapter);
 	if (error)
@@ -480,7 +482,7 @@ ixv_attach(device_t parent, device_t dev
 		adapter->num_rx_desc = ixv_rxd;
 
 	/* Setup MSI-X */
-	error = ixv_configure_interrupts(adapter); 
+	error = ixv_configure_interrupts(adapter);
 	if (error)
 		goto err_out;
 
@@ -511,6 +513,11 @@ ixv_attach(device_t parent, device_t dev
 	if (adapter->feat_en & IXGBE_FEATURE_NETMAP)
 		ixgbe_netmap_attach(adapter);
 
+	snprintb(buf, sizeof(buf), IXGBE_FEATURE_FLAGS, adapter->feat_cap);
+	aprint_verbose_dev(dev, "feature cap %s\n", buf);
+	snprintb(buf, sizeof(buf), IXGBE_FEATURE_FLAGS, adapter->feat_en);
+	aprint_verbose_dev(dev, "feature ena %s\n", buf);
+
 	INIT_DEBUGOUT("ixv_attach: end");
 	adapter->osdep.attached = true;
 
@@ -673,7 +680,7 @@ ixv_init_locked(struct adapter *adapter)
 	KASSERT(mutex_owned(>core_mtx));
 	hw->adapter_stopped = FALSE;
 	hw->mac.ops.stop_adapter(hw);
-callout_stop(>timer);
+	callout_stop(>timer);
 
 	/* reprogram the RAR[0] in case user changed it. */
 	hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
@@ -838,7 +845,7 @@ ixv_msix_que(void *arg)
 	 *  - Calculate based on average size over
 	 *the last interval.
 	 */
-if (que->eitr_setting)
+	if (que->eitr_setting)
 		IXGBE_WRITE_REG(>hw, IXGBE_VTEITR(que->msix),
 		que->eitr_setting);
 
@@ -916,7 +923,7 @@ ixv_msix_mbx(void *arg)
  *   the interface using ifconfig.
  /
 static void
-ixv_media_status(struct ifnet * ifp, struct ifmediareq * ifmr)
+ixv_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
 {
 	struct adapter *adapter = ifp->if_softc;
 
@@ -1190,7 +1197,7 @@ ixv_update_link_status(struct adapter *a
 	bpsmsg = "unknown speed";
 	break;
 }
-device_printf(dev,"Link is up %s %s \n",
+device_printf(dev, "Link is up %s %s \n",
 bpsmsg, "Full Duplex");
 			}
 			adapter->link_active = TRUE;
@@ -1199,7 +1206,7 @@ ixv_update_link_status(struct adapter *a
 	} else { /* Link down */
 		if (adapter->link_active == TRUE) {
 			if (bootverbose)
-device_printf(dev,"Link is Down\n");
+device_printf(dev, "Link is Down\n");
 			if_link_state_change(ifp, LINK_STATE_DOWN);
 			adapter->link_active = FALSE;
 		}
@@ -1897,7 +1904,7 @@ ixv_configure_ivars(struct adapter *adap
 		/* ... and the TX */
 		ixv_set_ivar(adapter, i, que->msix, 1);
 		/* Set an initial value in EITR */
-IXGBE_WRITE_REG(>hw, IXGBE_VTEITR(que->msix),
+		IXGBE_WRITE_REG(>hw, IXGBE_VTEITR(que->msix),
 		IXGBE_EITR_DEFAULT);
 	}
 
@@ -1932,7 +1939,7 @@ ixv_save_stats(struct adapter *adapter)
 		stats->vfmprc.ev_count - stats->base_vfmprc;
 	}
 } /* ixv_save_stats */
- 
+
 /
  * ixv_init_stats
  /
@@ -1988,7 +1995,7 @@ ixv_init_stats(struct adapter *adapter)
 void
 ixv_update_stats(struct adapter *adapter)
 {
-struct ixgbe_hw *hw = >hw;
+	struct ixgbe_hw *hw = >hw;
 	struct ixgbevf_hw_stats *stats = >stats.vf;
 
 UPDATE_STAT_32(IXGBE_VFGPRC, stats->last_vfgprc, stats->vfgprc);
@@ -2273,7 +2280,7 @@ ixv_print_debug_info(struct adapter *ada
 struct lro_ctrl *lro;
 #endif /* LRO */
 
-	device_printf(dev,"Error Byte Count = %u \n",
+	device_printf(dev, "Error Byte Count = %u \n",
 	IXGBE_READ_REG(hw, IXGBE_ERRBC));
 
 	for (int i = 0; i < adapter->num_queues; i++, que++) {
@@ -2282,21 +2289,21 @@ ixv_print_debug_info(struct adapter *ada
 #ifdef LRO
 		lro = >lro;
 #endif /* LRO */
-		device_printf(dev,"QUE(%d) IRQs Handled: %lu\n",
+		

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

2017-09-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep 13 04:48:41 UTC 2017

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

Log Message:
 Set get_link_status to true in ixv_init_locked() to get the first link status
correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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.61 src/sys/dev/pci/ixgbe/ixv.c:1.62
--- src/sys/dev/pci/ixgbe/ixv.c:1.61	Tue Sep 12 05:28:31 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed Sep 13 04:48:40 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.61 2017/09/12 05:28:31 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.62 2017/09/13 04:48:40 msaitoh Exp $*/
 
 /**
 
@@ -750,6 +750,7 @@ ixv_init_locked(struct adapter *adapter)
 	ixv_init_stats(adapter);
 
 	/* Config/Enable Link */
+	hw->mac.get_link_status = TRUE;
 	hw->mac.ops.check_link(hw, >link_speed, >link_up,
 	FALSE);
 



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

2017-09-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 12 05:28:31 UTC 2017

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

Log Message:
 Fix panic caused by rev. 1.58's change. Don't if_start from interrupt context.
The restart code exists in ixv_handle_que().


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 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.60 src/sys/dev/pci/ixgbe/ixv.c:1.61
--- src/sys/dev/pci/ixgbe/ixv.c:1.60	Mon Sep 11 10:11:05 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Tue Sep 12 05:28:31 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.60 2017/09/11 10:11:05 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.61 2017/09/12 05:28:31 msaitoh Exp $*/
 
 /**
 
@@ -808,7 +808,6 @@ ixv_msix_que(void *arg)
 {
 	struct ix_queue	*que = arg;
 	struct adapter  *adapter = que->adapter;
-	struct ifnet*ifp = adapter->ifp;
 	struct tx_ring	*txr = que->txr;
 	struct rx_ring	*rxr = que->rxr;
 	bool		more;
@@ -826,19 +825,6 @@ ixv_msix_que(void *arg)
 
 	IXGBE_TX_LOCK(txr);
 	ixgbe_txeof(txr);
-	/*
-	 * Make certain that if the stack
-	 * has anything queued the task gets
-	 * scheduled to handle it.
-	 */
-	if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX))
-		if (!ixgbe_mq_ring_empty(ifp, txr->txr_interq))
-			ixgbe_mq_start_locked(ifp, txr);
-		/* Only for queue 0 */
-		/* NetBSD still needs this for CBQ */
-		if ((>queues[0] == que)
-		&& (!ixgbe_legacy_ring_empty(ifp, NULL)))
-			ixgbe_legacy_start_locked(ifp, txr);
 	IXGBE_TX_UNLOCK(txr);
 
 	/* Do AIM now? */
@@ -2545,6 +2531,7 @@ ixv_handle_que(void *context)
 			if (!ixgbe_mq_ring_empty(ifp, txr->txr_interq))
 ixgbe_mq_start_locked(ifp, txr);
 		/* Only for queue 0 */
+		/* NetBSD still needs this for CBQ */
 		if ((>queues[0] == que)
 		&& (!ixgbe_legacy_ring_empty(ifp, NULL)))
 			ixgbe_legacy_start_locked(ifp, txr);



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

2017-09-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep 11 10:11:05 UTC 2017

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

Log Message:
 Print Mailbox API version.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 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.59 src/sys/dev/pci/ixgbe/ixv.c:1.60
--- src/sys/dev/pci/ixgbe/ixv.c:1.59	Mon Sep 11 09:52:13 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Mon Sep 11 10:11:05 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.59 2017/09/11 09:52:13 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.60 2017/09/11 10:11:05 msaitoh Exp $*/
 
 /**
 
@@ -290,7 +290,7 @@ ixv_attach(device_t parent, device_t dev
 	pcireg_t	id, subid;
 	ixgbe_vendor_info_t *ent;
 	const struct pci_attach_args *pa = aux;
-
+	const char *apivstr;
 	INIT_DEBUGOUT("ixv_attach: begin");
 
 	/*
@@ -414,6 +414,27 @@ ixv_attach(device_t parent, device_t dev
 	if (error)
 		aprint_normal_dev(dev,
 		"MBX API negotiation failed during attach!\n");
+	switch (hw->api_version) {
+	case ixgbe_mbox_api_10:
+		apivstr = "1.0";
+		break;
+	case ixgbe_mbox_api_20:
+		apivstr = "2.0";
+		break;
+	case ixgbe_mbox_api_11:
+		apivstr = "1.1";
+		break;
+	case ixgbe_mbox_api_12:
+		apivstr = "1.2";
+		break;
+	case ixgbe_mbox_api_13:
+		apivstr = "1.3";
+		break;
+	default:
+		apivstr = "unknown";
+		break;
+	}
+	aprint_normal_dev(dev, "Mailbox API %s\n", apivstr);
 
 	/* If no mac address was assigned, make a random one */
 	if (!ixv_check_ether_addr(hw->mac.addr)) {



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

2017-09-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep 11 09:52:13 UTC 2017

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

Log Message:
 Use cprng_strong64() insread of cprng_fast64() to prevent panic.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 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.58 src/sys/dev/pci/ixgbe/ixv.c:1.59
--- src/sys/dev/pci/ixgbe/ixv.c:1.58	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixv.c	Mon Sep 11 09:52:13 2017
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.58 2017/08/30 08:49:18 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.59 2017/09/11 09:52:13 msaitoh Exp $*/
 
 /**
 
@@ -418,7 +418,7 @@ ixv_attach(device_t parent, device_t dev
 	/* If no mac address was assigned, make a random one */
 	if (!ixv_check_ether_addr(hw->mac.addr)) {
 		u8 addr[ETHER_ADDR_LEN];
-		uint64_t rndval = cprng_fast64();
+		uint64_t rndval = cprng_strong64();
 
 		memcpy(addr, , sizeof(addr));
 		addr[0] &= 0xFE;



CVS commit: src/sys/dev/pci

2017-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  5 08:01:43 UTC 2017

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

Log Message:
Add an XHCI_DISABLE_MSI option


To generate a diff of this commit:
cvs rdiff -u -r1.390 -r1.391 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.8 -r1.9 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/files.pci
diff -u src/sys/dev/pci/files.pci:1.390 src/sys/dev/pci/files.pci:1.391
--- src/sys/dev/pci/files.pci:1.390	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/files.pci	Tue Sep  5 08:01:43 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.390 2017/08/30 08:49:18 msaitoh Exp $
+#	$NetBSD: files.pci,v 1.391 2017/09/05 08:01:43 skrll Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -635,6 +635,7 @@ file	dev/pci/usb_pci.c		ehci_pci | ehci_
 # xHCI USB controller
 attach	xhci at pci with xhci_pci
 file	dev/pci/xhci_pci.c		xhci_pci
+defflag	opt_xhci_pci.h			XHCI_DISABLE_MSI
 
 # OHCI IEEE 1394 controller
 attach	fwohci at pci with fwohci_pci

Index: src/sys/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.8 src/sys/dev/pci/xhci_pci.c:1.9
--- src/sys/dev/pci/xhci_pci.c:1.8	Thu Jan 19 16:05:00 2017
+++ src/sys/dev/pci/xhci_pci.c	Tue Sep  5 08:01:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.8 2017/01/19 16:05:00 skrll Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.9 2017/09/05 08:01:43 skrll Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.8 2017/01/19 16:05:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.9 2017/09/05 08:01:43 skrll Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_xhci_pci.h"
+#endif
 
 #include 
 #include 
@@ -173,8 +177,16 @@ xhci_pci_attach(device_t parent, device_
 	pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
 		   csr | PCI_COMMAND_MASTER_ENABLE);
 
+	/* Allocation settings */
+	int counts[PCI_INTR_TYPE_SIZE] = {
+		[PCI_INTR_TYPE_INTX] = 1,
+#ifndef XHCI_DISABLE_MSI
+		[PCI_INTR_TYPE_MSI] = 1,
+#endif
+	};
+
 	/* Allocate and establish the interrupt. */
-	if (pci_intr_alloc(pa, >sc_pihp, NULL, 0)) {
+	if (pci_intr_alloc(pa, >sc_pihp, counts, PCI_INTR_TYPE_MSIX)) {
 		aprint_error_dev(self, "can't allocate handler\n");
 		goto fail;
 	}



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

2017-08-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug 31 02:48:55 UTC 2017

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

Log Message:
 Fix 2500 KX media setting in last commit.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 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.99 src/sys/dev/pci/ixgbe/ixgbe.c:1.100
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.99	Wed Aug 30 08:49:18 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Aug 31 02:48:55 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.99 2017/08/30 08:49:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.100 2017/08/31 02:48:55 msaitoh Exp $ */
 
 /**
 
@@ -1392,7 +1392,7 @@ ixgbe_add_media_types(struct adapter *ad
 		ADD(IFM_1000_KX | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_2500BASE_KX) {
-		ADD(IFM_1000_KX, 0);
+		ADD(IFM_2500_KX, 0);
 		ADD(IFM_2500_KX | IFM_FDX, 0);
 	}
 	if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_BX)



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

2017-08-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Aug 30 01:25:07 UTC 2017

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

Log Message:
 Don't limit number of queue pair to 8. Take max TX queues and max RX queues
into account. 82598 has 32 TX queue and 64 RX queues. Others has 128 TX queues
and 128 RX queues. Number of MSI-X table entries is 64, so the max queue pairs
is 63 (64 minus the Others (e.g. link status change)).


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 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.96 src/sys/dev/pci/ixgbe/ixgbe.c:1.97
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.96	Thu Aug 24 10:43:42 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Aug 30 01:25:07 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.96 2017/08/24 10:43:42 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.97 2017/08/30 01:25:07 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2960,6 +2960,7 @@ static int
 ixgbe_setup_msix(struct adapter *adapter)
 {
 	device_t dev = adapter->dev;
+	struct ixgbe_mac_info *mac = >hw.mac;
 	int want, queues, msgs;
 
 	/* Override by tuneable */
@@ -2986,8 +2987,9 @@ ixgbe_setup_msix(struct adapter *adapter
 	if (ixgbe_num_queues != 0)
 		queues = ixgbe_num_queues;
 	/* Set max queues to 8 when autoconfiguring */
-	else if ((ixgbe_num_queues == 0) && (queues > 8))
-		queues = 8;
+	else
+		queues = min(queues,
+		min(mac->max_tx_queues, mac->max_rx_queues));
 
 	/* reflect correct sysctl value */
 	ixgbe_num_queues = queues;



CVS commit: src/sys/dev/pci

2017-08-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Aug 25 22:45:33 UTC 2017

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

Log Message:
Radeon PLLs can't have odd post dividers when used with digital outputs -
add a flag to track this in relevant functions.
Now DVI output works properly on my Mini 2
Needs testing on Mini 1 and other hardware...


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/radeonfb.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/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.91 src/sys/dev/pci/radeonfb.c:1.92
--- src/sys/dev/pci/radeonfb.c:1.91	Wed Aug 23 19:47:39 2017
+++ src/sys/dev/pci/radeonfb.c	Fri Aug 25 22:45:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.91 2017/08/23 19:47:39 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.92 2017/08/25 22:45:33 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.91 2017/08/23 19:47:39 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.92 2017/08/25 22:45:33 macallan Exp $");
 
 #include 
 #include 
@@ -120,13 +120,16 @@ static uintmax_t radeonfb_getprop_num(st
 static int radeonfb_getclocks(struct radeonfb_softc *);
 static int radeonfb_gettmds(struct radeonfb_softc *);
 static int radeonfb_calc_dividers(struct radeonfb_softc *, uint32_t,
-uint32_t *, uint32_t *);
+uint32_t *, uint32_t *, int);
+/* flags for radeonfb_calc_dividers */
+#define NO_ODD_FBDIV	1
+
 static int radeonfb_getconnectors(struct radeonfb_softc *);
 static const struct videomode *radeonfb_modelookup(const char *);
 static void radeonfb_init_screen(void *, struct vcons_screen *, int, long *);
 static void radeonfb_pllwriteupdate(struct radeonfb_softc *, int);
 static void radeonfb_pllwaitatomicread(struct radeonfb_softc *, int);
-static void radeonfb_program_vclk(struct radeonfb_softc *, int, int);
+static void radeonfb_program_vclk(struct radeonfb_softc *, int, int, int);
 static void radeonfb_modeswitch(struct radeonfb_display *);
 static void radeonfb_setcrtc(struct radeonfb_display *, int);
 static void radeonfb_init_misc(struct radeonfb_softc *);
@@ -580,9 +583,12 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_TMDS_TRANSMITTER_CNTL);
 	PRINTREG(RADEON_TMDS_PLL_CNTL);
 	PRINTREG(RADEON_LVDS_GEN_CNTL);
-	PRINTREG(RADEON_FP_HORZ_STRETCH);
-	PRINTREG(RADEON_FP_VERT_STRETCH);
 	PRINTREG(RADEON_DISP_HW_DEBUG);
+	PRINTREG(RADEON_PIXCLKS_CNTL);
+	PRINTREG(RADEON_CRTC_H_SYNC_STRT_WID);
+	PRINTREG(RADEON_FP_H_SYNC_STRT_WID);
+	PRINTREG(RADEON_CRTC2_H_SYNC_STRT_WID);
+	PRINTREG(RADEON_FP_H2_SYNC_STRT_WID);
 	if (IS_RV100(sc))
 		PUT32(sc, RADEON_TMDS_PLL_CNTL, 0xa27);
 
@@ -1041,6 +1047,7 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_TMDS_CNTL);
 	PRINTREG(RADEON_TMDS_TRANSMITTER_CNTL);
 	PRINTREG(RADEON_TMDS_PLL_CNTL);
+	PRINTREG(RADEON_PIXCLKS_CNTL);
 
 	return;
 
@@ -1625,7 +1632,7 @@ dontprobe:
 
 int
 radeonfb_calc_dividers(struct radeonfb_softc *sc, uint32_t dotclock,
-uint32_t *postdivbit, uint32_t *feedbackdiv)
+uint32_t *postdivbit, uint32_t *feedbackdiv, int flags)
 {
 	int		i;
 	uint32_t	outfreq;
@@ -1633,6 +1640,7 @@ radeonfb_calc_dividers(struct radeonfb_s
 
 	DPRINTF(("dot clock: %u\n", dotclock));
 	for (i = 0; (div = radeonfb_dividers[i].divider) != 0; i++) {
+		if ((flags & NO_ODD_FBDIV) && ((div & 1) != 0)) continue;
 		outfreq = div * dotclock;
 		if ((outfreq >= sc->sc_minpll) &&
 		(outfreq <= sc->sc_maxpll)) {
@@ -2021,13 +2029,13 @@ radeonfb_pllwaitatomicread(struct radeon
 }
 
 void
-radeonfb_program_vclk(struct radeonfb_softc *sc, int dotclock, int crtc)
+radeonfb_program_vclk(struct radeonfb_softc *sc, int dotclock, int crtc, int flags)
 {
 	uint32_t	pbit = 0;
 	uint32_t	feed = 0;
 	uint32_t	data, refdiv, div0;
 
-	radeonfb_calc_dividers(sc, dotclock, , );
+	radeonfb_calc_dividers(sc, dotclock, , , flags);
 
 	if (crtc == 0) {
 
@@ -2190,6 +2198,21 @@ radeonfb_modeswitch(struct radeonfb_disp
 	for (i = 0; i < dp->rd_ncrtcs; i++)
 		radeonfb_setcrtc(dp, i);
 
+#if 0
+	/*
+	 * DVO chip voodoo from xf86-video-radeon
+	 * apparently this is needed for some powerbooks with DVI outputs
+	 */
+
+	uint8_t data[5][2] = {{0x8, 0x030}, {0x9, 0}, {0xa, 0x90}, {0xc, 0x89}, {0x8, 0x3b}};
+	int n = 0;
+	iic_acquire_bus(>sc_i2c[0].ric_controller, 0);
+	for (i = 0; i < 5; i++)
+		n += iic_exec(>sc_i2c[0].ric_controller, I2C_OP_WRITE, 0x38, data[i], 2, NULL, 0, 0);
+	iic_release_bus(>sc_i2c[0].ric_controller, 0);
+	printf("n = %d\n", n);
+#endif
+
 	/* activate the display */
 	radeonfb_blank(dp, 0);
 }
@@ -2197,7 +2220,7 @@ radeonfb_modeswitch(struct radeonfb_disp
 void
 radeonfb_setcrtc(struct radeonfb_display *dp, int index)
 {
-	int			crtc;
+	int			crtc, flags = 0;
 	struct videomode	*mode;
 	struct radeonfb_softc	*sc;
 	struct radeonfb_crtc	*cp;
@@ 

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

2017-08-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug 24 10:43:42 UTC 2017

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

Log Message:
 Remove unused counters.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/ixgbe/ixgbe.h

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.95 src/sys/dev/pci/ixgbe/ixgbe.c:1.96
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.95	Mon Jul  3 08:29:58 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Aug 24 10:43:42 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.95 2017/07/03 08:29:58 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.96 2017/08/24 10:43:42 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -4847,18 +4847,6 @@ ixgbe_add_hw_stats(struct adapter *adapt
 	const char *xname = device_xname(dev);
 
 	/* Driver Statistics */
-#if 0
-	/* These counters are not updated by the software */
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "mbuf_header_failed",
-			CTLFLAG_RD, >mbuf_header_failed,
-			"???");
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "mbuf_packet_failed",
-			CTLFLAG_RD, >mbuf_packet_failed,
-			"???");
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "no_tx_map_avail",
-			CTLFLAG_RD, >no_tx_map_avail,
-			"???");
-#endif
 	evcnt_attach_dynamic(>handleq, EVCNT_TYPE_MISC,
 	NULL, xname, "Handled queue in softint");
 	evcnt_attach_dynamic(>req, EVCNT_TYPE_MISC,

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.24 src/sys/dev/pci/ixgbe/ixgbe.h:1.25
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.24	Mon Feb 13 10:13:54 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Thu Aug 24 10:43:42 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe.h 303890 2016-08-09 19:32:06Z dumbbell $*/
-/*$NetBSD: ixgbe.h,v 1.24 2017/02/13 10:13:54 msaitoh Exp $*/
+/*$NetBSD: ixgbe.h,v 1.25 2017/08/24 10:43:42 msaitoh Exp $*/
 
 
 #ifndef _IXGBE_H_
@@ -400,7 +400,6 @@ struct tx_ring {
 	u32			packets;
 	/* Soft Stats */
 	struct evcnt	   	tso_tx;
-	struct evcnt	   	no_tx_map_avail;
 	struct evcnt		no_desc_avail;
 	struct evcnt		total_packets;
 	struct evcnt		pcq_drops;
@@ -580,8 +579,6 @@ struct adapter {
 
 	/* Misc stats maintained by the driver */
 	struct evcnt   		mbuf_defrag_failed;
-	struct evcnt	   	mbuf_header_failed;
-	struct evcnt	   	mbuf_packet_failed;
 	struct evcnt	   	efbig_tx_dma_setup;
 	struct evcnt	   	efbig2_tx_dma_setup;
 	struct evcnt	   	einval_tx_dma_setup;



CVS commit: src/sys/dev/pci

2017-08-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 23 19:47:39 UTC 2017

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

Log Message:
Mac Mini WIP:
- plug the external TMDS into the right CRTC when in use
- use the right output types for Mini configs
now VGA works properly ( and not just by accident ) on my Mini 2. DVI is still
garbled but at least produces output.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/pci/radeonfb.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/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.90 src/sys/dev/pci/radeonfb.c:1.91
--- src/sys/dev/pci/radeonfb.c:1.90	Fri Aug 11 22:59:05 2017
+++ src/sys/dev/pci/radeonfb.c	Wed Aug 23 19:47:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.90 2017/08/11 22:59:05 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.91 2017/08/23 19:47:39 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.90 2017/08/11 22:59:05 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.91 2017/08/23 19:47:39 macallan Exp $");
 
 #include 
 #include 
@@ -416,7 +416,7 @@ static const struct {
 	{ RADEON_R200,	{{15000, 0xa1b}, {-1, 0xa3f}}},
 	{ RADEON_RV250,	{{15500, 0x81b}, {-1, 0x83f}}},
 	{ RADEON_RS300, {{0, 0}}},
-	{ RADEON_RV280,	{{13000, 0x400f4}, {15000, 0x400f7}}},
+	{ RADEON_RV280,	{{13000, 0x400f4}, {15000, 0x400f7}, {-1, 0x40111}}},
 	{ RADEON_R300,	{{-1, 0xb01cb}}},
 	{ RADEON_R350,	{{-1, 0xb01cb}}},
 	{ RADEON_RV350,	{{15000, 0xb0155}, {-1, 0xb01cb}}},
@@ -572,9 +572,6 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_CRTC2_GEN_CNTL);
 	PRINTREG(RADEON_DISP_OUTPUT_CNTL);
 	PRINTREG(RADEON_DAC_CNTL2);
-	PRINTREG(RADEON_FP_GEN_CNTL);
-	PRINTREG(RADEON_FP2_GEN_CNTL);
-
 	PRINTREG(RADEON_BIOS_4_SCRATCH);
 	PRINTREG(RADEON_FP_GEN_CNTL);
 	sc->sc_fp_gen_cntl = GET32(sc, RADEON_FP_GEN_CNTL);
@@ -585,7 +582,7 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_LVDS_GEN_CNTL);
 	PRINTREG(RADEON_FP_HORZ_STRETCH);
 	PRINTREG(RADEON_FP_VERT_STRETCH);
-
+	PRINTREG(RADEON_DISP_HW_DEBUG);
 	if (IS_RV100(sc))
 		PUT32(sc, RADEON_TMDS_PLL_CNTL, 0xa27);
 
@@ -707,11 +704,29 @@ radeonfb_attach(device_t parent, device_
   RADEON_FP_SEL_CRTC1,
 ~RADEON_FP_SEL_MASK);
 			}
+		case RADEON_TMDS_EXT:
+			/* point FP2 at the CRTC this port uses */
+			DPRINTF(("%s: plugging external TMDS into CRTC %d\n",
+			__func__, sc->sc_ports[i].rp_number));
+			if (IS_R300(sc)) {
+PATCH32(sc, RADEON_FP2_GEN_CNTL,
+sc->sc_ports[i].rp_number ?
+  R200_FP2_SOURCE_SEL_CRTC2 :
+  R200_FP2_SOURCE_SEL_CRTC1,
+~R200_FP2_SOURCE_SEL_CRTC2);
+			} else {
+PATCH32(sc, RADEON_FP2_GEN_CNTL,
+sc->sc_ports[i].rp_number ?
+  RADEON_FP2_SRC_SEL_CRTC2 :
+  RADEON_FP2_SRC_SEL_CRTC1,
+~RADEON_FP2_SRC_SEL_CRTC2);
+			}
 		}
 	}
 	PRINTREG(RADEON_DAC_CNTL2);
 	PRINTREG(RADEON_DISP_HW_DEBUG);
 
+	PRINTREG(RADEON_DAC_CNTL);
 	/* other DAC programming */
 	v = GET32(sc, RADEON_DAC_CNTL);
 	v &= (RADEON_DAC_RANGE_CNTL_MASK | RADEON_DAC_BLANKING);
@@ -1023,6 +1038,9 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_DAC_CNTL2);
 	PRINTREG(RADEON_FP_GEN_CNTL);
 	PRINTREG(RADEON_FP2_GEN_CNTL);
+	PRINTREG(RADEON_TMDS_CNTL);
+	PRINTREG(RADEON_TMDS_TRANSMITTER_CNTL);
+	PRINTREG(RADEON_TMDS_PLL_CNTL);
 
 	return;
 
@@ -1739,6 +1757,13 @@ radeonfb_getconnectors(struct radeonfb_s
 			if (conn == RADEON_CONN_NONE)
 continue;	/* no connector */
 
+
+
+			/* 
+			 * XXX
+			 * both Mac Mini variants have both outputs wired to 
+			 * the same connector and share the DDC lines
+			 */ 
 			if ((found > 0) &&
 			(sc->sc_ports[port].rp_ddc_type == ddc)) {
 /* duplicate entry for same connector */
@@ -1780,18 +1805,24 @@ nobios:
 		"dvi-external", _ext);
 		if (dvi_ext) {
 			sc->sc_ports[0].rp_mon_type = RADEON_MT_UNKNOWN;
-			sc->sc_ports[0].rp_ddc_type = RADEON_DDC_DVI;
-			sc->sc_ports[0].rp_dac_type = RADEON_DAC_TVDAC;
+			sc->sc_ports[0].rp_ddc_type = RADEON_DDC_CRT2;
+			sc->sc_ports[0].rp_dac_type = RADEON_DAC_PRIMARY;
 			sc->sc_ports[0].rp_conn_type = RADEON_CONN_DVI_I;
-			sc->sc_ports[0].rp_tmds_type = RADEON_TMDS_EXT;
-			sc->sc_ports[0].rp_number = 1;
+			sc->sc_ports[0].rp_tmds_type = RADEON_TMDS_EXT;	/* output to fp2 */
+			sc->sc_ports[0].rp_number = 0;
+			sc->sc_ports[1].rp_mon_type = RADEON_MT_UNKNOWN;
+			sc->sc_ports[1].rp_ddc_type = RADEON_DDC_NONE;
+			sc->sc_ports[1].rp_dac_type = RADEON_DAC_UNKNOWN;
+			sc->sc_ports[1].rp_conn_type = RADEON_CONN_NONE;
+			sc->sc_ports[1].rp_tmds_type = RADEON_TMDS_UNKNOWN;
+			sc->sc_ports[1].rp_number = 1;
 		} else	if (dvi_int) {
 			sc->sc_ports[0].rp_mon_type = RADEON_MT_UNKNOWN;
-			sc->sc_ports[0].rp_ddc_type = RADEON_DDC_DVI;
-			sc->sc_ports[0].rp_dac_type = 

CVS commit: src/sys/dev/pci

2017-08-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 23 19:21:14 UTC 2017

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

Log Message:
consistency...


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/radeonfbreg.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/radeonfbreg.h
diff -u src/sys/dev/pci/radeonfbreg.h:1.5 src/sys/dev/pci/radeonfbreg.h:1.6
--- src/sys/dev/pci/radeonfbreg.h:1.5	Sun Dec 30 09:45:05 2012
+++ src/sys/dev/pci/radeonfbreg.h	Wed Aug 23 19:21:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfbreg.h,v 1.5 2012/12/30 09:45:05 macallan Exp $	*/
+/*	$NetBSD: radeonfbreg.h,v 1.6 2017/08/23 19:21:14 macallan Exp $	*/
 
 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h,v 1.31 2003/11/10 18:41:23 tsi Exp $ */
 /*
@@ -704,6 +704,7 @@
 #   define R200_FP2_SOURCE_SEL_CRTC2   (1 << 10)
 #   define R200_FP2_SOURCE_SEL_RMX (2 << 10)
 #   define RADEON_FP2_SRC_SEL_MASK (3 << 13)
+#   define RADEON_FP2_SRC_SEL_CRTC1(0 << 13)
 #   define RADEON_FP2_SRC_SEL_CRTC2(1 << 13)
 #   define RADEON_FP2_FP_POL   (1 << 16)
 #   define RADEON_FP2_LP_POL   (1 << 17)



CVS commit: src/sys/dev/pci

2017-08-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Aug 20 10:55:37 UTC 2017

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

Log Message:
M_WAITOK cannot fail, so remove the test branches. Otherwise it looks
like leak/uninitialized area.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/oboe.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/oboe.c
diff -u src/sys/dev/pci/oboe.c:1.43 src/sys/dev/pci/oboe.c:1.44
--- src/sys/dev/pci/oboe.c:1.43	Fri Jul 24 06:17:10 2015
+++ src/sys/dev/pci/oboe.c	Sun Aug 20 10:55:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: oboe.c,v 1.43 2015/07/24 06:17:10 martin Exp $	*/
+/*	$NetBSD: oboe.c,v 1.44 2017/08/20 10:55:37 maxv Exp $	*/
 
 /*	FVDL THIS DRIVER IS BROKEN FOR NON-i386 -- vtophys() usage	*/
 
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: oboe.c,v 1.43 2015/07/24 06:17:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oboe.c,v 1.44 2017/08/20 10:55:37 maxv Exp $");
 
 #include 
 #include 
@@ -641,9 +641,7 @@ oboe_alloc_taskfile(struct oboe_softc *s
 	/* XXX */
 	uintptr_t addr =
 	(uintptr_t)malloc(OBOE_TASK_BUF_LEN, M_DEVBUF, M_WAITOK);
-	if (addr == 0) {
-		goto bad;
-	}
+
 	addr &= ~(sizeof (struct OboeTaskFile) - 1);
 	addr += sizeof (struct OboeTaskFile);
 	sc->sc_taskfile = (struct OboeTaskFile *) addr;
@@ -653,26 +651,15 @@ oboe_alloc_taskfile(struct oboe_softc *s
 			malloc(TX_BUF_SZ, M_DEVBUF, M_WAITOK);
 		sc->sc_xmit_stores[i] =
 			malloc(TX_BUF_SZ, M_DEVBUF, M_WAITOK);
-		if (sc->sc_xmit_bufs[i] == NULL ||
-		sc->sc_xmit_stores[i] == NULL) {
-			goto bad;
-		}
 	}
 	for (i = 0; i < RX_SLOTS; ++i) {
 		sc->sc_recv_bufs[i] =
 			malloc(RX_BUF_SZ, M_DEVBUF, M_WAITOK);
 		sc->sc_recv_stores[i] =
 			malloc(RX_BUF_SZ, M_DEVBUF, M_WAITOK);
-		if (sc->sc_recv_bufs[i] == NULL ||
-		sc->sc_recv_stores[i] == NULL) {
-			goto bad;
-		}
 	}
 
 	return 0;
-bad:
-	printf("oboe: malloc for buffers failed()\n");
-	return 1;
 }
 
 static void



CVS commit: src/sys/dev/pci

2017-08-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug 17 01:24:09 UTC 2017

Modified Files:
src/sys/dev/pci: ichsmb.c ismt.c

Log Message:
Add C3000 devices.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/pci/ichsmb.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ismt.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/ichsmb.c
diff -u src/sys/dev/pci/ichsmb.c:1.50 src/sys/dev/pci/ichsmb.c:1.51
--- src/sys/dev/pci/ichsmb.c:1.50	Fri Mar 31 08:38:13 2017
+++ src/sys/dev/pci/ichsmb.c	Thu Aug 17 01:24:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichsmb.c,v 1.50 2017/03/31 08:38:13 msaitoh Exp $	*/
+/*	$NetBSD: ichsmb.c,v 1.51 2017/08/17 01:24:09 msaitoh Exp $	*/
 /*	$OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.50 2017/03/31 08:38:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.51 2017/08/17 01:24:09 msaitoh Exp $");
 
 #include 
 #include 
@@ -130,6 +130,7 @@ ichsmb_match(device_t parent, cfdata_t m
 		case PCI_PRODUCT_INTEL_DH89XXCC_SMB:
 		case PCI_PRODUCT_INTEL_DH89XXCL_SMB:
 		case PCI_PRODUCT_INTEL_C2000_PCU_SMBUS:
+		case PCI_PRODUCT_INTEL_C3K_SMBUS_LEGACY:
 			return 1;
 		}
 	}

Index: src/sys/dev/pci/ismt.c
diff -u src/sys/dev/pci/ismt.c:1.5 src/sys/dev/pci/ismt.c:1.6
--- src/sys/dev/pci/ismt.c:1.5	Thu Apr 27 10:01:54 2017
+++ src/sys/dev/pci/ismt.c	Thu Aug 17 01:24:09 2017
@@ -60,7 +60,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/dev/ismt/ismt.c 266474 2014-05-20 19:55:06Z jimharris $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: ismt.c,v 1.5 2017/04/27 10:01:54 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ismt.c,v 1.6 2017/08/17 01:24:09 msaitoh Exp $");
 
 #include 
 #include 
@@ -801,6 +801,7 @@ ismt_match(device_t parent, cfdata_t mat
 	case PCI_PRODUCT_INTEL_S1200_SMBUS_0:
 	case PCI_PRODUCT_INTEL_S1200_SMBUS_1:
 	case PCI_PRODUCT_INTEL_C2000_SMBUS:
+	case PCI_PRODUCT_INTEL_C3K_SMBUS:
 		break;
 	default:
 		return 0;



CVS commit: src/sys/dev/pci

2017-08-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug 17 01:05:22 UTC 2017

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

Log Message:
Add C3000 devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1296 -r1.1297 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.1296 src/sys/dev/pci/pcidevs:1.1297
--- src/sys/dev/pci/pcidevs:1.1296	Wed Aug  2 07:35:05 2017
+++ src/sys/dev/pci/pcidevs	Thu Aug 17 01:05:22 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1296 2017/08/02 07:35:05 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1297 2017/08/17 01:05:22 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3057,6 +3057,8 @@ product INTEL 82441FX		0x1237	82441FX (P
 product INTEL 82380AB		0x123c	82380AB (MISA) Mobile PCI-ISA Bridge
 product INTEL 82380FB		0x124b	82380FB (MPCI2) Mobile PCI-PCI Bridge
 product INTEL 82439HX		0x1250	82439HX (TXC) System Controller
+product INTEL C3K_X553_10G	0x1306	C3000 X553 10G Ethernet
+product INTEL C3K_X553_1G	0x1307	C3000 X553 1G Ethernet
 product INTEL 82870P2_PPB	0x1460	82870P2 P64H2 PCI-PCI Bridge
 product INTEL 82870P2_IOxAPIC	0x1461	82870P2 P64H2 IOxAPIC
 product INTEL 82870P2_HPLUG	0x1462	82870P2 P64H2 Hot Plug Controller
@@ -3143,14 +3145,25 @@ product INTEL X552_KR		0x15ab	X552 KR
 product INTEL X552_SFP		0x15ac	X552 SFP+
 product INTEL X557_AT2		0x15ad	X557-AT2
 product INTEL X552_1G_T		0x15ae	X552 1000Base-T
+product INTEL C3K_X553_VF_HYPV	0x15b4	C3000 X553 VF (Hyper-V)
 product INTEL I219_LM2		0x15b7	I219-LM Ethernet Connection
 product INTEL I219_V2		0x15b8	I219-V Ethernet Connection
 product INTEL I219_LM3		0x15b9	I219-LM Ethernet Connection
+product INTEL C3K_X553_KRKX	0x15c2	C3000 X553 Backplane (KR/KX 10G SKU)
+product INTEL C3K_X553_KX_25G	0x15c3	C3000 X553 Backplane (KX 2.5G)
+product INTEL C3K_X553_SFI_SFP	0x15c4	C3000 X553 10G SFP+
+product INTEL C3K_X553_VF	0x15c5	C3000 X553 VF
+product INTEL C3K_X553_SGMII_BP	0x15c6	C3000 X553 1GbE SGMII Backplane (10G SKU)
+product INTEL C3K_X553_SGMII_BP_L 0x15c7 C3000 X553 1GbE SGMII Backplane (non-10G SKU)
+product INTEL C3K_X553_10G_T	0x15c8	C3000 X553 10GBASE-T (X557)
+product INTEL C3K_X553_KR_SFP	0x15ce	C3000 X553 10G SFP+
 product INTEL X550T1	 	0x15d1	X550 10G Ethernet
 product INTEL I219_V5		0x15d6	I219-V Ethernet Connection
 product INTEL I219_LM4		0x15d7	I219-LM Ethernet Connection
 product INTEL I219_V4		0x15d8	I219-V Ethernet Connection
 product INTEL I219_LM5		0x15e3	I219-LM Ethernet Connection
+product INTEL C3K_X553_SGMII	0x15e4	C3000 X553 1GbE SGMII (10G SKU)
+product INTEL C3K_X553_SGMII_L	0x15e5	C3000 X553 1GbE SGMII (non-10G SKU)
 product INTEL CORE5G_HB_1	0x1604	Core 5G Host Bridge
 product INTEL CORE5G_M_GT1	0x1606	HD Graphics (GT1)
 product INTEL CORE5G_HDA_1	0x160c	Core 5G HD Audio
@@ -3190,6 +3203,71 @@ product INTEL CORE6G_H_GT4	0x193b	Iris P
 product INTEL CORE6G_S_GT4_2	0x193d	Iris Pro Graphics (GT4)
 product INTEL 80960_RP		0x1960	ROB-in i960RP Microprocessor
 product INTEL 80960RM_2		0x1962	i960 RM PCI-PCI
+product INTEL C3K_SYSA_0	0x1980	C3000 System Agent
+product INTEL C3K_GLREG		0x19a1	C3000 GLREG
+product INTEL C3K_RCEC		0x19a2	C3000 RCEC
+product INTEL C3K_PCIERP_QAT	0x19a3	C3000 PCIe Root Port for QAT
+product INTEL C3K_PCIERP_0	0x19a4	C3000 PCIe Cluster 0 Port 0
+product INTEL C3K_PCIERP_1	0x19a5	C3000 PCIe Cluster 0 Port 1
+product INTEL C3K_PCIERP_2	0x19a6	C3000 PCIe Cluster 0 Port 2
+product INTEL C3K_PCIERP_3	0x19a7	C3000 PCIe Cluster 0 Port 3
+product INTEL C3K_PCIERP_4	0x19a8	C3000 PCIe Cluster 1 Port 0
+product INTEL C3K_PCIERP_5	0x19a9	C3000 PCIe Cluster 1 Port 1
+product INTEL C3K_PCIERP_6	0x19aa	C3000 PCIe Cluster 1 Port 2
+product INTEL C3K_PCIERP_7	0x19ab	C3000 PCIe Cluster 1 Port 3
+product INTEL C3K_SMBUS		0x19ac	C3000 SMBus
+product INTEL C3K_SATA0_0	0x19b0	C3000 SATA Controller 0
+product INTEL C3K_SATA0_1	0x19b1	C3000 SATA Controller 0
+product INTEL C3K_SATA0_2	0x19b2	C3000 SATA Controller 0
+product INTEL C3K_SATA0_3	0x19b3	C3000 SATA Controller 0
+product INTEL C3K_SATA0_4	0x19b4	C3000 SATA Controller 0
+product INTEL C3K_SATA0_5	0x19b5	C3000 SATA Controller 0
+product INTEL C3K_SATA0_6	0x19b6	C3000 SATA Controller 0
+product INTEL C3K_SATA0_7	0x19b7	C3000 SATA Controller 0
+product INTEL C3K_SATA0_8	0x19b8	C3000 SATA Controller 0
+product INTEL C3K_SATA0_9	0x19b9	C3000 SATA Controller 0
+product INTEL C3K_SATA0_10	0x19ba	C3000 SATA Controller 0
+product INTEL C3K_SATA0_11	0x19bb	C3000 SATA Controller 0
+product INTEL C3K_SATA0_12	0x19bc	C3000 SATA Controller 0
+product INTEL C3K_SATA0_13	0x19bd	C3000 SATA Controller 0
+product INTEL C3K_SATA0_14	0x19be	C3000 SATA Controller 0
+product INTEL C3K_SATA0_15	0x19bf	C3000 SATA Controller 0
+product INTEL C3K_SATA1_0	0x19c0	C3000 SATA Controller 1
+product INTEL C3K_SATA1_1	0x19c1	C3000 SATA Controller 1
+product INTEL 

CVS commit: src/sys/dev/pci

2017-08-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Aug 12 11:03:47 UTC 2017

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

Log Message:
tag arcmsr scsipi adapter and pci interrupt as MPSAFE. I/O is now done
without taking kernel lock.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/pci/arcmsr.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/arcmsr.c
diff -u src/sys/dev/pci/arcmsr.c:1.36 src/sys/dev/pci/arcmsr.c:1.37
--- src/sys/dev/pci/arcmsr.c:1.36	Sun Jun 19 21:12:44 2016
+++ src/sys/dev/pci/arcmsr.c	Sat Aug 12 11:03:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: arcmsr.c,v 1.36 2016/06/19 21:12:44 dholland Exp $ */
+/*	$NetBSD: arcmsr.c,v 1.37 2017/08/12 11:03:47 mlelstv Exp $ */
 /*	$OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */
 
 /*
@@ -21,7 +21,7 @@
 #include "bio.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.36 2016/06/19 21:12:44 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.37 2017/08/12 11:03:47 mlelstv Exp $");
 
 #include 
 #include 
@@ -241,6 +241,7 @@ arc_attach(device_t parent, device_t sel
 	adapt->adapt_max_periph = adapt->adapt_openings;
 	adapt->adapt_minphys = arc_minphys;		
 	adapt->adapt_request = arc_scsi_cmd;
+	adapt->adapt_flags = SCSIPI_ADAPT_MPSAFE;
 
 	memset(chan, 0, sizeof(*chan));
 	chan->chan_adapter = adapt;
@@ -625,6 +626,8 @@ arc_map_pci_resources(device_t self, str
 		goto unmap;
 	}
 
+	pci_intr_setattr(pa->pa_pc, , PCI_INTR_MPSAFE, true);
+
 	sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
 	arc_intr, sc);
 	if (sc->sc_ih == NULL) {



CVS commit: src/sys/dev/pci

2017-08-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Aug 11 22:59:05 UTC 2017

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

Log Message:
set display output parameters according to properties
Now VGA output works as intended on my Mini 2. DVI is still garbled ( but
visible ) and Mini 1 is untested.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/dev/pci/radeonfb.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/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.89 src/sys/dev/pci/radeonfb.c:1.90
--- src/sys/dev/pci/radeonfb.c:1.89	Fri Jun  2 22:08:00 2017
+++ src/sys/dev/pci/radeonfb.c	Fri Aug 11 22:59:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.89 2017/06/02 22:08:00 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.90 2017/08/11 22:59:05 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.89 2017/06/02 22:08:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.90 2017/08/11 22:59:05 macallan Exp $");
 
 #include 
 #include 
@@ -379,6 +379,9 @@ static struct {
 	{ PCI_PRODUCT_ATI_RADEON_R423_UT,	RADEON_R420, 0 },
 	{ PCI_PRODUCT_ATI_RADEON_R423_5D57,	RADEON_R420, 0 },
 	{ PCI_PRODUCT_ATI_RADEON_R430_554F,	RADEON_R420, 0 },
+
+	/* R5xx family */
+	{ 0x7240,	RADEON_R420, 0 },	
 #endif
 	{ 0, 0, 0 }
 };
@@ -1769,8 +1772,27 @@ radeonfb_getconnectors(struct radeonfb_s
 
 nobios:
 	if (!found) {
+		bool dvi_ext = FALSE, dvi_int = FALSE;
 		DPRINTF(("No connector info in BIOS!\n"));
-		if IS_MOBILITY(sc) {
+		prop_dictionary_get_bool(device_properties(sc->sc_dev),
+		"dvi-internal", _int);
+		prop_dictionary_get_bool(device_properties(sc->sc_dev),
+		"dvi-external", _ext);
+		if (dvi_ext) {
+			sc->sc_ports[0].rp_mon_type = RADEON_MT_UNKNOWN;
+			sc->sc_ports[0].rp_ddc_type = RADEON_DDC_DVI;
+			sc->sc_ports[0].rp_dac_type = RADEON_DAC_TVDAC;
+			sc->sc_ports[0].rp_conn_type = RADEON_CONN_DVI_I;
+			sc->sc_ports[0].rp_tmds_type = RADEON_TMDS_EXT;
+			sc->sc_ports[0].rp_number = 1;
+		} else	if (dvi_int) {
+			sc->sc_ports[0].rp_mon_type = RADEON_MT_UNKNOWN;
+			sc->sc_ports[0].rp_ddc_type = RADEON_DDC_DVI;
+			sc->sc_ports[0].rp_dac_type = RADEON_DAC_TVDAC;
+			sc->sc_ports[0].rp_conn_type = RADEON_CONN_DVI_I;
+			sc->sc_ports[0].rp_tmds_type = RADEON_TMDS_INT;
+			sc->sc_ports[0].rp_number = 1;
+		} else if IS_MOBILITY(sc) {
 			/* default, port 0 = internal TMDS, port 1 = CRT */
 			sc->sc_ports[0].rp_mon_type = RADEON_MT_UNKNOWN;
 			sc->sc_ports[0].rp_ddc_type = RADEON_DDC_DVI;
@@ -2591,7 +2613,7 @@ radeonfb_putpal(struct radeonfb_display 
 	/* initialize the palette for every CRTC used by this display */
 	for (cc = 0; cc < dp->rd_ncrtcs; cc++) {
 		crtc = dp->rd_crtcs[cc].rc_number;
-		DPRINTF(("%s: doing crtc %d %d\n", __func__, cc, crtc));
+		//DPRINTF(("%s: doing crtc %d %d\n", __func__, cc, crtc));
 
 		if (crtc)
 			SET32(sc, RADEON_DAC_CNTL2, RADEON_DAC2_PALETTE_ACC_CTL);



CVS commit: src/sys/dev/pci

2017-08-02 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Wed Aug  2 08:39:14 UTC 2017

Modified Files:
src/sys/dev/pci: files.pci virtio.c virtiovar.h
Added Files:
src/sys/dev/pci: files.virtio virtio_pci.c

Log Message:
Reorg the virtio(4) config(9) code to be explicitly pci specific.

We'll later use this for a non-pci virtio(4) usecase.

ok martin


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 src/sys/dev/pci/files.pci
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/files.virtio \
src/sys/dev/pci/virtio_pci.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/virtiovar.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/files.pci
diff -u src/sys/dev/pci/files.pci:1.388 src/sys/dev/pci/files.pci:1.389
--- src/sys/dev/pci/files.pci:1.388	Thu Apr 13 10:37:36 2017
+++ src/sys/dev/pci/files.pci	Wed Aug  2 08:39:14 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.388 2017/04/13 10:37:36 knakahara Exp $
+#	$NetBSD: files.pci,v 1.389 2017/08/02 08:39:14 cherry Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -1137,29 +1137,11 @@ device  sisfb: wsemuldisplaydev, rasops8
 attach  sisfb at pci
 filedev/pci/sisfb.c		sisfb	needs-flag
 
-# VirtIO
-device	virtio {}
-attach	virtio at pci
-file	dev/pci/virtio.c	virtio
-
-attach	ld at virtio with ld_virtio
-file	dev/pci/ld_virtio.c	ld_virtio
-
-device	viomb
-attach	viomb at virtio
-file	dev/pci/viomb.c		viomb
-
-device	vioif: ether, ifnet, arp
-attach	vioif at virtio
-file	dev/pci/if_vioif.c	vioif
-
-device	viornd
-attach	viornd at virtio
-file	dev/pci/viornd.c	viornd
-
-device	vioscsi: scsi
-attach	vioscsi at virtio
-file	dev/pci/vioscsi.c	vioscsi
+# VirtIO: XXX: move to dev/vmm/virtio
+include "dev/pci/files.virtio"
+
+attach	virtio at pci with virtio_pci
+file	dev/pci/virtio_pci.c	virtio_pci
 
 # Silicon Motion SM712(LynxEM+) frame buffer
 device	lynxfb: wsemuldisplaydev, rasops16

Index: src/sys/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.28 src/sys/dev/pci/virtio.c:1.29
--- src/sys/dev/pci/virtio.c:1.28	Thu Jun  1 02:45:11 2017
+++ src/sys/dev/pci/virtio.c	Wed Aug  2 08:39:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.28 2017/06/01 02:45:11 chs Exp $	*/
+/*	$NetBSD: virtio.c,v 1.29 2017/08/02 08:39:14 cherry Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28 2017/06/01 02:45:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.29 2017/08/02 08:39:14 cherry Exp $");
 
 #include 
 #include 
@@ -43,15 +43,11 @@ __KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1
 
 #define VIRTIO_PRIVATE
 
-#include 
-#include 
+#include  /* XXX: move to non-pci */
+#include  /* XXX: move to non-pci */
 
 #define MINSEG_INDIRECT		2 /* use indirect if nsegs >= this value */
 
-static int	virtio_match(device_t, cfdata_t, void *);
-static void	virtio_attach(device_t, device_t, void *);
-static int	virtio_rescan(device_t, const char *, const int *);
-static int	virtio_detach(device_t, int);
 static int	virtio_intr(void *arg);
 static int	virtio_msix_queue_intr(void *);
 static int	virtio_msix_config_intr(void *);
@@ -66,9 +62,6 @@ static void	virtio_soft_intr(void *arg);
 static void	virtio_init_vq(struct virtio_softc *,
 		struct virtqueue *, const bool);
 
-CFATTACH_DECL3_NEW(virtio, sizeof(struct virtio_softc),
-virtio_match, virtio_attach, virtio_detach, NULL, virtio_rescan, NULL,
-DVF_DETACH_SHUTDOWN);
 
 /* we use the legacy virtio spec, so the pci registers are host native
  * byte order, not pci (i.e. LE) byte order */
@@ -109,7 +102,7 @@ nbo_bus_space_write_4(bus_space_tag_t sp
 #define	REG_LO_OFF	0
 #endif
 
-static void
+void
 virtio_set_status(struct virtio_softc *sc, int status)
 {
 	int old = 0;
@@ -121,42 +114,6 @@ virtio_set_status(struct virtio_softc *s
 			  status|old);
 }
 
-#define virtio_device_reset(sc)	virtio_set_status((sc), 0)
-
-static int
-virtio_match(device_t parent, cfdata_t match, void *aux)
-{
-	struct pci_attach_args *pa;
-
-	pa = (struct pci_attach_args *)aux;
-	switch (PCI_VENDOR(pa->pa_id)) {
-	case PCI_VENDOR_QUMRANET:
-		if ((PCI_PRODUCT_QUMRANET_VIRTIO_1000 <=
-		 PCI_PRODUCT(pa->pa_id)) &&
-		(PCI_PRODUCT(pa->pa_id) <=
-		 PCI_PRODUCT_QUMRANET_VIRTIO_103F))
-			return 1;
-		break;
-	}
-
-	return 0;
-}
-
-static const char *virtio_device_name[] = {
-	"Unknown (0)",			/* 0 */
-	"Network",			/* 1 */
-	"Block",			/* 2 */
-	"Console",			/* 3 */
-	"Entropy",			/* 4 */
-	"Memory Balloon",		/* 5 */
-	"I/O Memory",			/* 6 */
-	"Remote Processor Messaging",	/* 7 */
-	"SCSI",/* 8 */
-	"9P Transport",			/* 9 */
-	"mac80211 wlan",		/* 10 */
-};
-#define NDEVNAMES	__arraycount(virtio_device_name)
-
 #define VIRTIO_MSIX_CONFIG_VECTOR_INDEX	0
 #define 

CVS commit: src/sys/dev/pci

2017-08-02 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Aug  2 07:35:06 UTC 2017

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

Log Message:
 PCI device ID of Atom x5-Z8350's video is 0x22b0. ark.intel.com says 0x22b0 is
Intel HD Graphics 400.


To generate a diff of this commit:
cvs rdiff -u -r1.1295 -r1.1296 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.1295 src/sys/dev/pci/pcidevs:1.1296
--- src/sys/dev/pci/pcidevs:1.1295	Wed Jul 26 08:57:24 2017
+++ src/sys/dev/pci/pcidevs	Wed Aug  2 07:35:05 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1295 2017/07/26 08:57:24 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1296 2017/08/02 07:35:05 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3378,7 +3378,7 @@ product INTEL BSW_PCU_LPC	0x229c	Braswel
 product INTEL BSW_AHCI		0x22a3	Braswell AHCI
 product INTEL BSW_LPE_AUDIO	0x22a8	Braswell Low Power Engine Audio
 product INTEL Z8K_LPIO1_SPI_3	0x22ac	Atom Z8000 LPIO1 SPI3
-product INTEL CHV_IGD_1		0x22b0	HD Graphics
+product INTEL CHV_IGD_1		0x22b0	HD Graphics 400
 product INTEL CHV_IGD_2		0x22b1	HD Graphics
 product INTEL CHV_IGD_3		0x22b2	HD Graphics
 product INTEL CHV_IGD_4		0x22b3	HD Graphics



CVS commit: src/sys/dev/pci

2017-07-31 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jul 31 06:41:01 UTC 2017

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

Log Message:
rename unclear functions. pointed out by msaitoh@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.536 -r1.537 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.536 src/sys/dev/pci/if_wm.c:1.537
--- src/sys/dev/pci/if_wm.c:1.536	Fri Jul 28 10:34:58 2017
+++ src/sys/dev/pci/if_wm.c	Mon Jul 31 06:41:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.536 2017/07/28 10:34:58 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.537 2017/07/31 06:41:01 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.536 2017/07/28 10:34:58 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.537 2017/07/31 06:41:01 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -706,8 +706,8 @@ static int	wm_setup_legacy(struct wm_sof
 static int	wm_setup_msix(struct wm_softc *);
 static int	wm_init(struct ifnet *);
 static int	wm_init_locked(struct ifnet *);
-static void	wm_turnon(struct wm_softc *);
-static void	wm_turnoff(struct wm_softc *);
+static void	wm_unset_stopping_flags(struct wm_softc *);
+static void	wm_set_stopping_flags(struct wm_softc *);
 static void	wm_stop(struct ifnet *, int);
 static void	wm_stop_locked(struct ifnet *, int);
 static void	wm_dump_mbuf_chain(struct wm_softc *, struct mbuf *);
@@ -5121,7 +5121,7 @@ wm_setup_msix(struct wm_softc *sc)
 }
 
 static void
-wm_turnon(struct wm_softc *sc)
+wm_unset_stopping_flags(struct wm_softc *sc)
 {
 	int i;
 
@@ -5147,7 +5147,7 @@ wm_turnon(struct wm_softc *sc)
 }
 
 static void
-wm_turnoff(struct wm_softc *sc)
+wm_set_stopping_flags(struct wm_softc *sc)
 {
 	int i;
 
@@ -5812,7 +5812,7 @@ wm_init_locked(struct ifnet *ifp)
 	/* Set the receive filter. */
 	wm_set_filter(sc);
 
-	wm_turnon(sc);
+	wm_unset_stopping_flags(sc);
 
 	/* Start the one second link check clock. */
 	callout_reset(>sc_tick_ch, hz, wm_tick, sc);
@@ -5855,7 +5855,7 @@ wm_stop_locked(struct ifnet *ifp, int di
 		device_xname(sc->sc_dev), __func__));
 	KASSERT(WM_CORE_LOCKED(sc));
 
-	wm_turnoff(sc);
+	wm_set_stopping_flags(sc);
 
 	/* Stop the one second clock. */
 	callout_stop(>sc_tick_ch);



CVS commit: src/sys/dev/pci

2017-07-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 29 01:54:56 UTC 2017

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

Log Message:
Null out sbuf->m on failure to avoid double-free later.

>From Ilja Van Sprundel.

Also null out sbuf->map out of paranoia.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pci/if_ipw.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.64 src/sys/dev/pci/if_ipw.c:1.65
--- src/sys/dev/pci/if_ipw.c:1.64	Tue May 23 02:19:14 2017
+++ src/sys/dev/pci/if_ipw.c	Sat Jul 29 01:54:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ipw.c,v 1.64 2017/05/23 02:19:14 ozaki-r Exp $	*/
+/*	$NetBSD: if_ipw.c,v 1.65 2017/07/29 01:54:56 riastradh 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.64 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.65 2017/07/29 01:54:56 riastradh Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2100 MiniPCI driver
@@ -607,6 +607,7 @@ ipw_dma_alloc(struct ipw_softc *sc)
 		MCLGET(sbuf->m, M_DONTWAIT);
 		if (!(sbuf->m->m_flags & M_EXT)) {
 			m_freem(sbuf->m);
+			sbuf->m = NULL;
 			aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf cluster\n");
 			error = ENOMEM;
 			goto fail;
@@ -619,6 +620,7 @@ ipw_dma_alloc(struct ipw_softc *sc)
 		if (error != 0) {
 			aprint_error_dev(sc->sc_dev, "could not create rxbuf dma map\n");
 			m_freem(sbuf->m);
+			sbuf->m = NULL;
 			goto fail;
 		}
 
@@ -626,7 +628,9 @@ ipw_dma_alloc(struct ipw_softc *sc)
 		sbuf->m, BUS_DMA_READ | BUS_DMA_NOWAIT);
 		if (error != 0) {
 			bus_dmamap_destroy(sc->sc_dmat, sbuf->map);
+			sbuf->map = NULL;
 			m_freem(sbuf->m);
+			sbuf->m = NULL;
 			aprint_error_dev(sc->sc_dev, "could not map rxbuf dma memory\n");
 			goto fail;
 		}



CVS commit: src/sys/dev/pci

2017-07-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jul 29 01:47:48 UTC 2017

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

Log Message:
Check for MCLGET failure in et_newbuf.

>From Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/if_et.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_et.c
diff -u src/sys/dev/pci/if_et.c:1.14 src/sys/dev/pci/if_et.c:1.15
--- src/sys/dev/pci/if_et.c:1.14	Thu Dec 15 09:28:05 2016
+++ src/sys/dev/pci/if_et.c	Sat Jul 29 01:47:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_et.c,v 1.14 2016/12/15 09:28:05 ozaki-r Exp $	*/
+/*	$NetBSD: if_et.c,v 1.15 2017/07/29 01:47:48 riastradh Exp $	*/
 /*	$OpenBSD: if_et.c,v 1.11 2008/06/08 06:18:07 jsg Exp $	*/
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.14 2016/12/15 09:28:05 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.15 2017/07/29 01:47:48 riastradh Exp $");
 
 #include "opt_inet.h"
 #include "vlan.h"
@@ -2026,6 +2026,10 @@ et_newbuf(struct et_rxbuf_data *rbd, int
 		if (m == NULL)
 			return (ENOBUFS);
 		MCLGET(m, init ? M_WAITOK : M_DONTWAIT);
+		if ((m->m_flags & M_EXT) == 0) {
+			m_freem(m);
+			return (ENOBUFS);
+		}
 		len = MCLBYTES;
 	} else {
 		MGETHDR(m, init ? M_WAITOK : M_DONTWAIT, MT_DATA);



CVS commit: src/sys/dev/pci

2017-07-28 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Jul 28 10:34:58 UTC 2017

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

Log Message:
add comment about confusing wm_rxeof() calling.

pointed out by msaitoh@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.535 -r1.536 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.535 src/sys/dev/pci/if_wm.c:1.536
--- src/sys/dev/pci/if_wm.c:1.535	Fri Jul 28 10:21:10 2017
+++ src/sys/dev/pci/if_wm.c	Fri Jul 28 10:34:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.535 2017/07/28 10:21:10 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.536 2017/07/28 10:34: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.535 2017/07/28 10:21:10 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.536 2017/07/28 10:34:58 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -8805,6 +8805,11 @@ wm_intr_legacy(void *arg)
 			WM_Q_EVCNT_INCR(rxq, rxintr);
 		}
 #endif
+		/*
+		 * wm_rxeof() does *not* call upper layer functions directly,
+		 * as if_percpuq_enqueue() just call softint_schedule().
+		 * So, we can call wm_rxeof() in interrupt context.
+		 */
 		wm_rxeof(rxq, UINT_MAX);
 
 		mutex_exit(rxq->rxq_lock);



CVS commit: src/sys/dev/pci

2017-07-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jul 28 10:21:10 UTC 2017

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

Log Message:
 Check some wm_nvm_read()'s return vale.


To generate a diff of this commit:
cvs rdiff -u -r1.534 -r1.535 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.534 src/sys/dev/pci/if_wm.c:1.535
--- src/sys/dev/pci/if_wm.c:1.534	Fri Jul 28 09:12:40 2017
+++ src/sys/dev/pci/if_wm.c	Fri Jul 28 10:21:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.534 2017/07/28 09:12:40 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.535 2017/07/28 10:21:10 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.534 2017/07/28 09:12:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.535 2017/07/28 10:21:10 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -11598,7 +11598,10 @@ wm_nvm_set_addrbits_size_eecd(struct wm_
 	case WM_T_82547_2:
 		/* Set dummy value to access EEPROM */
 		sc->sc_nvm_wordsize = 64;
-		wm_nvm_read(sc, NVM_OFF_EEPROM_SIZE, 1, );
+		if (wm_nvm_read(sc, NVM_OFF_EEPROM_SIZE, 1, ) != 0) {
+			aprint_error_dev(sc->sc_dev,
+			"%s: failed to read EEPROM size\n", __func__);
+		}
 		reg = data;
 		size = __SHIFTOUT(reg, EECD_EE_SIZE_EX_MASK);
 		if (size == 0)
@@ -12483,9 +12486,8 @@ wm_nvm_version(struct wm_softc *sc)
 	 * Qemu's e1000e emulation (82574L)'s SPI has only 64 words.
 	 * I've never seen on real 82574 hardware with such small SPI ROM.
 	 */
-	if (sc->sc_nvm_wordsize >= NVM_OFF_IMAGE_UID1)
-		wm_nvm_read(sc, NVM_OFF_IMAGE_UID1, 1, );
-	else
+	if ((sc->sc_nvm_wordsize < NVM_OFF_IMAGE_UID1)
+	|| (wm_nvm_read(sc, NVM_OFF_IMAGE_UID1, 1, ) != 0))
 		have_uid = false;
 
 	switch (sc->sc_type) {
@@ -12522,8 +12524,8 @@ wm_nvm_version(struct wm_softc *sc)
 	default:
 		return;
 	}
-	if (check_version) {
-		wm_nvm_read(sc, NVM_OFF_VERSION, 1, _data);
+	if (check_version
+	&& (wm_nvm_read(sc, NVM_OFF_VERSION, 1, _data) == 0)) {
 		major = (nvm_data & NVM_MAJOR_MASK) >> NVM_MAJOR_SHIFT;
 		if (have_build || ((nvm_data & 0x0f00) != 0x)) {
 			minor = (nvm_data & NVM_MINOR_MASK) >> NVM_MINOR_SHIFT;
@@ -12547,14 +12549,16 @@ printver:
 	}
 
 	/* Assume the Option ROM area is at avove NVM_SIZE */
-	if ((sc->sc_nvm_wordsize >= NVM_SIZE) && check_optionrom) {
-		wm_nvm_read(sc, NVM_OFF_COMB_VER_PTR, 1, );
+	if ((sc->sc_nvm_wordsize >= NVM_SIZE) && check_optionrom
+	&& (wm_nvm_read(sc, NVM_OFF_COMB_VER_PTR, 1, ) == 0)) {
 		/* Option ROM Version */
 		if ((off != 0x) && (off != 0x)) {
+			int rv;
+
 			off += NVM_COMBO_VER_OFF;
-			wm_nvm_read(sc, off + 1, 1, );
-			wm_nvm_read(sc, off, 1, );
-			if ((uid0 != 0) && (uid0 != 0x)
+			rv = wm_nvm_read(sc, off + 1, 1, );
+			rv |= wm_nvm_read(sc, off, 1, );
+			if ((rv == 0) && (uid0 != 0) && (uid0 != 0x)
 			&& (uid1 != 0) && (uid1 != 0x)) {
 /* 16bits */
 major = uid0 >> 8;
@@ -12566,10 +12570,8 @@ printver:
 		}
 	}
 
-	if (have_uid) {
-		wm_nvm_read(sc, NVM_OFF_IMAGE_UID0, 1, );
+	if (have_uid && (wm_nvm_read(sc, NVM_OFF_IMAGE_UID0, 1, ) == 0))
 		aprint_verbose(", Image Unique ID %08x", (uid1 << 16) | uid0);
-	}
 }
 
 /*



CVS commit: src/sys/dev/pci

2017-07-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jul 28 09:12:40 UTC 2017

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

Log Message:
 Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never seen on
real 82574 hardware with such small SPI ROM. Check sc->sc_nvm_wordsize before
accessing higer address words to prevent timeout.


To generate a diff of this commit:
cvs rdiff -u -r1.533 -r1.534 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.533 src/sys/dev/pci/if_wm.c:1.534
--- src/sys/dev/pci/if_wm.c:1.533	Thu Jul 27 03:21:42 2017
+++ src/sys/dev/pci/if_wm.c	Fri Jul 28 09:12:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.533 2017/07/27 03:21:42 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.534 2017/07/28 09:12:40 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.533 2017/07/27 03:21:42 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.534 2017/07/28 09:12:40 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -12477,7 +12477,17 @@ wm_nvm_version(struct wm_softc *sc)
 	 *		0x2013	2.1.3?
 	 *	82583	0x10a0	1.10.0? (document says it's default vaule)
 	 */
-	wm_nvm_read(sc, NVM_OFF_IMAGE_UID1, 1, );
+
+	/*
+	 * XXX
+	 * Qemu's e1000e emulation (82574L)'s SPI has only 64 words.
+	 * I've never seen on real 82574 hardware with such small SPI ROM.
+	 */
+	if (sc->sc_nvm_wordsize >= NVM_OFF_IMAGE_UID1)
+		wm_nvm_read(sc, NVM_OFF_IMAGE_UID1, 1, );
+	else
+		have_uid = false;
+
 	switch (sc->sc_type) {
 	case WM_T_82571:
 	case WM_T_82572:
@@ -12535,7 +12545,9 @@ printver:
 			aprint_verbose(".%d", build);
 		}
 	}
-	if (check_optionrom) {
+
+	/* Assume the Option ROM area is at avove NVM_SIZE */
+	if ((sc->sc_nvm_wordsize >= NVM_SIZE) && check_optionrom) {
 		wm_nvm_read(sc, NVM_OFF_COMB_VER_PTR, 1, );
 		/* Option ROM Version */
 		if ((off != 0x) && (off != 0x)) {



CVS commit: src/sys/dev/pci

2017-07-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 27 03:21:43 UTC 2017

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

Log Message:
 Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers say
"In rare circumstances, the SW semaphore may already be held unintentionally."
on I21[01]. PXE boot is one of the case.

XXX pullup-[678].


To generate a diff of this commit:
cvs rdiff -u -r1.532 -r1.533 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/pci/if_wmvar.h

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.532 src/sys/dev/pci/if_wm.c:1.533
--- src/sys/dev/pci/if_wm.c:1.532	Wed Jul 26 08:09:59 2017
+++ src/sys/dev/pci/if_wm.c	Thu Jul 27 03:21:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.532 2017/07/26 08:09:59 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.533 2017/07/27 03:21:42 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.532 2017/07/26 08:09:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.533 2017/07/27 03:21:42 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2215,6 +2215,8 @@ alloc_retry:
 		break;
 	case WM_T_I210:
 	case WM_T_I211:
+		/* Allow a single clear of the SW semaphore on I210 and newer*/
+		sc->sc_flags |= WM_F_WA_I210_CLSEM;
 		if (wm_nvm_get_flash_presence_i210(sc)) {
 			sc->nvm.read = wm_nvm_read_eerd;
 			/* Don't use WM_F_LOCK_EECD because we use EERD */
@@ -12704,6 +12706,7 @@ wm_get_swsm_semaphore(struct wm_softc *s
 		device_xname(sc->sc_dev), __func__));
 	KASSERT(sc->sc_nvm_wordsize > 0);
 
+retry:
 	/* Get the SW semaphore. */
 	timeout = sc->sc_nvm_wordsize + 1;
 	while (timeout) {
@@ -12717,6 +12720,16 @@ wm_get_swsm_semaphore(struct wm_softc *s
 	}
 
 	if (timeout == 0) {
+		if ((sc->sc_flags & WM_F_WA_I210_CLSEM) != 0) {
+			/*
+			 * In rare circumstances, the SW semaphore may already
+			 * be held unintentionally. Clear the semaphore once
+			 * before giving up.
+			 */
+			sc->sc_flags &= ~WM_F_WA_I210_CLSEM;
+			wm_put_swsm_semaphore(sc);
+			goto retry;
+		}
 		aprint_error_dev(sc->sc_dev,
 		"could not acquire SWSM SMBI\n");
 		return 1;

Index: src/sys/dev/pci/if_wmvar.h
diff -u src/sys/dev/pci/if_wmvar.h:1.36 src/sys/dev/pci/if_wmvar.h:1.37
--- src/sys/dev/pci/if_wmvar.h:1.36	Wed Jul 26 06:48:49 2017
+++ src/sys/dev/pci/if_wmvar.h	Thu Jul 27 03:21:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmvar.h,v 1.36 2017/07/26 06:48:49 msaitoh Exp $	*/
+/*	$NetBSD: if_wmvar.h,v 1.37 2017/07/27 03:21:42 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -96,6 +96,7 @@
 #define WM_F_80003_MDIC_WA	0x0100 /* 80003 MDIC workaround */
 #define	WM_F_PCS_DIS_AUTONEGO	0x0200 /* PCS Disable Autonego */
 #define	WM_F_PLL_WA_I210	0x0400 /* I21[01] PLL workaround */
+#define	WM_F_WA_I210_CLSEM	0x0800 /* I21[01] Semaphore workaround */
 
 #define WM_FLAGS "\20" \
 	"\1" "HAS_MII"	"\2" "LOCK_EECD" "\3" "_B02"	"\4" "_B03"	\



CVS commit: src/sys/dev/pci

2017-07-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 26 08:57:24 UTC 2017

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

Log Message:
Add Intel 5520/X58 QuickPath from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1294 -r1.1295 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.1294 src/sys/dev/pci/pcidevs:1.1295
--- src/sys/dev/pci/pcidevs:1.1294	Sat Jul 22 08:58:24 2017
+++ src/sys/dev/pci/pcidevs	Wed Jul 26 08:57:24 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1294 2017/07/22 08:58:24 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1295 2017/07/26 08:57:24 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3972,6 +3972,8 @@ product INTEL 82X58_PCIE_7	0x340e	5520/5
 product INTEL 82X58_PCIE_8	0x340f	5520/5500/X58 PCIE Root Port 8
 product INTEL 82X58_PCIE_9	0x3410	5520/5500/X58 PCIE Root Port 9
 product INTEL 82X58_PCIE_10	0x3411	5520/5500/X58 PCIE Root Port 10
+product INTEL 82X58_QP0_PHY	0x3418	5520/X58 QuickPath
+product INTEL 5520_QP1_PHY	0x3419	5520 QuickPath
 product INTEL 82X58_PCIE_0_0	0x3420	5520/5500/X58 PCIE Root Port 0
 product INTEL 82X58_PCIE_0_1	0x3421	5520/5500/X58 PCIE Root Port 0
 product INTEL 82X58_GPIO	0x3422	5520/5500/X58 Scratchpads and GPIO



CVS commit: src/sys/dev/pci

2017-07-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 26 08:09:59 UTC 2017

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

Log Message:
 On 8254[17] with SPI ROM, wm_nvm_set_addrbits_size_eecd() calls wm_nvm_read(),
so it's required to set flags and functions before calling it. It was broken
again in if_wm.c rev. 1.530 (see also 1.313). Tested with Dell Power Edge 1850.


To generate a diff of this commit:
cvs rdiff -u -r1.531 -r1.532 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.531 src/sys/dev/pci/if_wm.c:1.532
--- src/sys/dev/pci/if_wm.c:1.531	Wed Jul 26 06:48:49 2017
+++ src/sys/dev/pci/if_wm.c	Wed Jul 26 08:09:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.531 2017/07/26 06:48:49 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.532 2017/07/26 08:09:59 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.531 2017/07/26 06:48:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.532 2017/07/26 08:09:59 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2078,6 +2078,13 @@ alloc_retry:
 	case WM_T_82547:
 	case WM_T_82547_2:
 		reg = CSR_READ(sc, WMREG_EECD);
+		/*
+		 * wm_nvm_set_addrbits_size_eecd() accesses SPI in it only
+		 * on 8254[17], so set flags and functios before calling it.
+		 */
+		sc->sc_flags |= WM_F_LOCK_EECD;
+		sc->nvm.acquire = wm_get_eecd;
+		sc->nvm.release = wm_put_eecd;
 		if (reg & EECD_EE_TYPE) {
 			/* SPI */
 			sc->nvm.read = wm_nvm_read_spi;
@@ -2094,9 +2101,6 @@ alloc_retry:
 sc->sc_nvm_addrbits = 6;
 			}
 		}
-		sc->sc_flags |= WM_F_LOCK_EECD;
-		sc->nvm.acquire = wm_get_eecd;
-		sc->nvm.release = wm_put_eecd;
 		break;
 	case WM_T_82571:
 	case WM_T_82572:



CVS commit: src/sys/dev/pci

2017-07-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 26 06:48:49 UTC 2017

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

Log Message:
-  Our MII readreg/writereg API has not way to detect an error.
  kmrn_{read,write}reg() are not used for MII API, so it's not required for
  these functions to use the same API. So,
  - Change return value as error code.
  - Change register vaule from int to uint16_t.
  - read: pass pointer for uint16_t as an argument.
  - Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not in
  wm_reset(). If the workaround isn't required, don't use the workaround code
  in wm_gmii_i80003_{read,write}reg.


To generate a diff of this commit:
cvs rdiff -u -r1.530 -r1.531 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_wmvar.h

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.530 src/sys/dev/pci/if_wm.c:1.531
--- src/sys/dev/pci/if_wm.c:1.530	Tue Jul 25 06:00:17 2017
+++ src/sys/dev/pci/if_wm.c	Wed Jul 26 06:48:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.530 2017/07/25 06:00:17 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.531 2017/07/26 06:48:49 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.530 2017/07/25 06:00:17 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.531 2017/07/26 06:48:49 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -809,10 +809,10 @@ static void	wm_gmii_statchg(struct ifnet
  * These functions are not for accessing MII registers but for accessing
  * kumeran specific registers.
  */
-static int	wm_kmrn_readreg(struct wm_softc *, int);
-static int	wm_kmrn_readreg_locked(struct wm_softc *, int);
-static void	wm_kmrn_writereg(struct wm_softc *, int, int);
-static void	wm_kmrn_writereg_locked(struct wm_softc *, int, int);
+static int	wm_kmrn_readreg(struct wm_softc *, int, uint16_t *);
+static int	wm_kmrn_readreg_locked(struct wm_softc *, int, uint16_t *);
+static int	wm_kmrn_writereg(struct wm_softc *, int, uint16_t);
+static int	wm_kmrn_writereg_locked(struct wm_softc *, int, uint16_t);
 /* SGMII */
 static bool	wm_sgmii_uses_mdio(struct wm_softc *);
 static int	wm_sgmii_readreg(device_t, int, int);
@@ -4247,6 +4247,8 @@ wm_reset(struct wm_softc *sc)
 	int phy_reset = 0;
 	int i, error = 0;
 	uint32_t reg;
+	uint16_t kmreg;
+	int rv;
 
 	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
@@ -4641,6 +4643,21 @@ wm_reset(struct wm_softc *sc)
 
 	if ((sc->sc_flags & WM_F_PLL_WA_I210) != 0)
 		wm_pll_workaround_i210(sc);
+
+	if (sc->sc_type == WM_T_80003) {
+		/* default to TRUE to enable the MDIC W/A */
+		sc->sc_flags |= WM_F_80003_MDIC_WA;
+	
+		rv = wm_kmrn_readreg(sc,
+		KUMCTRLSTA_OFFSET >> KUMCTRLSTA_OFFSET_SHIFT, );
+		if (rv == 0) {
+			if ((kmreg & KUMCTRLSTA_OPMODE_MASK)
+			== KUMCTRLSTA_OPMODE_INBAND_MDIO)
+sc->sc_flags &= ~WM_F_80003_MDIC_WA;
+			else
+sc->sc_flags |= WM_F_80003_MDIC_WA;
+		}
+	}
 }
 
 /*
@@ -5414,7 +5431,7 @@ wm_init_locked(struct ifnet *ifp)
 	wm_set_vlan(sc);
 
 	if (sc->sc_flags & WM_F_HAS_MII) {
-		int val;
+		uint16_t kmreg;
 
 		switch (sc->sc_type) {
 		case WM_T_80003:
@@ -5433,19 +5450,20 @@ wm_init_locked(struct ifnet *ifp)
 			 */
 			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_TIMEOUTS,
 			0x);
-			val = wm_kmrn_readreg(sc, KUMCTRLSTA_OFFSET_INB_PARAM);
-			val |= 0x3F;
-			wm_kmrn_writereg(sc,
-			KUMCTRLSTA_OFFSET_INB_PARAM, val);
+			wm_kmrn_readreg(sc, KUMCTRLSTA_OFFSET_INB_PARAM,
+			);
+			kmreg |= 0x3F;
+			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_INB_PARAM,
+			kmreg);
 			break;
 		default:
 			break;
 		}
 
 		if (sc->sc_type == WM_T_80003) {
-			val = CSR_READ(sc, WMREG_CTRL_EXT);
-			val &= ~CTRL_EXT_LINK_MODE_MASK;
-			CSR_WRITE(sc, WMREG_CTRL_EXT, val);
+			reg = CSR_READ(sc, WMREG_CTRL_EXT);
+			reg &= ~CTRL_EXT_LINK_MODE_MASK;
+			CSR_WRITE(sc, WMREG_CTRL_EXT, reg);
 
 			/* Bypass RX and TX FIFO's */
 			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_FIFO_CTRL,
@@ -9953,6 +9971,7 @@ static int
 wm_gmii_i80003_readreg(device_t dev, int phy, int reg)
 {
 	struct wm_softc *sc = device_private(dev);
+	int page_select, temp;
 	int rv;
 
 	if (phy != 1) /* only one PHY on kumeran bus */
@@ -9963,19 +9982,35 @@ wm_gmii_i80003_readreg(device_t dev, int
 		return 0;
 	}
 
-	if ((reg & MII_ADDRMASK) < GG82563_MIN_ALT_REG) {
-		wm_gmii_mdic_writereg(dev, phy, GG82563_PHY_PAGE_SELECT,
-		reg >> GG82563_PAGE_SHIFT);
-	} else {
-		wm_gmii_mdic_writereg(dev, phy, GG82563_PHY_PAGE_SELECT_ALT,
-		reg >> GG82563_PAGE_SHIFT);
+	if ((reg & MII_ADDRMASK) < GG82563_MIN_ALT_REG)
+		page_select = GG82563_PHY_PAGE_SELECT;
+	

CVS commit: src/sys/dev/pci

2017-07-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jul 25 06:00:17 UTC 2017

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

Log Message:
 Use new nvm.{acquire,release}() for semaphore. Almost the same except the
following:
 - 8257[12]: Don't directly access SPI but use EERD register.
 - 82575-I354: If the size of SPI ROM >= 32K words, use direct SPI access
   instead of EERD register access.
 - Add wm_nvm_eec_clock_raise() and wm_nvm_eec_clock_lower() and use them for
   Microwire/SPI bus control. Same as Linux and FreeBSD.
 - Redude timeout value for 80003 in wm_get_swfw_semaphore(). Same as
   Linux and FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.529 -r1.530 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/if_wmvar.h

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.529 src/sys/dev/pci/if_wm.c:1.530
--- src/sys/dev/pci/if_wm.c:1.529	Thu Jul 20 10:00:25 2017
+++ src/sys/dev/pci/if_wm.c	Tue Jul 25 06:00:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.529 2017/07/20 10:00:25 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.530 2017/07/25 06:00:17 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.529 2017/07/20 10:00:25 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.530 2017/07/25 06:00:17 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -442,6 +442,12 @@ struct wm_phyop {
 	int reset_delay_us;
 };
 
+struct wm_nvmop {
+	int (*acquire)(struct wm_softc *);
+	void (*release)(struct wm_softc *);
+	int (*read)(struct wm_softc *, int, int, uint16_t *);
+};
+
 /*
  * Software state per device.
  */
@@ -564,6 +570,7 @@ struct wm_softc {
 	kmutex_t *sc_ich_nvmmtx;	/* ICH/PCH specific NVM mutex */
 
 	struct wm_phyop phy;
+	struct wm_nvmop nvm;
 };
 
 #define WM_CORE_LOCK(_sc)	if ((_sc)->sc_core_lock) mutex_enter((_sc)->sc_core_lock)
@@ -857,8 +864,6 @@ static int	wm_nvm_read_spt(struct wm_sof
 static int	wm_nvm_read_word_invm(struct wm_softc *, uint16_t, uint16_t *);
 static int	wm_nvm_read_invm(struct wm_softc *, int, int, uint16_t *);
 /* Lock, detecting NVM type, validate checksum and read */
-static int	wm_nvm_acquire(struct wm_softc *);
-static void	wm_nvm_release(struct wm_softc *);
 static int	wm_nvm_is_onboard_eeprom(struct wm_softc *);
 static int	wm_nvm_get_flash_presence_i210(struct wm_softc *);
 static int	wm_nvm_validate_checksum(struct wm_softc *);
@@ -872,17 +877,23 @@ static int	wm_nvm_read(struct wm_softc *
  */
 static int	wm_get_null(struct wm_softc *);
 static void	wm_put_null(struct wm_softc *);
+static int	wm_get_eecd(struct wm_softc *);
+static void	wm_put_eecd(struct wm_softc *);
 static int	wm_get_swsm_semaphore(struct wm_softc *); /* 8257[123] */
 static void	wm_put_swsm_semaphore(struct wm_softc *);
 static int	wm_get_swfw_semaphore(struct wm_softc *, uint16_t);
 static void	wm_put_swfw_semaphore(struct wm_softc *, uint16_t);
+static int	wm_get_nvm_80003(struct wm_softc *);
+static void	wm_put_nvm_80003(struct wm_softc *);
+static int	wm_get_nvm_82571(struct wm_softc *);
+static void	wm_put_nvm_82571(struct wm_softc *);
 static int	wm_get_phy_82575(struct wm_softc *);
 static void	wm_put_phy_82575(struct wm_softc *);
 static int	wm_get_swfwhw_semaphore(struct wm_softc *); /* For 574/583 */
 static void	wm_put_swfwhw_semaphore(struct wm_softc *);
 static int	wm_get_swflag_ich8lan(struct wm_softc *);	/* For PHY */
 static void	wm_put_swflag_ich8lan(struct wm_softc *);
-static int	wm_get_nvm_ich8lan(struct wm_softc *);		/* For NVM */
+static int	wm_get_nvm_ich8lan(struct wm_softc *);
 static void	wm_put_nvm_ich8lan(struct wm_softc *);
 static int	wm_get_hw_semaphore_82573(struct wm_softc *);
 static void	wm_put_hw_semaphore_82573(struct wm_softc *);
@@ -1713,8 +1724,8 @@ wm_attach(device_t parent, device_t self
 	sc->sc_type = wmp->wmp_type;
 
 	/* Set default function pointers */
-	sc->phy.acquire = wm_get_null;
-	sc->phy.release = wm_put_null;
+	sc->phy.acquire = sc->nvm.acquire = wm_get_null;
+	sc->phy.release = sc->nvm.release = wm_put_null;
 	sc->phy.reset_delay_us = (sc->sc_type >= WM_T_82571) ? 100 : 1;
 
 	if (sc->sc_type < WM_T_82543) {
@@ -2039,6 +2050,7 @@ alloc_retry:
 	case WM_T_82543:
 	case WM_T_82544:
 		/* Microwire */
+		sc->nvm.read = wm_nvm_read_uwire;
 		sc->sc_nvm_wordsize = 64;
 		sc->sc_nvm_addrbits = 6;
 		break;
@@ -2048,6 +2060,7 @@ alloc_retry:
 	case WM_T_82546:
 	case WM_T_82546_3:
 		/* Microwire */
+		sc->nvm.read = wm_nvm_read_uwire;
 		reg = CSR_READ(sc, WMREG_EECD);
 		if (reg & EECD_EE_SIZE) {
 			sc->sc_nvm_wordsize = 256;
@@ -2057,19 +2070,22 @@ alloc_retry:
 			sc->sc_nvm_addrbits = 6;
 		}
 		sc->sc_flags |= WM_F_LOCK_EECD;
+		sc->nvm.acquire = wm_get_eecd;
+		sc->nvm.release = wm_put_eecd;
 		break;
 	case 

CVS commit: src/sys/dev/pci

2017-07-22 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 22 08:58:24 UTC 2017

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

Log Message:
- Add some AMD devices.
- Add Broadcom BCM5762.


To generate a diff of this commit:
cvs rdiff -u -r1.1293 -r1.1294 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.1293 src/sys/dev/pci/pcidevs:1.1294
--- src/sys/dev/pci/pcidevs:1.1293	Fri Jul  7 06:52:24 2017
+++ src/sys/dev/pci/pcidevs	Sat Jul 22 08:58:24 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1293 2017/07/07 06:52:24 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1294 2017/07/22 08:58:24 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1052,6 +1052,10 @@ product AMD CS5536_UDC	0x2096	CS5536 UDC
 product AMD CS5536_UOC	0x2097	CS5536 UOC
 product AMD CS5536_IDE	0x209a	CS5536 IDE Controller
 product AMD SC520_SC	0x3000	Elan SC520 System Controller
+product AMD HUDSON_PCIE_0	0x43a0	Hudson PCIE Root Port 0
+product AMD HUDSON_PCIE_1	0x43a1	Hudson PCIE Root Port 1
+product AMD HUDSON_PCIE_2	0x43a2	Hudson PCIE Root Port 2
+product AMD HUDSON_PCIE_3	0x43a3	Hudson PCIE Root Port 3
 product AMD SC751_SC	0x7006	AMD751 System Controller
 product AMD SC751_PPB	0x7007	AMD751 PCI-PCI Bridge
 product AMD IGR4_AGP	0x700a	AMD IGR4 AGP Bridge
@@ -1256,6 +1260,8 @@ product ATTANSIC E2200		0xe091	E2200
 
 /* ATI products */
 /* See http://www.x.org/wiki/Radeon%20ASICs */
+product ATI RADEON_KAVERI_HDMI	0x1308	Kaveri HDMI Audio
+product ATI RADEON_KAVERI_R7_1	0x1313	Kaveri Radeon R7 (Kaveri)
 product ATI RADEON_WRESTLER_HDMI	0x1314	Wrestler HDMI Audio
 product ATI RADEON_BEAVERCREEK_HDMI	0x1714	BeaverCreek HDMI Audio
 product ATI RADEON_RV380_3150	0x3150	Radeon Mobility X600 (M24) 3150
@@ -1807,6 +1813,7 @@ product BROADCOM BCM5761	0x1681	BCM5761 
 product BROADCOM BCM57762	0x1682	BCM57762 Gigabit Ethernet
 product BROADCOM BCM5764	0x1684	BCM5764 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM57766	0x1686	BCM57766 NetXtreme 1000baseT Ethernet
+product BROADCOM BCM5762	0x1687	BCM5762 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5761S	0x1688	BCM5761S 10/100/1000 Ethernet
 product BROADCOM BCM5761SE	0x1689	BCM5761SE 10/100/1000 Ethernet
 product BROADCOM BCM57760	0x1690	BCM57760 NetXtreme 1000baseT Ethernet



CVS commit: src/sys/dev/pci

2017-07-21 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Jul 21 21:01:13 UTC 2017

Modified Files:
src/sys/dev/pci: aceride.c pciide_acer_reg.h

Log Message:
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.

The patch is from port-sparc64@.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/pci/aceride.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/pciide_acer_reg.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/aceride.c
diff -u src/sys/dev/pci/aceride.c:1.36 src/sys/dev/pci/aceride.c:1.37
--- src/sys/dev/pci/aceride.c:1.36	Mon Oct  7 19:51:55 2013
+++ src/sys/dev/pci/aceride.c	Fri Jul 21 21:01:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: aceride.c,v 1.36 2013/10/07 19:51:55 jakllsch Exp $	*/
+/*	$NetBSD: aceride.c,v 1.37 2017/07/21 21:01:13 nakayama Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aceride.c,v 1.36 2013/10/07 19:51:55 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aceride.c,v 1.37 2017/07/21 21:01:13 nakayama Exp $");
 
 #include 
 #include 
@@ -194,8 +194,13 @@ acer_chip_map(struct pciide_softc *sc, c
 	interface = PCI_INTERFACE(pci_conf_read(sc->sc_pc, sc->sc_tag,
 	PCI_CLASS_REG));
 
-	/* From linux: enable "Cable Detection" */
 	if (rev >= 0xC2) {
+		/* From FreeBSD: use device interrupt as byte count end */
+		pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_0x4A,
+		pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4A)
+		| ACER_0x4A_BCEINT);
+
+		/* From linux: enable "Cable Detection" */
 		pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_0x4B,
 		pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4B)
 		| ACER_0x4B_CDETECT);

Index: src/sys/dev/pci/pciide_acer_reg.h
diff -u src/sys/dev/pci/pciide_acer_reg.h:1.12 src/sys/dev/pci/pciide_acer_reg.h:1.13
--- src/sys/dev/pci/pciide_acer_reg.h:1.12	Mon Oct 19 18:41:15 2009
+++ src/sys/dev/pci/pciide_acer_reg.h	Fri Jul 21 21:01:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciide_acer_reg.h,v 1.12 2009/10/19 18:41:15 bouyer Exp $	*/
+/*	$NetBSD: pciide_acer_reg.h,v 1.13 2017/07/21 21:01:13 nakayama Exp $	*/
 
 /*
  * Copyright (c) 1999 Manuel Bouyer.
@@ -37,6 +37,8 @@
  * bit 1 is 0 -> secondary has 80 pin cable
  */
 #define ACER_0x4A_80PIN(chan)	(0x1 << (chan))
+/* From FreeBSD, use device interrupt as byte count end */
+#define ACER_0x4A_BCEINT	0x20
 
 /* From FreeBSD, for UDMA mode > 2 */
 #define ACER_0x4B	0x4b



CVS commit: src/sys/dev/pci

2017-07-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 20 10:00:25 UTC 2017

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

Log Message:
 Fix a bug that sc->sc_flags can't be passed to igphy(4). This bug was added
in if_wm.c rev 1.527.


To generate a diff of this commit:
cvs rdiff -u -r1.528 -r1.529 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.528 src/sys/dev/pci/if_wm.c:1.529
--- src/sys/dev/pci/if_wm.c:1.528	Tue Jul 18 08:22:55 2017
+++ src/sys/dev/pci/if_wm.c	Thu Jul 20 10:00:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.528 2017/07/18 08:22:55 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.529 2017/07/20 10:00:25 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.528 2017/07/18 08:22:55 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.529 2017/07/20 10:00:25 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2480,17 +2480,13 @@ alloc_retry:
 			sc->sc_nvm_k1_enabled = 0;
 	}
 
-	/*
-	 * Determine if we're TBI,GMII or SGMII mode, and initialize the
-	 * media structures accordingly.
-	 */
+	/* Determine if we're GMII, TBI, SERDES or SGMII mode */
 	if (sc->sc_type == WM_T_ICH8 || sc->sc_type == WM_T_ICH9
 	|| sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_PCH
 	|| sc->sc_type == WM_T_PCH2 || sc->sc_type == WM_T_PCH_LPT
 	|| sc->sc_type == WM_T_PCH_SPT || sc->sc_type == WM_T_82573
 	|| sc->sc_type == WM_T_82574 || sc->sc_type == WM_T_82583) {
-		/* STATUS_TBIMODE reserved/reused, can't rely on it */
-		wm_gmii_mediainit(sc, wmp->wmp_product);
+		/* Copper only */
 	} else if ((sc->sc_type == WM_T_82575) || (sc->sc_type == WM_T_82576)
 	|| (sc->sc_type ==WM_T_82580) || (sc->sc_type ==WM_T_I350)
 	|| (sc->sc_type ==WM_T_I354) || (sc->sc_type ==WM_T_I210)
@@ -2556,11 +2552,6 @@ alloc_retry:
 		else
 			reg &= ~CTRL_EXT_I2C_ENA;
 		CSR_WRITE(sc, WMREG_CTRL_EXT, reg);
-
-		if (sc->sc_mediatype == WM_MEDIATYPE_COPPER)
-			wm_gmii_mediainit(sc, wmp->wmp_product);
-		else
-			wm_tbi_mediainit(sc);
 	} else if (sc->sc_type < WM_T_82543 ||
 	(CSR_READ(sc, WMREG_STATUS) & STATUS_TBIMODE) != 0) {
 		if (sc->sc_mediatype == WM_MEDIATYPE_COPPER) {
@@ -2568,14 +2559,12 @@ alloc_retry:
 			"WARNING: TBIMODE set on 1000BASE-T product!\n");
 			sc->sc_mediatype = WM_MEDIATYPE_FIBER;
 		}
-		wm_tbi_mediainit(sc);
 	} else {
 		if (sc->sc_mediatype == WM_MEDIATYPE_FIBER) {
 			aprint_error_dev(sc->sc_dev,
 			"WARNING: TBIMODE clear on 1000BASE-X product!\n");
 			sc->sc_mediatype = WM_MEDIATYPE_COPPER;
 		}
-		wm_gmii_mediainit(sc, wmp->wmp_product);
 	}
 	snprintb(buf, sizeof(buf), WM_FLAGS, sc->sc_flags);
 	aprint_verbose_dev(sc->sc_dev, "%s\n", buf);
@@ -2583,6 +2572,12 @@ alloc_retry:
 	/* Set device properties (macflags) */
 	prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags);
 
+	/* Initialize the media structures accordingly. */
+	if (sc->sc_mediatype == WM_MEDIATYPE_COPPER)
+		wm_gmii_mediainit(sc, wmp->wmp_product);
+	else
+		wm_tbi_mediainit(sc); /* All others */
+
 	ifp = >sc_ethercom.ec_if;
 	xname = device_xname(sc->sc_dev);
 	strlcpy(ifp->if_xname, xname, IFNAMSIZ);



CVS commit: src/sys/dev/pci

2017-07-19 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Jul 19 16:55:12 UTC 2017

Modified Files:
src/sys/dev/pci: if_iwn.c if_iwnreg.h if_iwnvar.h

Log Message:
Pull in some hardware support from FreeBSD. Also fix 5GHz mode by
adapting the method described in: https://forums.freebsd.org/threads/53574/.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/pci/if_iwn.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/if_iwnreg.h
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/if_iwnvar.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_iwn.c
diff -u src/sys/dev/pci/if_iwn.c:1.84 src/sys/dev/pci/if_iwn.c:1.85
--- src/sys/dev/pci/if_iwn.c:1.84	Thu Feb  2 10:05:35 2017
+++ src/sys/dev/pci/if_iwn.c	Wed Jul 19 16:55:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwn.c,v 1.84 2017/02/02 10:05:35 nonaka Exp $	*/
+/*	$NetBSD: if_iwn.c,v 1.85 2017/07/19 16:55:12 mlelstv 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.84 2017/02/02 10:05:35 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.85 2017/07/19 16:55:12 mlelstv Exp $");
 
 #define IWN_USE_RBUF	/* Use local storage for RX */
 #undef IWN_HWCRYPTO	/* XXX does not even compile yet */
@@ -790,7 +790,7 @@ iwn5000_attach(struct iwn_softc *sc, pci
 			sc->fwname = "iwlwifi-6000g2a-5.ucode";
 		break;
 	case IWN_HW_REV_TYPE_2030:
-		sc->limits = _sensitivity_limits;
+		sc->limits = _sensitivity_limits;
 		sc->fwname = "iwlwifi-2030-6.ucode";
 		ops->config_bt_coex = iwn_config_bt_coex_adv2;
 		break;
@@ -1781,6 +1781,7 @@ iwn_read_eeprom_enhinfo(struct iwn_softc
 	struct iwn_eeprom_enhinfo enhinfo[35];
 	uint16_t val, base;
 	int8_t maxpwr;
+	uint8_t flags;
 	int i;
 
 	iwn_read_prom_data(sc, IWN5000_EEPROM_REG, , 2);
@@ -1790,7 +1791,8 @@ iwn_read_eeprom_enhinfo(struct iwn_softc
 
 	memset(sc->enh_maxpwr, 0, sizeof sc->enh_maxpwr);
 	for (i = 0; i < __arraycount(enhinfo); i++) {
-		if (enhinfo[i].chan == 0 || enhinfo[i].reserved != 0)
+		flags = enhinfo[i].flags;
+		if (!(flags & IWN_ENHINFO_VALID))
 			continue;	/* Skip invalid entries. */
 
 		maxpwr = 0;
@@ -1915,6 +1917,10 @@ iwn_newstate(struct ieee80211com *ic, en
 		sc->rxon.filter &= ~htole32(IWN_FILTER_BSS);
 		sc->calib.state = IWN_CALIB_STATE_INIT;
 
+		/* Wait until we hear a beacon before we transmit */
+		if (IEEE80211_IS_CHAN_PASSIVE(ic->ic_curchan))
+			sc->sc_beacon_wait = 1;
+
 		if ((error = iwn_auth(sc)) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"could not move to auth state\n");
@@ -1923,6 +1929,18 @@ iwn_newstate(struct ieee80211com *ic, en
 		break;
 
 	case IEEE80211_S_RUN:
+		/*
+		 * RUN -> RUN transition; Just restart timers.
+		 */
+		if (ic->ic_state == IEEE80211_S_RUN) {
+			sc->calib_cnt = 0;
+			break;
+		}
+
+		/* Wait until we hear a beacon before we transmit */
+		if (IEEE80211_IS_CHAN_PASSIVE(ic->ic_curchan))
+			sc->sc_beacon_wait = 1;
+
 		if ((error = iwn_run(sc)) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"could not move to run state\n");
@@ -1933,6 +1951,13 @@ iwn_newstate(struct ieee80211com *ic, en
 	case IEEE80211_S_INIT:
 		sc->sc_flags &= ~IWN_FLAG_SCANNING;
 		sc->calib.state = IWN_CALIB_STATE_INIT;
+		/*
+		 * Purge the xmit queue so we don't have old frames
+		 * during a new association attempt.
+		 */
+		sc->sc_beacon_wait = 0;
+		ifp->if_flags &= ~IFF_OACTIVE;
+		iwn_start(ifp);
 		break;
 	}
 
@@ -2154,6 +2179,25 @@ iwn_rx_done(struct iwn_softc *sc, struct
 		bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m);
 	}
 
+	/*
+	 * If it's a beacon and we're waiting, then do the wakeup.
+	 */
+	if (sc->sc_beacon_wait) {
+		uint8_t type, subtype;
+		type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
+		subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
+		/*
+		 * This assumes at this point we've received our own
+		 * beacon.
+		 */
+		if (type == IEEE80211_FC0_TYPE_MGT &&
+		subtype == IEEE80211_FC0_SUBTYPE_BEACON) {
+			sc->sc_beacon_wait = 0;
+			ifp->if_flags &= ~IFF_OACTIVE;
+			iwn_start(ifp);
+		}
+	}
+
 	/* Send the frame to the 802.11 layer. */
 	ieee80211_input(ic, m, ni, rssi, 0);
 
@@ -3142,6 +3186,11 @@ iwn_start(struct ifnet *ifp)
 		return;
 
 	for (;;) {
+		if (sc->sc_beacon_wait == 1) {
+			ifp->if_flags |= IFF_OACTIVE;
+			break;
+		}
+
 		if (sc->qfullmsk != 0) {
 			ifp->if_flags |= IFF_OACTIVE;
 			break;
@@ -3184,7 +3233,8 @@ iwn_start(struct ifnet *ifp)
 		ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ?
 		M_WME_GETAC(m) : WME_AC_BE;
 
-		bpf_mtap(ifp, m);
+		if (sc->sc_beacon_wait == 0)
+			bpf_mtap(ifp, m);
 
 		if ((m = ieee80211_encap(ic, m, ni)) == NULL) {
 			ieee80211_free_node(ni);
@@ -3192,6 +3242,9 @@ iwn_start(struct ifnet *ifp)
 			continue;
 		}
 sendit:
+		if (sc->sc_beacon_wait)
+			continue;
+
 		bpf_mtap3(ic->ic_rawbpf, m);
 
 		if (iwn_tx(sc, m, ni, ac) != 

CVS commit: src/sys/dev/pci

2017-07-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jul 18 08:05:03 UTC 2017

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

Log Message:
 Move some initialization stuff in wm_attach() before wm_reset(). Some flags
and callback function is required to set correctly before wm_reset() because
wm_reset() and some helper functions refer them.


To generate a diff of this commit:
cvs rdiff -u -r1.526 -r1.527 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.526 src/sys/dev/pci/if_wm.c:1.527
--- src/sys/dev/pci/if_wm.c:1.526	Tue Jul 18 08:01:07 2017
+++ src/sys/dev/pci/if_wm.c	Tue Jul 18 08:05:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.526 2017/07/18 08:01:07 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.527 2017/07/18 08:05:03 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.526 2017/07/18 08:01:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.527 2017/07/18 08:05:03 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2188,9 +2188,6 @@ alloc_retry:
 		break;
 	}
 
-	/* Reset the chip to a known state. */
-	wm_reset(sc);
-
 	/* Ensure the SMBI bit is clear before first NVM or PHY access */
 	switch (sc->sc_type) {
 	case WM_T_82571:
@@ -2237,9 +2234,6 @@ alloc_retry:
 			sc->sc_flags |= WM_F_EEPROM_INVALID;
 	}
 
-	/* Set device properties (macflags) */
-	prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags);
-
 	if (sc->sc_flags & WM_F_EEPROM_INVALID)
 		aprint_verbose_dev(sc->sc_dev, "No EEPROM");
 	else {
@@ -2263,6 +2257,15 @@ alloc_retry:
 	wm_nvm_version(sc);
 	aprint_verbose("\n");
 
+	/*
+	 * XXX The first call of wm_gmii_setup_phytype. The result might be
+	 * incorrect.
+	 */
+	wm_gmii_setup_phytype(sc, 0, 0);
+
+	/* Reset the chip to a known state. */
+	wm_reset(sc);
+
 	/* Check for I21[01] PLL workaround */
 	if (sc->sc_type == WM_T_I210)
 		sc->sc_flags |= WM_F_PLL_WA_I210;
@@ -2575,6 +2578,9 @@ alloc_retry:
 	snprintb(buf, sizeof(buf), WM_FLAGS, sc->sc_flags);
 	aprint_verbose_dev(sc->sc_dev, "%s\n", buf);
 
+	/* Set device properties (macflags) */
+	prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags);
+
 	ifp = >sc_ethercom.ec_if;
 	xname = device_xname(sc->sc_dev);
 	strlcpy(ifp->if_xname, xname, IFNAMSIZ);
@@ -9416,12 +9422,6 @@ wm_gmii_mediainit(struct wm_softc *sc, p
 	/* Initialize our media structures and probe the GMII. */
 	mii->mii_ifp = ifp;
 
-	/*
-	 * The first call of wm_mii_setup_phytype. The result might be
-	 * incorrect.
-	 */
-	wm_gmii_setup_phytype(sc, 0, 0);
-
 	mii->mii_statchg = wm_gmii_statchg;
 
 	/* get PHY control from SMBus to PCIe */
@@ -9514,7 +9514,7 @@ wm_gmii_mediainit(struct wm_softc *sc, p
 
 		/*
 		 * PHY Found! Check PHY type again by the second call of
-		 * wm_mii_setup_phytype.
+		 * wm_gmii_setup_phytype.
 		 */
 		wm_gmii_setup_phytype(sc, child->mii_mpd_oui,
 		child->mii_mpd_model);



CVS commit: src/sys/dev/pci

2017-07-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jul 18 08:01:07 UTC 2017

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

Log Message:
 Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to prevent
hungup. A semaphore is get/put in wm_nvm_{read,write}.


To generate a diff of this commit:
cvs rdiff -u -r1.525 -r1.526 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.525 src/sys/dev/pci/if_wm.c:1.526
--- src/sys/dev/pci/if_wm.c:1.525	Fri Jul 14 04:34:29 2017
+++ src/sys/dev/pci/if_wm.c	Tue Jul 18 08:01:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.525 2017/07/14 04:34:29 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.526 2017/07/18 08:01:07 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.525 2017/07/14 04:34:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.526 2017/07/18 08:01:07 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -11964,13 +11964,6 @@ wm_nvm_read_ich8(struct wm_softc *sc, in
 	 */
 	bank_offset = flash_bank * (sc->sc_ich8_flash_bank_size * 2);
 
-	error = wm_get_swfwhw_semaphore(sc);
-	if (error) {
-		aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
-		__func__);
-		return error;
-	}
-
 	for (i = 0; i < words; i++) {
 		/* The NVM part needs a byte offset, hence * 2 */
 		act_offset = bank_offset + ((offset + i) * 2);
@@ -11983,7 +11976,6 @@ wm_nvm_read_ich8(struct wm_softc *sc, in
 		data[i] = word;
 	}
 
-	wm_put_swfwhw_semaphore(sc);
 	return error;
 }
 
@@ -12028,13 +12020,6 @@ wm_nvm_read_spt(struct wm_softc *sc, int
 	 */
 	bank_offset = flash_bank * (sc->sc_ich8_flash_bank_size * 2);
 
-	error = wm_get_swfwhw_semaphore(sc);
-	if (error) {
-		aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
-		__func__);
-		return error;
-	}
-
 	for (i = 0; i < words; i++) {
 		/* The NVM part needs a byte offset, hence * 2 */
 		act_offset = bank_offset + ((offset + i) * 2);
@@ -12052,7 +12037,6 @@ wm_nvm_read_spt(struct wm_softc *sc, int
 			data[i] = (uint16_t)((dword >> 16) & 0x);
 	}
 
-	wm_put_swfwhw_semaphore(sc);
 	return error;
 }
 



CVS commit: src/sys/dev/pci

2017-07-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jul 14 04:34:29 UTC 2017

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

Log Message:
 Calling wm_init_lcd_from_nvm() makes hang on some machines reported by
Brad Harder. Until fix this problem correctly, Disable whole of
wm_init_lcd_from_nvm().


To generate a diff of this commit:
cvs rdiff -u -r1.524 -r1.525 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.524 src/sys/dev/pci/if_wm.c:1.525
--- src/sys/dev/pci/if_wm.c:1.524	Thu Jul 13 13:27:08 2017
+++ src/sys/dev/pci/if_wm.c	Fri Jul 14 04:34:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.524 2017/07/13 13:27:08 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.525 2017/07/14 04:34:29 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.524 2017/07/13 13:27:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.525 2017/07/14 04:34:29 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3702,6 +3702,7 @@ wm_phy_post_reset(struct wm_softc *sc)
 void
 wm_init_lcd_from_nvm(struct wm_softc *sc)
 {
+#if 0
 	uint32_t extcnfctr, sw_cfg_mask, cnf_size, word_addr, i, reg;
 	uint16_t phy_page = 0;
 
@@ -3786,6 +3787,7 @@ wm_init_lcd_from_nvm(struct wm_softc *sc
 release:	
 	sc->phy.release(sc);
 	return;
+#endif
 }
 
 



CVS commit: src/sys/dev/pci

2017-07-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 13 13:27:08 UTC 2017

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

Log Message:
 IF TX is not required to flush, RX is also not required to flush. Same as
other OSes.


To generate a diff of this commit:
cvs rdiff -u -r1.523 -r1.524 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.523 src/sys/dev/pci/if_wm.c:1.524
--- src/sys/dev/pci/if_wm.c:1.523	Thu Jul 13 08:22:21 2017
+++ src/sys/dev/pci/if_wm.c	Thu Jul 13 13:27:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.523 2017/07/13 08:22:21 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.524 2017/07/13 13:27:08 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.523 2017/07/13 08:22:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.524 2017/07/13 13:27:08 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4076,7 +4076,10 @@ wm_flush_desc_rings(struct wm_softc *sc)
 {
 	pcireg_t preg;
 	uint32_t reg;
+	struct wm_txqueue *txq;
+	wiseman_txdesc_t *txd;
 	int nexttx;
+	uint32_t rctl;
 
 	/* First, disable MULR fix in FEXTNVM11 */
 	reg = CSR_READ(sc, WMREG_FEXTNVM11);
@@ -4085,66 +4088,64 @@ wm_flush_desc_rings(struct wm_softc *sc)
 
 	preg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, WM_PCI_DESCRING_STATUS);
 	reg = CSR_READ(sc, WMREG_TDLEN(0));
-	if (((preg & DESCRING_STATUS_FLUSH_REQ) != 0) && (reg != 0)) {
-		struct wm_txqueue *txq;
-		wiseman_txdesc_t *txd;
-
-		/* TX */
-		printf("%s: Need TX flush (reg = %08x, len = %u)\n",
-		device_xname(sc->sc_dev), preg, reg);
-		reg = CSR_READ(sc, WMREG_TCTL);
-		CSR_WRITE(sc, WMREG_TCTL, reg | TCTL_EN);
+	if (((preg & DESCRING_STATUS_FLUSH_REQ) == 0) || (reg == 0))
+		return;
 
-		txq = >sc_queue[0].wmq_txq;
-		nexttx = txq->txq_next;
-		txd = >txq_descs[nexttx];
-		wm_set_dma_addr(>wtx_addr, WM_CDTXADDR(txq, nexttx));
-		txd->wtx_cmdlen = htole32(WTX_CMD_IFCS| 512);
-		txd->wtx_fields.wtxu_status = 0;
-		txd->wtx_fields.wtxu_options = 0;
-		txd->wtx_fields.wtxu_vlan = 0;
+	/* TX */
+	printf("%s: Need TX flush (reg = %08x, len = %u)\n",
+	device_xname(sc->sc_dev), preg, reg);
+	reg = CSR_READ(sc, WMREG_TCTL);
+	CSR_WRITE(sc, WMREG_TCTL, reg | TCTL_EN);
+
+	txq = >sc_queue[0].wmq_txq;
+	nexttx = txq->txq_next;
+	txd = >txq_descs[nexttx];
+	wm_set_dma_addr(>wtx_addr, WM_CDTXADDR(txq, nexttx));
+	txd->wtx_cmdlen = htole32(WTX_CMD_IFCS| 512);
+	txd->wtx_fields.wtxu_status = 0;
+	txd->wtx_fields.wtxu_options = 0;
+	txd->wtx_fields.wtxu_vlan = 0;
 
-		bus_space_barrier(sc->sc_st, sc->sc_sh, 0, 0,
-			BUS_SPACE_BARRIER_WRITE);
+	bus_space_barrier(sc->sc_st, sc->sc_sh, 0, 0,
+	BUS_SPACE_BARRIER_WRITE);
 		
-		txq->txq_next = WM_NEXTTX(txq, txq->txq_next);
-		CSR_WRITE(sc, WMREG_TDT(0), txq->txq_next);
-		bus_space_barrier(sc->sc_st, sc->sc_sh, 0, 0,
-			BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
-		delay(250);
-	}
+	txq->txq_next = WM_NEXTTX(txq, txq->txq_next);
+	CSR_WRITE(sc, WMREG_TDT(0), txq->txq_next);
+	bus_space_barrier(sc->sc_st, sc->sc_sh, 0, 0,
+	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
+	delay(250);
+
 	preg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, WM_PCI_DESCRING_STATUS);
-	if (preg & DESCRING_STATUS_FLUSH_REQ) {
-		uint32_t rctl;
+	if ((preg & DESCRING_STATUS_FLUSH_REQ) == 0)
+		return;
 
-		/* RX */
-		printf("%s: Need RX flush (reg = %08x)\n",
-		device_xname(sc->sc_dev), preg);
-		rctl = CSR_READ(sc, WMREG_RCTL);
-		CSR_WRITE(sc, WMREG_RCTL, rctl & ~RCTL_EN);
-		CSR_WRITE_FLUSH(sc);
-		delay(150);
+	/* RX */
+	printf("%s: Need RX flush (reg = %08x)\n",
+	device_xname(sc->sc_dev), preg);
+	rctl = CSR_READ(sc, WMREG_RCTL);
+	CSR_WRITE(sc, WMREG_RCTL, rctl & ~RCTL_EN);
+	CSR_WRITE_FLUSH(sc);
+	delay(150);
 
-		reg = CSR_READ(sc, WMREG_RXDCTL(0));
-		/* zero the lower 14 bits (prefetch and host thresholds) */
-		reg &= 0xc000;
-		/*
-		 * update thresholds: prefetch threshold to 31, host threshold
-		 * to 1 and make sure the granularity is "descriptors" and not
-		 * "cache lines"
-		 */
-		reg |= (0x1f | (1 << 8) | RXDCTL_GRAN);
-		CSR_WRITE(sc, WMREG_RXDCTL(0), reg);
+	reg = CSR_READ(sc, WMREG_RXDCTL(0));
+	/* zero the lower 14 bits (prefetch and host thresholds) */
+	reg &= 0xc000;
+	/*
+	 * update thresholds: prefetch threshold to 31, host threshold
+	 * to 1 and make sure the granularity is "descriptors" and not
+	 * "cache lines"
+	 */
+	reg |= (0x1f | (1 << 8) | RXDCTL_GRAN);
+	CSR_WRITE(sc, WMREG_RXDCTL(0), reg);
 
-		/*
-		 * momentarily enable the RX ring for the changes to take
-		 * effect
-		 */
-		CSR_WRITE(sc, WMREG_RCTL, rctl | RCTL_EN);
-		CSR_WRITE_FLUSH(sc);
-		delay(150);
-		CSR_WRITE(sc, WMREG_RCTL, rctl & ~RCTL_EN);
-	}
+	/*
+	 * momentarily enable the RX ring for the 

CVS commit: src/sys/dev/pci

2017-07-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 13 08:41:20 UTC 2017

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

Log Message:
- Official shortname of LN Requester is LNR, so change PCI_EXTCAP_LN_REQ
  to PCI_EXTCAP_LNR
- Use macro.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/pci/pcireg.h

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.189 src/sys/dev/pci/pci_subr.c:1.190
--- src/sys/dev/pci/pci_subr.c:1.189	Thu Jun 15 15:38:18 2017
+++ src/sys/dev/pci/pci_subr.c	Thu Jul 13 08:41:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.189 2017/06/15 15:38:18 flxd Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.190 2017/07/13 08:41:19 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.189 2017/06/15 15:38:18 flxd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.190 2017/07/13 08:41:19 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -2087,7 +2087,7 @@ pci_conf_print_pcie_cap(const pcireg_t *
 		break;
 	}
 	printf("  OBFF Supported: ");
-	switch ((reg & PCIE_DCAP2_OBFF) >> 18) {
+	switch (__SHIFTOUT(reg, PCIE_DCAP2_OBFF)) {
 	case 0x0:
 		printf("Not supported\n");
 		break;
@@ -2139,7 +2139,7 @@ pci_conf_print_pcie_cap(const pcireg_t *
 	onoff("Emergency Power Reduction Request", reg,
 	PCIE_DCSR2_EMGPWRRED_REQ);
 	printf("  OBFF: ");
-	switch ((reg & PCIE_DCSR2_OBFF_EN) >> 13) {
+	switch (__SHIFTOUT(reg, PCIE_DCSR2_OBFF_EN)) {
 	case 0x0:
 		printf("Disabled\n");
 		break;
@@ -3939,7 +3939,7 @@ static struct {
 	  NULL },
 	{ PCI_EXTCAP_PASID,	"Process Address Space ID",
 	  pci_conf_print_pasid_cap },
-	{ PCI_EXTCAP_LN_REQ,	"LN Requester",
+	{ PCI_EXTCAP_LNR,	"LN Requester",
 	  pci_conf_print_lnr_cap },
 	{ PCI_EXTCAP_DPC,	"Downstream Port Containment",
 	  pci_conf_print_dpc_cap },

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.131 src/sys/dev/pci/pcireg.h:1.132
--- src/sys/dev/pci/pcireg.h:1.131	Thu Jun 15 06:51:18 2017
+++ src/sys/dev/pci/pcireg.h	Thu Jul 13 08:41:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.131 2017/06/15 06:51:18 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.132 2017/07/13 08:41:19 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -1433,7 +1433,7 @@ struct pci_rom {
 #define	PCI_EXTCAP_SEC_PCIE	0x0019	/* Secondary PCI Express */
 #define	PCI_EXTCAP_PMUX		0x001a	/* Protocol Multiplexing */
 #define	PCI_EXTCAP_PASID	0x001b	/* Process Address Space ID */
-#define	PCI_EXTCAP_LN_REQ	0x001c	/* LN Requester */
+#define	PCI_EXTCAP_LNR		0x001c	/* LN Requester */
 #define	PCI_EXTCAP_DPC		0x001d	/* Downstream Port Containment */
 #define	PCI_EXTCAP_L1PM		0x001e	/* L1 PM Substates */
 #define	PCI_EXTCAP_PTM		0x001f	/* Precision Time Management */



CVS commit: src/sys/dev/pci

2017-07-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 13 08:04:56 UTC 2017

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

Log Message:
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of page
  select. PHY access from igphy() automatically did it, but accessing from
  wm(4) for wrokaround didn't work correctly. This change affects 8254[17],
  8257[12] ICH8, ICH9 and ICH10.
- Add diagnostic code.


To generate a diff of this commit:
cvs rdiff -u -r1.521 -r1.522 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.521 src/sys/dev/pci/if_wm.c:1.522
--- src/sys/dev/pci/if_wm.c:1.521	Thu Jul 13 07:50:49 2017
+++ src/sys/dev/pci/if_wm.c	Thu Jul 13 08:04:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.521 2017/07/13 07:50:49 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.522 2017/07/13 08:04:56 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.521 2017/07/13 07:50:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.522 2017/07/13 08:04:56 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -9617,6 +9617,12 @@ wm_gmii_mdic_readreg(device_t dev, int p
 	uint32_t mdic = 0;
 	int i, rv;
 
+	if (reg > MII_ADDRMASK) {
+		device_printf(dev, "%s: PHYTYPE = %d, addr 0x%x > 0x1f\n",
+		__func__, sc->sc_phytype, reg);
+		reg &= MII_ADDRMASK;
+	}
+
 	CSR_WRITE(sc, WMREG_MDIC, MDIC_OP_READ | MDIC_PHYADD(phy) |
 	MDIC_REGADD(reg));
 
@@ -9658,6 +9664,12 @@ wm_gmii_mdic_writereg(device_t dev, int 
 	uint32_t mdic = 0;
 	int i;
 
+	if (reg > MII_ADDRMASK) {
+		device_printf(dev, "%s: PHYTYPE = %d, addr 0x%x > 0x1f\n",
+		__func__, sc->sc_phytype, reg);
+		reg &= MII_ADDRMASK;
+	}
+
 	CSR_WRITE(sc, WMREG_MDIC, MDIC_OP_WRITE | MDIC_PHYADD(phy) |
 	MDIC_REGADD(reg) | MDIC_DATA(val));
 
@@ -9691,7 +9703,24 @@ wm_gmii_i82544_readreg(device_t dev, int
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
 		return 0;
 	}
-	rv = wm_gmii_mdic_readreg(dev, phy, reg);
+
+	if (reg > BME1000_MAX_MULTI_PAGE_REG) {
+		switch (sc->sc_phytype) {
+		case WMPHY_IGP:
+		case WMPHY_IGP_2:
+		case WMPHY_IGP_3:
+			wm_gmii_mdic_writereg(dev, phy, MII_IGPHY_PAGE_SELECT, reg);
+			break;
+		default:
+#ifdef WM_DEBUG
+			device_printf(dev, "%s: PHYTYPE = 0x%x, addr = %02x\n",
+			__func__, sc->sc_phytype, reg);
+#endif
+			break;
+		}
+	}
+	
+	rv = wm_gmii_mdic_readreg(dev, phy, reg & MII_ADDRMASK);
 	sc->phy.release(sc);
 
 	return rv;
@@ -9711,7 +9740,24 @@ wm_gmii_i82544_writereg(device_t dev, in
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
 		return;
 	}
-	wm_gmii_mdic_writereg(dev, phy, reg, val);
+
+	if (reg > BME1000_MAX_MULTI_PAGE_REG) {
+		switch (sc->sc_phytype) {
+		case WMPHY_IGP:
+		case WMPHY_IGP_2:
+		case WMPHY_IGP_3:
+			wm_gmii_mdic_writereg(dev, phy, MII_IGPHY_PAGE_SELECT, reg);
+			break;
+		default:
+#ifdef WM_DEBUG
+			device_printf(dev, "%s: PHYTYPE == 0x%x, addr = %02x",
+			__func__, sc->sc_phytype, reg);
+#endif
+			break;
+		}
+	}
+			
+	wm_gmii_mdic_writereg(dev, phy, reg & MII_ADDRMASK, val);
 	sc->phy.release(sc);
 }
 
@@ -10092,6 +10138,13 @@ wm_gmii_82580_readreg(device_t dev, int 
 		return 0;
 	}
 
+#ifdef DIAGNOSTIC
+	if (reg > MII_ADDRMASK) {
+		device_printf(dev, "%s: PHYTYPE = %d, addr 0x%x > 0x1f\n",
+		__func__, sc->sc_phytype, reg);
+		reg &= MII_ADDRMASK;
+	}
+#endif
 	rv = wm_gmii_mdic_readreg(dev, phy, reg);
 
 	sc->phy.release(sc);
@@ -10115,6 +10168,13 @@ wm_gmii_82580_writereg(device_t dev, int
 		return;
 	}
 
+#ifdef DIAGNOSTIC
+	if (reg > MII_ADDRMASK) {
+		device_printf(dev, "%s: PHYTYPE = %d, addr 0x%x > 0x1f\n",
+		__func__, sc->sc_phytype, reg);
+		reg &= MII_ADDRMASK;
+	}
+#endif
 	wm_gmii_mdic_writereg(dev, phy, reg, val);
 
 	sc->phy.release(sc);



CVS commit: src/sys/dev/pci

2017-07-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul 13 07:50:49 UTC 2017

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

Log Message:
- Use device_printf() instead of aprint_error_dev() for PHY read/write
  functions because those are used not only in device attach.
- Add debug printf.
- Rename variables.


To generate a diff of this commit:
cvs rdiff -u -r1.520 -r1.521 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.520 src/sys/dev/pci/if_wm.c:1.521
--- src/sys/dev/pci/if_wm.c:1.520	Wed Jul 12 08:18:36 2017
+++ src/sys/dev/pci/if_wm.c	Thu Jul 13 07:50:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.520 2017/07/12 08:18:36 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.521 2017/07/13 07:50:49 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.520 2017/07/12 08:18:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.521 2017/07/13 07:50:49 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -9012,6 +9012,9 @@ wm_gmii_setup_phytype(struct wm_softc *s
 	mii_readreg_t new_readreg;
 	mii_writereg_t new_writereg;
 
+	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+		device_xname(sc->sc_dev), __func__));
+
 	if (mii->mii_readreg == NULL) {
 		/*
 		 *  This is the first call of this function. For ICH and PCH
@@ -9570,9 +9573,9 @@ wm_i82543_mii_recvbits(struct wm_softc *
  *	Read a PHY register on the GMII (i82543 version).
  */
 static int
-wm_gmii_i82543_readreg(device_t self, int phy, int reg)
+wm_gmii_i82543_readreg(device_t dev, int phy, int reg)
 {
-	struct wm_softc *sc = device_private(self);
+	struct wm_softc *sc = device_private(dev);
 	int rv;
 
 	wm_i82543_mii_sendbits(sc, 0xU, 32);
@@ -9581,7 +9584,7 @@ wm_gmii_i82543_readreg(device_t self, in
 	rv = wm_i82543_mii_recvbits(sc) & 0x;
 
 	DPRINTF(WM_DEBUG_GMII, ("%s: GMII: read phy %d reg %d -> 0x%04x\n",
-	device_xname(sc->sc_dev), phy, reg, rv));
+	device_xname(dev), phy, reg, rv));
 
 	return rv;
 }
@@ -9592,9 +9595,9 @@ wm_gmii_i82543_readreg(device_t self, in
  *	Write a PHY register on the GMII (i82543 version).
  */
 static void
-wm_gmii_i82543_writereg(device_t self, int phy, int reg, int val)
+wm_gmii_i82543_writereg(device_t dev, int phy, int reg, int val)
 {
-	struct wm_softc *sc = device_private(self);
+	struct wm_softc *sc = device_private(dev);
 
 	wm_i82543_mii_sendbits(sc, 0xU, 32);
 	wm_i82543_mii_sendbits(sc, val | (MII_COMMAND_ACK << 16) |
@@ -9608,9 +9611,9 @@ wm_gmii_i82543_writereg(device_t self, i
  *	Read a PHY register on the GMII.
  */
 static int
-wm_gmii_mdic_readreg(device_t self, int phy, int reg)
+wm_gmii_mdic_readreg(device_t dev, int phy, int reg)
 {
-	struct wm_softc *sc = device_private(self);
+	struct wm_softc *sc = device_private(dev);
 	uint32_t mdic = 0;
 	int i, rv;
 
@@ -9626,12 +9629,12 @@ wm_gmii_mdic_readreg(device_t self, int 
 
 	if ((mdic & MDIC_READY) == 0) {
 		log(LOG_WARNING, "%s: MDIC read timed out: phy %d reg %d\n",
-		device_xname(sc->sc_dev), phy, reg);
+		device_xname(dev), phy, reg);
 		rv = 0;
 	} else if (mdic & MDIC_E) {
 #if 0 /* This is normal if no PHY is present. */
 		log(LOG_WARNING, "%s: MDIC read error: phy %d reg %d\n",
-		device_xname(sc->sc_dev), phy, reg);
+		device_xname(dev), phy, reg);
 #endif
 		rv = 0;
 	} else {
@@ -9649,9 +9652,9 @@ wm_gmii_mdic_readreg(device_t self, int 
  *	Write a PHY register on the GMII.
  */
 static void
-wm_gmii_mdic_writereg(device_t self, int phy, int reg, int val)
+wm_gmii_mdic_writereg(device_t dev, int phy, int reg, int val)
 {
-	struct wm_softc *sc = device_private(self);
+	struct wm_softc *sc = device_private(dev);
 	uint32_t mdic = 0;
 	int i;
 
@@ -9667,10 +9670,10 @@ wm_gmii_mdic_writereg(device_t self, int
 
 	if ((mdic & MDIC_READY) == 0)
 		log(LOG_WARNING, "%s: MDIC write timed out: phy %d reg %d\n",
-		device_xname(sc->sc_dev), phy, reg);
+		device_xname(dev), phy, reg);
 	else if (mdic & MDIC_E)
 		log(LOG_WARNING, "%s: MDIC write error: phy %d reg %d\n",
-		device_xname(sc->sc_dev), phy, reg);
+		device_xname(dev), phy, reg);
 }
 
 /*
@@ -9679,17 +9682,16 @@ wm_gmii_mdic_writereg(device_t self, int
  *	Read a PHY register on the GMII.
  */
 static int
-wm_gmii_i82544_readreg(device_t self, int phy, int reg)
+wm_gmii_i82544_readreg(device_t dev, int phy, int reg)
 {
-	struct wm_softc *sc = device_private(self);
+	struct wm_softc *sc = device_private(dev);
 	int rv;
 
 	if (sc->phy.acquire(sc)) {
-		aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
-		__func__);
+		device_printf(dev, "%s: failed to get semaphore\n", __func__);
 		return 0;
 	}
-	rv = wm_gmii_mdic_readreg(self, phy, reg);
+	rv = wm_gmii_mdic_readreg(dev, phy, reg);
 	

CVS commit: src/sys/dev/pci

2017-07-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 12 08:18:36 UTC 2017

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

Log Message:
Remove debug printf().


To generate a diff of this commit:
cvs rdiff -u -r1.519 -r1.520 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.519 src/sys/dev/pci/if_wm.c:1.520
--- src/sys/dev/pci/if_wm.c:1.519	Wed Jul 12 08:15:31 2017
+++ src/sys/dev/pci/if_wm.c	Wed Jul 12 08:18:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.519 2017/07/12 08:15:31 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.520 2017/07/12 08:18:36 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.519 2017/07/12 08:15:31 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.520 2017/07/12 08:18:36 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -13380,8 +13380,6 @@ wm_lplu_d0_disable(struct wm_softc *sc)
 	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
-	printf("%s called\n", __func__);
-
 	if (sc->sc_phytype == WMPHY_IFE)
 		return;
 



CVS commit: src/sys/dev/pci

2017-07-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 12 08:15:31 UTC 2017

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

Log Message:
 Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before this 
commit,
above devices and non-PCIe devices accessed wrong register.


To generate a diff of this commit:
cvs rdiff -u -r1.518 -r1.519 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.100 -r1.101 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.518 src/sys/dev/pci/if_wm.c:1.519
--- src/sys/dev/pci/if_wm.c:1.518	Thu Jul  6 08:50:52 2017
+++ src/sys/dev/pci/if_wm.c	Wed Jul 12 08:15:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.518 2017/07/06 08:50:52 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.519 2017/07/12 08:15:31 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -73,7 +73,6 @@
  * TODO (in order of importance):
  *
  *	- Check XXX'ed comments
- *	- Disable D0 LPLU on 8257[12356], 82580 and I350.
  *	- TX Multi queue improvement (refine queue selection logic)
  *	- Split header buffer for newer descriptors
  *	- EEE (Energy Efficiency Ethernet)
@@ -84,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.518 2017/07/06 08:50:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.519 2017/07/12 08:15:31 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -910,7 +909,6 @@ static void	wm_igp3_phy_powerdown_workar
 static void	wm_enable_wakeup(struct wm_softc *);
 /* LPLU (Low Power Link Up) */
 static void	wm_lplu_d0_disable(struct wm_softc *);
-static void	wm_lplu_d0_disable_pch(struct wm_softc *);
 /* EEE */
 static void	wm_set_eee_i350(struct wm_softc *);
 
@@ -8954,6 +8952,8 @@ wm_gmii_reset(struct wm_softc *sc)
 	case WM_T_82571:
 	case WM_T_82572:
 	case WM_T_82573:
+	case WM_T_82574:
+	case WM_T_82583:
 	case WM_T_82575:
 	case WM_T_82576:
 	case WM_T_82580:
@@ -8964,10 +8964,6 @@ wm_gmii_reset(struct wm_softc *sc)
 	case WM_T_80003:
 		/* null */
 		break;
-	case WM_T_82574:
-	case WM_T_82583:
-		wm_lplu_d0_disable(sc);
-		break;
 	case WM_T_82541:
 	case WM_T_82547:
 		/* XXX Configure actively LED after PHY reset */
@@ -9441,10 +9437,7 @@ wm_gmii_mediachange(struct ifnet *ifp)
 		return 0;
 
 	/* Disable D0 LPLU. */
-	if (sc->sc_type >= WM_T_PCH)	/* PCH* */
-		wm_lplu_d0_disable_pch(sc);
-	else
-		wm_lplu_d0_disable(sc);	/* ICH* */
+	wm_lplu_d0_disable(sc);
 
 	sc->sc_ctrl &= ~(CTRL_SPEED_MASK | CTRL_FD);
 	sc->sc_ctrl |= CTRL_SLU;
@@ -13381,28 +13374,58 @@ wm_enable_wakeup(struct wm_softc *sc)
 static void
 wm_lplu_d0_disable(struct wm_softc *sc)
 {
+	struct mii_data *mii = >sc_mii;
 	uint32_t reg;
 
 	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
-	reg = CSR_READ(sc, WMREG_PHY_CTRL);
-	reg &= ~(PHY_CTRL_GBE_DIS | PHY_CTRL_D0A_LPLU);
-	CSR_WRITE(sc, WMREG_PHY_CTRL, reg);
-}
-
-static void
-wm_lplu_d0_disable_pch(struct wm_softc *sc)
-{
-	uint32_t reg;
+	printf("%s called\n", __func__);
 
-	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
-		device_xname(sc->sc_dev), __func__));
+	if (sc->sc_phytype == WMPHY_IFE)
+		return;
 
-	reg = wm_gmii_hv_readreg(sc->sc_dev, 1, HV_OEM_BITS);
-	reg &= ~(HV_OEM_BITS_A1KDIS | HV_OEM_BITS_LPLU);
-	reg |= HV_OEM_BITS_ANEGNOW;
-	wm_gmii_hv_writereg(sc->sc_dev, 1, HV_OEM_BITS, reg);
+	switch (sc->sc_type) {
+	case WM_T_82571:
+	case WM_T_82572:
+	case WM_T_82573:
+	case WM_T_82575:
+	case WM_T_82576:
+		reg = mii->mii_readreg(sc->sc_dev, 1, MII_IGPHY_POWER_MGMT);
+		reg &= ~PMR_D0_LPLU;
+		mii->mii_writereg(sc->sc_dev, 1, MII_IGPHY_POWER_MGMT, reg);
+		break;
+	case WM_T_82580:
+	case WM_T_I350:
+	case WM_T_I210:
+	case WM_T_I211:
+		reg = CSR_READ(sc, WMREG_PHPM);
+		reg &= ~PHPM_D0A_LPLU;
+		CSR_WRITE(sc, WMREG_PHPM, reg);
+		break;
+	case WM_T_82574:
+	case WM_T_82583:
+	case WM_T_ICH8:
+	case WM_T_ICH9:
+	case WM_T_ICH10:
+		reg = CSR_READ(sc, WMREG_PHY_CTRL);
+		reg &= ~(PHY_CTRL_GBE_DIS | PHY_CTRL_D0A_LPLU);
+		CSR_WRITE(sc, WMREG_PHY_CTRL, reg);
+		CSR_WRITE_FLUSH(sc);
+		break;
+	case WM_T_PCH:
+	case WM_T_PCH2:
+	case WM_T_PCH_LPT:
+	case WM_T_PCH_SPT:
+		reg = wm_gmii_hv_readreg(sc->sc_dev, 1, HV_OEM_BITS);
+		reg &= ~(HV_OEM_BITS_A1KDIS | HV_OEM_BITS_LPLU);
+		if (wm_phy_resetisblocked(sc) == false)
+			reg |= HV_OEM_BITS_ANEGNOW;
+		wm_gmii_hv_writereg(sc->sc_dev, 1, HV_OEM_BITS, reg);
+		break;
+	default:
+		break;
+	}
 }
 
 /* EEE */

Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.100 src/sys/dev/pci/if_wmreg.h:1.101
--- src/sys/dev/pci/if_wmreg.h:1.100	Mon Jun 26 04:22:46 2017
+++ src/sys/dev/pci/if_wmreg.h	Wed Jul 12 08:15:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.100 2017/06/26 04:22:46 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.101 2017/07/12 08:15:31 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi 

CVS commit: src/sys/dev/pci

2017-07-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jul  7 06:52:24 UTC 2017

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

Log Message:
 Add Atom Z8000 devices from "Intel Atom Z8000 Processor Series Datasheet
(Volume 2 of 2)".


To generate a diff of this commit:
cvs rdiff -u -r1.1292 -r1.1293 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.1292 src/sys/dev/pci/pcidevs:1.1293
--- src/sys/dev/pci/pcidevs:1.1292	Tue Jul  4 05:02:47 2017
+++ src/sys/dev/pci/pcidevs	Fri Jul  7 06:52:24 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1292 2017/07/04 05:02:47 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1293 2017/07/07 06:52:24 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3356,8 +3356,12 @@ product INTEL C2000_25GBE	0x1f45	C2000 E
 product INTEL BSW_HB		0x2280	Braswell Soc Transaction Router
 product INTEL BSW_HDA		0x2284	Braswell HD Audio
 product INTEL BSW_SIO_DMA_2	0x2286	Braswell SIO DMA
+product INTEL Z8K_LPIO1_PWM_1	0x2288	Atom Z8000 LPIO1 PWM1
+product INTEL Z8K_LPIO1_PWM_2	0x2289	Atom Z8000 LPIO1 PWM2
 product INTEL BSW_SIO_HSUART_1	0x228a	Braswell Serial
 product INTEL BSW_SIO_HSUART_2	0x228c	Braswell Serial
+product INTEL Z8K_LPIO1_SPI_1	0x228e	Atom Z8000 LPIO1 SPI1
+product INTEL Z8K_LPIO1_SPI_2	0x2290	Atom Z8000 LPIO1 SPI2
 product INTEL BSW_PCU_SMB	0x2292	Braswell PCU SMBus
 product INTEL BSW_SSC_MMC	0x2294	Braswell SCC MMC Port
 product INTEL BSW_SSC_SDIO	0x2295	Braswell SCC SDIO Port
@@ -3366,11 +3370,13 @@ product INTEL BSW_TXE		0x2298	Braswell T
 product INTEL BSW_PCU_LPC	0x229c	Braswell PCU LPC
 product INTEL BSW_AHCI		0x22a3	Braswell AHCI
 product INTEL BSW_LPE_AUDIO	0x22a8	Braswell Low Power Engine Audio
+product INTEL Z8K_LPIO1_SPI_3	0x22ac	Atom Z8000 LPIO1 SPI3
 product INTEL CHV_IGD_1		0x22b0	HD Graphics
 product INTEL CHV_IGD_2		0x22b1	HD Graphics
 product INTEL CHV_IGD_3		0x22b2	HD Graphics
 product INTEL CHV_IGD_4		0x22b3	HD Graphics
 product INTEL BSW_XHCI		0x22b5	Braswell xHCI
+product INTEL Z8K_USBOTG	0x22b7	Atom Z8000 USB (OTG)
 product INTEL BSW_ISP_CAMERA	0x22b8	Braswell ISP Camera
 product INTEL BSW_SIO_DMA_1	0x22c0	Braswell SIO DMA
 product INTEL BSW_SIO_I2C_1	0x22c1	Braswell SIO I2C
@@ -3384,6 +3390,7 @@ product INTEL BSW_PCIE_1	0x22c8	Braswell
 product INTEL BSW_PCIE_2	0x22ca	Braswell PCIe
 product INTEL BSW_PCIE_3	0x22cc	Braswell PCIe
 product INTEL BSW_PCIE_4	0x22ce	Braswell PCIe
+product INTEL Z8K_IOSF2OCP	0x22d8	Atom Z8000 IOSF2OCP
 product INTEL BSW_PUINT		0x22dc	Braswell Power Management
 product INTEL DH89XXCC_LPC	0x2310	DH89xxCC LPC Controller
 product INTEL DH89XXCC_SATA_1	0x2323	DH89xxCC SATA Controller



CVS commit: src/sys/dev/pci

2017-07-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul  6 08:50:52 UTC 2017

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

Log Message:
 Move the location of wm_get_hw_control() in wm_init_locked() again. Doing
it "after" wm_reset() is required for some AMT based machines to linkup
1Gbps. Tested with HP dc7700.


To generate a diff of this commit:
cvs rdiff -u -r1.517 -r1.518 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.517 src/sys/dev/pci/if_wm.c:1.518
--- src/sys/dev/pci/if_wm.c:1.517	Mon Jun 26 04:22:46 2017
+++ src/sys/dev/pci/if_wm.c	Thu Jul  6 08:50:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.517 2017/06/26 04:22:46 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.518 2017/07/06 08:50:52 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.517 2017/06/26 04:22:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.518 2017/07/06 08:50:52 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -5129,10 +5129,6 @@ wm_init_locked(struct ifnet *ifp)
 	ifp->if_collisions += CSR_READ(sc, WMREG_COLC);
 	ifp->if_ierrors += CSR_READ(sc, WMREG_RXERRC);
 
-	/* AMT based hardware can now take control from firmware */
-	if ((sc->sc_flags & WM_F_HAS_AMT) != 0)
-		wm_get_hw_control(sc);
-
 	/* PCH_SPT hardware workaround */
 	if (sc->sc_type == WM_T_PCH_SPT)
 		wm_flush_desc_rings(sc);
@@ -5140,6 +5136,13 @@ wm_init_locked(struct ifnet *ifp)
 	/* Reset the chip to a known state. */
 	wm_reset(sc);
 
+	/*
+	 * AMT based hardware can now take control from firmware
+	 * Do this after reset.
+	 */
+	if ((sc->sc_flags & WM_F_HAS_AMT) != 0)
+		wm_get_hw_control(sc);
+
 	if ((sc->sc_type == WM_T_PCH_SPT) &&
 	pci_intr_type(sc->sc_pc, sc->sc_intrs[0]) == PCI_INTR_TYPE_INTX)
 		wm_legacy_irq_quirk_spt(sc);



CVS commit: src/sys/dev/pci

2017-07-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jul  4 05:03:09 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.1284 -r1.1285 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1283 -r1.1284 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.1284 src/sys/dev/pci/pcidevs.h:1.1285
--- src/sys/dev/pci/pcidevs.h:1.1284	Tue Jun 27 08:10:44 2017
+++ src/sys/dev/pci/pcidevs.h	Tue Jul  4 05:03:08 2017
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1284 2017/06/27 08:10:44 wiz Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1285 2017/07/04 05:03:08 msaitoh Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1291 2017/06/17 20:25:06 jdolecek Exp
+ *	NetBSD: pcidevs,v 1.1292 2017/07/04 05:02:47 msaitoh Exp
  */
 
 /*
@@ -3732,6 +3732,8 @@
 #define	PCI_PRODUCT_INTEL_82965Q_EXP	0x2991		/* 82965Q PCI Express Bridge */
 #define	PCI_PRODUCT_INTEL_82965Q_IGD	0x2992		/* 82965Q Integrated Graphics Device */
 #define	PCI_PRODUCT_INTEL_82965Q_IGD_1	0x2993		/* 82965Q Integrated Graphics Device */
+#define	PCI_PRODUCT_INTEL_82965Q_HECI_1	0x2994		/* 82Q965 HECI */
+#define	PCI_PRODUCT_INTEL_82965Q_HECI_2	0x2995		/* 82Q965 HECI */
 #define	PCI_PRODUCT_INTEL_82Q965_KT	0x2997		/* 82Q965 KT */
 #define	PCI_PRODUCT_INTEL_82965G_HB	0x29a0		/* 82965G Host Bridge */
 #define	PCI_PRODUCT_INTEL_82965G_EXP	0x29a1		/* 82965G PCI Express Bridge */

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1283 src/sys/dev/pci/pcidevs_data.h:1.1284
--- src/sys/dev/pci/pcidevs_data.h:1.1283	Tue Jun 27 08:10:44 2017
+++ src/sys/dev/pci/pcidevs_data.h	Tue Jul  4 05:03:08 2017
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1283 2017/06/27 08:10:44 wiz Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1284 2017/07/04 05:03:08 msaitoh Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1291 2017/06/17 20:25:06 jdolecek Exp
+ *	NetBSD: pcidevs,v 1.1292 2017/07/04 05:02:47 msaitoh Exp
  */
 
 /*
@@ -6195,6 +6195,10 @@ static const uint16_t pci_products[] = {
 	21409, 692, 1716, 2427, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_IGD_1, 
 	21409, 692, 1716, 2427, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_HECI_1, 
+	21416, 21398, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965Q_HECI_2, 
+	21416, 21398, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82Q965_KT, 
 	21416, 20168, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965G_HB, 
@@ -14718,10 +14722,10 @@ static const char pci_words[] = { "." 
 	"(C)\0" /* 1 refs @ 21380 */
 	"82946GZ\0" /* 3 refs @ 21384 */
 	"82G35\0" /* 6 refs @ 21392 */
-	"HECI\0" /* 3 refs @ 21398 */
+	"HECI\0" /* 5 refs @ 21398 */
 	"82965\0" /* 1 refs @ 21403 */
 	"82965Q\0" /* 5 refs @ 21409 */
-	"82Q965\0" /* 1 refs @ 21416 */
+	"82Q965\0" /* 3 refs @ 21416 */
 	"82965G\0" /* 4 refs @ 21423 */
 	"82P965/G965\0" /* 1 refs @ 21430 */
 	"82Q35\0" /* 9 refs @ 21442 */



CVS commit: src/sys/dev/pci

2017-07-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jul  4 05:02:48 UTC 2017

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

Log Message:
 Add Intel 82Q965 HECI.


To generate a diff of this commit:
cvs rdiff -u -r1.1291 -r1.1292 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.1291 src/sys/dev/pci/pcidevs:1.1292
--- src/sys/dev/pci/pcidevs:1.1291	Sat Jun 17 20:25:06 2017
+++ src/sys/dev/pci/pcidevs	Tue Jul  4 05:02:47 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1291 2017/06/17 20:25:06 jdolecek Exp $
+$NetBSD: pcidevs,v 1.1292 2017/07/04 05:02:47 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3725,6 +3725,8 @@ product INTEL 82965Q_HB		0x2990  82965Q 
 product INTEL 82965Q_EXP	0x2991  82965Q PCI Express Bridge
 product INTEL 82965Q_IGD	0x2992  82965Q Integrated Graphics Device
 product INTEL 82965Q_IGD_1	0x2993  82965Q Integrated Graphics Device
+product INTEL 82965Q_HECI_1	0x2994	82Q965 HECI
+product INTEL 82965Q_HECI_2	0x2995	82Q965 HECI
 product INTEL 82Q965_KT		0x2997  82Q965 KT
 product INTEL 82965G_HB		0x29a0  82965G Host Bridge
 product INTEL 82965G_EXP	0x29a1  82965G PCI Express Bridge



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

2017-07-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul  3 08:29:58 UTC 2017

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

Log Message:
 Print PHY ID.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 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.94 src/sys/dev/pci/ixgbe/ixgbe.c:1.95
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.94	Tue Jun 27 10:33:09 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Jul  3 08:29:58 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.94 2017/06/27 10:33:09 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.95 2017/07/03 08:29:58 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -71,6 +71,8 @@
 #include "vlan.h"
 
 #include 
+#include 
+#include 
 
 /*
  *  Driver version
@@ -722,6 +724,26 @@ ixgbe_attach(device_t parent, device_t d
 		break;
 	}
 
+	if (hw->phy.id != 0) {
+		uint16_t id1, id2;
+		int oui, model, rev;
+		const char *descr;
+
+		id1 = hw->phy.id >> 16;
+		id2 = hw->phy.id & 0x;
+		oui = MII_OUI(id1, id2);
+		model = MII_MODEL(id2);
+		rev = MII_REV(id2);
+		if ((descr = mii_get_descr(oui, model)) != NULL)
+			aprint_normal_dev(dev,
+			"PHY: %s (OUI 0x%06x, model 0x%04x), rev. %d\n",
+			descr, oui, model, rev);
+		else
+			aprint_normal_dev(dev,
+			"PHY OUI 0x%06x, model 0x%04x, rev. %d\n",
+			oui, model, rev);
+	}
+
 	/* hw.ix defaults init */
 	ixgbe_set_advertise(adapter, ixgbe_advertise_speed);
 	ixgbe_set_flowcntl(adapter, ixgbe_flow_control);



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

2017-06-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jun 28 03:57:36 UTC 2017

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

Log Message:
 Add IXGBE_TIPG_IPGT_MASK and IXGBE_PAP_PACE_MASK for packet pacing.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/ixgbe/ixgbe_type.h

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.24 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.25
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.24	Tue Jun 27 08:03:55 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Wed Jun 28 03:57:36 2017
@@ -31,7 +31,7 @@
 
 **/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_type.h 299200 2016-05-06 22:54:56Z pfg $*/
-/*$NetBSD: ixgbe_type.h,v 1.24 2017/06/27 08:03:55 msaitoh Exp $*/
+/*$NetBSD: ixgbe_type.h,v 1.25 2017/06/28 03:57:36 msaitoh Exp $*/
 
 #ifndef _IXGBE_TYPE_H_
 #define _IXGBE_TYPE_H_
@@ -510,6 +510,7 @@
 /* Tx DCA Control register : 128 of these (0-127) */
 #define IXGBE_DCA_TXCTRL_82599(_i)	(0x0600C + ((_i) * 0x40))
 #define IXGBE_TIPG			0x0CB00
+#define IXGBE_TIPG_IPGT_MASK		0x00FF
 #define IXGBE_TXPBSIZE(_i)		(0x0CC00 + ((_i) * 4)) /* 8 of these */
 #define IXGBE_MNGTXMAP			0x0CD10
 #define IXGBE_TIPG_FIBER_DEFAULT	3
@@ -1759,6 +1760,7 @@ enum {
 
 /* PAP bit masks*/
 #define IXGBE_PAP_TXPAUSECNT_MASK	0x /* Pause counter mask */
+#define IXGBE_PAP_PACE_MASK		0x000F /* Pace bit mask */
 
 /* RMCS Bit Masks */
 #define IXGBE_RMCS_RRM			0x0002 /* Rx Recycle Mode enable */



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

2017-06-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jun 27 10:33:09 UTC 2017

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

Log Message:
 Fix a bug of ixg(4)'s media setting.

Before:
 ifconfig ixg0 media 100baseTX  -> advertise 100Mbps only
 ifconfig ixg0 media 1000baseT  -> advertise 1Gbps and 1000Mbps (NG)
 ifconfig ixg0 media 10Gbase-T  -> advertise all (NG)
 ifconfig ixg0 media auto   -> advertise all

After:
 ifconfig ixg0 media 100baseTX  -> advertise 100Mbps only
 ifconfig ixg0 media 1000baseT  -> advertise 1Gbps only
 ifconfig ixg0 media 10Gbase-T  -> advertise 10Gbps only
 ifconfig ixg0 media auto   -> advertise all


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 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.93 src/sys/dev/pci/ixgbe/ixgbe.c:1.94
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.93	Tue Jun 27 05:17:54 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Tue Jun 27 10:33:09 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.93 2017/06/27 05:17:54 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.94 2017/06/27 10:33:09 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2131,6 +2131,9 @@ ixgbe_media_change(struct ifnet * ifp)
 	struct ifmedia *ifm = >media;
 	struct ixgbe_hw *hw = >hw;
 	ixgbe_link_speed speed = 0;
+	ixgbe_link_speed link_caps = 0;
+	bool negotiate = false;
+	s32 err = IXGBE_NOT_IMPLEMENTED;
 
 	INIT_DEBUGOUT("ixgbe_media_change: begin");
 
@@ -2147,10 +2150,19 @@ ixgbe_media_change(struct ifnet * ifp)
 	*/
 	switch (IFM_SUBTYPE(ifm->ifm_media)) {
 		case IFM_AUTO:
+			err = hw->mac.ops.get_link_capabilities(hw, _caps,
+			);
+			if (err != IXGBE_SUCCESS) {
+device_printf(adapter->dev, "Unable to determine "
+"supported advertise speeds\n");
+return (ENODEV);
+			}
+			speed |= link_caps;
+			break;
 		case IFM_10G_T:
-			speed |= IXGBE_LINK_SPEED_100_FULL;
 		case IFM_10G_LRM:
 		case IFM_10G_LR:
+		case IFM_10G_TWINAX:
 #ifndef IFM_ETH_XTYPE
 		case IFM_10G_SR: /* KR, too */
 		case IFM_10G_CX4: /* KX4 */
@@ -2158,12 +2170,9 @@ ixgbe_media_change(struct ifnet * ifp)
 		case IFM_10G_KR:
 		case IFM_10G_KX4:
 #endif
-			speed |= IXGBE_LINK_SPEED_1GB_FULL;
-		case IFM_10G_TWINAX:
 			speed |= IXGBE_LINK_SPEED_10GB_FULL;
 			break;
 		case IFM_1000_T:
-			speed |= IXGBE_LINK_SPEED_100_FULL;
 		case IFM_1000_LX:
 		case IFM_1000_SX:
 		case IFM_1000_KX:



CVS commit: src/sys/dev/pci

2017-06-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jun 27 08:10:44 UTC 2017

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

Log Message:
regen (comment change only)


To generate a diff of this commit:
cvs rdiff -u -r1.1283 -r1.1284 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1282 -r1.1283 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.1283 src/sys/dev/pci/pcidevs.h:1.1284
--- src/sys/dev/pci/pcidevs.h:1.1283	Sat Jun 17 20:25:26 2017
+++ src/sys/dev/pci/pcidevs.h	Tue Jun 27 08:10:44 2017
@@ -1,7 +1,7 @@
-/*	$NetBSD: pcidevs.h,v 1.1283 2017/06/17 20:25:26 jdolecek Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1284 2017/06/27 08:10:44 wiz Exp $	*/
 
 /*
- * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
+ * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
  *	NetBSD: pcidevs,v 1.1291 2017/06/17 20:25:06 jdolecek Exp

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1282 src/sys/dev/pci/pcidevs_data.h:1.1283
--- src/sys/dev/pci/pcidevs_data.h:1.1282	Sat Jun 17 20:25:26 2017
+++ src/sys/dev/pci/pcidevs_data.h	Tue Jun 27 08:10:44 2017
@@ -1,7 +1,7 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1282 2017/06/17 20:25:26 jdolecek Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1283 2017/06/27 08:10:44 wiz Exp $	*/
 
 /*
- * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
+ * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
  *	NetBSD: pcidevs,v 1.1291 2017/06/17 20:25:06 jdolecek Exp



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

2017-06-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jun 27 08:03:55 UTC 2017

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

Log Message:
 Add some register definitions for X550 and newer.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/pci/ixgbe/ixgbe_type.h

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.23 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.24
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.23	Fri Jun 23 09:02:48 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Tue Jun 27 08:03:55 2017
@@ -31,7 +31,7 @@
 
 **/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_type.h 299200 2016-05-06 22:54:56Z pfg $*/
-/*$NetBSD: ixgbe_type.h,v 1.23 2017/06/23 09:02:48 msaitoh Exp $*/
+/*$NetBSD: ixgbe_type.h,v 1.24 2017/06/27 08:03:55 msaitoh Exp $*/
 
 #ifndef _IXGBE_TYPE_H_
 #define _IXGBE_TYPE_H_
@@ -1052,6 +1052,24 @@ struct ixgbe_dmac_config {
 #define IXGBE_GSCN_2		0x11028
 #define IXGBE_GSCN_3		0x1102C
 #define IXGBE_FACTPS		0x10150
+
+/* X550 */
+#define IXGBE_PCI_ICAUSE	0x11520
+#define IXGBE_PCI_IENA		0x11528
+#define IXGBE_PCI_VMINDEX	0x11530
+#define IXGBE_PCI_VMPEND	0x11538
+#define IXGBE_PCI_DREVID	0x11540
+#define IXGBE_PCI_BYTCTH	0x11544
+#define IXGBE_PCI_BYTCTL	0x11548
+#define IXGBE_PCI_LATCT		0x11720 /* Denverton */
+#define IXGBE_PCI_LCBDATA	0x11734
+#define IXGBE_PCI_PKTCT		0x11740 /* Denverton */
+#define IXGBE_PCI_LCBADD	0x11788
+#define IXGBE_GSCL_1_X550	0x11800
+#define IXGBE_GSCL_2_X550	0x11804
+#define IXGBE_PCI_GSCL(_i)	(0x011810 + ((_i) * 4))
+#define IXGBE_PCI_GSCN(_i)	(0x011820 + ((_i) * 4))
+
 #define IXGBE_FACTPS_X540	IXGBE_FACTPS
 #define IXGBE_FACTPS_X550	IXGBE_FACTPS
 #define IXGBE_FACTPS_X550EM_x	IXGBE_FACTPS



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

2017-06-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jun 27 05:17:54 UTC 2017

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

Log Message:
 Reduce diff against FreeBSD. change hw.ixgN.ts to hw.ixgN.thermal_test
(FreeBSD r282289).


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 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.92 src/sys/dev/pci/ixgbe/ixgbe.c:1.93
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.92	Tue Jun 27 05:01:51 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Tue Jun 27 05:17:54 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.92 2017/06/27 05:01:51 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.93 2017/06/27 05:17:54 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -4690,7 +4690,7 @@ ixgbe_add_device_sysctls(struct adapter 
 
 	if (sysctl_createv(log, 0, , ,
 	CTLFLAG_READWRITE, CTLTYPE_INT,
-	"ts", SYSCTL_DESCR("Thermal Test"),
+	"thermal_test", SYSCTL_DESCR("Thermal Test"),
 	ixgbe_sysctl_thermal_test, 0, (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0)
 		aprint_error_dev(dev, "could not create sysctl\n");
 



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

2017-06-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jun 27 05:01:52 UTC 2017

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

Log Message:
 Reduce diff against FreeBSD. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/ixgbe/ixgbe_api.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.91 src/sys/dev/pci/ixgbe/ixgbe.c:1.92
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.91	Fri Jun 23 06:33:35 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Tue Jun 27 05:01:51 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.91 2017/06/23 06:33:35 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.92 2017/06/27 05:01:51 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -5474,8 +5474,8 @@ ixgbe_sysctl_thermal_test(SYSCTLFN_ARGS)
 {
 	struct sysctlnode node = *rnode;
 	struct adapter	*adapter = (struct adapter *)node.sysctl_data;
-	int		error, fire = 0;
 	struct ixgbe_hw *hw;
+	int error, fire = 0;
 
 	hw = >hw;
 

Index: src/sys/dev/pci/ixgbe/ixgbe_api.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_api.c:1.15 src/sys/dev/pci/ixgbe/ixgbe_api.c:1.16
--- src/sys/dev/pci/ixgbe/ixgbe_api.c:1.15	Mon Dec  5 08:50:29 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_api.c	Tue Jun 27 05:01:51 2017
@@ -31,13 +31,15 @@
 
 **/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_api.c 299200 2016-05-06 22:54:56Z pfg $*/
-/*$NetBSD: ixgbe_api.c,v 1.15 2016/12/05 08:50:29 msaitoh Exp $*/
+/*$NetBSD: ixgbe_api.c,v 1.16 2017/06/27 05:01:51 msaitoh Exp $*/
 
 #include "ixgbe_api.h"
 #include "ixgbe_common.h"
 
+#define IXGBE_EMPTY_PARAM
+
 static const u32 ixgbe_mvals_base[IXGBE_MVALS_IDX_LIMIT] = {
-	IXGBE_MVALS_INIT()
+	IXGBE_MVALS_INIT(IXGBE_EMPTY_PARAM)
 };
 
 static const u32 ixgbe_mvals_X540[IXGBE_MVALS_IDX_LIMIT] = {



CVS commit: src/sys/dev/pci

2017-06-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 26 18:23:49 UTC 2017

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

Log Message:
PR/52333: Jia-Ju Bai: explicitly pass BUS_DMA_NOWAIT to bus_dmamap_load_mbuf()
called from an interrupt context. It should not matter since the maps are
constructed with BUS_DMA_ALLOCNOW, but :-)


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/if_vte.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_vte.c
diff -u src/sys/dev/pci/if_vte.c:1.17 src/sys/dev/pci/if_vte.c:1.18
--- src/sys/dev/pci/if_vte.c:1.17	Mon May 22 22:19:14 2017
+++ src/sys/dev/pci/if_vte.c	Mon Jun 26 14:23:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vte.c,v 1.17 2017/05/23 02:19:14 ozaki-r Exp $	*/
+/*	$NetBSD: if_vte.c,v 1.18 2017/06/26 18:23:49 christos Exp $	*/
 
 /*
  * Copyright (c) 2011 Manuel Bouyer.  All rights reserved.
@@ -55,7 +55,7 @@
 /* Driver for DM Electronics, Inc, Vortex86 RDC R6040 FastEthernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vte.c,v 1.17 2017/05/23 02:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vte.c,v 1.18 2017/06/26 18:23:49 christos Exp $");
 
 #include 
 #include 
@@ -733,7 +733,8 @@ vte_encap(struct vte_softc *sc, struct m
 		m->m_len = m->m_pkthdr.len;
 	}
 
-	error = bus_dmamap_load_mbuf(sc->vte_dmatag, txd->tx_dmamap, m, 0);
+	error = bus_dmamap_load_mbuf(sc->vte_dmatag, txd->tx_dmamap, m,
+	BUS_DMA_NOWAIT);
 	if (error != 0) {
 		txd->tx_flags &= ~VTE_TXMBUF;
 		return (NULL);
@@ -1055,7 +1056,7 @@ vte_newbuf(struct vte_softc *sc, struct 
 	m_adj(m, sizeof(uint32_t));
 
 	if (bus_dmamap_load_mbuf(sc->vte_dmatag,
-	sc->vte_cdata.vte_rx_sparemap, m, 0) != 0) {
+	sc->vte_cdata.vte_rx_sparemap, m, BUS_DMA_NOWAIT) != 0) {
 		m_freem(m);
 		return (ENOBUFS);
 	}



  1   2   3   4   5   6   7   8   9   10   >