From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id 00BD1201 for ; Wed, 7 Nov 2018 06:08:45 +0100 (CET) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id wA758ixr017838; Wed, 7 Nov 2018 14:08:44 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id wA758iE0030901; Wed, 7 Nov 2018 14:08:44 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id QAA30254; Wed, 7 Nov 2018 14:07:32 +0900 Received: from imss03.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id wA757WrJ008873; Wed, 7 Nov 2018 14:07:32 +0900 Received: from mgate02.silk.ntt-tx.co.jp (smtp02.silk.ntt-tx.co.jp [10.107.0.37]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id wA757WiI008870; Wed, 7 Nov 2018 14:07:32 +0900 Message-Id: <201811070507.wA757WiI008870@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate02.silk.ntt-tx.co.jp (unknown) id wA757WhM024524 ; Wed, 7 Nov 2018 14:07:32 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Cc: spp@dpdk.org Date: Wed, 7 Nov 2018 14:07:27 +0900 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp> References: <20181107050732.28344-1-x-fn-spp@sl.ntt-tx.co.jp> X-TM-AS-MML: No Subject: [spp] [PATCH 1/6] shared: addition of attach() X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Nov 2018 05:08:46 -0000 From: Hideyuki Yamashita >>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 Signed-off-by: Naoki Takada --- 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 #include #include +#include #include +#include #include #include #include @@ -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