Changeset View
Changeset View
Standalone View
Standalone View
sys/net/iflib.c
Show First 20 Lines • Show All 520 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Only allow a single packet to take up most 1/nth of the tx ring | * Only allow a single packet to take up most 1/nth of the tx ring | ||||
*/ | */ | ||||
#define MAX_SINGLE_PACKET_FRACTION 12 | #define MAX_SINGLE_PACKET_FRACTION 12 | ||||
#define IF_BAD_DMA (bus_addr_t)-1 | #define IF_BAD_DMA (bus_addr_t)-1 | ||||
#define CTX_ACTIVE(ctx) ((if_getdrvflags((ctx)->ifc_ifp) & IFF_DRV_RUNNING)) | #define CTX_ACTIVE(ctx) ((if_getdrvflags((ctx)->ifc_ifp) & IFF_DRV_RUNNING)) | ||||
/* | |||||
#define CTX_LOCK_INIT(_sc, _name) mtx_init(&(_sc)->ifc_mtx, _name, "iflib ctx lock", MTX_DEF) | |||||
#define CTX_LOCK(ctx) mtx_lock(&(ctx)->ifc_mtx) | |||||
#define CTX_UNLOCK(ctx) mtx_unlock(&(ctx)->ifc_mtx) | |||||
#define CTX_LOCK_DESTROY(ctx) mtx_destroy(&(ctx)->ifc_mtx) | |||||
*/ | |||||
#define CTX_LOCK_INIT(_sc, _name) sx_init(&(_sc)->ifc_sx, _name) | #define CTX_LOCK_INIT(_sc, _name) sx_init(&(_sc)->ifc_sx, _name) | ||||
#define CTX_LOCK(ctx) sx_xlock(&(ctx)->ifc_sx) | #define CTX_LOCK(ctx) sx_xlock(&(ctx)->ifc_sx) | ||||
#define CTX_UNLOCK(ctx) sx_xunlock(&(ctx)->ifc_sx) | #define CTX_UNLOCK(ctx) sx_xunlock(&(ctx)->ifc_sx) | ||||
#define CTX_LOCK_DESTROY(ctx) sx_destroy(&(ctx)->ifc_sx) | #define CTX_LOCK_DESTROY(ctx) sx_destroy(&(ctx)->ifc_sx) | ||||
#define CALLOUT_LOCK(txq) mtx_lock(&txq->ift_mtx) | #define CALLOUT_LOCK(txq) mtx_lock(&txq->ift_mtx) | ||||
#define CALLOUT_UNLOCK(txq) mtx_unlock(&txq->ift_mtx) | #define CALLOUT_UNLOCK(txq) mtx_unlock(&txq->ift_mtx) | ||||
▲ Show 20 Lines • Show All 1,982 Lines • ▼ Show 20 Lines | |||||
callout_reset_on(&txq->ift_timer, hz/2, iflib_timer, | callout_reset_on(&txq->ift_timer, hz/2, iflib_timer, | ||||
txq, txq->ift_timer.c_cpu); | txq, txq->ift_timer.c_cpu); | ||||
IFDI_LINK_INTR_ENABLE(ctx); | IFDI_LINK_INTR_ENABLE(ctx); | ||||
} | } | ||||
if (ctx->ifc_flags & IFC_DO_RESET) { | if (ctx->ifc_flags & IFC_DO_RESET) { | ||||
ctx->ifc_flags &= ~IFC_DO_RESET; | ctx->ifc_flags &= ~IFC_DO_RESET; | ||||
iflib_if_init_locked(ctx); | iflib_if_init_locked(ctx); | ||||
} | } | ||||
IFDI_UPDATE_ADMIN_STATUS(ctx); | |||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
IFDI_UPDATE_ADMIN_STATUS(ctx); | |||||
if (LINK_ACTIVE(ctx) == 0 || !running) | if (LINK_ACTIVE(ctx) == 0 || !running) | ||||
return; | return; | ||||
for (txq = ctx->ifc_txqs, i = 0; i < sctx->isc_ntxqsets; i++, txq++) | for (txq = ctx->ifc_txqs, i = 0; i < sctx->isc_ntxqsets; i++, txq++) | ||||
iflib_txq_check_drain(txq, IFLIB_RESTART_BUDGET); | iflib_txq_check_drain(txq, IFLIB_RESTART_BUDGET); | ||||
} | } | ||||
/* CONFIG context only */ | /* CONFIG context only */ | ||||
▲ Show 20 Lines • Show All 489 Lines • ▼ Show 20 Lines | |||||
scctx->isc_ntxd[i] = sctx->isc_ntxd_min[i]; | scctx->isc_ntxd[i] = sctx->isc_ntxd_min[i]; | ||||
} | } | ||||
if (scctx->isc_ntxd[i] > sctx->isc_ntxd_max[i]) { | if (scctx->isc_ntxd[i] > sctx->isc_ntxd_max[i]) { | ||||
device_printf(dev, "ntxd%d: %d greater than ntxd_max %d - resetting to max\n", | device_printf(dev, "ntxd%d: %d greater than ntxd_max %d - resetting to max\n", | ||||
i, scctx->isc_ntxd[i], sctx->isc_ntxd_max[i]); | i, scctx->isc_ntxd[i], sctx->isc_ntxd_max[i]); | ||||
scctx->isc_ntxd[i] = sctx->isc_ntxd_max[i]; | scctx->isc_ntxd[i] = sctx->isc_ntxd_max[i]; | ||||
} | } | ||||
} | } | ||||
CTX_LOCK(ctx); | |||||
if ((err = IFDI_ATTACH_PRE(ctx)) != 0) { | err = IFDI_ATTACH_PRE(ctx); | ||||
CTX_UNLOCK(ctx); | |||||
if (err) { | |||||
device_printf(dev, "IFDI_ATTACH_PRE failed %d\n", err); | device_printf(dev, "IFDI_ATTACH_PRE failed %d\n", err); | ||||
return (err); | return (err); | ||||
} | } | ||||
_iflib_pre_assert(scctx); | _iflib_pre_assert(scctx); | ||||
ctx->ifc_txrx = *scctx->isc_txrx; | ctx->ifc_txrx = *scctx->isc_txrx; | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
MPASS(scctx->isc_capenable); | MPASS(scctx->isc_capenable); | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
rid = 1; | rid = 1; | ||||
} | } | ||||
if ((err = iflib_legacy_setup(ctx, ctx->isc_legacy_intr, ctx->ifc_softc, &rid, "irq0")) != 0) { | if ((err = iflib_legacy_setup(ctx, ctx->isc_legacy_intr, ctx->ifc_softc, &rid, "irq0")) != 0) { | ||||
device_printf(dev, "iflib_legacy_setup failed %d\n", err); | device_printf(dev, "iflib_legacy_setup failed %d\n", err); | ||||
goto fail_intr_free; | goto fail_intr_free; | ||||
} | } | ||||
} | } | ||||
ether_ifattach(ctx->ifc_ifp, ctx->ifc_mac); | ether_ifattach(ctx->ifc_ifp, ctx->ifc_mac); | ||||
if ((err = IFDI_ATTACH_POST(ctx)) != 0) { | CTX_LOCK(ctx); | ||||
err = IFDI_ATTACH_POST(ctx); | |||||
CTX_UNLOCK(ctx); | |||||
if (err) { | |||||
device_printf(dev, "IFDI_ATTACH_POST failed %d\n", err); | device_printf(dev, "IFDI_ATTACH_POST failed %d\n", err); | ||||
goto fail_detach; | goto fail_detach; | ||||
} | } | ||||
if ((err = iflib_netmap_attach(ctx))) { | if ((err = iflib_netmap_attach(ctx))) { | ||||
device_printf(ctx->ifc_dev, "netmap attach failed: %d\n", err); | device_printf(ctx->ifc_dev, "netmap attach failed: %d\n", err); | ||||
goto fail_detach; | goto fail_detach; | ||||
} | } | ||||
*ctxp = ctx; | *ctxp = ctx; | ||||
▲ Show 20 Lines • Show All 943 Lines • ▼ Show 20 Lines | |||||
if (err) | if (err) | ||||
log(LOG_WARNING, "IFDI_PROMISC_SET returned %d\n", err); | log(LOG_WARNING, "IFDI_PROMISC_SET returned %d\n", err); | ||||
} | } | ||||
static void | static void | ||||
async_gtask(void *ctx) | async_gtask(void *ctx) | ||||
{ | { | ||||
struct async_task_arg *at_arg = ctx; | struct async_task_arg *at_arg = ctx; | ||||
if_ctx_t if_ctx = at_arg->ata_ctx; | if_ctx_t if_ctx = at_arg->ata_ctx; | ||||
hselasky: Remember that using SX over MTX affects priority resolution when the mutex is congested ??? | |||||
Not Done Inline ActionsNot relevant for infrequent long running configuration operations. kmacy: Not relevant for infrequent long running configuration operations. | |||||
void *arg = at_arg->ata_arg; | void *arg = at_arg->ata_arg; | ||||
at_arg->ata_fn(if_ctx, arg); | at_arg->ata_fn(if_ctx, arg); | ||||
taskqgroup_detach(qgroup_if_config_tqg, at_arg->ata_gtask); | taskqgroup_detach(qgroup_if_config_tqg, at_arg->ata_gtask); | ||||
free(at_arg->ata_gtask, M_IFLIB); | free(at_arg->ata_gtask, M_IFLIB); | ||||
} | } | ||||
static int | static int | ||||
Show All 31 Lines |
Remember that using SX over MTX affects priority resolution when the mutex is congested ???