ethsw.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2015 Freescale Semiconductor, Inc.
  4. *
  5. * Ethernet Switch commands
  6. */
  7. #ifndef _CMD_ETHSW_H_
  8. #define _CMD_ETHSW_H_
  9. #define ETHSW_MAX_CMD_PARAMS 20
  10. #define ETHSW_CMD_PORT_ALL -1
  11. #define ETHSW_CMD_VLAN_ALL -1
  12. #define ETHSW_CMD_AGGR_GRP_NONE -1
  13. /* IDs used to track keywords in a command */
  14. enum ethsw_keyword_id {
  15. ethsw_id_key_end = -1,
  16. ethsw_id_help,
  17. ethsw_id_show,
  18. ethsw_id_port,
  19. ethsw_id_enable,
  20. ethsw_id_disable,
  21. ethsw_id_statistics,
  22. ethsw_id_clear,
  23. ethsw_id_learning,
  24. ethsw_id_auto,
  25. ethsw_id_vlan,
  26. ethsw_id_fdb,
  27. ethsw_id_add,
  28. ethsw_id_del,
  29. ethsw_id_flush,
  30. ethsw_id_pvid,
  31. ethsw_id_untagged,
  32. ethsw_id_all,
  33. ethsw_id_none,
  34. ethsw_id_egress,
  35. ethsw_id_tag,
  36. ethsw_id_classified,
  37. ethsw_id_shared,
  38. ethsw_id_private,
  39. ethsw_id_ingress,
  40. ethsw_id_filtering,
  41. ethsw_id_aggr,
  42. ethsw_id_count, /* keep last */
  43. };
  44. enum ethsw_keyword_opt_id {
  45. ethsw_id_port_no = ethsw_id_count + 1,
  46. ethsw_id_vlan_no,
  47. ethsw_id_pvid_no,
  48. ethsw_id_add_del_no,
  49. ethsw_id_add_del_mac,
  50. ethsw_id_aggr_no,
  51. ethsw_id_count_all, /* keep last */
  52. };
  53. struct ethsw_command_def {
  54. int cmd_to_keywords[ETHSW_MAX_CMD_PARAMS];
  55. int cmd_keywords_nr;
  56. int port;
  57. int vid;
  58. int aggr_grp;
  59. uchar ethaddr[6];
  60. int (*cmd_function)(struct ethsw_command_def *parsed_cmd);
  61. };
  62. /* Structure to be created and initialized by an Ethernet Switch driver */
  63. struct ethsw_command_func {
  64. const char *ethsw_name;
  65. int (*port_enable)(struct ethsw_command_def *parsed_cmd);
  66. int (*port_disable)(struct ethsw_command_def *parsed_cmd);
  67. int (*port_show)(struct ethsw_command_def *parsed_cmd);
  68. int (*port_stats)(struct ethsw_command_def *parsed_cmd);
  69. int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd);
  70. int (*port_learn)(struct ethsw_command_def *parsed_cmd);
  71. int (*port_learn_show)(struct ethsw_command_def *parsed_cmd);
  72. int (*fdb_show)(struct ethsw_command_def *parsed_cmd);
  73. int (*fdb_flush)(struct ethsw_command_def *parsed_cmd);
  74. int (*fdb_entry_add)(struct ethsw_command_def *parsed_cmd);
  75. int (*fdb_entry_del)(struct ethsw_command_def *parsed_cmd);
  76. int (*pvid_show)(struct ethsw_command_def *parsed_cmd);
  77. int (*pvid_set)(struct ethsw_command_def *parsed_cmd);
  78. int (*vlan_show)(struct ethsw_command_def *parsed_cmd);
  79. int (*vlan_set)(struct ethsw_command_def *parsed_cmd);
  80. int (*port_untag_show)(struct ethsw_command_def *parsed_cmd);
  81. int (*port_untag_set)(struct ethsw_command_def *parsed_cmd);
  82. int (*port_egr_vlan_show)(struct ethsw_command_def *parsed_cmd);
  83. int (*port_egr_vlan_set)(struct ethsw_command_def *parsed_cmd);
  84. int (*vlan_learn_show)(struct ethsw_command_def *parsed_cmd);
  85. int (*vlan_learn_set)(struct ethsw_command_def *parsed_cmd);
  86. int (*port_ingr_filt_show)(struct ethsw_command_def *parsed_cmd);
  87. int (*port_ingr_filt_set)(struct ethsw_command_def *parsed_cmd);
  88. int (*port_aggr_show)(struct ethsw_command_def *parsed_cmd);
  89. int (*port_aggr_set)(struct ethsw_command_def *parsed_cmd);
  90. };
  91. int ethsw_define_functions(const struct ethsw_command_func *cmd_func);
  92. #endif /* _CMD_ETHSW_H_ */