]> git.proxmox.com Git - mirror_ovs.git/blob - include/openflow/nicira-ext.h
71a1de035d18d1f78696c05e27b6a9a8133732fe
[mirror_ovs.git] / include / openflow / nicira-ext.h
1 /*
2 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef OPENFLOW_NICIRA_EXT_H
18 #define OPENFLOW_NICIRA_EXT_H 1
19
20 #include <openflow/openflow.h>
21 #include <openvswitch/types.h>
22
23 /* The following vendor extensions, proposed by Nicira, are not yet
24 * standardized, so they are not included in openflow.h. Some of them may be
25 * suitable for standardization; others we never expect to standardize. */
26
27 \f
28 /* Nicira vendor-specific error messages extension.
29 *
30 * OpenFlow 1.0 has a set of predefined error types (OFPET_*) and codes (which
31 * are specific to each type). It does not have any provision for
32 * vendor-specific error codes, and it does not even provide "generic" error
33 * codes that can apply to problems not anticipated by the OpenFlow
34 * specification authors.
35 *
36 * This extension attempts to address the problem by adding a generic "error
37 * vendor extension". The extension works as follows: use NXET_VENDOR as type
38 * and NXVC_VENDOR_ERROR as code, followed by struct nx_vendor_error with
39 * vendor-specific details, followed by at least 64 bytes of the failed
40 * request.
41 *
42 * It would be better to have a type-specific vendor extension, e.g. so that
43 * OFPET_BAD_ACTION could be used with vendor-specific code values. But
44 * OFPET_BAD_ACTION and most other standardized types already specify that
45 * their 'data' values are (the start of) the OpenFlow message being replied
46 * to, so there is no room to insert a vendor ID.
47 *
48 * Currently this extension is only implemented by Open vSwitch, but it seems
49 * like a reasonable candidate for future standardization.
50 */
51
52 /* This is a random number to avoid accidental collision with any other
53 * vendor's extension. */
54 #define NXET_VENDOR 0xb0c2
55
56 /* ofp_error msg 'code' values for NXET_VENDOR. */
57 enum nx_vendor_code {
58 NXVC_VENDOR_ERROR /* 'data' contains struct nx_vendor_error. */
59 };
60
61 /* 'data' for 'type' == NXET_VENDOR, 'code' == NXVC_VENDOR_ERROR. */
62 struct nx_vendor_error {
63 ovs_be32 vendor; /* Vendor ID as in struct ofp_vendor_header. */
64 ovs_be16 type; /* Vendor-defined type. */
65 ovs_be16 code; /* Vendor-defined subtype. */
66 /* Followed by at least the first 64 bytes of the failed request. */
67 };
68 \f
69 /* Nicira vendor requests and replies. */
70
71 /* Fields to use when hashing flows. */
72 enum nx_hash_fields {
73 /* Ethernet source address (NXM_OF_ETH_SRC) only. */
74 NX_HASH_FIELDS_ETH_SRC,
75
76 /* L2 through L4, symmetric across src/dst. Specifically, each of the
77 * following fields, if present, is hashed (slashes separate symmetric
78 * pairs):
79 *
80 * - NXM_OF_ETH_DST / NXM_OF_ETH_SRC
81 * - NXM_OF_ETH_TYPE
82 * - The VID bits from NXM_OF_VLAN_TCI, ignoring PCP and CFI.
83 * - NXM_OF_IP_PROTO
84 * - NXM_OF_IP_SRC / NXM_OF_IP_DST
85 * - NXM_OF_TCP_SRC / NXM_OF_TCP_DST
86 */
87 NX_HASH_FIELDS_SYMMETRIC_L4,
88
89 /* L3+L4 only, including the following fields:
90 *
91 * - NXM_OF_IP_PROTO
92 * - NXM_OF_IP_SRC / NXM_OF_IP_DST
93 * - NXM_OF_SCTP_SRC / NXM_OF_SCTP_DST
94 * - NXM_OF_TCP_SRC / NXM_OF_TCP_DST
95 */
96 NX_HASH_FIELDS_SYMMETRIC_L3L4,
97
98 /* L3+L4 only with UDP ports, including the following fields:
99 *
100 * - NXM_OF_IP_PROTO
101 * - NXM_OF_IP_SRC / NXM_OF_IP_DST
102 * - NXM_OF_SCTP_SRC / NXM_OF_SCTP_DST
103 * - NXM_OF_TCP_SRC / NXM_OF_TCP_DST
104 * - NXM_OF_UDP_SRC / NXM_OF_UDP_DST
105 */
106 NX_HASH_FIELDS_SYMMETRIC_L3L4_UDP,
107
108 /* Network source address (NXM_OF_IP_SRC) only. */
109 NX_HASH_FIELDS_NW_SRC,
110
111 /* Network destination address (NXM_OF_IP_DST) only. */
112 NX_HASH_FIELDS_NW_DST
113
114 };
115
116 /* This command enables or disables an Open vSwitch extension that allows a
117 * controller to specify the OpenFlow table to which a flow should be added,
118 * instead of having the switch decide which table is most appropriate as
119 * required by OpenFlow 1.0. Because NXM was designed as an extension to
120 * OpenFlow 1.0, the extension applies equally to ofp10_flow_mod and
121 * nx_flow_mod. By default, the extension is disabled.
122 *
123 * When this feature is enabled, Open vSwitch treats struct ofp10_flow_mod's
124 * and struct nx_flow_mod's 16-bit 'command' member as two separate fields.
125 * The upper 8 bits are used as the table ID, the lower 8 bits specify the
126 * command as usual. A table ID of 0xff is treated like a wildcarded table ID.
127 *
128 * The specific treatment of the table ID depends on the type of flow mod:
129 *
130 * - OFPFC_ADD: Given a specific table ID, the flow is always placed in that
131 * table. If an identical flow already exists in that table only, then it
132 * is replaced. If the flow cannot be placed in the specified table,
133 * either because the table is full or because the table cannot support
134 * flows of the given type, the switch replies with an OFPFMFC_TABLE_FULL
135 * error. (A controller can distinguish these cases by comparing the
136 * current and maximum number of entries reported in ofp_table_stats.)
137 *
138 * If the table ID is wildcarded, the switch picks an appropriate table
139 * itself. If an identical flow already exist in the selected flow table,
140 * then it is replaced. The choice of table might depend on the flows
141 * that are already in the switch; for example, if one table fills up then
142 * the switch might fall back to another one.
143 *
144 * - OFPFC_MODIFY, OFPFC_DELETE: Given a specific table ID, only flows
145 * within that table are matched and modified or deleted. If the table ID
146 * is wildcarded, flows within any table may be matched and modified or
147 * deleted.
148 *
149 * - OFPFC_MODIFY_STRICT, OFPFC_DELETE_STRICT: Given a specific table ID,
150 * only a flow within that table may be matched and modified or deleted.
151 * If the table ID is wildcarded and exactly one flow within any table
152 * matches, then it is modified or deleted; if flows in more than one
153 * table match, then none is modified or deleted.
154 */
155 struct nx_flow_mod_table_id {
156 uint8_t set; /* Nonzero to enable, zero to disable. */
157 uint8_t pad[7];
158 };
159 OFP_ASSERT(sizeof(struct nx_flow_mod_table_id) == 8);
160
161 enum nx_packet_in_format {
162 NXPIF_STANDARD = 0, /* OFPT_PACKET_IN for this OpenFlow version. */
163 NXPIF_NXT_PACKET_IN = 1, /* NXT_PACKET_IN (since OVS v1.1). */
164 NXPIF_NXT_PACKET_IN2 = 2, /* NXT_PACKET_IN2 (since OVS v2.6). */
165 };
166
167 /* NXT_SET_PACKET_IN_FORMAT request.
168 *
169 * For any given OpenFlow version, Open vSwitch supports multiple formats for
170 * "packet-in" messages. The default is always the standard format for the
171 * OpenFlow version in question, but NXT_SET_PACKET_IN_FORMAT can be used to
172 * set an alternative format.
173 *
174 * From OVS v1.1 to OVS v2.5, this request was only honored for OpenFlow 1.0.
175 * Requests to set format NXPIF_NXT_PACKET_IN were accepted for OF1.1+ but they
176 * had no effect. (Requests to set formats other than NXPIF_STANDARD or
177 * NXPIF_NXT_PACKET_IN were rejected with OFPBRC_EPERM.)
178 *
179 * From OVS v2.6 onward, this request is honored for all OpenFlow versions.
180 */
181 struct nx_set_packet_in_format {
182 ovs_be32 format; /* One of NXPIF_*. */
183 };
184 OFP_ASSERT(sizeof(struct nx_set_packet_in_format) == 4);
185
186 /* NXT_PACKET_IN (analogous to OFPT_PACKET_IN).
187 *
188 * NXT_PACKET_IN is similar to the OpenFlow 1.2 OFPT_PACKET_IN. The
189 * differences are:
190 *
191 * - NXT_PACKET_IN includes the cookie of the rule that triggered the
192 * message. (OpenFlow 1.3 OFPT_PACKET_IN also includes the cookie.)
193 *
194 * - The metadata fields use NXM (instead of OXM) field numbers.
195 *
196 * Open vSwitch 1.9.0 and later omits metadata fields that are zero (as allowed
197 * by OpenFlow 1.2). Earlier versions included all implemented metadata
198 * fields.
199 *
200 * Open vSwitch does not include non-metadata in the nx_match, because by
201 * definition that information can be found in the packet itself. The format
202 * and the standards allow this, however, so controllers should be prepared to
203 * tolerate future changes.
204 *
205 * The NXM format is convenient for reporting metadata values, but it is
206 * important not to interpret the format as matching against a flow, because it
207 * does not. Nothing is being matched; arbitrary metadata masks would not be
208 * meaningful.
209 *
210 * Whereas in most cases a controller can expect to only get back NXM fields
211 * that it set up itself (e.g. flow dumps will ordinarily report only NXM
212 * fields from flows that the controller added), NXT_PACKET_IN messages might
213 * contain fields that the controller does not understand, because the switch
214 * might support fields (new registers, new protocols, etc.) that the
215 * controller does not. The controller must prepared to tolerate these.
216 *
217 * The 'cookie' field has no meaning when 'reason' is OFPR_NO_MATCH. In this
218 * case it should be UINT64_MAX. */
219 struct nx_packet_in {
220 ovs_be32 buffer_id; /* ID assigned by datapath. */
221 ovs_be16 total_len; /* Full length of frame. */
222 uint8_t reason; /* Reason packet is sent (one of OFPR_*). */
223 uint8_t table_id; /* ID of the table that was looked up. */
224 ovs_be64 cookie; /* Cookie of the rule that was looked up. */
225 ovs_be16 match_len; /* Size of nx_match. */
226 uint8_t pad[6]; /* Align to 64-bits. */
227 /* Followed by:
228 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
229 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
230 * all-zero bytes, then
231 * - Exactly 2 all-zero padding bytes, then
232 * - An Ethernet frame whose length is inferred from nxh.header.length.
233 *
234 * The padding bytes preceding the Ethernet frame ensure that the IP
235 * header (if any) following the Ethernet header is 32-bit aligned. */
236
237 /* uint8_t nxm_fields[...]; */ /* NXM headers. */
238 /* uint8_t pad[2]; */ /* Align to 64 bit + 16 bit. */
239 /* uint8_t data[0]; */ /* Ethernet frame. */
240 };
241 OFP_ASSERT(sizeof(struct nx_packet_in) == 24);
242
243 /* NXT_PACKET_IN2
244 * ==============
245 *
246 * NXT_PACKET_IN2 is conceptually similar to OFPT_PACKET_IN but it is expressed
247 * as an extensible set of properties instead of using a fixed structure.
248 *
249 * Added in Open vSwitch 2.6
250 *
251 *
252 * Continuations
253 * -------------
254 *
255 * When a "controller" action specifies the "pause" flag, the controller action
256 * freezes the packet's trip through Open vSwitch flow tables and serializes
257 * that state into the packet-in message as a "continuation". The controller
258 * can later send the continuation back to the switch, which will restart the
259 * packet's traversal from the point where it was interrupted. This permits an
260 * OpenFlow controller to interpose on a packet midway through processing in
261 * Open vSwitch.
262 *
263 * Continuations fit into packet processing this way:
264 *
265 * 1. A packet ingresses into Open vSwitch, which runs it through the OpenFlow
266 * tables.
267 *
268 * 2. An OpenFlow flow executes a "controller" action that includes the "pause"
269 * flag. Open vSwitch serializes the packet processing state and sends it,
270 * as an NXT_PACKET_IN2 that includes an additional NXPINT_CONTINUATION
271 * property (the continuation), to the OpenFlow controller.
272 *
273 * (The controller must use NXAST_CONTROLLER2 to generate the packet-in,
274 * because only this form of the "controller" action has a "pause" flag.
275 * Similarly, the controller must use NXT_SET_PACKET_IN_FORMAT to select
276 * NXT_PACKET_IN2 as the packet-in format, because this is the only format
277 * that supports continuation passing.)
278 *
279 * 3. The controller receives the NXT_PACKET_IN2 and processes it. The
280 * controller can interpret and, if desired, modify some of the contents of
281 * the packet-in, such as the packet and the metadata being processed.
282 *
283 * 4. The controller sends the continuation back to the switch, using an
284 * NXT_RESUME message. Packet processing resumes where it left off.
285 *
286 * The controller might change the pipeline configuration concurrently with
287 * steps 2 through 4. For example, it might add or remove OpenFlow flows. If
288 * that happens, then the packet will experience a mix of processing from the
289 * two configurations, that is, the initial processing (before
290 * NXAST_CONTROLLER2) uses the initial flow table, and the later processing
291 * (after NXT_RESUME) uses the later flow table. This means that the
292 * controller needs to take care to avoid incompatible pipeline changes while
293 * processing continuations.
294 *
295 * External side effects (e.g. "output") of OpenFlow actions processed before
296 * NXAST_CONTROLLER2 is encountered might be executed during step 2 or step 4,
297 * and the details may vary among Open vSwitch features and versions. Thus, a
298 * controller that wants to make sure that side effects are executed must pass
299 * the continuation back to the switch, that is, must not skip step 4.
300 *
301 * Architecturally, continuations may be "stateful" or "stateless", that is,
302 * they may or may not refer to buffered state maintained in Open vSwitch.
303 * This means that a controller should not attempt to resume a given
304 * continuations more than once (because the switch might have discarded the
305 * buffered state after the first use). For the same reason, continuations
306 * might become "stale" if the controller takes too long to resume them
307 * (because the switch might have discarded old buffered state). Taken
308 * together with the previous note, this means that a controller should resume
309 * each continuation exactly once (and promptly).
310 *
311 * Without the information in NXPINT_CONTINUATION, the controller can (with
312 * careful design, and help from the flow cookie) determine where the packet is
313 * in the pipeline, but in the general case it can't determine what nested
314 * "resubmit"s that may be in progress, or what data is on the stack maintained
315 * by NXAST_STACK_PUSH and NXAST_STACK_POP actions, what is in the OpenFlow
316 * action set, etc.
317 *
318 * Continuations are expensive because they require a round trip between the
319 * switch and the controller. Thus, they should not be used to implement
320 * processing that needs to happen at "line rate".
321 *
322 * The contents of NXPINT_CONTINUATION are private to the switch, may change
323 * unpredictably from one version of Open vSwitch to another, and are not
324 * documented here. The contents are also tied to a given Open vSwitch process
325 * and bridge, so that restarting Open vSwitch or deleting and recreating a
326 * bridge will cause the corresponding NXT_RESUME to be rejected.
327 *
328 * In the current implementation, Open vSwitch forks the packet processing
329 * pipeline across patch ports. Suppose, for example, that the pipeline for
330 * br0 outputs to a patch port whose peer belongs to br1, and that the pipeline
331 * for br1 executes a controller action with the "pause" flag. This only
332 * pauses processing within br1, and processing in br0 continues and possibly
333 * completes with visible side effects, such as outputting to ports, before
334 * br1's controller receives or processes the continuation. This
335 * implementation maintains the independence of separate bridges and, since
336 * processing in br1 cannot affect the behavior of br0 anyway, should not cause
337 * visible behavioral changes.
338 *
339 * A stateless implementation of continuations may ignore the "controller"
340 * action max_len, always sending the whole packet, because the full packet is
341 * required to continue traversal.
342 */
343 enum nx_packet_in2_prop_type {
344 /* Packet. */
345 NXPINT_PACKET, /* Raw packet data. */
346 NXPINT_FULL_LEN, /* ovs_be32: Full packet len, if truncated. */
347 NXPINT_BUFFER_ID, /* ovs_be32: Buffer ID, if buffered. */
348
349 /* Information about the flow that triggered the packet-in. */
350 NXPINT_TABLE_ID, /* uint8_t: Table ID. */
351 NXPINT_COOKIE, /* ovs_be64: Flow cookie. */
352
353 /* Other. */
354 NXPINT_REASON, /* uint8_t, one of OFPR_*. */
355 NXPINT_METADATA, /* NXM or OXM for metadata fields. */
356 NXPINT_USERDATA, /* From NXAST_CONTROLLER2 userdata. */
357 NXPINT_CONTINUATION, /* Private data for continuing processing. */
358 };
359
360 /* Configures the "role" of the sending controller. The default role is:
361 *
362 * - Other (NX_ROLE_OTHER), which allows the controller access to all
363 * OpenFlow features.
364 *
365 * The other possible roles are a related pair:
366 *
367 * - Master (NX_ROLE_MASTER) is equivalent to Other, except that there may
368 * be at most one Master controller at a time: when a controller
369 * configures itself as Master, any existing Master is demoted to the
370 * Slave role.
371 *
372 * - Slave (NX_ROLE_SLAVE) allows the controller read-only access to
373 * OpenFlow features. In particular attempts to modify the flow table
374 * will be rejected with an OFPBRC_EPERM error.
375 *
376 * Slave controllers do not receive OFPT_PACKET_IN or OFPT_FLOW_REMOVED
377 * messages, but they do receive OFPT_PORT_STATUS messages.
378 */
379 struct nx_role_request {
380 ovs_be32 role; /* One of NX_ROLE_*. */
381 };
382 OFP_ASSERT(sizeof(struct nx_role_request) == 4);
383
384 enum nx_role {
385 NX_ROLE_OTHER, /* Default role, full access. */
386 NX_ROLE_MASTER, /* Full access, at most one. */
387 NX_ROLE_SLAVE /* Read-only access. */
388 };
389
390 /* NXT_SET_ASYNC_CONFIG.
391 *
392 * Sent by a controller, this message configures the asynchronous messages that
393 * the controller wants to receive. Element 0 in each array specifies messages
394 * of interest when the controller has an "other" or "master" role; element 1,
395 * when the controller has a "slave" role.
396 *
397 * Each array element is a bitmask in which a 0-bit disables receiving a
398 * particular message and a 1-bit enables receiving it. Each bit controls the
399 * message whose 'reason' corresponds to the bit index. For example, the bit
400 * with value 1<<2 == 4 in port_status_mask[1] determines whether the
401 * controller will receive OFPT_PORT_STATUS messages with reason OFPPR_MODIFY
402 * (value 2) when the controller has a "slave" role.
403 *
404 * As a side effect, for service controllers, this message changes the
405 * miss_send_len from default of zero to OFP_DEFAULT_MISS_SEND_LEN (128).
406 */
407 struct nx_async_config {
408 ovs_be32 packet_in_mask[2]; /* Bitmasks of OFPR_* values. */
409 ovs_be32 port_status_mask[2]; /* Bitmasks of OFPRR_* values. */
410 ovs_be32 flow_removed_mask[2]; /* Bitmasks of OFPPR_* values. */
411 };
412 OFP_ASSERT(sizeof(struct nx_async_config) == 24);
413 \f
414 /* Flexible flow specifications (aka NXM = Nicira Extended Match).
415 *
416 * OpenFlow 1.0 has "struct ofp10_match" for specifying flow matches. This
417 * structure is fixed-length and hence difficult to extend. This section
418 * describes a more flexible, variable-length flow match, called "nx_match" for
419 * short, that is also supported by Open vSwitch. This section also defines a
420 * replacement for each OpenFlow message that includes struct ofp10_match.
421 *
422 * OpenFlow 1.2+ introduced OpenFlow Extensible Match (OXM), adapting
423 * the design of NXM. The format of NXM and OXM are compatible.
424 *
425 *
426 * Format
427 * ======
428 *
429 * An nx_match is a sequence of zero or more "nxm_entry"s, which are
430 * type-length-value (TLV) entries, each 5 to 259 (inclusive) bytes long.
431 * "nxm_entry"s are not aligned on or padded to any multibyte boundary. The
432 * first 4 bytes of an nxm_entry are its "header", followed by the entry's
433 * "body".
434 *
435 * An nxm_entry's header is interpreted as a 32-bit word in network byte order:
436 *
437 * |<-------------------- nxm_type ------------------>|
438 * | |
439 * |31 16 15 9| 8 7 0
440 * +----------------------------------+---------------+--+------------------+
441 * | nxm_vendor | nxm_field |hm| nxm_length |
442 * +----------------------------------+---------------+--+------------------+
443 *
444 * The most-significant 23 bits of the header are collectively "nxm_type".
445 * Bits 16...31 are "nxm_vendor", one of OFPXMC12_* values. In case of
446 * NXM, it's either OFPXMC12_NXM_0 or OFPXMC12_NXM_1.
447 * Bits 9...15 are "nxm_field", which is a vendor-specific value. nxm_type
448 * normally designates a protocol header, such as the Ethernet type, but it
449 * can also refer to packet metadata, such as the switch port on which a packet
450 * arrived.
451 *
452 * Bit 8 is "nxm_hasmask" (labeled "hm" above for space reasons). The meaning
453 * of this bit is explained later.
454 *
455 * The least-significant 8 bits are "nxm_length", a positive integer. The
456 * length of the nxm_entry, including the header, is exactly 4 + nxm_length
457 * bytes.
458 *
459 * For a given nxm_vendor, nxm_field, and nxm_hasmask value, nxm_length is a
460 * constant. It is included only to allow software to minimally parse
461 * "nxm_entry"s of unknown types. (Similarly, for a given nxm_vendor,
462 * nxm_field, and nxm_length, nxm_hasmask is a constant.)
463 *
464 *
465 * Semantics
466 * =========
467 *
468 * A zero-length nx_match (one with no "nxm_entry"s) matches every packet.
469 *
470 * An nxm_entry places a constraint on the packets matched by the nx_match:
471 *
472 * - If nxm_hasmask is 0, the nxm_entry's body contains a value for the
473 * field, called "nxm_value". The nx_match matches only packets in which
474 * the field equals nxm_value.
475 *
476 * - If nxm_hasmask is 1, then the nxm_entry's body contains a value for the
477 * field (nxm_value), followed by a bitmask of the same length as the
478 * value, called "nxm_mask". For each 1-bit in position J in nxm_mask, the
479 * nx_match matches only packets for which bit J in the given field's value
480 * matches bit J in nxm_value. A 0-bit in nxm_mask causes the
481 * corresponding bit in nxm_value is ignored (it should be 0; Open vSwitch
482 * may enforce this someday), as is the corresponding bit in the field's
483 * value. (The sense of the nxm_mask bits is the opposite of that used by
484 * the "wildcards" member of struct ofp10_match.)
485 *
486 * When nxm_hasmask is 1, nxm_length is always even.
487 *
488 * An all-zero-bits nxm_mask is equivalent to omitting the nxm_entry
489 * entirely. An all-one-bits nxm_mask is equivalent to specifying 0 for
490 * nxm_hasmask.
491 *
492 * When there are multiple "nxm_entry"s, all of the constraints must be met.
493 *
494 *
495 * Mask Restrictions
496 * =================
497 *
498 * Masks may be restricted:
499 *
500 * - Some nxm_types may not support masked wildcards, that is, nxm_hasmask
501 * must always be 0 when these fields are specified. For example, the
502 * field that identifies the port on which a packet was received may not be
503 * masked.
504 *
505 * - Some nxm_types that do support masked wildcards may only support certain
506 * nxm_mask patterns. For example, fields that have IPv4 address values
507 * may be restricted to CIDR masks.
508 *
509 * These restrictions should be noted in specifications for individual fields.
510 * A switch may accept an nxm_hasmask or nxm_mask value that the specification
511 * disallows, if the switch correctly implements support for that nxm_hasmask
512 * or nxm_mask value. A switch must reject an attempt to set up a flow that
513 * contains a nxm_hasmask or nxm_mask value that it does not support.
514 *
515 *
516 * Prerequisite Restrictions
517 * =========================
518 *
519 * The presence of an nxm_entry with a given nxm_type may be restricted based
520 * on the presence of or values of other "nxm_entry"s. For example:
521 *
522 * - An nxm_entry for nxm_type=NXM_OF_IP_TOS is allowed only if it is
523 * preceded by another entry with nxm_type=NXM_OF_ETH_TYPE, nxm_hasmask=0,
524 * and nxm_value=0x0800. That is, matching on the IP source address is
525 * allowed only if the Ethernet type is explicitly set to IP.
526 *
527 * - An nxm_entry for nxm_type=NXM_OF_TCP_SRC is allowed only if it is
528 * preceded by an entry with nxm_type=NXM_OF_ETH_TYPE, nxm_hasmask=0, and
529 * nxm_value either 0x0800 or 0x86dd, and another with
530 * nxm_type=NXM_OF_IP_PROTO, nxm_hasmask=0, nxm_value=6, in that order.
531 * That is, matching on the TCP source port is allowed only if the Ethernet
532 * type is IP or IPv6 and the IP protocol is TCP.
533 *
534 * These restrictions should be noted in specifications for individual fields.
535 * A switch may implement relaxed versions of these restrictions. A switch
536 * must reject an attempt to set up a flow that violates its restrictions.
537 *
538 *
539 * Ordering Restrictions
540 * =====================
541 *
542 * An nxm_entry that has prerequisite restrictions must appear after the
543 * "nxm_entry"s for its prerequisites. Ordering of "nxm_entry"s within an
544 * nx_match is not otherwise constrained.
545 *
546 * Any given nxm_type may appear in an nx_match at most once.
547 *
548 *
549 * nxm_entry Examples
550 * ==================
551 *
552 * These examples show the format of a single nxm_entry with particular
553 * nxm_hasmask and nxm_length values. The diagrams are labeled with field
554 * numbers and byte indexes.
555 *
556 *
557 * 8-bit nxm_value, nxm_hasmask=1, nxm_length=2:
558 *
559 * 0 3 4 5
560 * +------------+---+---+
561 * | header | v | m |
562 * +------------+---+---+
563 *
564 *
565 * 16-bit nxm_value, nxm_hasmask=0, nxm_length=2:
566 *
567 * 0 3 4 5
568 * +------------+------+
569 * | header | value|
570 * +------------+------+
571 *
572 *
573 * 32-bit nxm_value, nxm_hasmask=0, nxm_length=4:
574 *
575 * 0 3 4 7
576 * +------------+-------------+
577 * | header | nxm_value |
578 * +------------+-------------+
579 *
580 *
581 * 48-bit nxm_value, nxm_hasmask=0, nxm_length=6:
582 *
583 * 0 3 4 9
584 * +------------+------------------+
585 * | header | nxm_value |
586 * +------------+------------------+
587 *
588 *
589 * 48-bit nxm_value, nxm_hasmask=1, nxm_length=12:
590 *
591 * 0 3 4 9 10 15
592 * +------------+------------------+------------------+
593 * | header | nxm_value | nxm_mask |
594 * +------------+------------------+------------------+
595 *
596 *
597 * Error Reporting
598 * ===============
599 *
600 * A switch should report an error in an nx_match using error type
601 * OFPET_BAD_REQUEST and one of the NXBRC_NXM_* codes. Ideally the switch
602 * should report a specific error code, if one is assigned for the particular
603 * problem, but NXBRC_NXM_INVALID is also available to report a generic
604 * nx_match error.
605 */
606
607 /* Number of registers allocated NXM field IDs. */
608 #define NXM_NX_MAX_REGS 16
609
610 /* Bits in the value of NXM_NX_IP_FRAG. */
611 #define NX_IP_FRAG_ANY (1 << 0) /* Is this a fragment? */
612 #define NX_IP_FRAG_LATER (1 << 1) /* Is this a fragment with nonzero offset? */
613
614 /* Bits in the value of NXM_NX_TUN_FLAGS. */
615 #define NX_TUN_FLAG_OAM (1 << 0) /* Is this an OAM packet? */
616
617 /* ## --------------------- ## */
618 /* ## Requests and replies. ## */
619 /* ## --------------------- ## */
620
621 enum nx_flow_format {
622 NXFF_OPENFLOW10 = 0, /* Standard OpenFlow 1.0 compatible. */
623 NXFF_NXM = 2 /* Nicira extended match. */
624 };
625
626 /* NXT_SET_FLOW_FORMAT request. */
627 struct nx_set_flow_format {
628 ovs_be32 format; /* One of NXFF_*. */
629 };
630 OFP_ASSERT(sizeof(struct nx_set_flow_format) == 4);
631
632 /* NXT_FLOW_MOD (analogous to OFPT_FLOW_MOD).
633 *
634 * It is possible to limit flow deletions and modifications to certain
635 * cookies by using the NXM_NX_COOKIE(_W) matches. The "cookie" field
636 * is used only to add or modify flow cookies.
637 */
638 struct nx_flow_mod {
639 ovs_be64 cookie; /* Opaque controller-issued identifier. */
640 ovs_be16 command; /* OFPFC_* + possibly a table ID (see comment
641 * on struct nx_flow_mod_table_id). */
642 ovs_be16 idle_timeout; /* Idle time before discarding (seconds). */
643 ovs_be16 hard_timeout; /* Max time before discarding (seconds). */
644 ovs_be16 priority; /* Priority level of flow entry. */
645 ovs_be32 buffer_id; /* Buffered packet to apply to (or -1).
646 Not meaningful for OFPFC_DELETE*. */
647 ovs_be16 out_port; /* For OFPFC_DELETE* commands, require
648 matching entries to include this as an
649 output port. A value of OFPP_NONE
650 indicates no restriction. */
651 ovs_be16 flags; /* One of OFPFF_*. */
652 ovs_be16 match_len; /* Size of nx_match. */
653 uint8_t pad[6]; /* Align to 64-bits. */
654 /* Followed by:
655 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
656 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
657 * all-zero bytes, then
658 * - Actions to fill out the remainder of the message length (always a
659 * multiple of 8).
660 */
661 };
662 OFP_ASSERT(sizeof(struct nx_flow_mod) == 32);
663
664 /* NXT_FLOW_REMOVED (analogous to OFPT_FLOW_REMOVED).
665 *
666 * 'table_id' is present only in Open vSwitch 1.11 and later. In earlier
667 * versions of Open vSwitch, this is a padding byte that is always zeroed.
668 * Therefore, a 'table_id' value of 0 indicates that the table ID is not known,
669 * and other values may be interpreted as one more than the flow's former table
670 * ID. */
671 struct nx_flow_removed {
672 ovs_be64 cookie; /* Opaque controller-issued identifier. */
673 ovs_be16 priority; /* Priority level of flow entry. */
674 uint8_t reason; /* One of OFPRR_*. */
675 uint8_t table_id; /* Flow's former table ID, plus one. */
676 ovs_be32 duration_sec; /* Time flow was alive in seconds. */
677 ovs_be32 duration_nsec; /* Time flow was alive in nanoseconds beyond
678 duration_sec. */
679 ovs_be16 idle_timeout; /* Idle timeout from original flow mod. */
680 ovs_be16 match_len; /* Size of nx_match. */
681 ovs_be64 packet_count;
682 ovs_be64 byte_count;
683 /* Followed by:
684 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
685 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
686 * all-zero bytes. */
687 };
688 OFP_ASSERT(sizeof(struct nx_flow_removed) == 40);
689
690 /* Nicira vendor stats request of type NXST_FLOW (analogous to OFPST_FLOW
691 * request).
692 *
693 * It is possible to limit matches to certain cookies by using the
694 * NXM_NX_COOKIE and NXM_NX_COOKIE_W matches.
695 */
696 struct nx_flow_stats_request {
697 ovs_be16 out_port; /* Require matching entries to include this
698 as an output port. A value of OFPP_NONE
699 indicates no restriction. */
700 ovs_be16 match_len; /* Length of nx_match. */
701 uint8_t table_id; /* ID of table to read (from ofp_table_stats)
702 or 0xff for all tables. */
703 uint8_t pad[3]; /* Align to 64 bits. */
704 /* Followed by:
705 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
706 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
707 * all-zero bytes, which must also exactly fill out the length of the
708 * message.
709 */
710 };
711 OFP_ASSERT(sizeof(struct nx_flow_stats_request) == 8);
712
713 /* Body for Nicira vendor stats reply of type NXST_FLOW (analogous to
714 * OFPST_FLOW reply).
715 *
716 * The values of 'idle_age' and 'hard_age' are only meaningful when talking to
717 * a switch that implements the NXT_FLOW_AGE extension. Zero means that the
718 * true value is unknown, perhaps because hardware does not track the value.
719 * (Zero is also the value that one should ordinarily expect to see talking to
720 * a switch that does not implement NXT_FLOW_AGE, since those switches zero the
721 * padding bytes that these fields replaced.) A nonzero value X represents X-1
722 * seconds. A value of 65535 represents 65534 or more seconds.
723 *
724 * 'idle_age' is the number of seconds that the flow has been idle, that is,
725 * the number of seconds since a packet passed through the flow. 'hard_age' is
726 * the number of seconds since the flow was last modified (e.g. OFPFC_MODIFY or
727 * OFPFC_MODIFY_STRICT). (The 'duration_*' fields are the elapsed time since
728 * the flow was added, regardless of subsequent modifications.)
729 *
730 * For a flow with an idle or hard timeout, 'idle_age' or 'hard_age',
731 * respectively, will ordinarily be smaller than the timeout, but flow
732 * expiration times are only approximate and so one must be prepared to
733 * tolerate expirations that occur somewhat early or late.
734 */
735 struct nx_flow_stats {
736 ovs_be16 length; /* Length of this entry. */
737 uint8_t table_id; /* ID of table flow came from. */
738 uint8_t pad;
739 ovs_be32 duration_sec; /* Time flow has been alive in seconds. */
740 ovs_be32 duration_nsec; /* Time flow has been alive in nanoseconds
741 beyond duration_sec. */
742 ovs_be16 priority; /* Priority of the entry. */
743 ovs_be16 idle_timeout; /* Number of seconds idle before expiration. */
744 ovs_be16 hard_timeout; /* Number of seconds before expiration. */
745 ovs_be16 match_len; /* Length of nx_match. */
746 ovs_be16 idle_age; /* Seconds since last packet, plus one. */
747 ovs_be16 hard_age; /* Seconds since last modification, plus one. */
748 ovs_be64 cookie; /* Opaque controller-issued identifier. */
749 ovs_be64 packet_count; /* Number of packets, UINT64_MAX if unknown. */
750 ovs_be64 byte_count; /* Number of bytes, UINT64_MAX if unknown. */
751 /* Followed by:
752 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
753 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
754 * all-zero bytes, then
755 * - Actions to fill out the remainder 'length' bytes (always a multiple
756 * of 8).
757 */
758 };
759 OFP_ASSERT(sizeof(struct nx_flow_stats) == 48);
760
761 /* Nicira vendor stats request of type NXST_AGGREGATE (analogous to
762 * OFPST_AGGREGATE request).
763 *
764 * The reply format is identical to the reply format for OFPST_AGGREGATE,
765 * except for the header. */
766 struct nx_aggregate_stats_request {
767 ovs_be16 out_port; /* Require matching entries to include this
768 as an output port. A value of OFPP_NONE
769 indicates no restriction. */
770 ovs_be16 match_len; /* Length of nx_match. */
771 uint8_t table_id; /* ID of table to read (from ofp_table_stats)
772 or 0xff for all tables. */
773 uint8_t pad[3]; /* Align to 64 bits. */
774 /* Followed by:
775 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
776 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
777 * all-zero bytes, which must also exactly fill out the length of the
778 * message.
779 */
780 };
781 OFP_ASSERT(sizeof(struct nx_aggregate_stats_request) == 8);
782
783 struct nx_ipfix_stats_reply {
784 ovs_be64 total_flows;
785 ovs_be64 current_flows;
786 ovs_be64 pkts;
787 ovs_be64 ipv4_pkts;
788 ovs_be64 ipv6_pkts;
789 ovs_be64 error_pkts;
790 ovs_be64 ipv4_error_pkts;
791 ovs_be64 ipv6_error_pkts;
792 ovs_be64 tx_pkts;
793 ovs_be64 tx_errors;
794 ovs_be32 collector_set_id; /* Range 0 to 4,294,967,295. */
795 uint8_t pad[4]; /* Pad to a multiple of 8 bytes. */
796 };
797 OFP_ASSERT(sizeof(struct nx_ipfix_stats_reply) == 88);
798
799 \f
800 /* NXT_SET_CONTROLLER_ID.
801 *
802 * Each OpenFlow controller connection has a 16-bit identifier that is
803 * initially 0. This message changes the connection's ID to 'id'.
804 *
805 * Controller connection IDs need not be unique.
806 *
807 * The NXAST_CONTROLLER action is the only current user of controller
808 * connection IDs. */
809 struct nx_controller_id {
810 uint8_t zero[6]; /* Must be zero. */
811 ovs_be16 controller_id; /* New controller connection ID. */
812 };
813 OFP_ASSERT(sizeof(struct nx_controller_id) == 8);
814 \f
815 /* Flow Table Monitoring
816 * =====================
817 *
818 * NXST_FLOW_MONITOR allows a controller to keep track of changes to OpenFlow
819 * flow table(s) or subsets of them, with the following workflow:
820 *
821 * 1. The controller sends an NXST_FLOW_MONITOR request to begin monitoring
822 * flows. The 'id' in the request must be unique among all monitors that
823 * the controller has started and not yet canceled on this OpenFlow
824 * connection.
825 *
826 * 2. The switch responds with an NXST_FLOW_MONITOR reply. If the request's
827 * 'flags' included NXFMF_INITIAL, the reply includes all the flows that
828 * matched the request at the time of the request (with event NXFME_ADDED).
829 * If 'flags' did not include NXFMF_INITIAL, the reply is empty.
830 *
831 * The reply uses the xid of the request (as do all replies to OpenFlow
832 * requests).
833 *
834 * 3. Whenever a change to a flow table entry matches some outstanding monitor
835 * request's criteria and flags, the switch sends a notification to the
836 * controller as an additional NXST_FLOW_MONITOR reply with xid 0.
837 *
838 * When multiple outstanding monitors match a single change, only a single
839 * notification is sent. This merged notification includes the information
840 * requested in any of the individual monitors. That is, if any of the
841 * matching monitors requests actions (NXFMF_ACTIONS), the notification
842 * includes actions, and if any of the monitors request full changes for the
843 * controller's own changes (NXFMF_OWN), the controller's own changes will
844 * be included in full.
845 *
846 * 4. The controller may cancel a monitor with NXT_FLOW_MONITOR_CANCEL. No
847 * further notifications will be sent on the basis of the canceled monitor
848 * afterward.
849 *
850 *
851 * Buffer Management
852 * =================
853 *
854 * OpenFlow messages for flow monitor notifications can overflow the buffer
855 * space available to the switch, either temporarily (e.g. due to network
856 * conditions slowing OpenFlow traffic) or more permanently (e.g. the sustained
857 * rate of flow table change exceeds the network bandwidth between switch and
858 * controller).
859 *
860 * When Open vSwitch's notification buffer space reaches a limiting threshold,
861 * OVS reacts as follows:
862 *
863 * 1. OVS sends an NXT_FLOW_MONITOR_PAUSED message to the controller, following
864 * all the already queued notifications. After it receives this message,
865 * the controller knows that its view of the flow table, as represented by
866 * flow monitor notifications, is incomplete.
867 *
868 * 2. As long as the notification buffer is not empty:
869 *
870 * - NXMFE_ADD and NXFME_MODIFIED notifications will not be sent.
871 *
872 * - NXFME_DELETED notifications will still be sent, but only for flows
873 * that existed before OVS sent NXT_FLOW_MONITOR_PAUSED.
874 *
875 * - NXFME_ABBREV notifications will not be sent. They are treated as
876 * the expanded version (and therefore only the NXFME_DELETED
877 * components, if any, are sent).
878 *
879 * 3. When the notification buffer empties, OVS sends NXFME_ADD notifications
880 * for flows added since the buffer reached its limit and NXFME_MODIFIED
881 * notifications for flows that existed before the limit was reached and
882 * changed after the limit was reached.
883 *
884 * 4. OVS sends an NXT_FLOW_MONITOR_RESUMED message to the controller. After
885 * it receives this message, the controller knows that its view of the flow
886 * table, as represented by flow monitor notifications, is again complete.
887 *
888 * This allows the maximum buffer space requirement for notifications to be
889 * bounded by the limit plus the maximum number of supported flows.
890 *
891 *
892 * "Flow Removed" messages
893 * =======================
894 *
895 * The flow monitor mechanism is independent of OFPT_FLOW_REMOVED and
896 * NXT_FLOW_REMOVED. Flow monitor updates for deletion are sent if
897 * NXFMF_DELETE is set on a monitor, regardless of whether the
898 * OFPFF_SEND_FLOW_REM flag was set when the flow was added. */
899
900 /* NXST_FLOW_MONITOR request.
901 *
902 * The NXST_FLOW_MONITOR request's body consists of an array of zero or more
903 * instances of this structure. The request arranges to monitor the flows
904 * that match the specified criteria, which are interpreted in the same way as
905 * for NXST_FLOW.
906 *
907 * 'id' identifies a particular monitor for the purpose of allowing it to be
908 * canceled later with NXT_FLOW_MONITOR_CANCEL. 'id' must be unique among
909 * existing monitors that have not already been canceled.
910 *
911 * The reply includes the initial flow matches for monitors that have the
912 * NXFMF_INITIAL flag set. No single flow will be included in the reply more
913 * than once, even if more than one requested monitor matches that flow. The
914 * reply will be empty if none of the monitors has NXFMF_INITIAL set or if none
915 * of the monitors initially matches any flows.
916 *
917 * For NXFMF_ADD, an event will be reported if 'out_port' matches against the
918 * actions of the flow being added or, for a flow that is replacing an existing
919 * flow, if 'out_port' matches against the actions of the flow being replaced.
920 * For NXFMF_DELETE, 'out_port' matches against the actions of a flow being
921 * deleted. For NXFMF_MODIFY, an event will be reported if 'out_port' matches
922 * either the old or the new actions. */
923 struct nx_flow_monitor_request {
924 ovs_be32 id; /* Controller-assigned ID for this monitor. */
925 ovs_be16 flags; /* NXFMF_*. */
926 ovs_be16 out_port; /* Required output port, if not OFPP_NONE. */
927 ovs_be16 match_len; /* Length of nx_match. */
928 uint8_t table_id; /* One table's ID or 0xff for all tables. */
929 uint8_t zeros[5]; /* Align to 64 bits (must be zero). */
930 /* Followed by:
931 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
932 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
933 * all-zero bytes. */
934 };
935 OFP_ASSERT(sizeof(struct nx_flow_monitor_request) == 16);
936
937 /* 'flags' bits in struct nx_flow_monitor_request. */
938 enum nx_flow_monitor_flags {
939 /* When to send updates. */
940 NXFMF_INITIAL = 1 << 0, /* Initially matching flows. */
941 NXFMF_ADD = 1 << 1, /* New matching flows as they are added. */
942 NXFMF_DELETE = 1 << 2, /* Old matching flows as they are removed. */
943 NXFMF_MODIFY = 1 << 3, /* Matching flows as they are changed. */
944
945 /* What to include in updates. */
946 NXFMF_ACTIONS = 1 << 4, /* If set, actions are included. */
947 NXFMF_OWN = 1 << 5, /* If set, include own changes in full. */
948 };
949
950 /* NXST_FLOW_MONITOR reply header.
951 *
952 * The body of an NXST_FLOW_MONITOR reply is an array of variable-length
953 * structures, each of which begins with this header. The 'length' member may
954 * be used to traverse the array, and the 'event' member may be used to
955 * determine the particular structure.
956 *
957 * Every instance is a multiple of 8 bytes long. */
958 struct nx_flow_update_header {
959 ovs_be16 length; /* Length of this entry. */
960 ovs_be16 event; /* One of NXFME_*. */
961 /* ...other data depending on 'event'... */
962 };
963 OFP_ASSERT(sizeof(struct nx_flow_update_header) == 4);
964
965 /* 'event' values in struct nx_flow_update_header. */
966 enum nx_flow_update_event {
967 /* struct nx_flow_update_full. */
968 NXFME_ADDED = 0, /* Flow was added. */
969 NXFME_DELETED = 1, /* Flow was deleted. */
970 NXFME_MODIFIED = 2, /* Flow (generally its actions) was changed. */
971
972 /* struct nx_flow_update_abbrev. */
973 NXFME_ABBREV = 3, /* Abbreviated reply. */
974 };
975
976 /* NXST_FLOW_MONITOR reply for NXFME_ADDED, NXFME_DELETED, and
977 * NXFME_MODIFIED. */
978 struct nx_flow_update_full {
979 ovs_be16 length; /* Length is 24. */
980 ovs_be16 event; /* One of NXFME_*. */
981 ovs_be16 reason; /* OFPRR_* for NXFME_DELETED, else zero. */
982 ovs_be16 priority; /* Priority of the entry. */
983 ovs_be16 idle_timeout; /* Number of seconds idle before expiration. */
984 ovs_be16 hard_timeout; /* Number of seconds before expiration. */
985 ovs_be16 match_len; /* Length of nx_match. */
986 uint8_t table_id; /* ID of flow's table. */
987 uint8_t pad; /* Reserved, currently zeroed. */
988 ovs_be64 cookie; /* Opaque controller-issued identifier. */
989 /* Followed by:
990 * - Exactly match_len (possibly 0) bytes containing the nx_match, then
991 * - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
992 * all-zero bytes, then
993 * - Actions to fill out the remainder 'length' bytes (always a multiple
994 * of 8). If NXFMF_ACTIONS was not specified, or 'event' is
995 * NXFME_DELETED, no actions are included.
996 */
997 };
998 OFP_ASSERT(sizeof(struct nx_flow_update_full) == 24);
999
1000 /* NXST_FLOW_MONITOR reply for NXFME_ABBREV.
1001 *
1002 * When the controller does not specify NXFMF_OWN in a monitor request, any
1003 * flow tables changes due to the controller's own requests (on the same
1004 * OpenFlow channel) will be abbreviated, when possible, to this form, which
1005 * simply specifies the 'xid' of the OpenFlow request (e.g. an OFPT_FLOW_MOD or
1006 * NXT_FLOW_MOD) that caused the change.
1007 *
1008 * Some changes cannot be abbreviated and will be sent in full:
1009 *
1010 * - Changes that only partially succeed. This can happen if, for example,
1011 * a flow_mod with type OFPFC_MODIFY affects multiple flows, but only some
1012 * of those modifications succeed (e.g. due to hardware limitations).
1013 *
1014 * This cannot occur with the Open vSwitch software datapath. This also
1015 * cannot occur in Open vSwitch 2.4 and later, because these versions only
1016 * execute any flow modifications if all of them will succeed.
1017 *
1018 * - Changes that race with conflicting changes made by other controllers or
1019 * other flow_mods (not separated by barriers) by the same controller.
1020 *
1021 * This cannot occur with the current Open vSwitch implementation
1022 * (regardless of datapath) because Open vSwitch internally serializes
1023 * potentially conflicting changes.
1024 *
1025 * - Changes that occur when flow notification is paused (see "Buffer
1026 * Management" above).
1027 *
1028 * A flow_mod that does not change the flow table will not trigger any
1029 * notification, even an abbreviated one. For example, a "modify" or "delete"
1030 * flow_mod that does not match any flows will not trigger a notification.
1031 * Whether an "add" or "modify" that specifies all the same parameters that a
1032 * flow already has triggers a notification is unspecified and subject to
1033 * change in future versions of Open vSwitch.
1034 *
1035 * OVS will always send the notifications for a given flow table change before
1036 * the reply to a OFPT_BARRIER_REQUEST request that follows the flow table
1037 * change. Thus, if the controller does not receive an abbreviated (or
1038 * unabbreviated) notification for a flow_mod before the next
1039 * OFPT_BARRIER_REPLY, it will never receive one. */
1040 struct nx_flow_update_abbrev {
1041 ovs_be16 length; /* Length is 8. */
1042 ovs_be16 event; /* NXFME_ABBREV. */
1043 ovs_be32 xid; /* Controller-specified xid from flow_mod. */
1044 };
1045 OFP_ASSERT(sizeof(struct nx_flow_update_abbrev) == 8);
1046
1047 /* NXT_FLOW_MONITOR_CANCEL.
1048 *
1049 * Used by a controller to cancel an outstanding monitor. */
1050 struct nx_flow_monitor_cancel {
1051 ovs_be32 id; /* 'id' from nx_flow_monitor_request. */
1052 };
1053 OFP_ASSERT(sizeof(struct nx_flow_monitor_cancel) == 4);
1054
1055 /* Variable-length option TLV table maintenance commands.
1056 *
1057 * The option in Type-Length-Value format is widely used in tunnel options,
1058 * e.g., the base Geneve header is followed by zero or more options in TLV
1059 * format. Each option consists of a four byte option header and a variable
1060 * amount of option data interpreted according to the type. The generic TLV
1061 * format in tunnel options is as following:
1062 *
1063 * 0 1 2 3
1064 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1065 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1066 * | Option Class | Type |R|R|R| Length |
1067 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1068 * | Variable Option Data |
1069 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1070 *
1071 * In order to work with this variable-length options in TLV format in
1072 * tunnel options, we need to maintain a mapping table between an option
1073 * TLV (defined by <class, type, length>) and an NXM field that can be
1074 * operated on for the purposes of matches, actions, etc. This mapping
1075 * must be explicitly specified by the user.
1076 *
1077 * There are two primary groups of OpenFlow messages that are introduced
1078 * as Nicira extensions: modification commands (add, delete, clear mappings)
1079 * and table status request/reply to dump the current table along with switch
1080 * information.
1081 *
1082 * Note that mappings should not be changed while they are in active use by
1083 * a flow. The result of doing so is undefined. */
1084
1085 /* TLV table commands */
1086 enum nx_tlv_table_mod_command {
1087 NXTTMC_ADD, /* New mappings (fails if an option is already
1088 mapped). */
1089 NXTTMC_DELETE, /* Delete mappings, identified by index
1090 * (unmapped options are ignored). */
1091 NXTTMC_CLEAR, /* Clear all mappings. Additional information
1092 in this command is ignored. */
1093 };
1094
1095 /* Map between an option TLV and an NXM field. */
1096 struct nx_tlv_map {
1097 ovs_be16 option_class; /* TLV class. */
1098 uint8_t option_type; /* TLV type. */
1099 uint8_t option_len; /* TLV length (multiple of 4). */
1100 ovs_be16 index; /* NXM_NX_TUN_METADATA<n> index */
1101 uint8_t pad[2];
1102 };
1103 OFP_ASSERT(sizeof(struct nx_tlv_map) == 8);
1104
1105 /* NXT_TLV_TABLE_MOD.
1106 *
1107 * Use to configure a mapping between option TLVs (class, type, length)
1108 * and NXM fields (NXM_NX_TUN_METADATA<n> where 'index' is <n>).
1109 *
1110 * This command is atomic: all operations on different options will
1111 * either succeed or fail. */
1112 struct nx_tlv_table_mod {
1113 ovs_be16 command; /* One of NTTTMC_* */
1114 uint8_t pad[6];
1115 /* struct nx_tlv_map[0]; Array of maps between indicies and option
1116 TLVs. The number of elements is inferred
1117 from the length field in the header. */
1118 };
1119 OFP_ASSERT(sizeof(struct nx_tlv_table_mod) == 8);
1120
1121 /* NXT_TLV_TABLE_REPLY.
1122 *
1123 * Issued in reponse to an NXT_TLV_TABLE_REQUEST to give information
1124 * about the current status of the TLV table in the switch. Provides
1125 * both static information about the switch's capabilities as well as
1126 * the configured TLV table. */
1127 struct nx_tlv_table_reply {
1128 ovs_be32 max_option_space; /* Maximum total of option sizes supported. */
1129 ovs_be16 max_fields; /* Maximum number of match fields supported. */
1130 uint8_t reserved[10];
1131 /* struct nx_tlv_map[0]; Array of maps between indicies and option
1132 TLVs. The number of elements is inferred
1133 from the length field in the header. */
1134 };
1135 OFP_ASSERT(sizeof(struct nx_tlv_table_reply) == 16);
1136 \f
1137 /* NXT_CT_FLUSH_ZONE.
1138 *
1139 * Flushes the connection tracking table. */
1140 struct nx_zone_id {
1141 uint8_t zero[6]; /* Must be zero. */
1142 ovs_be16 zone_id; /* Connection tracking zone. */
1143 };
1144 OFP_ASSERT(sizeof(struct nx_zone_id) == 8);
1145
1146 #endif /* openflow/nicira-ext.h */