rte_eth_stats_get is to get physical device statistics. Without
return status, caller does not know whether function fails or not
(i.e. invalid port_id, driver has no stats_get callback). Caller
cannot differiente normal 0 stats or error case. This fix adds
a return status to the function.
Signed-off-by: Jia Yu <jyu@vmware.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
}
}
-void
+int
rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
{
struct rte_eth_dev *dev;
if (port_id >= nb_ports) {
PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
- return;
+ return (-ENODEV);
}
dev = &rte_eth_devices[port_id];
memset(stats, 0, sizeof(*stats));
- FUNC_PTR_OR_RET(*dev->dev_ops->stats_get);
+ FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP);
(*dev->dev_ops->stats_get)(dev, stats);
stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
+ return 0;
}
void
* - *obytes* with the total of successfully transmitted bytes.
* - *ierrors* with the total of erroneous received packets.
* - *oerrors* with the total of failed transmitted packets.
+ * @return
+ * Zero if successful. Non-zero otherwise.
*/
-extern void rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
+extern int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
/**
* Reset the general I/O statistics of an Ethernet device.