netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org
Cc: Simon Horman <simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
Subject: [PATCH/RFC 01/12] sw_flow: make struct sw_flow_key available outside of net/openvswitch/
Date: Wed, 28 Sep 2016 14:42:51 +0200	[thread overview]
Message-ID: <1475066582-1971-2-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1475066582-1971-1-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>

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 <simon.horman@netronome.com>
---
 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 <net/ip_tunnels.h>
+#include <uapi/linux/openvswitch.h>
+
+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 <linux/jiffies.h>
 #include <linux/time.h>
 #include <linux/flex_array.h>
+#include <linux/sw_flow.h>
 #include <net/inet_ecn.h>
 #include <net/ip_tunnels.h>
 #include <net/dst_metadata.h>
@@ -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;
-- 
2.7.0.rc3.207.g0ac5344

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

  parent reply	other threads:[~2016-09-28 12:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 12:42 [PATCH/RFC 00/12] Programming Open vSwitch (-like) flows into hardware using SwitchDev Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 02/12] switchdev: Add Open vSwitch (-like) flow object support Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 03/12] switchdev: Add support for getting port object details Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 04/12] rocker: Add Open vSwitch (-like) flow support Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 05/12] rocker: Support Open vSwitch (-like) flow stats Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 06/12] rocker: Add helper to check ports belong to the same rocker switch Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 07/12] rocker: switchdev Add Open vSwitch (-like) flow support to OF-DPA world Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 08/12] rocker: Support Open vSwitch (-like) flow stats in " Simon Horman
2016-09-28 12:42 ` [PATCH/RFC 09/12] openvswitch: Add key_attrs to struct sw_flow_match Simon Horman
2016-09-28 12:43 ` [PATCH/RFC 10/12] openvswitch: make get_dp_rcu() available outside datapath.c Simon Horman
2016-09-28 12:43 ` [PATCH/RFC 11/12] openvswitch: Support programming of flows into hardware Simon Horman
2016-09-28 12:43 ` [PATCH/RFC 12/12] hack: rocker: no ip frag match Simon Horman
     [not found] ` <1475066582-1971-1-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-09-28 12:42   ` Simon Horman [this message]
2016-09-28 13:54   ` [PATCH/RFC 00/12] Programming Open vSwitch (-like) flows into hardware using SwitchDev Or Gerlitz
2016-09-29  8:09     ` Simon Horman
     [not found]       ` <20160929080904.GA24113-ucRxlxcrRFEsysjaEhV7d2ey4e3TpSOZIxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-09-30 22:12         ` pravin shelar
     [not found]           ` <CAOrHB_CG6wJ4t1zTaFZ8Uq5Ltoiqx+ctk-ZhqZ0sy3tF5-YXVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-01  9:05             ` Or Gerlitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475066582-1971-2-git-send-email-simon.horman@netronome.com \
    --to=simon.horman-wfxrvt7yatfl57midrcfdg@public.gmane.org \
    --cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).