svn commit: r323830 - stable/10/sys/dev/ixgbe

Marius Strobl marius at FreeBSD.org
Wed Sep 20 21:22:22 UTC 2017


Author: marius
Date: Wed Sep 20 21:22:20 2017
New Revision: 323830
URL: https://svnweb.freebsd.org/changeset/base/323830

Log:
  Unbreak netmap(4) support in ixgbe(4) after r315333:
  - Both ixgbe_netmap.c and ixv_netmap.c assumed a netmap(4) driver
    newer than what's actually in stable/10.
  - Additionally, at the bottom line ixv_netmap.c did exactly the same
    as ixgbe_netmap.c, i. e. used IXGBE_TDH() as appropriate for PFs
    only instead of IXGBE_VFTDH() and tried to configure CRC stripping
    although the corresponding registers aren't available to VFs in the
    first place.
  
  With these changes, the netmap(4) support in ixgbe(4) is in line
  again with the code in sys/dev/netmap/ixgbe_netmap.h as of r295008.
  Breakage reported by: Slawa Olhovchenkov
  
  Just like r315333 that never existed in head, this is a direct commit
  to stable/10. However, ixgbe(4) in head has a related bug in that it
  assumes a netmap(4) driver API older than what's in head and also
  does the wrong things for VFs as it uses the PF-only ixgbe_netmap.c
  for both PFs and VFs in the first place.

Modified:
  stable/10/sys/dev/ixgbe/ixgbe_netmap.c
  stable/10/sys/dev/ixgbe/ixv_netmap.c
  stable/10/sys/dev/ixgbe/ixv_netmap.h

Modified: stable/10/sys/dev/ixgbe/ixgbe_netmap.c
==============================================================================
--- stable/10/sys/dev/ixgbe/ixgbe_netmap.c	Wed Sep 20 21:19:53 2017	(r323829)
+++ stable/10/sys/dev/ixgbe/ixgbe_netmap.c	Wed Sep 20 21:22:20 2017	(r323830)
@@ -316,6 +316,8 @@ ixgbe_netmap_txsync(struct netmap_kring *kring, int fl
 		}
 	}
 
+	nm_txsync_finalize(kring);
+
 	return 0;
 }
 
@@ -343,7 +345,7 @@ ixgbe_netmap_rxsync(struct netmap_kring *kring, int fl
 	u_int nic_i;	/* index into the NIC ring */
 	u_int n;
 	u_int const lim = kring->nkr_num_slots - 1;
-	u_int const head = kring->rhead;
+	u_int const head = nm_rxsync_prologue(kring);
 	int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR;
 
 	/* device-specific */
@@ -449,6 +451,9 @@ ixgbe_netmap_rxsync(struct netmap_kring *kring, int fl
 		nic_i = nm_prev(nic_i, lim);
 		IXGBE_WRITE_REG(&adapter->hw, rxr->tail, nic_i);
 	}
+
+	/* tell userspace that there might be new packets */
+	nm_rxsync_finalize(kring);
 
 	return 0;
 

Modified: stable/10/sys/dev/ixgbe/ixv_netmap.c
==============================================================================
--- stable/10/sys/dev/ixgbe/ixv_netmap.c	Wed Sep 20 21:19:53 2017	(r323829)
+++ stable/10/sys/dev/ixgbe/ixv_netmap.c	Wed Sep 20 21:22:20 2017	(r323830)
@@ -60,7 +60,7 @@
 /*
  * $FreeBSD$
  *
- * netmap support for: ixgbe
+ * netmap support for: ixv
  *
  * This file is meant to be a reference on how to implement
  * netmap support for a network driver.
@@ -83,63 +83,17 @@
 /*
  * device-specific sysctl variables:
  *
- * ixv_crcstrip: 0: keep CRC in rx frames (default), 1: strip it.
- *	During regular operations the CRC is stripped, but on some
- *	hardware reception of frames not multiple of 64 is slower,
- *	so using crcstrip=0 helps in benchmarks.
- *
  * ixv_rx_miss, ixv_rx_miss_bufs:
  *	count packets that might be missed due to lost interrupts.
  */
 SYSCTL_DECL(_dev_netmap);
 static int ixv_rx_miss, ixv_rx_miss_bufs;
-int ixv_crcstrip;
-SYSCTL_INT(_dev_netmap, OID_AUTO, ixv_crcstrip,
-    CTLFLAG_RW, &ixv_crcstrip, 0, "strip CRC on rx frames");
 SYSCTL_INT(_dev_netmap, OID_AUTO, ixv_rx_miss,
     CTLFLAG_RW, &ixv_rx_miss, 0, "potentially missed rx intr");
 SYSCTL_INT(_dev_netmap, OID_AUTO, ixv_rx_miss_bufs,
     CTLFLAG_RW, &ixv_rx_miss_bufs, 0, "potentially missed rx intr bufs");
 
 
-static void
-set_crcstrip(struct ixgbe_hw *hw, int onoff)
-{
-	/* crc stripping is set in two places:
-	 * IXGBE_HLREG0 (modified on init_locked and hw reset)
-	 * IXGBE_RDRXCTL (set by the original driver in
-	 *	ixgbe_setup_hw_rsc() called in init_locked.
-	 *	We disable the setting when netmap is compiled in).
-	 * We update the values here, but also in ixgbe.c because
-	 * init_locked sometimes is called outside our control.
-	 */
-	uint32_t hl, rxc;
-
-	hl = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-	rxc = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
-	if (netmap_verbose)
-		D("%s read  HLREG 0x%x rxc 0x%x",
-			onoff ? "enter" : "exit", hl, rxc);
-	/* hw requirements ... */
-	rxc &= ~IXGBE_RDRXCTL_RSCFRSTSIZE;
-	rxc |= IXGBE_RDRXCTL_RSCACKC;
-	if (onoff && !ixv_crcstrip) {
-		/* keep the crc. Fast rx */
-		hl &= ~IXGBE_HLREG0_RXCRCSTRP;
-		rxc &= ~IXGBE_RDRXCTL_CRCSTRIP;
-	} else {
-		/* reset default mode */
-		hl |= IXGBE_HLREG0_RXCRCSTRP;
-		rxc |= IXGBE_RDRXCTL_CRCSTRIP;
-	}
-	if (netmap_verbose)
-		D("%s write HLREG 0x%x rxc 0x%x",
-			onoff ? "enter" : "exit", hl, rxc);
-	IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hl);
-	IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rxc);
-}
-
-
 /*
  * Register/unregister. We are already under netmap lock.
  * Only called on the first register or the last unregister.
@@ -153,7 +107,6 @@ ixv_netmap_reg(struct netmap_adapter *na, int onoff)
 	IXGBE_CORE_LOCK(adapter);
 	adapter->stop_locked(adapter);
 
-	set_crcstrip(&adapter->hw, onoff);
 	/* enable or disable flags and callbacks in na and ifp */
 	if (onoff) {
 		nm_set_native_flags(na);
@@ -161,7 +114,6 @@ ixv_netmap_reg(struct netmap_adapter *na, int onoff)
 		nm_clear_native_flags(na);
 	}
 	adapter->init_locked(adapter);	/* also enables intr */
