From: Maciej Gajdzica Date: Fri, 19 Jun 2015 09:41:13 +0000 (+0200) Subject: port: add stats structures and config option X-Git-Tag: spdx-start~8994 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=45c24d8320f25a204935c06ee1b86bc48046a1d1;p=dpdk.git port: add stats structures and config option Added common data structures for port statistics. Added config option to enable stats collecting. Signed-off-by: Maciej Gajdzica Acked-by: Cristian Dumitrescu --- diff --git a/config/common_bsdapp b/config/common_bsdapp index 0b169c8ea4..bbe95a7caf 100644 --- a/config/common_bsdapp +++ b/config/common_bsdapp @@ -383,6 +383,7 @@ CONFIG_RTE_LIBRTE_REORDER=y # Compile librte_port # CONFIG_RTE_LIBRTE_PORT=y +CONFIG_RTE_PORT_STATS_COLLECT=n # # Compile librte_table diff --git a/config/common_linuxapp b/config/common_linuxapp index 5deb55ae4a..01ab5b3d9a 100644 --- a/config/common_linuxapp +++ b/config/common_linuxapp @@ -390,6 +390,7 @@ CONFIG_RTE_LIBRTE_REORDER=y # Compile librte_port # CONFIG_RTE_LIBRTE_PORT=y +CONFIG_RTE_PORT_STATS_COLLECT=n # # Compile librte_table diff --git a/lib/librte_port/rte_port.h b/lib/librte_port/rte_port.h index 1b99b0a913..396c7e91bf 100644 --- a/lib/librte_port/rte_port.h +++ b/lib/librte_port/rte_port.h @@ -81,6 +81,12 @@ extern "C" { Cannot be changed. */ #define RTE_PORT_IN_BURST_SIZE_MAX 64 +/** Input port statistics */ +struct rte_port_in_stats { + uint64_t n_pkts_in; + uint64_t n_pkts_drop; +}; + /** * Input port create * @@ -120,17 +126,42 @@ typedef int (*rte_port_in_op_rx)( struct rte_mbuf **pkts, uint32_t n_pkts); +/** + * Input port stats get + * + * @param port + * Handle to output port instance + * @param stats + * Handle to port_in stats struct to copy data + * @param clear + * Flag indicating that stats should be cleared after read + * + * @return + * Error code or 0 on success. + */ +typedef int (*rte_port_in_op_stats_read)( + void *port, + struct rte_port_in_stats *stats, + int clear); + /** Input port interface defining the input port operation */ struct rte_port_in_ops { - rte_port_in_op_create f_create; /**< Create */ - rte_port_in_op_free f_free; /**< Free */ - rte_port_in_op_rx f_rx; /**< Packet RX (packet burst) */ + rte_port_in_op_create f_create; /**< Create */ + rte_port_in_op_free f_free; /**< Free */ + rte_port_in_op_rx f_rx; /**< Packet RX (packet burst) */ + rte_port_in_op_stats_read f_stats; /**< Stats */ }; /* * Port OUT * */ +/** Output port statistics */ +struct rte_port_out_stats { + uint64_t n_pkts_in; + uint64_t n_pkts_drop; +}; + /** * Output port create * @@ -197,13 +228,32 @@ typedef int (*rte_port_out_op_tx_bulk)( */ typedef int (*rte_port_out_op_flush)(void *port); +/** + * Output port stats read + * + * @param port + * Handle to output port instance + * @param stats + * Handle to port_out stats struct to copy data + * @param clear + * Flag indicating that stats should be cleared after read + * + * @return + * Error code or 0 on success. + */ +typedef int (*rte_port_out_op_stats_read)( + void *port, + struct rte_port_out_stats *stats, + int clear); + /** Output port interface defining the output port operation */ struct rte_port_out_ops { - rte_port_out_op_create f_create; /**< Create */ - rte_port_out_op_free f_free; /**< Free */ - rte_port_out_op_tx f_tx; /**< Packet TX (single packet) */ - rte_port_out_op_tx_bulk f_tx_bulk; /**< Packet TX (packet burst) */ - rte_port_out_op_flush f_flush; /**< Flush */ + rte_port_out_op_create f_create; /**< Create */ + rte_port_out_op_free f_free; /**< Free */ + rte_port_out_op_tx f_tx; /**< Packet TX (single packet) */ + rte_port_out_op_tx_bulk f_tx_bulk; /**< Packet TX (packet burst) */ + rte_port_out_op_flush f_flush; /**< Flush */ + rte_port_out_op_stats_read f_stats; /**< Stats */ }; #ifdef __cplusplus