net_dropmon.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef __NET_DROPMON_H
  3. #define __NET_DROPMON_H
  4. #include <linux/types.h>
  5. #include <linux/netlink.h>
  6. struct net_dm_drop_point {
  7. __u8 pc[8];
  8. __u32 count;
  9. };
  10. #define is_drop_point_hw(x) do {\
  11. int ____i, ____j;\
  12. for (____i = 0; ____i < 8; i ____i++)\
  13. ____j |= x[____i];\
  14. ____j;\
  15. } while (0)
  16. #define NET_DM_CFG_VERSION 0
  17. #define NET_DM_CFG_ALERT_COUNT 1
  18. #define NET_DM_CFG_ALERT_DELAY 2
  19. #define NET_DM_CFG_MAX 3
  20. struct net_dm_config_entry {
  21. __u32 type;
  22. __u64 data __attribute__((aligned(8)));
  23. };
  24. struct net_dm_config_msg {
  25. __u32 entries;
  26. struct net_dm_config_entry options[];
  27. };
  28. struct net_dm_alert_msg {
  29. __u32 entries;
  30. struct net_dm_drop_point points[];
  31. };
  32. struct net_dm_user_msg {
  33. union {
  34. struct net_dm_config_msg user;
  35. struct net_dm_alert_msg alert;
  36. } u;
  37. };
  38. /* These are the netlink message types for this protocol */
  39. enum {
  40. NET_DM_CMD_UNSPEC = 0,
  41. NET_DM_CMD_ALERT,
  42. NET_DM_CMD_CONFIG,
  43. NET_DM_CMD_START,
  44. NET_DM_CMD_STOP,
  45. NET_DM_CMD_PACKET_ALERT,
  46. NET_DM_CMD_CONFIG_GET,
  47. NET_DM_CMD_CONFIG_NEW,
  48. NET_DM_CMD_STATS_GET,
  49. NET_DM_CMD_STATS_NEW,
  50. _NET_DM_CMD_MAX,
  51. };
  52. #define NET_DM_CMD_MAX (_NET_DM_CMD_MAX - 1)
  53. /*
  54. * Our group identifiers
  55. */
  56. #define NET_DM_GRP_ALERT 1
  57. enum net_dm_attr {
  58. NET_DM_ATTR_UNSPEC,
  59. NET_DM_ATTR_ALERT_MODE, /* u8 */
  60. NET_DM_ATTR_PC, /* u64 */
  61. NET_DM_ATTR_SYMBOL, /* string */
  62. NET_DM_ATTR_IN_PORT, /* nested */
  63. NET_DM_ATTR_TIMESTAMP, /* u64 */
  64. NET_DM_ATTR_PROTO, /* u16 */
  65. NET_DM_ATTR_PAYLOAD, /* binary */
  66. NET_DM_ATTR_PAD,
  67. NET_DM_ATTR_TRUNC_LEN, /* u32 */
  68. NET_DM_ATTR_ORIG_LEN, /* u32 */
  69. NET_DM_ATTR_QUEUE_LEN, /* u32 */
  70. NET_DM_ATTR_STATS, /* nested */
  71. NET_DM_ATTR_HW_STATS, /* nested */
  72. NET_DM_ATTR_ORIGIN, /* u16 */
  73. NET_DM_ATTR_HW_TRAP_GROUP_NAME, /* string */
  74. NET_DM_ATTR_HW_TRAP_NAME, /* string */
  75. NET_DM_ATTR_HW_ENTRIES, /* nested */
  76. NET_DM_ATTR_HW_ENTRY, /* nested */
  77. NET_DM_ATTR_HW_TRAP_COUNT, /* u32 */
  78. NET_DM_ATTR_SW_DROPS, /* flag */
  79. NET_DM_ATTR_HW_DROPS, /* flag */
  80. NET_DM_ATTR_FLOW_ACTION_COOKIE, /* binary */
  81. NET_DM_ATTR_REASON, /* string */
  82. __NET_DM_ATTR_MAX,
  83. NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1
  84. };
  85. /**
  86. * enum net_dm_alert_mode - Alert mode.
  87. * @NET_DM_ALERT_MODE_SUMMARY: A summary of recent drops is sent to user space.
  88. * @NET_DM_ALERT_MODE_PACKET: Each dropped packet is sent to user space along
  89. * with metadata.
  90. */
  91. enum net_dm_alert_mode {
  92. NET_DM_ALERT_MODE_SUMMARY,
  93. NET_DM_ALERT_MODE_PACKET,
  94. };
  95. enum {
  96. NET_DM_ATTR_PORT_NETDEV_IFINDEX, /* u32 */
  97. NET_DM_ATTR_PORT_NETDEV_NAME, /* string */
  98. __NET_DM_ATTR_PORT_MAX,
  99. NET_DM_ATTR_PORT_MAX = __NET_DM_ATTR_PORT_MAX - 1
  100. };
  101. enum {
  102. NET_DM_ATTR_STATS_DROPPED, /* u64 */
  103. __NET_DM_ATTR_STATS_MAX,
  104. NET_DM_ATTR_STATS_MAX = __NET_DM_ATTR_STATS_MAX - 1
  105. };
  106. enum net_dm_origin {
  107. NET_DM_ORIGIN_SW,
  108. NET_DM_ORIGIN_HW,
  109. };
  110. #endif