Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Dec 2017 18:15:06 +0000 (UTC)
From:      Eric Joyner <erj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r327031 - in head/sys: conf dev/ixgbe modules/ix modules/ixv
Message-ID:  <201712201815.vBKIF6IN062349@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: erj
Date: Wed Dec 20 18:15:06 2017
New Revision: 327031
URL: https://svnweb.freebsd.org/changeset/base/327031

Log:
  ixgbe(4): Convert driver to use iflib
  
  Initial update to the ixgbe PF and VF drivers to support the iflib interface.
  
  The PF driver version is bumped to 4.0.0, and the VF driver version is bumped to 2.0.0.
  
  Special thanks to sbruno@ for the support in helping make this conversion happen.
  
  Submitted by:	Jeb Cramer <cramerj@intel.com>, Krzysztof Galazka (Chris) <krzysztof.galazka@intel.com>, Piotr Pietruszewski <piotr.pietruszewski@intel.com>
  Reviewed by:	sbruno@, shurd@, #IntelNetworking
  Tested by:	Jeffrey Pieper <jeffrey.e.pieper@intel.com>, Sergey Kozlov <kozlov.sergey.404@gmail.com>
  Sponsored by:	Limelight Networks, Intel Corporation
  Differential Revision:	https://reviews.freebsd.org/D11727

Deleted:
  head/sys/dev/ixgbe/ixgbe_netmap.c
  head/sys/dev/ixgbe/ixgbe_netmap.h
Modified:
  head/sys/conf/files
  head/sys/dev/ixgbe/if_bypass.c
  head/sys/dev/ixgbe/if_fdir.c
  head/sys/dev/ixgbe/if_ix.c
  head/sys/dev/ixgbe/if_ixv.c
  head/sys/dev/ixgbe/if_sriov.c
  head/sys/dev/ixgbe/ix_txrx.c
  head/sys/dev/ixgbe/ixgbe.h
  head/sys/dev/ixgbe/ixgbe_common.c
  head/sys/dev/ixgbe/ixgbe_fdir.h
  head/sys/dev/ixgbe/ixgbe_osdep.c
  head/sys/dev/ixgbe/ixgbe_osdep.h
  head/sys/dev/ixgbe/ixgbe_phy.c
  head/sys/dev/ixgbe/ixgbe_sriov.h
  head/sys/dev/ixgbe/ixgbe_type.h
  head/sys/dev/ixgbe/ixgbe_vf.h
  head/sys/modules/ix/Makefile
  head/sys/modules/ixv/Makefile

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Wed Dec 20 18:06:09 2017	(r327030)
+++ head/sys/conf/files	Wed Dec 20 18:15:06 2017	(r327031)
@@ -2223,11 +2223,9 @@ dev/ixgbe/if_ixv.c		optional ixv inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe -DSMP"
 dev/ixgbe/if_bypass.c		optional ix inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
-dev/ixgbe/ixgbe_netmap.c	optional ix inet \
-	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/if_fdir.c		optional ix inet | ixv inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
-dev/ixgbe/if_sriov.c		optional ix inet | ixv inet \
+dev/ixgbe/if_sriov.c		optional ix inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ix_txrx.c		optional ix inet | ixv inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"

Modified: head/sys/dev/ixgbe/if_bypass.c
==============================================================================
--- head/sys/dev/ixgbe/if_bypass.c	Wed Dec 20 18:06:09 2017	(r327030)
+++ head/sys/dev/ixgbe/if_bypass.c	Wed Dec 20 18:15:06 2017	(r327031)
@@ -165,12 +165,12 @@ ixgbe_bp_set_state(SYSCTL_HANDLER_ARGS)
 	error = hw->mac.ops.bypass_rw(hw,
 	    BYPASS_PAGE_CTL0, &state);
 	ixgbe_bypass_mutex_clear(adapter);
-	if (error)
+	if (error != 0)
 		return (error);
 	state = (state >> BYPASS_STATUS_OFF_SHIFT) & 0x3;
 
 	error = sysctl_handle_int(oidp, &state, 0, req);
-	if ((error) || (req->newptr == NULL))
+	if ((error != 0) || (req->newptr == NULL))
 		return (error);
 
 	/* Sanity check new state */
@@ -437,7 +437,7 @@ ixgbe_bp_wd_set(SYSCTL_HANDLER_ARGS)
 	struct ixgbe_hw *hw = &adapter->hw;
 	int             error, tmp;
 	static int      timeout = 0;
-	u32             mask, arg = BYPASS_PAGE_CTL0;
+	u32             mask, arg;
 
 	/* Get the current hardware value */
 	ixgbe_bypass_mutex_enter(adapter);
@@ -456,48 +456,38 @@ ixgbe_bp_wd_set(SYSCTL_HANDLER_ARGS)
 	if ((error) || (req->newptr == NULL))
 		return (error);
 
