Skip to content

Commit 63ce6cb

Browse files
huangdengdui1ferruhy
authored andcommitted
app/testpmd: add command to flush multicast MAC addresses
Add command to flush all multicast MAC address Usage: mcast_addr flush <port_id> : flush all multicast MAC address on port_id Signed-off-by: Dengdui Huang <[email protected]> Acked-by: Chengwen Feng <[email protected]> Acked-by: Ferruh Yigit <[email protected]>
1 parent a0a1a09 commit 63ce6cb

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

app/test-pmd/cmdline.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ static void cmd_help_long_parsed(void *parsed_result,
506506
"mcast_addr remove (port_id) (mcast_addr)\n"
507507
" Remove a multicast MAC address from port_id.\n\n"
508508

509+
"mcast_addr flush (port_id)\n"
510+
" Flush all multicast MAC addresses on port_id.\n\n"
511+
509512
"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
510513
" Set the MAC address for a VF from the PF.\n\n"
511514

@@ -8567,6 +8570,45 @@ static cmdline_parse_inst_t cmd_mcast_addr = {
85678570
},
85688571
};
85698572

8573+
/* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
8574+
struct cmd_mcast_addr_flush_result {
8575+
cmdline_fixed_string_t mcast_addr_cmd;
8576+
cmdline_fixed_string_t what;
8577+
uint16_t port_num;
8578+
};
8579+
8580+
static void cmd_mcast_addr_flush_parsed(void *parsed_result,
8581+
__rte_unused struct cmdline *cl,
8582+
__rte_unused void *data)
8583+
{
8584+
struct cmd_mcast_addr_flush_result *res = parsed_result;
8585+
8586+
mcast_addr_flush(res->port_num);
8587+
}
8588+
8589+
static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
8590+
TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8591+
mcast_addr_cmd, "mcast_addr");
8592+
static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
8593+
TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8594+
"flush");
8595+
static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
8596+
TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8597+
RTE_UINT16);
8598+
8599+
static cmdline_parse_inst_t cmd_mcast_addr_flush = {
8600+
.f = cmd_mcast_addr_flush_parsed,
8601+
.data = (void *)0,
8602+
.help_str = "mcast_addr flush <port_id> : "
8603+
"flush all multicast MAC addresses on port_id",
8604+
.tokens = {
8605+
(void *)&cmd_mcast_addr_flush_cmd,
8606+
(void *)&cmd_mcast_addr_flush_what,
8607+
(void *)&cmd_mcast_addr_flush_portnum,
8608+
NULL,
8609+
},
8610+
};
8611+
85708612
/* vf vlan anti spoof configuration */
85718613

85728614
/* Common result structure for vf vlan anti spoof */
@@ -12935,6 +12977,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
1293512977
(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
1293612978
(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
1293712979
(cmdline_parse_inst_t *)&cmd_mcast_addr,
12980+
(cmdline_parse_inst_t *)&cmd_mcast_addr_flush,
1293812981
(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
1293912982
(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
1294012983
(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,

app/test-pmd/config.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6829,6 +6829,24 @@ mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr)
68296829
mcast_addr_pool_append(port, mc_addr);
68306830
}
68316831

6832+
void
6833+
mcast_addr_flush(portid_t port_id)
6834+
{
6835+
int ret;
6836+
6837+
if (port_id_is_invalid(port_id, ENABLED_WARN))
6838+
return;
6839+
6840+
ret = rte_eth_dev_set_mc_addr_list(port_id, NULL, 0);
6841+
if (ret != 0) {
6842+
fprintf(stderr,
6843+
"Failed to flush all multicast MAC addresses on port_id %u\n",
6844+
port_id);
6845+
return;
6846+
}
6847+
mcast_addr_pool_destroy(port_id);
6848+
}
6849+
68326850
void
68336851
port_dcb_info_display(portid_t port_id)
68346852
{

app/test-pmd/testpmd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ void show_mcast_macs(portid_t port_id);
11811181
/* Functions to manage the set of filtered Multicast MAC addresses */
11821182
void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr);
11831183
void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr);
1184+
void mcast_addr_flush(portid_t port_id);
11841185
void port_dcb_info_display(portid_t port_id);
11851186

11861187
uint8_t *open_file(const char *file_path, uint32_t *size);

doc/guides/testpmd_app_ug/testpmd_funcs.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,13 @@ filtered by port::
13231323

13241324
testpmd> mcast_addr remove (port_id) (mcast_addr)
13251325

1326+
mcast_addr flush
1327+
~~~~~~~~~~~~~~~~
1328+
1329+
Flush all multicast MAC addresses on port_id::
1330+
1331+
testpmd> mcast_addr flush (port_id)
1332+
13261333
mac_addr add (for VF)
13271334
~~~~~~~~~~~~~~~~~~~~~
13281335

0 commit comments

Comments
 (0)