Re: [U-Boot] [PATCH v4 12/16] drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953

2015-09-11 Thread Joe Hershberger
Hi Codrin,

On Wed, Sep 9, 2015 at 10:00 AM, Codrin Ciubotariu
 wrote:
> The new command:
> ethsw [port ] [vlan ] fdb
> { [help] | show | flush | { add | del }  }
>
> Can be used to add and delete FDB entries. Also, the command can be used
> to show entries from the FDB tables. When used with [port ]
> and [vlan ], only the matching the FDB entries can be seen or
> flushed. The command has also been added to the generic ethsw parser
> from cmd_ethsw.c.
>
> Signed-off-by: Johnson Leung 
> Signed-off-by: Codrin Ciubotariu 

Acked-by: Joe Hershberger 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 12/16] drivers/net/vsc9953: Add commands to manipulate the FDB for VSC9953

2015-09-09 Thread Codrin Ciubotariu
The new command:
ethsw [port ] [vlan ] fdb
{ [help] | show | flush | { add | del }  }

Can be used to add and delete FDB entries. Also, the command can be used
to show entries from the FDB tables. When used with [port ]
and [vlan ], only the matching the FDB entries can be seen or
flushed. The command has also been added to the generic ethsw parser
from cmd_ethsw.c.

Signed-off-by: Johnson Leung 
Signed-off-by: Codrin Ciubotariu 
---

Changes for v2:
- removed Change-id field;

Changes for v3:
- replaced values returned by functions called by the parser with 
CMD_RET_* macros;
- removed "CONFIG_" from macros added in vsc9953.h;
- each variabled is declared on a separate line, with one space instead 
of tab(s);
- vsc9953_mac_table_poll_idle() returns -EBUSY if the table is not idle;
- the array used to hold the MAC address (mac_addr) has been renamed to 
ethaddr
and is allocated statically instead of dynamically;
- reformulate definition of VSC9953_FDB_HELP macro;
- used the function added by previous patch to check if a string has 
the format
of a MAC address;

Changes for v4:
- eth_validate_ethaddr_str() is now declared in include/env_flags.h 
instead
of include/net.h so we have to include net.h instead of env_flags.h;

 common/cmd_ethsw.c| 178 +++
 drivers/net/vsc9953.c | 472 ++
 include/ethsw.h   |  15 ++
 include/vsc9953.h |  28 +++
 4 files changed, 693 insertions(+)

diff --git a/common/cmd_ethsw.c b/common/cmd_ethsw.c
index 0344da8..d33c78d 100644
--- a/common/cmd_ethsw.c
+++ b/common/cmd_ethsw.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static const char *ethsw_name;
@@ -34,6 +35,18 @@ static int ethsw_learn_help_key_func(struct 
ethsw_command_def *parsed_cmd)
return CMD_RET_SUCCESS;
 }
 
+#define ETHSW_FDB_HELP "ethsw [port ] [vlan ] fdb " \
+"{ [help] | show | flush | { add | del }  } " \
+"- Add/delete a mac entry in FDB; use show to see FDB entries; " \
+"if vlan  is missing, VID 1 will be used"
+
+static int ethsw_fdb_help_key_func(struct ethsw_command_def *parsed_cmd)
+{
+   printf(ETHSW_FDB_HELP"\n");
+
+   return CMD_RET_SUCCESS;
+}
+
 static struct keywords_to_function {
enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS];
int cmd_func_offset;
@@ -130,6 +143,59 @@ static struct keywords_to_function {
.cmd_func_offset = offsetof(struct ethsw_command_func,
port_learn),
.keyword_function = NULL,
+   }, {
+   .cmd_keyword = {
+   ethsw_id_fdb,
+   ethsw_id_key_end,
+   },
+   .cmd_func_offset = -1,
+   .keyword_function = _fdb_help_key_func,
+   }, {
+   .cmd_keyword = {
+   ethsw_id_fdb,
+   ethsw_id_help,
+   ethsw_id_key_end,
+   },
+   .cmd_func_offset = -1,
+   .keyword_function = _fdb_help_key_func,
+   }, {
+   .cmd_keyword = {
+   ethsw_id_fdb,
+   ethsw_id_show,
+   ethsw_id_key_end,
+   },
+   .cmd_func_offset = offsetof(struct ethsw_command_func,
+   fdb_show),
+   .keyword_function = NULL,
+   }, {
+   .cmd_keyword = {
+   ethsw_id_fdb,
+   ethsw_id_flush,
+   ethsw_id_key_end,
+   },
+   .cmd_func_offset = offsetof(struct ethsw_command_func,
+   fdb_flush),
+   .keyword_function = NULL,
+   }, {
+   .cmd_keyword = {
+   ethsw_id_fdb,
+   ethsw_id_add,
+   ethsw_id_add_del_mac,
+   ethsw_id_key_end,
+   },
+   .cmd_func_offset = offsetof(struct ethsw_command_func,
+   fdb_entry_add),
+   .keyword_function = NULL,
+   }, {
+   .cmd_keyword = {
+   ethsw_id_fdb,
+