diff options
author | Mark Johnston <markj@FreeBSD.org> | 2020-12-07 14:52:57 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2020-12-07 14:52:57 +0000 |
commit | 102540192c7195c99722869a11a48868e9116e91 (patch) | |
tree | 5416a512f12b569a848d554aff34a2c77e92e16e /sys | |
parent | 9de6a13e0f492954612bb7d9752bdd3a1102d17a (diff) | |
download | src-test2-102540192c7195c99722869a11a48868e9116e91.tar.gz src-test2-102540192c7195c99722869a11a48868e9116e91.zip |
iflib: Detach tasks upon device registration failure
In some error paths we would fail to detach from the iflib taskqueue
groups. Also move the detach code into its own subroutine instead of
duplicating it.
Submitted by: Sai Rajesh Tallamraju <stallamr@netapp.com>
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27342
Notes
Notes:
svn path=/head/; revision=368411
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/iflib.c | 89 |
1 files changed, 34 insertions, 55 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 9e7bc7f57b71..45f0cf58d87f 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -142,6 +142,7 @@ struct iflib_ctx; static void iru_init(if_rxd_update_t iru, iflib_rxq_t rxq, uint8_t flid); static void iflib_timer(void *arg); +static void iflib_tqg_detach(if_ctx_t ctx); typedef struct iflib_filter_info { driver_filter_t *ifi_filter; @@ -4842,7 +4843,7 @@ fail_intr_free: fail_queues: iflib_tx_structures_free(ctx); iflib_rx_structures_free(ctx); - taskqgroup_detach(qgroup_if_config_tqg, &ctx->ifc_admin_task); + iflib_tqg_detach(ctx); IFDI_DETACH(ctx); fail_unlock: CTX_UNLOCK(ctx); @@ -5042,6 +5043,7 @@ fail_detach: fail_queues: iflib_tx_structures_free(ctx); iflib_rx_structures_free(ctx); + iflib_tqg_detach(ctx); fail_iflib_detach: IFDI_DETACH(ctx); fail_unlock: @@ -5058,11 +5060,6 @@ iflib_pseudo_deregister(if_ctx_t ctx) { if_t ifp = ctx->ifc_ifp; if_shared_ctx_t sctx = ctx->ifc_sctx; - iflib_txq_t txq; - iflib_rxq_t rxq; - int i, j; - struct taskqgroup *tqg; - iflib_fl_t fl; /* Unregister VLAN event handlers early */ iflib_unregister_vlan_handlers(ctx); @@ -5074,30 +5071,8 @@ iflib_pseudo_deregister(if_ctx_t ctx) } else { ether_ifdetach(ifp); } - /* XXX drain any dependent tasks */ - tqg = qgroup_if_io_tqg; - for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) { - callout_drain(&txq->ift_timer); -#ifdef DEV_NETMAP - callout_drain(&txq->ift_netmap_timer); -#endif /* DEV_NETMAP */ - if (txq->ift_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &txq->ift_task); - } - for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) { - callout_drain(&rxq->ifr_watchdog); - if (rxq->ifr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &rxq->ifr_task); - - for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++) - free(fl->ifl_rx_bitmap, M_IFLIB); - } - tqg = qgroup_if_config_tqg; - if (ctx->ifc_admin_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &ctx->ifc_admin_task); - if (ctx->ifc_vflr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &ctx->ifc_vflr_task); + iflib_tqg_detach(ctx); iflib_tx_structures_free(ctx); iflib_rx_structures_free(ctx); @@ -5127,12 +5102,7 @@ int iflib_device_deregister(if_ctx_t ctx) { if_t ifp = ctx->ifc_ifp; - iflib_txq_t txq; - iflib_rxq_t rxq; device_t dev = ctx->ifc_dev; - int i, j; - struct taskqgroup *tqg; - iflib_fl_t fl; /* Make sure VLANS are not using driver */ if (if_vlantrunkinuse(ifp)) { @@ -5163,28 +5133,8 @@ iflib_device_deregister(if_ctx_t ctx) iflib_rem_pfil(ctx); if (ctx->ifc_led_dev != NULL) led_destroy(ctx->ifc_led_dev); - /* XXX drain any dependent tasks */ - tqg = qgroup_if_io_tqg; - for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) { - callout_drain(&txq->ift_timer); -#ifdef DEV_NETMAP - callout_drain(&txq->ift_netmap_timer); -#endif /* DEV_NETMAP */ - if (txq->ift_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &txq->ift_task); - } - for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) { - if (rxq->ifr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &rxq->ifr_task); - for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++) - free(fl->ifl_rx_bitmap, M_IFLIB); - } - tqg = qgroup_if_config_tqg; - if (ctx->ifc_admin_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &ctx->ifc_admin_task); - if (ctx->ifc_vflr_task.gt_uniq != NULL) - taskqgroup_detach(tqg, &ctx->ifc_vflr_task); + iflib_tqg_detach(ctx); CTX_LOCK(ctx); IFDI_DETACH(ctx); CTX_UNLOCK(ctx); @@ -5208,6 +5158,35 @@ iflib_device_deregister(if_ctx_t ctx) } static void +iflib_tqg_detach(if_ctx_t ctx) +{ + iflib_txq_t txq; + iflib_rxq_t rxq; + int i; + struct taskqgroup *tqg; + + /* XXX drain any dependent tasks */ + tqg = qgroup_if_io_tqg; + for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) { + callout_drain(&txq->ift_timer); +#ifdef DEV_NETMAP + callout_drain(&txq->ift_netmap_timer); +#endif /* DEV_NETMAP */ + if (txq->ift_task.gt_uniq != NULL) + taskqgroup_detach(tqg, &txq->ift_task); + } + for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) { + if (rxq->ifr_task.gt_uniq != NULL) + taskqgroup_detach(tqg, &rxq->ifr_task); + } + tqg = qgroup_if_config_tqg; + if (ctx->ifc_admin_task.gt_uniq != NULL) + taskqgroup_detach(tqg, &ctx->ifc_admin_task); + if (ctx->ifc_vflr_task.gt_uniq != NULL) + taskqgroup_detach(tqg, &ctx->ifc_vflr_task); +} + +static void iflib_free_intr_mem(if_ctx_t ctx) { |