Module Name:    src
Committed By:   msaitoh
Date:           Mon Dec  5 08:50:29 UTC 2016

Modified Files:
        src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixgbe_api.c
            ixgbe_common.c ixgbe_mbx.c ixgbe_osdep.h ixgbe_phy.c ixgbe_type.h
            ixgbe_x540.c ixgbe_x550.c ixv.c

Log Message:
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
  Setup phy and gbic power as per Linux 4.3.13 driver.
  This fixes link not detected on X540-AT2 after booting to Linux which
  turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/ixgbe/ix_txrx.c \
    src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_api.c \
    src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/ixgbe_mbx.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/ixgbe_x540.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/ixgbe/ixgbe_x550.c
cvs rdiff -u -r1.28 -r1.29 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/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.9 src/sys/dev/pci/ixgbe/ix_txrx.c:1.10
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.9	Fri Dec  2 12:14:37 2016
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Mon Dec  5 08:50:29 2016
@@ -58,8 +58,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-/*$FreeBSD: head/sys/dev/ixgbe/ix_txrx.c 292751 2015-12-26 17:27:48Z bz $*/
-/*$NetBSD: ix_txrx.c,v 1.9 2016/12/02 12:14:37 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ix_txrx.c 301538 2016-06-07 04:51:50Z sephe $*/
+/*$NetBSD: ix_txrx.c,v 1.10 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -433,7 +433,7 @@ ixgbe_xmit(struct tx_ring *txr, struct m
 	}
 
 	/* Make certain there are enough descriptors */
-	if (map->dm_nsegs > txr->tx_avail - 2) {
+	if (txr->tx_avail < (map->dm_nsegs + 2)) {
 		txr->no_desc_avail.ev_count++;
 		ixgbe_dmamap_unload(txr->txtag, txbuf->map);
 		return EAGAIN;
@@ -1804,7 +1804,6 @@ ixgbe_rxeof(struct ix_queue *que)
 	struct ifnet		*ifp = adapter->ifp;
 #ifdef LRO
 	struct lro_ctrl		*lro = &rxr->lro;
-	struct lro_entry	*queued;
 #endif /* LRO */
 	int			i, nextp, processed = 0;
 	u32			staterr = 0;
@@ -2026,7 +2025,7 @@ ixgbe_rxeof(struct ix_queue *que)
 #endif
                                     default:
                                         M_HASHTYPE_SET(sendmp,
-                                            M_HASHTYPE_OPAQUE);
+                                            M_HASHTYPE_OPAQUE_HASH);
                                 }
                         } else {
                                 sendmp->m_pkthdr.flowid = que->msix;
@@ -2066,10 +2065,7 @@ next_desc:
 	/*
 	 * Flush any outstanding LRO work
 	 */
-	while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) {
-		SLIST_REMOVE_HEAD(&lro->lro_active, next);
-		tcp_lro_flush(lro, queued);
-	}
+	tcp_lro_flush_all(lro);
 #endif /* LRO */
 
 	IXGBE_RX_UNLOCK(rxr);
Index: src/sys/dev/pci/ixgbe/ixgbe_phy.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.9 src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.10
--- src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.9	Fri Dec  2 10:42:04 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_phy.c	Mon Dec  5 08:50:29 2016
@@ -30,8 +30,8 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_phy.c 292674 2015-12-23 22:45:17Z sbruno $*/
-/*$NetBSD: ixgbe_phy.c,v 1.9 2016/12/02 10:42:04 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_phy.c 303032 2016-07-19 17:31:48Z sbruno $*/
+/*$NetBSD: ixgbe_phy.c,v 1.10 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #include "ixgbe_api.h"
 #include "ixgbe_common.h"
@@ -1535,13 +1535,6 @@ s32 ixgbe_identify_sfp_module_generic(st
 				hw->phy.type = ixgbe_phy_sfp_intel;
 				break;
 			default:
-				if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
-					hw->phy.type =
-						 ixgbe_phy_sfp_passive_unknown;
-				else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
-					hw->phy.type =
-						ixgbe_phy_sfp_active_unknown;
-				else
 					hw->phy.type = ixgbe_phy_sfp_unknown;
 				break;
 			}
@@ -1550,6 +1543,10 @@ s32 ixgbe_identify_sfp_module_generic(st
 		/* Allow any DA cable vendor */
 		if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
 		    IXGBE_SFF_DA_ACTIVE_CABLE)) {
+			if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
+				hw->phy.type = ixgbe_phy_sfp_passive_unknown;
+			else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
+				hw->phy.type = ixgbe_phy_sfp_active_unknown;
 			status = IXGBE_SUCCESS;
 			goto out;
 		}
