Message ID | 1418106629-22227-8-git-send-email-mukawa@igel.co.jp (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B5C4B806B; Tue, 9 Dec 2014 07:31:02 +0100 (CET) Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by dpdk.org (Postfix) with ESMTP id C16E38058 for <dev@dpdk.org>; Tue, 9 Dec 2014 07:31:00 +0100 (CET) Received: by mail-pd0-f175.google.com with SMTP id y10so6717537pdj.20 for <dev@dpdk.org>; Mon, 08 Dec 2014 22:31:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ykEEdLb2sd+dcc1JwJ4wSrQNpE6kd4uLtWdX1Pid31o=; b=ebRgE8k4LMOSY4/aoi58pX4QfRhdvLDOFOppDR3hV465TycNAy0aqyPI/nmqty3fRL aYaQWXaJ+TwG8BSFFSlGQRvXRvt6sPV2aEY7h9T3/TLOSoi49G0JK1y41/0T9Ws5m0N0 ph2q4iiHV7O9DESAoR1bGQEosIP76D0F+esxWzHhfz+yDICzcj3Ewg1qCVjyDfHymC3Q AOjY8NHAjL5dA0LOQ+7QbqNP5CWdivsPbGJYnJnrHz6vgyu3r5r5KZMJHsdSwB4wdjPy srwWyW3S+YQ2aIc2D9f8gn5YzT8L8VbqflXCLJlsyo+HgvRTcqC1JBOvwTD2LG0PYvVT s/0w== X-Gm-Message-State: ALoCoQnIIKPm6orVYnDZHS+o0Kwkv7xt3lI1Bhu1dVSJ1gsr22+65MP/whA/uPMDcmrCzodibIau X-Received: by 10.66.194.195 with SMTP id hy3mr2156221pac.125.1418106660139; Mon, 08 Dec 2014 22:31:00 -0800 (PST) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id f12sm403088pat.43.2014.12.08.22.30.57 for <multiple recipients> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 22:30:59 -0800 (PST) From: Tetsuya Mukawa <mukawa@igel.co.jp> To: dev@dpdk.org Date: Tue, 9 Dec 2014 15:30:08 +0900 Message-Id: <1418106629-22227-8-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com, masutani.hitoshi@lab.ntt.co.jp Subject: [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 <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Tetsuya Mukawa
Dec. 9, 2014, 6:30 a.m. UTC
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, then
compare these with current values to know which port is actually
attached or detached.
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_ether/rte_ethdev.c | 21 +++++++++++++++++++++
lib/librte_ether/rte_ethdev.h | 21 +++++++++++++++++++++
2 files changed, 42 insertions(+)
Comments
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, then > compare these with current values to know which port is actually > attached or detached. > > Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp> > --- > 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_ethdev.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); > } > > +void > +rte_eth_dev_save(struct rte_eth_dev *devs) > +{ > + if (devs == 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 = 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. Thanks, Michael > + return 1; > +} > + > static int > rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) > { > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.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); > > /** > + * 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 pointer > + * 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 the pointer
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, then >> compare these with current values to know which port is actually >> attached or detached. >> >> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp> >> --- >> 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_ethdev.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); >> } >> >> +void >> +rte_eth_dev_save(struct rte_eth_dev *devs) >> +{ >> + if (devs == 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 = 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_queues) >> { >> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.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); >> >> /** >> + * 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 pointer >> + * 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 the pointer
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(). >>> 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, then >>> compare these with current values to know which port is actually >>> attached or detached. >>> >>> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp> >>> --- >>> 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_ethdev.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); >>> } >>> >>> +void >>> +rte_eth_dev_save(struct rte_eth_dev *devs) >>> +{ >>> + if (devs == 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 = 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. 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. 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_queues) >>> { >>> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.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); >>> >>> /** >>> + * 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 pointer >>> + * 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 the pointer > >
(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(). >>>> 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, then >>>> compare these with current values to know which port is actually >>>> attached or detached. >>>> >>>> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp> >>>> --- >>>> 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_ethdev.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); >>>> } >>>> >>>> +void >>>> +rte_eth_dev_save(struct rte_eth_dev *devs) >>>> +{ >>>> + if (devs == 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 = 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. > 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 function. 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_queues) >>>> { >>>> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.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); >>>> >>>> /** >>>> + * 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 pointer >>>> + * 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 the pointer >>
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.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); } +void +rte_eth_dev_save(struct rte_eth_dev *devs) +{ + if (devs == 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 = 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, devs++) + if (rte_eth_devices[*port_id].attached ^ devs->attached) + return 0; + return 1; +} + static int rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.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); /** + * 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 pointer + * 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 the pointer