Skip to contentSkip to conversation

fix incorrect statistics data

PATCH Superseded Junyu Jiang 2 participants 7 messages Jul 15, 2020 – Jul 22, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

cover fix incorrect statistics data

This patchset fixed the issue that rx_bytes and tx_bytes overflowed on 40 bit limitation by enlarging the limitation.

Junyu Jiang (2):
net/ice: fix incorrect Rx bytes statistics
net/ice: fix incorrect Tx bytes statistics

 drivers/net/ice/ice_ethdev.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 net/ice: fix incorrect Rx bytes statistics

This patch fixed the issue that rx_bytes overflowed on 40 bit limitation by enlarging the limitation.

Fixes a37bde56314d ("net/ice: support statistics")
---
 drivers/net/ice/ice_ethdev.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/net/ice/ice_ethdev.c +14 -0
index 3534d18ca..d92b6ffa1 100644
@@ -4143,6 +4143,10 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	struct ice_eth_stats *nes = &vsi->eth_stats;
 	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
 	int idx = rte_le_to_cpu_16(vsi->vsi_id);
+	uint64_t old_rx_bytes = nes->rx_bytes;
+
+	old_rx_bytes += (nes->rx_unicast + nes->rx_multicast +
+			 nes->rx_broadcast) * RTE_ETHER_CRC_LEN;
 
 	ice_stat_update_40(hw, GLV_GORCH(idx), GLV_GORCL(idx),
 			   vsi->offset_loaded, &oes->rx_bytes,
@@ -4156,6 +4160,9 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	ice_stat_update_40(hw, GLV_BPRCH(idx), GLV_BPRCL(idx),
 			   vsi->offset_loaded, &oes->rx_broadcast,
 			   &nes->rx_broadcast);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (old_rx_bytes > nes->rx_bytes && vsi->offset_loaded)
+		nes->rx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
 	/* exclude CRC bytes */
 	nes->rx_bytes -= (nes->rx_unicast + nes->rx_multicast +
 			  nes->rx_broadcast) * RTE_ETHER_CRC_LEN;
@@ -4208,6 +4215,10 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 {
 	struct ice_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct ice_hw_port_stats *os = &pf->stats_offset; /* old stats */
+	uint64_t old_rx_bytes = ns->eth.rx_bytes;
+
+	old_rx_bytes += (ns->eth.rx_unicast + ns->eth.rx_multicast +
+			 ns->eth.rx_broadcast) * RTE_ETHER_CRC_LEN;
 
 	/* Get statistics of struct ice_eth_stats */
 	ice_stat_update_40(hw, GLPRT_GORCH(hw->port_info->lport),
@@ -4229,6 +4240,9 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 	ice_stat_update_32(hw, PRTRPB_RDPC,
 			   pf->offset_loaded, &os->eth.rx_discards,
 			   &ns->eth.rx_discards);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (old_rx_bytes > ns->eth.rx_bytes && pf->offset_loaded)
+		ns->eth.rx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
 
 	/* Workaround: CRC size should not be included in byte statistics,
 	 * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 net/ice: fix incorrect Tx bytes statistics

In reply to Junyu Jiang

This patch fixed the issue that tx_bytes overflowed on 40 bit limitation by enlarging the limitation.

Fixes a37bde56314d ("net/ice: support statistics")
---
 drivers/net/ice/ice_ethdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ice/ice_ethdev.c +10 -0
index d92b6ffa1..b6b45e274 100644
@@ -4144,6 +4144,7 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
 	int idx = rte_le_to_cpu_16(vsi->vsi_id);
 	uint64_t old_rx_bytes = nes->rx_bytes;
+	uint64_t old_tx_bytes = nes->tx_bytes;
 
 	old_rx_bytes += (nes->rx_unicast + nes->rx_multicast +
 			 nes->rx_broadcast) * RTE_ETHER_CRC_LEN;
@@ -4189,6 +4190,9 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	/* GLV_TDPC not supported */
 	ice_stat_update_32(hw, GLV_TEPC(idx), vsi->offset_loaded,
 			   &oes->tx_errors, &nes->tx_errors);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (old_tx_bytes > nes->tx_bytes && vsi->offset_loaded)
+		nes->tx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
 	vsi->offset_loaded = true;
 
 	PMD_DRV_LOG(DEBUG, "************** VSI[%u] stats start **************",
@@ -4216,9 +4220,12 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 	struct ice_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct ice_hw_port_stats *os = &pf->stats_offset; /* old stats */
 	uint64_t old_rx_bytes = ns->eth.rx_bytes;
+	uint64_t old_tx_bytes = ns->eth.tx_bytes;
 
 	old_rx_bytes += (ns->eth.rx_unicast + ns->eth.rx_multicast +
 			 ns->eth.rx_broadcast) * RTE_ETHER_CRC_LEN;
+	old_tx_bytes += (ns->eth.tx_unicast + ns->eth.tx_multicast +
+			 ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN;
 
 	/* Get statistics of struct ice_eth_stats */
 	ice_stat_update_40(hw, GLPRT_GORCH(hw->port_info->lport),
@@ -4273,6 +4280,9 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 			   GLPRT_BPTCL(hw->port_info->lport),
 			   pf->offset_loaded, &os->eth.tx_broadcast,
 			   &ns->eth.tx_broadcast);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (old_tx_bytes > ns->eth.tx_bytes && pf->offset_loaded)
+		ns->eth.tx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
 	ns->eth.tx_bytes -= (ns->eth.tx_unicast + ns->eth.tx_multicast +
 			     ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN;
 
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 1/1 net/ice: fix incorrect Rx/Tx bytes statistics

In reply to Junyu Jiang

This patch fixed the issue that rx/tx bytes overflowed on 40 bit limitation by enlarging the limitation.

Fixes a37bde56314d ("net/ice: support statistics")
---
 drivers/net/ice/ice_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.h |  4 ++++
 2 files changed, 40 insertions(+)
drivers/net/ice/ice_ethdev.c +36 -0
index 3534d18ca..85aa6cfe6 100644
@@ -4139,6 +4139,10 @@ ice_stat_update_40(struct ice_hw *hw,
 static void
 ice_update_vsi_stats(struct ice_vsi *vsi)
 {
+	uint64_t old_rx_bytes_h = vsi->old_rx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_rx_bytes_l = vsi->old_rx_bytes & ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_h = vsi->old_tx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_l = vsi->old_tx_bytes & ICE_40_BIT_MASK;
 	struct ice_eth_stats *oes = &vsi->eth_stats_offset;
 	struct ice_eth_stats *nes = &vsi->eth_stats;
 	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
@@ -4156,6 +4160,13 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	ice_stat_update_40(hw, GLV_BPRCH(idx), GLV_BPRCL(idx),
 			   vsi->offset_loaded, &oes->rx_broadcast,
 			   &nes->rx_broadcast);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (vsi->offset_loaded) {
+		if (old_rx_bytes_l > nes->rx_bytes)
+			old_rx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		nes->rx_bytes += old_rx_bytes_h;
+	}
+	vsi->old_rx_bytes = nes->rx_bytes;
 	/* exclude CRC bytes */
 	nes->rx_bytes -= (nes->rx_unicast + nes->rx_multicast +
 			  nes->rx_broadcast) * RTE_ETHER_CRC_LEN;
@@ -4182,6 +4193,13 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	/* GLV_TDPC not supported */
 	ice_stat_update_32(hw, GLV_TEPC(idx), vsi->offset_loaded,
 			   &oes->tx_errors, &nes->tx_errors);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (vsi->offset_loaded) {
+		if (old_tx_bytes_l > nes->tx_bytes)
+			old_tx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		nes->tx_bytes += old_tx_bytes_h;
+	}
+	vsi->old_tx_bytes = nes->tx_bytes;
 	vsi->offset_loaded = true;
 
 	PMD_DRV_LOG(DEBUG, "************** VSI[%u] stats start **************",
@@ -4206,6 +4224,10 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 static void
 ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 {
+	uint64_t old_rx_bytes_h = pf->old_rx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_rx_bytes_l = pf->old_rx_bytes & ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_h = pf->old_tx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_l = pf->old_tx_bytes & ICE_40_BIT_MASK;
 	struct ice_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct ice_hw_port_stats *os = &pf->stats_offset; /* old stats */
 
@@ -4229,6 +4251,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 	ice_stat_update_32(hw, PRTRPB_RDPC,
 			   pf->offset_loaded, &os->eth.rx_discards,
 			   &ns->eth.rx_discards);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (pf->offset_loaded) {
+		if (old_rx_bytes_l > ns->eth.rx_bytes)
+			old_rx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		ns->eth.rx_bytes += old_rx_bytes_h;
+	}
+	pf->old_rx_bytes = ns->eth.rx_bytes;
 
 	/* Workaround: CRC size should not be included in byte statistics,
 	 * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx
@@ -4259,6 +4288,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 			   GLPRT_BPTCL(hw->port_info->lport),
 			   pf->offset_loaded, &os->eth.tx_broadcast,
 			   &ns->eth.tx_broadcast);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (pf->offset_loaded) {
+		if (old_tx_bytes_l > ns->eth.tx_bytes)
+			old_tx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		ns->eth.tx_bytes += old_tx_bytes_h;
+	}
+	pf->old_tx_bytes = ns->eth.tx_bytes;
 	ns->eth.tx_bytes -= (ns->eth.tx_unicast + ns->eth.tx_multicast +
 			     ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN;
 
drivers/net/ice/ice_ethdev.h +4 -0
index 2bff735ca..69fd35b47 100644
@@ -248,6 +248,8 @@ struct ice_vsi {
 	struct ice_eth_stats eth_stats_offset;
 	struct ice_eth_stats eth_stats;
 	bool offset_loaded;
+	uint64_t old_rx_bytes;
+	uint64_t old_tx_bytes;
 };
 
 enum proto_xtr_type {
@@ -391,6 +393,8 @@ struct ice_pf {
 	struct ice_parser_list perm_parser_list;
 	struct ice_parser_list dist_parser_list;
 	bool init_link_up;
+	uint64_t old_rx_bytes;
+	uint64_t old_tx_bytes;
 };
 
 #define ICE_MAX_QUEUE_NUM  2048
Signature · 1 line
2.17.1
#4 lore raw

Re: [dpdk-dev] [PATCH v2] net/ice: fix incorrect Rx/Tx bytes statistics

Quoted 28 lines

-----Original Message-----
From: Jiang, JunyuX <[email protected]>
Sent: Friday, July 17, 2020 10:18 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Jiang, JunyuX <[email protected]>; [email protected]
Subject: [PATCH v2] net/ice: fix incorrect Rx/Tx bytes statistics

This patch fixed the issue that rx/tx bytes overflowed on 40 bit limitation by enlarging the limitation.

Fixes a37bde56314d ("net/ice: support statistics")
---
 drivers/net/ice/ice_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.h |  4 ++++
 2 files changed, 40 insertions(+)
drivers/net/ice/ice_ethdev.c index renamed from drivers/net/ice/ice_ethdev.c +0 -0

3534d18ca..85aa6cfe6 100644

drivers/net/ice/ice_ethdev.c ice_stat_update_40(struct ice_hw *hw, static · line 4143

Quoted 5 lines
drivers/net/ice/ice_ethdev.c +4 -0
@@ -4139,6 +4139,10 @@ ice_stat_update_40(struct ice_hw *hw,  static
 void  ice_update_vsi_stats(struct ice_vsi *vsi)  {
+	uint64_t old_rx_bytes_h = vsi->old_rx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_rx_bytes_l = vsi->old_rx_bytes & ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_h = vsi->old_tx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_l = vsi->old_tx_bytes & ICE_40_BIT_MASK;

Could you use a macro to replace above variable? so above variable is not necessary

#define ICE_RXTX_BYTES_LOW(bytes) ((bytes) & ICE_40_BIT_MASK); #define ICE_RXTX_BYTES_HIGH ....

Quoted 95 lines
drivers/net/ice/ice_ethdev.c +0 -0
 	struct ice_eth_stats *oes = &vsi->eth_stats_offset;
 	struct ice_eth_stats *nes = &vsi->eth_stats;
 	struct ice_hw *hw = ICE_VSI_TO_HW(vsi); @@ -4156,6 +4160,13 @@
 ice_update_vsi_stats(struct ice_vsi *vsi)
 	ice_stat_update_40(hw, GLV_BPRCH(idx), GLV_BPRCL(idx),
drivers/net/ice/ice_ethdev.c +15 -0
 			   vsi->offset_loaded, &oes->rx_broadcast,
 			   &nes->rx_broadcast);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (vsi->offset_loaded) {
+		if (old_rx_bytes_l > nes->rx_bytes)
+			old_rx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		nes->rx_bytes += old_rx_bytes_h;
+	}
+	vsi->old_rx_bytes = nes->rx_bytes;
 	/* exclude CRC bytes */
 	nes->rx_bytes -= (nes->rx_unicast + nes->rx_multicast +
 			  nes->rx_broadcast) * RTE_ETHER_CRC_LEN; @@ -4182,6
+4193,13 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	/* GLV_TDPC not supported */
 	ice_stat_update_32(hw, GLV_TEPC(idx), vsi->offset_loaded,
 			   &oes->tx_errors, &nes->tx_errors);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (vsi->offset_loaded) {
+		if (old_tx_bytes_l > nes->tx_bytes)
+			old_tx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		nes->tx_bytes += old_tx_bytes_h;
+	}
+	vsi->old_tx_bytes = nes->tx_bytes;
 	vsi->offset_loaded = true;
 
 	PMD_DRV_LOG(DEBUG, "************** VSI[%u] stats start

**************", @@ -4206,6 +4224,10 @@ ice_update_vsi_stats(struct ice_vsi *vsi) static void ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw) {

drivers/net/ice/ice_ethdev.c +11 -0
+	uint64_t old_rx_bytes_h = pf->old_rx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_rx_bytes_l = pf->old_rx_bytes & ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_h = pf->old_tx_bytes & ~ICE_40_BIT_MASK;
+	uint64_t old_tx_bytes_l = pf->old_tx_bytes & ICE_40_BIT_MASK;
 	struct ice_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct ice_hw_port_stats *os = &pf->stats_offset; /* old stats */
@@ -4229,6 +4251,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct
 ice_hw *hw)
 	ice_stat_update_32(hw, PRTRPB_RDPC,
 			   pf->offset_loaded, &os->eth.rx_discards,
 			   &ns->eth.rx_discards);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (pf->offset_loaded) {
+		if (old_rx_bytes_l > ns->eth.rx_bytes)
+			old_rx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		ns->eth.rx_bytes += old_rx_bytes_h;
+	}
+	pf->old_rx_bytes = ns->eth.rx_bytes;
 
 	/* Workaround: CRC size should not be included in byte statistics,
drivers/net/ice/ice_ethdev.c +7 -0
 	 * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx
@@ -4259,6 +4288,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct
 ice_hw *hw)
 			   GLPRT_BPTCL(hw->port_info->lport),
 			   pf->offset_loaded, &os->eth.tx_broadcast,
 			   &ns->eth.tx_broadcast);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (pf->offset_loaded) {
+		if (old_tx_bytes_l > ns->eth.tx_bytes)
+			old_tx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		ns->eth.tx_bytes += old_tx_bytes_h;
+	}
+	pf->old_tx_bytes = ns->eth.tx_bytes;
 	ns->eth.tx_bytes -= (ns->eth.tx_unicast + ns->eth.tx_multicast +
 			     ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN;
drivers/net/ice/ice_ethdev.h index renamed from drivers/net/ice/ice_ethdev.h +0 -0

2bff735ca..69fd35b47 100644

drivers/net/ice/ice_ethdev.h +4 -1
@@ -248,6 +248,8 @@ struct ice_vsi {
 	struct ice_eth_stats eth_stats_offset;
 	struct ice_eth_stats eth_stats;
 	bool offset_loaded;
+	uint64_t old_rx_bytes;
+	uint64_t old_tx_bytes;
 };
 
 enum proto_xtr_type {
@@ -391,6 +393,8 @@ struct ice_pf {
 	struct ice_parser_list perm_parser_list;
 	struct ice_parser_list dist_parser_list;
 	bool init_link_up;
+	uint64_t old_rx_bytes;
+	uint64_t old_tx_bytes;
 };
 
 #define ICE_MAX_QUEUE_NUM  2048
--

2.17.1

#5 lore raw

PATCH v3 1/1 net/ice: fix incorrect Rx/Tx bytes statistics

In reply to Junyu Jiang

This patch fixed the issue that rx/tx bytes overflowed on 40 bit limitation by enlarging the limitation.

Fixes a37bde56314d ("net/ice: support statistics")
---
 drivers/net/ice/ice_ethdev.c | 28 ++++++++++++++++++++++++++++
 drivers/net/ice/ice_ethdev.h |  7 +++++++
 2 files changed, 35 insertions(+)
drivers/net/ice/ice_ethdev.c +28 -0
index 3534d18ca..950c27094 100644
@@ -4156,6 +4156,13 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	ice_stat_update_40(hw, GLV_BPRCH(idx), GLV_BPRCL(idx),
 			   vsi->offset_loaded, &oes->rx_broadcast,
 			   &nes->rx_broadcast);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (vsi->offset_loaded) {
+		if (ICE_RXTX_BYTES_LOW(vsi->old_rx_bytes) > nes->rx_bytes)
+			nes->rx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		nes->rx_bytes += ICE_RXTX_BYTES_HIGH(vsi->old_rx_bytes);
+	}
+	vsi->old_rx_bytes = nes->rx_bytes;
 	/* exclude CRC bytes */
 	nes->rx_bytes -= (nes->rx_unicast + nes->rx_multicast +
 			  nes->rx_broadcast) * RTE_ETHER_CRC_LEN;
@@ -4182,6 +4189,13 @@ ice_update_vsi_stats(struct ice_vsi *vsi)
 	/* GLV_TDPC not supported */
 	ice_stat_update_32(hw, GLV_TEPC(idx), vsi->offset_loaded,
 			   &oes->tx_errors, &nes->tx_errors);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (vsi->offset_loaded) {
+		if (ICE_RXTX_BYTES_LOW(vsi->old_tx_bytes) > nes->tx_bytes)
+			nes->tx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		nes->tx_bytes += ICE_RXTX_BYTES_HIGH(vsi->old_tx_bytes);
+	}
+	vsi->old_tx_bytes = nes->tx_bytes;
 	vsi->offset_loaded = true;
 
 	PMD_DRV_LOG(DEBUG, "************** VSI[%u] stats start **************",
@@ -4229,6 +4243,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 	ice_stat_update_32(hw, PRTRPB_RDPC,
 			   pf->offset_loaded, &os->eth.rx_discards,
 			   &ns->eth.rx_discards);
+	/* enlarge the limitation when rx_bytes overflowed */
+	if (pf->offset_loaded) {
+		if (ICE_RXTX_BYTES_LOW(pf->old_rx_bytes) > ns->eth.rx_bytes)
+			ns->eth.rx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		ns->eth.rx_bytes += ICE_RXTX_BYTES_HIGH(pf->old_rx_bytes);
+	}
+	pf->old_rx_bytes = ns->eth.rx_bytes;
 
 	/* Workaround: CRC size should not be included in byte statistics,
 	 * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx
@@ -4259,6 +4280,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
 			   GLPRT_BPTCL(hw->port_info->lport),
 			   pf->offset_loaded, &os->eth.tx_broadcast,
 			   &ns->eth.tx_broadcast);
+	/* enlarge the limitation when tx_bytes overflowed */
+	if (pf->offset_loaded) {
+		if (ICE_RXTX_BYTES_LOW(pf->old_tx_bytes) > ns->eth.tx_bytes)
+			ns->eth.tx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH;
+		ns->eth.tx_bytes += ICE_RXTX_BYTES_HIGH(pf->old_tx_bytes);
+	}
+	pf->old_tx_bytes = ns->eth.tx_bytes;
 	ns->eth.tx_bytes -= (ns->eth.tx_unicast + ns->eth.tx_multicast +
 			     ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN;
 
drivers/net/ice/ice_ethdev.h +7 -0
index 2bff735ca..87984ef9e 100644
@@ -133,6 +133,9 @@
 #define ICE_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + ICE_VLAN_TAG_SIZE * 2)
 
+#define ICE_RXTX_BYTES_HIGH(bytes) ((bytes) & ~ICE_40_BIT_MASK)
+#define ICE_RXTX_BYTES_LOW(bytes) ((bytes) & ICE_40_BIT_MASK)
+
 /* DDP package type */
 enum ice_pkg_type {
 	ICE_PKG_TYPE_UNKNOWN,
@@ -248,6 +251,8 @@ struct ice_vsi {
 	struct ice_eth_stats eth_stats_offset;
 	struct ice_eth_stats eth_stats;
 	bool offset_loaded;
+	uint64_t old_rx_bytes;
+	uint64_t old_tx_bytes;
 };
 
 enum proto_xtr_type {
@@ -391,6 +396,8 @@ struct ice_pf {
 	struct ice_parser_list perm_parser_list;
 	struct ice_parser_list dist_parser_list;
 	bool init_link_up;
+	uint64_t old_rx_bytes;
+	uint64_t old_tx_bytes;
 };
 
 #define ICE_MAX_QUEUE_NUM  2048
Signature · 1 line
2.17.1
Acked-by on v3 1/1 Applied
#6 lore raw

Re: [dpdk-dev] [PATCH v3] net/ice: fix incorrect Rx/Tx bytes statistics

Quoted 11 lines

-----Original Message-----
From: Jiang, JunyuX <[email protected]>
Sent: Tuesday, July 21, 2020 3:20 PM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Jiang, JunyuX <[email protected]>; [email protected]
Subject: [PATCH v3] net/ice: fix incorrect Rx/Tx bytes statistics

Quoted 7 lines

This patch fixed the issue that rx/tx bytes overflowed on 40 bit limitation by enlarging the limitation.

Fixes a37bde56314d ("net/ice: support statistics")

Applied to dpdk-next-net-intel.

Thanks
Qi