xref: /linux-6.15/include/uapi/linux/openvswitch.h (revision 06bd2bdf)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
222e3880aSThomas Graf 
322e3880aSThomas Graf /*
49dd7f890SJarno Rajahalme  * Copyright (c) 2007-2017 Nicira, Inc.
522e3880aSThomas Graf  *
622e3880aSThomas Graf  * This program is free software; you can redistribute it and/or
722e3880aSThomas Graf  * modify it under the terms of version 2 of the GNU General Public
822e3880aSThomas Graf  * License as published by the Free Software Foundation.
922e3880aSThomas Graf  *
1022e3880aSThomas Graf  * This program is distributed in the hope that it will be useful, but
1122e3880aSThomas Graf  * WITHOUT ANY WARRANTY; without even the implied warranty of
1222e3880aSThomas Graf  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1322e3880aSThomas Graf  * General Public License for more details.
1422e3880aSThomas Graf  *
1522e3880aSThomas Graf  * You should have received a copy of the GNU General Public License
1622e3880aSThomas Graf  * along with this program; if not, write to the Free Software
1722e3880aSThomas Graf  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1822e3880aSThomas Graf  * 02110-1301, USA
1922e3880aSThomas Graf  */
2022e3880aSThomas Graf 
2122e3880aSThomas Graf #ifndef _UAPI__LINUX_OPENVSWITCH_H
2222e3880aSThomas Graf #define _UAPI__LINUX_OPENVSWITCH_H 1
2322e3880aSThomas Graf 
2422e3880aSThomas Graf #include <linux/types.h>
2522e3880aSThomas Graf #include <linux/if_ether.h>
2622e3880aSThomas Graf 
2722e3880aSThomas Graf /**
2822e3880aSThomas Graf  * struct ovs_header - header for OVS Generic Netlink messages.
2922e3880aSThomas Graf  * @dp_ifindex: ifindex of local port for datapath (0 to make a request not
3022e3880aSThomas Graf  * specific to a datapath).
3122e3880aSThomas Graf  *
3222e3880aSThomas Graf  * Attributes following the header are specific to a particular OVS Generic
3322e3880aSThomas Graf  * Netlink family, but all of the OVS families use this header.
3422e3880aSThomas Graf  */
3522e3880aSThomas Graf 
3622e3880aSThomas Graf struct ovs_header {
3722e3880aSThomas Graf 	int dp_ifindex;
3822e3880aSThomas Graf };
3922e3880aSThomas Graf 
4022e3880aSThomas Graf /* Datapaths. */
4122e3880aSThomas Graf 
4222e3880aSThomas Graf #define OVS_DATAPATH_FAMILY  "ovs_datapath"
4322e3880aSThomas Graf #define OVS_DATAPATH_MCGROUP "ovs_datapath"
4444da5ae5SThomas Graf 
4544da5ae5SThomas Graf /* V2:
4644da5ae5SThomas Graf  *   - API users are expected to provide OVS_DP_ATTR_USER_FEATURES
4744da5ae5SThomas Graf  *     when creating the datapath.
4844da5ae5SThomas Graf  */
4944da5ae5SThomas Graf #define OVS_DATAPATH_VERSION 2
5044da5ae5SThomas Graf 
5144da5ae5SThomas Graf /* First OVS datapath version to support features */
5244da5ae5SThomas Graf #define OVS_DP_VER_FEATURES 2
5322e3880aSThomas Graf 
5422e3880aSThomas Graf enum ovs_datapath_cmd {
5522e3880aSThomas Graf 	OVS_DP_CMD_UNSPEC,
5622e3880aSThomas Graf 	OVS_DP_CMD_NEW,
5722e3880aSThomas Graf 	OVS_DP_CMD_DEL,
5822e3880aSThomas Graf 	OVS_DP_CMD_GET,
5922e3880aSThomas Graf 	OVS_DP_CMD_SET
6022e3880aSThomas Graf };
6122e3880aSThomas Graf 
6222e3880aSThomas Graf /**
6322e3880aSThomas Graf  * enum ovs_datapath_attr - attributes for %OVS_DP_* commands.
6422e3880aSThomas Graf  * @OVS_DP_ATTR_NAME: Name of the network device that serves as the "local
6522e3880aSThomas Graf  * port".  This is the name of the network device whose dp_ifindex is given in
6622e3880aSThomas Graf  * the &struct ovs_header.  Always present in notifications.  Required in
6722e3880aSThomas Graf  * %OVS_DP_NEW requests.  May be used as an alternative to specifying
6822e3880aSThomas Graf  * dp_ifindex in other requests (with a dp_ifindex of 0).
6922e3880aSThomas Graf  * @OVS_DP_ATTR_UPCALL_PID: The Netlink socket in userspace that is initially
7022e3880aSThomas Graf  * set on the datapath port (for OVS_ACTION_ATTR_MISS).  Only valid on
7122e3880aSThomas Graf  * %OVS_DP_CMD_NEW requests. A value of zero indicates that upcalls should
7222e3880aSThomas Graf  * not be sent.
7322e3880aSThomas Graf  * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the
7422e3880aSThomas Graf  * datapath.  Always present in notifications.
751bd7116fSAndy Zhou  * @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the
761bd7116fSAndy Zhou  * datapath. Always present in notifications.
7722e3880aSThomas Graf  *
7822e3880aSThomas Graf  * These attributes follow the &struct ovs_header within the Generic Netlink
7922e3880aSThomas Graf  * payload for %OVS_DP_* commands.
8022e3880aSThomas Graf  */
8122e3880aSThomas Graf enum ovs_datapath_attr {
8222e3880aSThomas Graf 	OVS_DP_ATTR_UNSPEC,
8322e3880aSThomas Graf 	OVS_DP_ATTR_NAME,		/* name of dp_ifindex netdev */
8422e3880aSThomas Graf 	OVS_DP_ATTR_UPCALL_PID,		/* Netlink PID to receive upcalls */
8522e3880aSThomas Graf 	OVS_DP_ATTR_STATS,		/* struct ovs_dp_stats */
861bd7116fSAndy Zhou 	OVS_DP_ATTR_MEGAFLOW_STATS,	/* struct ovs_dp_megaflow_stats */
8743d4be9cSThomas Graf 	OVS_DP_ATTR_USER_FEATURES,	/* OVS_DP_F_*  */
8866c7a5eeSNicolas Dichtel 	OVS_DP_ATTR_PAD,
8922e3880aSThomas Graf 	__OVS_DP_ATTR_MAX
9022e3880aSThomas Graf };
9122e3880aSThomas Graf 
9222e3880aSThomas Graf #define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1)
9322e3880aSThomas Graf 
9422e3880aSThomas Graf struct ovs_dp_stats {
9522e3880aSThomas Graf 	__u64 n_hit;             /* Number of flow table matches. */
9622e3880aSThomas Graf 	__u64 n_missed;          /* Number of flow table misses. */
9722e3880aSThomas Graf 	__u64 n_lost;            /* Number of misses not sent to userspace. */
9822e3880aSThomas Graf 	__u64 n_flows;           /* Number of flows present */
9922e3880aSThomas Graf };
10022e3880aSThomas Graf 
1011bd7116fSAndy Zhou struct ovs_dp_megaflow_stats {
1021bd7116fSAndy Zhou 	__u64 n_mask_hit;	 /* Number of masks used for flow lookups. */
1031bd7116fSAndy Zhou 	__u32 n_masks;		 /* Number of masks for the datapath. */
1041bd7116fSAndy Zhou 	__u32 pad0;		 /* Pad for future expension. */
1051bd7116fSAndy Zhou 	__u64 pad1;		 /* Pad for future expension. */
1061bd7116fSAndy Zhou 	__u64 pad2;		 /* Pad for future expension. */
1071bd7116fSAndy Zhou };
1081bd7116fSAndy Zhou 
10922e3880aSThomas Graf struct ovs_vport_stats {
11022e3880aSThomas Graf 	__u64   rx_packets;		/* total packets received       */
11122e3880aSThomas Graf 	__u64   tx_packets;		/* total packets transmitted    */
11222e3880aSThomas Graf 	__u64   rx_bytes;		/* total bytes received         */
11322e3880aSThomas Graf 	__u64   tx_bytes;		/* total bytes transmitted      */
11422e3880aSThomas Graf 	__u64   rx_errors;		/* bad packets received         */
11522e3880aSThomas Graf 	__u64   tx_errors;		/* packet transmit problems     */
11622e3880aSThomas Graf 	__u64   rx_dropped;		/* no space in linux buffers    */
11722e3880aSThomas Graf 	__u64   tx_dropped;		/* no space available in linux  */
11822e3880aSThomas Graf };
11922e3880aSThomas Graf 
12043d4be9cSThomas Graf /* Allow last Netlink attribute to be unaligned */
12143d4be9cSThomas Graf #define OVS_DP_F_UNALIGNED	(1 << 0)
12243d4be9cSThomas Graf 
1235cd667b0SAlex Wang /* Allow datapath to associate multiple Netlink PIDs to each vport */
1245cd667b0SAlex Wang #define OVS_DP_F_VPORT_PIDS	(1 << 1)
1255cd667b0SAlex Wang 
12622e3880aSThomas Graf /* Fixed logical ports. */
12722e3880aSThomas Graf #define OVSP_LOCAL      ((__u32)0)
12822e3880aSThomas Graf 
12922e3880aSThomas Graf /* Packet transfer. */
13022e3880aSThomas Graf 
13122e3880aSThomas Graf #define OVS_PACKET_FAMILY "ovs_packet"
13222e3880aSThomas Graf #define OVS_PACKET_VERSION 0x1
13322e3880aSThomas Graf 
13422e3880aSThomas Graf enum ovs_packet_cmd {
13522e3880aSThomas Graf 	OVS_PACKET_CMD_UNSPEC,
13622e3880aSThomas Graf 
13722e3880aSThomas Graf 	/* Kernel-to-user notifications. */
13822e3880aSThomas Graf 	OVS_PACKET_CMD_MISS,    /* Flow table miss. */
13922e3880aSThomas Graf 	OVS_PACKET_CMD_ACTION,  /* OVS_ACTION_ATTR_USERSPACE action. */
14022e3880aSThomas Graf 
14122e3880aSThomas Graf 	/* Userspace commands. */
14222e3880aSThomas Graf 	OVS_PACKET_CMD_EXECUTE  /* Apply actions to a packet. */
14322e3880aSThomas Graf };
14422e3880aSThomas Graf 
14522e3880aSThomas Graf /**
14622e3880aSThomas Graf  * enum ovs_packet_attr - attributes for %OVS_PACKET_* commands.
14722e3880aSThomas Graf  * @OVS_PACKET_ATTR_PACKET: Present for all notifications.  Contains the entire
14822e3880aSThomas Graf  * packet as received, from the start of the Ethernet header onward.  For
14922e3880aSThomas Graf  * %OVS_PACKET_CMD_ACTION, %OVS_PACKET_ATTR_PACKET reflects changes made by
15022e3880aSThomas Graf  * actions preceding %OVS_ACTION_ATTR_USERSPACE, but %OVS_PACKET_ATTR_KEY is
15122e3880aSThomas Graf  * the flow key extracted from the packet as originally received.
15222e3880aSThomas Graf  * @OVS_PACKET_ATTR_KEY: Present for all notifications.  Contains the flow key
15322e3880aSThomas Graf  * extracted from the packet as nested %OVS_KEY_ATTR_* attributes.  This allows
15422e3880aSThomas Graf  * userspace to adapt its flow setup strategy by comparing its notion of the
15522e3880aSThomas Graf  * flow key against the kernel's.
15622e3880aSThomas Graf  * @OVS_PACKET_ATTR_ACTIONS: Contains actions for the packet.  Used
15722e3880aSThomas Graf  * for %OVS_PACKET_CMD_EXECUTE.  It has nested %OVS_ACTION_ATTR_* attributes.
158ccea7445SNeil McKee  * Also used in upcall when %OVS_ACTION_ATTR_USERSPACE has optional
159ccea7445SNeil McKee  * %OVS_USERSPACE_ATTR_ACTIONS attribute.
16022e3880aSThomas Graf  * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION
16122e3880aSThomas Graf  * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
16222e3880aSThomas Graf  * %OVS_USERSPACE_ATTR_USERDATA attribute, with the same length and content
16322e3880aSThomas Graf  * specified there.
1648f0aad6fSWenyu Zhang  * @OVS_PACKET_ATTR_EGRESS_TUN_KEY: Present for an %OVS_PACKET_CMD_ACTION
1658f0aad6fSWenyu Zhang  * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
1668f0aad6fSWenyu Zhang  * %OVS_USERSPACE_ATTR_EGRESS_TUN_PORT attribute, which is sent only if the
1678f0aad6fSWenyu Zhang  * output port is actually a tunnel port. Contains the output tunnel key
1688f0aad6fSWenyu Zhang  * extracted from the packet as nested %OVS_TUNNEL_KEY_ATTR_* attributes.
1697f8a436eSJoe Stringer  * @OVS_PACKET_ATTR_MRU: Present for an %OVS_PACKET_CMD_ACTION and
170b95e5928SWilliam Tu  * @OVS_PACKET_ATTR_LEN: Packet size before truncation.
1717f8a436eSJoe Stringer  * %OVS_PACKET_ATTR_USERSPACE action specify the Maximum received fragment
1727f8a436eSJoe Stringer  * size.
17322e3880aSThomas Graf  *
17422e3880aSThomas Graf  * These attributes follow the &struct ovs_header within the Generic Netlink
17522e3880aSThomas Graf  * payload for %OVS_PACKET_* commands.
17622e3880aSThomas Graf  */
17722e3880aSThomas Graf enum ovs_packet_attr {
17822e3880aSThomas Graf 	OVS_PACKET_ATTR_UNSPEC,
17922e3880aSThomas Graf 	OVS_PACKET_ATTR_PACKET,      /* Packet data. */
18022e3880aSThomas Graf 	OVS_PACKET_ATTR_KEY,         /* Nested OVS_KEY_ATTR_* attributes. */
18122e3880aSThomas Graf 	OVS_PACKET_ATTR_ACTIONS,     /* Nested OVS_ACTION_ATTR_* attributes. */
18222e3880aSThomas Graf 	OVS_PACKET_ATTR_USERDATA,    /* OVS_ACTION_ATTR_USERSPACE arg. */
1838f0aad6fSWenyu Zhang 	OVS_PACKET_ATTR_EGRESS_TUN_KEY,  /* Nested OVS_TUNNEL_KEY_ATTR_*
1848f0aad6fSWenyu Zhang 					    attributes. */
1851ba39804SThomas Graf 	OVS_PACKET_ATTR_UNUSED1,
1861ba39804SThomas Graf 	OVS_PACKET_ATTR_UNUSED2,
1871ba39804SThomas Graf 	OVS_PACKET_ATTR_PROBE,      /* Packet operation is a feature probe,
1881ba39804SThomas Graf 				       error logging should be suppressed. */
1897f8a436eSJoe Stringer 	OVS_PACKET_ATTR_MRU,	    /* Maximum received IP fragment size. */
190b95e5928SWilliam Tu 	OVS_PACKET_ATTR_LEN,		/* Packet size before truncation. */
19122e3880aSThomas Graf 	__OVS_PACKET_ATTR_MAX
19222e3880aSThomas Graf };
19322e3880aSThomas Graf 
19422e3880aSThomas Graf #define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1)
19522e3880aSThomas Graf 
19622e3880aSThomas Graf /* Virtual ports. */
19722e3880aSThomas Graf 
19822e3880aSThomas Graf #define OVS_VPORT_FAMILY  "ovs_vport"
19922e3880aSThomas Graf #define OVS_VPORT_MCGROUP "ovs_vport"
20022e3880aSThomas Graf #define OVS_VPORT_VERSION 0x1
20122e3880aSThomas Graf 
20222e3880aSThomas Graf enum ovs_vport_cmd {
20322e3880aSThomas Graf 	OVS_VPORT_CMD_UNSPEC,
20422e3880aSThomas Graf 	OVS_VPORT_CMD_NEW,
20522e3880aSThomas Graf 	OVS_VPORT_CMD_DEL,
20622e3880aSThomas Graf 	OVS_VPORT_CMD_GET,
20722e3880aSThomas Graf 	OVS_VPORT_CMD_SET
20822e3880aSThomas Graf };
20922e3880aSThomas Graf 
21022e3880aSThomas Graf enum ovs_vport_type {
21122e3880aSThomas Graf 	OVS_VPORT_TYPE_UNSPEC,
21222e3880aSThomas Graf 	OVS_VPORT_TYPE_NETDEV,   /* network device */
21322e3880aSThomas Graf 	OVS_VPORT_TYPE_INTERNAL, /* network device implemented by datapath */
214aa310701SPravin B Shelar 	OVS_VPORT_TYPE_GRE,      /* GRE tunnel. */
21558264848SPravin B Shelar 	OVS_VPORT_TYPE_VXLAN,	 /* VXLAN tunnel. */
216f5796684SJesse Gross 	OVS_VPORT_TYPE_GENEVE,	 /* Geneve tunnel. */
21722e3880aSThomas Graf 	__OVS_VPORT_TYPE_MAX
21822e3880aSThomas Graf };
21922e3880aSThomas Graf 
22022e3880aSThomas Graf #define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1)
22122e3880aSThomas Graf 
22222e3880aSThomas Graf /**
22322e3880aSThomas Graf  * enum ovs_vport_attr - attributes for %OVS_VPORT_* commands.
22422e3880aSThomas Graf  * @OVS_VPORT_ATTR_PORT_NO: 32-bit port number within datapath.
22522e3880aSThomas Graf  * @OVS_VPORT_ATTR_TYPE: 32-bit %OVS_VPORT_TYPE_* constant describing the type
22622e3880aSThomas Graf  * of vport.
22722e3880aSThomas Graf  * @OVS_VPORT_ATTR_NAME: Name of vport.  For a vport based on a network device
22822e3880aSThomas Graf  * this is the name of the network device.  Maximum length %IFNAMSIZ-1 bytes
22922e3880aSThomas Graf  * plus a null terminator.
23022e3880aSThomas Graf  * @OVS_VPORT_ATTR_OPTIONS: Vport-specific configuration information.
2315cd667b0SAlex Wang  * @OVS_VPORT_ATTR_UPCALL_PID: The array of Netlink socket pids in userspace
2325cd667b0SAlex Wang  * among which OVS_PACKET_CMD_MISS upcalls will be distributed for packets
2335cd667b0SAlex Wang  * received on this port.  If this is a single-element array of value 0,
2345cd667b0SAlex Wang  * upcalls should not be sent.
23522e3880aSThomas Graf  * @OVS_VPORT_ATTR_STATS: A &struct ovs_vport_stats giving statistics for
23622e3880aSThomas Graf  * packets sent or received through the vport.
23722e3880aSThomas Graf  *
23822e3880aSThomas Graf  * These attributes follow the &struct ovs_header within the Generic Netlink
23922e3880aSThomas Graf  * payload for %OVS_VPORT_* commands.
24022e3880aSThomas Graf  *
24122e3880aSThomas Graf  * For %OVS_VPORT_CMD_NEW requests, the %OVS_VPORT_ATTR_TYPE and
24222e3880aSThomas Graf  * %OVS_VPORT_ATTR_NAME attributes are required.  %OVS_VPORT_ATTR_PORT_NO is
24322e3880aSThomas Graf  * optional; if not specified a free port number is automatically selected.
24422e3880aSThomas Graf  * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type
24522e3880aSThomas Graf  * of vport.
24622e3880aSThomas Graf  *
24722e3880aSThomas Graf  * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to
24822e3880aSThomas Graf  * look up the vport to operate on; otherwise dp_idx from the &struct
24922e3880aSThomas Graf  * ovs_header plus %OVS_VPORT_ATTR_PORT_NO determine the vport.
25022e3880aSThomas Graf  */
25122e3880aSThomas Graf enum ovs_vport_attr {
25222e3880aSThomas Graf 	OVS_VPORT_ATTR_UNSPEC,
25322e3880aSThomas Graf 	OVS_VPORT_ATTR_PORT_NO,	/* u32 port number within datapath */
25422e3880aSThomas Graf 	OVS_VPORT_ATTR_TYPE,	/* u32 OVS_VPORT_TYPE_* constant. */
25522e3880aSThomas Graf 	OVS_VPORT_ATTR_NAME,	/* string name, up to IFNAMSIZ bytes long */
25622e3880aSThomas Graf 	OVS_VPORT_ATTR_OPTIONS, /* nested attributes, varies by vport type */
2575cd667b0SAlex Wang 	OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */
2585cd667b0SAlex Wang 				/* receiving upcalls */
25922e3880aSThomas Graf 	OVS_VPORT_ATTR_STATS,	/* struct ovs_vport_stats */
26066c7a5eeSNicolas Dichtel 	OVS_VPORT_ATTR_PAD,
2619354d452SJiri Benc 	OVS_VPORT_ATTR_IFINDEX,
2629354d452SJiri Benc 	OVS_VPORT_ATTR_NETNSID,
26322e3880aSThomas Graf 	__OVS_VPORT_ATTR_MAX
26422e3880aSThomas Graf };
26522e3880aSThomas Graf 
26622e3880aSThomas Graf #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1)
26722e3880aSThomas Graf 
2681dd144cfSThomas Graf enum {
2691dd144cfSThomas Graf 	OVS_VXLAN_EXT_UNSPEC,
2701dd144cfSThomas Graf 	OVS_VXLAN_EXT_GBP,	/* Flag or __u32 */
2711dd144cfSThomas Graf 	__OVS_VXLAN_EXT_MAX,
2721dd144cfSThomas Graf };
2731dd144cfSThomas Graf 
2741dd144cfSThomas Graf #define OVS_VXLAN_EXT_MAX (__OVS_VXLAN_EXT_MAX - 1)
2751dd144cfSThomas Graf 
2761dd144cfSThomas Graf 
27758264848SPravin B Shelar /* OVS_VPORT_ATTR_OPTIONS attributes for tunnels.
27858264848SPravin B Shelar  */
27958264848SPravin B Shelar enum {
28058264848SPravin B Shelar 	OVS_TUNNEL_ATTR_UNSPEC,
28158264848SPravin B Shelar 	OVS_TUNNEL_ATTR_DST_PORT, /* 16-bit UDP port, used by L4 tunnels. */
2821dd144cfSThomas Graf 	OVS_TUNNEL_ATTR_EXTENSION,
28358264848SPravin B Shelar 	__OVS_TUNNEL_ATTR_MAX
28458264848SPravin B Shelar };
28558264848SPravin B Shelar 
28658264848SPravin B Shelar #define OVS_TUNNEL_ATTR_MAX (__OVS_TUNNEL_ATTR_MAX - 1)
28758264848SPravin B Shelar 
28822e3880aSThomas Graf /* Flows. */
28922e3880aSThomas Graf 
29022e3880aSThomas Graf #define OVS_FLOW_FAMILY  "ovs_flow"
29122e3880aSThomas Graf #define OVS_FLOW_MCGROUP "ovs_flow"
29222e3880aSThomas Graf #define OVS_FLOW_VERSION 0x1
29322e3880aSThomas Graf 
29422e3880aSThomas Graf enum ovs_flow_cmd {
29522e3880aSThomas Graf 	OVS_FLOW_CMD_UNSPEC,
29622e3880aSThomas Graf 	OVS_FLOW_CMD_NEW,
29722e3880aSThomas Graf 	OVS_FLOW_CMD_DEL,
29822e3880aSThomas Graf 	OVS_FLOW_CMD_GET,
29922e3880aSThomas Graf 	OVS_FLOW_CMD_SET
30022e3880aSThomas Graf };
30122e3880aSThomas Graf 
30222e3880aSThomas Graf struct ovs_flow_stats {
30322e3880aSThomas Graf 	__u64 n_packets;         /* Number of matched packets. */
30422e3880aSThomas Graf 	__u64 n_bytes;           /* Number of matched bytes. */
30522e3880aSThomas Graf };
30622e3880aSThomas Graf 
30722e3880aSThomas Graf enum ovs_key_attr {
30822e3880aSThomas Graf 	OVS_KEY_ATTR_UNSPEC,
30922e3880aSThomas Graf 	OVS_KEY_ATTR_ENCAP,	/* Nested set of encapsulated attributes. */
31022e3880aSThomas Graf 	OVS_KEY_ATTR_PRIORITY,  /* u32 skb->priority */
31122e3880aSThomas Graf 	OVS_KEY_ATTR_IN_PORT,   /* u32 OVS dp port number */
31222e3880aSThomas Graf 	OVS_KEY_ATTR_ETHERNET,  /* struct ovs_key_ethernet */
31322e3880aSThomas Graf 	OVS_KEY_ATTR_VLAN,	/* be16 VLAN TCI */
31422e3880aSThomas Graf 	OVS_KEY_ATTR_ETHERTYPE,	/* be16 Ethernet type */
31522e3880aSThomas Graf 	OVS_KEY_ATTR_IPV4,      /* struct ovs_key_ipv4 */
31622e3880aSThomas Graf 	OVS_KEY_ATTR_IPV6,      /* struct ovs_key_ipv6 */
31722e3880aSThomas Graf 	OVS_KEY_ATTR_TCP,       /* struct ovs_key_tcp */
31822e3880aSThomas Graf 	OVS_KEY_ATTR_UDP,       /* struct ovs_key_udp */
31922e3880aSThomas Graf 	OVS_KEY_ATTR_ICMP,      /* struct ovs_key_icmp */
32022e3880aSThomas Graf 	OVS_KEY_ATTR_ICMPV6,    /* struct ovs_key_icmpv6 */
32122e3880aSThomas Graf 	OVS_KEY_ATTR_ARP,       /* struct ovs_key_arp */
32222e3880aSThomas Graf 	OVS_KEY_ATTR_ND,        /* struct ovs_key_nd */
32322e3880aSThomas Graf 	OVS_KEY_ATTR_SKB_MARK,  /* u32 skb mark */
3247d5437c7SPravin B Shelar 	OVS_KEY_ATTR_TUNNEL,    /* Nested set of ovs_tunnel attributes */
325a175a723SJoe Stringer 	OVS_KEY_ATTR_SCTP,      /* struct ovs_key_sctp */
3265eb26b15SJarno Rajahalme 	OVS_KEY_ATTR_TCP_FLAGS,	/* be16 TCP flags. */
327971427f3SAndy Zhou 	OVS_KEY_ATTR_DP_HASH,      /* u32 hash value. Value 0 indicates the hash
328971427f3SAndy Zhou 				   is not computed by the datapath. */
329971427f3SAndy Zhou 	OVS_KEY_ATTR_RECIRC_ID, /* u32 recirc id */
33025cd9ba0SSimon Horman 	OVS_KEY_ATTR_MPLS,      /* array of struct ovs_key_mpls.
33125cd9ba0SSimon Horman 				 * The implementation may restrict
33225cd9ba0SSimon Horman 				 * the accepted length of the array. */
333fbccce59SJoe Stringer 	OVS_KEY_ATTR_CT_STATE,	/* u32 bitmask of OVS_CS_F_* */
3347f8a436eSJoe Stringer 	OVS_KEY_ATTR_CT_ZONE,	/* u16 connection tracking zone. */
335182e3042SJoe Stringer 	OVS_KEY_ATTR_CT_MARK,	/* u32 connection tracking mark */
33633db4125SJoe Stringer 	OVS_KEY_ATTR_CT_LABELS,	/* 16-octet connection tracking label */
3379dd7f890SJarno Rajahalme 	OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4,   /* struct ovs_key_ct_tuple_ipv4 */
3389dd7f890SJarno Rajahalme 	OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6,   /* struct ovs_key_ct_tuple_ipv6 */
339b2d0f5d5SYi Yang 	OVS_KEY_ATTR_NSH,       /* Nested set of ovs_nsh_key_* */
3407d5437c7SPravin B Shelar 
3417d5437c7SPravin B Shelar #ifdef __KERNEL__
3421d8fff90SThomas Graf 	OVS_KEY_ATTR_TUNNEL_INFO,  /* struct ip_tunnel_info */
3437d5437c7SPravin B Shelar #endif
34422e3880aSThomas Graf 	__OVS_KEY_ATTR_MAX
34522e3880aSThomas Graf };
34622e3880aSThomas Graf 
34722e3880aSThomas Graf #define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1)
34822e3880aSThomas Graf 
3497d5437c7SPravin B Shelar enum ovs_tunnel_key_attr {
350daa6630aSNicolas Dichtel 	/* OVS_TUNNEL_KEY_ATTR_NONE, standard nl API requires this attribute! */
3517d5437c7SPravin B Shelar 	OVS_TUNNEL_KEY_ATTR_ID,                 /* be64 Tunnel ID */
3527d5437c7SPravin B Shelar 	OVS_TUNNEL_KEY_ATTR_IPV4_SRC,           /* be32 src IP address. */
3537d5437c7SPravin B Shelar 	OVS_TUNNEL_KEY_ATTR_IPV4_DST,           /* be32 dst IP address. */
3547d5437c7SPravin B Shelar 	OVS_TUNNEL_KEY_ATTR_TOS,                /* u8 Tunnel IP ToS. */
3557d5437c7SPravin B Shelar 	OVS_TUNNEL_KEY_ATTR_TTL,                /* u8 Tunnel IP TTL. */
3567d5437c7SPravin B Shelar 	OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT,      /* No argument, set DF. */
3577d5437c7SPravin B Shelar 	OVS_TUNNEL_KEY_ATTR_CSUM,               /* No argument. CSUM packet. */
35867fa0341SJesse Gross 	OVS_TUNNEL_KEY_ATTR_OAM,                /* No argument. OAM frame.  */
359f5796684SJesse Gross 	OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS,        /* Array of Geneve options. */
3608f0aad6fSWenyu Zhang 	OVS_TUNNEL_KEY_ATTR_TP_SRC,		/* be16 src Transport Port. */
3618f0aad6fSWenyu Zhang 	OVS_TUNNEL_KEY_ATTR_TP_DST,		/* be16 dst Transport Port. */
3621dd144cfSThomas Graf 	OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS,		/* Nested OVS_VXLAN_EXT_* */
3636b26ba3aSJiri Benc 	OVS_TUNNEL_KEY_ATTR_IPV6_SRC,		/* struct in6_addr src IPv6 address. */
3646b26ba3aSJiri Benc 	OVS_TUNNEL_KEY_ATTR_IPV6_DST,		/* struct in6_addr dst IPv6 address. */
365b46f6dedSNicolas Dichtel 	OVS_TUNNEL_KEY_ATTR_PAD,
366fc1372f8SWilliam Tu 	OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS,	/* struct erspan_metadata */
3677d5437c7SPravin B Shelar 	__OVS_TUNNEL_KEY_ATTR_MAX
3687d5437c7SPravin B Shelar };
3697d5437c7SPravin B Shelar 
3707d5437c7SPravin B Shelar #define OVS_TUNNEL_KEY_ATTR_MAX (__OVS_TUNNEL_KEY_ATTR_MAX - 1)
3717d5437c7SPravin B Shelar 
37222e3880aSThomas Graf /**
37322e3880aSThomas Graf  * enum ovs_frag_type - IPv4 and IPv6 fragment type
37422e3880aSThomas Graf  * @OVS_FRAG_TYPE_NONE: Packet is not a fragment.
37522e3880aSThomas Graf  * @OVS_FRAG_TYPE_FIRST: Packet is a fragment with offset 0.
37622e3880aSThomas Graf  * @OVS_FRAG_TYPE_LATER: Packet is a fragment with nonzero offset.
37722e3880aSThomas Graf  *
37822e3880aSThomas Graf  * Used as the @ipv4_frag in &struct ovs_key_ipv4 and as @ipv6_frag &struct
37922e3880aSThomas Graf  * ovs_key_ipv6.
38022e3880aSThomas Graf  */
38122e3880aSThomas Graf enum ovs_frag_type {
38222e3880aSThomas Graf 	OVS_FRAG_TYPE_NONE,
38322e3880aSThomas Graf 	OVS_FRAG_TYPE_FIRST,
38422e3880aSThomas Graf 	OVS_FRAG_TYPE_LATER,
38522e3880aSThomas Graf 	__OVS_FRAG_TYPE_MAX
38622e3880aSThomas Graf };
38722e3880aSThomas Graf 
38822e3880aSThomas Graf #define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1)
38922e3880aSThomas Graf 
39022e3880aSThomas Graf struct ovs_key_ethernet {
39122e3880aSThomas Graf 	__u8	 eth_src[ETH_ALEN];
39222e3880aSThomas Graf 	__u8	 eth_dst[ETH_ALEN];
39322e3880aSThomas Graf };
39422e3880aSThomas Graf 
39525cd9ba0SSimon Horman struct ovs_key_mpls {
39625cd9ba0SSimon Horman 	__be32 mpls_lse;
39725cd9ba0SSimon Horman };
39825cd9ba0SSimon Horman 
39922e3880aSThomas Graf struct ovs_key_ipv4 {
40022e3880aSThomas Graf 	__be32 ipv4_src;
40122e3880aSThomas Graf 	__be32 ipv4_dst;
40222e3880aSThomas Graf 	__u8   ipv4_proto;
40322e3880aSThomas Graf 	__u8   ipv4_tos;
40422e3880aSThomas Graf 	__u8   ipv4_ttl;
40522e3880aSThomas Graf 	__u8   ipv4_frag;	/* One of OVS_FRAG_TYPE_*. */
40622e3880aSThomas Graf };
40722e3880aSThomas Graf 
40822e3880aSThomas Graf struct ovs_key_ipv6 {
40922e3880aSThomas Graf 	__be32 ipv6_src[4];
41022e3880aSThomas Graf 	__be32 ipv6_dst[4];
41122e3880aSThomas Graf 	__be32 ipv6_label;	/* 20-bits in least-significant bits. */
41222e3880aSThomas Graf 	__u8   ipv6_proto;
41322e3880aSThomas Graf 	__u8   ipv6_tclass;
41422e3880aSThomas Graf 	__u8   ipv6_hlimit;
41522e3880aSThomas Graf 	__u8   ipv6_frag;	/* One of OVS_FRAG_TYPE_*. */
41622e3880aSThomas Graf };
41722e3880aSThomas Graf 
41822e3880aSThomas Graf struct ovs_key_tcp {
41922e3880aSThomas Graf 	__be16 tcp_src;
42022e3880aSThomas Graf 	__be16 tcp_dst;
42122e3880aSThomas Graf };
42222e3880aSThomas Graf 
42322e3880aSThomas Graf struct ovs_key_udp {
42422e3880aSThomas Graf 	__be16 udp_src;
42522e3880aSThomas Graf 	__be16 udp_dst;
42622e3880aSThomas Graf };
42722e3880aSThomas Graf 
428a175a723SJoe Stringer struct ovs_key_sctp {
429a175a723SJoe Stringer 	__be16 sctp_src;
430a175a723SJoe Stringer 	__be16 sctp_dst;
431a175a723SJoe Stringer };
432a175a723SJoe Stringer 
43322e3880aSThomas Graf struct ovs_key_icmp {
43422e3880aSThomas Graf 	__u8 icmp_type;
43522e3880aSThomas Graf 	__u8 icmp_code;
43622e3880aSThomas Graf };
43722e3880aSThomas Graf 
43822e3880aSThomas Graf struct ovs_key_icmpv6 {
43922e3880aSThomas Graf 	__u8 icmpv6_type;
44022e3880aSThomas Graf 	__u8 icmpv6_code;
44122e3880aSThomas Graf };
44222e3880aSThomas Graf 
44322e3880aSThomas Graf struct ovs_key_arp {
44422e3880aSThomas Graf 	__be32 arp_sip;
44522e3880aSThomas Graf 	__be32 arp_tip;
44622e3880aSThomas Graf 	__be16 arp_op;
44722e3880aSThomas Graf 	__u8   arp_sha[ETH_ALEN];
44822e3880aSThomas Graf 	__u8   arp_tha[ETH_ALEN];
44922e3880aSThomas Graf };
45022e3880aSThomas Graf 
45122e3880aSThomas Graf struct ovs_key_nd {
4521a4e96a0SJarno Rajahalme 	__be32	nd_target[4];
45322e3880aSThomas Graf 	__u8	nd_sll[ETH_ALEN];
45422e3880aSThomas Graf 	__u8	nd_tll[ETH_ALEN];
45522e3880aSThomas Graf };
45622e3880aSThomas Graf 
457cb80d58fSJarno Rajahalme #define OVS_CT_LABELS_LEN_32	4
458cb80d58fSJarno Rajahalme #define OVS_CT_LABELS_LEN	(OVS_CT_LABELS_LEN_32 * sizeof(__u32))
45933db4125SJoe Stringer struct ovs_key_ct_labels {
460cb80d58fSJarno Rajahalme 	union {
46133db4125SJoe Stringer 		__u8	ct_labels[OVS_CT_LABELS_LEN];
462cb80d58fSJarno Rajahalme 		__u32	ct_labels_32[OVS_CT_LABELS_LEN_32];
463cb80d58fSJarno Rajahalme 	};
464c2ac6673SJoe Stringer };
465c2ac6673SJoe Stringer 
4667f8a436eSJoe Stringer /* OVS_KEY_ATTR_CT_STATE flags */
4677f8a436eSJoe Stringer #define OVS_CS_F_NEW               0x01 /* Beginning of a new connection. */
4687f8a436eSJoe Stringer #define OVS_CS_F_ESTABLISHED       0x02 /* Part of an existing connection. */
4697f8a436eSJoe Stringer #define OVS_CS_F_RELATED           0x04 /* Related to an established
4707f8a436eSJoe Stringer 					 * connection. */
471fbccce59SJoe Stringer #define OVS_CS_F_REPLY_DIR         0x08 /* Flow is in the reply direction. */
472fbccce59SJoe Stringer #define OVS_CS_F_INVALID           0x10 /* Could not track connection. */
473fbccce59SJoe Stringer #define OVS_CS_F_TRACKED           0x20 /* Conntrack has occurred. */
47405752523SJarno Rajahalme #define OVS_CS_F_SRC_NAT           0x40 /* Packet's source address/port was
47505752523SJarno Rajahalme 					 * mangled by NAT.
47605752523SJarno Rajahalme 					 */
47705752523SJarno Rajahalme #define OVS_CS_F_DST_NAT           0x80 /* Packet's destination address/port
47805752523SJarno Rajahalme 					 * was mangled by NAT.
47905752523SJarno Rajahalme 					 */
48005752523SJarno Rajahalme 
48105752523SJarno Rajahalme #define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
4827f8a436eSJoe Stringer 
4839dd7f890SJarno Rajahalme struct ovs_key_ct_tuple_ipv4 {
4849dd7f890SJarno Rajahalme 	__be32 ipv4_src;
4859dd7f890SJarno Rajahalme 	__be32 ipv4_dst;
4869dd7f890SJarno Rajahalme 	__be16 src_port;
4879dd7f890SJarno Rajahalme 	__be16 dst_port;
4889dd7f890SJarno Rajahalme 	__u8   ipv4_proto;
4899dd7f890SJarno Rajahalme };
4909dd7f890SJarno Rajahalme 
4919dd7f890SJarno Rajahalme struct ovs_key_ct_tuple_ipv6 {
4929dd7f890SJarno Rajahalme 	__be32 ipv6_src[4];
4939dd7f890SJarno Rajahalme 	__be32 ipv6_dst[4];
4949dd7f890SJarno Rajahalme 	__be16 src_port;
4959dd7f890SJarno Rajahalme 	__be16 dst_port;
4969dd7f890SJarno Rajahalme 	__u8   ipv6_proto;
4979dd7f890SJarno Rajahalme };
4989dd7f890SJarno Rajahalme 
499b2d0f5d5SYi Yang enum ovs_nsh_key_attr {
500b2d0f5d5SYi Yang 	OVS_NSH_KEY_ATTR_UNSPEC,
501b2d0f5d5SYi Yang 	OVS_NSH_KEY_ATTR_BASE,  /* struct ovs_nsh_key_base. */
502b2d0f5d5SYi Yang 	OVS_NSH_KEY_ATTR_MD1,   /* struct ovs_nsh_key_md1. */
503b2d0f5d5SYi Yang 	OVS_NSH_KEY_ATTR_MD2,   /* variable-length octets for MD type 2. */
504b2d0f5d5SYi Yang 	__OVS_NSH_KEY_ATTR_MAX
505b2d0f5d5SYi Yang };
506b2d0f5d5SYi Yang 
507b2d0f5d5SYi Yang #define OVS_NSH_KEY_ATTR_MAX (__OVS_NSH_KEY_ATTR_MAX - 1)
508b2d0f5d5SYi Yang 
509b2d0f5d5SYi Yang struct ovs_nsh_key_base {
510b2d0f5d5SYi Yang 	__u8 flags;
511b2d0f5d5SYi Yang 	__u8 ttl;
512b2d0f5d5SYi Yang 	__u8 mdtype;
513b2d0f5d5SYi Yang 	__u8 np;
514b2d0f5d5SYi Yang 	__be32 path_hdr;
515b2d0f5d5SYi Yang };
516b2d0f5d5SYi Yang 
517b2d0f5d5SYi Yang #define NSH_MD1_CONTEXT_SIZE 4
518b2d0f5d5SYi Yang 
519b2d0f5d5SYi Yang struct ovs_nsh_key_md1 {
520b2d0f5d5SYi Yang 	__be32 context[NSH_MD1_CONTEXT_SIZE];
521b2d0f5d5SYi Yang };
522b2d0f5d5SYi Yang 
52322e3880aSThomas Graf /**
52422e3880aSThomas Graf  * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.
52522e3880aSThomas Graf  * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow
52622e3880aSThomas Graf  * key.  Always present in notifications.  Required for all requests (except
52722e3880aSThomas Graf  * dumps).
52822e3880aSThomas Graf  * @OVS_FLOW_ATTR_ACTIONS: Nested %OVS_ACTION_ATTR_* attributes specifying
52922e3880aSThomas Graf  * the actions to take for packets that match the key.  Always present in
53022e3880aSThomas Graf  * notifications.  Required for %OVS_FLOW_CMD_NEW requests, optional for
531be52c9e9SJarno Rajahalme  * %OVS_FLOW_CMD_SET requests.  An %OVS_FLOW_CMD_SET without
532be52c9e9SJarno Rajahalme  * %OVS_FLOW_ATTR_ACTIONS will not modify the actions.  To clear the actions,
533be52c9e9SJarno Rajahalme  * an %OVS_FLOW_ATTR_ACTIONS without any nested attributes must be given.
53422e3880aSThomas Graf  * @OVS_FLOW_ATTR_STATS: &struct ovs_flow_stats giving statistics for this
53522e3880aSThomas Graf  * flow.  Present in notifications if the stats would be nonzero.  Ignored in
53622e3880aSThomas Graf  * requests.
53722e3880aSThomas Graf  * @OVS_FLOW_ATTR_TCP_FLAGS: An 8-bit value giving the OR'd value of all of the
53822e3880aSThomas Graf  * TCP flags seen on packets in this flow.  Only present in notifications for
53922e3880aSThomas Graf  * TCP flows, and only if it would be nonzero.  Ignored in requests.
54022e3880aSThomas Graf  * @OVS_FLOW_ATTR_USED: A 64-bit integer giving the time, in milliseconds on
54122e3880aSThomas Graf  * the system monotonic clock, at which a packet was last processed for this
54222e3880aSThomas Graf  * flow.  Only present in notifications if a packet has been processed for this
54322e3880aSThomas Graf  * flow.  Ignored in requests.
54422e3880aSThomas Graf  * @OVS_FLOW_ATTR_CLEAR: If present in a %OVS_FLOW_CMD_SET request, clears the
54522e3880aSThomas Graf  * last-used time, accumulated TCP flags, and statistics for this flow.
54622e3880aSThomas Graf  * Otherwise ignored in requests.  Never present in notifications.
54703f0d916SAndy Zhou  * @OVS_FLOW_ATTR_MASK: Nested %OVS_KEY_ATTR_* attributes specifying the
54803f0d916SAndy Zhou  * mask bits for wildcarded flow match. Mask bit value '1' specifies exact
54903f0d916SAndy Zhou  * match with corresponding flow key bit, while mask bit value '0' specifies
55003f0d916SAndy Zhou  * a wildcarded match. Omitting attribute is treated as wildcarding all
55103f0d916SAndy Zhou  * corresponding fields. Optional for all requests. If not present,
55203f0d916SAndy Zhou  * all flow key bits are exact match bits.
55374ed7ab9SJoe Stringer  * @OVS_FLOW_ATTR_UFID: A value between 1-16 octets specifying a unique
55474ed7ab9SJoe Stringer  * identifier for the flow. Causes the flow to be indexed by this value rather
55574ed7ab9SJoe Stringer  * than the value of the %OVS_FLOW_ATTR_KEY attribute. Optional for all
55674ed7ab9SJoe Stringer  * requests. Present in notifications if the flow was created with this
55774ed7ab9SJoe Stringer  * attribute.
55874ed7ab9SJoe Stringer  * @OVS_FLOW_ATTR_UFID_FLAGS: A 32-bit value of OR'd %OVS_UFID_F_*
55974ed7ab9SJoe Stringer  * flags that provide alternative semantics for flow installation and
56074ed7ab9SJoe Stringer  * retrieval. Optional for all requests.
56122e3880aSThomas Graf  *
56222e3880aSThomas Graf  * These attributes follow the &struct ovs_header within the Generic Netlink
56322e3880aSThomas Graf  * payload for %OVS_FLOW_* commands.
56422e3880aSThomas Graf  */
56522e3880aSThomas Graf enum ovs_flow_attr {
56622e3880aSThomas Graf 	OVS_FLOW_ATTR_UNSPEC,
56722e3880aSThomas Graf 	OVS_FLOW_ATTR_KEY,       /* Sequence of OVS_KEY_ATTR_* attributes. */
56822e3880aSThomas Graf 	OVS_FLOW_ATTR_ACTIONS,   /* Nested OVS_ACTION_ATTR_* attributes. */
56922e3880aSThomas Graf 	OVS_FLOW_ATTR_STATS,     /* struct ovs_flow_stats. */
57022e3880aSThomas Graf 	OVS_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */
57122e3880aSThomas Graf 	OVS_FLOW_ATTR_USED,      /* u64 msecs last used in monotonic time. */
57222e3880aSThomas Graf 	OVS_FLOW_ATTR_CLEAR,     /* Flag to clear stats, tcp_flags, used. */
57303f0d916SAndy Zhou 	OVS_FLOW_ATTR_MASK,      /* Sequence of OVS_KEY_ATTR_* attributes. */
57405da5898SJarno Rajahalme 	OVS_FLOW_ATTR_PROBE,     /* Flow operation is a feature probe, error
57505da5898SJarno Rajahalme 				  * logging should be suppressed. */
57674ed7ab9SJoe Stringer 	OVS_FLOW_ATTR_UFID,      /* Variable length unique flow identifier. */
57774ed7ab9SJoe Stringer 	OVS_FLOW_ATTR_UFID_FLAGS,/* u32 of OVS_UFID_F_*. */
5780238b720SNicolas Dichtel 	OVS_FLOW_ATTR_PAD,
57922e3880aSThomas Graf 	__OVS_FLOW_ATTR_MAX
58022e3880aSThomas Graf };
58122e3880aSThomas Graf 
58222e3880aSThomas Graf #define OVS_FLOW_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1)
58322e3880aSThomas Graf 
58422e3880aSThomas Graf /**
58574ed7ab9SJoe Stringer  * Omit attributes for notifications.
58674ed7ab9SJoe Stringer  *
58774ed7ab9SJoe Stringer  * If a datapath request contains an %OVS_UFID_F_OMIT_* flag, then the datapath
58874ed7ab9SJoe Stringer  * may omit the corresponding %OVS_FLOW_ATTR_* from the response.
58974ed7ab9SJoe Stringer  */
59074ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_KEY      (1 << 0)
59174ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_MASK     (1 << 1)
59274ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_ACTIONS  (1 << 2)
59374ed7ab9SJoe Stringer 
59474ed7ab9SJoe Stringer /**
59522e3880aSThomas Graf  * enum ovs_sample_attr - Attributes for %OVS_ACTION_ATTR_SAMPLE action.
59622e3880aSThomas Graf  * @OVS_SAMPLE_ATTR_PROBABILITY: 32-bit fraction of packets to sample with
59722e3880aSThomas Graf  * @OVS_ACTION_ATTR_SAMPLE.  A value of 0 samples no packets, a value of
59822e3880aSThomas Graf  * %UINT32_MAX samples all packets and intermediate values sample intermediate
59922e3880aSThomas Graf  * fractions of packets.
60022e3880aSThomas Graf  * @OVS_SAMPLE_ATTR_ACTIONS: Set of actions to execute in sampling event.
60122e3880aSThomas Graf  * Actions are passed as nested attributes.
60222e3880aSThomas Graf  *
60322e3880aSThomas Graf  * Executes the specified actions with the given probability on a per-packet
60422e3880aSThomas Graf  * basis.
60522e3880aSThomas Graf  */
60622e3880aSThomas Graf enum ovs_sample_attr {
60722e3880aSThomas Graf 	OVS_SAMPLE_ATTR_UNSPEC,
60822e3880aSThomas Graf 	OVS_SAMPLE_ATTR_PROBABILITY, /* u32 number */
60922e3880aSThomas Graf 	OVS_SAMPLE_ATTR_ACTIONS,     /* Nested OVS_ACTION_ATTR_* attributes. */
61022e3880aSThomas Graf 	__OVS_SAMPLE_ATTR_MAX,
611798c1661Sandy zhou 
612798c1661Sandy zhou #ifdef __KERNEL__
613798c1661Sandy zhou 	OVS_SAMPLE_ATTR_ARG          /* struct sample_arg  */
614798c1661Sandy zhou #endif
61522e3880aSThomas Graf };
61622e3880aSThomas Graf 
61722e3880aSThomas Graf #define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1)
61822e3880aSThomas Graf 
619798c1661Sandy zhou #ifdef __KERNEL__
620798c1661Sandy zhou struct sample_arg {
621798c1661Sandy zhou 	bool exec;                   /* When true, actions in sample will not
622798c1661Sandy zhou 				      * change flow keys. False otherwise.
623798c1661Sandy zhou 				      */
624798c1661Sandy zhou 	u32  probability;            /* Same value as
625798c1661Sandy zhou 				      * 'OVS_SAMPLE_ATTR_PROBABILITY'.
626798c1661Sandy zhou 				      */
627798c1661Sandy zhou };
628798c1661Sandy zhou #endif
629798c1661Sandy zhou 
63022e3880aSThomas Graf /**
63122e3880aSThomas Graf  * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action.
63222e3880aSThomas Graf  * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION
63322e3880aSThomas Graf  * message should be sent.  Required.
63422e3880aSThomas Graf  * @OVS_USERSPACE_ATTR_USERDATA: If present, its variable-length argument is
63522e3880aSThomas Graf  * copied to the %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA.
6368f0aad6fSWenyu Zhang  * @OVS_USERSPACE_ATTR_EGRESS_TUN_PORT: If present, u32 output port to get
6378f0aad6fSWenyu Zhang  * tunnel info.
638ccea7445SNeil McKee  * @OVS_USERSPACE_ATTR_ACTIONS: If present, send actions with upcall.
63922e3880aSThomas Graf  */
64022e3880aSThomas Graf enum ovs_userspace_attr {
64122e3880aSThomas Graf 	OVS_USERSPACE_ATTR_UNSPEC,
64222e3880aSThomas Graf 	OVS_USERSPACE_ATTR_PID,	      /* u32 Netlink PID to receive upcalls. */
64322e3880aSThomas Graf 	OVS_USERSPACE_ATTR_USERDATA,  /* Optional user-specified cookie. */
6448f0aad6fSWenyu Zhang 	OVS_USERSPACE_ATTR_EGRESS_TUN_PORT,  /* Optional, u32 output port
6458f0aad6fSWenyu Zhang 					      * to get tunnel info. */
646ccea7445SNeil McKee 	OVS_USERSPACE_ATTR_ACTIONS,   /* Optional flag to get actions. */
64722e3880aSThomas Graf 	__OVS_USERSPACE_ATTR_MAX
64822e3880aSThomas Graf };
64922e3880aSThomas Graf 
65022e3880aSThomas Graf #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)
65122e3880aSThomas Graf 
652f2a4d086SWilliam Tu struct ovs_action_trunc {
653a1d1f65fSMikko Rapeli 	__u32 max_len; /* Max packet size in bytes. */
654f2a4d086SWilliam Tu };
655f2a4d086SWilliam Tu 
65622e3880aSThomas Graf /**
65725cd9ba0SSimon Horman  * struct ovs_action_push_mpls - %OVS_ACTION_ATTR_PUSH_MPLS action argument.
65825cd9ba0SSimon Horman  * @mpls_lse: MPLS label stack entry to push.
65925cd9ba0SSimon Horman  * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame.
66025cd9ba0SSimon Horman  *
66125cd9ba0SSimon Horman  * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and
66225cd9ba0SSimon Horman  * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected.
66325cd9ba0SSimon Horman  */
66425cd9ba0SSimon Horman struct ovs_action_push_mpls {
66525cd9ba0SSimon Horman 	__be32 mpls_lse;
66625cd9ba0SSimon Horman 	__be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */
66725cd9ba0SSimon Horman };
66825cd9ba0SSimon Horman 
66925cd9ba0SSimon Horman /**
67022e3880aSThomas Graf  * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument.
67122e3880aSThomas Graf  * @vlan_tpid: Tag protocol identifier (TPID) to push.
67222e3880aSThomas Graf  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
67322e3880aSThomas Graf  * (but it will not be set in the 802.1Q header that is pushed).
67422e3880aSThomas Graf  *
6758c146bb9SThomas F Herbert  * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
6768c146bb9SThomas F Herbert  * The only acceptable TPID values are those that the kernel module also parses
6778c146bb9SThomas F Herbert  * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
6788c146bb9SThomas F Herbert  * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
67922e3880aSThomas Graf  */
68022e3880aSThomas Graf struct ovs_action_push_vlan {
6818c146bb9SThomas F Herbert 	__be16 vlan_tpid;	/* 802.1Q or 802.1ad TPID. */
68222e3880aSThomas Graf 	__be16 vlan_tci;	/* 802.1Q TCI (VLAN ID and priority). */
68322e3880aSThomas Graf };
68422e3880aSThomas Graf 
685971427f3SAndy Zhou /* Data path hash algorithm for computing Datapath hash.
686971427f3SAndy Zhou  *
687971427f3SAndy Zhou  * The algorithm type only specifies the fields in a flow
688971427f3SAndy Zhou  * will be used as part of the hash. Each datapath is free
689971427f3SAndy Zhou  * to use its own hash algorithm. The hash value will be
690971427f3SAndy Zhou  * opaque to the user space daemon.
691971427f3SAndy Zhou  */
692971427f3SAndy Zhou enum ovs_hash_alg {
693971427f3SAndy Zhou 	OVS_HASH_ALG_L4,
694971427f3SAndy Zhou };
695971427f3SAndy Zhou 
696971427f3SAndy Zhou /*
697971427f3SAndy Zhou  * struct ovs_action_hash - %OVS_ACTION_ATTR_HASH action argument.
698971427f3SAndy Zhou  * @hash_alg: Algorithm used to compute hash prior to recirculation.
699971427f3SAndy Zhou  * @hash_basis: basis used for computing hash.
700971427f3SAndy Zhou  */
701971427f3SAndy Zhou struct ovs_action_hash {
702e6571aa5SMikko Rapeli 	__u32  hash_alg;     /* One of ovs_hash_alg. */
703e6571aa5SMikko Rapeli 	__u32  hash_basis;
704971427f3SAndy Zhou };
705971427f3SAndy Zhou 
70622e3880aSThomas Graf /**
7077f8a436eSJoe Stringer  * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action.
708ab38a7b5SJoe Stringer  * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack
709ab38a7b5SJoe Stringer  * table. This allows future packets for the same connection to be identified
7101d008a1dSJoe Stringer  * as 'established' or 'related'. The flow key for the current packet will
7111d008a1dSJoe Stringer  * retain the pre-commit connection state.
7127f8a436eSJoe Stringer  * @OVS_CT_ATTR_ZONE: u16 connection tracking zone.
713182e3042SJoe Stringer  * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the
714182e3042SJoe Stringer  * mask, the corresponding bit in the value is copied to the connection
715182e3042SJoe Stringer  * tracking mark field in the connection.
716e5f5d747SPaolo Abeni  * @OVS_CT_ATTR_LABELS: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN
717c2ac6673SJoe Stringer  * mask. For each bit set in the mask, the corresponding bit in the value is
718c2ac6673SJoe Stringer  * copied to the connection tracking label field in the connection.
719cae3a262SJoe Stringer  * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG.
72005752523SJarno Rajahalme  * @OVS_CT_ATTR_NAT: Nested OVS_NAT_ATTR_* for performing L3 network address
72105752523SJarno Rajahalme  * translation (NAT) on the packet.
722dd41d33fSJarno Rajahalme  * @OVS_CT_ATTR_FORCE_COMMIT: Like %OVS_CT_ATTR_COMMIT, but instead of doing
723dd41d33fSJarno Rajahalme  * nothing if the connection is already committed will check that the current
724dd41d33fSJarno Rajahalme  * packet is in conntrack entry's original direction.  If directionality does
725dd41d33fSJarno Rajahalme  * not match, will delete the existing conntrack entry and commit a new one.
72612064551SJarno Rajahalme  * @OVS_CT_ATTR_EVENTMASK: Mask of bits indicating which conntrack event types
72712064551SJarno Rajahalme  * (enum ip_conntrack_events IPCT_*) should be reported.  For any bit set to
72812064551SJarno Rajahalme  * zero, the corresponding event type is not generated.  Default behavior
72912064551SJarno Rajahalme  * depends on system configuration, but typically all event types are
73012064551SJarno Rajahalme  * generated, hence listening on NFNLGRP_CONNTRACK_UPDATE events may get a lot
73112064551SJarno Rajahalme  * of events.  Explicitly passing this attribute allows limiting the updates
73212064551SJarno Rajahalme  * received to the events of interest.  The bit 1 << IPCT_NEW, 1 <<
73312064551SJarno Rajahalme  * IPCT_RELATED, and 1 << IPCT_DESTROY must be set to ones for those events to
73412064551SJarno Rajahalme  * be received on NFNLGRP_CONNTRACK_NEW and NFNLGRP_CONNTRACK_DESTROY groups,
73512064551SJarno Rajahalme  * respectively.  Remaining bits control the changes for which an event is
73612064551SJarno Rajahalme  * delivered on the NFNLGRP_CONNTRACK_UPDATE group.
737*06bd2bdfSYi-Hung Wei  * @OVS_CT_ATTR_TIMEOUT: Variable length string defining conntrack timeout.
7387f8a436eSJoe Stringer  */
7397f8a436eSJoe Stringer enum ovs_ct_attr {
7407f8a436eSJoe Stringer 	OVS_CT_ATTR_UNSPEC,
741ab38a7b5SJoe Stringer 	OVS_CT_ATTR_COMMIT,     /* No argument, commits connection. */
7427f8a436eSJoe Stringer 	OVS_CT_ATTR_ZONE,       /* u16 zone id. */
743182e3042SJoe Stringer 	OVS_CT_ATTR_MARK,       /* mark to associate with this connection. */
74433db4125SJoe Stringer 	OVS_CT_ATTR_LABELS,     /* labels to associate with this connection. */
745cae3a262SJoe Stringer 	OVS_CT_ATTR_HELPER,     /* netlink helper to assist detection of
746cae3a262SJoe Stringer 				   related connections. */
74705752523SJarno Rajahalme 	OVS_CT_ATTR_NAT,        /* Nested OVS_NAT_ATTR_* */
748dd41d33fSJarno Rajahalme 	OVS_CT_ATTR_FORCE_COMMIT,  /* No argument */
74912064551SJarno Rajahalme 	OVS_CT_ATTR_EVENTMASK,  /* u32 mask of IPCT_* events. */
750*06bd2bdfSYi-Hung Wei 	OVS_CT_ATTR_TIMEOUT,	/* Associate timeout with this connection for
751*06bd2bdfSYi-Hung Wei 				 * fine-grain timeout tuning. */
7527f8a436eSJoe Stringer 	__OVS_CT_ATTR_MAX
7537f8a436eSJoe Stringer };
7547f8a436eSJoe Stringer 
7557f8a436eSJoe Stringer #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1)
7567f8a436eSJoe Stringer 
7577f8a436eSJoe Stringer /**
75805752523SJarno Rajahalme  * enum ovs_nat_attr - Attributes for %OVS_CT_ATTR_NAT.
75905752523SJarno Rajahalme  *
76005752523SJarno Rajahalme  * @OVS_NAT_ATTR_SRC: Flag for Source NAT (mangle source address/port).
76105752523SJarno Rajahalme  * @OVS_NAT_ATTR_DST: Flag for Destination NAT (mangle destination
76205752523SJarno Rajahalme  * address/port).  Only one of (@OVS_NAT_ATTR_SRC, @OVS_NAT_ATTR_DST) may be
76305752523SJarno Rajahalme  * specified.  Effective only for packets for ct_state NEW connections.
76405752523SJarno Rajahalme  * Packets of committed connections are mangled by the NAT action according to
76505752523SJarno Rajahalme  * the committed NAT type regardless of the flags specified.  As a corollary, a
76605752523SJarno Rajahalme  * NAT action without a NAT type flag will only mangle packets of committed
76705752523SJarno Rajahalme  * connections.  The following NAT attributes only apply for NEW
76805752523SJarno Rajahalme  * (non-committed) connections, and they may be included only when the CT
76905752523SJarno Rajahalme  * action has the @OVS_CT_ATTR_COMMIT flag and either @OVS_NAT_ATTR_SRC or
77005752523SJarno Rajahalme  * @OVS_NAT_ATTR_DST is also included.
77105752523SJarno Rajahalme  * @OVS_NAT_ATTR_IP_MIN: struct in_addr or struct in6_addr
77205752523SJarno Rajahalme  * @OVS_NAT_ATTR_IP_MAX: struct in_addr or struct in6_addr
77305752523SJarno Rajahalme  * @OVS_NAT_ATTR_PROTO_MIN: u16 L4 protocol specific lower boundary (port)
77405752523SJarno Rajahalme  * @OVS_NAT_ATTR_PROTO_MAX: u16 L4 protocol specific upper boundary (port)
77505752523SJarno Rajahalme  * @OVS_NAT_ATTR_PERSISTENT: Flag for persistent IP mapping across reboots
77605752523SJarno Rajahalme  * @OVS_NAT_ATTR_PROTO_HASH: Flag for pseudo random L4 port mapping (MD5)
77705752523SJarno Rajahalme  * @OVS_NAT_ATTR_PROTO_RANDOM: Flag for fully randomized L4 port mapping
77805752523SJarno Rajahalme  */
77905752523SJarno Rajahalme enum ovs_nat_attr {
78005752523SJarno Rajahalme 	OVS_NAT_ATTR_UNSPEC,
78105752523SJarno Rajahalme 	OVS_NAT_ATTR_SRC,
78205752523SJarno Rajahalme 	OVS_NAT_ATTR_DST,
78305752523SJarno Rajahalme 	OVS_NAT_ATTR_IP_MIN,
78405752523SJarno Rajahalme 	OVS_NAT_ATTR_IP_MAX,
78505752523SJarno Rajahalme 	OVS_NAT_ATTR_PROTO_MIN,
78605752523SJarno Rajahalme 	OVS_NAT_ATTR_PROTO_MAX,
78705752523SJarno Rajahalme 	OVS_NAT_ATTR_PERSISTENT,
78805752523SJarno Rajahalme 	OVS_NAT_ATTR_PROTO_HASH,
78905752523SJarno Rajahalme 	OVS_NAT_ATTR_PROTO_RANDOM,
79005752523SJarno Rajahalme 	__OVS_NAT_ATTR_MAX,
79105752523SJarno Rajahalme };
79205752523SJarno Rajahalme 
79305752523SJarno Rajahalme #define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1)
79405752523SJarno Rajahalme 
79591820da6SJiri Benc /*
79691820da6SJiri Benc  * struct ovs_action_push_eth - %OVS_ACTION_ATTR_PUSH_ETH action argument.
79791820da6SJiri Benc  * @addresses: Source and destination MAC addresses.
79891820da6SJiri Benc  * @eth_type: Ethernet type
79991820da6SJiri Benc  */
80091820da6SJiri Benc struct ovs_action_push_eth {
80191820da6SJiri Benc 	struct ovs_key_ethernet addresses;
80291820da6SJiri Benc };
80391820da6SJiri Benc 
8044d5ec89fSNuman Siddique /*
8054d5ec89fSNuman Siddique  * enum ovs_check_pkt_len_attr - Attributes for %OVS_ACTION_ATTR_CHECK_PKT_LEN.
8064d5ec89fSNuman Siddique  *
8074d5ec89fSNuman Siddique  * @OVS_CHECK_PKT_LEN_ATTR_PKT_LEN: u16 Packet length to check for.
8084d5ec89fSNuman Siddique  * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER: Nested OVS_ACTION_ATTR_*
8094d5ec89fSNuman Siddique  * actions to apply if the packer length is greater than the specified
8104d5ec89fSNuman Siddique  * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
8114d5ec89fSNuman Siddique  * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL - Nested OVS_ACTION_ATTR_*
8124d5ec89fSNuman Siddique  * actions to apply if the packer length is lesser or equal to the specified
8134d5ec89fSNuman Siddique  * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
8144d5ec89fSNuman Siddique  */
8154d5ec89fSNuman Siddique enum ovs_check_pkt_len_attr {
8164d5ec89fSNuman Siddique 	OVS_CHECK_PKT_LEN_ATTR_UNSPEC,
8174d5ec89fSNuman Siddique 	OVS_CHECK_PKT_LEN_ATTR_PKT_LEN,
8184d5ec89fSNuman Siddique 	OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER,
8194d5ec89fSNuman Siddique 	OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL,
8204d5ec89fSNuman Siddique 	__OVS_CHECK_PKT_LEN_ATTR_MAX,
8214d5ec89fSNuman Siddique 
8224d5ec89fSNuman Siddique #ifdef __KERNEL__
8234d5ec89fSNuman Siddique 	OVS_CHECK_PKT_LEN_ATTR_ARG          /* struct check_pkt_len_arg  */
8244d5ec89fSNuman Siddique #endif
8254d5ec89fSNuman Siddique };
8264d5ec89fSNuman Siddique 
8274d5ec89fSNuman Siddique #define OVS_CHECK_PKT_LEN_ATTR_MAX (__OVS_CHECK_PKT_LEN_ATTR_MAX - 1)
8284d5ec89fSNuman Siddique 
8294d5ec89fSNuman Siddique #ifdef __KERNEL__
8304d5ec89fSNuman Siddique struct check_pkt_len_arg {
8314d5ec89fSNuman Siddique 	u16 pkt_len;	/* Same value as OVS_CHECK_PKT_LEN_ATTR_PKT_LEN'. */
8324d5ec89fSNuman Siddique 	bool exec_for_greater;	/* When true, actions in IF_GREATER will
8334d5ec89fSNuman Siddique 				 * not change flow keys. False otherwise.
8344d5ec89fSNuman Siddique 				 */
8354d5ec89fSNuman Siddique 	bool exec_for_lesser_equal; /* When true, actions in IF_LESS_EQUAL
8364d5ec89fSNuman Siddique 				     * will not change flow keys. False
8374d5ec89fSNuman Siddique 				     * otherwise.
8384d5ec89fSNuman Siddique 				     */
8394d5ec89fSNuman Siddique };
8404d5ec89fSNuman Siddique #endif
8414d5ec89fSNuman Siddique 
84205752523SJarno Rajahalme /**
84322e3880aSThomas Graf  * enum ovs_action_attr - Action types.
84422e3880aSThomas Graf  *
84522e3880aSThomas Graf  * @OVS_ACTION_ATTR_OUTPUT: Output packet to port.
846f2a4d086SWilliam Tu  * @OVS_ACTION_ATTR_TRUNC: Output packet to port with truncated packet size.
84722e3880aSThomas Graf  * @OVS_ACTION_ATTR_USERSPACE: Send packet to userspace according to nested
84822e3880aSThomas Graf  * %OVS_USERSPACE_ATTR_* attributes.
84922e3880aSThomas Graf  * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header.  The
85022e3880aSThomas Graf  * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its
85122e3880aSThomas Graf  * value.
85283d2b9baSJarno Rajahalme  * @OVS_ACTION_ATTR_SET_MASKED: Replaces the contents of an existing header.  A
85383d2b9baSJarno Rajahalme  * nested %OVS_KEY_ATTR_* attribute specifies a header to modify, its value,
85483d2b9baSJarno Rajahalme  * and a mask.  For every bit set in the mask, the corresponding bit value
85583d2b9baSJarno Rajahalme  * is copied from the value to the packet header field, rest of the bits are
85683d2b9baSJarno Rajahalme  * left unchanged.  The non-masked value bits must be passed in as zeroes.
85783d2b9baSJarno Rajahalme  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
8588c146bb9SThomas F Herbert  * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
8598c146bb9SThomas F Herbert  * onto the packet.
8608c146bb9SThomas F Herbert  * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
8618c146bb9SThomas F Herbert  * from the packet.
86222e3880aSThomas Graf  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
86322e3880aSThomas Graf  * the nested %OVS_SAMPLE_ATTR_* attributes.
86425cd9ba0SSimon Horman  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
86525cd9ba0SSimon Horman  * top of the packets MPLS label stack.  Set the ethertype of the
86625cd9ba0SSimon Horman  * encapsulating frame to either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC to
86725cd9ba0SSimon Horman  * indicate the new packet contents.
86825cd9ba0SSimon Horman  * @OVS_ACTION_ATTR_POP_MPLS: Pop an MPLS label stack entry off of the
86925cd9ba0SSimon Horman  * packet's MPLS label stack.  Set the encapsulating frame's ethertype to
87025cd9ba0SSimon Horman  * indicate the new packet contents. This could potentially still be
87125cd9ba0SSimon Horman  * %ETH_P_MPLS if the resulting MPLS label stack is not empty.  If there
87225cd9ba0SSimon Horman  * is no MPLS label stack, as determined by ethertype, no action is taken.
8737f8a436eSJoe Stringer  * @OVS_ACTION_ATTR_CT: Track the connection. Populate the conntrack-related
8747f8a436eSJoe Stringer  * entries in the flow key.
87591820da6SJiri Benc  * @OVS_ACTION_ATTR_PUSH_ETH: Push a new outermost Ethernet header onto the
87691820da6SJiri Benc  * packet.
87791820da6SJiri Benc  * @OVS_ACTION_ATTR_POP_ETH: Pop the outermost Ethernet header off the
87891820da6SJiri Benc  * packet.
879b8226962SEric Garver  * @OVS_ACTION_ATTR_CT_CLEAR: Clear conntrack state from the packet.
880b2d0f5d5SYi Yang  * @OVS_ACTION_ATTR_PUSH_NSH: push NSH header to the packet.
881b2d0f5d5SYi Yang  * @OVS_ACTION_ATTR_POP_NSH: pop the outermost NSH header off the packet.
882cd8a6c33SAndy Zhou  * @OVS_ACTION_ATTR_METER: Run packet through a meter, which may drop the
883cd8a6c33SAndy Zhou  * packet, or modify the packet (e.g., change the DSCP field).
884b2335040SYifeng Sun  * @OVS_ACTION_ATTR_CLONE: make a copy of the packet and execute a list of
885b2335040SYifeng Sun  * actions without affecting the original packet and key.
8864d5ec89fSNuman Siddique  * @OVS_ACTION_ATTR_CHECK_PKT_LEN: Check the packet length and execute a set
8874d5ec89fSNuman Siddique  * of actions if greater than the specified packet length, else execute
8884d5ec89fSNuman Siddique  * another set of actions.
88922e3880aSThomas Graf  *
89022e3880aSThomas Graf  * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  Not all
89122e3880aSThomas Graf  * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
89222e3880aSThomas Graf  * type may not be changed.
89383d2b9baSJarno Rajahalme  *
89483d2b9baSJarno Rajahalme  * @OVS_ACTION_ATTR_SET_TO_MASKED: Kernel internal masked set action translated
89583d2b9baSJarno Rajahalme  * from the @OVS_ACTION_ATTR_SET.
89622e3880aSThomas Graf  */
89722e3880aSThomas Graf 
89822e3880aSThomas Graf enum ovs_action_attr {
89922e3880aSThomas Graf 	OVS_ACTION_ATTR_UNSPEC,
90022e3880aSThomas Graf 	OVS_ACTION_ATTR_OUTPUT,	      /* u32 port number. */
90122e3880aSThomas Graf 	OVS_ACTION_ATTR_USERSPACE,    /* Nested OVS_USERSPACE_ATTR_*. */
90222e3880aSThomas Graf 	OVS_ACTION_ATTR_SET,          /* One nested OVS_KEY_ATTR_*. */
90322e3880aSThomas Graf 	OVS_ACTION_ATTR_PUSH_VLAN,    /* struct ovs_action_push_vlan. */
90422e3880aSThomas Graf 	OVS_ACTION_ATTR_POP_VLAN,     /* No argument. */
90522e3880aSThomas Graf 	OVS_ACTION_ATTR_SAMPLE,       /* Nested OVS_SAMPLE_ATTR_*. */
906971427f3SAndy Zhou 	OVS_ACTION_ATTR_RECIRC,       /* u32 recirc_id. */
907971427f3SAndy Zhou 	OVS_ACTION_ATTR_HASH,	      /* struct ovs_action_hash. */
90825cd9ba0SSimon Horman 	OVS_ACTION_ATTR_PUSH_MPLS,    /* struct ovs_action_push_mpls. */
90925cd9ba0SSimon Horman 	OVS_ACTION_ATTR_POP_MPLS,     /* __be16 ethertype. */
91083d2b9baSJarno Rajahalme 	OVS_ACTION_ATTR_SET_MASKED,   /* One nested OVS_KEY_ATTR_* including
91183d2b9baSJarno Rajahalme 				       * data immediately followed by a mask.
91283d2b9baSJarno Rajahalme 				       * The data must be zero for the unmasked
91383d2b9baSJarno Rajahalme 				       * bits. */
9140a7cc172SJoe Stringer 	OVS_ACTION_ATTR_CT,           /* Nested OVS_CT_ATTR_* . */
915f2a4d086SWilliam Tu 	OVS_ACTION_ATTR_TRUNC,        /* u32 struct ovs_action_trunc. */
91691820da6SJiri Benc 	OVS_ACTION_ATTR_PUSH_ETH,     /* struct ovs_action_push_eth. */
91791820da6SJiri Benc 	OVS_ACTION_ATTR_POP_ETH,      /* No argument. */
918b8226962SEric Garver 	OVS_ACTION_ATTR_CT_CLEAR,     /* No argument. */
919b2d0f5d5SYi Yang 	OVS_ACTION_ATTR_PUSH_NSH,     /* Nested OVS_NSH_KEY_ATTR_*. */
920b2d0f5d5SYi Yang 	OVS_ACTION_ATTR_POP_NSH,      /* No argument. */
921cd8a6c33SAndy Zhou 	OVS_ACTION_ATTR_METER,        /* u32 meter ID. */
922b2335040SYifeng Sun 	OVS_ACTION_ATTR_CLONE,        /* Nested OVS_CLONE_ATTR_*.  */
9234d5ec89fSNuman Siddique 	OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
92425cd9ba0SSimon Horman 
92583d2b9baSJarno Rajahalme 	__OVS_ACTION_ATTR_MAX,	      /* Nothing past this will be accepted
92683d2b9baSJarno Rajahalme 				       * from userspace. */
92783d2b9baSJarno Rajahalme 
92883d2b9baSJarno Rajahalme #ifdef __KERNEL__
92983d2b9baSJarno Rajahalme 	OVS_ACTION_ATTR_SET_TO_MASKED, /* Kernel module internal masked
93083d2b9baSJarno Rajahalme 					* set action converted from
93183d2b9baSJarno Rajahalme 					* OVS_ACTION_ATTR_SET. */
93283d2b9baSJarno Rajahalme #endif
93322e3880aSThomas Graf };
93422e3880aSThomas Graf 
93522e3880aSThomas Graf #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
93622e3880aSThomas Graf 
93757940406SAndy Zhou /* Meters. */
93857940406SAndy Zhou #define OVS_METER_FAMILY  "ovs_meter"
93957940406SAndy Zhou #define OVS_METER_MCGROUP "ovs_meter"
94057940406SAndy Zhou #define OVS_METER_VERSION 0x1
94157940406SAndy Zhou 
94257940406SAndy Zhou enum ovs_meter_cmd {
94357940406SAndy Zhou 	OVS_METER_CMD_UNSPEC,
94457940406SAndy Zhou 	OVS_METER_CMD_FEATURES,	/* Get features supported by the datapath. */
94557940406SAndy Zhou 	OVS_METER_CMD_SET,	/* Add or modify a meter. */
94657940406SAndy Zhou 	OVS_METER_CMD_DEL,	/* Delete a meter. */
94757940406SAndy Zhou 	OVS_METER_CMD_GET	/* Get meter stats. */
94857940406SAndy Zhou };
94957940406SAndy Zhou 
95057940406SAndy Zhou enum ovs_meter_attr {
95157940406SAndy Zhou 	OVS_METER_ATTR_UNSPEC,
95257940406SAndy Zhou 	OVS_METER_ATTR_ID,	/* u32 meter ID within datapath. */
95357940406SAndy Zhou 	OVS_METER_ATTR_KBPS,	/* No argument. If set, units in kilobits
95457940406SAndy Zhou 				 * per second. Otherwise, units in
95557940406SAndy Zhou 				 * packets per second.
95657940406SAndy Zhou 				 */
95757940406SAndy Zhou 	OVS_METER_ATTR_STATS,	/* struct ovs_flow_stats for the meter. */
95857940406SAndy Zhou 	OVS_METER_ATTR_BANDS,	/* Nested attributes for meter bands. */
95957940406SAndy Zhou 	OVS_METER_ATTR_USED,	/* u64 msecs last used in monotonic time. */
96057940406SAndy Zhou 	OVS_METER_ATTR_CLEAR,	/* Flag to clear stats, used. */
96157940406SAndy Zhou 	OVS_METER_ATTR_MAX_METERS, /* u32 number of meters supported. */
96257940406SAndy Zhou 	OVS_METER_ATTR_MAX_BANDS,  /* u32 max number of bands per meter. */
96357940406SAndy Zhou 	OVS_METER_ATTR_PAD,
96457940406SAndy Zhou 	__OVS_METER_ATTR_MAX
96557940406SAndy Zhou };
96657940406SAndy Zhou 
96757940406SAndy Zhou #define OVS_METER_ATTR_MAX (__OVS_METER_ATTR_MAX - 1)
96857940406SAndy Zhou 
96957940406SAndy Zhou enum ovs_band_attr {
97057940406SAndy Zhou 	OVS_BAND_ATTR_UNSPEC,
97157940406SAndy Zhou 	OVS_BAND_ATTR_TYPE,	/* u32 OVS_METER_BAND_TYPE_* constant. */
97257940406SAndy Zhou 	OVS_BAND_ATTR_RATE,	/* u32 band rate in meter units (see above). */
97357940406SAndy Zhou 	OVS_BAND_ATTR_BURST,	/* u32 burst size in meter units. */
97457940406SAndy Zhou 	OVS_BAND_ATTR_STATS,	/* struct ovs_flow_stats for the band. */
97557940406SAndy Zhou 	__OVS_BAND_ATTR_MAX
97657940406SAndy Zhou };
97757940406SAndy Zhou 
97857940406SAndy Zhou #define OVS_BAND_ATTR_MAX (__OVS_BAND_ATTR_MAX - 1)
97957940406SAndy Zhou 
98057940406SAndy Zhou enum ovs_meter_band_type {
98157940406SAndy Zhou 	OVS_METER_BAND_TYPE_UNSPEC,
98257940406SAndy Zhou 	OVS_METER_BAND_TYPE_DROP,   /* Drop exceeding packets. */
98357940406SAndy Zhou 	__OVS_METER_BAND_TYPE_MAX
98457940406SAndy Zhou };
98557940406SAndy Zhou 
98657940406SAndy Zhou #define OVS_METER_BAND_TYPE_MAX (__OVS_METER_BAND_TYPE_MAX - 1)
98757940406SAndy Zhou 
9885972be6bSYi-Hung Wei /* Conntrack limit */
9895972be6bSYi-Hung Wei #define OVS_CT_LIMIT_FAMILY  "ovs_ct_limit"
9905972be6bSYi-Hung Wei #define OVS_CT_LIMIT_MCGROUP "ovs_ct_limit"
9915972be6bSYi-Hung Wei #define OVS_CT_LIMIT_VERSION 0x1
9925972be6bSYi-Hung Wei 
9935972be6bSYi-Hung Wei enum ovs_ct_limit_cmd {
9945972be6bSYi-Hung Wei 	OVS_CT_LIMIT_CMD_UNSPEC,
9955972be6bSYi-Hung Wei 	OVS_CT_LIMIT_CMD_SET,		/* Add or modify ct limit. */
9965972be6bSYi-Hung Wei 	OVS_CT_LIMIT_CMD_DEL,		/* Delete ct limit. */
9975972be6bSYi-Hung Wei 	OVS_CT_LIMIT_CMD_GET		/* Get ct limit. */
9985972be6bSYi-Hung Wei };
9995972be6bSYi-Hung Wei 
10005972be6bSYi-Hung Wei enum ovs_ct_limit_attr {
10015972be6bSYi-Hung Wei 	OVS_CT_LIMIT_ATTR_UNSPEC,
10025972be6bSYi-Hung Wei 	OVS_CT_LIMIT_ATTR_ZONE_LIMIT,	/* Nested struct ovs_zone_limit. */
10035972be6bSYi-Hung Wei 	__OVS_CT_LIMIT_ATTR_MAX
10045972be6bSYi-Hung Wei };
10055972be6bSYi-Hung Wei 
10065972be6bSYi-Hung Wei #define OVS_CT_LIMIT_ATTR_MAX (__OVS_CT_LIMIT_ATTR_MAX - 1)
10075972be6bSYi-Hung Wei 
10085972be6bSYi-Hung Wei #define OVS_ZONE_LIMIT_DEFAULT_ZONE -1
10095972be6bSYi-Hung Wei 
10105972be6bSYi-Hung Wei struct ovs_zone_limit {
10115972be6bSYi-Hung Wei 	int zone_id;
10125972be6bSYi-Hung Wei 	__u32 limit;
10135972be6bSYi-Hung Wei 	__u32 count;
10145972be6bSYi-Hung Wei };
10155972be6bSYi-Hung Wei 
101622e3880aSThomas Graf #endif /* _LINUX_OPENVSWITCH_H */
1017