switch.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * switch.h: Switch configuration API
  3. *
  4. * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name>
  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 _LINUX_SWITCH_H
  17. #define _LINUX_SWITCH_H
  18. #include <linux/types.h>
  19. #include <linux/netdevice.h>
  20. #include <linux/netlink.h>
  21. #include <linux/genetlink.h>
  22. #include <netlink/netlink.h>
  23. #include <netlink/genl/genl.h>
  24. #include <netlink/genl/ctrl.h>
  25. /* main attributes */
  26. enum {
  27. SWITCH_ATTR_UNSPEC,
  28. /* global */
  29. SWITCH_ATTR_TYPE,
  30. /* device */
  31. SWITCH_ATTR_ID,
  32. SWITCH_ATTR_DEV_NAME,
  33. SWITCH_ATTR_ALIAS,
  34. SWITCH_ATTR_NAME,
  35. SWITCH_ATTR_VLANS,
  36. SWITCH_ATTR_PORTS,
  37. SWITCH_ATTR_PORTMAP,
  38. SWITCH_ATTR_CPU_PORT,
  39. /* attributes */
  40. SWITCH_ATTR_OP_ID,
  41. SWITCH_ATTR_OP_TYPE,
  42. SWITCH_ATTR_OP_NAME,
  43. SWITCH_ATTR_OP_PORT,
  44. SWITCH_ATTR_OP_VLAN,
  45. SWITCH_ATTR_OP_VALUE_INT,
  46. SWITCH_ATTR_OP_VALUE_STR,
  47. SWITCH_ATTR_OP_VALUE_PORTS,
  48. SWITCH_ATTR_OP_VALUE_LINK,
  49. SWITCH_ATTR_OP_DESCRIPTION,
  50. /* port lists */
  51. SWITCH_ATTR_PORT,
  52. SWITCH_ATTR_MAX
  53. };
  54. enum {
  55. /* port map */
  56. SWITCH_PORTMAP_PORTS,
  57. SWITCH_PORTMAP_SEGMENT,
  58. SWITCH_PORTMAP_VIRT,
  59. SWITCH_PORTMAP_MAX
  60. };
  61. /* commands */
  62. enum {
  63. SWITCH_CMD_UNSPEC,
  64. SWITCH_CMD_GET_SWITCH,
  65. SWITCH_CMD_NEW_ATTR,
  66. SWITCH_CMD_LIST_GLOBAL,
  67. SWITCH_CMD_GET_GLOBAL,
  68. SWITCH_CMD_SET_GLOBAL,
  69. SWITCH_CMD_LIST_PORT,
  70. SWITCH_CMD_GET_PORT,
  71. SWITCH_CMD_SET_PORT,
  72. SWITCH_CMD_LIST_VLAN,
  73. SWITCH_CMD_GET_VLAN,
  74. SWITCH_CMD_SET_VLAN
  75. };
  76. /* data types */
  77. enum switch_val_type {
  78. SWITCH_TYPE_UNSPEC,
  79. SWITCH_TYPE_INT,
  80. SWITCH_TYPE_STRING,
  81. SWITCH_TYPE_PORTS,
  82. SWITCH_TYPE_LINK,
  83. SWITCH_TYPE_NOVAL,
  84. };
  85. /* port nested attributes */
  86. enum {
  87. SWITCH_PORT_UNSPEC,
  88. SWITCH_PORT_ID,
  89. SWITCH_PORT_FLAG_TAGGED,
  90. SWITCH_PORT_ATTR_MAX
  91. };
  92. /* link nested attributes */
  93. enum {
  94. SWITCH_LINK_UNSPEC,
  95. SWITCH_LINK_FLAG_LINK,
  96. SWITCH_LINK_FLAG_DUPLEX,
  97. SWITCH_LINK_FLAG_ANEG,
  98. SWITCH_LINK_FLAG_TX_FLOW,
  99. SWITCH_LINK_FLAG_RX_FLOW,
  100. SWITCH_LINK_SPEED,
  101. SWITCH_LINK_FLAG_EEE_100BASET,
  102. SWITCH_LINK_FLAG_EEE_1000BASET,
  103. SWITCH_LINK_ATTR_MAX,
  104. };
  105. #define SWITCH_ATTR_DEFAULTS_OFFSET 0x1000
  106. #endif /* _LINUX_SWITCH_H */