devlink.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * include/uapi/linux/devlink.h - Network physical device Netlink interface
  3. * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
  4. * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef _UAPI_LINUX_DEVLINK_H_
  12. #define _UAPI_LINUX_DEVLINK_H_
  13. #define DEVLINK_GENL_NAME "devlink"
  14. #define DEVLINK_GENL_VERSION 0x1
  15. #define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
  16. enum devlink_command {
  17. /* don't change the order or add anything between, this is ABI! */
  18. DEVLINK_CMD_UNSPEC,
  19. DEVLINK_CMD_GET, /* can dump */
  20. DEVLINK_CMD_SET,
  21. DEVLINK_CMD_NEW,
  22. DEVLINK_CMD_DEL,
  23. DEVLINK_CMD_PORT_GET, /* can dump */
  24. DEVLINK_CMD_PORT_SET,
  25. DEVLINK_CMD_PORT_NEW,
  26. DEVLINK_CMD_PORT_DEL,
  27. DEVLINK_CMD_PORT_SPLIT,
  28. DEVLINK_CMD_PORT_UNSPLIT,
  29. DEVLINK_CMD_SB_GET, /* can dump */
  30. DEVLINK_CMD_SB_SET,
  31. DEVLINK_CMD_SB_NEW,
  32. DEVLINK_CMD_SB_DEL,
  33. DEVLINK_CMD_SB_POOL_GET, /* can dump */
  34. DEVLINK_CMD_SB_POOL_SET,
  35. DEVLINK_CMD_SB_POOL_NEW,
  36. DEVLINK_CMD_SB_POOL_DEL,
  37. DEVLINK_CMD_SB_PORT_POOL_GET, /* can dump */
  38. DEVLINK_CMD_SB_PORT_POOL_SET,
  39. DEVLINK_CMD_SB_PORT_POOL_NEW,
  40. DEVLINK_CMD_SB_PORT_POOL_DEL,
  41. DEVLINK_CMD_SB_TC_POOL_BIND_GET, /* can dump */
  42. DEVLINK_CMD_SB_TC_POOL_BIND_SET,
  43. DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
  44. DEVLINK_CMD_SB_TC_POOL_BIND_DEL,
  45. /* Shared buffer occupancy monitoring commands */
  46. DEVLINK_CMD_SB_OCC_SNAPSHOT,
  47. DEVLINK_CMD_SB_OCC_MAX_CLEAR,
  48. DEVLINK_CMD_ESWITCH_MODE_GET,
  49. DEVLINK_CMD_ESWITCH_MODE_SET,
  50. /* add new commands above here */
  51. __DEVLINK_CMD_MAX,
  52. DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
  53. };
  54. enum devlink_port_type {
  55. DEVLINK_PORT_TYPE_NOTSET,
  56. DEVLINK_PORT_TYPE_AUTO,
  57. DEVLINK_PORT_TYPE_ETH,
  58. DEVLINK_PORT_TYPE_IB,
  59. };
  60. enum devlink_sb_pool_type {
  61. DEVLINK_SB_POOL_TYPE_INGRESS,
  62. DEVLINK_SB_POOL_TYPE_EGRESS,
  63. };
  64. /* static threshold - limiting the maximum number of bytes.
  65. * dynamic threshold - limiting the maximum number of bytes
  66. * based on the currently available free space in the shared buffer pool.
  67. * In this mode, the maximum quota is calculated based
  68. * on the following formula:
  69. * max_quota = alpha / (1 + alpha) * Free_Buffer
  70. * While Free_Buffer is the amount of none-occupied buffer associated to
  71. * the relevant pool.
  72. * The value range which can be passed is 0-20 and serves
  73. * for computation of alpha by following formula:
  74. * alpha = 2 ^ (passed_value - 10)
  75. */
  76. enum devlink_sb_threshold_type {
  77. DEVLINK_SB_THRESHOLD_TYPE_STATIC,
  78. DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC,
  79. };
  80. #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
  81. enum devlink_eswitch_mode {
  82. DEVLINK_ESWITCH_MODE_LEGACY,
  83. DEVLINK_ESWITCH_MODE_SWITCHDEV,
  84. };
  85. enum devlink_attr {
  86. /* don't change the order or add anything between, this is ABI! */
  87. DEVLINK_ATTR_UNSPEC,
  88. /* bus name + dev name together are a handle for devlink entity */
  89. DEVLINK_ATTR_BUS_NAME, /* string */
  90. DEVLINK_ATTR_DEV_NAME, /* string */
  91. DEVLINK_ATTR_PORT_INDEX, /* u32 */
  92. DEVLINK_ATTR_PORT_TYPE, /* u16 */
  93. DEVLINK_ATTR_PORT_DESIRED_TYPE, /* u16 */
  94. DEVLINK_ATTR_PORT_NETDEV_IFINDEX, /* u32 */
  95. DEVLINK_ATTR_PORT_NETDEV_NAME, /* string */
  96. DEVLINK_ATTR_PORT_IBDEV_NAME, /* string */
  97. DEVLINK_ATTR_PORT_SPLIT_COUNT, /* u32 */
  98. DEVLINK_ATTR_PORT_SPLIT_GROUP, /* u32 */
  99. DEVLINK_ATTR_SB_INDEX, /* u32 */
  100. DEVLINK_ATTR_SB_SIZE, /* u32 */
  101. DEVLINK_ATTR_SB_INGRESS_POOL_COUNT, /* u16 */
  102. DEVLINK_ATTR_SB_EGRESS_POOL_COUNT, /* u16 */
  103. DEVLINK_ATTR_SB_INGRESS_TC_COUNT, /* u16 */
  104. DEVLINK_ATTR_SB_EGRESS_TC_COUNT, /* u16 */
  105. DEVLINK_ATTR_SB_POOL_INDEX, /* u16 */
  106. DEVLINK_ATTR_SB_POOL_TYPE, /* u8 */
  107. DEVLINK_ATTR_SB_POOL_SIZE, /* u32 */
  108. DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE, /* u8 */
  109. DEVLINK_ATTR_SB_THRESHOLD, /* u32 */
  110. DEVLINK_ATTR_SB_TC_INDEX, /* u16 */
  111. DEVLINK_ATTR_SB_OCC_CUR, /* u32 */
  112. DEVLINK_ATTR_SB_OCC_MAX, /* u32 */
  113. DEVLINK_ATTR_ESWITCH_MODE, /* u16 */
  114. /* add new attributes above here, update the policy in devlink.c */
  115. __DEVLINK_ATTR_MAX,
  116. DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
  117. };
  118. #endif /* _UAPI_LINUX_DEVLINK_H_ */