f4c97a1e5ddabeb82e8b67eac045a653d4d54db9
[cascardo/ovs.git] / include / openflow / openflow-1.2.h
1 /* Copyright (c) 2008, 2011, 2012, 2013, 2014 The Board of Trustees of The Leland Stanford
2  * Junior University
3  *
4  * We are making the OpenFlow specification and associated documentation
5  * (Software) available for public use and benefit with the expectation
6  * that others will use, modify and enhance the Software and contribute
7  * those enhancements back to the community. However, since we would
8  * like to make the Software available for broadest use, with as few
9  * restrictions as possible permission is hereby granted, free of
10  * charge, to any person obtaining a copy of this Software to deal in
11  * the Software under the copyrights without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27  * SOFTWARE.
28  *
29  * The name and trademarks of copyright holder(s) may NOT be used in
30  * advertising or publicity pertaining to the Software or any
31  * derivatives without specific, written prior permission.
32  */
33
34 /*
35  * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
36  * Copyright (c) 2012 Horms Solutions Ltd.
37  *
38  * Licensed under the Apache License, Version 2.0 (the "License");
39  * you may not use this file except in compliance with the License.
40  * You may obtain a copy of the License at:
41  *
42  *     http://www.apache.org/licenses/LICENSE-2.0
43  *
44  * Unless required by applicable law or agreed to in writing, software
45  * distributed under the License is distributed on an "AS IS" BASIS,
46  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47  * See the License for the specific language governing permissions and
48  * limitations under the License.
49  */
50
51 /* OpenFlow: protocol between controller and datapath. */
52
53 #ifndef OPENFLOW_12_H
54 #define OPENFLOW_12_H 1
55
56 #include "openflow/openflow-1.1.h"
57
58 /* Error type for experimenter error messages. */
59 #define OFPET12_EXPERIMENTER 0xffff
60
61 /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
62  * special conditions.
63  */
64 enum ofp12_vlan_id {
65     OFPVID12_PRESENT = 0x1000, /* Bit that indicate that a VLAN id is set */
66     OFPVID12_NONE    = 0x0000, /* No VLAN id was set. */
67 };
68
69 /* Bit definitions for IPv6 Extension Header pseudo-field. */
70 enum ofp12_ipv6exthdr_flags {
71     OFPIEH12_NONEXT = 1 << 0,   /* "No next header" encountered. */
72     OFPIEH12_ESP    = 1 << 1,   /* Encrypted Sec Payload header present. */
73     OFPIEH12_AUTH   = 1 << 2,   /* Authentication header present. */
74     OFPIEH12_DEST   = 1 << 3,   /* 1 or 2 dest headers present. */
75     OFPIEH12_FRAG   = 1 << 4,   /* Fragment header present. */
76     OFPIEH12_ROUTER = 1 << 5,   /* Router header present. */
77     OFPIEH12_HOP    = 1 << 6,   /* Hop-by-hop header present. */
78     OFPIEH12_UNREP  = 1 << 7,   /* Unexpected repeats encountered. */
79     OFPIEH12_UNSEQ  = 1 << 8    /* Unexpected sequencing encountered. */
80 };
81
82 /* Header for OXM experimenter match fields. */
83 struct ofp12_oxm_experimenter_header {
84     ovs_be32 oxm_header;   /* oxm_class = OFPXMC_EXPERIMENTER */
85     ovs_be32 experimenter; /* Experimenter ID which takes the same
86                               form as in struct ofp11_experimenter_header. */
87 };
88 OFP_ASSERT(sizeof(struct ofp12_oxm_experimenter_header) == 8);
89
90 enum ofp12_controller_max_len {
91     OFPCML12_MAX       = 0xffe5, /* maximum max_len value which can be used
92                                   * to request a specific byte length. */
93     OFPCML12_NO_BUFFER = 0xffff  /* indicates that no buffering should be
94                                   * applied and the whole packet is to be
95                                   * sent to the controller. */
96 };
97
98 /* OpenFlow 1.2 specific flags
99  * (struct ofp12_flow_mod, member flags). */
100 enum ofp12_flow_mod_flags {
101     OFPFF12_RESET_COUNTS  = 1 << 2   /* Reset flow packet and byte counts. */
102 };
103
104 /* OpenFlow 1.2 specific capabilities
105  * (struct ofp_switch_features, member capabilities). */
106 enum ofp12_capabilities {
107     OFPC12_PORT_BLOCKED   = 1 << 8   /* Switch will block looping ports. */
108 };
109
110 /* Full description for a queue. */
111 struct ofp12_packet_queue {
112     ovs_be32 queue_id;     /* id for the specific queue. */
113     ovs_be32 port;         /* Port this queue is attached to. */
114     ovs_be16 len;          /* Length in bytes of this queue desc. */
115     uint8_t pad[6];        /* 64-bit alignment. */
116     /* Followed by any number of queue properties expressed using
117      * ofp_queue_prop_header, to fill out a total of 'len' bytes. */
118 };
119 OFP_ASSERT(sizeof(struct ofp12_packet_queue) == 16);
120
121 /* Body of reply to OFPST_TABLE request. */
122 struct ofp12_table_stats {
123     uint8_t table_id;        /* Identifier of table.  Lower numbered tables
124                                 are consulted first. */
125     uint8_t pad[7];          /* Align to 64-bits. */
126     char name[OFP_MAX_TABLE_NAME_LEN];
127     ovs_be64 match;          /* Bitmap of (1 << OFPXMT_*) that indicate the
128                                 fields the table can match on. */
129     ovs_be64 wildcards;      /* Bitmap of (1 << OFPXMT_*) wildcards that are
130                                 supported by the table. */
131     ovs_be32 write_actions;  /* Bitmap of OFPAT_* that are supported
132                                 by the table with OFPIT_WRITE_ACTIONS. */
133     ovs_be32 apply_actions;  /* Bitmap of OFPAT_* that are supported
134                                 by the table with OFPIT_APPLY_ACTIONS. */
135     ovs_be64 write_setfields;/* Bitmap of (1 << OFPXMT_*) header fields that
136                                 can be set with OFPIT_WRITE_ACTIONS. */
137     ovs_be64 apply_setfields;/* Bitmap of (1 << OFPXMT_*) header fields that
138                                 can be set with OFPIT_APPLY_ACTIONS. */
139     ovs_be64 metadata_match; /* Bits of metadata table can match. */
140     ovs_be64 metadata_write; /* Bits of metadata table can write. */
141     ovs_be32 instructions;   /* Bitmap of OFPIT_* values supported. */
142     ovs_be32 config;         /* Bitmap of OFPTC_* values */
143     ovs_be32 max_entries;    /* Max number of entries supported. */
144     ovs_be32 active_count;   /* Number of active entries. */
145     ovs_be64 lookup_count;   /* Number of packets looked up in table. */
146     ovs_be64 matched_count;  /* Number of packets that hit table. */
147 };
148 OFP_ASSERT(sizeof(struct ofp12_table_stats) == 128);
149
150 /* Number of types of groups supported by ofp12_group_features_stats. */
151 #define OFPGT12_N_TYPES 4
152
153 /* Body of reply to OFPST12_GROUP_FEATURES request. Group features. */
154 struct ofp12_group_features_stats {
155     ovs_be32  types;           /* Bitmap of OFPGT11_* values supported. */
156     ovs_be32  capabilities;    /* Bitmap of OFPGFC12_* capability supported. */
157
158     /* Each element in the following arrays corresponds to the group type with
159      * the same number, e.g. max_groups[0] is the maximum number of OFPGT11_ALL
160      * groups, actions[2] is the actions supported by OFPGT11_INDIRECT
161      * groups. */
162     ovs_be32  max_groups[OFPGT12_N_TYPES]; /* Max number of groups. */
163     ovs_be32  actions[OFPGT12_N_TYPES];    /* Bitmaps of supported OFPAT_*. */
164 };
165 OFP_ASSERT(sizeof(struct ofp12_group_features_stats) == 40);
166
167 /* Group configuration flags */
168 enum ofp12_group_capabilities {
169     OFPGFC12_SELECT_WEIGHT   = 1 << 0, /* Support weight for select groups */
170     OFPGFC12_SELECT_LIVENESS = 1 << 1, /* Support liveness for select groups */
171     OFPGFC12_CHAINING        = 1 << 2, /* Support chaining groups */
172     OFPGFC12_CHAINING_CHECKS = 1 << 3, /* Check chaining for loops and delete */
173 };
174
175 /* Body for ofp12_stats_request/reply of type OFPST_EXPERIMENTER. */
176 struct ofp12_experimenter_stats_header {
177     ovs_be32 experimenter;    /* Experimenter ID which takes the same form
178                                  as in struct ofp_experimenter_header. */
179     ovs_be32 exp_type;        /* Experimenter defined. */
180     /* Experimenter-defined arbitrary additional data. */
181 };
182 OFP_ASSERT(sizeof(struct ofp12_experimenter_stats_header) == 8);
183
184 /* Role request and reply message. */
185 struct ofp12_role_request {
186     ovs_be32 role;            /* One of OFPCR12_ROLE_*. */
187     uint8_t pad[4];           /* Align to 64 bits. */
188     ovs_be64 generation_id;   /* Master Election Generation Id */
189 };
190 OFP_ASSERT(sizeof(struct ofp12_role_request) == 16);
191
192 /* Controller roles. */
193 enum ofp12_controller_role {
194     OFPCR12_ROLE_NOCHANGE,    /* Don't change current role. */
195     OFPCR12_ROLE_EQUAL,       /* Default role, full access. */
196     OFPCR12_ROLE_MASTER,      /* Full access, at most one master. */
197     OFPCR12_ROLE_SLAVE,       /* Read-only access. */
198 };
199
200 /* Packet received on port (datapath -> controller). */
201 struct ofp12_packet_in {
202     ovs_be32 buffer_id;     /* ID assigned by datapath. */
203     ovs_be16 total_len;     /* Full length of frame. */
204     uint8_t reason;         /* Reason packet is being sent (one of OFPR_*) */
205     uint8_t table_id;       /* ID of the table that was looked up */
206     /* Followed by:
207      *   - Match
208      *   - Exactly 2 all-zero padding bytes, then
209      *   - An Ethernet frame whose length is inferred from header.length.
210      * The padding bytes preceding the Ethernet frame ensure that the IP
211      * header (if any) following the Ethernet header is 32-bit aligned.
212      */
213     /* struct ofp12_match match; */
214     /* uint8_t pad[2];         Align to 64 bit + 16 bit */
215     /* uint8_t data[0];        Ethernet frame */
216 };
217 OFP_ASSERT(sizeof(struct ofp12_packet_in) == 8);
218
219 /* Flow removed (datapath -> controller). */
220 struct ofp12_flow_removed {
221     ovs_be64 cookie;          /* Opaque controller-issued identifier. */
222
223     ovs_be16 priority;        /* Priority level of flow entry. */
224     uint8_t reason;           /* One of OFPRR_*. */
225     uint8_t table_id;         /* ID of the table */
226
227     ovs_be32 duration_sec;    /* Time flow was alive in seconds. */
228     ovs_be32 duration_nsec;   /* Time flow was alive in nanoseconds beyond
229                                  duration_sec. */
230     ovs_be16 idle_timeout;    /* Idle timeout from original flow mod. */
231     ovs_be16 hard_timeout;    /* Hard timeout from original flow mod. */
232     ovs_be64 packet_count;
233     ovs_be64 byte_count;
234     /* struct ofp12_match match;  Description of fields. Variable size. */
235 };
236 OFP_ASSERT(sizeof(struct ofp12_flow_removed) == 40);
237
238 #endif /* openflow/openflow-1.2.h */