jcs's openbsd hax
openbsd

Remove MCX_MAX_QUEUES, which was just an arbitrary number we picked, and instead use IF_MAX_VECTORS for arrays and doorbell layout checks, and account for the maximum number of EQs from the device capabilities when determining how many queues to use.

ok dlg@ bluhm@

jmatthew 00a93588 04f2cf2d

+8 -7
+8 -7
sys/dev/pci/if_mcx.c
··· 1 - /* $OpenBSD: if_mcx.c,v 1.120 2025/11/11 17:43:18 bluhm Exp $ */ 1 + /* $OpenBSD: if_mcx.c,v 1.121 2025/11/19 04:58:04 jmatthew Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2017 David Gwynne <dlg@openbsd.org> ··· 90 90 #define MCX_LOG_RQ_SIZE 10 91 91 #define MCX_LOG_SQ_SIZE 11 92 92 93 - #define MCX_MAX_QUEUES 16 94 - 95 93 /* completion event moderation - about 10khz, or 90% of the cq */ 96 94 #define MCX_CQ_MOD_PERIOD 50 97 95 #define MCX_CQ_MOD_COUNTER \ ··· 121 119 #define MCX_WQ_DOORBELL_BASE MCX_PAGE_SIZE/2 122 120 #define MCX_WQ_DOORBELL_STRIDE 64 123 121 /* make sure the doorbells fit */ 124 - CTASSERT(MCX_MAX_QUEUES * MCX_CQ_DOORBELL_STRIDE < MCX_WQ_DOORBELL_BASE); 125 - CTASSERT(MCX_MAX_QUEUES * MCX_WQ_DOORBELL_STRIDE < 122 + CTASSERT(IF_MAX_VECTORS * MCX_CQ_DOORBELL_STRIDE < MCX_WQ_DOORBELL_BASE); 123 + CTASSERT(IF_MAX_VECTORS * MCX_WQ_DOORBELL_STRIDE < 126 124 MCX_DOORBELL_AREA_SIZE - MCX_WQ_DOORBELL_BASE); 127 125 128 126 #define MCX_WQ_DOORBELL_MASK 0xffff ··· 2482 2480 2483 2481 struct mcx_dmamem sc_doorbell_mem; 2484 2482 2483 + int sc_max_eqs; 2485 2484 struct mcx_eq sc_admin_eq; 2486 2485 struct mcx_eq sc_queue_eq; 2487 2486 ··· 2934 2933 2935 2934 msix--; /* admin ops took one */ 2936 2935 sc->sc_intrmap = intrmap_create(&sc->sc_dev, msix, 2937 - MIN(MCX_MAX_QUEUES, IF_MAX_VECTORS), INTRMAP_POWEROF2); 2936 + MIN(sc->sc_max_eqs, IF_MAX_VECTORS), INTRMAP_POWEROF2); 2938 2937 if (sc->sc_intrmap == NULL) { 2939 2938 printf(": unable to create interrupt map\n"); 2940 2939 goto teardown; ··· 4045 4044 4046 4045 sc->sc_mhz = bemtoh32(&hca->device_frequency_mhz); 4047 4046 sc->sc_khz = bemtoh32(&hca->device_frequency_khz); 4047 + 4048 + sc->sc_max_eqs = 1 << (hca->log_max_eq & MCX_CAP_DEVICE_LOG_MAX_EQ); 4048 4049 4049 4050 free: 4050 4051 mcx_dmamem_free(sc, &mxm); ··· 7303 7304 struct mcx_flow_match match_crit; 7304 7305 struct mcx_rss_rule *rss; 7305 7306 uint32_t dest; 7306 - int rqns[MCX_MAX_QUEUES]; 7307 + int rqns[IF_MAX_VECTORS]; 7307 7308 7308 7309 if (mcx_create_tis(sc, &sc->sc_tis) != 0) 7309 7310 goto down;