1 /* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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. */
15 #ifndef OFPROT_DPIF_XLATE_H
16 #define OFPROT_DPIF_XLATE_H 1
19 #include "meta-flow.h"
22 #include "ofproto-dpif-mirror.h"
23 #include "ofproto-dpif.h"
34 /* Wildcards relevant in translation. Any fields that were used to
35 * calculate the action must be set for caching and kernel
36 * wildcarding to work. For example, if the flow lookup involved
37 * performing the "normal" action on IPv4 and ARP packets, 'wc'
38 * would have the 'in_port' (always set), 'dl_type' (flow match),
39 * 'vlan_tci' (normal action), and 'dl_dst' (normal action) fields
41 struct flow_wildcards wc;
43 tag_type tags; /* Tags associated with actions. */
44 enum slow_path_reason slow; /* 0 if fast path may be used. */
45 bool has_learn; /* Actions include NXAST_LEARN? */
46 bool has_normal; /* Actions output to OFPP_NORMAL? */
47 bool has_fin_timeout; /* Actions include NXAST_FIN_TIMEOUT? */
48 ofp_port_t nf_output_iface; /* Output interface index for NetFlow. */
49 mirror_mask_t mirrors; /* Bitmap of associated mirrors. */
51 uint64_t odp_actions_stub[256 / 8];
52 struct ofpbuf odp_actions;
56 struct ofproto_dpif *ofproto;
58 /* Flow to which the OpenFlow actions apply. xlate_actions() will modify
59 * this flow when actions change header fields. */
62 /* The packet corresponding to 'flow', or a null pointer if we are
63 * revalidating without a packet to refer to. */
64 const struct ofpbuf *packet;
66 /* Should OFPP_NORMAL update the MAC learning table? Should "learn"
67 * actions update the flow table?
69 * We want to update these tables if we are actually processing a packet,
70 * or if we are accounting for packets that the datapath has processed, but
71 * not if we are just revalidating. */
74 /* The rule initiating translation or NULL. */
75 struct rule_dpif *rule;
77 /* The actions to translate. If 'rule' is not NULL, these may be NULL. */
78 const struct ofpact *ofpacts;
81 /* Union of the set of TCP flags seen so far in this flow. (Used only by
82 * NXAST_FIN_TIMEOUT. Set to zero to avoid updating updating rules'
86 /* If nonnull, flow translation calls this function just before executing a
87 * resubmit or OFPP_TABLE action. In addition, disables logging of traces
88 * when the recursion depth is exceeded.
90 * 'rule' is the rule being submitted into. It will be null if the
91 * resubmit or OFPP_TABLE action didn't find a matching rule.
93 * 'recurse' is the resubmit recursion depth at time of invocation.
95 * This is normally null so the client has to set it manually after
96 * calling xlate_in_init(). */
97 void (*resubmit_hook)(struct xlate_in *, struct rule_dpif *rule,
100 /* If nonnull, flow translation calls this function to report some
101 * significant decision, e.g. to explain why OFPP_NORMAL translation
102 * dropped a packet. 'recurse' is the resubmit recursion depth at time of
104 void (*report_hook)(struct xlate_in *, const char *s, int recurse);
106 /* If nonnull, flow translation credits the specified statistics to each
107 * rule reached through a resubmit or OFPP_TABLE action.
109 * This is normally null so the client has to set it manually after
110 * calling xlate_in_init(). */
111 const struct dpif_flow_stats *resubmit_stats;
114 void xlate_ofproto_set(struct ofproto_dpif *, const char *name,
115 const struct mac_learning *, const struct mbridge *,
116 const struct dpif_sflow *, const struct dpif_ipfix *,
117 enum ofp_config_flags, bool forward_bpdu,
118 bool has_in_band, bool has_netflow, bool has_stp);
119 void xlate_remove_ofproto(struct ofproto_dpif *);
121 void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *,
122 const char *name, enum port_vlan_mode, int vlan,
123 unsigned long *trunks, bool use_priority_tags,
124 const struct bond *, const struct lacp *,
126 void xlate_bundle_remove(struct ofbundle *);
128 void xlate_ofport_set(struct ofproto_dpif *, struct ofbundle *,
129 struct ofport_dpif *, ofp_port_t, odp_port_t,
130 const struct netdev *, const struct cfm *,
131 const struct bfd *, struct ofport_dpif *peer,
132 enum ofputil_port_config, enum stp_state, bool is_tunnel,
134 void xlate_ofport_remove(struct ofport_dpif *);
136 void xlate_actions(struct xlate_in *, struct xlate_out *);
137 void xlate_in_init(struct xlate_in *, struct ofproto_dpif *,
138 const struct flow *, struct rule_dpif *,
139 uint8_t tcp_flags, const struct ofpbuf *packet);
140 void xlate_out_uninit(struct xlate_out *);
141 void xlate_actions_for_side_effects(struct xlate_in *);
142 void xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src);
144 #endif /* ofproto-dpif-xlate.h */