mirror of
https://xff.cz/git/u-boot/
synced 2025-09-30 15:01:27 +02:00
drivers/net/vsc9953: Add commands for VLAN ingress filtering
The command: ethsw [port <port_no>] ingress filtering { [help] | show | enable | disable } - enable/disable VLAN ingress filtering on port can be used to enable/disable/show VLAN ingress filtering on a port. This command has also been added to the ethsw generic parser from common/cmd_ethsw.c Signed-off-by: Johnson Leung <johnson.leung@freescale.com> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@freescale.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: York Sun <yorksun@freescale.com>
This commit is contained in:
committed by
York Sun
parent
21d214fcd0
commit
5ed1bacd34
@@ -103,6 +103,17 @@ static int ethsw_vlan_learn_help_key_func(struct ethsw_command_def *parsed_cmd)
|
|||||||
return CMD_RET_SUCCESS;
|
return CMD_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ETHSW_PORT_INGR_FLTR_HELP "ethsw [port <port_no>] ingress filtering" \
|
||||||
|
" { [help] | show | enable | disable } " \
|
||||||
|
"- enable/disable VLAN ingress filtering on port"
|
||||||
|
|
||||||
|
static int ethsw_ingr_fltr_help_key_func(struct ethsw_command_def *parsed_cmd)
|
||||||
|
{
|
||||||
|
printf(ETHSW_PORT_INGR_FLTR_HELP"\n");
|
||||||
|
|
||||||
|
return CMD_RET_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static struct keywords_to_function {
|
static struct keywords_to_function {
|
||||||
enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS];
|
enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS];
|
||||||
int cmd_func_offset;
|
int cmd_func_offset;
|
||||||
@@ -474,6 +485,53 @@ static struct keywords_to_function {
|
|||||||
.cmd_func_offset = offsetof(struct ethsw_command_func,
|
.cmd_func_offset = offsetof(struct ethsw_command_func,
|
||||||
vlan_learn_set),
|
vlan_learn_set),
|
||||||
.keyword_function = NULL,
|
.keyword_function = NULL,
|
||||||
|
}, {
|
||||||
|
.cmd_keyword = {
|
||||||
|
ethsw_id_ingress,
|
||||||
|
ethsw_id_filtering,
|
||||||
|
ethsw_id_key_end,
|
||||||
|
},
|
||||||
|
.cmd_func_offset = -1,
|
||||||
|
.keyword_function = ðsw_ingr_fltr_help_key_func,
|
||||||
|
}, {
|
||||||
|
.cmd_keyword = {
|
||||||
|
ethsw_id_ingress,
|
||||||
|
ethsw_id_filtering,
|
||||||
|
ethsw_id_help,
|
||||||
|
ethsw_id_key_end,
|
||||||
|
},
|
||||||
|
.cmd_func_offset = -1,
|
||||||
|
.keyword_function = ðsw_ingr_fltr_help_key_func,
|
||||||
|
}, {
|
||||||
|
.cmd_keyword = {
|
||||||
|
ethsw_id_ingress,
|
||||||
|
ethsw_id_filtering,
|
||||||
|
ethsw_id_show,
|
||||||
|
ethsw_id_key_end,
|
||||||
|
},
|
||||||
|
.cmd_func_offset = offsetof(struct ethsw_command_func,
|
||||||
|
port_ingr_filt_show),
|
||||||
|
.keyword_function = NULL,
|
||||||
|
}, {
|
||||||
|
.cmd_keyword = {
|
||||||
|
ethsw_id_ingress,
|
||||||
|
ethsw_id_filtering,
|
||||||
|
ethsw_id_enable,
|
||||||
|
ethsw_id_key_end,
|
||||||
|
},
|
||||||
|
.cmd_func_offset = offsetof(struct ethsw_command_func,
|
||||||
|
port_ingr_filt_set),
|
||||||
|
.keyword_function = NULL,
|
||||||
|
}, {
|
||||||
|
.cmd_keyword = {
|
||||||
|
ethsw_id_ingress,
|
||||||
|
ethsw_id_filtering,
|
||||||
|
ethsw_id_disable,
|
||||||
|
ethsw_id_key_end,
|
||||||
|
},
|
||||||
|
.cmd_func_offset = offsetof(struct ethsw_command_func,
|
||||||
|
port_ingr_filt_set),
|
||||||
|
.keyword_function = NULL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -597,6 +655,12 @@ struct keyword_def {
|
|||||||
}, {
|
}, {
|
||||||
.keyword_name = "private",
|
.keyword_name = "private",
|
||||||
.match = &keyword_match_gen,
|
.match = &keyword_match_gen,
|
||||||
|
}, {
|
||||||
|
.keyword_name = "ingress",
|
||||||
|
.match = &keyword_match_gen,
|
||||||
|
}, {
|
||||||
|
.keyword_name = "filtering",
|
||||||
|
.match = &keyword_match_gen,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -959,4 +1023,5 @@ U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw,
|
|||||||
ETHSW_PORT_UNTAG_HELP"\n"
|
ETHSW_PORT_UNTAG_HELP"\n"
|
||||||
ETHSW_EGR_VLAN_TAG_HELP"\n"
|
ETHSW_EGR_VLAN_TAG_HELP"\n"
|
||||||
ETHSW_VLAN_FDB_HELP"\n"
|
ETHSW_VLAN_FDB_HELP"\n"
|
||||||
|
ETHSW_PORT_INGR_FLTR_HELP"\n"
|
||||||
);
|
);
|
||||||
|
@@ -1447,6 +1447,33 @@ static int vsc9953_vlan_learning_get(enum vlan_learning_mode *lrn_mode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Enable/disable VLAN ingress filtering on a VSC9953 port */
|
||||||
|
static void vsc9953_port_ingress_filtering_set(int port_no, int enabled)
|
||||||
|
{
|
||||||
|
struct vsc9953_analyzer *l2ana_reg;
|
||||||
|
|
||||||
|
l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET +
|
||||||
|
VSC9953_ANA_OFFSET);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
setbits_le32(&l2ana_reg->ana.vlan_mask, 1 << port_no);
|
||||||
|
else
|
||||||
|
clrbits_le32(&l2ana_reg->ana.vlan_mask, 1 << port_no);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return VLAN ingress filtering on a VSC9953 port */
|
||||||
|
static int vsc9953_port_ingress_filtering_get(int port_no)
|
||||||
|
{
|
||||||
|
u32 val;
|
||||||
|
struct vsc9953_analyzer *l2ana_reg;
|
||||||
|
|
||||||
|
l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET +
|
||||||
|
VSC9953_ANA_OFFSET);
|
||||||
|
|
||||||
|
val = in_le32(&l2ana_reg->ana.vlan_mask);
|
||||||
|
return !!(val & (1 << port_no));
|
||||||
|
}
|
||||||
|
|
||||||
static int vsc9953_port_status_key_func(struct ethsw_command_def *parsed_cmd)
|
static int vsc9953_port_status_key_func(struct ethsw_command_def *parsed_cmd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -1980,6 +2007,63 @@ static int vsc9953_vlan_learn_set_key_func(struct ethsw_command_def *parsed_cmd)
|
|||||||
return CMD_RET_SUCCESS;
|
return CMD_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vsc9953_ingr_fltr_show_key_func(struct ethsw_command_def *parsed_cmd)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int enabled;
|
||||||
|
|
||||||
|
printf("%7s\t%18s\n", "Port", "Ingress filtering");
|
||||||
|
if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) {
|
||||||
|
if (!VSC9953_PORT_CHECK(parsed_cmd->port)) {
|
||||||
|
printf("Invalid port number: %d\n", parsed_cmd->port);
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
}
|
||||||
|
enabled = vsc9953_port_ingress_filtering_get(parsed_cmd->port);
|
||||||
|
printf("%7d\t%18s\n", parsed_cmd->port, enabled ? "enable" :
|
||||||
|
"disable");
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < VSC9953_MAX_PORTS; i++) {
|
||||||
|
enabled = vsc9953_port_ingress_filtering_get(i);
|
||||||
|
printf("%7d\t%18s\n", parsed_cmd->port, enabled ?
|
||||||
|
"enable" :
|
||||||
|
"disable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CMD_RET_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vsc9953_ingr_fltr_set_key_func(struct ethsw_command_def *parsed_cmd)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int enable;
|
||||||
|
|
||||||
|
/* keywords for enabling/disabling ingress filtering
|
||||||
|
* are the last in the array
|
||||||
|
*/
|
||||||
|
if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] ==
|
||||||
|
ethsw_id_enable)
|
||||||
|
enable = 1;
|
||||||
|
else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] ==
|
||||||
|
ethsw_id_disable)
|
||||||
|
enable = 0;
|
||||||
|
else
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) {
|
||||||
|
if (!VSC9953_PORT_CHECK(parsed_cmd->port)) {
|
||||||
|
printf("Invalid port number: %d\n", parsed_cmd->port);
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
}
|
||||||
|
vsc9953_port_ingress_filtering_set(parsed_cmd->port, enable);
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < VSC9953_MAX_PORTS; i++)
|
||||||
|
vsc9953_port_ingress_filtering_set(i, enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CMD_RET_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static struct ethsw_command_func vsc9953_cmd_func = {
|
static struct ethsw_command_func vsc9953_cmd_func = {
|
||||||
.ethsw_name = "L2 Switch VSC9953",
|
.ethsw_name = "L2 Switch VSC9953",
|
||||||
.port_enable = &vsc9953_port_status_key_func,
|
.port_enable = &vsc9953_port_status_key_func,
|
||||||
@@ -2003,6 +2087,8 @@ static struct ethsw_command_func vsc9953_cmd_func = {
|
|||||||
.port_egr_vlan_set = &vsc9953_egr_vlan_tag_set_key_func,
|
.port_egr_vlan_set = &vsc9953_egr_vlan_tag_set_key_func,
|
||||||
.vlan_learn_show = &vsc9953_vlan_learn_show_key_func,
|
.vlan_learn_show = &vsc9953_vlan_learn_show_key_func,
|
||||||
.vlan_learn_set = &vsc9953_vlan_learn_set_key_func,
|
.vlan_learn_set = &vsc9953_vlan_learn_set_key_func,
|
||||||
|
.port_ingr_filt_show = &vsc9953_ingr_fltr_show_key_func,
|
||||||
|
.port_ingr_filt_set = &vsc9953_ingr_fltr_set_key_func
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONFIG_CMD_ETHSW */
|
#endif /* CONFIG_CMD_ETHSW */
|
||||||
|
@@ -39,6 +39,8 @@ enum ethsw_keyword_id {
|
|||||||
ethsw_id_classified,
|
ethsw_id_classified,
|
||||||
ethsw_id_shared,
|
ethsw_id_shared,
|
||||||
ethsw_id_private,
|
ethsw_id_private,
|
||||||
|
ethsw_id_ingress,
|
||||||
|
ethsw_id_filtering,
|
||||||
ethsw_id_count, /* keep last */
|
ethsw_id_count, /* keep last */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,6 +86,8 @@ struct ethsw_command_func {
|
|||||||
int (*port_egr_vlan_set)(struct ethsw_command_def *parsed_cmd);
|
int (*port_egr_vlan_set)(struct ethsw_command_def *parsed_cmd);
|
||||||
int (*vlan_learn_show)(struct ethsw_command_def *parsed_cmd);
|
int (*vlan_learn_show)(struct ethsw_command_def *parsed_cmd);
|
||||||
int (*vlan_learn_set)(struct ethsw_command_def *parsed_cmd);
|
int (*vlan_learn_set)(struct ethsw_command_def *parsed_cmd);
|
||||||
|
int (*port_ingr_filt_show)(struct ethsw_command_def *parsed_cmd);
|
||||||
|
int (*port_ingr_filt_set)(struct ethsw_command_def *parsed_cmd);
|
||||||
};
|
};
|
||||||
|
|
||||||
int ethsw_define_functions(const struct ethsw_command_func *cmd_func);
|
int ethsw_define_functions(const struct ethsw_command_func *cmd_func);
|
||||||
|
Reference in New Issue
Block a user