svn commit: r326369 - head/sys/net
Stephen Hurd
shurd at FreeBSD.org
Wed Nov 29 18:14:58 UTC 2017
Author: shurd
Date: Wed Nov 29 18:14:57 2017
New Revision: 326369
URL: https://svnweb.freebsd.org/changeset/base/326369
Log:
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
Modified:
head/sys/net/iflib.c
Modified: head/sys/net/iflib.c
==============================================================================
--- head/sys/net/iflib.c Wed Nov 29 14:45:28 2017 (r326368)
+++ head/sys/net/iflib.c Wed Nov 29 18:14:57 2017 (r326369)
@@ -4259,6 +4259,14 @@ iflib_device_register(device_t dev, void *sc, if_share
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())
More information about the svn-src-all
mailing list