From 01c2925034311b85a59106349a9bc6be4a463619 Mon Sep 17 00:00:00 2001 From: shurd Date: Fri, 11 May 2018 20:40:26 +0000 Subject: MFC r333329, r333366, r333373 r333329: Fix off-by-one error requesting tx interrupt r333366: Cleanup queues when iflib_device_register fails r333373: Log iflib_tx_structures_setup failure in function Approved by: re (gjb@) Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D15354 --- sys/net/iflib.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 9768ccc..2a0a9c3 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -3269,7 +3269,7 @@ defrag: */ txq->ift_rs_pending += nsegs + 1; if (txq->ift_rs_pending > TXQ_MAX_RS_DEFERRED(txq) || - iflib_no_tx_batch || (TXQ_AVAIL(txq) - nsegs - 1) <= MAX_TX_DESC(ctx)) { + iflib_no_tx_batch || (TXQ_AVAIL(txq) - nsegs) <= MAX_TX_DESC(ctx) + 2) { pi.ipi_flags |= IPI_TX_INTR; txq->ift_rs_pending = 0; } @@ -4342,10 +4342,8 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct goto fail; } - if ((err = iflib_qset_structures_setup(ctx))) { - device_printf(dev, "qset structure setup failed %d\n", err); + if ((err = iflib_qset_structures_setup(ctx))) goto fail_queues; - } /* * Group taskqueues aren't properly set up until SMP is started, * so we disable interrupts until we can handle them post @@ -4392,7 +4390,8 @@ fail_intr_free: if (scctx->isc_intr == IFLIB_INTR_MSIX || scctx->isc_intr == IFLIB_INTR_MSI) pci_release_msi(ctx->ifc_dev); fail_queues: - /* XXX free queues */ + iflib_tx_structures_free(ctx); + iflib_rx_structures_free(ctx); fail: IFDI_DETACH(ctx); return (err); @@ -5003,14 +5002,18 @@ iflib_qset_structures_setup(if_ctx_t ctx) { int err; - if ((err = iflib_tx_structures_setup(ctx)) != 0) + /* + * It is expected that the caller takes care of freeing queues if this + * fails. + */ + if ((err = iflib_tx_structures_setup(ctx)) != 0) { + device_printf(ctx->ifc_dev, "iflib_tx_structures_setup failed: %d\n", err); return (err); + } - if ((err = iflib_rx_structures_setup(ctx)) != 0) { + if ((err = iflib_rx_structures_setup(ctx)) != 0) device_printf(ctx->ifc_dev, "iflib_rx_structures_setup failed: %d\n", err); - iflib_tx_structures_free(ctx); - iflib_rx_structures_free(ctx); - } + return (err); } -- cgit v1.1