Changeset View
Changeset View
Standalone View
Standalone View
sys/net/iflib.c
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | struct iflib_ctx { | ||||
cpuset_t ifc_cpus; | cpuset_t ifc_cpus; | ||||
if_shared_ctx_t ifc_sctx; | if_shared_ctx_t ifc_sctx; | ||||
struct if_softc_ctx ifc_softc_ctx; | struct if_softc_ctx ifc_softc_ctx; | ||||
struct sx ifc_ctx_sx; | struct sx ifc_ctx_sx; | ||||
struct mtx ifc_state_mtx; | struct mtx ifc_state_mtx; | ||||
uint16_t ifc_nhwtxqs; | |||||
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; | ||||
int ifc_link_state; | int ifc_link_state; | ||||
int ifc_link_irq; | int ifc_link_irq; | ||||
▲ Show 20 Lines • Show All 1,578 Lines • ▼ Show 20 Lines | iflib_txsd_free(if_ctx_t ctx, iflib_txq_t txq, int i) | ||||
*mp = NULL; | *mp = NULL; | ||||
} | } | ||||
static int | static int | ||||
iflib_txq_setup(iflib_txq_t txq) | iflib_txq_setup(iflib_txq_t txq) | ||||
{ | { | ||||
if_ctx_t ctx = txq->ift_ctx; | if_ctx_t ctx = txq->ift_ctx; | ||||
if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | ||||
if_shared_ctx_t sctx = ctx->ifc_sctx; | |||||
iflib_dma_info_t di; | iflib_dma_info_t di; | ||||
int i; | int i; | ||||
/* Set number of descriptors available */ | /* Set number of descriptors available */ | ||||
txq->ift_qstatus = IFLIB_QUEUE_IDLE; | txq->ift_qstatus = IFLIB_QUEUE_IDLE; | ||||
/* XXX make configurable */ | /* XXX make configurable */ | ||||
txq->ift_update_freq = IFLIB_DEFAULT_TX_UPDATE_FREQ; | txq->ift_update_freq = IFLIB_DEFAULT_TX_UPDATE_FREQ; | ||||
/* Reset indices */ | /* Reset indices */ | ||||
txq->ift_cidx_processed = 0; | txq->ift_cidx_processed = 0; | ||||
txq->ift_pidx = txq->ift_cidx = txq->ift_npending = 0; | txq->ift_pidx = txq->ift_cidx = txq->ift_npending = 0; | ||||
txq->ift_size = scctx->isc_ntxd[txq->ift_br_offset]; | txq->ift_size = scctx->isc_ntxd[txq->ift_br_offset]; | ||||
for (i = 0, di = txq->ift_ifdi; i < ctx->ifc_nhwtxqs; i++, di++) | for (i = 0, di = txq->ift_ifdi; i < sctx->isc_ntxqs; i++, di++) | ||||
bzero((void *)di->idi_vaddr, di->idi_size); | bzero((void *)di->idi_vaddr, di->idi_size); | ||||
IFDI_TXQ_SETUP(ctx, txq->ift_id); | IFDI_TXQ_SETUP(ctx, txq->ift_id); | ||||
for (i = 0, di = txq->ift_ifdi; i < ctx->ifc_nhwtxqs; i++, di++) | for (i = 0, di = txq->ift_ifdi; i < sctx->isc_ntxqs; i++, di++) | ||||
bus_dmamap_sync(di->idi_tag, di->idi_map, | bus_dmamap_sync(di->idi_tag, di->idi_map, | ||||
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); | BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); | ||||
return (0); | return (0); | ||||
} | } | ||||
/********************************************************************* | /********************************************************************* | ||||
* | * | ||||
* Allocate memory for rx_buffer structures. Since we use one | * Allocate memory for rx_buffer structures. Since we use one | ||||
▲ Show 20 Lines • Show All 570 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
iflib_stop(if_ctx_t ctx) | iflib_stop(if_ctx_t ctx) | ||||
{ | { | ||||
iflib_txq_t txq = ctx->ifc_txqs; | iflib_txq_t txq = ctx->ifc_txqs; | ||||
iflib_rxq_t rxq = ctx->ifc_rxqs; | iflib_rxq_t rxq = ctx->ifc_rxqs; | ||||
if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; | ||||
if_shared_ctx_t sctx = ctx->ifc_sctx; | |||||
iflib_dma_info_t di; | iflib_dma_info_t di; | ||||
iflib_fl_t fl; | iflib_fl_t fl; | ||||
int i, j; | int i, j; | ||||
/* Tell the stack that the interface is no longer active */ | /* Tell the stack that the interface is no longer active */ | ||||
if_setdrvflagbits(ctx->ifc_ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING); | if_setdrvflagbits(ctx->ifc_ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING); | ||||
IFDI_INTR_DISABLE(ctx); | IFDI_INTR_DISABLE(ctx); | ||||
Show All 17 Lines | for (j = 0; j < txq->ift_size; j++) { | ||||
iflib_txsd_free(ctx, txq, j); | iflib_txsd_free(ctx, txq, j); | ||||
} | } | ||||
txq->ift_processed = txq->ift_cleaned = txq->ift_cidx_processed = 0; | txq->ift_processed = txq->ift_cleaned = txq->ift_cidx_processed = 0; | ||||
txq->ift_in_use = txq->ift_gen = txq->ift_cidx = txq->ift_pidx = txq->ift_no_desc_avail = 0; | txq->ift_in_use = txq->ift_gen = txq->ift_cidx = txq->ift_pidx = txq->ift_no_desc_avail = 0; | ||||
txq->ift_closed = txq->ift_mbuf_defrag = txq->ift_mbuf_defrag_failed = 0; | txq->ift_closed = txq->ift_mbuf_defrag = txq->ift_mbuf_defrag_failed = 0; | ||||
txq->ift_no_tx_dma_setup = txq->ift_txd_encap_efbig = txq->ift_map_failed = 0; | txq->ift_no_tx_dma_setup = txq->ift_txd_encap_efbig = txq->ift_map_failed = 0; | ||||
txq->ift_pullups = 0; | txq->ift_pullups = 0; | ||||
ifmp_ring_reset_stats(txq->ift_br); | ifmp_ring_reset_stats(txq->ift_br); | ||||
for (j = 0, di = txq->ift_ifdi; j < ctx->ifc_nhwtxqs; j++, di++) | for (j = 0, di = txq->ift_ifdi; j < sctx->isc_ntxqs; j++, di++) | ||||
bzero((void *)di->idi_vaddr, di->idi_size); | bzero((void *)di->idi_vaddr, di->idi_size); | ||||
} | } | ||||
for (i = 0; i < scctx->isc_nrxqsets; i++, rxq++) { | for (i = 0; i < scctx->isc_nrxqsets; i++, rxq++) { | ||||
/* make sure all transmitters have completed before proceeding XXX */ | /* make sure all transmitters have completed before proceeding XXX */ | ||||
for (j = 0, di = rxq->ifr_ifdi; j < rxq->ifr_nfl; j++, di++) | for (j = 0, di = rxq->ifr_ifdi; j < sctx->isc_nrxqs; j++, di++) | ||||
bzero((void *)di->idi_vaddr, di->idi_size); | bzero((void *)di->idi_vaddr, di->idi_size); | ||||
/* also resets the free lists pidx/cidx */ | /* also resets the free lists pidx/cidx */ | ||||
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++) | ||||
iflib_fl_bufs_free(fl); | iflib_fl_bufs_free(fl); | ||||
} | } | ||||
} | } | ||||
static inline caddr_t | static inline caddr_t | ||||
▲ Show 20 Lines • Show All 3,085 Lines • ▼ Show 20 Lines | iflib_tx_structures_setup(if_ctx_t ctx) | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
iflib_tx_structures_free(if_ctx_t ctx) | iflib_tx_structures_free(if_ctx_t ctx) | ||||
{ | { | ||||
iflib_txq_t txq = ctx->ifc_txqs; | iflib_txq_t txq = ctx->ifc_txqs; | ||||
if_shared_ctx_t sctx = ctx->ifc_sctx; | |||||
int i, j; | int i, j; | ||||
for (i = 0; i < NTXQSETS(ctx); i++, txq++) { | for (i = 0; i < NTXQSETS(ctx); i++, txq++) { | ||||
iflib_txq_destroy(txq); | iflib_txq_destroy(txq); | ||||
for (j = 0; j < ctx->ifc_nhwtxqs; j++) | for (j = 0; j < sctx->isc_ntxqs; j++) | ||||
iflib_dma_free(&txq->ift_ifdi[j]); | iflib_dma_free(&txq->ift_ifdi[j]); | ||||
} | } | ||||
free(ctx->ifc_txqs, M_IFLIB); | free(ctx->ifc_txqs, M_IFLIB); | ||||
ctx->ifc_txqs = NULL; | ctx->ifc_txqs = NULL; | ||||
IFDI_QUEUES_FREE(ctx); | IFDI_QUEUES_FREE(ctx); | ||||
} | } | ||||
/********************************************************************* | /********************************************************************* | ||||
▲ Show 20 Lines • Show All 1,088 Lines • Show Last 20 Lines |