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