return -EINVAL;
}
- /*
- * If link state interrupt is enabled, check that the
- * device supports it.
- */
+ /* Check that the device supports requested interrupts */
if ((dev_conf->intr_conf.lsc == 1) &&
(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
dev->data->drv_name);
return -EINVAL;
}
+ if ((dev_conf->intr_conf.rmv == 1) &&
+ (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
+ RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
+ dev->data->drv_name);
+ return -EINVAL;
+ }
/*
* If jumbo frames are enabled, check that the maximum RX packet
dev->data->dev_started = 0;
(*dev->dev_ops->dev_close)(dev);
+ dev->data->nb_rx_queues = 0;
rte_free(dev->data->rx_queues);
dev->data->rx_queues = NULL;
+ dev->data->nb_tx_queues = 0;
rte_free(dev->data->tx_queues);
dev->data->tx_queues = NULL;
}
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
- if (dev->dev_ops->xstats_get_names_by_ids != NULL) {
- count = (*dev->dev_ops->xstats_get_names_by_ids)(dev, NULL,
+ if (dev->dev_ops->xstats_get_names_by_id != NULL) {
+ count = (*dev->dev_ops->xstats_get_names_by_id)(dev, NULL,
NULL, 0);
if (count < 0)
return count;
}
int
-rte_eth_xstats_get_id_by_name(uint8_t port_id, const char *xstat_name,
- uint64_t *id)
-{
- int cnt_xstats, idx_xstat;
-
- RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-
- if (!id) {
- RTE_PMD_DEBUG_TRACE("Error: id pointer is NULL\n");
- return -1;
- }
-
- if (!xstat_name) {
- RTE_PMD_DEBUG_TRACE("Error: xstat_name pointer is NULL\n");
- return -1;
- }
-
- /* Get count */
- cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0, NULL);
- if (cnt_xstats < 0) {
- RTE_PMD_DEBUG_TRACE("Error: Cannot get count of xstats\n");
- return -1;
- }
-
- /* Get id-name lookup table */
- struct rte_eth_xstat_name xstats_names[cnt_xstats];
-
- if (cnt_xstats != rte_eth_xstats_get_names(
- port_id, xstats_names, cnt_xstats, NULL)) {
- RTE_PMD_DEBUG_TRACE("Error: Cannot get xstats lookup\n");
- return -1;
- }
-
- for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) {
- if (!strcmp(xstats_names[idx_xstat].name, xstat_name)) {
- *id = idx_xstat;
- return 0;
- };
- }
-
- return -EINVAL;
-}
-
-int
-rte_eth_xstats_get_names_v1607(uint8_t port_id,
- struct rte_eth_xstat_name *xstats_names,
- unsigned int size)
-{
- return rte_eth_xstats_get_names(port_id, xstats_names, size, NULL);
-}
-VERSION_SYMBOL(rte_eth_xstats_get_names, _v1607, 16.07);
-
-int
-rte_eth_xstats_get_names_v1705(uint8_t port_id,
+rte_eth_xstats_get_names_by_id(uint8_t port_id,
struct rte_eth_xstat_name *xstats_names, unsigned int size,
uint64_t *ids)
{
}
}
- if (dev->dev_ops->xstats_get_names_by_ids != NULL) {
+ if (dev->dev_ops->xstats_get_names_by_id != NULL) {
/* If there are any driver-specific xstats, append them
* to end of list.
*/
cnt_driver_entries =
- (*dev->dev_ops->xstats_get_names_by_ids)(
+ (*dev->dev_ops->xstats_get_names_by_id)(
dev,
xstats_names + cnt_used_entries,
NULL,
uint16_t len, i;
struct rte_eth_xstat_name *xstats_names_copy;
- len = rte_eth_xstats_get_names_v1705(port_id, NULL, 0, NULL);
+ len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
xstats_names_copy =
malloc(sizeof(struct rte_eth_xstat_name) * len);
return -1;
}
- rte_eth_xstats_get_names_v1705(port_id, xstats_names_copy,
+ rte_eth_xstats_get_names_by_id(port_id, xstats_names_copy,
len, NULL);
for (i = 0; i < size; i++) {
return size;
}
}
-BIND_DEFAULT_SYMBOL(rte_eth_xstats_get_names, _v1705, 17.05);
-
-MAP_STATIC_SYMBOL(int
- rte_eth_xstats_get_names(uint8_t port_id,
- struct rte_eth_xstat_name *xstats_names,
- unsigned int size,
- uint64_t *ids), rte_eth_xstats_get_names_v1705);
-/* retrieve ethdev extended statistics */
int
-rte_eth_xstats_get_v22(uint8_t port_id, struct rte_eth_xstat *xstats,
- unsigned int n)
+rte_eth_xstats_get_names(uint8_t port_id,
+ struct rte_eth_xstat_name *xstats_names,
+ unsigned int size)
{
- uint64_t *values_copy;
- uint16_t size, i;
+ struct rte_eth_dev *dev;
+ int cnt_used_entries;
+ int cnt_expected_entries;
+ int cnt_driver_entries;
+ uint32_t idx, id_queue;
+ uint16_t num_q;
- values_copy = malloc(sizeof(values_copy) * n);
- if (!values_copy) {
- RTE_PMD_DEBUG_TRACE(
- "ERROR: Cannot allocate memory for xstats\n");
- return -1;
+ cnt_expected_entries = get_xstats_count(port_id);
+ if (xstats_names == NULL || cnt_expected_entries < 0 ||
+ (int)size < cnt_expected_entries)
+ return cnt_expected_entries;
+
+ /* port_id checked in get_xstats_count() */
+ dev = &rte_eth_devices[port_id];
+ cnt_used_entries = 0;
+
+ for (idx = 0; idx < RTE_NB_STATS; idx++) {
+ snprintf(xstats_names[cnt_used_entries].name,
+ sizeof(xstats_names[0].name),
+ "%s", rte_stats_strings[idx].name);
+ cnt_used_entries++;
+ }
+ num_q = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+ for (id_queue = 0; id_queue < num_q; id_queue++) {
+ for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
+ snprintf(xstats_names[cnt_used_entries].name,
+ sizeof(xstats_names[0].name),
+ "rx_q%u%s",
+ id_queue, rte_rxq_stats_strings[idx].name);
+ cnt_used_entries++;
+ }
+
+ }
+ num_q = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+ for (id_queue = 0; id_queue < num_q; id_queue++) {
+ for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) {
+ snprintf(xstats_names[cnt_used_entries].name,
+ sizeof(xstats_names[0].name),
+ "tx_q%u%s",
+ id_queue, rte_txq_stats_strings[idx].name);
+ cnt_used_entries++;
+ }
}
- size = rte_eth_xstats_get(port_id, 0, values_copy, n);
- for (i = 0; i < n; i++) {
- xstats[i].id = i;
- xstats[i].value = values_copy[i];
+ if (dev->dev_ops->xstats_get_names != NULL) {
+ /* If there are any driver-specific xstats, append them
+ * to end of list.
+ */
+ cnt_driver_entries = (*dev->dev_ops->xstats_get_names)(
+ dev,
+ xstats_names + cnt_used_entries,
+ size - cnt_used_entries);
+ if (cnt_driver_entries < 0)
+ return cnt_driver_entries;
+ cnt_used_entries += cnt_driver_entries;
}
- free(values_copy);
- return size;
+
+ return cnt_used_entries;
}
-VERSION_SYMBOL(rte_eth_xstats_get, _v22, 2.2);
/* retrieve ethdev extended statistics */
int
-rte_eth_xstats_get_v1705(uint8_t port_id, uint64_t *ids, uint64_t *values,
+rte_eth_xstats_get_by_id(uint8_t port_id, const uint64_t *ids, uint64_t *values,
unsigned int n)
{
/* If need all xstats */
/* implemented by the driver */
- if (dev->dev_ops->xstats_get_by_ids != NULL) {
+ if (dev->dev_ops->xstats_get_by_id != NULL) {
/* Retrieve the xstats from the driver at the end of the
* xstats struct. Retrieve all xstats.
*/
- xcount = (*dev->dev_ops->xstats_get_by_ids)(dev,
+ xcount = (*dev->dev_ops->xstats_get_by_id)(dev,
NULL,
values ? values + count : NULL,
(n > count) ? n - count : 0);
uint16_t i, size;
uint64_t *values_copy;
- size = rte_eth_xstats_get_v1705(port_id, NULL, NULL, 0);
+ size = rte_eth_xstats_get_by_id(port_id, NULL, NULL, 0);
values_copy = malloc(sizeof(values_copy) * size);
if (!values_copy) {
return -1;
}
- rte_eth_xstats_get_v1705(port_id, NULL, values_copy, size);
+ rte_eth_xstats_get_by_id(port_id, NULL, values_copy, size);
for (i = 0; i < n; i++) {
if (ids[i] >= size) {
return n;
}
}
-BIND_DEFAULT_SYMBOL(rte_eth_xstats_get, _v1705, 17.05);
-
-MAP_STATIC_SYMBOL(int
- rte_eth_xstats_get(uint8_t port_id, uint64_t *ids,
- uint64_t *values, unsigned int n), rte_eth_xstats_get_v1705);
int
-rte_eth_xstats_get_all(uint8_t port_id, struct rte_eth_xstat *xstats,
+rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat *xstats,
unsigned int n)
{
- uint64_t *values_copy;
- uint16_t size, i;
+ struct rte_eth_stats eth_stats;
+ struct rte_eth_dev *dev;
+ unsigned int count = 0, i, q;
+ signed int xcount = 0;
+ uint64_t val, *stats_ptr;
+ uint16_t nb_rxqs, nb_txqs;
- values_copy = malloc(sizeof(values_copy) * n);
- if (!values_copy) {
- RTE_PMD_DEBUG_TRACE(
- "ERROR: Cannot allocate memory for xstats\n");
- return -1;
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+ dev = &rte_eth_devices[port_id];
+
+ nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+ nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+
+ /* Return generic statistics */
+ count = RTE_NB_STATS + (nb_rxqs * RTE_NB_RXQ_STATS) +
+ (nb_txqs * RTE_NB_TXQ_STATS);
+
+ /* implemented by the driver */
+ if (dev->dev_ops->xstats_get != NULL) {
+ /* Retrieve the xstats from the driver at the end of the
+ * xstats struct.
+ */
+ xcount = (*dev->dev_ops->xstats_get)(dev,
+ xstats ? xstats + count : NULL,
+ (n > count) ? n - count : 0);
+
+ if (xcount < 0)
+ return xcount;
}
- size = rte_eth_xstats_get(port_id, 0, values_copy, n);
- for (i = 0; i < n; i++) {
- xstats[i].id = i;
- xstats[i].value = values_copy[i];
+ if (n < count + xcount || xstats == NULL)
+ return count + xcount;
+
+ /* now fill the xstats structure */
+ count = 0;
+ rte_eth_stats_get(port_id, ð_stats);
+
+ /* global stats */
+ for (i = 0; i < RTE_NB_STATS; i++) {
+ stats_ptr = RTE_PTR_ADD(ð_stats,
+ rte_stats_strings[i].offset);
+ val = *stats_ptr;
+ xstats[count++].value = val;
}
- free(values_copy);
- return size;
-}
-int
-rte_eth_xstats_get_names_all(uint8_t port_id,
- struct rte_eth_xstat_name *xstats_names, unsigned int n)
-{
- return rte_eth_xstats_get_names(port_id, xstats_names, n, NULL);
+ /* per-rxq stats */
+ for (q = 0; q < nb_rxqs; q++) {
+ for (i = 0; i < RTE_NB_RXQ_STATS; i++) {
+ stats_ptr = RTE_PTR_ADD(ð_stats,
+ rte_rxq_stats_strings[i].offset +
+ q * sizeof(uint64_t));
+ val = *stats_ptr;
+ xstats[count++].value = val;
+ }
+ }
+
+ /* per-txq stats */
+ for (q = 0; q < nb_txqs; q++) {
+ for (i = 0; i < RTE_NB_TXQ_STATS; i++) {
+ stats_ptr = RTE_PTR_ADD(ð_stats,
+ rte_txq_stats_strings[i].offset +
+ q * sizeof(uint64_t));
+ val = *stats_ptr;
+ xstats[count++].value = val;
+ }
+ }
+
+ for (i = 0; i < count; i++)
+ xstats[i].id = i;
+ /* add an offset to driver-specific stats */
+ for ( ; i < count + xcount; i++)
+ xstats[i].id += count;
+
+ return count + xcount;
}
/* reset ethdev extended statistics */