blob: 3e96e1c6a50af73d000beac5e77020c1068823a2 [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
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500115 def update_pm_config(self, device, pm_configs):
116 raise NotImplementedError()
117
Steve Crooks3c2c7582017-01-10 15:02:26 -0600118 def update_flows_bulk(self, device, flows, groups):
119 log.info('bulk-flow-update', device_id=device.id,
120 flows=flows, groups=groups)
121 assert len(groups.items) == 0
122 handler = self.devices_handlers[device.proxy_address.channel_id]
Steve Crooksf248e182017-02-07 10:50:24 -0500123 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600124
125 def update_flows_incrementally(self, device, flow_changes, group_changes):
126 raise NotImplementedError()
127
128 def send_proxied_message(self, proxy_address, msg):
129 log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
130
131 def receive_proxied_message(self, proxy_address, msg):
132 log.info('receive-proxied-message', proxy_address=proxy_address,
133 device_id=proxy_address.device_id, msg=hexify(msg))
134 handler = self.devices_handlers[proxy_address.channel_id]
135 handler.receive_message(msg)
136
137 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
138 log.info('packet-out', logical_device_id=logical_device_id,
139 egress_port_no=egress_port_no, msg_len=len(msg))
140
141
142class BroadcomOnuHandler(object):
143
144 def __init__(self, adapter, device_id):
145 self.adapter = adapter
146 self.adapter_agent = adapter.adapter_agent
147 self.device_id = device_id
148 self.log = structlog.get_logger(device_id=device_id)
149 self.incoming_messages = DeferredQueue()
150 self.proxy_address = None
151 self.tx_id = 0
152
153 def receive_message(self, msg):
154 self.incoming_messages.put(msg)
155
156 def activate(self, device):
157 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800158
159 # first we verify that we got parent reference and proxy info
160 assert device.parent_id
161 assert device.proxy_address.device_id
162 assert device.proxy_address.channel_id
163
Steve Crooks3c2c7582017-01-10 15:02:26 -0600164 # register for proxied messages right away
165 self.proxy_address = device.proxy_address
166 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
167
168 # populate device info
169 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800170 device.vendor = 'Broadcom'
Steve Crooks3c2c7582017-01-10 15:02:26 -0600171 device.model ='n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800172 device.hardware_version = 'to be filled'
173 device.firmware_version = 'to be filled'
174 device.software_version = 'to be filled'
175 device.serial_number = uuid4().hex
176 device.connect_status = ConnectStatus.REACHABLE
177 self.adapter_agent.update_device(device)
178
Steve Crooks3c2c7582017-01-10 15:02:26 -0600179 # register physical ports
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800180 uni_port = Port(
Steve Crooks3c2c7582017-01-10 15:02:26 -0600181 port_no=2,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800182 label='UNI facing Ethernet port',
183 type=Port.ETHERNET_UNI,
184 admin_state=AdminState.ENABLED,
185 oper_status=OperStatus.ACTIVE
186 )
187 self.adapter_agent.add_port(device.id, uni_port)
188 self.adapter_agent.add_port(device.id, Port(
189 port_no=1,
190 label='PON port',
191 type=Port.PON_ONU,
192 admin_state=AdminState.ENABLED,
193 oper_status=OperStatus.ACTIVE,
194 peers=[
195 Port.PeerPort(
196 device_id=device.parent_id,
197 port_no=device.parent_port_no
198 )
199 ]
200 ))
201
Steve Crooks3c2c7582017-01-10 15:02:26 -0600202 # add uni port to logical device
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800203 parent_device = self.adapter_agent.get_device(device.parent_id)
204 logical_device_id = parent_device.parent_id
205 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800206 port_no = device.proxy_address.channel_id
207 cap = OFPPF_1GB_FD | OFPPF_FIBER
208 self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
Steve Crooks3c2c7582017-01-10 15:02:26 -0600209 id='uni-{}'.format(port_no),
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800210 ofp_port=ofp_port(
211 port_no=port_no,
Steve Crooks77334a72017-01-25 20:29:37 -0500212 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 -0800213 name='uni-{}'.format(port_no),
214 config=0,
215 state=OFPPS_LIVE,
216 curr=cap,
217 advertised=cap,
218 peer=cap,
219 curr_speed=OFPPF_1GB_FD,
220 max_speed=OFPPF_1GB_FD
221 ),
222 device_id=device.id,
223 device_port_no=uni_port.port_no
224 ))
225
Steve Crooks77334a72017-01-25 20:29:37 -0500226 reactor.callLater(10, self.message_exchange)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800227
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800228 device = self.adapter_agent.get_device(device.id)
229 device.oper_status = OperStatus.ACTIVE
230 self.adapter_agent.update_device(device)
231
Steve Crooks3c2c7582017-01-10 15:02:26 -0600232 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500233 def update_flow_table(self, device, flows):
234 #
235 # We need to proxy through the OLT to get to the ONU
236 # Configuration from here should be using OMCI
237 #
238 self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800239
Steve Crooksf248e182017-02-07 10:50:24 -0500240 def is_downstream(port):
241 return port == 2 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800242
Steve Crooksf248e182017-02-07 10:50:24 -0500243 def is_upstream(port):
244 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800245
Steve Crooksf248e182017-02-07 10:50:24 -0500246 for flow in flows:
247 try:
248 _in_port = fd.get_in_port(flow)
249 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600250
Steve Crooksf248e182017-02-07 10:50:24 -0500251 if is_downstream(_in_port):
252 self.log.info('downstream-flow')
253 elif is_upstream(_in_port):
254 self.log.info('upstream-flow')
255 else:
256 raise Exception('port should be 1 or 2 by our convention')
257
258 _out_port = fd.get_out_port(flow) # may be None
259 self.log.info('out-port', out_port=_out_port)
260
261 for field in fd.get_ofb_fields(flow):
262 if field.type == fd.ETH_TYPE:
263 _type = field.eth_type
264 self.log.info('field-type-eth-type',
265 eth_type=_type)
266
267 elif field.type == fd.IP_PROTO:
268 _proto = field.ip_proto
269 self.log.info('field-type-ip-proto',
270 ip_proto=_proto)
271
272 elif field.type == fd.IN_PORT:
273 _port = field.port
274 self.log.info('field-type-in-port',
275 in_port=_port)
276
277 elif field.type == fd.VLAN_VID:
278 _vlan_vid = field.vlan_vid & 0xfff
279 self.log.info('field-type-vlan-vid',
280 vlan=_vlan_vid)
281
282 elif field.type == fd.VLAN_PCP:
283 _vlan_pcp = field.vlan_pcp
284 self.log.info('field-type-vlan-pcp',
285 pcp=_vlan_pcp)
286
287 elif field.type == fd.UDP_DST:
288 _udp_dst = field.udp_dst
289 self.log.info('field-type-udp-dst',
290 udp_dst=_udp_dst)
291
292 elif field.type == fd.UDP_SRC:
293 _udp_src = field.udp_src
294 self.log.info('field-type-udp-src',
295 udp_src=_udp_src)
296
297 elif field.type == fd.IPV4_DST:
298 _ipv4_dst = field.ipv4_dst
299 self.log.info('field-type-ipv4-dst',
300 ipv4_dst=_ipv4_dst)
301
302 elif field.type == fd.IPV4_SRC:
303 _ipv4_src = field.ipv4_src
304 self.log.info('field-type-ipv4-src',
305 ipv4_dst=_ipv4_src)
306
307 elif field.type == fd.METADATA:
308 _metadata = field.metadata
309 self.log.info('field-type-metadata',
310 metadata=_metadata)
311
312 else:
313 raise NotImplementedError('field.type={}'.format(
314 field.type))
315
316 for action in fd.get_actions(flow):
317
318 if action.type == fd.OUTPUT:
319 _output = action.output.port
320 self.log.info('action-type-output',
321 output=_output, in_port=_in_port)
322
323 elif action.type == fd.POP_VLAN:
324 self.log.info('action-type-pop-vlan',
325 in_port=_in_port)
326
327 elif action.type == fd.PUSH_VLAN:
328 _push_tpid = action.push.ethertype
329 log.info('action-type-push-vlan',
330 push_tpid=_push_tpid, in_port=_in_port)
331 if action.push.ethertype != 0x8100:
332 self.log.error('unhandled-tpid',
333 ethertype=action.push.ethertype)
334
335 elif action.type == fd.SET_FIELD:
336 _field = action.set_field.field.ofb_field
337 assert (action.set_field.field.oxm_class ==
338 OFPXMC_OPENFLOW_BASIC)
339 self.log.info('action-type-set-field',
340 field=_field, in_port=_in_port)
341 if _field.type == fd.VLAN_VID:
342 self.log.info('set-field-type-valn-vid',
343 vlan_vid=_field.vlan_vid & 0xfff)
344 else:
345 self.log.error('unsupported-action-set-field-type',
346 field_type=_field.type)
347 else:
348 log.error('unsupported-action-type',
349 action_type=action.type, in_port=_in_port)
350
351 #
352 # All flows created from ONU adapter should be OMCI based
353 #
354
355 except Exception as e:
356 log.exception('failed-to-install-flow', e=e, flow=flow)
357
Steve Crooks3c2c7582017-01-10 15:02:26 -0600358
359 def get_tx_id(self):
360 self.tx_id += 1
361 return self.tx_id
362
363 def send_omci_message(self, frame):
364 _frame = hexify(str(frame))
365 self.log.info('send-omci-message-%s' % _frame)
366 device = self.adapter_agent.get_device(self.device_id)
367 try:
368 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
369 except Exception as e:
370 self.log.info('send-omci-message-exception', exc=str(e))
371
372 def send_get_circuit_pack(self, entity_id=0):
373 frame = OmciFrame(
374 transaction_id=self.get_tx_id(),
375 message_type=OmciGet.message_id,
376 omci_message=OmciGet(
377 entity_class=CircuitPack.class_id,
378 entity_id=entity_id,
379 attributes_mask=CircuitPack.mask_for('vendor_id')
380 )
381 )
382 self.send_omci_message(frame)
383
384 def send_mib_reset(self, entity_id=0):
385 frame = OmciFrame(
386 transaction_id=self.get_tx_id(),
387 message_type=OmciMibReset.message_id,
388 omci_message=OmciMibReset(
389 entity_class=OntData.class_id,
390 entity_id=entity_id
391 )
392 )
393 self.send_omci_message(frame)
394
395 def send_create_gal_ethernet_profile(self, entity_id, max_gem_payload_size):
396 frame = OmciFrame(
397 transaction_id=self.get_tx_id(),
398 message_type=OmciCreate.message_id,
399 omci_message=OmciCreate(
400 entity_class=GalEthernetProfile.class_id,
401 entity_id=entity_id,
402 data=dict(
403 max_gem_payload_size=max_gem_payload_size
404 )
405 )
406 )
407 self.send_omci_message(frame)
408
409 def send_set_tcont(self, entity_id, alloc_id):
410 data = dict(
411 alloc_id=alloc_id
412 )
413 frame = OmciFrame(
414 transaction_id=self.get_tx_id(),
415 message_type=OmciSet.message_id,
416 omci_message=OmciSet(
417 entity_class=Tcont.class_id,
418 entity_id = entity_id,
419 attributes_mask=Tcont.mask_for(*data.keys()),
420 data=data
421 )
422 )
423 self.send_omci_message(frame)
424
425 def send_create_8021p_mapper_service_profile(self, entity_id):
426 frame = OmciFrame(
427 transaction_id = self.get_tx_id(),
428 message_type=OmciCreate.message_id,
429 omci_message=OmciCreate(
430 entity_class=Ieee8021pMapperServiceProfile.class_id,
431 entity_id=entity_id,
432 data=dict(
433 tp_pointer=OmciNullPointer,
434 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
435 )
436 )
437 )
438 self.send_omci_message(frame)
439
440 def send_create_mac_bridge_service_profile(self, entity_id):
441 frame = OmciFrame(
442 transaction_id = self.get_tx_id(),
443 message_type=OmciCreate.message_id,
444 omci_message=OmciCreate(
445 entity_class=MacBridgeServiceProfile.class_id,
446 entity_id=entity_id,
447 data=dict(
448 spanning_tree_ind=False,
449 learning_ind=True,
450 priority=0x8000,
451 max_age=20 * 256,
452 hello_time=2 * 256,
453 forward_delay=15 * 256,
454 unknown_mac_address_discard=True
455 )
456 )
457 )
458 self.send_omci_message(frame)
459
460 def send_create_gem_port_network_ctp(self, entity_id, port_id, tcont_id):
461 frame = OmciFrame(
462 transaction_id = self.get_tx_id(),
463 message_type=OmciCreate.message_id,
464 omci_message=OmciCreate(
465 entity_class=GemPortNetworkCtp.class_id,
466 entity_id=entity_id,
467 data=dict(
468 port_id=port_id,
469 tcont_pointer=tcont_id,
470 direction=3,
471 traffic_management_pointer_upstream=0x100
472 )
473 )
474 )
475 self.send_omci_message(frame)
476
477 def send_create_multicast_gem_interworking_tp(self, entity_id, gem_port_net_ctp_id):
478 frame = OmciFrame(
479 transaction_id = self.get_tx_id(),
480 message_type=OmciCreate.message_id,
481 omci_message=OmciCreate(
482 entity_class=MulticastGemInterworkingTp.class_id,
483 entity_id=entity_id,
484 data=dict(
485 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
486 interworking_option=0,
487 service_profile_pointer=0x1,
488 )
489 )
490 )
491 self.send_omci_message(frame)
492
493 def send_create_gem_inteworking_tp(self, entity_id, gem_port_net_ctp_id, service_profile_id):
494 frame = OmciFrame(
495 transaction_id = self.get_tx_id(),
496 message_type=OmciCreate.message_id,
497 omci_message=OmciCreate(
498 entity_class=GemInterworkingTp.class_id,
499 entity_id=entity_id,
500 data=dict(
501 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
502 interworking_option=5,
503 service_profile_pointer=service_profile_id,
504 interworking_tp_pointer=0x0,
505 gal_profile_pointer=0x1
506 )
507 )
508 )
509 self.send_omci_message(frame)
510
511 def send_set_8021p_mapper_service_profile(self, entity_id, interwork_tp_id):
512 data = dict(
513 interwork_tp_pointer_for_p_bit_priority_0 = interwork_tp_id
514 )
515 frame = OmciFrame(
516 transaction_id = self.get_tx_id(),
517 message_type=OmciSet.message_id,
518 omci_message=OmciSet(
519 entity_class=Ieee8021pMapperServiceProfile.class_id,
520 entity_id=entity_id,
521 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
522 *data.keys()),
523 data=data
524 )
525 )
526 self.send_omci_message(frame)
527
528 def send_create_mac_bridge_port_configuration_data(self,
529 entity_id,
530 bridge_id,
531 port_id,
532 tp_type,
533 tp_id):
534 frame = OmciFrame(
535 transaction_id=self.get_tx_id(),
536 message_type=OmciCreate.message_id,
537 omci_message=OmciCreate(
538 entity_class=MacBridgePortConfigurationData.class_id,
539 entity_id=entity_id,
540 data=dict(
541 bridge_id_pointer = bridge_id,
542 port_num=port_id,
543 tp_type=tp_type,
544 tp_pointer = tp_id
545 )
546 )
547 )
548 self.send_omci_message(frame)
549
550 def send_create_vlan_tagging_filter_data(self, entity_id, vlan_id):
551 frame = OmciFrame(
552 transaction_id = self.get_tx_id(),
553 message_type=OmciCreate.message_id,
554 omci_message=OmciCreate(
555 entity_class=VlanTaggingFilterData.class_id,
556 entity_id=entity_id,
557 data=dict(
558 vlan_filter_0=vlan_id,
559 forward_operation=0x10,
560 number_of_entries=1
561 )
562 )
563 )
564 self.send_omci_message(frame)
565
566 def send_create_extended_vlan_tagging_operation_configuration_data(self, entity_id):
567 frame = OmciFrame(
568 transaction_id = self.get_tx_id(),
569 message_type=OmciCreate.message_id,
570 omci_message=OmciCreate(
571 entity_class=
572 ExtendedVlanTaggingOperationConfigurationData.class_id,
573 entity_id=entity_id,
574 data=dict(
575 association_type=10,
576 associated_me_pointer=0x401
577 )
578 )
579 )
580 self.send_omci_message(frame)
581
582 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, entity_id, input_tpid, output_tpid):
583 data = dict(
584 input_tpid = input_tpid,
585 output_tpid = output_tpid,
586 downstream_mode=0, # inverse of upstream
587 )
588 frame = OmciFrame(
589 transaction_id = self.get_tx_id(),
590 message_type=OmciSet.message_id,
591 omci_message=OmciSet(
592 entity_class=\
593 ExtendedVlanTaggingOperationConfigurationData.class_id,
594 entity_id=entity_id,
595 attributes_mask= \
596 ExtendedVlanTaggingOperationConfigurationData.mask_for(
597 *data.keys()),
598 data=data
599 )
600 )
601 self.send_omci_message(frame)
602
603 def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self,
604 entity_id,
605 filter_inner_vid,
606 treatment_inner_vid):
607 data = dict(
608 received_frame_vlan_tagging_operation_table=\
609 VlanTaggingOperation(
610 filter_outer_priority=15,
611 filter_inner_priority=8,
612 filter_inner_vid = filter_inner_vid,
613 filter_inner_tpid_de=5,
614 filter_ether_type=0,
615 treatment_tags_to_remove=1,
616 pad3=2,
617 treatment_outer_priority=15,
618 treatment_inner_priority=8,
619 treatment_inner_vid = treatment_inner_vid,
620 treatment_inner_tpid_de=4
621 )
622 )
623 frame = OmciFrame(
624 transaction_id = self.get_tx_id(),
625 message_type=OmciSet.message_id,
626 omci_message=OmciSet(
627 entity_class=\
628 ExtendedVlanTaggingOperationConfigurationData.class_id,
629 entity_id = entity_id,
630 attributes_mask= \
631 ExtendedVlanTaggingOperationConfigurationData.mask_for(
632 *data.keys()),
633 data=data
634 )
635 )
636 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800637
638 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -0600639 def wait_for_response(self):
640 log.info('wait-for-response')
641 try:
642 response = yield self.incoming_messages.get()
643 resp = OmciFrame(response)
644 resp.show()
645 except Exception as e:
646 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800647
Steve Crooks3c2c7582017-01-10 15:02:26 -0600648 @inlineCallbacks
649 def message_exchange(self):
650 log.info('message_exchange')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800651 # reset incoming message queue
652 while self.incoming_messages.pending:
653 _ = yield self.incoming_messages.get()
654
655 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -0600656 # MIB Reset - OntData - 0
657 self.send_mib_reset()
658 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800659
Steve Crooks3c2c7582017-01-10 15:02:26 -0600660 # Create AR - GalEthernetProfile - 1
661 self.send_create_gal_ethernet_profile(1, 48)
662 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800663
Steve Crooks3c2c7582017-01-10 15:02:26 -0600664 # Set AR - TCont - 32768 - 1024
665 self.send_set_tcont(0x8000, 0x400)
666 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800667
Steve Crooks3c2c7582017-01-10 15:02:26 -0600668 # Set AR - TCont - 32769 - 1025
669 self.send_set_tcont(0x8001, 0x401)
670 yield self.wait_for_response()
Zsolt Haraszti656ecc62016-12-28 15:08:23 -0800671
Steve Crooks3c2c7582017-01-10 15:02:26 -0600672 # Set AR - TCont - 32770 - 1026
673 self.send_set_tcont(0x8002, 0x402)
674 yield self.wait_for_response()
675
676 # Set AR - TCont - 32771 - 1027
677 self.send_set_tcont(0x8003, 0x403)
678 yield self.wait_for_response()
679
680 # Create AR - 802.1pMapperServiceProfile - 32768
681 self.send_create_8021p_mapper_service_profile(0x8000)
682 yield self.wait_for_response()
683
684 # Create AR - 802.1pMapperServiceProfile - 32769
685 self.send_create_8021p_mapper_service_profile(0x8001)
686 yield self.wait_for_response()
687
688 # Create AR - 802.1pMapperServiceProfile - 32770
689 self.send_create_8021p_mapper_service_profile(0x8002)
690 yield self.wait_for_response()
691
692 # Create AR - 802.1pMapperServiceProfile - 32771
693 self.send_create_8021p_mapper_service_profile(0x8003)
694 yield self.wait_for_response()
695
696 # Create AR - MacBridgeServiceProfile - 513
697 self.send_create_mac_bridge_service_profile(0x201)
698 yield self.wait_for_response()
699
700 # Create AR - GemPortNetworkCtp - 256 - 1024 - 32768
701 self.send_create_gem_port_network_ctp(0x100, 0x400, 0x8000)
702 yield self.wait_for_response()
703
704 # Create AR - GemPortNetworkCtp - 257 - 1025 - 32769
705 self.send_create_gem_port_network_ctp(0x101, 0x401, 0x8001)
706 yield self.wait_for_response()
707
708 # Create AR - GemPortNetworkCtp - 258 - 1026 - 32770
709 self.send_create_gem_port_network_ctp(0x102, 0x402, 0x8002)
710 yield self.wait_for_response()
711
712 # Create AR - GemPortNetworkCtp - 259 - 1027 - 32771
713 self.send_create_gem_port_network_ctp(0x103, 0x403, 0x8003)
714 yield self.wait_for_response()
715
716 # Create AR - MulticastGemInterworkingTp - 6 - 260
717 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
718 yield self.wait_for_response()
719
720 # Create AR - GemInterworkingTp - 32769 - 256 -32768 - 1
721 self.send_create_gem_inteworking_tp(0x8001, 0x100, 0x8000)
722 yield self.wait_for_response()
723
724 # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1
725 self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001)
726 yield self.wait_for_response()
727
728 # Create AR - GemInterworkingTp - 32771 - 258 -32770 - 1
729 self.send_create_gem_inteworking_tp(0x8003, 0x102, 0x8002)
730 yield self.wait_for_response()
731
732 # Create AR - GemInterworkingTp - 32772 - 259 -32771 - 1
733 self.send_create_gem_inteworking_tp(0x8004, 0x103, 0x8003)
734 yield self.wait_for_response()
735
736 # Set AR - 802.1pMapperServiceProfile - 32768 - 32769
737 self.send_set_8021p_mapper_service_profile(0x8000, 0x8001)
738 yield self.wait_for_response()
739
740 # Set AR - 802.1pMapperServiceProfile - 32769 - 32770
741 self.send_set_8021p_mapper_service_profile(0x8001, 0x8002)
742 yield self.wait_for_response()
743
744 # Set AR - 802.1pMapperServiceProfile - 32770 - 32771
745 self.send_set_8021p_mapper_service_profile(0x8002, 0x8003)
746 yield self.wait_for_response()
747
748 # Set AR - 802.1pMapperServiceProfile - 32771 - 32772
749 self.send_set_8021p_mapper_service_profile(0x8003, 0x8004)
750 yield self.wait_for_response()
751
752 # Create AR - MacBridgePortConfigData - 8449 - 513 - 2 - 3 - 32768
753 self.send_create_mac_bridge_port_configuration_data(0x2101, 0x201, 2, 3, 0x8000)
754 yield self.wait_for_response()
755
756 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
757 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
758 yield self.wait_for_response()
759
760 # Create AR - MacBridgePortConfigData - 8451 - 513 - 4 - 3 - 32770
761 self.send_create_mac_bridge_port_configuration_data(0x2103, 0x201, 4, 3, 0x8002)
762 yield self.wait_for_response()
763
764 # Create AR - MacBridgePortConfigData - 8452 - 513 - 5 - 3 - 32771
765 self.send_create_mac_bridge_port_configuration_data(0x2104, 0x201, 5, 3, 0x8003)
766 yield self.wait_for_response()
767
768 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
769 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
770 yield self.wait_for_response()
771
772 # Create AR - VlanTaggingFilterData - 8449 - 040000000000000000000000000000000000000000000000
773 self.send_create_vlan_tagging_filter_data(0x2101, 0x0400)
774 yield self.wait_for_response()
775
776 # Create AR - VlanTaggingFilterData - 8450 - 040100000000000000000000000000000000000000000000
777 self.send_create_vlan_tagging_filter_data(0x2102, 0x0401)
778 yield self.wait_for_response()
779
780 # Create AR - VlanTaggingFilterData - 8451 - 040200000000000000000000000000000000000000000000
781 self.send_create_vlan_tagging_filter_data(0x2103, 0x0402)
782 yield self.wait_for_response()
783
784 # Create AR - VlanTaggingFilterData - 8452 - 040300000000000000000000000000000000000000000000
785 self.send_create_vlan_tagging_filter_data(0x2104, 0x0403)
786 yield self.wait_for_response()
787
788 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 10 - 1025
789 self.send_create_extended_vlan_tagging_operation_configuration_data(0x202)
790 yield self.wait_for_response()
791
792 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
793 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202,0x8100,0x8100)
794 yield self.wait_for_response()
795
796 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x400 - 5 - 0x400 - 4
797 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x400, 0x400)
798 yield self.wait_for_response()
799
800 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x401 - 5 - 0x401 - 4
801 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x401, 0x401)
802 yield self.wait_for_response()
803
804 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x402 - 5 - 0x402 - 4
805 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x402, 0x402)
806 yield self.wait_for_response()
807
808 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x403 - 5 - 0x403 - 4
809 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x403, 0x403)
810 yield self.wait_for_response()
811
812 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 11 - 1025
813 self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 1, 11, 0x401)
814 yield self.wait_for_response()
815