Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Sep 2021 23:22:30 GMT
From:      Eric Joyner <erj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 9fb4d2769549 - stable/12 - ixl(4): Report RX errors as sum of all RX error counters
Message-ID:  <202109202322.18KNMUe5061374@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by erj:

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

commit 9fb4d27695499501572335700418ca40b20cb6b1
Author:     Krzysztof Galazka <krzysztof.galazka@intel.com>
AuthorDate: 2021-03-03 01:33:11 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2021-09-20 21:31:03 +0000

    ixl(4): Report RX errors as sum of all RX error counters
    
    HW keeps track of RX errors using several counters, each for
    specific type of errors. Report RX errors to OS as sum
    of all those counters: CRC errors, illegal bytes, checksum,
    length, undersize, fragment, oversize and jabber errors.
    
    There is no HW counter for frames with invalid L3/L4 checksums
    so add a SW one.
    
    Also add a "rx_errors" sysctl with a copy of netstat IERRORS
    counter value to make it easier accessible from scripts.
    
    Reviewed By:    erj
    Tested By:      gowtham.kumar.ks@intel.com
    Sponsored By:   Intel Corporation
    Differential Revision:  https://reviews.freebsd.org/D27639
    
    (cherry picked from commit 9f99061ef9c95b171fc92d34026222bb5e052337)
---
 sys/dev/ixl/ixl.h         |  1 +
 sys/dev/ixl/ixl_pf_main.c | 15 +++++++++++++--
 sys/dev/ixl/ixl_txrx.c    | 16 +++++++++-------
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/sys/dev/ixl/ixl.h b/sys/dev/ixl/ixl.h
index 65e92c470a6c..b3052b52eadd 100644
--- a/sys/dev/ixl/ixl.h
+++ b/sys/dev/ixl/ixl.h
@@ -387,6 +387,7 @@ struct rx_ring {
 	u64			rx_packets;
 	u64 			rx_bytes;
 	u64 			desc_errs;
+	u64			csum_errs;
 };
 
 /*
diff --git a/sys/dev/ixl/ixl_pf_main.c b/sys/dev/ixl/ixl_pf_main.c
index 7fd4d78ef40e..782d51ac696d 100644
--- a/sys/dev/ixl/ixl_pf_main.c
+++ b/sys/dev/ixl/ixl_pf_main.c
@@ -780,6 +780,11 @@ ixl_vsi_add_sysctls(struct ixl_vsi * vsi, const char * sysctl_name, bool queues_
 	vsi_list = SYSCTL_CHILDREN(vsi->vsi_node);
 	ixl_add_sysctls_eth_stats(&vsi->sysctl_ctx, vsi_list, &vsi->eth_stats);
 
+	/* Copy of netstat RX errors counter for validation purposes */
+	SYSCTL_ADD_UQUAD(&vsi->sysctl_ctx, vsi_list, OID_AUTO, "rx_errors",
+			CTLFLAG_RD, &vsi->ierrors,
+			"RX packet errors");
+
 	if (queues_sysctls)
 		ixl_vsi_add_queues_stats(vsi, &vsi->sysctl_ctx);
 }
@@ -1998,7 +2003,7 @@ ixl_update_vsi_stats(struct ixl_vsi *vsi)
 	struct ixl_pf		*pf;
 	struct ifnet		*ifp;
 	struct i40e_eth_stats	*es;
-	u64			tx_discards;
+	u64			tx_discards, csum_errs;
 
 	struct i40e_hw_port_stats *nsd;
 
@@ -2011,6 +2016,11 @@ ixl_update_vsi_stats(struct ixl_vsi *vsi)
 
 	tx_discards = es->tx_discards + nsd->tx_dropped_link_down;
 
