Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 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 | |
| 15 | /* IDs used to track keywords in a command */ |
| 16 | enum ethsw_keyword_id { |
| 17 | ethsw_id_key_end = -1, |
| 18 | ethsw_id_help, |
| 19 | ethsw_id_show, |
| 20 | ethsw_id_port, |
| 21 | ethsw_id_enable, |
| 22 | ethsw_id_disable, |
Codrin Ciubotariu | c003473 | 2015-07-24 16:55:29 +0300 | [diff] [blame] | 23 | ethsw_id_statistics, |
| 24 | ethsw_id_clear, |
Codrin Ciubotariu | 2d1607f | 2015-07-24 16:55:30 +0300 | [diff] [blame^] | 25 | ethsw_id_learning, |
| 26 | ethsw_id_auto, |
Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 27 | ethsw_id_count, /* keep last */ |
| 28 | }; |
| 29 | |
| 30 | enum ethsw_keyword_opt_id { |
| 31 | ethsw_id_port_no = ethsw_id_count + 1, |
| 32 | ethsw_id_count_all, /* keep last */ |
| 33 | }; |
| 34 | |
| 35 | struct ethsw_command_def { |
| 36 | int cmd_to_keywords[ETHSW_MAX_CMD_PARAMS]; |
| 37 | int cmd_keywords_nr; |
| 38 | int port; |
| 39 | int (*cmd_function)(struct ethsw_command_def *parsed_cmd); |
| 40 | }; |
| 41 | |
| 42 | /* Structure to be created and initialized by an Ethernet Switch driver */ |
| 43 | struct ethsw_command_func { |
| 44 | const char *ethsw_name; |
| 45 | int (*port_enable)(struct ethsw_command_def *parsed_cmd); |
| 46 | int (*port_disable)(struct ethsw_command_def *parsed_cmd); |
| 47 | int (*port_show)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | c003473 | 2015-07-24 16:55:29 +0300 | [diff] [blame] | 48 | int (*port_stats)(struct ethsw_command_def *parsed_cmd); |
| 49 | int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | 2d1607f | 2015-07-24 16:55:30 +0300 | [diff] [blame^] | 50 | int (*port_learn)(struct ethsw_command_def *parsed_cmd); |
| 51 | int (*port_learn_show)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | int ethsw_define_functions(const struct ethsw_command_func *cmd_func); |
| 55 | |
| 56 | #endif /* _CMD_ETHSW_H_ */ |