Changeset View
Changeset View
Standalone View
Standalone View
sys/net/iflib.c
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | struct iflib_ctx { | ||||
struct sx ifc_ctx_sx; | struct sx ifc_ctx_sx; | ||||
struct mtx ifc_state_mtx; | struct mtx ifc_state_mtx; | ||||
iflib_txq_t ifc_txqs; | iflib_txq_t ifc_txqs; | ||||
iflib_rxq_t ifc_rxqs; | iflib_rxq_t ifc_rxqs; | ||||
uint32_t ifc_if_flags; | uint32_t ifc_if_flags; | ||||
uint32_t ifc_flags; | uint32_t ifc_flags; | ||||
uint32_t ifc_max_fl_buf_size; | uint32_t ifc_max_fl_buf_size; | ||||
uint32_t ifc_rx_mbuf_sz; | |||||
int ifc_link_state; | int ifc_link_state; | ||||
int ifc_link_irq; | int ifc_link_irq; | ||||
int ifc_watchdog_events; | int ifc_watchdog_events; | ||||
struct cdev *ifc_led_dev; | struct cdev *ifc_led_dev; | ||||
struct resource *ifc_msix_mem; | struct resource *ifc_msix_mem; | ||||
struct if_irq ifc_legacy_irq; | struct if_irq ifc_legacy_irq; | ||||
▲ Show 20 Lines • Show All 1,985 Lines • ▼ Show 20 Lines | |||||
* Initialize a receive ring and its buffers. | * Initialize a receive ring and its buffers. | ||||
* | * | ||||
**********************************************************************/ | **********************************************************************/ | ||||
static int | static int | ||||
iflib_fl_setup(iflib_fl_t fl) | iflib_fl_setup(iflib_fl_t fl) | ||||
{ | { | ||||
iflib_rxq_t rxq = fl->ifl_rxq; | iflib_rxq_t rxq = fl->ifl_rxq; | ||||
if_ctx_t ctx = rxq->ifr_ctx; | if_ctx_t ctx = rxq->ifr_ctx; | ||||
if_softc_ctx_t sctx = &ctx->ifc_softc_ctx; | |||||
bit_nclear(fl->ifl_rx_bitmap, 0, fl->ifl_size - 1); | bit_nclear(fl->ifl_rx_bitmap, 0, fl->ifl_size - 1); | ||||
/* | /* | ||||
** Free current RX buffer structs and their mbufs | ** Free current RX buffer structs and their mbufs | ||||
*/ | */ | ||||
iflib_fl_bufs_free(fl); | iflib_fl_bufs_free(fl); | ||||
/* Now replenish the mbufs */ | /* Now replenish the mbufs */ | ||||
MPASS(fl->ifl_credits == 0); | MPASS(fl->ifl_credits == 0); | ||||
/* | fl->ifl_buf_size = ctx->ifc_rx_mbuf_sz; | ||||
* XXX don't set the max_frame_size to larger | |||||
* than the hardware can handle | |||||
*/ | |||||
if (sctx->isc_max_frame_size <= 2048) | |||||
fl->ifl_buf_size = MCLBYTES; | |||||
else | |||||
fl->ifl_buf_size = MJUMPAGESIZE; | |||||
if (fl->ifl_buf_size > ctx->ifc_max_fl_buf_size) | if (fl->ifl_buf_size > ctx->ifc_max_fl_buf_size) | ||||
ctx->ifc_max_fl_buf_size = fl->ifl_buf_size; | ctx->ifc_max_fl_buf_size = fl->ifl_buf_size; | ||||
fl->ifl_cltype = m_gettype(fl->ifl_buf_size); | fl->ifl_cltype = m_gettype(fl->ifl_buf_size); | ||||
fl->ifl_zone = m_getzone(fl->ifl_buf_size); | fl->ifl_zone = m_getzone(fl->ifl_buf_size); | ||||
/* avoid pre-allocating zillions of clusters to an idle card | /* avoid pre-allocating zillions of clusters to an idle card | ||||
* potentially speeding up attach | * potentially speeding up attach | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | hung: | ||||
STATE_LOCK(ctx); | STATE_LOCK(ctx); | ||||
if_setdrvflagbits(ctx->ifc_ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING); | if_setdrvflagbits(ctx->ifc_ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING); | ||||
ctx->ifc_flags |= (IFC_DO_WATCHDOG|IFC_DO_RESET); | ctx->ifc_flags |= (IFC_DO_WATCHDOG|IFC_DO_RESET); | ||||
iflib_admin_intr_deferred(ctx); | iflib_admin_intr_deferred(ctx); | ||||
STATE_UNLOCK(ctx); | STATE_UNLOCK(ctx); | ||||
} | } | ||||
static void | static void | ||||
iflib_calc_rx_mbuf_sz(if_ctx_t ctx) | |||||
{ | |||||
if_softc_ctx_t sctx = &ctx->ifc_softc_ctx; | |||||
/* | |||||
* XXX don't set the max_frame_size to larger | |||||
* than the hardware can handle | |||||
*/ | |||||
if (sctx->isc_max_frame_size <= 2048) | |||||
erj: I know this is copied from the original code, but shouldn't this check be against MCLBYTES… | |||||
Not Done Inline ActionsYes, I agree. jacob.e.keller_intel.com: Yes, I agree. | |||||
ctx->ifc_rx_mbuf_sz = MCLBYTES; | |||||
else | |||||
ctx->ifc_rx_mbuf_sz = MJUMPAGESIZE; | |||||
} | |||||
uint32_t | |||||
iflib_get_rx_mbuf_sz(if_ctx_t ctx) | |||||
{ | |||||
return ctx->ifc_rx_mbuf_sz; | |||||
erjUnsubmitted Not Done Inline Actionsstyle(9) nit -- there should be parentheses around this return value erj: style(9) nit -- there should be parentheses around this return value | |||||
} | |||||
static void | |||||
iflib_init_locked(if_ctx_t ctx) | iflib_init_locked(if_ctx_t ctx) | ||||
{ | { | ||||
if_softc_ctx_t sctx = &ctx->ifc_softc_ctx; | if_softc_ctx_t sctx = &ctx->ifc_softc_ctx; | ||||
if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | ||||
if_t ifp = ctx->ifc_ifp; | if_t ifp = ctx->ifc_ifp; | ||||
iflib_fl_t fl; | iflib_fl_t fl; | ||||
iflib_txq_t txq; | iflib_txq_t txq; | ||||
iflib_rxq_t rxq; | iflib_rxq_t rxq; | ||||
Show All 17 Lines | if (if_getcapenable(ifp) & IFCAP_TSO6) | ||||
if_sethwassistbits(ifp, CSUM_IP6_TSO, 0); | if_sethwassistbits(ifp, CSUM_IP6_TSO, 0); | ||||
for (i = 0, txq = ctx->ifc_txqs; i < sctx->isc_ntxqsets; i++, txq++) { | for (i = 0, txq = ctx->ifc_txqs; i < sctx->isc_ntxqsets; i++, txq++) { | ||||
CALLOUT_LOCK(txq); | CALLOUT_LOCK(txq); | ||||
callout_stop(&txq->ift_timer); | callout_stop(&txq->ift_timer); | ||||
CALLOUT_UNLOCK(txq); | CALLOUT_UNLOCK(txq); | ||||
iflib_netmap_txq_init(ctx, txq); | iflib_netmap_txq_init(ctx, txq); | ||||
} | } | ||||
/* Calculate a suitable Rx mbuf size prior to calling IFDI_INIT, so | |||||
erjUnsubmitted Not Done Inline ActionsYou would also start the comment on the line after the opening "/*". erj: You would also start the comment on the line after the opening "/*". | |||||
* that drivers can use the value when setting up the hardware receive | |||||
* buffers. | |||||
*/ | |||||
iflib_calc_rx_mbuf_sz(ctx); | |||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
i = if_getdrvflags(ifp); | i = if_getdrvflags(ifp); | ||||
#endif | #endif | ||||
IFDI_INIT(ctx); | IFDI_INIT(ctx); | ||||
MPASS(if_getdrvflags(ifp) == i); | MPASS(if_getdrvflags(ifp) == i); | ||||
for (i = 0, rxq = ctx->ifc_rxqs; i < sctx->isc_nrxqsets; i++, rxq++) { | for (i = 0, rxq = ctx->ifc_rxqs; i < sctx->isc_nrxqsets; i++, rxq++) { | ||||
/* XXX this should really be done on a per-queue basis */ | /* XXX this should really be done on a per-queue basis */ | ||||
if (if_getcapenable(ifp) & IFCAP_NETMAP) { | if (if_getcapenable(ifp) & IFCAP_NETMAP) { | ||||
▲ Show 20 Lines • Show All 4,185 Lines • Show Last 20 Lines |
I know this is copied from the original code, but shouldn't this check be against MCLBYTES, just in case that ever changes to not being 2048?