Rich Lane | 1ac4300 | 2013-12-03 12:56:35 -0800 | [diff] [blame] | 1 | // Copyright 2013, Big Switch Networks, Inc. |
| 2 | // |
| 3 | // LoxiGen is licensed under the Eclipse Public License, |
| 4 | // version 1.0 (EPL), with the following special exception: |
| 5 | // |
| 6 | // LOXI Exception |
| 7 | // |
| 8 | // As a special exception to the terms of the EPL, you may |
| 9 | // distribute libraries generated by LoxiGen (LoxiGen Libraries) |
| 10 | // under the terms of your choice, provided that copyright and |
| 11 | // licensing notices generated by LoxiGen are not altered or removed |
| 12 | // from the LoxiGen Libraries and the notice provided below is (i) |
| 13 | // included in the LoxiGen Libraries, if distributed in source code |
| 14 | // form and (ii) included in any documentation for the LoxiGen |
| 15 | // Libraries, if distributed in binary form. |
| 16 | // |
| 17 | // Notice: "Copyright 2013, Big Switch Networks, Inc. |
| 18 | // This library was generated by the LoxiGen Compiler." |
| 19 | // |
| 20 | // You may not use this file except in compliance with the EPL or |
| 21 | // LOXI Exception. You may obtain a copy of the EPL at: |
| 22 | // |
| 23 | // http://www.eclipse.org/legal/epl-v10.html |
| 24 | // |
| 25 | // Unless required by applicable law or agreed to in writing, |
| 26 | // software distributed under the License is distributed on an "AS |
| 27 | // IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 28 | // express or implied. See the EPL for the specific language |
| 29 | // governing permissions and limitations under the EPL. |
| 30 | |
| 31 | #version 4 |
Rich Lane | 4b1d8f4 | 2014-10-31 15:25:14 -0700 | [diff] [blame] | 32 | #version 5 |
Rich Lane | 1ac4300 | 2013-12-03 12:56:35 -0800 | [diff] [blame] | 33 | |
| 34 | // We have a number of switch agents that need to be configured by the |
| 35 | // controller and report stats. Some of them will have large tables (1000+ |
| 36 | // entries) and so need an efficient synchronization mechanism (as can be |
| 37 | // accomplished using the cookie field in flowtable entries). It's a |
| 38 | // significant amount of work to do this from scratch for each new table. |
| 39 | // This extension (and the corresponding Indigo code) provides a framework |
| 40 | // to ease implementing new tables. |
| 41 | |
| 42 | // We don't plan on replacing our use of the OpenFlow flow table and group |
| 43 | // table with this scheme. This is intended for controlling switch |
| 44 | // functionality like the ARP and LACP agents which don't map at all to |
| 45 | // flow-mods. |
| 46 | |
| 47 | // Each switch will have a number of tables indexed by a 16-bit table ID. Each |
| 48 | // table has a name, id, a set of entries, and an array of checksum buckets. |
| 49 | // There is no order to the entries; stats requests will return them in an |
| 50 | // arbitrary order. The controller is expected to use the table name to |
| 51 | // determine the semantics of a table. |
| 52 | |
| 53 | // Each entry has a key, value, stats, and checksum. The key and value are TLV |
| 54 | // lists given by the controller in a gentable_entry_add message. The switch must |
| 55 | // return these lists in stats replies exactly as it received them. The stats |
| 56 | // are a list of TLVs controlled by the switch. The stats are expected to |
| 57 | // include more than simple counters (for example, last hit time or seen TCP |
| 58 | // flags). The checksum is an opaque value used for table synchronization. |
| 59 | |
| 60 | // LOXI includes a built-in type of_checksum_128_t, which is 128 bits but |
| 61 | // only requires 32-bit alignment. |
| 62 | |
| 63 | |
| 64 | // These TLV classes are used for keys, values, and stats. Like OXM, lists of |
| 65 | // TLVs are tightly packed without padding. TLV lists may include duplicates |
| 66 | // and the semantics of this is left to the particular table. |
| 67 | // |
| 68 | // If this is eventually standardized it would be good to add a "class" type |
| 69 | // member as in OXM. |
| 70 | struct of_bsn_tlv { |
| 71 | uint16_t type == ?; |
| 72 | uint16_t length; |
| 73 | }; |
| 74 | |
| 75 | |
| 76 | // This message sets key=value in the given table. If key already exists in the |
| 77 | // table then it modifies the value, preserving stats. |
| 78 | // |
| 79 | // If the switch cannot process the message then it should reply with an error |
| 80 | // message. The contents of the table must not be changed in case of an error. |
| 81 | struct of_bsn_gentable_entry_add : of_bsn_header { |
| 82 | uint8_t version; |
| 83 | uint8_t type == 4; |
| 84 | uint16_t length; |
| 85 | uint32_t xid; |
| 86 | uint32_t experimenter == 0x5c16c7; |
| 87 | uint32_t subtype == 46; |
| 88 | uint16_t table_id; |
| 89 | uint16_t key_length; |
| 90 | of_checksum_128_t checksum; |
| 91 | list(of_bsn_tlv_t) key; |
| 92 | list(of_bsn_tlv_t) value; |
| 93 | }; |
| 94 | |
| 95 | |
| 96 | // This message deletes the entry with the given key in the given table. |
| 97 | // |
| 98 | // If the switch cannot process the message then it should reply with an error |
| 99 | // message. The contents of the table must not be changed in case of an error. |
Rich Lane | 45e341f | 2014-02-05 13:28:58 -0800 | [diff] [blame] | 100 | // If the key does not exist in the table no error will be generated. |
Rich Lane | 1ac4300 | 2013-12-03 12:56:35 -0800 | [diff] [blame] | 101 | struct of_bsn_gentable_entry_delete : of_bsn_header { |
| 102 | uint8_t version; |
| 103 | uint8_t type == 4; |
| 104 | uint16_t length; |
| 105 | uint32_t xid; |
| 106 | uint32_t experimenter == 0x5c16c7; |
| 107 | uint32_t subtype == 47; |
| 108 | uint16_t table_id; |
| 109 | list(of_bsn_tlv_t) key; |
| 110 | }; |
| 111 | |
| 112 | |
| 113 | // This message deletes a range of table entries. The checksum_mask must be a |
| 114 | // prefix mask. The checksum must be zero in the bits where the checksum_mask |
| 115 | // is zero. |
| 116 | // |
| 117 | // The switch may fail to delete some table entries. No error messages will be |
| 118 | // sent, but the error_count in the reply message will be incremented. |
| 119 | struct of_bsn_gentable_clear_request : of_bsn_header { |
| 120 | uint8_t version; |
| 121 | uint8_t type == 4; |
| 122 | uint16_t length; |
| 123 | uint32_t xid; |
| 124 | uint32_t experimenter == 0x5c16c7; |
| 125 | uint32_t subtype == 48; |
| 126 | uint16_t table_id; |
| 127 | pad(2); |
| 128 | of_checksum_128_t checksum; |
| 129 | of_checksum_128_t checksum_mask; |
| 130 | }; |
| 131 | |
| 132 | struct of_bsn_gentable_clear_reply : of_bsn_header { |
| 133 | uint8_t version; |
| 134 | uint8_t type == 4; |
| 135 | uint16_t length; |
| 136 | uint32_t xid; |
| 137 | uint32_t experimenter == 0x5c16c7; |
| 138 | uint32_t subtype == 49; |
| 139 | uint16_t table_id; |
| 140 | pad(2); |
| 141 | uint32_t deleted_count; |
| 142 | uint32_t error_count; |
| 143 | }; |
| 144 | |
| 145 | |
| 146 | // This message sets the size of the buckets array. The switch may reject this |
Rich Lane | f511bf0 | 2014-01-06 11:56:30 -0800 | [diff] [blame] | 147 | // message if the table has entries. buckets_size must be a power of 2. |
Rich Lane | 1ac4300 | 2013-12-03 12:56:35 -0800 | [diff] [blame] | 148 | struct of_bsn_gentable_set_buckets_size : of_bsn_header { |
| 149 | uint8_t version; |
| 150 | uint8_t type == 4; |
| 151 | uint16_t length; |
| 152 | uint32_t xid; |
| 153 | uint32_t experimenter == 0x5c16c7; |
| 154 | uint32_t subtype == 50; |
| 155 | uint16_t table_id; |
| 156 | pad(2); |
| 157 | uint32_t buckets_size; |
| 158 | }; |
| 159 | |
| 160 | |
| 161 | // Retrieve the configuration state (key, value, and checksum) for each table |
| 162 | // entry in a range of buckets. |
| 163 | // |
| 164 | // The checksum_mask must be a prefix mask. The checksum must be zero in the |
| 165 | // bits where the checksum_mask is zero. |
| 166 | struct of_bsn_gentable_entry_desc_stats_request : of_bsn_stats_request { |
| 167 | uint8_t version; |
| 168 | uint8_t type == 18; |
| 169 | uint16_t length; |
| 170 | uint32_t xid; |
| 171 | uint16_t stats_type == 0xffff; |
| 172 | enum ofp_stats_request_flags flags; |
| 173 | pad(4); |
| 174 | uint32_t experimenter == 0x5c16c7; |
| 175 | uint32_t subtype == 2; |
| 176 | uint16_t table_id; |
| 177 | pad(2); |
| 178 | of_checksum_128_t checksum; |
| 179 | of_checksum_128_t checksum_mask; |
| 180 | }; |
| 181 | |
| 182 | struct of_bsn_gentable_entry_desc_stats_entry { |
| 183 | uint16_t length; |
| 184 | uint16_t key_length; |
| 185 | of_checksum_128_t checksum; |
| 186 | list(of_bsn_tlv_t) key; |
| 187 | list(of_bsn_tlv_t) value; |
| 188 | }; |
| 189 | |
| 190 | struct of_bsn_gentable_entry_desc_stats_reply : of_bsn_stats_reply { |
| 191 | uint8_t version; |
| 192 | uint8_t type == 19; |
| 193 | uint16_t length; |
| 194 | uint32_t xid; |
| 195 | uint16_t stats_type == 0xffff; |
| 196 | enum ofp_stats_reply_flags flags; |
| 197 | pad(4); |
| 198 | uint32_t experimenter == 0x5c16c7; |
| 199 | uint32_t subtype == 2; |
| 200 | list(of_bsn_gentable_entry_desc_stats_entry_t) entries; |
| 201 | }; |
| 202 | |
| 203 | |
| 204 | // Retrieve the runtime state (key and stats) for each table entry in a range |
| 205 | // of buckets. |
| 206 | // |
| 207 | // The checksum_mask must be a prefix mask. The checksum must be zero in the |
| 208 | // bits where the checksum_mask is zero. |
| 209 | struct of_bsn_gentable_entry_stats_request : of_bsn_stats_request { |
| 210 | uint8_t version; |
| 211 | uint8_t type == 18; |
| 212 | uint16_t length; |
| 213 | uint32_t xid; |
| 214 | uint16_t stats_type == 0xffff; |
| 215 | enum ofp_stats_request_flags flags; |
| 216 | pad(4); |
| 217 | uint32_t experimenter == 0x5c16c7; |
| 218 | uint32_t subtype == 3; |
| 219 | uint16_t table_id; |
| 220 | pad(2); |
| 221 | of_checksum_128_t checksum; |
| 222 | of_checksum_128_t checksum_mask; |
| 223 | }; |
| 224 | |
| 225 | struct of_bsn_gentable_entry_stats_entry { |
| 226 | uint16_t length; |
| 227 | uint16_t key_length; |
| 228 | list(of_bsn_tlv_t) key; |
| 229 | list(of_bsn_tlv_t) stats; |
| 230 | }; |
| 231 | |
| 232 | struct of_bsn_gentable_entry_stats_reply : of_bsn_stats_reply { |
| 233 | uint8_t version; |
| 234 | uint8_t type == 19; |
| 235 | uint16_t length; |
| 236 | uint32_t xid; |
| 237 | uint16_t stats_type == 0xffff; |
| 238 | enum ofp_stats_reply_flags flags; |
| 239 | pad(4); |
| 240 | uint32_t experimenter == 0x5c16c7; |
| 241 | uint32_t subtype == 3; |
| 242 | list(of_bsn_gentable_entry_stats_entry_t) entries; |
| 243 | }; |
| 244 | |
| 245 | |
| 246 | // Retrieve the description for all tables. |
| 247 | struct of_bsn_gentable_desc_stats_request : of_bsn_stats_request { |
| 248 | uint8_t version; |
| 249 | uint8_t type == 18; |
| 250 | uint16_t length; |
| 251 | uint32_t xid; |
| 252 | uint16_t stats_type == 0xffff; |
| 253 | enum ofp_stats_request_flags flags; |
| 254 | pad(4); |
| 255 | uint32_t experimenter == 0x5c16c7; |
| 256 | uint32_t subtype == 4; |
| 257 | }; |
| 258 | |
| 259 | struct of_bsn_gentable_desc_stats_entry { |
| 260 | uint16_t length; |
| 261 | uint16_t table_id; |
| 262 | of_table_name_t name; |
| 263 | uint32_t buckets_size; |
Rich Lane | 7b2a8b6 | 2014-01-02 14:00:49 -0800 | [diff] [blame] | 264 | uint32_t max_entries; |
| 265 | pad(4); |
Rich Lane | 1ac4300 | 2013-12-03 12:56:35 -0800 | [diff] [blame] | 266 | /* TODO properties */ |
| 267 | }; |
| 268 | |
| 269 | struct of_bsn_gentable_desc_stats_reply : of_bsn_stats_reply { |
| 270 | uint8_t version; |
| 271 | uint8_t type == 19; |
| 272 | uint16_t length; |
| 273 | uint32_t xid; |
| 274 | uint16_t stats_type == 0xffff; |
| 275 | enum ofp_stats_reply_flags flags; |
| 276 | pad(4); |
| 277 | uint32_t experimenter == 0x5c16c7; |
| 278 | uint32_t subtype == 4; |
| 279 | list(of_bsn_gentable_desc_stats_entry_t) entries; |
| 280 | }; |
| 281 | |
| 282 | |
| 283 | // Retrieves stats for every table. This includes the total checksum, so the |
| 284 | // controller can quickly check whether the whole table is in sync. |
| 285 | // |
Rich Lane | 7f6288b | 2014-06-30 17:23:59 -0700 | [diff] [blame] | 286 | // The checksum of a table is the sum of the checksums of all entries in the |
Rich Lane | 1ac4300 | 2013-12-03 12:56:35 -0800 | [diff] [blame] | 287 | // table. |
| 288 | struct of_bsn_gentable_stats_request : of_bsn_stats_request { |
| 289 | uint8_t version; |
| 290 | uint8_t type == 18; |
| 291 | uint16_t length; |
| 292 | uint32_t xid; |
| 293 | uint16_t stats_type == 0xffff; |
| 294 | enum ofp_stats_request_flags flags; |
| 295 | pad(4); |
| 296 | uint32_t experimenter == 0x5c16c7; |
| 297 | uint32_t subtype == 7; |
| 298 | }; |
| 299 | |
| 300 | struct of_bsn_gentable_stats_entry { |
| 301 | uint16_t table_id; |
| 302 | pad(2); |
| 303 | uint32_t entry_count; |
| 304 | of_checksum_128_t checksum; |
| 305 | }; |
| 306 | |
| 307 | struct of_bsn_gentable_stats_reply : of_bsn_stats_reply { |
| 308 | uint8_t version; |
| 309 | uint8_t type == 19; |
| 310 | uint16_t length; |
| 311 | uint32_t xid; |
| 312 | uint16_t stats_type == 0xffff; |
| 313 | enum ofp_stats_reply_flags flags; |
| 314 | pad(4); |
| 315 | uint32_t experimenter == 0x5c16c7; |
| 316 | uint32_t subtype == 7; |
| 317 | list(of_bsn_gentable_stats_entry_t) entries; |
| 318 | }; |
| 319 | |
| 320 | |
| 321 | // Retrieves the checksum for every bucket in a table. The entries are ordered |
| 322 | // by bucket index. |
| 323 | // |
Rich Lane | 7f6288b | 2014-06-30 17:23:59 -0700 | [diff] [blame] | 324 | // The checksum of a bucket is the sum of the checksums of all entries in the |
Rich Lane | 1ac4300 | 2013-12-03 12:56:35 -0800 | [diff] [blame] | 325 | // bucket. |
| 326 | struct of_bsn_gentable_bucket_stats_request : of_bsn_stats_request { |
| 327 | uint8_t version; |
| 328 | uint8_t type == 18; |
| 329 | uint16_t length; |
| 330 | uint32_t xid; |
| 331 | uint16_t stats_type == 0xffff; |
| 332 | enum ofp_stats_request_flags flags; |
| 333 | pad(4); |
| 334 | uint32_t experimenter == 0x5c16c7; |
| 335 | uint32_t subtype == 5; |
| 336 | uint16_t table_id; |
| 337 | }; |
| 338 | |
| 339 | struct of_bsn_gentable_bucket_stats_entry { |
| 340 | of_checksum_128_t checksum; |
| 341 | }; |
| 342 | |
| 343 | struct of_bsn_gentable_bucket_stats_reply : of_bsn_stats_reply { |
| 344 | uint8_t version; |
| 345 | uint8_t type == 19; |
| 346 | uint16_t length; |
| 347 | uint32_t xid; |
| 348 | uint16_t stats_type == 0xffff; |
| 349 | enum ofp_stats_reply_flags flags; |
| 350 | pad(4); |
| 351 | uint32_t experimenter == 0x5c16c7; |
| 352 | uint32_t subtype == 5; |
| 353 | list(of_bsn_gentable_bucket_stats_entry_t) entries; |
| 354 | }; |
Rich Lane | fc9bbff | 2014-10-23 09:35:20 -0700 | [diff] [blame] | 355 | |
| 356 | // Reference a gentable entry from an action list |
| 357 | struct of_action_bsn_gentable : of_action_bsn { |
| 358 | uint16_t type == 65535; |
| 359 | uint16_t len; |
| 360 | uint32_t experimenter == 0x5c16c7; |
| 361 | uint32_t subtype == 5; |
| 362 | uint32_t table_id; |
| 363 | list(of_bsn_tlv_t) key; |
| 364 | }; |