From patchwork Sun Oct 8 01:56:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dengdui Huang X-Patchwork-Id: 132392 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63507426E6; Sun, 8 Oct 2023 03:56:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8534402ED; Sun, 8 Oct 2023 03:56:37 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id BF4B1402D4 for ; Sun, 8 Oct 2023 03:56:35 +0200 (CEST) Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S34tq26mhzTmNf; Sun, 8 Oct 2023 09:53:07 +0800 (CST) Received: from localhost.huawei.com (10.50.163.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sun, 8 Oct 2023 09:56:30 +0800 From: Dengdui Huang To: CC: , , , , , Subject: [PATCH v3 1/2] app/testpmd: fix help string Date: Sun, 8 Oct 2023 09:56:29 +0800 Message-ID: <20231008015630.406378-2-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231008015630.406378-1-huangdengdui@huawei.com> References: <20230801024304.2187484-1-huangdengdui@huawei.com> <20231008015630.406378-1-huangdengdui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500011.china.huawei.com (7.185.36.84) 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 Command help string is missing 'mcast_addr add|remove'. This patch add it. Fixes: 8fff667578a7 ("app/testpmd: new command to add/remove multicast MAC addresses") Cc: stable@dpdk.org Signed-off-by: Dengdui Huang Acked-by: Chengwen Feng --- app/test-pmd/cmdline.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a0e97719b3..3165347a05 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -516,6 +516,12 @@ static void cmd_help_long_parsed(void *parsed_result, "set allmulti (port_id|all) (on|off)\n" " Set the allmulti mode on port_id, or all.\n\n" + "mcast_addr add (port_id) (mcast_addr)\n" + " Add a multicast MAC addresses on port_id.\n\n" + + "mcast_addr remove (port_id) (mcast_addr)" + " Remove a multicast MAC address from port_id.\n\n" + "set flow_ctrl rx (on|off) tx (on|off) (high_water)" " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" " (on|off) autoneg (on|off) (port_id)\n" From patchwork Sun Oct 8 01:56:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dengdui Huang X-Patchwork-Id: 132393 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF795426E6; Sun, 8 Oct 2023 03:56:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 164E14064C; Sun, 8 Oct 2023 03:56:39 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 9C58640263 for ; Sun, 8 Oct 2023 03:56:35 +0200 (CEST) Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S34tq2KFCzTmP1; Sun, 8 Oct 2023 09:53:07 +0800 (CST) Received: from localhost.huawei.com (10.50.163.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sun, 8 Oct 2023 09:56:30 +0800 From: Dengdui Huang To: CC: , , , , , Subject: [PATCH v3 2/2] app/testpmd: add flush all multicast MAC address command Date: Sun, 8 Oct 2023 09:56:30 +0800 Message-ID: <20231008015630.406378-3-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231008015630.406378-1-huangdengdui@huawei.com> References: <20230801024304.2187484-1-huangdengdui@huawei.com> <20231008015630.406378-1-huangdengdui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500011.china.huawei.com (7.185.36.84) 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 Add command to flush all multicast MAC address Usage: mcast_addr flush : flush all multicast MAC address on port_id Signed-off-by: Dengdui Huang Acked-by: Chengwen Feng --- app/test-pmd/cmdline.c | 43 +++++++++++++++++++++ app/test-pmd/config.c | 18 +++++++++ app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++++ 4 files changed, 69 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 3165347a05..6404d06e8f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -522,6 +522,9 @@ static void cmd_help_long_parsed(void *parsed_result, "mcast_addr remove (port_id) (mcast_addr)" " Remove a multicast MAC address from port_id.\n\n" + "mcast_addr flush (port_id)\n" + " Flush all multicast MAC addresses on port_id.\n\n" + "set flow_ctrl rx (on|off) tx (on|off) (high_water)" " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" " (on|off) autoneg (on|off) (port_id)\n" @@ -8567,6 +8570,45 @@ static cmdline_parse_inst_t cmd_mcast_addr = { }, }; +/* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */ +struct cmd_mcast_addr_flush_result { + cmdline_fixed_string_t mcast_addr_cmd; + cmdline_fixed_string_t what; + uint16_t port_num; +}; + +static void cmd_mcast_addr_flush_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_mcast_addr_flush_result *res = parsed_result; + + mcast_addr_flush(res->port_num); +} + +static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, + mcast_addr_cmd, "mcast_addr"); +static cmdline_parse_token_string_t cmd_mcast_addr_flush_what = + TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, + "flush"); +static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, + RTE_UINT16); + +static cmdline_parse_inst_t cmd_mcast_addr_flush = { + .f = cmd_mcast_addr_flush_parsed, + .data = (void *)0, + .help_str = "mcast_addr flush : " + "flush all multicast MAC addresses on port_id", + .tokens = { + (void *)&cmd_mcast_addr_flush_cmd, + (void *)&cmd_mcast_addr_flush_what, + (void *)&cmd_mcast_addr_flush_portnum, + NULL, + }, +}; + /* vf vlan anti spoof configuration */ /* Common result structure for vf vlan anti spoof */ @@ -12935,6 +12977,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, (cmdline_parse_inst_t *)&cmd_mcast_addr, + (cmdline_parse_inst_t *)&cmd_mcast_addr_flush, (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 709864bb44..7034fa125b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -6829,6 +6829,24 @@ mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr) mcast_addr_pool_append(port, mc_addr); } +void +mcast_addr_flush(portid_t port_id) +{ + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + ret = rte_eth_dev_set_mc_addr_list(port_id, NULL, 0); + if (ret != 0) { + fprintf(stderr, + "Failed to flush all multicast MAC addresses on port_id %u\n", + port_id); + return; + } + mcast_addr_pool_destroy(port_id); +} + void port_dcb_info_display(portid_t port_id) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index e236845a81..6457ac4c0a 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1181,6 +1181,7 @@ void show_mcast_macs(portid_t port_id); /* Functions to manage the set of filtered Multicast MAC addresses */ void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr); void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr); +void mcast_addr_flush(portid_t port_id); void port_dcb_info_display(portid_t port_id); uint8_t *open_file(const char *file_path, uint32_t *size); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index e6d218caaa..7a40980d6c 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1323,6 +1323,13 @@ filtered by port:: testpmd> mcast_addr remove (port_id) (mcast_addr) +mcast_addr flush +~~~~~~~~~~~~~~~~ + +Flush all multicast MAC addresses on port_id:: + + testpmd> mcast_addr flush (port_id) + mac_addr add (for VF) ~~~~~~~~~~~~~~~~~~~~~