Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ena/ena.c
Show First 20 Lines • Show All 758 Lines • ▼ Show 20 Lines | |||||
ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid) | ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid) | ||||
{ | { | ||||
struct ena_que *que = &adapter->que[qid]; | struct ena_que *que = &adapter->que[qid]; | ||||
struct ena_ring *rx_ring = que->rx_ring; | struct ena_ring *rx_ring = que->rx_ring; | ||||
int size, err, i; | int size, err, i; | ||||
size = sizeof(struct ena_rx_buffer) * rx_ring->ring_size; | size = sizeof(struct ena_rx_buffer) * rx_ring->ring_size; | ||||
#ifdef DEV_NETMAP | |||||
ena_netmap_reset_rx_ring(adapter, qid); | |||||
rx_ring->initialized = false; | |||||
#endif /* DEV_NETMAP */ | |||||
/* | /* | ||||
* Alloc extra element so in rx path | * Alloc extra element so in rx path | ||||
* we can always prefetch rx_info + 1 | * we can always prefetch rx_info + 1 | ||||
*/ | */ | ||||
size += sizeof(struct ena_rx_buffer); | size += sizeof(struct ena_rx_buffer); | ||||
rx_ring->rx_buffer_info = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO); | rx_ring->rx_buffer_info = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO); | ||||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) | ||||
for (i = 0; i < num; i++) { | for (i = 0; i < num; i++) { | ||||
struct ena_rx_buffer *rx_info; | struct ena_rx_buffer *rx_info; | ||||
ena_trace(ENA_DBG | ENA_RXPTH | ENA_RSC, | ena_trace(ENA_DBG | ENA_RXPTH | ENA_RSC, | ||||
"RX buffer - next to use: %d\n", next_to_use); | "RX buffer - next to use: %d\n", next_to_use); | ||||
req_id = rx_ring->free_rx_ids[next_to_use]; | req_id = rx_ring->free_rx_ids[next_to_use]; | ||||
rx_info = &rx_ring->rx_buffer_info[req_id]; | rx_info = &rx_ring->rx_buffer_info[req_id]; | ||||
#ifdef DEV_NETMAP | |||||
if (adapter->ifp->if_capenable & IFCAP_NETMAP) | |||||
rc = ena_netmap_alloc_rx_slot(adapter, rx_ring, rx_info); | |||||
else | |||||
#endif /* DEV_NETMAP */ | |||||
rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); | rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); | ||||
if (unlikely(rc != 0)) { | if (unlikely(rc != 0)) { | ||||
ena_trace(ENA_WARNING, | ena_trace(ENA_WARNING, | ||||
"failed to alloc buffer for rx queue %d\n", | "failed to alloc buffer for rx queue %d\n", | ||||
rx_ring->qid); | rx_ring->qid); | ||||
break; | break; | ||||
} | } | ||||
rc = ena_com_add_single_rx_desc(rx_ring->ena_com_io_sq, | rc = ena_com_add_single_rx_desc(rx_ring->ena_com_io_sq, | ||||
&rx_info->ena_buf, req_id); | &rx_info->ena_buf, req_id); | ||||
Show All 28 Lines | ena_free_rx_bufs(struct ena_adapter *adapter, unsigned int qid) | ||||
struct ena_ring *rx_ring = &adapter->rx_ring[qid]; | struct ena_ring *rx_ring = &adapter->rx_ring[qid]; | ||||
unsigned int i; | unsigned int i; | ||||
for (i = 0; i < rx_ring->ring_size; i++) { | for (i = 0; i < rx_ring->ring_size; i++) { | ||||
struct ena_rx_buffer *rx_info = &rx_ring->rx_buffer_info[i]; | struct ena_rx_buffer *rx_info = &rx_ring->rx_buffer_info[i]; | ||||
if (rx_info->mbuf != NULL) | if (rx_info->mbuf != NULL) | ||||
ena_free_rx_mbuf(adapter, rx_ring, rx_info); | ena_free_rx_mbuf(adapter, rx_ring, rx_info); | ||||
#ifdef DEV_NETMAP | |||||
if (((if_getflags(adapter->ifp) & IFF_DYING) == 0) && | |||||
(adapter->ifp->if_capenable & IFCAP_NETMAP)) { | |||||
if (rx_info->netmap_buf_idx != 0) | |||||
ena_netmap_free_rx_slot(adapter, rx_ring, | |||||
rx_info); | |||||
} | } | ||||
#endif /* DEV_NETMAP */ | |||||
} | } | ||||
} | |||||
/** | /** | ||||
* ena_refill_all_rx_bufs - allocate all queues Rx buffers | * ena_refill_all_rx_bufs - allocate all queues Rx buffers | ||||
* @adapter: network interface device structure | * @adapter: network interface device structure | ||||
* | * | ||||
*/ | */ | ||||
static void | static void | ||||
ena_refill_all_rx_bufs(struct ena_adapter *adapter) | ena_refill_all_rx_bufs(struct ena_adapter *adapter) | ||||
{ | { | ||||
struct ena_ring *rx_ring; | struct ena_ring *rx_ring; | ||||
int i, rc, bufs_num; | int i, rc, bufs_num; | ||||
for (i = 0; i < adapter->num_queues; i++) { | for (i = 0; i < adapter->num_queues; i++) { | ||||
rx_ring = &adapter->rx_ring[i]; | rx_ring = &adapter->rx_ring[i]; | ||||
bufs_num = rx_ring->ring_size - 1; | bufs_num = rx_ring->ring_size - 1; | ||||
rc = ena_refill_rx_bufs(rx_ring, bufs_num); | rc = ena_refill_rx_bufs(rx_ring, bufs_num); | ||||
if (unlikely(rc != bufs_num)) | if (unlikely(rc != bufs_num)) | ||||
ena_trace(ENA_WARNING, "refilling Queue %d failed. " | ena_trace(ENA_WARNING, "refilling Queue %d failed. " | ||||
"Allocated %d buffers from: %d\n", i, rc, bufs_num); | "Allocated %d buffers from: %d\n", i, rc, bufs_num); | ||||
#ifdef DEV_NETMAP | |||||
rx_ring->initialized = true; | |||||
#endif /* DEV_NETMAP */ | |||||
} | } | ||||
} | } | ||||
static void | static void | ||||
ena_free_all_rx_bufs(struct ena_adapter *adapter) | ena_free_all_rx_bufs(struct ena_adapter *adapter) | ||||
{ | { | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |