]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/ofproto-dpif-xlate-cache.h
ofproto: Use ofproto_flow_mod for learn execution from xlate cache.
[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>
20#include <netinet/in.h>
21
22#include "openvswitch/types.h"
23#include "dp-packet.h"
24#include "odp-util.h"
25#include "ofproto/ofproto-dpif-mirror.h"
26#include "openvswitch/ofpbuf.h"
27
28struct bfd;
29struct bond;
30struct dpif_flow_stats;
31struct flow;
32struct group_dpif;
33struct mbridge;
34struct netdev;
35struct netflow;
36struct ofpbuf;
37struct ofproto_dpif;
38struct ofputil_bucket;
39struct ofputil_flow_mod;
40struct rule_dpif;
41
42enum xc_type {
a027899e 43 XC_TABLE,
901a517e
JR
44 XC_RULE,
45 XC_BOND,
46 XC_NETDEV,
47 XC_NETFLOW,
48 XC_MIRROR,
49 XC_LEARN,
50 XC_NORMAL,
51 XC_FIN_TIMEOUT,
52 XC_GROUP,
53 XC_TNL_NEIGH,
54};
55
56/* xlate_cache entries hold enough information to perform the side effects of
57 * xlate_actions() for a rule, without needing to perform rule translation
58 * from scratch. The primary usage of these is to submit statistics to objects
59 * that a flow relates to, although they may be used for other effects as well
60 * (for instance, refreshing hard timeouts for learned flows).
61 *
62 * An explicit reference is taken to all pointers other than the ones for
63 * struct ofproto_dpif. ofproto_dpif pointers are explicitly protected by
64 * destroying all xlate caches before the ofproto is destroyed. */
65struct xc_entry {
66 enum xc_type type;
67 union {
a027899e
JR
68 struct {
69 struct ofproto_dpif *ofproto;
70 uint8_t id;
71 bool match; /* or miss. */
72 } table;
901a517e
JR
73 struct rule_dpif *rule;
74 struct {
75 struct netdev *tx;
76 struct netdev *rx;
77 struct bfd *bfd;
78 } dev;
79 struct {
80 struct netflow *netflow;
81 struct flow *flow;
82 ofp_port_t iface;
83 } nf;
84 struct {
85 struct mbridge *mbridge;
86 mirror_mask_t mirrors;
87 } mirror;
88 struct {
89 struct bond *bond;
90 struct flow *flow;
91 uint16_t vid;
92 } bond;
93 struct {
2c7ee524 94 struct ofproto_flow_mod *ofm;
901a517e
JR
95 } learn;
96 struct {
97 struct ofproto_dpif *ofproto;
98 ofp_port_t in_port;
99 struct eth_addr dl_src;
100 int vlan;
101 bool is_gratuitous_arp;
102 } normal;
103 struct {
104 struct rule_dpif *rule;
105 uint16_t idle;
106 uint16_t hard;
107 } fin;
108 struct {
109 struct group_dpif *group;
110 struct ofputil_bucket *bucket;
111 } group;
112 struct {
113 char br_name[IFNAMSIZ];
114 struct in6_addr d_ipv6;
115 } tnl_neigh_cache;
116 };
117};
118
119#define XC_ENTRY_FOR_EACH(ENTRY, ENTRIES) \
120 for (ENTRY = ofpbuf_try_pull(ENTRIES, sizeof *ENTRY); \
121 ENTRY; \
122 ENTRY = ofpbuf_try_pull(ENTRIES, sizeof *ENTRY))
123
124struct xlate_cache {
125 struct ofpbuf entries;
126};
127
128struct xlate_cache *xlate_cache_new(void);
129struct xc_entry *xlate_cache_add_entry(struct xlate_cache *, enum xc_type);
130void xlate_push_stats_entry(struct xc_entry *, const struct dpif_flow_stats *);
131void xlate_push_stats(struct xlate_cache *, const struct dpif_flow_stats *);
132void xlate_cache_clear_entry(struct xc_entry *);
133void xlate_cache_clear(struct xlate_cache *);
134void xlate_cache_delete(struct xlate_cache *);
135
136#endif /* ofproto-dpif-xlate-cache.h */