From: Intel Date: Wed, 19 Dec 2012 23:00:00 +0000 (+0100) Subject: ethdev: add stats per queue X-Git-Tag: spdx-start~11370 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5de201df892;p=dpdk.git ethdev: add stats per queue Signed-off-by: Intel --- diff --git a/config/defconfig_i686-default-linuxapp-gcc b/config/defconfig_i686-default-linuxapp-gcc index c4e192c201..d6c7c28623 100644 --- a/config/defconfig_i686-default-linuxapp-gcc +++ b/config/defconfig_i686-default-linuxapp-gcc @@ -127,6 +127,7 @@ CONFIG_RTE_LIBRTE_ETHER=y CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n CONFIG_RTE_MAX_ETHPORTS=32 CONFIG_RTE_LIBRTE_IEEE1588=n +CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16 # # Compile burst-oriented IGB PMD driver diff --git a/config/defconfig_i686-default-linuxapp-icc b/config/defconfig_i686-default-linuxapp-icc index bdedf73f9e..a981dc58e9 100644 --- a/config/defconfig_i686-default-linuxapp-icc +++ b/config/defconfig_i686-default-linuxapp-icc @@ -127,6 +127,7 @@ CONFIG_RTE_LIBRTE_ETHER=y CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n CONFIG_RTE_MAX_ETHPORTS=32 CONFIG_RTE_LIBRTE_IEEE1588=n +CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16 # # Compile burst-oriented IGB PMD driver diff --git a/config/defconfig_x86_64-default-linuxapp-gcc b/config/defconfig_x86_64-default-linuxapp-gcc index c64fd8f70f..3ddc39dda7 100644 --- a/config/defconfig_x86_64-default-linuxapp-gcc +++ b/config/defconfig_x86_64-default-linuxapp-gcc @@ -127,6 +127,7 @@ CONFIG_RTE_LIBRTE_ETHER=y CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n CONFIG_RTE_MAX_ETHPORTS=32 CONFIG_RTE_LIBRTE_IEEE1588=n +CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16 # # Compile burst-oriented IGB PMD driver diff --git a/config/defconfig_x86_64-default-linuxapp-icc b/config/defconfig_x86_64-default-linuxapp-icc index 65411c6988..63e3aa60f8 100644 --- a/config/defconfig_x86_64-default-linuxapp-icc +++ b/config/defconfig_x86_64-default-linuxapp-icc @@ -127,6 +127,7 @@ CONFIG_RTE_LIBRTE_ETHER=y CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n CONFIG_RTE_MAX_ETHPORTS=32 CONFIG_RTE_LIBRTE_IEEE1588=n +CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16 # # Compile burst-oriented IGB PMD driver diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index cfb450a13d..ac22f7a665 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -126,6 +126,11 @@ struct rte_eth_dev_callback { enum rte_eth_event_type event; /**< Interrupt event type */ }; +enum { + STAT_QMAP_TX = 0, + STAT_QMAP_RX +}; + static inline void rte_eth_dev_data_alloc(void) { @@ -730,6 +735,43 @@ rte_eth_stats_reset(uint8_t port_id) (*dev->dev_ops->stats_reset)(dev); } + +static int +set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx, + uint8_t is_rx) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + dev = &rte_eth_devices[port_id]; + + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP); + return (*dev->dev_ops->queue_stats_mapping_set) + (dev, queue_id, stat_idx, is_rx); +} + + +int +rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, uint16_t tx_queue_id, + uint8_t stat_idx) +{ + return set_queue_stats_mapping(port_id, tx_queue_id, stat_idx, + STAT_QMAP_TX); +} + + +int +rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, uint16_t rx_queue_id, + uint8_t stat_idx) +{ + return set_queue_stats_mapping(port_id, rx_queue_id, stat_idx, + STAT_QMAP_RX); +} + + void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index ef835d4799..afcd240e75 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -116,6 +116,7 @@ * - VLAN filtering configuration * - MAC addresses supplied to MAC address array * - flow director filtering mode (but not filtering rules) + * - NIC queue statistics mappings * * Any other configuration will not be stored and will need to be re-entered * after a call to rte_eth_dev_start(). @@ -192,6 +193,16 @@ struct rte_eth_stats { uint64_t rx_nombuf; /**< Total number of RX mbuf allocation failures. */ uint64_t fdirmatch; /**< Total number of RX packets matching a filter. */ uint64_t fdirmiss; /**< Total number of RX packets not matching any filter. */ + uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + /**< Total number of queue RX packets. */ + uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + /**< Total number of queue TX packets. */ + uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + /**< Total number of successfully received queue bytes. */ + uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + /**< Total number of successfully transmitted queue bytes. */ + uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + /**< Total number of queue packets received that are dropped. */ }; /** @@ -597,6 +608,12 @@ typedef void (*eth_stats_get_t)(struct rte_eth_dev *dev, typedef void (*eth_stats_reset_t)(struct rte_eth_dev *dev); /**< @internal Reset global I/O statistics of an Ethernet device to 0. */ +typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev, + uint16_t queue_id, + uint8_t stat_idx, + uint8_t is_rx); +/**< @internal Set a queue statistics mapping for a tx/rx queue of an Ethernet device. */ + typedef void (*eth_dev_infos_get_t)(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); /**< @internal Get specific informations of an Ethernet device. */ @@ -704,6 +721,8 @@ struct eth_dev_ops { eth_link_update_t link_update; /**< Get device link state. */ eth_stats_get_t stats_get; /**< Get device statistics. */ eth_stats_reset_t stats_reset; /**< Reset device statistics. */ + eth_queue_stats_mapping_set_t queue_stats_mapping_set; + /**< Configure per queue stat counter mapping. */ eth_dev_infos_get_t dev_infos_get; /**< Get device info. */ vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */ eth_rx_queue_setup_t rx_queue_setup;/**< Set up device RX queue.*/ @@ -1226,6 +1245,48 @@ extern void rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats); */ extern void rte_eth_stats_reset(uint8_t port_id); +/** + * Set a mapping for the specified transmit queue to the specified per-queue + * statistics counter. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param tx_queue_id + * The index of the transmit queue for which a queue stats mapping is required. + * The value must be in the range [0, nb_tx_queue - 1] previously supplied + * to rte_eth_dev_configure(). + * @param stat_idx + * The per-queue packet statistics functionality number that the transmit + * queue is to be assigned. + * The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1]. + * @return + * Zero if successful. Non-zero otherwise. + */ +extern int rte_eth_dev_set_tx_queue_stats_mapping(uint8_t port_id, + uint16_t tx_queue_id, + uint8_t stat_idx); + +/** + * Set a mapping for the specified receive queue to the specified per-queue + * statistics counter. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param rx_queue_id + * The index of the receive queue for which a queue stats mapping is required. + * The value must be in the range [0, nb_rx_queue - 1] previously supplied + * to rte_eth_dev_configure(). + * @param stat_idx + * The per-queue packet statistics functionality number that the receive + * queue is to be assigned. + * The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS_MAPS - 1]. + * @return + * Zero if successful. Non-zero otherwise. + */ +extern int rte_eth_dev_set_rx_queue_stats_mapping(uint8_t port_id, + uint16_t rx_queue_id, + uint8_t stat_idx); + /** * Retrieve the Ethernet address of an Ethernet device. *