devlink.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * include/uapi/linux/devlink.h - Network physical device Netlink interface
  4. * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
  5. * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #ifndef _UAPI_LINUX_DEVLINK_H_
  13. #define _UAPI_LINUX_DEVLINK_H_
  14. #define DEVLINK_GENL_NAME "devlink"
  15. #define DEVLINK_GENL_VERSION 0x1
  16. #define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
  17. enum devlink_command {
  18. /* don't change the order or add anything between, this is ABI! */
  19. DEVLINK_CMD_UNSPEC,
  20. DEVLINK_CMD_GET, /* can dump */
  21. DEVLINK_CMD_SET,
  22. DEVLINK_CMD_NEW,
  23. DEVLINK_CMD_DEL,
  24. DEVLINK_CMD_PORT_GET, /* can dump */
  25. DEVLINK_CMD_PORT_SET,
  26. DEVLINK_CMD_PORT_NEW,
  27. DEVLINK_CMD_PORT_DEL,
  28. DEVLINK_CMD_PORT_SPLIT,
  29. DEVLINK_CMD_PORT_UNSPLIT,
  30. DEVLINK_CMD_SB_GET, /* can dump */
  31. DEVLINK_CMD_SB_SET,
  32. DEVLINK_CMD_SB_NEW,
  33. DEVLINK_CMD_SB_DEL,
  34. DEVLINK_CMD_SB_POOL_GET, /* can dump */
  35. DEVLINK_CMD_SB_POOL_SET,
  36. DEVLINK_CMD_SB_POOL_NEW,
  37. DEVLINK_CMD_SB_POOL_DEL,
  38. DEVLINK_CMD_SB_PORT_POOL_GET, /* can dump */
  39. DEVLINK_CMD_SB_PORT_POOL_SET,
  40. DEVLINK_CMD_SB_PORT_POOL_NEW,
  41. DEVLINK_CMD_SB_PORT_POOL_DEL,
  42. DEVLINK_CMD_SB_TC_POOL_BIND_GET, /* can dump */
  43. DEVLINK_CMD_SB_TC_POOL_BIND_SET,
  44. DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
  45. DEVLINK_CMD_SB_TC_POOL_BIND_DEL,
  46. /* Shared buffer occupancy monitoring commands */
  47. DEVLINK_CMD_SB_OCC_SNAPSHOT,
  48. DEVLINK_CMD_SB_OCC_MAX_CLEAR,
  49. DEVLINK_CMD_ESWITCH_GET,
  50. #define DEVLINK_CMD_ESWITCH_MODE_GET /* obsolete, never use this! */ \
  51. DEVLINK_CMD_ESWITCH_GET
  52. DEVLINK_CMD_ESWITCH_SET,
  53. #define DEVLINK_CMD_ESWITCH_MODE_SET /* obsolete, never use this! */ \
  54. DEVLINK_CMD_ESWITCH_SET
  55. DEVLINK_CMD_DPIPE_TABLE_GET,
  56. DEVLINK_CMD_DPIPE_ENTRIES_GET,
  57. DEVLINK_CMD_DPIPE_HEADERS_GET,
  58. DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
  59. DEVLINK_CMD_RESOURCE_SET,
  60. DEVLINK_CMD_RESOURCE_DUMP,
  61. /* Hot driver reload, makes configuration changes take place. The
  62. * devlink instance is not released during the process.
  63. */
  64. DEVLINK_CMD_RELOAD,
  65. DEVLINK_CMD_PARAM_GET, /* can dump */
  66. DEVLINK_CMD_PARAM_SET,
  67. DEVLINK_CMD_PARAM_NEW,
  68. DEVLINK_CMD_PARAM_DEL,
  69. DEVLINK_CMD_REGION_GET,
  70. DEVLINK_CMD_REGION_SET,
  71. DEVLINK_CMD_REGION_NEW,
  72. DEVLINK_CMD_REGION_DEL,
  73. DEVLINK_CMD_REGION_READ,
  74. /* add new commands above here */
  75. __DEVLINK_CMD_MAX,
  76. DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
  77. };
  78. enum devlink_port_type {
  79. DEVLINK_PORT_TYPE_NOTSET,
  80. DEVLINK_PORT_TYPE_AUTO,
  81. DEVLINK_PORT_TYPE_ETH,
  82. DEVLINK_PORT_TYPE_IB,
  83. };
  84. enum devlink_sb_pool_type {
  85. DEVLINK_SB_POOL_TYPE_INGRESS,
  86. DEVLINK_SB_POOL_TYPE_EGRESS,
  87. };
  88. /* static threshold - limiting the maximum number of bytes.
  89. * dynamic threshold - limiting the maximum number of bytes
  90. * based on the currently available free space in the shared buffer pool.
  91. * In this mode, the maximum quota is calculated based
  92. * on the following formula:
  93. * max_quota = alpha / (1 + alpha) * Free_Buffer
  94. * While Free_Buffer is the amount of none-occupied buffer associated to
  95. * the relevant pool.
  96. * The value range which can be passed is 0-20 and serves
  97. * for computation of alpha by following formula:
  98. * alpha = 2 ^ (passed_value - 10)
  99. */
  100. enum devlink_sb_threshold_type {
  101. DEVLINK_SB_THRESHOLD_TYPE_STATIC,
  102. DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC,
  103. };
  104. #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
  105. enum devlink_eswitch_mode {
  106. DEVLINK_ESWITCH_MODE_LEGACY,
  107. DEVLINK_ESWITCH_MODE_SWITCHDEV,
  108. };
  109. enum devlink_eswitch_inline_mode {
  110. DEVLINK_ESWITCH_INLINE_MODE_NONE,
  111. DEVLINK_ESWITCH_INLINE_MODE_LINK,
  112. DEVLINK_ESWITCH_INLINE_MODE_NETWORK,
  113. DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT,
  114. };
  115. enum devlink_eswitch_encap_mode {
  116. DEVLINK_ESWITCH_ENCAP_MODE_NONE,
  117. DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
  118. };
  119. enum devlink_port_flavour {
  120. DEVLINK_PORT_FLAVOUR_PHYSICAL, /* Any kind of a port physically
  121. * facing the user.
  122. */
  123. DEVLINK_PORT_FLAVOUR_CPU, /* CPU port */
  124. DEVLINK_PORT_FLAVOUR_DSA, /* Distributed switch architecture
  125. * interconnect port.
  126. */
  127. };
  128. enum devlink_param_cmode {
  129. DEVLINK_PARAM_CMODE_RUNTIME,
  130. DEVLINK_PARAM_CMODE_DRIVERINIT,
  131. DEVLINK_PARAM_CMODE_PERMANENT,
  132. /* Add new configuration modes above */
  133. __DEVLINK_PARAM_CMODE_MAX,
  134. DEVLINK_PARAM_CMODE_MAX = __DEVLINK_PARAM_CMODE_MAX - 1
  135. };
  136. enum devlink_attr {
  137. /* don't change the order or add anything between, this is ABI! */
  138. DEVLINK_ATTR_UNSPEC,
  139. /* bus name + dev name together are a handle for devlink entity */
  140. DEVLINK_ATTR_BUS_NAME, /* string */
  141. DEVLINK_ATTR_DEV_NAME, /* string */
  142. DEVLINK_ATTR_PORT_INDEX, /* u32 */
  143. DEVLINK_ATTR_PORT_TYPE, /* u16 */
  144. DEVLINK_ATTR_PORT_DESIRED_TYPE, /* u16 */
  145. DEVLINK_ATTR_PORT_NETDEV_IFINDEX, /* u32 */
  146. DEVLINK_ATTR_PORT_NETDEV_NAME, /* string */
  147. DEVLINK_ATTR_PORT_IBDEV_NAME, /* string */
  148. DEVLINK_ATTR_PORT_SPLIT_COUNT, /* u32 */
  149. DEVLINK_ATTR_PORT_SPLIT_GROUP, /* u32 */
  150. DEVLINK_ATTR_SB_INDEX, /* u32 */
  151. DEVLINK_ATTR_SB_SIZE, /* u32 */
  152. DEVLINK_ATTR_SB_INGRESS_POOL_COUNT, /* u16 */
  153. DEVLINK_ATTR_SB_EGRESS_POOL_COUNT, /* u16 */
  154. DEVLINK_ATTR_SB_INGRESS_TC_COUNT, /* u16 */
  155. DEVLINK_ATTR_SB_EGRESS_TC_COUNT, /* u16 */
  156. DEVLINK_ATTR_SB_POOL_INDEX, /* u16 */
  157. DEVLINK_ATTR_SB_POOL_TYPE, /* u8 */
  158. DEVLINK_ATTR_SB_POOL_SIZE, /* u32 */
  159. DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE, /* u8 */
  160. DEVLINK_ATTR_SB_THRESHOLD, /* u32 */
  161. DEVLINK_ATTR_SB_TC_INDEX, /* u16 */
  162. DEVLINK_ATTR_SB_OCC_CUR, /* u32 */
  163. DEVLINK_ATTR_SB_OCC_MAX, /* u32 */
  164. DEVLINK_ATTR_ESWITCH_MODE, /* u16 */
  165. DEVLINK_ATTR_ESWITCH_INLINE_MODE, /* u8 */
  166. DEVLINK_ATTR_DPIPE_TABLES, /* nested */
  167. DEVLINK_ATTR_DPIPE_TABLE, /* nested */
  168. DEVLINK_ATTR_DPIPE_TABLE_NAME, /* string */
  169. DEVLINK_ATTR_DPIPE_TABLE_SIZE, /* u64 */
  170. DEVLINK_ATTR_DPIPE_TABLE_MATCHES, /* nested */
  171. DEVLINK_ATTR_DPIPE_TABLE_ACTIONS, /* nested */
  172. DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED, /* u8 */
  173. DEVLINK_ATTR_DPIPE_ENTRIES, /* nested */
  174. DEVLINK_ATTR_DPIPE_ENTRY, /* nested */
  175. DEVLINK_ATTR_DPIPE_ENTRY_INDEX, /* u64 */
  176. DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES, /* nested */
  177. DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES, /* nested */
  178. DEVLINK_ATTR_DPIPE_ENTRY_COUNTER, /* u64 */
  179. DEVLINK_ATTR_DPIPE_MATCH, /* nested */
  180. DEVLINK_ATTR_DPIPE_MATCH_VALUE, /* nested */
  181. DEVLINK_ATTR_DPIPE_MATCH_TYPE, /* u32 */
  182. DEVLINK_ATTR_DPIPE_ACTION, /* nested */
  183. DEVLINK_ATTR_DPIPE_ACTION_VALUE, /* nested */
  184. DEVLINK_ATTR_DPIPE_ACTION_TYPE, /* u32 */
  185. DEVLINK_ATTR_DPIPE_VALUE,
  186. DEVLINK_ATTR_DPIPE_VALUE_MASK,
  187. DEVLINK_ATTR_DPIPE_VALUE_MAPPING, /* u32 */
  188. DEVLINK_ATTR_DPIPE_HEADERS, /* nested */
  189. DEVLINK_ATTR_DPIPE_HEADER, /* nested */
  190. DEVLINK_ATTR_DPIPE_HEADER_NAME, /* string */
  191. DEVLINK_ATTR_DPIPE_HEADER_ID, /* u32 */
  192. DEVLINK_ATTR_DPIPE_HEADER_FIELDS, /* nested */
  193. DEVLINK_ATTR_DPIPE_HEADER_GLOBAL, /* u8 */
  194. DEVLINK_ATTR_DPIPE_HEADER_INDEX, /* u32 */
  195. DEVLINK_ATTR_DPIPE_FIELD, /* nested */
  196. DEVLINK_ATTR_DPIPE_FIELD_NAME, /* string */
  197. DEVLINK_ATTR_DPIPE_FIELD_ID, /* u32 */
  198. DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH, /* u32 */
  199. DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE, /* u32 */
  200. DEVLINK_ATTR_PAD,
  201. DEVLINK_ATTR_ESWITCH_ENCAP_MODE, /* u8 */
  202. DEVLINK_ATTR_RESOURCE_LIST, /* nested */
  203. DEVLINK_ATTR_RESOURCE, /* nested */
  204. DEVLINK_ATTR_RESOURCE_NAME, /* string */
  205. DEVLINK_ATTR_RESOURCE_ID, /* u64 */
  206. DEVLINK_ATTR_RESOURCE_SIZE, /* u64 */
  207. DEVLINK_ATTR_RESOURCE_SIZE_NEW, /* u64 */
  208. DEVLINK_ATTR_RESOURCE_SIZE_VALID, /* u8 */
  209. DEVLINK_ATTR_RESOURCE_SIZE_MIN, /* u64 */
  210. DEVLINK_ATTR_RESOURCE_SIZE_MAX, /* u64 */
  211. DEVLINK_ATTR_RESOURCE_SIZE_GRAN, /* u64 */
  212. DEVLINK_ATTR_RESOURCE_UNIT, /* u8 */
  213. DEVLINK_ATTR_RESOURCE_OCC, /* u64 */
  214. DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID, /* u64 */
  215. DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,/* u64 */
  216. DEVLINK_ATTR_PORT_FLAVOUR, /* u16 */
  217. DEVLINK_ATTR_PORT_NUMBER, /* u32 */
  218. DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER, /* u32 */
  219. DEVLINK_ATTR_PARAM, /* nested */
  220. DEVLINK_ATTR_PARAM_NAME, /* string */
  221. DEVLINK_ATTR_PARAM_GENERIC, /* flag */
  222. DEVLINK_ATTR_PARAM_TYPE, /* u8 */
  223. DEVLINK_ATTR_PARAM_VALUES_LIST, /* nested */
  224. DEVLINK_ATTR_PARAM_VALUE, /* nested */
  225. DEVLINK_ATTR_PARAM_VALUE_DATA, /* dynamic */
  226. DEVLINK_ATTR_PARAM_VALUE_CMODE, /* u8 */
  227. DEVLINK_ATTR_REGION_NAME, /* string */
  228. DEVLINK_ATTR_REGION_SIZE, /* u64 */
  229. DEVLINK_ATTR_REGION_SNAPSHOTS, /* nested */
  230. DEVLINK_ATTR_REGION_SNAPSHOT, /* nested */
  231. DEVLINK_ATTR_REGION_SNAPSHOT_ID, /* u32 */
  232. DEVLINK_ATTR_REGION_CHUNKS, /* nested */
  233. DEVLINK_ATTR_REGION_CHUNK, /* nested */
  234. DEVLINK_ATTR_REGION_CHUNK_DATA, /* binary */
  235. DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */
  236. DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */
  237. /* add new attributes above here, update the policy in devlink.c */
  238. __DEVLINK_ATTR_MAX,
  239. DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
  240. };
  241. /* Mapping between internal resource described by the field and system
  242. * structure
  243. */
  244. enum devlink_dpipe_field_mapping_type {
  245. DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE,
  246. DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX,
  247. };
  248. /* Match type - specify the type of the match */
  249. enum devlink_dpipe_match_type {
  250. DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT,
  251. };
  252. /* Action type - specify the action type */
  253. enum devlink_dpipe_action_type {
  254. DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY,
  255. };
  256. enum devlink_dpipe_field_ethernet_id {
  257. DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC,
  258. };
  259. enum devlink_dpipe_field_ipv4_id {
  260. DEVLINK_DPIPE_FIELD_IPV4_DST_IP,
  261. };
  262. enum devlink_dpipe_field_ipv6_id {
  263. DEVLINK_DPIPE_FIELD_IPV6_DST_IP,
  264. };
  265. enum devlink_dpipe_header_id {
  266. DEVLINK_DPIPE_HEADER_ETHERNET,
  267. DEVLINK_DPIPE_HEADER_IPV4,
  268. DEVLINK_DPIPE_HEADER_IPV6,
  269. };
  270. enum devlink_resource_unit {
  271. DEVLINK_RESOURCE_UNIT_ENTRY,
  272. };
  273. #endif /* _UAPI_LINUX_DEVLINK_H_ */