nicira-ext: Clarify comments about 'src' and 'dst' in NXAST_REG actions.
[sliver-openvswitch.git] / include / openflow / nicira-ext.h
1 /*
2  * Copyright (c) 2008, 2009, 2010 Nicira Networks
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 #define NICIRA_OUI_STR "002320"
24
25 /* The following vendor extensions, proposed by Nicira Networks, are not yet
26  * standardized, so they are not included in openflow.h.  Some of them may be
27  * suitable for standardization; others we never expect to standardize. */
28
29 #define NX_VENDOR_ID 0x00002320
30 \f
31 /* Nicira vendor-specific error messages extension.
32  *
33  * OpenFlow 1.0 has a set of predefined error types (OFPET_*) and codes (which
34  * are specific to each type).  It does not have any provision for
35  * vendor-specific error codes, and it does not even provide "generic" error
36  * codes that can apply to problems not anticipated by the OpenFlow
37  * specification authors.
38  *
39  * This extension attempts to address the problem by adding a generic "error
40  * vendor extension".  The extension works as follows: use NXET_VENDOR as type
41  * and NXVC_VENDOR_CODE as code, followed by struct nx_vendor_error with
42  * vendor-specific details, followed by at least 64 bytes of the failed
43  * request.
44  *
45  * It would be better to have a type-specific vendor extension, e.g. so that
46  * OFPET_BAD_ACTION could be used with vendor-specific code values.  But
47  * OFPET_BAD_ACTION and most other standardized types already specify that
48  * their 'data' values are (the start of) the OpenFlow message being replied
49  * to, so there is no room to insert a vendor ID.
50  *
51  * Currently this extension is only implemented by Open vSwitch, but it seems
52  * like a reasonable candidate for future standardization.
53  */
54
55 /* This is a random number to avoid accidental collision with any other
56  * vendor's extension. */
57 #define NXET_VENDOR 0xb0c2
58
59 /* ofp_error msg 'code' values for NXET_VENDOR. */
60 enum nx_vendor_code {
61     NXVC_VENDOR_ERROR           /* 'data' contains struct nx_vendor_error. */
62 };
63
64 /* 'data' for 'type' == NXET_VENDOR, 'code' == NXVC_VENDOR_ERROR. */
65 struct nx_vendor_error {
66     ovs_be32 vendor;            /* Vendor ID as in struct ofp_vendor_header. */
67     ovs_be16 type;              /* Vendor-defined type. */
68     ovs_be16 code;              /* Vendor-defined subtype. */
69     /* Followed by at least the first 64 bytes of the failed request. */
70 };
71 \f
72 /* Specific Nicira extension error numbers.
73  *
74  * These are the "code" values used in nx_vendor_error.  So far, the "type"
75  * values in nx_vendor_error are the same as those in ofp_error_msg.  That is,
76  * at Nicira so far we've only needed additional vendor-specific 'code' values,
77  * so we're using the existing 'type' values to avoid having to invent new ones
78  * that duplicate the current ones' meanings. */
79
80 /* Additional "code" values for OFPET_BAD_REQUEST. */
81 enum {
82 /* Nicira Extended Match (NXM) errors. */
83
84     /* Generic error code used when there is an error in an NXM sent to the
85      * switch.  The switch may use one of the more specific error codes below,
86      * if there is an appropriate one, to simplify debugging, but it is not
87      * required to do so. */
88     NXBRC_NXM_INVALID = 0x100,
89
90     /* The nxm_type, or nxm_type taken in combination with nxm_hasmask or
91      * nxm_length or both, is invalid or not implemented. */
92     NXBRC_NXM_BAD_TYPE = 0x101,
93
94     /* Invalid nxm_value. */
95     NXBRC_NXM_BAD_VALUE = 0x102,
96
97     /* Invalid nxm_mask. */
98     NXBRC_NXM_BAD_MASK = 0x103,
99
100     /* A prerequisite was not met. */
101     NXBRC_NXM_BAD_PREREQ = 0x104,
102
103     /* A given nxm_type was specified more than once. */
104     NXBRC_NXM_DUP_TYPE = 0x105
105 };
106
107 /* Additional "code" values for OFPET_FLOW_MOD_FAILED. */
108 enum {
109     /* Generic hardware error. */
110     NXFMFC_HARDWARE = 0x100,
111
112     /* A nonexistent table ID was specified in the "command" field of struct
113      * ofp_flow_mod, when the nxt_flow_mod_table_id extension is enabled.
114      * (This extension is not yet implemented on this branch of Open
115      * vSwitch.) */
116     NXFMFC_BAD_TABLE_ID = 0x101
117 };
118 \f
119 /* Nicira vendor requests and replies. */
120
121 /* Header for Nicira vendor requests and replies. */
122 struct nicira_header {
123     struct ofp_header header;
124     ovs_be32 vendor;            /* NX_VENDOR_ID. */
125     ovs_be32 subtype;           /* One of NXT_* below. */
126 };
127 OFP_ASSERT(sizeof(struct nicira_header) == 16);
128
129 /* Values for the 'subtype' member of struct nicira_header. */
130 enum nicira_type {
131     /* Switch status request.  The request body is an ASCII string that
132      * specifies a prefix of the key names to include in the output; if it is
133      * the null string, then all key-value pairs are included. */
134     NXT_STATUS_REQUEST,
135
136     /* Switch status reply.  The reply body is an ASCII string of key-value
137      * pairs in the form "key=value\n". */
138     NXT_STATUS_REPLY,
139
140     /* No longer used. */
141     NXT_ACT_SET_CONFIG__OBSOLETE,
142     NXT_ACT_GET_CONFIG__OBSOLETE,
143     NXT_COMMAND_REQUEST__OBSOLETE,
144     NXT_COMMAND_REPLY__OBSOLETE,
145     NXT_FLOW_END_CONFIG__OBSOLETE,
146     NXT_FLOW_END__OBSOLETE,
147     NXT_MGMT__OBSOLETE,
148
149     /* Use the high 32 bits of the cookie field as the tunnel ID in the flow
150      * match. */
151     NXT_TUN_ID_FROM_COOKIE,
152
153     /* Controller role support.  The request body is struct nx_role_request.
154      * The reply echos the request. */
155     NXT_ROLE_REQUEST,
156     NXT_ROLE_REPLY,
157
158     /* Flexible flow specification (aka NXM = Nicira Extended Match). */
159     NXT_SET_FLOW_FORMAT,        /* Set flow format. */
160     NXT_FLOW_MOD,               /* Analogous to OFPT_FLOW_MOD. */
161     NXT_FLOW_REMOVED            /* Analogous to OFPT_FLOW_REMOVED. */
162 };
163
164 /* Header for Nicira vendor stats request and reply messages. */
165 struct nicira_stats_msg {
166     struct ofp_header header;   /* OFPT_STATS_REQUEST or OFPT_STATS_REPLY. */
167     ovs_be16 type;              /* OFPST_VENDOR. */
168     ovs_be16 flags;             /* OFPSF_{REQ,REPLY}_*. */
169     ovs_be32 vendor;            /* NX_VENDOR_ID. */
170     ovs_be32 subtype;           /* One of NXST_* below. */
171     uint8_t pad[4];             /* Align to 64-bits. */
172 };
173 OFP_ASSERT(sizeof(struct nicira_stats_msg) == 24);
174
175 /* Values for the 'subtype' member of struct nicira_stats_msg. */
176 enum nicira_stats_type {
177     /* Flexible flow specification (aka NXM = Nicira Extended Match). */
178     NXST_FLOW,                  /* Analogous to OFPST_FLOW. */
179     NXST_AGGREGATE              /* Analogous to OFPST_AGGREGATE. */
180 };
181
182 /* NXT_TUN_ID_FROM_COOKIE request. */
183 struct nxt_tun_id_cookie {
184     struct ofp_header header;
185     uint32_t vendor;            /* NX_VENDOR_ID. */
186     uint32_t subtype;           /* NXT_TUN_ID_FROM_COOKIE */
187     uint8_t set;                /* Nonzero to enable, zero to disable. */
188     uint8_t pad[7];
189 };
190 OFP_ASSERT(sizeof(struct nxt_tun_id_cookie) == 24);
191
192 /* Configures the "role" of the sending controller.  The default role is:
193  *
194  *    - Other (NX_ROLE_OTHER), which allows the controller access to all
195  *      OpenFlow features.
196  *
197  * The other possible roles are a related pair:
198  *
199  *    - Master (NX_ROLE_MASTER) is equivalent to Other, except that there may
200  *      be at most one Master controller at a time: when a controller
201  *      configures itself as Master, any existing Master is demoted to the
202  *      Slave role.
203  *
204  *    - Slave (NX_ROLE_SLAVE) allows the controller read-only access to
205  *      OpenFlow features.  In particular attempts to modify the flow table
206  *      will be rejected with an OFPBRC_EPERM error.
207  *
208  *      Slave controllers do not receive OFPT_PACKET_IN or OFPT_FLOW_REMOVED
209  *      messages, but they do receive OFPT_PORT_STATUS messages.
210  */
211 struct nx_role_request {
212     struct nicira_header nxh;
213     uint32_t role;              /* One of NX_ROLE_*. */
214 };
215
216 enum nx_role {
217     NX_ROLE_OTHER,              /* Default role, full access. */
218     NX_ROLE_MASTER,             /* Full access, at most one. */
219     NX_ROLE_SLAVE               /* Read-only access. */
220 };
221 \f
222 /* Nicira vendor flow actions. */
223
224 enum nx_action_subtype {
225     NXAST_SNAT__OBSOLETE,       /* No longer used. */
226     NXAST_RESUBMIT,             /* struct nx_action_resubmit */
227     NXAST_SET_TUNNEL,           /* struct nx_action_set_tunnel */
228     NXAST_DROP_SPOOFED_ARP,     /* struct nx_action_drop_spoofed_arp */
229     NXAST_SET_QUEUE,            /* struct nx_action_set_queue */
230     NXAST_POP_QUEUE,            /* struct nx_action_pop_queue */
231     NXAST_REG_MOVE,             /* struct nx_action_reg_move */
232     NXAST_REG_LOAD,             /* struct nx_action_reg_load */
233     NXAST_NOTE                  /* struct nx_action_note */
234 };
235
236 /* Header for Nicira-defined actions. */
237 struct nx_action_header {
238     uint16_t type;                  /* OFPAT_VENDOR. */
239     uint16_t len;                   /* Length is 16. */
240     uint32_t vendor;                /* NX_VENDOR_ID. */
241     uint16_t subtype;               /* NXAST_*. */
242     uint8_t pad[6];
243 };
244 OFP_ASSERT(sizeof(struct nx_action_header) == 16);
245
246 /* Action structure for NXAST_RESUBMIT.
247  *
248  * NXAST_RESUBMIT searches the flow table again, using a flow that is slightly
249  * modified from the original lookup:
250  *
251  *    - The 'in_port' member of struct nx_action_resubmit is used as the flow's
252  *      in_port.
253  *
254  *    - If NXAST_RESUBMIT is preceded by actions that affect the flow
255  *      (e.g. OFPAT_SET_VLAN_VID), then the flow is updated with the new
256  *      values.
257  *
258  * Following the lookup, the original in_port is restored.
259  *
260  * If the modified flow matched in the flow table, then the corresponding
261  * actions are executed.  Afterward, actions following NXAST_RESUBMIT in the
262  * original set of actions, if any, are executed; any changes made to the
263  * packet (e.g. changes to VLAN) by secondary actions persist when those
264  * actions are executed, although the original in_port is restored.
265  *
266  * NXAST_RESUBMIT may be used any number of times within a set of actions.
267  *
268  * NXAST_RESUBMIT may nest to an implementation-defined depth.  Beyond this
269  * implementation-defined depth, further NXAST_RESUBMIT actions are simply
270  * ignored.  (Open vSwitch 1.0.1 and earlier did not support recursion.)
271  */
272 struct nx_action_resubmit {
273     uint16_t type;                  /* OFPAT_VENDOR. */
274     uint16_t len;                   /* Length is 16. */
275     uint32_t vendor;                /* NX_VENDOR_ID. */
276     uint16_t subtype;               /* NXAST_RESUBMIT. */
277     uint16_t in_port;               /* New in_port for checking flow table. */
278     uint8_t pad[4];
279 };
280 OFP_ASSERT(sizeof(struct nx_action_resubmit) == 16);
281
282 /* Action structure for NXAST_SET_TUNNEL.
283  *
284  * Sets the encapsulating tunnel ID. */
285 struct nx_action_set_tunnel {
286     uint16_t type;                  /* OFPAT_VENDOR. */
287     uint16_t len;                   /* Length is 16. */
288     uint32_t vendor;                /* NX_VENDOR_ID. */
289     uint16_t subtype;               /* NXAST_SET_TUNNEL. */
290     uint8_t pad[2];
291     uint32_t tun_id;                /* Tunnel ID. */
292 };
293 OFP_ASSERT(sizeof(struct nx_action_set_tunnel) == 16);
294
295 /* Action structure for NXAST_DROP_SPOOFED_ARP.
296  *
297  * Stops processing further actions, if the packet being processed is an
298  * Ethernet+IPv4 ARP packet for which the source Ethernet address inside the
299  * ARP packet differs from the source Ethernet address in the Ethernet header.
300  *
301  * This is useful because OpenFlow does not provide a way to match on the
302  * Ethernet addresses inside ARP packets, so there is no other way to drop
303  * spoofed ARPs other than sending every ARP packet to a controller. */
304 struct nx_action_drop_spoofed_arp {
305     uint16_t type;                  /* OFPAT_VENDOR. */
306     uint16_t len;                   /* Length is 16. */
307     uint32_t vendor;                /* NX_VENDOR_ID. */
308     uint16_t subtype;               /* NXAST_DROP_SPOOFED_ARP. */
309     uint8_t pad[6];
310 };
311 OFP_ASSERT(sizeof(struct nx_action_drop_spoofed_arp) == 16);
312
313 /* Action structure for NXAST_SET_QUEUE.
314  *
315  * Set the queue that should be used when packets are output.  This is similar
316  * to the OpenFlow OFPAT_ENQUEUE action, but does not take the output port as
317  * an argument.  This allows the queue to be defined before the port is
318  * known. */
319 struct nx_action_set_queue {
320     uint16_t type;                  /* OFPAT_VENDOR. */
321     uint16_t len;                   /* Length is 16. */
322     uint32_t vendor;                /* NX_VENDOR_ID. */
323     uint16_t subtype;               /* NXAST_SET_QUEUE. */
324     uint8_t pad[2];
325     uint32_t queue_id;              /* Where to enqueue packets. */
326 };
327 OFP_ASSERT(sizeof(struct nx_action_set_queue) == 16);
328
329 /* Action structure for NXAST_POP_QUEUE.
330  *
331  * Restores the queue to the value it was before any NXAST_SET_QUEUE actions
332  * were used.  Only the original queue can be restored this way; no stack is
333  * maintained. */
334 struct nx_action_pop_queue {
335     uint16_t type;                  /* OFPAT_VENDOR. */
336     uint16_t len;                   /* Length is 16. */
337     uint32_t vendor;                /* NX_VENDOR_ID. */
338     uint16_t subtype;               /* NXAST_POP_QUEUE. */
339     uint8_t pad[6];
340 };
341 OFP_ASSERT(sizeof(struct nx_action_pop_queue) == 16);
342
343 /* Action structure for NXAST_REG_MOVE.
344  *
345  * Copies src[src_ofs:src_ofs+n_bits] to dst[dst_ofs:dst_ofs+n_bits], where
346  * a[b:c] denotes the bits within 'a' numbered 'b' through 'c' (not including
347  * bit 'c').  Bit numbering starts at 0 for the least-significant bit, 1 for
348  * the next most significant bit, and so on.
349  *
350  * 'src' and 'dst' are nxm_header values with nxm_hasmask=0.  (It doesn't make
351  * sense to use nxm_hasmask=1 because the action does not do any kind of
352  * matching; it uses the actual value of a field.)
353  *
354  * The following nxm_header values are potentially acceptable as 'src':
355  *
356  *   - NXM_OF_IN_PORT
357  *   - NXM_OF_ETH_DST
358  *   - NXM_OF_ETH_SRC
359  *   - NXM_OF_ETH_TYPE
360  *   - NXM_OF_VLAN_TCI
361  *   - NXM_OF_IP_TOS
362  *   - NXM_OF_IP_PROTO
363  *   - NXM_OF_IP_SRC
364  *   - NXM_OF_IP_DST
365  *   - NXM_OF_TCP_SRC
366  *   - NXM_OF_TCP_DST
367  *   - NXM_OF_UDP_SRC
368  *   - NXM_OF_UDP_DST
369  *   - NXM_OF_ICMP_TYPE
370  *   - NXM_OF_ICMP_CODE
371  *   - NXM_OF_ARP_OP
372  *   - NXM_OF_ARP_SPA
373  *   - NXM_OF_ARP_TPA
374  *   - NXM_NX_TUN_ID
375  *   - NXM_NX_REG(idx) for idx in the switch's accepted range.
376  *
377  * The following nxm_header values are potentially acceptable as 'dst':
378  *
379  *   - NXM_NX_REG(idx) for idx in the switch's accepted range.
380  *
381  *   - NXM_OF_VLAN_TCI.  Modifying this field's value has side effects on the
382  *     packet's 802.1Q header.  Setting a value with CFI=0 removes the 802.1Q
383  *     header (if any), ignoring the other bits.  Setting a value with CFI=1
384  *     adds or modifies the 802.1Q header appropriately, setting the TCI field
385  *     to the field's new value (with the CFI bit masked out).
386  *
387  *   - NXM_NX_TUN_ID.  Modifying this value modifies the tunnel ID used for the
388  *     packet's next tunnel encapsulation.
389  *
390  * A given nxm_header value may be used as 'src' or 'dst' only on a flow whose
391  * nx_match satisfies its prerequisites.  For example, NXM_OF_IP_TOS may be
392  * used only if the flow's nx_match includes an nxm_entry that specifies
393  * nxm_type=NXM_OF_ETH_TYPE, nxm_hasmask=0, and nxm_value=0x0800.
394  *
395  * The switch will reject actions for which src_ofs+n_bits is greater than the
396  * width of 'src' or dst_ofs+n_bits is greater than the width of 'dst' with
397  * error type OFPET_BAD_ACTION, code OFPBAC_BAD_ARGUMENT.
398  */
399 struct nx_action_reg_move {
400     ovs_be16 type;                  /* OFPAT_VENDOR. */
401     ovs_be16 len;                   /* Length is 16. */
402     ovs_be32 vendor;                /* NX_VENDOR_ID. */
403     ovs_be16 subtype;               /* NXAST_REG_MOVE. */
404     ovs_be16 n_bits;                /* Number of bits. */
405     ovs_be16 src_ofs;               /* Starting bit offset in source. */
406     ovs_be16 dst_ofs;               /* Starting bit offset in destination. */
407     ovs_be32 src;                   /* Source register. */
408     ovs_be32 dst;                   /* Destination register. */
409 };
410 OFP_ASSERT(sizeof(struct nx_action_reg_move) == 24);
411
412 /* Action structure for NXAST_REG_LOAD.
413  *
414  * Copies value[0:n_bits] to dst[ofs:ofs+n_bits], where a[b:c] denotes the bits
415  * within 'a' numbered 'b' through 'c' (not including bit 'c').  Bit numbering
416  * starts at 0 for the least-significant bit, 1 for the next most significant
417  * bit, and so on.
418  *
419  * 'dst' is an nxm_header with nxm_hasmask=0.  It must be one of the following:
420  *
421  *   - NXM_NX_REG(idx) for idx in the switch's accepted range.
422  *
423  * The 'ofs' and 'n_bits' fields are combined into a single 'ofs_nbits' field
424  * to avoid enlarging the structure by another 8 bytes.  To allow 'n_bits' to
425  * take a value between 1 and 64 (inclusive) while taking up only 6 bits, it is
426  * also stored as one less than its true value:
427  *
428  *  15                           6 5                0
429  * +------------------------------+------------------+
430  * |              ofs             |    n_bits - 1    |
431  * +------------------------------+------------------+
432  *
433  * The switch will reject actions for which ofs+n_bits is greater than the
434  * width of 'dst', or in which any bits in 'value' with value 2**n_bits or
435  * greater are set to 1, with error type OFPET_BAD_ACTION, code
436  * OFPBAC_BAD_ARGUMENT.
437  */
438 struct nx_action_reg_load {
439     ovs_be16 type;                  /* OFPAT_VENDOR. */
440     ovs_be16 len;                   /* Length is 16. */
441     ovs_be32 vendor;                /* NX_VENDOR_ID. */
442     ovs_be16 subtype;               /* NXAST_REG_LOAD. */
443     ovs_be16 ofs_nbits;             /* (ofs << 6) | (n_bits - 1). */
444     ovs_be32 dst;                   /* Destination register. */
445     ovs_be64 value;                 /* Immediate value. */
446 };
447 OFP_ASSERT(sizeof(struct nx_action_reg_load) == 24);
448
449 /* Action structure for NXAST_NOTE.
450  *
451  * This action has no effect.  It is variable length.  The switch does not
452  * attempt to interpret the user-defined 'note' data in any way.  A controller
453  * can use this action to attach arbitrary metadata to a flow.
454  *
455  * This action might go away in the future.
456  */
457 struct nx_action_note {
458     uint16_t type;                  /* OFPAT_VENDOR. */
459     uint16_t len;                   /* A multiple of 8, but at least 16. */
460     uint32_t vendor;                /* NX_VENDOR_ID. */
461     uint16_t subtype;               /* NXAST_NOTE. */
462     uint8_t note[6];                /* Start of user-defined data. */
463     /* Possibly followed by additional user-defined data. */
464 };
465 OFP_ASSERT(sizeof(struct nx_action_note) == 16);
466
467 /* Wildcard for tunnel ID. */
468 #define NXFW_TUN_ID  (1 << 25)
469
470 #define NXFW_ALL NXFW_TUN_ID
471 #define OVSFW_ALL (OFPFW_ALL | NXFW_ALL)
472 \f
473 /* Flexible flow specifications (aka NXM = Nicira Extended Match).
474  *
475  * OpenFlow 1.0 has "struct ofp_match" for specifying flow matches.  This
476  * structure is fixed-length and hence difficult to extend.  This section
477  * describes a more flexible, variable-length flow match, called "nx_match" for
478  * short, that is also supported by Open vSwitch.  This section also defines a
479  * replacement for each OpenFlow message that includes struct ofp_match.
480  *
481  *
482  * Format
483  * ======
484  *
485  * An nx_match is a sequence of zero or more "nxm_entry"s, which are
486  * type-length-value (TLV) entries, each 5 to 259 (inclusive) bytes long.
487  * "nxm_entry"s are not aligned on or padded to any multibyte boundary.  The
488  * first 4 bytes of an nxm_entry are its "header", followed by the entry's
489  * "body".
490  *
491  * An nxm_entry's header is interpreted as a 32-bit word in network byte order:
492  *
493  * |<-------------------- nxm_type ------------------>|
494  * |                                                  |
495  * |31                              16 15            9| 8 7                0
496  * +----------------------------------+---------------+--+------------------+
497  * |            nxm_vendor            |   nxm_field   |hm|    nxm_length    |
498  * +----------------------------------+---------------+--+------------------+
499  *
500  * The most-significant 23 bits of the header are collectively "nxm_type".
501  * Bits 16...31 are "nxm_vendor", one of the NXM_VENDOR_* values below.  Bits
502  * 9...15 are "nxm_field", which is a vendor-specific value.  nxm_type normally
503  * designates a protocol header, such as the Ethernet type, but it can also
504  * refer to packet metadata, such as the switch port on which a packet arrived.
505  *
506  * Bit 8 is "nxm_hasmask" (labeled "hm" above for space reasons).  The meaning
507  * of this bit is explained later.
508  *
509  * The least-significant 8 bits are "nxm_length", a positive integer.  The
510  * length of the nxm_entry, including the header, is exactly 4 + nxm_length
511  * bytes.
512  *
513  * For a given nxm_vendor, nxm_field, and nxm_hasmask value, nxm_length is a
514  * constant.  It is included only to allow software to minimally parse
515  * "nxm_entry"s of unknown types.  (Similarly, for a given nxm_vendor,
516  * nxm_field, and nxm_length, nxm_hasmask is a constant.)
517  *
518  *
519  * Semantics
520  * =========
521  *
522  * A zero-length nx_match (one with no "nxm_entry"s) matches every packet.
523  *
524  * An nxm_entry places a constraint on the packets matched by the nx_match:
525  *
526  *   - If nxm_hasmask is 0, the nxm_entry's body contains a value for the
527  *     field, called "nxm_value".  The nx_match matches only packets in which
528  *     the field equals nxm_value.
529  *
530  *   - If nxm_hasmask is 1, then the nxm_entry's body contains a value for the
531  *     field (nxm_value), followed by a bitmask of the same length as the
532  *     value, called "nxm_mask".  For each 1-bit in position J in nxm_mask, the
533  *     nx_match matches only packets for which bit J in the given field's value
534  *     matches bit J in nxm_value.  A 0-bit in nxm_mask causes the
535  *     corresponding bits in nxm_value and the field's value to be ignored.
536  *     (The sense of the nxm_mask bits is the opposite of that used by the
537  *     "wildcards" member of struct ofp_match.)
538  *
539  *     When nxm_hasmask is 1, nxm_length is always even.
540  *
541  *     An all-zero-bits nxm_mask is equivalent to omitting the nxm_entry
542  *     entirely.  An all-one-bits nxm_mask is equivalent to specifying 0 for
543  *     nxm_hasmask.
544  *
545  * When there are multiple "nxm_entry"s, all of the constraints must be met.
546  *
547  *
548  * Mask Restrictions
549  * =================
550  *
551  * Masks may be restricted:
552  *
553  *   - Some nxm_types may not support masked wildcards, that is, nxm_hasmask
554  *     must always be 0 when these fields are specified.  For example, the
555  *     field that identifies the port on which a packet was received may not be
556  *     masked.
557  *
558  *   - Some nxm_types that do support masked wildcards may only support certain
559  *     nxm_mask patterns.  For example, fields that have IPv4 address values
560  *     may be restricted to CIDR masks.
561  *
562  * These restrictions should be noted in specifications for individual fields.
563  * A switch may accept an nxm_hasmask or nxm_mask value that the specification
564  * disallows, if the switch correctly implements support for that nxm_hasmask
565  * or nxm_mask value.  A switch must reject an attempt to set up a flow that
566  * contains a nxm_hasmask or nxm_mask value that it does not support.
567  *
568  *
569  * Prerequisite Restrictions
570  * =========================
571  *
572  * The presence of an nxm_entry with a given nxm_type may be restricted based
573  * on the presence of or values of other "nxm_entry"s.  For example:
574  *
575  *   - An nxm_entry for nxm_type=NXM_OF_IP_TOS is allowed only if it is
576  *     preceded by another entry with nxm_type=NXM_OF_ETH_TYPE, nxm_hasmask=0,
577  *     and nxm_value=0x0800.  That is, matching on the IP source address is
578  *     allowed only if the Ethernet type is explicitly set to IP.
579  *
580  *   - An nxm_entry for nxm_type=NXM_OF_TCP_SRC is allowed only if it is preced
581  *     by an entry with nxm_type=NXM_OF_ETH_TYPE, nxm_hasmask=0,
582  *     nxm_value=0x0800 and another with nxm_type=NXM_OF_IP_PROTO,
583  *     nxm_hasmask=0, nxm_value=6, in that order.  That is, matching on the TCP
584  *     source port is allowed only if the Ethernet type is IP and the IP
585  *     protocol is TCP.
586  *
587  * These restrictions should be noted in specifications for individual fields.
588  * A switch may implement relaxed versions of these restrictions.  A switch
589  * must reject an attempt to set up a flow that violates its restrictions.
590  *
591  *
592  * Ordering Restrictions
593  * =====================
594  *
595  * An nxm_entry that has prerequisite restrictions must appear after the
596  * "nxm_entry"s for its prerequisites.  Ordering of "nxm_entry"s within an
597  * nx_match is not otherwise constrained.
598  *
599  * Any given nxm_type may appear in an nx_match at most once.
600  *
601  *
602  * nxm_entry Examples
603  * ==================
604  *
605  * These examples show the format of a single nxm_entry with particular
606  * nxm_hasmask and nxm_length values.  The diagrams are labeled with field
607  * numbers and byte indexes.
608  *
609  *
610  * 8-bit nxm_value, nxm_hasmask=1, nxm_length=1:
611  *
612  *  0          3  4   5
613  * +------------+---+---+
614  * |   header   | v | m |
615  * +------------+---+---+
616  *
617  *
618  * 16-bit nxm_value, nxm_hasmask=0, nxm_length=2:
619  *
620  *  0          3 4    5
621  * +------------+------+
622  * |   header   | value|
623  * +------------+------+
624  *
625  *
626  * 32-bit nxm_value, nxm_hasmask=0, nxm_length=4:
627  *
628  *  0          3 4           7
629  * +------------+-------------+
630  * |   header   |  nxm_value  |
631  * +------------+-------------+
632  *
633  *
634  * 48-bit nxm_value, nxm_hasmask=0, nxm_length=6:
635  *
636  *  0          3 4                9
637  * +------------+------------------+
638  * |   header   |     nxm_value    |
639  * +------------+------------------+
640  *
641  *
642  * 48-bit nxm_value, nxm_hasmask=1, nxm_length=12:
643  *
644  *  0          3 4                9 10              15
645  * +------------+------------------+------------------+
646  * |   header   |     nxm_value    |      nxm_mask    |
647  * +------------+------------------+------------------+
648  *
649  *
650  * Error Reporting
651  * ===============
652  *
653  * A switch should report an error in an nx_match using error type
654  * OFPET_BAD_REQUEST and one of the NXBRC_NXM_* codes.  Ideally the switch
655  * should report a specific error code, if one is assigned for the particular
656  * problem, but NXBRC_NXM_INVALID is also available to report a generic
657  * nx_match error.
658  */
659
660 #define NXM_HEADER__(VENDOR, FIELD, HASMASK, LENGTH) \
661     (((VENDOR) << 16) | ((FIELD) << 9) | ((HASMASK) << 8) | (LENGTH))
662 #define NXM_HEADER(VENDOR, FIELD, LENGTH) \
663     NXM_HEADER__(VENDOR, FIELD, 0, LENGTH)
664 #define NXM_HEADER_W(VENDOR, FIELD, LENGTH) \
665     NXM_HEADER__(VENDOR, FIELD, 1, (LENGTH) * 2)
666 #define NXM_VENDOR(HEADER) ((HEADER) >> 16)
667 #define NXM_FIELD(HEADER) (((HEADER) >> 9) & 0x7f)
668 #define NXM_TYPE(HEADER) (((HEADER) >> 9) & 0x7fffff)
669 #define NXM_HASMASK(HEADER) (((HEADER) >> 8) & 1)
670 #define NXM_LENGTH(HEADER) ((HEADER) & 0xff)
671
672 #define NXM_MAKE_WILD_HEADER(HEADER) \
673         NXM_HEADER_W(NXM_VENDOR(HEADER), NXM_FIELD(HEADER), NXM_LENGTH(HEADER))
674
675 /* ## ------------------------------- ## */
676 /* ## OpenFlow 1.0-compatible fields. ## */
677 /* ## ------------------------------- ## */
678
679 /* Physical or virtual port on which the packet was received.
680  *
681  * Prereqs: None.
682  *
683  * Format: 16-bit integer in network byte order.
684  *
685  * Masking: Not maskable. */
686 #define NXM_OF_IN_PORT    NXM_HEADER  (0x0000,  0, 2)
687
688 /* Source or destination address in Ethernet header.
689  *
690  * Prereqs: None.
691  *
692  * Format: 48-bit Ethernet MAC address.
693  *
694  * Masking: The nxm_mask patterns 01:00:00:00:00:00 and FE:FF:FF:FF:FF:FF must
695  *   be supported for NXM_OF_ETH_DST_W (as well as the trivial patterns that
696  *   are all-0-bits or all-1-bits).  Support for other patterns and for masking
697  *   of NXM_OF_ETH_SRC is optional. */
698 #define NXM_OF_ETH_DST    NXM_HEADER  (0x0000,  1, 6)
699 #define NXM_OF_ETH_DST_W  NXM_HEADER_W(0x0000,  1, 6)
700 #define NXM_OF_ETH_SRC    NXM_HEADER  (0x0000,  2, 6)
701
702 /* Packet's Ethernet type.
703  *
704  * For an Ethernet II packet this is taken from the Ethernet header.  For an
705  * 802.2 LLC+SNAP header with OUI 00-00-00 this is taken from the SNAP header.
706  * A packet that has neither format has value 0x05ff
707  * (OFP_DL_TYPE_NOT_ETH_TYPE).
708  *
709  * For a packet with an 802.1Q header, this is the type of the encapsulated
710  * frame.
711  *
712  * Prereqs: None.
713  *
714  * Format: 16-bit integer in network byte order.
715  *
716  * Masking: Not maskable. */
717 #define NXM_OF_ETH_TYPE   NXM_HEADER  (0x0000,  3, 2)
718
719 /* 802.1Q TCI.
720  *
721  * For a packet with an 802.1Q header, this is the Tag Control Information
722  * (TCI) field, with the CFI bit forced to 1.  For a packet with no 802.1Q
723  * header, this has value 0.
724  *
725  * Prereqs: None.
726  *
727  * Format: 16-bit integer in network byte order.
728  *
729  * Masking: Arbitrary masks.
730  *
731  * This field can be used in various ways:
732  *
733  *   - If it is not constrained at all, the nx_match matches packets without
734  *     an 802.1Q header or with an 802.1Q header that has any TCI value.
735  *
736  *   - Testing for an exact match with 0 matches only packets without an
737  *     802.1Q header.
738  *
739  *   - Testing for an exact match with a TCI value with CFI=1 matches packets
740  *     that have an 802.1Q header with a specified VID and PCP.
741  *
742  *   - Testing for an exact match with a nonzero TCI value with CFI=0 does
743  *     not make sense.  The switch may reject this combination.
744  *
745  *   - Testing with a specific VID and CFI=1, with nxm_mask=0x1fff, matches
746  *     packets that have an 802.1Q header with that VID (and any PCP).
747  *
748  *   - Testing with a specific PCP and CFI=1, with nxm_mask=0xf000, matches
749  *     packets that have an 802.1Q header with that PCP (and any VID).
750  *
751  *   - Testing with nxm_value=0, nxm_mask=0xe000 matches packets with no 802.1Q
752  *     header or with an 802.1Q header with a VID of 0.
753  */
754 #define NXM_OF_VLAN_TCI   NXM_HEADER  (0x0000,  4, 2)
755 #define NXM_OF_VLAN_TCI_W NXM_HEADER_W(0x0000,  4, 2)
756
757 /* The "type of service" byte of the IP header, with the ECN bits forced to 0.
758  *
759  * Prereqs: NXM_OF_ETH_TYPE must match 0x0800 exactly.
760  *
761  * Format: 8-bit integer with 2 least-significant bits forced to 0.
762  *
763  * Masking: Not maskable. */
764 #define NXM_OF_IP_TOS     NXM_HEADER  (0x0000,  5, 1)
765
766 /* The "protocol" byte in the IP header.
767  *
768  * Prereqs: NXM_OF_ETH_TYPE must match 0x0800 exactly.
769  *
770  * Format: 8-bit integer.
771  *
772  * Masking: Not maskable. */
773 #define NXM_OF_IP_PROTO   NXM_HEADER  (0x0000,  6, 1)
774
775 /* The source or destination address in the IP header.
776  *
777  * Prereqs: NXM_OF_ETH_TYPE must match 0x0800 exactly.
778  *
779  * Format: 32-bit integer in network byte order.
780  *
781  * Masking: Only CIDR masks are allowed, that is, masks that consist of N
782  *   high-order bits set to 1 and the other 32-N bits set to 0. */
783 #define NXM_OF_IP_SRC     NXM_HEADER  (0x0000,  7, 4)
784 #define NXM_OF_IP_SRC_W   NXM_HEADER_W(0x0000,  7, 4)
785 #define NXM_OF_IP_DST     NXM_HEADER  (0x0000,  8, 4)
786 #define NXM_OF_IP_DST_W   NXM_HEADER_W(0x0000,  8, 4)
787
788 /* The source or destination port in the TCP header.
789  *
790  * Prereqs:
791  *   NXM_OF_ETH_TYPE must match 0x0800 exactly.
792  *   NXM_OF_IP_PROTO must match 6 exactly.
793  *
794  * Format: 16-bit integer in network byte order.
795  *
796  * Masking: Not maskable. */
797 #define NXM_OF_TCP_SRC    NXM_HEADER  (0x0000,  9, 2)
798 #define NXM_OF_TCP_DST    NXM_HEADER  (0x0000, 10, 2)
799
800 /* The source or destination port in the UDP header.
801  *
802  * Prereqs:
803  *   NXM_OF_ETH_TYPE must match 0x0800 exactly.
804  *   NXM_OF_IP_PROTO must match 17 exactly.
805  *
806  * Format: 16-bit integer in network byte order.
807  *
808  * Masking: Not maskable. */
809 #define NXM_OF_UDP_SRC    NXM_HEADER  (0x0000, 11, 2)
810 #define NXM_OF_UDP_DST    NXM_HEADER  (0x0000, 12, 2)
811
812 /* The type or code in the ICMP header.
813  *
814  * Prereqs:
815  *   NXM_OF_ETH_TYPE must match 0x0800 exactly.
816  *   NXM_OF_IP_PROTO must match 1 exactly.
817  *
818  * Format: 8-bit integer.
819  *
820  * Masking: Not maskable. */
821 #define NXM_OF_ICMP_TYPE  NXM_HEADER  (0x0000, 13, 1)
822 #define NXM_OF_ICMP_CODE  NXM_HEADER  (0x0000, 14, 1)
823
824 /* ARP opcode.
825  *
826  * For an Ethernet+IP ARP packet, the opcode in the ARP header.  Always 0
827  * otherwise.  Only ARP opcodes between 1 and 255 should be specified for
828  * matching.
829  *
830  * Prereqs: NXM_OF_ETH_TYPE must match 0x0806 exactly.
831  *
832  * Format: 16-bit integer in network byte order.
833  *
834  * Masking: Not maskable. */
835 #define NXM_OF_ARP_OP     NXM_HEADER  (0x0000, 15, 2)
836
837 /* For an Ethernet+IP ARP packet, the source or target protocol address
838  * in the ARP header.  Always 0 otherwise.
839  *
840  * Prereqs: NXM_OF_ETH_TYPE must match 0x0806 exactly.
841  *
842  * Format: 32-bit integer in network byte order.
843  *
844  * Masking: Only CIDR masks are allowed, that is, masks that consist of N
845  *   high-order bits set to 1 and the other 32-N bits set to 0. */
846 #define NXM_OF_ARP_SPA    NXM_HEADER  (0x0000, 16, 4)
847 #define NXM_OF_ARP_SPA_W  NXM_HEADER_W(0x0000, 16, 4)
848 #define NXM_OF_ARP_TPA    NXM_HEADER  (0x0000, 17, 4)
849 #define NXM_OF_ARP_TPA_W  NXM_HEADER_W(0x0000, 17, 4)
850
851 /* ## ------------------------ ## */
852 /* ## Nicira match extensions. ## */
853 /* ## ------------------------ ## */
854
855 /* Metadata registers.
856  *
857  * Registers initially have value 0.  Actions allow register values to be
858  * manipulated.
859  *
860  * Prereqs: None.
861  *
862  * Format: Array of 32-bit integer registers.  Space is reserved for up to
863  *   NXM_NX_MAX_REGS registers, but switches may implement fewer.
864  *
865  * Masking: Arbitrary masks. */
866 #define NXM_NX_MAX_REGS 16
867 #define NXM_NX_REG(IDX)   NXM_HEADER  (0x0001, IDX, 4)
868 #define NXM_NX_REG_W(IDX) NXM_HEADER_W(0x0001, IDX, 4)
869 #define NXM_NX_REG_IDX(HEADER) NXM_FIELD(HEADER)
870 #define NXM_IS_NX_REG(HEADER) (!((((HEADER) ^ NXM_NX_REG0)) & 0xffffe1ff))
871 #define NXM_IS_NX_REG_W(HEADER) (!((((HEADER) ^ NXM_NX_REG0_W)) & 0xffffe1ff))
872 #define NXM_NX_REG0       NXM_HEADER  (0x0001, 0, 4)
873 #define NXM_NX_REG0_W     NXM_HEADER_W(0x0001, 0, 4)
874 #define NXM_NX_REG1       NXM_HEADER  (0x0001, 1, 4)
875 #define NXM_NX_REG1_W     NXM_HEADER_W(0x0001, 1, 4)
876 #define NXM_NX_REG2       NXM_HEADER  (0x0001, 2, 4)
877 #define NXM_NX_REG2_W     NXM_HEADER_W(0x0001, 2, 4)
878 #define NXM_NX_REG3       NXM_HEADER  (0x0001, 3, 4)
879 #define NXM_NX_REG3_W     NXM_HEADER_W(0x0001, 3, 4)
880
881 /* Tunnel ID.
882  *
883  * For a packet received via GRE tunnel including a (32-bit) key, the key is
884  * stored in the low 32-bits and the high bits are zeroed.  For other packets,
885  * the value is 0.
886  *
887  * Prereqs: None.
888  *
889  * Format: 64-bit integer in network byte order.
890  *
891  * Masking: Arbitrary masks. */
892 #define NXM_NX_TUN_ID     NXM_HEADER  (0x0001, 16, 8)
893 #define NXM_NX_TUN_ID_W   NXM_HEADER_W(0x0001, 16, 8)
894
895 /* ## --------------------- ## */
896 /* ## Requests and replies. ## */
897 /* ## --------------------- ## */
898
899 enum nx_flow_format {
900     NXFF_OPENFLOW10 = 0,         /* Standard OpenFlow 1.0 compatible. */
901     NXFF_TUN_ID_FROM_COOKIE = 1, /* OpenFlow 1.0, plus obtain tunnel ID from
902                                   * cookie. */
903     NXFF_NXM = 2                 /* Nicira extended match. */
904 };
905
906 /* NXT_SET_FLOW_FORMAT request. */
907 struct nxt_set_flow_format {
908     struct ofp_header header;
909     ovs_be32 vendor;            /* NX_VENDOR_ID. */
910     ovs_be32 subtype;           /* NXT_SET_FLOW_FORMAT. */
911     ovs_be32 format;            /* One of NXFF_*. */
912 };
913 OFP_ASSERT(sizeof(struct nxt_set_flow_format) == 20);
914
915 /* NXT_FLOW_MOD (analogous to OFPT_FLOW_MOD). */
916 struct nx_flow_mod {
917     struct nicira_header nxh;
918     ovs_be64 cookie;              /* Opaque controller-issued identifier. */
919     ovs_be16 command;             /* One of OFPFC_*. */
920     ovs_be16 idle_timeout;        /* Idle time before discarding (seconds). */
921     ovs_be16 hard_timeout;        /* Max time before discarding (seconds). */
922     ovs_be16 priority;            /* Priority level of flow entry. */
923     ovs_be32 buffer_id;           /* Buffered packet to apply to (or -1).
924                                      Not meaningful for OFPFC_DELETE*. */
925     ovs_be16 out_port;            /* For OFPFC_DELETE* commands, require
926                                      matching entries to include this as an
927                                      output port.  A value of OFPP_NONE
928                                      indicates no restriction. */
929     ovs_be16 flags;               /* One of OFPFF_*. */
930     ovs_be16 match_len;           /* Size of nx_match. */
931     uint8_t pad[6];               /* Align to 64-bits. */
932     /* Followed by:
933      *   - Exactly match_len (possibly 0) bytes containing the nx_match, then
934      *   - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
935      *     all-zero bytes, then
936      *   - Actions to fill out the remainder of the message length (always a
937      *     multiple of 8).
938      */
939 };
940 OFP_ASSERT(sizeof(struct nx_flow_mod) == 48);
941
942 /* NXT_FLOW_REMOVED (analogous to OFPT_FLOW_REMOVED). */
943 struct nx_flow_removed {
944     struct nicira_header nxh;
945     ovs_be64 cookie;          /* Opaque controller-issued identifier. */
946     ovs_be16 priority;        /* Priority level of flow entry. */
947     uint8_t reason;           /* One of OFPRR_*. */
948     uint8_t pad[1];           /* Align to 32-bits. */
949     ovs_be32 duration_sec;    /* Time flow was alive in seconds. */
950     ovs_be32 duration_nsec;   /* Time flow was alive in nanoseconds beyond
951                                  duration_sec. */
952     ovs_be16 idle_timeout;    /* Idle timeout from original flow mod. */
953     ovs_be16 match_len;       /* Size of nx_match. */
954     ovs_be64 packet_count;
955     ovs_be64 byte_count;
956     /* Followed by:
957      *   - Exactly match_len (possibly 0) bytes containing the nx_match, then
958      *   - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
959      *     all-zero bytes. */
960 };
961 OFP_ASSERT(sizeof(struct nx_flow_removed) == 56);
962
963 /* Nicira vendor stats request of type NXST_FLOW (analogous to OFPST_FLOW
964  * request). */
965 struct nx_flow_stats_request {
966     struct nicira_stats_msg nsm;
967     ovs_be16 out_port;        /* Require matching entries to include this
968                                  as an output port.  A value of OFPP_NONE
969                                  indicates no restriction. */
970     ovs_be16 match_len;       /* Length of nx_match. */
971     uint8_t table_id;         /* ID of table to read (from ofp_table_stats)
972                                  or 0xff for all tables. */
973     uint8_t pad[3];           /* Align to 64 bits. */
974     /* Followed by:
975      *   - Exactly match_len (possibly 0) bytes containing the nx_match, then
976      *   - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
977      *     all-zero bytes, which must also exactly fill out the length of the
978      *     message.
979      */
980 };
981 OFP_ASSERT(sizeof(struct nx_flow_stats_request) == 32);
982
983 /* Body for Nicira vendor stats reply of type NXST_FLOW (analogous to
984  * OFPST_FLOW reply). */
985 struct nx_flow_stats {
986     ovs_be16 length;          /* Length of this entry. */
987     uint8_t table_id;         /* ID of table flow came from. */
988     uint8_t pad;
989     ovs_be32 duration_sec;    /* Time flow has been alive in seconds. */
990     ovs_be32 duration_nsec;   /* Time flow has been alive in nanoseconds
991                                  beyond duration_sec. */
992     ovs_be16 priority;        /* Priority of the entry. Only meaningful
993                                  when this is not an exact-match entry. */
994     ovs_be16 idle_timeout;    /* Number of seconds idle before expiration. */
995     ovs_be16 hard_timeout;    /* Number of seconds before expiration. */
996     ovs_be16 match_len;       /* Length of nx_match. */
997     uint8_t pad2[4];          /* Align to 64 bits. */
998     ovs_be64 cookie;          /* Opaque controller-issued identifier. */
999     ovs_be64 packet_count;    /* Number of packets in flow. */
1000     ovs_be64 byte_count;      /* Number of bytes in flow. */
1001     /* Followed by:
1002      *   - Exactly match_len (possibly 0) bytes containing the nx_match, then
1003      *   - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
1004      *     all-zero bytes, then
1005      *   - Actions to fill out the remainder 'length' bytes (always a multiple
1006      *     of 8).
1007      */
1008 };
1009 OFP_ASSERT(sizeof(struct nx_flow_stats) == 48);
1010
1011 /* Nicira vendor stats request of type NXST_AGGREGATE (analogous to
1012  * OFPST_AGGREGATE request). */
1013 struct nx_aggregate_stats_request {
1014     struct nicira_stats_msg nsm;
1015     ovs_be16 out_port;        /* Require matching entries to include this
1016                                  as an output port.  A value of OFPP_NONE
1017                                  indicates no restriction. */
1018     ovs_be16 match_len;       /* Length of nx_match. */
1019     uint8_t table_id;         /* ID of table to read (from ofp_table_stats)
1020                                  or 0xff for all tables. */
1021     uint8_t pad[3];           /* Align to 64 bits. */
1022     /* Followed by:
1023      *   - Exactly match_len (possibly 0) bytes containing the nx_match, then
1024      *   - Exactly (match_len + 7)/8*8 - match_len (between 0 and 7) bytes of
1025      *     all-zero bytes, which must also exactly fill out the length of the
1026      *     message.
1027      */
1028 };
1029 OFP_ASSERT(sizeof(struct nx_aggregate_stats_request) == 32);
1030
1031 /* Body for nicira_stats_msg reply of type NXST_AGGREGATE (analogous to
1032  * OFPST_AGGREGATE reply).
1033  *
1034  * ofp_aggregate_stats_reply does not contain an ofp_match structure, so we
1035  * reuse it entirely.  (It would be very odd to use OFPST_AGGREGATE to reply to
1036  * an NXST_AGGREGATE request, so we don't do that.) */
1037 struct nx_aggregate_stats_reply {
1038     struct nicira_stats_msg nsm;
1039     struct ofp_aggregate_stats_reply asr;
1040 };
1041 OFP_ASSERT(sizeof(struct nx_aggregate_stats_reply) == 48);
1042
1043 #endif /* openflow/nicira-ext.h */