struct rte_eth_xstat_name *xstats_names;
struct rte_eth_xstat *xstats;
int len, ret, i;
- int idx_name;
static const char *nic_stats_border = "########################";
len = rte_eth_xstats_get_names(port_id, NULL, 0);
}
for (i = 0; i < len; i++)
- for (idx_name = 0; idx_name < len; idx_name++)
- if (xstats_names[idx_name].id == xstats[i].id) {
- printf("%s: %"PRIu64"\n",
- xstats_names[idx_name].name,
- xstats[i].value);
- break;
- }
+ printf("%s: %"PRIu64"\n",
+ xstats_names[i].name,
+ xstats[i].value);
printf("%s############################\n",
nic_stats_border);
nic_xstats_display(portid_t port_id)
{
struct rte_eth_xstat *xstats;
- int cnt_xstats, idx_xstat, idx_name;
+ int cnt_xstats, idx_xstat;
struct rte_eth_xstat_name *xstats_names;
printf("###### NIC extended statistics for port %-2d\n", port_id);
/* Display xstats */
for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++)
- for (idx_name = 0; idx_name < cnt_xstats; idx_name++)
- if (xstats_names[idx_name].id == xstats[idx_xstat].id) {
- printf("%s: %"PRIu64"\n",
- xstats_names[idx_name].name,
- xstats[idx_xstat].value);
- break;
- }
+ printf("%s: %"PRIu64"\n",
+ xstats_names[idx_xstat].name,
+ xstats[idx_xstat].value);
free(xstats_names);
free(xstats);
}
information.
Each ``struct rte_eth_xstat`` contains an identifier and value pair, and
-each ``struct rte_eth_xstat_name`` contains an identifier and string pair.
-Each identifier within ``struct rte_eth_xstat`` must have a corresponding
-entry in ``struct rte_eth_xstat_name`` with a matching identifier. These
-identifiers, as well as the number of extended statistic exposed, must
-remain constant during runtime.
-
-Note that extended statistic identifiers are driver-specific, and hence
-might not be the same for different ports. Although it is expected that
-drivers will make the identifiers used within ``struct rte_eth_xstat`` and
-``struct rte_eth_xstat_name`` entries match the entries' array index, this
-property should not be relied on by applications for lookups.
+each ``struct rte_eth_xstat_name`` contains a string. Each identifier
+within the ``struct rte_eth_xstat`` lookup array must have a corresponding
+entry in the ``struct rte_eth_xstat_name`` lookup array. Within the latter
+the index of the entry is the identifier the string is associated with.
+These identifiers, as well as the number of extended statistic exposed, must
+remain constant during runtime. Note that extended statistic identifiers are
+driver-specific, and hence might not be the same for different ports.
A naming scheme exists for the strings exposed to clients of the API. This is
to allow scraping of the API for statistics of interest. The naming scheme uses
for (i = 0; i < IGB_NB_XSTATS; i++) {
snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
"%s", rte_igb_stats_strings[i].name);
- xstats_names[i].id = i;
}
return IGB_NB_XSTATS;
snprintf(xstats_names[i].name,
sizeof(xstats_names[i].name), "%s",
rte_igbvf_stats_strings[i].name);
- xstats_names[i].id = i;
}
return IGBVF_NB_XSTATS;
}
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s", fm10k_hw_stats_strings[count].name);
- xstats_names[count].id = count;
count++;
}
sizeof(xstats_names[count].name),
"rx_q%u_%s", q,
fm10k_hw_stats_rx_q_strings[i].name);
- xstats_names[count].id = count;
count++;
}
for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
sizeof(xstats_names[count].name),
"tx_q%u_%s", q,
fm10k_hw_stats_tx_q_strings[i].name);
- xstats_names[count].id = count;
count++;
}
}
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s", rte_i40e_stats_strings[i].name);
- xstats_names[count].id = count;
count++;
}
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s", rte_i40e_hw_port_strings[i].name);
- xstats_names[count].id = count;
count++;
}
sizeof(xstats_names[count].name),
"rx_priority%u_%s", prio,
rte_i40e_rxq_prio_strings[i].name);
- xstats_names[count].id = count;
count++;
}
}
sizeof(xstats_names[count].name),
"tx_priority%u_%s", prio,
rte_i40e_txq_prio_strings[i].name);
- xstats_names[count].id = count;
count++;
}
}
/* Get stats from i40e_eth_stats struct */
for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
- xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)&hw_stats->eth) +
rte_i40e_stats_strings[i].offset);
count++;
/* Get individiual stats from i40e_hw_port struct */
for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
- xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
rte_i40e_hw_port_strings[i].offset);
count++;
for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
for (prio = 0; prio < 8; prio++) {
- xstats[count].id = count;
xstats[count].value =
*(uint64_t *)(((char *)hw_stats) +
rte_i40e_rxq_prio_strings[i].offset +
for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
for (prio = 0; prio < 8; prio++) {
- xstats[count].id = count;
xstats[count].value =
*(uint64_t *)(((char *)hw_stats) +
rte_i40e_txq_prio_strings[i].offset +
snprintf(xstats_names[i].name,
sizeof(xstats_names[i].name),
"%s", rte_i40evf_stats_strings[i].name);
- xstats_names[i].id = i;
}
return I40EVF_NB_XSTATS;
}
/* Extended stats from ixgbe_hw_stats */
for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
- xstats_names[count].id = count;
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"%s",
/* RX Priority Stats */
for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
- xstats_names[count].id = count;
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"rx_priority%u_%s", i,
/* TX Priority Stats */
for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
- xstats_names[count].id = count;
snprintf(xstats_names[count].name,
sizeof(xstats_names[count].name),
"tx_priority%u_%s", i,
/* Extended stats from ixgbe_hw_stats */
count = 0;
for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
- xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
rte_ixgbe_stats_strings[i].offset);
count++;
/* RX Priority Stats */
for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
- xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
rte_ixgbe_rxq_strings[stat].offset +
(sizeof(uint64_t) * i));
/* TX Priority Stats */
for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
- xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
rte_ixgbe_txq_strings[stat].offset +
(sizeof(uint64_t) * i));
/* Extended stats */
for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
- xstats[i].id = i;
xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
rte_ixgbevf_stats_strings[i].offset);
}
sizeof(xstats_names[count].name),
"rx_q%u_%s", i,
rte_virtio_rxq_stat_strings[t].name);
- xstats_names[count].id = count;
count++;
}
}
sizeof(xstats_names[count].name),
"tx_q%u_%s", i,
rte_virtio_txq_stat_strings[t].name);
- xstats_names[count].id = count;
count++;
}
}
unsigned t;
for (t = 0; t < VIRTIO_NB_RXQ_XSTATS; t++) {
- xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)rxvq) +
rte_virtio_rxq_stat_strings[t].offset);
count++;
unsigned t;
for (t = 0; t < VIRTIO_NB_TXQ_XSTATS; t++) {
- xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)txvq) +
rte_virtio_txq_stat_strings[t].offset);
count++;
cnt_used_entries = 0;
for (idx = 0; idx < RTE_NB_STATS; idx++) {
- xstats_names[cnt_used_entries].id = cnt_used_entries;
snprintf(xstats_names[cnt_used_entries].name,
sizeof(xstats_names[0].name),
"%s", rte_stats_strings[idx].name);
}
for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) {
for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
- xstats_names[cnt_used_entries].id = cnt_used_entries;
snprintf(xstats_names[cnt_used_entries].name,
sizeof(xstats_names[0].name),
"rx_q%u%s",
}
for (id_queue = 0; id_queue < dev->data->nb_tx_queues; id_queue++) {
for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) {
- xstats_names[cnt_used_entries].id = cnt_used_entries;
snprintf(xstats_names[cnt_used_entries].name,
sizeof(xstats_names[0].name),
"tx_q%u%s",
*/
struct rte_eth_xstat_name {
char name[RTE_ETH_XSTATS_NAME_SIZE];
- uint64_t id;
};
#define ETH_DCB_NUM_TCS 8