diff options
author | Stephen Hurd <shurd@FreeBSD.org> | 2017-11-29 18:14:57 +0000 |
---|---|---|
committer | Stephen Hurd <shurd@FreeBSD.org> | 2017-11-29 18:14:57 +0000 |
commit | e516b5353bb4fabfe3767a07008320f731b745b3 (patch) | |
tree | ecfc5058d9366f0972489b9eb510527139d0b681 /sys/net | |
parent | 1084894f803be10fb616f5422cb0d1009206284a (diff) | |
download | src-e516b5353bb4fabfe3767a07008320f731b745b3.tar.gz src-e516b5353bb4fabfe3767a07008320f731b745b3.zip |
Ensure that ctx->ifc_cpus is always initialized
If a device didn't support MSI-X, ctx->ifc_cpus would not be initialized,
but the IRQ allocation routines still uses the value. Move the
initialization to common code.
Sponsored by: Limelight Networks
Notes
Notes:
svn path=/head/; revision=326369
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/iflib.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c index c1ee25d5c0d4..2175bab7194c 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -4259,6 +4259,14 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct GROUPTASK_INIT(&ctx->ifc_admin_task, 0, _task_fn_admin, ctx); /* XXX format name */ taskqgroup_attach(qgroup_if_config_tqg, &ctx->ifc_admin_task, ctx, -1, "admin"); + + /* Set up cpu set. If it fails, zero out the set. */ + if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) != 0) { + device_printf(dev, "Unable to fetch CPU list\n"); + CPU_COPY(&all_cpus, &ctx->ifc_cpus); + } + MPASS(CPU_COUNT(&ctx->ifc_cpus) > 0); + /* ** Now setup MSI or MSI/X, should ** return us the number of supported @@ -4984,7 +4992,7 @@ find_nth(if_ctx_t ctx, cpuset_t *cpus, int qid) int i, cpuid, eqid, count; CPU_COPY(&ctx->ifc_cpus, cpus); - count = CPU_COUNT(&ctx->ifc_cpus); + count = CPU_COUNT(cpus); eqid = qid % count; /* clear up to the qid'th bit */ for (i = 0; i < eqid; i++) { @@ -5391,20 +5399,14 @@ iflib_msix_init(if_ctx_t ctx) #else queuemsgs = msgs - admincnt; #endif - if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) == 0) { #ifdef RSS - queues = imin(queuemsgs, rss_getnumbuckets()); + queues = imin(queuemsgs, rss_getnumbuckets()); #else - queues = queuemsgs; + queues = queuemsgs; #endif - queues = imin(CPU_COUNT(&ctx->ifc_cpus), queues); - device_printf(dev, "pxm cpus: %d queue msgs: %d admincnt: %d\n", - CPU_COUNT(&ctx->ifc_cpus), queuemsgs, admincnt); - } else { - device_printf(dev, "Unable to fetch CPU list\n"); - /* Figure out a reasonable auto config value */ - queues = min(queuemsgs, mp_ncpus); - } + queues = imin(CPU_COUNT(&ctx->ifc_cpus), queues); + device_printf(dev, "pxm cpus: %d queue msgs: %d admincnt: %d\n", + CPU_COUNT(&ctx->ifc_cpus), queuemsgs, admincnt); #ifdef RSS /* If we're doing RSS, clamp at the number of RSS buckets */ if (queues > rss_getnumbuckets()) |