switch.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * switch.h: Switch configuration API
  3. *
  4. * Copyright (C) 2008 Felix Fietkau <[email protected]>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #ifndef _UAPI_LINUX_SWITCH_H
  17. #define _UAPI_LINUX_SWITCH_H
  18. #include <linux/types.h>
  19. #include <linux/netdevice.h>
  20. #include <linux/netlink.h>
  21. #include <linux/genetlink.h>
  22. #ifndef __KERNEL__
  23. #include <netlink/netlink.h>
  24. #include <netlink/genl/genl.h>
  25. #include <netlink/genl/ctrl.h>
  26. #endif
  27. /* main attributes */
  28. enum {
  29. SWITCH_ATTR_UNSPEC,
  30. /* global */
  31. SWITCH_ATTR_TYPE,
  32. /* device */
  33. SWITCH_ATTR_ID,
  34. SWITCH_ATTR_DEV_NAME,
  35. SWITCH_ATTR_ALIAS,
  36. SWITCH_ATTR_NAME,
  37. SWITCH_ATTR_VLANS,
  38. SWITCH_ATTR_PORTS,
  39. SWITCH_ATTR_PORTMAP,
  40. SWITCH_ATTR_CPU_PORT,
  41. /* attributes */
  42. SWITCH_ATTR_OP_ID,
  43. SWITCH_ATTR_OP_TYPE,
  44. SWITCH_ATTR_OP_NAME,
  45. SWITCH_ATTR_OP_PORT,
  46. SWITCH_ATTR_OP_VLAN,
  47. SWITCH_ATTR_OP_VALUE_INT,
  48. SWITCH_ATTR_OP_VALUE_STR,
  49. SWITCH_ATTR_OP_VALUE_PORTS,
  50. SWITCH_ATTR_OP_VALUE_LINK,
  51. SWITCH_ATTR_OP_DESCRIPTION,
  52. /* port lists */
  53. SWITCH_ATTR_PORT,
  54. SWITCH_ATTR_MAX
  55. };
  56. enum {
  57. /* port map */
  58. SWITCH_PORTMAP_PORTS,
  59. SWITCH_PORTMAP_SEGMENT,
  60. SWITCH_PORTMAP_VIRT,
  61. SWITCH_PORTMAP_MAX
  62. };
  63. /* commands */
  64. enum {
  65. SWITCH_CMD_UNSPEC,
  66. SWITCH_CMD_GET_SWITCH,
  67. SWITCH_CMD_NEW_ATTR,
  68. SWITCH_CMD_LIST_GLOBAL,
  69. SWITCH_CMD_GET_GLOBAL,
  70. SWITCH_CMD_SET_GLOBAL,
  71. SWITCH_CMD_LIST_PORT,
  72. SWITCH_CMD_GET_PORT,
  73. SWITCH_CMD_SET_PORT,
  74. SWITCH_CMD_LIST_VLAN,
  75. SWITCH_CMD_GET_VLAN,
  76. SWITCH_CMD_SET_VLAN
  77. };
  78. /* data types */
  79. enum switch_val_type {
  80. SWITCH_TYPE_UNSPEC,
  81. SWITCH_TYPE_INT,
  82. SWITCH_TYPE_STRING,
  83. SWITCH_TYPE_PORTS,
  84. SWITCH_TYPE_LINK,
  85. SWITCH_TYPE_NOVAL,
  86. };
  87. /* port nested attributes */
  88. enum {
  89. SWITCH_PORT_UNSPEC,
  90. SWITCH_PORT_ID,
  91. SWITCH_PORT_FLAG_TAGGED,
  92. SWITCH_PORT_ATTR_MAX
  93. };
  94. /* link nested attributes */
  95. enum {
  96. SWITCH_LINK_UNSPEC,
  97. SWITCH_LINK_FLAG_LINK,
  98. SWITCH_LINK_FLAG_DUPLEX,
  99. SWITCH_LINK_FLAG_ANEG,
  100. SWITCH_LINK_FLAG_TX_FLOW,
  101. SWITCH_LINK_FLAG_RX_FLOW,
  102. SWITCH_LINK_SPEED,
  103. SWITCH_LINK_FLAG_EEE_100BASET,
  104. SWITCH_LINK_FLAG_EEE_1000BASET,
  105. SWITCH_LINK_ATTR_MAX,
  106. };
  107. #define SWITCH_ATTR_DEFAULTS_OFFSET 0x1000
  108. #endif /* _UAPI_LINUX_SWITCH_H */