DPDK patches and discussions
 help / color / mirror / Atom feed
From: "lihuisong (C)" <lihuisong@huawei.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>,
	"Min Hu (Connor)" <humin29@huawei.com>, <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <xiaoyun.li@intel.com>
Subject: Re: [dpdk-dev] [PATCH 2/3] app/testpmd: fix slave device isn't released
Date: Tue, 8 Feb 2022 09:12:48 +0800	[thread overview]
Message-ID: <f4e02a97-c034-44b4-ed08-609b63bc5503@huawei.com> (raw)
In-Reply-To: <a40dc20f-2d72-df19-4340-e2124d6e4545@intel.com>


在 2022/2/4 20:14, Ferruh Yigit 写道:
> On 10/25/2021 7:39 AM, Min Hu (Connor) wrote:
>> From: Huisong Li <lihuisong@huawei.com>
>>
>> Currently, some eth devices are added to bond device, these devices 
>> are not
>> released when the quit command is executed in testpmd. This patch 
>> adds the
>> release operation for all active slaves under a bond device.
>>
>
> 'close_port()' function traverses all ports, when bonding is close, if it
> removes the slaves, won't 'close_port()' close slave devices?
Yes
>
> If so this prevents, 'cl_quit' global variable.
The variable is used to ensure that the slave ports are not closed when the
bonding port is closed, and are closed when testpmd quit or is killed.
>
>> Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in 
>> bonding")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   app/test-pmd/cmdline.c |  1 +
>>   app/test-pmd/testpmd.c | 67 ++++++++++++++++++++++++++++++++++++------
>>   app/test-pmd/testpmd.h |  1 +
>>   3 files changed, 60 insertions(+), 9 deletions(-)
>>
>> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
>> index 5bfb4b509b..98236a8be3 100644
>> --- a/app/test-pmd/cmdline.c
>> +++ b/app/test-pmd/cmdline.c
>> @@ -8743,6 +8743,7 @@ static void cmd_quit_parsed(__rte_unused void 
>> *parsed_result,
>>                   __rte_unused void *data)
>>   {
>>       cmdline_quit(cl);
>> +    cl_quit = 1;
>>   }
>>     cmdline_parse_token_string_t cmd_quit_quit =
>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
>> index d6b9ebc4dd..fea9744bd6 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -221,6 +221,7 @@ unsigned int xstats_display_num; /**< Size of 
>> extended statistics to show */
>>    * option. Set flag to exit stats period loop after received 
>> SIGINT/SIGTERM.
>>    */
>>   uint8_t f_quit;
>> +uint8_t cl_quit; /* Quit testpmd from cmdline. */
>>     /*
>>    * Max Rx frame size, set by '--max-pkt-len' parameter.
>> @@ -613,15 +614,6 @@ eth_dev_start_mp(uint16_t port_id)
>>       return 0;
>>   }
>>   -static int
>> -eth_dev_stop_mp(uint16_t port_id)
>> -{
>> -    if (is_proc_primary())
>> -        return rte_eth_dev_stop(port_id);
>> -
>> -    return 0;
>> -}
>> -
>>   static void
>>   mempool_free_mp(struct rte_mempool *mp)
>>   {
>> @@ -3123,6 +3115,55 @@ remove_invalid_ports(void)
>>       nb_cfg_ports = nb_fwd_ports;
>>   }
>>   +#ifdef RTE_NET_BOND
>> +static void
>> +handle_bonding_slave_device(portid_t bond_pid)
>
> 'handle' in the function is not very specific, it is not clear
> what this function does.
ok
>
>> +{
>> +    portid_t slave_pids[RTE_MAX_ETHPORTS];
>> +    struct rte_port *port;
>> +    portid_t slave_pid;
>> +    int num_slaves;
>> +    int i;
>> +
>> +    num_slaves = rte_eth_bond_slaves_get(bond_pid, slave_pids,
>> +                         RTE_MAX_ETHPORTS);
>> +    if (num_slaves < 0) {
>> +        fprintf(stderr, "Failed to get slave list for port = %u\n",
>> +            bond_pid);
>> +        return;
>> +    }
>> +
>> +    for (i = 0; i < num_slaves; i++) {
>> +        slave_pid = slave_pids[i];
>> +        /* Before removing a slave device, stop the slave device. */
>> +        if (port_is_started(slave_pid) == 1) {
>> +            if (rte_eth_dev_stop(slave_pid) != 0)
>> +                fprintf(stderr, "rte_eth_dev_stop failed for port 
>> %u\n",
>> +                    slave_pid);
>> +
>> +            port = &ports[slave_pid];
>> +            if (rte_atomic16_cmpset(&(port->port_status),
>> +                RTE_PORT_STARTED, RTE_PORT_STOPPED) == 0)
>> +                fprintf(stderr, "Port %u can not be set into 
>> stopped\n",
>> +                    slave_pid);
>> +        }
>> +
>> +        /*
>> +         * Remove the slave from a bonded device in case of failing to
>> +         * close bond device.
>> +         */
>> +        if (rte_eth_bond_slave_remove(bond_pid, slave_pid) != 0)
>
> Similar to Aman's comment in previous patch, if a bonding device is 
> removed
> shouldn't the bonding PMD stop the slaves and removed them, instead of 
> application?

