Index: sys/net/iflib.c =================================================================== --- sys/net/iflib.c +++ sys/net/iflib.c @@ -4385,6 +4385,12 @@ i, scctx->isc_nrxd[i], sctx->isc_nrxd_max[i]); scctx->isc_nrxd[i] = sctx->isc_nrxd_max[i]; } + if (!powerof2(scctx->isc_nrxd[i])) { + int rounded = 1 << (fls(scctx->isc_nrxd[i]) - 1); + device_printf(dev, "nrxd%d: %d is not a power of 2 - rounding down to %d\n", + i, scctx->isc_nrxd[i], rounded); + scctx->isc_nrxd[i] = rounded; + } } for (i = 0; i < sctx->isc_ntxqs; i++) { @@ -4398,6 +4404,12 @@ i, scctx->isc_ntxd[i], sctx->isc_ntxd_max[i]); scctx->isc_ntxd[i] = sctx->isc_ntxd_max[i]; } + if (!powerof2(scctx->isc_ntxd[i])) { + int rounded = 1 << (fls(scctx->isc_ntxd[i]) - 1); + device_printf(dev, "ntxd%d: %d is not a power of 2 - rounding down to %d\n", + i, scctx->isc_ntxd[i], rounded); + scctx->isc_ntxd[i] = rounded; + } } } @@ -4408,7 +4420,6 @@ if_ctx_t ctx; if_t ifp; if_softc_ctx_t scctx; - int i; uint16_t main_txq; uint16_t main_rxq; @@ -4463,22 +4474,6 @@ /* XXX change for per-queue sizes */ device_printf(dev, "Using %d tx descriptors and %d rx descriptors\n", scctx->isc_ntxd[main_txq], scctx->isc_nrxd[main_rxq]); - for (i = 0; i < sctx->isc_nrxqs; i++) { - if (!powerof2(scctx->isc_nrxd[i])) { - /* round down instead? */ - device_printf(dev, "# rx descriptors must be a power of 2\n"); - err = EINVAL; - goto fail_iflib_detach; - } - } - for (i = 0; i < sctx->isc_ntxqs; i++) { - if (!powerof2(scctx->isc_ntxd[i])) { - device_printf(dev, - "# tx descriptors must be a power of 2"); - err = EINVAL; - goto fail_iflib_detach; - } - } if (scctx->isc_tx_nsegments > scctx->isc_ntxd[main_txq] / MAX_SINGLE_PACKET_FRACTION) @@ -4615,7 +4610,6 @@ fail_queues: iflib_tx_structures_free(ctx); iflib_rx_structures_free(ctx); -fail_iflib_detach: IFDI_DETACH(ctx); fail_unlock: CTX_UNLOCK(ctx); @@ -4658,9 +4652,6 @@ scctx = &ctx->ifc_softc_ctx; ifp = ctx->ifc_ifp; - /* - * XXX sanity check that ntxd & nrxd are a power of 2 - */ iflib_reset_qvalues(ctx); CTX_LOCK(ctx); if ((err = IFDI_ATTACH_PRE(ctx)) != 0) { @@ -4725,22 +4716,6 @@ /* XXX change for per-queue sizes */ device_printf(dev, "Using %d tx descriptors and %d rx descriptors\n", scctx->isc_ntxd[main_txq], scctx->isc_nrxd[main_rxq]); - for (i = 0; i < sctx->isc_nrxqs; i++) { - if (!powerof2(scctx->isc_nrxd[i])) { - /* round down instead? */ - device_printf(dev, "# rx descriptors must be a power of 2\n"); - err = EINVAL; - goto fail_iflib_detach; - } - } - for (i = 0; i < sctx->isc_ntxqs; i++) { - if (!powerof2(scctx->isc_ntxd[i])) { - device_printf(dev, - "# tx descriptors must be a power of 2"); - err = EINVAL; - goto fail_iflib_detach; - } - } if (scctx->isc_tx_nsegments > scctx->isc_ntxd[main_txq] / MAX_SINGLE_PACKET_FRACTION)