-	mask = BYPASS_WDT_ENABLE_M;
+	arg = 0x1 << BYPASS_WDT_ENABLE_SHIFT;
+	mask = BYPASS_WDT_ENABLE_M | BYPASS_WDT_VALUE_M;
 	switch (timeout) {
-		case 0: /* disables the timer */
-			break;
-		case 1:
-			arg = BYPASS_WDT_1_5 << BYPASS_WDT_TIME_SHIFT;
-			arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-			mask |= BYPASS_WDT_VALUE_M;
-			break;
-		case 2:
-			arg = BYPASS_WDT_2 << BYPASS_WDT_TIME_SHIFT;
-			arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-			mask |= BYPASS_WDT_VALUE_M;
-			break;
-		case 3:
-			arg = BYPASS_WDT_3 << BYPASS_WDT_TIME_SHIFT;
-			arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-			mask |= BYPASS_WDT_VALUE_M;
-			break;
-		case 4:
-			arg = BYPASS_WDT_4 << BYPASS_WDT_TIME_SHIFT;
-			arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-			mask |= BYPASS_WDT_VALUE_M;
-			break;
-		case 8:
-			arg = BYPASS_WDT_8 << BYPASS_WDT_TIME_SHIFT;
-			arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-			mask |= BYPASS_WDT_VALUE_M;
-			break;
-		case 16:
-			arg = BYPASS_WDT_16 << BYPASS_WDT_TIME_SHIFT;
-			arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-			mask |= BYPASS_WDT_VALUE_M;
-			break;
-		case 32:
-			arg = BYPASS_WDT_32 << BYPASS_WDT_TIME_SHIFT;
-			arg |= 0x1 << BYPASS_WDT_ENABLE_SHIFT;
-			mask |= BYPASS_WDT_VALUE_M;
-			break;
-		default:
-			return (EINVAL);
+	case 0: /* disables the timer */
+		arg = BYPASS_PAGE_CTL0;
+		mask = BYPASS_WDT_ENABLE_M;
+		break;
+	case 1:
+		arg |= BYPASS_WDT_1_5 << BYPASS_WDT_TIME_SHIFT;
+		break;
+	case 2:
+		arg |= BYPASS_WDT_2 << BYPASS_WDT_TIME_SHIFT;
+		break;
+	case 3:
+		arg |= BYPASS_WDT_3 << BYPASS_WDT_TIME_SHIFT;
+		break;
+	case 4:
+		arg |= BYPASS_WDT_4 << BYPASS_WDT_TIME_SHIFT;
+		break;
+	case 8:
+		arg |= BYPASS_WDT_8 << BYPASS_WDT_TIME_SHIFT;
+		break;
+	case 16:
+		arg |= BYPASS_WDT_16 << BYPASS_WDT_TIME_SHIFT;
+		break;
+	case 32:
+		arg |= BYPASS_WDT_32 << BYPASS_WDT_TIME_SHIFT;
+		break;
+	default:
+		return (EINVAL);
 	}
+
 	/* Set the new watchdog */
 	ixgbe_bypass_mutex_enter(adapter);
 	error = hw->mac.ops.bypass_set(hw, BYPASS_PAGE_CTL0, mask, arg);
@@ -541,7 +531,8 @@ ixgbe_bp_wd_reset(SYSCTL_HANDLER_ARGS)
 			error = IXGBE_BYPASS_FW_WRITE_FAILURE;
 			break;
 		}
-		if (hw->mac.ops.bypass_rw(hw, BYPASS_PAGE_CTL1, &reset_wd)) {
+		error = hw->mac.ops.bypass_rw(hw, BYPASS_PAGE_CTL1, &reset_wd);
+		if (error != 0) {
 			error = IXGBE_ERR_INVALID_ARGUMENT;
 			break;
 		}
@@ -615,7 +606,7 @@ ixgbe_bp_log(SYSCTL_HANDLER_ARGS)
 			    &data);
 			ixgbe_bypass_mutex_clear(adapter);
 			if (error)
-				return (-EINVAL);
+				return (EINVAL);
 			eeprom[count].logs += data << (8 * i);
 		}
 
@@ -624,7 +615,7 @@ ixgbe_bp_log(SYSCTL_HANDLER_ARGS)
 		    log_off + i, &eeprom[count].actions);
 		ixgbe_bypass_mutex_clear(adapter);
 		if (error)
-			return (-EINVAL);
+			return (EINVAL);
 
 		/* Quit if not a unread log */
 		if (!(eeprom[count].logs & BYPASS_LOG_CLEAR_M))
@@ -696,21 +687,21 @@ ixgbe_bp_log(SYSCTL_HANDLER_ARGS)
 		ixgbe_bypass_mutex_clear(adapter);
 
 		if (error)
-			return (-EINVAL);
+			return (EINVAL);
 	}
 
 	status = 0; /* reset */
 	/* Another log command can now run */
 	while (atomic_cmpset_int(&adapter->bypass.log, 1, 0) == 0)
 		usec_delay(3000);
-	return(error);
+	return (error);
 
 unlock_err:
 	ixgbe_bypass_mutex_clear(adapter);
 	status = 0; /* reset */
 	while (atomic_cmpset_int(&adapter->bypass.log, 1, 0) == 0)
 		usec_delay(3000);
-	return (-EINVAL);
+	return (EINVAL);
 } /* ixgbe_bp_log */
 
 /************************************************************************
@@ -802,7 +793,5 @@ ixgbe_bypass_init(struct adapter *adapter)
 	    adapter, 0, ixgbe_bp_wd_reset, "S", "Bypass WD Reset");
 
 	adapter->feat_en |= IXGBE_FEATURE_BYPASS;
-
-	return;
 } /* ixgbe_bypass_init */
 

Modified: head/sys/dev/ixgbe/if_fdir.c
==============================================================================
--- head/sys/dev/ixgbe/if_fdir.c	Wed Dec 20 18:06:09 2017	(r327030)
+++ head/sys/dev/ixgbe/if_fdir.c	Wed Dec 20 18:15:06 2017	(r327031)
@@ -50,10 +50,11 @@ ixgbe_init_fdir(struct adapter *adapter)
 } /* ixgbe_init_fdir */
 
 void
