]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/ofproto-dpif-xlate.h
ofproto: Move all statistics accounting into xlate_actions().
[mirror_ovs.git] / ofproto / ofproto-dpif-xlate.h
CommitLineData
9583bc14
EJ
1/* Copyright (c) 2009, 2010, 2011, 2012, 2013 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
e1ec7dd4
EJ
15#ifndef OFPROTO_DPIF_XLATE_H
16#define OFPROTO_DPIF_XLATE_H 1
9583bc14
EJ
17
18#include "flow.h"
19#include "meta-flow.h"
20#include "odp-util.h"
21#include "ofpbuf.h"
ec7ceaed 22#include "ofproto-dpif-mirror.h"
9583bc14 23#include "ofproto-dpif.h"
70742c7f
EJ
24#include "ofproto.h"
25#include "stp.h"
9583bc14 26
46c88433
EJ
27struct bfd;
28struct bond;
89a8a7f0 29struct dpif;
46c88433
EJ
30struct lacp;
31struct dpif_ipfix;
32struct dpif_sflow;
33struct mac_learning;
34
9583bc14
EJ
35struct xlate_out {
36 /* Wildcards relevant in translation. Any fields that were used to
37 * calculate the action must be set for caching and kernel
38 * wildcarding to work. For example, if the flow lookup involved
39 * performing the "normal" action on IPv4 and ARP packets, 'wc'
40 * would have the 'in_port' (always set), 'dl_type' (flow match),
41 * 'vlan_tci' (normal action), and 'dl_dst' (normal action) fields
42 * set. */
43 struct flow_wildcards wc;
44
9583bc14 45 enum slow_path_reason slow; /* 0 if fast path may be used. */
10c44245 46 bool fail_open; /* Initial rule is fail open? */
9583bc14
EJ
47 bool has_learn; /* Actions include NXAST_LEARN? */
48 bool has_normal; /* Actions output to OFPP_NORMAL? */
49 bool has_fin_timeout; /* Actions include NXAST_FIN_TIMEOUT? */
4e022ec0 50 ofp_port_t nf_output_iface; /* Output interface index for NetFlow. */
9583bc14
EJ
51 mirror_mask_t mirrors; /* Bitmap of associated mirrors. */
52
53 uint64_t odp_actions_stub[256 / 8];
54 struct ofpbuf odp_actions;
55};
56
57struct xlate_in {
58 struct ofproto_dpif *ofproto;
59
60 /* Flow to which the OpenFlow actions apply. xlate_actions() will modify
61 * this flow when actions change header fields. */
62 struct flow flow;
63
64 /* The packet corresponding to 'flow', or a null pointer if we are
65 * revalidating without a packet to refer to. */
66 const struct ofpbuf *packet;
67
68 /* Should OFPP_NORMAL update the MAC learning table? Should "learn"
69 * actions update the flow table?
70 *
71 * We want to update these tables if we are actually processing a packet,
72 * or if we are accounting for packets that the datapath has processed, but
73 * not if we are just revalidating. */
74 bool may_learn;
75
10c44245
EJ
76 /* The rule initiating translation or NULL. If both 'rule' and 'ofpacts'
77 * are NULL, xlate_actions() will do the initial rule lookup itself. */
9583bc14
EJ
78 struct rule_dpif *rule;
79
80 /* The actions to translate. If 'rule' is not NULL, these may be NULL. */
81 const struct ofpact *ofpacts;
82 size_t ofpacts_len;
83
84 /* Union of the set of TCP flags seen so far in this flow. (Used only by
85 * NXAST_FIN_TIMEOUT. Set to zero to avoid updating updating rules'
86 * timeouts.) */
a66733a8 87 uint16_t tcp_flags;
9583bc14
EJ
88
89 /* If nonnull, flow translation calls this function just before executing a
90 * resubmit or OFPP_TABLE action. In addition, disables logging of traces
91 * when the recursion depth is exceeded.
92 *
93 * 'rule' is the rule being submitted into. It will be null if the
94 * resubmit or OFPP_TABLE action didn't find a matching rule.
95 *
4d0acc70
EJ
96 * 'recurse' is the resubmit recursion depth at time of invocation.
97 *
9583bc14
EJ
98 * This is normally null so the client has to set it manually after
99 * calling xlate_in_init(). */
4d0acc70
EJ
100 void (*resubmit_hook)(struct xlate_in *, struct rule_dpif *rule,
101 int recurse);
9583bc14
EJ
102
103 /* If nonnull, flow translation calls this function to report some
104 * significant decision, e.g. to explain why OFPP_NORMAL translation
4d0acc70
EJ
105 * dropped a packet. 'recurse' is the resubmit recursion depth at time of
106 * invocation. */
107 void (*report_hook)(struct xlate_in *, const char *s, int recurse);
9583bc14
EJ
108
109 /* If nonnull, flow translation credits the specified statistics to each
110 * rule reached through a resubmit or OFPP_TABLE action.
111 *
112 * This is normally null so the client has to set it manually after
113 * calling xlate_in_init(). */
114 const struct dpif_flow_stats *resubmit_stats;
115};
116
dc24a00f
EJ
117extern struct ovs_rwlock xlate_rwlock;
118
46c88433 119void xlate_ofproto_set(struct ofproto_dpif *, const char *name,
ec89fc6f
EJ
120 struct dpif *, struct rule_dpif *miss_rule,
121 struct rule_dpif *no_packet_in_rule,
122 const struct mac_learning *, struct stp *,
123 const struct mbridge *, const struct dpif_sflow *,
ce3955be
EJ
124 const struct dpif_ipfix *, const struct netflow *,
125 enum ofp_config_flags, bool forward_bpdu,
126 bool has_in_band)
dc24a00f
EJ
127 OVS_REQ_WRLOCK(xlate_rwlock);
128void xlate_remove_ofproto(struct ofproto_dpif *) OVS_REQ_WRLOCK(xlate_rwlock);
46c88433
EJ
129
130void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *,
131 const char *name, enum port_vlan_mode, int vlan,
132 unsigned long *trunks, bool use_priority_tags,
133 const struct bond *, const struct lacp *,
dc24a00f
EJ
134 bool floodable) OVS_REQ_WRLOCK(xlate_rwlock);
135void xlate_bundle_remove(struct ofbundle *) OVS_REQ_WRLOCK(xlate_rwlock);
46c88433
EJ
136
137void xlate_ofport_set(struct ofproto_dpif *, struct ofbundle *,
138 struct ofport_dpif *, ofp_port_t, odp_port_t,
139 const struct netdev *, const struct cfm *,
140 const struct bfd *, struct ofport_dpif *peer,
55954f6e 141 int stp_port_no, const struct ofproto_port_queue *qdscp,
dd8cd4b4
SH
142 size_t n_qdscp, enum ofputil_port_config,
143 enum ofputil_port_state, bool is_tunnel,
dc24a00f
EJ
144 bool may_enable) OVS_REQ_WRLOCK(xlate_rwlock);
145void xlate_ofport_remove(struct ofport_dpif *) OVS_REQ_WRLOCK(xlate_rwlock);
46c88433 146
8449c4d6
EJ
147int xlate_receive(const struct dpif_backer *, struct ofpbuf *packet,
148 const struct nlattr *key, size_t key_len,
149 struct flow *, enum odp_key_fitness *,
1dfdb9b3
EJ
150 struct ofproto_dpif **, struct dpif_ipfix **,
151 struct dpif_sflow **, struct netflow **,
152 odp_port_t *odp_in_port)
dc24a00f 153 OVS_EXCLUDED(xlate_rwlock);
8449c4d6 154
dc24a00f
EJ
155void xlate_actions(struct xlate_in *, struct xlate_out *)
156 OVS_EXCLUDED(xlate_rwlock);
9583bc14 157void xlate_in_init(struct xlate_in *, struct ofproto_dpif *,
d6fc5f57
EJ
158 const struct flow *, struct rule_dpif *, uint16_t tcp_flags,
159 const struct ofpbuf *packet);
9583bc14
EJ
160void xlate_out_uninit(struct xlate_out *);
161void xlate_actions_for_side_effects(struct xlate_in *);
162void xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src);
10e57640 163
91d6cd12
AW
164int xlate_send_packet(const struct ofport_dpif *, struct ofpbuf *);
165
9583bc14 166#endif /* ofproto-dpif-xlate.h */