@@ -2735,6 +2732,9 @@ s32 ixgbe_set_copper_phy_power(struct ix
 	u32 status;
 	u16 reg;
 
+	if (!on && ixgbe_mng_present(hw))
+		return 0;
+
 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
 				      &reg);

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.51 src/sys/dev/pci/ixgbe/ixgbe.c:1.52
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.51	Fri Dec  2 12:14:37 2016
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Dec  5 08:50:29 2016
@@ -58,8 +58,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-/*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 294578 2016-01-22 17:03:32Z smh $*/
-/*$NetBSD: ixgbe.c,v 1.51 2016/12/02 12:14:37 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
+/*$NetBSD: ixgbe.c,v 1.52 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -194,12 +194,14 @@ static void	ixgbe_unregister_vlan(void *
 
 static void	ixgbe_add_device_sysctls(struct adapter *);
 static void     ixgbe_add_hw_stats(struct adapter *);
+static int	ixgbe_set_flowcntl(struct adapter *, int);
+static int	ixgbe_set_advertise(struct adapter *, int);
 
 /* Sysctl handlers */
 static void	ixgbe_set_sysctl_value(struct adapter *, const char *,
 		     const char *, int *, int);
-static int	ixgbe_set_flowcntl(SYSCTLFN_PROTO);
-static int	ixgbe_set_advertise(SYSCTLFN_PROTO);
+static int	ixgbe_sysctl_flowcntl(SYSCTLFN_PROTO);
+static int	ixgbe_sysctl_advertise(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_thermal_test(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_dmac(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_phy_temp(SYSCTLFN_PROTO);
@@ -280,19 +282,37 @@ MODULE_DEPEND(ix, ether, 1, 1, 1);
 ** traffic for that interrupt vector
 */
 static int ixgbe_enable_aim = TRUE;
-#define SYSCTL_INT(__x, __y)
-SYSCTL_INT("hw.ixgbe.enable_aim", &ixgbe_enable_aim);
+#define SYSCTL_INT(_a1, _a2, _a3, _a4, _a5, _a6, _a7)
+SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &ixgbe_enable_aim, 0,
+    "Enable adaptive interrupt moderation");
 
 static int ixgbe_max_interrupt_rate = (4000000 / IXGBE_LOW_LATENCY);
-SYSCTL_INT("hw.ixgbe.max_interrupt_rate", &ixgbe_max_interrupt_rate);
+SYSCTL_INT(_hw_ix, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN,
+    &ixgbe_max_interrupt_rate, 0, "Maximum interrupts per second");
 
 /* How many packets rxeof tries to clean at a time */
 static int ixgbe_rx_process_limit = 256;
-SYSCTL_INT("hw.ixgbe.rx_process_limit", &ixgbe_rx_process_limit);
+SYSCTL_INT(_hw_ix, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN,
+    &ixgbe_rx_process_limit, 0,
+    "Maximum number of received packets to process at a time,"
+    "-1 means unlimited");
 
 /* How many packets txeof tries to clean at a time */
 static int ixgbe_tx_process_limit = 256;
-SYSCTL_INT("hw.ixgbe.tx_process_limit", &ixgbe_tx_process_limit);
+SYSCTL_INT(_hw_ix, OID_AUTO, tx_process_limit, CTLFLAG_RDTUN,
+    &ixgbe_tx_process_limit, 0,
+    "Maximum number of sent packets to process at a time,"
+    "-1 means unlimited");
+
+/* Flow control setting, default to full */
+static int ixgbe_flow_control = ixgbe_fc_full;
+SYSCTL_INT(_hw_ix, OID_AUTO, flow_control, CTLFLAG_RDTUN,
+    &ixgbe_flow_control, 0, "Default flow control used for all adapters");
+
+/* Advertise Speed, default to 0 (auto) */
+static int ixgbe_advertise_speed = 0;
+SYSCTL_INT(_hw_ix, OID_AUTO, advertise_speed, CTLFLAG_RDTUN,
+    &ixgbe_advertise_speed, 0, "Default advertised speed for all adapters");
 
 /*
 ** Smart speed setting, default to on
@@ -308,7 +328,8 @@ static int ixgbe_smart_speed = ixgbe_sma
  * but this allows it to be forced off for testing.
  */
 static int ixgbe_enable_msix = 1;
-SYSCTL_INT("hw.ixgbe.enable_msix", &ixgbe_enable_msix);
+SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixgbe_enable_msix, 0,
+    "Enable MSI-X interrupts");
 
 /*
  * Number of Queues, can be set to 0,
@@ -317,7 +338,8 @@ SYSCTL_INT("hw.ixgbe.enable_msix", &ixgb
  * can be overriden manually here.
  */
 static int ixgbe_num_queues = 1;
-SYSCTL_INT("hw.ixgbe.num_queues", &ixgbe_num_queues);
+SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, &ixgbe_num_queues, 0,
+    "Number of queues to configure, 0 indicates autoconfigure");
 
 /*
 ** Number of TX descriptors per ring,
@@ -325,11 +347,13 @@ SYSCTL_INT("hw.ixgbe.num_queues", &ixgbe
 ** the better performing choice.
 */
 static int ixgbe_txd = PERFORM_TXD;
