xref: /rk3399_rockchip-uboot/include/ethsw.h (revision a2477924cd302cfae730ebefb431814eb99ad861)
14ea54e3fSCodrin Ciubotariu /*
24ea54e3fSCodrin Ciubotariu  * Copyright 2015 Freescale Semiconductor, Inc.
34ea54e3fSCodrin Ciubotariu  *
44ea54e3fSCodrin Ciubotariu  * SPDX-License-Identifier:      GPL-2.0+
54ea54e3fSCodrin Ciubotariu  *
64ea54e3fSCodrin Ciubotariu  * Ethernet Switch commands
74ea54e3fSCodrin Ciubotariu  */
84ea54e3fSCodrin Ciubotariu 
94ea54e3fSCodrin Ciubotariu #ifndef _CMD_ETHSW_H_
104ea54e3fSCodrin Ciubotariu #define _CMD_ETHSW_H_
114ea54e3fSCodrin Ciubotariu 
124ea54e3fSCodrin Ciubotariu #define ETHSW_MAX_CMD_PARAMS 20
134ea54e3fSCodrin Ciubotariu #define ETHSW_CMD_PORT_ALL -1
1422449858SCodrin Ciubotariu #define ETHSW_CMD_VLAN_ALL -1
154ea54e3fSCodrin Ciubotariu 
164ea54e3fSCodrin Ciubotariu /* IDs used to track keywords in a command */
174ea54e3fSCodrin Ciubotariu enum ethsw_keyword_id {
184ea54e3fSCodrin Ciubotariu 	ethsw_id_key_end = -1,
194ea54e3fSCodrin Ciubotariu 	ethsw_id_help,
204ea54e3fSCodrin Ciubotariu 	ethsw_id_show,
214ea54e3fSCodrin Ciubotariu 	ethsw_id_port,
224ea54e3fSCodrin Ciubotariu 	ethsw_id_enable,
234ea54e3fSCodrin Ciubotariu 	ethsw_id_disable,
2486719f0cSCodrin Ciubotariu 	ethsw_id_statistics,
2586719f0cSCodrin Ciubotariu 	ethsw_id_clear,
2668c929daSCodrin Ciubotariu 	ethsw_id_learning,
2768c929daSCodrin Ciubotariu 	ethsw_id_auto,
2822449858SCodrin Ciubotariu 	ethsw_id_vlan,
2922449858SCodrin Ciubotariu 	ethsw_id_fdb,
3022449858SCodrin Ciubotariu 	ethsw_id_add,
3122449858SCodrin Ciubotariu 	ethsw_id_del,
3222449858SCodrin Ciubotariu 	ethsw_id_flush,
33*a2477924SCodrin Ciubotariu 	ethsw_id_pvid,
34*a2477924SCodrin Ciubotariu 	ethsw_id_untagged,
35*a2477924SCodrin Ciubotariu 	ethsw_id_all,
36*a2477924SCodrin Ciubotariu 	ethsw_id_none,
37*a2477924SCodrin Ciubotariu 	ethsw_id_egress,
38*a2477924SCodrin Ciubotariu 	ethsw_id_tag,
39*a2477924SCodrin Ciubotariu 	ethsw_id_classified,
404ea54e3fSCodrin Ciubotariu 	ethsw_id_count,	/* keep last */
414ea54e3fSCodrin Ciubotariu };
424ea54e3fSCodrin Ciubotariu 
434ea54e3fSCodrin Ciubotariu enum ethsw_keyword_opt_id {
444ea54e3fSCodrin Ciubotariu 	ethsw_id_port_no = ethsw_id_count + 1,
4522449858SCodrin Ciubotariu 	ethsw_id_vlan_no,
46*a2477924SCodrin Ciubotariu 	ethsw_id_pvid_no,
4722449858SCodrin Ciubotariu 	ethsw_id_add_del_no,
4822449858SCodrin Ciubotariu 	ethsw_id_add_del_mac,
494ea54e3fSCodrin Ciubotariu 	ethsw_id_count_all,	/* keep last */
504ea54e3fSCodrin Ciubotariu };
514ea54e3fSCodrin Ciubotariu 
524ea54e3fSCodrin Ciubotariu struct ethsw_command_def {
534ea54e3fSCodrin Ciubotariu 	int cmd_to_keywords[ETHSW_MAX_CMD_PARAMS];
544ea54e3fSCodrin Ciubotariu 	int cmd_keywords_nr;
554ea54e3fSCodrin Ciubotariu 	int port;
5622449858SCodrin Ciubotariu 	int vid;
5722449858SCodrin Ciubotariu 	uchar ethaddr[6];
584ea54e3fSCodrin Ciubotariu 	int (*cmd_function)(struct ethsw_command_def *parsed_cmd);
594ea54e3fSCodrin Ciubotariu };
604ea54e3fSCodrin Ciubotariu 
614ea54e3fSCodrin Ciubotariu /* Structure to be created and initialized by an Ethernet Switch driver */
624ea54e3fSCodrin Ciubotariu struct ethsw_command_func {
634ea54e3fSCodrin Ciubotariu 	const char *ethsw_name;
644ea54e3fSCodrin Ciubotariu 	int (*port_enable)(struct ethsw_command_def *parsed_cmd);
654ea54e3fSCodrin Ciubotariu 	int (*port_disable)(struct ethsw_command_def *parsed_cmd);
664ea54e3fSCodrin Ciubotariu 	int (*port_show)(struct ethsw_command_def *parsed_cmd);
6786719f0cSCodrin Ciubotariu 	int (*port_stats)(struct ethsw_command_def *parsed_cmd);
6886719f0cSCodrin Ciubotariu 	int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd);
6968c929daSCodrin Ciubotariu 	int (*port_learn)(struct ethsw_command_def *parsed_cmd);
7068c929daSCodrin Ciubotariu 	int (*port_learn_show)(struct ethsw_command_def *parsed_cmd);
7122449858SCodrin Ciubotariu 	int (*fdb_show)(struct ethsw_command_def *parsed_cmd);
7222449858SCodrin Ciubotariu 	int (*fdb_flush)(struct ethsw_command_def *parsed_cmd);
7322449858SCodrin Ciubotariu 	int (*fdb_entry_add)(struct ethsw_command_def *parsed_cmd);
7422449858SCodrin Ciubotariu 	int (*fdb_entry_del)(struct ethsw_command_def *parsed_cmd);
75*a2477924SCodrin Ciubotariu 	int (*pvid_show)(struct ethsw_command_def *parsed_cmd);
76*a2477924SCodrin Ciubotariu 	int (*pvid_set)(struct ethsw_command_def *parsed_cmd);
77*a2477924SCodrin Ciubotariu 	int (*vlan_show)(struct ethsw_command_def *parsed_cmd);
78*a2477924SCodrin Ciubotariu 	int (*vlan_set)(struct ethsw_command_def *parsed_cmd);
79*a2477924SCodrin Ciubotariu 	int (*port_untag_show)(struct ethsw_command_def *parsed_cmd);
80*a2477924SCodrin Ciubotariu 	int (*port_untag_set)(struct ethsw_command_def *parsed_cmd);
81*a2477924SCodrin Ciubotariu 	int (*port_egr_vlan_show)(struct ethsw_command_def *parsed_cmd);
82*a2477924SCodrin Ciubotariu 	int (*port_egr_vlan_set)(struct ethsw_command_def *parsed_cmd);
834ea54e3fSCodrin Ciubotariu };
844ea54e3fSCodrin Ciubotariu 
854ea54e3fSCodrin Ciubotariu int ethsw_define_functions(const struct ethsw_command_func *cmd_func);
864ea54e3fSCodrin Ciubotariu 
874ea54e3fSCodrin Ciubotariu #endif /* _CMD_ETHSW_H_ */
88