Skip to contentSkip to conversation

i40e: fixed tx packets stats bug

PATCH Superseded zhida zang 3 participants 3 messages Nov 20, 2014 – Nov 21, 2014 1 message not in the archive

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

zhida zang

author
#0 lore raw

PATCH v2 1/1 i40e: fixed tx packets stats bug

From: zzang <[email protected]>

i40e only count tx packets that sent by pf. But in some condition packet can be sent by NIC without being counted by pf. So count vsi tx packets instead.

---
 lib/librte_pmd_i40e/i40e_ethdev.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
lib/librte_pmd_i40e/i40e_ethdev.c +7 -3
index 4b7a827..c1ea37e 100644
@@ -1102,6 +1102,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct i40e_hw_port_stats *os = &pf->stats_offset; /* old stats */
+	struct i40e_eth_stats *ves = &pf->main_vsi->eth_stats; /* vsi stats */
 
 	/* Get statistics of struct i40e_eth_stats */
 	i40e_stat_update_48(hw, I40E_GLPRT_GORCH(hw->port),
@@ -1277,15 +1278,18 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	/* GLPRT_MSPDC not supported */
 	/* GLPRT_XEC not supported */
 
-	pf->offset_loaded = true;
-
 	if (pf->main_vsi)
 		i40e_update_vsi_stats(pf->main_vsi);
 
 	stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
 						ns->eth.rx_broadcast;
-	stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
+	if (pf->offset_loaded)
+		stats->opackets = ves->tx_unicast + ves->tx_multicast +
+						ves->tx_broadcast;
+	else
+		stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
 						ns->eth.tx_broadcast;
+	pf->offset_loaded = true;
 	stats->ibytes   = ns->eth.rx_bytes;
 	stats->obytes   = ns->eth.tx_bytes;
 	stats->oerrors  = ns->eth.tx_errors;
Signature · 1 line
1.9.3
Acked-by
#2 lore raw
In reply to a message not in the archive

This patch V2 updated commit log.

Quoted 55 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of zhida zang
Sent: Thursday, November 20, 2014 4:40 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v2] i40e: fixed tx packets stats bug

From: zzang <[email protected]>

i40e only count tx packets that sent by pf. But in some condition packet can be sent by NIC without being counted by pf. So count vsi tx packets instead.

---
 lib/librte_pmd_i40e/i40e_ethdev.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
lib/librte_pmd_i40e/i40e_ethdev.c +1 -0
index 4b7a827..c1ea37e 100644
@@ -1102,6 +1102,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct
 rte_eth_stats *stats)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
 	struct i40e_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct i40e_hw_port_stats *os = &pf->stats_offset; /* old stats */
+	struct i40e_eth_stats *ves = &pf->main_vsi->eth_stats; /* vsi stats */
 
lib/librte_pmd_i40e/i40e_ethdev.c +1 -0
 	/* Get statistics of struct i40e_eth_stats */
 	i40e_stat_update_48(hw, I40E_GLPRT_GORCH(hw->port), @@ -1277,15
+1278,18 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats

*stats)

lib/librte_pmd_i40e/i40e_ethdev.c +6 -4
 	/* GLPRT_MSPDC not supported */
 	/* GLPRT_XEC not supported */
 
-	pf->offset_loaded = true;
-
 	if (pf->main_vsi)
 		i40e_update_vsi_stats(pf->main_vsi);
 
 	stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
 						ns->eth.rx_broadcast;
-	stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
+	if (pf->offset_loaded)
+		stats->opackets = ves->tx_unicast + ves->tx_multicast +
+						ves->tx_broadcast;
+	else
+		stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
 						ns->eth.tx_broadcast;
+	pf->offset_loaded = true;
 	stats->ibytes   = ns->eth.rx_bytes;
 	stats->obytes   = ns->eth.tx_bytes;
 	stats->oerrors  = ns->eth.tx_errors;
--
Quoted 1 line

1.9.3

#3 lore raw
Quoted 1 line · Jijiang

This patch V2 updated commit log.

Not only updated commit log, but also the code :)

Thanks,
Michael

Quoted 59 lines
Quoted 56 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of zhida zang
Sent: Thursday, November 20, 2014 4:40 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v2] i40e: fixed tx packets stats bug

From: zzang <[email protected]>

i40e only count tx packets that sent by pf. But in some condition packet can be sent by NIC without being counted by pf. So count vsi tx packets instead.

---
 lib/librte_pmd_i40e/i40e_ethdev.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
lib/librte_pmd_i40e/i40e_ethdev.c +1 -0
index 4b7a827..c1ea37e 100644
@@ -1102,6 +1102,7 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct
 rte_eth_stats *stats)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data-
 > dev_private);
 	struct i40e_hw_port_stats *ns = &pf->stats; /* new stats */
 	struct i40e_hw_port_stats *os = &pf->stats_offset; /* old stats */
+	struct i40e_eth_stats *ves = &pf->main_vsi->eth_stats; /* vsi stats */
 
lib/librte_pmd_i40e/i40e_ethdev.c +1 -0
 	/* Get statistics of struct i40e_eth_stats */
 	i40e_stat_update_48(hw, I40E_GLPRT_GORCH(hw->port), @@ -1277,15
+1278,18 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats

*stats)

lib/librte_pmd_i40e/i40e_ethdev.c +6 -4
 	/* GLPRT_MSPDC not supported */
 	/* GLPRT_XEC not supported */
 
-	pf->offset_loaded = true;
-
 	if (pf->main_vsi)
 		i40e_update_vsi_stats(pf->main_vsi);
 
 	stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
 						ns->eth.rx_broadcast;
-	stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
+	if (pf->offset_loaded)
+		stats->opackets = ves->tx_unicast + ves->tx_multicast +
+						ves->tx_broadcast;
+	else
+		stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
 						ns->eth.tx_broadcast;
+	pf->offset_loaded = true;
 	stats->ibytes   = ns->eth.rx_bytes;
 	stats->obytes   = ns->eth.tx_bytes;
 	stats->oerrors  = ns->eth.tx_errors;
--
Quoted 1 line

1.9.3