svn commit: r359029 - head/sys/dev/vmware/vmxnet3

Patrick Kelsey pkelsey at FreeBSD.org
Tue Mar 17 03:32:13 UTC 2020


Author: pkelsey
Date: Tue Mar 17 03:32:13 2020
New Revision: 359029
URL: https://svnweb.freebsd.org/changeset/base/359029

Log:
  Restore power-of-2 queue count constraint from r290948
  
  When vmx(4) was converted to an iflib driver in r343291, the
  power-of-2 queue count constraint was removed as it appeared that
  current implementations of the VMXNET3 virtual device no longer
  required that constraint.  It turns out that some of the
  implementations still do, and on such systems, the device will fail to
  initialize when configured with a non-power-of-2 RX or TX queue count.
  
  PR:		237321
  Reported by:	ncrogers at gmail.com
  MFC after:	1 week

Modified:
  head/sys/dev/vmware/vmxnet3/if_vmx.c

Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c
==============================================================================
--- head/sys/dev/vmware/vmxnet3/if_vmx.c	Mon Mar 16 23:37:57 2020	(r359028)
+++ head/sys/dev/vmware/vmxnet3/if_vmx.c	Tue Mar 17 03:32:13 2020	(r359029)
@@ -321,6 +321,13 @@ vmxnet3_register(device_t dev)
 }
 
 static int
+trunc_powerof2(int val)
+{
+
+	return (1U << (fls(val) - 1));
+}
+
+static int
 vmxnet3_attach_pre(if_ctx_t ctx)
 {
 	device_t dev;
@@ -349,12 +356,16 @@ vmxnet3_attach_pre(if_ctx_t ctx)
 	/* If 0, the iflib tunable was not set, so set to the default */
 	if (scctx->isc_nrxqsets == 0)
 		scctx->isc_nrxqsets = VMXNET3_DEF_RX_QUEUES;
+	scctx->isc_nrxqsets = trunc_powerof2(scctx->isc_nrxqsets);
 	scctx->isc_nrxqsets_max = min(VMXNET3_MAX_RX_QUEUES, mp_ncpus);
+	scctx->isc_nrxqsets_max = trunc_powerof2(scctx->isc_nrxqsets_max);
 
 	/* If 0, the iflib tunable was not set, so set to the default */
 	if (scctx->isc_ntxqsets == 0)
 		scctx->isc_ntxqsets = VMXNET3_DEF_TX_QUEUES;
+	scctx->isc_ntxqsets = trunc_powerof2(scctx->isc_ntxqsets);
 	scctx->isc_ntxqsets_max = min(VMXNET3_MAX_TX_QUEUES, mp_ncpus);
+	scctx->isc_ntxqsets_max = trunc_powerof2(scctx->isc_ntxqsets_max);
 
 	/*
 	 * Enforce that the transmit completion queue descriptor count is


More information about the svn-src-all mailing list