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 54FA53F9 for ; Tue, 9 Dec 2014 15:40:10 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 09 Dec 2014 06:39:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="426922839" Received: from kmsmsx153.gar.corp.intel.com ([172.21.73.88]) by FMSMGA003.fm.intel.com with ESMTP; 09 Dec 2014 06:28:48 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.110.15) by KMSMSX153.gar.corp.intel.com (172.21.73.88) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 9 Dec 2014 22:39:26 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.182]) with mapi id 14.03.0195.001; Tue, 9 Dec 2014 22:39:19 +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: AQHQE3n2AC8ueqOSQUGeUjv+feL4eg== Date: Tue, 9 Dec 2014 14:39:18 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9E1E8@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> 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: Tue, 09 Dec 2014 14:40:12 -0000 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, then= =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_ethdev.= 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_id)= =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= =0A= Can we have more than one port changed?=0A= If so, your logic should do little modify.=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_queues)= =0A= > {=0A= > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.= 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 pointe= r=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-based= =0A= > * driver.=0A= > * Allocates a new ethdev slot for an ethernet device and returns the po= inter=0A= =0A=