#define ENA_STAT_TX_ENTRY(stat) \
ENA_STAT_ENTRY(stat, tx)
+#define ENA_STAT_ENI_ENTRY(stat) \
+ ENA_STAT_ENTRY(stat, eni)
+
#define ENA_STAT_GLOBAL_ENTRY(stat) \
ENA_STAT_ENTRY(stat, dev)
ENA_STAT_GLOBAL_ENTRY(tx_drops),
};
+static const struct ena_stats ena_stats_eni_strings[] = {
+ ENA_STAT_ENI_ENTRY(bw_in_allowance_exceeded),
+ ENA_STAT_ENI_ENTRY(bw_out_allowance_exceeded),
+ ENA_STAT_ENI_ENTRY(pps_allowance_exceeded),
+ ENA_STAT_ENI_ENTRY(conntrack_allowance_exceeded),
+ ENA_STAT_ENI_ENTRY(linklocal_allowance_exceeded),
+};
+
static const struct ena_stats ena_stats_tx_strings[] = {
ENA_STAT_TX_ENTRY(cnt),
ENA_STAT_TX_ENTRY(bytes),
};
#define ENA_STATS_ARRAY_GLOBAL ARRAY_SIZE(ena_stats_global_strings)
+#define ENA_STATS_ARRAY_ENI ARRAY_SIZE(ena_stats_eni_strings)
#define ENA_STATS_ARRAY_TX ARRAY_SIZE(ena_stats_tx_strings)
#define ENA_STATS_ARRAY_RX ARRAY_SIZE(ena_stats_rx_strings)
void *opaque);
static int ena_parse_devargs(struct ena_adapter *adapter,
struct rte_devargs *devargs);
+static int ena_copy_eni_stats(struct ena_adapter *adapter);
static const struct eth_dev_ops ena_dev_ops = {
.dev_configure = ena_dev_configure,
/* This function calculates the number of xstats based on the current config */
static unsigned int ena_xstats_calc_num(struct rte_eth_dev *dev)
{
- return ENA_STATS_ARRAY_GLOBAL +
+ return ENA_STATS_ARRAY_GLOBAL + ENA_STATS_ARRAY_ENI +
(dev->data->nb_tx_queues * ENA_STATS_ARRAY_TX) +
(dev->data->nb_rx_queues * ENA_STATS_ARRAY_RX);
}
return sent_idx;
}
+int ena_copy_eni_stats(struct ena_adapter *adapter)
+{
+ struct ena_admin_eni_stats admin_eni_stats;
+ int rc;
+
+ rte_spinlock_lock(&adapter->admin_lock);
+ rc = ena_com_get_eni_stats(&adapter->ena_dev, &admin_eni_stats);
+ rte_spinlock_unlock(&adapter->admin_lock);
+ if (rc != 0) {
+ if (rc == ENA_COM_UNSUPPORTED) {
+ PMD_DRV_LOG(DEBUG,
+ "Retrieving ENI metrics is not supported.\n");
+ } else {
+ PMD_DRV_LOG(WARNING,
+ "Failed to get ENI metrics: %d\n", rc);
+ }
+ return rc;
+ }
+
+ rte_memcpy(&adapter->eni_stats, &admin_eni_stats,
+ sizeof(struct ena_stats_eni));
+
+ return 0;
+}
+
/**
* DPDK callback to retrieve names of extended device statistics
*
strcpy(xstats_names[count].name,
ena_stats_global_strings[stat].name);
+ for (stat = 0; stat < ENA_STATS_ARRAY_ENI; stat++, count++)
+ strcpy(xstats_names[count].name,
+ ena_stats_eni_strings[stat].name);
+
for (stat = 0; stat < ENA_STATS_ARRAY_RX; stat++)
for (i = 0; i < dev->data->nb_rx_queues; i++, count++)
snprintf(xstats_names[count].name,
((char *)stats_begin + stat_offset));
}
+ /* Even if the function below fails, we should copy previous (or initial
+ * values) to keep structure of rte_eth_xstat consistent.
+ */
+ ena_copy_eni_stats(adapter);
+ for (stat = 0; stat < ENA_STATS_ARRAY_ENI; stat++, count++) {
+ stat_offset = ena_stats_eni_strings[stat].stat_offset;
+ stats_begin = &adapter->eni_stats;
+
+ xstats[count].id = count;
+ xstats[count].value = *((uint64_t *)
+ ((char *)stats_begin + stat_offset));
+ }
+
for (stat = 0; stat < ENA_STATS_ARRAY_RX; stat++) {
for (i = 0; i < dev->data->nb_rx_queues; i++, count++) {
stat_offset = ena_stats_rx_strings[stat].stat_offset;
unsigned int i;
int qid;
int valid = 0;
+ bool was_eni_copied = false;
+
for (i = 0; i < n; ++i) {
id = ids[i];
/* Check if id belongs to global statistics */
continue;
}
- /* Check if id belongs to rx queue statistics */
+ /* Check if id belongs to ENI statistics */
id -= ENA_STATS_ARRAY_GLOBAL;
+ if (id < ENA_STATS_ARRAY_ENI) {
+ /* Avoid reading ENI stats multiple times in a single
+ * function call, as it requires communication with the
+ * admin queue.
+ */
+ if (!was_eni_copied) {
+ was_eni_copied = true;
+ ena_copy_eni_stats(adapter);
+ }
+ values[i] = *((uint64_t *)&adapter->eni_stats + id);
+ ++valid;
+ continue;
+ }
+
+ /* Check if id belongs to rx queue statistics */
+ id -= ENA_STATS_ARRAY_ENI;
rx_entries = ENA_STATS_ARRAY_RX * dev->data->nb_rx_queues;
if (id < rx_entries) {
qid = id % dev->data->nb_rx_queues;
u64 tx_drops;
};
+struct ena_stats_eni {
+ /*
+ * The number of packets shaped due to inbound aggregate BW
+ * allowance being exceeded
+ */
+ uint64_t bw_in_allowance_exceeded;
+ /*
+ * The number of packets shaped due to outbound aggregate BW
+ * allowance being exceeded
+ */
+ uint64_t bw_out_allowance_exceeded;
+ /* The number of packets shaped due to PPS allowance being exceeded */
+ uint64_t pps_allowance_exceeded;
+ /*
+ * The number of packets shaped due to connection tracking
+ * allowance being exceeded and leading to failure in establishment
+ * of new connections
+ */
+ uint64_t conntrack_allowance_exceeded;
+ /*
+ * The number of packets shaped due to linklocal packet rate
+ * allowance being exceeded
+ */
+ uint64_t linklocal_allowance_exceeded;
+};
+
struct ena_offloads {
bool tso4_supported;
bool tx_csum_supported;
uint64_t keep_alive_timeout;
struct ena_stats_dev dev_stats;
+ struct ena_stats_eni eni_stats;
bool trigger_reset;