@@ -755,7 +755,7 @@ show_port(void)
}
printf("\t -- driver %s device %s socket %d\n",
- dev_info.driver_name, dev_info.device->name,
+ dev_info.driver_name, rte_dev_name(dev_info.device),
rte_eth_dev_socket_id(i));
ret = rte_eth_dev_owner_get(i, &owner);
@@ -1254,7 +1254,7 @@ show_crypto(void)
rte_cryptodev_name_get(i),
dev_info.driver_name,
dev_info.driver_id,
- dev_info.device->numa_node,
+ rte_dev_numa_node(dev_info.device),
rte_cryptodev_queue_pair_count(i));
display_crypto_feature_info(dev_info.feature_flags);
@@ -1466,7 +1466,7 @@ dump_regs(char *file_prefix)
else
printf("Device (%s) regs dumped successfully, "
"driver:%s version:0X%08X\n",
- dev_info.device->name,
+ rte_dev_name(dev_info.device),
dev_info.driver_name, reg_info.version);
fclose(fp_regs);
@@ -645,19 +645,19 @@ device_infos_display(const char *identifier)
snprintf(devstr, sizeof(devstr), "bus=%s", rte_bus_name(next));
RTE_DEV_FOREACH(dev, devstr, &dev_iter) {
- if (!dev->driver)
+ if (rte_dev_driver(dev) == NULL)
continue;
/* Check for matching device if identifier is present */
if (identifier &&
- strncmp(da.name, dev->name, strlen(dev->name)))
+ strncmp(da.name, rte_dev_name(dev), strlen(rte_dev_name(dev))))
continue;
printf("\n%s Infos for device %s %s\n",
- info_border, dev->name, info_border);
- printf("Bus name: %s", rte_bus_name(dev->bus));
- printf("\nDriver name: %s", rte_driver_name(dev->driver));
+ info_border, rte_dev_name(dev), info_border);
+ printf("Bus name: %s", rte_bus_name(rte_dev_bus(dev)));
+ printf("\nDriver name: %s", rte_driver_name(rte_dev_driver(dev)));
printf("\nDevargs: %s",
- dev->devargs ? dev->devargs->args : "");
- printf("\nConnect to socket: %d", dev->numa_node);
+ rte_dev_devargs(dev) ? rte_dev_devargs(dev)->args : "");
+ printf("\nConnect to socket: %d", rte_dev_numa_node(dev));
printf("\n");
/* List ports with matching device name */
@@ -802,8 +802,8 @@ port_infos_display(portid_t port_id)
else
printf("\nFirmware-version: %s", "not available");
- if (dev_info.device->devargs && dev_info.device->devargs->args)
- printf("\nDevargs: %s", dev_info.device->devargs->args);
+ if (rte_dev_devargs(dev_info.device) && rte_dev_devargs(dev_info.device)->args)
+ printf("\nDevargs: %s", rte_dev_devargs(dev_info.device)->args);
printf("\nConnect to socket: %u", port->socket_id);
if (port_numa[port_id] != NUMA_NO_CONFIG) {
@@ -1057,7 +1057,7 @@ dma_unmap_cb(struct rte_mempool *mp __rte_unused, void *opaque __rte_unused,
TESTPMD_LOG(DEBUG,
"unable to DMA unmap addr 0x%p "
"for device %s\n",
- memhdr->addr, dev_info.device->name);
+ memhdr->addr, rte_dev_name(dev_info.device));
}
}
ret = rte_extmem_unregister(memhdr->addr, memhdr->len);
@@ -1098,7 +1098,7 @@ dma_map_cb(struct rte_mempool *mp __rte_unused, void *opaque __rte_unused,
TESTPMD_LOG(DEBUG,
"unable to DMA map addr 0x%p "
"for device %s\n",
- memhdr->addr, dev_info.device->name);
+ memhdr->addr, rte_dev_name(dev_info.device));
}
}
}
@@ -3441,7 +3441,7 @@ detach_device(struct rte_device *dev)
}
if (rte_dev_remove(dev) < 0) {
- TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->name);
+ TESTPMD_LOG(ERR, "Failed to detach device %s\n", rte_dev_name(dev));
return;
}
remove_invalid_ports();
@@ -23,7 +23,7 @@ static const char * const valid_keys[] = {
static int
cmp_dev_name(const struct rte_device *dev, const void *name)
{
- return strcmp(dev->name, name);
+ return strcmp(rte_dev_name(dev), name);
}
static int
@@ -39,7 +39,7 @@ cmp_dev_match(const struct rte_device *dev, const void *_kvlist)
/* if key is present in kvlist and does not match, filter device */
name = rte_kvargs_get(kvlist, key);
- if (name != NULL && strcmp(name, dev->name))
+ if (name != NULL && strcmp(name, rte_dev_name(dev)) != 0)
return -1;
return 0;
@@ -49,7 +49,7 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
strlcpy(drvinfo->driver, dev_info.driver_name,
sizeof(drvinfo->driver));
strlcpy(drvinfo->version, rte_version(), sizeof(drvinfo->version));
- strlcpy(drvinfo->bus_info, dev_info.device->name,
+ strlcpy(drvinfo->bus_info, rte_dev_name(dev_info.device),
sizeof(drvinfo->bus_info));
memset(®_info, 0, sizeof(reg_info));
@@ -403,7 +403,7 @@ populate_ipv4_flow_into_table(const struct rte_hash *h)
em_route_base_v4[i].v4_key.port_dst,
em_route_base_v4[i].v4_key.port_src,
em_route_base_v4[i].v4_key.proto,
- em_route_base_v4[i].if_out, dev_info.device->name);
+ em_route_base_v4[i].if_out, rte_dev_name(dev_info.device));
}
printf("Hash: Adding 0x%" PRIx64 " keys\n",
(uint64_t)route_num_v4);
@@ -455,7 +455,7 @@ populate_ipv6_flow_into_table(const struct rte_hash *h)
em_route_base_v6[i].v6_key.port_dst,
em_route_base_v6[i].v6_key.port_src,
em_route_base_v6[i].v6_key.proto,
- em_route_base_v6[i].if_out, dev_info.device->name);
+ em_route_base_v6[i].if_out, rte_dev_name(dev_info.device));
}
printf("Hash: Adding 0x%" PRIx64 "keys\n",
(uint64_t)route_num_v6);
@@ -640,11 +640,11 @@ setup_fib(const int socketid)
printf("FIB: Adding route %s / %d (%d) [%s]\n", abuf,
route_base_v4[i].depth,
route_base_v4[i].if_out,
- dev_info.device->name);
+ rte_dev_name(dev_info.device));
} else {
printf("FIB: IPv4 route added to port %d [%s]\n",
route_base_v4[i].if_out,
- dev_info.device->name);
+ rte_dev_name(dev_info.device));
}
}
/* >8 End of setup fib. */
@@ -695,11 +695,11 @@ setup_fib(const int socketid)
printf("FIB: Adding route %s / %d (%d) [%s]\n", abuf,
route_base_v6[i].depth,
route_base_v6[i].if_out,
- dev_info.device->name);
+ rte_dev_name(dev_info.device));
} else {
printf("FIB: IPv6 route added to port %d [%s]\n",
route_base_v6[i].if_out,
- dev_info.device->name);
+ rte_dev_name(dev_info.device));
}
}
}
@@ -598,7 +598,7 @@ setup_lpm(const int socketid)
printf("LPM: Adding route %s / %d (%d) [%s]\n",
inet_ntop(AF_INET, &in, abuf, sizeof(abuf)),
route_base_v4[i].depth,
- route_base_v4[i].if_out, dev_info.device->name);
+ route_base_v4[i].if_out, rte_dev_name(dev_info.device));
}
/* create the LPM6 table */
@@ -642,7 +642,7 @@ setup_lpm(const int socketid)
inet_ntop(AF_INET6, route_base_v6[i].ip_8, abuf,
sizeof(abuf)),
route_base_v6[i].depth,
- route_base_v6[i].if_out, dev_info.device->name);
+ route_base_v6[i].if_out, rte_dev_name(dev_info.device));
}
}
@@ -119,7 +119,7 @@ new_device(int vid)
"Failed to get generic device for port %d\n", i);
continue;
}
- printf("\nnew port %s, device : %s\n", ifname, dev->name);
+ printf("\nnew port %s, device : %s\n", ifname, rte_dev_name(dev));
vports[i].vid = vid;
break;
}
@@ -149,7 +149,7 @@ destroy_device(int vid)
continue;
}
- printf("\ndestroy port %s, device: %s\n", ifname, dev->name);
+ printf("\ndestroy port %s, device: %s\n", ifname, rte_dev_name(dev));
break;
}
}
@@ -353,23 +353,23 @@ static void cmd_list_vdpa_devices_parsed(
cmdline_printf(cl, "device name\tqueue num\tsupported features\n");
RTE_DEV_FOREACH(dev, "class=vdpa", &dev_iter) {
- vdev = rte_vdpa_find_device_by_name(dev->name);
+ vdev = rte_vdpa_find_device_by_name(rte_dev_name(dev));
if (!vdev)
continue;
if (rte_vdpa_get_queue_num(vdev, &queue_num) < 0) {
RTE_LOG(ERR, VDPA,
"failed to get vdpa queue number "
- "for device %s.\n", dev->name);
+ "for device %s.\n", rte_dev_name(dev));
continue;
}
if (rte_vdpa_get_features(vdev, &features) < 0) {
RTE_LOG(ERR, VDPA,
"failed to get vdpa features "
- "for device %s.\n", dev->name);
+ "for device %s.\n", rte_dev_name(dev));
continue;
}
cmdline_printf(cl, "%s\t\t%" PRIu32 "\t\t0x%" PRIx64 "\n",
- dev->name, queue_num, features);
+ rte_dev_name(dev), queue_num, features);
}
}
@@ -606,10 +606,10 @@ main(int argc, char *argv[])
cmdline_stdin_exit(cl);
} else {
RTE_DEV_FOREACH(dev, "class=vdpa", &dev_iter) {
- vdev = rte_vdpa_find_device_by_name(dev->name);
+ vdev = rte_vdpa_find_device_by_name(rte_dev_name(dev));
if (vdev == NULL) {
rte_panic("Failed to find vDPA dev for %s\n",
- dev->name);
+ rte_dev_name(dev));
}
vports[devcnt].dev = vdev;
snprintf(vports[devcnt].ifname, MAX_PATH_LEN, "%s%d",
@@ -25,6 +25,36 @@ rte_driver_name(const struct rte_driver *driver)
return driver->name;
}
+const struct rte_bus *
+rte_dev_bus(const struct rte_device *dev)
+{
+ return dev->bus;
+}
+
+const struct rte_devargs *
+rte_dev_devargs(const struct rte_device *dev)
+{
+ return dev->devargs;
+}
+
+const struct rte_driver *
+rte_dev_driver(const struct rte_device *dev)
+{
+ return dev->driver;
+}
+
+const char *
+rte_dev_name(const struct rte_device *dev)
+{
+ return dev->name;
+}
+
+int
+rte_dev_numa_node(const struct rte_device *dev)
+{
+ return dev->numa_node;
+}
+
/**
* The device event callback description.
*
@@ -24,6 +24,9 @@ extern "C" {
#include <rte_compat.h>
#include <rte_log.h>
+struct rte_bus;
+struct rte_devargs;
+struct rte_device;
struct rte_driver;
/**
@@ -80,6 +83,81 @@ struct rte_mem_resource {
const char *
rte_driver_name(const struct rte_driver *driver);
+/**
+ * Retrieve a device bus.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @param dev
+ * A pointer to a device structure.
+ * @return
+ * A pointer to this device bus.
+ */
+__rte_experimental
+const struct rte_bus *
+rte_dev_bus(const struct rte_device *dev);
+
+/**
+ * Retrieve a device arguments.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @param dev
+ * A pointer to a device structure.
+ * @return
+ * A pointer to this device devargs.
+ */
+__rte_experimental
+const struct rte_devargs *
+rte_dev_devargs(const struct rte_device *dev);
+
+/**
+ * Retrieve a device driver.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @param dev
+ * A pointer to a device structure.
+ * @return
+ * A pointer to this device driver.
+ */
+__rte_experimental
+const struct rte_driver *
+rte_dev_driver(const struct rte_device *dev);
+
+/**
+ * Retrieve a device name.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @param dev
+ * A pointer to a device structure.
+ * @return
+ * A pointer to this device name.
+ */
+__rte_experimental
+const char *
+rte_dev_name(const struct rte_device *dev);
+
+/**
+ * Retrieve a device numa node.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @param dev
+ * A pointer to a device structure.
+ * @return
+ * A pointer to this device numa node.
+ */
+__rte_experimental
+int
+rte_dev_numa_node(const struct rte_device *dev);
+
/*
* Internal identifier length
* Sufficiently large to allow for UUID or PCI address
@@ -424,6 +424,13 @@ EXPERIMENTAL {
rte_thread_self;
rte_thread_set_affinity_by_id;
rte_thread_set_priority;
+
+ # added in 22.11
+ rte_dev_bus;
+ rte_dev_devargs;
+ rte_dev_driver;
+ rte_dev_name;
+ rte_dev_numa_node;
};
INTERNAL {
@@ -3380,7 +3380,7 @@ int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
* exists for the device and the rte_eth_dev 'dev' has been populated
* successfully with a call to it:
*
- * driver_name = rte_driver_name(dev->device->driver)
+ * driver_name = rte_driver_name(rte_dev_driver(dev->device));
* nb_rx_queues = dev->data->nb_rx_queues
* nb_tx_queues = dev->data->nb_tx_queues
* dev_flags = &dev->data->dev_flags