[U-Boot] [PATCH 10/11 v2] drivers/net/vsc9953: Add commands for VLAN ingress filtering
Joe Hershberger
joe.hershberger at gmail.com
Fri Jun 26 00:42:22 CEST 2015
Hi Codrin,
On Tue, Jun 23, 2015 at 11:48 AM, Codrin Ciubotariu
<codrin.ciubotariu at freescale.com> wrote:
> 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.
>
> Signed-off-by: Johnson Leung <johnson.leung at freescale.com>
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu at freescale.com>
> ---
> Changes for v2:
> - removed Change-id field;
>
> drivers/net/vsc9953.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 137 insertions(+)
>
> diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c
> index 3129b03..d5520d9 100644
> --- a/drivers/net/vsc9953.c
> +++ b/drivers/net/vsc9953.c
> @@ -1555,6 +1555,33 @@ static int vsc9953_vlan_learning_get(enum vlan_learning_mode *lrn_mode)
> 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);
> +}
> +
> +/* Show VLAN ingress filtering on a VSC9953 port */
> +static void vsc9953_port_ingress_filtering_get(int port_no, int *enabled)
Why not just return the enabled status instead of a pointer?
> +{
> + 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);
> + *enabled = !!(val & (1 << port_no));
> +}
> +
> enum egress_vlan_tag {
> EGR_TAG_CLASS = 0,
> EGR_TAG_PVID,
> @@ -1626,6 +1653,8 @@ enum keyword_id {
> id_classified,
> id_shared,
> id_private,
> + id_ingress,
> + id_filtering,
> id_count, /* keep last */
> };
>
> @@ -2031,6 +2060,68 @@ static int vsc9953_port_untag_set_key_func(struct command_def *parsed_cmd)
> return 0;
> }
>
> +#define VSC9953_PORT_INGR_FLTR_HELP "ethsw [port <port_no>] ingress filtering" \
> +" { [help] | show | enable | disable } " \
> +"- enable/disable VLAN ingress filtering on port"
> +
> +static int vsc9953_ingr_fltr_help_key_func(struct command_def *parsed_cmd)
> +{
> + printf(VSC9953_PORT_INGR_FLTR_HELP"\n");
> +
> + return 0;
Please use:
+ return CMD_RET_SUCCESS;
> +}
> +
> +static int vsc9953_ingr_fltr_show_key_func(struct command_def *parsed_cmd)
> +{
> + int i, enabled;
Use one space and put each variable on a separate line.
> +
> + printf("%7s\t%18s\n", "Port", "Ingress filtering");
> + if (parsed_cmd->port != VSC9953_CMD_PORT_ALL) {
> + vsc9953_port_ingress_filtering_get(parsed_cmd->port, &enabled);
> + printf("%7d\t%18s\n", parsed_cmd->port, enabled ? "enable" :
> + "disable");
> + } else {
> + for (i = 0; i < VSC9953_MAX_PORTS; i++) {
> + vsc9953_port_ingress_filtering_get(i, &enabled);
> + printf("%7d\t%18s\n", parsed_cmd->port, enabled ?
> + "enable" :
> + "disable");
> + }
> + }
> +
> + return 0;
Please use:
+ return CMD_RET_SUCCESS;
> +}
> +
> +static int vsc9953_ingr_fltr_set_key_func(struct command_def *parsed_cmd)
> +{
> + int i, enable;
Use one space and put each variable on a separate line.
> +
> + /* keywords for enabling/disabling ingress filtering
> + * are the last in the array
> + */
> + if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] ==
> + id_enable)
> + enable = 1;
> + else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] ==
> + id_disable)
> + enable = 0;
> + else
> + return -1;
Please use:
+ return CMD_RET_USAGE;
> +
> + if (parsed_cmd->port != VSC9953_CMD_PORT_ALL) {
> + if (!VSC9953_PORT_CHECK(parsed_cmd->port)) {
> + printf("Invalid port number: %d\n", parsed_cmd->port);
> + return -1;
Please use:
+ return CMD_RET_USAGE;
> + }
> + 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 0;
Please use:
+ return CMD_RET_SUCCESS;
> +}
> +
> #define VSC9953_EGR_VLAN_TAG_HELP "ethsw [port <port_no>] egress tag " \
> "{ [help] | show | pvid | classified } " \
> "- Configure VID source for egress tag. " \
> @@ -2479,6 +2570,45 @@ struct keywords_to_function {
> id_key_end,
> },
> .keyword_function = &vsc9953_vlan_learn_set_key_func,
> + }, {
> + .cmd_keyword = {
> + id_ingress,
> + id_filtering,
> + -1,
id_key_end
> + },
> + .keyword_function = &vsc9953_ingr_fltr_help_key_func,
> + }, {
> + .cmd_keyword = {
> + id_ingress,
> + id_filtering,
> + id_help,
> + -1,
id_key_end
> + },
> + .keyword_function = &vsc9953_ingr_fltr_help_key_func,
> + }, {
> + .cmd_keyword = {
> + id_ingress,
> + id_filtering,
> + id_show,
> + -1,
id_key_end
> + },
> + .keyword_function = &vsc9953_ingr_fltr_show_key_func,
> + }, {
> + .cmd_keyword = {
> + id_ingress,
> + id_filtering,
> + id_enable,
> + -1,
id_key_end
> + },
> + .keyword_function = &vsc9953_ingr_fltr_set_key_func,
> + }, {
> + .cmd_keyword = {
> + id_ingress,
> + id_filtering,
> + id_disable,
> + -1,
id_key_end
> + },
> + .keyword_function = &vsc9953_ingr_fltr_set_key_func,
> },
> };
>
> @@ -2601,6 +2731,12 @@ struct keyword_def {
> }, {
> .keyword_name = "private",
> .match = &keyword_match_gen,
> + }, {
> + .keyword_name = "ingress",
> + .match = &keyword_match_gen,
> + }, {
> + .keyword_name = "filtering",
> + .match = &keyword_match_gen,
> },
> };
>
> @@ -2925,6 +3061,7 @@ U_BOOT_CMD(ethsw, VSC9953_MAX_CMD_PARAMS, 0, do_ethsw,
> VSC9953_PORT_UNTAG_HELP"\n"
> VSC9953_EGR_VLAN_TAG_HELP"\n"
> VSC9953_VLAN_FDB_HELP"\n"
> + VSC9953_PORT_INGR_FLTR_HELP"\n"
> );
>
> #endif /* CONFIG_VSC9953_CMD */
> --
> 1.9.3
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
More information about the U-Boot
mailing list