From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v2 2/4] bus/net: implement hotplug bus operations
Date: Thu, 8 Jun 2017 02:00:59 +0200 [thread overview]
Message-ID: <65d6b36ea418739e8ba34248d773efc90ff2d4bc.1496877142.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1496877142.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1496877142.git.gaetan.rivet@6wind.com>
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
drivers/bus/net/rte_bus_net.c | 60 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/drivers/bus/net/rte_bus_net.c b/drivers/bus/net/rte_bus_net.c
index 27a43f4..f5c7c95 100644
--- a/drivers/bus/net/rte_bus_net.c
+++ b/drivers/bus/net/rte_bus_net.c
@@ -253,11 +253,71 @@ rte_bus_net_pci_xfrm(const struct rte_devargs *src,
return ret < 0 || ret > (int)sizeof(dst->name) || dst->args == NULL;
}
+static struct rte_device *
+net_plug(struct rte_devargs *da)
+{
+ struct rte_net_device *dev;
+
+ dev = net_scan_one(da->name);
+ if (dev == NULL) {
+ rte_errno = EFAULT;
+ return NULL;
+ }
+ if (net_probe_one(dev)) {
+ rte_errno = ENODEV;
+ return NULL;
+ }
+ return dev->sh_dev;
+}
+
+static int
+net_unplug(struct rte_device *dev)
+{
+ struct rte_net_device *ndev;
+ void *tmp;
+ int ret;
+ int err;
+
+ FOREACH_NET_DEVICE_SAFE(ndev, tmp) {
+ struct rte_device *rdev;
+ struct rte_devargs *da;
+ struct rte_devargs *sub;
+
+ if (dev != &ndev->device &&
+ dev != ndev->sh_dev)
+ continue;
+ rdev = ndev->sh_dev;
+ if (rdev == NULL)
+ continue;
+ da = ndev->device.devargs;
+ sub = rdev->devargs;
+ ret = sub->bus->unplug(rdev);
+ if (ret) {
+ err = rte_errno;
+ ERROR("unplug failed");
+ rte_errno = err;
+ return ret;
+ }
+ free(sub);
+ rte_eal_devargs_rmv(da);
+ REMOVE_NET_DEVICE(ndev);
+ free(ndev);
+ break;
+ }
+ if (ndev == NULL) {
+ ERROR("no such device");
+ return -ENODEV;
+ }
+ return 0;
+}
+
struct rte_bus rte_bus_net = {
.scan = net_scan,
.probe = net_probe,
.find_device = net_find_device,
.parse = net_parse,
+ .plug = net_plug,
+ .unplug = net_unplug,
.conf = {
.scan_mode = RTE_BUS_SCAN_UNDEFINED,
},
--
2.1.4
next prev parent reply other threads:[~2017-06-08 0:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 10:44 [dpdk-dev] [PATCH 0/3] Introduce net bus Gaetan Rivet
2017-06-01 10:44 ` [dpdk-dev] [PATCH 1/3] bus/net: introduce " Gaetan Rivet
2017-06-01 10:44 ` [dpdk-dev] [PATCH 2/3] net/mlx4: net bus support Gaetan Rivet
2017-06-01 10:44 ` [dpdk-dev] [PATCH 3/3] net/mlx5: " Gaetan Rivet
2017-06-08 0:00 ` [dpdk-dev] [PATCH v2 0/4] Introduce net bus Gaetan Rivet
2017-06-08 0:00 ` [dpdk-dev] [PATCH v2 1/4] bus/net: introduce " Gaetan Rivet
2017-06-08 0:00 ` Gaetan Rivet [this message]
2017-06-08 0:01 ` [dpdk-dev] [PATCH v2 3/4] net/mlx4: net bus support Gaetan Rivet
2017-06-08 0:01 ` [dpdk-dev] [PATCH v2 4/4] net/mlx5: " Gaetan Rivet
2017-06-08 7:31 ` [dpdk-dev] [PATCH v2 0/4] Introduce net bus Thomas Monjalon
2017-06-08 20:31 ` Gaëtan Rivet
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=65d6b36ea418739e8ba34248d773efc90ff2d4bc.1496877142.git.gaetan.rivet@6wind.com \
--to=gaetan.rivet@6wind.com \
--cc=dev@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).