-SYSCTL_INT("hw.ixgbe.txd", &ixgbe_txd);
+SYSCTL_INT(_hw_ix, OID_AUTO, txd, CTLFLAG_RDTUN, &ixgbe_txd, 0,
+    "Number of transmit descriptors per queue");
 
 /* Number of RX descriptors per ring */
 static int ixgbe_rxd = PERFORM_RXD;
-SYSCTL_INT("hw.ixgbe.rxd", &ixgbe_rxd);
+SYSCTL_INT(_hw_ix, OID_AUTO, rxd, CTLFLAG_RDTUN, &ixgbe_rxd, 0,
+    "Number of receive descriptors per queue");
 
 /*
 ** Defining this on will allow the use
@@ -337,7 +361,8 @@ SYSCTL_INT("hw.ixgbe.rxd", &ixgbe_rxd);
 ** doing so you are on your own :)
 */
 static int allow_unsupported_sfp = false;
-SYSCTL_INT("hw.ix.unsupported_sfp", &allow_unsupported_sfp);
+#define TUNABLE_INT(__x, __y)
+TUNABLE_INT("hw.ix.unsupported_sfp", &allow_unsupported_sfp);
 
 /* Keep running tab on them for sanity check */
 static int ixgbe_total_ports;
@@ -575,6 +600,11 @@ ixgbe_attach(device_t parent, device_t d
 		break;
 	}
 
+	/* hw.ix defaults init */
+	ixgbe_set_advertise(adapter, ixgbe_advertise_speed);
+	ixgbe_set_flowcntl(adapter, ixgbe_flow_control);
+	adapter->enable_aim = ixgbe_enable_aim;
+
 	error = -1;
 	if ((adapter->msix > 1) && (ixgbe_enable_msix))
 		error = ixgbe_allocate_msix(adapter, pa);
