From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91BE941DB5; Thu, 2 Mar 2023 14:01:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24EC740E2D; Thu, 2 Mar 2023 14:01:57 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 751EC40E09 for ; Thu, 2 Mar 2023 14:01:54 +0100 (CET) Received: from dggpeml100021.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PSB4Z5yN3zSkNL; Thu, 2 Mar 2023 20:58:54 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by dggpeml100021.china.huawei.com (7.185.36.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 2 Mar 2023 21:01:49 +0800 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.021; Thu, 2 Mar 2023 14:01:48 +0100 From: Konstantin Ananyev To: Fengchengwen , "thomas@monjalon.net" , "ferruh.yigit@amd.com" , "Aman Singh" , Yuying Zhang CC: "dev@dpdk.org" Subject: RE: [PATCH 5/5] app/testpmd: add error recovery usage demo Thread-Topic: [PATCH 5/5] app/testpmd: add error recovery usage demo Thread-Index: AQHZS+uxoGmz7XfZq0+Nr//BgLCP2K7ndRtQ Date: Thu, 2 Mar 2023 13:01:47 +0000 Message-ID: <27b5e0017a304183b812a7e45858e03a@huawei.com> References: <20230301030610.49468-1-fengchengwen@huawei.com> <20230301030610.49468-6-fengchengwen@huawei.com> In-Reply-To: <20230301030610.49468-6-fengchengwen@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.206.138.42] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org >=20 > This patch adds error recovery usage demo which will: > 1. stop packet forwarding when the RTE_ETH_EVENT_ERR_RECOVERING event > is received. > 2. restart packet forwarding when the RTE_ETH_EVENT_RECOVERY_SUCCESS > event is received. > 3. prompt the ports that fail to recovery and need to be removed when > the RTE_ETH_EVENT_RECOVERY_FAILED event is received. >=20 > In addition, a message is added to the printed information, requiring > no command to be executed during the error recovery. >=20 > Signed-off-by: Chengwen Feng > --- > app/test-pmd/testpmd.c | 80 ++++++++++++++++++++++++++++++++++++++++++ > app/test-pmd/testpmd.h | 4 ++- > 2 files changed, 83 insertions(+), 1 deletion(-) >=20 > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index 0c14325b8d..fdc3ae604b 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -3823,6 +3823,77 @@ rmv_port_callback(void *arg) > start_packet_forwarding(0); > } >=20 > +static int need_start_when_recovery_over; > + > +static bool > +has_port_in_err_recovering(void) > +{ > + struct rte_port *port; > + portid_t pid; > + > + RTE_ETH_FOREACH_DEV(pid) { > + port =3D &ports[pid]; > + if (port->err_recovering) > + return true; > + } > + > + return false; > +} > + > +static void > +err_recovering_callback(portid_t port_id) > +{ > + if (!has_port_in_err_recovering()) > + printf("Please stop executing any commands until recovery result event= s are received!\n"); > + > + ports[port_id].err_recovering =3D 1; > + ports[port_id].recover_failed =3D 0; > + > + /* To simplify implementation, stop forwarding regardless of whether th= e port is used. */ > + if (!test_done) { > + printf("Stop packet forwarding because some ports are in error recover= ing!\n"); > + stop_packet_forwarding(); > + need_start_when_recovery_over =3D 1; > + } > +} One thought I have - should we somehow stop user to attempt restart RX/TX w= hile recovery in progress? But probably it is an overkill, and just documenting what is happening is e= nough.... Do we need to update testpmd UG with some short description? Apart from that, LGTM: Acked-by: Konstantin Ananyev > + > +static void > +recover_success_callback(portid_t port_id) > +{ > + ports[port_id].err_recovering =3D 0; > + if (has_port_in_err_recovering()) > + return; > + > + if (need_start_when_recovery_over) { > + printf("Recovery success! Restart packet forwarding!\n"); > + start_packet_forwarding(0); > + need_start_when_recovery_over =3D 0; > + } else { > + printf("Recovery success!\n"); > + } > +} > + > +static void > +recover_failed_callback(portid_t port_id) > +{ > + struct rte_port *port; > + portid_t pid; > + > + ports[port_id].err_recovering =3D 0; > + ports[port_id].recover_failed =3D 1; > + if (has_port_in_err_recovering()) > + return; > + > + need_start_when_recovery_over =3D 0; > + printf("The ports:"); > + RTE_ETH_FOREACH_DEV(pid) { > + port =3D &ports[pid]; > + if (port->recover_failed) > + printf(" %u", pid); > + } > + printf(" recovery failed! Please remove them!\n"); > +} > + > /* This function is used by the interrupt thread */ > static int > eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void = *param, > @@ -3878,6 +3949,15 @@ eth_event_callback(portid_t port_id, enum rte_eth_= event_type type, void *param, > } > break; > } > + case RTE_ETH_EVENT_ERR_RECOVERING: > + err_recovering_callback(port_id); > + break; > + case RTE_ETH_EVENT_RECOVERY_SUCCESS: > + recover_success_callback(port_id); > + break; > + case RTE_ETH_EVENT_RECOVERY_FAILED: > + recover_failed_callback(port_id); > + break; > default: > break; > } > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 329a6378a1..1bbf82a96c 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -323,7 +323,9 @@ struct rte_port { > uint8_t slave_flag : 1, /**< bonding slave port */ > bond_flag : 1, /**< port is bond device */ > fwd_mac_swap : 1, /**< swap packet MAC before forward */ > - update_conf : 1; /**< need to update bonding device configuration */ > + update_conf : 1, /**< need to update bonding device configuration */ > + err_recovering : 1, /**< port is in error recovering */ > + recover_failed : 1; /**< port recover failed */ > struct port_template *pattern_templ_list; /**< Pattern templates. */ > struct port_template *actions_templ_list; /**< Actions templates. */ > struct port_table *table_list; /**< Flow tables. */ > -- > 2.17.1