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. 73e4252cb6SMark Gray * @OVS_DP_ATTR_PER_CPU_PIDS: Per-cpu array of PIDs for upcalls when 74b83d23a2SMark Gray * OVS_DP_F_DISPATCH_UPCALL_PER_CPU feature is set. 7522e3880aSThomas Graf * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the 7622e3880aSThomas Graf * datapath. Always present in notifications. 771bd7116fSAndy Zhou * @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the 781bd7116fSAndy Zhou * datapath. Always present in notifications. 7954c4ef34SAndrey Zhadchenko * @OVS_DP_ATTR_IFINDEX: Interface index for a new datapath netdev. Only 8054c4ef34SAndrey Zhadchenko * valid for %OVS_DP_CMD_NEW requests. 8122e3880aSThomas Graf * 8222e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 8322e3880aSThomas Graf * payload for %OVS_DP_* commands. 8422e3880aSThomas Graf */ 8522e3880aSThomas Graf enum ovs_datapath_attr { 8622e3880aSThomas Graf OVS_DP_ATTR_UNSPEC, 8722e3880aSThomas Graf OVS_DP_ATTR_NAME, /* name of dp_ifindex netdev */ 8822e3880aSThomas Graf OVS_DP_ATTR_UPCALL_PID, /* Netlink PID to receive upcalls */ 8922e3880aSThomas Graf OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */ 901bd7116fSAndy Zhou OVS_DP_ATTR_MEGAFLOW_STATS, /* struct ovs_dp_megaflow_stats */ 9143d4be9cSThomas Graf OVS_DP_ATTR_USER_FEATURES, /* OVS_DP_F_* */ 9266c7a5eeSNicolas Dichtel OVS_DP_ATTR_PAD, 939bf24f59SEelco Chaudron OVS_DP_ATTR_MASKS_CACHE_SIZE, 94784dcfa5SMark Gray OVS_DP_ATTR_PER_CPU_PIDS, /* Netlink PIDS to receive upcalls in 95784dcfa5SMark Gray * per-cpu dispatch mode 96b83d23a2SMark Gray */ 9754c4ef34SAndrey Zhadchenko OVS_DP_ATTR_IFINDEX, 9822e3880aSThomas Graf __OVS_DP_ATTR_MAX 9922e3880aSThomas Graf }; 10022e3880aSThomas Graf 10122e3880aSThomas Graf #define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1) 10222e3880aSThomas Graf 10322e3880aSThomas Graf struct ovs_dp_stats { 10422e3880aSThomas Graf __u64 n_hit; /* Number of flow table matches. */ 10522e3880aSThomas Graf __u64 n_missed; /* Number of flow table misses. */ 10622e3880aSThomas Graf __u64 n_lost; /* Number of misses not sent to userspace. */ 10722e3880aSThomas Graf __u64 n_flows; /* Number of flows present */ 10822e3880aSThomas Graf }; 10922e3880aSThomas Graf 1101bd7116fSAndy Zhou struct ovs_dp_megaflow_stats { 1111bd7116fSAndy Zhou __u64 n_mask_hit; /* Number of masks used for flow lookups. */ 1121bd7116fSAndy Zhou __u32 n_masks; /* Number of masks for the datapath. */ 1131bd7116fSAndy Zhou __u32 pad0; /* Pad for future expension. */ 1149d2f627bSEelco Chaudron __u64 n_cache_hit; /* Number of cache matches for flow lookups. */ 1151bd7116fSAndy Zhou __u64 pad1; /* Pad for future expension. */ 1161bd7116fSAndy Zhou }; 1171bd7116fSAndy Zhou 11822e3880aSThomas Graf struct ovs_vport_stats { 11922e3880aSThomas Graf __u64 rx_packets; /* total packets received */ 12022e3880aSThomas Graf __u64 tx_packets; /* total packets transmitted */ 12122e3880aSThomas Graf __u64 rx_bytes; /* total bytes received */ 12222e3880aSThomas Graf __u64 tx_bytes; /* total bytes transmitted */ 12322e3880aSThomas Graf __u64 rx_errors; /* bad packets received */ 12422e3880aSThomas Graf __u64 tx_errors; /* packet transmit problems */ 12522e3880aSThomas Graf __u64 rx_dropped; /* no space in linux buffers */ 12622e3880aSThomas Graf __u64 tx_dropped; /* no space available in linux */ 12722e3880aSThomas Graf }; 12822e3880aSThomas Graf 12943d4be9cSThomas Graf /* Allow last Netlink attribute to be unaligned */ 13043d4be9cSThomas Graf #define OVS_DP_F_UNALIGNED (1 << 0) 13143d4be9cSThomas Graf 1325cd667b0SAlex Wang /* Allow datapath to associate multiple Netlink PIDs to each vport */ 1335cd667b0SAlex Wang #define OVS_DP_F_VPORT_PIDS (1 << 1) 1345cd667b0SAlex Wang 13595a7233cSPaul Blakey /* Allow tc offload recirc sharing */ 13695a7233cSPaul Blakey #define OVS_DP_F_TC_RECIRC_SHARING (1 << 2) 13795a7233cSPaul Blakey 138b83d23a2SMark Gray /* Allow per-cpu dispatch of upcalls */ 139b83d23a2SMark Gray #define OVS_DP_F_DISPATCH_UPCALL_PER_CPU (1 << 3) 140b83d23a2SMark Gray 14122e3880aSThomas Graf /* Fixed logical ports. */ 14222e3880aSThomas Graf #define OVSP_LOCAL ((__u32)0) 14322e3880aSThomas Graf 14422e3880aSThomas Graf /* Packet transfer. */ 14522e3880aSThomas Graf 14622e3880aSThomas Graf #define OVS_PACKET_FAMILY "ovs_packet" 14722e3880aSThomas Graf #define OVS_PACKET_VERSION 0x1 14822e3880aSThomas Graf 14922e3880aSThomas Graf enum ovs_packet_cmd { 15022e3880aSThomas Graf OVS_PACKET_CMD_UNSPEC, 15122e3880aSThomas Graf 15222e3880aSThomas Graf /* Kernel-to-user notifications. */ 15322e3880aSThomas Graf OVS_PACKET_CMD_MISS, /* Flow table miss. */ 15422e3880aSThomas Graf OVS_PACKET_CMD_ACTION, /* OVS_ACTION_ATTR_USERSPACE action. */ 15522e3880aSThomas Graf 15622e3880aSThomas Graf /* Userspace commands. */ 15722e3880aSThomas Graf OVS_PACKET_CMD_EXECUTE /* Apply actions to a packet. */ 15822e3880aSThomas Graf }; 15922e3880aSThomas Graf 16022e3880aSThomas Graf /** 16122e3880aSThomas Graf * enum ovs_packet_attr - attributes for %OVS_PACKET_* commands. 16222e3880aSThomas Graf * @OVS_PACKET_ATTR_PACKET: Present for all notifications. Contains the entire 16322e3880aSThomas Graf * packet as received, from the start of the Ethernet header onward. For 16422e3880aSThomas Graf * %OVS_PACKET_CMD_ACTION, %OVS_PACKET_ATTR_PACKET reflects changes made by 16522e3880aSThomas Graf * actions preceding %OVS_ACTION_ATTR_USERSPACE, but %OVS_PACKET_ATTR_KEY is 16622e3880aSThomas Graf * the flow key extracted from the packet as originally received. 16722e3880aSThomas Graf * @OVS_PACKET_ATTR_KEY: Present for all notifications. Contains the flow key 16822e3880aSThomas Graf * extracted from the packet as nested %OVS_KEY_ATTR_* attributes. This allows 16922e3880aSThomas Graf * userspace to adapt its flow setup strategy by comparing its notion of the 17022e3880aSThomas Graf * flow key against the kernel's. 17122e3880aSThomas Graf * @OVS_PACKET_ATTR_ACTIONS: Contains actions for the packet. Used 17222e3880aSThomas Graf * for %OVS_PACKET_CMD_EXECUTE. It has nested %OVS_ACTION_ATTR_* attributes. 173ccea7445SNeil McKee * Also used in upcall when %OVS_ACTION_ATTR_USERSPACE has optional 174ccea7445SNeil McKee * %OVS_USERSPACE_ATTR_ACTIONS attribute. 17522e3880aSThomas Graf * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION 17622e3880aSThomas Graf * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an 17722e3880aSThomas Graf * %OVS_USERSPACE_ATTR_USERDATA attribute, with the same length and content 17822e3880aSThomas Graf * specified there. 1798f0aad6fSWenyu Zhang * @OVS_PACKET_ATTR_EGRESS_TUN_KEY: Present for an %OVS_PACKET_CMD_ACTION 1808f0aad6fSWenyu Zhang * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an 1818f0aad6fSWenyu Zhang * %OVS_USERSPACE_ATTR_EGRESS_TUN_PORT attribute, which is sent only if the 1828f0aad6fSWenyu Zhang * output port is actually a tunnel port. Contains the output tunnel key 1838f0aad6fSWenyu Zhang * extracted from the packet as nested %OVS_TUNNEL_KEY_ATTR_* attributes. 1847f8a436eSJoe Stringer * @OVS_PACKET_ATTR_MRU: Present for an %OVS_PACKET_CMD_ACTION and 185b95e5928SWilliam Tu * @OVS_PACKET_ATTR_LEN: Packet size before truncation. 1867f8a436eSJoe Stringer * %OVS_PACKET_ATTR_USERSPACE action specify the Maximum received fragment 1877f8a436eSJoe Stringer * size. 188bd1903b7STonghao Zhang * @OVS_PACKET_ATTR_HASH: Packet hash info (e.g. hash, sw_hash and l4_hash in skb). 18922e3880aSThomas Graf * 19022e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 19122e3880aSThomas Graf * payload for %OVS_PACKET_* commands. 19222e3880aSThomas Graf */ 19322e3880aSThomas Graf enum ovs_packet_attr { 19422e3880aSThomas Graf OVS_PACKET_ATTR_UNSPEC, 19522e3880aSThomas Graf OVS_PACKET_ATTR_PACKET, /* Packet data. */ 19622e3880aSThomas Graf OVS_PACKET_ATTR_KEY, /* Nested OVS_KEY_ATTR_* attributes. */ 19722e3880aSThomas Graf OVS_PACKET_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */ 19822e3880aSThomas Graf OVS_PACKET_ATTR_USERDATA, /* OVS_ACTION_ATTR_USERSPACE arg. */ 1998f0aad6fSWenyu Zhang OVS_PACKET_ATTR_EGRESS_TUN_KEY, /* Nested OVS_TUNNEL_KEY_ATTR_* 2008f0aad6fSWenyu Zhang attributes. */ 2011ba39804SThomas Graf OVS_PACKET_ATTR_UNUSED1, 2021ba39804SThomas Graf OVS_PACKET_ATTR_UNUSED2, 2031ba39804SThomas Graf OVS_PACKET_ATTR_PROBE, /* Packet operation is a feature probe, 2041ba39804SThomas Graf error logging should be suppressed. */ 2057f8a436eSJoe Stringer OVS_PACKET_ATTR_MRU, /* Maximum received IP fragment size. */ 206b95e5928SWilliam Tu OVS_PACKET_ATTR_LEN, /* Packet size before truncation. */ 207bd1903b7STonghao Zhang OVS_PACKET_ATTR_HASH, /* Packet hash. */ 20822e3880aSThomas Graf __OVS_PACKET_ATTR_MAX 20922e3880aSThomas Graf }; 21022e3880aSThomas Graf 21122e3880aSThomas Graf #define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1) 21222e3880aSThomas Graf 21322e3880aSThomas Graf /* Virtual ports. */ 21422e3880aSThomas Graf 21522e3880aSThomas Graf #define OVS_VPORT_FAMILY "ovs_vport" 21622e3880aSThomas Graf #define OVS_VPORT_MCGROUP "ovs_vport" 21722e3880aSThomas Graf #define OVS_VPORT_VERSION 0x1 21822e3880aSThomas Graf 21922e3880aSThomas Graf enum ovs_vport_cmd { 22022e3880aSThomas Graf OVS_VPORT_CMD_UNSPEC, 22122e3880aSThomas Graf OVS_VPORT_CMD_NEW, 22222e3880aSThomas Graf OVS_VPORT_CMD_DEL, 22322e3880aSThomas Graf OVS_VPORT_CMD_GET, 22422e3880aSThomas Graf OVS_VPORT_CMD_SET 22522e3880aSThomas Graf }; 22622e3880aSThomas Graf 22722e3880aSThomas Graf enum ovs_vport_type { 22822e3880aSThomas Graf OVS_VPORT_TYPE_UNSPEC, 22922e3880aSThomas Graf OVS_VPORT_TYPE_NETDEV, /* network device */ 23022e3880aSThomas Graf OVS_VPORT_TYPE_INTERNAL, /* network device implemented by datapath */ 231aa310701SPravin B Shelar OVS_VPORT_TYPE_GRE, /* GRE tunnel. */ 23258264848SPravin B Shelar OVS_VPORT_TYPE_VXLAN, /* VXLAN tunnel. */ 233f5796684SJesse Gross OVS_VPORT_TYPE_GENEVE, /* Geneve tunnel. */ 23422e3880aSThomas Graf __OVS_VPORT_TYPE_MAX 23522e3880aSThomas Graf }; 23622e3880aSThomas Graf 23722e3880aSThomas Graf #define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1) 23822e3880aSThomas Graf 23922e3880aSThomas Graf /** 24022e3880aSThomas Graf * enum ovs_vport_attr - attributes for %OVS_VPORT_* commands. 24122e3880aSThomas Graf * @OVS_VPORT_ATTR_PORT_NO: 32-bit port number within datapath. 24222e3880aSThomas Graf * @OVS_VPORT_ATTR_TYPE: 32-bit %OVS_VPORT_TYPE_* constant describing the type 24322e3880aSThomas Graf * of vport. 24422e3880aSThomas Graf * @OVS_VPORT_ATTR_NAME: Name of vport. For a vport based on a network device 24522e3880aSThomas Graf * this is the name of the network device. Maximum length %IFNAMSIZ-1 bytes 24622e3880aSThomas Graf * plus a null terminator. 24722e3880aSThomas Graf * @OVS_VPORT_ATTR_OPTIONS: Vport-specific configuration information. 2485cd667b0SAlex Wang * @OVS_VPORT_ATTR_UPCALL_PID: The array of Netlink socket pids in userspace 2495cd667b0SAlex Wang * among which OVS_PACKET_CMD_MISS upcalls will be distributed for packets 2505cd667b0SAlex Wang * received on this port. If this is a single-element array of value 0, 2515cd667b0SAlex Wang * upcalls should not be sent. 25222e3880aSThomas Graf * @OVS_VPORT_ATTR_STATS: A &struct ovs_vport_stats giving statistics for 25322e3880aSThomas Graf * packets sent or received through the vport. 25422e3880aSThomas Graf * 25522e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 25622e3880aSThomas Graf * payload for %OVS_VPORT_* commands. 25722e3880aSThomas Graf * 25822e3880aSThomas Graf * For %OVS_VPORT_CMD_NEW requests, the %OVS_VPORT_ATTR_TYPE and 25922e3880aSThomas Graf * %OVS_VPORT_ATTR_NAME attributes are required. %OVS_VPORT_ATTR_PORT_NO is 26022e3880aSThomas Graf * optional; if not specified a free port number is automatically selected. 26122e3880aSThomas Graf * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type 26222e3880aSThomas Graf * of vport. 26322e3880aSThomas Graf * 26422e3880aSThomas Graf * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to 26522e3880aSThomas Graf * look up the vport to operate on; otherwise dp_idx from the &struct 26622e3880aSThomas Graf * ovs_header plus %OVS_VPORT_ATTR_PORT_NO determine the vport. 26722e3880aSThomas Graf */ 26822e3880aSThomas Graf enum ovs_vport_attr { 26922e3880aSThomas Graf OVS_VPORT_ATTR_UNSPEC, 27022e3880aSThomas Graf OVS_VPORT_ATTR_PORT_NO, /* u32 port number within datapath */ 27122e3880aSThomas Graf OVS_VPORT_ATTR_TYPE, /* u32 OVS_VPORT_TYPE_* constant. */ 27222e3880aSThomas Graf OVS_VPORT_ATTR_NAME, /* string name, up to IFNAMSIZ bytes long */ 27322e3880aSThomas Graf OVS_VPORT_ATTR_OPTIONS, /* nested attributes, varies by vport type */ 2745cd667b0SAlex Wang OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */ 2755cd667b0SAlex Wang /* receiving upcalls */ 27622e3880aSThomas Graf OVS_VPORT_ATTR_STATS, /* struct ovs_vport_stats */ 27766c7a5eeSNicolas Dichtel OVS_VPORT_ATTR_PAD, 2789354d452SJiri Benc OVS_VPORT_ATTR_IFINDEX, 2799354d452SJiri Benc OVS_VPORT_ATTR_NETNSID, 2801933ea36Swangchuanlei OVS_VPORT_ATTR_UPCALL_STATS, 28122e3880aSThomas Graf __OVS_VPORT_ATTR_MAX 28222e3880aSThomas Graf }; 28322e3880aSThomas Graf 28422e3880aSThomas Graf #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1) 28522e3880aSThomas Graf 2861933ea36Swangchuanlei /** 2871933ea36Swangchuanlei * enum ovs_vport_upcall_attr - attributes for %OVS_VPORT_UPCALL* commands 2881933ea36Swangchuanlei * @OVS_VPORT_UPCALL_SUCCESS: 64-bit upcall success packets. 2891933ea36Swangchuanlei * @OVS_VPORT_UPCALL_FAIL: 64-bit upcall fail packets. 2901933ea36Swangchuanlei */ 2911933ea36Swangchuanlei enum ovs_vport_upcall_attr { 2921933ea36Swangchuanlei OVS_VPORT_UPCALL_ATTR_SUCCESS, 2931933ea36Swangchuanlei OVS_VPORT_UPCALL_ATTR_FAIL, 2941933ea36Swangchuanlei __OVS_VPORT_UPCALL_ATTR_MAX 2951933ea36Swangchuanlei }; 2961933ea36Swangchuanlei 2971933ea36Swangchuanlei #define OVS_VPORT_UPCALL_ATTR_MAX (__OVS_VPORT_UPCALL_ATTR_MAX - 1) 2981933ea36Swangchuanlei 2991dd144cfSThomas Graf enum { 3001dd144cfSThomas Graf OVS_VXLAN_EXT_UNSPEC, 3011dd144cfSThomas Graf OVS_VXLAN_EXT_GBP, /* Flag or __u32 */ 3021dd144cfSThomas Graf __OVS_VXLAN_EXT_MAX, 3031dd144cfSThomas Graf }; 3041dd144cfSThomas Graf 3051dd144cfSThomas Graf #define OVS_VXLAN_EXT_MAX (__OVS_VXLAN_EXT_MAX - 1) 3061dd144cfSThomas Graf 3071dd144cfSThomas Graf 30858264848SPravin B Shelar /* OVS_VPORT_ATTR_OPTIONS attributes for tunnels. 30958264848SPravin B Shelar */ 31058264848SPravin B Shelar enum { 31158264848SPravin B Shelar OVS_TUNNEL_ATTR_UNSPEC, 31258264848SPravin B Shelar OVS_TUNNEL_ATTR_DST_PORT, /* 16-bit UDP port, used by L4 tunnels. */ 3131dd144cfSThomas Graf OVS_TUNNEL_ATTR_EXTENSION, 31458264848SPravin B Shelar __OVS_TUNNEL_ATTR_MAX 31558264848SPravin B Shelar }; 31658264848SPravin B Shelar 31758264848SPravin B Shelar #define OVS_TUNNEL_ATTR_MAX (__OVS_TUNNEL_ATTR_MAX - 1) 31858264848SPravin B Shelar 31922e3880aSThomas Graf /* Flows. */ 32022e3880aSThomas Graf 32122e3880aSThomas Graf #define OVS_FLOW_FAMILY "ovs_flow" 32222e3880aSThomas Graf #define OVS_FLOW_MCGROUP "ovs_flow" 32322e3880aSThomas Graf #define OVS_FLOW_VERSION 0x1 32422e3880aSThomas Graf 32522e3880aSThomas Graf enum ovs_flow_cmd { 32622e3880aSThomas Graf OVS_FLOW_CMD_UNSPEC, 32722e3880aSThomas Graf OVS_FLOW_CMD_NEW, 32822e3880aSThomas Graf OVS_FLOW_CMD_DEL, 32922e3880aSThomas Graf OVS_FLOW_CMD_GET, 33022e3880aSThomas Graf OVS_FLOW_CMD_SET 33122e3880aSThomas Graf }; 33222e3880aSThomas Graf 33322e3880aSThomas Graf struct ovs_flow_stats { 33422e3880aSThomas Graf __u64 n_packets; /* Number of matched packets. */ 33522e3880aSThomas Graf __u64 n_bytes; /* Number of matched bytes. */ 33622e3880aSThomas Graf }; 33722e3880aSThomas Graf 33822e3880aSThomas Graf enum ovs_key_attr { 33922e3880aSThomas Graf OVS_KEY_ATTR_UNSPEC, 34022e3880aSThomas Graf OVS_KEY_ATTR_ENCAP, /* Nested set of encapsulated attributes. */ 34122e3880aSThomas Graf OVS_KEY_ATTR_PRIORITY, /* u32 skb->priority */ 34222e3880aSThomas Graf OVS_KEY_ATTR_IN_PORT, /* u32 OVS dp port number */ 34322e3880aSThomas Graf OVS_KEY_ATTR_ETHERNET, /* struct ovs_key_ethernet */ 34422e3880aSThomas Graf OVS_KEY_ATTR_VLAN, /* be16 VLAN TCI */ 34522e3880aSThomas Graf OVS_KEY_ATTR_ETHERTYPE, /* be16 Ethernet type */ 34622e3880aSThomas Graf OVS_KEY_ATTR_IPV4, /* struct ovs_key_ipv4 */ 34722e3880aSThomas Graf OVS_KEY_ATTR_IPV6, /* struct ovs_key_ipv6 */ 34822e3880aSThomas Graf OVS_KEY_ATTR_TCP, /* struct ovs_key_tcp */ 34922e3880aSThomas Graf OVS_KEY_ATTR_UDP, /* struct ovs_key_udp */ 35022e3880aSThomas Graf OVS_KEY_ATTR_ICMP, /* struct ovs_key_icmp */ 35122e3880aSThomas Graf OVS_KEY_ATTR_ICMPV6, /* struct ovs_key_icmpv6 */ 35222e3880aSThomas Graf OVS_KEY_ATTR_ARP, /* struct ovs_key_arp */ 35322e3880aSThomas Graf OVS_KEY_ATTR_ND, /* struct ovs_key_nd */ 35422e3880aSThomas Graf OVS_KEY_ATTR_SKB_MARK, /* u32 skb mark */ 3557d5437c7SPravin B Shelar OVS_KEY_ATTR_TUNNEL, /* Nested set of ovs_tunnel attributes */ 356a175a723SJoe Stringer OVS_KEY_ATTR_SCTP, /* struct ovs_key_sctp */ 3575eb26b15SJarno Rajahalme OVS_KEY_ATTR_TCP_FLAGS, /* be16 TCP flags. */ 358971427f3SAndy Zhou OVS_KEY_ATTR_DP_HASH, /* u32 hash value. Value 0 indicates the hash 359971427f3SAndy Zhou is not computed by the datapath. */ 360971427f3SAndy Zhou OVS_KEY_ATTR_RECIRC_ID, /* u32 recirc id */ 36125cd9ba0SSimon Horman OVS_KEY_ATTR_MPLS, /* array of struct ovs_key_mpls. 36225cd9ba0SSimon Horman * The implementation may restrict 36325cd9ba0SSimon Horman * the accepted length of the array. */ 364fbccce59SJoe Stringer OVS_KEY_ATTR_CT_STATE, /* u32 bitmask of OVS_CS_F_* */ 3657f8a436eSJoe Stringer OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */ 366182e3042SJoe Stringer OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */ 36733db4125SJoe Stringer OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */ 3689dd7f890SJarno Rajahalme OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4, /* struct ovs_key_ct_tuple_ipv4 */ 3699dd7f890SJarno Rajahalme OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6, /* struct ovs_key_ct_tuple_ipv6 */ 370b2d0f5d5SYi Yang OVS_KEY_ATTR_NSH, /* Nested set of ovs_nsh_key_* */ 3717d5437c7SPravin B Shelar 3721926407aSIlya Maximets /* User space decided to squat on types 29 and 30. They are defined 3731926407aSIlya Maximets * below, but should not be sent to the kernel. 3741926407aSIlya Maximets * 3751926407aSIlya Maximets * WARNING: No new types should be added unless they are defined 3761926407aSIlya Maximets * for both kernel and user space (no 'ifdef's). It's hard 3771926407aSIlya Maximets * to keep compatibility otherwise. 3781926407aSIlya Maximets */ 3791926407aSIlya Maximets OVS_KEY_ATTR_PACKET_TYPE, /* be32 packet type */ 3801926407aSIlya Maximets OVS_KEY_ATTR_ND_EXTENSIONS, /* IPv6 Neighbor Discovery extensions */ 3811926407aSIlya Maximets 3821926407aSIlya Maximets OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info. 3831926407aSIlya Maximets * For in-kernel use only. 3841926407aSIlya Maximets */ 3851926407aSIlya Maximets OVS_KEY_ATTR_IPV6_EXTHDRS, /* struct ovs_key_ipv6_exthdr */ 38622e3880aSThomas Graf __OVS_KEY_ATTR_MAX 38722e3880aSThomas Graf }; 38822e3880aSThomas Graf 38922e3880aSThomas Graf #define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1) 39022e3880aSThomas Graf 3917d5437c7SPravin B Shelar enum ovs_tunnel_key_attr { 392daa6630aSNicolas Dichtel /* OVS_TUNNEL_KEY_ATTR_NONE, standard nl API requires this attribute! */ 3937d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */ 3947d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */ 3957d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */ 3967d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_TOS, /* u8 Tunnel IP ToS. */ 3977d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_TTL, /* u8 Tunnel IP TTL. */ 3987d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT, /* No argument, set DF. */ 3997d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_CSUM, /* No argument. CSUM packet. */ 40067fa0341SJesse Gross OVS_TUNNEL_KEY_ATTR_OAM, /* No argument. OAM frame. */ 401f5796684SJesse Gross OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS, /* Array of Geneve options. */ 4028f0aad6fSWenyu Zhang OVS_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. */ 4038f0aad6fSWenyu Zhang OVS_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. */ 4041dd144cfSThomas Graf OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested OVS_VXLAN_EXT_* */ 4056b26ba3aSJiri Benc OVS_TUNNEL_KEY_ATTR_IPV6_SRC, /* struct in6_addr src IPv6 address. */ 4066b26ba3aSJiri Benc OVS_TUNNEL_KEY_ATTR_IPV6_DST, /* struct in6_addr dst IPv6 address. */ 407b46f6dedSNicolas Dichtel OVS_TUNNEL_KEY_ATTR_PAD, 408fc1372f8SWilliam Tu OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS, /* struct erspan_metadata */ 40918b6f717Swenxu OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE, /* No argument. IPV4_INFO_BRIDGE mode.*/ 4107d5437c7SPravin B Shelar __OVS_TUNNEL_KEY_ATTR_MAX 4117d5437c7SPravin B Shelar }; 4127d5437c7SPravin B Shelar 4137d5437c7SPravin B Shelar #define OVS_TUNNEL_KEY_ATTR_MAX (__OVS_TUNNEL_KEY_ATTR_MAX - 1) 4147d5437c7SPravin B Shelar 41522e3880aSThomas Graf /** 41622e3880aSThomas Graf * enum ovs_frag_type - IPv4 and IPv6 fragment type 41722e3880aSThomas Graf * @OVS_FRAG_TYPE_NONE: Packet is not a fragment. 41822e3880aSThomas Graf * @OVS_FRAG_TYPE_FIRST: Packet is a fragment with offset 0. 41922e3880aSThomas Graf * @OVS_FRAG_TYPE_LATER: Packet is a fragment with nonzero offset. 42022e3880aSThomas Graf * 42122e3880aSThomas Graf * Used as the @ipv4_frag in &struct ovs_key_ipv4 and as @ipv6_frag &struct 42222e3880aSThomas Graf * ovs_key_ipv6. 42322e3880aSThomas Graf */ 42422e3880aSThomas Graf enum ovs_frag_type { 42522e3880aSThomas Graf OVS_FRAG_TYPE_NONE, 42622e3880aSThomas Graf OVS_FRAG_TYPE_FIRST, 42722e3880aSThomas Graf OVS_FRAG_TYPE_LATER, 42822e3880aSThomas Graf __OVS_FRAG_TYPE_MAX 42922e3880aSThomas Graf }; 43022e3880aSThomas Graf 43122e3880aSThomas Graf #define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1) 43222e3880aSThomas Graf 43322e3880aSThomas Graf struct ovs_key_ethernet { 43422e3880aSThomas Graf __u8 eth_src[ETH_ALEN]; 43522e3880aSThomas Graf __u8 eth_dst[ETH_ALEN]; 43622e3880aSThomas Graf }; 43722e3880aSThomas Graf 43825cd9ba0SSimon Horman struct ovs_key_mpls { 43925cd9ba0SSimon Horman __be32 mpls_lse; 44025cd9ba0SSimon Horman }; 44125cd9ba0SSimon Horman 44222e3880aSThomas Graf struct ovs_key_ipv4 { 44322e3880aSThomas Graf __be32 ipv4_src; 44422e3880aSThomas Graf __be32 ipv4_dst; 44522e3880aSThomas Graf __u8 ipv4_proto; 44622e3880aSThomas Graf __u8 ipv4_tos; 44722e3880aSThomas Graf __u8 ipv4_ttl; 44822e3880aSThomas Graf __u8 ipv4_frag; /* One of OVS_FRAG_TYPE_*. */ 44922e3880aSThomas Graf }; 45022e3880aSThomas Graf 45122e3880aSThomas Graf struct ovs_key_ipv6 { 45222e3880aSThomas Graf __be32 ipv6_src[4]; 45322e3880aSThomas Graf __be32 ipv6_dst[4]; 45422e3880aSThomas Graf __be32 ipv6_label; /* 20-bits in least-significant bits. */ 45522e3880aSThomas Graf __u8 ipv6_proto; 45622e3880aSThomas Graf __u8 ipv6_tclass; 45722e3880aSThomas Graf __u8 ipv6_hlimit; 45822e3880aSThomas Graf __u8 ipv6_frag; /* One of OVS_FRAG_TYPE_*. */ 45922e3880aSThomas Graf }; 46022e3880aSThomas Graf 46128a3f060SToms Atteka /* separate structure to support backward compatibility with older user space */ 46228a3f060SToms Atteka struct ovs_key_ipv6_exthdrs { 46328a3f060SToms Atteka __u16 hdrs; 46428a3f060SToms Atteka }; 46528a3f060SToms Atteka 46622e3880aSThomas Graf struct ovs_key_tcp { 46722e3880aSThomas Graf __be16 tcp_src; 46822e3880aSThomas Graf __be16 tcp_dst; 46922e3880aSThomas Graf }; 47022e3880aSThomas Graf 47122e3880aSThomas Graf struct ovs_key_udp { 47222e3880aSThomas Graf __be16 udp_src; 47322e3880aSThomas Graf __be16 udp_dst; 47422e3880aSThomas Graf }; 47522e3880aSThomas Graf 476a175a723SJoe Stringer struct ovs_key_sctp { 477a175a723SJoe Stringer __be16 sctp_src; 478a175a723SJoe Stringer __be16 sctp_dst; 479a175a723SJoe Stringer }; 480a175a723SJoe Stringer 48122e3880aSThomas Graf struct ovs_key_icmp { 48222e3880aSThomas Graf __u8 icmp_type; 48322e3880aSThomas Graf __u8 icmp_code; 48422e3880aSThomas Graf }; 48522e3880aSThomas Graf 48622e3880aSThomas Graf struct ovs_key_icmpv6 { 48722e3880aSThomas Graf __u8 icmpv6_type; 48822e3880aSThomas Graf __u8 icmpv6_code; 48922e3880aSThomas Graf }; 49022e3880aSThomas Graf 49122e3880aSThomas Graf struct ovs_key_arp { 49222e3880aSThomas Graf __be32 arp_sip; 49322e3880aSThomas Graf __be32 arp_tip; 49422e3880aSThomas Graf __be16 arp_op; 49522e3880aSThomas Graf __u8 arp_sha[ETH_ALEN]; 49622e3880aSThomas Graf __u8 arp_tha[ETH_ALEN]; 49722e3880aSThomas Graf }; 49822e3880aSThomas Graf 49922e3880aSThomas Graf struct ovs_key_nd { 5001a4e96a0SJarno Rajahalme __be32 nd_target[4]; 50122e3880aSThomas Graf __u8 nd_sll[ETH_ALEN]; 50222e3880aSThomas Graf __u8 nd_tll[ETH_ALEN]; 50322e3880aSThomas Graf }; 50422e3880aSThomas Graf 505cb80d58fSJarno Rajahalme #define OVS_CT_LABELS_LEN_32 4 506cb80d58fSJarno Rajahalme #define OVS_CT_LABELS_LEN (OVS_CT_LABELS_LEN_32 * sizeof(__u32)) 50733db4125SJoe Stringer struct ovs_key_ct_labels { 508cb80d58fSJarno Rajahalme union { 50933db4125SJoe Stringer __u8 ct_labels[OVS_CT_LABELS_LEN]; 510cb80d58fSJarno Rajahalme __u32 ct_labels_32[OVS_CT_LABELS_LEN_32]; 511cb80d58fSJarno Rajahalme }; 512c2ac6673SJoe Stringer }; 513c2ac6673SJoe Stringer 5147f8a436eSJoe Stringer /* OVS_KEY_ATTR_CT_STATE flags */ 5157f8a436eSJoe Stringer #define OVS_CS_F_NEW 0x01 /* Beginning of a new connection. */ 5167f8a436eSJoe Stringer #define OVS_CS_F_ESTABLISHED 0x02 /* Part of an existing connection. */ 5177f8a436eSJoe Stringer #define OVS_CS_F_RELATED 0x04 /* Related to an established 5187f8a436eSJoe Stringer * connection. */ 519fbccce59SJoe Stringer #define OVS_CS_F_REPLY_DIR 0x08 /* Flow is in the reply direction. */ 520fbccce59SJoe Stringer #define OVS_CS_F_INVALID 0x10 /* Could not track connection. */ 521fbccce59SJoe Stringer #define OVS_CS_F_TRACKED 0x20 /* Conntrack has occurred. */ 52205752523SJarno Rajahalme #define OVS_CS_F_SRC_NAT 0x40 /* Packet's source address/port was 52305752523SJarno Rajahalme * mangled by NAT. 52405752523SJarno Rajahalme */ 52505752523SJarno Rajahalme #define OVS_CS_F_DST_NAT 0x80 /* Packet's destination address/port 52605752523SJarno Rajahalme * was mangled by NAT. 52705752523SJarno Rajahalme */ 52805752523SJarno Rajahalme 52905752523SJarno Rajahalme #define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT) 5307f8a436eSJoe Stringer 5319dd7f890SJarno Rajahalme struct ovs_key_ct_tuple_ipv4 { 5329dd7f890SJarno Rajahalme __be32 ipv4_src; 5339dd7f890SJarno Rajahalme __be32 ipv4_dst; 5349dd7f890SJarno Rajahalme __be16 src_port; 5359dd7f890SJarno Rajahalme __be16 dst_port; 5369dd7f890SJarno Rajahalme __u8 ipv4_proto; 5379dd7f890SJarno Rajahalme }; 5389dd7f890SJarno Rajahalme 5399dd7f890SJarno Rajahalme struct ovs_key_ct_tuple_ipv6 { 5409dd7f890SJarno Rajahalme __be32 ipv6_src[4]; 5419dd7f890SJarno Rajahalme __be32 ipv6_dst[4]; 5429dd7f890SJarno Rajahalme __be16 src_port; 5439dd7f890SJarno Rajahalme __be16 dst_port; 5449dd7f890SJarno Rajahalme __u8 ipv6_proto; 5459dd7f890SJarno Rajahalme }; 5469dd7f890SJarno Rajahalme 547b2d0f5d5SYi Yang enum ovs_nsh_key_attr { 548b2d0f5d5SYi Yang OVS_NSH_KEY_ATTR_UNSPEC, 549b2d0f5d5SYi Yang OVS_NSH_KEY_ATTR_BASE, /* struct ovs_nsh_key_base. */ 550b2d0f5d5SYi Yang OVS_NSH_KEY_ATTR_MD1, /* struct ovs_nsh_key_md1. */ 551b2d0f5d5SYi Yang OVS_NSH_KEY_ATTR_MD2, /* variable-length octets for MD type 2. */ 552b2d0f5d5SYi Yang __OVS_NSH_KEY_ATTR_MAX 553b2d0f5d5SYi Yang }; 554b2d0f5d5SYi Yang 555b2d0f5d5SYi Yang #define OVS_NSH_KEY_ATTR_MAX (__OVS_NSH_KEY_ATTR_MAX - 1) 556b2d0f5d5SYi Yang 557b2d0f5d5SYi Yang struct ovs_nsh_key_base { 558b2d0f5d5SYi Yang __u8 flags; 559b2d0f5d5SYi Yang __u8 ttl; 560b2d0f5d5SYi Yang __u8 mdtype; 561b2d0f5d5SYi Yang __u8 np; 562b2d0f5d5SYi Yang __be32 path_hdr; 563b2d0f5d5SYi Yang }; 564b2d0f5d5SYi Yang 565b2d0f5d5SYi Yang #define NSH_MD1_CONTEXT_SIZE 4 566b2d0f5d5SYi Yang 567b2d0f5d5SYi Yang struct ovs_nsh_key_md1 { 568b2d0f5d5SYi Yang __be32 context[NSH_MD1_CONTEXT_SIZE]; 569b2d0f5d5SYi Yang }; 570b2d0f5d5SYi Yang 57122e3880aSThomas Graf /** 57222e3880aSThomas Graf * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands. 57322e3880aSThomas Graf * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow 57422e3880aSThomas Graf * key. Always present in notifications. Required for all requests (except 57522e3880aSThomas Graf * dumps). 57622e3880aSThomas Graf * @OVS_FLOW_ATTR_ACTIONS: Nested %OVS_ACTION_ATTR_* attributes specifying 57722e3880aSThomas Graf * the actions to take for packets that match the key. Always present in 57822e3880aSThomas Graf * notifications. Required for %OVS_FLOW_CMD_NEW requests, optional for 579be52c9e9SJarno Rajahalme * %OVS_FLOW_CMD_SET requests. An %OVS_FLOW_CMD_SET without 580be52c9e9SJarno Rajahalme * %OVS_FLOW_ATTR_ACTIONS will not modify the actions. To clear the actions, 581be52c9e9SJarno Rajahalme * an %OVS_FLOW_ATTR_ACTIONS without any nested attributes must be given. 58222e3880aSThomas Graf * @OVS_FLOW_ATTR_STATS: &struct ovs_flow_stats giving statistics for this 58322e3880aSThomas Graf * flow. Present in notifications if the stats would be nonzero. Ignored in 58422e3880aSThomas Graf * requests. 58522e3880aSThomas Graf * @OVS_FLOW_ATTR_TCP_FLAGS: An 8-bit value giving the OR'd value of all of the 58622e3880aSThomas Graf * TCP flags seen on packets in this flow. Only present in notifications for 58722e3880aSThomas Graf * TCP flows, and only if it would be nonzero. Ignored in requests. 58822e3880aSThomas Graf * @OVS_FLOW_ATTR_USED: A 64-bit integer giving the time, in milliseconds on 58922e3880aSThomas Graf * the system monotonic clock, at which a packet was last processed for this 59022e3880aSThomas Graf * flow. Only present in notifications if a packet has been processed for this 59122e3880aSThomas Graf * flow. Ignored in requests. 59222e3880aSThomas Graf * @OVS_FLOW_ATTR_CLEAR: If present in a %OVS_FLOW_CMD_SET request, clears the 59322e3880aSThomas Graf * last-used time, accumulated TCP flags, and statistics for this flow. 59422e3880aSThomas Graf * Otherwise ignored in requests. Never present in notifications. 59503f0d916SAndy Zhou * @OVS_FLOW_ATTR_MASK: Nested %OVS_KEY_ATTR_* attributes specifying the 59603f0d916SAndy Zhou * mask bits for wildcarded flow match. Mask bit value '1' specifies exact 59703f0d916SAndy Zhou * match with corresponding flow key bit, while mask bit value '0' specifies 59803f0d916SAndy Zhou * a wildcarded match. Omitting attribute is treated as wildcarding all 59903f0d916SAndy Zhou * corresponding fields. Optional for all requests. If not present, 60003f0d916SAndy Zhou * all flow key bits are exact match bits. 60174ed7ab9SJoe Stringer * @OVS_FLOW_ATTR_UFID: A value between 1-16 octets specifying a unique 60274ed7ab9SJoe Stringer * identifier for the flow. Causes the flow to be indexed by this value rather 60374ed7ab9SJoe Stringer * than the value of the %OVS_FLOW_ATTR_KEY attribute. Optional for all 60474ed7ab9SJoe Stringer * requests. Present in notifications if the flow was created with this 60574ed7ab9SJoe Stringer * attribute. 60674ed7ab9SJoe Stringer * @OVS_FLOW_ATTR_UFID_FLAGS: A 32-bit value of OR'd %OVS_UFID_F_* 60774ed7ab9SJoe Stringer * flags that provide alternative semantics for flow installation and 60874ed7ab9SJoe Stringer * retrieval. Optional for all requests. 60922e3880aSThomas Graf * 61022e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 61122e3880aSThomas Graf * payload for %OVS_FLOW_* commands. 61222e3880aSThomas Graf */ 61322e3880aSThomas Graf enum ovs_flow_attr { 61422e3880aSThomas Graf OVS_FLOW_ATTR_UNSPEC, 61522e3880aSThomas Graf OVS_FLOW_ATTR_KEY, /* Sequence of OVS_KEY_ATTR_* attributes. */ 61622e3880aSThomas Graf OVS_FLOW_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */ 61722e3880aSThomas Graf OVS_FLOW_ATTR_STATS, /* struct ovs_flow_stats. */ 61822e3880aSThomas Graf OVS_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */ 61922e3880aSThomas Graf OVS_FLOW_ATTR_USED, /* u64 msecs last used in monotonic time. */ 62022e3880aSThomas Graf OVS_FLOW_ATTR_CLEAR, /* Flag to clear stats, tcp_flags, used. */ 62103f0d916SAndy Zhou OVS_FLOW_ATTR_MASK, /* Sequence of OVS_KEY_ATTR_* attributes. */ 62205da5898SJarno Rajahalme OVS_FLOW_ATTR_PROBE, /* Flow operation is a feature probe, error 62305da5898SJarno Rajahalme * logging should be suppressed. */ 62474ed7ab9SJoe Stringer OVS_FLOW_ATTR_UFID, /* Variable length unique flow identifier. */ 62574ed7ab9SJoe Stringer OVS_FLOW_ATTR_UFID_FLAGS,/* u32 of OVS_UFID_F_*. */ 6260238b720SNicolas Dichtel OVS_FLOW_ATTR_PAD, 62722e3880aSThomas Graf __OVS_FLOW_ATTR_MAX 62822e3880aSThomas Graf }; 62922e3880aSThomas Graf 63022e3880aSThomas Graf #define OVS_FLOW_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1) 63122e3880aSThomas Graf 63222e3880aSThomas Graf /** 63374ed7ab9SJoe Stringer * Omit attributes for notifications. 63474ed7ab9SJoe Stringer * 63574ed7ab9SJoe Stringer * If a datapath request contains an %OVS_UFID_F_OMIT_* flag, then the datapath 63674ed7ab9SJoe Stringer * may omit the corresponding %OVS_FLOW_ATTR_* from the response. 63774ed7ab9SJoe Stringer */ 63874ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_KEY (1 << 0) 63974ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_MASK (1 << 1) 64074ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_ACTIONS (1 << 2) 64174ed7ab9SJoe Stringer 64274ed7ab9SJoe Stringer /** 64322e3880aSThomas Graf * enum ovs_sample_attr - Attributes for %OVS_ACTION_ATTR_SAMPLE action. 64422e3880aSThomas Graf * @OVS_SAMPLE_ATTR_PROBABILITY: 32-bit fraction of packets to sample with 64522e3880aSThomas Graf * @OVS_ACTION_ATTR_SAMPLE. A value of 0 samples no packets, a value of 64622e3880aSThomas Graf * %UINT32_MAX samples all packets and intermediate values sample intermediate 64722e3880aSThomas Graf * fractions of packets. 64822e3880aSThomas Graf * @OVS_SAMPLE_ATTR_ACTIONS: Set of actions to execute in sampling event. 64922e3880aSThomas Graf * Actions are passed as nested attributes. 65022e3880aSThomas Graf * 65122e3880aSThomas Graf * Executes the specified actions with the given probability on a per-packet 65222e3880aSThomas Graf * basis. 65322e3880aSThomas Graf */ 65422e3880aSThomas Graf enum ovs_sample_attr { 65522e3880aSThomas Graf OVS_SAMPLE_ATTR_UNSPEC, 65622e3880aSThomas Graf OVS_SAMPLE_ATTR_PROBABILITY, /* u32 number */ 65722e3880aSThomas Graf OVS_SAMPLE_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */ 65822e3880aSThomas Graf __OVS_SAMPLE_ATTR_MAX, 659798c1661Sandy zhou 660798c1661Sandy zhou #ifdef __KERNEL__ 661798c1661Sandy zhou OVS_SAMPLE_ATTR_ARG /* struct sample_arg */ 662798c1661Sandy zhou #endif 66322e3880aSThomas Graf }; 66422e3880aSThomas Graf 66522e3880aSThomas Graf #define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1) 66622e3880aSThomas Graf 667798c1661Sandy zhou #ifdef __KERNEL__ 668798c1661Sandy zhou struct sample_arg { 669798c1661Sandy zhou bool exec; /* When true, actions in sample will not 670798c1661Sandy zhou * change flow keys. False otherwise. 671798c1661Sandy zhou */ 672798c1661Sandy zhou u32 probability; /* Same value as 673798c1661Sandy zhou * 'OVS_SAMPLE_ATTR_PROBABILITY'. 674798c1661Sandy zhou */ 675798c1661Sandy zhou }; 676798c1661Sandy zhou #endif 677798c1661Sandy zhou 67822e3880aSThomas Graf /** 67922e3880aSThomas Graf * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action. 68022e3880aSThomas Graf * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION 68122e3880aSThomas Graf * message should be sent. Required. 68222e3880aSThomas Graf * @OVS_USERSPACE_ATTR_USERDATA: If present, its variable-length argument is 68322e3880aSThomas Graf * copied to the %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA. 6848f0aad6fSWenyu Zhang * @OVS_USERSPACE_ATTR_EGRESS_TUN_PORT: If present, u32 output port to get 6858f0aad6fSWenyu Zhang * tunnel info. 686ccea7445SNeil McKee * @OVS_USERSPACE_ATTR_ACTIONS: If present, send actions with upcall. 68722e3880aSThomas Graf */ 68822e3880aSThomas Graf enum ovs_userspace_attr { 68922e3880aSThomas Graf OVS_USERSPACE_ATTR_UNSPEC, 69022e3880aSThomas Graf OVS_USERSPACE_ATTR_PID, /* u32 Netlink PID to receive upcalls. */ 69122e3880aSThomas Graf OVS_USERSPACE_ATTR_USERDATA, /* Optional user-specified cookie. */ 6928f0aad6fSWenyu Zhang OVS_USERSPACE_ATTR_EGRESS_TUN_PORT, /* Optional, u32 output port 6938f0aad6fSWenyu Zhang * to get tunnel info. */ 694ccea7445SNeil McKee OVS_USERSPACE_ATTR_ACTIONS, /* Optional flag to get actions. */ 69522e3880aSThomas Graf __OVS_USERSPACE_ATTR_MAX 69622e3880aSThomas Graf }; 69722e3880aSThomas Graf 69822e3880aSThomas Graf #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1) 69922e3880aSThomas Graf 700f2a4d086SWilliam Tu struct ovs_action_trunc { 701a1d1f65fSMikko Rapeli __u32 max_len; /* Max packet size in bytes. */ 702f2a4d086SWilliam Tu }; 703f2a4d086SWilliam Tu 70422e3880aSThomas Graf /** 70525cd9ba0SSimon Horman * struct ovs_action_push_mpls - %OVS_ACTION_ATTR_PUSH_MPLS action argument. 70625cd9ba0SSimon Horman * @mpls_lse: MPLS label stack entry to push. 70725cd9ba0SSimon Horman * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame. 70825cd9ba0SSimon Horman * 70925cd9ba0SSimon Horman * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and 71025cd9ba0SSimon Horman * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected. 71125cd9ba0SSimon Horman */ 71225cd9ba0SSimon Horman struct ovs_action_push_mpls { 71325cd9ba0SSimon Horman __be32 mpls_lse; 71425cd9ba0SSimon Horman __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */ 71525cd9ba0SSimon Horman }; 71625cd9ba0SSimon Horman 71725cd9ba0SSimon Horman /** 718f66b53fdSMartin Varghese * struct ovs_action_add_mpls - %OVS_ACTION_ATTR_ADD_MPLS action 719f66b53fdSMartin Varghese * argument. 720f66b53fdSMartin Varghese * @mpls_lse: MPLS label stack entry to push. 721f66b53fdSMartin Varghese * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame. 722f66b53fdSMartin Varghese * @tun_flags: MPLS tunnel attributes. 723f66b53fdSMartin Varghese * 724f66b53fdSMartin Varghese * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and 725f66b53fdSMartin Varghese * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected. 726f66b53fdSMartin Varghese */ 727f66b53fdSMartin Varghese struct ovs_action_add_mpls { 728f66b53fdSMartin Varghese __be32 mpls_lse; 729f66b53fdSMartin Varghese __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */ 730f66b53fdSMartin Varghese __u16 tun_flags; 731f66b53fdSMartin Varghese }; 732f66b53fdSMartin Varghese 733f66b53fdSMartin Varghese #define OVS_MPLS_L3_TUNNEL_FLAG_MASK (1 << 0) /* Flag to specify the place of 734f66b53fdSMartin Varghese * insertion of MPLS header. 735f66b53fdSMartin Varghese * When false, the MPLS header 736f66b53fdSMartin Varghese * will be inserted at the start 737f66b53fdSMartin Varghese * of the packet. 738f66b53fdSMartin Varghese * When true, the MPLS header 739f66b53fdSMartin Varghese * will be inserted at the start 740f66b53fdSMartin Varghese * of the l3 header. 741f66b53fdSMartin Varghese */ 742f66b53fdSMartin Varghese 743f66b53fdSMartin Varghese /** 74422e3880aSThomas Graf * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument. 74522e3880aSThomas Graf * @vlan_tpid: Tag protocol identifier (TPID) to push. 74622e3880aSThomas Graf * @vlan_tci: Tag control identifier (TCI) to push. The CFI bit must be set 74722e3880aSThomas Graf * (but it will not be set in the 802.1Q header that is pushed). 74822e3880aSThomas Graf * 7498c146bb9SThomas F Herbert * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD. 7508c146bb9SThomas F Herbert * The only acceptable TPID values are those that the kernel module also parses 7518c146bb9SThomas F Herbert * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed 7528c146bb9SThomas F Herbert * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results. 75322e3880aSThomas Graf */ 75422e3880aSThomas Graf struct ovs_action_push_vlan { 7558c146bb9SThomas F Herbert __be16 vlan_tpid; /* 802.1Q or 802.1ad TPID. */ 75622e3880aSThomas Graf __be16 vlan_tci; /* 802.1Q TCI (VLAN ID and priority). */ 75722e3880aSThomas Graf }; 75822e3880aSThomas Graf 759971427f3SAndy Zhou /* Data path hash algorithm for computing Datapath hash. 760971427f3SAndy Zhou * 761971427f3SAndy Zhou * The algorithm type only specifies the fields in a flow 762971427f3SAndy Zhou * will be used as part of the hash. Each datapath is free 763971427f3SAndy Zhou * to use its own hash algorithm. The hash value will be 764971427f3SAndy Zhou * opaque to the user space daemon. 765971427f3SAndy Zhou */ 766971427f3SAndy Zhou enum ovs_hash_alg { 767971427f3SAndy Zhou OVS_HASH_ALG_L4, 768e069ba07SAaron Conole OVS_HASH_ALG_SYM_L4, 769971427f3SAndy Zhou }; 770971427f3SAndy Zhou 771971427f3SAndy Zhou /* 772971427f3SAndy Zhou * struct ovs_action_hash - %OVS_ACTION_ATTR_HASH action argument. 773971427f3SAndy Zhou * @hash_alg: Algorithm used to compute hash prior to recirculation. 774971427f3SAndy Zhou * @hash_basis: basis used for computing hash. 775971427f3SAndy Zhou */ 776971427f3SAndy Zhou struct ovs_action_hash { 777e6571aa5SMikko Rapeli __u32 hash_alg; /* One of ovs_hash_alg. */ 778e6571aa5SMikko Rapeli __u32 hash_basis; 779971427f3SAndy Zhou }; 780971427f3SAndy Zhou 78122e3880aSThomas Graf /** 7827f8a436eSJoe Stringer * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action. 783ab38a7b5SJoe Stringer * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack 784ab38a7b5SJoe Stringer * table. This allows future packets for the same connection to be identified 7851d008a1dSJoe Stringer * as 'established' or 'related'. The flow key for the current packet will 7861d008a1dSJoe Stringer * retain the pre-commit connection state. 7877f8a436eSJoe Stringer * @OVS_CT_ATTR_ZONE: u16 connection tracking zone. 788182e3042SJoe Stringer * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the 789182e3042SJoe Stringer * mask, the corresponding bit in the value is copied to the connection 790182e3042SJoe Stringer * tracking mark field in the connection. 791e5f5d747SPaolo Abeni * @OVS_CT_ATTR_LABELS: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN 792c2ac6673SJoe Stringer * mask. For each bit set in the mask, the corresponding bit in the value is 793c2ac6673SJoe Stringer * copied to the connection tracking label field in the connection. 794cae3a262SJoe Stringer * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG. 79505752523SJarno Rajahalme * @OVS_CT_ATTR_NAT: Nested OVS_NAT_ATTR_* for performing L3 network address 79605752523SJarno Rajahalme * translation (NAT) on the packet. 797dd41d33fSJarno Rajahalme * @OVS_CT_ATTR_FORCE_COMMIT: Like %OVS_CT_ATTR_COMMIT, but instead of doing 798dd41d33fSJarno Rajahalme * nothing if the connection is already committed will check that the current 799dd41d33fSJarno Rajahalme * packet is in conntrack entry's original direction. If directionality does 800dd41d33fSJarno Rajahalme * not match, will delete the existing conntrack entry and commit a new one. 80112064551SJarno Rajahalme * @OVS_CT_ATTR_EVENTMASK: Mask of bits indicating which conntrack event types 80212064551SJarno Rajahalme * (enum ip_conntrack_events IPCT_*) should be reported. For any bit set to 80312064551SJarno Rajahalme * zero, the corresponding event type is not generated. Default behavior 80412064551SJarno Rajahalme * depends on system configuration, but typically all event types are 80512064551SJarno Rajahalme * generated, hence listening on NFNLGRP_CONNTRACK_UPDATE events may get a lot 80612064551SJarno Rajahalme * of events. Explicitly passing this attribute allows limiting the updates 80712064551SJarno Rajahalme * received to the events of interest. The bit 1 << IPCT_NEW, 1 << 80812064551SJarno Rajahalme * IPCT_RELATED, and 1 << IPCT_DESTROY must be set to ones for those events to 80912064551SJarno Rajahalme * be received on NFNLGRP_CONNTRACK_NEW and NFNLGRP_CONNTRACK_DESTROY groups, 81012064551SJarno Rajahalme * respectively. Remaining bits control the changes for which an event is 81112064551SJarno Rajahalme * delivered on the NFNLGRP_CONNTRACK_UPDATE group. 81206bd2bdfSYi-Hung Wei * @OVS_CT_ATTR_TIMEOUT: Variable length string defining conntrack timeout. 8137f8a436eSJoe Stringer */ 8147f8a436eSJoe Stringer enum ovs_ct_attr { 8157f8a436eSJoe Stringer OVS_CT_ATTR_UNSPEC, 816ab38a7b5SJoe Stringer OVS_CT_ATTR_COMMIT, /* No argument, commits connection. */ 8177f8a436eSJoe Stringer OVS_CT_ATTR_ZONE, /* u16 zone id. */ 818182e3042SJoe Stringer OVS_CT_ATTR_MARK, /* mark to associate with this connection. */ 81933db4125SJoe Stringer OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */ 820cae3a262SJoe Stringer OVS_CT_ATTR_HELPER, /* netlink helper to assist detection of 821cae3a262SJoe Stringer related connections. */ 82205752523SJarno Rajahalme OVS_CT_ATTR_NAT, /* Nested OVS_NAT_ATTR_* */ 823dd41d33fSJarno Rajahalme OVS_CT_ATTR_FORCE_COMMIT, /* No argument */ 82412064551SJarno Rajahalme OVS_CT_ATTR_EVENTMASK, /* u32 mask of IPCT_* events. */ 82506bd2bdfSYi-Hung Wei OVS_CT_ATTR_TIMEOUT, /* Associate timeout with this connection for 82606bd2bdfSYi-Hung Wei * fine-grain timeout tuning. */ 8277f8a436eSJoe Stringer __OVS_CT_ATTR_MAX 8287f8a436eSJoe Stringer }; 8297f8a436eSJoe Stringer 8307f8a436eSJoe Stringer #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1) 8317f8a436eSJoe Stringer 8327f8a436eSJoe Stringer /** 83305752523SJarno Rajahalme * enum ovs_nat_attr - Attributes for %OVS_CT_ATTR_NAT. 83405752523SJarno Rajahalme * 83505752523SJarno Rajahalme * @OVS_NAT_ATTR_SRC: Flag for Source NAT (mangle source address/port). 83605752523SJarno Rajahalme * @OVS_NAT_ATTR_DST: Flag for Destination NAT (mangle destination 83705752523SJarno Rajahalme * address/port). Only one of (@OVS_NAT_ATTR_SRC, @OVS_NAT_ATTR_DST) may be 83805752523SJarno Rajahalme * specified. Effective only for packets for ct_state NEW connections. 83905752523SJarno Rajahalme * Packets of committed connections are mangled by the NAT action according to 84005752523SJarno Rajahalme * the committed NAT type regardless of the flags specified. As a corollary, a 84105752523SJarno Rajahalme * NAT action without a NAT type flag will only mangle packets of committed 84205752523SJarno Rajahalme * connections. The following NAT attributes only apply for NEW 84305752523SJarno Rajahalme * (non-committed) connections, and they may be included only when the CT 84405752523SJarno Rajahalme * action has the @OVS_CT_ATTR_COMMIT flag and either @OVS_NAT_ATTR_SRC or 84505752523SJarno Rajahalme * @OVS_NAT_ATTR_DST is also included. 84605752523SJarno Rajahalme * @OVS_NAT_ATTR_IP_MIN: struct in_addr or struct in6_addr 84705752523SJarno Rajahalme * @OVS_NAT_ATTR_IP_MAX: struct in_addr or struct in6_addr 84805752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_MIN: u16 L4 protocol specific lower boundary (port) 84905752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_MAX: u16 L4 protocol specific upper boundary (port) 85005752523SJarno Rajahalme * @OVS_NAT_ATTR_PERSISTENT: Flag for persistent IP mapping across reboots 85105752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_HASH: Flag for pseudo random L4 port mapping (MD5) 85205752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_RANDOM: Flag for fully randomized L4 port mapping 85305752523SJarno Rajahalme */ 85405752523SJarno Rajahalme enum ovs_nat_attr { 85505752523SJarno Rajahalme OVS_NAT_ATTR_UNSPEC, 85605752523SJarno Rajahalme OVS_NAT_ATTR_SRC, 85705752523SJarno Rajahalme OVS_NAT_ATTR_DST, 85805752523SJarno Rajahalme OVS_NAT_ATTR_IP_MIN, 85905752523SJarno Rajahalme OVS_NAT_ATTR_IP_MAX, 86005752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_MIN, 86105752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_MAX, 86205752523SJarno Rajahalme OVS_NAT_ATTR_PERSISTENT, 86305752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_HASH, 86405752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_RANDOM, 86505752523SJarno Rajahalme __OVS_NAT_ATTR_MAX, 86605752523SJarno Rajahalme }; 86705752523SJarno Rajahalme 86805752523SJarno Rajahalme #define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1) 86905752523SJarno Rajahalme 87091820da6SJiri Benc /* 87191820da6SJiri Benc * struct ovs_action_push_eth - %OVS_ACTION_ATTR_PUSH_ETH action argument. 87291820da6SJiri Benc * @addresses: Source and destination MAC addresses. 87391820da6SJiri Benc * @eth_type: Ethernet type 87491820da6SJiri Benc */ 87591820da6SJiri Benc struct ovs_action_push_eth { 87691820da6SJiri Benc struct ovs_key_ethernet addresses; 87791820da6SJiri Benc }; 87891820da6SJiri Benc 8794d5ec89fSNuman Siddique /* 8804d5ec89fSNuman Siddique * enum ovs_check_pkt_len_attr - Attributes for %OVS_ACTION_ATTR_CHECK_PKT_LEN. 8814d5ec89fSNuman Siddique * 8824d5ec89fSNuman Siddique * @OVS_CHECK_PKT_LEN_ATTR_PKT_LEN: u16 Packet length to check for. 8834d5ec89fSNuman Siddique * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER: Nested OVS_ACTION_ATTR_* 8844d5ec89fSNuman Siddique * actions to apply if the packer length is greater than the specified 8854d5ec89fSNuman Siddique * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN. 8864d5ec89fSNuman Siddique * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL - Nested OVS_ACTION_ATTR_* 8874d5ec89fSNuman Siddique * actions to apply if the packer length is lesser or equal to the specified 8884d5ec89fSNuman Siddique * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN. 8894d5ec89fSNuman Siddique */ 8904d5ec89fSNuman Siddique enum ovs_check_pkt_len_attr { 8914d5ec89fSNuman Siddique OVS_CHECK_PKT_LEN_ATTR_UNSPEC, 8924d5ec89fSNuman Siddique OVS_CHECK_PKT_LEN_ATTR_PKT_LEN, 8934d5ec89fSNuman Siddique OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER, 8944d5ec89fSNuman Siddique OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL, 8954d5ec89fSNuman Siddique __OVS_CHECK_PKT_LEN_ATTR_MAX, 8964d5ec89fSNuman Siddique 8974d5ec89fSNuman Siddique #ifdef __KERNEL__ 8984d5ec89fSNuman Siddique OVS_CHECK_PKT_LEN_ATTR_ARG /* struct check_pkt_len_arg */ 8994d5ec89fSNuman Siddique #endif 9004d5ec89fSNuman Siddique }; 9014d5ec89fSNuman Siddique 9024d5ec89fSNuman Siddique #define OVS_CHECK_PKT_LEN_ATTR_MAX (__OVS_CHECK_PKT_LEN_ATTR_MAX - 1) 9034d5ec89fSNuman Siddique 9044d5ec89fSNuman Siddique #ifdef __KERNEL__ 9054d5ec89fSNuman Siddique struct check_pkt_len_arg { 9064d5ec89fSNuman Siddique u16 pkt_len; /* Same value as OVS_CHECK_PKT_LEN_ATTR_PKT_LEN'. */ 9074d5ec89fSNuman Siddique bool exec_for_greater; /* When true, actions in IF_GREATER will 9084d5ec89fSNuman Siddique * not change flow keys. False otherwise. 9094d5ec89fSNuman Siddique */ 9104d5ec89fSNuman Siddique bool exec_for_lesser_equal; /* When true, actions in IF_LESS_EQUAL 9114d5ec89fSNuman Siddique * will not change flow keys. False 9124d5ec89fSNuman Siddique * otherwise. 9134d5ec89fSNuman Siddique */ 9144d5ec89fSNuman Siddique }; 9154d5ec89fSNuman Siddique #endif 9164d5ec89fSNuman Siddique 91705752523SJarno Rajahalme /** 91822e3880aSThomas Graf * enum ovs_action_attr - Action types. 91922e3880aSThomas Graf * 92022e3880aSThomas Graf * @OVS_ACTION_ATTR_OUTPUT: Output packet to port. 921f2a4d086SWilliam Tu * @OVS_ACTION_ATTR_TRUNC: Output packet to port with truncated packet size. 92222e3880aSThomas Graf * @OVS_ACTION_ATTR_USERSPACE: Send packet to userspace according to nested 92322e3880aSThomas Graf * %OVS_USERSPACE_ATTR_* attributes. 92422e3880aSThomas Graf * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header. The 92522e3880aSThomas Graf * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its 92622e3880aSThomas Graf * value. 92783d2b9baSJarno Rajahalme * @OVS_ACTION_ATTR_SET_MASKED: Replaces the contents of an existing header. A 92883d2b9baSJarno Rajahalme * nested %OVS_KEY_ATTR_* attribute specifies a header to modify, its value, 92983d2b9baSJarno Rajahalme * and a mask. For every bit set in the mask, the corresponding bit value 93083d2b9baSJarno Rajahalme * is copied from the value to the packet header field, rest of the bits are 93183d2b9baSJarno Rajahalme * left unchanged. The non-masked value bits must be passed in as zeroes. 93283d2b9baSJarno Rajahalme * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute. 9338c146bb9SThomas F Herbert * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header 9348c146bb9SThomas F Herbert * onto the packet. 9358c146bb9SThomas F Herbert * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header 9368c146bb9SThomas F Herbert * from the packet. 93722e3880aSThomas Graf * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in 93822e3880aSThomas Graf * the nested %OVS_SAMPLE_ATTR_* attributes. 93925cd9ba0SSimon Horman * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the 94025cd9ba0SSimon Horman * top of the packets MPLS label stack. Set the ethertype of the 94125cd9ba0SSimon Horman * encapsulating frame to either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC to 94225cd9ba0SSimon Horman * indicate the new packet contents. 94325cd9ba0SSimon Horman * @OVS_ACTION_ATTR_POP_MPLS: Pop an MPLS label stack entry off of the 94425cd9ba0SSimon Horman * packet's MPLS label stack. Set the encapsulating frame's ethertype to 94525cd9ba0SSimon Horman * indicate the new packet contents. This could potentially still be 94625cd9ba0SSimon Horman * %ETH_P_MPLS if the resulting MPLS label stack is not empty. If there 94725cd9ba0SSimon Horman * is no MPLS label stack, as determined by ethertype, no action is taken. 9487f8a436eSJoe Stringer * @OVS_ACTION_ATTR_CT: Track the connection. Populate the conntrack-related 9497f8a436eSJoe Stringer * entries in the flow key. 95091820da6SJiri Benc * @OVS_ACTION_ATTR_PUSH_ETH: Push a new outermost Ethernet header onto the 95191820da6SJiri Benc * packet. 95291820da6SJiri Benc * @OVS_ACTION_ATTR_POP_ETH: Pop the outermost Ethernet header off the 95391820da6SJiri Benc * packet. 954b8226962SEric Garver * @OVS_ACTION_ATTR_CT_CLEAR: Clear conntrack state from the packet. 955b2d0f5d5SYi Yang * @OVS_ACTION_ATTR_PUSH_NSH: push NSH header to the packet. 956b2d0f5d5SYi Yang * @OVS_ACTION_ATTR_POP_NSH: pop the outermost NSH header off the packet. 957cd8a6c33SAndy Zhou * @OVS_ACTION_ATTR_METER: Run packet through a meter, which may drop the 958cd8a6c33SAndy Zhou * packet, or modify the packet (e.g., change the DSCP field). 959b2335040SYifeng Sun * @OVS_ACTION_ATTR_CLONE: make a copy of the packet and execute a list of 960b2335040SYifeng Sun * actions without affecting the original packet and key. 9614d5ec89fSNuman Siddique * @OVS_ACTION_ATTR_CHECK_PKT_LEN: Check the packet length and execute a set 9624d5ec89fSNuman Siddique * of actions if greater than the specified packet length, else execute 9634d5ec89fSNuman Siddique * another set of actions. 964f66b53fdSMartin Varghese * @OVS_ACTION_ATTR_ADD_MPLS: Push a new MPLS label stack entry at the 965f66b53fdSMartin Varghese * start of the packet or at the start of the l3 header depending on the value 966f66b53fdSMartin Varghese * of l3 tunnel flag in the tun_flags field of OVS_ACTION_ATTR_ADD_MPLS 967f66b53fdSMartin Varghese * argument. 968*e7bc7db9SEric Garver * @OVS_ACTION_ATTR_DROP: Explicit drop action. 96922e3880aSThomas Graf * 97022e3880aSThomas Graf * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all 97122e3880aSThomas Graf * fields within a header are modifiable, e.g. the IPv4 protocol and fragment 97222e3880aSThomas Graf * type may not be changed. 97383d2b9baSJarno Rajahalme * 97483d2b9baSJarno Rajahalme * @OVS_ACTION_ATTR_SET_TO_MASKED: Kernel internal masked set action translated 97583d2b9baSJarno Rajahalme * from the @OVS_ACTION_ATTR_SET. 97622e3880aSThomas Graf */ 97722e3880aSThomas Graf 97822e3880aSThomas Graf enum ovs_action_attr { 97922e3880aSThomas Graf OVS_ACTION_ATTR_UNSPEC, 98022e3880aSThomas Graf OVS_ACTION_ATTR_OUTPUT, /* u32 port number. */ 98122e3880aSThomas Graf OVS_ACTION_ATTR_USERSPACE, /* Nested OVS_USERSPACE_ATTR_*. */ 98222e3880aSThomas Graf OVS_ACTION_ATTR_SET, /* One nested OVS_KEY_ATTR_*. */ 98322e3880aSThomas Graf OVS_ACTION_ATTR_PUSH_VLAN, /* struct ovs_action_push_vlan. */ 98422e3880aSThomas Graf OVS_ACTION_ATTR_POP_VLAN, /* No argument. */ 98522e3880aSThomas Graf OVS_ACTION_ATTR_SAMPLE, /* Nested OVS_SAMPLE_ATTR_*. */ 986971427f3SAndy Zhou OVS_ACTION_ATTR_RECIRC, /* u32 recirc_id. */ 987971427f3SAndy Zhou OVS_ACTION_ATTR_HASH, /* struct ovs_action_hash. */ 98825cd9ba0SSimon Horman OVS_ACTION_ATTR_PUSH_MPLS, /* struct ovs_action_push_mpls. */ 98925cd9ba0SSimon Horman OVS_ACTION_ATTR_POP_MPLS, /* __be16 ethertype. */ 99083d2b9baSJarno Rajahalme OVS_ACTION_ATTR_SET_MASKED, /* One nested OVS_KEY_ATTR_* including 99183d2b9baSJarno Rajahalme * data immediately followed by a mask. 99283d2b9baSJarno Rajahalme * The data must be zero for the unmasked 99383d2b9baSJarno Rajahalme * bits. */ 9940a7cc172SJoe Stringer OVS_ACTION_ATTR_CT, /* Nested OVS_CT_ATTR_* . */ 995f2a4d086SWilliam Tu OVS_ACTION_ATTR_TRUNC, /* u32 struct ovs_action_trunc. */ 99691820da6SJiri Benc OVS_ACTION_ATTR_PUSH_ETH, /* struct ovs_action_push_eth. */ 99791820da6SJiri Benc OVS_ACTION_ATTR_POP_ETH, /* No argument. */ 998b8226962SEric Garver OVS_ACTION_ATTR_CT_CLEAR, /* No argument. */ 999b2d0f5d5SYi Yang OVS_ACTION_ATTR_PUSH_NSH, /* Nested OVS_NSH_KEY_ATTR_*. */ 1000b2d0f5d5SYi Yang OVS_ACTION_ATTR_POP_NSH, /* No argument. */ 1001cd8a6c33SAndy Zhou OVS_ACTION_ATTR_METER, /* u32 meter ID. */ 1002b2335040SYifeng Sun OVS_ACTION_ATTR_CLONE, /* Nested OVS_CLONE_ATTR_*. */ 10034d5ec89fSNuman Siddique OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */ 1004f66b53fdSMartin Varghese OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */ 1005744676e7SMatteo Croce OVS_ACTION_ATTR_DEC_TTL, /* Nested OVS_DEC_TTL_ATTR_*. */ 1006*e7bc7db9SEric Garver OVS_ACTION_ATTR_DROP, /* u32 error code. */ 100725cd9ba0SSimon Horman 100883d2b9baSJarno Rajahalme __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted 100983d2b9baSJarno Rajahalme * from userspace. */ 101083d2b9baSJarno Rajahalme 101183d2b9baSJarno Rajahalme #ifdef __KERNEL__ 101283d2b9baSJarno Rajahalme OVS_ACTION_ATTR_SET_TO_MASKED, /* Kernel module internal masked 101383d2b9baSJarno Rajahalme * set action converted from 101483d2b9baSJarno Rajahalme * OVS_ACTION_ATTR_SET. */ 101583d2b9baSJarno Rajahalme #endif 101622e3880aSThomas Graf }; 101722e3880aSThomas Graf 101822e3880aSThomas Graf #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1) 101922e3880aSThomas Graf 102057940406SAndy Zhou /* Meters. */ 102157940406SAndy Zhou #define OVS_METER_FAMILY "ovs_meter" 102257940406SAndy Zhou #define OVS_METER_MCGROUP "ovs_meter" 102357940406SAndy Zhou #define OVS_METER_VERSION 0x1 102457940406SAndy Zhou 102557940406SAndy Zhou enum ovs_meter_cmd { 102657940406SAndy Zhou OVS_METER_CMD_UNSPEC, 102757940406SAndy Zhou OVS_METER_CMD_FEATURES, /* Get features supported by the datapath. */ 102857940406SAndy Zhou OVS_METER_CMD_SET, /* Add or modify a meter. */ 102957940406SAndy Zhou OVS_METER_CMD_DEL, /* Delete a meter. */ 103057940406SAndy Zhou OVS_METER_CMD_GET /* Get meter stats. */ 103157940406SAndy Zhou }; 103257940406SAndy Zhou 103357940406SAndy Zhou enum ovs_meter_attr { 103457940406SAndy Zhou OVS_METER_ATTR_UNSPEC, 103557940406SAndy Zhou OVS_METER_ATTR_ID, /* u32 meter ID within datapath. */ 103657940406SAndy Zhou OVS_METER_ATTR_KBPS, /* No argument. If set, units in kilobits 103757940406SAndy Zhou * per second. Otherwise, units in 103857940406SAndy Zhou * packets per second. 103957940406SAndy Zhou */ 104057940406SAndy Zhou OVS_METER_ATTR_STATS, /* struct ovs_flow_stats for the meter. */ 104157940406SAndy Zhou OVS_METER_ATTR_BANDS, /* Nested attributes for meter bands. */ 104257940406SAndy Zhou OVS_METER_ATTR_USED, /* u64 msecs last used in monotonic time. */ 104357940406SAndy Zhou OVS_METER_ATTR_CLEAR, /* Flag to clear stats, used. */ 104457940406SAndy Zhou OVS_METER_ATTR_MAX_METERS, /* u32 number of meters supported. */ 104557940406SAndy Zhou OVS_METER_ATTR_MAX_BANDS, /* u32 max number of bands per meter. */ 104657940406SAndy Zhou OVS_METER_ATTR_PAD, 104757940406SAndy Zhou __OVS_METER_ATTR_MAX 104857940406SAndy Zhou }; 104957940406SAndy Zhou 105057940406SAndy Zhou #define OVS_METER_ATTR_MAX (__OVS_METER_ATTR_MAX - 1) 105157940406SAndy Zhou 105257940406SAndy Zhou enum ovs_band_attr { 105357940406SAndy Zhou OVS_BAND_ATTR_UNSPEC, 105457940406SAndy Zhou OVS_BAND_ATTR_TYPE, /* u32 OVS_METER_BAND_TYPE_* constant. */ 105557940406SAndy Zhou OVS_BAND_ATTR_RATE, /* u32 band rate in meter units (see above). */ 105657940406SAndy Zhou OVS_BAND_ATTR_BURST, /* u32 burst size in meter units. */ 105757940406SAndy Zhou OVS_BAND_ATTR_STATS, /* struct ovs_flow_stats for the band. */ 105857940406SAndy Zhou __OVS_BAND_ATTR_MAX 105957940406SAndy Zhou }; 106057940406SAndy Zhou 106157940406SAndy Zhou #define OVS_BAND_ATTR_MAX (__OVS_BAND_ATTR_MAX - 1) 106257940406SAndy Zhou 106357940406SAndy Zhou enum ovs_meter_band_type { 106457940406SAndy Zhou OVS_METER_BAND_TYPE_UNSPEC, 106557940406SAndy Zhou OVS_METER_BAND_TYPE_DROP, /* Drop exceeding packets. */ 106657940406SAndy Zhou __OVS_METER_BAND_TYPE_MAX 106757940406SAndy Zhou }; 106857940406SAndy Zhou 106957940406SAndy Zhou #define OVS_METER_BAND_TYPE_MAX (__OVS_METER_BAND_TYPE_MAX - 1) 107057940406SAndy Zhou 10715972be6bSYi-Hung Wei /* Conntrack limit */ 10725972be6bSYi-Hung Wei #define OVS_CT_LIMIT_FAMILY "ovs_ct_limit" 10735972be6bSYi-Hung Wei #define OVS_CT_LIMIT_MCGROUP "ovs_ct_limit" 10745972be6bSYi-Hung Wei #define OVS_CT_LIMIT_VERSION 0x1 10755972be6bSYi-Hung Wei 10765972be6bSYi-Hung Wei enum ovs_ct_limit_cmd { 10775972be6bSYi-Hung Wei OVS_CT_LIMIT_CMD_UNSPEC, 10785972be6bSYi-Hung Wei OVS_CT_LIMIT_CMD_SET, /* Add or modify ct limit. */ 10795972be6bSYi-Hung Wei OVS_CT_LIMIT_CMD_DEL, /* Delete ct limit. */ 10805972be6bSYi-Hung Wei OVS_CT_LIMIT_CMD_GET /* Get ct limit. */ 10815972be6bSYi-Hung Wei }; 10825972be6bSYi-Hung Wei 10835972be6bSYi-Hung Wei enum ovs_ct_limit_attr { 10845972be6bSYi-Hung Wei OVS_CT_LIMIT_ATTR_UNSPEC, 10855972be6bSYi-Hung Wei OVS_CT_LIMIT_ATTR_ZONE_LIMIT, /* Nested struct ovs_zone_limit. */ 10865972be6bSYi-Hung Wei __OVS_CT_LIMIT_ATTR_MAX 10875972be6bSYi-Hung Wei }; 10885972be6bSYi-Hung Wei 10895972be6bSYi-Hung Wei #define OVS_CT_LIMIT_ATTR_MAX (__OVS_CT_LIMIT_ATTR_MAX - 1) 10905972be6bSYi-Hung Wei 10915972be6bSYi-Hung Wei #define OVS_ZONE_LIMIT_DEFAULT_ZONE -1 10925972be6bSYi-Hung Wei 10935972be6bSYi-Hung Wei struct ovs_zone_limit { 10945972be6bSYi-Hung Wei int zone_id; 10955972be6bSYi-Hung Wei __u32 limit; 10965972be6bSYi-Hung Wei __u32 count; 10975972be6bSYi-Hung Wei }; 10985972be6bSYi-Hung Wei 1099744676e7SMatteo Croce enum ovs_dec_ttl_attr { 1100744676e7SMatteo Croce OVS_DEC_TTL_ATTR_UNSPEC, 1101744676e7SMatteo Croce OVS_DEC_TTL_ATTR_ACTION, /* Nested struct nlattr */ 1102744676e7SMatteo Croce __OVS_DEC_TTL_ATTR_MAX 1103744676e7SMatteo Croce }; 1104744676e7SMatteo Croce 110569929d4cSEelco Chaudron #define OVS_DEC_TTL_ATTR_MAX (__OVS_DEC_TTL_ATTR_MAX - 1) 110669929d4cSEelco Chaudron 110722e3880aSThomas Graf #endif /* _LINUX_OPENVSWITCH_H */ 1108