Lines Matching refs:rx_queue

35 static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue)  in efx_reuse_page()  argument
37 struct efx_nic *efx = rx_queue->efx; in efx_reuse_page()
42 if (unlikely(!rx_queue->page_ring)) in efx_reuse_page()
44 index = rx_queue->page_remove & rx_queue->page_ptr_mask; in efx_reuse_page()
45 page = rx_queue->page_ring[index]; in efx_reuse_page()
49 rx_queue->page_ring[index] = NULL; in efx_reuse_page()
51 if (rx_queue->page_remove != rx_queue->page_add) in efx_reuse_page()
52 ++rx_queue->page_remove; in efx_reuse_page()
56 ++rx_queue->page_recycle_count; in efx_reuse_page()
64 ++rx_queue->page_recycle_failed; in efx_reuse_page()
77 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_recycle_rx_page() local
78 struct efx_nic *efx = rx_queue->efx; in efx_recycle_rx_page()
86 index = rx_queue->page_add & rx_queue->page_ptr_mask; in efx_recycle_rx_page()
87 if (rx_queue->page_ring[index] == NULL) { in efx_recycle_rx_page()
88 unsigned int read_index = rx_queue->page_remove & in efx_recycle_rx_page()
89 rx_queue->page_ptr_mask; in efx_recycle_rx_page()
96 ++rx_queue->page_remove; in efx_recycle_rx_page()
97 rx_queue->page_ring[index] = page; in efx_recycle_rx_page()
98 ++rx_queue->page_add; in efx_recycle_rx_page()
101 ++rx_queue->page_recycle_full; in efx_recycle_rx_page()
111 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_recycle_rx_pages() local
113 if (unlikely(!rx_queue->page_ring)) in efx_recycle_rx_pages()
118 rx_buf = efx_rx_buf_next(rx_queue, rx_buf); in efx_recycle_rx_pages()
126 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_discard_rx_packet() local
130 efx_free_rx_buffers(rx_queue, rx_buf, n_frags); in efx_discard_rx_packet()
133 static void efx_init_rx_recycle_ring(struct efx_rx_queue *rx_queue) in efx_init_rx_recycle_ring() argument
136 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_recycle_ring()
141 rx_queue->page_ring = kcalloc(page_ring_size, in efx_init_rx_recycle_ring()
142 sizeof(*rx_queue->page_ring), GFP_KERNEL); in efx_init_rx_recycle_ring()
143 if (!rx_queue->page_ring) in efx_init_rx_recycle_ring()
144 rx_queue->page_ptr_mask = 0; in efx_init_rx_recycle_ring()
146 rx_queue->page_ptr_mask = page_ring_size - 1; in efx_init_rx_recycle_ring()
149 static void efx_fini_rx_recycle_ring(struct efx_rx_queue *rx_queue) in efx_fini_rx_recycle_ring() argument
151 struct efx_nic *efx = rx_queue->efx; in efx_fini_rx_recycle_ring()
154 if (unlikely(!rx_queue->page_ring)) in efx_fini_rx_recycle_ring()
158 for (i = 0; i <= rx_queue->page_ptr_mask; i++) { in efx_fini_rx_recycle_ring()
159 struct page *page = rx_queue->page_ring[i]; in efx_fini_rx_recycle_ring()
171 kfree(rx_queue->page_ring); in efx_fini_rx_recycle_ring()
172 rx_queue->page_ring = NULL; in efx_fini_rx_recycle_ring()
175 static void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue, in efx_fini_rx_buffer() argument
184 efx_unmap_rx_buffer(rx_queue->efx, rx_buf); in efx_fini_rx_buffer()
185 efx_free_rx_buffers(rx_queue, rx_buf, 1); in efx_fini_rx_buffer()
190 int efx_probe_rx_queue(struct efx_rx_queue *rx_queue) in efx_probe_rx_queue() argument
192 struct efx_nic *efx = rx_queue->efx; in efx_probe_rx_queue()
199 rx_queue->ptr_mask = entries - 1; in efx_probe_rx_queue()
203 efx_rx_queue_index(rx_queue), efx->rxq_entries, in efx_probe_rx_queue()
204 rx_queue->ptr_mask); in efx_probe_rx_queue()
207 rx_queue->buffer = kcalloc(entries, sizeof(*rx_queue->buffer), in efx_probe_rx_queue()
209 if (!rx_queue->buffer) in efx_probe_rx_queue()
212 rc = efx_nic_probe_rx(rx_queue); in efx_probe_rx_queue()
214 kfree(rx_queue->buffer); in efx_probe_rx_queue()
215 rx_queue->buffer = NULL; in efx_probe_rx_queue()
221 void efx_init_rx_queue(struct efx_rx_queue *rx_queue) in efx_init_rx_queue() argument
224 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_queue()
227 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_init_rx_queue()
228 "initialising RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_init_rx_queue()
231 rx_queue->added_count = 0; in efx_init_rx_queue()
232 rx_queue->notified_count = 0; in efx_init_rx_queue()
233 rx_queue->granted_count = 0; in efx_init_rx_queue()
234 rx_queue->removed_count = 0; in efx_init_rx_queue()
235 rx_queue->min_fill = -1U; in efx_init_rx_queue()
236 efx_init_rx_recycle_ring(rx_queue); in efx_init_rx_queue()
238 rx_queue->page_remove = 0; in efx_init_rx_queue()
239 rx_queue->page_add = rx_queue->page_ptr_mask + 1; in efx_init_rx_queue()
240 rx_queue->page_recycle_count = 0; in efx_init_rx_queue()
241 rx_queue->page_recycle_failed = 0; in efx_init_rx_queue()
242 rx_queue->page_recycle_full = 0; in efx_init_rx_queue()
244 rx_queue->old_rx_packets = rx_queue->rx_packets; in efx_init_rx_queue()
245 rx_queue->old_rx_bytes = rx_queue->rx_bytes; in efx_init_rx_queue()
259 rx_queue->max_fill = max_fill; in efx_init_rx_queue()
260 rx_queue->fast_fill_trigger = trigger; in efx_init_rx_queue()
261 rx_queue->refill_enabled = true; in efx_init_rx_queue()
264 rc = xdp_rxq_info_reg(&rx_queue->xdp_rxq_info, efx->net_dev, in efx_init_rx_queue()
265 rx_queue->core_index, 0); in efx_init_rx_queue()
275 efx_nic_init_rx(rx_queue); in efx_init_rx_queue()
278 void efx_fini_rx_queue(struct efx_rx_queue *rx_queue) in efx_fini_rx_queue() argument
283 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_fini_rx_queue()
284 "shutting down RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_fini_rx_queue()
286 timer_delete_sync(&rx_queue->slow_fill); in efx_fini_rx_queue()
287 if (rx_queue->grant_credits) in efx_fini_rx_queue()
288 flush_work(&rx_queue->grant_work); in efx_fini_rx_queue()
291 if (rx_queue->buffer) { in efx_fini_rx_queue()
292 for (i = rx_queue->removed_count; i < rx_queue->added_count; in efx_fini_rx_queue()
294 unsigned int index = i & rx_queue->ptr_mask; in efx_fini_rx_queue()
296 rx_buf = efx_rx_buffer(rx_queue, index); in efx_fini_rx_queue()
297 efx_fini_rx_buffer(rx_queue, rx_buf); in efx_fini_rx_queue()
301 efx_fini_rx_recycle_ring(rx_queue); in efx_fini_rx_queue()
303 if (xdp_rxq_info_is_reg(&rx_queue->xdp_rxq_info)) in efx_fini_rx_queue()
304 xdp_rxq_info_unreg(&rx_queue->xdp_rxq_info); in efx_fini_rx_queue()
307 void efx_remove_rx_queue(struct efx_rx_queue *rx_queue) in efx_remove_rx_queue() argument
309 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_remove_rx_queue()
310 "destroying RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_remove_rx_queue()
312 efx_nic_remove_rx(rx_queue); in efx_remove_rx_queue()
314 kfree(rx_queue->buffer); in efx_remove_rx_queue()
315 rx_queue->buffer = NULL; in efx_remove_rx_queue()
336 void efx_free_rx_buffers(struct efx_rx_queue *rx_queue, in efx_free_rx_buffers() argument
345 rx_buf = efx_rx_buf_next(rx_queue, rx_buf); in efx_free_rx_buffers()
351 struct efx_rx_queue *rx_queue = timer_container_of(rx_queue, t, in efx_rx_slow_fill() local
355 efx_nic_generate_fill_event(rx_queue); in efx_rx_slow_fill()
356 ++rx_queue->slow_fill_count; in efx_rx_slow_fill()
359 void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue) in efx_schedule_slow_fill() argument
361 mod_timer(&rx_queue->slow_fill, jiffies + msecs_to_jiffies(10)); in efx_schedule_slow_fill()
373 static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue, bool atomic) in efx_init_rx_buffers() argument
376 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_buffers()
384 page = efx_reuse_page(rx_queue); in efx_init_rx_buffers()
411 index = rx_queue->added_count & rx_queue->ptr_mask; in efx_init_rx_buffers()
412 rx_buf = efx_rx_buffer(rx_queue, index); in efx_init_rx_buffers()
420 ++rx_queue->added_count; in efx_init_rx_buffers()
457 void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic) in efx_fast_push_rx_descriptors() argument
459 struct efx_nic *efx = rx_queue->efx; in efx_fast_push_rx_descriptors()
463 if (!rx_queue->refill_enabled) in efx_fast_push_rx_descriptors()
467 fill_level = (rx_queue->added_count - rx_queue->removed_count); in efx_fast_push_rx_descriptors()
468 EFX_WARN_ON_ONCE_PARANOID(fill_level > rx_queue->efx->rxq_entries); in efx_fast_push_rx_descriptors()
469 if (fill_level >= rx_queue->fast_fill_trigger) in efx_fast_push_rx_descriptors()
473 if (unlikely(fill_level < rx_queue->min_fill)) { in efx_fast_push_rx_descriptors()
475 rx_queue->min_fill = fill_level; in efx_fast_push_rx_descriptors()
479 space = rx_queue->max_fill - fill_level; in efx_fast_push_rx_descriptors()
482 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev, in efx_fast_push_rx_descriptors()
485 efx_rx_queue_index(rx_queue), fill_level, in efx_fast_push_rx_descriptors()
486 rx_queue->max_fill); in efx_fast_push_rx_descriptors()
489 rc = efx_init_rx_buffers(rx_queue, atomic); in efx_fast_push_rx_descriptors()
492 efx_schedule_slow_fill(rx_queue); in efx_fast_push_rx_descriptors()
497 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev, in efx_fast_push_rx_descriptors()
499 "to level %d\n", efx_rx_queue_index(rx_queue), in efx_fast_push_rx_descriptors()
500 rx_queue->added_count - rx_queue->removed_count); in efx_fast_push_rx_descriptors()
503 if (rx_queue->notified_count != rx_queue->added_count) in efx_fast_push_rx_descriptors()
504 efx_nic_notify_rx_desc(rx_queue); in efx_fast_push_rx_descriptors()
520 struct efx_rx_queue *rx_queue; in efx_rx_packet_gro() local
522 rx_queue = efx_channel_get_rx_queue(channel); in efx_rx_packet_gro()
523 efx_free_rx_buffers(rx_queue, rx_buf, n_frags); in efx_rx_packet_gro()
549 rx_buf = efx_rx_buf_next(&channel->rx_queue, rx_buf); in efx_rx_packet_gro()
555 skb_record_rx_queue(skb, channel->rx_queue.core_index); in efx_rx_packet_gro()