svn commit: r310799 - in stable/10/sys: conf dev/hyperv/netvsc modules/hyperv/netvsc

Sepherosa Ziehau sephe at FreeBSD.org
Fri Dec 30 01:59:20 UTC 2016


Author: sephe
Date: Fri Dec 30 01:59:19 2016
New Revision: 310799
URL: https://svnweb.freebsd.org/changeset/base/310799

Log:
  MFC 309346,309348
  
  309346
      hyperv/hn: Add HN_DEBUG kernel option.
  
      If bufring is used for per-TX ring descs, don't update "available"
      counter, which is only used to help debugging.
  
      Sponsored by:   Microsoft
      Differential Revision:  https://reviews.freebsd.org/D8674
  
  309348
      hyperv/hn: Don't hold txdesc, if no BPFs are attached.
  
      Sponsored by:   Microsoft
      Differential Revision:  https://reviews.freebsd.org/D8675

Modified:
  stable/10/sys/conf/options
  stable/10/sys/dev/hyperv/netvsc/if_hn.c
  stable/10/sys/modules/hyperv/netvsc/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/conf/options
==============================================================================
--- stable/10/sys/conf/options	Fri Dec 30 01:34:06 2016	(r310798)
+++ stable/10/sys/conf/options	Fri Dec 30 01:59:19 2016	(r310799)
@@ -947,3 +947,6 @@ RANDOM_RWFILE	opt_random.h
 
 # Intel em(4) driver
 EM_MULTIQUEUE	opt_em.h
+
+# Hyper-V network driver
+HN_DEBUG	opt_hn.h

Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/if_hn.c	Fri Dec 30 01:34:06 2016	(r310798)
+++ stable/10/sys/dev/hyperv/netvsc/if_hn.c	Fri Dec 30 01:59:19 2016	(r310799)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 
 #include "opt_inet6.h"
 #include "opt_inet.h"
+#include "opt_hn.h"
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -1436,10 +1437,12 @@ hn_txdesc_put(struct hn_tx_ring *txr, st
 	txr->hn_txdesc_avail++;
 	SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link);
 	mtx_unlock_spin(&txr->hn_txlist_spin);
-#else
+#else	/* HN_USE_TXDESC_BUFRING */
+#ifdef HN_DEBUG
 	atomic_add_int(&txr->hn_txdesc_avail, 1);
-	buf_ring_enqueue(txr->hn_txdesc_br, txd);
 #endif
+	buf_ring_enqueue(txr->hn_txdesc_br, txd);
+#endif	/* !HN_USE_TXDESC_BUFRING */
 
 	return 1;
 }
@@ -1465,8 +1468,10 @@ hn_txdesc_get(struct hn_tx_ring *txr)
 
 	if (txd != NULL) {
 #ifdef HN_USE_TXDESC_BUFRING
+#ifdef HN_DEBUG
 		atomic_subtract_int(&txr->hn_txdesc_avail, 1);
 #endif
+#endif	/* HN_USE_TXDESC_BUFRING */
 		KASSERT(txd->m == NULL && txd->refs == 0 &&
 		    STAILQ_EMPTY(&txd->agg_list) &&
 		    txd->chim_index == HN_NVS_CHIM_IDX_INVALID &&
@@ -1933,17 +1938,20 @@ done:
 static int
 hn_txpkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd)
 {
-	int error, send_failed = 0;
+	int error, send_failed = 0, has_bpf;
 
 again:
-	/*
-	 * Make sure that this txd and any aggregated txds are not freed
-	 * before ETHER_BPF_MTAP.
-	 */
-	hn_txdesc_hold(txd);
+	has_bpf = bpf_peers_present(ifp->if_bpf);
+	if (has_bpf) {
+		/*
+		 * Make sure that this txd and any aggregated txds are not
+		 * freed before ETHER_BPF_MTAP.
+		 */
+		hn_txdesc_hold(txd);
+	}
 	error = txr->hn_sendpkt(txr, txd);
 	if (!error) {
-		if (bpf_peers_present(ifp->if_bpf)) {
+		if (has_bpf) {
 			const struct hn_txdesc *tmp_txd;
 
 			ETHER_BPF_MTAP(ifp, txd->m);
@@ -1966,7 +1974,8 @@ again:
 		txr->hn_pkts += txr->hn_stat_pkts;
 		txr->hn_sends++;
 	}
-	hn_txdesc_put(txr, txd);
+	if (has_bpf)
+		hn_txdesc_put(txr, txd);
 
 	if (__predict_false(error)) {
 		int freed;
@@ -3479,9 +3488,11 @@ hn_tx_ring_create(struct hn_softc *sc, i
 		if (txr->hn_tx_sysctl_tree != NULL) {
 			child = SYSCTL_CHILDREN(txr->hn_tx_sysctl_tree);
 
+#ifdef HN_DEBUG
 			SYSCTL_ADD_INT(ctx, child, OID_AUTO, "txdesc_avail",
 			    CTLFLAG_RD, &txr->hn_txdesc_avail, 0,
 			    "# of available TX descs");
+#endif
 #ifdef HN_IFSTART_SUPPORT
 			if (!hn_use_if_start)
 #endif

Modified: stable/10/sys/modules/hyperv/netvsc/Makefile
==============================================================================
--- stable/10/sys/modules/hyperv/netvsc/Makefile	Fri Dec 30 01:34:06 2016	(r310798)
+++ stable/10/sys/modules/hyperv/netvsc/Makefile	Fri Dec 30 01:59:19 2016	(r310799)
@@ -5,7 +5,7 @@
 
 KMOD=	hv_netvsc
 SRCS=	hn_nvs.c hn_rndis.c if_hn.c
-SRCS+=	bus_if.h device_if.h opt_inet.h opt_inet6.h vmbus_if.h
+SRCS+=	bus_if.h device_if.h opt_inet.h opt_inet6.h vmbus_if.h opt_hn.h
 
 CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/netvsc
 


More information about the svn-src-all mailing list