]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/ofproto-dpif-xlate-cache.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / ofproto / ofproto-dpif-xlate-cache.h
CommitLineData
901a517e
JR
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>
b2befd5b 20#include <sys/types.h>
901a517e
JR
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
29struct bfd;
30struct bond;
31struct dpif_flow_stats;
32struct flow;
33struct group_dpif;
34struct mbridge;
35struct netdev;
36struct netflow;
37struct ofpbuf;
38struct ofproto_dpif;
39struct ofputil_bucket;
40struct ofputil_flow_mod;
41struct rule_dpif;
42
43enum xc_type {
a027899e 44 XC_TABLE,
901a517e
JR
45 XC_RULE,
46 XC_BOND,
47 XC_NETDEV,
48 XC_NETFLOW,
49 XC_MIRROR,
df70a773 50 XC_LEARN, /* Calls back to ofproto. */
901a517e 51 XC_NORMAL,
df70a773 52 XC_FIN_TIMEOUT, /* Calls back to ofproto. */
901a517e
JR
53 XC_GROUP,
54 XC_TNL_NEIGH,
7c12dfc5 55 XC_TUNNEL_HEADER,
901a517e
JR
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. */
67struct xc_entry {
68 enum xc_type type;
69 union {
a027899e
JR
70 struct {
71 struct ofproto_dpif *ofproto;
72 uint8_t id;
73 bool match; /* or miss. */
74 } table;
901a517e
JR
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 {
2c7ee524 96 struct ofproto_flow_mod *ofm;
4c71600d 97 unsigned limit;
901a517e
JR
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;
df70a773
JR
119 struct {
120 struct ofproto_dpif *ofproto;
121 struct ofproto_async_msg *am;
122 } controller;
7c12dfc5
SC
123 struct {
124 enum {
125 ADD,
126 REMOVE,
127 } operation;
128 uint16_t hdr_size;
129 } tunnel_hdr;
901a517e
JR
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
138struct xlate_cache {
139 struct ofpbuf entries;
140};
141
1f4a8933 142void xlate_cache_init(struct xlate_cache *);
901a517e
JR
143struct xlate_cache *xlate_cache_new(void);
144struct xc_entry *xlate_cache_add_entry(struct xlate_cache *, enum xc_type);
16441315 145void xlate_push_stats_entry(struct xc_entry *, struct dpif_flow_stats *,
146 bool);
147void xlate_push_stats(struct xlate_cache *, struct dpif_flow_stats *,
148 bool);
901a517e
JR
149void xlate_cache_clear_entry(struct xc_entry *);
150void xlate_cache_clear(struct xlate_cache *);
1f4a8933 151void xlate_cache_uninit(struct xlate_cache *);
901a517e 152void xlate_cache_delete(struct xlate_cache *);
7c12dfc5 153void xlate_cache_steal_entries(struct xlate_cache *, struct xlate_cache *);
901a517e
JR
154
155#endif /* ofproto-dpif-xlate-cache.h */