From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by dpdk.org (Postfix) with ESMTP id 292D86A95 for ; Thu, 11 Dec 2014 04:12:12 +0100 (CET) Received: by mail-pa0-f52.google.com with SMTP id eu11so4123891pac.11 for ; Wed, 10 Dec 2014 19:12:11 -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=TeUMa0pQSYL9Twp94hsez5MRNhlVRY7ug0wUnD6vd+8=; b=CcQHkLPt4i9bHuk/cPx+KuZ+nFrtdMSqeTPOHr2+GD6Y9FGKT07N5HDsMYyVjbVcWF lEw3Cl4XzwqigB5s4QL7WHmWJavuVva2fQRDgm6z3M5r91O4brUWusZP1LzIlxtosZjB oLxB27BFAo2j+nJtTCoAKLfUdsu/i3O3rg2FcYM1yLBjKE2+osJ/LV8R4u8bVNOPW2td F6NGOIpMpuDDKYFDdxireEB8R4TofqA5xr/cPBZAZ+w88VLjKZA4FWhLfMgQB52eeiFs 9PgJH3jK1QC8gAPeWgo4T7ORN4IedX8NOIicCuB/q9+Y8RTUdlQe2/aBrzhDjJlxlqPs vqHQ== X-Gm-Message-State: ALoCoQnYZiLF90/k+iQWp24w/zMfvliJ2b7tD7Rw7vTUnsoobDJrvoG7rS618HQ7Gur8bsQuy65N X-Received: by 10.70.59.35 with SMTP id w3mr13078623pdq.104.1418267531281; Wed, 10 Dec 2014 19:12:11 -0800 (PST) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id jp15sm5452732pbb.17.2014.12.10.19.12.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Dec 2014 19:12:10 -0800 (PST) Message-ID: <54890B88.5050608@igel.co.jp> Date: Thu, 11 Dec 2014 12:12:08 +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> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9E1E8@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 03:12:12 -0000 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(). >> rte_eth_dev_save() is used for saving current rte_eth_dev structures. >> rte_eth_dev_get_changed_port() receives the rte_eth_dev structures, th= en >> 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_ethd= ev.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 *port_= id) >> +{ >> + /* check which port was attached or detached */ >> + for (*port_id =3D 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, devs= ++) >> + 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 same time. 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_queu= es) >> { >> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethd= ev.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 poi= nter >> + * 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-ba= sed >> * driver. >> * Allocates a new ethdev slot for an ethernet device and returns the= pointer