Commit a73d65b5 authored by David S. Miller's avatar David S. Miller

Merge branch 'nfp-whitespace-sync-and-flower-TCP-flags'

Jakub Kicinski says:

====================
nfp: whitespace sync and flower TCP flags

Whitespace cleanup from Michael and flower offload support for matching
on TCP flags from Pieter.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4a886482 ffa61202
...@@ -61,6 +61,13 @@ ...@@ -61,6 +61,13 @@
#define NFP_FLOWER_MASK_MPLS_BOS BIT(8) #define NFP_FLOWER_MASK_MPLS_BOS BIT(8)
#define NFP_FLOWER_MASK_MPLS_Q BIT(0) #define NFP_FLOWER_MASK_MPLS_Q BIT(0)
/* Compressed HW representation of TCP Flags */
#define NFP_FL_TCP_FLAG_URG BIT(4)
#define NFP_FL_TCP_FLAG_PSH BIT(3)
#define NFP_FL_TCP_FLAG_RST BIT(2)
#define NFP_FL_TCP_FLAG_SYN BIT(1)
#define NFP_FL_TCP_FLAG_FIN BIT(0)
#define NFP_FL_SC_ACT_DROP 0x80000000 #define NFP_FL_SC_ACT_DROP 0x80000000
#define NFP_FL_SC_ACT_USER 0x7D000000 #define NFP_FL_SC_ACT_USER 0x7D000000
#define NFP_FL_SC_ACT_POPV 0x6A000000 #define NFP_FL_SC_ACT_POPV 0x6A000000
...@@ -257,7 +264,7 @@ struct nfp_flower_tp_ports { ...@@ -257,7 +264,7 @@ struct nfp_flower_tp_ports {
* 3 2 1 * 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | DSCP |ECN| protocol | reserved | * | DSCP |ECN| protocol | ttl | flags |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ipv4_addr_src | * | ipv4_addr_src |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...@@ -268,7 +275,7 @@ struct nfp_flower_ipv4 { ...@@ -268,7 +275,7 @@ struct nfp_flower_ipv4 {
u8 tos; u8 tos;
u8 proto; u8 proto;
u8 ttl; u8 ttl;
u8 reserved; u8 flags;
__be32 ipv4_src; __be32 ipv4_src;
__be32 ipv4_dst; __be32 ipv4_dst;
}; };
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/time64.h> #include <linux/time64.h>
#include <linux/types.h> #include <linux/types.h>
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
#include <net/tcp.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
struct net_device; struct net_device;
......
...@@ -181,6 +181,26 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame, ...@@ -181,6 +181,26 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame,
frame->tos = flow_ip->tos; frame->tos = flow_ip->tos;
frame->ttl = flow_ip->ttl; frame->ttl = flow_ip->ttl;
} }
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_TCP)) {
struct flow_dissector_key_tcp *tcp;
u32 tcp_flags;
tcp = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_TCP, target);
tcp_flags = be16_to_cpu(tcp->flags);
if (tcp_flags & TCPHDR_FIN)
frame->flags |= NFP_FL_TCP_FLAG_FIN;
if (tcp_flags & TCPHDR_SYN)
frame->flags |= NFP_FL_TCP_FLAG_SYN;
if (tcp_flags & TCPHDR_RST)
frame->flags |= NFP_FL_TCP_FLAG_RST;
if (tcp_flags & TCPHDR_PSH)
frame->flags |= NFP_FL_TCP_FLAG_PSH;
if (tcp_flags & TCPHDR_URG)
frame->flags |= NFP_FL_TCP_FLAG_URG;
}
} }
static void static void
......
...@@ -44,11 +44,16 @@ ...@@ -44,11 +44,16 @@
#include "../nfp_net.h" #include "../nfp_net.h"
#include "../nfp_port.h" #include "../nfp_port.h"
#define NFP_FLOWER_SUPPORTED_TCPFLAGS \
(TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST | \
TCPHDR_PSH | TCPHDR_URG)
#define NFP_FLOWER_WHITELIST_DISSECTOR \ #define NFP_FLOWER_WHITELIST_DISSECTOR \
(BIT(FLOW_DISSECTOR_KEY_CONTROL) | \ (BIT(FLOW_DISSECTOR_KEY_CONTROL) | \
BIT(FLOW_DISSECTOR_KEY_BASIC) | \ BIT(FLOW_DISSECTOR_KEY_BASIC) | \
BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | \ BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | \
BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | \ BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | \
BIT(FLOW_DISSECTOR_KEY_TCP) | \
BIT(FLOW_DISSECTOR_KEY_PORTS) | \ BIT(FLOW_DISSECTOR_KEY_PORTS) | \
BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) | \ BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) | \
BIT(FLOW_DISSECTOR_KEY_VLAN) | \ BIT(FLOW_DISSECTOR_KEY_VLAN) | \
...@@ -288,6 +293,35 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, ...@@ -288,6 +293,35 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,
} }
} }
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_TCP)) {
struct flow_dissector_key_tcp *tcp;
u32 tcp_flags;
tcp = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_TCP,
flow->key);
tcp_flags = be16_to_cpu(tcp->flags);
if (tcp_flags & ~NFP_FLOWER_SUPPORTED_TCPFLAGS)
return -EOPNOTSUPP;
/* We only support PSH and URG flags when either
* FIN, SYN or RST is present as well.
*/
if ((tcp_flags & (TCPHDR_PSH | TCPHDR_URG)) &&
!(tcp_flags & (TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST)))
return -EOPNOTSUPP;
/* We need to store TCP flags in the IPv4 key space, thus
* we need to ensure we include a IPv4 key layer if we have
* not done so already.
*/
if (!(key_layer & NFP_FLOWER_LAYER_IPV4)) {
key_layer |= NFP_FLOWER_LAYER_IPV4;
key_size += sizeof(struct nfp_flower_ipv4);
}
}
ret_key_ls->key_layer = key_layer; ret_key_ls->key_layer = key_layer;
ret_key_ls->key_layer_two = key_layer_two; ret_key_ls->key_layer_two = key_layer_two;
ret_key_ls->key_size = key_size; ret_key_ls->key_size = key_size;
......
/* /*
* Copyright (C) 2015-2017 Netronome Systems, Inc. * Copyright (C) 2015-2018 Netronome Systems, Inc.
* *
* This software is dual licensed under the GNU General License Version 2, * This software is dual licensed under the GNU General License Version 2,
* June 1991 as shown in the file COPYING in the top-level directory of this * June 1991 as shown in the file COPYING in the top-level directory of this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment