Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jun 2016 06:32:00 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r301918 - in stable/10/sys/dev/hyperv: include netvsc
Message-ID:  <201606150632.u5F6W0SL022499@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Wed Jun 15 06:32:00 2016
New Revision: 301918
URL: https://svnweb.freebsd.org/changeset/base/301918

Log:
  MFC 296293,296296,296297,296305
  
  296293
      hyperv/hn: Pass channel to hv_nv_on_receive_completion()
  
      While I'm here, staticize this function.
  
      Submitted by:       Hongjiang Zhang <honzhan microsoft com>
      Modified by:        sephe
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
  
  296296
      hyperv/hn: Make read buffer per-channel
  
      Submitted by:       Hongjiang Zhang <honzhan microsoft com>
      Reorganized by:     sephe
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
  
  296297
      hyperv/hn: Fix typo in comment
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC
  
  296305
      hyperv/hn: Make # of rings configurable
  
      And since the host may not being able to allocate the # of rings
      requested by us, save the # of rings allocated by the host in the
      ring_inuse counters; use ring_inuse counters for run time operation.
  
      This paves the way for the upcoming vRSS support.
  
      MFC after:  1 week
      Sponsored by:       Microsoft OSTC

Modified:
  stable/10/sys/dev/hyperv/include/hyperv.h
  stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c
  stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h
  stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c
  stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- stable/10/sys/dev/hyperv/include/hyperv.h	Wed Jun 15 06:27:43 2016	(r301917)
+++ stable/10/sys/dev/hyperv/include/hyperv.h	Wed Jun 15 06:32:00 2016	(r301918)
@@ -828,6 +828,7 @@ typedef struct hv_vmbus_channel {
 	 */
 	void				*hv_chan_priv1;
 	void				*hv_chan_priv2;
+	void				*hv_chan_priv3;
 } hv_vmbus_channel;
 
 #define HV_VMBUS_CHAN_ISPRIMARY(chan)	((chan)->primary_channel == NULL)

Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c	Wed Jun 15 06:27:43 2016	(r301917)
+++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c	Wed Jun 15 06:32:00 2016	(r301918)
@@ -48,6 +48,9 @@
 #include "hv_rndis.h"
 #include "hv_rndis_filter.h"
 
+/* priv1 and priv2 are consumed by the main driver */
+#define hv_chan_rdbuf	hv_chan_priv3
+
 MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver");
 
 /*
@@ -61,6 +64,8 @@ static int  hv_nv_destroy_rx_buffer(netv
 static int  hv_nv_connect_to_vsp(struct hv_device *device);
 static void hv_nv_on_send_completion(netvsc_dev *net_dev,
     struct hv_device *device, hv_vm_packet_descriptor *pkt);
+static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan,
+    uint64_t tid, uint32_t status);
 static void hv_nv_on_receive(netvsc_dev *net_dev,
     struct hv_device *device, struct hv_vmbus_channel *chan,
     hv_vm_packet_descriptor *pkt);
@@ -663,25 +668,30 @@ hv_nv_disconnect_from_vsp(netvsc_dev *ne
 netvsc_dev *
 hv_nv_on_device_add(struct hv_device *device, void *additional_info)
 {
+	struct hv_vmbus_channel *chan = device->channel;
 	netvsc_dev *net_dev;
 	int ret = 0;
 
 	net_dev = hv_nv_alloc_net_device(device);
-	if (!net_dev)
-		goto cleanup;
+	if (net_dev == NULL)
+		return NULL;
 
 	/* Initialize the NetVSC channel extension */
 
 	sema_init(&net_dev->channel_init_sema, 0, "netdev_sema");
 
+	chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK);
+
 	/*
 	 * Open the channel
 	 */
-	ret = hv_vmbus_channel_open(device->channel,
+	ret = hv_vmbus_channel_open(chan,
 	    NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE,
-	    NULL, 0, hv_nv_on_channel_callback, device->channel);
-	if (ret != 0)
+	    NULL, 0, hv_nv_on_channel_callback, chan);
+	if (ret != 0) {
+		free(chan->hv_chan_rdbuf, M_NETVSC);
 		goto cleanup;
+	}
 
 	/*
 	 * Connect with the NetVsp
@@ -694,8 +704,8 @@ hv_nv_on_device_add(struct hv_device *de
 
 close:
 	/* Now, we can close the channel safely */
-
-	hv_vmbus_channel_close(device->channel);
+	free(chan->hv_chan_rdbuf, M_NETVSC);
+	hv_vmbus_channel_close(chan);
 
 cleanup:
 	/*
@@ -733,6 +743,7 @@ hv_nv_on_device_remove(struct hv_device 
 		    HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE;
 	}
 
+	free(device->channel->hv_chan_rdbuf, M_NETVSC);
 	hv_vmbus_channel_close(device->channel);
 
 	sema_destroy(&net_dev->channel_init_sema);
@@ -910,7 +921,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
 	 * messages (not just data messages) will trigger a response
 	 * message back to the host.
 	 */
-	hv_nv_on_receive_completion(device, vm_xfer_page_pkt->d.transaction_id,
+	hv_nv_on_receive_completion(chan, vm_xfer_page_pkt->d.transaction_id,
 	    status);
 }
 
@@ -919,8 +930,8 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
  *
  * Send a receive completion packet to RNDIS device (ie NetVsp)
  */
-void
-hv_nv_on_receive_completion(struct hv_device *device, uint64_t tid,
+static void
+hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid,
     uint32_t status)
 {
 	nvsp_msg rx_comp_msg;
@@ -935,7 +946,7 @@ hv_nv_on_receive_completion(struct hv_de
 
 retry_send_cmplt:
 	/* Send the completion */
-	ret = hv_vmbus_channel_send_packet(device->channel, &rx_comp_msg,
+	ret = hv_vmbus_channel_send_packet(chan, &rx_comp_msg,
 	    sizeof(nvsp_msg), tid, HV_VMBUS_PACKET_TYPE_COMPLETION, 0);
 	if (ret == 0) {
 		/* success */
@@ -972,7 +983,7 @@ hv_nv_on_channel_callback(void *xchan)
 	if (net_dev == NULL)
 		return;
 
-	buffer = net_dev->callback_buf;
+	buffer = chan->hv_chan_rdbuf;
 
 	do {
 		ret = hv_vmbus_channel_recv_packet_raw(chan,

Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h	Wed Jun 15 06:27:43 2016	(r301917)
+++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h	Wed Jun 15 06:32:00 2016	(r301918)
@@ -923,8 +923,6 @@ typedef struct netvsc_dev_ {
 	hv_bool_uint8_t				destroy;
 	/* Negotiated NVSP version */
 	uint32_t				nvsp_version;
-	
-	uint8_t					callback_buf[NETVSC_PACKET_SIZE]; 
 } netvsc_dev;
 
 
@@ -1081,9 +1079,11 @@ typedef struct hn_softc {
 	netvsc_dev  	*net_dev;
 
 	int		hn_rx_ring_cnt;
+	int		hn_rx_ring_inuse;
 	struct hn_rx_ring *hn_rx_ring;
 
 	int		hn_tx_ring_cnt;
+	int		hn_tx_ring_inuse;
 	struct hn_tx_ring *hn_tx_ring;
 	int		hn_tx_chimney_max;
 	struct taskqueue *hn_tx_taskq;
@@ -1096,8 +1096,6 @@ typedef struct hn_softc {
 extern int hv_promisc_mode;
 
 void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status);
-void hv_nv_on_receive_completion(struct hv_device *device,
-    uint64_t tid, uint32_t status);
 netvsc_dev *hv_nv_on_device_add(struct hv_device *device,
     void *additional_info);
 int hv_nv_on_device_remove(struct hv_device *device,

Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Wed Jun 15 06:27:43 2016	(r301917)
+++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Wed Jun 15 06:32:00 2016	(r301918)
@@ -281,6 +281,14 @@ static int hn_use_if_start = 0;
 SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN,
     &hn_use_if_start, 0, "Use if_start TX method");
 
+static int hn_ring_cnt = 1;
+SYSCTL_INT(_hw_hn, OID_AUTO, ring_cnt, CTLFLAG_RDTUN,
+    &hn_ring_cnt, 0, "# of TX/RX rings to used");
+
+static int hn_single_tx_ring = 1;
+SYSCTL_INT(_hw_hn, OID_AUTO, single_tx_ring, CTLFLAG_RDTUN,
+    &hn_single_tx_ring, 0, "Use one TX ring");
+
 /*
  * Forward declarations
  */
@@ -310,13 +318,13 @@ static int hn_tx_conf_int_sysctl(SYSCTL_
 static int hn_check_iplen(const struct mbuf *, int);
 static int hn_create_tx_ring(struct hn_softc *, int);
 static void hn_destroy_tx_ring(struct hn_tx_ring *);
-static int hn_create_tx_data(struct hn_softc *);
+static int hn_create_tx_data(struct hn_softc *, int);
 static void hn_destroy_tx_data(struct hn_softc *);
 static void hn_start_taskfunc(void *, int);
 static void hn_start_txeof_taskfunc(void *, int);
 static void hn_stop_tx_tasks(struct hn_softc *);
 static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **);
-static void hn_create_rx_data(struct hn_softc *sc);
+static void hn_create_rx_data(struct hn_softc *sc, int);
 static void hn_destroy_rx_data(struct hn_softc *sc);
 static void hn_set_tx_chimney_size(struct hn_softc *, int);
 
@@ -405,7 +413,7 @@ netvsc_attach(device_t dev)
 	hn_softc_t *sc;
 	int unit = device_get_unit(dev);
 	struct ifnet *ifp = NULL;
-	int error;
+	int error, ring_cnt, tx_ring_cnt;
 #if __FreeBSD_version >= 1100045
 	int tso_maxlen;
 #endif
@@ -447,11 +455,24 @@ netvsc_attach(device_t dev)
 	ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER);
 	ifp->if_softc = sc;
 
-	error = hn_create_tx_data(sc);
+	ring_cnt = hn_ring_cnt;
+	if (ring_cnt <= 0 || ring_cnt >= mp_ncpus)
+		ring_cnt = mp_ncpus;
+
+	tx_ring_cnt = ring_cnt;
+	if (hn_single_tx_ring || hn_use_if_start) {
+		/*
+		 * - Explicitly asked to use single TX ring.
+		 * - ifnet.if_start is used; ifnet.if_start only needs
+		 *   one TX ring.
+		 */
+		tx_ring_cnt = 1;
+	}
+	error = hn_create_tx_data(sc, tx_ring_cnt);
 	if (error)
 		goto failed;
 
-	hn_create_rx_data(sc);
+	hn_create_rx_data(sc, ring_cnt);
 
 	/*
 	 * Associate the first TX/RX ring w/ the primary channel.
@@ -498,10 +519,16 @@ netvsc_attach(device_t dev)
 	    IFCAP_LRO;
 	ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO;
 
-	error = hv_rf_on_device_add(device_ctx, &device_info);
+	error = hv_rf_on_device_add(device_ctx, &device_info, ring_cnt);
 	if (error)
 		goto failed;
 
+	/* TODO: vRSS */
+	sc->hn_tx_ring_inuse = 1;
+	sc->hn_rx_ring_inuse = 1;
+	device_printf(dev, "%d TX ring, %d RX ring\n",
+	    sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse);
+
 	if (device_info.link_state == 0) {
 		sc->hn_carrier = 1;
 	}
@@ -1416,7 +1443,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 		if (sc->hn_rx_ring[0].hn_lro.lro_length_lim <
 		    HN_LRO_LENLIM_MIN(ifp)) {
 			int i;
-			for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
+			for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
 				sc->hn_rx_ring[i].hn_lro.lro_length_lim =
 				    HN_LRO_LENLIM_MIN(ifp);
 			}
@@ -1453,7 +1480,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 			NV_UNLOCK(sc);
 			break;
 		}
-		error = hv_rf_on_device_add(hn_dev, &device_info);
+		error = hv_rf_on_device_add(hn_dev, &device_info,
+		    sc->hn_rx_ring_inuse);
 		if (error) {
 			NV_LOCK(sc);
 			sc->temp_unusable = FALSE;
@@ -1606,7 +1634,7 @@ hn_stop(hn_softc_t *sc)
 
 	atomic_clear_int(&ifp->if_drv_flags,
 	    (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i)
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i)
 		sc->hn_tx_ring[i].hn_oactive = 0;
 
 	if_link_state_change(ifp, LINK_STATE_DOWN);
@@ -1699,7 +1727,7 @@ hn_ifinit_locked(hn_softc_t *sc)
 	}
 
 	atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i)
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i)
 		sc->hn_tx_ring[i].hn_oactive = 0;
 
 	atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING);
@@ -1764,7 +1792,7 @@ hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS
 		return EINVAL;
 
 	NV_LOCK(sc);
-	for (i = 0; i < sc->hn_rx_ring_cnt; ++i)
+	for (i = 0; i < sc->hn_rx_ring_inuse; ++i)
 		sc->hn_rx_ring[i].hn_lro.lro_length_lim = lenlim;
 	NV_UNLOCK(sc);
 	return 0;
@@ -1794,7 +1822,7 @@ hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS
 	 */
 	--ackcnt;
 	NV_LOCK(sc);
-	for (i = 0; i < sc->hn_rx_ring_cnt; ++i)
+	for (i = 0; i < sc->hn_rx_ring_inuse; ++i)
 		sc->hn_rx_ring[i].hn_lro.lro_ackcnt_lim = ackcnt;
 	NV_UNLOCK(sc);
 	return 0;
@@ -1818,7 +1846,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARG
 		return error;
 
 	NV_LOCK(sc);
-	for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
 		struct hn_rx_ring *rxr = &sc->hn_rx_ring[i];
 
 		if (on)
@@ -1858,7 +1886,7 @@ hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARG
 	uint64_t stat;
 
 	stat = 0;
-	for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
 		rxr = &sc->hn_rx_ring[i];
 		stat += *((int *)((uint8_t *)rxr + ofs));
 	}
@@ -1868,7 +1896,7 @@ hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARG
 		return error;
 
 	/* Zero out this stat. */
-	for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
 		rxr = &sc->hn_rx_ring[i];
 		*((int *)((uint8_t *)rxr + ofs)) = 0;
 	}
