ethdev: add stats per queue

Signed-off-by: Intel
This commit is contained in:
Intel 2012-12-20 00:00:00 +01:00 committed by Thomas Monjalon
parent f831c63cbe
commit 5de201df89
6 changed files with 107 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)
{

View File

@ -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.
*