]>
Commit | Line | Data |
---|---|---|
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 |
27 | struct bfd; |
28 | struct bond; | |
89a8a7f0 | 29 | struct dpif; |
46c88433 EJ |
30 | struct lacp; |
31 | struct dpif_ipfix; | |
32 | struct dpif_sflow; | |
33 | struct mac_learning; | |
6d95c4e8 | 34 | struct mcast_snooping; |
b256dc52 | 35 | struct xlate_cache; |
46c88433 | 36 | |
adcf00ba AZ |
37 | struct xlate_recirc { |
38 | uint32_t recirc_id; /* !0 Use recirculation instead of output. */ | |
39 | uint8_t hash_alg; /* !0 Compute hash for recirc before. */ | |
62ac1f20 | 40 | uint32_t hash_basis; /* Compute hash for recirc before. */ |
adcf00ba AZ |
41 | }; |
42 | ||
9583bc14 EJ |
43 | struct xlate_out { |
44 | /* Wildcards relevant in translation. Any fields that were used to | |
45 | * calculate the action must be set for caching and kernel | |
46 | * wildcarding to work. For example, if the flow lookup involved | |
47 | * performing the "normal" action on IPv4 and ARP packets, 'wc' | |
48 | * would have the 'in_port' (always set), 'dl_type' (flow match), | |
49 | * 'vlan_tci' (normal action), and 'dl_dst' (normal action) fields | |
50 | * set. */ | |
51 | struct flow_wildcards wc; | |
52 | ||
9583bc14 | 53 | enum slow_path_reason slow; /* 0 if fast path may be used. */ |
10c44245 | 54 | bool fail_open; /* Initial rule is fail open? */ |
9583bc14 EJ |
55 | bool has_learn; /* Actions include NXAST_LEARN? */ |
56 | bool has_normal; /* Actions output to OFPP_NORMAL? */ | |
57 | bool has_fin_timeout; /* Actions include NXAST_FIN_TIMEOUT? */ | |
4e022ec0 | 58 | ofp_port_t nf_output_iface; /* Output interface index for NetFlow. */ |
9583bc14 EJ |
59 | mirror_mask_t mirrors; /* Bitmap of associated mirrors. */ |
60 | ||
61 | uint64_t odp_actions_stub[256 / 8]; | |
cc377352 EJ |
62 | struct ofpbuf odp_actions_buf; |
63 | struct ofpbuf *odp_actions; | |
9583bc14 EJ |
64 | }; |
65 | ||
66 | struct xlate_in { | |
67 | struct ofproto_dpif *ofproto; | |
68 | ||
69 | /* Flow to which the OpenFlow actions apply. xlate_actions() will modify | |
70 | * this flow when actions change header fields. */ | |
71 | struct flow flow; | |
72 | ||
73 | /* The packet corresponding to 'flow', or a null pointer if we are | |
74 | * revalidating without a packet to refer to. */ | |
75 | const struct ofpbuf *packet; | |
76 | ||
77 | /* Should OFPP_NORMAL update the MAC learning table? Should "learn" | |
78 | * actions update the flow table? | |
79 | * | |
80 | * We want to update these tables if we are actually processing a packet, | |
81 | * or if we are accounting for packets that the datapath has processed, but | |
82 | * not if we are just revalidating. */ | |
83 | bool may_learn; | |
84 | ||
3f207910 EJ |
85 | /* If the caller of xlate_actions() doesn't need the flow_wildcards |
86 | * contained in struct xlate_out. 'skip_wildcards' can be set to true | |
87 | * disabling the expensive wildcard computation. When true, 'wc' in struct | |
88 | * xlate_out is undefined and should not be read. */ | |
89 | bool skip_wildcards; | |
90 | ||
10c44245 EJ |
91 | /* The rule initiating translation or NULL. If both 'rule' and 'ofpacts' |
92 | * are NULL, xlate_actions() will do the initial rule lookup itself. */ | |
9583bc14 EJ |
93 | struct rule_dpif *rule; |
94 | ||
95 | /* The actions to translate. If 'rule' is not NULL, these may be NULL. */ | |
96 | const struct ofpact *ofpacts; | |
97 | size_t ofpacts_len; | |
98 | ||
99 | /* Union of the set of TCP flags seen so far in this flow. (Used only by | |
100 | * NXAST_FIN_TIMEOUT. Set to zero to avoid updating updating rules' | |
101 | * timeouts.) */ | |
a66733a8 | 102 | uint16_t tcp_flags; |
9583bc14 EJ |
103 | |
104 | /* If nonnull, flow translation calls this function just before executing a | |
105 | * resubmit or OFPP_TABLE action. In addition, disables logging of traces | |
106 | * when the recursion depth is exceeded. | |
107 | * | |
108 | * 'rule' is the rule being submitted into. It will be null if the | |
109 | * resubmit or OFPP_TABLE action didn't find a matching rule. | |
110 | * | |
4d0acc70 EJ |
111 | * 'recurse' is the resubmit recursion depth at time of invocation. |
112 | * | |
9583bc14 EJ |
113 | * This is normally null so the client has to set it manually after |
114 | * calling xlate_in_init(). */ | |
4d0acc70 EJ |
115 | void (*resubmit_hook)(struct xlate_in *, struct rule_dpif *rule, |
116 | int recurse); | |
9583bc14 EJ |
117 | |
118 | /* If nonnull, flow translation calls this function to report some | |
119 | * significant decision, e.g. to explain why OFPP_NORMAL translation | |
4d0acc70 EJ |
120 | * dropped a packet. 'recurse' is the resubmit recursion depth at time of |
121 | * invocation. */ | |
122 | void (*report_hook)(struct xlate_in *, const char *s, int recurse); | |
9583bc14 EJ |
123 | |
124 | /* If nonnull, flow translation credits the specified statistics to each | |
125 | * rule reached through a resubmit or OFPP_TABLE action. | |
126 | * | |
127 | * This is normally null so the client has to set it manually after | |
128 | * calling xlate_in_init(). */ | |
129 | const struct dpif_flow_stats *resubmit_stats; | |
b256dc52 JS |
130 | |
131 | /* If nonnull, flow translation populates this cache with references to all | |
132 | * modules that are affected by translation. This 'xlate_cache' may be | |
133 | * passed to xlate_push_stats() to perform the same function as | |
134 | * xlate_actions() without the full cost of translation. | |
135 | * | |
136 | * This is normally null so the client has to set it manually after | |
137 | * calling xlate_in_init(). */ | |
138 | struct xlate_cache *xcache; | |
cc377352 EJ |
139 | |
140 | /* Allows callers to optionally supply their own buffer for the resulting | |
141 | * odp_actions stored in xlate_out. If NULL, the default buffer will be | |
142 | * used. */ | |
143 | struct ofpbuf *odp_actions; | |
9583bc14 EJ |
144 | }; |
145 | ||
46c88433 | 146 | void xlate_ofproto_set(struct ofproto_dpif *, const char *name, |
ec89fc6f EJ |
147 | struct dpif *, struct rule_dpif *miss_rule, |
148 | struct rule_dpif *no_packet_in_rule, | |
149 | const struct mac_learning *, struct stp *, | |
6d95c4e8 | 150 | const struct mcast_snooping *, |
ec89fc6f | 151 | const struct mbridge *, const struct dpif_sflow *, |
ce3955be EJ |
152 | const struct dpif_ipfix *, const struct netflow *, |
153 | enum ofp_config_flags, bool forward_bpdu, | |
adcf00ba AZ |
154 | bool has_in_band, bool enable_recirc, |
155 | bool variable_length_userdata, | |
84f0f298 RW |
156 | size_t mpls_label_stack_length); |
157 | void xlate_remove_ofproto(struct ofproto_dpif *); | |
46c88433 EJ |
158 | |
159 | void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *, | |
160 | const char *name, enum port_vlan_mode, int vlan, | |
161 | unsigned long *trunks, bool use_priority_tags, | |
162 | const struct bond *, const struct lacp *, | |
84f0f298 RW |
163 | bool floodable); |
164 | void xlate_bundle_remove(struct ofbundle *); | |
46c88433 EJ |
165 | |
166 | void xlate_ofport_set(struct ofproto_dpif *, struct ofbundle *, | |
167 | struct ofport_dpif *, ofp_port_t, odp_port_t, | |
168 | const struct netdev *, const struct cfm *, | |
169 | const struct bfd *, struct ofport_dpif *peer, | |
55954f6e | 170 | int stp_port_no, const struct ofproto_port_queue *qdscp, |
dd8cd4b4 SH |
171 | size_t n_qdscp, enum ofputil_port_config, |
172 | enum ofputil_port_state, bool is_tunnel, | |
84f0f298 RW |
173 | bool may_enable); |
174 | void xlate_ofport_remove(struct ofport_dpif *); | |
46c88433 | 175 | |
ef377a58 JR |
176 | struct ofproto_dpif * xlate_lookup_ofproto(const struct dpif_backer *, |
177 | const struct flow *, | |
178 | ofp_port_t *ofp_in_port); | |
cc377352 EJ |
179 | int xlate_receive(const struct dpif_backer *, const struct flow *, |
180 | struct ofproto_dpif **, struct dpif_ipfix **, | |
1dfdb9b3 | 181 | struct dpif_sflow **, struct netflow **, |
cc377352 | 182 | ofp_port_t *ofp_in_port); |
8449c4d6 | 183 | |
84f0f298 | 184 | void xlate_actions(struct xlate_in *, struct xlate_out *); |
9583bc14 | 185 | void xlate_in_init(struct xlate_in *, struct ofproto_dpif *, |
cc377352 | 186 | const struct flow *, ofp_port_t in_port, struct rule_dpif *, |
adcf00ba | 187 | uint16_t tcp_flags, const struct ofpbuf *packet); |
9583bc14 EJ |
188 | void xlate_out_uninit(struct xlate_out *); |
189 | void xlate_actions_for_side_effects(struct xlate_in *); | |
190 | void xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src); | |
10e57640 | 191 | |
91d6cd12 AW |
192 | int xlate_send_packet(const struct ofport_dpif *, struct ofpbuf *); |
193 | ||
b256dc52 JS |
194 | struct xlate_cache *xlate_cache_new(void); |
195 | void xlate_push_stats(struct xlate_cache *, bool may_learn, | |
196 | const struct dpif_flow_stats *); | |
197 | void xlate_cache_clear(struct xlate_cache *); | |
198 | void xlate_cache_delete(struct xlate_cache *); | |
199 | ||
84f0f298 RW |
200 | void xlate_txn_start(void); |
201 | void xlate_txn_commit(void); | |
202 | ||
9583bc14 | 203 | #endif /* ofproto-dpif-xlate.h */ |