Lines Matching +full:prefetch +full:- +full:dma
1 // SPDX-License-Identifier: GPL-2.0
14 bool xdp_on = READ_ONCE(adapter->xdp_prog); in ixgbe_xsk_pool()
15 int qid = ring->ring_idx; in ixgbe_xsk_pool()
17 if (!xdp_on || !test_bit(qid, adapter->af_xdp_zc_qps)) in ixgbe_xsk_pool()
20 return xsk_get_pool_from_qid(adapter->netdev, qid); in ixgbe_xsk_pool()
27 struct net_device *netdev = adapter->netdev; in ixgbe_xsk_pool_enable()
31 if (qid >= adapter->num_rx_queues) in ixgbe_xsk_pool_enable()
32 return -EINVAL; in ixgbe_xsk_pool_enable()
34 if (qid >= netdev->real_num_rx_queues || in ixgbe_xsk_pool_enable()
35 qid >= netdev->real_num_tx_queues) in ixgbe_xsk_pool_enable()
36 return -EINVAL; in ixgbe_xsk_pool_enable()
38 err = xsk_pool_dma_map(pool, &adapter->pdev->dev, IXGBE_RX_DMA_ATTR); in ixgbe_xsk_pool_enable()
42 if_running = netif_running(adapter->netdev) && in ixgbe_xsk_pool_enable()
48 set_bit(qid, adapter->af_xdp_zc_qps); in ixgbe_xsk_pool_enable()
54 err = ixgbe_xsk_wakeup(adapter->netdev, qid, XDP_WAKEUP_RX); in ixgbe_xsk_pool_enable()
56 clear_bit(qid, adapter->af_xdp_zc_qps); in ixgbe_xsk_pool_enable()
70 pool = xsk_get_pool_from_qid(adapter->netdev, qid); in ixgbe_xsk_pool_disable()
72 return -EINVAL; in ixgbe_xsk_pool_disable()
74 if_running = netif_running(adapter->netdev) && in ixgbe_xsk_pool_disable()
80 clear_bit(qid, adapter->af_xdp_zc_qps); in ixgbe_xsk_pool_disable()
107 xdp_prog = READ_ONCE(rx_ring->xdp_prog); in ixgbe_run_xdp_zc()
111 err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); in ixgbe_run_xdp_zc()
114 if (xsk_uses_need_wakeup(rx_ring->xsk_pool) && err == -ENOBUFS) in ixgbe_run_xdp_zc()
130 spin_lock(&ring->tx_lock); in ixgbe_run_xdp_zc()
133 spin_unlock(&ring->tx_lock); in ixgbe_run_xdp_zc()
141 bpf_warn_invalid_xdp_action(rx_ring->netdev, xdp_prog, act); in ixgbe_run_xdp_zc()
146 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); in ixgbe_run_xdp_zc()
155 u16 i = rx_ring->next_to_use; in ixgbe_alloc_rx_buffers_zc()
156 dma_addr_t dma; in ixgbe_alloc_rx_buffers_zc() local
164 bi = &rx_ring->rx_buffer_info[i]; in ixgbe_alloc_rx_buffers_zc()
165 i -= rx_ring->count; in ixgbe_alloc_rx_buffers_zc()
168 bi->xdp = xsk_buff_alloc(rx_ring->xsk_pool); in ixgbe_alloc_rx_buffers_zc()
169 if (!bi->xdp) { in ixgbe_alloc_rx_buffers_zc()
174 dma = xsk_buff_xdp_get_dma(bi->xdp); in ixgbe_alloc_rx_buffers_zc()
177 * because each write-back erases this info. in ixgbe_alloc_rx_buffers_zc()
179 rx_desc->read.pkt_addr = cpu_to_le64(dma); in ixgbe_alloc_rx_buffers_zc()
186 bi = rx_ring->rx_buffer_info; in ixgbe_alloc_rx_buffers_zc()
187 i -= rx_ring->count; in ixgbe_alloc_rx_buffers_zc()
191 rx_desc->wb.upper.length = 0; in ixgbe_alloc_rx_buffers_zc()
193 count--; in ixgbe_alloc_rx_buffers_zc()
196 i += rx_ring->count; in ixgbe_alloc_rx_buffers_zc()
198 if (rx_ring->next_to_use != i) { in ixgbe_alloc_rx_buffers_zc()
199 rx_ring->next_to_use = i; in ixgbe_alloc_rx_buffers_zc()
203 * applicable for weak-ordered memory model archs, in ixgbe_alloc_rx_buffers_zc()
204 * such as IA-64). in ixgbe_alloc_rx_buffers_zc()
207 writel(i, rx_ring->tail); in ixgbe_alloc_rx_buffers_zc()
216 unsigned int totalsize = xdp->data_end - xdp->data_meta; in ixgbe_construct_skb_zc()
217 unsigned int metasize = xdp->data - xdp->data_meta; in ixgbe_construct_skb_zc()
220 net_prefetch(xdp->data_meta); in ixgbe_construct_skb_zc()
223 skb = __napi_alloc_skb(&rx_ring->q_vector->napi, totalsize, in ixgbe_construct_skb_zc()
228 memcpy(__skb_put(skb, totalsize), xdp->data_meta, in ixgbe_construct_skb_zc()
241 u32 ntc = rx_ring->next_to_clean + 1; in ixgbe_inc_ntc()
243 ntc = (ntc < rx_ring->count) ? ntc : 0; in ixgbe_inc_ntc()
244 rx_ring->next_to_clean = ntc; in ixgbe_inc_ntc()
245 prefetch(IXGBE_RX_DESC(rx_ring, ntc)); in ixgbe_inc_ntc()
253 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_clean_rx_irq_zc()
272 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ring->next_to_clean); in ixgbe_clean_rx_irq_zc()
273 size = le16_to_cpu(rx_desc->wb.upper.length); in ixgbe_clean_rx_irq_zc()
283 bi = &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; in ixgbe_clean_rx_irq_zc()
289 xsk_buff_free(bi->xdp); in ixgbe_clean_rx_irq_zc()
290 bi->xdp = NULL; in ixgbe_clean_rx_irq_zc()
293 &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; in ixgbe_clean_rx_irq_zc()
294 next_bi->discard = true; in ixgbe_clean_rx_irq_zc()
298 if (unlikely(bi->discard)) { in ixgbe_clean_rx_irq_zc()
299 xsk_buff_free(bi->xdp); in ixgbe_clean_rx_irq_zc()
300 bi->xdp = NULL; in ixgbe_clean_rx_irq_zc()
301 bi->discard = false; in ixgbe_clean_rx_irq_zc()
306 bi->xdp->data_end = bi->xdp->data + size; in ixgbe_clean_rx_irq_zc()
307 xsk_buff_dma_sync_for_cpu(bi->xdp, rx_ring->xsk_pool); in ixgbe_clean_rx_irq_zc()
308 xdp_res = ixgbe_run_xdp_zc(adapter, rx_ring, bi->xdp); in ixgbe_clean_rx_irq_zc()
316 xsk_buff_free(bi->xdp); in ixgbe_clean_rx_irq_zc()
321 bi->xdp = NULL; in ixgbe_clean_rx_irq_zc()
331 skb = ixgbe_construct_skb_zc(rx_ring, bi->xdp); in ixgbe_clean_rx_irq_zc()
333 rx_ring->rx_stats.alloc_rx_buff_failed++; in ixgbe_clean_rx_irq_zc()
337 xsk_buff_free(bi->xdp); in ixgbe_clean_rx_irq_zc()
338 bi->xdp = NULL; in ixgbe_clean_rx_irq_zc()
346 total_rx_bytes += skb->len; in ixgbe_clean_rx_irq_zc()
362 u64_stats_update_begin(&rx_ring->syncp); in ixgbe_clean_rx_irq_zc()
363 rx_ring->stats.packets += total_rx_packets; in ixgbe_clean_rx_irq_zc()
364 rx_ring->stats.bytes += total_rx_bytes; in ixgbe_clean_rx_irq_zc()
365 u64_stats_update_end(&rx_ring->syncp); in ixgbe_clean_rx_irq_zc()
366 q_vector->rx.total_packets += total_rx_packets; in ixgbe_clean_rx_irq_zc()
367 q_vector->rx.total_bytes += total_rx_bytes; in ixgbe_clean_rx_irq_zc()
369 if (xsk_uses_need_wakeup(rx_ring->xsk_pool)) { in ixgbe_clean_rx_irq_zc()
370 if (failure || rx_ring->next_to_clean == rx_ring->next_to_use) in ixgbe_clean_rx_irq_zc()
371 xsk_set_rx_need_wakeup(rx_ring->xsk_pool); in ixgbe_clean_rx_irq_zc()
373 xsk_clear_rx_need_wakeup(rx_ring->xsk_pool); in ixgbe_clean_rx_irq_zc()
385 for (i = 0; i < rx_ring->count; i++) { in ixgbe_xsk_clean_rx_ring()
386 bi = &rx_ring->rx_buffer_info[i]; in ixgbe_xsk_clean_rx_ring()
388 if (!bi->xdp) in ixgbe_xsk_clean_rx_ring()
391 xsk_buff_free(bi->xdp); in ixgbe_xsk_clean_rx_ring()
392 bi->xdp = NULL; in ixgbe_xsk_clean_rx_ring()
398 struct xsk_buff_pool *pool = xdp_ring->xsk_pool; in ixgbe_xmit_zc()
403 dma_addr_t dma; in ixgbe_xmit_zc() local
406 while (budget-- > 0) { in ixgbe_xmit_zc()
412 if (!netif_carrier_ok(xdp_ring->netdev)) in ixgbe_xmit_zc()
418 dma = xsk_buff_raw_get_dma(pool, desc.addr); in ixgbe_xmit_zc()
419 xsk_buff_raw_dma_sync_for_device(pool, dma, desc.len); in ixgbe_xmit_zc()
421 tx_bi = &xdp_ring->tx_buffer_info[xdp_ring->next_to_use]; in ixgbe_xmit_zc()
422 tx_bi->bytecount = desc.len; in ixgbe_xmit_zc()
423 tx_bi->xdpf = NULL; in ixgbe_xmit_zc()
424 tx_bi->gso_segs = 1; in ixgbe_xmit_zc()
426 tx_desc = IXGBE_TX_DESC(xdp_ring, xdp_ring->next_to_use); in ixgbe_xmit_zc()
427 tx_desc->read.buffer_addr = cpu_to_le64(dma); in ixgbe_xmit_zc()
434 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type); in ixgbe_xmit_zc()
435 tx_desc->read.olinfo_status = in ixgbe_xmit_zc()
438 xdp_ring->next_to_use++; in ixgbe_xmit_zc()
439 if (xdp_ring->next_to_use == xdp_ring->count) in ixgbe_xmit_zc()
440 xdp_ring->next_to_use = 0; in ixgbe_xmit_zc()
454 xdp_return_frame(tx_bi->xdpf); in ixgbe_clean_xdp_tx_buffer()
455 dma_unmap_single(tx_ring->dev, in ixgbe_clean_xdp_tx_buffer()
456 dma_unmap_addr(tx_bi, dma), in ixgbe_clean_xdp_tx_buffer()
464 u16 ntc = tx_ring->next_to_clean, ntu = tx_ring->next_to_use; in ixgbe_clean_xdp_tx_irq()
466 struct xsk_buff_pool *pool = tx_ring->xsk_pool; in ixgbe_clean_xdp_tx_irq()
471 tx_bi = &tx_ring->tx_buffer_info[ntc]; in ixgbe_clean_xdp_tx_irq()
475 if (!(tx_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD))) in ixgbe_clean_xdp_tx_irq()
478 total_bytes += tx_bi->bytecount; in ixgbe_clean_xdp_tx_irq()
479 total_packets += tx_bi->gso_segs; in ixgbe_clean_xdp_tx_irq()
481 if (tx_bi->xdpf) in ixgbe_clean_xdp_tx_irq()
486 tx_bi->xdpf = NULL; in ixgbe_clean_xdp_tx_irq()
491 if (unlikely(ntc == tx_ring->count)) { in ixgbe_clean_xdp_tx_irq()
493 tx_bi = tx_ring->tx_buffer_info; in ixgbe_clean_xdp_tx_irq()
497 /* issue prefetch for next Tx descriptor */ in ixgbe_clean_xdp_tx_irq()
498 prefetch(tx_desc); in ixgbe_clean_xdp_tx_irq()
501 tx_ring->next_to_clean = ntc; in ixgbe_clean_xdp_tx_irq()
503 u64_stats_update_begin(&tx_ring->syncp); in ixgbe_clean_xdp_tx_irq()
504 tx_ring->stats.bytes += total_bytes; in ixgbe_clean_xdp_tx_irq()
505 tx_ring->stats.packets += total_packets; in ixgbe_clean_xdp_tx_irq()
506 u64_stats_update_end(&tx_ring->syncp); in ixgbe_clean_xdp_tx_irq()
507 q_vector->tx.total_bytes += total_bytes; in ixgbe_clean_xdp_tx_irq()
508 q_vector->tx.total_packets += total_packets; in ixgbe_clean_xdp_tx_irq()
516 return ixgbe_xmit_zc(tx_ring, q_vector->tx.work_limit); in ixgbe_clean_xdp_tx_irq()
524 if (test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_xsk_wakeup()
525 return -ENETDOWN; in ixgbe_xsk_wakeup()
527 if (!READ_ONCE(adapter->xdp_prog)) in ixgbe_xsk_wakeup()
528 return -EINVAL; in ixgbe_xsk_wakeup()
530 if (qid >= adapter->num_xdp_queues) in ixgbe_xsk_wakeup()
531 return -EINVAL; in ixgbe_xsk_wakeup()
533 ring = adapter->xdp_ring[qid]; in ixgbe_xsk_wakeup()
535 if (test_bit(__IXGBE_TX_DISABLED, &ring->state)) in ixgbe_xsk_wakeup()
536 return -ENETDOWN; in ixgbe_xsk_wakeup()
538 if (!ring->xsk_pool) in ixgbe_xsk_wakeup()
539 return -EINVAL; in ixgbe_xsk_wakeup()
541 if (!napi_if_scheduled_mark_missed(&ring->q_vector->napi)) { in ixgbe_xsk_wakeup()
542 u64 eics = BIT_ULL(ring->q_vector->v_idx); in ixgbe_xsk_wakeup()
552 u16 ntc = tx_ring->next_to_clean, ntu = tx_ring->next_to_use; in ixgbe_xsk_clean_tx_ring()
553 struct xsk_buff_pool *pool = tx_ring->xsk_pool; in ixgbe_xsk_clean_tx_ring()
558 tx_bi = &tx_ring->tx_buffer_info[ntc]; in ixgbe_xsk_clean_tx_ring()
560 if (tx_bi->xdpf) in ixgbe_xsk_clean_tx_ring()
565 tx_bi->xdpf = NULL; in ixgbe_xsk_clean_tx_ring()
568 if (ntc == tx_ring->count) in ixgbe_xsk_clean_tx_ring()