-ixgbe_reinit_fdir(void *context, int pending)
+ixgbe_reinit_fdir(void *context)
 {
-	struct adapter *adapter = context;
-	struct ifnet   *ifp = adapter->ifp;
+	if_ctx_t       ctx = context;
+	struct adapter *adapter = iflib_get_softc(ctx);
+	struct ifnet   *ifp = iflib_get_ifp(ctx);
 
 	if (!(adapter->feat_en & IXGBE_FEATURE_FDIR))
 		return;
@@ -146,9 +147,9 @@ ixgbe_atr(struct tx_ring *txr, struct mbuf *mp)
 
 /* TASK_INIT needs this function defined regardless if it's enabled */
 void
-ixgbe_reinit_fdir(void *context, int pending)
+ixgbe_reinit_fdir(void *context)
 {
-	UNREFERENCED_2PARAMETER(context, pending);
+	UNREFERENCED_PARAMETER(context);
 } /* ixgbe_reinit_fdir */
 
 void

Modified: head/sys/dev/ixgbe/if_ix.c
==============================================================================
--- head/sys/dev/ixgbe/if_ix.c	Wed Dec 20 18:06:09 2017	(r327030)
+++ head/sys/dev/ixgbe/if_ix.c	Wed Dec 20 18:15:06 2017	(r327031)
@@ -33,18 +33,21 @@
 /*$FreeBSD$*/
 
 
-#ifndef IXGBE_STANDALONE_BUILD
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_rss.h"
-#endif
 
 #include "ixgbe.h"
+#include "ixgbe_sriov.h"
+#include "ifdi_if.h"
 
+#include <net/netmap.h>
+#include <dev/netmap/netmap_kern.h>
+
 /************************************************************************
  * Driver version
  ************************************************************************/
-char ixgbe_driver_version[] = "3.2.12-k";
+char ixgbe_driver_version[] = "4.0.0-k";
 
 
 /************************************************************************
@@ -56,180 +59,173 @@ char ixgbe_driver_version[] = "3.2.12-k";
  *
  *   { Vendor ID, Device ID, SubVendor ID, SubDevice ID, String Index }
  ************************************************************************/
-static ixgbe_vendor_info_t ixgbe_vendor_info_array[] =
+static pci_vendor_info_t ixgbe_vendor_info_array[] =
 {
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_BYPASS, 0, 0, 0},
-	{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS, 0, 0, 0},
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T,  "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_BYPASS, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
+  PVID(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS, "Intel(R) PRO/10GbE PCI-Express Network Driver"),
 	/* required last entry */
-	{0, 0, 0, 0, 0}
+  PVID_END
 };
 
-/************************************************************************
- * Table of branding strings
- ************************************************************************/
-static char    *ixgbe_strings[] = {
-	"Intel(R) PRO/10GbE PCI-Express Network Driver"
-};
+static void *ixgbe_register(device_t dev);
+static int  ixgbe_if_attach_pre(if_ctx_t ctx);
+static int  ixgbe_if_attach_post(if_ctx_t ctx);
+static int  ixgbe_if_detach(if_ctx_t ctx);
+static int  ixgbe_if_shutdown(if_ctx_t ctx);
+static int  ixgbe_if_suspend(if_ctx_t ctx);
+static int  ixgbe_if_resume(if_ctx_t ctx);
 
+static void ixgbe_if_stop(if_ctx_t ctx);
+void ixgbe_if_enable_intr(if_ctx_t ctx);
+static void ixgbe_if_disable_intr(if_ctx_t ctx);
+static int  ixgbe_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t qid);
+static void ixgbe_if_media_status(if_ctx_t ctx, struct ifmediareq * ifmr);
+static int  ixgbe_if_media_change(if_ctx_t ctx);
+static int  ixgbe_if_msix_intr_assign(if_ctx_t, int);
+static int  ixgbe_if_mtu_set(if_ctx_t ctx, uint32_t mtu);
+static void ixgbe_if_crcstrip_set(if_ctx_t ctx, int onoff, int strip);
+static void ixgbe_if_multi_set(if_ctx_t ctx);
+static int  ixgbe_if_promisc_set(if_ctx_t ctx, int flags);
+static int  ixgbe_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
+                                     uint64_t *paddrs, int nrxqs, int nrxqsets);
+static int  ixgbe_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
+                                     uint64_t *paddrs, int nrxqs, int nrxqsets);
+static void ixgbe_if_queues_free(if_ctx_t ctx);
+static void ixgbe_if_timer(if_ctx_t ctx, uint16_t);
+static void ixgbe_if_update_admin_status(if_ctx_t ctx);
+static void ixgbe_if_vlan_register(if_ctx_t ctx, u16 vtag);
+static void ixgbe_if_vlan_unregister(if_ctx_t ctx, u16 vtag);
+
+int ixgbe_intr(void *arg);
+
 /************************************************************************
  * Function prototypes
  ************************************************************************/
-static int      ixgbe_probe(device_t);
-static int      ixgbe_attach(device_t);
-static int      ixgbe_detach(device_t);
-static int      ixgbe_shutdown(device_t);
-static int      ixgbe_suspend(device_t);
-static int      ixgbe_resume(device_t);
-static int      ixgbe_ioctl(struct ifnet *, u_long, caddr_t);
-static void     ixgbe_init(void *);
-static void     ixgbe_init_locked(struct adapter *);
-static void     ixgbe_stop(void *);
 #if __FreeBSD_version >= 1100036
-static uint64_t ixgbe_get_counter(struct ifnet *, ift_counter);
+static uint64_t ixgbe_if_get_counter(if_ctx_t, ift_counter);
 #endif
