From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 8BC8968BE for ; Thu, 11 Dec 2014 05:57:18 +0100 (CET) Received: by mail-pd0-f178.google.com with SMTP id r10so4202932pdi.23 for ; Wed, 10 Dec 2014 20:57:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=ODbXrFBV0FaOr/Jyv6PTjkUhJiMd+G046WwpZG+Y/UM=; b=G14wvJOxPRKfwrhawul3YZ56d+Zhkl7XfhfhHIlBMWsmx9vD/RV06pwCMVE5UiRFhV 9uut0612zJy6NrujMBorhmjgeLO1kFEEQlMa0oWV2Va785AqpfEgUZ0mzN7tO+L7C1I6 gAYEfXPvvZLvWe3a1SuCPE4g4iOwq82QnQ64X8l6xgJnyoDvV++TulCwFCJLADtHQzOL jayK1518p436UujwTsh96Ko8+y1a8CgNSz5siTwNLvhEJVBvKMYAO7hmeaIqa4vMIPtZ uC3PC0hu62IQwJxHM3d9X0YB+ImYy2EH6dDXVlT5+9v0LDImS/qT0kXAQ5nKKFgzN1nQ W32Q== X-Gm-Message-State: ALoCoQmZ+PDEsjQ/ZQKr01WSea5VkhLeTDgxjNQJlMB3kZMF3mdltkXiWqePV3DF53eACVC8ggj5 X-Received: by 10.70.102.234 with SMTP id fr10mr13211657pdb.145.1418273837755; Wed, 10 Dec 2014 20:57:17 -0800 (PST) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id vy1sm75862pac.20.2014.12.10.20.57.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Dec 2014 20:57:17 -0800 (PST) Message-ID: <5489242B.90807@igel.co.jp> Date: Thu, 11 Dec 2014 13:57:15 +0900 From: Tetsuya Mukawa User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "Qiu, Michael" , "dev@dpdk.org" References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-8-git-send-email-mukawa@igel.co.jp> <533710CFB86FA344BFBF2D6802E60286C9E1E8@SHSMSX101.ccr.corp.intel.com> <54890B88.5050608@igel.co.jp> <533710CFB86FA344BFBF2D6802E60286C9EC10@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9EC10@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "nakajima.yoshihiro@lab.ntt.co.jp" , "masutani.hitoshi@lab.ntt.co.jp" , "menrigh@brocade.com" Subject: Re: [dpdk-dev] [PATCH v3 07/28] ethdev: Add functions to know which port is attached or detached X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2014 04:57:18 -0000 (2014/12/11 12:35), Qiu, Michael wrote: > On 12/11/2014 11:12 AM, Tetsuya Mukawa wrote: >> Hi Michael, >> >> (2014/12/09 23:39), Qiu, Michael wrote: >>> On 2014/12/9 14:32, Tetsuya Mukawa wrote: >>>> The patch adds rte_eth_dev_save() and rte_eth_dev_get_changed_port()= =2E >>>> rte_eth_dev_save() is used for saving current rte_eth_dev structures= =2E >>>> rte_eth_dev_get_changed_port() receives the rte_eth_dev structures, = then >>>> compare these with current values to know which port is actually >>>> attached or detached. >>>> >>>> Signed-off-by: Tetsuya Mukawa >>>> --- >>>> lib/librte_ether/rte_ethdev.c | 21 +++++++++++++++++++++ >>>> lib/librte_ether/rte_ethdev.h | 21 +++++++++++++++++++++ >>>> 2 files changed, 42 insertions(+) >>>> >>>> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_et= hdev.c >>>> index 51697e1..6a3700e 100644 >>>> --- a/lib/librte_ether/rte_ethdev.c >>>> +++ b/lib/librte_ether/rte_ethdev.c >>>> @@ -416,6 +416,27 @@ rte_eth_dev_count(void) >>>> return (nb_ports); >>>> } >>>> =20 >>>> +void >>>> +rte_eth_dev_save(struct rte_eth_dev *devs) >>>> +{ >>>> + if (devs =3D=3D NULL) >>>> + return; >>>> + >>>> + /* save current rte_eth_devices */ >>>> + memcpy(devs, rte_eth_devices, >>>> + sizeof(struct rte_eth_dev) * RTE_MAX_ETHPORTS); >>>> +} >>>> + >>>> +int >>>> +rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *por= t_id) >>>> +{ >>>> + /* check which port was attached or detached */ >>>> + for (*port_id =3D 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, de= vs++) >>>> + if (rte_eth_devices[*port_id].attached ^ devs->attached) >>>> + return 0; >>> Can we have more than one port changed? >>> If so, your logic should do little modify. >> The port hotplug APIs cannot attach or detach multiple port at the sam= e >> time. > What I mean is can we first detach one port, then another? If it legal > to do this, here will always return the port with the min port_id. It's not legal. Above 2 functions are implemented to be called by rte_eal_dev_attach(). When rte_eal_dev_attach() is called, rte_eth_dev_save() and rte_eth_dev_get_changed_port() will be invoked continuously in the functi= on. But while executing the 2 functions, only one port status will be changed, because rte_eal_dev_attach() and rte_eal_dev_detach() should be called one by one. Thanks, Tetsuya > > Thanks, > Michael >> And the APIs are not thread safe. DPDK application should have lock >> properly if multiple threads call the APIs. >> Because of this, we don't need to take care of such a case. >> >>> Thanks, >>> Michael >>>> + return 1; >>>> +} >>>> + >>>> static int >>>> rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_qu= eues) >>>> { >>>> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_et= hdev.h >>>> index b329e11..03c8850 100644 >>>> --- a/lib/librte_ether/rte_ethdev.h >>>> +++ b/lib/librte_ether/rte_ethdev.h >>>> @@ -1642,6 +1642,27 @@ extern struct rte_eth_dev rte_eth_devices[]; >>>> extern uint8_t rte_eth_dev_count(void); >>>> =20 >>>> /** >>>> + * Function for internal use by port hotplug functions. >>>> + * Copies current ethdev structures to the specified pointer. >>>> + * >>>> + * @param devs The pointer to the ethdev structures >>>> + */ >>>> +extern void rte_eth_dev_save(struct rte_eth_dev *devs); >>>> + >>>> +/** >>>> + * Function for internal use by port hotplug functions. >>>> + * Compare the specified ethdev structures with currents. Then >>>> + * if there is a port which status is changed, fill the specified p= ointer >>>> + * with the port id of that port. >>>> + * @param devs The pointer to the ethdev structures >>>> + * @param port_id The pointer to the port id >>>> + * @return >>>> + * - 0 on success, negative on error >>>> + */ >>>> +extern int rte_eth_dev_get_changed_port( >>>> + struct rte_eth_dev *devs, uint8_t *port_id); >>>> + >>>> +/** >>>> * Function for internal use by dummy drivers primarily, e.g. ring-= based >>>> * driver. >>>> * Allocates a new ethdev slot for an ethernet device and returns t= he pointer >>