I agree. I plan to remove them, and move the operations of clearing the 
slave flag

and closing slave port to after the bonding port is closed.

>
>> +            fprintf(stderr, "Failed to remove slave %u from master 
>> port = %u\n",
>> +                slave_pid, bond_pid);
>> +        clear_port_slave_flag(slave_pid);
>> +
>> +        /* Close slave device when testpmd quit or is killed. */
>> +        if (cl_quit == 1 || f_quit == 1)
>> +            rte_eth_dev_close(slave_pid);
>> +    }
>> +}
>> +#endif
>> +
>>   void
>>   close_port(portid_t pid)
>>   {
>> @@ -3161,6 +3202,14 @@ close_port(portid_t pid)
>>             if (is_proc_primary()) {
>>               port_flow_flush(pi);
>> +#ifdef RTE_NET_BOND
>> +            /*
>> +             * If this port is bond device, all slaves under the
>> +             * device need to be removed or closed.
>> +             */
>> +            if (port->bond_flag == 1)
>> +                handle_bonding_slave_device(pi);
>> +#endif
>>               port_flex_item_flush(pi);
>>               rte_eth_dev_close(pi);
>>           }
>> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
>> index ad3b4f875c..216fc41432 100644
>> --- a/app/test-pmd/testpmd.h
>> +++ b/app/test-pmd/testpmd.h
>> @@ -27,6 +27,7 @@
>>   #define RTE_PORT_STARTED        (uint16_t)1
>>   #define RTE_PORT_CLOSED         (uint16_t)2
>>   #define RTE_PORT_HANDLING       (uint16_t)3
>> +extern uint8_t cl_quit;
>>     /*
>>    * It is used to allocate the memory for hash key.
>
> .

  reply	other threads:[~2022-02-08  1:12 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25  6:39 [dpdk-dev] [PATCH 0/3] bugfix for testpmd Min Hu (Connor)
2021-10-25  6:39 ` [dpdk-dev] [PATCH 1/3] app/testpmd: fix port status of active slave device Min Hu (Connor)
2021-11-15 13:01   ` Singh, Aman Deep
2021-11-16  1:20     ` lihuisong (C)
2022-02-03  7:06       ` Singh, Aman Deep
2022-02-04 12:07   ` Ferruh Yigit
2022-02-08  1:19     ` lihuisong (C)
2021-10-25  6:39 ` [dpdk-dev] [PATCH 2/3] app/testpmd: fix slave device isn't released Min Hu (Connor)
2022-02-04 12:14   ` Ferruh Yigit
2022-02-08  1:12     ` lihuisong (C) [this message]
2021-10-25  6:39 ` [dpdk-dev] [PATCH 3/3] app/testpmd: remove unused header file Min Hu (Connor)
2021-11-08 16:05   ` Ferruh Yigit
2022-03-24  3:00 ` [PATCH V2 0/4] bugfix for bonding Min Hu (Connor)
2022-03-24  3:00   ` [PATCH V2 1/4] net/bonding: fix non-active slaves aren't stopped Min Hu (Connor)
2022-04-26 18:19     ` Ferruh Yigit
2022-04-29  6:45       ` Min Hu (Connor)
2022-04-29 13:31         ` Ferruh Yigit
2022-05-03  6:54           ` Min Hu (Connor)
2022-05-03 19:04             ` Ferruh Yigit
2022-05-05  1:16               ` Min Hu (Connor)
2022-03-24  3:00   ` [PATCH V2 2/4] net/bonding: fix non-terminable while loop Min Hu (Connor)
2022-04-26 18:19     ` Ferruh Yigit
2022-04-29  6:52       ` Min Hu (Connor)
2022-04-29 13:35         ` Ferruh Yigit
2022-03-24  3:00   ` [PATCH V2 3/4] app/testpmd: fix port status of slave device Min Hu (Connor)
2022-03-24  3:00   ` [PATCH V2 4/4] app/testpmd: fix slave device isn't released Min Hu (Connor)
2022-05-30  6:01     ` Min Hu (Connor)
2022-05-30 10:21       ` Singh, Aman Deep
2022-04-25  6:49   ` [PATCH V2 0/4] bugfix for bonding Min Hu (Connor)
2022-05-03 10:02   ` [PATCH v3 0/5] " Min Hu (Connor)
2022-05-03 10:02     ` [PATCH v3 1/5] net/bonding: fix non-active slaves aren't stopped Min Hu (Connor)
2022-05-03 10:02     ` [PATCH v3 2/5] net/bonding: fix non-terminable while loop Min Hu (Connor)
2022-05-03 10:02     ` [PATCH v3 3/5] app/testpmd: fix port status of slave device Min Hu (Connor)
2022-05-03 23:39       ` Konstantin Ananyev
2022-05-06  8:16         ` Min Hu (Connor)
2022-05-08 11:28           ` Konstantin Ananyev
2022-05-10 16:34           ` Ferruh Yigit
2022-05-10 21:48             ` Konstantin Ananyev
2022-05-11  2:16               ` Min Hu (Connor)
2022-05-11 10:05                 ` Ferruh Yigit
2022-05-11  2:14       ` [PATCH v4] " Min Hu (Connor)
2022-05-11 22:08         ` Konstantin Ananyev
2022-05-19  7:15           ` Andrew Rybchenko
2022-05-03 10:02     ` [PATCH v3 4/5] app/testpmd: fix slave device isn't released Min Hu (Connor)
2022-06-01 17:54       ` Ferruh Yigit
2022-06-07  8:15         ` Dongdong Liu
2022-06-07  8:10       ` [PATCH v4] " Dongdong Liu
2022-06-07 14:31         ` Ferruh Yigit
2022-06-09  7:50           ` Dongdong Liu
2022-06-09  8:50             ` Ferruh Yigit
2022-06-09 11:20               ` Dongdong Liu
2022-06-09 11:49       ` [PATCH v5] " Dongdong Liu
2022-06-10  8:10         ` Ferruh Yigit
2022-05-03 10:02     ` [PATCH v3 5/5] ethdev: fix dev state when stop Min Hu (Connor)
2022-05-25 17:44       ` Ferruh Yigit
2022-05-26 10:21         ` Thomas Monjalon
2022-05-30 12:04           ` Ferruh Yigit
2022-05-11 14:04     ` [PATCH v3 0/5] bugfix for bonding 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=f4e02a97-c034-44b4-ed08-609b63bc5503@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=humin29@huawei.com \
    --cc=thomas@monjalon.net \
    --cc=xiaoyun.li@intel.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).