From: x-fn-spp@sl.ntt-tx.co.jp
To: ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Cc: spp@dpdk.org
Subject: [spp] [PATCH 4/6] shared: addition of detach()
Date: Wed, 7 Nov 2018 14:07:30 +0900 [thread overview]
Message-ID: <201811070507.wA757WFn008883@imss03.silk.ntt-tx.co.jp> (raw)
In-Reply-To: <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp>
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
next prev parent reply other threads:[~2018-11-07 5:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 ` x-fn-spp [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201811070507.wA757WFn008883@imss03.silk.ntt-tx.co.jp \
--to=x-fn-spp@sl.ntt-tx.co.jp \
--cc=ferruh.yigit@intel.com \
--cc=ogawa.yasufumi@lab.ntt.co.jp \
--cc=spp@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).