From patchwork Wed Sep 28 12:42:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 676189 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 3skcnP6CNQz9s2Q for ; Wed, 28 Sep 2016 22:43:21 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b=2J7zIgJO; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 74DEE105FF; Wed, 28 Sep 2016 05:43:14 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id C5C03103B8 for ; Wed, 28 Sep 2016 05:43:12 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 38C4742045E for ; Wed, 28 Sep 2016 06:43:11 -0600 (MDT) X-ASG-Debug-ID: 1475066590-09eadd519cc0370001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id FS3nC73RQQTq2EPA (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 28 Sep 2016 06:43:10 -0600 (MDT) X-Barracuda-Envelope-From: simon.horman@netronome.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-wm0-f52.google.com) (74.125.82.52) by mx1-pf1.cudamail.com with ESMTPS (AES128-SHA encrypted); 28 Sep 2016 12:43:09 -0000 Received-SPF: neutral (mx1-pf1.cudamail.com: 74.125.82.52 is neither permitted nor denied by SPF record at mktomail.com) X-Barracuda-Apparent-Source-IP: 74.125.82.52 X-Barracuda-RBL-IP: 74.125.82.52 Received: by mail-wm0-f52.google.com with SMTP id l132so69400198wmf.1 for ; Wed, 28 Sep 2016 05:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b+u0cfQFs+HWsjPcNopE/5c6d5aPc++ViT084wZkfqs=; b=2J7zIgJO//sjKKQJxVxlBuGSVkyhczAG3hQ08dY5wRinMLxUhmQX6ABgWetFIGtaG5 0rf0S5k2oV/y17xzabCjlmntrr61l41xJCI2AKM/+b98iGDdGZBe47zd1ueK2bc18P92 4Zgzl/4P8VArv+h3IG8IuG6299g5sGwNL1lcP8eFwhDK3TPxoYvtpuAUGVkRBTIRUHXc Ko/JTefUNUnRC5Yj2VoI0mnaPXAOBmhwO/LDffWL7njMSzjk5B3KQN8vE32WGFEfN3aK OwxcFuDPyREcFO7QIDk/TbBcWgpyua5PLyQVMrILuTpwsROCenU8SRYEl1GDMpS3qfyM NmIQ== 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; bh=b+u0cfQFs+HWsjPcNopE/5c6d5aPc++ViT084wZkfqs=; b=jew4M3OdtSPOeHeaSjfoQ0P5wqQiBrUOzRBMqHhENdtMREwGjOsUnLHQ/k5VZOrjXF ZOuXCmt9YMMBoOl4EQ34ZBbriCUy3/t1GeFg0iVNw9qm+l2uYrLmjLe/EYOyShF67AQ9 8+QqbnqOgVwMIvgbBpRO4cUfgImj4EOCVe1Mi4KvxFb0YMMnTRM9sIPPC982FTrhZB/D V1otF2bqFTtWs4tE5ffoSwJkzNAisQ9i8tBz0DVtanNuGHzz6vwH8ToRnrShOZZuyV+S 4o1jbvXGzTwBwjtC7wQA4mRecBTNcZz0DXaujFbhqBWIohJgVKldpGBGVLqZxSDOpeJG HE8g== X-Gm-Message-State: AA6/9RnO5o6Y3CUI17FodAPVIzEFdkAGtrV5qWKyBWWgV0MG6Jj3EYcGF6T24obq1O8hZZ6Q X-Received: by 10.28.25.71 with SMTP id 68mr7828381wmz.91.1475066588073; Wed, 28 Sep 2016 05:43:08 -0700 (PDT) Received: from penelope.horms.nl (52D9BC73.cm-11-1c.dynamic.ziggo.nl. [82.217.188.115]) by smtp.gmail.com with ESMTPSA id g17sm8661670wme.3.2016.09.28.05.43.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Sep 2016 05:43:06 -0700 (PDT) X-CudaMail-Envelope-Sender: simon.horman@netronome.com From: Simon Horman To: netdev@vger.kernel.org, dev@openvswitch.org X-CudaMail-MID: CM-E1-927012412 X-CudaMail-DTE: 092816 X-CudaMail-Originating-IP: 74.125.82.52 Date: Wed, 28 Sep 2016 14:42:51 +0200 X-ASG-Orig-Subj: [##CM-E1-927012412##][PATCH/RFC 01/12] sw_flow: make struct sw_flow_key available outside of net/openvswitch/ Message-Id: <1475066582-1971-2-git-send-email-simon.horman@netronome.com> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1475066582-1971-1-git-send-email-simon.horman@netronome.com> References: <1475066582-1971-1-git-send-email-simon.horman@netronome.com> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1475066590 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 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 global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC0_MISMATCH_TO, BSF_SC5_MJ1963, DKIM_SIGNED, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.33289 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 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: Simon Horman Subject: [ovs-dev] [PATCH/RFC 01/12] sw_flow: make struct sw_flow_key available outside of net/openvswitch/ 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" This is preparation for using struct sw_flow_key as a structure to describe Open vSwitch (-like) flows to hardware. This structure was chosen because it has the required fields. It should also be possible to use a different structure if desired. There are a few fields and structures used in struct sw_flow_key which have ovs in their name. Some consideration could be given to: * Renaming them to make them more generic * Providing a trimmed-down structure. * Using an alternate structure Signed-off-by: Simon Horman --- include/linux/sw_flow.h | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ net/openvswitch/flow.h | 75 +----------------------------------- 2 files changed, 101 insertions(+), 74 deletions(-) create mode 100644 include/linux/sw_flow.h diff --git a/include/linux/sw_flow.h b/include/linux/sw_flow.h new file mode 100644 index 000000000000..17e25418dc56 --- /dev/null +++ b/include/linux/sw_flow.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2007-2011 Nicira Networks. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA + */ + +#ifndef _LINUX_SW_FLOW_H +#define _LINUX_SW_FLOW_H 1 + +#include +#include + +struct vlan_head { + __be16 tpid; /* Vlan type. Generally 802.1q or 802.1ad.*/ + __be16 tci; /* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */ +}; + +struct sw_flow_key { + u8 tun_opts[IP_TUNNEL_OPTS_MAX]; + u8 tun_opts_len; + struct ip_tunnel_key tun_key; /* Encapsulating tunnel key. */ + struct { + u32 priority; /* Packet QoS priority. */ + u32 skb_mark; /* SKB mark. */ + u16 in_port; /* Input switch port (or DP_MAX_PORTS). */ + } __packed phy; /* Safe when right after 'tun_key'. */ + u8 tun_proto; /* Protocol of encapsulating tunnel. */ + u32 ovs_flow_hash; /* Datapath computed hash value. */ + u32 recirc_id; /* Recirculation ID. */ + struct { + u8 src[ETH_ALEN]; /* Ethernet source address. */ + u8 dst[ETH_ALEN]; /* Ethernet destination address. */ + struct vlan_head vlan; + struct vlan_head cvlan; + __be16 type; /* Ethernet frame type. */ + } eth; + union { + struct { + __be32 top_lse; /* top label stack entry */ + } mpls; + struct { + u8 proto; /* IP protocol or lower 8 bits of ARP opcode. */ + u8 tos; /* IP ToS. */ + u8 ttl; /* IP TTL/hop limit. */ + u8 frag; /* One of OVS_FRAG_TYPE_*. */ + } ip; + }; + struct { + __be16 src; /* TCP/UDP/SCTP source port. */ + __be16 dst; /* TCP/UDP/SCTP destination port. */ + __be16 flags; /* TCP flags. */ + } tp; + union { + struct { + struct { + __be32 src; /* IP source address. */ + __be32 dst; /* IP destination address. */ + } addr; + struct { + u8 sha[ETH_ALEN]; /* ARP source hardware address. */ + u8 tha[ETH_ALEN]; /* ARP target hardware address. */ + } arp; + } ipv4; + struct { + struct { + struct in6_addr src; /* IPv6 source address. */ + struct in6_addr dst; /* IPv6 destination address. */ + } addr; + __be32 label; /* IPv6 flow label. */ + struct { + struct in6_addr target; /* ND target address. */ + u8 sll[ETH_ALEN]; /* ND source link layer address. */ + u8 tll[ETH_ALEN]; /* ND target link layer address. */ + } nd; + } ipv6; + }; + struct { + /* Connection tracking fields. */ + u16 zone; + u32 mark; + u8 state; + struct ovs_key_ct_labels labels; + } ct; + +} __aligned(BITS_PER_LONG/8); /* Ensure that we can do comparisons as longs. */ + + +#endif /* _LINUX_SW_FLOW_H */ diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index ae783f5c6695..0c70c3532469 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -50,84 +51,10 @@ struct ovs_tunnel_info { struct metadata_dst *tun_dst; }; -struct vlan_head { - __be16 tpid; /* Vlan type. Generally 802.1q or 802.1ad.*/ - __be16 tci; /* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */ -}; - #define OVS_SW_FLOW_KEY_METADATA_SIZE \ (offsetof(struct sw_flow_key, recirc_id) + \ FIELD_SIZEOF(struct sw_flow_key, recirc_id)) -struct sw_flow_key { - u8 tun_opts[IP_TUNNEL_OPTS_MAX]; - u8 tun_opts_len; - struct ip_tunnel_key tun_key; /* Encapsulating tunnel key. */ - struct { - u32 priority; /* Packet QoS priority. */ - u32 skb_mark; /* SKB mark. */ - u16 in_port; /* Input switch port (or DP_MAX_PORTS). */ - } __packed phy; /* Safe when right after 'tun_key'. */ - u8 tun_proto; /* Protocol of encapsulating tunnel. */ - u32 ovs_flow_hash; /* Datapath computed hash value. */ - u32 recirc_id; /* Recirculation ID. */ - struct { - u8 src[ETH_ALEN]; /* Ethernet source address. */ - u8 dst[ETH_ALEN]; /* Ethernet destination address. */ - struct vlan_head vlan; - struct vlan_head cvlan; - __be16 type; /* Ethernet frame type. */ - } eth; - union { - struct { - __be32 top_lse; /* top label stack entry */ - } mpls; - struct { - u8 proto; /* IP protocol or lower 8 bits of ARP opcode. */ - u8 tos; /* IP ToS. */ - u8 ttl; /* IP TTL/hop limit. */ - u8 frag; /* One of OVS_FRAG_TYPE_*. */ - } ip; - }; - struct { - __be16 src; /* TCP/UDP/SCTP source port. */ - __be16 dst; /* TCP/UDP/SCTP destination port. */ - __be16 flags; /* TCP flags. */ - } tp; - union { - struct { - struct { - __be32 src; /* IP source address. */ - __be32 dst; /* IP destination address. */ - } addr; - struct { - u8 sha[ETH_ALEN]; /* ARP source hardware address. */ - u8 tha[ETH_ALEN]; /* ARP target hardware address. */ - } arp; - } ipv4; - struct { - struct { - struct in6_addr src; /* IPv6 source address. */ - struct in6_addr dst; /* IPv6 destination address. */ - } addr; - __be32 label; /* IPv6 flow label. */ - struct { - struct in6_addr target; /* ND target address. */ - u8 sll[ETH_ALEN]; /* ND source link layer address. */ - u8 tll[ETH_ALEN]; /* ND target link layer address. */ - } nd; - } ipv6; - }; - struct { - /* Connection tracking fields. */ - u16 zone; - u32 mark; - u8 state; - struct ovs_key_ct_labels labels; - } ct; - -} __aligned(BITS_PER_LONG/8); /* Ensure that we can do comparisons as longs. */ - struct sw_flow_key_range { unsigned short int start; unsigned short int end;