]> git.proxmox.com Git - mirror_ovs.git/blob - ofproto/ofproto-dpif-xlate-cache.h
ofproto-dpif: Fix for recirc issue with mpls traffic with dp_hash
[mirror_ovs.git] / ofproto / ofproto-dpif-xlate-cache.h
1 /* Copyright (c) 2016 Nicira, Inc.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License. */
14
15 #ifndef OFPROTO_DPIF_XLATE_CACHE_H
16 #define OFPROTO_DPIF_XLATE_CACHE_H 1
17
18 #include <net/if.h>
19 #include <sys/socket.h>
20 #include <sys/types.h>
21 #include <netinet/in.h>
22
23 #include "openvswitch/types.h"
24 #include "dp-packet.h"
25 #include "odp-util.h"
26 #include "ofproto/ofproto-dpif-mirror.h"
27 #include "openvswitch/ofpbuf.h"
28
29 struct bfd;
30 struct bond;
31 struct dpif_flow_stats;
32 struct flow;
33 struct group_dpif;
34 struct mbridge;
35 struct netdev;
36 struct netflow;
37 struct ofpbuf;
38 struct ofproto_dpif;
39 struct ofputil_bucket;
40 struct ofputil_flow_mod;
41 struct rule_dpif;
42
43 enum xc_type {
44 XC_TABLE,
45 XC_RULE,
46 XC_BOND,
47 XC_NETDEV,
48 XC_NETFLOW,
49 XC_MIRROR,
50 XC_LEARN, /* Calls back to ofproto. */
51 XC_NORMAL,
52 XC_FIN_TIMEOUT, /* Calls back to ofproto. */
53 XC_GROUP,
54 XC_TNL_NEIGH,
55 XC_TUNNEL_HEADER,
56 };
57
58 /* xlate_cache entries hold enough information to perform the side effects of
59 * xlate_actions() for a rule, without needing to perform rule translation
60 * from scratch. The primary usage of these is to submit statistics to objects
61 * that a flow relates to, although they may be used for other effects as well
62 * (for instance, refreshing hard timeouts for learned flows).
63 *
64 * An explicit reference is taken to all pointers other than the ones for
65 * struct ofproto_dpif. ofproto_dpif pointers are explicitly protected by
66 * destroying all xlate caches before the ofproto is destroyed. */
67 struct xc_entry {
68 enum xc_type type;
69 union {
70 struct {
71 struct ofproto_dpif *ofproto;
72 uint8_t id;
73 bool match; /* or miss. */
74 } table;
75 struct rule_dpif *rule;
76 struct {
77 struct netdev *tx;
78 struct netdev *rx;
79 struct bfd *bfd;
80 } dev;
81 struct {
82 struct netflow *netflow;
83 struct flow *flow;
84 ofp_port_t iface;
85 } nf;
86 struct {
87 struct mbridge *mbridge;
88 mirror_mask_t mirrors;
89 } mirror;
90 struct {
91 struct bond *bond;
92 struct flow *flow;
93 uint16_t vid;
94 } bond;
95 struct {
96 struct ofproto_flow_mod *ofm;
97 unsigned limit;
98 } learn;
99 struct {
100 struct ofproto_dpif *ofproto;
101 ofp_port_t in_port;
102 struct eth_addr dl_src;
103 int vlan;
104 bool is_gratuitous_arp;
105 } normal;
106 struct {
107 struct rule_dpif *rule;
108 uint16_t idle;
109 uint16_t hard;
110 } fin;
111 struct {
112 struct group_dpif *group;
113 struct ofputil_bucket *bucket;
114 } group;
115 struct {
116 char br_name[IFNAMSIZ];
117 struct in6_addr d_ipv6;
118 } tnl_neigh_cache;
119 struct {
120 struct ofproto_dpif *ofproto;
121 struct ofproto_async_msg *am;
122 } controller;
123 struct {
124 enum {
125 ADD,
126 REMOVE,
127 } operation;
128 uint16_t hdr_size;
129 } tunnel_hdr;
130 };
131 };
132
133 #define XC_ENTRY_FOR_EACH(ENTRY, ENTRIES) \
134 for (ENTRY = ofpbuf_try_pull(ENTRIES, sizeof *ENTRY); \
135 ENTRY; \
136 ENTRY = ofpbuf_try_pull(ENTRIES, sizeof *ENTRY))
137
138 struct xlate_cache {
139 struct ofpbuf entries;
140 };
141
142 void xlate_cache_init(struct xlate_cache *);
143 struct xlate_cache *xlate_cache_new(void);
144 struct xc_entry *xlate_cache_add_entry(struct xlate_cache *, enum xc_type);
145 void xlate_push_stats_entry(struct xc_entry *, struct dpif_flow_stats *);
146 void xlate_push_stats(struct xlate_cache *, struct dpif_flow_stats *);
147 void xlate_cache_clear_entry(struct xc_entry *);
148 void xlate_cache_clear(struct xlate_cache *);
149 void xlate_cache_uninit(struct xlate_cache *);
150 void xlate_cache_delete(struct xlate_cache *);
151 void xlate_cache_steal_entries(struct xlate_cache *, struct xlate_cache *);
152
153 #endif /* ofproto-dpif-xlate-cache.h */