Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef __NET_DROPMON_H
0003 #define __NET_DROPMON_H
0004 
0005 #include <linux/types.h>
0006 #include <linux/netlink.h>
0007 
0008 struct net_dm_drop_point {
0009     __u8 pc[8];
0010     __u32 count;
0011 };
0012 
0013 #define is_drop_point_hw(x) do {\
0014     int ____i, ____j;\
0015     for (____i = 0; ____i < 8; i ____i++)\
0016         ____j |= x[____i];\
0017     ____j;\
0018 } while (0)
0019 
0020 #define NET_DM_CFG_VERSION  0
0021 #define NET_DM_CFG_ALERT_COUNT  1
0022 #define NET_DM_CFG_ALERT_DELAY 2
0023 #define NET_DM_CFG_MAX 3
0024 
0025 struct net_dm_config_entry {
0026     __u32 type;
0027     __u64 data __attribute__((aligned(8)));
0028 };
0029 
0030 struct net_dm_config_msg {
0031     __u32 entries;
0032     struct net_dm_config_entry options[];
0033 };
0034 
0035 struct net_dm_alert_msg {
0036     __u32 entries;
0037     struct net_dm_drop_point points[];
0038 };
0039 
0040 struct net_dm_user_msg {
0041     union {
0042         struct net_dm_config_msg user;
0043         struct net_dm_alert_msg alert;
0044     } u;
0045 };
0046 
0047 
0048 /* These are the netlink message types for this protocol */
0049 
0050 enum {
0051     NET_DM_CMD_UNSPEC = 0,
0052     NET_DM_CMD_ALERT,
0053     NET_DM_CMD_CONFIG,
0054     NET_DM_CMD_START,
0055     NET_DM_CMD_STOP,
0056     NET_DM_CMD_PACKET_ALERT,
0057     NET_DM_CMD_CONFIG_GET,
0058     NET_DM_CMD_CONFIG_NEW,
0059     NET_DM_CMD_STATS_GET,
0060     NET_DM_CMD_STATS_NEW,
0061     _NET_DM_CMD_MAX,
0062 };
0063 
0064 #define NET_DM_CMD_MAX (_NET_DM_CMD_MAX - 1)
0065 
0066 /*
0067  * Our group identifiers
0068  */
0069 #define NET_DM_GRP_ALERT 1
0070 
0071 enum net_dm_attr {
0072     NET_DM_ATTR_UNSPEC,
0073 
0074     NET_DM_ATTR_ALERT_MODE,         /* u8 */
0075     NET_DM_ATTR_PC,             /* u64 */
0076     NET_DM_ATTR_SYMBOL,         /* string */
0077     NET_DM_ATTR_IN_PORT,            /* nested */
0078     NET_DM_ATTR_TIMESTAMP,          /* u64 */
0079     NET_DM_ATTR_PROTO,          /* u16 */
0080     NET_DM_ATTR_PAYLOAD,            /* binary */
0081     NET_DM_ATTR_PAD,
0082     NET_DM_ATTR_TRUNC_LEN,          /* u32 */
0083     NET_DM_ATTR_ORIG_LEN,           /* u32 */
0084     NET_DM_ATTR_QUEUE_LEN,          /* u32 */
0085     NET_DM_ATTR_STATS,          /* nested */
0086     NET_DM_ATTR_HW_STATS,           /* nested */
0087     NET_DM_ATTR_ORIGIN,         /* u16 */
0088     NET_DM_ATTR_HW_TRAP_GROUP_NAME,     /* string */
0089     NET_DM_ATTR_HW_TRAP_NAME,       /* string */
0090     NET_DM_ATTR_HW_ENTRIES,         /* nested */
0091     NET_DM_ATTR_HW_ENTRY,           /* nested */
0092     NET_DM_ATTR_HW_TRAP_COUNT,      /* u32 */
0093     NET_DM_ATTR_SW_DROPS,           /* flag */
0094     NET_DM_ATTR_HW_DROPS,           /* flag */
0095     NET_DM_ATTR_FLOW_ACTION_COOKIE,     /* binary */
0096     NET_DM_ATTR_REASON,         /* string */
0097 
0098     __NET_DM_ATTR_MAX,
0099     NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1
0100 };
0101 
0102 /**
0103  * enum net_dm_alert_mode - Alert mode.
0104  * @NET_DM_ALERT_MODE_SUMMARY: A summary of recent drops is sent to user space.
0105  * @NET_DM_ALERT_MODE_PACKET: Each dropped packet is sent to user space along
0106  *                            with metadata.
0107  */
0108 enum net_dm_alert_mode {
0109     NET_DM_ALERT_MODE_SUMMARY,
0110     NET_DM_ALERT_MODE_PACKET,
0111 };
0112 
0113 enum {
0114     NET_DM_ATTR_PORT_NETDEV_IFINDEX,    /* u32 */
0115     NET_DM_ATTR_PORT_NETDEV_NAME,       /* string */
0116 
0117     __NET_DM_ATTR_PORT_MAX,
0118     NET_DM_ATTR_PORT_MAX = __NET_DM_ATTR_PORT_MAX - 1
0119 };
0120 
0121 enum {
0122     NET_DM_ATTR_STATS_DROPPED,      /* u64 */
0123 
0124     __NET_DM_ATTR_STATS_MAX,
0125     NET_DM_ATTR_STATS_MAX = __NET_DM_ATTR_STATS_MAX - 1
0126 };
0127 
0128 enum net_dm_origin {
0129     NET_DM_ORIGIN_SW,
0130     NET_DM_ORIGIN_HW,
0131 };
0132 
0133 #endif