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 29DE61B111 for ; Thu, 27 Sep 2018 10:58:50 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C7C70212AC; Thu, 27 Sep 2018 04:58:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 27 Sep 2018 04:58:49 -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=e5FHEEIrbm4FzeiryQK8Mdrso0 o37Mi5rq/8W9hX3/o=; b=BezDVAZms7Of0xOhjqPvEEPmKoXaFA3629iNGFs0BT H4olJLnrNdAC9+kdUGs/2ywTl0QBaBJNbBcIjGQo6iBUzlH/+dCLKs10j5fqTrZb 6+F0YWD0wxZXLRFeaXpnqj1tT9Plotjjjtdpw/O8LG6seXclWK82OMQVmnMgGgt2 c= 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=e5FHEE Irbm4FzeiryQK8Mdrso0o37Mi5rq/8W9hX3/o=; b=Bh+kGTc2QjevWTDbdhRJXB ez2a0+aYB9LZPmTukxg+cRTYq2MYs37QT+xMVr33L5f/2bLc0u32qSSEuUjMGoIT OGygW6WGVzmhayGVnCgojgEWKz/57jmSBTK0RRtOpIh8g1hr3LPTdPIiQZB3zhbP em/eYXNPI9rWA3UsGNWWcWsr5lEASEpjrIPAb6NzqFB8SgrnpIx+0d0U3AwO45CZ r7PtMjGMxGhcGfBuPB3E6XhttXN4N0f2paEEbLTJcvZ3Hr4BpTcG0mMctho1y2hF jfKPyKX4iTfGTTNd3cqVdsi1upqivLYKxAOCrWH+A3Q5/1lOA6LFhmiZtrjn4Rhw == X-ME-Proxy: X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id B7EA9E44DF; Thu, 27 Sep 2018 04:58:48 -0400 (EDT) From: Thomas Monjalon To: Hideyuki Yamashita Cc: dev@dpdk.org, Gaetan Rivet Date: Thu, 27 Sep 2018 10:58:47 +0200 Message-ID: <1671413.72NatgAg1l@xps> In-Reply-To: <201809270138.w8R1cJHm000890@ccmail04.silk.ntt-tx.co.jp> References: <201809210720.w8L7JtuZ016319@ccmail04.silk.ntt-tx.co.jp> <2330393.uxWCJWc828@xps> <201809270138.w8R1cJHm000890@ccmail04.silk.ntt-tx.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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: Thu, 27 Sep 2018 08:58:50 -0000 27/09/2018 03:38, Hideyuki Yamashita: > Dear Thomas, > > Thanks for your answer. > It took me a little time to digest answer. > Please see inline. > > > > 21/09/2018 09:19, Hideyuki Yamashita: > > > Dear Gaetan and Thomas, > > > > > > Thanks for your answer. > > > Please see inline. > > > > > > > 20/09/2018 11:09, Ga?an Rivet: > > > > > On Thu, Sep 20, 2018 at 05:46:37PM +0900, Hideyuki Yamashita wrote: > > > > > > Hello, > > > > > > > > > > > > From dpdk 18.08 release rte_eth_dev_attach and > > > > > > rte_eth_dev_detach becom deprecated API and > > > > > > it is recommended to replace with rte_eal_hotplug_add > > > > > > and rte_eal_hotplug_remove. > > > > > > > > > > > > My program uses above mentioned deprecated APIs > > > > > > and have to replace those. > > > > > > Note that my program uses attach to attach vhost, pcap pmd. > > > > > > > > > > > > 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. > > > > > > > > > > > > e.g. > > > > > > lib/librte_ethdev/rte_ethdev.c line 643-686 for attach > > > > > > lib/librte_ethdev/rte_ethdev.c line 690-720 for detach > > > > > > > > > > > > Your advice/guidance are much appreciated. > > > > > > Thanks! > > > > > > > > > > Hello Hideyuki, > > > > > > > > > > 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 create > > > > > the necessary devices. > > > > > > > > > > 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) > > > > > > Q1. > > > Why eth_dev_last_created_port can not be used? > > > When I look into rte_eth_dev_atthach in 18.08, it calls > > > > > > *port_id = eth_dev_last_created_port; > > > > > > at the end of the function. > > > > You can have a race condition. > Please elaborate me a bit more. > > Is it correct understanding that race condition > includes > - read information before port is available > - other device may be plugged (or unplugged) > and so using "eth_dev_last_created_port" is > NOT reliable? I am thinking about the second one only. > > > Q2. > > > Is it possible to use rte_eth_dev_get_port_by name > > > instead of calling RTE_ETH_FOREACH_DEV or using > > > eth_dev_last_created_port? > > > > This function works only if you know the ethdev name generated by the PMD. > Thanks > > > > Q3. > > > 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. > > For now, the most reliable solution is to use the notifications. > > I think I have two alternatives: > Alt1: > call "rte_eal_hotplug_add" > and retrieve port_id for newly plugged device > using RTE_ETH_FOREACH_DEV. > (as Gaetan said) > > Alt2: > call "rte_eth_dev_callback_register" to subscribe "port probe" event > and "rte_eal_hotplug_add" > and finally get notification including port id. > (As you said) > > My question is which is better alternative? > Are there any bad point on Alt1 like using > eth_dev_last_created_port? > (e.g. port not available when called RTE_ETH_FOREACH_DEV) I think both are OK.