From: Jerin Jacob Date: Sun, 8 Oct 2017 12:44:21 +0000 (+0530) Subject: net/octeontx: add basic stats support X-Git-Tag: spdx-start~1566 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5538990924f27396b004cb17273bc0852428656f;p=dpdk.git net/octeontx: add basic stats support Mark Basic stats support in features. Signed-off-by: Jerin Jacob Signed-off-by: Santosh Shukla --- diff --git a/doc/guides/nics/features/octeontx.ini b/doc/guides/nics/features/octeontx.ini index ed5de9a74a..a7eabc42ac 100644 --- a/doc/guides/nics/features/octeontx.ini +++ b/doc/guides/nics/features/octeontx.ini @@ -10,6 +10,7 @@ Lock-free Tx queue = Y Jumbo frame = Y Promiscuous mode = Y CRC offload = Y +Basic stats = Y Linux VFIO = Y ARMv8 = Y Usage doc = Y diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index e71a0cbb5c..8eb6bdd69e 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -182,6 +182,38 @@ octeontx_port_promisc_set(struct octeontx_nic *nic, int en) nic->port_id, en ? "set" : "unset"); } +static void +octeontx_port_stats(struct octeontx_nic *nic, struct rte_eth_stats *stats) +{ + octeontx_mbox_bgx_port_stats_t bgx_stats; + int res; + + PMD_INIT_FUNC_TRACE(); + + res = octeontx_bgx_port_stats(nic->port_id, &bgx_stats); + if (res < 0) + octeontx_log_err("failed to get port stats %d", nic->port_id); + + stats->ipackets = bgx_stats.rx_packets; + stats->ibytes = bgx_stats.rx_bytes; + stats->imissed = bgx_stats.rx_dropped; + stats->ierrors = bgx_stats.rx_errors; + stats->opackets = bgx_stats.tx_packets; + stats->obytes = bgx_stats.tx_bytes; + stats->oerrors = bgx_stats.tx_errors; + + octeontx_log_dbg("port%d stats inpkts=%" PRIx64 " outpkts=%" PRIx64 "", + nic->port_id, stats->ipackets, stats->opackets); +} + +static void +octeontx_port_stats_clr(struct octeontx_nic *nic) +{ + PMD_INIT_FUNC_TRACE(); + + octeontx_bgx_port_stats_clr(nic->port_id); +} + static inline void devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf, struct rte_event_dev_info *info) @@ -401,6 +433,24 @@ octeontx_dev_link_update(struct rte_eth_dev *dev, return octeontx_atomic_write_link_status(dev, &link); } +static void +octeontx_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct octeontx_nic *nic = octeontx_pmd_priv(dev); + + PMD_INIT_FUNC_TRACE(); + octeontx_port_stats(nic, stats); +} + +static void +octeontx_dev_stats_reset(struct rte_eth_dev *dev) +{ + struct octeontx_nic *nic = octeontx_pmd_priv(dev); + + PMD_INIT_FUNC_TRACE(); + octeontx_port_stats_clr(nic); +} + static void octeontx_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) @@ -444,6 +494,8 @@ static const struct eth_dev_ops octeontx_dev_ops = { .promiscuous_enable = octeontx_dev_promisc_enable, .promiscuous_disable = octeontx_dev_promisc_disable, .link_update = octeontx_dev_link_update, + .stats_get = octeontx_dev_stats_get, + .stats_reset = octeontx_dev_stats_reset, }; /* Create Ethdev interface per BGX LMAC ports */