MCPcopy Create free account
hub / github.com/F-Stack/f-stack / iflib_queues_alloc

Function iflib_queues_alloc

freebsd/net/iflib.c:5582–5801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5580}
5581
5582static int
5583iflib_queues_alloc(if_ctx_t ctx)
5584{
5585 if_shared_ctx_t sctx = ctx->ifc_sctx;
5586 if_softc_ctx_t scctx = &ctx->ifc_softc_ctx;
5587 device_t dev = ctx->ifc_dev;
5588 int nrxqsets = scctx->isc_nrxqsets;
5589 int ntxqsets = scctx->isc_ntxqsets;
5590 iflib_txq_t txq;
5591 iflib_rxq_t rxq;
5592 iflib_fl_t fl = NULL;
5593 int i, j, cpu, err, txconf, rxconf;
5594 iflib_dma_info_t ifdip;
5595 uint32_t *rxqsizes = scctx->isc_rxqsizes;
5596 uint32_t *txqsizes = scctx->isc_txqsizes;
5597 uint8_t nrxqs = sctx->isc_nrxqs;
5598 uint8_t ntxqs = sctx->isc_ntxqs;
5599 int nfree_lists = sctx->isc_nfl ? sctx->isc_nfl : 1;
5600 int fl_offset = (sctx->isc_flags & IFLIB_HAS_RXCQ ? 1 : 0);
5601 caddr_t *vaddrs;
5602 uint64_t *paddrs;
5603
5604 KASSERT(ntxqs > 0, ("number of queues per qset must be at least 1"));
5605 KASSERT(nrxqs > 0, ("number of queues per qset must be at least 1"));
5606 KASSERT(nrxqs >= fl_offset + nfree_lists,
5607 ("there must be at least a rxq for each free list"));
5608
5609 /* Allocate the TX ring struct memory */
5610 if (!(ctx->ifc_txqs =
5611 (iflib_txq_t) malloc(sizeof(struct iflib_txq) *
5612 ntxqsets, M_IFLIB, M_NOWAIT | M_ZERO))) {
5613 device_printf(dev, "Unable to allocate TX ring memory\n");
5614 err = ENOMEM;
5615 goto fail;
5616 }
5617
5618 /* Now allocate the RX */
5619 if (!(ctx->ifc_rxqs =
5620 (iflib_rxq_t) malloc(sizeof(struct iflib_rxq) *
5621 nrxqsets, M_IFLIB, M_NOWAIT | M_ZERO))) {
5622 device_printf(dev, "Unable to allocate RX ring memory\n");
5623 err = ENOMEM;
5624 goto rx_fail;
5625 }
5626
5627 txq = ctx->ifc_txqs;
5628 rxq = ctx->ifc_rxqs;
5629
5630 /*
5631 * XXX handle allocation failure
5632 */
5633 for (txconf = i = 0, cpu = CPU_FIRST(); i < ntxqsets; i++, txconf++, txq++, cpu = CPU_NEXT(cpu)) {
5634 /* Set up some basics */
5635
5636 if ((ifdip = malloc(sizeof(struct iflib_dma_info) * ntxqs,
5637 M_IFLIB, M_NOWAIT | M_ZERO)) == NULL) {
5638 device_printf(dev,
5639 "Unable to allocate TX DMA info memory\n");

Callers 2

iflib_device_registerFunction · 0.85
iflib_pseudo_registerFunction · 0.85

Calls 14

mallocFunction · 0.85
device_printfFunction · 0.85
iflib_dma_allocFunction · 0.85
bzeroFunction · 0.85
iflib_txsd_allocFunction · 0.85
snprintfFunction · 0.85
device_get_nameunitFunction · 0.85
mtx_initFunction · 0.85
ifmp_ring_allocFunction · 0.85
iflib_rxsd_allocFunction · 0.85
bit_allocFunction · 0.85
iflib_tx_structures_freeFunction · 0.85

Tested by

no test coverage detected