]> git.proxmox.com Git - mirror_ovs.git/blob - ofproto/ofproto-dpif-trace.h
63dbb50bad5718145fd972c7d9276fdbfd692781
[mirror_ovs.git] / ofproto / ofproto-dpif-trace.h
1 /* Copyright (c) 2016, 2017 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_TRACE_H
16 #define OFPROTO_DPIF_TRACE_H 1
17
18 /* Tracing
19 * =======
20 *
21 * The Open vSwitch software datapath based switch implementation supports
22 * "tracing". A trace describes what happens to a particular kind of packet as
23 * it passes through the switch, including information on each table, flow, and
24 * action that would apply to the packet. The trace is internally represented
25 * as a tree that reflects control flow; for example, an OpenFlow switch
26 * top-level node (of type OFT_BRIDGE) has a child node for each table visited
27 * by a packet (of type OFT_TABLE), and each table node has a child node for
28 * each action (OFT_ACTION) executed in the table.
29 */
30
31 #include "openvswitch/dynamic-string.h"
32 #include "ofproto/ofproto-dpif.h"
33 #include "openvswitch/compiler.h"
34 #include "openvswitch/list.h"
35 #include "flow.h"
36
37 /* Type of a node within a trace. */
38 enum oftrace_node_type {
39 /* Nodes that may have children (nonterminal nodes). */
40 OFT_BRIDGE, /* Packet travel through an OpenFlow switch. */
41 OFT_TABLE, /* Packet travel through a flow table. */
42 OFT_BUCKET, /* Executing a bucket in an OpenFlow group. */
43 OFT_THAW, /* Thawing a frozen state. */
44
45 /* Nodes that never have children (terminal nodes). */
46 OFT_ACTION, /* An action. */
47 OFT_DETAIL, /* Some detail of an action. */
48 OFT_WARN, /* A worrisome situation. */
49 OFT_ERROR, /* An erroneous situation, worth logging. */
50 };
51
52 /* Reason why a flow is in a recirculation queue. */
53 enum oftrace_recirc_type {
54 OFT_RECIRC_CONNTRACK,
55 OFT_RECIRC_MPLS,
56 OFT_RECIRC_BOND,
57 };
58
59 /* A node within a trace. */
60 struct oftrace_node {
61 struct ovs_list node; /* In parent. */
62 struct ovs_list subs; /* List of "struct oftrace_node" children. */
63
64 enum oftrace_node_type type;
65 char *text;
66 };
67
68 /* A node within a recirculation queue. */
69 struct oftrace_recirc_node {
70 struct ovs_list node; /* In recirc_queue. */
71
72 enum oftrace_recirc_type type;
73 uint32_t recirc_id;
74 struct flow flow;
75 struct dp_packet *packet;
76 };
77
78 /* A node within a next_ct_states list. */
79 struct oftrace_next_ct_state {
80 struct ovs_list node; /* In next_ct_states. */
81 uint32_t state;
82 };
83
84 void ofproto_dpif_trace_init(void);
85 void ofproto_trace(struct ofproto_dpif *ofproto, const struct flow *flow,
86 const struct dp_packet *packet,
87 const struct ofpact *, size_t ofpacts_len,
88 struct ovs_list *next_ct_states, struct ds *output);
89
90 struct oftrace_node *oftrace_report(struct ovs_list *, enum oftrace_node_type,
91 const char *text);
92 bool oftrace_add_recirc_node(struct ovs_list *recirc_queue,
93 enum oftrace_recirc_type, const struct flow *,
94 const struct dp_packet *, uint32_t recirc_id,
95 const uint16_t zone);
96
97 #endif /* ofproto-dpif-trace.h */