1 /* 2 * Copyright 2015 Freescale Semiconductor, Inc. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 * 6 * Ethernet Switch commands 7 */ 8 9 #ifndef _CMD_ETHSW_H_ 10 #define _CMD_ETHSW_H_ 11 12 #define ETHSW_MAX_CMD_PARAMS 20 13 #define ETHSW_CMD_PORT_ALL -1 14 #define ETHSW_CMD_VLAN_ALL -1 15 16 /* IDs used to track keywords in a command */ 17 enum ethsw_keyword_id { 18 ethsw_id_key_end = -1, 19 ethsw_id_help, 20 ethsw_id_show, 21 ethsw_id_port, 22 ethsw_id_enable, 23 ethsw_id_disable, 24 ethsw_id_statistics, 25 ethsw_id_clear, 26 ethsw_id_learning, 27 ethsw_id_auto, 28 ethsw_id_vlan, 29 ethsw_id_fdb, 30 ethsw_id_add, 31 ethsw_id_del, 32 ethsw_id_flush, 33 ethsw_id_count, /* keep last */ 34 }; 35 36 enum ethsw_keyword_opt_id { 37 ethsw_id_port_no = ethsw_id_count + 1, 38 ethsw_id_vlan_no, 39 ethsw_id_add_del_no, 40 ethsw_id_add_del_mac, 41 ethsw_id_count_all, /* keep last */ 42 }; 43 44 struct ethsw_command_def { 45 int cmd_to_keywords[ETHSW_MAX_CMD_PARAMS]; 46 int cmd_keywords_nr; 47 int port; 48 int vid; 49 uchar ethaddr[6]; 50 int (*cmd_function)(struct ethsw_command_def *parsed_cmd); 51 }; 52 53 /* Structure to be created and initialized by an Ethernet Switch driver */ 54 struct ethsw_command_func { 55 const char *ethsw_name; 56 int (*port_enable)(struct ethsw_command_def *parsed_cmd); 57 int (*port_disable)(struct ethsw_command_def *parsed_cmd); 58 int (*port_show)(struct ethsw_command_def *parsed_cmd); 59 int (*port_stats)(struct ethsw_command_def *parsed_cmd); 60 int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd); 61 int (*port_learn)(struct ethsw_command_def *parsed_cmd); 62 int (*port_learn_show)(struct ethsw_command_def *parsed_cmd); 63 int (*fdb_show)(struct ethsw_command_def *parsed_cmd); 64 int (*fdb_flush)(struct ethsw_command_def *parsed_cmd); 65 int (*fdb_entry_add)(struct ethsw_command_def *parsed_cmd); 66 int (*fdb_entry_del)(struct ethsw_command_def *parsed_cmd); 67 }; 68 69 int ethsw_define_functions(const struct ethsw_command_func *cmd_func); 70 71 #endif /* _CMD_ETHSW_H_ */ 72