diff mbox

[ovs-dev,07/11] compat: net: store port/representator id in metadata_dst.

Message ID 20170721234614.2800-8-joe@ovn.org
State Accepted
Headers show

Commit Message

Joe Stringer July 21, 2017, 11:46 p.m. UTC
Upstream commit:
    commit 3fcece12bc1b6dcdf0986f2cd9e8f63b1f9b6aa0
    Author: Jakub Kicinski <jakub.kicinski@netronome.com>
    Date: Fri Jun 23 22:11:58 2017 +0200

    net: store port/representator id in metadata_dst

    Switches and modern SR-IOV enabled NICs may multiplex traffic from Port
    representators and control messages over single set of hardware queues.
    Control messages and muxed traffic may need ordered delivery.

    Those requirements make it hard to comfortably use TC infrastructure today
    unless we have a way of attaching metadata to skbs at the upper device.
    Because single set of queues is used for many netdevs stopping TC/sched
    queues of all of them reliably is impossible and lower device has to
    retreat to returning NETDEV_TX_BUSY and usually has to take extra locks on
    the fastpath.

    This patch attempts to enable port/representative devs to attach metadata
    to skbs which carry port id.  This way representatives can be queueless and
    all queuing can be performed at the lower netdev in the usual way.

    Traffic arriving on the port/representative interfaces will be have
    metadata attached and will subsequently be queued to the lower device for
    transmission.  The lower device should recognize the metadata and translate
    it to HW specific format which is most likely either a special header
    inserted before the network headers or descriptor/metadata fields.

    Metadata is associated with the lower device by storing the netdev pointer
    along with port id so that if TC decides to redirect or mirror the new
    netdev will not try to interpret it.

    This is mostly for SR-IOV devices since switches don't have lower netdevs
    today.

    Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
    Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
    Signed-off-by: Simon Horman <horms@verge.net.au>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Upstream: 3fcece12bc1b ("net: store port/representator id in metadata_dst")
Signed-off-by: Joe Stringer <joe@ovn.org>
---
 acinclude.m4                                     |  3 +++
 datapath/flow_netlink.c                          |  4 +++-
 datapath/linux/compat/include/net/dst_metadata.h | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/acinclude.m4 b/acinclude.m4
index d72e13cd6c73..fce052477001 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -719,6 +719,9 @@  AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [skb_vlan_tagged])
   OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [eth_type_vlan])
 
+  OVS_FIND_PARAM_IFELSE([$KSRC/include/net/dst_metadata.h],
+                        [metadata_dst_alloc], [metadata_type])
+
   OVS_GREP_IFELSE([$KSRC/include/linux/u64_stats_sync.h], [u64_stats_fetch_begin_irq])
 
   OVS_GREP_IFELSE([$KSRC/include/net/vxlan.h], [struct vxlan_metadata],
diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c
index 07ab8e9a40b6..9b4861250b5a 100644
--- a/datapath/flow_netlink.c
+++ b/datapath/flow_netlink.c
@@ -2203,7 +2203,9 @@  static int validate_and_copy_set_tun(const struct nlattr *attr,
 	if (start < 0)
 		return start;
 
-	tun_dst = metadata_dst_alloc(key.tun_opts_len, GFP_KERNEL);
+	tun_dst = metadata_dst_alloc(key.tun_opts_len, METADATA_IP_TUNNEL,
+				     GFP_KERNEL);
+
 	if (!tun_dst)
 		return -ENOMEM;
 
diff --git a/datapath/linux/compat/include/net/dst_metadata.h b/datapath/linux/compat/include/net/dst_metadata.h
index 279b7144bd17..e401eb400925 100644
--- a/datapath/linux/compat/include/net/dst_metadata.h
+++ b/datapath/linux/compat/include/net/dst_metadata.h
@@ -103,4 +103,19 @@  static inline void ovs_ipv6_tun_rx_dst(struct metadata_dst *md_dst,
 
 void ovs_ip_tunnel_rcv(struct net_device *dev, struct sk_buff *skb,
 		      struct metadata_dst *tun_dst);
+
+#ifndef HAVE_METADATA_DST_ALLOC_WITH_METADATA_TYPE
+enum metadata_type {
+	METADATA_IP_TUNNEL,
+	METADATA_HW_PORT_MUX,
+};
+
+static inline struct metadata_dst *
+rpl_metadata_dst_alloc(u8 optslen, enum metadata_type type, gfp_t flags)
+{
+	return metadata_dst_alloc(optslen, flags);
+}
+#define metadata_dst_alloc rpl_metadata_dst_alloc
+#endif
+
 #endif /* __NET_DST_METADATA_WRAPPER_H */