diff mbox

[dpdk-dev,4/8] bond: queue stats mapping

Message ID 1433329147-2840-5-git-send-email-tomaszx.kulasek@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Tomasz Kulasek June 3, 2015, 10:59 a.m. UTC
Queue stats mapping is used in example application. This patch adds propagation
of mapping over the slaves, and fills bonding port's stats with a sum of
corresponding values taken from bonded slaves, when stats are requested for
bonding port.

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 4f6fc68..7a4ecb8 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1766,7 +1766,7 @@  bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	struct bond_dev_private *internals = dev->data->dev_private;
 	struct rte_eth_stats slave_stats;
 
-	int i;
+	int i, j;
 
 	/* clear bonded stats before populating from slaves */
 	memset(stats, 0, sizeof(*stats));
@@ -1788,6 +1788,15 @@  bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 		stats->rx_pause_xon += slave_stats.rx_pause_xon;
 		stats->tx_pause_xoff += slave_stats.tx_pause_xoff;
 		stats->rx_pause_xoff += slave_stats.rx_pause_xoff;
+
+		for (j = 0; j < RTE_ETHDEV_QUEUE_STAT_CNTRS; j++) {
+			stats->q_ipackets[j] += slave_stats.q_ipackets[j];
+			stats->q_opackets[j] += slave_stats.q_ipackets[j];
+			stats->q_ibytes[j] += slave_stats.q_ipackets[j];
+			stats->q_obytes[j] += slave_stats.q_ipackets[j];
+			stats->q_errors[j] += slave_stats.q_ipackets[j];
+		}
+
 	}
 }
 
@@ -2090,6 +2099,24 @@  bond_ethdev_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+bond_ethdev_queue_stats_mapping_set(struct rte_eth_dev *dev,
+		uint16_t queue_id, uint8_t stat_idx, uint8_t is_rx)
+{
+	int i;
+	struct bond_dev_private *internals = dev->data->dev_private;
+
+	for (i = 0; i < internals->slave_count; i++)
+		if (is_rx)
+			rte_eth_dev_set_rx_queue_stats_mapping (
+					internals->slaves[i].port_id, queue_id, stat_idx);
+		else
+			rte_eth_dev_set_tx_queue_stats_mapping (
+					internals->slaves[i].port_id, queue_id, stat_idx);
+
+	return 0;
+}
+
 struct eth_dev_ops default_dev_ops = {
 		.dev_start            = bond_ethdev_start,
 		.dev_stop             = bond_ethdev_stop,
@@ -2103,6 +2130,7 @@  struct eth_dev_ops default_dev_ops = {
 		.link_update          = bond_ethdev_link_update,
 		.stats_get            = bond_ethdev_stats_get,
 		.stats_reset          = bond_ethdev_stats_reset,
+		.queue_stats_mapping_set = bond_ethdev_queue_stats_mapping_set,
 		.promiscuous_enable   = bond_ethdev_promiscuous_enable,
 		.promiscuous_disable  = bond_ethdev_promiscuous_disable,
 		.reta_update          = bond_ethdev_rss_reta_update,