blob: 1854d3230a087bac31221ae82a429e66f4828b98 [file] [log] [blame]
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001#
Zsolt Haraszti3eb27a52017-01-03 21:56:48 -08002# Copyright 2017 the original author or authors.
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08003#
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"""
Steve Crooks3c2c7582017-01-10 15:02:26 -060018Broadcom OLT/ONU adapter.
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080019"""
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080020
Steve Crooks3c2c7582017-01-10 15:02:26 -060021from uuid import uuid4
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080022import structlog
23from twisted.internet import reactor
Steve Crooks3c2c7582017-01-10 15:02:26 -060024from twisted.internet.defer import DeferredQueue, inlineCallbacks
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080025from zope.interface import implementer
26
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080027from voltha.adapters.interface import IAdapterInterface
28from voltha.core.logical_device_agent import mac_str_to_tuple
Steve Crooksf248e182017-02-07 10:50:24 -050029import voltha.core.flow_decomposer as fd
Steve Crooks3c2c7582017-01-10 15:02:26 -060030from voltha.protos import third_party
31from voltha.protos.adapter_pb2 import Adapter
32from voltha.protos.adapter_pb2 import AdapterConfig
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080033from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \
34 AdminState
Steve Crooks3c2c7582017-01-10 15:02:26 -060035from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port
36from voltha.protos.health_pb2 import HealthStatus
37from voltha.protos.logical_device_pb2 import LogicalPort
38from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD
Steve Crooksf248e182017-02-07 10:50:24 -050039from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port
Steve Crooks3c2c7582017-01-10 15:02:26 -060040from common.frameio.frameio import hexify
41from voltha.extensions.omci.omci import *
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080042
Steve Crooks3c2c7582017-01-10 15:02:26 -060043_ = third_party
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080044log = structlog.get_logger()
45
46
47@implementer(IAdapterInterface)
48class BroadcomOnuAdapter(object):
49
50 name = 'broadcom_onu'
51
52 supported_device_types = [
53 DeviceType(
Steve Crooks3c2c7582017-01-10 15:02:26 -060054 id=name,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080055 adapter=name,
56 accepts_bulk_flow_update=True
57 )
58 ]
59
60 def __init__(self, adapter_agent, config):
61 self.adapter_agent = adapter_agent
62 self.config = config
63 self.descriptor = Adapter(
64 id=self.name,
65 vendor='Voltha project',
Steve Crooks3c2c7582017-01-10 15:02:26 -060066 version='0.4',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080067 config=AdapterConfig(log_level=LogLevel.INFO)
68 )
Steve Crooks3c2c7582017-01-10 15:02:26 -060069 self.devices_handlers = dict() # device_id -> BroadcomOnuHandler()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080070
71 def start(self):
72 log.debug('starting')
73 log.info('started')
74
75 def stop(self):
76 log.debug('stopping')
77 log.info('stopped')
78
79 def adapter_descriptor(self):
80 return self.descriptor
81
82 def device_types(self):
83 return DeviceTypes(items=self.supported_device_types)
84
85 def health(self):
86 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
87
88 def change_master_state(self, master):
89 raise NotImplementedError()
90
91 def adopt_device(self, device):
Steve Crooks3c2c7582017-01-10 15:02:26 -060092 log.info('adopt_device', device_id=device.id)
93 self.devices_handlers[device.proxy_address.channel_id] = BroadcomOnuHandler(self, device.id)
94 reactor.callLater(0, self.devices_handlers[device.proxy_address.channel_id].activate, device)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080095 return device
96
97 def abandon_device(self, device):
98 raise NotImplementedError()
99
Khen Nursimulud068d812017-03-06 11:44:18 -0500100 def disable_device(self, device):
101 raise NotImplementedError()
102
103 def reenable_device(self, device):
104 raise NotImplementedError()
105
106 def reboot_device(self, device):
107 raise NotImplementedError()
108
109 def delete_device(self, device):
110 raise NotImplementedError()
111
112 def get_device_details(self, device):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800113 raise NotImplementedError()
114
Steve Crooks3c2c7582017-01-10 15:02:26 -0600115 def update_flows_bulk(self, device, flows, groups):
116 log.info('bulk-flow-update', device_id=device.id,
117 flows=flows, groups=groups)
118 assert len(groups.items) == 0
119 handler = self.devices_handlers[device.proxy_address.channel_id]
Steve Crooksf248e182017-02-07 10:50:24 -0500120 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600121
122 def update_flows_incrementally(self, device, flow_changes, group_changes):
123 raise NotImplementedError()
124
125 def send_proxied_message(self, proxy_address, msg):
126 log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
127
128 def receive_proxied_message(self, proxy_address, msg):
129 log.info('receive-proxied-message', proxy_address=proxy_address,
130 device_id=proxy_address.device_id, msg=hexify(msg))
131 handler = self.devices_handlers[proxy_address.channel_id]
132 handler.receive_message(msg)
133
134 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
135 log.info('packet-out', logical_device_id=logical_device_id,
136 egress_port_no=egress_port_no, msg_len=len(msg))
137
138
139class BroadcomOnuHandler(object):
140
141 def __init__(self, adapter, device_id):
142 self.adapter = adapter
143 self.adapter_agent = adapter.adapter_agent
144 self.device_id = device_id
145 self.log = structlog.get_logger(device_id=device_id)
146 self.incoming_messages = DeferredQueue()
147 self.proxy_address = None
148 self.tx_id = 0
149
150 def receive_message(self, msg):
151 self.incoming_messages.put(msg)
152
153 def activate(self, device):
154 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800155
156 # first we verify that we got parent reference and proxy info
157 assert device.parent_id
158 assert device.proxy_address.device_id
159 assert device.proxy_address.channel_id
160
Steve Crooks3c2c7582017-01-10 15:02:26 -0600161 # register for proxied messages right away
162 self.proxy_address = device.proxy_address
163 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
164
165 # populate device info
166 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800167 device.vendor = 'Broadcom'
Steve Crooks3c2c7582017-01-10 15:02:26 -0600168 device.model ='n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800169 device.hardware_version = 'to be filled'
170 device.firmware_version = 'to be filled'
171 device.software_version = 'to be filled'
172 device.serial_number = uuid4().hex
173 device.connect_status = ConnectStatus.REACHABLE
174 self.adapter_agent.update_device(device)
175
Steve Crooks3c2c7582017-01-10 15:02:26 -0600176 # register physical ports
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800177 uni_port = Port(
Steve Crooks3c2c7582017-01-10 15:02:26 -0600178 port_no=2,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800179 label='UNI facing Ethernet port',
180 type=Port.ETHERNET_UNI,
181 admin_state=AdminState.ENABLED,
182 oper_status=OperStatus.ACTIVE
183 )
184 self.adapter_agent.add_port(device.id, uni_port)
185 self.adapter_agent.add_port(device.id, Port(
186 port_no=1,
187 label='PON port',
188 type=Port.PON_ONU,
189 admin_state=AdminState.ENABLED,
190 oper_status=OperStatus.ACTIVE,
191 peers=[
192 Port.PeerPort(
193 device_id=device.parent_id,
194 port_no=device.parent_port_no
195 )
196 ]
197 ))
198
Steve Crooks3c2c7582017-01-10 15:02:26 -0600199 # add uni port to logical device
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800200 parent_device = self.adapter_agent.get_device(device.parent_id)
201 logical_device_id = parent_device.parent_id
202 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800203 port_no = device.proxy_address.channel_id
204 cap = OFPPF_1GB_FD | OFPPF_FIBER
205 self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
Steve Crooks3c2c7582017-01-10 15:02:26 -0600206 id='uni-{}'.format(port_no),
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800207 ofp_port=ofp_port(
208 port_no=port_no,
Steve Crooks77334a72017-01-25 20:29:37 -0500209 hw_addr=mac_str_to_tuple('00:00:00:00:%02x:%02x' % ((port_no >> 8) & 0xff, port_no & 0xff)),
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800210 name='uni-{}'.format(port_no),
211 config=0,
212 state=OFPPS_LIVE,
213 curr=cap,
214 advertised=cap,
215 peer=cap,
216 curr_speed=OFPPF_1GB_FD,
217 max_speed=OFPPF_1GB_FD
218 ),
219 device_id=device.id,
220 device_port_no=uni_port.port_no
221 ))
222
Steve Crooks77334a72017-01-25 20:29:37 -0500223 reactor.callLater(10, self.message_exchange)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800224
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800225 device = self.adapter_agent.get_device(device.id)
226 device.oper_status = OperStatus.ACTIVE
227 self.adapter_agent.update_device(device)
228
Steve Crooks3c2c7582017-01-10 15:02:26 -0600229 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500230 def update_flow_table(self, device, flows):
231 #
232 # We need to proxy through the OLT to get to the ONU
233 # Configuration from here should be using OMCI
234 #
235 self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800236
Steve Crooksf248e182017-02-07 10:50:24 -0500237 def is_downstream(port):
238 return port == 2 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800239
Steve Crooksf248e182017-02-07 10:50:24 -0500240 def is_upstream(port):
241 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800242
Steve Crooksf248e182017-02-07 10:50:24 -0500243 for flow in flows:
244 try:
245 _in_port = fd.get_in_port(flow)
246 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600247
Steve Crooksf248e182017-02-07 10:50:24 -0500248 if is_downstream(_in_port):
249 self.log.info('downstream-flow')
250 elif is_upstream(_in_port):
251 self.log.info('upstream-flow')
252 else:
253 raise Exception('port should be 1 or 2 by our convention')
254
255 _out_port = fd.get_out_port(flow) # may be None
256 self.log.info('out-port', out_port=_out_port)
257
258 for field in fd.get_ofb_fields(flow):
259 if field.type == fd.ETH_TYPE:
260 _type = field.eth_type
261 self.log.info('field-type-eth-type',
262 eth_type=_type)
263
264 elif field.type == fd.IP_PROTO:
265 _proto = field.ip_proto
266 self.log.info('field-type-ip-proto',
267 ip_proto=_proto)
268
269 elif field.type == fd.IN_PORT:
270 _port = field.port
271 self.log.info('field-type-in-port',
272 in_port=_port)
273
274 elif field.type == fd.VLAN_VID:
275 _vlan_vid = field.vlan_vid & 0xfff
276 self.log.info('field-type-vlan-vid',
277 vlan=_vlan_vid)
278
279 elif field.type == fd.VLAN_PCP:
280 _vlan_pcp = field.vlan_pcp
281 self.log.info('field-type-vlan-pcp',
282 pcp=_vlan_pcp)
283
284 elif field.type == fd.UDP_DST:
285 _udp_dst = field.udp_dst
286 self.log.info('field-type-udp-dst',
287 udp_dst=_udp_dst)
288
289 elif field.type == fd.UDP_SRC:
290 _udp_src = field.udp_src
291 self.log.info('field-type-udp-src',
292 udp_src=_udp_src)
293
294 elif field.type == fd.IPV4_DST:
295 _ipv4_dst = field.ipv4_dst
296 self.log.info('field-type-ipv4-dst',
297 ipv4_dst=_ipv4_dst)
298
299 elif field.type == fd.IPV4_SRC:
300 _ipv4_src = field.ipv4_src
301 self.log.info('field-type-ipv4-src',
302 ipv4_dst=_ipv4_src)
303
304 elif field.type == fd.METADATA:
305 _metadata = field.metadata
306 self.log.info('field-type-metadata',
307 metadata=_metadata)
308
309 else:
310 raise NotImplementedError('field.type={}'.format(
311 field.type))
312
313 for action in fd.get_actions(flow):
314
315 if action.type == fd.OUTPUT:
316 _output = action.output.port
317 self.log.info('action-type-output',
318 output=_output, in_port=_in_port)
319
320 elif action.type == fd.POP_VLAN:
321 self.log.info('action-type-pop-vlan',
322 in_port=_in_port)
323
324 elif action.type == fd.PUSH_VLAN:
325 _push_tpid = action.push.ethertype
326 log.info('action-type-push-vlan',
327 push_tpid=_push_tpid, in_port=_in_port)
328 if action.push.ethertype != 0x8100:
329 self.log.error('unhandled-tpid',
330 ethertype=action.push.ethertype)
331
332 elif action.type == fd.SET_FIELD:
333 _field = action.set_field.field.ofb_field
334 assert (action.set_field.field.oxm_class ==
335 OFPXMC_OPENFLOW_BASIC)
336 self.log.info('action-type-set-field',
337 field=_field, in_port=_in_port)
338 if _field.type == fd.VLAN_VID:
339 self.log.info('set-field-type-valn-vid',
340 vlan_vid=_field.vlan_vid & 0xfff)
341 else:
342 self.log.error('unsupported-action-set-field-type',
343 field_type=_field.type)
344 else:
345 log.error('unsupported-action-type',
346 action_type=action.type, in_port=_in_port)
347
348 #
349 # All flows created from ONU adapter should be OMCI based
350 #
351
352 except Exception as e:
353 log.exception('failed-to-install-flow', e=e, flow=flow)
354
Steve Crooks3c2c7582017-01-10 15:02:26 -0600355
356 def get_tx_id(self):
357 self.tx_id += 1
358 return self.tx_id
359
360 def send_omci_message(self, frame):
361 _frame = hexify(str(frame))
362 self.log.info('send-omci-message-%s' % _frame)
363 device = self.adapter_agent.get_device(self.device_id)
364 try:
365 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
366 except Exception as e:
367 self.log.info('send-omci-message-exception', exc=str(e))
368
369 def send_get_circuit_pack(self, entity_id=0):
370 frame = OmciFrame(
371 transaction_id=self.get_tx_id(),
372 message_type=OmciGet.message_id,
373 omci_message=OmciGet(
374 entity_class=CircuitPack.class_id,
375 entity_id=entity_id,
376 attributes_mask=CircuitPack.mask_for('vendor_id')
377 )
378 )
379 self.send_omci_message(frame)
380
381 def send_mib_reset(self, entity_id=0):
382 frame = OmciFrame(
383 transaction_id=self.get_tx_id(),
384 message_type=OmciMibReset.message_id,
385 omci_message=OmciMibReset(
386 entity_class=OntData.class_id,
387 entity_id=entity_id
388 )
389 )
390 self.send_omci_message(frame)
391
392 def send_create_gal_ethernet_profile(self, entity_id, max_gem_payload_size):
393 frame = OmciFrame(
394 transaction_id=self.get_tx_id(),
395 message_type=OmciCreate.message_id,
396 omci_message=OmciCreate(
397 entity_class=GalEthernetProfile.class_id,
398 entity_id=entity_id,
399 data=dict(
400 max_gem_payload_size=max_gem_payload_size
401 )
402 )
403 )
404 self.send_omci_message(frame)
405
406 def send_set_tcont(self, entity_id, alloc_id):
407 data = dict(
408 alloc_id=alloc_id
409 )
410 frame = OmciFrame(
411 transaction_id=self.get_tx_id(),
412 message_type=OmciSet.message_id,
413 omci_message=OmciSet(
414 entity_class=Tcont.class_id,
415 entity_id = entity_id,
416 attributes_mask=Tcont.mask_for(*data.keys()),
417 data=data
418 )
419 )
420 self.send_omci_message(frame)
421
422 def send_create_8021p_mapper_service_profile(self, entity_id):
423 frame = OmciFrame(
424 transaction_id = self.get_tx_id(),
425 message_type=OmciCreate.message_id,
426 omci_message=OmciCreate(
427 entity_class=Ieee8021pMapperServiceProfile.class_id,
428 entity_id=entity_id,
429 data=dict(
430 tp_pointer=OmciNullPointer,
431 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
432 )
433 )
434 )
435 self.send_omci_message(frame)
436
437 def send_create_mac_bridge_service_profile(self, entity_id):
438 frame = OmciFrame(
439 transaction_id = self.get_tx_id(),
440 message_type=OmciCreate.message_id,
441 omci_message=OmciCreate(
442 entity_class=MacBridgeServiceProfile.class_id,
443 entity_id=entity_id,
444 data=dict(
445 spanning_tree_ind=False,
446 learning_ind=True,
447 priority=0x8000,
448 max_age=20 * 256,
449 hello_time=2 * 256,
450 forward_delay=15 * 256,
451 unknown_mac_address_discard=True
452 )
453 )
454 )
455 self.send_omci_message(frame)
456
457 def send_create_gem_port_network_ctp(self, entity_id, port_id, tcont_id):
458 frame = OmciFrame(
459 transaction_id = self.get_tx_id(),
460 message_type=OmciCreate.message_id,
461 omci_message=OmciCreate(
462 entity_class=GemPortNetworkCtp.class_id,
463 entity_id=entity_id,
464 data=dict(
465 port_id=port_id,
466 tcont_pointer=tcont_id,
467 direction=3,
468 traffic_management_pointer_upstream=0x100
469 )
470 )
471 )
472 self.send_omci_message(frame)
473
474 def send_create_multicast_gem_interworking_tp(self, entity_id, gem_port_net_ctp_id):
475 frame = OmciFrame(
476 transaction_id = self.get_tx_id(),
477 message_type=OmciCreate.message_id,
478 omci_message=OmciCreate(
479 entity_class=MulticastGemInterworkingTp.class_id,
480 entity_id=entity_id,
481 data=dict(
482 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
483 interworking_option=0,
484 service_profile_pointer=0x1,
485 )
486 )
487 )
488 self.send_omci_message(frame)
489
490 def send_create_gem_inteworking_tp(self, entity_id, gem_port_net_ctp_id, service_profile_id):
491 frame = OmciFrame(
492 transaction_id = self.get_tx_id(),
493 message_type=OmciCreate.message_id,
494 omci_message=OmciCreate(
495 entity_class=GemInterworkingTp.class_id,
496 entity_id=entity_id,
497 data=dict(
498 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
499 interworking_option=5,
500 service_profile_pointer=service_profile_id,
501 interworking_tp_pointer=0x0,
502 gal_profile_pointer=0x1
503 )
504 )
505 )
506 self.send_omci_message(frame)
507
508 def send_set_8021p_mapper_service_profile(self, entity_id, interwork_tp_id):
509 data = dict(
510 interwork_tp_pointer_for_p_bit_priority_0 = interwork_tp_id
511 )
512 frame = OmciFrame(
513 transaction_id = self.get_tx_id(),
514 message_type=OmciSet.message_id,
515 omci_message=OmciSet(
516 entity_class=Ieee8021pMapperServiceProfile.class_id,
517 entity_id=entity_id,
518 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
519 *data.keys()),
520 data=data
521 )
522 )
523 self.send_omci_message(frame)
524
525 def send_create_mac_bridge_port_configuration_data(self,
526 entity_id,
527 bridge_id,
528 port_id,
529 tp_type,
530 tp_id):
531 frame = OmciFrame(
532 transaction_id=self.get_tx_id(),
533 message_type=OmciCreate.message_id,
534 omci_message=OmciCreate(
535 entity_class=MacBridgePortConfigurationData.class_id,
536 entity_id=entity_id,
537 data=dict(
538 bridge_id_pointer = bridge_id,
539 port_num=port_id,
540 tp_type=tp_type,
541 tp_pointer = tp_id
542 )
543 )
544 )
545 self.send_omci_message(frame)
546
547 def send_create_vlan_tagging_filter_data(self, entity_id, vlan_id):
548 frame = OmciFrame(
549 transaction_id = self.get_tx_id(),
550 message_type=OmciCreate.message_id,
551 omci_message=OmciCreate(
552 entity_class=VlanTaggingFilterData.class_id,
553 entity_id=entity_id,
554 data=dict(
555 vlan_filter_0=vlan_id,
556 forward_operation=0x10,
557 number_of_entries=1
558 )
559 )
560 )
561 self.send_omci_message(frame)
562
563 def send_create_extended_vlan_tagging_operation_configuration_data(self, entity_id):
564 frame = OmciFrame(
565 transaction_id = self.get_tx_id(),
566 message_type=OmciCreate.message_id,
567 omci_message=OmciCreate(
568 entity_class=
569 ExtendedVlanTaggingOperationConfigurationData.class_id,
570 entity_id=entity_id,
571 data=dict(
572 association_type=10,
573 associated_me_pointer=0x401
574 )
575 )
576 )
577 self.send_omci_message(frame)
578
579 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, entity_id, input_tpid, output_tpid):
580 data = dict(
581 input_tpid = input_tpid,
582 output_tpid = output_tpid,
583 downstream_mode=0, # inverse of upstream
584 )
585 frame = OmciFrame(
586 transaction_id = self.get_tx_id(),
587 message_type=OmciSet.message_id,
588 omci_message=OmciSet(
589 entity_class=\
590 ExtendedVlanTaggingOperationConfigurationData.class_id,
591 entity_id=entity_id,
592 attributes_mask= \
593 ExtendedVlanTaggingOperationConfigurationData.mask_for(
594 *data.keys()),
595 data=data
596 )
597 )
598 self.send_omci_message(frame)
599
600 def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self,
601 entity_id,
602 filter_inner_vid,
603 treatment_inner_vid):
604 data = dict(
605 received_frame_vlan_tagging_operation_table=\
606 VlanTaggingOperation(
607 filter_outer_priority=15,
608 filter_inner_priority=8,
609 filter_inner_vid = filter_inner_vid,
610 filter_inner_tpid_de=5,
611 filter_ether_type=0,
612 treatment_tags_to_remove=1,
613 pad3=2,
614 treatment_outer_priority=15,
615 treatment_inner_priority=8,
616 treatment_inner_vid = treatment_inner_vid,
617 treatment_inner_tpid_de=4
618 )
619 )
620 frame = OmciFrame(
621 transaction_id = self.get_tx_id(),
622 message_type=OmciSet.message_id,
623 omci_message=OmciSet(
624 entity_class=\
625 ExtendedVlanTaggingOperationConfigurationData.class_id,
626 entity_id = entity_id,
627 attributes_mask= \
628 ExtendedVlanTaggingOperationConfigurationData.mask_for(
629 *data.keys()),
630 data=data
631 )
632 )
633 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800634
635 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -0600636 def wait_for_response(self):
637 log.info('wait-for-response')
638 try:
639 response = yield self.incoming_messages.get()
640 resp = OmciFrame(response)
641 resp.show()
642 except Exception as e:
643 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800644
Steve Crooks3c2c7582017-01-10 15:02:26 -0600645 @inlineCallbacks
646 def message_exchange(self):
647 log.info('message_exchange')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800648 # reset incoming message queue
649 while self.incoming_messages.pending:
650 _ = yield self.incoming_messages.get()
651
652 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -0600653 # MIB Reset - OntData - 0
654 self.send_mib_reset()
655 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800656
Steve Crooks3c2c7582017-01-10 15:02:26 -0600657 # Create AR - GalEthernetProfile - 1
658 self.send_create_gal_ethernet_profile(1, 48)
659 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800660
Steve Crooks3c2c7582017-01-10 15:02:26 -0600661 # Set AR - TCont - 32768 - 1024
662 self.send_set_tcont(0x8000, 0x400)
663 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800664
Steve Crooks3c2c7582017-01-10 15:02:26 -0600665 # Set AR - TCont - 32769 - 1025
666 self.send_set_tcont(0x8001, 0x401)
667 yield self.wait_for_response()
Zsolt Haraszti656ecc62016-12-28 15:08:23 -0800668
Steve Crooks3c2c7582017-01-10 15:02:26 -0600669 # Set AR - TCont - 32770 - 1026
670 self.send_set_tcont(0x8002, 0x402)
671 yield self.wait_for_response()
672
673 # Set AR - TCont - 32771 - 1027
674 self.send_set_tcont(0x8003, 0x403)
675 yield self.wait_for_response()
676
677 # Create AR - 802.1pMapperServiceProfile - 32768
678 self.send_create_8021p_mapper_service_profile(0x8000)
679 yield self.wait_for_response()
680
681 # Create AR - 802.1pMapperServiceProfile - 32769
682 self.send_create_8021p_mapper_service_profile(0x8001)
683 yield self.wait_for_response()
684
685 # Create AR - 802.1pMapperServiceProfile - 32770
686 self.send_create_8021p_mapper_service_profile(0x8002)
687 yield self.wait_for_response()
688
689 # Create AR - 802.1pMapperServiceProfile - 32771
690 self.send_create_8021p_mapper_service_profile(0x8003)
691 yield self.wait_for_response()
692
693 # Create AR - MacBridgeServiceProfile - 513
694 self.send_create_mac_bridge_service_profile(0x201)
695 yield self.wait_for_response()
696
697 # Create AR - GemPortNetworkCtp - 256 - 1024 - 32768
698 self.send_create_gem_port_network_ctp(0x100, 0x400, 0x8000)
699 yield self.wait_for_response()
700
701 # Create AR - GemPortNetworkCtp - 257 - 1025 - 32769
702 self.send_create_gem_port_network_ctp(0x101, 0x401, 0x8001)
703 yield self.wait_for_response()
704
705 # Create AR - GemPortNetworkCtp - 258 - 1026 - 32770
706 self.send_create_gem_port_network_ctp(0x102, 0x402, 0x8002)
707 yield self.wait_for_response()
708
709 # Create AR - GemPortNetworkCtp - 259 - 1027 - 32771
710 self.send_create_gem_port_network_ctp(0x103, 0x403, 0x8003)
711 yield self.wait_for_response()
712
713 # Create AR - MulticastGemInterworkingTp - 6 - 260
714 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
715 yield self.wait_for_response()
716
717 # Create AR - GemInterworkingTp - 32769 - 256 -32768 - 1
718 self.send_create_gem_inteworking_tp(0x8001, 0x100, 0x8000)
719 yield self.wait_for_response()
720
721 # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1
722 self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001)
723 yield self.wait_for_response()
724
725 # Create AR - GemInterworkingTp - 32771 - 258 -32770 - 1
726 self.send_create_gem_inteworking_tp(0x8003, 0x102, 0x8002)
727 yield self.wait_for_response()
728
729 # Create AR - GemInterworkingTp - 32772 - 259 -32771 - 1
730 self.send_create_gem_inteworking_tp(0x8004, 0x103, 0x8003)
731 yield self.wait_for_response()
732
733 # Set AR - 802.1pMapperServiceProfile - 32768 - 32769
734 self.send_set_8021p_mapper_service_profile(0x8000, 0x8001)
735 yield self.wait_for_response()
736
737 # Set AR - 802.1pMapperServiceProfile - 32769 - 32770
738 self.send_set_8021p_mapper_service_profile(0x8001, 0x8002)
739 yield self.wait_for_response()
740
741 # Set AR - 802.1pMapperServiceProfile - 32770 - 32771
742 self.send_set_8021p_mapper_service_profile(0x8002, 0x8003)
743 yield self.wait_for_response()
744
745 # Set AR - 802.1pMapperServiceProfile - 32771 - 32772
746 self.send_set_8021p_mapper_service_profile(0x8003, 0x8004)
747 yield self.wait_for_response()
748
749 # Create AR - MacBridgePortConfigData - 8449 - 513 - 2 - 3 - 32768
750 self.send_create_mac_bridge_port_configuration_data(0x2101, 0x201, 2, 3, 0x8000)
751 yield self.wait_for_response()
752
753 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
754 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
755 yield self.wait_for_response()
756
757 # Create AR - MacBridgePortConfigData - 8451 - 513 - 4 - 3 - 32770
758 self.send_create_mac_bridge_port_configuration_data(0x2103, 0x201, 4, 3, 0x8002)
759 yield self.wait_for_response()
760
761 # Create AR - MacBridgePortConfigData - 8452 - 513 - 5 - 3 - 32771
762 self.send_create_mac_bridge_port_configuration_data(0x2104, 0x201, 5, 3, 0x8003)
763 yield self.wait_for_response()
764
765 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
766 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
767 yield self.wait_for_response()
768
769 # Create AR - VlanTaggingFilterData - 8449 - 040000000000000000000000000000000000000000000000
770 self.send_create_vlan_tagging_filter_data(0x2101, 0x0400)
771 yield self.wait_for_response()
772
773 # Create AR - VlanTaggingFilterData - 8450 - 040100000000000000000000000000000000000000000000
774 self.send_create_vlan_tagging_filter_data(0x2102, 0x0401)
775 yield self.wait_for_response()
776
777 # Create AR - VlanTaggingFilterData - 8451 - 040200000000000000000000000000000000000000000000
778 self.send_create_vlan_tagging_filter_data(0x2103, 0x0402)
779 yield self.wait_for_response()
780
781 # Create AR - VlanTaggingFilterData - 8452 - 040300000000000000000000000000000000000000000000
782 self.send_create_vlan_tagging_filter_data(0x2104, 0x0403)
783 yield self.wait_for_response()
784
785 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 10 - 1025
786 self.send_create_extended_vlan_tagging_operation_configuration_data(0x202)
787 yield self.wait_for_response()
788
789 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
790 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202,0x8100,0x8100)
791 yield self.wait_for_response()
792
793 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x400 - 5 - 0x400 - 4
794 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x400, 0x400)
795 yield self.wait_for_response()
796
797 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x401 - 5 - 0x401 - 4
798 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x401, 0x401)
799 yield self.wait_for_response()
800
801 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x402 - 5 - 0x402 - 4
802 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x402, 0x402)
803 yield self.wait_for_response()
804
805 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x403 - 5 - 0x403 - 4
806 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x403, 0x403)
807 yield self.wait_for_response()
808
809 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 11 - 1025
810 self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 1, 11, 0x401)
811 yield self.wait_for_response()
812