Lines Matching +full:pa +full:- +full:stats
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2014-2019 aQuantia Corporation
5 * Copyright (C) 2019-2020 Marvell International Ltd.
32 for (i = 0; i < sinfo->nr_frags; i++) { in aq_get_rxpages_xdp()
33 skb_frag_t *frag = &sinfo->frags[i]; in aq_get_rxpages_xdp()
38 page_ref_inc(buff->rxdata.page); in aq_get_rxpages_xdp()
43 unsigned int len = PAGE_SIZE << rxpage->order; in aq_free_rxpage()
45 dma_unmap_page(dev, rxpage->daddr, len, DMA_FROM_DEVICE); in aq_free_rxpage()
48 __free_pages(rxpage->page, rxpage->order); in aq_free_rxpage()
49 rxpage->page = NULL; in aq_free_rxpage()
54 struct device *dev = aq_nic_get_dev(rx_ring->aq_nic); in aq_alloc_rxpages()
55 unsigned int order = rx_ring->page_order; in aq_alloc_rxpages()
57 int ret = -ENOMEM; in aq_alloc_rxpages()
70 rxpage->page = page; in aq_alloc_rxpages()
71 rxpage->daddr = daddr; in aq_alloc_rxpages()
72 rxpage->order = order; in aq_alloc_rxpages()
73 rxpage->pg_off = rx_ring->page_offset; in aq_alloc_rxpages()
86 unsigned int order = self->page_order; in aq_get_rxpages()
87 u16 page_offset = self->page_offset; in aq_get_rxpages()
88 u16 frame_max = self->frame_max; in aq_get_rxpages()
89 u16 tail_size = self->tail_size; in aq_get_rxpages()
92 if (rxbuf->rxdata.page) { in aq_get_rxpages()
94 if (page_ref_count(rxbuf->rxdata.page) > 1) { in aq_get_rxpages()
96 rxbuf->rxdata.pg_off += frame_max + page_offset + in aq_get_rxpages()
98 if (rxbuf->rxdata.pg_off + frame_max + tail_size <= in aq_get_rxpages()
100 u64_stats_update_begin(&self->stats.rx.syncp); in aq_get_rxpages()
101 self->stats.rx.pg_flips++; in aq_get_rxpages()
102 u64_stats_update_end(&self->stats.rx.syncp); in aq_get_rxpages()
108 aq_free_rxpage(&rxbuf->rxdata, in aq_get_rxpages()
109 aq_nic_get_dev(self->aq_nic)); in aq_get_rxpages()
110 u64_stats_update_begin(&self->stats.rx.syncp); in aq_get_rxpages()
111 self->stats.rx.pg_losts++; in aq_get_rxpages()
112 u64_stats_update_end(&self->stats.rx.syncp); in aq_get_rxpages()
115 rxbuf->rxdata.pg_off = page_offset; in aq_get_rxpages()
116 u64_stats_update_begin(&self->stats.rx.syncp); in aq_get_rxpages()
117 self->stats.rx.pg_reuses++; in aq_get_rxpages()
118 u64_stats_update_end(&self->stats.rx.syncp); in aq_get_rxpages()
122 if (!rxbuf->rxdata.page) { in aq_get_rxpages()
123 ret = aq_alloc_rxpages(&rxbuf->rxdata, self); in aq_get_rxpages()
125 u64_stats_update_begin(&self->stats.rx.syncp); in aq_get_rxpages()
126 self->stats.rx.alloc_fails++; in aq_get_rxpages()
127 u64_stats_update_end(&self->stats.rx.syncp); in aq_get_rxpages()
140 self->buff_ring = in aq_ring_alloc()
141 kcalloc(self->size, sizeof(struct aq_ring_buff_s), GFP_KERNEL); in aq_ring_alloc()
143 if (!self->buff_ring) { in aq_ring_alloc()
144 err = -ENOMEM; in aq_ring_alloc()
148 self->dx_ring = dma_alloc_coherent(aq_nic_get_dev(aq_nic), in aq_ring_alloc()
149 self->size * self->dx_size, in aq_ring_alloc()
150 &self->dx_ring_pa, GFP_KERNEL); in aq_ring_alloc()
151 if (!self->dx_ring) { in aq_ring_alloc()
152 err = -ENOMEM; in aq_ring_alloc()
169 self->aq_nic = aq_nic; in aq_ring_tx_alloc()
170 self->idx = idx; in aq_ring_tx_alloc()
171 self->size = aq_nic_cfg->txds; in aq_ring_tx_alloc()
172 self->dx_size = aq_nic_cfg->aq_hw_caps->txd_size; in aq_ring_tx_alloc()
182 self->aq_nic = aq_nic; in aq_ring_rx_alloc()
183 self->idx = idx; in aq_ring_rx_alloc()
184 self->size = aq_nic_cfg->rxds; in aq_ring_rx_alloc()
185 self->dx_size = aq_nic_cfg->aq_hw_caps->rxd_size; in aq_ring_rx_alloc()
186 self->xdp_prog = aq_nic->xdp_prog; in aq_ring_rx_alloc()
187 self->frame_max = AQ_CFG_RX_FRAME_MAX; in aq_ring_rx_alloc()
189 /* Only order-2 is allowed if XDP is enabled */ in aq_ring_rx_alloc()
190 if (READ_ONCE(self->xdp_prog)) { in aq_ring_rx_alloc()
191 self->page_offset = AQ_XDP_HEADROOM; in aq_ring_rx_alloc()
192 self->page_order = AQ_CFG_XDP_PAGEORDER; in aq_ring_rx_alloc()
193 self->tail_size = AQ_XDP_TAILROOM; in aq_ring_rx_alloc()
195 self->page_offset = 0; in aq_ring_rx_alloc()
196 self->page_order = fls(self->frame_max / PAGE_SIZE + in aq_ring_rx_alloc()
197 (self->frame_max % PAGE_SIZE ? 1 : 0)) - 1; in aq_ring_rx_alloc()
198 if (aq_nic_cfg->rxpageorder > self->page_order) in aq_ring_rx_alloc()
199 self->page_order = aq_nic_cfg->rxpageorder; in aq_ring_rx_alloc()
200 self->tail_size = 0; in aq_ring_rx_alloc()
215 self->aq_nic = aq_nic; in aq_ring_hwts_rx_alloc()
216 self->idx = idx; in aq_ring_hwts_rx_alloc()
217 self->size = size; in aq_ring_hwts_rx_alloc()
218 self->dx_size = dx_size; in aq_ring_hwts_rx_alloc()
220 self->dx_ring = dma_alloc_coherent(dev, sz, &self->dx_ring_pa, in aq_ring_hwts_rx_alloc()
222 if (!self->dx_ring) { in aq_ring_hwts_rx_alloc()
224 return -ENOMEM; in aq_ring_hwts_rx_alloc()
232 self->hw_head = 0; in aq_ring_init()
233 self->sw_head = 0; in aq_ring_init()
234 self->sw_tail = 0; in aq_ring_init()
235 self->ring_type = ring_type; in aq_ring_init()
237 if (self->ring_type == ATL_RING_RX) in aq_ring_init()
238 u64_stats_init(&self->stats.rx.syncp); in aq_ring_init()
240 u64_stats_init(&self->stats.tx.syncp); in aq_ring_init()
261 struct net_device *ndev = aq_nic_get_ndev(ring->aq_nic); in aq_ring_queue_wake()
264 AQ_NIC_RING2QMAP(ring->aq_nic, in aq_ring_queue_wake()
265 ring->idx))) { in aq_ring_queue_wake()
267 AQ_NIC_RING2QMAP(ring->aq_nic, ring->idx)); in aq_ring_queue_wake()
268 u64_stats_update_begin(&ring->stats.tx.syncp); in aq_ring_queue_wake()
269 ring->stats.tx.queue_restarts++; in aq_ring_queue_wake()
270 u64_stats_update_end(&ring->stats.tx.syncp); in aq_ring_queue_wake()
276 struct net_device *ndev = aq_nic_get_ndev(ring->aq_nic); in aq_ring_queue_stop()
279 AQ_NIC_RING2QMAP(ring->aq_nic, in aq_ring_queue_stop()
280 ring->idx))) in aq_ring_queue_stop()
282 AQ_NIC_RING2QMAP(ring->aq_nic, ring->idx)); in aq_ring_queue_stop()
287 struct device *dev = aq_nic_get_dev(self->aq_nic); in aq_ring_tx_clean()
291 budget && self->sw_head != self->hw_head; budget--) { in aq_ring_tx_clean()
292 struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; in aq_ring_tx_clean()
294 if (likely(buff->is_mapped)) { in aq_ring_tx_clean()
295 if (unlikely(buff->is_sop)) { in aq_ring_tx_clean()
296 if (!buff->is_eop && in aq_ring_tx_clean()
297 buff->eop_index != 0xffffU && in aq_ring_tx_clean()
298 (!aq_ring_dx_in_range(self->sw_head, in aq_ring_tx_clean()
299 buff->eop_index, in aq_ring_tx_clean()
300 self->hw_head))) in aq_ring_tx_clean()
303 dma_unmap_single(dev, buff->pa, buff->len, in aq_ring_tx_clean()
306 dma_unmap_page(dev, buff->pa, buff->len, in aq_ring_tx_clean()
311 if (likely(!buff->is_eop)) in aq_ring_tx_clean()
314 if (buff->skb) { in aq_ring_tx_clean()
315 u64_stats_update_begin(&self->stats.tx.syncp); in aq_ring_tx_clean()
316 ++self->stats.tx.packets; in aq_ring_tx_clean()
317 self->stats.tx.bytes += buff->skb->len; in aq_ring_tx_clean()
318 u64_stats_update_end(&self->stats.tx.syncp); in aq_ring_tx_clean()
319 dev_kfree_skb_any(buff->skb); in aq_ring_tx_clean()
320 } else if (buff->xdpf) { in aq_ring_tx_clean()
321 u64_stats_update_begin(&self->stats.tx.syncp); in aq_ring_tx_clean()
322 ++self->stats.tx.packets; in aq_ring_tx_clean()
323 self->stats.tx.bytes += xdp_get_frame_len(buff->xdpf); in aq_ring_tx_clean()
324 u64_stats_update_end(&self->stats.tx.syncp); in aq_ring_tx_clean()
325 xdp_return_frame_rx_napi(buff->xdpf); in aq_ring_tx_clean()
329 buff->skb = NULL; in aq_ring_tx_clean()
330 buff->xdpf = NULL; in aq_ring_tx_clean()
331 buff->pa = 0U; in aq_ring_tx_clean()
332 buff->eop_index = 0xffffU; in aq_ring_tx_clean()
333 self->sw_head = aq_ring_next_dx(self, self->sw_head); in aq_ring_tx_clean()
343 if (!(self->aq_nic->ndev->features & NETIF_F_RXCSUM)) in aq_rx_checksum()
346 if (unlikely(buff->is_cso_err)) { in aq_rx_checksum()
347 u64_stats_update_begin(&self->stats.rx.syncp); in aq_rx_checksum()
348 ++self->stats.rx.errors; in aq_rx_checksum()
349 u64_stats_update_end(&self->stats.rx.syncp); in aq_rx_checksum()
350 skb->ip_summed = CHECKSUM_NONE; in aq_rx_checksum()
353 if (buff->is_ip_cso) { in aq_rx_checksum()
356 skb->ip_summed = CHECKSUM_NONE; in aq_rx_checksum()
359 if (buff->is_udp_cso || buff->is_tcp_cso) in aq_rx_checksum()
373 vec = cpu % aq_cfg->vecs; in aq_xdp_xmit()
374 ring = aq_nic->aq_ring_tx[AQ_NIC_CFG_TCVEC2RING(aq_cfg, 0, vec)]; in aq_xdp_xmit()
383 return num_frames - drop; in aq_xdp_xmit()
417 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
418 ++rx_ring->stats.rx.packets; in aq_xdp_run_prog()
419 rx_ring->stats.rx.bytes += xdp_get_buff_len(xdp); in aq_xdp_run_prog()
420 u64_stats_update_end(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
422 prog = READ_ONCE(rx_ring->xdp_prog); in aq_xdp_run_prog()
424 return aq_xdp_build_skb(xdp, aq_nic->ndev, buff); in aq_xdp_run_prog()
426 prefetchw(xdp->data_hard_start); /* xdp_frame write */ in aq_xdp_run_prog()
429 if (xdp_buff_has_frags(xdp) && !prog->aux->xdp_has_frags) in aq_xdp_run_prog()
435 skb = aq_xdp_build_skb(xdp, aq_nic->ndev, buff); in aq_xdp_run_prog()
438 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
439 ++rx_ring->stats.rx.xdp_pass; in aq_xdp_run_prog()
440 u64_stats_update_end(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
446 tx_ring = aq_nic->aq_ring_tx[rx_ring->idx]; in aq_xdp_run_prog()
450 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
451 ++rx_ring->stats.rx.xdp_tx; in aq_xdp_run_prog()
452 u64_stats_update_end(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
456 if (xdp_do_redirect(aq_nic->ndev, xdp, prog) < 0) in aq_xdp_run_prog()
459 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
460 ++rx_ring->stats.rx.xdp_redirect; in aq_xdp_run_prog()
461 u64_stats_update_end(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
468 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
469 ++rx_ring->stats.rx.xdp_aborted; in aq_xdp_run_prog()
470 u64_stats_update_end(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
471 trace_xdp_exception(aq_nic->ndev, prog, act); in aq_xdp_run_prog()
472 bpf_warn_invalid_xdp_action(aq_nic->ndev, prog, act); in aq_xdp_run_prog()
475 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
476 ++rx_ring->stats.rx.xdp_drop; in aq_xdp_run_prog()
477 u64_stats_update_end(&rx_ring->stats.rx.syncp); in aq_xdp_run_prog()
481 return ERR_PTR(-result); in aq_xdp_run_prog()
496 if (unlikely(sinfo->nr_frags >= MAX_SKB_FRAGS)) in aq_add_rx_fragment()
499 frag = &sinfo->frags[sinfo->nr_frags++]; in aq_add_rx_fragment()
500 buff_ = &ring->buff_ring[buff_->next]; in aq_add_rx_fragment()
502 buff_->rxdata.daddr, in aq_add_rx_fragment()
503 buff_->rxdata.pg_off, in aq_add_rx_fragment()
504 buff_->len, in aq_add_rx_fragment()
506 sinfo->xdp_frags_size += buff_->len; in aq_add_rx_fragment()
507 skb_frag_fill_page_desc(frag, buff_->rxdata.page, in aq_add_rx_fragment()
508 buff_->rxdata.pg_off, in aq_add_rx_fragment()
509 buff_->len); in aq_add_rx_fragment()
511 buff_->is_cleaned = 1; in aq_add_rx_fragment()
513 buff->is_ip_cso &= buff_->is_ip_cso; in aq_add_rx_fragment()
514 buff->is_udp_cso &= buff_->is_udp_cso; in aq_add_rx_fragment()
515 buff->is_tcp_cso &= buff_->is_tcp_cso; in aq_add_rx_fragment()
516 buff->is_cso_err |= buff_->is_cso_err; in aq_add_rx_fragment()
518 if (page_is_pfmemalloc(buff_->rxdata.page)) in aq_add_rx_fragment()
521 } while (!buff_->is_eop); in aq_add_rx_fragment()
531 struct net_device *ndev = aq_nic_get_ndev(self->aq_nic); in __aq_ring_rx_clean()
534 for (; (self->sw_head != self->hw_head) && budget; in __aq_ring_rx_clean()
535 self->sw_head = aq_ring_next_dx(self, self->sw_head), in __aq_ring_rx_clean()
536 --budget, ++(*work_done)) { in __aq_ring_rx_clean()
537 struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; in __aq_ring_rx_clean()
538 bool is_ptp_ring = aq_ptp_ring(self->aq_nic, self); in __aq_ring_rx_clean()
545 if (buff->is_cleaned) in __aq_ring_rx_clean()
548 if (!buff->is_eop) { in __aq_ring_rx_clean()
554 if (buff_->next >= self->size) { in __aq_ring_rx_clean()
555 err = -EIO; in __aq_ring_rx_clean()
560 next_ = buff_->next; in __aq_ring_rx_clean()
561 buff_ = &self->buff_ring[next_]; in __aq_ring_rx_clean()
563 aq_ring_dx_in_range(self->sw_head, in __aq_ring_rx_clean()
565 self->hw_head); in __aq_ring_rx_clean()
573 buff->is_error |= buff_->is_error; in __aq_ring_rx_clean()
574 buff->is_cso_err |= buff_->is_cso_err; in __aq_ring_rx_clean()
576 } while (!buff_->is_eop); in __aq_ring_rx_clean()
578 if (buff->is_error || in __aq_ring_rx_clean()
579 (buff->is_lro && buff->is_cso_err)) { in __aq_ring_rx_clean()
582 if (buff_->next >= self->size) { in __aq_ring_rx_clean()
583 err = -EIO; in __aq_ring_rx_clean()
586 next_ = buff_->next; in __aq_ring_rx_clean()
587 buff_ = &self->buff_ring[next_]; in __aq_ring_rx_clean()
589 buff_->is_cleaned = true; in __aq_ring_rx_clean()
590 } while (!buff_->is_eop); in __aq_ring_rx_clean()
592 u64_stats_update_begin(&self->stats.rx.syncp); in __aq_ring_rx_clean()
593 ++self->stats.rx.errors; in __aq_ring_rx_clean()
594 u64_stats_update_end(&self->stats.rx.syncp); in __aq_ring_rx_clean()
599 if (buff->is_error) { in __aq_ring_rx_clean()
600 u64_stats_update_begin(&self->stats.rx.syncp); in __aq_ring_rx_clean()
601 ++self->stats.rx.errors; in __aq_ring_rx_clean()
602 u64_stats_update_end(&self->stats.rx.syncp); in __aq_ring_rx_clean()
606 dma_sync_single_range_for_cpu(aq_nic_get_dev(self->aq_nic), in __aq_ring_rx_clean()
607 buff->rxdata.daddr, in __aq_ring_rx_clean()
608 buff->rxdata.pg_off, in __aq_ring_rx_clean()
609 buff->len, DMA_FROM_DEVICE); in __aq_ring_rx_clean()
613 u64_stats_update_begin(&self->stats.rx.syncp); in __aq_ring_rx_clean()
614 self->stats.rx.skb_alloc_fails++; in __aq_ring_rx_clean()
615 u64_stats_update_end(&self->stats.rx.syncp); in __aq_ring_rx_clean()
616 err = -ENOMEM; in __aq_ring_rx_clean()
620 buff->len -= in __aq_ring_rx_clean()
621 aq_ptp_extract_ts(self->aq_nic, skb_hwtstamps(skb), in __aq_ring_rx_clean()
622 aq_buf_vaddr(&buff->rxdata), in __aq_ring_rx_clean()
623 buff->len); in __aq_ring_rx_clean()
625 hdr_len = buff->len; in __aq_ring_rx_clean()
627 hdr_len = eth_get_headlen(skb->dev, in __aq_ring_rx_clean()
628 aq_buf_vaddr(&buff->rxdata), in __aq_ring_rx_clean()
631 memcpy(__skb_put(skb, hdr_len), aq_buf_vaddr(&buff->rxdata), in __aq_ring_rx_clean()
634 if (buff->len - hdr_len > 0) { in __aq_ring_rx_clean()
635 skb_add_rx_frag(skb, i++, buff->rxdata.page, in __aq_ring_rx_clean()
636 buff->rxdata.pg_off + hdr_len, in __aq_ring_rx_clean()
637 buff->len - hdr_len, in __aq_ring_rx_clean()
638 self->frame_max); in __aq_ring_rx_clean()
639 page_ref_inc(buff->rxdata.page); in __aq_ring_rx_clean()
642 if (!buff->is_eop) { in __aq_ring_rx_clean()
645 next_ = buff_->next; in __aq_ring_rx_clean()
646 buff_ = &self->buff_ring[next_]; in __aq_ring_rx_clean()
648 dma_sync_single_range_for_cpu(aq_nic_get_dev(self->aq_nic), in __aq_ring_rx_clean()
649 buff_->rxdata.daddr, in __aq_ring_rx_clean()
650 buff_->rxdata.pg_off, in __aq_ring_rx_clean()
651 buff_->len, in __aq_ring_rx_clean()
654 buff_->rxdata.page, in __aq_ring_rx_clean()
655 buff_->rxdata.pg_off, in __aq_ring_rx_clean()
656 buff_->len, in __aq_ring_rx_clean()
657 self->frame_max); in __aq_ring_rx_clean()
658 page_ref_inc(buff_->rxdata.page); in __aq_ring_rx_clean()
659 buff_->is_cleaned = 1; in __aq_ring_rx_clean()
661 buff->is_ip_cso &= buff_->is_ip_cso; in __aq_ring_rx_clean()
662 buff->is_udp_cso &= buff_->is_udp_cso; in __aq_ring_rx_clean()
663 buff->is_tcp_cso &= buff_->is_tcp_cso; in __aq_ring_rx_clean()
664 buff->is_cso_err |= buff_->is_cso_err; in __aq_ring_rx_clean()
666 } while (!buff_->is_eop); in __aq_ring_rx_clean()
669 if (buff->is_vlan) in __aq_ring_rx_clean()
671 buff->vlan_rx_tag); in __aq_ring_rx_clean()
673 skb->protocol = eth_type_trans(skb, ndev); in __aq_ring_rx_clean()
677 skb_set_hash(skb, buff->rss_hash, in __aq_ring_rx_clean()
678 buff->is_hash_l4 ? PKT_HASH_TYPE_L4 : in __aq_ring_rx_clean()
683 : AQ_NIC_RING2QMAP(self->aq_nic, in __aq_ring_rx_clean()
684 self->idx)); in __aq_ring_rx_clean()
686 u64_stats_update_begin(&self->stats.rx.syncp); in __aq_ring_rx_clean()
687 ++self->stats.rx.packets; in __aq_ring_rx_clean()
688 self->stats.rx.bytes += skb->len; in __aq_ring_rx_clean()
689 u64_stats_update_end(&self->stats.rx.syncp); in __aq_ring_rx_clean()
702 int frame_sz = rx_ring->page_offset + rx_ring->frame_max + in __aq_ring_xdp_clean()
703 rx_ring->tail_size; in __aq_ring_xdp_clean()
704 struct aq_nic_s *aq_nic = rx_ring->aq_nic; in __aq_ring_xdp_clean()
710 for (; (rx_ring->sw_head != rx_ring->hw_head) && budget; in __aq_ring_xdp_clean()
711 rx_ring->sw_head = aq_ring_next_dx(rx_ring, rx_ring->sw_head), in __aq_ring_xdp_clean()
712 --budget, ++(*work_done)) { in __aq_ring_xdp_clean()
713 struct aq_ring_buff_s *buff = &rx_ring->buff_ring[rx_ring->sw_head]; in __aq_ring_xdp_clean()
714 bool is_ptp_ring = aq_ptp_ring(rx_ring->aq_nic, rx_ring); in __aq_ring_xdp_clean()
723 if (buff->is_cleaned) in __aq_ring_xdp_clean()
726 if (!buff->is_eop) { in __aq_ring_xdp_clean()
729 if (buff_->next >= rx_ring->size) { in __aq_ring_xdp_clean()
730 err = -EIO; in __aq_ring_xdp_clean()
733 next_ = buff_->next; in __aq_ring_xdp_clean()
734 buff_ = &rx_ring->buff_ring[next_]; in __aq_ring_xdp_clean()
736 aq_ring_dx_in_range(rx_ring->sw_head, in __aq_ring_xdp_clean()
738 rx_ring->hw_head); in __aq_ring_xdp_clean()
743 buff->is_error |= buff_->is_error; in __aq_ring_xdp_clean()
744 buff->is_cso_err |= buff_->is_cso_err; in __aq_ring_xdp_clean()
745 } while (!buff_->is_eop); in __aq_ring_xdp_clean()
751 if (buff->is_error || in __aq_ring_xdp_clean()
752 (buff->is_lro && buff->is_cso_err)) { in __aq_ring_xdp_clean()
755 if (buff_->next >= rx_ring->size) { in __aq_ring_xdp_clean()
756 err = -EIO; in __aq_ring_xdp_clean()
759 next_ = buff_->next; in __aq_ring_xdp_clean()
760 buff_ = &rx_ring->buff_ring[next_]; in __aq_ring_xdp_clean()
762 buff_->is_cleaned = true; in __aq_ring_xdp_clean()
763 } while (!buff_->is_eop); in __aq_ring_xdp_clean()
765 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in __aq_ring_xdp_clean()
766 ++rx_ring->stats.rx.errors; in __aq_ring_xdp_clean()
767 u64_stats_update_end(&rx_ring->stats.rx.syncp); in __aq_ring_xdp_clean()
772 if (buff->is_error) { in __aq_ring_xdp_clean()
773 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in __aq_ring_xdp_clean()
774 ++rx_ring->stats.rx.errors; in __aq_ring_xdp_clean()
775 u64_stats_update_end(&rx_ring->stats.rx.syncp); in __aq_ring_xdp_clean()
780 buff->rxdata.daddr, in __aq_ring_xdp_clean()
781 buff->rxdata.pg_off, in __aq_ring_xdp_clean()
782 buff->len, DMA_FROM_DEVICE); in __aq_ring_xdp_clean()
783 hard_start = page_address(buff->rxdata.page) + in __aq_ring_xdp_clean()
784 buff->rxdata.pg_off - rx_ring->page_offset; in __aq_ring_xdp_clean()
787 ptp_hwtstamp_len = aq_ptp_extract_ts(rx_ring->aq_nic, &shhwtstamps, in __aq_ring_xdp_clean()
788 aq_buf_vaddr(&buff->rxdata), in __aq_ring_xdp_clean()
789 buff->len); in __aq_ring_xdp_clean()
790 buff->len -= ptp_hwtstamp_len; in __aq_ring_xdp_clean()
793 xdp_init_buff(&xdp, frame_sz, &rx_ring->xdp_rxq); in __aq_ring_xdp_clean()
794 xdp_prepare_buff(&xdp, hard_start, rx_ring->page_offset, in __aq_ring_xdp_clean()
795 buff->len, false); in __aq_ring_xdp_clean()
796 if (!buff->is_eop) { in __aq_ring_xdp_clean()
798 u64_stats_update_begin(&rx_ring->stats.rx.syncp); in __aq_ring_xdp_clean()
799 ++rx_ring->stats.rx.packets; in __aq_ring_xdp_clean()
800 rx_ring->stats.rx.bytes += xdp_get_buff_len(&xdp); in __aq_ring_xdp_clean()
801 ++rx_ring->stats.rx.xdp_aborted; in __aq_ring_xdp_clean()
802 u64_stats_update_end(&rx_ring->stats.rx.syncp); in __aq_ring_xdp_clean()
814 if (buff->is_vlan) in __aq_ring_xdp_clean()
816 buff->vlan_rx_tag); in __aq_ring_xdp_clean()
820 skb_set_hash(skb, buff->rss_hash, in __aq_ring_xdp_clean()
821 buff->is_hash_l4 ? PKT_HASH_TYPE_L4 : in __aq_ring_xdp_clean()
826 : AQ_NIC_RING2QMAP(rx_ring->aq_nic, in __aq_ring_xdp_clean()
827 rx_ring->idx)); in __aq_ring_xdp_clean()
850 while (self->sw_head != self->hw_head) { in aq_ring_hwts_rx_clean()
853 aq_nic->aq_hw_ops->extract_hwts(aq_nic->aq_hw, in aq_ring_hwts_rx_clean()
854 self->dx_ring + in aq_ring_hwts_rx_clean()
855 (self->sw_head * self->dx_size), in aq_ring_hwts_rx_clean()
856 self->dx_size, &ns); in aq_ring_hwts_rx_clean()
859 self->sw_head = aq_ring_next_dx(self, self->sw_head); in aq_ring_hwts_rx_clean()
871 self->size / 2)) in aq_ring_rx_fill()
874 for (i = aq_ring_avail_dx(self); i--; in aq_ring_rx_fill()
875 self->sw_tail = aq_ring_next_dx(self, self->sw_tail)) { in aq_ring_rx_fill()
876 buff = &self->buff_ring[self->sw_tail]; in aq_ring_rx_fill()
878 buff->flags = 0U; in aq_ring_rx_fill()
879 buff->len = self->frame_max; in aq_ring_rx_fill()
885 buff->pa = aq_buf_daddr(&buff->rxdata); in aq_ring_rx_fill()
898 for (; self->sw_head != self->sw_tail; in aq_ring_rx_deinit()
899 self->sw_head = aq_ring_next_dx(self, self->sw_head)) { in aq_ring_rx_deinit()
900 struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; in aq_ring_rx_deinit()
902 aq_free_rxpage(&buff->rxdata, aq_nic_get_dev(self->aq_nic)); in aq_ring_rx_deinit()
911 kfree(self->buff_ring); in aq_ring_free()
912 self->buff_ring = NULL; in aq_ring_free()
914 if (self->dx_ring) { in aq_ring_free()
915 dma_free_coherent(aq_nic_get_dev(self->aq_nic), in aq_ring_free()
916 self->size * self->dx_size, self->dx_ring, in aq_ring_free()
917 self->dx_ring_pa); in aq_ring_free()
918 self->dx_ring = NULL; in aq_ring_free()
927 if (self->dx_ring) { in aq_ring_hwts_rx_free()
928 dma_free_coherent(aq_nic_get_dev(self->aq_nic), in aq_ring_hwts_rx_free()
929 self->size * self->dx_size + AQ_CFG_RXDS_DEF, in aq_ring_hwts_rx_free()
930 self->dx_ring, self->dx_ring_pa); in aq_ring_hwts_rx_free()
931 self->dx_ring = NULL; in aq_ring_hwts_rx_free()
940 if (self->ring_type == ATL_RING_RX) { in aq_ring_fill_stats_data()
944 start = u64_stats_fetch_begin(&self->stats.rx.syncp); in aq_ring_fill_stats_data()
945 data[count] = self->stats.rx.packets; in aq_ring_fill_stats_data()
946 data[++count] = self->stats.rx.jumbo_packets; in aq_ring_fill_stats_data()
947 data[++count] = self->stats.rx.lro_packets; in aq_ring_fill_stats_data()
948 data[++count] = self->stats.rx.errors; in aq_ring_fill_stats_data()
949 data[++count] = self->stats.rx.alloc_fails; in aq_ring_fill_stats_data()
950 data[++count] = self->stats.rx.skb_alloc_fails; in aq_ring_fill_stats_data()
951 data[++count] = self->stats.rx.polls; in aq_ring_fill_stats_data()
952 data[++count] = self->stats.rx.pg_flips; in aq_ring_fill_stats_data()
953 data[++count] = self->stats.rx.pg_reuses; in aq_ring_fill_stats_data()
954 data[++count] = self->stats.rx.pg_losts; in aq_ring_fill_stats_data()
955 data[++count] = self->stats.rx.xdp_aborted; in aq_ring_fill_stats_data()
956 data[++count] = self->stats.rx.xdp_drop; in aq_ring_fill_stats_data()
957 data[++count] = self->stats.rx.xdp_pass; in aq_ring_fill_stats_data()
958 data[++count] = self->stats.rx.xdp_tx; in aq_ring_fill_stats_data()
959 data[++count] = self->stats.rx.xdp_invalid; in aq_ring_fill_stats_data()
960 data[++count] = self->stats.rx.xdp_redirect; in aq_ring_fill_stats_data()
961 } while (u64_stats_fetch_retry(&self->stats.rx.syncp, start)); in aq_ring_fill_stats_data()
966 start = u64_stats_fetch_begin(&self->stats.tx.syncp); in aq_ring_fill_stats_data()
967 data[count] = self->stats.tx.packets; in aq_ring_fill_stats_data()
968 data[++count] = self->stats.tx.queue_restarts; in aq_ring_fill_stats_data()
969 } while (u64_stats_fetch_retry(&self->stats.tx.syncp, start)); in aq_ring_fill_stats_data()