Add basic implementation for OpenFlow 1.4 bundles
[sliver-openvswitch.git] / include / openflow / openflow-1.4.h
1 /* Copyright (c) 2008 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  * OpenFlow 1.4 is more extensible by using TLV structures
43  */
44
45 /* Common header for all async config Properties */
46 struct ofp14_async_config_prop_header {
47     ovs_be16    type;       /* One of OFPACPT_*. */
48     ovs_be16    length;     /* Length in bytes of this property. */
49 };
50 OFP_ASSERT(sizeof(struct ofp14_async_config_prop_header) == 4);
51
52 /* Asynchronous message configuration.
53  * OFPT_GET_ASYNC_REPLY or OFPT_SET_ASYNC.
54  */
55 struct ofp14_async_config {
56     struct ofp_header header;
57     /* Async config Property list - 0 or more */
58     struct ofp14_async_config_prop_header properties[0];
59 };
60 OFP_ASSERT(sizeof(struct ofp14_async_config) == 8);
61
62 /* Async Config property types.
63 * Low order bit cleared indicates a property for the slave role.
64 * Low order bit set indicates a property for the master/equal role.
65 */
66 enum ofp14_async_config_prop_type {
67     OFPACPT_PACKET_IN_SLAVE       = 0, /* Packet-in mask for slave. */
68     OFPACPT_PACKET_IN_MASTER      = 1, /* Packet-in mask for master. */
69     OFPACPT_PORT_STATUS_SLAVE     = 2, /* Port-status mask for slave. */
70     OFPACPT_PORT_STATUS_MASTER    = 3, /* Port-status mask for master. */
71     OFPACPT_FLOW_REMOVED_SLAVE    = 4, /* Flow removed mask for slave. */
72     OFPACPT_FLOW_REMOVED_MASTER   = 5, /* Flow removed mask for master. */
73     OFPACPT_ROLE_STATUS_SLAVE     = 6, /* Role status mask for slave. */
74     OFPACPT_ROLE_STATUS_MASTER    = 7, /* Role status mask for master. */
75     OFPACPT_TABLE_STATUS_SLAVE    = 8, /* Table status mask for slave. */
76     OFPACPT_TABLE_STATUS_MASTER   = 9, /* Table status mask for master. */
77     OFPACPT_REQUESTFORWARD_SLAVE  = 10, /* RequestForward mask for slave. */
78     OFPACPT_REQUESTFORWARD_MASTER = 11, /* RequestForward mask for master. */
79     OFPTFPT_EXPERIMENTER_SLAVE    = 0xFFFE, /* Experimenter for slave. */
80     OFPTFPT_EXPERIMENTER_MASTER   = 0xFFFF, /* Experimenter for master. */
81 };
82
83 /* Various reason based properties */
84 struct ofp14_async_config_prop_reasons {
85     /* 'type' is one of OFPACPT_PACKET_IN_*, OFPACPT_PORT_STATUS_*,
86      * OFPACPT_FLOW_REMOVED_*, OFPACPT_ROLE_STATUS_*,
87      * OFPACPT_TABLE_STATUS_*, OFPACPT_REQUESTFORWARD_*. */
88     ovs_be16    type;
89     ovs_be16    length; /* Length in bytes of this property. */
90     ovs_be32    mask;   /* Bitmasks of reason values. */
91 };
92 OFP_ASSERT(sizeof(struct ofp14_async_config_prop_reasons) == 8);
93
94 /* Experimenter async config property */
95 struct ofp14_async_config_prop_experimenter {
96     ovs_be16        type;       /* One of OFPTFPT_EXPERIMENTER_SLAVE,
97                                    OFPTFPT_EXPERIMENTER_MASTER. */
98     ovs_be16        length;     /* Length in bytes of this property. */
99     ovs_be32        experimenter;  /* Experimenter ID which takes the same
100                                       form as in struct
101                                       ofp_experimenter_header. */
102     ovs_be32        exp_type;      /* Experimenter defined. */
103     /* Followed by:
104      *   - Exactly (length - 12) bytes containing the experimenter data, then
105      *   - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
106      *     bytes of all-zero bytes */
107 };
108 OFP_ASSERT(sizeof(struct ofp14_async_config_prop_experimenter) == 12);
109
110 /* Common header for all Role Properties */
111 struct ofp14_role_prop_header {
112     ovs_be16 type;   /* One of OFPRPT_*. */
113     ovs_be16 length; /* Length in bytes of this property. */
114 };
115 OFP_ASSERT(sizeof(struct ofp14_role_prop_header) == 4);
116
117 /* Role status event message. */
118 struct ofp14_role_status {
119     ovs_be32 role;              /* One of OFPCR_ROLE_*. */
120     uint8_t  reason;            /* One of OFPCRR_*. */
121     uint8_t  pad[3];            /* Align to 64 bits. */
122     ovs_be64 generation_id;     /* Master Election Generation Id */
123
124     /* Followed by a list of struct ofp14_role_prop_header */
125 };
126 OFP_ASSERT(sizeof(struct ofp14_role_status) == 16);
127
128 /* What changed about the controller role */
129 enum ofp14_controller_role_reason {
130     OFPCRR_MASTER_REQUEST = 0,  /* Another controller asked to be master. */
131     OFPCRR_CONFIG         = 1,  /* Configuration changed on the switch. */
132     OFPCRR_EXPERIMENTER   = 2,  /* Experimenter data changed. */
133 };
134
135 /* Role property types.
136 */
137 enum ofp14_role_prop_type {
138     OFPRPT_EXPERIMENTER         = 0xFFFF, /* Experimenter property. */
139 };
140
141 /* Experimenter role property */
142 struct ofp14_role_prop_experimenter {
143     ovs_be16        type;       /* One of OFPRPT_EXPERIMENTER. */
144     ovs_be16        length;     /* Length in bytes of this property. */
145     ovs_be32        experimenter; /* Experimenter ID which takes the same
146                                      form as in struct
147                                      ofp_experimenter_header. */
148     ovs_be32        exp_type;     /* Experimenter defined. */
149     /* Followed by:
150      *   - Exactly (length - 12) bytes containing the experimenter data, then
151      *   - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
152      *     bytes of all-zero bytes */
153 };
154 OFP_ASSERT(sizeof(struct ofp14_role_prop_experimenter) == 12);
155
156 /* Bundle control message types */
157 enum ofp14_bundle_ctrl_type {
158     OFPBCT_OPEN_REQUEST    = 0,
159     OFPBCT_OPEN_REPLY      = 1,
160     OFPBCT_CLOSE_REQUEST   = 2,
161     OFPBCT_CLOSE_REPLY     = 3,
162     OFPBCT_COMMIT_REQUEST  = 4,
163     OFPBCT_COMMIT_REPLY    = 5,
164     OFPBCT_DISCARD_REQUEST = 6,
165     OFPBCT_DISCARD_REPLY   = 7,
166 };
167
168 /* Bundle configuration flags. */
169 enum ofp14_bundle_flags {
170     OFPBF_ATOMIC  = 1 << 0,  /* Execute atomically. */
171     OFPBF_ORDERED = 1 << 1,  /* Execute in specified order. */
172 };
173
174 /* Message structure for OFPT_BUNDLE_CONTROL and OFPT_BUNDLE_ADD_MESSAGE. */
175 struct ofp14_bundle_ctrl_msg {
176     ovs_be32 bundle_id;     /* Identify the bundle. */
177     ovs_be16 type;          /* OFPT_BUNDLE_CONTROL: one of OFPBCT_*.
178                              * OFPT_BUNDLE_ADD_MESSAGE: not used. */
179     ovs_be16 flags;         /* Bitmap of OFPBF_* flags. */
180     /* Followed by:
181      * - For OFPT_BUNDLE_ADD_MESSAGE only, an encapsulated OpenFlow message,
182      *   beginning with an ofp_header whose xid is identical to this message's
183      *   outer xid.
184      * - For OFPT_BUNDLE_ADD_MESSAGE only, and only if at least one property is
185      *   present, 0 to 7 bytes of padding to align on a 64-bit boundary.
186      * - Zero or more properties (see struct ofp14_bundle_prop_header). */
187 };
188 OFP_ASSERT(sizeof(struct ofp14_bundle_ctrl_msg) == 8);
189
190 #endif /* openflow/openflow-1.4.h */