git: de64aa32c810 - main - mana: Add handling of CQE_RX_TRUNCATED

From: Wei Hu <whu_at_FreeBSD.org>
Date: Tue, 15 Feb 2022 07:33:11 UTC
The branch main has been updated by whu:

URL: https://cgit.FreeBSD.org/src/commit/?id=de64aa32c810f154ac66661a234118cba8f802f9

commit de64aa32c810f154ac66661a234118cba8f802f9
Author:     Wei Hu <whu@FreeBSD.org>
AuthorDate: 2022-02-15 07:07:31 +0000
Commit:     Wei Hu <whu@FreeBSD.org>
CommitDate: 2022-02-15 07:27:42 +0000

    mana: Add handling of CQE_RX_TRUNCATED
    
    The proper way to drop this kind of CQE is advancing rxq tail
    without indicating the packet to the upper network layer.
    
    MFC after:      2 weeks
    Sponsored by:   Microsoft
---
 sys/dev/mana/mana_en.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c
index 171b530e5350..a075851a6ab5 100644
--- a/sys/dev/mana/mana_en.c
+++ b/sys/dev/mana/mana_en.c
@@ -1613,8 +1613,11 @@ mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq,
 		break;
 
 	case CQE_RX_TRUNCATED:
+		apc = if_getsoftc(ndev);
+		counter_u64_add(apc->port_stats.rx_drops, 1);
+		rxbuf_oob = &rxq->rx_oobs[rxq->buf_index];
 		if_printf(ndev, "Dropped a truncated packet\n");
-		return;
+		goto drop;
 
 	case CQE_RX_COALESCED_4:
 		if_printf(ndev, "RX coalescing is unsupported\n");
@@ -1680,6 +1683,7 @@ mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq,
 
 	mana_rx_mbuf(old_mbuf, oob, rxq);
 
+drop:
 	mana_move_wq_tail(rxq->gdma_rq, rxbuf_oob->wqe_inf.wqe_size_in_bu);
 
 	mana_post_pkt_rxq(rxq);