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 720F74590C; Thu, 5 Sep 2024 11:30:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EDBCB42E83; Thu, 5 Sep 2024 11:29:36 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 38F0542E57 for ; Thu, 5 Sep 2024 11:29:28 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4WzvFF0RSdz1S9NF; Thu, 5 Sep 2024 17:29:05 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 35C071A0190; Thu, 5 Sep 2024 17:29:27 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 5 Sep 2024 17:29:27 +0800 From: Chengwen Feng To: , , , , Aman Singh CC: , , , Subject: [PATCH v4 5/7] app/testpmd: add error recovery usage demo Date: Thu, 5 Sep 2024 09:25:02 +0000 Message-ID: <20240905092504.10725-6-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240905092504.10725-1-fengchengwen@huawei.com> References: <20230301030610.49468-1-fengchengwen@huawei.com> <20240905092504.10725-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) 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 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. In addition, a message is added to the printed information, requiring no command to be executed during the error recovery. Signed-off-by: Chengwen Feng Acked-by: Konstantin Ananyev --- app/test-pmd/testpmd.c | 80 ++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 4 ++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index b1401136e4..9c9182ede1 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3938,6 +3938,77 @@ rmv_port_callback(void *arg) start_packet_forwarding(0); } +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 = &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 events are received!\n"); + + ports[port_id].err_recovering = 1; + ports[port_id].recover_failed = 0; + + /* To simplify implementation, stop forwarding regardless of whether the port is used. */ + if (!test_done) { + printf("Stop packet forwarding because some ports are in error recovering!\n"); + stop_packet_forwarding(); + need_start_when_recovery_over = 1; + } +} + +static void +recover_success_callback(portid_t port_id) +{ + ports[port_id].err_recovering = 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 = 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 = 0; + ports[port_id].recover_failed = 1; + if (has_port_in_err_recovering()) + return; + + need_start_when_recovery_over = 0; + printf("The ports:"); + RTE_ETH_FOREACH_DEV(pid) { + port = &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, @@ -3993,6 +4064,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 9facd7f281..5c5e4041a3 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -343,7 +343,9 @@ struct rte_port { uint8_t member_flag : 1, /**< bonding member 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