-static void     ixgbe_init_device_features(struct adapter *);
-static void     ixgbe_check_fan_failure(struct adapter *, u32, bool);
-static void     ixgbe_add_media_types(struct adapter *);
-static void     ixgbe_media_status(struct ifnet *, struct ifmediareq *);
-static int      ixgbe_media_change(struct ifnet *);
-static int      ixgbe_allocate_pci_resources(struct adapter *);
-static void     ixgbe_get_slot_info(struct adapter *);
-static int      ixgbe_allocate_msix(struct adapter *);
-static int      ixgbe_allocate_legacy(struct adapter *);
-static int      ixgbe_configure_interrupts(struct adapter *);
-static void     ixgbe_free_pci_resources(struct adapter *);
-static void     ixgbe_local_timer(void *);
-static int      ixgbe_setup_interface(device_t, struct adapter *);
-static void     ixgbe_config_gpie(struct adapter *);
-static void     ixgbe_config_dmac(struct adapter *);
-static void     ixgbe_config_delay_values(struct adapter *);
-static void     ixgbe_config_link(struct adapter *);
-static void     ixgbe_check_wol_support(struct adapter *);
-static int      ixgbe_setup_low_power_mode(struct adapter *);
-static void     ixgbe_rearm_queues(struct adapter *, u64);
 
-static void     ixgbe_initialize_transmit_units(struct adapter *);
-static void     ixgbe_initialize_receive_units(struct adapter *);
-static void     ixgbe_enable_rx_drop(struct adapter *);
-static void     ixgbe_disable_rx_drop(struct adapter *);
-static void     ixgbe_initialize_rss_mapping(struct adapter *);
+static void ixgbe_enable_queue(struct adapter *adapter, u32 vector);
+static void ixgbe_disable_queue(struct adapter *adapter, u32 vector);
+static void ixgbe_add_device_sysctls(if_ctx_t ctx);
+static int  ixgbe_allocate_pci_resources(if_ctx_t ctx);
+static int  ixgbe_setup_low_power_mode(if_ctx_t ctx);
 
-static void     ixgbe_enable_intr(struct adapter *);
-static void     ixgbe_disable_intr(struct adapter *);
-static void     ixgbe_update_stats_counters(struct adapter *);
-static void     ixgbe_set_promisc(struct adapter *);
-static void     ixgbe_set_multi(struct adapter *);
-static void     ixgbe_update_link_status(struct adapter *);
-static void     ixgbe_set_ivar(struct adapter *, u8, u8, s8);
-static void     ixgbe_configure_ivars(struct adapter *);
-static u8       *ixgbe_mc_array_itr(struct ixgbe_hw *, u8 **, u32 *);
+static void ixgbe_config_dmac(struct adapter *adapter);
+static void ixgbe_configure_ivars(struct adapter *adapter);
+static void ixgbe_set_ivar(struct adapter *adapter, u8 entry, u8 vector,
+                           s8 type);
+static u8   *ixgbe_mc_array_itr(struct ixgbe_hw *, u8 **, u32 *);
+static bool ixgbe_sfp_probe(if_ctx_t ctx);
 
-static void     ixgbe_setup_vlan_hw_support(struct adapter *);
-static void     ixgbe_register_vlan(void *, struct ifnet *, u16);
-static void     ixgbe_unregister_vlan(void *, struct ifnet *, u16);
+static void ixgbe_free_pci_resources(if_ctx_t ctx);
 
-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);
-static int      ixgbe_get_advertise(struct adapter *);
+static int  ixgbe_msix_link(void *arg);
+static int  ixgbe_msix_que(void *arg);
+static void ixgbe_initialize_rss_mapping(struct adapter *adapter);
+static void ixgbe_initialize_receive_units(if_ctx_t ctx);
+static void ixgbe_initialize_transmit_units(if_ctx_t ctx);
 
+static int  ixgbe_setup_interface(if_ctx_t ctx);
+static void ixgbe_init_device_features(struct adapter *adapter);
+static void ixgbe_check_fan_failure(struct adapter *, u32, bool);
+static void ixgbe_add_media_types(if_ctx_t ctx);
+static void ixgbe_update_stats_counters(struct adapter *adapter);
+static void ixgbe_config_link(struct adapter *adapter);
+static void ixgbe_get_slot_info(struct adapter *);
+static void ixgbe_check_wol_support(struct adapter *adapter);
+static void ixgbe_enable_rx_drop(struct adapter *);
+static void ixgbe_disable_rx_drop(struct adapter *);
+
+static void ixgbe_add_hw_stats(struct adapter *adapter);
+static int  ixgbe_set_flowcntl(struct adapter *, int);
+static int  ixgbe_set_advertise(struct adapter *, int);
+static int  ixgbe_get_advertise(struct adapter *);
+static void ixgbe_setup_vlan_hw_support(if_ctx_t ctx);
+static void ixgbe_config_gpie(struct adapter *adapter);
+static void ixgbe_config_delay_values(struct adapter *adapter);
+
 /* Sysctl handlers */
