Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Jul 2021 15:01:44 GMT
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d02e436353d2 - main - igc: sync igc_txrx with igb(4)
Message-ID:  <202107311501.16VF1il7027283@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kbowling (ports committer):

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

commit d02e436353d292e6fd50f70ea80507095543764e
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2021-07-31 15:00:16 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2021-07-31 15:00:16 +0000

    igc: sync igc_txrx with igb(4)
    
    Reviewed by:    grehan
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D31227
---
 sys/dev/igc/igc_txrx.c | 92 +++++++++++++++++++++++++++++---------------------
 1 file changed, 53 insertions(+), 39 deletions(-)

diff --git a/sys/dev/igc/igc_txrx.c b/sys/dev/igc/igc_txrx.c
index 2636aa77069a..ee4d5a5c0c6b 100644
--- a/sys/dev/igc/igc_txrx.c
+++ b/sys/dev/igc/igc_txrx.c
@@ -52,16 +52,20 @@ static int igc_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear);
 
 static void igc_isc_rxd_refill(void *arg, if_rxd_update_t iru);
 
-static void igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx);
-static int igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget);
+static void igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused,
+    qidx_t pidx);
+static int igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx,
+    qidx_t budget);
 
 static int igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri);
 
-static int igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status);
-static int igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status);
+static int igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi,
+    uint32_t *cmd_type_len, uint32_t *olinfo_status);
+static int igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi,
+    uint32_t *cmd_type_len, uint32_t *olinfo_status);
 
-static void igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype);
-static int igc_determine_rsstype(u16 pkt_info);
+static void igc_rx_checksum(uint32_t staterr, if_rxd_info_t ri, uint32_t ptype);
+static int igc_determine_rsstype(uint16_t pkt_info);
 
 extern void igc_if_enable_intr(if_ctx_t ctx);
 extern int igc_intr(void *arg);
@@ -119,12 +123,13 @@ igc_dump_rs(struct igc_adapter *adapter)
  *
  **********************************************************************/
 static int
-igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status)
+igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, uint32_t *cmd_type_len,
+    uint32_t *olinfo_status)
 {
 	struct igc_adv_tx_context_desc *TXD;
-	u32 type_tucmd_mlhl = 0, vlan_macip_lens = 0;
-	u32 mss_l4len_idx = 0;
-	u32 paylen;
+	uint32_t type_tucmd_mlhl = 0, vlan_macip_lens = 0;
+	uint32_t mss_l4len_idx = 0;
+	uint32_t paylen;
 
 	switch(pi->ipi_etype) {
 	case ETHERTYPE_IPV6:
@@ -179,11 +184,12 @@ igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *oli
  *
  **********************************************************************/
 static int
-igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status)
+igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, uint32_t *cmd_type_len,
+    uint32_t *olinfo_status)
 {
 	struct igc_adv_tx_context_desc *TXD;
-	u32 vlan_macip_lens, type_tucmd_mlhl;
-	u32 mss_l4len_idx;
+	uint32_t vlan_macip_lens, type_tucmd_mlhl;
+	uint32_t mss_l4len_idx;
 	mss_l4len_idx = vlan_macip_lens = type_tucmd_mlhl = 0;
 
 	/* First check if TSO is to be used */
@@ -242,7 +248,7 @@ igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *
 			type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_L4T_SCTP;
 			*olinfo_status |= IGC_TXD_POPTS_TXSM << 8;
 		}
-               break;
+		break;
 	default:
 		break;
 	}
@@ -267,7 +273,7 @@ igc_isc_txd_encap(void *arg, if_pkt_info_t pi)
 	bus_dma_segment_t *segs = pi->ipi_segs;
 	union igc_adv_tx_desc *txd = NULL;
 	int i, j, pidx_last;
-	u32 olinfo_status, cmd_type_len, txd_flags;
+	uint32_t olinfo_status, cmd_type_len, txd_flags;
 	qidx_t ntxd;
 
 	pidx_last = olinfo_status = 0;
@@ -422,7 +428,7 @@ igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget)
 	struct igc_rx_queue *que = &sc->rx_queues[rxqid];
 	struct rx_ring *rxr = &que->rxr;
 	union igc_adv_rx_desc *rxd;
