[PATCH v1 5/6] iflib.c: Deactivate use of ifc_cpus

Jan Sommer jan.sommer at dlr.de
Fri Aug 14 19:57:52 UTC 2020


- cpusets and SMP are currently not supported in libbsd for RTEMS
- Disable the ifc_cpus context variable and replace its usage,
essentially hard-coding for cpu 0
---
 freebsd/sys/dev/e1000/if_em.c |  6 ++++++
 freebsd/sys/net/iflib.c       | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/freebsd/sys/dev/e1000/if_em.c b/freebsd/sys/dev/e1000/if_em.c
index 32eb4afe..4fc6e7b6 100644
--- a/freebsd/sys/dev/e1000/if_em.c
+++ b/freebsd/sys/dev/e1000/if_em.c
@@ -1837,8 +1837,14 @@ em_if_update_admin_status(if_ctx_t ctx)
 
 	if (adapter->hw.mac.type < em_mac_min)
 		lem_smartspeed(adapter);
+#ifdef __rtems__
+	else if (hw->mac.type == e1000_82574 &&
+			adapter->intr_type == IFLIB_INTR_MSIX)
+		E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_LINK | E1000_IMS_LSC);
+#else /* __rtems__ */
 
 	E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_LINK | E1000_IMS_LSC);
+#endif /* __rtems__ */
 }
 
 static void
diff --git a/freebsd/sys/net/iflib.c b/freebsd/sys/net/iflib.c
index 7183e1e5..733172dc 100644
--- a/freebsd/sys/net/iflib.c
+++ b/freebsd/sys/net/iflib.c
@@ -159,7 +159,9 @@ struct iflib_ctx {
 	device_t ifc_dev;
 	if_t ifc_ifp;
 
+#ifndef __rtems__
 	cpuset_t ifc_cpus;
+#endif /* __rtems__ */
 	if_shared_ctx_t ifc_sctx;
 	struct if_softc_ctx ifc_softc_ctx;
 
@@ -4498,6 +4500,7 @@ get_ctx_core_offset(if_ctx_t ctx)
 		qc = max(scctx->isc_ntxqsets, scctx->isc_nrxqsets);
 
 	mtx_lock(&cpu_offset_mtx);
+#ifndef __rtems__
 	SLIST_FOREACH(op, &cpu_offsets, entries) {
 		if (CPU_CMP(&ctx->ifc_cpus, &op->set) == 0) {
 			ret = op->offset;
@@ -4507,6 +4510,7 @@ get_ctx_core_offset(if_ctx_t ctx)
 			break;
 		}
 	}
+#endif /* __rtems__ */
 	if (ret == CORE_OFFSET_UNSPECIFIED) {
 		ret = 0;
 		op = malloc(sizeof(struct cpu_offset), M_IFLIB,
@@ -4517,7 +4521,9 @@ get_ctx_core_offset(if_ctx_t ctx)
 		} else {
 			op->offset = qc;
 			op->refcount = 1;
+#ifndef __rtems__
 			CPU_COPY(&ctx->ifc_cpus, &op->set);
+#endif /* __rtems__ */
 			SLIST_INSERT_HEAD(&cpu_offsets, op, entries);
 		}
 	}
@@ -4533,7 +4539,11 @@ unref_ctx_core_offset(if_ctx_t ctx)
 
 	mtx_lock(&cpu_offset_mtx);
 	SLIST_FOREACH_SAFE(op, &cpu_offsets, entries, top) {
+#ifndef __rtems__
 		if (CPU_CMP(&ctx->ifc_cpus, &op->set) == 0) {
+#else /* __rtems__ */
+		{
+#endif /* __rtems__ */
 			MPASS(op->refcount > 0);
 			op->refcount--;
 			if (op->refcount == 0) {
@@ -4647,12 +4657,14 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct
 	taskqgroup_attach(qgroup_if_config_tqg, &ctx->ifc_admin_task, ctx,
 	    NULL, NULL, "admin");
 
+#ifndef __rtems__
 	/* Set up cpu set.  If it fails, use the set of all CPUs. */
 	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);
+#endif /* __rtems__ */
 
 	/*
 	** Now set up MSI or MSI-X, should return us the number of supported
@@ -5484,7 +5496,9 @@ iflib_queues_alloc(if_ctx_t ctx)
 			txq->ift_br_offset = 0;
 		}
 		/* XXX fix this */
+#ifndef __rtems__
 		txq->ift_timer.c_cpu = cpu;
+#endif /* __rtems__ */
 
 		if (iflib_txsd_alloc(txq)) {
 			device_printf(dev, "Critical Failure setting up TX buffers\n");
@@ -6291,11 +6305,19 @@ iflib_msix_init(if_ctx_t ctx)
 #else
 	queues = queuemsgs;
 #endif
+#ifndef __rtems__
 	queues = imin(CPU_COUNT(&ctx->ifc_cpus), queues);
+#else /* __rtems__ */
+	queues = imin(1, queues);
+#endif /* __rtems__ */
 	if (bootverbose)
 		device_printf(dev,
 		    "intr CPUs: %d queue msgs: %d admincnt: %d\n",
+#ifndef __rtems__
 		    CPU_COUNT(&ctx->ifc_cpus), queuemsgs, admincnt);
+#else /* __rtems__ */
+		    1, queuemsgs, admincnt);
+#endif /* __rtems__ */
 #ifdef  RSS
 	/* If we're doing RSS, clamp at the number of RSS buckets */
 	if (queues > rss_getnumbuckets())
-- 
2.17.1



More information about the devel mailing list