1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 
3 /*
4  * Copyright (c) 2007-2017 Nicira, Inc.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA
19  */
20 
21 #ifndef _UAPI__LINUX_OPENVSWITCH_H
22 #define _UAPI__LINUX_OPENVSWITCH_H 1
23 
24 #include <linux/types.h>
25 #include <linux/if_ether.h>
26 
27 /**
28  * struct ovs_header - header for OVS Generic Netlink messages.
29  * @dp_ifindex: ifindex of local port for datapath (0 to make a request not
30  * specific to a datapath).
31  *
32  * Attributes following the header are specific to a particular OVS Generic
33  * Netlink family, but all of the OVS families use this header.
34  */
35 
36 struct ovs_header {
37 	int dp_ifindex;
38 };
39 
40 /* Datapaths. */
41 
42 #define OVS_DATAPATH_FAMILY  "ovs_datapath"
43 #define OVS_DATAPATH_MCGROUP "ovs_datapath"
44 
45 /* V2:
46  *   - API users are expected to provide OVS_DP_ATTR_USER_FEATURES
47  *     when creating the datapath.
48  */
49 #define OVS_DATAPATH_VERSION 2
50 
51 /* First OVS datapath version to support features */
52 #define OVS_DP_VER_FEATURES 2
53 
54 enum ovs_datapath_cmd {
55 	OVS_DP_CMD_UNSPEC,
56 	OVS_DP_CMD_NEW,
57 	OVS_DP_CMD_DEL,
58 	OVS_DP_CMD_GET,
59 	OVS_DP_CMD_SET
60 };
61 
62 /**
63  * enum ovs_datapath_attr - attributes for %OVS_DP_* commands.
64  * @OVS_DP_ATTR_NAME: Name of the network device that serves as the "local
65  * port".  This is the name of the network device whose dp_ifindex is given in
66  * the &struct ovs_header.  Always present in notifications.  Required in
67  * %OVS_DP_NEW requests.  May be used as an alternative to specifying
68  * dp_ifindex in other requests (with a dp_ifindex of 0).
69  * @OVS_DP_ATTR_UPCALL_PID: The Netlink socket in userspace that is initially
70  * set on the datapath port (for OVS_ACTION_ATTR_MISS).  Only valid on
71  * %OVS_DP_CMD_NEW requests. A value of zero indicates that upcalls should
72  * not be sent.
73  * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the
74  * datapath.  Always present in notifications.
75  * @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the
76  * datapath. Always present in notifications.
77  *
78  * These attributes follow the &struct ovs_header within the Generic Netlink
79  * payload for %OVS_DP_* commands.
80  */
81 enum ovs_datapath_attr {
82 	OVS_DP_ATTR_UNSPEC,
83 	OVS_DP_ATTR_NAME,		/* name of dp_ifindex netdev */
84 	OVS_DP_ATTR_UPCALL_PID,		/* Netlink PID to receive upcalls */
85 	OVS_DP_ATTR_STATS,		/* struct ovs_dp_stats */
86 	OVS_DP_ATTR_MEGAFLOW_STATS,	/* struct ovs_dp_megaflow_stats */
87 	OVS_DP_ATTR_USER_FEATURES,	/* OVS_DP_F_*  */
88 	OVS_DP_ATTR_PAD,
89 	OVS_DP_ATTR_MASKS_CACHE_SIZE,
90 	__OVS_DP_ATTR_MAX
91 };
92 
93 #define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1)
94 
95 struct ovs_dp_stats {
96 	uint64_t n_hit;             /* Number of flow table matches. */
97 	uint64_t n_missed;          /* Number of flow table misses. */
98 	uint64_t n_lost;            /* Number of misses not sent to userspace. */
99 	uint64_t n_flows;           /* Number of flows present */
100 };
101 
102 struct ovs_dp_megaflow_stats {
103 	uint64_t n_mask_hit;	 /* Number of masks used for flow lookups. */
104 	uint32_t n_masks;		 /* Number of masks for the datapath. */
105 	uint32_t pad0;		 /* Pad for future expension. */
106 	uint64_t n_cache_hit;       /* Number of cache matches for flow lookups. */
107 	uint64_t pad1;		 /* Pad for future expension. */
108 };
109 
110 struct ovs_vport_stats {
111 	uint64_t   rx_packets;		/* total packets received       */
112 	uint64_t   tx_packets;		/* total packets transmitted    */
113 	uint64_t   rx_bytes;		/* total bytes received         */
114 	uint64_t   tx_bytes;		/* total bytes transmitted      */
115 	uint64_t   rx_errors;		/* bad packets received         */
116 	uint64_t   tx_errors;		/* packet transmit problems     */
117 	uint64_t   rx_dropped;		/* no space in linux buffers    */
118 	uint64_t   tx_dropped;		/* no space available in linux  */
119 };
120 
121 /* Allow last Netlink attribute to be unaligned */
122 #define OVS_DP_F_UNALIGNED	(1 << 0)
123 
124 /* Allow datapath to associate multiple Netlink PIDs to each vport */
125 #define OVS_DP_F_VPORT_PIDS	(1 << 1)
126 
127 /* Allow tc offload recirc sharing */
128 #define OVS_DP_F_TC_RECIRC_SHARING	(1 << 2)
129 
130 /* Fixed logical ports. */
131 #define OVSP_LOCAL      ((uint32_t)0)
132 
133 /* Packet transfer. */
134 
135 #define OVS_PACKET_FAMILY "ovs_packet"
136 #define OVS_PACKET_VERSION 0x1
137 
138 enum ovs_packet_cmd {
139 	OVS_PACKET_CMD_UNSPEC,
140 
141 	/* Kernel-to-user notifications. */
142 	OVS_PACKET_CMD_MISS,    /* Flow table miss. */
143 	OVS_PACKET_CMD_ACTION,  /* OVS_ACTION_ATTR_USERSPACE action. */
144 
145 	/* Userspace commands. */
146 	OVS_PACKET_CMD_EXECUTE  /* Apply actions to a packet. */
147 };
148 
149 /**
150  * enum ovs_packet_attr - attributes for %OVS_PACKET_* commands.
151  * @OVS_PACKET_ATTR_PACKET: Present for all notifications.  Contains the entire
152  * packet as received, from the start of the Ethernet header onward.  For
153  * %OVS_PACKET_CMD_ACTION, %OVS_PACKET_ATTR_PACKET reflects changes made by
154  * actions preceding %OVS_ACTION_ATTR_USERSPACE, but %OVS_PACKET_ATTR_KEY is
155  * the flow key extracted from the packet as originally received.
156  * @OVS_PACKET_ATTR_KEY: Present for all notifications.  Contains the flow key
157  * extracted from the packet as nested %OVS_KEY_ATTR_* attributes.  This allows
158  * userspace to adapt its flow setup strategy by comparing its notion of the
159  * flow key against the kernel's.
160  * @OVS_PACKET_ATTR_ACTIONS: Contains actions for the packet.  Used
161  * for %OVS_PACKET_CMD_EXECUTE.  It has nested %OVS_ACTION_ATTR_* attributes.
162  * Also used in upcall when %OVS_ACTION_ATTR_USERSPACE has optional
163  * %OVS_USERSPACE_ATTR_ACTIONS attribute.
164  * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION
165  * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
166  * %OVS_USERSPACE_ATTR_USERDATA attribute, with the same length and content
167  * specified there.
168  * @OVS_PACKET_ATTR_EGRESS_TUN_KEY: Present for an %OVS_PACKET_CMD_ACTION
169  * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
170  * %OVS_USERSPACE_ATTR_EGRESS_TUN_PORT attribute, which is sent only if the
171  * output port is actually a tunnel port. Contains the output tunnel key
172  * extracted from the packet as nested %OVS_TUNNEL_KEY_ATTR_* attributes.
173  * @OVS_PACKET_ATTR_MRU: Present for an %OVS_PACKET_CMD_ACTION and
174  * @OVS_PACKET_ATTR_LEN: Packet size before truncation.
175  * %OVS_PACKET_ATTR_USERSPACE action specify the Maximum received fragment
176  * size.
177  * @OVS_PACKET_ATTR_HASH: Packet hash info (e.g. hash, sw_hash and l4_hash in skb).
178  *
179  * These attributes follow the &struct ovs_header within the Generic Netlink
180  * payload for %OVS_PACKET_* commands.
181  */
182 enum ovs_packet_attr {
183 	OVS_PACKET_ATTR_UNSPEC,
184 	OVS_PACKET_ATTR_PACKET,      /* Packet data. */
185 	OVS_PACKET_ATTR_KEY,         /* Nested OVS_KEY_ATTR_* attributes. */
186 	OVS_PACKET_ATTR_ACTIONS,     /* Nested OVS_ACTION_ATTR_* attributes. */
187 	OVS_PACKET_ATTR_USERDATA,    /* OVS_ACTION_ATTR_USERSPACE arg. */
188 	OVS_PACKET_ATTR_EGRESS_TUN_KEY,  /* Nested OVS_TUNNEL_KEY_ATTR_*
189 					    attributes. */
190 	OVS_PACKET_ATTR_UNUSED1,
191 	OVS_PACKET_ATTR_UNUSED2,
192 	OVS_PACKET_ATTR_PROBE,      /* Packet operation is a feature probe,
193 				       error logging should be suppressed. */
194 	OVS_PACKET_ATTR_MRU,	    /* Maximum received IP fragment size. */
195 	OVS_PACKET_ATTR_LEN,	    /* Packet size before truncation. */
196 	OVS_PACKET_ATTR_HASH,	    /* Packet hash. */
197 	__OVS_PACKET_ATTR_MAX
198 };
199 
200 #define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1)
201 
202 /* Virtual ports. */
203 
204 #define OVS_VPORT_FAMILY  "ovs_vport"
205 #define OVS_VPORT_MCGROUP "ovs_vport"
206 #define OVS_VPORT_VERSION 0x1
207 
208 enum ovs_vport_cmd {
209 	OVS_VPORT_CMD_UNSPEC,
210 	OVS_VPORT_CMD_NEW,
211 	OVS_VPORT_CMD_DEL,
212 	OVS_VPORT_CMD_GET,
213 	OVS_VPORT_CMD_SET
214 };
215 
216 enum ovs_vport_type {
217 	OVS_VPORT_TYPE_UNSPEC,
218 	OVS_VPORT_TYPE_NETDEV,   /* network device */
219 	OVS_VPORT_TYPE_INTERNAL, /* network device implemented by datapath */
220 	OVS_VPORT_TYPE_GRE,      /* GRE tunnel. */
221 	OVS_VPORT_TYPE_VXLAN,	 /* VXLAN tunnel. */
222 	OVS_VPORT_TYPE_GENEVE,	 /* Geneve tunnel. */
223 	__OVS_VPORT_TYPE_MAX
224 };
225 
226 #define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1)
227 
228 /**
229  * enum ovs_vport_attr - attributes for %OVS_VPORT_* commands.
230  * @OVS_VPORT_ATTR_PORT_NO: 32-bit port number within datapath.
231  * @OVS_VPORT_ATTR_TYPE: 32-bit %OVS_VPORT_TYPE_* constant describing the type
232  * of vport.
233  * @OVS_VPORT_ATTR_NAME: Name of vport.  For a vport based on a network device
234  * this is the name of the network device.  Maximum length %IFNAMSIZ-1 bytes
235  * plus a null terminator.
236  * @OVS_VPORT_ATTR_OPTIONS: Vport-specific configuration information.
237  * @OVS_VPORT_ATTR_UPCALL_PID: The array of Netlink socket pids in userspace
238  * among which OVS_PACKET_CMD_MISS upcalls will be distributed for packets
239  * received on this port.  If this is a single-element array of value 0,
240  * upcalls should not be sent.
241  * @OVS_VPORT_ATTR_STATS: A &struct ovs_vport_stats giving statistics for
242  * packets sent or received through the vport.
243  *
244  * These attributes follow the &struct ovs_header within the Generic Netlink
245  * payload for %OVS_VPORT_* commands.
246  *
247  * For %OVS_VPORT_CMD_NEW requests, the %OVS_VPORT_ATTR_TYPE and
248  * %OVS_VPORT_ATTR_NAME attributes are required.  %OVS_VPORT_ATTR_PORT_NO is
249  * optional; if not specified a free port number is automatically selected.
250  * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type
251  * of vport.
252  *
253  * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to
254  * look up the vport to operate on; otherwise dp_idx from the &struct
255  * ovs_header plus %OVS_VPORT_ATTR_PORT_NO determine the vport.
256  */
257 enum ovs_vport_attr {
258 	OVS_VPORT_ATTR_UNSPEC,
259 	OVS_VPORT_ATTR_PORT_NO,	/* u32 port number within datapath */
260 	OVS_VPORT_ATTR_TYPE,	/* u32 OVS_VPORT_TYPE_* constant. */
261 	OVS_VPORT_ATTR_NAME,	/* string name, up to IFNAMSIZ bytes long */
262 	OVS_VPORT_ATTR_OPTIONS, /* nested attributes, varies by vport type */
263 	OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */
264 				/* receiving upcalls */
265 	OVS_VPORT_ATTR_STATS,	/* struct ovs_vport_stats */
266 	OVS_VPORT_ATTR_PAD,
267 	OVS_VPORT_ATTR_IFINDEX,
268 	OVS_VPORT_ATTR_NETNSID,
269 	__OVS_VPORT_ATTR_MAX
270 };
271 
272 #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1)
273 
274 enum {
275 	OVS_VXLAN_EXT_UNSPEC,
276 	OVS_VXLAN_EXT_GBP,	/* Flag or uint32_t */
277 	__OVS_VXLAN_EXT_MAX,
278 };
279 
280 #define OVS_VXLAN_EXT_MAX (__OVS_VXLAN_EXT_MAX - 1)
281 
282 
283 /* OVS_VPORT_ATTR_OPTIONS attributes for tunnels.
284  */
285 enum {
286 	OVS_TUNNEL_ATTR_UNSPEC,
287 	OVS_TUNNEL_ATTR_DST_PORT, /* 16-bit UDP port, used by L4 tunnels. */
288 	OVS_TUNNEL_ATTR_EXTENSION,
289 	__OVS_TUNNEL_ATTR_MAX
290 };
291 
292 #define OVS_TUNNEL_ATTR_MAX (__OVS_TUNNEL_ATTR_MAX - 1)
293 
294 /* Flows. */
295 
296 #define OVS_FLOW_FAMILY  "ovs_flow"
297 #define OVS_FLOW_MCGROUP "ovs_flow"
298 #define OVS_FLOW_VERSION 0x1
299 
300 enum ovs_flow_cmd {
301 	OVS_FLOW_CMD_UNSPEC,
302 	OVS_FLOW_CMD_NEW,
303 	OVS_FLOW_CMD_DEL,
304 	OVS_FLOW_CMD_GET,
305 	OVS_FLOW_CMD_SET
306 };
307 
308 struct ovs_flow_stats {
309 	uint64_t n_packets;         /* Number of matched packets. */
310 	uint64_t n_bytes;           /* Number of matched bytes. */
311 };
312 
313 enum ovs_key_attr {
314 	OVS_KEY_ATTR_UNSPEC,
315 	OVS_KEY_ATTR_ENCAP,	/* Nested set of encapsulated attributes. */
316 	OVS_KEY_ATTR_PRIORITY,  /* u32 skb->priority */
317 	OVS_KEY_ATTR_IN_PORT,   /* u32 OVS dp port number */
318 	OVS_KEY_ATTR_ETHERNET,  /* struct ovs_key_ethernet */
319 	OVS_KEY_ATTR_VLAN,	/* be16 VLAN TCI */
320 	OVS_KEY_ATTR_ETHERTYPE,	/* be16 Ethernet type */
321 	OVS_KEY_ATTR_IPV4,      /* struct ovs_key_ipv4 */
322 	OVS_KEY_ATTR_IPV6,      /* struct ovs_key_ipv6 */
323 	OVS_KEY_ATTR_TCP,       /* struct ovs_key_tcp */
324 	OVS_KEY_ATTR_UDP,       /* struct ovs_key_udp */
325 	OVS_KEY_ATTR_ICMP,      /* struct ovs_key_icmp */
326 	OVS_KEY_ATTR_ICMPV6,    /* struct ovs_key_icmpv6 */
327 	OVS_KEY_ATTR_ARP,       /* struct ovs_key_arp */
328 	OVS_KEY_ATTR_ND,        /* struct ovs_key_nd */
329 	OVS_KEY_ATTR_SKB_MARK,  /* u32 skb mark */
330 	OVS_KEY_ATTR_TUNNEL,    /* Nested set of ovs_tunnel attributes */
331 	OVS_KEY_ATTR_SCTP,      /* struct ovs_key_sctp */
332 	OVS_KEY_ATTR_TCP_FLAGS,	/* be16 TCP flags. */
333 	OVS_KEY_ATTR_DP_HASH,      /* u32 hash value. Value 0 indicates the hash
334 				   is not computed by the datapath. */
335 	OVS_KEY_ATTR_RECIRC_ID, /* u32 recirc id */
336 	OVS_KEY_ATTR_MPLS,      /* array of struct ovs_key_mpls.
337 				 * The implementation may restrict
338 				 * the accepted length of the array. */
339 	OVS_KEY_ATTR_CT_STATE,	/* u32 bitmask of OVS_CS_F_* */
340 	OVS_KEY_ATTR_CT_ZONE,	/* u16 connection tracking zone. */
341 	OVS_KEY_ATTR_CT_MARK,	/* u32 connection tracking mark */
342 	OVS_KEY_ATTR_CT_LABELS,	/* 16-octet connection tracking label */
343 	OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4,   /* struct ovs_key_ct_tuple_ipv4 */
344 	OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6,   /* struct ovs_key_ct_tuple_ipv6 */
345 	OVS_KEY_ATTR_NSH,       /* Nested set of ovs_nsh_key_* */
346 
347 #ifdef __KERNEL__
348 	OVS_KEY_ATTR_TUNNEL_INFO,  /* struct ip_tunnel_info */
349 #endif
350 	__OVS_KEY_ATTR_MAX
351 };
352 
353 #define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1)
354 
355 enum ovs_tunnel_key_attr {
356 	/* OVS_TUNNEL_KEY_ATTR_NONE, standard nl API requires this attribute! */
357 	OVS_TUNNEL_KEY_ATTR_ID,                 /* be64 Tunnel ID */
358 	OVS_TUNNEL_KEY_ATTR_IPV4_SRC,           /* be32 src IP address. */
359 	OVS_TUNNEL_KEY_ATTR_IPV4_DST,           /* be32 dst IP address. */
360 	OVS_TUNNEL_KEY_ATTR_TOS,                /* u8 Tunnel IP ToS. */
361 	OVS_TUNNEL_KEY_ATTR_TTL,                /* u8 Tunnel IP TTL. */
362 	OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT,      /* No argument, set DF. */
363 	OVS_TUNNEL_KEY_ATTR_CSUM,               /* No argument. CSUM packet. */
364 	OVS_TUNNEL_KEY_ATTR_OAM,                /* No argument. OAM frame.  */
365 	OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS,        /* Array of Geneve options. */
366 	OVS_TUNNEL_KEY_ATTR_TP_SRC,		/* be16 src Transport Port. */
367 	OVS_TUNNEL_KEY_ATTR_TP_DST,		/* be16 dst Transport Port. */
368 	OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS,		/* Nested OVS_VXLAN_EXT_* */
369 	OVS_TUNNEL_KEY_ATTR_IPV6_SRC,		/* struct in6_addr src IPv6 address. */
370 	OVS_TUNNEL_KEY_ATTR_IPV6_DST,		/* struct in6_addr dst IPv6 address. */
371 	OVS_TUNNEL_KEY_ATTR_PAD,
372 	OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS,	/* struct erspan_metadata */
373 	OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE,	/* No argument. IPV4_INFO_BRIDGE mode.*/
374 	__OVS_TUNNEL_KEY_ATTR_MAX
375 };
376 
377 #define OVS_TUNNEL_KEY_ATTR_MAX (__OVS_TUNNEL_KEY_ATTR_MAX - 1)
378 
379 /**
380  * enum ovs_frag_type - IPv4 and IPv6 fragment type
381  * @OVS_FRAG_TYPE_NONE: Packet is not a fragment.
382  * @OVS_FRAG_TYPE_FIRST: Packet is a fragment with offset 0.
383  * @OVS_FRAG_TYPE_LATER: Packet is a fragment with nonzero offset.
384  *
385  * Used as the @ipv4_frag in &struct ovs_key_ipv4 and as @ipv6_frag &struct
386  * ovs_key_ipv6.
387  */
388 enum ovs_frag_type {
389 	OVS_FRAG_TYPE_NONE,
390 	OVS_FRAG_TYPE_FIRST,
391 	OVS_FRAG_TYPE_LATER,
392 	__OVS_FRAG_TYPE_MAX
393 };
394 
395 #define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1)
396 
397 struct ovs_key_ethernet {
398 	uint8_t	 eth_src[ETH_ALEN];
399 	uint8_t	 eth_dst[ETH_ALEN];
400 };
401 
402 struct ovs_key_mpls {
403 	uint32_t mpls_lse;
404 };
405 
406 struct ovs_key_ipv4 {
407 	uint32_t ipv4_src;
408 	uint32_t ipv4_dst;
409 	uint8_t   ipv4_proto;
410 	uint8_t   ipv4_tos;
411 	uint8_t   ipv4_ttl;
412 	uint8_t   ipv4_frag;	/* One of OVS_FRAG_TYPE_*. */
413 };
414 
415 struct ovs_key_ipv6 {
416 	uint32_t ipv6_src[4];
417 	uint32_t ipv6_dst[4];
418 	uint32_t ipv6_label;	/* 20-bits in least-significant bits. */
419 	uint8_t   ipv6_proto;
420 	uint8_t   ipv6_tclass;
421 	uint8_t   ipv6_hlimit;
422 	uint8_t   ipv6_frag;	/* One of OVS_FRAG_TYPE_*. */
423 };
424 
425 struct ovs_key_tcp {
426 	uint16_t tcp_src;
427 	uint16_t tcp_dst;
428 };
429 
430 struct ovs_key_udp {
431 	uint16_t udp_src;
432 	uint16_t udp_dst;
433 };
434 
435 struct ovs_key_sctp {
436 	uint16_t sctp_src;
437 	uint16_t sctp_dst;
438 };
439 
440 struct ovs_key_icmp {
441 	uint8_t icmp_type;
442 	uint8_t icmp_code;
443 };
444 
445 struct ovs_key_icmpv6 {
446 	uint8_t icmpv6_type;
447 	uint8_t icmpv6_code;
448 };
449 
450 struct ovs_key_arp {
451 	uint32_t arp_sip;
452 	uint32_t arp_tip;
453 	uint16_t arp_op;
454 	uint8_t   arp_sha[ETH_ALEN];
455 	uint8_t   arp_tha[ETH_ALEN];
456 };
457 
458 struct ovs_key_nd {
459 	uint32_t	nd_target[4];
460 	uint8_t	nd_sll[ETH_ALEN];
461 	uint8_t	nd_tll[ETH_ALEN];
462 };
463 
464 #define OVS_CT_LABELS_LEN_32	4
465 #define OVS_CT_LABELS_LEN	(OVS_CT_LABELS_LEN_32 * sizeof(uint32_t))
466 struct ovs_key_ct_labels {
467 	union {
468 		uint8_t	ct_labels[OVS_CT_LABELS_LEN];
469 		uint32_t	ct_labels_32[OVS_CT_LABELS_LEN_32];
470 	};
471 };
472 
473 /* OVS_KEY_ATTR_CT_STATE flags */
474 #define OVS_CS_F_NEW               0x01 /* Beginning of a new connection. */
475 #define OVS_CS_F_ESTABLISHED       0x02 /* Part of an existing connection. */
476 #define OVS_CS_F_RELATED           0x04 /* Related to an established
477 					 * connection. */
478 #define OVS_CS_F_REPLY_DIR         0x08 /* Flow is in the reply direction. */
479 #define OVS_CS_F_INVALID           0x10 /* Could not track connection. */
480 #define OVS_CS_F_TRACKED           0x20 /* Conntrack has occurred. */
481 #define OVS_CS_F_SRC_NAT           0x40 /* Packet's source address/port was
482 					 * mangled by NAT.
483 					 */
484 #define OVS_CS_F_DST_NAT           0x80 /* Packet's destination address/port
485 					 * was mangled by NAT.
486 					 */
487 
488 #define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
489 
490 struct ovs_key_ct_tuple_ipv4 {
491 	uint32_t ipv4_src;
492 	uint32_t ipv4_dst;
493 	uint16_t src_port;
494 	uint16_t dst_port;
495 	uint8_t   ipv4_proto;
496 };
497 
498 struct ovs_key_ct_tuple_ipv6 {
499 	uint32_t ipv6_src[4];
500 	uint32_t ipv6_dst[4];
501 	uint16_t src_port;
502 	uint16_t dst_port;
503 	uint8_t   ipv6_proto;
504 };
505 
506 enum ovs_nsh_key_attr {
507 	OVS_NSH_KEY_ATTR_UNSPEC,
508 	OVS_NSH_KEY_ATTR_BASE,  /* struct ovs_nsh_key_base. */
509 	OVS_NSH_KEY_ATTR_MD1,   /* struct ovs_nsh_key_md1. */
510 	OVS_NSH_KEY_ATTR_MD2,   /* variable-length octets for MD type 2. */
511 	__OVS_NSH_KEY_ATTR_MAX
512 };
513 
514 #define OVS_NSH_KEY_ATTR_MAX (__OVS_NSH_KEY_ATTR_MAX - 1)
515 
516 struct ovs_nsh_key_base {
517 	uint8_t flags;
518 	uint8_t ttl;
519 	uint8_t mdtype;
520 	uint8_t np;
521 	uint32_t path_hdr;
522 };
523 
524 #define NSH_MD1_CONTEXT_SIZE 4
525 
526 struct ovs_nsh_key_md1 {
527 	uint32_t context[NSH_MD1_CONTEXT_SIZE];
528 };
529 
530 /**
531  * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.
532  * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow
533  * key.  Always present in notifications.  Required for all requests (except
534  * dumps).
535  * @OVS_FLOW_ATTR_ACTIONS: Nested %OVS_ACTION_ATTR_* attributes specifying
536  * the actions to take for packets that match the key.  Always present in
537  * notifications.  Required for %OVS_FLOW_CMD_NEW requests, optional for
538  * %OVS_FLOW_CMD_SET requests.  An %OVS_FLOW_CMD_SET without
539  * %OVS_FLOW_ATTR_ACTIONS will not modify the actions.  To clear the actions,
540  * an %OVS_FLOW_ATTR_ACTIONS without any nested attributes must be given.
541  * @OVS_FLOW_ATTR_STATS: &struct ovs_flow_stats giving statistics for this
542  * flow.  Present in notifications if the stats would be nonzero.  Ignored in
543  * requests.
544  * @OVS_FLOW_ATTR_TCP_FLAGS: An 8-bit value giving the OR'd value of all of the
545  * TCP flags seen on packets in this flow.  Only present in notifications for
546  * TCP flows, and only if it would be nonzero.  Ignored in requests.
547  * @OVS_FLOW_ATTR_USED: A 64-bit integer giving the time, in milliseconds on
548  * the system monotonic clock, at which a packet was last processed for this
549  * flow.  Only present in notifications if a packet has been processed for this
550  * flow.  Ignored in requests.
551  * @OVS_FLOW_ATTR_CLEAR: If present in a %OVS_FLOW_CMD_SET request, clears the
552  * last-used time, accumulated TCP flags, and statistics for this flow.
553  * Otherwise ignored in requests.  Never present in notifications.
554  * @OVS_FLOW_ATTR_MASK: Nested %OVS_KEY_ATTR_* attributes specifying the
555  * mask bits for wildcarded flow match. Mask bit value '1' specifies exact
556  * match with corresponding flow key bit, while mask bit value '0' specifies
557  * a wildcarded match. Omitting attribute is treated as wildcarding all
558  * corresponding fields. Optional for all requests. If not present,
559  * all flow key bits are exact match bits.
560  * @OVS_FLOW_ATTR_UFID: A value between 1-16 octets specifying a unique
561  * identifier for the flow. Causes the flow to be indexed by this value rather
562  * than the value of the %OVS_FLOW_ATTR_KEY attribute. Optional for all
563  * requests. Present in notifications if the flow was created with this
564  * attribute.
565  * @OVS_FLOW_ATTR_UFID_FLAGS: A 32-bit value of OR'd %OVS_UFID_F_*
566  * flags that provide alternative semantics for flow installation and
567  * retrieval. Optional for all requests.
568  *
569  * These attributes follow the &struct ovs_header within the Generic Netlink
570  * payload for %OVS_FLOW_* commands.
571  */
572 enum ovs_flow_attr {
573 	OVS_FLOW_ATTR_UNSPEC,
574 	OVS_FLOW_ATTR_KEY,       /* Sequence of OVS_KEY_ATTR_* attributes. */
575 	OVS_FLOW_ATTR_ACTIONS,   /* Nested OVS_ACTION_ATTR_* attributes. */
576 	OVS_FLOW_ATTR_STATS,     /* struct ovs_flow_stats. */
577 	OVS_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */
578 	OVS_FLOW_ATTR_USED,      /* u64 msecs last used in monotonic time. */
579 	OVS_FLOW_ATTR_CLEAR,     /* Flag to clear stats, tcp_flags, used. */
580 	OVS_FLOW_ATTR_MASK,      /* Sequence of OVS_KEY_ATTR_* attributes. */
581 	OVS_FLOW_ATTR_PROBE,     /* Flow operation is a feature probe, error
582 				  * logging should be suppressed. */
583 	OVS_FLOW_ATTR_UFID,      /* Variable length unique flow identifier. */
584 	OVS_FLOW_ATTR_UFID_FLAGS,/* u32 of OVS_UFID_F_*. */
585 	OVS_FLOW_ATTR_PAD,
586 	__OVS_FLOW_ATTR_MAX
587 };
588 
589 #define OVS_FLOW_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1)
590 
591 /**
592  * Omit attributes for notifications.
593  *
594  * If a datapath request contains an %OVS_UFID_F_OMIT_* flag, then the datapath
595  * may omit the corresponding %OVS_FLOW_ATTR_* from the response.
596  */
597 #define OVS_UFID_F_OMIT_KEY      (1 << 0)
598 #define OVS_UFID_F_OMIT_MASK     (1 << 1)
599 #define OVS_UFID_F_OMIT_ACTIONS  (1 << 2)
600 
601 /**
602  * enum ovs_sample_attr - Attributes for %OVS_ACTION_ATTR_SAMPLE action.
603  * @OVS_SAMPLE_ATTR_PROBABILITY: 32-bit fraction of packets to sample with
604  * @OVS_ACTION_ATTR_SAMPLE.  A value of 0 samples no packets, a value of
605  * %UINT32_MAX samples all packets and intermediate values sample intermediate
606  * fractions of packets.
607  * @OVS_SAMPLE_ATTR_ACTIONS: Set of actions to execute in sampling event.
608  * Actions are passed as nested attributes.
609  *
610  * Executes the specified actions with the given probability on a per-packet
611  * basis.
612  */
613 enum ovs_sample_attr {
614 	OVS_SAMPLE_ATTR_UNSPEC,
615 	OVS_SAMPLE_ATTR_PROBABILITY, /* u32 number */
616 	OVS_SAMPLE_ATTR_ACTIONS,     /* Nested OVS_ACTION_ATTR_* attributes. */
617 	__OVS_SAMPLE_ATTR_MAX,
618 
619 #ifdef __KERNEL__
620 	OVS_SAMPLE_ATTR_ARG          /* struct sample_arg  */
621 #endif
622 };
623 
624 #define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1)
625 
626 #ifdef __KERNEL__
627 struct sample_arg {
628 	bool exec;                   /* When true, actions in sample will not
629 				      * change flow keys. False otherwise.
630 				      */
631 	u32  probability;            /* Same value as
632 				      * 'OVS_SAMPLE_ATTR_PROBABILITY'.
633 				      */
634 };
635 #endif
636 
637 /**
638  * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action.
639  * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION
640  * message should be sent.  Required.
641  * @OVS_USERSPACE_ATTR_USERDATA: If present, its variable-length argument is
642  * copied to the %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA.
643  * @OVS_USERSPACE_ATTR_EGRESS_TUN_PORT: If present, u32 output port to get
644  * tunnel info.
645  * @OVS_USERSPACE_ATTR_ACTIONS: If present, send actions with upcall.
646  */
647 enum ovs_userspace_attr {
648 	OVS_USERSPACE_ATTR_UNSPEC,
649 	OVS_USERSPACE_ATTR_PID,	      /* u32 Netlink PID to receive upcalls. */
650 	OVS_USERSPACE_ATTR_USERDATA,  /* Optional user-specified cookie. */
651 	OVS_USERSPACE_ATTR_EGRESS_TUN_PORT,  /* Optional, u32 output port
652 					      * to get tunnel info. */
653 	OVS_USERSPACE_ATTR_ACTIONS,   /* Optional flag to get actions. */
654 	__OVS_USERSPACE_ATTR_MAX
655 };
656 
657 #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)
658 
659 struct ovs_action_trunc {
660 	uint32_t max_len; /* Max packet size in bytes. */
661 };
662 
663 /**
664  * struct ovs_action_push_mpls - %OVS_ACTION_ATTR_PUSH_MPLS action argument.
665  * @mpls_lse: MPLS label stack entry to push.
666  * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame.
667  *
668  * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and
669  * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected.
670  */
671 struct ovs_action_push_mpls {
672 	uint32_t mpls_lse;
673 	uint16_t mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */
674 };
675 
676 /**
677  * struct ovs_action_add_mpls - %OVS_ACTION_ATTR_ADD_MPLS action
678  * argument.
679  * @mpls_lse: MPLS label stack entry to push.
680  * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame.
681  * @tun_flags: MPLS tunnel attributes.
682  *
683  * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and
684  * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected.
685  */
686 struct ovs_action_add_mpls {
687 	uint32_t mpls_lse;
688 	uint16_t mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */
689 	uint16_t tun_flags;
690 };
691 
692 #define OVS_MPLS_L3_TUNNEL_FLAG_MASK  (1 << 0) /* Flag to specify the place of
693 						* insertion of MPLS header.
694 						* When false, the MPLS header
695 						* will be inserted at the start
696 						* of the packet.
697 						* When true, the MPLS header
698 						* will be inserted at the start
699 						* of the l3 header.
700 						*/
701 
702 /**
703  * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument.
704  * @vlan_tpid: Tag protocol identifier (TPID) to push.
705  * @vlan_tci: Tag control identifier (TCI) to push.  The CFI bit must be set
706  * (but it will not be set in the 802.1Q header that is pushed).
707  *
708  * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
709  * The only acceptable TPID values are those that the kernel module also parses
710  * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
711  * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
712  */
713 struct ovs_action_push_vlan {
714 	uint16_t vlan_tpid;	/* 802.1Q or 802.1ad TPID. */
715 	uint16_t vlan_tci;	/* 802.1Q TCI (VLAN ID and priority). */
716 };
717 
718 /* Data path hash algorithm for computing Datapath hash.
719  *
720  * The algorithm type only specifies the fields in a flow
721  * will be used as part of the hash. Each datapath is free
722  * to use its own hash algorithm. The hash value will be
723  * opaque to the user space daemon.
724  */
725 enum ovs_hash_alg {
726 	OVS_HASH_ALG_L4,
727 };
728 
729 /*
730  * struct ovs_action_hash - %OVS_ACTION_ATTR_HASH action argument.
731  * @hash_alg: Algorithm used to compute hash prior to recirculation.
732  * @hash_basis: basis used for computing hash.
733  */
734 struct ovs_action_hash {
735 	uint32_t  hash_alg;     /* One of ovs_hash_alg. */
736 	uint32_t  hash_basis;
737 };
738 
739 /**
740  * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action.
741  * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack
742  * table. This allows future packets for the same connection to be identified
743  * as 'established' or 'related'. The flow key for the current packet will
744  * retain the pre-commit connection state.
745  * @OVS_CT_ATTR_ZONE: u16 connection tracking zone.
746  * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the
747  * mask, the corresponding bit in the value is copied to the connection
748  * tracking mark field in the connection.
749  * @OVS_CT_ATTR_LABELS: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN
750  * mask. For each bit set in the mask, the corresponding bit in the value is
751  * copied to the connection tracking label field in the connection.
752  * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG.
753  * @OVS_CT_ATTR_NAT: Nested OVS_NAT_ATTR_* for performing L3 network address
754  * translation (NAT) on the packet.
755  * @OVS_CT_ATTR_FORCE_COMMIT: Like %OVS_CT_ATTR_COMMIT, but instead of doing
756  * nothing if the connection is already committed will check that the current
757  * packet is in conntrack entry's original direction.  If directionality does
758  * not match, will delete the existing conntrack entry and commit a new one.
759  * @OVS_CT_ATTR_EVENTMASK: Mask of bits indicating which conntrack event types
760  * (enum ip_conntrack_events IPCT_*) should be reported.  For any bit set to
761  * zero, the corresponding event type is not generated.  Default behavior
762  * depends on system configuration, but typically all event types are
763  * generated, hence listening on NFNLGRP_CONNTRACK_UPDATE events may get a lot
764  * of events.  Explicitly passing this attribute allows limiting the updates
765  * received to the events of interest.  The bit 1 << IPCT_NEW, 1 <<
766  * IPCT_RELATED, and 1 << IPCT_DESTROY must be set to ones for those events to
767  * be received on NFNLGRP_CONNTRACK_NEW and NFNLGRP_CONNTRACK_DESTROY groups,
768  * respectively.  Remaining bits control the changes for which an event is
769  * delivered on the NFNLGRP_CONNTRACK_UPDATE group.
770  * @OVS_CT_ATTR_TIMEOUT: Variable length string defining conntrack timeout.
771  */
772 enum ovs_ct_attr {
773 	OVS_CT_ATTR_UNSPEC,
774 	OVS_CT_ATTR_COMMIT,     /* No argument, commits connection. */
775 	OVS_CT_ATTR_ZONE,       /* u16 zone id. */
776 	OVS_CT_ATTR_MARK,       /* mark to associate with this connection. */
777 	OVS_CT_ATTR_LABELS,     /* labels to associate with this connection. */
778 	OVS_CT_ATTR_HELPER,     /* netlink helper to assist detection of
779 				   related connections. */
780 	OVS_CT_ATTR_NAT,        /* Nested OVS_NAT_ATTR_* */
781 	OVS_CT_ATTR_FORCE_COMMIT,  /* No argument */
782 	OVS_CT_ATTR_EVENTMASK,  /* u32 mask of IPCT_* events. */
783 	OVS_CT_ATTR_TIMEOUT,	/* Associate timeout with this connection for
784 				 * fine-grain timeout tuning. */
785 	__OVS_CT_ATTR_MAX
786 };
787 
788 #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1)
789 
790 /**
791  * enum ovs_nat_attr - Attributes for %OVS_CT_ATTR_NAT.
792  *
793  * @OVS_NAT_ATTR_SRC: Flag for Source NAT (mangle source address/port).
794  * @OVS_NAT_ATTR_DST: Flag for Destination NAT (mangle destination
795  * address/port).  Only one of (@OVS_NAT_ATTR_SRC, @OVS_NAT_ATTR_DST) may be
796  * specified.  Effective only for packets for ct_state NEW connections.
797  * Packets of committed connections are mangled by the NAT action according to
798  * the committed NAT type regardless of the flags specified.  As a corollary, a
799  * NAT action without a NAT type flag will only mangle packets of committed
800  * connections.  The following NAT attributes only apply for NEW
801  * (non-committed) connections, and they may be included only when the CT
802  * action has the @OVS_CT_ATTR_COMMIT flag and either @OVS_NAT_ATTR_SRC or
803  * @OVS_NAT_ATTR_DST is also included.
804  * @OVS_NAT_ATTR_IP_MIN: struct in_addr or struct in6_addr
805  * @OVS_NAT_ATTR_IP_MAX: struct in_addr or struct in6_addr
806  * @OVS_NAT_ATTR_PROTO_MIN: u16 L4 protocol specific lower boundary (port)
807  * @OVS_NAT_ATTR_PROTO_MAX: u16 L4 protocol specific upper boundary (port)
808  * @OVS_NAT_ATTR_PERSISTENT: Flag for persistent IP mapping across reboots
809  * @OVS_NAT_ATTR_PROTO_HASH: Flag for pseudo random L4 port mapping (MD5)
810  * @OVS_NAT_ATTR_PROTO_RANDOM: Flag for fully randomized L4 port mapping
811  */
812 enum ovs_nat_attr {
813 	OVS_NAT_ATTR_UNSPEC,
814 	OVS_NAT_ATTR_SRC,
815 	OVS_NAT_ATTR_DST,
816 	OVS_NAT_ATTR_IP_MIN,
817 	OVS_NAT_ATTR_IP_MAX,
818 	OVS_NAT_ATTR_PROTO_MIN,
819 	OVS_NAT_ATTR_PROTO_MAX,
820 	OVS_NAT_ATTR_PERSISTENT,
821 	OVS_NAT_ATTR_PROTO_HASH,
822 	OVS_NAT_ATTR_PROTO_RANDOM,
823 	__OVS_NAT_ATTR_MAX,
824 };
825 
826 #define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1)
827 
828 /*
829  * struct ovs_action_push_eth - %OVS_ACTION_ATTR_PUSH_ETH action argument.
830  * @addresses: Source and destination MAC addresses.
831  * @eth_type: Ethernet type
832  */
833 struct ovs_action_push_eth {
834 	struct ovs_key_ethernet addresses;
835 };
836 
837 /*
838  * enum ovs_check_pkt_len_attr - Attributes for %OVS_ACTION_ATTR_CHECK_PKT_LEN.
839  *
840  * @OVS_CHECK_PKT_LEN_ATTR_PKT_LEN: u16 Packet length to check for.
841  * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER: Nested OVS_ACTION_ATTR_*
842  * actions to apply if the packer length is greater than the specified
843  * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
844  * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL - Nested OVS_ACTION_ATTR_*
845  * actions to apply if the packer length is lesser or equal to the specified
846  * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
847  */
848 enum ovs_check_pkt_len_attr {
849 	OVS_CHECK_PKT_LEN_ATTR_UNSPEC,
850 	OVS_CHECK_PKT_LEN_ATTR_PKT_LEN,
851 	OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER,
852 	OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL,
853 	__OVS_CHECK_PKT_LEN_ATTR_MAX,
854 
855 #ifdef __KERNEL__
856 	OVS_CHECK_PKT_LEN_ATTR_ARG          /* struct check_pkt_len_arg  */
857 #endif
858 };
859 
860 #define OVS_CHECK_PKT_LEN_ATTR_MAX (__OVS_CHECK_PKT_LEN_ATTR_MAX - 1)
861 
862 #ifdef __KERNEL__
863 struct check_pkt_len_arg {
864 	u16 pkt_len;	/* Same value as OVS_CHECK_PKT_LEN_ATTR_PKT_LEN'. */
865 	bool exec_for_greater;	/* When true, actions in IF_GREATER will
866 				 * not change flow keys. False otherwise.
867 				 */
868 	bool exec_for_lesser_equal; /* When true, actions in IF_LESS_EQUAL
869 				     * will not change flow keys. False
870 				     * otherwise.
871 				     */
872 };
873 #endif
874 
875 /**
876  * enum ovs_action_attr - Action types.
877  *
878  * @OVS_ACTION_ATTR_OUTPUT: Output packet to port.
879  * @OVS_ACTION_ATTR_TRUNC: Output packet to port with truncated packet size.
880  * @OVS_ACTION_ATTR_USERSPACE: Send packet to userspace according to nested
881  * %OVS_USERSPACE_ATTR_* attributes.
882  * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header.  The
883  * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its
884  * value.
885  * @OVS_ACTION_ATTR_SET_MASKED: Replaces the contents of an existing header.  A
886  * nested %OVS_KEY_ATTR_* attribute specifies a header to modify, its value,
887  * and a mask.  For every bit set in the mask, the corresponding bit value
888  * is copied from the value to the packet header field, rest of the bits are
889  * left unchanged.  The non-masked value bits must be passed in as zeroes.
890  * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
891  * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
892  * onto the packet.
893  * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
894  * from the packet.
895  * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
896  * the nested %OVS_SAMPLE_ATTR_* attributes.
897  * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
898  * top of the packets MPLS label stack.  Set the ethertype of the
899  * encapsulating frame to either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC to
900  * indicate the new packet contents.
901  * @OVS_ACTION_ATTR_POP_MPLS: Pop an MPLS label stack entry off of the
902  * packet's MPLS label stack.  Set the encapsulating frame's ethertype to
903  * indicate the new packet contents. This could potentially still be
904  * %ETH_P_MPLS if the resulting MPLS label stack is not empty.  If there
905  * is no MPLS label stack, as determined by ethertype, no action is taken.
906  * @OVS_ACTION_ATTR_CT: Track the connection. Populate the conntrack-related
907  * entries in the flow key.
908  * @OVS_ACTION_ATTR_PUSH_ETH: Push a new outermost Ethernet header onto the
909  * packet.
910  * @OVS_ACTION_ATTR_POP_ETH: Pop the outermost Ethernet header off the
911  * packet.
912  * @OVS_ACTION_ATTR_CT_CLEAR: Clear conntrack state from the packet.
913  * @OVS_ACTION_ATTR_PUSH_NSH: push NSH header to the packet.
914  * @OVS_ACTION_ATTR_POP_NSH: pop the outermost NSH header off the packet.
915  * @OVS_ACTION_ATTR_METER: Run packet through a meter, which may drop the
916  * packet, or modify the packet (e.g., change the DSCP field).
917  * @OVS_ACTION_ATTR_CLONE: make a copy of the packet and execute a list of
918  * actions without affecting the original packet and key.
919  * @OVS_ACTION_ATTR_CHECK_PKT_LEN: Check the packet length and execute a set
920  * of actions if greater than the specified packet length, else execute
921  * another set of actions.
922  * @OVS_ACTION_ATTR_ADD_MPLS: Push a new MPLS label stack entry at the
923  * start of the packet or at the start of the l3 header depending on the value
924  * of l3 tunnel flag in the tun_flags field of OVS_ACTION_ATTR_ADD_MPLS
925  * argument.
926  *
927  * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  Not all
928  * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
929  * type may not be changed.
930  *
931  * @OVS_ACTION_ATTR_SET_TO_MASKED: Kernel internal masked set action translated
932  * from the @OVS_ACTION_ATTR_SET.
933  */
934 
935 enum ovs_action_attr {
936 	OVS_ACTION_ATTR_UNSPEC,
937 	OVS_ACTION_ATTR_OUTPUT,	      /* u32 port number. */
938 	OVS_ACTION_ATTR_USERSPACE,    /* Nested OVS_USERSPACE_ATTR_*. */
939 	OVS_ACTION_ATTR_SET,          /* One nested OVS_KEY_ATTR_*. */
940 	OVS_ACTION_ATTR_PUSH_VLAN,    /* struct ovs_action_push_vlan. */
941 	OVS_ACTION_ATTR_POP_VLAN,     /* No argument. */
942 	OVS_ACTION_ATTR_SAMPLE,       /* Nested OVS_SAMPLE_ATTR_*. */
943 	OVS_ACTION_ATTR_RECIRC,       /* u32 recirc_id. */
944 	OVS_ACTION_ATTR_HASH,	      /* struct ovs_action_hash. */
945 	OVS_ACTION_ATTR_PUSH_MPLS,    /* struct ovs_action_push_mpls. */
946 	OVS_ACTION_ATTR_POP_MPLS,     /* uint16_t ethertype. */
947 	OVS_ACTION_ATTR_SET_MASKED,   /* One nested OVS_KEY_ATTR_* including
948 				       * data immediately followed by a mask.
949 				       * The data must be zero for the unmasked
950 				       * bits. */
951 	OVS_ACTION_ATTR_CT,           /* Nested OVS_CT_ATTR_* . */
952 	OVS_ACTION_ATTR_TRUNC,        /* u32 struct ovs_action_trunc. */
953 	OVS_ACTION_ATTR_PUSH_ETH,     /* struct ovs_action_push_eth. */
954 	OVS_ACTION_ATTR_POP_ETH,      /* No argument. */
955 	OVS_ACTION_ATTR_CT_CLEAR,     /* No argument. */
956 	OVS_ACTION_ATTR_PUSH_NSH,     /* Nested OVS_NSH_KEY_ATTR_*. */
957 	OVS_ACTION_ATTR_POP_NSH,      /* No argument. */
958 	OVS_ACTION_ATTR_METER,        /* u32 meter ID. */
959 	OVS_ACTION_ATTR_CLONE,        /* Nested OVS_CLONE_ATTR_*.  */
960 	OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
961 	OVS_ACTION_ATTR_ADD_MPLS,     /* struct ovs_action_add_mpls. */
962 	OVS_ACTION_ATTR_DEC_TTL,      /* Nested OVS_DEC_TTL_ATTR_*. */
963 
964 	__OVS_ACTION_ATTR_MAX,	      /* Nothing past this will be accepted
965 				       * from userspace. */
966 
967 #ifdef __KERNEL__
968 	OVS_ACTION_ATTR_SET_TO_MASKED, /* Kernel module internal masked
969 					* set action converted from
970 					* OVS_ACTION_ATTR_SET. */
971 #endif
972 };
973 
974 #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
975 
976 /* Meters. */
977 #define OVS_METER_FAMILY  "ovs_meter"
978 #define OVS_METER_MCGROUP "ovs_meter"
979 #define OVS_METER_VERSION 0x1
980 
981 enum ovs_meter_cmd {
982 	OVS_METER_CMD_UNSPEC,
983 	OVS_METER_CMD_FEATURES,	/* Get features supported by the datapath. */
984 	OVS_METER_CMD_SET,	/* Add or modify a meter. */
985 	OVS_METER_CMD_DEL,	/* Delete a meter. */
986 	OVS_METER_CMD_GET	/* Get meter stats. */
987 };
988 
989 enum ovs_meter_attr {
990 	OVS_METER_ATTR_UNSPEC,
991 	OVS_METER_ATTR_ID,	/* u32 meter ID within datapath. */
992 	OVS_METER_ATTR_KBPS,	/* No argument. If set, units in kilobits
993 				 * per second. Otherwise, units in
994 				 * packets per second.
995 				 */
996 	OVS_METER_ATTR_STATS,	/* struct ovs_flow_stats for the meter. */
997 	OVS_METER_ATTR_BANDS,	/* Nested attributes for meter bands. */
998 	OVS_METER_ATTR_USED,	/* u64 msecs last used in monotonic time. */
999 	OVS_METER_ATTR_CLEAR,	/* Flag to clear stats, used. */
1000 	OVS_METER_ATTR_MAX_METERS, /* u32 number of meters supported. */
1001 	OVS_METER_ATTR_MAX_BANDS,  /* u32 max number of bands per meter. */
1002 	OVS_METER_ATTR_PAD,
1003 	__OVS_METER_ATTR_MAX
1004 };
1005 
1006 #define OVS_METER_ATTR_MAX (__OVS_METER_ATTR_MAX - 1)
1007 
1008 enum ovs_band_attr {
1009 	OVS_BAND_ATTR_UNSPEC,
1010 	OVS_BAND_ATTR_TYPE,	/* u32 OVS_METER_BAND_TYPE_* constant. */
1011 	OVS_BAND_ATTR_RATE,	/* u32 band rate in meter units (see above). */
1012 	OVS_BAND_ATTR_BURST,	/* u32 burst size in meter units. */
1013 	OVS_BAND_ATTR_STATS,	/* struct ovs_flow_stats for the band. */
1014 	__OVS_BAND_ATTR_MAX
1015 };
1016 
1017 #define OVS_BAND_ATTR_MAX (__OVS_BAND_ATTR_MAX - 1)
1018 
1019 enum ovs_meter_band_type {
1020 	OVS_METER_BAND_TYPE_UNSPEC,
1021 	OVS_METER_BAND_TYPE_DROP,   /* Drop exceeding packets. */
1022 	__OVS_METER_BAND_TYPE_MAX
1023 };
1024 
1025 #define OVS_METER_BAND_TYPE_MAX (__OVS_METER_BAND_TYPE_MAX - 1)
1026 
1027 /* Conntrack limit */
1028 #define OVS_CT_LIMIT_FAMILY  "ovs_ct_limit"
1029 #define OVS_CT_LIMIT_MCGROUP "ovs_ct_limit"
1030 #define OVS_CT_LIMIT_VERSION 0x1
1031 
1032 enum ovs_ct_limit_cmd {
1033 	OVS_CT_LIMIT_CMD_UNSPEC,
1034 	OVS_CT_LIMIT_CMD_SET,		/* Add or modify ct limit. */
1035 	OVS_CT_LIMIT_CMD_DEL,		/* Delete ct limit. */
1036 	OVS_CT_LIMIT_CMD_GET		/* Get ct limit. */
1037 };
1038 
1039 enum ovs_ct_limit_attr {
1040 	OVS_CT_LIMIT_ATTR_UNSPEC,
1041 	OVS_CT_LIMIT_ATTR_ZONE_LIMIT,	/* Nested struct ovs_zone_limit. */
1042 	__OVS_CT_LIMIT_ATTR_MAX
1043 };
1044 
1045 #define OVS_CT_LIMIT_ATTR_MAX (__OVS_CT_LIMIT_ATTR_MAX - 1)
1046 
1047 #define OVS_ZONE_LIMIT_DEFAULT_ZONE -1
1048 
1049 struct ovs_zone_limit {
1050 	int zone_id;
1051 	uint32_t limit;
1052 	uint32_t count;
1053 };
1054 
1055 enum ovs_dec_ttl_attr {
1056 	OVS_DEC_TTL_ATTR_UNSPEC,
1057 	OVS_DEC_TTL_ATTR_ACTION,	/* Nested struct nlattr */
1058 	__OVS_DEC_TTL_ATTR_MAX
1059 };
1060 
1061 #define OVS_DEC_TTL_ATTR_MAX (__OVS_DEC_TTL_ATTR_MAX - 1)
1062 
1063 #endif /* _LINUX_OPENVSWITCH_H */
1064