blob: bef5adf50ec0e93a86e3c4e39089f237c213dd47 [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
Peter Shafikd7f33772017-05-17 13:56:34 -040023from twisted.internet import reactor, task
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
ggowdru236bd952017-06-20 20:32:55 -070035from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image
Steve Crooks3c2c7582017-01-10 15:02:26 -060036from 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,
rshettyc26a3c32017-07-27 11:06:38 +053055 vendor_id='BRCM',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080056 adapter=name,
57 accepts_bulk_flow_update=True
58 )
59 ]
60
61 def __init__(self, adapter_agent, config):
62 self.adapter_agent = adapter_agent
63 self.config = config
64 self.descriptor = Adapter(
65 id=self.name,
66 vendor='Voltha project',
Steve Crooks3c2c7582017-01-10 15:02:26 -060067 version='0.4',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080068 config=AdapterConfig(log_level=LogLevel.INFO)
69 )
Steve Crooks3c2c7582017-01-10 15:02:26 -060070 self.devices_handlers = dict() # device_id -> BroadcomOnuHandler()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080071
Peter Shafik9107f2e2017-05-02 15:54:39 -040072 # register for adapter messages
73 self.adapter_agent.register_for_inter_adapter_messages()
74
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080075 def start(self):
76 log.debug('starting')
77 log.info('started')
78
79 def stop(self):
80 log.debug('stopping')
81 log.info('stopped')
82
83 def adapter_descriptor(self):
84 return self.descriptor
85
86 def device_types(self):
87 return DeviceTypes(items=self.supported_device_types)
88
89 def health(self):
90 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
91
92 def change_master_state(self, master):
93 raise NotImplementedError()
94
95 def adopt_device(self, device):
Steve Crooks3c2c7582017-01-10 15:02:26 -060096 log.info('adopt_device', device_id=device.id)
97 self.devices_handlers[device.proxy_address.channel_id] = BroadcomOnuHandler(self, device.id)
98 reactor.callLater(0, self.devices_handlers[device.proxy_address.channel_id].activate, device)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080099 return device
100
khenaidoo032d3302017-06-09 14:50:04 -0400101 def reconcile_device(self, device):
102 raise NotImplementedError()
103
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800104 def abandon_device(self, device):
105 raise NotImplementedError()
106
Khen Nursimulud068d812017-03-06 11:44:18 -0500107 def disable_device(self, device):
108 raise NotImplementedError()
109
110 def reenable_device(self, device):
111 raise NotImplementedError()
112
113 def reboot_device(self, device):
114 raise NotImplementedError()
115
Lydia Fang01f2e852017-06-28 17:24:58 -0700116 def download_image(self, device, request):
117 raise NotImplementedError()
118
119 def get_image_download_status(self, device, request):
120 raise NotImplementedError()
121
122 def cancel_image_download(self, device, request):
123 raise NotImplementedError()
124
125 def activate_image_update(self, device, request):
126 raise NotImplementedError()
127
128 def revert_image_update(self, device, request):
129 raise NotImplementedError()
130
sathishg5ae86222017-06-28 15:16:29 +0530131 def self_test_device(self, device):
132 """
133 This is called to Self a device based on a NBI call.
134 :param device: A Voltha.Device object.
135 :return: Will return result of self test
136 """
137 log.info('self-test-device', device=device.id)
138 raise NotImplementedError()
139
Khen Nursimulud068d812017-03-06 11:44:18 -0500140 def delete_device(self, device):
141 raise NotImplementedError()
142
143 def get_device_details(self, device):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800144 raise NotImplementedError()
145
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500146 def update_pm_config(self, device, pm_configs):
147 raise NotImplementedError()
148
Steve Crooks3c2c7582017-01-10 15:02:26 -0600149 def update_flows_bulk(self, device, flows, groups):
150 log.info('bulk-flow-update', device_id=device.id,
151 flows=flows, groups=groups)
152 assert len(groups.items) == 0
153 handler = self.devices_handlers[device.proxy_address.channel_id]
Steve Crooksf248e182017-02-07 10:50:24 -0500154 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600155
156 def update_flows_incrementally(self, device, flow_changes, group_changes):
157 raise NotImplementedError()
158
159 def send_proxied_message(self, proxy_address, msg):
160 log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
161
162 def receive_proxied_message(self, proxy_address, msg):
163 log.info('receive-proxied-message', proxy_address=proxy_address,
164 device_id=proxy_address.device_id, msg=hexify(msg))
165 handler = self.devices_handlers[proxy_address.channel_id]
166 handler.receive_message(msg)
167
168 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
169 log.info('packet-out', logical_device_id=logical_device_id,
170 egress_port_no=egress_port_no, msg_len=len(msg))
171
Peter Shafik9107f2e2017-05-02 15:54:39 -0400172 def receive_inter_adapter_message(self, msg):
173 log.info('receive_inter_adapter_message', msg=msg)
Peter Shafikd7f33772017-05-17 13:56:34 -0400174 proxy_address = msg['proxy_address']
175 assert proxy_address is not None
176
rshettyc26a3c32017-07-27 11:06:38 +0530177 if proxy_address.channel_id in self.devices_handlers:
178 handler = self.devices_handlers[proxy_address.channel_id]
179 if handler is not None:
180 handler.event_messages.put(msg)
Peter Shafik9107f2e2017-05-02 15:54:39 -0400181
Nikolay Titov89004ec2017-06-19 18:22:42 -0400182 def create_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530183 log.info('create-interface', device_id=device.id)
184 if device.proxy_address.channel_id in self.devices_handlers:
185 handler = self.devices_handlers[device.proxy_address.channel_id]
186 if handler is not None:
187 handler.create_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400188
189 def update_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530190 log.info('update-interface', device_id=device.id)
191 if device.proxy_address.channel_id in self.devices_handlers:
192 handler = self.devices_handlers[device.proxy_address.channel_id]
193 if handler is not None:
194 handler.update_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400195
196 def remove_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530197 log.info('remove-interface', device_id=device.id)
198 if device.proxy_address.channel_id in self.devices_handlers:
199 handler = self.devices_handlers[device.proxy_address.channel_id]
200 if handler is not None:
201 handler.remove_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400202
203 def receive_onu_detect_state(self, device_id, state):
204 raise NotImplementedError()
205
Nikolay Titov176f1db2017-08-10 12:38:43 -0400206 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
207 raise NotImplementedError()
208
209 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
210 raise NotImplementedError()
211
212 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
213 raise NotImplementedError()
214
215 def create_gemport(self, device, data):
216 raise NotImplementedError()
217
218 def update_gemport(self, device, data):
219 raise NotImplementedError()
220
221 def remove_gemport(self, device, data):
222 raise NotImplementedError()
223
224 def create_multicast_gemport(self, device, data):
225 raise NotImplementedError()
226
227 def update_multicast_gemport(self, device, data):
228 raise NotImplementedError()
229
230 def remove_multicast_gemport(self, device, data):
231 raise NotImplementedError()
232
233 def create_multicast_distribution_set(self, device, data):
234 raise NotImplementedError()
235
236 def update_multicast_distribution_set(self, device, data):
237 raise NotImplementedError()
238
239 def remove_multicast_distribution_set(self, device, data):
240 raise NotImplementedError()
241
242 def suppress_alarm(self, filter):
243 raise NotImplementedError()
244
Stephane Barbarie980a0912017-05-11 11:27:06 -0400245 def unsuppress_alarm(self, filter):
246 raise NotImplementedError()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600247
248class BroadcomOnuHandler(object):
249
250 def __init__(self, adapter, device_id):
251 self.adapter = adapter
252 self.adapter_agent = adapter.adapter_agent
253 self.device_id = device_id
254 self.log = structlog.get_logger(device_id=device_id)
255 self.incoming_messages = DeferredQueue()
Peter Shafikd7f33772017-05-17 13:56:34 -0400256 self.event_messages = DeferredQueue()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600257 self.proxy_address = None
258 self.tx_id = 0
259
Peter Shafikd7f33772017-05-17 13:56:34 -0400260 # Need to query ONU for number of supported uni ports
261 # For now, temporarily set number of ports to 1 - port #2
262 self.uni_ports = (2,)
263
264 # Handle received ONU event messages
265 reactor.callLater(0, self.handle_onu_events)
266
Steve Crooks3c2c7582017-01-10 15:02:26 -0600267 def receive_message(self, msg):
268 self.incoming_messages.put(msg)
269
Peter Shafikd7f33772017-05-17 13:56:34 -0400270 @inlineCallbacks
271 def handle_onu_events(self):
272 event_msg = yield self.event_messages.get()
273
274 if event_msg['event'] == 'activation-completed':
275
276 if event_msg['event_data']['activation_successful'] == True:
277 for uni in self.uni_ports:
278 port_no = self.proxy_address.channel_id + uni
279 reactor.callLater(1,
280 self.message_exchange,
281 self.proxy_address.onu_id,
282 self.proxy_address.onu_session_id,
283 port_no)
284
285 device = self.adapter_agent.get_device(self.device_id)
286 device.oper_status = OperStatus.ACTIVE
287 self.adapter_agent.update_device(device)
288
289 else:
290 device = self.adapter_agent.get_device(self.device_id)
291 device.oper_status = OperStatus.FAILED
292 self.adapter_agent.update_device(device)
293
294 elif event_msg['event'] == 'deactivation-completed':
295 device = self.adapter_agent.get_device(self.device_id)
296 device.oper_status = OperStatus.DISCOVERED
297 self.adapter_agent.update_device(device)
298
299 elif event_msg['event'] == 'ranging-completed':
300
301 if event_msg['event_data']['ranging_successful'] == True:
302 device = self.adapter_agent.get_device(self.device_id)
303 device.oper_status = OperStatus.ACTIVATING
304 self.adapter_agent.update_device(device)
305
306 else:
307 device = self.adapter_agent.get_device(self.device_id)
308 device.oper_status = OperStatus.FAILED
309 self.adapter_agent.update_device(device)
310
311 # Handle next event
312 reactor.callLater(0, self.handle_onu_events)
313
314
Steve Crooks3c2c7582017-01-10 15:02:26 -0600315 def activate(self, device):
316 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800317
318 # first we verify that we got parent reference and proxy info
319 assert device.parent_id
320 assert device.proxy_address.device_id
Steve Crooks9b160d72017-03-31 10:48:29 -0500321 #assert device.proxy_address.channel_id # c-vid
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800322
Steve Crooks3c2c7582017-01-10 15:02:26 -0600323 # register for proxied messages right away
324 self.proxy_address = device.proxy_address
325 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
326
Peter Shafik9107f2e2017-05-02 15:54:39 -0400327
Steve Crooks3c2c7582017-01-10 15:02:26 -0600328 # populate device info
329 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800330 device.vendor = 'Broadcom'
Steve Crooks9e85ce82017-03-20 12:00:53 -0400331 device.model = 'n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800332 device.hardware_version = 'to be filled'
333 device.firmware_version = 'to be filled'
ggowdru236bd952017-06-20 20:32:55 -0700334 device.images.image.extend([
335 Image(version="to be filled")
336 ])
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800337 device.connect_status = ConnectStatus.REACHABLE
338 self.adapter_agent.update_device(device)
339
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800340 self.adapter_agent.add_port(device.id, Port(
Steve Crooks9b160d72017-03-31 10:48:29 -0500341 port_no=100,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800342 label='PON port',
343 type=Port.PON_ONU,
344 admin_state=AdminState.ENABLED,
345 oper_status=OperStatus.ACTIVE,
346 peers=[
347 Port.PeerPort(
348 device_id=device.parent_id,
349 port_no=device.parent_port_no
350 )
351 ]
352 ))
353
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800354 parent_device = self.adapter_agent.get_device(device.parent_id)
355 logical_device_id = parent_device.parent_id
356 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800357
Peter Shafikd7f33772017-05-17 13:56:34 -0400358 for uni in self.uni_ports:
Steve Crooks9b160d72017-03-31 10:48:29 -0500359 # register physical ports
360 uni_port = Port(
361 port_no=uni,
362 label='UNI facing Ethernet port '+str(uni),
363 type=Port.ETHERNET_UNI,
364 admin_state=AdminState.ENABLED,
365 oper_status=OperStatus.ACTIVE
366 )
367 self.adapter_agent.add_port(device.id, uni_port)
368
369 # add uni port to logical device
370 port_no = device.proxy_address.channel_id + uni
371 cap = OFPPF_1GB_FD | OFPPF_FIBER
372 self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
373 id='uni-{}'.format(port_no),
374 ofp_port=ofp_port(
375 port_no=port_no,
376 hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' %
377 (device.proxy_address.onu_id & 0xff,
378 (port_no >> 8) & 0xff,
379 port_no & 0xff)),
380 name='uni-{}'.format(port_no),
381 config=0,
382 state=OFPPS_LIVE,
383 curr=cap,
384 advertised=cap,
385 peer=cap,
386 curr_speed=OFPPF_1GB_FD,
387 max_speed=OFPPF_1GB_FD
388 ),
389 device_id=device.id,
390 device_port_no=uni_port.port_no
391 ))
392
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800393 device = self.adapter_agent.get_device(device.id)
Peter Shafikd7f33772017-05-17 13:56:34 -0400394 device.oper_status = OperStatus.DISCOVERED
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800395 self.adapter_agent.update_device(device)
396
Steve Crooks3c2c7582017-01-10 15:02:26 -0600397 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500398 def update_flow_table(self, device, flows):
399 #
400 # We need to proxy through the OLT to get to the ONU
401 # Configuration from here should be using OMCI
402 #
403 self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800404
Steve Crooksf248e182017-02-07 10:50:24 -0500405 def is_downstream(port):
Steve Crooks9b160d72017-03-31 10:48:29 -0500406 return port == 100 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800407
Steve Crooksf248e182017-02-07 10:50:24 -0500408 def is_upstream(port):
409 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800410
Steve Crooksf248e182017-02-07 10:50:24 -0500411 for flow in flows:
Steve Crooks9b160d72017-03-31 10:48:29 -0500412 _type = None
413 _port = None
414 _vlan_vid = None
415 _udp_dst = None
416 _udp_src = None
417 _ipv4_dst = None
418 _ipv4_src = None
419 _metadata = None
420 _output = None
421 _push_tpid = None
422 _field = None
423 _set_vlan_vid = None
Steve Crooksf248e182017-02-07 10:50:24 -0500424 try:
425 _in_port = fd.get_in_port(flow)
426 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600427
Steve Crooksf248e182017-02-07 10:50:24 -0500428 if is_downstream(_in_port):
429 self.log.info('downstream-flow')
430 elif is_upstream(_in_port):
431 self.log.info('upstream-flow')
432 else:
433 raise Exception('port should be 1 or 2 by our convention')
434
435 _out_port = fd.get_out_port(flow) # may be None
436 self.log.info('out-port', out_port=_out_port)
437
438 for field in fd.get_ofb_fields(flow):
439 if field.type == fd.ETH_TYPE:
440 _type = field.eth_type
441 self.log.info('field-type-eth-type',
442 eth_type=_type)
443
444 elif field.type == fd.IP_PROTO:
445 _proto = field.ip_proto
446 self.log.info('field-type-ip-proto',
447 ip_proto=_proto)
448
449 elif field.type == fd.IN_PORT:
450 _port = field.port
451 self.log.info('field-type-in-port',
452 in_port=_port)
453
454 elif field.type == fd.VLAN_VID:
455 _vlan_vid = field.vlan_vid & 0xfff
456 self.log.info('field-type-vlan-vid',
457 vlan=_vlan_vid)
458
459 elif field.type == fd.VLAN_PCP:
460 _vlan_pcp = field.vlan_pcp
461 self.log.info('field-type-vlan-pcp',
462 pcp=_vlan_pcp)
463
464 elif field.type == fd.UDP_DST:
465 _udp_dst = field.udp_dst
466 self.log.info('field-type-udp-dst',
467 udp_dst=_udp_dst)
468
469 elif field.type == fd.UDP_SRC:
470 _udp_src = field.udp_src
471 self.log.info('field-type-udp-src',
472 udp_src=_udp_src)
473
474 elif field.type == fd.IPV4_DST:
475 _ipv4_dst = field.ipv4_dst
476 self.log.info('field-type-ipv4-dst',
477 ipv4_dst=_ipv4_dst)
478
479 elif field.type == fd.IPV4_SRC:
480 _ipv4_src = field.ipv4_src
481 self.log.info('field-type-ipv4-src',
482 ipv4_dst=_ipv4_src)
483
484 elif field.type == fd.METADATA:
Steve Crooks9b160d72017-03-31 10:48:29 -0500485 _metadata = field.table_metadata
Steve Crooksf248e182017-02-07 10:50:24 -0500486 self.log.info('field-type-metadata',
487 metadata=_metadata)
488
489 else:
490 raise NotImplementedError('field.type={}'.format(
491 field.type))
492
493 for action in fd.get_actions(flow):
494
495 if action.type == fd.OUTPUT:
496 _output = action.output.port
497 self.log.info('action-type-output',
498 output=_output, in_port=_in_port)
499
500 elif action.type == fd.POP_VLAN:
501 self.log.info('action-type-pop-vlan',
502 in_port=_in_port)
503
504 elif action.type == fd.PUSH_VLAN:
505 _push_tpid = action.push.ethertype
506 log.info('action-type-push-vlan',
507 push_tpid=_push_tpid, in_port=_in_port)
508 if action.push.ethertype != 0x8100:
509 self.log.error('unhandled-tpid',
510 ethertype=action.push.ethertype)
511
512 elif action.type == fd.SET_FIELD:
513 _field = action.set_field.field.ofb_field
514 assert (action.set_field.field.oxm_class ==
515 OFPXMC_OPENFLOW_BASIC)
516 self.log.info('action-type-set-field',
517 field=_field, in_port=_in_port)
518 if _field.type == fd.VLAN_VID:
Steve Crooks9b160d72017-03-31 10:48:29 -0500519 _set_vlan_vid = _field.vlan_vid & 0xfff
520 self.log.info('set-field-type-valn-vid', _set_vlan_vid)
Steve Crooksf248e182017-02-07 10:50:24 -0500521 else:
522 self.log.error('unsupported-action-set-field-type',
523 field_type=_field.type)
524 else:
525 log.error('unsupported-action-type',
526 action_type=action.type, in_port=_in_port)
527
528 #
529 # All flows created from ONU adapter should be OMCI based
530 #
Steve Crooks9b160d72017-03-31 10:48:29 -0500531 if _vlan_vid == 0:
532 # allow priority tagged packets
533 # Set AR - ExtendedVlanTaggingOperationConfigData
534 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
535 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0,
536 1, 8, _in_port)
537 yield self.wait_for_response()
538
539 # Set AR - ExtendedVlanTaggingOperationConfigData
540 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
541 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0,
542 1, 8, _in_port)
543 yield self.wait_for_response()
Steve Crooksf248e182017-02-07 10:50:24 -0500544
545 except Exception as e:
546 log.exception('failed-to-install-flow', e=e, flow=flow)
547
Steve Crooks3c2c7582017-01-10 15:02:26 -0600548 def get_tx_id(self):
549 self.tx_id += 1
550 return self.tx_id
551
552 def send_omci_message(self, frame):
553 _frame = hexify(str(frame))
554 self.log.info('send-omci-message-%s' % _frame)
555 device = self.adapter_agent.get_device(self.device_id)
556 try:
557 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
558 except Exception as e:
559 self.log.info('send-omci-message-exception', exc=str(e))
560
561 def send_get_circuit_pack(self, entity_id=0):
562 frame = OmciFrame(
563 transaction_id=self.get_tx_id(),
564 message_type=OmciGet.message_id,
565 omci_message=OmciGet(
566 entity_class=CircuitPack.class_id,
567 entity_id=entity_id,
568 attributes_mask=CircuitPack.mask_for('vendor_id')
569 )
570 )
571 self.send_omci_message(frame)
572
573 def send_mib_reset(self, entity_id=0):
574 frame = OmciFrame(
575 transaction_id=self.get_tx_id(),
576 message_type=OmciMibReset.message_id,
577 omci_message=OmciMibReset(
578 entity_class=OntData.class_id,
579 entity_id=entity_id
580 )
581 )
582 self.send_omci_message(frame)
583
Steve Crooks9e85ce82017-03-20 12:00:53 -0400584 def send_create_gal_ethernet_profile(self,
585 entity_id,
586 max_gem_payload_size):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600587 frame = OmciFrame(
588 transaction_id=self.get_tx_id(),
589 message_type=OmciCreate.message_id,
590 omci_message=OmciCreate(
591 entity_class=GalEthernetProfile.class_id,
592 entity_id=entity_id,
593 data=dict(
594 max_gem_payload_size=max_gem_payload_size
595 )
596 )
597 )
598 self.send_omci_message(frame)
599
Steve Crooks9e85ce82017-03-20 12:00:53 -0400600 def send_set_tcont(self,
601 entity_id,
602 alloc_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600603 data = dict(
604 alloc_id=alloc_id
605 )
606 frame = OmciFrame(
607 transaction_id=self.get_tx_id(),
608 message_type=OmciSet.message_id,
609 omci_message=OmciSet(
610 entity_class=Tcont.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400611 entity_id=entity_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600612 attributes_mask=Tcont.mask_for(*data.keys()),
613 data=data
614 )
615 )
616 self.send_omci_message(frame)
617
Steve Crooks9e85ce82017-03-20 12:00:53 -0400618 def send_create_8021p_mapper_service_profile(self,
619 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600620 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400621 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600622 message_type=OmciCreate.message_id,
623 omci_message=OmciCreate(
624 entity_class=Ieee8021pMapperServiceProfile.class_id,
625 entity_id=entity_id,
626 data=dict(
627 tp_pointer=OmciNullPointer,
628 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
Steve Crooks9b160d72017-03-31 10:48:29 -0500629 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
630 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
631 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
632 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
633 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
634 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
635 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
Steve Crooks3c2c7582017-01-10 15:02:26 -0600636 )
637 )
638 )
639 self.send_omci_message(frame)
640
Steve Crooks9e85ce82017-03-20 12:00:53 -0400641 def send_create_mac_bridge_service_profile(self,
642 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600643 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400644 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600645 message_type=OmciCreate.message_id,
646 omci_message=OmciCreate(
647 entity_class=MacBridgeServiceProfile.class_id,
648 entity_id=entity_id,
649 data=dict(
650 spanning_tree_ind=False,
651 learning_ind=True,
652 priority=0x8000,
653 max_age=20 * 256,
654 hello_time=2 * 256,
655 forward_delay=15 * 256,
656 unknown_mac_address_discard=True
657 )
658 )
659 )
660 self.send_omci_message(frame)
661
Steve Crooks9e85ce82017-03-20 12:00:53 -0400662 def send_create_gem_port_network_ctp(self,
663 entity_id,
664 port_id,
665 tcont_id,
666 direction,
667 tm):
668 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
669 if _directions.has_key(direction):
670 _direction = _directions[direction]
671 else:
672 self.log.error('invalid-gem-port-direction', direction=direction)
673 raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction))
674
Steve Crooks3c2c7582017-01-10 15:02:26 -0600675 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400676 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600677 message_type=OmciCreate.message_id,
678 omci_message=OmciCreate(
679 entity_class=GemPortNetworkCtp.class_id,
680 entity_id=entity_id,
681 data=dict(
682 port_id=port_id,
683 tcont_pointer=tcont_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400684 direction=_direction,
685 traffic_management_pointer_upstream=tm
Steve Crooks3c2c7582017-01-10 15:02:26 -0600686 )
687 )
688 )
689 self.send_omci_message(frame)
690
Steve Crooks9e85ce82017-03-20 12:00:53 -0400691 def send_create_multicast_gem_interworking_tp(self,
692 entity_id,
693 gem_port_net_ctp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600694 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400695 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600696 message_type=OmciCreate.message_id,
697 omci_message=OmciCreate(
698 entity_class=MulticastGemInterworkingTp.class_id,
699 entity_id=entity_id,
700 data=dict(
701 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
702 interworking_option=0,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400703 service_profile_pointer=0x1
Steve Crooks3c2c7582017-01-10 15:02:26 -0600704 )
705 )
706 )
707 self.send_omci_message(frame)
708
Steve Crooks9e85ce82017-03-20 12:00:53 -0400709 def send_create_gem_inteworking_tp(self,
710 entity_id,
711 gem_port_net_ctp_id,
712 service_profile_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600713 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400714 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600715 message_type=OmciCreate.message_id,
716 omci_message=OmciCreate(
717 entity_class=GemInterworkingTp.class_id,
718 entity_id=entity_id,
719 data=dict(
720 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
721 interworking_option=5,
722 service_profile_pointer=service_profile_id,
723 interworking_tp_pointer=0x0,
724 gal_profile_pointer=0x1
725 )
726 )
727 )
728 self.send_omci_message(frame)
729
Steve Crooks9e85ce82017-03-20 12:00:53 -0400730 def send_set_8021p_mapper_service_profile(self,
731 entity_id,
732 interwork_tp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600733 data = dict(
Steve Crooks9b160d72017-03-31 10:48:29 -0500734 interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id,
735 interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id,
736 interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id,
737 interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id,
738 interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id,
739 interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id,
740 interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id,
741 interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600742 )
743 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400744 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600745 message_type=OmciSet.message_id,
746 omci_message=OmciSet(
747 entity_class=Ieee8021pMapperServiceProfile.class_id,
748 entity_id=entity_id,
749 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
750 *data.keys()),
751 data=data
752 )
753 )
754 self.send_omci_message(frame)
755
756 def send_create_mac_bridge_port_configuration_data(self,
757 entity_id,
758 bridge_id,
759 port_id,
760 tp_type,
761 tp_id):
762 frame = OmciFrame(
763 transaction_id=self.get_tx_id(),
764 message_type=OmciCreate.message_id,
765 omci_message=OmciCreate(
766 entity_class=MacBridgePortConfigurationData.class_id,
767 entity_id=entity_id,
768 data=dict(
769 bridge_id_pointer = bridge_id,
770 port_num=port_id,
771 tp_type=tp_type,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400772 tp_pointer=tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600773 )
774 )
775 )
776 self.send_omci_message(frame)
777
Steve Crooks9e85ce82017-03-20 12:00:53 -0400778 def send_create_vlan_tagging_filter_data(self,
779 entity_id,
780 vlan_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600781 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400782 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600783 message_type=OmciCreate.message_id,
784 omci_message=OmciCreate(
785 entity_class=VlanTaggingFilterData.class_id,
786 entity_id=entity_id,
787 data=dict(
788 vlan_filter_0=vlan_id,
789 forward_operation=0x10,
790 number_of_entries=1
791 )
792 )
793 )
794 self.send_omci_message(frame)
795
Steve Crooks46d64302017-03-10 15:11:06 -0500796 def send_create_extended_vlan_tagging_operation_configuration_data(self,
797 entity_id,
798 assoc_type,
799 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600800 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400801 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600802 message_type=OmciCreate.message_id,
803 omci_message=OmciCreate(
804 entity_class=
805 ExtendedVlanTaggingOperationConfigurationData.class_id,
806 entity_id=entity_id,
807 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500808 association_type=assoc_type,
809 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600810 )
811 )
812 )
813 self.send_omci_message(frame)
814
Steve Crooks9e85ce82017-03-20 12:00:53 -0400815 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self,
816 entity_id,
817 input_tpid,
818 output_tpid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600819 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400820 input_tpid=input_tpid,
821 output_tpid=output_tpid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600822 downstream_mode=0, # inverse of upstream
823 )
824 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400825 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600826 message_type=OmciSet.message_id,
827 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400828 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600829 ExtendedVlanTaggingOperationConfigurationData.class_id,
830 entity_id=entity_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400831 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600832 ExtendedVlanTaggingOperationConfigurationData.mask_for(
833 *data.keys()),
834 data=data
835 )
836 )
837 self.send_omci_message(frame)
838
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400839 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
840 entity_id,
841 filter_inner_vid,
842 treatment_inner_vid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600843 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400844 received_frame_vlan_tagging_operation_table=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600845 VlanTaggingOperation(
846 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500847 filter_outer_vid=4096,
848 filter_outer_tpid_de=0,
849
850 filter_inner_priority=15,
851 filter_inner_vid=filter_inner_vid,
852 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600853 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -0500854
855 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600856 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500857 treatment_outer_vid=0,
858 treatment_outer_tpid_de=0,
859
860 treatment_inner_priority=0,
861 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600862 treatment_inner_tpid_de=4
863 )
864 )
865 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400866 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600867 message_type=OmciSet.message_id,
868 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400869 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600870 ExtendedVlanTaggingOperationConfigurationData.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400871 entity_id=entity_id,
872 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600873 ExtendedVlanTaggingOperationConfigurationData.mask_for(
874 *data.keys()),
875 data=data
876 )
877 )
878 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800879
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400880 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
881 entity_id,
882 filter_inner_priority,
883 filter_inner_vid,
884 filter_inner_tpid_de,
885 treatment_tags_to_remove,
886 treatment_inner_priority,
887 treatment_inner_vid):
888 data = dict(
889 received_frame_vlan_tagging_operation_table=
890 VlanTaggingOperation(
891 filter_outer_priority=15,
892 filter_outer_vid=4096,
893 filter_outer_tpid_de=0,
894
895 filter_inner_priority=filter_inner_priority,
896 filter_inner_vid=filter_inner_vid,
897 filter_inner_tpid_de=filter_inner_tpid_de,
898 filter_ether_type=0,
899
900 treatment_tags_to_remove=treatment_tags_to_remove,
901 treatment_outer_priority=15,
902 treatment_outer_vid=0,
903 treatment_outer_tpid_de=0,
904
905 treatment_inner_priority=treatment_inner_priority,
906 treatment_inner_vid=treatment_inner_vid,
907 treatment_inner_tpid_de=4
908 )
909 )
910 frame = OmciFrame(
911 transaction_id=self.get_tx_id(),
912 message_type=OmciSet.message_id,
913 omci_message=OmciSet(
914 entity_class=
915 ExtendedVlanTaggingOperationConfigurationData.class_id,
916 entity_id=entity_id,
917 attributes_mask=
918 ExtendedVlanTaggingOperationConfigurationData.mask_for(
919 *data.keys()),
920 data=data
921 )
922 )
923 self.send_omci_message(frame)
924
Steve Crooks9e85ce82017-03-20 12:00:53 -0400925 def send_create_multicast_operations_profile(self,
926 entity_id,
927 igmp_ver):
928 frame = OmciFrame(
929 transaction_id=self.get_tx_id(),
930 message_type=OmciCreate.message_id,
931 omci_message=OmciCreate(
932 entity_class=
933 MulticastOperationsProfile.class_id,
934 entity_id=entity_id,
935 data=dict(
936 igmp_version=igmp_ver,
937 igmp_function=0,
938 immediate_leave=0
939 )
940 )
941 )
942 self.send_omci_message(frame)
943
944 def send_set_multicast_operations_profile_acl_row0(self,
945 entity_id,
946 acl_table,
947 row_key,
948 gem_port,
949 vlan,
950 src_ip,
951 dst_ip_start,
952 dst_ip_end):
953 row0 = AccessControlRow0(
954 set_ctrl=1,
955 row_part_id=0,
956 test=0,
957 row_key=row_key,
958 gem_port_id=gem_port,
959 vlan_id=vlan,
960 src_ip=src_ip,
961 dst_ip_start=dst_ip_start,
962 dst_ip_end=dst_ip_end,
963 ipm_group_bw=0
964 )
965
966 if acl_table == 'dynamic':
967 data = dict(
968 dynamic_access_control_list_table=row0
969 )
970 else:
971 data = dict(
972 static_access_control_list_table=row0
973 )
974
975 frame = OmciFrame(
976 transaction_id=self.get_tx_id(),
977 message_type=OmciSet.message_id,
978 omci_message=OmciSet(
979 entity_class=MulticastOperationsProfile.class_id,
980 entity_id=entity_id,
981 attributes_mask=MulticastOperationsProfile.mask_for(
982 *data.keys()),
983 data=data
984 )
985 )
986 self.send_omci_message(frame)
987
988 def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self,
989 entity_id,
990 ctrl_type,
991 tci):
992 data = dict(
993 ds_igmp_mcast_tci=
994 DownstreamIgmpMulticastTci(
995 ctrl_type=ctrl_type,
996 tci=tci
997 )
998 )
999 frame = OmciFrame(
1000 transaction_id=self.get_tx_id(),
1001 message_type=OmciSet.message_id,
1002 omci_message=OmciSet(
1003 entity_class=MulticastOperationsProfile.class_id,
1004 entity_id=entity_id,
1005 attributes_mask=MulticastOperationsProfile.mask_for(
1006 *data.keys()),
1007 data=data
1008 )
1009 )
1010 self.send_omci_message(frame)
1011
1012 def send_create_multicast_subscriber_config_info(self,
1013 entity_id,
1014 me_type,
1015 mcast_oper_profile):
1016 frame = OmciFrame(
1017 transaction_id=self.get_tx_id(),
1018 message_type=OmciCreate.message_id,
1019 omci_message=OmciCreate(
1020 entity_class=
1021 MulticastSubscriberConfigInfo.class_id,
1022 entity_id=entity_id,
1023 data=dict(
1024 me_type=me_type,
1025 mcast_operations_profile_pointer=mcast_oper_profile
1026 )
1027 )
1028 )
1029 self.send_omci_message(frame)
1030
1031 def send_set_multicast_subscriber_config_info(self,
1032 entity_id,
1033 max_groups=0,
1034 max_mcast_bw=0,
1035 bw_enforcement=0):
1036 data = dict(
1037 max_simultaneous_groups=max_groups,
1038 max_multicast_bandwidth=max_mcast_bw,
1039 bandwidth_enforcement=bw_enforcement
1040 )
1041 frame = OmciFrame(
1042 transaction_id=self.get_tx_id(),
1043 message_type=OmciSet.message_id,
1044 omci_message=OmciSet(
1045 entity_class=MulticastSubscriberConfigInfo.class_id,
1046 entity_id=entity_id,
1047 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1048 *data.keys()),
1049 data=data
1050 )
1051 )
1052 self.send_omci_message(frame)
1053
1054 def send_set_multicast_service_package(self,
1055 entity_id,
1056 row_key,
1057 vid_uni,
1058 max_groups,
1059 max_mcast_bw,
1060 mcast_oper_profile):
1061 data = dict(
1062 multicast_service_package_table=
1063 MulticastServicePackage(
1064 set_ctrl=1,
1065 row_key=row_key,
1066
1067 vid_uni=vid_uni,
1068 max_simultaneous_groups=max_groups,
1069 max_multicast_bw=max_mcast_bw,
1070 mcast_operations_profile_pointer=mcast_oper_profile
1071 )
1072 )
1073 frame = OmciFrame(
1074 transaction_id=self.get_tx_id(),
1075 message_type=OmciSet.message_id,
1076 omci_message=OmciSet(
1077 entity_class=MulticastSubscriberConfigInfo.class_id,
1078 entity_id=entity_id,
1079 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1080 *data.keys()),
1081 data=data
1082 )
1083 )
1084 self.send_omci_message(frame)
1085
1086 def send_set_multicast_allowed_preview_groups_row0(self,
1087 entity_id,
1088 row_key,
1089 src_ip,
1090 vlan_id_ani,
1091 vlan_id_uni):
1092 data = dict(
1093 allowed_preview_groups_table=
1094 AllowedPreviewGroupsRow0(
1095 set_ctrl=1,
1096 row_part_id=0,
1097 row_key=row_key,
1098
1099 src_ip=src_ip,
1100 vlan_id_ani=vlan_id_ani,
1101 vlan_id_uni=vlan_id_uni
1102 )
1103 )
1104 frame = OmciFrame(
1105 transaction_id=self.get_tx_id(),
1106 message_type=OmciSet.message_id,
1107 omci_message=OmciSet(
1108 entity_class=MulticastSubscriberConfigInfo.class_id,
1109 entity_id=entity_id,
1110 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1111 *data.keys()),
1112 data=data
1113 )
1114 )
1115 self.send_omci_message(frame)
1116
1117 def send_set_multicast_allowed_preview_groups_row1(self,
1118 entity_id,
1119 row_key,
1120 dst_ip,
1121 duration,
1122 time_left):
1123 data = dict(
1124 allowed_preview_groups_table=
1125 AllowedPreviewGroupsRow1(
1126 set_ctrl=1,
1127 row_part_id=1,
1128 row_key=row_key,
1129
1130 dst_ip=dst_ip,
1131 duration=duration,
1132 time_left=time_left
1133 )
1134 )
1135 frame = OmciFrame(
1136 transaction_id=self.get_tx_id(),
1137 message_type=OmciSet.message_id,
1138 omci_message=OmciSet(
1139 entity_class=MulticastSubscriberConfigInfo.class_id,
1140 entity_id=entity_id,
1141 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1142 *data.keys()),
1143 data=data
1144 )
1145 )
1146 self.send_omci_message(frame)
1147
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001148 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -06001149 def wait_for_response(self):
1150 log.info('wait-for-response')
1151 try:
1152 response = yield self.incoming_messages.get()
Steve Crooks9e85ce82017-03-20 12:00:53 -04001153 log.info('got-response')
1154 # resp = OmciFrame(response)
1155 # resp.show()
Steve Crooks3c2c7582017-01-10 15:02:26 -06001156 except Exception as e:
1157 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001158
Steve Crooks3c2c7582017-01-10 15:02:26 -06001159 @inlineCallbacks
Steve Crooks9b160d72017-03-31 10:48:29 -05001160 def message_exchange(self, onu, gem, cvid):
1161 log.info('message_exchange', onu=onu, gem=gem, cvid=cvid)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001162 # reset incoming message queue
1163 while self.incoming_messages.pending:
1164 _ = yield self.incoming_messages.get()
1165
Steve Crooks9b160d72017-03-31 10:48:29 -05001166 tcont = gem
1167
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001168 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -06001169 # MIB Reset - OntData - 0
1170 self.send_mib_reset()
1171 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001172
Steve Crooks3c2c7582017-01-10 15:02:26 -06001173 # Create AR - GalEthernetProfile - 1
1174 self.send_create_gal_ethernet_profile(1, 48)
1175 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001176
Steve Crooks9b160d72017-03-31 10:48:29 -05001177 # TCONT config
1178 # Set AR - TCont - 32769 - (1025 or 1026)
1179 self.send_set_tcont(0x8001, tcont)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001180 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001181
Steve Crooks9b160d72017-03-31 10:48:29 -05001182 # Mapper Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001183 # Create AR - 802.1pMapperServiceProfile - 32769
1184 self.send_create_8021p_mapper_service_profile(0x8001)
1185 yield self.wait_for_response()
1186
Steve Crooks9b160d72017-03-31 10:48:29 -05001187 # MAC Bridge Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001188 # Create AR - MacBridgeServiceProfile - 513
1189 self.send_create_mac_bridge_service_profile(0x201)
1190 yield self.wait_for_response()
1191
Steve Crooks9b160d72017-03-31 10:48:29 -05001192 # GEM Port Network CTP config
1193 # Create AR - GemPortNetworkCtp - 257 - <gem> - 32769
1194 self.send_create_gem_port_network_ctp(0x101, gem, 0x8001, "bi-directional", 0x100)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001195 yield self.wait_for_response()
1196
1197 # Create AR - GemPortNetworkCtp - 260 - 4000 - 0
1198 self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001199 yield self.wait_for_response()
1200
Steve Crooks9b160d72017-03-31 10:48:29 -05001201 # Multicast GEM Interworking config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001202 # Create AR - MulticastGemInterworkingTp - 6 - 260
1203 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
1204 yield self.wait_for_response()
1205
Steve Crooks9b160d72017-03-31 10:48:29 -05001206 # GEM Interworking config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001207 # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1
1208 self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001)
1209 yield self.wait_for_response()
1210
Steve Crooks9b160d72017-03-31 10:48:29 -05001211 # Mapper Service Profile config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001212 # Set AR - 802.1pMapperServiceProfile - 32769 - 32770
1213 self.send_set_8021p_mapper_service_profile(0x8001, 0x8002)
1214 yield self.wait_for_response()
1215
Steve Crooks9b160d72017-03-31 10:48:29 -05001216 # MAC Bridge Port config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001217 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
1218 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
1219 yield self.wait_for_response()
1220
Steve Crooks3c2c7582017-01-10 15:02:26 -06001221 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
1222 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
1223 yield self.wait_for_response()
1224
Steve Crooks9b160d72017-03-31 10:48:29 -05001225 # VLAN Tagging Filter config
1226 # Create AR - VlanTaggingFilterData - 8450 - c-vid
1227 self.send_create_vlan_tagging_filter_data(0x2102, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001228 yield self.wait_for_response()
1229
Steve Crooks9b160d72017-03-31 10:48:29 -05001230 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001231 # Create AR - MulticastOperationsProfile
1232 self.send_create_multicast_operations_profile(0x201, 3)
1233 yield self.wait_for_response()
1234
1235 # Set AR - MulticastOperationsProfile - Dynamic Access Control List table
1236 self.send_set_multicast_operations_profile_acl_row0(0x201,
1237 'dynamic',
1238 0,
1239 0x0fa0,
1240 0x0fa0,
1241 '0.0.0.0',
1242 '224.0.0.0',
1243 '239.255.255.255')
1244 yield self.wait_for_response()
1245
Steve Crooks9b160d72017-03-31 10:48:29 -05001246 # Multicast Subscriber config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001247 # Create AR - MulticastSubscriberConfigInfo
1248 self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201)
1249 yield self.wait_for_response()
1250
Steve Crooks9b160d72017-03-31 10:48:29 -05001251 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001252 # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI
Steve Crooks9b160d72017-03-31 10:48:29 -05001253 self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001254 yield self.wait_for_response()
1255
Steve Crooks9b160d72017-03-31 10:48:29 -05001256 # Port 2
1257 # Extended VLAN Tagging Operation config
1258 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102
1259 # TODO: add entry here for additional UNI interfaces
Steve Crooks9e85ce82017-03-20 12:00:53 -04001260 self.send_create_extended_vlan_tagging_operation_configuration_data(0x202, 2, 0x102)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001261 yield self.wait_for_response()
1262
1263 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
Steve Crooks46d64302017-03-10 15:11:06 -05001264 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001265 yield self.wait_for_response()
1266
Steve Crooks46d64302017-03-10 15:11:06 -05001267 # Set AR - ExtendedVlanTaggingOperationConfigData
Steve Crooks9b160d72017-03-31 10:48:29 -05001268 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1269 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, 1, 8, cvid)
Steve Crooksa9d0a7c2017-03-28 22:40:01 -04001270 #yield self.wait_for_response()
1271
1272 # Set AR - ExtendedVlanTaggingOperationConfigData
Steve Crooks9b160d72017-03-31 10:48:29 -05001273 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1274 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001275 yield self.wait_for_response()
1276
Steve Crooks9b160d72017-03-31 10:48:29 -05001277 # MAC Bridge Port config
1278 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102
1279 # TODO: add more entries here for other UNI ports
1280 self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 2, 1, 0x102)
1281 yield self.wait_for_response()
1282
1283 # Port 5
1284 # Extended VLAN Tagging Operation config
1285 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102
1286 # TODO: add entry here for additional UNI interfaces
1287 self.send_create_extended_vlan_tagging_operation_configuration_data(0x205, 2, 0x105)
1288 yield self.wait_for_response()
1289
1290 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1291 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x205, 0x8100, 0x8100)
1292 yield self.wait_for_response()
1293
1294 # Set AR - ExtendedVlanTaggingOperationConfigData
1295 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1296 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0, 1, 8, cvid)
1297 #yield self.wait_for_response()
1298
1299 # Set AR - ExtendedVlanTaggingOperationConfigData
1300 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1301 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x205, 0x1000, cvid)
1302 yield self.wait_for_response()
1303
1304 # MAC Bridge Port config
1305 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102
1306 # TODO: add more entries here for other UNI ports
1307 self.send_create_mac_bridge_port_configuration_data(0x205, 0x201, 5, 1, 0x105)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001308 yield self.wait_for_response()
rshettyc26a3c32017-07-27 11:06:38 +05301309
1310 def create_interface(self, data):
1311 self.log.info('Not Implemented yet')
1312 return;
1313
1314 def update_interface(self, data):
1315 self.log.info('Not Implemented yet')
1316 return;
1317
1318 def remove_interface(self, data):
1319 self.log.info('Not Implemented yet')
1320 return;