blob: 0b64bd6b4195410c0d70812c2fa86b45ac3e8b1c [file] [log] [blame]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Lane7dcdf022013-12-11 14:45:27 -08005
6# Automatically generated by LOXI from template module.py
Rich Lanec2ee4b82013-04-24 17:12:38 -07007# Do not modify
8
Rich Lanec2ee4b82013-04-24 17:12:38 -07009import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Lanec2ee4b82013-04-24 17:12:38 -070011import const
Rich Lane7dcdf022013-12-11 14:45:27 -080012import common
13import action
14import instruction
15import oxm
Rich Lanec2ee4b82013-04-24 17:12:38 -070016import util
17import loxi.generic_util
18
Rich Lane7dcdf022013-12-11 14:45:27 -080019class bsn_interface(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -070020
21 def __init__(self, hw_addr=None, name=None, ipv4_addr=None, ipv4_netmask=None):
22 if hw_addr != None:
23 self.hw_addr = hw_addr
24 else:
25 self.hw_addr = [0,0,0,0,0,0]
26 if name != None:
27 self.name = name
28 else:
29 self.name = ""
30 if ipv4_addr != None:
31 self.ipv4_addr = ipv4_addr
32 else:
33 self.ipv4_addr = 0
34 if ipv4_netmask != None:
35 self.ipv4_netmask = ipv4_netmask
36 else:
37 self.ipv4_netmask = 0
38 return
39
40 def pack(self):
41 packed = []
42 packed.append(struct.pack("!6B", *self.hw_addr))
43 packed.append('\x00' * 2)
44 packed.append(struct.pack("!16s", self.name))
45 packed.append(struct.pack("!L", self.ipv4_addr))
46 packed.append(struct.pack("!L", self.ipv4_netmask))
47 return ''.join(packed)
48
49 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080050 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -070051 obj = bsn_interface()
Rich Lanec2ee4b82013-04-24 17:12:38 -070052 obj.hw_addr = list(reader.read('!6B'))
53 reader.skip(2)
54 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -070055 obj.ipv4_addr = reader.read("!L")[0]
56 obj.ipv4_netmask = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -070057 return obj
58
59 def __eq__(self, other):
60 if type(self) != type(other): return False
61 if self.hw_addr != other.hw_addr: return False
62 if self.name != other.name: return False
63 if self.ipv4_addr != other.ipv4_addr: return False
64 if self.ipv4_netmask != other.ipv4_netmask: return False
65 return True
66
Rich Lanec2ee4b82013-04-24 17:12:38 -070067 def pretty_print(self, q):
68 q.text("bsn_interface {")
69 with q.group():
70 with q.indent(2):
71 q.breakable()
72 q.text("hw_addr = ");
73 q.text(util.pretty_mac(self.hw_addr))
74 q.text(","); q.breakable()
75 q.text("name = ");
76 q.pp(self.name)
77 q.text(","); q.breakable()
78 q.text("ipv4_addr = ");
79 q.text(util.pretty_ipv4(self.ipv4_addr))
80 q.text(","); q.breakable()
81 q.text("ipv4_netmask = ");
82 q.text(util.pretty_ipv4(self.ipv4_netmask))
83 q.breakable()
84 q.text('}')
85
Rich Lane7dcdf022013-12-11 14:45:27 -080086
87class bsn_vport(loxi.OFObject):
88 subtypes = {}
89
90 @staticmethod
91 def unpack(reader):
92 subtype, = reader.peek('!H', 0)
93 try:
94 subclass = bsn_vport.subtypes[subtype]
95 except KeyError:
96 raise loxi.ProtocolError("unknown bsn_vport subtype %#x" % subtype)
97 return subclass.unpack(reader)
98
99
100class bsn_vport_q_in_q(bsn_vport):
Dan Talaycof6202252013-07-02 01:00:29 -0700101 type = 0
102
Kiran Poola150d8b02013-09-20 13:30:39 -0700103 def __init__(self, port_no=None, ingress_tpid=None, ingress_vlan_id=None, egress_tpid=None, egress_vlan_id=None, if_name=None):
Dan Talaycof6202252013-07-02 01:00:29 -0700104 if port_no != None:
105 self.port_no = port_no
106 else:
107 self.port_no = 0
108 if ingress_tpid != None:
109 self.ingress_tpid = ingress_tpid
110 else:
111 self.ingress_tpid = 0
112 if ingress_vlan_id != None:
113 self.ingress_vlan_id = ingress_vlan_id
114 else:
115 self.ingress_vlan_id = 0
116 if egress_tpid != None:
117 self.egress_tpid = egress_tpid
118 else:
119 self.egress_tpid = 0
120 if egress_vlan_id != None:
121 self.egress_vlan_id = egress_vlan_id
122 else:
123 self.egress_vlan_id = 0
Kiran Poola150d8b02013-09-20 13:30:39 -0700124 if if_name != None:
125 self.if_name = if_name
126 else:
127 self.if_name = ""
Dan Talaycof6202252013-07-02 01:00:29 -0700128 return
129
130 def pack(self):
131 packed = []
132 packed.append(struct.pack("!H", self.type))
Kiran Poola150d8b02013-09-20 13:30:39 -0700133 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Dan Talaycof6202252013-07-02 01:00:29 -0700134 packed.append(struct.pack("!L", self.port_no))
135 packed.append(struct.pack("!H", self.ingress_tpid))
136 packed.append(struct.pack("!H", self.ingress_vlan_id))
137 packed.append(struct.pack("!H", self.egress_tpid))
138 packed.append(struct.pack("!H", self.egress_vlan_id))
Kiran Poola150d8b02013-09-20 13:30:39 -0700139 packed.append(struct.pack("!16s", self.if_name))
Dan Talaycof6202252013-07-02 01:00:29 -0700140 length = sum([len(x) for x in packed])
Kiran Poola150d8b02013-09-20 13:30:39 -0700141 packed[1] = struct.pack("!H", length)
Dan Talaycof6202252013-07-02 01:00:29 -0700142 return ''.join(packed)
143
144 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800145 def unpack(reader):
Dan Talaycof6202252013-07-02 01:00:29 -0700146 obj = bsn_vport_q_in_q()
Dan Talaycof6202252013-07-02 01:00:29 -0700147 _type = reader.read("!H")[0]
148 assert(_type == 0)
149 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800150 orig_reader = reader
151 reader = orig_reader.slice(_length - (2 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700152 obj.port_no = reader.read("!L")[0]
153 obj.ingress_tpid = reader.read("!H")[0]
154 obj.ingress_vlan_id = reader.read("!H")[0]
155 obj.egress_tpid = reader.read("!H")[0]
156 obj.egress_vlan_id = reader.read("!H")[0]
Kiran Poola150d8b02013-09-20 13:30:39 -0700157 obj.if_name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700158 return obj
159
160 def __eq__(self, other):
161 if type(self) != type(other): return False
162 if self.port_no != other.port_no: return False
163 if self.ingress_tpid != other.ingress_tpid: return False
164 if self.ingress_vlan_id != other.ingress_vlan_id: return False
165 if self.egress_tpid != other.egress_tpid: return False
166 if self.egress_vlan_id != other.egress_vlan_id: return False
Kiran Poola150d8b02013-09-20 13:30:39 -0700167 if self.if_name != other.if_name: return False
Dan Talaycof6202252013-07-02 01:00:29 -0700168 return True
169
Dan Talaycof6202252013-07-02 01:00:29 -0700170 def pretty_print(self, q):
171 q.text("bsn_vport_q_in_q {")
172 with q.group():
173 with q.indent(2):
174 q.breakable()
175 q.text("port_no = ");
176 q.text("%#x" % self.port_no)
177 q.text(","); q.breakable()
178 q.text("ingress_tpid = ");
179 q.text("%#x" % self.ingress_tpid)
180 q.text(","); q.breakable()
181 q.text("ingress_vlan_id = ");
182 q.text("%#x" % self.ingress_vlan_id)
183 q.text(","); q.breakable()
184 q.text("egress_tpid = ");
185 q.text("%#x" % self.egress_tpid)
186 q.text(","); q.breakable()
187 q.text("egress_vlan_id = ");
188 q.text("%#x" % self.egress_vlan_id)
Kiran Poola150d8b02013-09-20 13:30:39 -0700189 q.text(","); q.breakable()
190 q.text("if_name = ");
191 q.pp(self.if_name)
Dan Talaycof6202252013-07-02 01:00:29 -0700192 q.breakable()
193 q.text('}')
194
Rich Lane7dcdf022013-12-11 14:45:27 -0800195bsn_vport.subtypes[0] = bsn_vport_q_in_q
196
197class bucket(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700198
199 def __init__(self, weight=None, watch_port=None, watch_group=None, actions=None):
200 if weight != None:
201 self.weight = weight
202 else:
203 self.weight = 0
204 if watch_port != None:
205 self.watch_port = watch_port
206 else:
207 self.watch_port = 0
208 if watch_group != None:
209 self.watch_group = watch_group
210 else:
211 self.watch_group = 0
212 if actions != None:
213 self.actions = actions
214 else:
215 self.actions = []
216 return
217
218 def pack(self):
219 packed = []
220 packed.append(struct.pack("!H", 0)) # placeholder for len at index 0
221 packed.append(struct.pack("!H", self.weight))
Dan Talaycof6202252013-07-02 01:00:29 -0700222 packed.append(util.pack_port_no(self.watch_port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700223 packed.append(struct.pack("!L", self.watch_group))
224 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800225 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700226 length = sum([len(x) for x in packed])
227 packed[0] = struct.pack("!H", length)
228 return ''.join(packed)
229
230 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800231 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700232 obj = bucket()
Dan Talaycof6202252013-07-02 01:00:29 -0700233 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800234 orig_reader = reader
235 reader = orig_reader.slice(_len - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700236 obj.weight = reader.read("!H")[0]
237 obj.watch_port = util.unpack_port_no(reader)
238 obj.watch_group = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700239 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800240 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700241 return obj
242
243 def __eq__(self, other):
244 if type(self) != type(other): return False
245 if self.weight != other.weight: return False
246 if self.watch_port != other.watch_port: return False
247 if self.watch_group != other.watch_group: return False
248 if self.actions != other.actions: return False
249 return True
250
Rich Lanec2ee4b82013-04-24 17:12:38 -0700251 def pretty_print(self, q):
252 q.text("bucket {")
253 with q.group():
254 with q.indent(2):
255 q.breakable()
256 q.text("weight = ");
257 q.text("%#x" % self.weight)
258 q.text(","); q.breakable()
259 q.text("watch_port = ");
260 q.text(util.pretty_port(self.watch_port))
261 q.text(","); q.breakable()
262 q.text("watch_group = ");
263 q.text("%#x" % self.watch_group)
264 q.text(","); q.breakable()
265 q.text("actions = ");
266 q.pp(self.actions)
267 q.breakable()
268 q.text('}')
269
Rich Lane7dcdf022013-12-11 14:45:27 -0800270
271class bucket_counter(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700272
273 def __init__(self, packet_count=None, byte_count=None):
274 if packet_count != None:
275 self.packet_count = packet_count
276 else:
277 self.packet_count = 0
278 if byte_count != None:
279 self.byte_count = byte_count
280 else:
281 self.byte_count = 0
282 return
283
284 def pack(self):
285 packed = []
286 packed.append(struct.pack("!Q", self.packet_count))
287 packed.append(struct.pack("!Q", self.byte_count))
288 return ''.join(packed)
289
290 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800291 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700292 obj = bucket_counter()
Dan Talaycof6202252013-07-02 01:00:29 -0700293 obj.packet_count = reader.read("!Q")[0]
294 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700295 return obj
296
297 def __eq__(self, other):
298 if type(self) != type(other): return False
299 if self.packet_count != other.packet_count: return False
300 if self.byte_count != other.byte_count: return False
301 return True
302
Rich Lanec2ee4b82013-04-24 17:12:38 -0700303 def pretty_print(self, q):
304 q.text("bucket_counter {")
305 with q.group():
306 with q.indent(2):
307 q.breakable()
308 q.text("packet_count = ");
309 q.text("%#x" % self.packet_count)
310 q.text(","); q.breakable()
311 q.text("byte_count = ");
312 q.text("%#x" % self.byte_count)
313 q.breakable()
314 q.text('}')
315
Rich Lane7dcdf022013-12-11 14:45:27 -0800316
317class flow_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700318
319 def __init__(self, table_id=None, duration_sec=None, duration_nsec=None, priority=None, idle_timeout=None, hard_timeout=None, cookie=None, packet_count=None, byte_count=None, match=None, instructions=None):
320 if table_id != None:
321 self.table_id = table_id
322 else:
323 self.table_id = 0
324 if duration_sec != None:
325 self.duration_sec = duration_sec
326 else:
327 self.duration_sec = 0
328 if duration_nsec != None:
329 self.duration_nsec = duration_nsec
330 else:
331 self.duration_nsec = 0
332 if priority != None:
333 self.priority = priority
334 else:
335 self.priority = 0
336 if idle_timeout != None:
337 self.idle_timeout = idle_timeout
338 else:
339 self.idle_timeout = 0
340 if hard_timeout != None:
341 self.hard_timeout = hard_timeout
342 else:
343 self.hard_timeout = 0
344 if cookie != None:
345 self.cookie = cookie
346 else:
347 self.cookie = 0
348 if packet_count != None:
349 self.packet_count = packet_count
350 else:
351 self.packet_count = 0
352 if byte_count != None:
353 self.byte_count = byte_count
354 else:
355 self.byte_count = 0
356 if match != None:
357 self.match = match
358 else:
359 self.match = common.match()
360 if instructions != None:
361 self.instructions = instructions
362 else:
363 self.instructions = []
364 return
365
366 def pack(self):
367 packed = []
368 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
369 packed.append(struct.pack("!B", self.table_id))
370 packed.append('\x00' * 1)
371 packed.append(struct.pack("!L", self.duration_sec))
372 packed.append(struct.pack("!L", self.duration_nsec))
373 packed.append(struct.pack("!H", self.priority))
374 packed.append(struct.pack("!H", self.idle_timeout))
375 packed.append(struct.pack("!H", self.hard_timeout))
376 packed.append('\x00' * 6)
377 packed.append(struct.pack("!Q", self.cookie))
378 packed.append(struct.pack("!Q", self.packet_count))
379 packed.append(struct.pack("!Q", self.byte_count))
380 packed.append(self.match.pack())
Rich Lane7dcdf022013-12-11 14:45:27 -0800381 packed.append(loxi.generic_util.pack_list(self.instructions))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700382 length = sum([len(x) for x in packed])
383 packed[0] = struct.pack("!H", length)
384 return ''.join(packed)
385
386 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800387 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700388 obj = flow_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700389 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800390 orig_reader = reader
391 reader = orig_reader.slice(_length - (0 + 2))
Dan Talaycof6202252013-07-02 01:00:29 -0700392 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700393 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700394 obj.duration_sec = reader.read("!L")[0]
395 obj.duration_nsec = reader.read("!L")[0]
396 obj.priority = reader.read("!H")[0]
397 obj.idle_timeout = reader.read("!H")[0]
398 obj.hard_timeout = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700399 reader.skip(6)
Dan Talaycof6202252013-07-02 01:00:29 -0700400 obj.cookie = reader.read("!Q")[0]
401 obj.packet_count = reader.read("!Q")[0]
402 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700403 obj.match = common.match.unpack(reader)
Rich Lane7dcdf022013-12-11 14:45:27 -0800404 obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700405 return obj
406
407 def __eq__(self, other):
408 if type(self) != type(other): return False
409 if self.table_id != other.table_id: return False
410 if self.duration_sec != other.duration_sec: return False
411 if self.duration_nsec != other.duration_nsec: return False
412 if self.priority != other.priority: return False
413 if self.idle_timeout != other.idle_timeout: return False
414 if self.hard_timeout != other.hard_timeout: return False
415 if self.cookie != other.cookie: return False
416 if self.packet_count != other.packet_count: return False
417 if self.byte_count != other.byte_count: return False
418 if self.match != other.match: return False
419 if self.instructions != other.instructions: return False
420 return True
421
Rich Lanec2ee4b82013-04-24 17:12:38 -0700422 def pretty_print(self, q):
423 q.text("flow_stats_entry {")
424 with q.group():
425 with q.indent(2):
426 q.breakable()
427 q.text("table_id = ");
428 q.text("%#x" % self.table_id)
429 q.text(","); q.breakable()
430 q.text("duration_sec = ");
431 q.text("%#x" % self.duration_sec)
432 q.text(","); q.breakable()
433 q.text("duration_nsec = ");
434 q.text("%#x" % self.duration_nsec)
435 q.text(","); q.breakable()
436 q.text("priority = ");
437 q.text("%#x" % self.priority)
438 q.text(","); q.breakable()
439 q.text("idle_timeout = ");
440 q.text("%#x" % self.idle_timeout)
441 q.text(","); q.breakable()
442 q.text("hard_timeout = ");
443 q.text("%#x" % self.hard_timeout)
444 q.text(","); q.breakable()
445 q.text("cookie = ");
446 q.text("%#x" % self.cookie)
447 q.text(","); q.breakable()
448 q.text("packet_count = ");
449 q.text("%#x" % self.packet_count)
450 q.text(","); q.breakable()
451 q.text("byte_count = ");
452 q.text("%#x" % self.byte_count)
453 q.text(","); q.breakable()
454 q.text("match = ");
455 q.pp(self.match)
456 q.text(","); q.breakable()
457 q.text("instructions = ");
458 q.pp(self.instructions)
459 q.breakable()
460 q.text('}')
461
Rich Lane7dcdf022013-12-11 14:45:27 -0800462
463class group_desc_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700464
Rich Lane6f4978c2013-10-20 21:33:52 -0700465 def __init__(self, group_type=None, group_id=None, buckets=None):
466 if group_type != None:
467 self.group_type = group_type
Rich Lanec2ee4b82013-04-24 17:12:38 -0700468 else:
Rich Lane6f4978c2013-10-20 21:33:52 -0700469 self.group_type = 0
Rich Lanec2ee4b82013-04-24 17:12:38 -0700470 if group_id != None:
471 self.group_id = group_id
472 else:
473 self.group_id = 0
474 if buckets != None:
475 self.buckets = buckets
476 else:
477 self.buckets = []
478 return
479
480 def pack(self):
481 packed = []
482 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
Rich Lane6f4978c2013-10-20 21:33:52 -0700483 packed.append(struct.pack("!B", self.group_type))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700484 packed.append('\x00' * 1)
485 packed.append(struct.pack("!L", self.group_id))
Rich Lane7dcdf022013-12-11 14:45:27 -0800486 packed.append(loxi.generic_util.pack_list(self.buckets))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700487 length = sum([len(x) for x in packed])
488 packed[0] = struct.pack("!H", length)
489 return ''.join(packed)
490
491 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800492 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700493 obj = group_desc_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700494 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800495 orig_reader = reader
496 reader = orig_reader.slice(_length - (0 + 2))
Rich Lane6f4978c2013-10-20 21:33:52 -0700497 obj.group_type = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700498 reader.skip(1)
Dan Talaycof6202252013-07-02 01:00:29 -0700499 obj.group_id = reader.read("!L")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800500 obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700501 return obj
502
503 def __eq__(self, other):
504 if type(self) != type(other): return False
Rich Lane6f4978c2013-10-20 21:33:52 -0700505 if self.group_type != other.group_type: return False
Rich Lanec2ee4b82013-04-24 17:12:38 -0700506 if self.group_id != other.group_id: return False
507 if self.buckets != other.buckets: return False
508 return True
509
Rich Lanec2ee4b82013-04-24 17:12:38 -0700510 def pretty_print(self, q):
511 q.text("group_desc_stats_entry {")
512 with q.group():
513 with q.indent(2):
514 q.breakable()
Rich Lane6f4978c2013-10-20 21:33:52 -0700515 q.text("group_type = ");
516 q.text("%#x" % self.group_type)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700517 q.text(","); q.breakable()
518 q.text("group_id = ");
519 q.text("%#x" % self.group_id)
520 q.text(","); q.breakable()
521 q.text("buckets = ");
522 q.pp(self.buckets)
523 q.breakable()
524 q.text('}')
525
Rich Lane7dcdf022013-12-11 14:45:27 -0800526
527class group_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700528
529 def __init__(self, group_id=None, ref_count=None, packet_count=None, byte_count=None, bucket_stats=None):
530 if group_id != None:
531 self.group_id = group_id
532 else:
533 self.group_id = 0
534 if ref_count != None:
535 self.ref_count = ref_count
536 else:
537 self.ref_count = 0
538 if packet_count != None:
539 self.packet_count = packet_count
540 else:
541 self.packet_count = 0
542 if byte_count != None:
543 self.byte_count = byte_count
544 else:
545 self.byte_count = 0
546 if bucket_stats != None:
547 self.bucket_stats = bucket_stats
548 else:
549 self.bucket_stats = []
550 return
551
552 def pack(self):
553 packed = []
554 packed.append(struct.pack("!H", 0)) # placeholder for length at index 0
555 packed.append('\x00' * 2)
556 packed.append(struct.pack("!L", self.group_id))
557 packed.append(struct.pack("!L", self.ref_count))
558 packed.append('\x00' * 4)
559 packed.append(struct.pack("!Q", self.packet_count))
560 packed.append(struct.pack("!Q", self.byte_count))
Rich Lane7dcdf022013-12-11 14:45:27 -0800561 packed.append(loxi.generic_util.pack_list(self.bucket_stats))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700562 length = sum([len(x) for x in packed])
563 packed[0] = struct.pack("!H", length)
564 return ''.join(packed)
565
566 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800567 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700568 obj = group_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700569 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800570 orig_reader = reader
571 reader = orig_reader.slice(_length - (0 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700572 reader.skip(2)
Dan Talaycof6202252013-07-02 01:00:29 -0700573 obj.group_id = reader.read("!L")[0]
574 obj.ref_count = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700575 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700576 obj.packet_count = reader.read("!Q")[0]
577 obj.byte_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700578 obj.bucket_stats = loxi.generic_util.unpack_list(reader, common.bucket_counter.unpack)
579 return obj
580
581 def __eq__(self, other):
582 if type(self) != type(other): return False
583 if self.group_id != other.group_id: return False
584 if self.ref_count != other.ref_count: return False
585 if self.packet_count != other.packet_count: return False
586 if self.byte_count != other.byte_count: return False
587 if self.bucket_stats != other.bucket_stats: return False
588 return True
589
Rich Lanec2ee4b82013-04-24 17:12:38 -0700590 def pretty_print(self, q):
591 q.text("group_stats_entry {")
592 with q.group():
593 with q.indent(2):
594 q.breakable()
595 q.text("group_id = ");
596 q.text("%#x" % self.group_id)
597 q.text(","); q.breakable()
598 q.text("ref_count = ");
599 q.text("%#x" % self.ref_count)
600 q.text(","); q.breakable()
601 q.text("packet_count = ");
602 q.text("%#x" % self.packet_count)
603 q.text(","); q.breakable()
604 q.text("byte_count = ");
605 q.text("%#x" % self.byte_count)
606 q.text(","); q.breakable()
607 q.text("bucket_stats = ");
608 q.pp(self.bucket_stats)
609 q.breakable()
610 q.text('}')
611
Rich Lane7dcdf022013-12-11 14:45:27 -0800612
613class match_v3(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700614 type = 1
615
616 def __init__(self, oxm_list=None):
617 if oxm_list != None:
618 self.oxm_list = oxm_list
619 else:
620 self.oxm_list = []
621 return
622
623 def pack(self):
624 packed = []
625 packed.append(struct.pack("!H", self.type))
626 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
Rich Lane7dcdf022013-12-11 14:45:27 -0800627 packed.append(loxi.generic_util.pack_list(self.oxm_list))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700628 length = sum([len(x) for x in packed])
629 packed[1] = struct.pack("!H", length)
Rich Laned53156a2013-08-05 17:17:33 -0700630 packed.append(loxi.generic_util.pad_to(8, length))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700631 return ''.join(packed)
632
633 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800634 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700635 obj = match_v3()
Dan Talaycof6202252013-07-02 01:00:29 -0700636 _type = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700637 assert(_type == 1)
Dan Talaycof6202252013-07-02 01:00:29 -0700638 _length = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800639 orig_reader = reader
640 reader = orig_reader.slice(_length - (2 + 2))
641 obj.oxm_list = loxi.generic_util.unpack_list(reader, oxm.oxm.unpack)
642 orig_reader.skip_align()
Rich Lanec2ee4b82013-04-24 17:12:38 -0700643 return obj
644
645 def __eq__(self, other):
646 if type(self) != type(other): return False
647 if self.oxm_list != other.oxm_list: return False
648 return True
649
Rich Lanec2ee4b82013-04-24 17:12:38 -0700650 def pretty_print(self, q):
651 q.text("match_v3 {")
652 with q.group():
653 with q.indent(2):
654 q.breakable()
655 q.text("oxm_list = ");
656 q.pp(self.oxm_list)
657 q.breakable()
658 q.text('}')
659
Rich Lane7dcdf022013-12-11 14:45:27 -0800660
661class packet_queue(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700662
663 def __init__(self, queue_id=None, port=None, properties=None):
664 if queue_id != None:
665 self.queue_id = queue_id
666 else:
667 self.queue_id = 0
668 if port != None:
669 self.port = port
670 else:
671 self.port = 0
672 if properties != None:
673 self.properties = properties
674 else:
675 self.properties = []
676 return
677
678 def pack(self):
679 packed = []
680 packed.append(struct.pack("!L", self.queue_id))
Dan Talaycof6202252013-07-02 01:00:29 -0700681 packed.append(util.pack_port_no(self.port))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700682 packed.append(struct.pack("!H", 0)) # placeholder for len at index 2
683 packed.append('\x00' * 6)
Rich Lane7dcdf022013-12-11 14:45:27 -0800684 packed.append(loxi.generic_util.pack_list(self.properties))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700685 length = sum([len(x) for x in packed])
686 packed[2] = struct.pack("!H", length)
687 return ''.join(packed)
688
689 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800690 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700691 obj = packet_queue()
Dan Talaycof6202252013-07-02 01:00:29 -0700692 obj.queue_id = reader.read("!L")[0]
693 obj.port = util.unpack_port_no(reader)
694 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800695 orig_reader = reader
696 reader = orig_reader.slice(_len - (8 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700697 reader.skip(6)
Rich Lane7dcdf022013-12-11 14:45:27 -0800698 obj.properties = loxi.generic_util.unpack_list(reader, common.queue_prop.unpack)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700699 return obj
700
701 def __eq__(self, other):
702 if type(self) != type(other): return False
703 if self.queue_id != other.queue_id: return False
704 if self.port != other.port: return False
705 if self.properties != other.properties: return False
706 return True
707
Rich Lanec2ee4b82013-04-24 17:12:38 -0700708 def pretty_print(self, q):
709 q.text("packet_queue {")
710 with q.group():
711 with q.indent(2):
712 q.breakable()
713 q.text("queue_id = ");
714 q.text("%#x" % self.queue_id)
715 q.text(","); q.breakable()
716 q.text("port = ");
717 q.text(util.pretty_port(self.port))
718 q.text(","); q.breakable()
719 q.text("properties = ");
720 q.pp(self.properties)
721 q.breakable()
722 q.text('}')
723
Rich Lane7dcdf022013-12-11 14:45:27 -0800724
725class port_desc(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700726
727 def __init__(self, port_no=None, hw_addr=None, name=None, config=None, state=None, curr=None, advertised=None, supported=None, peer=None, curr_speed=None, max_speed=None):
728 if port_no != None:
729 self.port_no = port_no
730 else:
731 self.port_no = 0
732 if hw_addr != None:
733 self.hw_addr = hw_addr
734 else:
735 self.hw_addr = [0,0,0,0,0,0]
736 if name != None:
737 self.name = name
738 else:
739 self.name = ""
740 if config != None:
741 self.config = config
742 else:
743 self.config = 0
744 if state != None:
745 self.state = state
746 else:
747 self.state = 0
748 if curr != None:
749 self.curr = curr
750 else:
751 self.curr = 0
752 if advertised != None:
753 self.advertised = advertised
754 else:
755 self.advertised = 0
756 if supported != None:
757 self.supported = supported
758 else:
759 self.supported = 0
760 if peer != None:
761 self.peer = peer
762 else:
763 self.peer = 0
764 if curr_speed != None:
765 self.curr_speed = curr_speed
766 else:
767 self.curr_speed = 0
768 if max_speed != None:
769 self.max_speed = max_speed
770 else:
771 self.max_speed = 0
772 return
773
774 def pack(self):
775 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -0700776 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700777 packed.append('\x00' * 4)
778 packed.append(struct.pack("!6B", *self.hw_addr))
779 packed.append('\x00' * 2)
780 packed.append(struct.pack("!16s", self.name))
781 packed.append(struct.pack("!L", self.config))
782 packed.append(struct.pack("!L", self.state))
783 packed.append(struct.pack("!L", self.curr))
784 packed.append(struct.pack("!L", self.advertised))
785 packed.append(struct.pack("!L", self.supported))
786 packed.append(struct.pack("!L", self.peer))
787 packed.append(struct.pack("!L", self.curr_speed))
788 packed.append(struct.pack("!L", self.max_speed))
789 return ''.join(packed)
790
791 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800792 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700793 obj = port_desc()
Dan Talaycof6202252013-07-02 01:00:29 -0700794 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700795 reader.skip(4)
796 obj.hw_addr = list(reader.read('!6B'))
797 reader.skip(2)
798 obj.name = reader.read("!16s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -0700799 obj.config = reader.read("!L")[0]
800 obj.state = reader.read("!L")[0]
801 obj.curr = reader.read("!L")[0]
802 obj.advertised = reader.read("!L")[0]
803 obj.supported = reader.read("!L")[0]
804 obj.peer = reader.read("!L")[0]
805 obj.curr_speed = reader.read("!L")[0]
806 obj.max_speed = reader.read("!L")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700807 return obj
808
809 def __eq__(self, other):
810 if type(self) != type(other): return False
811 if self.port_no != other.port_no: return False
812 if self.hw_addr != other.hw_addr: return False
813 if self.name != other.name: return False
814 if self.config != other.config: return False
815 if self.state != other.state: return False
816 if self.curr != other.curr: return False
817 if self.advertised != other.advertised: return False
818 if self.supported != other.supported: return False
819 if self.peer != other.peer: return False
820 if self.curr_speed != other.curr_speed: return False
821 if self.max_speed != other.max_speed: return False
822 return True
823
Rich Lanec2ee4b82013-04-24 17:12:38 -0700824 def pretty_print(self, q):
825 q.text("port_desc {")
826 with q.group():
827 with q.indent(2):
828 q.breakable()
829 q.text("port_no = ");
830 q.text(util.pretty_port(self.port_no))
831 q.text(","); q.breakable()
832 q.text("hw_addr = ");
833 q.text(util.pretty_mac(self.hw_addr))
834 q.text(","); q.breakable()
835 q.text("name = ");
836 q.pp(self.name)
837 q.text(","); q.breakable()
838 q.text("config = ");
839 q.text("%#x" % self.config)
840 q.text(","); q.breakable()
841 q.text("state = ");
842 q.text("%#x" % self.state)
843 q.text(","); q.breakable()
844 q.text("curr = ");
845 q.text("%#x" % self.curr)
846 q.text(","); q.breakable()
847 q.text("advertised = ");
848 q.text("%#x" % self.advertised)
849 q.text(","); q.breakable()
850 q.text("supported = ");
851 q.text("%#x" % self.supported)
852 q.text(","); q.breakable()
853 q.text("peer = ");
854 q.text("%#x" % self.peer)
855 q.text(","); q.breakable()
856 q.text("curr_speed = ");
857 q.text("%#x" % self.curr_speed)
858 q.text(","); q.breakable()
859 q.text("max_speed = ");
860 q.text("%#x" % self.max_speed)
861 q.breakable()
862 q.text('}')
863
Rich Lane7dcdf022013-12-11 14:45:27 -0800864
865class port_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700866
867 def __init__(self, port_no=None, rx_packets=None, tx_packets=None, rx_bytes=None, tx_bytes=None, rx_dropped=None, tx_dropped=None, rx_errors=None, tx_errors=None, rx_frame_err=None, rx_over_err=None, rx_crc_err=None, collisions=None):
868 if port_no != None:
869 self.port_no = port_no
870 else:
871 self.port_no = 0
872 if rx_packets != None:
873 self.rx_packets = rx_packets
874 else:
875 self.rx_packets = 0
876 if tx_packets != None:
877 self.tx_packets = tx_packets
878 else:
879 self.tx_packets = 0
880 if rx_bytes != None:
881 self.rx_bytes = rx_bytes
882 else:
883 self.rx_bytes = 0
884 if tx_bytes != None:
885 self.tx_bytes = tx_bytes
886 else:
887 self.tx_bytes = 0
888 if rx_dropped != None:
889 self.rx_dropped = rx_dropped
890 else:
891 self.rx_dropped = 0
892 if tx_dropped != None:
893 self.tx_dropped = tx_dropped
894 else:
895 self.tx_dropped = 0
896 if rx_errors != None:
897 self.rx_errors = rx_errors
898 else:
899 self.rx_errors = 0
900 if tx_errors != None:
901 self.tx_errors = tx_errors
902 else:
903 self.tx_errors = 0
904 if rx_frame_err != None:
905 self.rx_frame_err = rx_frame_err
906 else:
907 self.rx_frame_err = 0
908 if rx_over_err != None:
909 self.rx_over_err = rx_over_err
910 else:
911 self.rx_over_err = 0
912 if rx_crc_err != None:
913 self.rx_crc_err = rx_crc_err
914 else:
915 self.rx_crc_err = 0
916 if collisions != None:
917 self.collisions = collisions
918 else:
919 self.collisions = 0
920 return
921
922 def pack(self):
923 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -0700924 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -0700925 packed.append('\x00' * 4)
926 packed.append(struct.pack("!Q", self.rx_packets))
927 packed.append(struct.pack("!Q", self.tx_packets))
928 packed.append(struct.pack("!Q", self.rx_bytes))
929 packed.append(struct.pack("!Q", self.tx_bytes))
930 packed.append(struct.pack("!Q", self.rx_dropped))
931 packed.append(struct.pack("!Q", self.tx_dropped))
932 packed.append(struct.pack("!Q", self.rx_errors))
933 packed.append(struct.pack("!Q", self.tx_errors))
934 packed.append(struct.pack("!Q", self.rx_frame_err))
935 packed.append(struct.pack("!Q", self.rx_over_err))
936 packed.append(struct.pack("!Q", self.rx_crc_err))
937 packed.append(struct.pack("!Q", self.collisions))
938 return ''.join(packed)
939
940 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800941 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -0700942 obj = port_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -0700943 obj.port_no = util.unpack_port_no(reader)
Rich Lanec2ee4b82013-04-24 17:12:38 -0700944 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -0700945 obj.rx_packets = reader.read("!Q")[0]
946 obj.tx_packets = reader.read("!Q")[0]
947 obj.rx_bytes = reader.read("!Q")[0]
948 obj.tx_bytes = reader.read("!Q")[0]
949 obj.rx_dropped = reader.read("!Q")[0]
950 obj.tx_dropped = reader.read("!Q")[0]
951 obj.rx_errors = reader.read("!Q")[0]
952 obj.tx_errors = reader.read("!Q")[0]
953 obj.rx_frame_err = reader.read("!Q")[0]
954 obj.rx_over_err = reader.read("!Q")[0]
955 obj.rx_crc_err = reader.read("!Q")[0]
956 obj.collisions = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -0700957 return obj
958
959 def __eq__(self, other):
960 if type(self) != type(other): return False
961 if self.port_no != other.port_no: return False
962 if self.rx_packets != other.rx_packets: return False
963 if self.tx_packets != other.tx_packets: return False
964 if self.rx_bytes != other.rx_bytes: return False
965 if self.tx_bytes != other.tx_bytes: return False
966 if self.rx_dropped != other.rx_dropped: return False
967 if self.tx_dropped != other.tx_dropped: return False
968 if self.rx_errors != other.rx_errors: return False
969 if self.tx_errors != other.tx_errors: return False
970 if self.rx_frame_err != other.rx_frame_err: return False
971 if self.rx_over_err != other.rx_over_err: return False
972 if self.rx_crc_err != other.rx_crc_err: return False
973 if self.collisions != other.collisions: return False
974 return True
975
Rich Lanec2ee4b82013-04-24 17:12:38 -0700976 def pretty_print(self, q):
977 q.text("port_stats_entry {")
978 with q.group():
979 with q.indent(2):
980 q.breakable()
981 q.text("port_no = ");
982 q.text(util.pretty_port(self.port_no))
983 q.text(","); q.breakable()
984 q.text("rx_packets = ");
985 q.text("%#x" % self.rx_packets)
986 q.text(","); q.breakable()
987 q.text("tx_packets = ");
988 q.text("%#x" % self.tx_packets)
989 q.text(","); q.breakable()
990 q.text("rx_bytes = ");
991 q.text("%#x" % self.rx_bytes)
992 q.text(","); q.breakable()
993 q.text("tx_bytes = ");
994 q.text("%#x" % self.tx_bytes)
995 q.text(","); q.breakable()
996 q.text("rx_dropped = ");
997 q.text("%#x" % self.rx_dropped)
998 q.text(","); q.breakable()
999 q.text("tx_dropped = ");
1000 q.text("%#x" % self.tx_dropped)
1001 q.text(","); q.breakable()
1002 q.text("rx_errors = ");
1003 q.text("%#x" % self.rx_errors)
1004 q.text(","); q.breakable()
1005 q.text("tx_errors = ");
1006 q.text("%#x" % self.tx_errors)
1007 q.text(","); q.breakable()
1008 q.text("rx_frame_err = ");
1009 q.text("%#x" % self.rx_frame_err)
1010 q.text(","); q.breakable()
1011 q.text("rx_over_err = ");
1012 q.text("%#x" % self.rx_over_err)
1013 q.text(","); q.breakable()
1014 q.text("rx_crc_err = ");
1015 q.text("%#x" % self.rx_crc_err)
1016 q.text(","); q.breakable()
1017 q.text("collisions = ");
1018 q.text("%#x" % self.collisions)
1019 q.breakable()
1020 q.text('}')
1021
Rich Lane7dcdf022013-12-11 14:45:27 -08001022
1023class queue_prop(loxi.OFObject):
1024 subtypes = {}
1025
1026 @staticmethod
1027 def unpack(reader):
1028 subtype, = reader.peek('!H', 0)
1029 try:
1030 subclass = queue_prop.subtypes[subtype]
1031 except KeyError:
1032 raise loxi.ProtocolError("unknown queue_prop subtype %#x" % subtype)
1033 return subclass.unpack(reader)
1034
1035
1036class queue_prop_experimenter(queue_prop):
1037 subtypes = {}
1038
1039 @staticmethod
1040 def unpack(reader):
1041 subtype, = reader.peek('!L', 8)
1042 try:
1043 subclass = queue_prop_experimenter.subtypes[subtype]
1044 except KeyError:
1045 raise loxi.ProtocolError("unknown queue_prop_experimenter queue_prop subtype %#x" % subtype)
1046 return subclass.unpack(reader)
1047
1048queue_prop.subtypes[65535] = queue_prop_experimenter
1049
1050class queue_prop_max_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001051 type = 2
Rich Lanec2ee4b82013-04-24 17:12:38 -07001052
1053 def __init__(self, rate=None):
1054 if rate != None:
1055 self.rate = rate
1056 else:
1057 self.rate = 0
1058 return
1059
1060 def pack(self):
1061 packed = []
1062 packed.append(struct.pack("!H", self.type))
1063 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1064 packed.append('\x00' * 4)
1065 packed.append(struct.pack("!H", self.rate))
1066 packed.append('\x00' * 6)
1067 length = sum([len(x) for x in packed])
1068 packed[1] = struct.pack("!H", length)
1069 return ''.join(packed)
1070
1071 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001072 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001073 obj = queue_prop_max_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001074 _type = reader.read("!H")[0]
1075 assert(_type == 2)
1076 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001077 orig_reader = reader
1078 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001079 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001080 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001081 reader.skip(6)
1082 return obj
1083
1084 def __eq__(self, other):
1085 if type(self) != type(other): return False
1086 if self.rate != other.rate: return False
1087 return True
1088
Rich Lanec2ee4b82013-04-24 17:12:38 -07001089 def pretty_print(self, q):
1090 q.text("queue_prop_max_rate {")
1091 with q.group():
1092 with q.indent(2):
1093 q.breakable()
1094 q.text("rate = ");
1095 q.text("%#x" % self.rate)
1096 q.breakable()
1097 q.text('}')
1098
Rich Lane7dcdf022013-12-11 14:45:27 -08001099queue_prop.subtypes[2] = queue_prop_max_rate
1100
1101class queue_prop_min_rate(queue_prop):
Dan Talaycof6202252013-07-02 01:00:29 -07001102 type = 1
Rich Lanec2ee4b82013-04-24 17:12:38 -07001103
1104 def __init__(self, rate=None):
1105 if rate != None:
1106 self.rate = rate
1107 else:
1108 self.rate = 0
1109 return
1110
1111 def pack(self):
1112 packed = []
1113 packed.append(struct.pack("!H", self.type))
1114 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1115 packed.append('\x00' * 4)
1116 packed.append(struct.pack("!H", self.rate))
1117 packed.append('\x00' * 6)
1118 length = sum([len(x) for x in packed])
1119 packed[1] = struct.pack("!H", length)
1120 return ''.join(packed)
1121
1122 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001123 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001124 obj = queue_prop_min_rate()
Dan Talaycof6202252013-07-02 01:00:29 -07001125 _type = reader.read("!H")[0]
1126 assert(_type == 1)
1127 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001128 orig_reader = reader
1129 reader = orig_reader.slice(_len - (2 + 2))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001130 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001131 obj.rate = reader.read("!H")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001132 reader.skip(6)
1133 return obj
1134
1135 def __eq__(self, other):
1136 if type(self) != type(other): return False
1137 if self.rate != other.rate: return False
1138 return True
1139
Rich Lanec2ee4b82013-04-24 17:12:38 -07001140 def pretty_print(self, q):
1141 q.text("queue_prop_min_rate {")
1142 with q.group():
1143 with q.indent(2):
1144 q.breakable()
1145 q.text("rate = ");
1146 q.text("%#x" % self.rate)
1147 q.breakable()
1148 q.text('}')
1149
Rich Lane7dcdf022013-12-11 14:45:27 -08001150queue_prop.subtypes[1] = queue_prop_min_rate
1151
1152class queue_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001153
1154 def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None):
1155 if port_no != None:
1156 self.port_no = port_no
1157 else:
1158 self.port_no = 0
1159 if queue_id != None:
1160 self.queue_id = queue_id
1161 else:
1162 self.queue_id = 0
1163 if tx_bytes != None:
1164 self.tx_bytes = tx_bytes
1165 else:
1166 self.tx_bytes = 0
1167 if tx_packets != None:
1168 self.tx_packets = tx_packets
1169 else:
1170 self.tx_packets = 0
1171 if tx_errors != None:
1172 self.tx_errors = tx_errors
1173 else:
1174 self.tx_errors = 0
1175 return
1176
1177 def pack(self):
1178 packed = []
Dan Talaycof6202252013-07-02 01:00:29 -07001179 packed.append(util.pack_port_no(self.port_no))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001180 packed.append(struct.pack("!L", self.queue_id))
1181 packed.append(struct.pack("!Q", self.tx_bytes))
1182 packed.append(struct.pack("!Q", self.tx_packets))
1183 packed.append(struct.pack("!Q", self.tx_errors))
1184 return ''.join(packed)
1185
1186 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001187 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001188 obj = queue_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001189 obj.port_no = util.unpack_port_no(reader)
1190 obj.queue_id = reader.read("!L")[0]
1191 obj.tx_bytes = reader.read("!Q")[0]
1192 obj.tx_packets = reader.read("!Q")[0]
1193 obj.tx_errors = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001194 return obj
1195
1196 def __eq__(self, other):
1197 if type(self) != type(other): return False
1198 if self.port_no != other.port_no: return False
1199 if self.queue_id != other.queue_id: return False
1200 if self.tx_bytes != other.tx_bytes: return False
1201 if self.tx_packets != other.tx_packets: return False
1202 if self.tx_errors != other.tx_errors: return False
1203 return True
1204
Rich Lanec2ee4b82013-04-24 17:12:38 -07001205 def pretty_print(self, q):
1206 q.text("queue_stats_entry {")
1207 with q.group():
1208 with q.indent(2):
1209 q.breakable()
1210 q.text("port_no = ");
1211 q.text(util.pretty_port(self.port_no))
1212 q.text(","); q.breakable()
1213 q.text("queue_id = ");
1214 q.text("%#x" % self.queue_id)
1215 q.text(","); q.breakable()
1216 q.text("tx_bytes = ");
1217 q.text("%#x" % self.tx_bytes)
1218 q.text(","); q.breakable()
1219 q.text("tx_packets = ");
1220 q.text("%#x" % self.tx_packets)
1221 q.text(","); q.breakable()
1222 q.text("tx_errors = ");
1223 q.text("%#x" % self.tx_errors)
1224 q.breakable()
1225 q.text('}')
1226
Rich Lane7dcdf022013-12-11 14:45:27 -08001227
1228class table_stats_entry(loxi.OFObject):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001229
1230 def __init__(self, table_id=None, name=None, match=None, wildcards=None, write_actions=None, apply_actions=None, write_setfields=None, apply_setfields=None, metadata_match=None, metadata_write=None, instructions=None, config=None, max_entries=None, active_count=None, lookup_count=None, matched_count=None):
1231 if table_id != None:
1232 self.table_id = table_id
1233 else:
1234 self.table_id = 0
1235 if name != None:
1236 self.name = name
1237 else:
1238 self.name = ""
1239 if match != None:
1240 self.match = match
1241 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001242 self.match = util.init_match_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001243 if wildcards != None:
1244 self.wildcards = wildcards
1245 else:
Dan Talaycof6202252013-07-02 01:00:29 -07001246 self.wildcards = util.init_wc_bmap()
Rich Lanec2ee4b82013-04-24 17:12:38 -07001247 if write_actions != None:
1248 self.write_actions = write_actions
1249 else:
1250 self.write_actions = 0
1251 if apply_actions != None:
1252 self.apply_actions = apply_actions
1253 else:
1254 self.apply_actions = 0
1255 if write_setfields != None:
1256 self.write_setfields = write_setfields
1257 else:
1258 self.write_setfields = 0
1259 if apply_setfields != None:
1260 self.apply_setfields = apply_setfields
1261 else:
1262 self.apply_setfields = 0
1263 if metadata_match != None:
1264 self.metadata_match = metadata_match
1265 else:
1266 self.metadata_match = 0
1267 if metadata_write != None:
1268 self.metadata_write = metadata_write
1269 else:
1270 self.metadata_write = 0
1271 if instructions != None:
1272 self.instructions = instructions
1273 else:
1274 self.instructions = 0
1275 if config != None:
1276 self.config = config
1277 else:
1278 self.config = 0
1279 if max_entries != None:
1280 self.max_entries = max_entries
1281 else:
1282 self.max_entries = 0
1283 if active_count != None:
1284 self.active_count = active_count
1285 else:
1286 self.active_count = 0
1287 if lookup_count != None:
1288 self.lookup_count = lookup_count
1289 else:
1290 self.lookup_count = 0
1291 if matched_count != None:
1292 self.matched_count = matched_count
1293 else:
1294 self.matched_count = 0
1295 return
1296
1297 def pack(self):
1298 packed = []
1299 packed.append(struct.pack("!B", self.table_id))
1300 packed.append('\x00' * 7)
1301 packed.append(struct.pack("!32s", self.name))
Dan Talaycof6202252013-07-02 01:00:29 -07001302 packed.append(util.pack_match_bmap(self.match))
1303 packed.append(util.pack_wc_bmap(self.wildcards))
Rich Lanec2ee4b82013-04-24 17:12:38 -07001304 packed.append(struct.pack("!L", self.write_actions))
1305 packed.append(struct.pack("!L", self.apply_actions))
1306 packed.append(struct.pack("!Q", self.write_setfields))
1307 packed.append(struct.pack("!Q", self.apply_setfields))
1308 packed.append(struct.pack("!Q", self.metadata_match))
1309 packed.append(struct.pack("!Q", self.metadata_write))
1310 packed.append(struct.pack("!L", self.instructions))
1311 packed.append(struct.pack("!L", self.config))
1312 packed.append(struct.pack("!L", self.max_entries))
1313 packed.append(struct.pack("!L", self.active_count))
1314 packed.append(struct.pack("!Q", self.lookup_count))
1315 packed.append(struct.pack("!Q", self.matched_count))
1316 return ''.join(packed)
1317
1318 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001319 def unpack(reader):
Rich Lanec2ee4b82013-04-24 17:12:38 -07001320 obj = table_stats_entry()
Dan Talaycof6202252013-07-02 01:00:29 -07001321 obj.table_id = reader.read("!B")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001322 reader.skip(7)
1323 obj.name = reader.read("!32s")[0].rstrip("\x00")
Dan Talaycof6202252013-07-02 01:00:29 -07001324 obj.match = util.unpack_match_bmap(reader)
1325 obj.wildcards = util.unpack_wc_bmap(reader)
1326 obj.write_actions = reader.read("!L")[0]
1327 obj.apply_actions = reader.read("!L")[0]
1328 obj.write_setfields = reader.read("!Q")[0]
1329 obj.apply_setfields = reader.read("!Q")[0]
1330 obj.metadata_match = reader.read("!Q")[0]
1331 obj.metadata_write = reader.read("!Q")[0]
1332 obj.instructions = reader.read("!L")[0]
1333 obj.config = reader.read("!L")[0]
1334 obj.max_entries = reader.read("!L")[0]
1335 obj.active_count = reader.read("!L")[0]
1336 obj.lookup_count = reader.read("!Q")[0]
1337 obj.matched_count = reader.read("!Q")[0]
Rich Lanec2ee4b82013-04-24 17:12:38 -07001338 return obj
1339
1340 def __eq__(self, other):
1341 if type(self) != type(other): return False
1342 if self.table_id != other.table_id: return False
1343 if self.name != other.name: return False
1344 if self.match != other.match: return False
1345 if self.wildcards != other.wildcards: return False
1346 if self.write_actions != other.write_actions: return False
1347 if self.apply_actions != other.apply_actions: return False
1348 if self.write_setfields != other.write_setfields: return False
1349 if self.apply_setfields != other.apply_setfields: return False
1350 if self.metadata_match != other.metadata_match: return False
1351 if self.metadata_write != other.metadata_write: return False
1352 if self.instructions != other.instructions: return False
1353 if self.config != other.config: return False
1354 if self.max_entries != other.max_entries: return False
1355 if self.active_count != other.active_count: return False
1356 if self.lookup_count != other.lookup_count: return False
1357 if self.matched_count != other.matched_count: return False
1358 return True
1359
Rich Lanec2ee4b82013-04-24 17:12:38 -07001360 def pretty_print(self, q):
1361 q.text("table_stats_entry {")
1362 with q.group():
1363 with q.indent(2):
1364 q.breakable()
1365 q.text("table_id = ");
1366 q.text("%#x" % self.table_id)
1367 q.text(","); q.breakable()
1368 q.text("name = ");
1369 q.pp(self.name)
1370 q.text(","); q.breakable()
1371 q.text("match = ");
1372 q.pp(self.match)
1373 q.text(","); q.breakable()
1374 q.text("wildcards = ");
1375 q.pp(self.wildcards)
1376 q.text(","); q.breakable()
1377 q.text("write_actions = ");
1378 q.text("%#x" % self.write_actions)
1379 q.text(","); q.breakable()
1380 q.text("apply_actions = ");
1381 q.text("%#x" % self.apply_actions)
1382 q.text(","); q.breakable()
1383 q.text("write_setfields = ");
1384 q.text("%#x" % self.write_setfields)
1385 q.text(","); q.breakable()
1386 q.text("apply_setfields = ");
1387 q.text("%#x" % self.apply_setfields)
1388 q.text(","); q.breakable()
1389 q.text("metadata_match = ");
1390 q.text("%#x" % self.metadata_match)
1391 q.text(","); q.breakable()
1392 q.text("metadata_write = ");
1393 q.text("%#x" % self.metadata_write)
1394 q.text(","); q.breakable()
1395 q.text("instructions = ");
1396 q.text("%#x" % self.instructions)
1397 q.text(","); q.breakable()
1398 q.text("config = ");
1399 q.text("%#x" % self.config)
1400 q.text(","); q.breakable()
1401 q.text("max_entries = ");
1402 q.text("%#x" % self.max_entries)
1403 q.text(","); q.breakable()
1404 q.text("active_count = ");
1405 q.text("%#x" % self.active_count)
1406 q.text(","); q.breakable()
1407 q.text("lookup_count = ");
1408 q.text("%#x" % self.lookup_count)
1409 q.text(","); q.breakable()
1410 q.text("matched_count = ");
1411 q.text("%#x" % self.matched_count)
1412 q.breakable()
1413 q.text('}')
1414
1415
Rich Lane7dcdf022013-12-11 14:45:27 -08001416
Rich Lanec2ee4b82013-04-24 17:12:38 -07001417match = match_v3