| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2007-2017 Nicira, Inc. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or |
|---|
| 5 | | - * modify it under the terms of version 2 of the GNU General Public |
|---|
| 6 | | - * License as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 9 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 11 | | - * General Public License for more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License |
|---|
| 14 | | - * along with this program; if not, write to the Free Software |
|---|
| 15 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|---|
| 16 | | - * 02110-1301, USA |
|---|
| 17 | 4 | */ |
|---|
| 18 | 5 | |
|---|
| 19 | 6 | #ifndef FLOW_H |
|---|
| .. | .. |
|---|
| 30 | 17 | #include <linux/in6.h> |
|---|
| 31 | 18 | #include <linux/jiffies.h> |
|---|
| 32 | 19 | #include <linux/time.h> |
|---|
| 33 | | -#include <linux/flex_array.h> |
|---|
| 34 | 20 | #include <linux/cpumask.h> |
|---|
| 35 | 21 | #include <net/inet_ecn.h> |
|---|
| 36 | 22 | #include <net/ip_tunnels.h> |
|---|
| .. | .. |
|---|
| 44 | 30 | MAC_PROTO_ETHERNET, |
|---|
| 45 | 31 | }; |
|---|
| 46 | 32 | #define SW_FLOW_KEY_INVALID 0x80 |
|---|
| 33 | +#define MPLS_LABEL_DEPTH 3 |
|---|
| 47 | 34 | |
|---|
| 48 | 35 | /* Store options at the end of the array if they are less than the |
|---|
| 49 | 36 | * maximum size. This allows us to get the benefits of variable length |
|---|
| 50 | 37 | * matching for small options. |
|---|
| 51 | 38 | */ |
|---|
| 52 | 39 | #define TUN_METADATA_OFFSET(opt_len) \ |
|---|
| 53 | | - (FIELD_SIZEOF(struct sw_flow_key, tun_opts) - opt_len) |
|---|
| 40 | + (sizeof_field(struct sw_flow_key, tun_opts) - opt_len) |
|---|
| 54 | 41 | #define TUN_METADATA_OPTS(flow_key, opt_len) \ |
|---|
| 55 | 42 | ((void *)((flow_key)->tun_opts + TUN_METADATA_OFFSET(opt_len))) |
|---|
| 56 | 43 | |
|---|
| .. | .. |
|---|
| 60 | 47 | |
|---|
| 61 | 48 | struct vlan_head { |
|---|
| 62 | 49 | __be16 tpid; /* Vlan type. Generally 802.1q or 802.1ad.*/ |
|---|
| 63 | | - __be16 tci; /* 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */ |
|---|
| 50 | + __be16 tci; /* 0 if no VLAN, VLAN_CFI_MASK set otherwise. */ |
|---|
| 64 | 51 | }; |
|---|
| 65 | 52 | |
|---|
| 66 | 53 | #define OVS_SW_FLOW_KEY_METADATA_SIZE \ |
|---|
| 67 | 54 | (offsetof(struct sw_flow_key, recirc_id) + \ |
|---|
| 68 | | - FIELD_SIZEOF(struct sw_flow_key, recirc_id)) |
|---|
| 55 | + sizeof_field(struct sw_flow_key, recirc_id)) |
|---|
| 69 | 56 | |
|---|
| 70 | 57 | struct ovs_key_nsh { |
|---|
| 71 | 58 | struct ovs_nsh_key_base base; |
|---|
| .. | .. |
|---|
| 98 | 85 | * protocol. |
|---|
| 99 | 86 | */ |
|---|
| 100 | 87 | union { |
|---|
| 101 | | - struct { |
|---|
| 102 | | - __be32 top_lse; /* top label stack entry */ |
|---|
| 103 | | - } mpls; |
|---|
| 104 | 88 | struct { |
|---|
| 105 | 89 | u8 proto; /* IP protocol or lower 8 bits of ARP opcode. */ |
|---|
| 106 | 90 | u8 tos; /* IP ToS. */ |
|---|
| .. | .. |
|---|
| 149 | 133 | } nd; |
|---|
| 150 | 134 | }; |
|---|
| 151 | 135 | } ipv6; |
|---|
| 136 | + struct { |
|---|
| 137 | + u32 num_labels_mask; /* labels present bitmap of effective length MPLS_LABEL_DEPTH */ |
|---|
| 138 | + __be32 lse[MPLS_LABEL_DEPTH]; /* label stack entry */ |
|---|
| 139 | + } mpls; |
|---|
| 140 | + |
|---|
| 152 | 141 | struct ovs_key_nsh nsh; /* network service header */ |
|---|
| 153 | 142 | }; |
|---|
| 154 | 143 | struct { |
|---|
| .. | .. |
|---|
| 180 | 169 | struct sw_flow_mask { |
|---|
| 181 | 170 | int ref_count; |
|---|
| 182 | 171 | struct rcu_head rcu; |
|---|
| 183 | | - struct list_head list; |
|---|
| 184 | 172 | struct sw_flow_key_range range; |
|---|
| 185 | 173 | struct sw_flow_key key; |
|---|
| 186 | 174 | }; |
|---|
| .. | .. |
|---|
| 208 | 196 | struct nlattr actions[]; |
|---|
| 209 | 197 | }; |
|---|
| 210 | 198 | |
|---|
| 211 | | -struct flow_stats { |
|---|
| 199 | +struct sw_flow_stats { |
|---|
| 212 | 200 | u64 packet_count; /* Number of packets matched. */ |
|---|
| 213 | 201 | u64 byte_count; /* Number of bytes matched. */ |
|---|
| 214 | 202 | unsigned long used; /* Last used time (in jiffies). */ |
|---|
| .. | .. |
|---|
| 230 | 218 | struct cpumask cpu_used_mask; |
|---|
| 231 | 219 | struct sw_flow_mask *mask; |
|---|
| 232 | 220 | struct sw_flow_actions __rcu *sf_acts; |
|---|
| 233 | | - struct flow_stats __rcu *stats[]; /* One for each CPU. First one |
|---|
| 221 | + struct sw_flow_stats __rcu *stats[]; /* One for each CPU. First one |
|---|
| 234 | 222 | * is allocated at flow creation time, |
|---|
| 235 | 223 | * the rest are allocated on demand |
|---|
| 236 | 224 | * while holding the 'stats[0].lock'. |
|---|
| .. | .. |
|---|
| 284 | 272 | u64 ovs_flow_used_time(unsigned long flow_jiffies); |
|---|
| 285 | 273 | |
|---|
| 286 | 274 | int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key); |
|---|
| 275 | +int ovs_flow_key_update_l3l4(struct sk_buff *skb, struct sw_flow_key *key); |
|---|
| 287 | 276 | int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, |
|---|
| 288 | 277 | struct sk_buff *skb, |
|---|
| 289 | 278 | struct sw_flow_key *key); |
|---|