Lines Matching refs:rx_queue
41 static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue) in efx_reuse_page() argument
43 struct efx_nic *efx = rx_queue->efx; in efx_reuse_page()
48 if (unlikely(!rx_queue->page_ring)) in efx_reuse_page()
50 index = rx_queue->page_remove & rx_queue->page_ptr_mask; in efx_reuse_page()
51 page = rx_queue->page_ring[index]; in efx_reuse_page()
55 rx_queue->page_ring[index] = NULL; in efx_reuse_page()
57 if (rx_queue->page_remove != rx_queue->page_add) in efx_reuse_page()
58 ++rx_queue->page_remove; in efx_reuse_page()
62 ++rx_queue->page_recycle_count; in efx_reuse_page()
70 ++rx_queue->page_recycle_failed; in efx_reuse_page()
83 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_recycle_rx_page() local
84 struct efx_nic *efx = rx_queue->efx; in efx_recycle_rx_page()
92 index = rx_queue->page_add & rx_queue->page_ptr_mask; in efx_recycle_rx_page()
93 if (rx_queue->page_ring[index] == NULL) { in efx_recycle_rx_page()
94 unsigned int read_index = rx_queue->page_remove & in efx_recycle_rx_page()
95 rx_queue->page_ptr_mask; in efx_recycle_rx_page()
102 ++rx_queue->page_remove; in efx_recycle_rx_page()
103 rx_queue->page_ring[index] = page; in efx_recycle_rx_page()
104 ++rx_queue->page_add; in efx_recycle_rx_page()
107 ++rx_queue->page_recycle_full; in efx_recycle_rx_page()
117 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_recycle_rx_pages() local
119 if (unlikely(!rx_queue->page_ring)) in efx_recycle_rx_pages()
124 rx_buf = efx_rx_buf_next(rx_queue, rx_buf); in efx_recycle_rx_pages()
132 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_discard_rx_packet() local
136 efx_free_rx_buffers(rx_queue, rx_buf, n_frags); in efx_discard_rx_packet()
139 static void efx_init_rx_recycle_ring(struct efx_rx_queue *rx_queue) in efx_init_rx_recycle_ring() argument
142 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_recycle_ring()
156 rx_queue->page_ring = kcalloc(page_ring_size, in efx_init_rx_recycle_ring()
157 sizeof(*rx_queue->page_ring), GFP_KERNEL); in efx_init_rx_recycle_ring()
158 if (!rx_queue->page_ring) in efx_init_rx_recycle_ring()
159 rx_queue->page_ptr_mask = 0; in efx_init_rx_recycle_ring()
161 rx_queue->page_ptr_mask = page_ring_size - 1; in efx_init_rx_recycle_ring()
164 static void efx_fini_rx_recycle_ring(struct efx_rx_queue *rx_queue) in efx_fini_rx_recycle_ring() argument
166 struct efx_nic *efx = rx_queue->efx; in efx_fini_rx_recycle_ring()
170 for (i = 0; i <= rx_queue->page_ptr_mask; i++) { in efx_fini_rx_recycle_ring()
171 struct page *page = rx_queue->page_ring[i]; in efx_fini_rx_recycle_ring()
183 kfree(rx_queue->page_ring); in efx_fini_rx_recycle_ring()
184 rx_queue->page_ring = NULL; in efx_fini_rx_recycle_ring()
187 static void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue, in efx_fini_rx_buffer() argument
196 efx_unmap_rx_buffer(rx_queue->efx, rx_buf); in efx_fini_rx_buffer()
197 efx_free_rx_buffers(rx_queue, rx_buf, 1); in efx_fini_rx_buffer()
202 int efx_probe_rx_queue(struct efx_rx_queue *rx_queue) in efx_probe_rx_queue() argument
204 struct efx_nic *efx = rx_queue->efx; in efx_probe_rx_queue()
211 rx_queue->ptr_mask = entries - 1; in efx_probe_rx_queue()
215 efx_rx_queue_index(rx_queue), efx->rxq_entries, in efx_probe_rx_queue()
216 rx_queue->ptr_mask); in efx_probe_rx_queue()
219 rx_queue->buffer = kcalloc(entries, sizeof(*rx_queue->buffer), in efx_probe_rx_queue()
221 if (!rx_queue->buffer) in efx_probe_rx_queue()
224 rc = efx_nic_probe_rx(rx_queue); in efx_probe_rx_queue()
226 kfree(rx_queue->buffer); in efx_probe_rx_queue()
227 rx_queue->buffer = NULL; in efx_probe_rx_queue()
233 void efx_init_rx_queue(struct efx_rx_queue *rx_queue) in efx_init_rx_queue() argument
236 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_queue()
239 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_init_rx_queue()
240 "initialising RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_init_rx_queue()
243 rx_queue->added_count = 0; in efx_init_rx_queue()
244 rx_queue->notified_count = 0; in efx_init_rx_queue()
245 rx_queue->removed_count = 0; in efx_init_rx_queue()
246 rx_queue->min_fill = -1U; in efx_init_rx_queue()
247 efx_init_rx_recycle_ring(rx_queue); in efx_init_rx_queue()
249 rx_queue->page_remove = 0; in efx_init_rx_queue()
250 rx_queue->page_add = rx_queue->page_ptr_mask + 1; in efx_init_rx_queue()
251 rx_queue->page_recycle_count = 0; in efx_init_rx_queue()
252 rx_queue->page_recycle_failed = 0; in efx_init_rx_queue()
253 rx_queue->page_recycle_full = 0; in efx_init_rx_queue()
267 rx_queue->max_fill = max_fill; in efx_init_rx_queue()
268 rx_queue->fast_fill_trigger = trigger; in efx_init_rx_queue()
269 rx_queue->refill_enabled = true; in efx_init_rx_queue()
272 rc = xdp_rxq_info_reg(&rx_queue->xdp_rxq_info, efx->net_dev, in efx_init_rx_queue()
273 rx_queue->core_index, 0); in efx_init_rx_queue()
281 rx_queue->xdp_rxq_info_valid = true; in efx_init_rx_queue()
285 efx_nic_init_rx(rx_queue); in efx_init_rx_queue()
288 void efx_fini_rx_queue(struct efx_rx_queue *rx_queue) in efx_fini_rx_queue() argument
293 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_fini_rx_queue()
294 "shutting down RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_fini_rx_queue()
296 del_timer_sync(&rx_queue->slow_fill); in efx_fini_rx_queue()
299 if (rx_queue->buffer) { in efx_fini_rx_queue()
300 for (i = rx_queue->removed_count; i < rx_queue->added_count; in efx_fini_rx_queue()
302 unsigned int index = i & rx_queue->ptr_mask; in efx_fini_rx_queue()
304 rx_buf = efx_rx_buffer(rx_queue, index); in efx_fini_rx_queue()
305 efx_fini_rx_buffer(rx_queue, rx_buf); in efx_fini_rx_queue()
309 efx_fini_rx_recycle_ring(rx_queue); in efx_fini_rx_queue()
311 if (rx_queue->xdp_rxq_info_valid) in efx_fini_rx_queue()
312 xdp_rxq_info_unreg(&rx_queue->xdp_rxq_info); in efx_fini_rx_queue()
314 rx_queue->xdp_rxq_info_valid = false; in efx_fini_rx_queue()
317 void efx_remove_rx_queue(struct efx_rx_queue *rx_queue) in efx_remove_rx_queue() argument
319 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_remove_rx_queue()
320 "destroying RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_remove_rx_queue()
322 efx_nic_remove_rx(rx_queue); in efx_remove_rx_queue()
324 kfree(rx_queue->buffer); in efx_remove_rx_queue()
325 rx_queue->buffer = NULL; in efx_remove_rx_queue()
346 void efx_free_rx_buffers(struct efx_rx_queue *rx_queue, in efx_free_rx_buffers() argument
355 rx_buf = efx_rx_buf_next(rx_queue, rx_buf); in efx_free_rx_buffers()
361 struct efx_rx_queue *rx_queue = from_timer(rx_queue, t, slow_fill); in efx_rx_slow_fill() local
364 efx_nic_generate_fill_event(rx_queue); in efx_rx_slow_fill()
365 ++rx_queue->slow_fill_count; in efx_rx_slow_fill()
368 void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue) in efx_schedule_slow_fill() argument
370 mod_timer(&rx_queue->slow_fill, jiffies + msecs_to_jiffies(10)); in efx_schedule_slow_fill()
382 static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue, bool atomic) in efx_init_rx_buffers() argument
385 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_buffers()
393 page = efx_reuse_page(rx_queue); in efx_init_rx_buffers()
420 index = rx_queue->added_count & rx_queue->ptr_mask; in efx_init_rx_buffers()
421 rx_buf = efx_rx_buffer(rx_queue, index); in efx_init_rx_buffers()
429 ++rx_queue->added_count; in efx_init_rx_buffers()
466 void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic) in efx_fast_push_rx_descriptors() argument
468 struct efx_nic *efx = rx_queue->efx; in efx_fast_push_rx_descriptors()
472 if (!rx_queue->refill_enabled) in efx_fast_push_rx_descriptors()
476 fill_level = (rx_queue->added_count - rx_queue->removed_count); in efx_fast_push_rx_descriptors()
477 EFX_WARN_ON_ONCE_PARANOID(fill_level > rx_queue->efx->rxq_entries); in efx_fast_push_rx_descriptors()
478 if (fill_level >= rx_queue->fast_fill_trigger) in efx_fast_push_rx_descriptors()
482 if (unlikely(fill_level < rx_queue->min_fill)) { in efx_fast_push_rx_descriptors()
484 rx_queue->min_fill = fill_level; in efx_fast_push_rx_descriptors()
488 space = rx_queue->max_fill - fill_level; in efx_fast_push_rx_descriptors()
491 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev, in efx_fast_push_rx_descriptors()
494 efx_rx_queue_index(rx_queue), fill_level, in efx_fast_push_rx_descriptors()
495 rx_queue->max_fill); in efx_fast_push_rx_descriptors()
498 rc = efx_init_rx_buffers(rx_queue, atomic); in efx_fast_push_rx_descriptors()
501 efx_schedule_slow_fill(rx_queue); in efx_fast_push_rx_descriptors()
506 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev, in efx_fast_push_rx_descriptors()
508 "to level %d\n", efx_rx_queue_index(rx_queue), in efx_fast_push_rx_descriptors()
509 rx_queue->added_count - rx_queue->removed_count); in efx_fast_push_rx_descriptors()
512 if (rx_queue->notified_count != rx_queue->added_count) in efx_fast_push_rx_descriptors()
513 efx_nic_notify_rx_desc(rx_queue); in efx_fast_push_rx_descriptors()
529 struct efx_rx_queue *rx_queue; in efx_rx_packet_gro() local
531 rx_queue = efx_channel_get_rx_queue(channel); in efx_rx_packet_gro()
532 efx_free_rx_buffers(rx_queue, rx_buf, n_frags); in efx_rx_packet_gro()
558 rx_buf = efx_rx_buf_next(&channel->rx_queue, rx_buf); in efx_rx_packet_gro()
564 skb_record_rx_queue(skb, channel->rx_queue.core_index); in efx_rx_packet_gro()