@@ -1884,7 +1912,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG
 	uint64_t stat;
 
 	stat = 0;
-	for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
 		rxr = &sc->hn_rx_ring[i];
 		stat += *((uint64_t *)((uint8_t *)rxr + ofs));
 	}
@@ -1894,7 +1922,7 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG
 		return error;
 
 	/* Zero out this stat. */
-	for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
 		rxr = &sc->hn_rx_ring[i];
 		*((uint64_t *)((uint8_t *)rxr + ofs)) = 0;
 	}
@@ -1938,7 +1966,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_A
 	u_long stat;
 
 	stat = 0;
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i) {
 		txr = &sc->hn_tx_ring[i];
 		stat += *((u_long *)((uint8_t *)txr + ofs));
 	}
@@ -1948,7 +1976,7 @@ hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_A
 		return error;
 
 	/* Zero out this stat. */
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i) {
 		txr = &sc->hn_tx_ring[i];
 		*((u_long *)((uint8_t *)txr + ofs)) = 0;
 	}
@@ -1970,7 +1998,7 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG
 		return error;
 
 	NV_LOCK(sc);
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i) {
 		txr = &sc->hn_tx_ring[i];
 		*((int *)((uint8_t *)txr + ofs)) = conf;
 	}
@@ -2067,7 +2095,7 @@ hn_dma_map_paddr(void *arg, bus_dma_segm
 }
 
 static void
-hn_create_rx_data(struct hn_softc *sc)
+hn_create_rx_data(struct hn_softc *sc, int ring_cnt)
 {
 	struct sysctl_oid_list *child;
 	struct sysctl_ctx_list *ctx;
@@ -2079,7 +2107,9 @@ hn_create_rx_data(struct hn_softc *sc)
 #endif
 	int i;
 
-	sc->hn_rx_ring_cnt = 1; /* TODO: vRSS */
+	sc->hn_rx_ring_cnt = ring_cnt;
+	sc->hn_rx_ring_inuse = sc->hn_rx_ring_cnt;
+
 	sc->hn_rx_ring = malloc(sizeof(struct hn_rx_ring) * sc->hn_rx_ring_cnt,
 	    M_NETVSC, M_WAITOK | M_ZERO);
 
@@ -2190,6 +2220,10 @@ hn_create_rx_data(struct hn_softc *sc)
 	    CTLTYPE_ULONG | CTLFLAG_RW, sc,
 	    __offsetof(struct hn_rx_ring, hn_small_pkts),
 	    hn_rx_stat_ulong_sysctl, "LU", "# of small packets received");
+	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rx_ring_cnt",
+	    CTLFLAG_RD, &sc->hn_rx_ring_cnt, 0, "# created RX rings");
+	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rx_ring_inuse",
+	    CTLFLAG_RD, &sc->hn_rx_ring_inuse, 0, "# used RX rings");
 }
 
 static void
@@ -2210,6 +2244,7 @@ hn_destroy_rx_data(struct hn_softc *sc)
 	sc->hn_rx_ring = NULL;
 
 	sc->hn_rx_ring_cnt = 0;
+	sc->hn_rx_ring_inuse = 0;
 }
 
 static int
@@ -2446,18 +2481,15 @@ hn_destroy_tx_ring(struct hn_tx_ring *tx
 }
 
 static int
