Lines Matching refs:rx_queue

34 static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue)  in efx_reuse_page()  argument
36 struct efx_nic *efx = rx_queue->efx; in efx_reuse_page()
41 if (unlikely(!rx_queue->page_ring)) in efx_reuse_page()
43 index = rx_queue->page_remove & rx_queue->page_ptr_mask; in efx_reuse_page()
44 page = rx_queue->page_ring[index]; in efx_reuse_page()
48 rx_queue->page_ring[index] = NULL; in efx_reuse_page()
50 if (rx_queue->page_remove != rx_queue->page_add) in efx_reuse_page()
51 ++rx_queue->page_remove; in efx_reuse_page()
55 ++rx_queue->page_recycle_count; in efx_reuse_page()
63 ++rx_queue->page_recycle_failed; in efx_reuse_page()
76 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_recycle_rx_page() local
77 struct efx_nic *efx = rx_queue->efx; in efx_recycle_rx_page()
85 index = rx_queue->page_add & rx_queue->page_ptr_mask; in efx_recycle_rx_page()
86 if (rx_queue->page_ring[index] == NULL) { in efx_recycle_rx_page()
87 unsigned int read_index = rx_queue->page_remove & in efx_recycle_rx_page()
88 rx_queue->page_ptr_mask; in efx_recycle_rx_page()
95 ++rx_queue->page_remove; in efx_recycle_rx_page()
96 rx_queue->page_ring[index] = page; in efx_recycle_rx_page()
97 ++rx_queue->page_add; in efx_recycle_rx_page()
100 ++rx_queue->page_recycle_full; in efx_recycle_rx_page()
110 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_recycle_rx_pages() local
112 if (unlikely(!rx_queue->page_ring)) in efx_recycle_rx_pages()
117 rx_buf = efx_rx_buf_next(rx_queue, rx_buf); in efx_recycle_rx_pages()
125 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); in efx_discard_rx_packet() local
129 efx_free_rx_buffers(rx_queue, rx_buf, n_frags); in efx_discard_rx_packet()
132 static void efx_init_rx_recycle_ring(struct efx_rx_queue *rx_queue) in efx_init_rx_recycle_ring() argument
135 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_recycle_ring()
140 rx_queue->page_ring = kcalloc(page_ring_size, in efx_init_rx_recycle_ring()
141 sizeof(*rx_queue->page_ring), GFP_KERNEL); in efx_init_rx_recycle_ring()
142 if (!rx_queue->page_ring) in efx_init_rx_recycle_ring()
143 rx_queue->page_ptr_mask = 0; in efx_init_rx_recycle_ring()
145 rx_queue->page_ptr_mask = page_ring_size - 1; in efx_init_rx_recycle_ring()
148 static void efx_fini_rx_recycle_ring(struct efx_rx_queue *rx_queue) in efx_fini_rx_recycle_ring() argument
150 struct efx_nic *efx = rx_queue->efx; in efx_fini_rx_recycle_ring()
153 if (unlikely(!rx_queue->page_ring)) in efx_fini_rx_recycle_ring()
157 for (i = 0; i <= rx_queue->page_ptr_mask; i++) { in efx_fini_rx_recycle_ring()
158 struct page *page = rx_queue->page_ring[i]; in efx_fini_rx_recycle_ring()
170 kfree(rx_queue->page_ring); in efx_fini_rx_recycle_ring()
171 rx_queue->page_ring = NULL; in efx_fini_rx_recycle_ring()
174 static void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue, in efx_fini_rx_buffer() argument
183 efx_unmap_rx_buffer(rx_queue->efx, rx_buf); in efx_fini_rx_buffer()
184 efx_free_rx_buffers(rx_queue, rx_buf, 1); in efx_fini_rx_buffer()
189 int efx_probe_rx_queue(struct efx_rx_queue *rx_queue) in efx_probe_rx_queue() argument
191 struct efx_nic *efx = rx_queue->efx; in efx_probe_rx_queue()
198 rx_queue->ptr_mask = entries - 1; in efx_probe_rx_queue()
202 efx_rx_queue_index(rx_queue), efx->rxq_entries, in efx_probe_rx_queue()
203 rx_queue->ptr_mask); in efx_probe_rx_queue()
206 rx_queue->buffer = kcalloc(entries, sizeof(*rx_queue->buffer), in efx_probe_rx_queue()
208 if (!rx_queue->buffer) in efx_probe_rx_queue()
211 rc = efx_nic_probe_rx(rx_queue); in efx_probe_rx_queue()
213 kfree(rx_queue->buffer); in efx_probe_rx_queue()
214 rx_queue->buffer = NULL; in efx_probe_rx_queue()
220 void efx_init_rx_queue(struct efx_rx_queue *rx_queue) in efx_init_rx_queue() argument
223 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_queue()
226 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_init_rx_queue()
227 "initialising RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_init_rx_queue()
230 rx_queue->added_count = 0; in efx_init_rx_queue()
231 rx_queue->notified_count = 0; in efx_init_rx_queue()
232 rx_queue->granted_count = 0; in efx_init_rx_queue()
233 rx_queue->removed_count = 0; in efx_init_rx_queue()
234 rx_queue->min_fill = -1U; in efx_init_rx_queue()
235 efx_init_rx_recycle_ring(rx_queue); in efx_init_rx_queue()
237 rx_queue->page_remove = 0; in efx_init_rx_queue()
238 rx_queue->page_add = rx_queue->page_ptr_mask + 1; in efx_init_rx_queue()
239 rx_queue->page_recycle_count = 0; in efx_init_rx_queue()
240 rx_queue->page_recycle_failed = 0; in efx_init_rx_queue()
241 rx_queue->page_recycle_full = 0; in efx_init_rx_queue()
255 rx_queue->max_fill = max_fill; in efx_init_rx_queue()
256 rx_queue->fast_fill_trigger = trigger; in efx_init_rx_queue()
257 rx_queue->refill_enabled = true; in efx_init_rx_queue()
260 rc = xdp_rxq_info_reg(&rx_queue->xdp_rxq_info, efx->net_dev, in efx_init_rx_queue()
261 rx_queue->core_index, 0); in efx_init_rx_queue()
269 rx_queue->xdp_rxq_info_valid = true; in efx_init_rx_queue()
273 efx_nic_init_rx(rx_queue); in efx_init_rx_queue()
276 void efx_fini_rx_queue(struct efx_rx_queue *rx_queue) in efx_fini_rx_queue() argument
281 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, in efx_fini_rx_queue()
282 "shutting down RX queue %d\n", efx_rx_queue_index(rx_queue)); in efx_fini_rx_queue()
284 del_timer_sync(&rx_queue->slow_fill); in efx_fini_rx_queue()
285 if (rx_queue->grant_credits) in efx_fini_rx_queue()
286 flush_work(&rx_queue->grant_work); in efx_fini_rx_queue()
289 if (rx_queue->buffer) { in efx_fini_rx_queue()
290 for (i = rx_queue->removed_count; i < rx_queue->added_count; in efx_fini_rx_queue()
292 unsigned int index = i & rx_queue->ptr_mask; in efx_fini_rx_queue()
294 rx_buf = efx_rx_buffer(rx_queue, index); in efx_fini_rx_queue()
295 efx_fini_rx_buffer(rx_queue, rx_buf); in efx_fini_rx_queue()
299 efx_fini_rx_recycle_ring(rx_queue); in efx_fini_rx_queue()
301 if (rx_queue->xdp_rxq_info_valid) in efx_fini_rx_queue()
302 xdp_rxq_info_unreg(&rx_queue->xdp_rxq_info); in efx_fini_rx_queue()
304 rx_queue->xdp_rxq_info_valid = false; 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 = from_timer(rx_queue, t, slow_fill); in efx_rx_slow_fill() local
354 efx_nic_generate_fill_event(rx_queue); in efx_rx_slow_fill()
355 ++rx_queue->slow_fill_count; in efx_rx_slow_fill()
358 void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue) in efx_schedule_slow_fill() argument
360 mod_timer(&rx_queue->slow_fill, jiffies + msecs_to_jiffies(10)); in efx_schedule_slow_fill()
372 static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue, bool atomic) in efx_init_rx_buffers() argument
375 struct efx_nic *efx = rx_queue->efx; in efx_init_rx_buffers()
383 page = efx_reuse_page(rx_queue); in efx_init_rx_buffers()
410 index = rx_queue->added_count & rx_queue->ptr_mask; in efx_init_rx_buffers()
411 rx_buf = efx_rx_buffer(rx_queue, index); in efx_init_rx_buffers()
419 ++rx_queue->added_count; in efx_init_rx_buffers()
456 void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic) in efx_fast_push_rx_descriptors() argument
458 struct efx_nic *efx = rx_queue->efx; in efx_fast_push_rx_descriptors()
462 if (!rx_queue->refill_enabled) in efx_fast_push_rx_descriptors()
466 fill_level = (rx_queue->added_count - rx_queue->removed_count); in efx_fast_push_rx_descriptors()
467 EFX_WARN_ON_ONCE_PARANOID(fill_level > rx_queue->efx->rxq_entries); in efx_fast_push_rx_descriptors()
468 if (fill_level >= rx_queue->fast_fill_trigger) in efx_fast_push_rx_descriptors()
472 if (unlikely(fill_level < rx_queue->min_fill)) { in efx_fast_push_rx_descriptors()
474 rx_queue->min_fill = fill_level; in efx_fast_push_rx_descriptors()
478 space = rx_queue->max_fill - fill_level; in efx_fast_push_rx_descriptors()
481 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev, in efx_fast_push_rx_descriptors()
484 efx_rx_queue_index(rx_queue), fill_level, in efx_fast_push_rx_descriptors()
485 rx_queue->max_fill); in efx_fast_push_rx_descriptors()
488 rc = efx_init_rx_buffers(rx_queue, atomic); in efx_fast_push_rx_descriptors()
491 efx_schedule_slow_fill(rx_queue); in efx_fast_push_rx_descriptors()
496 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev, in efx_fast_push_rx_descriptors()
498 "to level %d\n", efx_rx_queue_index(rx_queue), in efx_fast_push_rx_descriptors()
499 rx_queue->added_count - rx_queue->removed_count); in efx_fast_push_rx_descriptors()
502 if (rx_queue->notified_count != rx_queue->added_count) in efx_fast_push_rx_descriptors()
503 efx_nic_notify_rx_desc(rx_queue); in efx_fast_push_rx_descriptors()
519 struct efx_rx_queue *rx_queue; in efx_rx_packet_gro() local
521 rx_queue = efx_channel_get_rx_queue(channel); in efx_rx_packet_gro()
522 efx_free_rx_buffers(rx_queue, rx_buf, n_frags); in efx_rx_packet_gro()
548 rx_buf = efx_rx_buf_next(&channel->rx_queue, rx_buf); in efx_rx_packet_gro()
554 skb_record_rx_queue(skb, channel->rx_queue.core_index); in efx_rx_packet_gro()