[spp] [PATCH v2 1/6] shared: add dev_attach_by_devargs

x-fn-spp at sl.ntt-tx.co.jp x-fn-spp at sl.ntt-tx.co.jp
Wed Nov 21 07:52:14 CET 2018


From: Hideyuki Yamashita <yamashita.hideyuki at po.ntt-tx.co.jp>

SPP uses deprecated APIs removed in DPDK v18.11. Using rte_eth_hotplug_add()
is recommended instead of rte_eth_dev_attach()[1]. This patch is to add
dev_attach_by_devargs() to shared directory so that spp_primary, spp_nfv,
spp_vm and spp_vf can refer this new function.

[1]https://mails.dpdk.org/archives/dev/2018-October/117115.html

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki at po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki at lab.ntt.co.jp>
---
 src/shared/common.c | 26 ++++++++++++++++++++++++++
 src/shared/common.h | 17 +++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/src/shared/common.c b/src/shared/common.c
index f1754db..c88ce14 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -500,3 +500,29 @@ append_patch_info_json(char *str,
 
 	return 0;
 }
+
+/* attach the new device, then store port_id of the device */
+int
+dev_attach_by_devargs(const char *devargs, uint16_t *port_id)
+{
+	int ret = -1;
+	struct rte_devargs da;
+
+	memset(&da, 0, sizeof(da));
+
+	/* parse devargs */
+	if (rte_devargs_parse(&da, devargs))
+		return -1;
+
+	ret = rte_eal_hotplug_add(da.bus->name, da.name, da.args);
+	if (ret < 0) {
+		free(da.args);
+		return ret;
+	}
+
+	ret = rte_eth_dev_get_port_by_name(da.name, port_id);
+
+	free(da.args);
+
+	return ret;
+}
diff --git a/src/shared/common.h b/src/shared/common.h
index a5395aa..60514e5 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -18,7 +18,9 @@
 #include <rte_common.h>
 #include <rte_config.h>
 #include <rte_eal.h>
+#include <rte_devargs.h>
 #include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_launch.h>
 #include <rte_lcore.h>
 #include <rte_log.h>
@@ -217,4 +219,19 @@ int spp_atoi(const char *str, int *val);
 
 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
 
+/**
+ * Attach a new Ethernet device specified by arguments.
+ *
+ * @param devargs
+ *  A pointer to a strings array describing the new device
+ *  to be attached. The strings should be a pci address like
+ *  '0000:01:00.0' or virtual device name like 'net_pcap0'.
+ * @param port_id
+ *  A pointer to a port identifier actually attached.
+ * @return
+ *  0 on success and port_id is filled, negative on error
+ */
+int
+dev_attach_by_devargs(const char *devargs, uint16_t *port_id);
+
 #endif
-- 
2.18.0



More information about the spp mailing list