Soft Patch Panel
 help / color / mirror / Atom feed
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 1/6] shared: addition of attach()
Date: Wed,  7 Nov 2018 14:07:27 +0900	[thread overview]
Message-ID: <201811070507.wA757WiI008870@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_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

       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 ` x-fn-spp [this message]
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

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.wA757WiI008870@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).