From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw1020.ocn.ad.jp (mogw1020.ocn.ad.jp [153.149.231.26]) by dpdk.org (Postfix) with ESMTP id C78481B5F0 for ; Sat, 24 Nov 2018 16:02:37 +0100 (CET) Received: from mf-smf-ucb023c3 (mf-smf-ucb023c3.ocn.ad.jp [153.153.66.144]) by mogw1020.ocn.ad.jp (Postfix) with ESMTP id 5E70958029C; Sun, 25 Nov 2018 00:02:36 +0900 (JST) Received: from ocn-vc-mts-104c1.ocn.ad.jp ([153.138.237.81]) by mf-smf-ucb023c3 with ESMTP id QZPogp5Tz35qfQZS8gijK3; Sun, 25 Nov 2018 00:02:36 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.167]) by ocn-vc-mts-104c1.ocn.ad.jp with ESMTP id QZS8gGPXQq2v1QZS8gytp8; Sun, 25 Nov 2018 00:02:36 +0900 Received: from mugwort.local (p3371093-ipngn19601marunouchi.tokyo.ocn.ne.jp [153.228.164.93]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Sun, 25 Nov 2018 00:02:36 +0900 (JST) To: x-fn-spp@sl.ntt-tx.co.jp Cc: ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp, spp@dpdk.org References: <201811070507.wA757WWo008866@imss03.silk.ntt-tx.co.jp> <201811210652.wAL6qKRG011075@imss04.silk.ntt-tx.co.jp> From: Yasufumi Ogawa Message-ID: <2901ff2a-5450-39e2-3a97-39c6dcf5be7c@juno.ocn.ne.jp> Date: Sun, 25 Nov 2018 00:02:35 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <201811210652.wAL6qKRG011075@imss04.silk.ntt-tx.co.jp> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [spp] [PATCH v2 4/6] shared: add dev_detach_by_port_id 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: Sat, 24 Nov 2018 15:02:38 -0000 > SPP uses deprecated APIs removed in DPDK v18.11. Using rte_eth_hotplug_remove() > is recommended instead of rte_eth_dev_detach()[1]. This patch is to add > dev_detach_by_port_id() to shared directory so that spp_primary, spp_nfv, > spp_vm and spp_vf can refer this new function. Hideyuki, Commit message should be wrapped at 72 characters, but 1st and 3rd lines exceeds the limitation. Thanks > > [1]https://mails.dpdk.org/archives/dev/2018-October/117115.html > > Signed-off-by: Hideyuki Yamashita > Signed-off-by: Naoki Takada > --- > src/shared/common.c | 38 ++++++++++++++++++++++++++++++++++++++ > src/shared/common.h | 12 ++++++++++++ > 2 files changed, 50 insertions(+) > > diff --git a/src/shared/common.c b/src/shared/common.c > index c88ce14..0e32fa6 100644 > --- a/src/shared/common.c > +++ b/src/shared/common.c > @@ -526,3 +526,41 @@ dev_attach_by_devargs(const char *devargs, uint16_t *port_id) > > return ret; > } > + > +/* detach the device, then store the name of the device */ > +int > +dev_detach_by_port_id(uint16_t port_id) > +{ > + 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 60514e5..09dbf8a 100644 > --- a/src/shared/common.h > +++ b/src/shared/common.h > @@ -234,4 +234,16 @@ int spp_atoi(const char *str, int *val); > int > dev_attach_by_devargs(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. > + * @return > + * 0 on success and devname is filled, negative on error > + */ > +int dev_detach_by_port_id(uint16_t port_id); > + > #endif >