net/octeontx: add basic stats support

Mark Basic stats support in features.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
This commit is contained in:
Jerin Jacob 2017-10-08 18:14:21 +05:30 committed by Ferruh Yigit
parent 15bce35b75
commit 5538990924
2 changed files with 53 additions and 0 deletions

View File

@ -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

View File

@ -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 */