-	set_crcstrip(&adapter->hw, onoff); // XXX why twice ?
 	IXGBE_CORE_UNLOCK(adapter);
 	return (ifp->if_drv_flags & IFF_DRV_RUNNING ? 0 : 1);
 }
@@ -338,7 +290,7 @@ ixv_netmap_txsync(struct netmap_kring *kring, int flag
 		 * REPORT_STATUS in a few slots so TDH is the only
 		 * good way.
 		 */
-		nic_i = IXGBE_READ_REG(&adapter->hw, IXGBE_TDH(kring->ring_id));
+		nic_i = IXGBE_READ_REG(&adapter->hw, IXGBE_VFTDH(kring->ring_id));
 		if (nic_i >= kring->nkr_num_slots) { /* XXX can it happen ? */
 			D("TDH wrap %d", nic_i);
 			nic_i -= kring->nkr_num_slots;
@@ -350,6 +302,8 @@ ixv_netmap_txsync(struct netmap_kring *kring, int flag
 		}
 	}
 
+	nm_txsync_finalize(kring);
+
 	return 0;
 }
 
@@ -377,7 +331,7 @@ ixv_netmap_rxsync(struct netmap_kring *kring, int flag
 	u_int nic_i;	/* index into the NIC ring */
 	u_int n;
 	u_int const lim = kring->nkr_num_slots - 1;
-	u_int const head = kring->rhead;
+	u_int const head = nm_rxsync_prologue(kring);
 	int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR;
 
 	/* device-specific */
@@ -407,7 +361,7 @@ ixv_netmap_rxsync(struct netmap_kring *kring, int flag
 	 * rxr->next_to_check is set to 0 on a ring reinit
 	 */
 	if (netmap_no_pendintr || force_update) {
-		int crclen = (ixv_crcstrip) ? 0 : 4;
+		int crclen = 0;
 		uint16_t slot_flags = kring->nkr_slot_flags;
 
 		nic_i = rxr->next_to_check; // or also k2n(kring->nr_hwtail)
@@ -483,6 +437,9 @@ ixv_netmap_rxsync(struct netmap_kring *kring, int flag
 		nic_i = nm_prev(nic_i, lim);
 		IXGBE_WRITE_REG(&adapter->hw, rxr->tail, nic_i);
 	}
+
+	/* tell userspace that there might be new packets */
+	nm_rxsync_finalize(kring);
 
 	return 0;
 

Modified: stable/10/sys/dev/ixgbe/ixv_netmap.h
==============================================================================
--- stable/10/sys/dev/ixgbe/ixv_netmap.h	Wed Sep 20 21:19:53 2017	(r323829)
+++ stable/10/sys/dev/ixgbe/ixv_netmap.h	Wed Sep 20 21:22:20 2017	(r323830)
@@ -42,12 +42,10 @@
 #include <sys/selinfo.h>
 #include <dev/netmap/netmap_kern.h>
 
-extern int ixv_crcstrip;
-
 /*
- * ixgbe_netmap.c contains functions for netmap
+ * ixv_netmap.c contains functions for netmap
  * support that extend the standard driver.  See additional
- * comments in ixgbe_netmap.c.
+ * comments in ixv_netmap.c.
  */
 void ixv_netmap_attach(struct adapter *adapter);
 


More information about the svn-src-stable mailing list