Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixgbe/ix_txrx.c
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | static int ixgbe_tso_setup(struct tx_ring *, | ||||
struct mbuf *, u32 *, u32 *); | struct mbuf *, u32 *, u32 *); | ||||
#ifdef IXGBE_FDIR | #ifdef IXGBE_FDIR | ||||
static void ixgbe_atr(struct tx_ring *, struct mbuf *); | static void ixgbe_atr(struct tx_ring *, struct mbuf *); | ||||
#endif | #endif | ||||
static __inline void ixgbe_rx_discard(struct rx_ring *, int); | static __inline void ixgbe_rx_discard(struct rx_ring *, int); | ||||
static __inline void ixgbe_rx_input(struct rx_ring *, struct ifnet *, | static __inline void ixgbe_rx_input(struct rx_ring *, struct ifnet *, | ||||
struct mbuf *, u32); | struct mbuf *, u32); | ||||
MALLOC_DECLARE(M_IXGBE); | |||||
#ifdef IXGBE_LEGACY_TX | #ifdef IXGBE_LEGACY_TX | ||||
/************************************************************************ | /************************************************************************ | ||||
* ixgbe_legacy_start_locked - Transmit entry point | * ixgbe_legacy_start_locked - Transmit entry point | ||||
* | * | ||||
* Called by the stack to initiate a transmit. | * Called by the stack to initiate a transmit. | ||||
* The driver will remain in this routine as long as there are | * The driver will remain in this routine as long as there are | ||||
* packets to transmit and transmit resources are available. | * packets to transmit and transmit resources are available. | ||||
* In case resources are not available, the stack is notified | * In case resources are not available, the stack is notified | ||||
▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | if ((error = bus_dma_tag_create( | ||||
/* lockfuncarg */ NULL, | /* lockfuncarg */ NULL, | ||||
&txr->txtag))) { | &txr->txtag))) { | ||||
device_printf(dev,"Unable to allocate TX DMA tag\n"); | device_printf(dev,"Unable to allocate TX DMA tag\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
if (!(txr->tx_buffers = | if (!(txr->tx_buffers = | ||||
(struct ixgbe_tx_buf *)malloc(sizeof(struct ixgbe_tx_buf) * | (struct ixgbe_tx_buf *)malloc(sizeof(struct ixgbe_tx_buf) * | ||||
adapter->num_tx_desc, M_DEVBUF, M_NOWAIT | M_ZERO))) { | adapter->num_tx_desc, M_IXGBE, M_NOWAIT | M_ZERO))) { | ||||
device_printf(dev, "Unable to allocate tx_buffer memory\n"); | device_printf(dev, "Unable to allocate tx_buffer memory\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto fail; | goto fail; | ||||
} | } | ||||
/* Create the descriptor buffer dma maps */ | /* Create the descriptor buffer dma maps */ | ||||
txbuf = txr->tx_buffers; | txbuf = txr->tx_buffers; | ||||
for (i = 0; i < adapter->num_tx_desc; i++, txbuf++) { | for (i = 0; i < adapter->num_tx_desc; i++, txbuf++) { | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | ixgbe_free_transmit_structures(struct adapter *adapter) | ||||
for (int i = 0; i < adapter->num_queues; i++, txr++) { | for (int i = 0; i < adapter->num_queues; i++, txr++) { | ||||
IXGBE_TX_LOCK(txr); | IXGBE_TX_LOCK(txr); | ||||
ixgbe_free_transmit_buffers(txr); | ixgbe_free_transmit_buffers(txr); | ||||
ixgbe_dma_free(adapter, &txr->txdma); | ixgbe_dma_free(adapter, &txr->txdma); | ||||
IXGBE_TX_UNLOCK(txr); | IXGBE_TX_UNLOCK(txr); | ||||
IXGBE_TX_LOCK_DESTROY(txr); | IXGBE_TX_LOCK_DESTROY(txr); | ||||
} | } | ||||
free(adapter->tx_rings, M_DEVBUF); | free(adapter->tx_rings, M_IXGBE); | ||||
} | } | ||||
/************************************************************************ | /************************************************************************ | ||||
* ixgbe_free_transmit_buffers | * ixgbe_free_transmit_buffers | ||||
* | * | ||||
* Free transmit ring related data structures. | * Free transmit ring related data structures. | ||||
************************************************************************/ | ************************************************************************/ | ||||
static void | static void | ||||
Show All 23 Lines | for (i = 0; i < adapter->num_tx_desc; i++, tx_buffer++) { | ||||
} else if (tx_buffer->map != NULL) { | } else if (tx_buffer->map != NULL) { | ||||
bus_dmamap_unload(txr->txtag, tx_buffer->map); | bus_dmamap_unload(txr->txtag, tx_buffer->map); | ||||
bus_dmamap_destroy(txr->txtag, tx_buffer->map); | bus_dmamap_destroy(txr->txtag, tx_buffer->map); | ||||
tx_buffer->map = NULL; | tx_buffer->map = NULL; | ||||
} | } | ||||
} | } | ||||
#ifdef IXGBE_LEGACY_TX | #ifdef IXGBE_LEGACY_TX | ||||
if (txr->br != NULL) | if (txr->br != NULL) | ||||
buf_ring_free(txr->br, M_DEVBUF); | buf_ring_free(txr->br, M_IXGBE); | ||||
#endif | #endif | ||||
if (txr->tx_buffers != NULL) { | if (txr->tx_buffers != NULL) { | ||||
free(txr->tx_buffers, M_DEVBUF); | free(txr->tx_buffers, M_IXGBE); | ||||
txr->tx_buffers = NULL; | txr->tx_buffers = NULL; | ||||
} | } | ||||
if (txr->txtag != NULL) { | if (txr->txtag != NULL) { | ||||
bus_dma_tag_destroy(txr->txtag); | bus_dma_tag_destroy(txr->txtag); | ||||
txr->txtag = NULL; | txr->txtag = NULL; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 664 Lines • ▼ Show 20 Lines | |||||
ixgbe_allocate_receive_buffers(struct rx_ring *rxr) | ixgbe_allocate_receive_buffers(struct rx_ring *rxr) | ||||
{ | { | ||||
struct adapter *adapter = rxr->adapter; | struct adapter *adapter = rxr->adapter; | ||||
device_t dev = adapter->dev; | device_t dev = adapter->dev; | ||||
struct ixgbe_rx_buf *rxbuf; | struct ixgbe_rx_buf *rxbuf; | ||||
int bsize, error; | int bsize, error; | ||||
bsize = sizeof(struct ixgbe_rx_buf) * rxr->num_desc; | bsize = sizeof(struct ixgbe_rx_buf) * rxr->num_desc; | ||||
if (!(rxr->rx_buffers = (struct ixgbe_rx_buf *)malloc(bsize, M_DEVBUF, | if (!(rxr->rx_buffers = (struct ixgbe_rx_buf *)malloc(bsize, M_IXGBE, | ||||
M_NOWAIT | M_ZERO))) { | M_NOWAIT | M_ZERO))) { | ||||
device_printf(dev, "Unable to allocate rx_buffer memory\n"); | device_printf(dev, "Unable to allocate rx_buffer memory\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto fail; | goto fail; | ||||
} | } | ||||
if ((error = bus_dma_tag_create( | if ((error = bus_dma_tag_create( | ||||
/* parent */ bus_get_dma_tag(dev), | /* parent */ bus_get_dma_tag(dev), | ||||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | for (int i = 0; i < adapter->num_queues; i++, rxr++) { | ||||
struct lro_ctrl *lro = &rxr->lro; | struct lro_ctrl *lro = &rxr->lro; | ||||
ixgbe_free_receive_buffers(rxr); | ixgbe_free_receive_buffers(rxr); | ||||
/* Free LRO memory */ | /* Free LRO memory */ | ||||
tcp_lro_free(lro); | tcp_lro_free(lro); | ||||
/* Free the ring memory as well */ | /* Free the ring memory as well */ | ||||
ixgbe_dma_free(adapter, &rxr->rxdma); | ixgbe_dma_free(adapter, &rxr->rxdma); | ||||
} | } | ||||
free(adapter->rx_rings, M_DEVBUF); | free(adapter->rx_rings, M_IXGBE); | ||||
} | } | ||||
/************************************************************************ | /************************************************************************ | ||||
* ixgbe_free_receive_buffers - Free receive ring data structures | * ixgbe_free_receive_buffers - Free receive ring data structures | ||||
************************************************************************/ | ************************************************************************/ | ||||
void | void | ||||
ixgbe_free_receive_buffers(struct rx_ring *rxr) | ixgbe_free_receive_buffers(struct rx_ring *rxr) | ||||
Show All 16 Lines | for (int i = 0; i < adapter->num_rx_desc; i++) { | ||||
} | } | ||||
rxbuf->buf = NULL; | rxbuf->buf = NULL; | ||||
if (rxbuf->pmap != NULL) { | if (rxbuf->pmap != NULL) { | ||||
bus_dmamap_destroy(rxr->ptag, rxbuf->pmap); | bus_dmamap_destroy(rxr->ptag, rxbuf->pmap); | ||||
rxbuf->pmap = NULL; | rxbuf->pmap = NULL; | ||||
} | } | ||||
} | } | ||||
if (rxr->rx_buffers != NULL) { | if (rxr->rx_buffers != NULL) { | ||||
free(rxr->rx_buffers, M_DEVBUF); | free(rxr->rx_buffers, M_IXGBE); | ||||
rxr->rx_buffers = NULL; | rxr->rx_buffers = NULL; | ||||
} | } | ||||
} | } | ||||
if (rxr->ptag != NULL) { | if (rxr->ptag != NULL) { | ||||
bus_dma_tag_destroy(rxr->ptag); | bus_dma_tag_destroy(rxr->ptag); | ||||
rxr->ptag = NULL; | rxr->ptag = NULL; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | ixgbe_allocate_queues(struct adapter *adapter) | ||||
int rsize, tsize, error = IXGBE_SUCCESS; | int rsize, tsize, error = IXGBE_SUCCESS; | ||||
int txconf = 0, rxconf = 0; | int txconf = 0, rxconf = 0; | ||||
#ifdef PCI_IOV | #ifdef PCI_IOV | ||||
enum ixgbe_iov_mode iov_mode; | enum ixgbe_iov_mode iov_mode; | ||||
#endif | #endif | ||||
/* First, allocate the top level queue structs */ | /* First, allocate the top level queue structs */ | ||||
adapter->queues = (struct ix_queue *)malloc(sizeof(struct ix_queue) * | adapter->queues = (struct ix_queue *)malloc(sizeof(struct ix_queue) * | ||||
adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO); | adapter->num_queues, M_IXGBE, M_NOWAIT | M_ZERO); | ||||
if (!adapter->queues) { | if (!adapter->queues) { | ||||
device_printf(dev, "Unable to allocate queue memory\n"); | device_printf(dev, "Unable to allocate queue memory\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto fail; | goto fail; | ||||
} | } | ||||
/* Second, allocate the TX ring struct memory */ | /* Second, allocate the TX ring struct memory */ | ||||
adapter->tx_rings = (struct tx_ring *)malloc(sizeof(struct tx_ring) * | adapter->tx_rings = (struct tx_ring *)malloc(sizeof(struct tx_ring) * | ||||
adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO); | adapter->num_queues, M_IXGBE, M_NOWAIT | M_ZERO); | ||||
if (!adapter->tx_rings) { | if (!adapter->tx_rings) { | ||||
device_printf(dev, "Unable to allocate TX ring memory\n"); | device_printf(dev, "Unable to allocate TX ring memory\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto tx_fail; | goto tx_fail; | ||||
} | } | ||||
/* Third, allocate the RX ring */ | /* Third, allocate the RX ring */ | ||||
adapter->rx_rings = (struct rx_ring *)malloc(sizeof(struct rx_ring) * | adapter->rx_rings = (struct rx_ring *)malloc(sizeof(struct rx_ring) * | ||||
adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO); | adapter->num_queues, M_IXGBE, M_NOWAIT | M_ZERO); | ||||
if (!adapter->rx_rings) { | if (!adapter->rx_rings) { | ||||
device_printf(dev, "Unable to allocate RX ring memory\n"); | device_printf(dev, "Unable to allocate RX ring memory\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto rx_fail; | goto rx_fail; | ||||
} | } | ||||
/* For the ring itself */ | /* For the ring itself */ | ||||
tsize = roundup2(adapter->num_tx_desc * sizeof(union ixgbe_adv_tx_desc), | tsize = roundup2(adapter->num_tx_desc * sizeof(union ixgbe_adv_tx_desc), | ||||
Show All 40 Lines | #endif | ||||
if (ixgbe_allocate_transmit_buffers(txr)) { | if (ixgbe_allocate_transmit_buffers(txr)) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"Critical Failure setting up transmit buffers\n"); | "Critical Failure setting up transmit buffers\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto err_tx_desc; | goto err_tx_desc; | ||||
} | } | ||||
#ifndef IXGBE_LEGACY_TX | #ifndef IXGBE_LEGACY_TX | ||||
/* Allocate a buf ring */ | /* Allocate a buf ring */ | ||||
txr->br = buf_ring_alloc(IXGBE_BR_SIZE, M_DEVBUF, | txr->br = buf_ring_alloc(IXGBE_BR_SIZE, M_IXGBE, | ||||
M_WAITOK, &txr->tx_mtx); | M_WAITOK, &txr->tx_mtx); | ||||
if (txr->br == NULL) { | if (txr->br == NULL) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"Critical Failure setting up buf ring\n"); | "Critical Failure setting up buf ring\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto err_tx_desc; | goto err_tx_desc; | ||||
} | } | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | #endif | ||||
return (0); | return (0); | ||||
err_rx_desc: | err_rx_desc: | ||||
for (rxr = adapter->rx_rings; rxconf > 0; rxr++, rxconf--) | for (rxr = adapter->rx_rings; rxconf > 0; rxr++, rxconf--) | ||||
ixgbe_dma_free(adapter, &rxr->rxdma); | ixgbe_dma_free(adapter, &rxr->rxdma); | ||||
err_tx_desc: | err_tx_desc: | ||||
for (txr = adapter->tx_rings; txconf > 0; txr++, txconf--) | for (txr = adapter->tx_rings; txconf > 0; txr++, txconf--) | ||||
ixgbe_dma_free(adapter, &txr->txdma); | ixgbe_dma_free(adapter, &txr->txdma); | ||||
free(adapter->rx_rings, M_DEVBUF); | free(adapter->rx_rings, M_IXGBE); | ||||
rx_fail: | rx_fail: | ||||
free(adapter->tx_rings, M_DEVBUF); | free(adapter->tx_rings, M_IXGBE); | ||||
tx_fail: | tx_fail: | ||||
free(adapter->queues, M_DEVBUF); | free(adapter->queues, M_IXGBE); | ||||
fail: | fail: | ||||
return (error); | return (error); | ||||
} /* ixgbe_allocate_queues */ | } /* ixgbe_allocate_queues */ |