Author: jhb
Date: Mon Nov 16 21:36:50 2015
New Revision: 290948
URL: https://svnweb.freebsd.org/changeset/base/290948

Log:
  Only use a power of 2 for the number of receive and transmit queues.
  Using other values causes VMXNET3_CMD_ENABLE to fail.  The Linux
  driver also enforces this restriction.
  
  Reviewed by:  bryanv
  MFC after:    1 week
  Sponsored by: Norse
  Differential Revision:        https://reviews.freebsd.org/D4139

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 Nov 16 21:36:15 2015        
(r290947)
+++ head/sys/dev/vmware/vmxnet3/if_vmx.c        Mon Nov 16 21:36:50 2015        
(r290948)
@@ -510,6 +510,13 @@ vmxnet3_check_version(struct vmxnet3_sof
        return (0);
 }
 
+static int
+trunc_powerof2(int val)
+{
+
+       return (1U << (fls(val) - 1));
+}
+
 static void
 vmxnet3_initial_config(struct vmxnet3_softc *sc)
 {
@@ -520,14 +527,14 @@ vmxnet3_initial_config(struct vmxnet3_so
                nqueue = VMXNET3_DEF_TX_QUEUES;
        if (nqueue > mp_ncpus)
                nqueue = mp_ncpus;
-       sc->vmx_max_ntxqueues = nqueue;
+       sc->vmx_max_ntxqueues = trunc_powerof2(nqueue);
 
        nqueue = vmxnet3_tunable_int(sc, "rxnqueue", vmxnet3_default_rxnqueue);
        if (nqueue > VMXNET3_MAX_RX_QUEUES || nqueue < 1)
                nqueue = VMXNET3_DEF_RX_QUEUES;
        if (nqueue > mp_ncpus)
                nqueue = mp_ncpus;
-       sc->vmx_max_nrxqueues = nqueue;
+       sc->vmx_max_nrxqueues = trunc_powerof2(nqueue);
 
        if (vmxnet3_tunable_int(sc, "mq_disable", vmxnet3_mq_disable)) {
                sc->vmx_max_nrxqueues = 1;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to