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