Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154226965
D19880.id56496.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D19880.id56496.diff
View Options
Index: sys/net/iflib.c
===================================================================
--- sys/net/iflib.c
+++ sys/net/iflib.c
@@ -4317,9 +4317,6 @@
scctx->isc_txrx_budget_bytes_max = IFLIB_MAX_TX_BYTES;
scctx->isc_tx_qdepth = IFLIB_DEFAULT_TX_QDEPTH;
- /*
- * XXX sanity check that ntxd & nrxd are a power of 2
- */
if (ctx->ifc_sysctl_ntxqs != 0)
scctx->isc_ntxqsets = ctx->ifc_sysctl_ntxqs;
if (ctx->ifc_sysctl_nrxqs != 0)
@@ -4350,6 +4347,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++) {
@@ -4363,6 +4366,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;
+ }
}
}
@@ -4373,7 +4382,6 @@
if_ctx_t ctx;
if_t ifp;
if_softc_ctx_t scctx;
- int i;
uint16_t main_txq;
uint16_t main_rxq;
@@ -4428,22 +4436,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)
@@ -4580,7 +4572,6 @@
fail_queues:
iflib_tx_structures_free(ctx);
iflib_rx_structures_free(ctx);
-fail_iflib_detach:
IFDI_DETACH(ctx);
fail_unlock:
CTX_UNLOCK(ctx);
@@ -4623,9 +4614,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) {
@@ -4690,22 +4678,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)
@@ -5092,6 +5064,8 @@
static void
_iflib_assert(if_shared_ctx_t sctx)
{
+ int i;
+
MPASS(sctx->isc_tx_maxsize);
MPASS(sctx->isc_tx_maxsegsize);
@@ -5099,12 +5073,25 @@
MPASS(sctx->isc_rx_nsegments);
MPASS(sctx->isc_rx_maxsegsize);
- MPASS(sctx->isc_nrxd_min[0]);
- MPASS(sctx->isc_nrxd_max[0]);
- MPASS(sctx->isc_nrxd_default[0]);
- MPASS(sctx->isc_ntxd_min[0]);
- MPASS(sctx->isc_ntxd_max[0]);
- MPASS(sctx->isc_ntxd_default[0]);
+ MPASS(sctx->isc_nrxqs >= 1 && sctx->isc_nrxqs <= 8);
+ for (i = 0; i < sctx->isc_nrxqs; i++) {
+ MPASS(sctx->isc_nrxd_min[i]);
+ MPASS(powerof2(sctx->isc_nrxd_min[i]));
+ MPASS(sctx->isc_nrxd_max[i]);
+ MPASS(powerof2(sctx->isc_nrxd_max[i]));
+ MPASS(sctx->isc_nrxd_default[i]);
+ MPASS(powerof2(sctx->isc_nrxd_default[i]));
+ }
+
+ MPASS(sctx->isc_ntxqs >= 1 && sctx->isc_ntxqs <= 8);
+ for (i = 0; i < sctx->isc_ntxqs; i++) {
+ MPASS(sctx->isc_ntxd_min[i]);
+ MPASS(powerof2(sctx->isc_ntxd_min[i]));
+ MPASS(sctx->isc_ntxd_max[i]);
+ MPASS(powerof2(sctx->isc_ntxd_max[i]));
+ MPASS(sctx->isc_ntxd_default[i]);
+ MPASS(powerof2(sctx->isc_ntxd_default[i]));
+ }
}
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 28, 6:38 AM (7 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32256139
Default Alt Text
D19880.id56496.diff (4 KB)
Attached To
Mode
D19880: iflib: use default ntxd and nrxd when user value is not power of 2
Attached
Detach File
Event Timeline
Log In to Comment