From: Codrin Ciubotariu <codrin.ciubotariu@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 10/10] drivers/net/vsc9953: Add commands for VLAN ingress filtering
Date: Thu, 11 Jun 2015 18:10:20 +0300 [thread overview]
Message-ID: <1434035420-1663-12-git-send-email-codrin.ciubotariu@freescale.com> (raw)
In-Reply-To: <1434035420-1663-1-git-send-email-codrin.ciubotariu@freescale.com>
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@freescale.com>
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@freescale.com>
Change-Id: I658ef613724e3e1dbf78babde985c4d11c4a2706
---
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)
+{
+ 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;
+}
+
+static int vsc9953_ingr_fltr_show_key_func(struct command_def *parsed_cmd)
+{
+ int i, enabled;
+
+ 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;
+}
+
+static int vsc9953_ingr_fltr_set_key_func(struct command_def *parsed_cmd)
+{
+ int i, 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] ==
+ id_enable)
+ enable = 1;
+ else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] ==
+ id_disable)
+ enable = 0;
+ else
+ return -1;
+
+ 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;
+ }
+ 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;
+}
+
#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,
+ },
+ .keyword_function = &vsc9953_ingr_fltr_help_key_func,
+ }, {
+ .cmd_keyword = {
+ id_ingress,
+ id_filtering,
+ id_help,
+ -1,
+ },
+ .keyword_function = &vsc9953_ingr_fltr_help_key_func,
+ }, {
+ .cmd_keyword = {
+ id_ingress,
+ id_filtering,
+ id_show,
+ -1,
+ },
+ .keyword_function = &vsc9953_ingr_fltr_show_key_func,
+ }, {
+ .cmd_keyword = {
+ id_ingress,
+ id_filtering,
+ id_enable,
+ -1,
+ },
+ .keyword_function = &vsc9953_ingr_fltr_set_key_func,
+ }, {
+ .cmd_keyword = {
+ id_ingress,
+ id_filtering,
+ id_disable,
+ -1,
+ },
+ .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
prev parent reply other threads:[~2015-06-11 15:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 15:10 [U-Boot] [PATCH 00/10] Add more commands for VSC9953 L2 Switch Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH] drivers/net/vsc9953: Add GPL-2.0+ SPDX-License-Identifier Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 01/10] drivers/net/vsc9953: Cleanup patch Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 02/10] drivers/net/vsc9953: Fix missing reserved register Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 03/10] drivers/net/vsc9953: Add default configuration for VSC9953 L2 Switch Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 04/10] drivers/net/vsc9953: Refractor the parser for VSC9953 commands Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 05/10] drivers/net/vsc9953: Add command to show/clear port counters Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 06/10] drivers/net/vsc9953: Add commands to enable/disable HW learning Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 07/10] drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953 Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 08/10] drivers/net/vsc9953: Add VLAN commands " Codrin Ciubotariu
2015-06-11 15:10 ` [U-Boot] [PATCH 09/10] drivers/net/vsc9953: Add command for shared/private VLAN learning Codrin Ciubotariu
2015-06-11 15:10 ` Codrin Ciubotariu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434035420-1663-12-git-send-email-codrin.ciubotariu@freescale.com \
--to=codrin.ciubotariu@freescale.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox