From: Jonathan Matthew Subject: mcx: remove MCX_MAX_QUEUES To: tech@openbsd.org Cc: bluhm@openbsd.org Date: Tue, 18 Nov 2025 17:02:49 +1000 Now that we have IF_MAX_VECTORS as a limit on the number of queues an interface will set up, MCX_MAX_QUEUES is kind of pointless - the relevant limits are the size of the msi-x table and the maximum number of event queues the nic will let us create. This diff removes MCX_MAX_QUEUES, using IF_MAX_VECTORS instead where appropriate, and adds the EQ limit to the calculation. The EQ limit might not ever be the limiting factor as generally the msi-x table is smaller, but it's easy to account for it here. ok? Index: if_mcx.c =================================================================== RCS file: /cvs/src/sys/dev/pci/if_mcx.c,v diff -u -p -r1.120 if_mcx.c --- if_mcx.c 11 Nov 2025 17:43:18 -0000 1.120 +++ if_mcx.c 18 Nov 2025 06:20:34 -0000 @@ -90,8 +90,6 @@ enum mcx_cmdq_slot { #define MCX_LOG_RQ_SIZE 10 #define MCX_LOG_SQ_SIZE 11 -#define MCX_MAX_QUEUES 16 - /* completion event moderation - about 10khz, or 90% of the cq */ #define MCX_CQ_MOD_PERIOD 50 #define MCX_CQ_MOD_COUNTER \ @@ -121,8 +119,8 @@ CTASSERT(ETHER_HDR_LEN + ETHER_VLAN_ENCA #define MCX_WQ_DOORBELL_BASE MCX_PAGE_SIZE/2 #define MCX_WQ_DOORBELL_STRIDE 64 /* make sure the doorbells fit */ -CTASSERT(MCX_MAX_QUEUES * MCX_CQ_DOORBELL_STRIDE < MCX_WQ_DOORBELL_BASE); -CTASSERT(MCX_MAX_QUEUES * MCX_WQ_DOORBELL_STRIDE < +CTASSERT(IF_MAX_VECTORS * MCX_CQ_DOORBELL_STRIDE < MCX_WQ_DOORBELL_BASE); +CTASSERT(IF_MAX_VECTORS * MCX_WQ_DOORBELL_STRIDE < MCX_DOORBELL_AREA_SIZE - MCX_WQ_DOORBELL_BASE); #define MCX_WQ_DOORBELL_MASK 0xffff @@ -2482,6 +2480,7 @@ struct mcx_softc { struct mcx_dmamem sc_doorbell_mem; + int sc_max_eqs; struct mcx_eq sc_admin_eq; struct mcx_eq sc_queue_eq; @@ -2934,7 +2933,7 @@ mcx_attach(struct device *parent, struct msix--; /* admin ops took one */ sc->sc_intrmap = intrmap_create(&sc->sc_dev, msix, - MIN(MCX_MAX_QUEUES, IF_MAX_VECTORS), INTRMAP_POWEROF2); + MIN(sc->sc_max_eqs, IF_MAX_VECTORS), INTRMAP_POWEROF2); if (sc->sc_intrmap == NULL) { printf(": unable to create interrupt map\n"); goto teardown; @@ -4046,6 +4045,8 @@ mcx_hca_max_caps(struct mcx_softc *sc) sc->sc_mhz = bemtoh32(&hca->device_frequency_mhz); sc->sc_khz = bemtoh32(&hca->device_frequency_khz); + sc->sc_max_eqs = 1 << (hca->log_max_eq & MCX_CAP_DEVICE_LOG_MAX_EQ); + free: mcx_dmamem_free(sc, &mxm); @@ -7303,7 +7304,7 @@ mcx_up(struct mcx_softc *sc) struct mcx_flow_match match_crit; struct mcx_rss_rule *rss; uint32_t dest; - int rqns[MCX_MAX_QUEUES]; + int rqns[IF_MAX_VECTORS]; if (mcx_create_tis(sc, &sc->sc_tis) != 0) goto down;