* [spp] [PATCH 1/6] shared: addition of attach()
[not found] <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
@ 2018-11-07 5:07 ` x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 2/6] spp_nfv: replacement of rte_eth_dev_attach() x-fn-spp
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: x-fn-spp @ 2018-11-07 5:07 UTC (permalink / raw)
To: ferruh.yigit, ogawa.yasufumi; +Cc: spp
From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
>From DPDK 18.08, rte_eth_dev_attach becomes deprecated and will be
deleted in 18.11. There exists several places in spp where uses the
API and those should be replaced with rte_eth_hotplug_add.
As the first step, this patch creates new function named
spp_rte_eth_dev_attach under shared directory so that primary,nfv,vm,
vf can refer this new function.
Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@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..aba2309 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 return port_id of the device */
+int
+attach(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..a97943a 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
+attach(const char *devargs, uint16_t *port_id);
+
#endif
--
2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 2/6] spp_nfv: replacement of rte_eth_dev_attach()
[not found] <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
2018-11-07 5:07 ` [spp] [PATCH 1/6] shared: addition of attach() x-fn-spp
@ 2018-11-07 5:07 ` x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 3/6] spp_vf:replacement " x-fn-spp
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: x-fn-spp @ 2018-11-07 5:07 UTC (permalink / raw)
To: ferruh.yigit, ogawa.yasufumi; +Cc: spp
From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Replace rte_eth_dev_attach() with attach() for nfv.
Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
src/nfv/nfv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/nfv/nfv.c b/src/nfv/nfv.c
index 05290ed..e53037e 100644
--- a/src/nfv/nfv.c
+++ b/src/nfv/nfv.c
@@ -442,7 +442,7 @@ add_vhost_pmd(int index)
iface = get_vhost_iface_name(index);
sprintf(devargs, "%s,iface=%s,queues=%d", name, iface, nr_queues);
- ret = rte_eth_dev_attach(devargs, &vhost_port_id);
+ ret = attach(devargs, &vhost_port_id);
if (ret < 0)
return ret;
@@ -560,7 +560,7 @@ add_pcap_pmd(int index)
sprintf(devargs,
"%s,rx_pcap=%s,tx_pcap=%s",
name, rx_fpath, tx_fpath);
- ret = rte_eth_dev_attach(devargs, &pcap_pmd_port_id);
+ ret = attach(devargs, &pcap_pmd_port_id);
if (ret < 0)
return ret;
@@ -623,7 +623,7 @@ add_null_pmd(int index)
name = get_null_pmd_name(index);
sprintf(devargs, "%s", name);
- ret = rte_eth_dev_attach(devargs, &null_pmd_port_id);
+ ret = attach(devargs, &null_pmd_port_id);
if (ret < 0)
return ret;
--
2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 3/6] spp_vf:replacement of rte_eth_dev_attach()
[not found] <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
2018-11-07 5:07 ` [spp] [PATCH 1/6] shared: addition of attach() x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 2/6] spp_nfv: replacement of rte_eth_dev_attach() x-fn-spp
@ 2018-11-07 5:07 ` x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 4/6] shared: addition of detach() x-fn-spp
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: x-fn-spp @ 2018-11-07 5:07 UTC (permalink / raw)
To: ferruh.yigit, ogawa.yasufumi; +Cc: spp
From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Replace rte_eth_dev_attach() with attach() for vf.
Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
src/vf/spp_vf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 2a77ec6..425b88c 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -222,9 +222,9 @@ add_vhost_pmd(int index, int client)
sprintf(devargs, "%s,iface=%s,queues=%d,client=%d",
name, iface, nr_queues, client);
- ret = rte_eth_dev_attach(devargs, &vhost_port_id);
+ ret = attach(devargs, &vhost_port_id);
if (unlikely(ret < 0)) {
- RTE_LOG(ERR, APP, "rte_eth_dev_attach error. (ret = %d)\n",
+ RTE_LOG(ERR, APP, "attach error. (ret = %d)\n",
ret);
return ret;
}
--
2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 4/6] shared: addition of detach()
[not found] <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
` (2 preceding siblings ...)
2018-11-07 5:07 ` [spp] [PATCH 3/6] spp_vf:replacement " x-fn-spp
@ 2018-11-07 5:07 ` x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 5/6] spp_nfv: replacement of rte_eth_dev_detach() x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 6/6] spp_vm: " x-fn-spp
5 siblings, 0 replies; 6+ messages in thread
From: x-fn-spp @ 2018-11-07 5:07 UTC (permalink / raw)
To: ferruh.yigit, ogawa.yasufumi; +Cc: spp
From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
>From DPDK 18.08, rte_eth_dev_detach becomes deprecated and will be
deleted in 18.11. There exists several places in spp where uses the
API and those should be replaced with rte_eth_hotplug_remove.
As the first step, this patch creates new function named
spp_rte_eth_dev_detach under shared directory so that primary,nfv,vm,
vf can refer this new function.
Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
src/shared/common.c | 38 ++++++++++++++++++++++++++++++++++++++
src/shared/common.h | 15 +++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/src/shared/common.c b/src/shared/common.c
index aba2309..b91b16c 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -526,3 +526,41 @@ attach(const char *devargs, uint16_t *port_id)
return ret;
}
+
+/* detach the device, then store the name of the device */
+int
+detach(uint16_t port_id, char *name __rte_unused)
+{
+ struct rte_device *dev;
+ struct rte_bus *bus;
+ uint32_t dev_flags;
+ int ret = -1;
+
+ if (rte_eth_devices[port_id].data == NULL) {
+ RTE_LOG(INFO, APP,
+ "rte_eth_devices[%d].data is NULL\n", port_id);
+ return 0;
+ }
+ dev_flags = rte_eth_devices[port_id].data->dev_flags;
+ if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
+ RTE_LOG(ERR, APP,
+ "Port %"PRIu16" is bonded, cannot detach\n", port_id);
+ return -ENOTSUP;
+ }
+
+ dev = rte_eth_devices[port_id].device;
+ if (dev == NULL)
+ return -EINVAL;
+
+ bus = rte_bus_find_by_device(dev);
+ if (bus == NULL)
+ return -ENOENT;
+
+ ret = rte_eal_hotplug_remove(bus->name, dev->name);
+ if (ret < 0)
+ return ret;
+
+ rte_eth_dev_release_port(&rte_eth_devices[port_id]);
+
+ return 0;
+}
diff --git a/src/shared/common.h b/src/shared/common.h
index a97943a..104337a 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -234,4 +234,19 @@ int spp_atoi(const char *str, int *val);
int
attach(const char *devargs, uint16_t *port_id);
+/**
+ * Detach a Ethernet device specified by port identifier.
+ * This function must be called when the device is in the
+ * closed state.
+ *
+ * @param port_id
+ * The port identifier of the device to detach.
+ * @param devname
+ * A pointer to a buffer that will be filled with the device name.
+ * This buffer must be at least RTE_DEV_NAME_MAX_LEN long.
+ * @return
+ * 0 on success and devname is filled, negative on error
+ */
+int detach(uint16_t port_id, char *devname);
+
#endif
--
2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 5/6] spp_nfv: replacement of rte_eth_dev_detach()
[not found] <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
` (3 preceding siblings ...)
2018-11-07 5:07 ` [spp] [PATCH 4/6] shared: addition of detach() x-fn-spp
@ 2018-11-07 5:07 ` x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 6/6] spp_vm: " x-fn-spp
5 siblings, 0 replies; 6+ messages in thread
From: x-fn-spp @ 2018-11-07 5:07 UTC (permalink / raw)
To: ferruh.yigit, ogawa.yasufumi; +Cc: spp
From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Replace rte_eth_dev_detach() with detach() for nfv.
Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
src/nfv/nfv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/nfv/nfv.c b/src/nfv/nfv.c
index e53037e..926180a 100644
--- a/src/nfv/nfv.c
+++ b/src/nfv/nfv.c
@@ -316,7 +316,7 @@ do_del(char *res_uid)
if (port_id == PORT_RESET)
return -1;
- rte_eth_dev_detach(port_id, name);
+ detach(port_id, name);
} else if (!strcmp(p_type, "pcap")) {
char name[RTE_ETH_NAME_MAX_LEN];
@@ -325,7 +325,7 @@ do_del(char *res_uid)
if (port_id == PORT_RESET)
return -1;
- rte_eth_dev_detach(port_id, name);
+ detach(port_id, name);
} else if (!strcmp(p_type, "nullpmd")) {
char name[RTE_ETH_NAME_MAX_LEN];
@@ -334,7 +334,7 @@ do_del(char *res_uid)
if (port_id == PORT_RESET)
return -1;
- rte_eth_dev_detach(port_id, name);
+ detach(port_id, name);
}
--
2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 6/6] spp_vm: replacement of rte_eth_dev_detach().
[not found] <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
` (4 preceding siblings ...)
2018-11-07 5:07 ` [spp] [PATCH 5/6] spp_nfv: replacement of rte_eth_dev_detach() x-fn-spp
@ 2018-11-07 5:07 ` x-fn-spp
5 siblings, 0 replies; 6+ messages in thread
From: x-fn-spp @ 2018-11-07 5:07 UTC (permalink / raw)
To: ferruh.yigit, ogawa.yasufumi; +Cc: spp
From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Replace rte_eth_dev_detach() with detach() for vm.
Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
src/vm/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/vm/main.c b/src/vm/main.c
index 1d7d83a..f8aeb1e 100644
--- a/src/vm/main.c
+++ b/src/vm/main.c
@@ -251,7 +251,7 @@ do_del(char *res_uid)
if (port_id == PORT_RESET)
return -1;
- rte_eth_dev_detach(port_id, name);
+ detach(port_id, name);
}
forward_array_remove(port_id);
--
2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-11-07 5:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
2018-11-07 5:07 ` [spp] [PATCH 1/6] shared: addition of attach() x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 2/6] spp_nfv: replacement of rte_eth_dev_attach() x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 3/6] spp_vf:replacement " x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 4/6] shared: addition of detach() x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 5/6] spp_nfv: replacement of rte_eth_dev_detach() x-fn-spp
2018-11-07 5:07 ` [spp] [PATCH 6/6] spp_vm: " x-fn-spp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).