+	csum_errs = 0;
+	for (int i = 0; i < vsi->num_rx_queues; i++)
+		csum_errs += vsi->rx_queues[i].rxr.csum_errs;
+	nsd->checksum_error = csum_errs;
+
 	/* Update ifnet stats */
 	IXL_SET_IPACKETS(vsi, es->rx_unicast +
 	                   es->rx_multicast +
@@ -2024,7 +2034,8 @@ ixl_update_vsi_stats(struct ixl_vsi *vsi)
 	IXL_SET_OMCASTS(vsi, es->tx_multicast);
 
 	IXL_SET_IERRORS(vsi, nsd->crc_errors + nsd->illegal_bytes +
-	    nsd->rx_undersize + nsd->rx_oversize + nsd->rx_fragments +
+	    nsd->checksum_error + nsd->rx_length_errors +
+	    nsd->rx_undersize + nsd->rx_fragments + nsd->rx_oversize +
 	    nsd->rx_jabber);
 	IXL_SET_OERRORS(vsi, es->tx_errors);
 	IXL_SET_IQDROPS(vsi, es->rx_discards + nsd->eth.rx_discards);
diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c
index 7f092d47aec3..15204b7996e5 100644
--- a/sys/dev/ixl/ixl_txrx.c
+++ b/sys/dev/ixl/ixl_txrx.c
@@ -51,7 +51,7 @@
 #endif
 
 /* Local Prototypes */
-static void	ixl_rx_checksum(if_rxd_info_t ri, u32 status, u32 error, u8 ptype);
+static u8	ixl_rx_checksum(if_rxd_info_t ri, u32 status, u32 error, u8 ptype);
 
 static int	ixl_isc_txd_encap(void *arg, if_pkt_info_t pi);
 static void	ixl_isc_txd_flush(void *arg, uint16_t txqid, qidx_t pidx);
@@ -720,7 +720,7 @@ ixl_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
 	rxr->rx_packets++;
 
 	if ((if_getcapenable(vsi->ifp) & IFCAP_RXCSUM) != 0)
-		ixl_rx_checksum(ri, status, error, ptype);
+		rxr->csum_errs += ixl_rx_checksum(ri, status, error, ptype);
 	ri->iri_flowid = le32toh(cur->wb.qword0.hi_dword.rss);
 	ri->iri_rsstype = ixl_ptype_to_hash(ptype);
 	ri->iri_vtag = vtag;
@@ -737,7 +737,7 @@ ixl_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
  *  doesn't spend time verifying the checksum.
  *
  *********************************************************************/
-static void
+static u8
 ixl_rx_checksum(if_rxd_info_t ri, u32 status, u32 error, u8 ptype)
 {
 	struct i40e_rx_ptype_decoded decoded;
@@ -746,7 +746,7 @@ ixl_rx_checksum(if_rxd_info_t ri, u32 status, u32 error, u8 ptype)
 
 	/* No L3 or L4 checksum was calculated */
 	if (!(status & (1 << I40E_RX_DESC_STATUS_L3L4P_SHIFT)))
-		return;
+		return (0);
 
 	decoded = decode_rx_desc_ptype(ptype);
 
@@ -756,7 +756,7 @@ ixl_rx_checksum(if_rxd_info_t ri, u32 status, u32 error, u8 ptype)
 		if (status &
 		    (1 << I40E_RX_DESC_STATUS_IPV6EXADD_SHIFT)) {
 			ri->iri_csum_flags = 0;
-			return;
+			return (1);
 		}
 	}
 
@@ -764,17 +764,19 @@ ixl_rx_checksum(if_rxd_info_t ri, u32 status, u32 error, u8 ptype)
 
 	/* IPv4 checksum error */
 	if (error & (1 << I40E_RX_DESC_ERROR_IPE_SHIFT))
-		return;
+		return (1);
 
 	ri->iri_csum_flags |= CSUM_L3_VALID;
 	ri->iri_csum_flags |= CSUM_L4_CALC;
 
 	/* L4 checksum error */
 	if (error & (1 << I40E_RX_DESC_ERROR_L4E_SHIFT))
-		return;
+		return (1);
 
 	ri->iri_csum_flags |= CSUM_L4_VALID;
 	ri->iri_csum_data |= htons(0xffff);
+
+	return (0);
 }
 
 /* Set Report Status queue fields to 0 */



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