From patchwork Thu Mar 3 18:20:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ben@skyportsystems.com X-Patchwork-Id: 591551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id DDF6D140C65 for ; Fri, 4 Mar 2016 05:23:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=skyportsystems.com header.i=@skyportsystems.com header.b=tWckcyG1; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7B21D22C3E9; Thu, 3 Mar 2016 10:21:31 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 87A7F22C3E4 for ; Thu, 3 Mar 2016 10:21:28 -0800 (PST) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 186651E0418 for ; Thu, 3 Mar 2016 11:21:28 -0700 (MST) X-ASG-Debug-ID: 1457029287-09eadd2b1147a5a0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar5.cudamail.com with ESMTP id 8RubfPHMKU2wxqDD (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 03 Mar 2016 11:21:27 -0700 (MST) X-Barracuda-Envelope-From: ben@skyportsystems.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pa0-f41.google.com) (209.85.220.41) by mx3-pf3.cudamail.com with ESMTPS (RC4-SHA encrypted); 3 Mar 2016 19:11:18 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at _netblocks.google.com designates 209.85.220.41 as permitted sender) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.41 Received: by mail-pa0-f41.google.com with SMTP id fl4so19003426pad.0 for ; Thu, 03 Mar 2016 10:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skyportsystems.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=SqEGmL4ZzOr0dlk26Q7ck4EOsy0qTMIFpaqA1pPHHyI=; b=tWckcyG1CjOQEJB9gVhRNcOFpx4uulDgGcxMWA3blg5tKK4dQFa/T3r48F5uc2vjiv cfPLZ7VYCYETY8wWCaRO9uv2if1/NqhH9CBGLtKHFWVW6TnqQY9MFsctr7ut4Q8NNVke 9oW+JkEVSDF6VFnsP82xLtHMo0gUWTJ0pKk94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=SqEGmL4ZzOr0dlk26Q7ck4EOsy0qTMIFpaqA1pPHHyI=; b=fkrDxtS8GRpCrU2KZ9fRFwmhjygTopuA1iTvxS7X0QKPfIzscYU+zSK5xD4v9LHGZF iMYW2VV19BptrSu3n8XDNnzVhj3AeanaGq9f+elyu+LpxvG5cMfnmfuDHrwvT52TiET6 ww8+3GeWJ+Zc0h5NfZjvSYPs3TNcfldXQyr0HRGTiaNiOXqJdr0GA3Q0PJkjmXSenoNH Isw5YwEicT+vH1H1Wchvpq4iN9+cfcgnQ5nEie46W7jDS7SZkpmidIDzxZNWh1lIjcoY ZejF6IYpwlFTWbeLmsfwyMh5ZFH1Z3y4xP2cfmF5TkeRbQVEhcyyWr96kAOd7TEI7rom mbhQ== X-Gm-Message-State: AD7BkJIiwKeSsVQeGmmL5Yb0Sz8pq4twu3Ph0g4xtInJaUc1RrsNfr6OMQSD/BRkCWazfEJP X-Received: by 10.66.222.199 with SMTP id qo7mr5678928pac.38.1457029286001; Thu, 03 Mar 2016 10:21:26 -0800 (PST) Received: from Arrow.corp.skyportsystems.com (67-207-112-138.static.wiline.com. [67.207.112.138]) by smtp.gmail.com with ESMTPSA id g25sm62149841pfg.35.2016.03.03.10.21.25 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Mar 2016 10:21:25 -0800 (PST) X-CudaMail-Envelope-Sender: ben@skyportsystems.com X-Barracuda-Apparent-Source-IP: 67.207.112.138 From: ben@skyportsystems.com To: dev@openvswitch.org X-CudaMail-MID: CM-V3-302039398 X-CudaMail-DTE: 030316 X-CudaMail-Originating-IP: 209.85.220.41 Date: Thu, 3 Mar 2016 10:20:52 -0800 X-ASG-Orig-Subj: [##CM-V3-302039398##][PATCH v2 12/23] Break flow.h into private and public parts Message-Id: X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: References: In-Reply-To: References: X-GBUdb-Analysis: 0, 209.85.220.41, Ugly c=0.372106 p=-0.297297 Source Normal X-MessageSniffer-Rules: 0-0-0-28596-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1457029287 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, DKIM_SIGNED, NO_REAL_NAME, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.27542 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: Ben Warren Subject: [ovs-dev] [PATCH v2 12/23] Break flow.h into private and public parts X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" From: Ben Warren Public (struct definitions and some prototypes) go in include/openvswitch Signed-off-by: Ben Warren --- include/openvswitch/automake.mk | 1 + include/openvswitch/flow.h | 197 ++++++++++++++++++++++++++++++++++++++++ lib/flow.h | 175 +---------------------------------- 3 files changed, 200 insertions(+), 173 deletions(-) create mode 100644 include/openvswitch/flow.h diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk index fc183ff..184dd89 100644 --- a/include/openvswitch/automake.mk +++ b/include/openvswitch/automake.mk @@ -2,6 +2,7 @@ openvswitchincludedir = $(includedir)/openvswitch openvswitchinclude_HEADERS = \ include/openvswitch/compiler.h \ include/openvswitch/dynamic-string.h \ + include/openvswitch/flow.h \ include/openvswitch/geneve.h \ include/openvswitch/list.h \ include/openvswitch/ofpbuf.h \ diff --git a/include/openvswitch/flow.h b/include/openvswitch/flow.h new file mode 100644 index 0000000..11e124d --- /dev/null +++ b/include/openvswitch/flow.h @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OPENVSWITCH_FLOW_H +#define OPENVSWITCH_FLOW_H 1 + +#include "openvswitch/util.h" +#include "openflow/nicira-ext.h" +#include "openvswitch/packets.h" + +/* This sequence number should be incremented whenever anything involving flows + * or the wildcarding of flows changes. This will cause build assertion + * failures in places which likely need to be updated. */ +#define FLOW_WC_SEQ 35 + +/* Number of Open vSwitch extension 32-bit registers. */ +#define FLOW_N_REGS 8 +BUILD_ASSERT_DECL(FLOW_N_REGS <= NXM_NX_MAX_REGS); +BUILD_ASSERT_DECL(FLOW_N_REGS % 2 == 0); /* Even. */ + +/* Number of OpenFlow 1.5+ 64-bit registers. + * + * Each of these overlays a pair of Open vSwitch 32-bit registers, so there + * are half as many of them.*/ +#define FLOW_N_XREGS (FLOW_N_REGS / 2) + +/* Used for struct flow's dl_type member for frames that have no Ethernet + * type, that is, pure 802.2 frames. */ +#define FLOW_DL_TYPE_NONE 0x5ff + +/* Fragment bits, used for IPv4 and IPv6, always zero for non-IP flows. */ +#define FLOW_NW_FRAG_ANY (1 << 0) /* Set for any IP frag. */ +#define FLOW_NW_FRAG_LATER (1 << 1) /* Set for IP frag with nonzero offset. */ +#define FLOW_NW_FRAG_MASK (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER) + +BUILD_ASSERT_DECL(FLOW_NW_FRAG_ANY == NX_IP_FRAG_ANY); +BUILD_ASSERT_DECL(FLOW_NW_FRAG_LATER == NX_IP_FRAG_LATER); + +BUILD_ASSERT_DECL(FLOW_TNL_F_OAM == NX_TUN_FLAG_OAM); + +const char *flow_tun_flag_to_string(uint32_t flags); + +/* Maximum number of supported MPLS labels. */ +#define FLOW_MAX_MPLS_LABELS 3 + +/* + * A flow in the network. + * + * Must be initialized to all zeros to make any compiler-induced padding + * zeroed. Helps also in keeping unused fields (such as mutually exclusive + * IPv4 and IPv6 addresses) zeroed out. + * + * The meaning of 'in_port' is context-dependent. In most cases, it is a + * 16-bit OpenFlow 1.0 port number. In the software datapath interface (dpif) + * layer and its implementations (e.g. dpif-netlink, dpif-netdev), it is + * instead a 32-bit datapath port number. + * + * The fields are organized in four segments to facilitate staged lookup, where + * lower layer fields are first used to determine if the later fields need to + * be looked at. This enables better wildcarding for datapath flows. + * + * NOTE: Order of the fields is significant, any change in the order must be + * reflected in miniflow_extract()! + */ +struct flow { + /* Metadata */ + struct flow_tnl tunnel; /* Encapsulating tunnel parameters. */ + ovs_be64 metadata; /* OpenFlow Metadata. */ + uint32_t regs[FLOW_N_REGS]; /* Registers. */ + uint32_t skb_priority; /* Packet priority for QoS. */ + uint32_t pkt_mark; /* Packet mark. */ + uint32_t dp_hash; /* Datapath computed hash value. The exact + * computation is opaque to the user space. */ + union flow_in_port in_port; /* Input port.*/ + uint32_t recirc_id; /* Must be exact match. */ + uint16_t ct_state; /* Connection tracking state. */ + uint16_t ct_zone; /* Connection tracking zone. */ + uint32_t ct_mark; /* Connection mark.*/ + uint8_t pad1[4]; /* Pad to 64 bits. */ + ovs_u128 ct_label; /* Connection label. */ + uint32_t conj_id; /* Conjunction ID. */ + ofp_port_t actset_output; /* Output port in action set. */ + uint8_t pad2[2]; /* Pad to 64 bits. */ + + /* L2, Order the same as in the Ethernet header! (64-bit aligned) */ + struct eth_addr dl_dst; /* Ethernet destination address. */ + struct eth_addr dl_src; /* Ethernet source address. */ + ovs_be16 dl_type; /* Ethernet frame type. */ + ovs_be16 vlan_tci; /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */ + ovs_be32 mpls_lse[ROUND_UP(FLOW_MAX_MPLS_LABELS, 2)]; /* MPLS label stack + (with padding). */ + /* L3 (64-bit aligned) */ + ovs_be32 nw_src; /* IPv4 source address. */ + ovs_be32 nw_dst; /* IPv4 destination address. */ + struct in6_addr ipv6_src; /* IPv6 source address. */ + struct in6_addr ipv6_dst; /* IPv6 destination address. */ + ovs_be32 ipv6_label; /* IPv6 flow label. */ + uint8_t nw_frag; /* FLOW_FRAG_* flags. */ + uint8_t nw_tos; /* IP ToS (including DSCP and ECN). */ + uint8_t nw_ttl; /* IP TTL/Hop Limit. */ + uint8_t nw_proto; /* IP protocol or low 8 bits of ARP opcode. */ + struct in6_addr nd_target; /* IPv6 neighbor discovery (ND) target. */ + struct eth_addr arp_sha; /* ARP/ND source hardware address. */ + struct eth_addr arp_tha; /* ARP/ND target hardware address. */ + ovs_be16 tcp_flags; /* TCP flags. With L3 to avoid matching L4. */ + ovs_be16 pad3; /* Pad to 64 bits. */ + + /* L4 (64-bit aligned) */ + ovs_be16 tp_src; /* TCP/UDP/SCTP source port/ICMP type. */ + ovs_be16 tp_dst; /* TCP/UDP/SCTP destination port/ICMP code. */ + ovs_be32 igmp_group_ip4; /* IGMP group IPv4 address. + * Keep last for BUILD_ASSERT_DECL below. */ +}; +BUILD_ASSERT_DECL(sizeof(struct flow) % sizeof(uint64_t) == 0); +BUILD_ASSERT_DECL(sizeof(struct flow_tnl) % sizeof(uint64_t) == 0); + +#define FLOW_U64S (sizeof(struct flow) / sizeof(uint64_t)) + +/* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */ +BUILD_ASSERT_DECL(offsetof(struct flow, igmp_group_ip4) + sizeof(uint32_t) + == sizeof(struct flow_tnl) + 216 + && FLOW_WC_SEQ == 35); + +/* Incremental points at which flow classification may be performed in + * segments. + * This is located here since this is dependent on the structure of the + * struct flow defined above: + * Each offset must be on a distinct, successive U64 boundary strictly + * within the struct flow. */ +enum { + FLOW_SEGMENT_1_ENDS_AT = offsetof(struct flow, dl_dst), + FLOW_SEGMENT_2_ENDS_AT = offsetof(struct flow, nw_src), + FLOW_SEGMENT_3_ENDS_AT = offsetof(struct flow, tp_src), +}; +BUILD_ASSERT_DECL(FLOW_SEGMENT_1_ENDS_AT % sizeof(uint64_t) == 0); +BUILD_ASSERT_DECL(FLOW_SEGMENT_2_ENDS_AT % sizeof(uint64_t) == 0); +BUILD_ASSERT_DECL(FLOW_SEGMENT_3_ENDS_AT % sizeof(uint64_t) == 0); +BUILD_ASSERT_DECL( 0 < FLOW_SEGMENT_1_ENDS_AT); +BUILD_ASSERT_DECL(FLOW_SEGMENT_1_ENDS_AT < FLOW_SEGMENT_2_ENDS_AT); +BUILD_ASSERT_DECL(FLOW_SEGMENT_2_ENDS_AT < FLOW_SEGMENT_3_ENDS_AT); +BUILD_ASSERT_DECL(FLOW_SEGMENT_3_ENDS_AT < sizeof(struct flow)); + +/* Wildcards for a flow. + * + * A 1-bit in each bit in 'masks' indicates that the corresponding bit of + * the flow is significant (must match). A 0-bit indicates that the + * corresponding bit of the flow is wildcarded (need not match). */ +struct flow_wildcards { + struct flow masks; +}; + +#define WC_MASK_FIELD(WC, FIELD) \ + memset(&(WC)->masks.FIELD, 0xff, sizeof (WC)->masks.FIELD) +#define WC_MASK_FIELD_MASK(WC, FIELD, MASK) \ + ((WC)->masks.FIELD |= (MASK)) +#define WC_UNMASK_FIELD(WC, FIELD) \ + memset(&(WC)->masks.FIELD, 0, sizeof (WC)->masks.FIELD) + +void flow_wildcards_init_catchall(struct flow_wildcards *); + +void flow_wildcards_init_for_packet(struct flow_wildcards *, + const struct flow *); + +void flow_wildcards_clear_non_packet_fields(struct flow_wildcards *); + +bool flow_wildcards_is_catchall(const struct flow_wildcards *); + +void flow_wildcards_set_reg_mask(struct flow_wildcards *, + int idx, uint32_t mask); +void flow_wildcards_set_xreg_mask(struct flow_wildcards *, + int idx, uint64_t mask); + +void flow_wildcards_and(struct flow_wildcards *dst, + const struct flow_wildcards *src1, + const struct flow_wildcards *src2); +void flow_wildcards_or(struct flow_wildcards *dst, + const struct flow_wildcards *src1, + const struct flow_wildcards *src2); +bool flow_wildcards_has_extra(const struct flow_wildcards *, + const struct flow_wildcards *); +uint32_t flow_wildcards_hash(const struct flow_wildcards *, uint32_t basis); +bool flow_wildcards_equal(const struct flow_wildcards *, + const struct flow_wildcards *); + +#endif /* flow.h */ diff --git a/lib/flow.h b/lib/flow.h index dc7130d..0196ee7 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -23,8 +23,10 @@ #include #include "bitmap.h" #include "byte-order.h" +#include "openvswitch/compiler.h" #include "openflow/nicira-ext.h" #include "openflow/openflow.h" +#include "openvswitch/flow.h" #include "packets.h" #include "hash.h" #include "util.h" @@ -37,114 +39,6 @@ struct dp_packet; struct pkt_metadata; struct match; -/* This sequence number should be incremented whenever anything involving flows - * or the wildcarding of flows changes. This will cause build assertion - * failures in places which likely need to be updated. */ -#define FLOW_WC_SEQ 35 - -/* Number of Open vSwitch extension 32-bit registers. */ -#define FLOW_N_REGS 8 -BUILD_ASSERT_DECL(FLOW_N_REGS <= NXM_NX_MAX_REGS); -BUILD_ASSERT_DECL(FLOW_N_REGS % 2 == 0); /* Even. */ - -/* Number of OpenFlow 1.5+ 64-bit registers. - * - * Each of these overlays a pair of Open vSwitch 32-bit registers, so there - * are half as many of them.*/ -#define FLOW_N_XREGS (FLOW_N_REGS / 2) - -/* Used for struct flow's dl_type member for frames that have no Ethernet - * type, that is, pure 802.2 frames. */ -#define FLOW_DL_TYPE_NONE 0x5ff - -/* Fragment bits, used for IPv4 and IPv6, always zero for non-IP flows. */ -#define FLOW_NW_FRAG_ANY (1 << 0) /* Set for any IP frag. */ -#define FLOW_NW_FRAG_LATER (1 << 1) /* Set for IP frag with nonzero offset. */ -#define FLOW_NW_FRAG_MASK (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER) - -BUILD_ASSERT_DECL(FLOW_NW_FRAG_ANY == NX_IP_FRAG_ANY); -BUILD_ASSERT_DECL(FLOW_NW_FRAG_LATER == NX_IP_FRAG_LATER); - -BUILD_ASSERT_DECL(FLOW_TNL_F_OAM == NX_TUN_FLAG_OAM); - -const char *flow_tun_flag_to_string(uint32_t flags); - -/* Maximum number of supported MPLS labels. */ -#define FLOW_MAX_MPLS_LABELS 3 - -/* - * A flow in the network. - * - * Must be initialized to all zeros to make any compiler-induced padding - * zeroed. Helps also in keeping unused fields (such as mutually exclusive - * IPv4 and IPv6 addresses) zeroed out. - * - * The meaning of 'in_port' is context-dependent. In most cases, it is a - * 16-bit OpenFlow 1.0 port number. In the software datapath interface (dpif) - * layer and its implementations (e.g. dpif-netlink, dpif-netdev), it is - * instead a 32-bit datapath port number. - * - * The fields are organized in four segments to facilitate staged lookup, where - * lower layer fields are first used to determine if the later fields need to - * be looked at. This enables better wildcarding for datapath flows. - * - * NOTE: Order of the fields is significant, any change in the order must be - * reflected in miniflow_extract()! - */ -struct flow { - /* Metadata */ - struct flow_tnl tunnel; /* Encapsulating tunnel parameters. */ - ovs_be64 metadata; /* OpenFlow Metadata. */ - uint32_t regs[FLOW_N_REGS]; /* Registers. */ - uint32_t skb_priority; /* Packet priority for QoS. */ - uint32_t pkt_mark; /* Packet mark. */ - uint32_t dp_hash; /* Datapath computed hash value. The exact - * computation is opaque to the user space. */ - union flow_in_port in_port; /* Input port.*/ - uint32_t recirc_id; /* Must be exact match. */ - uint16_t ct_state; /* Connection tracking state. */ - uint16_t ct_zone; /* Connection tracking zone. */ - uint32_t ct_mark; /* Connection mark.*/ - uint8_t pad1[4]; /* Pad to 64 bits. */ - ovs_u128 ct_label; /* Connection label. */ - uint32_t conj_id; /* Conjunction ID. */ - ofp_port_t actset_output; /* Output port in action set. */ - uint8_t pad2[2]; /* Pad to 64 bits. */ - - /* L2, Order the same as in the Ethernet header! (64-bit aligned) */ - struct eth_addr dl_dst; /* Ethernet destination address. */ - struct eth_addr dl_src; /* Ethernet source address. */ - ovs_be16 dl_type; /* Ethernet frame type. */ - ovs_be16 vlan_tci; /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */ - ovs_be32 mpls_lse[ROUND_UP(FLOW_MAX_MPLS_LABELS, 2)]; /* MPLS label stack - (with padding). */ - /* L3 (64-bit aligned) */ - ovs_be32 nw_src; /* IPv4 source address. */ - ovs_be32 nw_dst; /* IPv4 destination address. */ - struct in6_addr ipv6_src; /* IPv6 source address. */ - struct in6_addr ipv6_dst; /* IPv6 destination address. */ - ovs_be32 ipv6_label; /* IPv6 flow label. */ - uint8_t nw_frag; /* FLOW_FRAG_* flags. */ - uint8_t nw_tos; /* IP ToS (including DSCP and ECN). */ - uint8_t nw_ttl; /* IP TTL/Hop Limit. */ - uint8_t nw_proto; /* IP protocol or low 8 bits of ARP opcode. */ - struct in6_addr nd_target; /* IPv6 neighbor discovery (ND) target. */ - struct eth_addr arp_sha; /* ARP/ND source hardware address. */ - struct eth_addr arp_tha; /* ARP/ND target hardware address. */ - ovs_be16 tcp_flags; /* TCP flags. With L3 to avoid matching L4. */ - ovs_be16 pad3; /* Pad to 64 bits. */ - - /* L4 (64-bit aligned) */ - ovs_be16 tp_src; /* TCP/UDP/SCTP source port/ICMP type. */ - ovs_be16 tp_dst; /* TCP/UDP/SCTP destination port/ICMP code. */ - ovs_be32 igmp_group_ip4; /* IGMP group IPv4 address. - * Keep last for BUILD_ASSERT_DECL below. */ -}; -BUILD_ASSERT_DECL(sizeof(struct flow) % sizeof(uint64_t) == 0); -BUILD_ASSERT_DECL(sizeof(struct flow_tnl) % sizeof(uint64_t) == 0); - -#define FLOW_U64S (sizeof(struct flow) / sizeof(uint64_t)) - /* Some flow fields are mutually exclusive or only appear within the flow * pipeline. IPv6 headers are bigger than IPv4 and MPLS, and IPv6 ND packets * are bigger than TCP,UDP and IGMP packets. */ @@ -156,30 +50,6 @@ BUILD_ASSERT_DECL(sizeof(struct flow_tnl) % sizeof(uint64_t) == 0); /* L4 */ - FLOW_U64_SIZE(tp_src) \ ) -/* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */ -BUILD_ASSERT_DECL(offsetof(struct flow, igmp_group_ip4) + sizeof(uint32_t) - == sizeof(struct flow_tnl) + 216 - && FLOW_WC_SEQ == 35); - -/* Incremental points at which flow classification may be performed in - * segments. - * This is located here since this is dependent on the structure of the - * struct flow defined above: - * Each offset must be on a distinct, successive U64 boundary strictly - * within the struct flow. */ -enum { - FLOW_SEGMENT_1_ENDS_AT = offsetof(struct flow, dl_dst), - FLOW_SEGMENT_2_ENDS_AT = offsetof(struct flow, nw_src), - FLOW_SEGMENT_3_ENDS_AT = offsetof(struct flow, tp_src), -}; -BUILD_ASSERT_DECL(FLOW_SEGMENT_1_ENDS_AT % sizeof(uint64_t) == 0); -BUILD_ASSERT_DECL(FLOW_SEGMENT_2_ENDS_AT % sizeof(uint64_t) == 0); -BUILD_ASSERT_DECL(FLOW_SEGMENT_3_ENDS_AT % sizeof(uint64_t) == 0); -BUILD_ASSERT_DECL( 0 < FLOW_SEGMENT_1_ENDS_AT); -BUILD_ASSERT_DECL(FLOW_SEGMENT_1_ENDS_AT < FLOW_SEGMENT_2_ENDS_AT); -BUILD_ASSERT_DECL(FLOW_SEGMENT_2_ENDS_AT < FLOW_SEGMENT_3_ENDS_AT); -BUILD_ASSERT_DECL(FLOW_SEGMENT_3_ENDS_AT < sizeof(struct flow)); - extern const uint8_t flow_segment_u64s[]; #define FLOW_U64_OFFSET(FIELD) \ @@ -314,47 +184,6 @@ hash_odp_port(odp_port_t odp_port) return hash_int(odp_to_u32(odp_port), 0); } -/* Wildcards for a flow. - * - * A 1-bit in each bit in 'masks' indicates that the corresponding bit of - * the flow is significant (must match). A 0-bit indicates that the - * corresponding bit of the flow is wildcarded (need not match). */ -struct flow_wildcards { - struct flow masks; -}; - -#define WC_MASK_FIELD(WC, FIELD) \ - memset(&(WC)->masks.FIELD, 0xff, sizeof (WC)->masks.FIELD) -#define WC_MASK_FIELD_MASK(WC, FIELD, MASK) \ - ((WC)->masks.FIELD |= (MASK)) -#define WC_UNMASK_FIELD(WC, FIELD) \ - memset(&(WC)->masks.FIELD, 0, sizeof (WC)->masks.FIELD) - -void flow_wildcards_init_catchall(struct flow_wildcards *); - -void flow_wildcards_init_for_packet(struct flow_wildcards *, - const struct flow *); - -void flow_wildcards_clear_non_packet_fields(struct flow_wildcards *); - -bool flow_wildcards_is_catchall(const struct flow_wildcards *); - -void flow_wildcards_set_reg_mask(struct flow_wildcards *, - int idx, uint32_t mask); -void flow_wildcards_set_xreg_mask(struct flow_wildcards *, - int idx, uint64_t mask); - -void flow_wildcards_and(struct flow_wildcards *dst, - const struct flow_wildcards *src1, - const struct flow_wildcards *src2); -void flow_wildcards_or(struct flow_wildcards *dst, - const struct flow_wildcards *src1, - const struct flow_wildcards *src2); -bool flow_wildcards_has_extra(const struct flow_wildcards *, - const struct flow_wildcards *); -uint32_t flow_wildcards_hash(const struct flow_wildcards *, uint32_t basis); -bool flow_wildcards_equal(const struct flow_wildcards *, - const struct flow_wildcards *); uint32_t flow_hash_5tuple(const struct flow *flow, uint32_t basis); uint32_t flow_hash_symmetric_l4(const struct flow *flow, uint32_t basis); uint32_t flow_hash_symmetric_l3l4(const struct flow *flow, uint32_t basis,