567aaaea9c4d774e063196b47154374a38acdd1e
[cascardo/ovs.git] / include / openflow / openflow-1.4.h
1 /* Copyright (c) 2008, 2014 The Board of Trustees of The Leland Stanford
2 * Junior University
3 * Copyright (c) 2011, 2012 Open Networking Foundation
4 *
5 * We are making the OpenFlow specification and associated documentation
6 * (Software) available for public use and benefit with the expectation
7 * that others will use, modify and enhance the Software and contribute
8 * those enhancements back to the community. However, since we would
9 * like to make the Software available for broadest use, with as few
10 * restrictions as possible permission is hereby granted, free of
11 * charge, to any person obtaining a copy of this Software to deal in
12 * the Software under the copyrights without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 * SOFTWARE.
29 *
30 * The name and trademarks of copyright holder(s) may NOT be used in
31 * advertising or publicity pertaining to the Software or any
32 * derivatives without specific, written prior permission.
33 */
34
35 /* OpenFlow: protocol between controller and datapath. */
36
37 #ifndef OPENFLOW_14_H
38 #define OPENFLOW_14_H 1
39
40 #include <openflow/openflow-1.3.h>
41
42
43 /* ## ---------- ## */
44 /* ## ofp14_port ## */
45 /* ## ---------- ## */
46
47 /* Port description property types. */
48 enum ofp_port_desc_prop_type {
49     OFPPDPT14_ETHERNET          = 0,      /* Ethernet property. */
50     OFPPDPT14_OPTICAL           = 1,      /* Optical property. */
51     OFPPDPT14_EXPERIMENTER      = 0xFFFF, /* Experimenter property. */
52 };
53
54 /* Ethernet port description property. */
55 struct ofp14_port_desc_prop_ethernet {
56     ovs_be16         type;    /* OFPPDPT14_ETHERNET. */
57     ovs_be16         length;  /* Length in bytes of this property. */
58     uint8_t          pad[4];  /* Align to 64 bits. */
59     /* Bitmaps of OFPPF_* that describe features.  All bits zeroed if
60      * unsupported or unavailable. */
61     ovs_be32 curr;          /* Current features. */
62     ovs_be32 advertised;    /* Features being advertised by the port. */
63     ovs_be32 supported;     /* Features supported by the port. */
64     ovs_be32 peer;          /* Features advertised by peer. */
65
66     ovs_be32 curr_speed;    /* Current port bitrate in kbps. */
67     ovs_be32 max_speed;     /* Max port bitrate in kbps */
68 };
69 OFP_ASSERT(sizeof(struct ofp14_port_desc_prop_ethernet) == 32);
70
71 struct ofp14_port {
72     ovs_be32 port_no;
73     ovs_be16 length;
74     uint8_t pad[2];
75     uint8_t hw_addr[OFP_ETH_ALEN];
76     uint8_t pad2[2];                  /* Align to 64 bits. */
77     char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
78
79     ovs_be32 config;        /* Bitmap of OFPPC_* flags. */
80     ovs_be32 state;         /* Bitmap of OFPPS_* flags. */
81
82     /* Followed by 0 or more OFPPDPT14_* properties. */
83 };
84 OFP_ASSERT(sizeof(struct ofp14_port) == 40);
85
86
87 /* ## -------------- ## */
88 /* ## ofp14_port_mod ## */
89 /* ## -------------- ## */
90
91 enum ofp14_port_mod_prop_type {
92     OFPPMPT14_ETHERNET          = 0,      /* Ethernet property. */
93     OFPPMPT14_OPTICAL           = 1,      /* Optical property. */
94     OFPPMPT14_EXPERIMENTER      = 0xFFFF, /* Experimenter property. */
95 };
96
97 /* Ethernet port mod property. */
98 struct ofp14_port_mod_prop_ethernet {
99     ovs_be16      type;       /* OFPPMPT14_ETHERNET. */
100     ovs_be16      length;     /* Length in bytes of this property. */
101     ovs_be32      advertise;  /* Bitmap of OFPPF_*.  Zero all bits to prevent
102                                  any action taking place. */
103 };
104 OFP_ASSERT(sizeof(struct ofp14_port_mod_prop_ethernet) == 8);
105
106 struct ofp14_port_mod {
107     ovs_be32 port_no;
108     uint8_t pad[4];
109     uint8_t hw_addr[OFP_ETH_ALEN];
110     uint8_t pad2[2];
111     ovs_be32 config;        /* Bitmap of OFPPC_* flags. */
112     ovs_be32 mask;          /* Bitmap of OFPPC_* flags to be changed. */
113     /* Followed by 0 or more OFPPMPT14_* properties. */
114 };
115 OFP_ASSERT(sizeof(struct ofp14_port_mod) == 24);
116
117 /* ## --------------- ## */
118 /* ## ofp14_table_mod ## */
119 /* ## --------------- ## */
120
121 enum ofp14_table_mod_prop_type {
122     OFPTMPT14_EVICTION               = 0x2,    /* Eviction property. */
123     OFPTMPT14_VACANCY                = 0x3,    /* Vacancy property. */
124     OFPTMPT14_EXPERIMENTER           = 0xFFFF, /* Experimenter property. */
125 };
126
127 enum ofp14_table_mod_prop_eviction_flag {
128     OFPTMPEF14_OTHER           = 1 << 0,     /* Using other factors. */
129     OFPTMPEF14_IMPORTANCE      = 1 << 1,     /* Using flow entry importance. */
130     OFPTMPEF14_LIFETIME        = 1 << 2,     /* Using flow entry lifetime. */
131 };
132
133 struct ofp14_table_mod_prop_eviction {
134     ovs_be16         type;    /* OFPTMPT14_EVICTION. */
135     ovs_be16         length;  /* Length in bytes of this property. */
136     ovs_be32         flags;   /* Bitmap of OFPTMPEF14_* flags */
137 };
138 OFP_ASSERT(sizeof(struct ofp14_table_mod_prop_eviction) == 8);
139
140 struct ofp14_table_mod_prop_vacancy {
141     ovs_be16         type;   /* OFPTMPT14_VACANCY. */
142     ovs_be16         length; /* Length in bytes of this property. */
143     uint8_t vacancy_down;    /* Vacancy threshold when space decreases (%). */
144     uint8_t vacancy_up;      /* Vacancy threshold when space increases (%). */
145     uint8_t vacancy;      /* Current vacancy (%) - only in ofp14_table_desc. */
146     uint8_t pad[1];          /* Align to 64 bits. */
147 };
148 OFP_ASSERT(sizeof(struct ofp14_table_mod_prop_vacancy) == 8);
149
150 struct ofp14_table_mod {
151     uint8_t table_id;     /* ID of the table, OFPTT_ALL indicates all tables */
152     uint8_t pad[3];         /* Pad to 32 bits */
153     ovs_be32 config;        /* Bitmap of OFPTC_* flags */
154     /* Followed by 0 or more OFPTMPT14_* properties. */
155 };
156 OFP_ASSERT(sizeof(struct ofp14_table_mod) == 8);
157
158 /* Body of reply to OFPMP_TABLE_DESC request. */
159 struct ofp14_table_desc {
160     ovs_be16 length;       /* Length is padded to 64 bits. */
161     uint8_t table_id;      /* Identifier of table. Lower numbered tables
162                               are consulted first. */
163     uint8_t pad[1];        /* Align to 32-bits. */
164     ovs_be32 config;       /* Bitmap of OFPTC_* values. */
165     /* Followed by 0 or more OFPTMPT14_* properties. */
166 };
167 OFP_ASSERT(sizeof(struct ofp14_table_desc) == 8);
168
169 /* ## ---------------- ## */
170 /* ## ofp14_port_stats ## */
171 /* ## ---------------- ## */
172
173 enum ofp14_port_stats_prop_type {
174     OFPPSPT14_ETHERNET          = 0,      /* Ethernet property. */
175     OFPPSPT14_OPTICAL           = 1,      /* Optical property. */
176     OFPPSPT14_EXPERIMENTER      = 0xFFFF, /* Experimenter property. */
177 };
178
179 struct ofp14_port_stats_prop_ethernet {
180     ovs_be16         type;    /* OFPPSPT14_ETHERNET. */
181     ovs_be16         length;  /* Length in bytes of this property. */
182     uint8_t          pad[4];  /* Align to 64 bits. */
183
184     ovs_be64 rx_frame_err;   /* Number of frame alignment errors. */
185     ovs_be64 rx_over_err;    /* Number of packets with RX overrun. */
186     ovs_be64 rx_crc_err;     /* Number of CRC errors. */
187     ovs_be64 collisions;     /* Number of collisions. */
188 };
189 OFP_ASSERT(sizeof(struct ofp14_port_stats_prop_ethernet) == 40);
190
191 struct ofp14_port_stats {
192     ovs_be16 length;         /* Length of this entry. */
193     uint8_t pad[2];          /* Align to 64 bits. */
194     ovs_be32 port_no;
195     ovs_be32 duration_sec;   /* Time port has been alive in seconds. */
196     ovs_be32 duration_nsec;  /* Time port has been alive in nanoseconds beyond
197                                 duration_sec. */
198     ovs_be64 rx_packets;     /* Number of received packets. */
199     ovs_be64 tx_packets;     /* Number of transmitted packets. */
200     ovs_be64 rx_bytes;       /* Number of received bytes. */
201     ovs_be64 tx_bytes;       /* Number of transmitted bytes. */
202
203     ovs_be64 rx_dropped;     /* Number of packets dropped by RX. */
204     ovs_be64 tx_dropped;     /* Number of packets dropped by TX. */
205     ovs_be64 rx_errors;      /* Number of receive errors.  This is a super-set
206                                 of more specific receive errors and should be
207                                 greater than or equal to the sum of all
208                                 rx_*_err values in properties. */
209     ovs_be64 tx_errors;      /* Number of transmit errors.  This is a super-set
210                                 of more specific transmit errors and should be
211                                 greater than or equal to the sum of all
212                                 tx_*_err values (none currently defined.) */
213     /* Followed by 0 or more OFPPSPT14_* properties. */
214 };
215 OFP_ASSERT(sizeof(struct ofp14_port_stats) == 80);
216
217
218 /* ## ----------------- ## */
219 /* ## ofp14_queue_stats ## */
220 /* ## ----------------- ## */
221
222 struct ofp14_queue_stats {
223     ovs_be16 length;         /* Length of this entry. */
224     uint8_t pad[6];          /* Align to 64 bits. */
225     struct ofp13_queue_stats qs;
226     /* Followed by 0 or more properties (none yet defined). */
227 };
228 OFP_ASSERT(sizeof(struct ofp14_queue_stats) == 48);
229
230
231 /* ## -------------- ## */
232 /* ## Miscellaneous. ## */
233 /* ## -------------- ## */
234
235 /* Common header for all async config Properties */
236 struct ofp14_async_config_prop_header {
237     ovs_be16    type;       /* One of OFPACPT_*. */
238     ovs_be16    length;     /* Length in bytes of this property. */
239 };
240 OFP_ASSERT(sizeof(struct ofp14_async_config_prop_header) == 4);
241
242 /* Asynchronous message configuration.
243  * OFPT_GET_ASYNC_REPLY or OFPT_SET_ASYNC.
244  */
245 struct ofp14_async_config {
246     struct ofp_header header;
247     /* Async config Property list - 0 or more */
248     struct ofp14_async_config_prop_header properties[0];
249 };
250 OFP_ASSERT(sizeof(struct ofp14_async_config) == 8);
251
252 /* Async Config property types.
253 * Low order bit cleared indicates a property for the slave role.
254 * Low order bit set indicates a property for the master/equal role.
255 */
256 enum ofp14_async_config_prop_type {
257     OFPACPT_PACKET_IN_SLAVE       = 0, /* Packet-in mask for slave. */
258     OFPACPT_PACKET_IN_MASTER      = 1, /* Packet-in mask for master. */
259     OFPACPT_PORT_STATUS_SLAVE     = 2, /* Port-status mask for slave. */
260     OFPACPT_PORT_STATUS_MASTER    = 3, /* Port-status mask for master. */
261     OFPACPT_FLOW_REMOVED_SLAVE    = 4, /* Flow removed mask for slave. */
262     OFPACPT_FLOW_REMOVED_MASTER   = 5, /* Flow removed mask for master. */
263     OFPACPT_ROLE_STATUS_SLAVE     = 6, /* Role status mask for slave. */
264     OFPACPT_ROLE_STATUS_MASTER    = 7, /* Role status mask for master. */
265     OFPACPT_TABLE_STATUS_SLAVE    = 8, /* Table status mask for slave. */
266     OFPACPT_TABLE_STATUS_MASTER   = 9, /* Table status mask for master. */
267     OFPACPT_REQUESTFORWARD_SLAVE  = 10, /* RequestForward mask for slave. */
268     OFPACPT_REQUESTFORWARD_MASTER = 11, /* RequestForward mask for master. */
269     OFPTFPT_EXPERIMENTER_SLAVE    = 0xFFFE, /* Experimenter for slave. */
270     OFPTFPT_EXPERIMENTER_MASTER   = 0xFFFF, /* Experimenter for master. */
271 };
272
273 /* Various reason based properties */
274 struct ofp14_async_config_prop_reasons {
275     /* 'type' is one of OFPACPT_PACKET_IN_*, OFPACPT_PORT_STATUS_*,
276      * OFPACPT_FLOW_REMOVED_*, OFPACPT_ROLE_STATUS_*,
277      * OFPACPT_TABLE_STATUS_*, OFPACPT_REQUESTFORWARD_*. */
278     ovs_be16    type;
279     ovs_be16    length; /* Length in bytes of this property. */
280     ovs_be32    mask;   /* Bitmasks of reason values. */
281 };
282 OFP_ASSERT(sizeof(struct ofp14_async_config_prop_reasons) == 8);
283
284 /* Experimenter async config property */
285 struct ofp14_async_config_prop_experimenter {
286     ovs_be16        type;       /* One of OFPTFPT_EXPERIMENTER_SLAVE,
287                                    OFPTFPT_EXPERIMENTER_MASTER. */
288     ovs_be16        length;     /* Length in bytes of this property. */
289     ovs_be32        experimenter;  /* Experimenter ID which takes the same
290                                       form as in struct
291                                       ofp_experimenter_header. */
292     ovs_be32        exp_type;      /* Experimenter defined. */
293     /* Followed by:
294      *   - Exactly (length - 12) bytes containing the experimenter data, then
295      *   - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
296      *     bytes of all-zero bytes */
297 };
298 OFP_ASSERT(sizeof(struct ofp14_async_config_prop_experimenter) == 12);
299
300 /* Common header for all Role Properties */
301 struct ofp14_role_prop_header {
302     ovs_be16 type;   /* One of OFPRPT_*. */
303     ovs_be16 length; /* Length in bytes of this property. */
304 };
305 OFP_ASSERT(sizeof(struct ofp14_role_prop_header) == 4);
306
307 /* Role status event message. */
308 struct ofp14_role_status {
309     ovs_be32 role;              /* One of OFPCR_ROLE_*. */
310     uint8_t  reason;            /* One of OFPCRR_*. */
311     uint8_t  pad[3];            /* Align to 64 bits. */
312     ovs_be64 generation_id;     /* Master Election Generation Id */
313
314     /* Followed by a list of struct ofp14_role_prop_header */
315 };
316 OFP_ASSERT(sizeof(struct ofp14_role_status) == 16);
317
318 /* What changed about the controller role */
319 enum ofp14_controller_role_reason {
320     OFPCRR_MASTER_REQUEST = 0,  /* Another controller asked to be master. */
321     OFPCRR_CONFIG         = 1,  /* Configuration changed on the switch. */
322     OFPCRR_EXPERIMENTER   = 2,  /* Experimenter data changed. */
323 };
324
325 /* Role property types.
326 */
327 enum ofp14_role_prop_type {
328     OFPRPT_EXPERIMENTER         = 0xFFFF, /* Experimenter property. */
329 };
330
331 /* Experimenter role property */
332 struct ofp14_role_prop_experimenter {
333     ovs_be16        type;       /* One of OFPRPT_EXPERIMENTER. */
334     ovs_be16        length;     /* Length in bytes of this property. */
335     ovs_be32        experimenter; /* Experimenter ID which takes the same
336                                      form as in struct
337                                      ofp_experimenter_header. */
338     ovs_be32        exp_type;     /* Experimenter defined. */
339     /* Followed by:
340      *   - Exactly (length - 12) bytes containing the experimenter data, then
341      *   - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
342      *     bytes of all-zero bytes */
343 };
344 OFP_ASSERT(sizeof(struct ofp14_role_prop_experimenter) == 12);
345
346 /* Bundle control message types */
347 enum ofp14_bundle_ctrl_type {
348     OFPBCT_OPEN_REQUEST    = 0,
349     OFPBCT_OPEN_REPLY      = 1,
350     OFPBCT_CLOSE_REQUEST   = 2,
351     OFPBCT_CLOSE_REPLY     = 3,
352     OFPBCT_COMMIT_REQUEST  = 4,
353     OFPBCT_COMMIT_REPLY    = 5,
354     OFPBCT_DISCARD_REQUEST = 6,
355     OFPBCT_DISCARD_REPLY   = 7,
356 };
357
358 /* Bundle configuration flags. */
359 enum ofp14_bundle_flags {
360     OFPBF_ATOMIC  = 1 << 0,  /* Execute atomically. */
361     OFPBF_ORDERED = 1 << 1,  /* Execute in specified order. */
362 };
363
364 /* Message structure for OFPT_BUNDLE_CONTROL and OFPT_BUNDLE_ADD_MESSAGE. */
365 struct ofp14_bundle_ctrl_msg {
366     ovs_be32 bundle_id;     /* Identify the bundle. */
367     ovs_be16 type;          /* OFPT_BUNDLE_CONTROL: one of OFPBCT_*.
368                              * OFPT_BUNDLE_ADD_MESSAGE: not used. */
369     ovs_be16 flags;         /* Bitmap of OFPBF_* flags. */
370     /* Followed by:
371      * - For OFPT_BUNDLE_ADD_MESSAGE only, an encapsulated OpenFlow message,
372      *   beginning with an ofp_header whose xid is identical to this message's
373      *   outer xid.
374      * - For OFPT_BUNDLE_ADD_MESSAGE only, and only if at least one property is
375      *   present, 0 to 7 bytes of padding to align on a 64-bit boundary.
376      * - Zero or more properties (see struct ofp14_bundle_prop_header). */
377 };
378 OFP_ASSERT(sizeof(struct ofp14_bundle_ctrl_msg) == 8);
379
380 /* Body for ofp14_multipart_request of type OFPMP_FLOW_MONITOR.
381  *
382  * The OFPMP_FLOW_MONITOR request's body consists of an array of zero or more
383  * instances of this structure. The request arranges to monitor the flows
384  * that match the specified criteria, which are interpreted in the same way as
385  * for OFPMP_FLOW.
386  *
387  * 'id' identifies a particular monitor for the purpose of allowing it to be
388  * canceled later with OFPFMC_DELETE. 'id' must be unique among
389  * existing monitors that have not already been canceled.
390  */
391 struct ofp14_flow_monitor_request {
392     ovs_be32 monitor_id;        /* Controller-assigned ID for this monitor. */
393     ovs_be32 out_port;          /* Required output port, if not OFPP_ANY. */
394     ovs_be32 out_group;         /* Required output port, if not OFPG_ANY. */
395     ovs_be16 flags;             /* OFPMF14_*. */
396     uint8_t table_id;           /* One table's ID or OFPTT_ALL (all tables). */
397     uint8_t command;            /* One of OFPFMC14_*. */
398     /* Followed by an ofp11_match structure. */
399 };
400 OFP_ASSERT(sizeof(struct ofp14_flow_monitor_request) == 16);
401
402 /* Flow monitor commands */
403 enum ofp14_flow_monitor_command {
404     OFPFMC14_ADD = 0, /* New flow monitor. */
405     OFPFMC14_MODIFY = 1, /* Modify existing flow monitor. */
406     OFPFMC14_DELETE = 2, /* Delete/cancel existing flow monitor. */
407 };
408
409 /* 'flags' bits in struct of_flow_monitor_request. */
410 enum ofp14_flow_monitor_flags {
411     /* When to send updates. */
412     /* Common to NX and OpenFlow 1.4 */
413     OFPFMF14_INITIAL = 1 << 0,     /* Initially matching flows. */
414     OFPFMF14_ADD = 1 << 1,         /* New matching flows as they are added. */
415     OFPFMF14_REMOVED = 1 << 2,     /* Old matching flows as they are removed. */
416     OFPFMF14_MODIFY = 1 << 3,      /* Matching flows as they are changed. */
417
418     /* What to include in updates. */
419     /* Common to NX and OpenFlow 1.4 */
420     OFPFMF14_INSTRUCTIONS = 1 << 4, /* If set, instructions are included. */
421     OFPFMF14_NO_ABBREV = 1 << 5,    /* If set, include own changes in full. */
422     /* OpenFlow 1.4 */
423     OFPFMF14_ONLY_OWN = 1 << 6,     /* If set, don't include other controllers.
424                                      */
425 };
426
427 #endif /* openflow/openflow-1.4.h */