]>
Commit | Line | Data |
---|---|---|
99520767 | 1 | /* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. |
9583bc14 EJ |
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 | 17 | |
cf62fa4c | 18 | #include "dp-packet.h" |
9583bc14 EJ |
19 | #include "flow.h" |
20 | #include "meta-flow.h" | |
21 | #include "odp-util.h" | |
22 | #include "ofpbuf.h" | |
ec7ceaed | 23 | #include "ofproto-dpif-mirror.h" |
e672ff9b | 24 | #include "ofproto-dpif-rid.h" |
9583bc14 | 25 | #include "ofproto-dpif.h" |
70742c7f EJ |
26 | #include "ofproto.h" |
27 | #include "stp.h" | |
0477baa9 | 28 | #include "ovs-lldp.h" |
9583bc14 | 29 | |
46c88433 EJ |
30 | struct bfd; |
31 | struct bond; | |
89a8a7f0 | 32 | struct dpif; |
46c88433 EJ |
33 | struct lacp; |
34 | struct dpif_ipfix; | |
35 | struct dpif_sflow; | |
36 | struct mac_learning; | |
6d95c4e8 | 37 | struct mcast_snooping; |
b256dc52 | 38 | struct xlate_cache; |
46c88433 | 39 | |
9583bc14 | 40 | struct xlate_out { |
9583bc14 | 41 | enum slow_path_reason slow; /* 0 if fast path may be used. */ |
9583bc14 | 42 | |
fbf5d6ec JR |
43 | struct recirc_refs recircs; /* Recirc action IDs on which references are |
44 | * held. */ | |
9583bc14 EJ |
45 | }; |
46 | ||
47 | struct xlate_in { | |
48 | struct ofproto_dpif *ofproto; | |
49 | ||
50 | /* Flow to which the OpenFlow actions apply. xlate_actions() will modify | |
51 | * this flow when actions change header fields. */ | |
52 | struct flow flow; | |
53 | ||
54 | /* The packet corresponding to 'flow', or a null pointer if we are | |
55 | * revalidating without a packet to refer to. */ | |
cf62fa4c | 56 | const struct dp_packet *packet; |
9583bc14 EJ |
57 | |
58 | /* Should OFPP_NORMAL update the MAC learning table? Should "learn" | |
59 | * actions update the flow table? | |
60 | * | |
61 | * We want to update these tables if we are actually processing a packet, | |
62 | * or if we are accounting for packets that the datapath has processed, but | |
63 | * not if we are just revalidating. */ | |
64 | bool may_learn; | |
65 | ||
10c44245 EJ |
66 | /* The rule initiating translation or NULL. If both 'rule' and 'ofpacts' |
67 | * are NULL, xlate_actions() will do the initial rule lookup itself. */ | |
9583bc14 EJ |
68 | struct rule_dpif *rule; |
69 | ||
70 | /* The actions to translate. If 'rule' is not NULL, these may be NULL. */ | |
71 | const struct ofpact *ofpacts; | |
72 | size_t ofpacts_len; | |
73 | ||
74 | /* Union of the set of TCP flags seen so far in this flow. (Used only by | |
75 | * NXAST_FIN_TIMEOUT. Set to zero to avoid updating updating rules' | |
76 | * timeouts.) */ | |
a66733a8 | 77 | uint16_t tcp_flags; |
9583bc14 EJ |
78 | |
79 | /* If nonnull, flow translation calls this function just before executing a | |
80 | * resubmit or OFPP_TABLE action. In addition, disables logging of traces | |
81 | * when the recursion depth is exceeded. | |
82 | * | |
83 | * 'rule' is the rule being submitted into. It will be null if the | |
84 | * resubmit or OFPP_TABLE action didn't find a matching rule. | |
85 | * | |
4d0acc70 EJ |
86 | * 'recurse' is the resubmit recursion depth at time of invocation. |
87 | * | |
9583bc14 EJ |
88 | * This is normally null so the client has to set it manually after |
89 | * calling xlate_in_init(). */ | |
4d0acc70 EJ |
90 | void (*resubmit_hook)(struct xlate_in *, struct rule_dpif *rule, |
91 | int recurse); | |
9583bc14 EJ |
92 | |
93 | /* If nonnull, flow translation calls this function to report some | |
94 | * significant decision, e.g. to explain why OFPP_NORMAL translation | |
4d0acc70 EJ |
95 | * dropped a packet. 'recurse' is the resubmit recursion depth at time of |
96 | * invocation. */ | |
c1b3756c BP |
97 | void (*report_hook)(struct xlate_in *, int recurse, |
98 | const char *format, va_list args); | |
9583bc14 EJ |
99 | |
100 | /* If nonnull, flow translation credits the specified statistics to each | |
101 | * rule reached through a resubmit or OFPP_TABLE action. | |
102 | * | |
103 | * This is normally null so the client has to set it manually after | |
104 | * calling xlate_in_init(). */ | |
105 | const struct dpif_flow_stats *resubmit_stats; | |
b256dc52 | 106 | |
cdd42eda JG |
107 | /* Recursion and resubmission levels carried over from a pre-existing |
108 | * translation of a related flow. An example of when this can occur is | |
109 | * the translation of an ARP packet that was generated as the result of | |
110 | * outputting to a tunnel port. In this case, the original flow going to | |
111 | * the tunnel is the related flow. Since the two flows are different, they | |
112 | * should not use the same xlate_ctx structure. However, we still need | |
113 | * limit the maximum recursion across the entire translation. | |
114 | * | |
115 | * These fields are normally set to zero, so the client has to set them | |
116 | * manually after calling xlate_in_init(). In that case, they should be | |
117 | * copied from the same-named fields in the related flow's xlate_ctx. */ | |
118 | int recurse; | |
119 | int resubmits; | |
120 | ||
b256dc52 JS |
121 | /* If nonnull, flow translation populates this cache with references to all |
122 | * modules that are affected by translation. This 'xlate_cache' may be | |
123 | * passed to xlate_push_stats() to perform the same function as | |
124 | * xlate_actions() without the full cost of translation. | |
125 | * | |
126 | * This is normally null so the client has to set it manually after | |
127 | * calling xlate_in_init(). */ | |
128 | struct xlate_cache *xcache; | |
cc377352 | 129 | |
1520ef4f BP |
130 | /* If nonnull, flow translation puts the resulting datapath actions in this |
131 | * buffer. If null, flow translation will not produce datapath actions. */ | |
cc377352 | 132 | struct ofpbuf *odp_actions; |
e672ff9b | 133 | |
49a73e0c BP |
134 | /* If nonnull, flow translation populates this with wildcards relevant in |
135 | * translation. Any fields that were used to calculate the action are set, | |
136 | * to allow caching and kernel wildcarding to work. For example, if the | |
137 | * flow lookup involved performing the "normal" action on IPv4 and ARP | |
138 | * packets, 'wc' would have the 'in_port' (always set), 'dl_type' (flow | |
139 | * match), 'vlan_tci' (normal action), and 'dl_dst' (normal action) fields | |
140 | * set. */ | |
141 | struct flow_wildcards *wc; | |
142 | ||
1d361a81 BP |
143 | /* The frozen state to be resumed, as returned by xlate_lookup(). */ |
144 | const struct frozen_state *frozen_state; | |
9583bc14 EJ |
145 | }; |
146 | ||
34dd0d78 | 147 | void xlate_ofproto_set(struct ofproto_dpif *, const char *name, struct dpif *, |
ec89fc6f | 148 | const struct mac_learning *, struct stp *, |
9efd308e | 149 | struct rstp *, const struct mcast_snooping *, |
ec89fc6f | 150 | const struct mbridge *, const struct dpif_sflow *, |
ce3955be | 151 | const struct dpif_ipfix *, const struct netflow *, |
b440dd8c JS |
152 | bool forward_bpdu, bool has_in_band, |
153 | const struct dpif_backer_support *support); | |
84f0f298 | 154 | void xlate_remove_ofproto(struct ofproto_dpif *); |
46c88433 EJ |
155 | |
156 | void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *, | |
157 | const char *name, enum port_vlan_mode, int vlan, | |
158 | unsigned long *trunks, bool use_priority_tags, | |
159 | const struct bond *, const struct lacp *, | |
84f0f298 RW |
160 | bool floodable); |
161 | void xlate_bundle_remove(struct ofbundle *); | |
46c88433 EJ |
162 | |
163 | void xlate_ofport_set(struct ofproto_dpif *, struct ofbundle *, | |
164 | struct ofport_dpif *, ofp_port_t, odp_port_t, | |
0477baa9 DF |
165 | const struct netdev *, const struct cfm *, const struct bfd *, |
166 | const struct lldp *, struct ofport_dpif *peer, | |
167 | int stp_port_no, const struct rstp_port *rstp_port, | |
9efd308e | 168 | const struct ofproto_port_queue *qdscp, |
dd8cd4b4 SH |
169 | size_t n_qdscp, enum ofputil_port_config, |
170 | enum ofputil_port_state, bool is_tunnel, | |
84f0f298 RW |
171 | bool may_enable); |
172 | void xlate_ofport_remove(struct ofport_dpif *); | |
46c88433 | 173 | |
ef377a58 JR |
174 | struct ofproto_dpif * xlate_lookup_ofproto(const struct dpif_backer *, |
175 | const struct flow *, | |
176 | ofp_port_t *ofp_in_port); | |
5c476ea3 JR |
177 | int xlate_lookup(const struct dpif_backer *, const struct flow *, |
178 | struct ofproto_dpif **, struct dpif_ipfix **, | |
179 | struct dpif_sflow **, struct netflow **, | |
180 | ofp_port_t *ofp_in_port); | |
8449c4d6 | 181 | |
fff1b9c0 JR |
182 | enum xlate_error { |
183 | XLATE_OK = 0, | |
184 | XLATE_BRIDGE_NOT_FOUND, | |
185 | XLATE_RECURSION_TOO_DEEP, | |
186 | XLATE_TOO_MANY_RESUBMITS, | |
187 | XLATE_STACK_TOO_DEEP, | |
188 | XLATE_NO_RECIRCULATION_CONTEXT, | |
189 | XLATE_RECIRCULATION_CONFLICT, | |
190 | XLATE_TOO_MANY_MPLS_LABELS, | |
191 | }; | |
192 | ||
193 | const char *xlate_strerror(enum xlate_error error); | |
194 | ||
195 | enum xlate_error xlate_actions(struct xlate_in *, struct xlate_out *); | |
196 | ||
9583bc14 | 197 | void xlate_in_init(struct xlate_in *, struct ofproto_dpif *, |
cc377352 | 198 | const struct flow *, ofp_port_t in_port, struct rule_dpif *, |
49a73e0c | 199 | uint16_t tcp_flags, const struct dp_packet *packet, |
1520ef4f | 200 | struct flow_wildcards *, struct ofpbuf *odp_actions); |
9583bc14 EJ |
201 | void xlate_out_uninit(struct xlate_out *); |
202 | void xlate_actions_for_side_effects(struct xlate_in *); | |
10e57640 | 203 | |
77ab5fd2 BP |
204 | enum ofperr xlate_resume(struct ofproto_dpif *, |
205 | const struct ofputil_packet_in_private *, | |
206 | struct ofpbuf *odp_actions, enum slow_path_reason *); | |
207 | ||
cf62fa4c | 208 | int xlate_send_packet(const struct ofport_dpif *, struct dp_packet *); |
91d6cd12 | 209 | |
b256dc52 | 210 | struct xlate_cache *xlate_cache_new(void); |
0725e747 | 211 | void xlate_push_stats(struct xlate_cache *, const struct dpif_flow_stats *); |
b256dc52 JS |
212 | void xlate_cache_clear(struct xlate_cache *); |
213 | void xlate_cache_delete(struct xlate_cache *); | |
214 | ||
84f0f298 RW |
215 | void xlate_txn_start(void); |
216 | void xlate_txn_commit(void); | |
217 | ||
9583bc14 | 218 | #endif /* ofproto-dpif-xlate.h */ |