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