-	u32 staterr = 0;
+	uint32_t staterr = 0;
 	int cnt, i;
 
 	for (cnt = 0, i = idx; cnt < scctx->isc_nrxd[0] && cnt <= budget;) {
@@ -453,16 +459,15 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
 	if_softc_ctx_t scctx = adapter->shared;
 	struct igc_rx_queue *que = &adapter->rx_queues[ri->iri_qsidx];
 	struct rx_ring *rxr = &que->rxr;
-	struct ifnet *ifp = iflib_get_ifp(adapter->ctx);
 	union igc_adv_rx_desc *rxd;
 
-	u16 pkt_info, len;
-	u16 vtag = 0;
-	u32 ptype;
-	u32 staterr = 0;
+	uint16_t pkt_info, len, vtag;
+	uint32_t ptype, staterr;
+	int i, cidx;
 	bool eop;
-	int i = 0;
-	int cidx = ri->iri_cidx;
+
+	staterr = i = vtag = 0;
+	cidx = ri->iri_cidx;
 
 	do {
 		rxd = (union igc_adv_rx_desc *)&rxr->rx_base[cidx];
@@ -507,14 +512,15 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
 
 	rxr->rx_packets++;
 
-	if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
+	if ((scctx->isc_capenable & IFCAP_RXCSUM) != 0)
 		igc_rx_checksum(staterr, ri, ptype);
 
-	if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
+	if ((scctx->isc_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
 	    (staterr & IGC_RXD_STAT_VP) != 0) {
 		ri->iri_vtag = vtag;
 		ri->iri_flags |= M_VLANTAG;
 	}
+
 	ri->iri_flowid =
 		le32toh(rxd->wb.lower.hi_dword.rss);
 	ri->iri_rsstype = igc_determine_rsstype(pkt_info);
@@ -531,26 +537,34 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
  *
  *********************************************************************/
 static void
-igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype)
+igc_rx_checksum(uint32_t staterr, if_rxd_info_t ri, uint32_t ptype)
 {
-	u16 status = (u16)staterr;
-	u8 errors = (u8) (staterr >> 24);
+	uint16_t status = (uint16_t)staterr;
+	uint8_t errors = (uint8_t)(staterr >> 24);
 
-	/* Ignore Checksum bit is set */
-	if (status & IGC_RXD_STAT_IXSM) {
-		ri->iri_csum_flags = 0;
+	if (__predict_false(status & IGC_RXD_STAT_IXSM))
 		return;
-	}
 
-	if (status & (IGC_RXD_STAT_TCPCS | IGC_RXD_STAT_UDPCS)) {
-		u64 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
-		/* Did it pass? */
-		if (!(errors & IGC_RXD_ERR_TCPE)) {
-			ri->iri_csum_flags |= type;
+	/* If there is a layer 3 or 4 error we are done */
+	if (__predict_false(errors & (IGC_RXD_ERR_IPE | IGC_RXD_ERR_TCPE)))
+		return;
+
+	/* IP Checksum Good */
+	if (status & IGC_RXD_STAT_IPCS)
+		ri->iri_csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID);
+
+	/* Valid L4E checksum */
+	if (__predict_true(status &
+	    (IGC_RXD_STAT_TCPCS | IGC_RXD_STAT_UDPCS))) {
+		/* SCTP header present */
+		if (__predict_false((ptype & IGC_RXDADV_PKTTYPE_ETQF) == 0 &&
+		    (ptype & IGC_RXDADV_PKTTYPE_SCTP) != 0)) {
+			ri->iri_csum_flags |= CSUM_SCTP_VALID;
+		} else {
+			ri->iri_csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
 			ri->iri_csum_data = htons(0xffff);
 		}
 	}
-	return;
 }
 
 /********************************************************************
@@ -559,7 +573,7 @@ igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype)
  *
  ******************************************************************/
 static int
-igc_determine_rsstype(u16 pkt_info)
+igc_determine_rsstype(uint16_t pkt_info)
 {
 	switch (pkt_info & IGC_RXDADV_RSSTYPE_MASK) {
 	case IGC_RXDADV_RSSTYPE_IPV4_TCP:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107311501.16VF1il7027283>