Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/iflib.c
Show First 20 Lines • Show All 696 Lines • ▼ Show 20 Lines | |||||
static int iflib_legacy_setup(if_ctx_t ctx, driver_filter_t filter, void *filterarg, int *rid, const char *str); | static int iflib_legacy_setup(if_ctx_t ctx, driver_filter_t filter, void *filterarg, int *rid, const char *str); | ||||
static void iflib_txq_check_drain(iflib_txq_t txq, int budget); | static void iflib_txq_check_drain(iflib_txq_t txq, int budget); | ||||
static uint32_t iflib_txq_can_drain(struct ifmp_ring *); | static uint32_t iflib_txq_can_drain(struct ifmp_ring *); | ||||
#ifdef ALTQ | #ifdef ALTQ | ||||
static void iflib_altq_if_start(if_t ifp); | static void iflib_altq_if_start(if_t ifp); | ||||
static int iflib_altq_if_transmit(if_t ifp, struct mbuf *m); | static int iflib_altq_if_transmit(if_t ifp, struct mbuf *m); | ||||
#endif | #endif | ||||
static int iflib_register(if_ctx_t); | static int iflib_register(if_ctx_t); | ||||
static void iflib_deregister(if_ctx_t); | |||||
static void iflib_init_locked(if_ctx_t ctx); | static void iflib_init_locked(if_ctx_t ctx); | ||||
static void iflib_add_device_sysctl_pre(if_ctx_t ctx); | static void iflib_add_device_sysctl_pre(if_ctx_t ctx); | ||||
static void iflib_add_device_sysctl_post(if_ctx_t ctx); | static void iflib_add_device_sysctl_post(if_ctx_t ctx); | ||||
static void iflib_ifmp_purge(iflib_txq_t txq); | static void iflib_ifmp_purge(iflib_txq_t txq); | ||||
static void _iflib_pre_assert(if_softc_ctx_t scctx); | static void _iflib_pre_assert(if_softc_ctx_t scctx); | ||||
static void iflib_if_init_locked(if_ctx_t ctx); | static void iflib_if_init_locked(if_ctx_t ctx); | ||||
static void iflib_free_intr_mem(if_ctx_t ctx); | static void iflib_free_intr_mem(if_ctx_t ctx); | ||||
#ifndef __NO_STRICT_ALIGNMENT | #ifndef __NO_STRICT_ALIGNMENT | ||||
▲ Show 20 Lines • Show All 4,072 Lines • ▼ Show 20 Lines | fail_intr_free: | ||||
iflib_free_intr_mem(ctx); | iflib_free_intr_mem(ctx); | ||||
fail_queues: | fail_queues: | ||||
iflib_tx_structures_free(ctx); | iflib_tx_structures_free(ctx); | ||||
iflib_rx_structures_free(ctx); | iflib_rx_structures_free(ctx); | ||||
taskqgroup_detach(qgroup_if_config_tqg, &ctx->ifc_admin_task); | taskqgroup_detach(qgroup_if_config_tqg, &ctx->ifc_admin_task); | ||||
IFDI_DETACH(ctx); | IFDI_DETACH(ctx); | ||||
fail_unlock: | fail_unlock: | ||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
iflib_deregister(ctx); | |||||
fail_ctx_free: | fail_ctx_free: | ||||
device_set_softc(ctx->ifc_dev, NULL); | device_set_softc(ctx->ifc_dev, NULL); | ||||
if (ctx->ifc_flags & IFC_SC_ALLOCATED) | if (ctx->ifc_flags & IFC_SC_ALLOCATED) | ||||
free(ctx->ifc_softc, M_IFLIB); | free(ctx->ifc_softc, M_IFLIB); | ||||
free(ctx, M_IFLIB); | free(ctx, M_IFLIB); | ||||
return (err); | return (err); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | fail_detach: | ||||
ether_ifdetach(ctx->ifc_ifp); | ether_ifdetach(ctx->ifc_ifp); | ||||
fail_queues: | fail_queues: | ||||
iflib_tx_structures_free(ctx); | iflib_tx_structures_free(ctx); | ||||
iflib_rx_structures_free(ctx); | iflib_rx_structures_free(ctx); | ||||
fail_iflib_detach: | fail_iflib_detach: | ||||
IFDI_DETACH(ctx); | IFDI_DETACH(ctx); | ||||
fail_unlock: | fail_unlock: | ||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
iflib_deregister(ctx); | |||||
fail_ctx_free: | fail_ctx_free: | ||||
free(ctx->ifc_softc, M_IFLIB); | free(ctx->ifc_softc, M_IFLIB); | ||||
free(ctx, M_IFLIB); | free(ctx, M_IFLIB); | ||||
return (err); | return (err); | ||||
} | } | ||||
int | int | ||||
iflib_pseudo_deregister(if_ctx_t ctx) | iflib_pseudo_deregister(if_ctx_t ctx) | ||||
{ | { | ||||
if_t ifp = ctx->ifc_ifp; | if_t ifp = ctx->ifc_ifp; | ||||
iflib_txq_t txq; | iflib_txq_t txq; | ||||
iflib_rxq_t rxq; | iflib_rxq_t rxq; | ||||
int i, j; | int i, j; | ||||
struct taskqgroup *tqg; | struct taskqgroup *tqg; | ||||
iflib_fl_t fl; | iflib_fl_t fl; | ||||
/* Unregister VLAN events */ | |||||
if (ctx->ifc_vlan_attach_event != NULL) | |||||
EVENTHANDLER_DEREGISTER(vlan_config, ctx->ifc_vlan_attach_event); | |||||
if (ctx->ifc_vlan_detach_event != NULL) | |||||
EVENTHANDLER_DEREGISTER(vlan_unconfig, ctx->ifc_vlan_detach_event); | |||||
ether_ifdetach(ifp); | ether_ifdetach(ifp); | ||||
/* ether_ifdetach calls if_qflush - lock must be destroy afterwards*/ | |||||
CTX_LOCK_DESTROY(ctx); | |||||
/* XXX drain any dependent tasks */ | /* XXX drain any dependent tasks */ | ||||
tqg = qgroup_if_io_tqg; | tqg = qgroup_if_io_tqg; | ||||
for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) { | for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) { | ||||
callout_drain(&txq->ift_timer); | callout_drain(&txq->ift_timer); | ||||
if (txq->ift_task.gt_uniq != NULL) | if (txq->ift_task.gt_uniq != NULL) | ||||
taskqgroup_detach(tqg, &txq->ift_task); | taskqgroup_detach(tqg, &txq->ift_task); | ||||
} | } | ||||
for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) { | for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) { | ||||
if (rxq->ifr_task.gt_uniq != NULL) | if (rxq->ifr_task.gt_uniq != NULL) | ||||
taskqgroup_detach(tqg, &rxq->ifr_task); | taskqgroup_detach(tqg, &rxq->ifr_task); | ||||
for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++) | for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++) | ||||
free(fl->ifl_rx_bitmap, M_IFLIB); | free(fl->ifl_rx_bitmap, M_IFLIB); | ||||
} | } | ||||
tqg = qgroup_if_config_tqg; | tqg = qgroup_if_config_tqg; | ||||
if (ctx->ifc_admin_task.gt_uniq != NULL) | if (ctx->ifc_admin_task.gt_uniq != NULL) | ||||
taskqgroup_detach(tqg, &ctx->ifc_admin_task); | taskqgroup_detach(tqg, &ctx->ifc_admin_task); | ||||
if (ctx->ifc_vflr_task.gt_uniq != NULL) | if (ctx->ifc_vflr_task.gt_uniq != NULL) | ||||
taskqgroup_detach(tqg, &ctx->ifc_vflr_task); | taskqgroup_detach(tqg, &ctx->ifc_vflr_task); | ||||
if_free(ifp); | |||||
iflib_tx_structures_free(ctx); | iflib_tx_structures_free(ctx); | ||||
iflib_rx_structures_free(ctx); | iflib_rx_structures_free(ctx); | ||||
iflib_deregister(ctx); | |||||
if (ctx->ifc_flags & IFC_SC_ALLOCATED) | if (ctx->ifc_flags & IFC_SC_ALLOCATED) | ||||
free(ctx->ifc_softc, M_IFLIB); | free(ctx->ifc_softc, M_IFLIB); | ||||
free(ctx, M_IFLIB); | free(ctx, M_IFLIB); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
iflib_device_attach(device_t dev) | iflib_device_attach(device_t dev) | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | if (ctx->ifc_admin_task.gt_uniq != NULL) | ||||
taskqgroup_detach(tqg, &ctx->ifc_admin_task); | taskqgroup_detach(tqg, &ctx->ifc_admin_task); | ||||
if (ctx->ifc_vflr_task.gt_uniq != NULL) | if (ctx->ifc_vflr_task.gt_uniq != NULL) | ||||
taskqgroup_detach(tqg, &ctx->ifc_vflr_task); | taskqgroup_detach(tqg, &ctx->ifc_vflr_task); | ||||
CTX_LOCK(ctx); | CTX_LOCK(ctx); | ||||
IFDI_DETACH(ctx); | IFDI_DETACH(ctx); | ||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
/* ether_ifdetach calls if_qflush - lock must be destroy afterwards*/ | /* ether_ifdetach calls if_qflush - lock must be destroy afterwards*/ | ||||
CTX_LOCK_DESTROY(ctx); | |||||
device_set_softc(ctx->ifc_dev, NULL); | |||||
iflib_free_intr_mem(ctx); | iflib_free_intr_mem(ctx); | ||||
bus_generic_detach(dev); | bus_generic_detach(dev); | ||||
if_free(ifp); | |||||
iflib_tx_structures_free(ctx); | iflib_tx_structures_free(ctx); | ||||
iflib_rx_structures_free(ctx); | iflib_rx_structures_free(ctx); | ||||
iflib_deregister(ctx); | |||||
device_set_softc(ctx->ifc_dev, NULL); | |||||
if (ctx->ifc_flags & IFC_SC_ALLOCATED) | if (ctx->ifc_flags & IFC_SC_ALLOCATED) | ||||
free(ctx->ifc_softc, M_IFLIB); | free(ctx->ifc_softc, M_IFLIB); | ||||
unref_ctx_core_offset(ctx); | unref_ctx_core_offset(ctx); | ||||
STATE_LOCK_DESTROY(ctx); | |||||
free(ctx, M_IFLIB); | free(ctx, M_IFLIB); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
iflib_free_intr_mem(if_ctx_t ctx) | iflib_free_intr_mem(if_ctx_t ctx) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | EVENTHANDLER_REGISTER(vlan_unconfig, iflib_vlan_unregister, ctx, | ||||
EVENTHANDLER_PRI_FIRST); | EVENTHANDLER_PRI_FIRST); | ||||
if ((sctx->isc_flags & IFLIB_DRIVER_MEDIA) == 0) { | if ((sctx->isc_flags & IFLIB_DRIVER_MEDIA) == 0) { | ||||
ctx->ifc_mediap = &ctx->ifc_media; | ctx->ifc_mediap = &ctx->ifc_media; | ||||
ifmedia_init(ctx->ifc_mediap, IFM_IMASK, | ifmedia_init(ctx->ifc_mediap, IFM_IMASK, | ||||
iflib_media_change, iflib_media_status); | iflib_media_change, iflib_media_status); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | |||||
static void | |||||
iflib_deregister(if_ctx_t ctx) | |||||
{ | |||||
if_t ifp = ctx->ifc_ifp; | |||||
/* Remove all media */ | |||||
ifmedia_removeall(&ctx->ifc_media); | |||||
/* Unregister VLAN events */ | |||||
if (ctx->ifc_vlan_attach_event != NULL) { | |||||
EVENTHANDLER_DEREGISTER(vlan_config, ctx->ifc_vlan_attach_event); | |||||
ctx->ifc_vlan_attach_event = NULL; | |||||
} | |||||
if (ctx->ifc_vlan_detach_event != NULL) { | |||||
EVENTHANDLER_DEREGISTER(vlan_unconfig, ctx->ifc_vlan_detach_event); | |||||
ctx->ifc_vlan_detach_event = NULL; | |||||
} | |||||
/* Release kobject reference */ | |||||
kobj_delete((kobj_t) ctx, NULL); | |||||
/* Free the ifnet structure */ | |||||
if_free(ifp); | |||||
STATE_LOCK_DESTROY(ctx); | |||||
/* ether_ifdetach calls if_qflush - lock must be destroy afterwards*/ | |||||
CTX_LOCK_DESTROY(ctx); | |||||
} | } | ||||
static int | static int | ||||
iflib_queues_alloc(if_ctx_t ctx) | iflib_queues_alloc(if_ctx_t ctx) | ||||
{ | { | ||||
if_shared_ctx_t sctx = ctx->ifc_sctx; | if_shared_ctx_t sctx = ctx->ifc_sctx; | ||||
if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | ||||
device_t dev = ctx->ifc_dev; | device_t dev = ctx->ifc_dev; | ||||
▲ Show 20 Lines • Show All 1,390 Lines • Show Last 20 Lines |