2 * Copyright (c) 2009 Nicira Networks.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef OPENFLOW_OPENFLOW_MGMT_H
18 #define OPENFLOW_OPENFLOW_MGMT_H 1
20 #include "openflow/nicira-ext.h"
23 OFMPT_CAPABILITY_REQUEST,
24 OFMPT_CAPABILITY_REPLY,
25 OFMPT_RESOURCES_REQUEST,
26 OFMPT_RESOURCES_UPDATE,
29 OFMPT_CONFIG_UPDATE_ACK,
33 /* Header on all OpenFlow management packets. */
35 struct nicira_header header;
36 uint16_t type; /* One of OFMPT_* above. */
39 OFP_ASSERT(sizeof(struct ofmp_header) == sizeof(struct nicira_header) + 4);
42 /* Generic TLV header. */
44 uint16_t type; /* Type of value (one of OFMPTLV_*). */
45 uint16_t len; /* Length of TLV (includes this header). */
46 uint8_t data[0]; /* Value of data as defined by type and length. */
48 OFP_ASSERT(sizeof(struct ofmp_tlv) == 4);
50 /* Universal TLV terminator. Used to indicate end of TLV list. */
52 uint16_t type; /* Type is 0. */
53 uint16_t len; /* Length is 4. */
55 OFP_ASSERT(sizeof(struct ofmp_tlv_end) == 4);
58 /* Bitmask of capability description styles. */
59 enum ofmp_capability_format {
60 OFMPCAF_SIMPLE = 0 << 0, /* "ovs-vswitchd.conf" style. */
63 /* Body of capbility request.
65 * OFMPT_CAPABILITY_REQUEST (controller -> switch) */
66 struct ofmp_capability_request {
67 struct ofmp_header header;
68 uint32_t format; /* One of OFMPCAF_*. */
70 OFP_ASSERT(sizeof(struct ofmp_capability_request) == 24);
72 /* Body of reply to capability request.
74 * OFMPT_CAPABILITY_REPLY (switch -> controller). */
75 struct ofmp_capability_reply {
76 struct ofmp_header header;
77 uint32_t format; /* One of OFMPCAF_*. */
78 uint64_t mgmt_id; /* Management ID. */
81 OFP_ASSERT(sizeof(struct ofmp_capability_reply) == 32);
84 /* Resource TLV for datapath description. */
86 uint16_t type; /* OFMPTSR_DP. */
87 uint16_t len; /* 32. */
89 uint64_t dp_id; /* Datapath ID. */
90 uint8_t name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated name. */
92 OFP_ASSERT(sizeof(struct ofmptsr_dp) == 32);
94 /* UUIDs will be passed around as *non-terminated* strings in their
95 * canonical form (e.g., 550e8400-e29b-41d4-a716-446655440000).
97 #define OFMP_UUID_LEN 36
99 /* Resource TLV for XenServer UUIDs associated with this datapath. */
100 struct ofmptsr_dp_uuid {
101 uint16_t type; /* OFMPTSR_DP_UUID. */
102 uint16_t len; /* Length. */
104 uint64_t dp_id; /* Datapath ID. */
105 uint8_t uuid_list[0]; /* List of UUIDs associated with
108 OFP_ASSERT(sizeof(struct ofmptsr_dp_uuid) == 16);
110 /* Resource TLV for XenServer UUID associated with this managment
113 struct ofmptsr_mgmt_uuid {
114 uint16_t type; /* OFMPTSR_MGMT_UUID. */
115 uint16_t len; /* 52. */
117 uint64_t mgmt_id; /* Management ID. */
118 uint8_t uuid[OFMP_UUID_LEN]; /* System UUID. */
119 uint8_t pad2[4]; /* Pad for 64-bit systems. */
121 OFP_ASSERT(sizeof(struct ofmptsr_mgmt_uuid) == 56);
123 /* Resource TLV for details about this XenServer vif. */
125 uint16_t type; /* OFMPTSR_VIF. */
126 uint16_t len; /* 136. */
127 uint8_t name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated name. */
128 uint8_t vif_uuid[OFMP_UUID_LEN]; /* VIF UUID. */
129 uint8_t vm_uuid[OFMP_UUID_LEN]; /* VM UUID. */
130 uint8_t net_uuid[OFMP_UUID_LEN]; /* Network UUID. */
131 uint64_t vif_mac; /* Management ID. */
133 OFP_ASSERT(sizeof(struct ofmptsr_vif) == 136);
135 /* TLV types for switch resource descriptions. */
136 enum ofmp_switch_resources {
137 OFMPTSR_END = 0, /* Terminator. */
138 OFMPTSR_DP, /* Datapath. */
139 OFMPTSR_DP_UUID, /* Xen: datapath uuid's. */
140 OFMPTSR_MGMT_UUID, /* Xen: management uuid. */
141 OFMPTSR_VIF, /* Xen: vif details. */
144 /* Body of resources request.
146 * OFMPT_RESOURCES_REQUEST (controller -> switch) */
147 struct ofmp_resources_request {
148 struct ofmp_header header;
151 /* Body of capbility update. Sent in response to a resources request or
152 * sent asynchronously when resources change on the switch.
154 * OFMPT_RESOURCES_UPDATE (switch -> controller) */
155 struct ofmp_resources_update {
156 struct ofmp_header header;
159 OFP_ASSERT(sizeof(struct ofmp_resources_update) == 20);
162 /* Bitmask of capability description styles. */
163 enum ofmp_config_format {
164 OFMPCOF_SIMPLE = 0 << 0, /* "ovs-vswitchd.conf" style. */
167 #define CONFIG_COOKIE_LEN 20
169 /* Body of configuration request.
171 * OFMPT_CONFIG_REQUEST (controller -> switch) */
172 struct ofmp_config_request {
173 struct ofmp_header header;
174 uint32_t format; /* One of OFMPCOF_*. */
176 OFP_ASSERT(sizeof(struct ofmp_config_request) == 24);
178 /* Body of configuration update. Sent in response to a configuration
179 * request from the controller. May be sent asynchronously by either
180 * the controller or switch to modify configuration or notify of
181 * changes, respectively. If sent by the controller, the switch must
182 * respond with a OFMPT_CONFIG_UPDATE_ACK.
184 * OFMPT_CONFIG_UPDATE (switch <-> controller) */
185 struct ofmp_config_update {
186 struct ofmp_header header;
187 uint32_t format; /* One of OFMPCOF_*. */
188 uint8_t cookie[CONFIG_COOKIE_LEN]; /* Cookie of config attempting to be
189 * replaced by this update. */
192 OFP_ASSERT(sizeof(struct ofmp_config_update) == 44);
194 /* Bitmask of configuration update ack flags. */
195 enum ofmp_config_update_ack_flags {
196 OFMPCUAF_SUCCESS = 1 << 0, /* Config succeeded. */
199 /* Body of configuration update ack. Sent in response to a configuration
202 * OFMPT_CONFIG_UPDATE_ACK (switch -> controller) */
203 struct ofmp_config_update_ack {
204 struct ofmp_header header;
205 uint32_t format; /* One of OFMPCOF_*. */
206 uint32_t flags; /* One of OFMPCUAF_*. */
207 uint8_t cookie[CONFIG_COOKIE_LEN]; /* Cookie of current configuration
208 * being used in the switch. */
210 OFP_ASSERT(sizeof(struct ofmp_config_update_ack) == 48);
212 /* Values for 'type' in ofmp_error_msg. */
213 enum ofmp_error_type {
214 OFMPET_BAD_CONFIG /* Problem with configuration. */
217 /* ofmp_error_msg 'code' values for OFMPET_BAD_CONFIG. 'data' contains
218 * at least the first 64 bytes of the failed request. */
219 enum ofmp_bad_config_code {
220 OFMPBCC_BUSY, /* Config updating, try again. */
221 OFMPBCC_OLD_COOKIE, /* Config has changed. */
224 /* Body of error message. May be sent by either the switch or the
225 * controller to indicate some error condition.
227 * OFMPT_ERROR (switch <-> controller) */
228 struct ofmp_error_msg {
229 struct ofmp_header header;
231 uint16_t type; /* One of OFMPET_*. */
232 uint16_t code; /* Code depending on 'type'. */
233 uint8_t data[0]; /* Variable-length data. Interpreted based
234 on the type and code. */
236 OFP_ASSERT(sizeof(struct ofmp_error_msg) == 24);
238 #endif /* openflow/openflow-mgmt.h */