From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 499D82A9 for ; Thu, 11 Dec 2014 04:35:11 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 10 Dec 2014 19:35:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,555,1413270000"; d="scan'208";a="645835179" Received: from kmsmsx153.gar.corp.intel.com ([172.21.73.88]) by fmsmga002.fm.intel.com with ESMTP; 10 Dec 2014 19:35:07 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by KMSMSX153.gar.corp.intel.com (172.21.73.88) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 11 Dec 2014 11:35:06 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by shsmsx102.ccr.corp.intel.com ([169.254.2.216]) with mapi id 14.03.0195.001; Thu, 11 Dec 2014 11:35:05 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 07/28] ethdev: Add functions to know which port is attached or detached Thread-Index: AQHQFPBX1iNNtl1lukqPng4DAqetCw== Date: Thu, 11 Dec 2014 03:35:05 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9EC10@SHSMSX101.ccr.corp.intel.com> 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> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 03:35:11 -0000 On 12/11/2014 11:12 AM, Tetsuya Mukawa wrote:=0A= > Hi Michael,=0A= >=0A= > (2014/12/09 23:39), Qiu, Michael wrote:=0A= >> On 2014/12/9 14:32, Tetsuya Mukawa wrote:=0A= >>> The patch adds rte_eth_dev_save() and rte_eth_dev_get_changed_port().= =0A= >>> rte_eth_dev_save() is used for saving current rte_eth_dev structures.= =0A= >>> rte_eth_dev_get_changed_port() receives the rte_eth_dev structures, the= n=0A= >>> compare these with current values to know which port is actually=0A= >>> attached or detached.=0A= >>>=0A= >>> Signed-off-by: Tetsuya Mukawa =0A= >>> ---=0A= >>> lib/librte_ether/rte_ethdev.c | 21 +++++++++++++++++++++=0A= >>> lib/librte_ether/rte_ethdev.h | 21 +++++++++++++++++++++=0A= >>> 2 files changed, 42 insertions(+)=0A= >>>=0A= >>> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethde= v.c=0A= >>> index 51697e1..6a3700e 100644=0A= >>> --- a/lib/librte_ether/rte_ethdev.c=0A= >>> +++ b/lib/librte_ether/rte_ethdev.c=0A= >>> @@ -416,6 +416,27 @@ rte_eth_dev_count(void)=0A= >>> return (nb_ports);=0A= >>> }=0A= >>> =0A= >>> +void=0A= >>> +rte_eth_dev_save(struct rte_eth_dev *devs)=0A= >>> +{=0A= >>> + if (devs =3D=3D NULL)=0A= >>> + return;=0A= >>> +=0A= >>> + /* save current rte_eth_devices */=0A= >>> + memcpy(devs, rte_eth_devices,=0A= >>> + sizeof(struct rte_eth_dev) * RTE_MAX_ETHPORTS);=0A= >>> +}=0A= >>> +=0A= >>> +int=0A= >>> +rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *port_i= d)=0A= >>> +{=0A= >>> + /* check which port was attached or detached */=0A= >>> + for (*port_id =3D 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, devs+= +)=0A= >>> + if (rte_eth_devices[*port_id].attached ^ devs->attached)=0A= >>> + return 0;=0A= >> Can we have more than one port changed?=0A= >> If so, your logic should do little modify.=0A= > The port hotplug APIs cannot attach or detach multiple port at the same= =0A= > time.=0A= =0A= What I mean is can we first detach one port, then another? If it legal=0A= to do this, here will always return the port with the min port_id.=0A= =0A= Thanks,=0A= Michael=0A= > And the APIs are not thread safe. DPDK application should have lock=0A= > properly if multiple threads call the APIs.=0A= > Because of this, we don't need to take care of such a case.=0A= >=0A= >> Thanks,=0A= >> Michael=0A= >>> + return 1;=0A= >>> +}=0A= >>> +=0A= >>> static int=0A= >>> rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queue= s)=0A= >>> {=0A= >>> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethde= v.h=0A= >>> index b329e11..03c8850 100644=0A= >>> --- a/lib/librte_ether/rte_ethdev.h=0A= >>> +++ b/lib/librte_ether/rte_ethdev.h=0A= >>> @@ -1642,6 +1642,27 @@ extern struct rte_eth_dev rte_eth_devices[];=0A= >>> extern uint8_t rte_eth_dev_count(void);=0A= >>> =0A= >>> /**=0A= >>> + * Function for internal use by port hotplug functions.=0A= >>> + * Copies current ethdev structures to the specified pointer.=0A= >>> + *=0A= >>> + * @param devs The pointer to the ethdev structures=0A= >>> + */=0A= >>> +extern void rte_eth_dev_save(struct rte_eth_dev *devs);=0A= >>> +=0A= >>> +/**=0A= >>> + * Function for internal use by port hotplug functions.=0A= >>> + * Compare the specified ethdev structures with currents. Then=0A= >>> + * if there is a port which status is changed, fill the specified poin= ter=0A= >>> + * with the port id of that port.=0A= >>> + * @param devs The pointer to the ethdev structures=0A= >>> + * @param port_id The pointer to the port id=0A= >>> + * @return=0A= >>> + * - 0 on success, negative on error=0A= >>> + */=0A= >>> +extern int rte_eth_dev_get_changed_port(=0A= >>> + struct rte_eth_dev *devs, uint8_t *port_id);=0A= >>> +=0A= >>> +/**=0A= >>> * Function for internal use by dummy drivers primarily, e.g. ring-bas= ed=0A= >>> * driver.=0A= >>> * Allocates a new ethdev slot for an ethernet device and returns the = pointer=0A= >=0A= >=0A= =0A=