Implement OFPT_TABLE_STATUS Message.
[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     struct eth_addr hw_addr;
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 struct ofp14_port_mod {
98     ovs_be32 port_no;
99     uint8_t pad[4];
100     struct eth_addr hw_addr;
101     uint8_t pad2[2];
102     ovs_be32 config;        /* Bitmap of OFPPC_* flags. */
103     ovs_be32 mask;          /* Bitmap of OFPPC_* flags to be changed. */
104     /* Followed by 0 or more OFPPMPT14_* properties. */
105 };
106 OFP_ASSERT(sizeof(struct ofp14_port_mod) == 24);
107
108 /* ## --------------- ## */
109 /* ## ofp14_table_mod ## */
110 /* ## --------------- ## */
111
112 enum ofp14_table_mod_prop_type {
113     OFPTMPT14_EVICTION               = 0x2,    /* Eviction property. */
114     OFPTMPT14_VACANCY                = 0x3,    /* Vacancy property. */
115     OFPTMPT14_EXPERIMENTER           = 0xFFFF, /* Experimenter property. */
116 };
117
118 enum ofp14_table_mod_prop_eviction_flag {
119     OFPTMPEF14_OTHER           = 1 << 0,     /* Using other factors. */
120     OFPTMPEF14_IMPORTANCE      = 1 << 1,     /* Using flow entry importance. */
121     OFPTMPEF14_LIFETIME        = 1 << 2,     /* Using flow entry lifetime. */
122 };
123
124 /* What changed about the table */
125 enum ofp14_table_reason {
126     OFPTR_VACANCY_DOWN = 3,    /* Vacancy down threshold event. */
127     OFPTR_VACANCY_UP   = 4,    /* Vacancy up threshold event. */
128 #define OFPTR_BITS ((1u << OFPTR_VACANCY_DOWN) | (1u << OFPTR_VACANCY_UP))
129 };
130
131 struct ofp14_table_mod_prop_vacancy {
132     ovs_be16         type;   /* OFPTMPT14_VACANCY. */
133     ovs_be16         length; /* Length in bytes of this property. */
134     uint8_t vacancy_down;    /* Vacancy threshold when space decreases (%). */
135     uint8_t vacancy_up;      /* Vacancy threshold when space increases (%). */
136     uint8_t vacancy;      /* Current vacancy (%) - only in ofp14_table_desc. */
137     uint8_t pad[1];          /* Align to 64 bits. */
138 };
139 OFP_ASSERT(sizeof(struct ofp14_table_mod_prop_vacancy) == 8);
140
141 struct ofp14_table_mod {
142     uint8_t table_id;     /* ID of the table, OFPTT_ALL indicates all tables */
143     uint8_t pad[3];         /* Pad to 32 bits */
144     ovs_be32 config;        /* Bitmap of OFPTC_* flags */
145     /* Followed by 0 or more OFPTMPT14_* properties. */
146 };
147 OFP_ASSERT(sizeof(struct ofp14_table_mod) == 8);
148
149 /* Body of reply to OFPMP_TABLE_DESC request. */
150 struct ofp14_table_desc {
151     ovs_be16 length;       /* Length is padded to 64 bits. */
152     uint8_t table_id;      /* Identifier of table. Lower numbered tables
153                               are consulted first. */
154     uint8_t pad[1];        /* Align to 32-bits. */
155     ovs_be32 config;       /* Bitmap of OFPTC_* values. */
156     /* Followed by 0 or more OFPTMPT14_* properties. */
157 };
158 OFP_ASSERT(sizeof(struct ofp14_table_desc) == 8);
159
160 /* A table config has changed in the datapath */
161 struct ofp14_table_status {
162     uint8_t reason;    /* One of OFPTR_*. */
163     uint8_t pad[7];    /* Pad to 64 bits */
164     /* Followed by struct ofp14_table_desc */
165 };
166 OFP_ASSERT(sizeof(struct ofp14_table_status) == 8);
167
168 /* ## ---------------- ## */
169 /* ## ofp14_port_stats ## */
170 /* ## ---------------- ## */
171
172 enum ofp14_port_stats_prop_type {
173     OFPPSPT14_ETHERNET          = 0,      /* Ethernet property. */
174     OFPPSPT14_OPTICAL           = 1,      /* Optical property. */
175     OFPPSPT14_EXPERIMENTER      = 0xFFFF, /* Experimenter property. */
176 };
177
178 struct ofp14_port_stats_prop_ethernet {
179     ovs_be16         type;    /* OFPPSPT14_ETHERNET. */
180     ovs_be16         length;  /* Length in bytes of this property. */
181     uint8_t          pad[4];  /* Align to 64 bits. */
182
183     ovs_be64 rx_frame_err;   /* Number of frame alignment errors. */
184     ovs_be64 rx_over_err;    /* Number of packets with RX overrun. */
185     ovs_be64 rx_crc_err;     /* Number of CRC errors. */
186     ovs_be64 collisions;     /* Number of collisions. */
187 };
188 OFP_ASSERT(sizeof(struct ofp14_port_stats_prop_ethernet) == 40);
189
190 struct ofp14_port_stats {
191     ovs_be16 length;         /* Length of this entry. */
192     uint8_t pad[2];          /* Align to 64 bits. */
193     ovs_be32 port_no;
194     ovs_be32 duration_sec;   /* Time port has been alive in seconds. */
195     ovs_be32 duration_nsec;  /* Time port has been alive in nanoseconds beyond
196                                 duration_sec. */
197     ovs_be64 rx_packets;     /* Number of received packets. */
198     ovs_be64 tx_packets;     /* Number of transmitted packets. */
199     ovs_be64 rx_bytes;       /* Number of received bytes. */
200     ovs_be64 tx_bytes;       /* Number of transmitted bytes. */
201
202     ovs_be64 rx_dropped;     /* Number of packets dropped by RX. */
203     ovs_be64 tx_dropped;     /* Number of packets dropped by TX. */
204     ovs_be64 rx_errors;      /* Number of receive errors.  This is a super-set
205                                 of more specific receive errors and should be
206                                 greater than or equal to the sum of all
207                                 rx_*_err values in properties. */
208     ovs_be64 tx_errors;      /* Number of transmit errors.  This is a super-set
209                                 of more specific transmit errors and should be
210                                 greater than or equal to the sum of all
211                                 tx_*_err values (none currently defined.) */
212     /* Followed by 0 or more OFPPSPT14_* properties. */
213 };
214 OFP_ASSERT(sizeof(struct ofp14_port_stats) == 80);
215
216
217 /* ## ----------------- ## */
218 /* ## ofp14_queue_stats ## */
219 /* ## ----------------- ## */
220
221 struct ofp14_queue_stats {
222     ovs_be16 length;         /* Length of this entry. */
223     uint8_t pad[6];          /* Align to 64 bits. */
224     struct ofp13_queue_stats qs;
225     /* Followed by 0 or more properties (none yet defined). */
226 };
227 OFP_ASSERT(sizeof(struct ofp14_queue_stats) == 48);
228
229
230 /* ## ---------------- ## */
231 /* ## ofp14_queue_desc ## */
232 /* ## ---------------- ## */
233
234 struct ofp14_queue_desc_request {
235     ovs_be32 port;              /* All ports if OFPP_ANY. */
236     ovs_be32 queue;             /* All queues if OFPQ_ALL. */
237 };
238 OFP_ASSERT(sizeof(struct ofp14_queue_desc_request) == 8);
239
240 /* Body of reply to OFPMP_QUEUE_DESC request. */
241 struct ofp14_queue_desc {
242     ovs_be32 port_no;           /* Port this queue is attached to. */
243     ovs_be32 queue_id;          /* ID for the specific queue. */
244     ovs_be16 len;               /* Length in bytes of this queue desc. */
245     uint8_t pad[6];             /* 64-bit alignment. */
246 };
247 OFP_ASSERT(sizeof(struct ofp14_queue_desc) == 16);
248
249 enum ofp14_queue_desc_prop_type {
250     OFPQDPT14_MIN_RATE = 1,
251     OFPQDPT14_MAX_RATE = 2,
252     OFPQDPT14_EXPERIMENTER = 0xffff
253 };
254
255 /* ## -------------- ## */
256 /* ## Miscellaneous. ## */
257 /* ## -------------- ## */
258
259 /* Request forward reason */
260 enum ofp14_requestforward_reason {
261     OFPRFR_GROUP_MOD = 0,      /* Forward group mod requests. */
262     OFPRFR_METER_MOD = 1,      /* Forward meter mod requests. */
263     OFPRFR_N_REASONS           /* Denotes number of reasons. */
264 };
265
266 /* Role status event message. */
267 struct ofp14_role_status {
268     ovs_be32 role;              /* One of OFPCR_ROLE_*. */
269     uint8_t  reason;            /* One of OFPCRR_*. */
270     uint8_t  pad[3];            /* Align to 64 bits. */
271     ovs_be64 generation_id;     /* Master Election Generation Id */
272
273     /* Followed by a list of struct ofp14_role_prop_header */
274 };
275 OFP_ASSERT(sizeof(struct ofp14_role_status) == 16);
276
277 /* What changed about the controller role */
278 enum ofp14_controller_role_reason {
279     OFPCRR_MASTER_REQUEST = 0,  /* Another controller asked to be master. */
280     OFPCRR_CONFIG         = 1,  /* Configuration changed on the switch. */
281     OFPCRR_EXPERIMENTER   = 2,  /* Experimenter data changed. */
282     OFPCRR_N_REASONS            /* Denotes number of reasons. */
283 };
284
285 /* Role property types.
286 */
287 enum ofp14_role_prop_type {
288     OFPRPT_EXPERIMENTER         = 0xFFFF, /* Experimenter property. */
289 };
290
291 /* Group/Meter request forwarding. */
292 struct ofp14_requestforward {
293     struct ofp_header request;  /* Request being forwarded. */
294 };
295 OFP_ASSERT(sizeof(struct ofp14_requestforward) == 8);
296
297 /* Bundle control message types */
298 enum ofp14_bundle_ctrl_type {
299     OFPBCT_OPEN_REQUEST    = 0,
300     OFPBCT_OPEN_REPLY      = 1,
301     OFPBCT_CLOSE_REQUEST   = 2,
302     OFPBCT_CLOSE_REPLY     = 3,
303     OFPBCT_COMMIT_REQUEST  = 4,
304     OFPBCT_COMMIT_REPLY    = 5,
305     OFPBCT_DISCARD_REQUEST = 6,
306     OFPBCT_DISCARD_REPLY   = 7,
307 };
308
309 /* Bundle configuration flags. */
310 enum ofp14_bundle_flags {
311     OFPBF_ATOMIC  = 1 << 0,  /* Execute atomically. */
312     OFPBF_ORDERED = 1 << 1,  /* Execute in specified order. */
313 };
314
315 /* Message structure for OFPT_BUNDLE_CONTROL and OFPT_BUNDLE_ADD_MESSAGE. */
316 struct ofp14_bundle_ctrl_msg {
317     ovs_be32 bundle_id;     /* Identify the bundle. */
318     ovs_be16 type;          /* OFPT_BUNDLE_CONTROL: one of OFPBCT_*.
319                              * OFPT_BUNDLE_ADD_MESSAGE: not used. */
320     ovs_be16 flags;         /* Bitmap of OFPBF_* flags. */
321     /* Followed by:
322      * - For OFPT_BUNDLE_ADD_MESSAGE only, an encapsulated OpenFlow message,
323      *   beginning with an ofp_header whose xid is identical to this message's
324      *   outer xid.
325      * - For OFPT_BUNDLE_ADD_MESSAGE only, and only if at least one property is
326      *   present, 0 to 7 bytes of padding to align on a 64-bit boundary.
327      * - Zero or more properties (see struct ofp14_bundle_prop_header). */
328 };
329 OFP_ASSERT(sizeof(struct ofp14_bundle_ctrl_msg) == 8);
330
331 /* Body for ofp14_multipart_request of type OFPMP_FLOW_MONITOR.
332  *
333  * The OFPMP_FLOW_MONITOR request's body consists of an array of zero or more
334  * instances of this structure. The request arranges to monitor the flows
335  * that match the specified criteria, which are interpreted in the same way as
336  * for OFPMP_FLOW.
337  *
338  * 'id' identifies a particular monitor for the purpose of allowing it to be
339  * canceled later with OFPFMC_DELETE. 'id' must be unique among
340  * existing monitors that have not already been canceled.
341  */
342 struct ofp14_flow_monitor_request {
343     ovs_be32 monitor_id;        /* Controller-assigned ID for this monitor. */
344     ovs_be32 out_port;          /* Required output port, if not OFPP_ANY. */
345     ovs_be32 out_group;         /* Required output port, if not OFPG_ANY. */
346     ovs_be16 flags;             /* OFPMF14_*. */
347     uint8_t table_id;           /* One table's ID or OFPTT_ALL (all tables). */
348     uint8_t command;            /* One of OFPFMC14_*. */
349     /* Followed by an ofp11_match structure. */
350 };
351 OFP_ASSERT(sizeof(struct ofp14_flow_monitor_request) == 16);
352
353 /* Flow monitor commands */
354 enum ofp14_flow_monitor_command {
355     OFPFMC14_ADD = 0, /* New flow monitor. */
356     OFPFMC14_MODIFY = 1, /* Modify existing flow monitor. */
357     OFPFMC14_DELETE = 2, /* Delete/cancel existing flow monitor. */
358 };
359
360 /* 'flags' bits in struct of_flow_monitor_request. */
361 enum ofp14_flow_monitor_flags {
362     /* When to send updates. */
363     /* Common to NX and OpenFlow 1.4 */
364     OFPFMF14_INITIAL = 1 << 0,     /* Initially matching flows. */
365     OFPFMF14_ADD = 1 << 1,         /* New matching flows as they are added. */
366     OFPFMF14_REMOVED = 1 << 2,     /* Old matching flows as they are removed. */
367     OFPFMF14_MODIFY = 1 << 3,      /* Matching flows as they are changed. */
368
369     /* What to include in updates. */
370     /* Common to NX and OpenFlow 1.4 */
371     OFPFMF14_INSTRUCTIONS = 1 << 4, /* If set, instructions are included. */
372     OFPFMF14_NO_ABBREV = 1 << 5,    /* If set, include own changes in full. */
373     /* OpenFlow 1.4 */
374     OFPFMF14_ONLY_OWN = 1 << 6,     /* If set, don't include other controllers.
375                                      */
376 };
377
378 #endif /* openflow/openflow-1.4.h */