@@ -583,6 +613,12 @@ ixgbe_attach(device_t parent, device_t d
 	if (error) 
 		goto err_late;
 
+	/* Enable the optics for 82599 SFP+ fiber */
+	ixgbe_enable_tx_laser(hw);
+
+	/* Enable power to the phy. */
+	ixgbe_set_phy_power(hw, TRUE);
+
 	/* Setup OS specific network interface */
 	if (ixgbe_setup_interface(dev, adapter) != 0)
 		goto err_late;
@@ -1307,6 +1343,9 @@ ixgbe_init_locked(struct adapter *adapte
 			device_printf(dev, "Error setting up EEE: %d\n", err);
 	}
 
+	/* Enable power to the phy. */
+	ixgbe_set_phy_power(hw, TRUE);
+
 	/* Config/Enable Link */
 	ixgbe_config_link(adapter);
 
@@ -1638,7 +1677,7 @@ ixgbe_msix_que(void *arg)
 
 	/* Do AIM now? */
 
-	if (ixgbe_enable_aim == FALSE)
+	if (adapter->enable_aim == FALSE)
 		goto no_calc;
 	/*
 	** Do Adaptive Interrupt Moderation:
@@ -2163,7 +2202,7 @@ ixgbe_mc_array_itr(struct ixgbe_hw *hw, 
 	mta = (struct ixgbe_mc_addr *)*update_ptr;
 	*vmdq = mta->vmdq;
 
-	*update_ptr = (u8*)(mta + 1);;
+	*update_ptr = (u8*)(mta + 1);
 	return (mta->addr);
 }
 
@@ -4087,6 +4126,9 @@ ixgbe_setup_low_power_mode(struct adapte
 
 	KASSERT(mutex_owned(&adapter->core_mtx));
 
+	if (!hw->wol_enabled)
+		ixgbe_set_phy_power(hw, FALSE);
+
 	/* Limit power management flow to X550EM baseT */
 	if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T
 	    && hw->phy.ops.enter_lplu) {
@@ -4403,7 +4445,7 @@ ixgbe_add_device_sysctls(struct adapter 
 	if (sysctl_createv(log, 0, &rnode, &cnode,
 	    CTLFLAG_READWRITE, CTLTYPE_INT,
 	    "fc", SYSCTL_DESCR(IXGBE_SYSCTL_DESC_SET_FC),
-	    ixgbe_set_flowcntl, 0, (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0)
+	    ixgbe_sysctl_flowcntl, 0, (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0)
 		aprint_error_dev(dev, "could not create sysctl\n");
 
 	/* XXX This is an *instance* sysctl controlling a *global* variable.
@@ -4418,7 +4460,7 @@ ixgbe_add_device_sysctls(struct adapter 
 	if (sysctl_createv(log, 0, &rnode, &cnode,
 	    CTLFLAG_READWRITE, CTLTYPE_INT,
 	    "advertise_speed", SYSCTL_DESCR(IXGBE_SYSCTL_DESC_ADV_SPEED),
-	    ixgbe_set_advertise, 0, (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0)
+	    ixgbe_sysctl_advertise, 0, (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0)
 		aprint_error_dev(dev, "could not create sysctl\n");
 
 	if (sysctl_createv(log, 0, &rnode, &cnode,
@@ -4873,23 +4915,32 @@ ixgbe_set_sysctl_value(struct adapter *a
 **	3 - full
 */
 static int
-ixgbe_set_flowcntl(SYSCTLFN_ARGS)
+ixgbe_sysctl_flowcntl(SYSCTLFN_ARGS)
 {
+	int error, fc;
 	struct sysctlnode node = *rnode;
 	struct adapter *adapter = (struct adapter *)node.sysctl_data;
-	int error, last;
 
 	node.sysctl_data = &adapter->fc;
-	last = adapter->fc;
+	fc = adapter->fc;
+
 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
 	if (error != 0 || newp == NULL)
 		return error;
 
 	/* Don't bother if it's not changed */
-	if (adapter->fc == last)
+	if (adapter->fc == fc)
 		return (0);
 
-	switch (adapter->fc) {
+	return ixgbe_set_flowcntl(adapter, fc);
+}
+
+
+static int
+ixgbe_set_flowcntl(struct adapter *adapter, int fc)
+{
+
+	switch (fc) {
 		case ixgbe_fc_rx_pause:
 		case ixgbe_fc_tx_pause:
 		case ixgbe_fc_full:
@@ -4903,13 +4954,13 @@ ixgbe_set_flowcntl(SYSCTLFN_ARGS)
 				ixgbe_enable_rx_drop(adapter);
 			break;
 		default:
-			adapter->fc = last;
 			return (EINVAL);
 	}
+	adapter->fc = fc;
 	/* Don't autoneg if forcing a value */
 	adapter->hw.fc.disable_fc_autoneg = TRUE;
 	ixgbe_fc_enable(&adapter->hw);
-	return 0;
+	return (0);
 }
 
 /*
@@ -4920,32 +4971,39 @@ ixgbe_set_flowcntl(SYSCTLFN_ARGS)
 **	0x4 - advertise 10G
 */
 static int
-ixgbe_set_advertise(SYSCTLFN_ARGS)
+ixgbe_sysctl_advertise(SYSCTLFN_ARGS)
 {
 	struct sysctlnode	node = *rnode;
-	int			old, error = 0, requested;
+	int			error = 0, advertise;
 	struct adapter		*adapter = (struct adapter *)node.sysctl_data;
-	device_t		dev;
-	struct ixgbe_hw		*hw;
-	ixgbe_link_speed	speed = 0;
-
-	dev = adapter->dev;
-	hw = &adapter->hw;
 
-	old = requested = adapter->advertise;
-	node.sysctl_data = &requested;
+	advertise = adapter->advertise;
+	node.sysctl_data = &advertise;
 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
 	if (error != 0 || newp == NULL)
 		return error;
 
-	/* No speed changes for backplane media */
-	if (hw->phy.media_type == ixgbe_media_type_backplane)
-		return (ENODEV);
+	return ixgbe_set_advertise(adapter, advertise);
+}
+
+static int
+ixgbe_set_advertise(struct adapter *adapter, int advertise)
+{
+	device_t		dev;
+	struct ixgbe_hw		*hw;
+	ixgbe_link_speed	speed;
 
 	/* Checks to validate new value */
-	if (requested == old) /* no change */
+	if (adapter->advertise == advertise) /* no change */
 		return (0);
 
+	hw = &adapter->hw;
+	dev = adapter->dev;
+
+	/* No speed changes for backplane media */
+	if (hw->phy.media_type == ixgbe_media_type_backplane)
+		return (ENODEV);
+
 	if (!((hw->phy.media_type == ixgbe_media_type_copper) ||
 	    (hw->phy.multispeed_fiber))) {
 		device_printf(dev,
@@ -4954,32 +5012,31 @@ ixgbe_set_advertise(SYSCTLFN_ARGS)
 		return (EINVAL);
 	}
 
-	if (requested < 0x1 || requested > 0x7) {
+	if (advertise < 0x1 || advertise > 0x7) {
 		device_printf(dev,
 		    "Invalid advertised speed; valid modes are 0x1 through 0x7\n");
 		return (EINVAL);
 	}
 
-	if ((requested & 0x1)
+	if ((advertise & 0x1)
 	    && (hw->mac.type != ixgbe_mac_X540)
 	    && (hw->mac.type != ixgbe_mac_X550)) {
 		device_printf(dev, "Set Advertise: 100Mb on X540/X550 only\n");
 		return (EINVAL);
 	}
 
-	adapter->advertise = requested;
-
 	/* Set new value and report new advertised mode */
-	if (requested & 0x1)
+	speed = 0;
+	if (advertise & 0x1)
 		speed |= IXGBE_LINK_SPEED_100_FULL;
-	if (requested & 0x2)
+	if (advertise & 0x2)
 		speed |= IXGBE_LINK_SPEED_1GB_FULL;
-	if (requested & 0x4)
+	if (advertise & 0x4)
 		speed |= IXGBE_LINK_SPEED_10GB_FULL;
+	adapter->advertise = advertise;
 
 	hw->mac.autotry_restart = TRUE;
 	hw->mac.ops.setup_link(hw, speed, TRUE);
-	adapter->advertise = requested;
 
 	return 0;
 }

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.17 src/sys/dev/pci/ixgbe/ixgbe.h:1.18
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.17	Fri Dec  2 10:46:58 2016
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Mon Dec  5 08:50:29 2016
@@ -58,8 +58,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe.h 292674 2015-12-23 22:45:17Z sbruno $*/
-/*$NetBSD: ixgbe.h,v 1.17 2016/12/02 10:46:58 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe.h 303890 2016-08-09 19:32:06Z dumbbell $*/
+/*$NetBSD: ixgbe.h,v 1.18 2016/12/05 08:50:29 msaitoh Exp $*/
 
 
 #ifndef _IXGBE_H_
@@ -509,6 +509,7 @@ struct adapter {
 	u32			optics;
 	u32			fc; /* local flow ctrl setting */
 	int			advertise;  /* link speeds */
+	bool			enable_aim; /* adaptive interrupt moderation */
 	bool			link_active;
 	u16			max_frame_size;
 	u16			num_segs;

Index: src/sys/dev/pci/ixgbe/ixgbe_api.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_api.c:1.14 src/sys/dev/pci/ixgbe/ixgbe_api.c:1.15
--- src/sys/dev/pci/ixgbe/ixgbe_api.c:1.14	Fri Dec  2 10:42:04 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_api.c	Mon Dec  5 08:50:29 2016
@@ -30,8 +30,8 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_api.c 292674 2015-12-23 22:45:17Z sbruno $*/
-/*$NetBSD: ixgbe_api.c,v 1.14 2016/12/02 10:42:04 msaitoh Exp $*/
+/*$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 $*/
 
 #include "ixgbe_api.h"
 #include "ixgbe_common.h"
@@ -878,7 +878,7 @@ s32 ixgbe_update_eeprom_checksum(struct 
  *  @vmdq: VMDq pool to assign
  *
  *  Puts an ethernet address into a receive address register, or
- *  finds the rar that it is aleady in; adds to the pool list
+ *  finds the rar that it is already in; adds to the pool list
  **/
 s32 ixgbe_insert_mac_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
 {
Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.14 src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.15
--- src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.14	Fri Dec  2 10:42:04 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h	Mon Dec  5 08:50:29 2016
@@ -30,8 +30,7 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_osdep.h 292674 2015-12-23 22:45:17Z sbruno $*/
-/*$NetBSD: ixgbe_osdep.h,v 1.14 2016/12/02 10:42:04 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_osdep.h 294734 2016-01-25 16:18:53Z smh $*//*$NetBSD: ixgbe_osdep.h,v 1.15 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #ifndef _IXGBE_OS_H_
 #define _IXGBE_OS_H_
@@ -55,6 +54,15 @@
 #define ASSERT(x) if(!(x)) panic("IXGBE: x")
 #define EWARN(H, W, S) printf(W)
 
+enum {
+	IXGBE_ERROR_SOFTWARE,
+	IXGBE_ERROR_POLLING,
+	IXGBE_ERROR_INVALID_STATE,
+	IXGBE_ERROR_UNSUPPORTED,
+	IXGBE_ERROR_ARGUMENT,
+	IXGBE_ERROR_CAUTION,
+};
+
 /* The happy-fun DELAY macro is defined in /usr/src/sys/i386/include/clock.h */
 #define usec_delay(x) DELAY(x)
 #define msec_delay(x) DELAY(1000*(x))
@@ -71,9 +79,23 @@
 	#define DEBUGOUT5(S,A,B,C,D,E)  printf(S "\n",A,B,C,D,E)
 	#define DEBUGOUT6(S,A,B,C,D,E,F)  printf(S "\n",A,B,C,D,E,F)
 	#define DEBUGOUT7(S,A,B,C,D,E,F,G)  printf(S "\n",A,B,C,D,E,F,G)
-	#define ERROR_REPORT1(S,A)      printf(S "\n",A)
-	#define ERROR_REPORT2(S,A,B)    printf(S "\n",A,B)
-	#define ERROR_REPORT3(S,A,B,C)  printf(S "\n",A,B,C)
+	#define ERROR_REPORT1 ERROR_REPORT
+	#define ERROR_REPORT2 ERROR_REPORT
+	#define ERROR_REPORT3 ERROR_REPORT
+	#define ERROR_REPORT(level, format, arg...) do { \
+		switch (level) { \
+		case IXGBE_ERROR_SOFTWARE: \
+		case IXGBE_ERROR_CAUTION: \
+		case IXGBE_ERROR_POLLING: \
+		case IXGBE_ERROR_INVALID_STATE: \
+		case IXGBE_ERROR_UNSUPPORTED: \
+		case IXGBE_ERROR_ARGUMENT: \
+			device_printf(ixgbe_dev_from_hw(hw), format, ## arg); \
+			break; \
+		default: \
+			break; \
+		} \
+	} while (0)
 #else
 	#define DEBUGOUT(S)		do { } while (/*CONSTCOND*/false)
 	#define DEBUGOUT1(S,A)		do { } while (/*CONSTCOND*/false)

Index: src/sys/dev/pci/ixgbe/ixgbe_common.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.10 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.11
--- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.10	Fri Dec  2 10:42:04 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_common.c	Mon Dec  5 08:50:29 2016
@@ -30,8 +30,8 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_common.c 292674 2015-12-23 22:45:17Z sbruno $*/
-/*$NetBSD: ixgbe_common.c,v 1.10 2016/12/02 10:42:04 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_common.c 299200 2016-05-06 22:54:56Z pfg $*/
+/*$NetBSD: ixgbe_common.c,v 1.11 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #include "ixgbe_common.h"
 #include "ixgbe_phy.h"
@@ -200,9 +200,12 @@ bool ixgbe_device_supports_autoneg_fc(st
 		break;
 	}
 
+	if (!supported) {
 	ERROR_REPORT2(IXGBE_ERROR_UNSUPPORTED,
 		      "Device %x does not support flow control autoneg",
 		      hw->device_id);
+	}
+
 	return supported;
 }
 
@@ -1900,7 +1903,7 @@ static s32 ixgbe_ready_eeprom(struct ixg
 
 		usec_delay(5);
 		ixgbe_standby_eeprom(hw);
-	};
+	}
 
 	/*
 	 * On some parts, SPI write time could vary from 0-20mSec on 3.3V
@@ -1986,7 +1989,7 @@ static void ixgbe_shift_out_eeprom_bits(
 		 * EEPROM
 		 */
 		mask = mask >> 1;
-	};
+	}
 
 	/* We leave the "DI" bit set to "0" when we leave this routine. */
 	eec &= ~IXGBE_EEC_DI;
@@ -3608,7 +3611,7 @@ u16 ixgbe_get_pcie_msix_count_generic(st
  *  @vmdq: VMDq pool to assign
  *
  *  Puts an ethernet address into a receive address register, or
- *  finds the rar that it is aleady in; adds to the pool list
+ *  finds the rar that it is already in; adds to the pool list
  **/
 s32 ixgbe_insert_mac_addr_generic(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
 {

Index: src/sys/dev/pci/ixgbe/ixgbe_mbx.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.5 src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.6
--- src/sys/dev/pci/ixgbe/ixgbe_mbx.c:1.5	Thu Dec  1 06:56:28 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_mbx.c	Mon Dec  5 08:50:29 2016
@@ -30,8 +30,8 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_mbx.c 282289 2015-04-30 22:53:27Z erj $*/
-/*$NetBSD: ixgbe_mbx.c,v 1.5 2016/12/01 06:56:28 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_mbx.c 299200 2016-05-06 22:54:56Z pfg $*/
+/*$NetBSD: ixgbe_mbx.c,v 1.6 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #include "ixgbe_type.h"
 #include "ixgbe_mbx.h"
@@ -43,7 +43,7 @@
  *  @size: Length of buffer
  *  @mbx_id: id of mailbox to read
  *
- *  returns SUCCESS if it successfuly read message from buffer
+ *  returns SUCCESS if it successfully read message from buffer
  **/
 s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
 {
@@ -463,7 +463,7 @@ out_no_write:
  *  @size: Length of buffer
  *  @mbx_id: id of mailbox to read
  *
- *  returns SUCCESS if it successfuly read message from buffer
+ *  returns SUCCESS if it successfully read message from buffer
  **/
 static s32 ixgbe_read_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size,
 			     u16 mbx_id)

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.16 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.17
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.16	Fri Dec  2 10:42:04 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Mon Dec  5 08:50:29 2016
@@ -30,8 +30,8 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_type.h 292674 2015-12-23 22:45:17Z sbruno $*/
-/*$NetBSD: ixgbe_type.h,v 1.16 2016/12/02 10:42:04 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_type.h 299200 2016-05-06 22:54:56Z pfg $*/
+/*$NetBSD: ixgbe_type.h,v 1.17 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #ifndef _IXGBE_TYPE_H_
 #define _IXGBE_TYPE_H_
@@ -54,7 +54,7 @@
  *
  * - IXGBE_ERROR_POLLING
  * This category is for errors related to polling/timeout issues and should be
- * used in any case where the timeout occured, or a failure to obtain a lock, or
+ * used in any case where the timeout occurred, or a failure to obtain a lock, or
  * failure to receive data within the time limit.
  *
  * - IXGBE_ERROR_CAUTION
@@ -80,13 +80,6 @@
  * (Ex: Flow control autonegotiation or an unsupported SFP+ module.)
  */
 
-#define IXGBE_ERROR_INVALID_STATE "invalid state: "
-#define IXGBE_ERROR_POLLING	"polling: "
-#define IXGBE_ERROR_CAUTION	"caution: "
-#define IXGBE_ERROR_SOFTWARE	"software: "
-#define IXGBE_ERROR_ARGUMENT	"arg: "
-#define IXGBE_ERROR_UNSUPPORTED	"unsupported: "
-
 #include "ixgbe_osdep.h"
 
 /* Override this by setting IOMEM in your ixgbe_osdep.h header */
@@ -1493,7 +1486,10 @@ struct ixgbe_dmac_config {
 #define IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK	0xFF01 /* int chip-wide mask */
 #define IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG	0xFC01 /* int chip-wide mask */
 #define IXGBE_MDIO_GLOBAL_ALARM_1		0xCC00 /* Global alarm 1 */
+#define IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT	0x0010 /* device fault */
 #define IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL	0x4000 /* high temp failure */
+#define IXGBE_MDIO_GLOBAL_FAULT_MSG		0xC850 /* Global Fault Message */
+#define IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP	0x8007 /* high temp failure */
 #define IXGBE_MDIO_GLOBAL_INT_MASK		0xD400 /* Global int mask */
 #define IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN	0x1000 /* autoneg vendor alarm int enable */
 #define IXGBE_MDIO_GLOBAL_ALARM_1_INT		0x4 /* int in Global alarm 1 */
@@ -2089,7 +2085,7 @@ enum {
 #define IXGBE_MACC_FS		0x00040000
 #define IXGBE_MAC_RX2TX_LPBK	0x00000002
 
-/* Veto Bit definiton */
+/* Veto Bit definition */
 #define IXGBE_MMNGC_MNG_VETO	0x00000001
 
 /* LINKS Bit Masks */

Index: src/sys/dev/pci/ixgbe/ixgbe_x540.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.7 src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.8
--- src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.7	Fri Dec  2 10:42:04 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_x540.c	Mon Dec  5 08:50:29 2016
@@ -30,7 +30,7 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x540.c 292674 2015-12-23 22:45:17Z sbruno $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x540.c 295093 2016-01-31 15:14:23Z smh $*/
 
 #include "ixgbe_x540.h"
 #include "ixgbe_type.h"
@@ -82,7 +82,6 @@ s32 ixgbe_init_ops_X540(struct ixgbe_hw 
 	/* PHY */
 	phy->ops.init = ixgbe_init_phy_ops_generic;
 	phy->ops.reset = NULL;
-	if (!ixgbe_mng_present(hw))
 		phy->ops.set_phy_power = ixgbe_set_copper_phy_power;
 
 	/* MAC */

Index: src/sys/dev/pci/ixgbe/ixgbe_x550.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.2 src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.3
--- src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.2	Fri Dec  2 10:42:04 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_x550.c	Mon Dec  5 08:50:29 2016
@@ -30,7 +30,7 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x550.c 292674 2015-12-23 22:45:17Z sbruno $*/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x550.c 295093 2016-01-31 15:14:23Z smh $*/
 
 #include "ixgbe_x550.h"
 #include "ixgbe_x540.h"
@@ -1264,7 +1264,7 @@ static s32 ixgbe_get_lasi_ext_t_x550em(s
 	    IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
 		return status;
 
-	/* High temperature failure alarm triggered */
+	/* Global alarm triggered */
 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
 				      &reg);
@@ -1277,6 +1277,21 @@ static s32 ixgbe_get_lasi_ext_t_x550em(s
 		/* power down the PHY in case the PHY FW didn't already */
 		ixgbe_set_copper_phy_power(hw, FALSE);
 		return IXGBE_ERR_OVERTEMP;
+	} else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
+		/*  device fault alarm triggered */
+		status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
+					  IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+					  &reg);
+
+		if (status != IXGBE_SUCCESS)
+			return status;
+
+		/* if device fault was due to high temp alarm handle and exit */
+		if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
+			/* power down the PHY in case the PHY FW didn't */
+			ixgbe_set_copper_phy_power(hw, FALSE);
+			return IXGBE_ERR_OVERTEMP;
+		}
 	}
 
 	/* Vendor alarm 2 triggered */

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.28 src/sys/dev/pci/ixgbe/ixv.c:1.29
--- src/sys/dev/pci/ixgbe/ixv.c:1.28	Fri Dec  2 12:14:37 2016
+++ src/sys/dev/pci/ixgbe/ixv.c	Mon Dec  5 08:50:29 2016
@@ -30,8 +30,8 @@
   POSSIBILITY OF SUCH DAMAGE.
 
 ******************************************************************************/
-/*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 292674 2015-12-23 22:45:17Z sbruno $*/
-/*$NetBSD: ixv.c,v 1.28 2016/12/02 12:14:37 msaitoh Exp $*/
+/*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 302384 2016-07-07 03:39:18Z sbruno $*/
+/*$NetBSD: ixv.c,v 1.29 2016/12/05 08:50:29 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -1189,7 +1189,7 @@ ixv_local_timer_locked(void *arg)
 
 	}
 
-	/* Only truely watchdog if all queues show hung */
+	/* Only truly watchdog if all queues show hung */
 	if (hung == adapter->num_queues)
 		goto watchdog;
 	else if (queues != 0) { /* Force an IRQ on queues with work */
@@ -2038,7 +2038,7 @@ ixv_handle_mbx(void *context)
 }
 
 /*
-** The VF stats registers never have a truely virgin
+** The VF stats registers never have a truly virgin
 ** starting point, so this routine tries to make an
 ** artificial one, marking ground zero on attach as
 ** it were.

Reply via email to