-static void     ixgbe_set_sysctl_value(struct adapter *, const char *,
-                                       const char *, int *, int);
-static int      ixgbe_sysctl_flowcntl(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_advertise(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_interrupt_rate_handler(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_dmac(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_phy_temp(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_phy_overtemp_occurred(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_flowcntl(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_advertise(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_interrupt_rate_handler(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_dmac(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_phy_temp(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_phy_overtemp_occurred(SYSCTL_HANDLER_ARGS);
 #ifdef IXGBE_DEBUG
-static int      ixgbe_sysctl_power_state(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_print_rss_config(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_power_state(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_print_rss_config(SYSCTL_HANDLER_ARGS);
 #endif
-static int      ixgbe_sysctl_rdh_handler(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_rdt_handler(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_tdt_handler(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_tdh_handler(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_eee_state(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_wol_enable(SYSCTL_HANDLER_ARGS);
-static int      ixgbe_sysctl_wufc(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_rdh_handler(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_rdt_handler(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_tdt_handler(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_tdh_handler(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_eee_state(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_wol_enable(SYSCTL_HANDLER_ARGS);
+static int  ixgbe_sysctl_wufc(SYSCTL_HANDLER_ARGS);
 
-/* Support for pluggable optic modules */
-static bool     ixgbe_sfp_probe(struct adapter *);
-
-/* Legacy (single vector) interrupt handler */
-static void     ixgbe_legacy_irq(void *);
-
-/* The MSI/MSI-X Interrupt handlers */
-static void     ixgbe_msix_que(void *);
-static void     ixgbe_msix_link(void *);
-
 /* Deferred interrupt tasklets */
-static void     ixgbe_handle_que(void *, int);
-static void     ixgbe_handle_link(void *, int);
-static void     ixgbe_handle_msf(void *, int);
-static void     ixgbe_handle_mod(void *, int);
-static void     ixgbe_handle_phy(void *, int);
+static void ixgbe_handle_msf(void *);
+static void ixgbe_handle_mod(void *);
+static void ixgbe_handle_phy(void *);
 
-
 /************************************************************************
  *  FreeBSD Device Interface Entry Points
  ************************************************************************/
 static device_method_t ix_methods[] = {
 	/* Device interface */
-	DEVMETHOD(device_probe, ixgbe_probe),
-	DEVMETHOD(device_attach, ixgbe_attach),
-	DEVMETHOD(device_detach, ixgbe_detach),
-	DEVMETHOD(device_shutdown, ixgbe_shutdown),
-	DEVMETHOD(device_suspend, ixgbe_suspend),
-	DEVMETHOD(device_resume, ixgbe_resume),
+	DEVMETHOD(device_register, ixgbe_register),
+	DEVMETHOD(device_probe, iflib_device_probe),
+	DEVMETHOD(device_attach, iflib_device_attach),
+	DEVMETHOD(device_detach, iflib_device_detach),
+	DEVMETHOD(device_shutdown, iflib_device_shutdown),
+	DEVMETHOD(device_suspend, iflib_device_suspend),
+	DEVMETHOD(device_resume, iflib_device_resume),
 #ifdef PCI_IOV
-	DEVMETHOD(pci_iov_init, ixgbe_init_iov),
-	DEVMETHOD(pci_iov_uninit, ixgbe_uninit_iov),
-	DEVMETHOD(pci_iov_add_vf, ixgbe_add_vf),
+	DEVMETHOD(pci_iov_init, iflib_device_iov_init),
+	DEVMETHOD(pci_iov_uninit, iflib_device_iov_uninit),
+	DEVMETHOD(pci_iov_add_vf, iflib_device_iov_add_vf),
 #endif /* PCI_IOV */
 	DEVMETHOD_END
 };
@@ -243,41 +239,57 @@ DRIVER_MODULE(ix, pci, ix_driver, ix_devclass, 0, 0);
 
 MODULE_DEPEND(ix, pci, 1, 1, 1);
 MODULE_DEPEND(ix, ether, 1, 1, 1);
-#ifdef DEV_NETMAP
-MODULE_DEPEND(ix, netmap, 1, 1, 1);
-#endif
+MODULE_DEPEND(ix, iflib, 1, 1, 1);
 
+static device_method_t ixgbe_if_methods[] = {
+	DEVMETHOD(ifdi_attach_pre, ixgbe_if_attach_pre),
+	DEVMETHOD(ifdi_attach_post, ixgbe_if_attach_post),
+	DEVMETHOD(ifdi_detach, ixgbe_if_detach),
+	DEVMETHOD(ifdi_shutdown, ixgbe_if_shutdown),
+	DEVMETHOD(ifdi_suspend, ixgbe_if_suspend),
+	DEVMETHOD(ifdi_resume, ixgbe_if_resume),
+	DEVMETHOD(ifdi_init, ixgbe_if_init),
+	DEVMETHOD(ifdi_stop, ixgbe_if_stop),
+	DEVMETHOD(ifdi_msix_intr_assign, ixgbe_if_msix_intr_assign),
+	DEVMETHOD(ifdi_intr_enable, ixgbe_if_enable_intr),
+	DEVMETHOD(ifdi_intr_disable, ixgbe_if_disable_intr),
+	DEVMETHOD(ifdi_tx_queue_intr_enable, ixgbe_if_rx_queue_intr_enable),
+	DEVMETHOD(ifdi_rx_queue_intr_enable, ixgbe_if_rx_queue_intr_enable),
+	DEVMETHOD(ifdi_tx_queues_alloc, ixgbe_if_tx_queues_alloc),
+	DEVMETHOD(ifdi_rx_queues_alloc, ixgbe_if_rx_queues_alloc),
+	DEVMETHOD(ifdi_queues_free, ixgbe_if_queues_free),
+	DEVMETHOD(ifdi_update_admin_status, ixgbe_if_update_admin_status),
+	DEVMETHOD(ifdi_multi_set, ixgbe_if_multi_set),
+	DEVMETHOD(ifdi_mtu_set, ixgbe_if_mtu_set),
+	DEVMETHOD(ifdi_crcstrip_set, ixgbe_if_crcstrip_set),
+	DEVMETHOD(ifdi_media_status, ixgbe_if_media_status),
+	DEVMETHOD(ifdi_media_change, ixgbe_if_media_change),
+	DEVMETHOD(ifdi_promisc_set, ixgbe_if_promisc_set),
+	DEVMETHOD(ifdi_timer, ixgbe_if_timer),
+	DEVMETHOD(ifdi_vlan_register, ixgbe_if_vlan_register),
+	DEVMETHOD(ifdi_vlan_unregister, ixgbe_if_vlan_unregister),
+	DEVMETHOD(ifdi_get_counter, ixgbe_if_get_counter),
+#ifdef PCI_IOV
+	DEVMETHOD(ifdi_iov_init, ixgbe_if_iov_init),
+	DEVMETHOD(ifdi_iov_uninit, ixgbe_if_iov_uninit),
+	DEVMETHOD(ifdi_iov_vf_add, ixgbe_if_iov_vf_add),
+#endif /* PCI_IOV */
+	DEVMETHOD_END
+};
+
 /*
  * TUNEABLE PARAMETERS:
  */
 
 static SYSCTL_NODE(_hw, OID_AUTO, ix, CTLFLAG_RD, 0, "IXGBE driver parameters");
+static driver_t ixgbe_if_driver = {
+  "ixgbe_if", ixgbe_if_methods, sizeof(struct adapter)
+};
 
-/*
- * AIM: Adaptive Interrupt Moderation
- * which means that the interrupt rate
- * is varied over time based on the
- * traffic for that interrupt vector
- */
-static int ixgbe_enable_aim = TRUE;
-SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RDTUN, &ixgbe_enable_aim, 0,
-    "Enable adaptive interrupt moderation");
-
 static int ixgbe_max_interrupt_rate = (4000000 / IXGBE_LOW_LATENCY);
 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_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_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,
@@ -306,30 +318,6 @@ SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTU
     "Enable MSI-X interrupts");
 
 /*
- * Number of Queues, can be set to 0,
- * it then autoconfigures based on the
- * number of cpus with a max of 8. This
- * can be overriden manually here.
- */
-static int ixgbe_num_queues = 0;
-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,
- * setting higher than RX as this seems
- * the better performing choice.
- */
-static int ixgbe_txd = PERFORM_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_ix, OID_AUTO, rxd, CTLFLAG_RDTUN, &ixgbe_rxd, 0,
-    "Number of receive descriptors per queue");
-
-/*
  * Defining this on will allow the use
  * of unsupported SFP+ modules, note that
  * doing so you are on your own :)
@@ -347,25 +335,218 @@ static int ixgbe_enable_fdir = 0;
 SYSCTL_INT(_hw_ix, OID_AUTO, enable_fdir, CTLFLAG_RDTUN, &ixgbe_enable_fdir, 0,
     "Enable Flow Director");
 
-/* Legacy Transmit (single queue) */
-static int ixgbe_enable_legacy_tx = 0;
-SYSCTL_INT(_hw_ix, OID_AUTO, enable_legacy_tx, CTLFLAG_RDTUN,
-    &ixgbe_enable_legacy_tx, 0, "Enable Legacy TX flow");
-
 /* Receive-Side Scaling */
 static int ixgbe_enable_rss = 1;
 SYSCTL_INT(_hw_ix, OID_AUTO, enable_rss, CTLFLAG_RDTUN, &ixgbe_enable_rss, 0,
     "Enable Receive-Side Scaling (RSS)");
 
+#if 0
 /* Keep running tab on them for sanity check */
 static int ixgbe_total_ports;
+#endif
 
-static int (*ixgbe_start_locked)(struct ifnet *, struct tx_ring *);
-static int (*ixgbe_ring_empty)(struct ifnet *, struct buf_ring *);
-
 MALLOC_DEFINE(M_IXGBE, "ix", "ix driver allocations");
 
+/*
+ * For Flow Director: this is the number of TX packets we sample
+ * for the filter pool, this means every 20th packet will be probed.
+ *
+ * This feature can be disabled by setting this to 0.
+ */
+static int atr_sample_rate = 20;
+
+extern struct if_txrx ixgbe_txrx;
+
+static struct if_shared_ctx ixgbe_sctx_init = {
+	.isc_magic = IFLIB_MAGIC,
+	.isc_q_align = PAGE_SIZE,/* max(DBA_ALIGN, PAGE_SIZE) */
+	.isc_tx_maxsize = IXGBE_TSO_SIZE,
+
+	.isc_tx_maxsegsize = PAGE_SIZE,
+
+	.isc_rx_maxsize = PAGE_SIZE*4,
+	.isc_rx_nsegments = 1,
+	.isc_rx_maxsegsize = PAGE_SIZE*4,
+	.isc_nfl = 1,
+	.isc_ntxqs = 1,
+	.isc_nrxqs = 1,
+
+	.isc_admin_intrcnt = 1,
+	.isc_vendor_info = ixgbe_vendor_info_array,
+	.isc_driver_version = ixgbe_driver_version,
+	.isc_driver = &ixgbe_if_driver,
+
+	.isc_nrxd_min = {MIN_RXD},
+	.isc_ntxd_min = {MIN_TXD},
+	.isc_nrxd_max = {MAX_RXD},
+	.isc_ntxd_max = {MAX_TXD},
+	.isc_nrxd_default = {DEFAULT_RXD},
+	.isc_ntxd_default = {DEFAULT_TXD},
+};
+
+if_shared_ctx_t ixgbe_sctx = &ixgbe_sctx_init;
+
 /************************************************************************
+ * ixgbe_if_tx_queues_alloc
+ ************************************************************************/
+static int
+ixgbe_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs,
+                         int ntxqs, int ntxqsets)
+{
+	struct adapter     *adapter = iflib_get_softc(ctx);
+	if_softc_ctx_t     scctx = adapter->shared;
+	struct ix_tx_queue *que;
+	int                i, j, error;
+
+	MPASS(adapter->num_tx_queues > 0);
+	MPASS(adapter->num_tx_queues == ntxqsets);
+	MPASS(ntxqs == 1);
+
+	/* Allocate queue structure memory */
+	adapter->tx_queues =
+	    (struct ix_tx_queue *)malloc(sizeof(struct ix_tx_queue) * ntxqsets,
+	                                 M_IXGBE, M_NOWAIT | M_ZERO);
+	if (!adapter->tx_queues) {
+		device_printf(iflib_get_dev(ctx),
+		    "Unable to allocate TX ring memory\n");
+		return (ENOMEM);
+	}
+
+	for (i = 0, que = adapter->tx_queues; i < ntxqsets; i++, que++) {
+		struct tx_ring *txr = &que->txr;
+
+		/* In case SR-IOV is enabled, align the index properly */
+		txr->me = ixgbe_vf_que_index(adapter->iov_mode, adapter->pool,
+		    i);
+
+		txr->adapter = que->adapter = adapter;
+		adapter->active_queues |= (u64)1 << txr->me;
+
+		/* Allocate report status array */
+		txr->tx_rsq = (qidx_t *)malloc(sizeof(qidx_t) * scctx->isc_ntxd[0], M_IXGBE, M_NOWAIT | M_ZERO);
+		if (txr->tx_rsq == NULL) {
+			error = ENOMEM;
+			goto fail;
+		}
+		for (j = 0; j < scctx->isc_ntxd[0]; j++)
+			txr->tx_rsq[j] = QIDX_INVALID;
+		/* get the virtual and physical address of the hardware queues */
+		txr->tail = IXGBE_TDT(txr->me);
+		txr->tx_base = (union ixgbe_adv_tx_desc *)vaddrs[i];
+		txr->tx_paddr = paddrs[i];
+
+		txr->bytes = 0;
+		txr->total_packets = 0;
+
+		/* Set the rate at which we sample packets */
+		if (adapter->feat_en & IXGBE_FEATURE_FDIR)
+			txr->atr_sample = atr_sample_rate;
+
+	}
+
+	iflib_config_gtask_init(ctx, &adapter->mod_task, ixgbe_handle_mod,
+	    "mod_task");
+	iflib_config_gtask_init(ctx, &adapter->msf_task, ixgbe_handle_msf,
+	    "msf_task");
+	iflib_config_gtask_init(ctx, &adapter->phy_task, ixgbe_handle_phy,
+	    "phy_task");
+	if (adapter->feat_cap & IXGBE_FEATURE_SRIOV)
+		iflib_config_gtask_init(ctx, &adapter->mbx_task,
+		    ixgbe_handle_mbx, "mbx_task");
+	if (adapter->feat_en & IXGBE_FEATURE_FDIR)
+		iflib_config_gtask_init(ctx, &adapter->fdir_task,
+		    ixgbe_reinit_fdir, "fdir_task");
+
+	device_printf(iflib_get_dev(ctx), "allocated for %d queues\n",
+	    adapter->num_tx_queues);
+
+	return (0);
+
+fail:
+	ixgbe_if_queues_free(ctx);
+
+	return (error);
+} /* ixgbe_if_tx_queues_alloc */
+
+/************************************************************************
+ * ixgbe_if_rx_queues_alloc
+ ************************************************************************/
+static int
+ixgbe_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs,
+                         int nrxqs, int nrxqsets)
+{
+	struct adapter     *adapter = iflib_get_softc(ctx);
+	struct ix_rx_queue *que;
+	int                i;
+
+	MPASS(adapter->num_rx_queues > 0);
+	MPASS(adapter->num_rx_queues == nrxqsets);
+	MPASS(nrxqs == 1);
+
+	/* Allocate queue structure memory */
+	adapter->rx_queues =
+	    (struct ix_rx_queue *)malloc(sizeof(struct ix_rx_queue)*nrxqsets,
+	                                 M_IXGBE, M_NOWAIT | M_ZERO);
+	if (!adapter->rx_queues) {
+		device_printf(iflib_get_dev(ctx),
+		    "Unable to allocate TX ring memory\n");
+		return (ENOMEM);
+	}
+
+	for (i = 0, que = adapter->rx_queues; i < nrxqsets; i++, que++) {
+		struct rx_ring *rxr = &que->rxr;
+
+		/* In case SR-IOV is enabled, align the index properly */
+		rxr->me = ixgbe_vf_que_index(adapter->iov_mode, adapter->pool,
+		    i);
+
+		rxr->adapter = que->adapter = adapter;
+
+		/* get the virtual and physical address of the hw queues */
+		rxr->tail = IXGBE_RDT(rxr->me);
+		rxr->rx_base = (union ixgbe_adv_rx_desc *)vaddrs[i];
+		rxr->rx_paddr = paddrs[i];
+		rxr->bytes = 0;
+		rxr->que = que;
+	}
+
+	device_printf(iflib_get_dev(ctx), "allocated for %d rx queues\n",
+	    adapter->num_rx_queues);
+
+	return (0);
+} /* ixgbe_if_rx_queues_alloc */
+
+/************************************************************************
+ * ixgbe_if_queues_free
+ ************************************************************************/
+static void
+ixgbe_if_queues_free(if_ctx_t ctx)
+{
+	struct adapter     *adapter = iflib_get_softc(ctx);
+	struct ix_tx_queue *tx_que = adapter->tx_queues;
+	struct ix_rx_queue *rx_que = adapter->rx_queues;
+	int                i;
+
+	if (tx_que != NULL) {
+		for (i = 0; i < adapter->num_tx_queues; i++, tx_que++) {
+			struct tx_ring *txr = &tx_que->txr;
+			if (txr->tx_rsq == NULL)
+				break;
+
+			free(txr->tx_rsq, M_IXGBE);
+			txr->tx_rsq = NULL;
+		}
+
+		free(adapter->tx_queues, M_IXGBE);
+		adapter->tx_queues = NULL;
+	}
+	if (rx_que != NULL) {
+		free(adapter->rx_queues, M_IXGBE);
+		adapter->rx_queues = NULL;
+	}
+} /* ixgbe_if_queues_free */
+
+/************************************************************************
  * ixgbe_initialize_rss_mapping
  ************************************************************************/
 static void
@@ -403,17 +584,17 @@ ixgbe_initialize_rss_mapping(struct adapter *adapter)
 
 	/* Set up the redirection table */
 	for (i = 0, j = 0; i < table_size; i++, j++) {
-		if (j == adapter->num_queues)
+		if (j == adapter->num_rx_queues)
 			j = 0;
 
 		if (adapter->feat_en & IXGBE_FEATURE_RSS) {
 			/*
 			 * Fetch the RSS bucket id for the given indirection
 			 * entry. Cap it at the number of configured buckets
-			 * (which is num_queues.)
+			 * (which is num_rx_queues.)
 			 */
 			queue_id = rss_get_indirection_to_bucket(i);
-			queue_id = queue_id % adapter->num_queues;
+			queue_id = queue_id % adapter->num_rx_queues;
 		} else
 			queue_id = (j * index_mult);
 
@@ -483,14 +664,16 @@ ixgbe_initialize_rss_mapping(struct adapter *adapter)
 #define BSIZEPKT_ROUNDUP ((1<<IXGBE_SRRCTL_BSIZEPKT_SHIFT)-1)
 
 static void
-ixgbe_initialize_receive_units(struct adapter *adapter)
+ixgbe_initialize_receive_units(if_ctx_t ctx)
 {
-	struct rx_ring  *rxr = adapter->rx_rings;
-	struct ixgbe_hw *hw = &adapter->hw;
-	struct ifnet    *ifp = adapter->ifp;
-	int             i, j;
-	u32             bufsz, fctrl, srrctl, rxcsum;
-	u32             hlreg;
+	struct adapter     *adapter = iflib_get_softc(ctx);
+	if_softc_ctx_t     scctx = adapter->shared;
+	struct ixgbe_hw    *hw = &adapter->hw;
+	struct ifnet       *ifp = iflib_get_ifp(ctx);
+	struct ix_rx_queue *que;
+	int                i, j;
+	u32                bufsz, fctrl, srrctl, rxcsum;
+	u32                hlreg;
 
 	/*
 	 * Make sure receives are disabled while
@@ -513,24 +696,16 @@ ixgbe_initialize_receive_units(struct adapter *adapter
 		hlreg |= IXGBE_HLREG0_JUMBOEN;
 	else
 		hlreg &= ~IXGBE_HLREG0_JUMBOEN;
-
-#ifdef DEV_NETMAP
-	/* CRC stripping is conditional in Netmap */
-	if ((adapter->feat_en & IXGBE_FEATURE_NETMAP) &&
-	    (ifp->if_capenable & IFCAP_NETMAP) &&
-	    !ix_crcstrip)
-		hlreg &= ~IXGBE_HLREG0_RXCRCSTRP;
-	else
-#endif /* DEV_NETMAP */
-		hlreg |= IXGBE_HLREG0_RXCRCSTRP;
-
 	IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg);
 
 	bufsz = (adapter->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >>
 	    IXGBE_SRRCTL_BSIZEPKT_SHIFT;
 
-	for (i = 0; i < adapter->num_queues; i++, rxr++) {
-		u64 rdba = rxr->rxdma.dma_paddr;
+	/* Setup the Base and Length of the Rx Descriptor Ring */
+	for (i = 0, que = adapter->rx_queues; i < adapter->num_rx_queues; i++, que++) {
+		struct rx_ring *rxr = &que->rxr;
+		u64            rdba = rxr->rx_paddr;
+
 		j = rxr->me;
 
 		/* Setup the Base and Length of the Rx Descriptor Ring */
@@ -538,7 +713,7 @@ ixgbe_initialize_receive_units(struct adapter *adapter
 		    (rdba & 0x00000000ffffffffULL));
 		IXGBE_WRITE_REG(hw, IXGBE_RDBAH(j), (rdba >> 32));
 		IXGBE_WRITE_REG(hw, IXGBE_RDLEN(j),
-		    adapter->num_rx_desc * sizeof(union ixgbe_adv_rx_desc));
+		     scctx->isc_nrxd[0] * sizeof(union ixgbe_adv_rx_desc));
 
 		/* Set up the SRRCTL register */
 		srrctl = IXGBE_READ_REG(hw, IXGBE_SRRCTL(j));
@@ -553,7 +728,7 @@ ixgbe_initialize_receive_units(struct adapter *adapter
 		 * so we do not need to clear the bit, but do it just in case
 		 * this code is moved elsewhere.
 		 */
-		if (adapter->num_queues > 1 &&
+		if (adapter->num_rx_queues > 1 &&
 		    adapter->hw.fc.requested_mode == ixgbe_fc_none) {
 			srrctl |= IXGBE_SRRCTL_DROP_EN;
 		} else {
@@ -582,7 +757,7 @@ ixgbe_initialize_receive_units(struct adapter *adapter
 
 	ixgbe_initialize_rss_mapping(adapter);
 
-	if (adapter->num_queues > 1) {
+	if (adapter->num_rx_queues > 1) {
 		/* RSS and RX IPP Checksum are mutually exclusive */
 		rxcsum |= IXGBE_RXCSUM_PCSD;
 	}

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712201815.vBKIF6IN062349>