blob: 25f358d128e0c2a8074e82896a1a5d5f64442948 [file] [log] [blame]
Codrin Ciubotariu4ea54e32015-07-24 16:55:27 +03001/*
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 Ciubotariu22449852015-09-09 18:00:52 +030014#define ETHSW_CMD_VLAN_ALL -1
Codrin Ciubotariuaae0e682015-12-15 15:21:06 +020015#define ETHSW_CMD_AGGR_GRP_NONE -1
Codrin Ciubotariu4ea54e32015-07-24 16:55:27 +030016
17/* IDs used to track keywords in a command */
18enum ethsw_keyword_id {
19 ethsw_id_key_end = -1,
20 ethsw_id_help,
21 ethsw_id_show,
22 ethsw_id_port,
23 ethsw_id_enable,
24 ethsw_id_disable,
Codrin Ciubotariu86719f02015-07-24 16:55:29 +030025 ethsw_id_statistics,
26 ethsw_id_clear,
Codrin Ciubotariu68c929d2015-07-24 16:55:30 +030027 ethsw_id_learning,
28 ethsw_id_auto,
Codrin Ciubotariu22449852015-09-09 18:00:52 +030029 ethsw_id_vlan,
30 ethsw_id_fdb,
31 ethsw_id_add,
32 ethsw_id_del,
33 ethsw_id_flush,
Codrin Ciubotariua2477922015-07-24 16:55:33 +030034 ethsw_id_pvid,
35 ethsw_id_untagged,
36 ethsw_id_all,
37 ethsw_id_none,
38 ethsw_id_egress,
39 ethsw_id_tag,
40 ethsw_id_classified,
Codrin Ciubotariu21d214f2015-07-24 16:55:34 +030041 ethsw_id_shared,
42 ethsw_id_private,
Codrin Ciubotariu5ed1bac2015-07-24 16:55:35 +030043 ethsw_id_ingress,
44 ethsw_id_filtering,
Codrin Ciubotariuaae0e682015-12-15 15:21:06 +020045 ethsw_id_aggr,
Codrin Ciubotariu4ea54e32015-07-24 16:55:27 +030046 ethsw_id_count, /* keep last */
47};
48
49enum ethsw_keyword_opt_id {
50 ethsw_id_port_no = ethsw_id_count + 1,
Codrin Ciubotariu22449852015-09-09 18:00:52 +030051 ethsw_id_vlan_no,
Codrin Ciubotariua2477922015-07-24 16:55:33 +030052 ethsw_id_pvid_no,
Codrin Ciubotariu22449852015-09-09 18:00:52 +030053 ethsw_id_add_del_no,
54 ethsw_id_add_del_mac,
Codrin Ciubotariuaae0e682015-12-15 15:21:06 +020055 ethsw_id_aggr_no,
Codrin Ciubotariu4ea54e32015-07-24 16:55:27 +030056 ethsw_id_count_all, /* keep last */
57};
58
59struct ethsw_command_def {
60 int cmd_to_keywords[ETHSW_MAX_CMD_PARAMS];
61 int cmd_keywords_nr;
62 int port;
Codrin Ciubotariu22449852015-09-09 18:00:52 +030063 int vid;
Codrin Ciubotariuaae0e682015-12-15 15:21:06 +020064 int aggr_grp;
Codrin Ciubotariu22449852015-09-09 18:00:52 +030065 uchar ethaddr[6];
Codrin Ciubotariu4ea54e32015-07-24 16:55:27 +030066 int (*cmd_function)(struct ethsw_command_def *parsed_cmd);
67};
68
69/* Structure to be created and initialized by an Ethernet Switch driver */
70struct ethsw_command_func {
71 const char *ethsw_name;
72 int (*port_enable)(struct ethsw_command_def *parsed_cmd);
73 int (*port_disable)(struct ethsw_command_def *parsed_cmd);
74 int (*port_show)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariu86719f02015-07-24 16:55:29 +030075 int (*port_stats)(struct ethsw_command_def *parsed_cmd);
76 int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariu68c929d2015-07-24 16:55:30 +030077 int (*port_learn)(struct ethsw_command_def *parsed_cmd);
78 int (*port_learn_show)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariu22449852015-09-09 18:00:52 +030079 int (*fdb_show)(struct ethsw_command_def *parsed_cmd);
80 int (*fdb_flush)(struct ethsw_command_def *parsed_cmd);
81 int (*fdb_entry_add)(struct ethsw_command_def *parsed_cmd);
82 int (*fdb_entry_del)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariua2477922015-07-24 16:55:33 +030083 int (*pvid_show)(struct ethsw_command_def *parsed_cmd);
84 int (*pvid_set)(struct ethsw_command_def *parsed_cmd);
85 int (*vlan_show)(struct ethsw_command_def *parsed_cmd);
86 int (*vlan_set)(struct ethsw_command_def *parsed_cmd);
87 int (*port_untag_show)(struct ethsw_command_def *parsed_cmd);
88 int (*port_untag_set)(struct ethsw_command_def *parsed_cmd);
89 int (*port_egr_vlan_show)(struct ethsw_command_def *parsed_cmd);
90 int (*port_egr_vlan_set)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariu21d214f2015-07-24 16:55:34 +030091 int (*vlan_learn_show)(struct ethsw_command_def *parsed_cmd);
92 int (*vlan_learn_set)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariu5ed1bac2015-07-24 16:55:35 +030093 int (*port_ingr_filt_show)(struct ethsw_command_def *parsed_cmd);
94 int (*port_ingr_filt_set)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariuaae0e682015-12-15 15:21:06 +020095 int (*port_aggr_show)(struct ethsw_command_def *parsed_cmd);
96 int (*port_aggr_set)(struct ethsw_command_def *parsed_cmd);
Codrin Ciubotariu4ea54e32015-07-24 16:55:27 +030097};
98
99int ethsw_define_functions(const struct ethsw_command_func *cmd_func);
100
101#endif /* _CMD_ETHSW_H_ */