Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org> --- v3: - reduce number of counters;
v2: - add function to check supported cnts; - add optional functio to reset cnts; include/odp/api/packet_io_stats.h | 94 ++++++++++++++++++++++++++ platform/linux-generic/include/odp/packet_io.h | 1 + 2 files changed, 95 insertions(+) create mode 100644 include/odp/api/packet_io_stats.h diff --git a/include/odp/api/packet_io_stats.h b/include/odp/api/packet_io_stats.h new file mode 100644 index 0000000..0faf15b --- /dev/null +++ b/include/odp/api/packet_io_stats.h @@ -0,0 +1,94 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Packet IO + */ + +#ifndef ODP_API_PACKET_IO_STATS_H_ +#define ODP_API_PACKET_IO_STATS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup odp_packet_io ODP PACKET IO + * @{ + */ + +/** + * Packet IO statistics + * + */ +typedef struct odp_pktio_stats_t { + uint64_t collisions; /**< number of collisions */ + uint64_t multicast; /**< multicast packets received */ + + uint64_t rx_bytes; /**< total bytes received */ + uint64_t rx_crc_errors; /**< received packets with crc error */ + uint64_t rx_dropped; /**< no space in buffers */ + uint64_t rx_errors; /**< bad packets received */ + uint64_t rx_length_errors; /**< bad packets length */ + uint64_t rx_over_errors; /**< receiver buff overflow */ + uint64_t rx_packets; /**< total packets received */ + + uint64_t tx_aborted_errors; /**< packets aborted during + transmission by a network device (e.g: + because of a medium collision) */ + uint64_t tx_bytes; /**< total bytes transmitted */ + uint64_t tx_carrier_errors; /**< not transmitted packets because of + carrier errors (e.g: physical link down) */ + uint64_t tx_dropped; /**< no resources to transmit packet*/ + uint64_t tx_errors; /**< packets transmit problems */ + uint64_t tx_fifo_errors; /**< packets transmit FIFO errors */ + uint64_t tx_packets; /**< total packets transmitted */ +} odp_pktio_stats_t; + +/** + * Get supported counters for pktio handle + * + * @param pktio Packet IO handle + * @param[out] *stats Output buffer + * For each stat field: + * 0 - counter not supported. + * !0 - counter is supported . + * @retval 0 on success + * @retval <0 on failure + */ +int odp_config_pktio_stats(odp_pktio_t pktio, odp_pktio_stats_t *stat); + +/** + * Get statistics for pktio handle + * + * @param pktio Packet IO handle + * @param[out] *stats Output buffer + * @retval 0 on success + * @retval <0 on failure + */ +int odp_pktio_stats(odp_pktio_t pktio, odp_pktio_stats_t *stats); + +/** + * Reset statistics for pktio handle + * + * @param pktio Packet IO handle + * @retval 0 on success + * @retval <0 on failure + * + * @note Optional. + */ +int odp_pktio_stats_reset(odp_pktio_t pktio); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/packet_io.h b/platform/linux-generic/include/odp/packet_io.h index 1d690f5..18f8e78 100644 --- a/platform/linux-generic/include/odp/packet_io.h +++ b/platform/linux-generic/include/odp/packet_io.h @@ -33,6 +33,7 @@ extern "C" { */ #include <odp/api/packet_io.h> +#include <odp/api/packet_io_stats.h> #ifdef __cplusplus } -- 1.9.1 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp