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 15*aae0e689SCodrin Ciubotariu #define ETHSW_CMD_AGGR_GRP_NONE -1 164ea54e3fSCodrin Ciubotariu 174ea54e3fSCodrin Ciubotariu /* IDs used to track keywords in a command */ 184ea54e3fSCodrin Ciubotariu enum ethsw_keyword_id { 194ea54e3fSCodrin Ciubotariu ethsw_id_key_end = -1, 204ea54e3fSCodrin Ciubotariu ethsw_id_help, 214ea54e3fSCodrin Ciubotariu ethsw_id_show, 224ea54e3fSCodrin Ciubotariu ethsw_id_port, 234ea54e3fSCodrin Ciubotariu ethsw_id_enable, 244ea54e3fSCodrin Ciubotariu ethsw_id_disable, 2586719f0cSCodrin Ciubotariu ethsw_id_statistics, 2686719f0cSCodrin Ciubotariu ethsw_id_clear, 2768c929daSCodrin Ciubotariu ethsw_id_learning, 2868c929daSCodrin Ciubotariu ethsw_id_auto, 2922449858SCodrin Ciubotariu ethsw_id_vlan, 3022449858SCodrin Ciubotariu ethsw_id_fdb, 3122449858SCodrin Ciubotariu ethsw_id_add, 3222449858SCodrin Ciubotariu ethsw_id_del, 3322449858SCodrin Ciubotariu ethsw_id_flush, 34a2477924SCodrin Ciubotariu ethsw_id_pvid, 35a2477924SCodrin Ciubotariu ethsw_id_untagged, 36a2477924SCodrin Ciubotariu ethsw_id_all, 37a2477924SCodrin Ciubotariu ethsw_id_none, 38a2477924SCodrin Ciubotariu ethsw_id_egress, 39a2477924SCodrin Ciubotariu ethsw_id_tag, 40a2477924SCodrin Ciubotariu ethsw_id_classified, 4121d214fcSCodrin Ciubotariu ethsw_id_shared, 4221d214fcSCodrin Ciubotariu ethsw_id_private, 435ed1bacdSCodrin Ciubotariu ethsw_id_ingress, 445ed1bacdSCodrin Ciubotariu ethsw_id_filtering, 45*aae0e689SCodrin Ciubotariu ethsw_id_aggr, 464ea54e3fSCodrin Ciubotariu ethsw_id_count, /* keep last */ 474ea54e3fSCodrin Ciubotariu }; 484ea54e3fSCodrin Ciubotariu 494ea54e3fSCodrin Ciubotariu enum ethsw_keyword_opt_id { 504ea54e3fSCodrin Ciubotariu ethsw_id_port_no = ethsw_id_count + 1, 5122449858SCodrin Ciubotariu ethsw_id_vlan_no, 52a2477924SCodrin Ciubotariu ethsw_id_pvid_no, 5322449858SCodrin Ciubotariu ethsw_id_add_del_no, 5422449858SCodrin Ciubotariu ethsw_id_add_del_mac, 55*aae0e689SCodrin Ciubotariu ethsw_id_aggr_no, 564ea54e3fSCodrin Ciubotariu ethsw_id_count_all, /* keep last */ 574ea54e3fSCodrin Ciubotariu }; 584ea54e3fSCodrin Ciubotariu 594ea54e3fSCodrin Ciubotariu struct ethsw_command_def { 604ea54e3fSCodrin Ciubotariu int cmd_to_keywords[ETHSW_MAX_CMD_PARAMS]; 614ea54e3fSCodrin Ciubotariu int cmd_keywords_nr; 624ea54e3fSCodrin Ciubotariu int port; 6322449858SCodrin Ciubotariu int vid; 64*aae0e689SCodrin Ciubotariu int aggr_grp; 6522449858SCodrin Ciubotariu uchar ethaddr[6]; 664ea54e3fSCodrin Ciubotariu int (*cmd_function)(struct ethsw_command_def *parsed_cmd); 674ea54e3fSCodrin Ciubotariu }; 684ea54e3fSCodrin Ciubotariu 694ea54e3fSCodrin Ciubotariu /* Structure to be created and initialized by an Ethernet Switch driver */ 704ea54e3fSCodrin Ciubotariu struct ethsw_command_func { 714ea54e3fSCodrin Ciubotariu const char *ethsw_name; 724ea54e3fSCodrin Ciubotariu int (*port_enable)(struct ethsw_command_def *parsed_cmd); 734ea54e3fSCodrin Ciubotariu int (*port_disable)(struct ethsw_command_def *parsed_cmd); 744ea54e3fSCodrin Ciubotariu int (*port_show)(struct ethsw_command_def *parsed_cmd); 7586719f0cSCodrin Ciubotariu int (*port_stats)(struct ethsw_command_def *parsed_cmd); 7686719f0cSCodrin Ciubotariu int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd); 7768c929daSCodrin Ciubotariu int (*port_learn)(struct ethsw_command_def *parsed_cmd); 7868c929daSCodrin Ciubotariu int (*port_learn_show)(struct ethsw_command_def *parsed_cmd); 7922449858SCodrin Ciubotariu int (*fdb_show)(struct ethsw_command_def *parsed_cmd); 8022449858SCodrin Ciubotariu int (*fdb_flush)(struct ethsw_command_def *parsed_cmd); 8122449858SCodrin Ciubotariu int (*fdb_entry_add)(struct ethsw_command_def *parsed_cmd); 8222449858SCodrin Ciubotariu int (*fdb_entry_del)(struct ethsw_command_def *parsed_cmd); 83a2477924SCodrin Ciubotariu int (*pvid_show)(struct ethsw_command_def *parsed_cmd); 84a2477924SCodrin Ciubotariu int (*pvid_set)(struct ethsw_command_def *parsed_cmd); 85a2477924SCodrin Ciubotariu int (*vlan_show)(struct ethsw_command_def *parsed_cmd); 86a2477924SCodrin Ciubotariu int (*vlan_set)(struct ethsw_command_def *parsed_cmd); 87a2477924SCodrin Ciubotariu int (*port_untag_show)(struct ethsw_command_def *parsed_cmd); 88a2477924SCodrin Ciubotariu int (*port_untag_set)(struct ethsw_command_def *parsed_cmd); 89a2477924SCodrin Ciubotariu int (*port_egr_vlan_show)(struct ethsw_command_def *parsed_cmd); 90a2477924SCodrin Ciubotariu int (*port_egr_vlan_set)(struct ethsw_command_def *parsed_cmd); 9121d214fcSCodrin Ciubotariu int (*vlan_learn_show)(struct ethsw_command_def *parsed_cmd); 9221d214fcSCodrin Ciubotariu int (*vlan_learn_set)(struct ethsw_command_def *parsed_cmd); 935ed1bacdSCodrin Ciubotariu int (*port_ingr_filt_show)(struct ethsw_command_def *parsed_cmd); 945ed1bacdSCodrin Ciubotariu int (*port_ingr_filt_set)(struct ethsw_command_def *parsed_cmd); 95*aae0e689SCodrin Ciubotariu int (*port_aggr_show)(struct ethsw_command_def *parsed_cmd); 96*aae0e689SCodrin Ciubotariu int (*port_aggr_set)(struct ethsw_command_def *parsed_cmd); 974ea54e3fSCodrin Ciubotariu }; 984ea54e3fSCodrin Ciubotariu 994ea54e3fSCodrin Ciubotariu int ethsw_define_functions(const struct ethsw_command_func *cmd_func); 1004ea54e3fSCodrin Ciubotariu 1014ea54e3fSCodrin Ciubotariu #endif /* _CMD_ETHSW_H_ */ 102