diff mbox

[NEXT,PATCHv3] api: define pktio statistics api

Message ID 1441629816-12209-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Sept. 7, 2015, 12:43 p.m. UTC
Signed-off-by: Maxim Uvarov <maxim.uvarov@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

Comments

Maxim Uvarov Sept. 10, 2015, 9:15 a.m. UTC | #1
Hello Petri,

is v3 good for you?

Maxim.


On 09/07/15 15:43, Maxim Uvarov wrote:
> Signed-off-by: Maxim Uvarov <maxim.uvarov@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
>   }
Ivan Khoronzhuk Sept. 22, 2015, 5:18 p.m. UTC | #2
Hi, Maxim

What about to extend API a little.
Why API doesn't support work with statistic counter, I mean not
only read. What if I want to reset a statistic counter and only one?

In my case I have h/w support to reset concrete counter by writing 0xffffffff
to it in runtime. Also there is possibility to subtract some value from counter
by writing this value in counter in runtime. In case if statistic module is off
these counters behave like usual registers for read/write.

Also it be good to have API allowing to enable and disable statistic for pktio.
The main reason for that the same statistic module can be used by different
pktios, so if it's used for one of them it cannot be used by other, to allow
it for first it should be disable for second. For instance 2 statistic modules
are shared between 4 eth ports, etc.

Also maybe it's redundancy, but what about to support some arithmetic operations
for counters, like diff and sum for time API.

If you want I can send the full list of counter that I can retrieve.


On 07.09.15 05:43, Maxim Uvarov wrote:
> Signed-off-by: Maxim Uvarov <maxim.uvarov@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
>   }
>
Maxim Uvarov Oct. 13, 2015, 1:27 p.m. UTC | #3
On 09/22/2015 20:18, Ivan Khoronzhuk wrote:
> Hi, Maxim
>
> What about to extend API a little.
> Why API doesn't support work with statistic counter, I mean not
> only read. What if I want to reset a statistic counter and only one?
>
> In my case I have h/w support to reset concrete counter by writing 
> 0xffffffff
> to it in runtime. Also there is possibility to subtract some value 
> from counter
> by writing this value in counter in runtime. In case if statistic 
> module is off
> these counters behave like usual registers for read/write.
>

Will:
int odp_config_pktio_stats_set(odp_pktio_t pktio, odp_pktio_stats_t *stat);

solve that? I'm not sure that everybody can support that. So I can add 
not that it's
optional.

I don't think that sub/add is useful for odp and everybody need this 
feature. We can
discuss that on meeting.


> Also it be good to have API allowing to enable and disable statistic 
> for pktio.
> The main reason for that the same statistic module can be used by 
> different
> pktios, so if it's used for one of them it cannot be used by other, to 
> allow
> it for first it should be disable for second. For instance 2 statistic 
> modules
> are shared between 4 eth ports, etc.

ok, will add it.
>
> Also maybe it's redundancy, but what about to support some arithmetic 
> operations
> for counters, like diff and sum for time API.
>
Arithmetic on pktio counters looks not very useful for first look. We 
can add it later if needed.

> If you want I can send the full list of counter that I can retrieve.
>
yes, please.

Maxim.
>
> On 07.09.15 05:43, Maxim Uvarov wrote:
>> Signed-off-by: Maxim Uvarov <maxim.uvarov@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
>>   }
>>
>
diff mbox

Patch

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
 }