-hn_create_tx_data(struct hn_softc *sc)
+hn_create_tx_data(struct hn_softc *sc, int ring_cnt)
 {
 	struct sysctl_oid_list *child;
 	struct sysctl_ctx_list *ctx;
 	int i;
 
-	if (hn_use_if_start) {
-		/* ifnet.if_start only needs one TX ring */
-		sc->hn_tx_ring_cnt = 1;
-	} else {
-		sc->hn_tx_ring_cnt = 1; /* TODO: vRSS */
-	}
+	sc->hn_tx_ring_cnt = ring_cnt;
+	sc->hn_tx_ring_inuse = sc->hn_tx_ring_cnt;
+
 	sc->hn_tx_ring = malloc(sizeof(struct hn_tx_ring) * sc->hn_tx_ring_cnt,
 	    M_NETVSC, M_WAITOK | M_ZERO);
 
@@ -2516,6 +2548,10 @@ hn_create_tx_data(struct hn_softc *sc)
 	    hn_tx_conf_int_sysctl, "I",
 	    "Always schedule transmission "
 	    "instead of doing direct transmission");
+	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "tx_ring_cnt",
+	    CTLFLAG_RD, &sc->hn_tx_ring_cnt, 0, "# created TX rings");
+	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "tx_ring_inuse",
+	    CTLFLAG_RD, &sc->hn_tx_ring_inuse, 0, "# used TX rings");
 
 	return 0;
 }
@@ -2526,7 +2562,7 @@ hn_set_tx_chimney_size(struct hn_softc *
 	int i;
 
 	NV_LOCK(sc);
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i)
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i)
 		sc->hn_tx_ring[i].hn_tx_chimney_size = chimney_size;
 	NV_UNLOCK(sc);
 }
@@ -2546,6 +2582,7 @@ hn_destroy_tx_data(struct hn_softc *sc)
 	sc->hn_tx_ring = NULL;
 
 	sc->hn_tx_ring_cnt = 0;
+	sc->hn_tx_ring_inuse = 0;
 }
 
 static void
@@ -2574,7 +2611,7 @@ hn_stop_tx_tasks(struct hn_softc *sc)
 {
 	int i;
 
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i) {
 		struct hn_tx_ring *txr = &sc->hn_tx_ring[i];
 
 		taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task);
@@ -2650,7 +2687,7 @@ hn_transmit(struct ifnet *ifp, struct mb
 	 * Select the TX ring based on flowid
 	 */
 	if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE)
-		idx = m->m_pkthdr.flowid % sc->hn_tx_ring_cnt;
+		idx = m->m_pkthdr.flowid % sc->hn_tx_ring_inuse;
 	txr = &sc->hn_tx_ring[idx];
 
 	error = drbr_enqueue(ifp, txr->hn_mbuf_br, m);
@@ -2682,7 +2719,7 @@ hn_xmit_qflush(struct ifnet *ifp)
 	struct hn_softc *sc = ifp->if_softc;
 	int i;
 
-	for (i = 0; i < sc->hn_tx_ring_cnt; ++i) {
+	for (i = 0; i < sc->hn_tx_ring_inuse; ++i) {
 		struct hn_tx_ring *txr = &sc->hn_tx_ring[i];
 		struct mbuf *m;
 

Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Wed Jun 15 06:27:43 2016	(r301917)
+++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Wed Jun 15 06:32:00 2016	(r301918)
@@ -816,7 +816,8 @@ hv_rf_close_device(rndis_device *device)
  * RNDIS filter on device add
  */
 int
-hv_rf_on_device_add(struct hv_device *device, void *additl_info)
+hv_rf_on_device_add(struct hv_device *device, void *additl_info,
+    int nchan __unused)
 {
 	int ret;
 	netvsc_dev *net_dev;

Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h
==============================================================================
--- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h	Wed Jun 15 06:27:43 2016	(r301917)
+++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h	Wed Jun 15 06:32:00 2016	(r301918)
@@ -101,7 +101,7 @@ int hv_rf_on_receive(netvsc_dev *net_dev
     struct hv_vmbus_channel *chan, netvsc_packet *pkt);
 void hv_rf_receive_rollup(netvsc_dev *net_dev);
 void hv_rf_channel_rollup(struct hv_vmbus_channel *chan);
-int hv_rf_on_device_add(struct hv_device *device, void *additl_info);
+int hv_rf_on_device_add(struct hv_device *device, void *additl_info, int nchan);
 int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel);
 int hv_rf_on_open(struct hv_device *device);
 int hv_rf_on_close(struct hv_device *device);



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