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 |
Codrin Ciubotariu | 4732e35 | 2015-09-09 18:00:52 +0300 | [diff] [blame] | 14 | #define ETHSW_CMD_VLAN_ALL -1 |
Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 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, |
Codrin Ciubotariu | c003473 | 2015-07-24 16:55:29 +0300 | [diff] [blame] | 24 | ethsw_id_statistics, |
| 25 | ethsw_id_clear, |
Codrin Ciubotariu | 2d1607f | 2015-07-24 16:55:30 +0300 | [diff] [blame] | 26 | ethsw_id_learning, |
| 27 | ethsw_id_auto, |
Codrin Ciubotariu | 4732e35 | 2015-09-09 18:00:52 +0300 | [diff] [blame] | 28 | ethsw_id_vlan, |
| 29 | ethsw_id_fdb, |
| 30 | ethsw_id_add, |
| 31 | ethsw_id_del, |
| 32 | ethsw_id_flush, |
Codrin Ciubotariu | 4718f95 | 2015-07-24 16:55:33 +0300 | [diff] [blame^] | 33 | ethsw_id_pvid, |
| 34 | ethsw_id_untagged, |
| 35 | ethsw_id_all, |
| 36 | ethsw_id_none, |
| 37 | ethsw_id_egress, |
| 38 | ethsw_id_tag, |
| 39 | ethsw_id_classified, |
Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 40 | ethsw_id_count, /* keep last */ |
| 41 | }; |
| 42 | |
| 43 | enum ethsw_keyword_opt_id { |
| 44 | ethsw_id_port_no = ethsw_id_count + 1, |
Codrin Ciubotariu | 4732e35 | 2015-09-09 18:00:52 +0300 | [diff] [blame] | 45 | ethsw_id_vlan_no, |
Codrin Ciubotariu | 4718f95 | 2015-07-24 16:55:33 +0300 | [diff] [blame^] | 46 | ethsw_id_pvid_no, |
Codrin Ciubotariu | 4732e35 | 2015-09-09 18:00:52 +0300 | [diff] [blame] | 47 | ethsw_id_add_del_no, |
| 48 | ethsw_id_add_del_mac, |
Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 49 | ethsw_id_count_all, /* keep last */ |
| 50 | }; |
| 51 | |
| 52 | struct ethsw_command_def { |
| 53 | int cmd_to_keywords[ETHSW_MAX_CMD_PARAMS]; |
| 54 | int cmd_keywords_nr; |
| 55 | int port; |
Codrin Ciubotariu | 4732e35 | 2015-09-09 18:00:52 +0300 | [diff] [blame] | 56 | int vid; |
| 57 | uchar ethaddr[6]; |
Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 58 | int (*cmd_function)(struct ethsw_command_def *parsed_cmd); |
| 59 | }; |
| 60 | |
| 61 | /* Structure to be created and initialized by an Ethernet Switch driver */ |
| 62 | struct ethsw_command_func { |
| 63 | const char *ethsw_name; |
| 64 | int (*port_enable)(struct ethsw_command_def *parsed_cmd); |
| 65 | int (*port_disable)(struct ethsw_command_def *parsed_cmd); |
| 66 | int (*port_show)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | c003473 | 2015-07-24 16:55:29 +0300 | [diff] [blame] | 67 | int (*port_stats)(struct ethsw_command_def *parsed_cmd); |
| 68 | int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | 2d1607f | 2015-07-24 16:55:30 +0300 | [diff] [blame] | 69 | int (*port_learn)(struct ethsw_command_def *parsed_cmd); |
| 70 | int (*port_learn_show)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | 4732e35 | 2015-09-09 18:00:52 +0300 | [diff] [blame] | 71 | int (*fdb_show)(struct ethsw_command_def *parsed_cmd); |
| 72 | int (*fdb_flush)(struct ethsw_command_def *parsed_cmd); |
| 73 | int (*fdb_entry_add)(struct ethsw_command_def *parsed_cmd); |
| 74 | int (*fdb_entry_del)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | 4718f95 | 2015-07-24 16:55:33 +0300 | [diff] [blame^] | 75 | int (*pvid_show)(struct ethsw_command_def *parsed_cmd); |
| 76 | int (*pvid_set)(struct ethsw_command_def *parsed_cmd); |
| 77 | int (*vlan_show)(struct ethsw_command_def *parsed_cmd); |
| 78 | int (*vlan_set)(struct ethsw_command_def *parsed_cmd); |
| 79 | int (*port_untag_show)(struct ethsw_command_def *parsed_cmd); |
| 80 | int (*port_untag_set)(struct ethsw_command_def *parsed_cmd); |
| 81 | int (*port_egr_vlan_show)(struct ethsw_command_def *parsed_cmd); |
| 82 | int (*port_egr_vlan_set)(struct ethsw_command_def *parsed_cmd); |
Codrin Ciubotariu | bfafe5c | 2015-07-24 16:55:27 +0300 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | int ethsw_define_functions(const struct ethsw_command_func *cmd_func); |
| 86 | |
| 87 | #endif /* _CMD_ETHSW_H_ */ |