From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id E201C1B53 for ; Fri, 21 Sep 2018 11:16:09 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 82D8A217D0; Fri, 21 Sep 2018 05:16:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 21 Sep 2018 05:16:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=zWvO6Yz+njbJjaKKEAGKWGgwWK B2I++YEhVTAmh/CBs=; b=VJtLZBTZLpkdf3LNaPwyhhZrPqv+yZmM9yZhxjhWvU +Jrb9tExp4iFJV5wqm/fwRpO2PnhQvUEdlicFsEpGbOXIPnLDF87wpV+mnf9bRGv 49s7LiOlmZMB20ULH1WDg5omALNUzEHXp0uRxpY5tubw6Q7oUJVqxRgVXEBCxd9I E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=zWvO6Y z+njbJjaKKEAGKWGgwWKB2I++YEhVTAmh/CBs=; b=EQH9UGHRNOrozMET9HEifH DbqD1RMiueIQU3URsN1ZCtTGwrXbN4GDW3hb3jgMWAaOcMOd1cEENjqoMOC+2a5T n5lX9xrHJGGwyVFDYaV26WGOU2XUUeMjL9wBflQn9XAaztNnJWQJ4K7OyYvd7q5Z fyTFwJSpitKvHdGTVInwJUUj0f45n9icJMz1ZDyrQNR4cPFAWIrfw8H+xXeVeu+k LmhxIfEABpqj8lzhaPoA8l85l9M2cv14lMquJTviiQXNv8aWWg5JYhiS3j9q9iYj Km7hbXsrNTIlmwYt23rvlk8r1raL4b8eirAVZpoV3f/CJgZfmFw6IhWz4XenXNUQ == X-ME-Proxy: X-ME-Sender: Received: from xps.localnet (unknown [37.168.226.207]) by mail.messagingengine.com (Postfix) with ESMTPA id DA092102DB; Fri, 21 Sep 2018 05:16:06 -0400 (EDT) From: Thomas Monjalon To: Hideyuki Yamashita Cc: dev@dpdk.org, Gaetan Rivet Date: Fri, 21 Sep 2018 11:16:04 +0200 Message-ID: <2330393.uxWCJWc828@xps> In-Reply-To: <201809210720.w8L7JtuZ016319@ccmail04.silk.ntt-tx.co.jp> References: <20180920090919.qigxfgy4qaw6p5om@bidouze.vm.6wind.com> <69884841.TAV26K5Juc@xps> <201809210720.w8L7JtuZ016319@ccmail04.silk.ntt-tx.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] How to replace rte_eth_dev_attach with rte_eal_hotplug_add X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2018 09:16:10 -0000 21/09/2018 09:19, Hideyuki Yamashita: > Dear Gaetan and Thomas,=20 >=20 > Thanks for your answer. > Please see inline. >=20 > > 20/09/2018 11:09, Ga=EF=BF=BDan Rivet: > > > On Thu, Sep 20, 2018 at 05:46:37PM +0900, Hideyuki Yamashita wrote: > > > > Hello, > > > >=20 > > > > From dpdk 18.08 release rte_eth_dev_attach and=20 > > > > rte_eth_dev_detach becom deprecated API and=20 > > > > it is recommended to replace with rte_eal_hotplug_add > > > > and rte_eal_hotplug_remove. > > > >=20 > > > > My program uses above mentioned deprecated APIs > > > > and have to replace those. > > > > Note that my program uses attach to attach vhost, pcap pmd. > > > >=20 > > > > My question is whether it is correct to replace those as following: > > > > find rte_eth_dev_attach function in rte_ethdev.c and > > > > migrate those content into my program. > > > >=20 > > > > e.g.=20 > > > > lib/librte_ethdev/rte_ethdev.c line 643-686 for attach > > > > lib/librte_ethdev/rte_ethdev.c line 690-720 for detach > > > >=20 > > > > Your advice/guidance are much appreciated. > > > > Thanks! > > >=20 > > > Hello Hideyuki, > > >=20 > > > You could use this code for guidance, while leaving the ethdev > > > specificities such as verifying the eth_dev_count_total(). The hotplug > > > function would already return an error if the PMD was not able to cre= ate > > > the necessary devices. > > >=20 > > > The main issue might be to find the port_id of your new port. > > > You won't be able to use eth_dev_last_created_port, so you would have= to > > > iterate over the ethdev using RTE_ETH_FOREACH_DEV and find the one > > > matching your parameters (you might for example match the rte_device > > > name with the name you used in hotplug_add, as there is no standard > > > naming scheme at the ethdev level). > First of all, thank for your answering to my question. > But I have questions. > (Sorry, I have poor knowledge about dpdk and have many basic questions) >=20 > Q1.=20 > Why eth_dev_last_created_port can not be used? > When I look into rte_eth_dev_atthach in 18.08, it calls=20 >=20 > *port_id =3D eth_dev_last_created_port; >=20 > at the end of the function. You can have a race condition. > > Q2.=20 > Is it possible to use rte_eth_dev_get_port_by name=20 > instead of calling RTE_ETH_FOREACH_DEV or using > eth_dev_last_created_port?=09 This function works only if you know the ethdev name generated by the PMD. > Q3.=20 > If answer to Q2 is no, then how can I get device name from each device? > For example, rte_eth_dev_info_get takes port_id as its > argument.But what I want to know is the port id of the specified device > name. If you want the ethdev port ids created after probing (based on devargs), you probably want to request it with the same devargs. I will try to work on something for this need. =46or now, the most reliable solution is to use the notifications. > > It is recommended to register a callback to receive the notifications > > of new ethdev ports. > > So it may be a change of programming style: sync vs async. > Thanks for your advice. > In general, I agree. >=20 > But what is the example of notification that program can receive > after device hotplugged? > Device unplugged notification like specified in rte_eth_event_type? Yes, look at these ones: RTE_ETH_EVENT_NEW, /**< port is probed */ RTE_ETH_EVENT_DESTROY, /**< port is released */ > If there are code in example, it is highly appreciated. You can register a callback with rte_eth_dev_callback_register(RTE_ETH_ALL, RTE_ETH_EVENT_NEW, ...) like done in drivers/net/failsafe/failsafe.c