From: "Iremonger, Bernard" <bernard.iremonger@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>,
"Yigit, Ferruh" <ferruh.yigit@intel.com>,
"arybchenko@solarflare.com" <arybchenko@solarflare.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"ophirmu@mellanox.com" <ophirmu@mellanox.com>,
"rahul.lakkireddy@chelsio.com" <rahul.lakkireddy@chelsio.com>,
Wisam Jaddo <wisamm@mellanox.com>
Subject: Re: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once
Date: Thu, 18 Oct 2018 10:40:03 +0000 [thread overview]
Message-ID: <8CEF83825BEC744B83065625E567D7C260D12CD2@IRSMSX107.ger.corp.intel.com> (raw)
In-Reply-To: <20181018012402.1240-2-thomas@monjalon.net>
Hi Wisam,
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Thursday, October 18, 2018 2:24 AM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>; arybchenko@solarflare.com
> Cc: dev@dpdk.org; ophirmu@mellanox.com; Iremonger, Bernard
> <bernard.iremonger@intel.com>; rahul.lakkireddy@chelsio.com; Wisam Jaddo
> <wisamm@mellanox.com>
> Subject: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at
> once
>
> From: Wisam Jaddo <wisamm@mellanox.com>
>
> When detaching a port, the full rte_device is removed.
> If the rte_device was hosting several ports, the testpmd list of ports must be
> updated for multiple removals.
./devtools/check-git-log.sh -1
Missing 'Fixes' tag:
app/testpmd: fix ports list after removing several at once
> Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
> ---
> app/test-pmd/testpmd.c | 36 +++++++++++++++++++++++++-----------
> 1 file changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> 5dbbf783f..c4109417a 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2186,6 +2186,30 @@ stop_port(portid_t pid)
> printf("Done\n");
> }
>
> +static void
> +remove_unused_fwd_ports(void)
> +{
> + int i;
> + int last_port_idx = nb_ports - 1;
> +
> + for (i = 0; i < last_port_idx + 1; i++) { /* iterate in ports_ids */
Why not use " i <= last_port_index" instead of adding back 1
> + if (rte_eth_devices[ports_ids[i]].state ==
> RTE_ETH_DEV_UNUSED) {
> + /* skip unused ports at the end */
> + while (rte_eth_devices[ports_ids[last_port_idx]].state
> + == RTE_ETH_DEV_UNUSED && i <=
> last_port_idx)
WARNING:LONG_LINE: line over 80 characters
#48: FILE: app/test-pmd/testpmd.c:2199:
+ == RTE_ETH_DEV_UNUSED && i <= last_port_idx)
> + last_port_idx--;
> + if (last_port_idx < i)
> + break;
> + /* overwrite unused port with last valid port */
> + ports_ids[i] = ports_ids[last_port_idx];
> + /* decrease ports count */
> + last_port_idx--;
> + }
> + }
> + nb_ports = rte_eth_dev_count_avail();
> + update_fwd_ports(RTE_MAX_ETHPORTS);
> +}
> +
> void
> close_port(portid_t pid)
> {
> @@ -2315,7 +2339,6 @@ void
> detach_port(portid_t port_id)
> {
> char name[RTE_ETH_NAME_MAX_LEN];
> - uint16_t i;
>
> printf("Detaching a port...\n");
>
> @@ -2332,16 +2355,7 @@ detach_port(portid_t port_id)
> return;
> }
>
> - for (i = 0; i < nb_ports; i++) {
> - if (ports_ids[i] == port_id) {
> - ports_ids[i] = ports_ids[nb_ports-1];
> - ports_ids[nb_ports-1] = 0;
> - break;
> - }
> - }
> - nb_ports = rte_eth_dev_count_avail();
> -
> - update_fwd_ports(RTE_MAX_ETHPORTS);
> + remove_unused_fwd_ports();
>
> printf("Port %u is detached. Now total ports is %d\n",
> port_id, nb_ports);
> --
> 2.19.0
Regards,
Bernard.
next prev parent reply other threads:[~2018-10-18 10:40 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 23:39 [dpdk-dev] [RFC] ethdev: complete closing to free all resources Thomas Monjalon
2018-09-10 8:03 ` Andrew Rybchenko
2018-09-10 8:42 ` Thomas Monjalon
2018-09-10 8:54 ` Andrew Rybchenko
2018-09-12 14:57 ` Thomas Monjalon
2018-09-12 15:44 ` Andrew Rybchenko
2018-09-28 12:46 ` Ferruh Yigit
2018-10-09 22:00 ` Thomas Monjalon
2018-10-09 22:17 ` [dpdk-dev] [PATCH v2] ethdev: complete closing of port Thomas Monjalon
2018-10-10 6:15 ` Andrew Rybchenko
2018-10-10 7:44 ` Thomas Monjalon
2018-10-10 7:50 ` Andrew Rybchenko
2018-10-10 8:39 ` Thomas Monjalon
2018-10-10 15:01 ` Andrew Rybchenko
2018-10-10 16:43 ` Thomas Monjalon
2018-10-10 18:01 ` Andrew Rybchenko
2018-10-10 19:03 ` Thomas Monjalon
2018-10-14 23:20 ` [dpdk-dev] [PATCH v3 0/2] ethdev port freeing Thomas Monjalon
2018-10-14 23:20 ` [dpdk-dev] [PATCH v3 1/2] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-16 11:16 ` Andrew Rybchenko
2018-10-16 12:22 ` Thomas Monjalon
2018-10-16 12:47 ` Andrew Rybchenko
2018-10-16 12:52 ` Thomas Monjalon
2018-10-16 12:55 ` Andrew Rybchenko
2018-10-14 23:20 ` [dpdk-dev] [PATCH v3 2/2] ethdev: complete closing of port Thomas Monjalon
2018-10-16 11:24 ` Andrew Rybchenko
2018-10-16 12:25 ` Thomas Monjalon
2018-10-17 1:54 ` [dpdk-dev] [PATCH v3 0/4] ethdev port freeing Thomas Monjalon
2018-10-17 1:54 ` [dpdk-dev] [PATCH v3 1/4] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-17 2:06 ` Thomas Monjalon
2018-10-17 6:26 ` Andrew Rybchenko
2018-10-17 8:20 ` Thomas Monjalon
2018-10-17 10:30 ` Iremonger, Bernard
2018-10-17 11:33 ` Thomas Monjalon
2018-10-17 1:54 ` [dpdk-dev] [PATCH v3 2/4] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-17 7:13 ` Andrew Rybchenko
2018-10-17 8:22 ` Thomas Monjalon
2018-10-17 1:54 ` [dpdk-dev] [PATCH v3 3/4] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-17 7:25 ` Andrew Rybchenko
2018-10-17 9:27 ` Thomas Monjalon
2018-10-17 1:54 ` [dpdk-dev] [PATCH v3 4/4] ethdev: complete closing of port Thomas Monjalon
2018-10-17 2:12 ` Thomas Monjalon
2018-10-17 10:24 ` [dpdk-dev] [PATCH v3 0/4] ethdev port freeing Shreyansh Jain
2018-10-17 11:31 ` Thomas Monjalon
2018-10-18 1:23 ` [dpdk-dev] [PATCH v5 0/6] " Thomas Monjalon
2018-10-18 1:23 ` [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once Thomas Monjalon
2018-10-18 10:40 ` Iremonger, Bernard [this message]
2018-10-18 11:29 ` Thomas Monjalon
2018-10-18 11:41 ` Iremonger, Bernard
2018-10-18 14:21 ` Thomas Monjalon
2018-10-18 16:42 ` Iremonger, Bernard
2018-10-18 17:06 ` Thomas Monjalon
2018-10-18 11:49 ` Wisam Monther
2018-10-18 13:22 ` Iremonger, Bernard
2018-10-18 1:23 ` [dpdk-dev] [PATCH v5 2/6] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-18 7:45 ` Andrew Rybchenko
2018-10-18 10:51 ` Iremonger, Bernard
2018-10-18 11:24 ` Thomas Monjalon
2018-10-18 1:23 ` [dpdk-dev] [PATCH v5 3/6] ethdev: fix doxygen comments of shared data fields Thomas Monjalon
2018-10-18 7:11 ` Andrew Rybchenko
2018-10-18 1:24 ` [dpdk-dev] [PATCH v5 4/6] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-18 7:13 ` Andrew Rybchenko
2018-10-18 1:24 ` [dpdk-dev] [PATCH v5 5/6] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-18 7:15 ` Andrew Rybchenko
2018-10-18 1:24 ` [dpdk-dev] [PATCH v5 6/6] ethdev: complete closing of port Thomas Monjalon
2018-10-18 8:33 ` Andrew Rybchenko
2018-10-18 9:32 ` Thomas Monjalon
2018-10-19 2:07 ` [dpdk-dev] [PATCH v6 0/6] ethdev port freeing Thomas Monjalon
2018-10-19 2:07 ` [dpdk-dev] [PATCH v6 1/6] app/testpmd: update port list for multiple removals Thomas Monjalon
2018-10-19 14:32 ` Iremonger, Bernard
2018-10-19 2:07 ` [dpdk-dev] [PATCH v6 2/6] app/testpmd: allow detaching a port not closed Thomas Monjalon
2018-10-19 14:32 ` Iremonger, Bernard
2018-10-19 2:07 ` [dpdk-dev] [PATCH v6 3/6] ethdev: fix doxygen comments of shared data fields Thomas Monjalon
2018-10-19 2:07 ` [dpdk-dev] [PATCH v6 4/6] ethdev: free all common data when releasing port Thomas Monjalon
2018-10-19 2:07 ` [dpdk-dev] [PATCH v6 5/6] ethdev: remove release function for secondary process Thomas Monjalon
2018-10-19 2:07 ` [dpdk-dev] [PATCH v6 6/6] ethdev: complete closing of port Thomas Monjalon
2018-10-19 10:13 ` Andrew Rybchenko
2018-10-22 15:43 ` [dpdk-dev] [PATCH v6 0/6] ethdev port freeing Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8CEF83825BEC744B83065625E567D7C260D12CD2@IRSMSX107.ger.corp.intel.com \
--to=bernard.iremonger@intel.com \
--cc=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=ophirmu@mellanox.com \
--cc=rahul.lakkireddy@chelsio.com \
--cc=thomas@monjalon.net \
--cc=wisamm@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).