blob: f81859ca7aba56c9f7e11132e606884e1a9f382b [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
Steve Crooks46d64302017-03-10 15:11:06 -0500566 def send_create_extended_vlan_tagging_operation_configuration_data(self,
567 entity_id,
568 assoc_type,
569 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600570 frame = OmciFrame(
571 transaction_id = self.get_tx_id(),
572 message_type=OmciCreate.message_id,
573 omci_message=OmciCreate(
574 entity_class=
575 ExtendedVlanTaggingOperationConfigurationData.class_id,
576 entity_id=entity_id,
577 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500578 association_type=assoc_type,
579 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600580 )
581 )
582 )
583 self.send_omci_message(frame)
584
585 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, entity_id, input_tpid, output_tpid):
586 data = dict(
587 input_tpid = input_tpid,
588 output_tpid = output_tpid,
589 downstream_mode=0, # inverse of upstream
590 )
591 frame = OmciFrame(
592 transaction_id = self.get_tx_id(),
593 message_type=OmciSet.message_id,
594 omci_message=OmciSet(
595 entity_class=\
596 ExtendedVlanTaggingOperationConfigurationData.class_id,
597 entity_id=entity_id,
598 attributes_mask= \
599 ExtendedVlanTaggingOperationConfigurationData.mask_for(
600 *data.keys()),
601 data=data
602 )
603 )
604 self.send_omci_message(frame)
605
606 def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self,
607 entity_id,
608 filter_inner_vid,
609 treatment_inner_vid):
610 data = dict(
611 received_frame_vlan_tagging_operation_table=\
612 VlanTaggingOperation(
613 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500614 filter_outer_vid=4096,
615 filter_outer_tpid_de=0,
616
617 filter_inner_priority=15,
618 filter_inner_vid=filter_inner_vid,
619 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600620 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -0500621
622 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600623 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500624 treatment_outer_vid=0,
625 treatment_outer_tpid_de=0,
626
627 treatment_inner_priority=0,
628 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600629 treatment_inner_tpid_de=4
630 )
631 )
632 frame = OmciFrame(
633 transaction_id = self.get_tx_id(),
634 message_type=OmciSet.message_id,
635 omci_message=OmciSet(
636 entity_class=\
637 ExtendedVlanTaggingOperationConfigurationData.class_id,
638 entity_id = entity_id,
639 attributes_mask= \
640 ExtendedVlanTaggingOperationConfigurationData.mask_for(
641 *data.keys()),
642 data=data
643 )
644 )
645 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800646
647 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -0600648 def wait_for_response(self):
649 log.info('wait-for-response')
650 try:
651 response = yield self.incoming_messages.get()
652 resp = OmciFrame(response)
653 resp.show()
654 except Exception as e:
655 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800656
Steve Crooks3c2c7582017-01-10 15:02:26 -0600657 @inlineCallbacks
658 def message_exchange(self):
659 log.info('message_exchange')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800660 # reset incoming message queue
661 while self.incoming_messages.pending:
662 _ = yield self.incoming_messages.get()
663
664 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -0600665 # MIB Reset - OntData - 0
666 self.send_mib_reset()
667 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800668
Steve Crooks3c2c7582017-01-10 15:02:26 -0600669 # Create AR - GalEthernetProfile - 1
670 self.send_create_gal_ethernet_profile(1, 48)
671 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800672
Steve Crooks3c2c7582017-01-10 15:02:26 -0600673 # Set AR - TCont - 32768 - 1024
674 self.send_set_tcont(0x8000, 0x400)
675 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800676
Steve Crooks3c2c7582017-01-10 15:02:26 -0600677 # Set AR - TCont - 32769 - 1025
678 self.send_set_tcont(0x8001, 0x401)
679 yield self.wait_for_response()
Zsolt Haraszti656ecc62016-12-28 15:08:23 -0800680
Steve Crooks3c2c7582017-01-10 15:02:26 -0600681 # Set AR - TCont - 32770 - 1026
682 self.send_set_tcont(0x8002, 0x402)
683 yield self.wait_for_response()
684
685 # Set AR - TCont - 32771 - 1027
686 self.send_set_tcont(0x8003, 0x403)
687 yield self.wait_for_response()
688
689 # Create AR - 802.1pMapperServiceProfile - 32768
690 self.send_create_8021p_mapper_service_profile(0x8000)
691 yield self.wait_for_response()
692
693 # Create AR - 802.1pMapperServiceProfile - 32769
694 self.send_create_8021p_mapper_service_profile(0x8001)
695 yield self.wait_for_response()
696
697 # Create AR - 802.1pMapperServiceProfile - 32770
698 self.send_create_8021p_mapper_service_profile(0x8002)
699 yield self.wait_for_response()
700
701 # Create AR - 802.1pMapperServiceProfile - 32771
702 self.send_create_8021p_mapper_service_profile(0x8003)
703 yield self.wait_for_response()
704
705 # Create AR - MacBridgeServiceProfile - 513
706 self.send_create_mac_bridge_service_profile(0x201)
707 yield self.wait_for_response()
708
709 # Create AR - GemPortNetworkCtp - 256 - 1024 - 32768
710 self.send_create_gem_port_network_ctp(0x100, 0x400, 0x8000)
711 yield self.wait_for_response()
712
713 # Create AR - GemPortNetworkCtp - 257 - 1025 - 32769
714 self.send_create_gem_port_network_ctp(0x101, 0x401, 0x8001)
715 yield self.wait_for_response()
716
717 # Create AR - GemPortNetworkCtp - 258 - 1026 - 32770
718 self.send_create_gem_port_network_ctp(0x102, 0x402, 0x8002)
719 yield self.wait_for_response()
720
721 # Create AR - GemPortNetworkCtp - 259 - 1027 - 32771
722 self.send_create_gem_port_network_ctp(0x103, 0x403, 0x8003)
723 yield self.wait_for_response()
724
725 # Create AR - MulticastGemInterworkingTp - 6 - 260
726 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
727 yield self.wait_for_response()
728
729 # Create AR - GemInterworkingTp - 32769 - 256 -32768 - 1
730 self.send_create_gem_inteworking_tp(0x8001, 0x100, 0x8000)
731 yield self.wait_for_response()
732
733 # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1
734 self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001)
735 yield self.wait_for_response()
736
737 # Create AR - GemInterworkingTp - 32771 - 258 -32770 - 1
738 self.send_create_gem_inteworking_tp(0x8003, 0x102, 0x8002)
739 yield self.wait_for_response()
740
741 # Create AR - GemInterworkingTp - 32772 - 259 -32771 - 1
742 self.send_create_gem_inteworking_tp(0x8004, 0x103, 0x8003)
743 yield self.wait_for_response()
744
745 # Set AR - 802.1pMapperServiceProfile - 32768 - 32769
746 self.send_set_8021p_mapper_service_profile(0x8000, 0x8001)
747 yield self.wait_for_response()
748
749 # Set AR - 802.1pMapperServiceProfile - 32769 - 32770
750 self.send_set_8021p_mapper_service_profile(0x8001, 0x8002)
751 yield self.wait_for_response()
752
753 # Set AR - 802.1pMapperServiceProfile - 32770 - 32771
754 self.send_set_8021p_mapper_service_profile(0x8002, 0x8003)
755 yield self.wait_for_response()
756
757 # Set AR - 802.1pMapperServiceProfile - 32771 - 32772
758 self.send_set_8021p_mapper_service_profile(0x8003, 0x8004)
759 yield self.wait_for_response()
760
761 # Create AR - MacBridgePortConfigData - 8449 - 513 - 2 - 3 - 32768
762 self.send_create_mac_bridge_port_configuration_data(0x2101, 0x201, 2, 3, 0x8000)
763 yield self.wait_for_response()
764
765 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
766 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
767 yield self.wait_for_response()
768
769 # Create AR - MacBridgePortConfigData - 8451 - 513 - 4 - 3 - 32770
770 self.send_create_mac_bridge_port_configuration_data(0x2103, 0x201, 4, 3, 0x8002)
771 yield self.wait_for_response()
772
773 # Create AR - MacBridgePortConfigData - 8452 - 513 - 5 - 3 - 32771
774 self.send_create_mac_bridge_port_configuration_data(0x2104, 0x201, 5, 3, 0x8003)
775 yield self.wait_for_response()
776
777 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
778 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
779 yield self.wait_for_response()
780
781 # Create AR - VlanTaggingFilterData - 8449 - 040000000000000000000000000000000000000000000000
782 self.send_create_vlan_tagging_filter_data(0x2101, 0x0400)
783 yield self.wait_for_response()
784
785 # Create AR - VlanTaggingFilterData - 8450 - 040100000000000000000000000000000000000000000000
786 self.send_create_vlan_tagging_filter_data(0x2102, 0x0401)
787 yield self.wait_for_response()
788
789 # Create AR - VlanTaggingFilterData - 8451 - 040200000000000000000000000000000000000000000000
790 self.send_create_vlan_tagging_filter_data(0x2103, 0x0402)
791 yield self.wait_for_response()
792
793 # Create AR - VlanTaggingFilterData - 8452 - 040300000000000000000000000000000000000000000000
794 self.send_create_vlan_tagging_filter_data(0x2104, 0x0403)
795 yield self.wait_for_response()
796
Steve Crooks46d64302017-03-10 15:11:06 -0500797 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x105
798 self.send_create_extended_vlan_tagging_operation_configuration_data(0x202, 2, 0x105)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600799 yield self.wait_for_response()
800
801 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
Steve Crooks46d64302017-03-10 15:11:06 -0500802 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600803 yield self.wait_for_response()
804
Steve Crooks46d64302017-03-10 15:11:06 -0500805 # Set AR - ExtendedVlanTaggingOperationConfigData
806 # 514 - RxVlanTaggingOperationTable - add VLAN 1025 to untagged pkts
807 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x1000, 0x401)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600808 yield self.wait_for_response()
809
Steve Crooks46d64302017-03-10 15:11:06 -0500810 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x105
811 self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 1, 1, 0x105)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600812 yield self.wait_for_response()