blob: 968fc427d85abc4f0a887ddda9fdb186ec9c92bc [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
Stephane Barbarie980a0912017-05-11 11:27:06 -0400182 def suppress_alarm(self, filter):
183 raise NotImplementedError()
184
Nikolay Titov89004ec2017-06-19 18:22:42 -0400185 def create_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530186 log.info('create-interface', device_id=device.id)
187 if device.proxy_address.channel_id in self.devices_handlers:
188 handler = self.devices_handlers[device.proxy_address.channel_id]
189 if handler is not None:
190 handler.create_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400191
192 def update_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530193 log.info('update-interface', device_id=device.id)
194 if device.proxy_address.channel_id in self.devices_handlers:
195 handler = self.devices_handlers[device.proxy_address.channel_id]
196 if handler is not None:
197 handler.update_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400198
199 def remove_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530200 log.info('remove-interface', device_id=device.id)
201 if device.proxy_address.channel_id in self.devices_handlers:
202 handler = self.devices_handlers[device.proxy_address.channel_id]
203 if handler is not None:
204 handler.remove_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400205
206 def receive_onu_detect_state(self, device_id, state):
207 raise NotImplementedError()
208
Stephane Barbarie980a0912017-05-11 11:27:06 -0400209 def unsuppress_alarm(self, filter):
210 raise NotImplementedError()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600211
212class BroadcomOnuHandler(object):
213
214 def __init__(self, adapter, device_id):
215 self.adapter = adapter
216 self.adapter_agent = adapter.adapter_agent
217 self.device_id = device_id
218 self.log = structlog.get_logger(device_id=device_id)
219 self.incoming_messages = DeferredQueue()
Peter Shafikd7f33772017-05-17 13:56:34 -0400220 self.event_messages = DeferredQueue()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600221 self.proxy_address = None
222 self.tx_id = 0
223
Peter Shafikd7f33772017-05-17 13:56:34 -0400224 # Need to query ONU for number of supported uni ports
225 # For now, temporarily set number of ports to 1 - port #2
226 self.uni_ports = (2,)
227
228 # Handle received ONU event messages
229 reactor.callLater(0, self.handle_onu_events)
230
Steve Crooks3c2c7582017-01-10 15:02:26 -0600231 def receive_message(self, msg):
232 self.incoming_messages.put(msg)
233
Peter Shafikd7f33772017-05-17 13:56:34 -0400234 @inlineCallbacks
235 def handle_onu_events(self):
236 event_msg = yield self.event_messages.get()
237
238 if event_msg['event'] == 'activation-completed':
239
240 if event_msg['event_data']['activation_successful'] == True:
241 for uni in self.uni_ports:
242 port_no = self.proxy_address.channel_id + uni
243 reactor.callLater(1,
244 self.message_exchange,
245 self.proxy_address.onu_id,
246 self.proxy_address.onu_session_id,
247 port_no)
248
249 device = self.adapter_agent.get_device(self.device_id)
250 device.oper_status = OperStatus.ACTIVE
251 self.adapter_agent.update_device(device)
252
253 else:
254 device = self.adapter_agent.get_device(self.device_id)
255 device.oper_status = OperStatus.FAILED
256 self.adapter_agent.update_device(device)
257
258 elif event_msg['event'] == 'deactivation-completed':
259 device = self.adapter_agent.get_device(self.device_id)
260 device.oper_status = OperStatus.DISCOVERED
261 self.adapter_agent.update_device(device)
262
263 elif event_msg['event'] == 'ranging-completed':
264
265 if event_msg['event_data']['ranging_successful'] == True:
266 device = self.adapter_agent.get_device(self.device_id)
267 device.oper_status = OperStatus.ACTIVATING
268 self.adapter_agent.update_device(device)
269
270 else:
271 device = self.adapter_agent.get_device(self.device_id)
272 device.oper_status = OperStatus.FAILED
273 self.adapter_agent.update_device(device)
274
275 # Handle next event
276 reactor.callLater(0, self.handle_onu_events)
277
278
Steve Crooks3c2c7582017-01-10 15:02:26 -0600279 def activate(self, device):
280 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800281
282 # first we verify that we got parent reference and proxy info
283 assert device.parent_id
284 assert device.proxy_address.device_id
Steve Crooks9b160d72017-03-31 10:48:29 -0500285 #assert device.proxy_address.channel_id # c-vid
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800286
Steve Crooks3c2c7582017-01-10 15:02:26 -0600287 # register for proxied messages right away
288 self.proxy_address = device.proxy_address
289 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
290
Peter Shafik9107f2e2017-05-02 15:54:39 -0400291
Steve Crooks3c2c7582017-01-10 15:02:26 -0600292 # populate device info
293 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800294 device.vendor = 'Broadcom'
Steve Crooks9e85ce82017-03-20 12:00:53 -0400295 device.model = 'n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800296 device.hardware_version = 'to be filled'
297 device.firmware_version = 'to be filled'
ggowdru236bd952017-06-20 20:32:55 -0700298 device.images.image.extend([
299 Image(version="to be filled")
300 ])
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800301 device.connect_status = ConnectStatus.REACHABLE
302 self.adapter_agent.update_device(device)
303
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800304 self.adapter_agent.add_port(device.id, Port(
Steve Crooks9b160d72017-03-31 10:48:29 -0500305 port_no=100,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800306 label='PON port',
307 type=Port.PON_ONU,
308 admin_state=AdminState.ENABLED,
309 oper_status=OperStatus.ACTIVE,
310 peers=[
311 Port.PeerPort(
312 device_id=device.parent_id,
313 port_no=device.parent_port_no
314 )
315 ]
316 ))
317
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800318 parent_device = self.adapter_agent.get_device(device.parent_id)
319 logical_device_id = parent_device.parent_id
320 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800321
Peter Shafikd7f33772017-05-17 13:56:34 -0400322 for uni in self.uni_ports:
Steve Crooks9b160d72017-03-31 10:48:29 -0500323 # register physical ports
324 uni_port = Port(
325 port_no=uni,
326 label='UNI facing Ethernet port '+str(uni),
327 type=Port.ETHERNET_UNI,
328 admin_state=AdminState.ENABLED,
329 oper_status=OperStatus.ACTIVE
330 )
331 self.adapter_agent.add_port(device.id, uni_port)
332
333 # add uni port to logical device
334 port_no = device.proxy_address.channel_id + uni
335 cap = OFPPF_1GB_FD | OFPPF_FIBER
336 self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
337 id='uni-{}'.format(port_no),
338 ofp_port=ofp_port(
339 port_no=port_no,
340 hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' %
341 (device.proxy_address.onu_id & 0xff,
342 (port_no >> 8) & 0xff,
343 port_no & 0xff)),
344 name='uni-{}'.format(port_no),
345 config=0,
346 state=OFPPS_LIVE,
347 curr=cap,
348 advertised=cap,
349 peer=cap,
350 curr_speed=OFPPF_1GB_FD,
351 max_speed=OFPPF_1GB_FD
352 ),
353 device_id=device.id,
354 device_port_no=uni_port.port_no
355 ))
356
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800357 device = self.adapter_agent.get_device(device.id)
Peter Shafikd7f33772017-05-17 13:56:34 -0400358 device.oper_status = OperStatus.DISCOVERED
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800359 self.adapter_agent.update_device(device)
360
Steve Crooks3c2c7582017-01-10 15:02:26 -0600361 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500362 def update_flow_table(self, device, flows):
363 #
364 # We need to proxy through the OLT to get to the ONU
365 # Configuration from here should be using OMCI
366 #
367 self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800368
Steve Crooksf248e182017-02-07 10:50:24 -0500369 def is_downstream(port):
Steve Crooks9b160d72017-03-31 10:48:29 -0500370 return port == 100 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800371
Steve Crooksf248e182017-02-07 10:50:24 -0500372 def is_upstream(port):
373 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800374
Steve Crooksf248e182017-02-07 10:50:24 -0500375 for flow in flows:
Steve Crooks9b160d72017-03-31 10:48:29 -0500376 _type = None
377 _port = None
378 _vlan_vid = None
379 _udp_dst = None
380 _udp_src = None
381 _ipv4_dst = None
382 _ipv4_src = None
383 _metadata = None
384 _output = None
385 _push_tpid = None
386 _field = None
387 _set_vlan_vid = None
Steve Crooksf248e182017-02-07 10:50:24 -0500388 try:
389 _in_port = fd.get_in_port(flow)
390 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600391
Steve Crooksf248e182017-02-07 10:50:24 -0500392 if is_downstream(_in_port):
393 self.log.info('downstream-flow')
394 elif is_upstream(_in_port):
395 self.log.info('upstream-flow')
396 else:
397 raise Exception('port should be 1 or 2 by our convention')
398
399 _out_port = fd.get_out_port(flow) # may be None
400 self.log.info('out-port', out_port=_out_port)
401
402 for field in fd.get_ofb_fields(flow):
403 if field.type == fd.ETH_TYPE:
404 _type = field.eth_type
405 self.log.info('field-type-eth-type',
406 eth_type=_type)
407
408 elif field.type == fd.IP_PROTO:
409 _proto = field.ip_proto
410 self.log.info('field-type-ip-proto',
411 ip_proto=_proto)
412
413 elif field.type == fd.IN_PORT:
414 _port = field.port
415 self.log.info('field-type-in-port',
416 in_port=_port)
417
418 elif field.type == fd.VLAN_VID:
419 _vlan_vid = field.vlan_vid & 0xfff
420 self.log.info('field-type-vlan-vid',
421 vlan=_vlan_vid)
422
423 elif field.type == fd.VLAN_PCP:
424 _vlan_pcp = field.vlan_pcp
425 self.log.info('field-type-vlan-pcp',
426 pcp=_vlan_pcp)
427
428 elif field.type == fd.UDP_DST:
429 _udp_dst = field.udp_dst
430 self.log.info('field-type-udp-dst',
431 udp_dst=_udp_dst)
432
433 elif field.type == fd.UDP_SRC:
434 _udp_src = field.udp_src
435 self.log.info('field-type-udp-src',
436 udp_src=_udp_src)
437
438 elif field.type == fd.IPV4_DST:
439 _ipv4_dst = field.ipv4_dst
440 self.log.info('field-type-ipv4-dst',
441 ipv4_dst=_ipv4_dst)
442
443 elif field.type == fd.IPV4_SRC:
444 _ipv4_src = field.ipv4_src
445 self.log.info('field-type-ipv4-src',
446 ipv4_dst=_ipv4_src)
447
448 elif field.type == fd.METADATA:
Steve Crooks9b160d72017-03-31 10:48:29 -0500449 _metadata = field.table_metadata
Steve Crooksf248e182017-02-07 10:50:24 -0500450 self.log.info('field-type-metadata',
451 metadata=_metadata)
452
453 else:
454 raise NotImplementedError('field.type={}'.format(
455 field.type))
456
457 for action in fd.get_actions(flow):
458
459 if action.type == fd.OUTPUT:
460 _output = action.output.port
461 self.log.info('action-type-output',
462 output=_output, in_port=_in_port)
463
464 elif action.type == fd.POP_VLAN:
465 self.log.info('action-type-pop-vlan',
466 in_port=_in_port)
467
468 elif action.type == fd.PUSH_VLAN:
469 _push_tpid = action.push.ethertype
470 log.info('action-type-push-vlan',
471 push_tpid=_push_tpid, in_port=_in_port)
472 if action.push.ethertype != 0x8100:
473 self.log.error('unhandled-tpid',
474 ethertype=action.push.ethertype)
475
476 elif action.type == fd.SET_FIELD:
477 _field = action.set_field.field.ofb_field
478 assert (action.set_field.field.oxm_class ==
479 OFPXMC_OPENFLOW_BASIC)
480 self.log.info('action-type-set-field',
481 field=_field, in_port=_in_port)
482 if _field.type == fd.VLAN_VID:
Steve Crooks9b160d72017-03-31 10:48:29 -0500483 _set_vlan_vid = _field.vlan_vid & 0xfff
484 self.log.info('set-field-type-valn-vid', _set_vlan_vid)
Steve Crooksf248e182017-02-07 10:50:24 -0500485 else:
486 self.log.error('unsupported-action-set-field-type',
487 field_type=_field.type)
488 else:
489 log.error('unsupported-action-type',
490 action_type=action.type, in_port=_in_port)
491
492 #
493 # All flows created from ONU adapter should be OMCI based
494 #
Steve Crooks9b160d72017-03-31 10:48:29 -0500495 if _vlan_vid == 0:
496 # allow priority tagged packets
497 # Set AR - ExtendedVlanTaggingOperationConfigData
498 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
499 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0,
500 1, 8, _in_port)
501 yield self.wait_for_response()
502
503 # Set AR - ExtendedVlanTaggingOperationConfigData
504 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
505 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0,
506 1, 8, _in_port)
507 yield self.wait_for_response()
Steve Crooksf248e182017-02-07 10:50:24 -0500508
509 except Exception as e:
510 log.exception('failed-to-install-flow', e=e, flow=flow)
511
Steve Crooks3c2c7582017-01-10 15:02:26 -0600512 def get_tx_id(self):
513 self.tx_id += 1
514 return self.tx_id
515
516 def send_omci_message(self, frame):
517 _frame = hexify(str(frame))
518 self.log.info('send-omci-message-%s' % _frame)
519 device = self.adapter_agent.get_device(self.device_id)
520 try:
521 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
522 except Exception as e:
523 self.log.info('send-omci-message-exception', exc=str(e))
524
525 def send_get_circuit_pack(self, entity_id=0):
526 frame = OmciFrame(
527 transaction_id=self.get_tx_id(),
528 message_type=OmciGet.message_id,
529 omci_message=OmciGet(
530 entity_class=CircuitPack.class_id,
531 entity_id=entity_id,
532 attributes_mask=CircuitPack.mask_for('vendor_id')
533 )
534 )
535 self.send_omci_message(frame)
536
537 def send_mib_reset(self, entity_id=0):
538 frame = OmciFrame(
539 transaction_id=self.get_tx_id(),
540 message_type=OmciMibReset.message_id,
541 omci_message=OmciMibReset(
542 entity_class=OntData.class_id,
543 entity_id=entity_id
544 )
545 )
546 self.send_omci_message(frame)
547
Steve Crooks9e85ce82017-03-20 12:00:53 -0400548 def send_create_gal_ethernet_profile(self,
549 entity_id,
550 max_gem_payload_size):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600551 frame = OmciFrame(
552 transaction_id=self.get_tx_id(),
553 message_type=OmciCreate.message_id,
554 omci_message=OmciCreate(
555 entity_class=GalEthernetProfile.class_id,
556 entity_id=entity_id,
557 data=dict(
558 max_gem_payload_size=max_gem_payload_size
559 )
560 )
561 )
562 self.send_omci_message(frame)
563
Steve Crooks9e85ce82017-03-20 12:00:53 -0400564 def send_set_tcont(self,
565 entity_id,
566 alloc_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600567 data = dict(
568 alloc_id=alloc_id
569 )
570 frame = OmciFrame(
571 transaction_id=self.get_tx_id(),
572 message_type=OmciSet.message_id,
573 omci_message=OmciSet(
574 entity_class=Tcont.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400575 entity_id=entity_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600576 attributes_mask=Tcont.mask_for(*data.keys()),
577 data=data
578 )
579 )
580 self.send_omci_message(frame)
581
Steve Crooks9e85ce82017-03-20 12:00:53 -0400582 def send_create_8021p_mapper_service_profile(self,
583 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600584 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400585 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600586 message_type=OmciCreate.message_id,
587 omci_message=OmciCreate(
588 entity_class=Ieee8021pMapperServiceProfile.class_id,
589 entity_id=entity_id,
590 data=dict(
591 tp_pointer=OmciNullPointer,
592 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
Steve Crooks9b160d72017-03-31 10:48:29 -0500593 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
594 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
595 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
596 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
597 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
598 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
599 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
Steve Crooks3c2c7582017-01-10 15:02:26 -0600600 )
601 )
602 )
603 self.send_omci_message(frame)
604
Steve Crooks9e85ce82017-03-20 12:00:53 -0400605 def send_create_mac_bridge_service_profile(self,
606 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600607 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400608 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600609 message_type=OmciCreate.message_id,
610 omci_message=OmciCreate(
611 entity_class=MacBridgeServiceProfile.class_id,
612 entity_id=entity_id,
613 data=dict(
614 spanning_tree_ind=False,
615 learning_ind=True,
616 priority=0x8000,
617 max_age=20 * 256,
618 hello_time=2 * 256,
619 forward_delay=15 * 256,
620 unknown_mac_address_discard=True
621 )
622 )
623 )
624 self.send_omci_message(frame)
625
Steve Crooks9e85ce82017-03-20 12:00:53 -0400626 def send_create_gem_port_network_ctp(self,
627 entity_id,
628 port_id,
629 tcont_id,
630 direction,
631 tm):
632 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
633 if _directions.has_key(direction):
634 _direction = _directions[direction]
635 else:
636 self.log.error('invalid-gem-port-direction', direction=direction)
637 raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction))
638
Steve Crooks3c2c7582017-01-10 15:02:26 -0600639 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400640 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600641 message_type=OmciCreate.message_id,
642 omci_message=OmciCreate(
643 entity_class=GemPortNetworkCtp.class_id,
644 entity_id=entity_id,
645 data=dict(
646 port_id=port_id,
647 tcont_pointer=tcont_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400648 direction=_direction,
649 traffic_management_pointer_upstream=tm
Steve Crooks3c2c7582017-01-10 15:02:26 -0600650 )
651 )
652 )
653 self.send_omci_message(frame)
654
Steve Crooks9e85ce82017-03-20 12:00:53 -0400655 def send_create_multicast_gem_interworking_tp(self,
656 entity_id,
657 gem_port_net_ctp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600658 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400659 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600660 message_type=OmciCreate.message_id,
661 omci_message=OmciCreate(
662 entity_class=MulticastGemInterworkingTp.class_id,
663 entity_id=entity_id,
664 data=dict(
665 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
666 interworking_option=0,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400667 service_profile_pointer=0x1
Steve Crooks3c2c7582017-01-10 15:02:26 -0600668 )
669 )
670 )
671 self.send_omci_message(frame)
672
Steve Crooks9e85ce82017-03-20 12:00:53 -0400673 def send_create_gem_inteworking_tp(self,
674 entity_id,
675 gem_port_net_ctp_id,
676 service_profile_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600677 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400678 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600679 message_type=OmciCreate.message_id,
680 omci_message=OmciCreate(
681 entity_class=GemInterworkingTp.class_id,
682 entity_id=entity_id,
683 data=dict(
684 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
685 interworking_option=5,
686 service_profile_pointer=service_profile_id,
687 interworking_tp_pointer=0x0,
688 gal_profile_pointer=0x1
689 )
690 )
691 )
692 self.send_omci_message(frame)
693
Steve Crooks9e85ce82017-03-20 12:00:53 -0400694 def send_set_8021p_mapper_service_profile(self,
695 entity_id,
696 interwork_tp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600697 data = dict(
Steve Crooks9b160d72017-03-31 10:48:29 -0500698 interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id,
699 interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id,
700 interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id,
701 interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id,
702 interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id,
703 interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id,
704 interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id,
705 interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600706 )
707 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400708 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600709 message_type=OmciSet.message_id,
710 omci_message=OmciSet(
711 entity_class=Ieee8021pMapperServiceProfile.class_id,
712 entity_id=entity_id,
713 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
714 *data.keys()),
715 data=data
716 )
717 )
718 self.send_omci_message(frame)
719
720 def send_create_mac_bridge_port_configuration_data(self,
721 entity_id,
722 bridge_id,
723 port_id,
724 tp_type,
725 tp_id):
726 frame = OmciFrame(
727 transaction_id=self.get_tx_id(),
728 message_type=OmciCreate.message_id,
729 omci_message=OmciCreate(
730 entity_class=MacBridgePortConfigurationData.class_id,
731 entity_id=entity_id,
732 data=dict(
733 bridge_id_pointer = bridge_id,
734 port_num=port_id,
735 tp_type=tp_type,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400736 tp_pointer=tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600737 )
738 )
739 )
740 self.send_omci_message(frame)
741
Steve Crooks9e85ce82017-03-20 12:00:53 -0400742 def send_create_vlan_tagging_filter_data(self,
743 entity_id,
744 vlan_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600745 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400746 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600747 message_type=OmciCreate.message_id,
748 omci_message=OmciCreate(
749 entity_class=VlanTaggingFilterData.class_id,
750 entity_id=entity_id,
751 data=dict(
752 vlan_filter_0=vlan_id,
753 forward_operation=0x10,
754 number_of_entries=1
755 )
756 )
757 )
758 self.send_omci_message(frame)
759
Steve Crooks46d64302017-03-10 15:11:06 -0500760 def send_create_extended_vlan_tagging_operation_configuration_data(self,
761 entity_id,
762 assoc_type,
763 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600764 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400765 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600766 message_type=OmciCreate.message_id,
767 omci_message=OmciCreate(
768 entity_class=
769 ExtendedVlanTaggingOperationConfigurationData.class_id,
770 entity_id=entity_id,
771 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500772 association_type=assoc_type,
773 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600774 )
775 )
776 )
777 self.send_omci_message(frame)
778
Steve Crooks9e85ce82017-03-20 12:00:53 -0400779 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self,
780 entity_id,
781 input_tpid,
782 output_tpid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600783 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400784 input_tpid=input_tpid,
785 output_tpid=output_tpid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600786 downstream_mode=0, # inverse of upstream
787 )
788 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400789 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600790 message_type=OmciSet.message_id,
791 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400792 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600793 ExtendedVlanTaggingOperationConfigurationData.class_id,
794 entity_id=entity_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400795 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600796 ExtendedVlanTaggingOperationConfigurationData.mask_for(
797 *data.keys()),
798 data=data
799 )
800 )
801 self.send_omci_message(frame)
802
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400803 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
804 entity_id,
805 filter_inner_vid,
806 treatment_inner_vid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600807 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400808 received_frame_vlan_tagging_operation_table=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600809 VlanTaggingOperation(
810 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500811 filter_outer_vid=4096,
812 filter_outer_tpid_de=0,
813
814 filter_inner_priority=15,
815 filter_inner_vid=filter_inner_vid,
816 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600817 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -0500818
819 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600820 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500821 treatment_outer_vid=0,
822 treatment_outer_tpid_de=0,
823
824 treatment_inner_priority=0,
825 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600826 treatment_inner_tpid_de=4
827 )
828 )
829 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400830 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600831 message_type=OmciSet.message_id,
832 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400833 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600834 ExtendedVlanTaggingOperationConfigurationData.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400835 entity_id=entity_id,
836 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600837 ExtendedVlanTaggingOperationConfigurationData.mask_for(
838 *data.keys()),
839 data=data
840 )
841 )
842 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800843
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400844 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
845 entity_id,
846 filter_inner_priority,
847 filter_inner_vid,
848 filter_inner_tpid_de,
849 treatment_tags_to_remove,
850 treatment_inner_priority,
851 treatment_inner_vid):
852 data = dict(
853 received_frame_vlan_tagging_operation_table=
854 VlanTaggingOperation(
855 filter_outer_priority=15,
856 filter_outer_vid=4096,
857 filter_outer_tpid_de=0,
858
859 filter_inner_priority=filter_inner_priority,
860 filter_inner_vid=filter_inner_vid,
861 filter_inner_tpid_de=filter_inner_tpid_de,
862 filter_ether_type=0,
863
864 treatment_tags_to_remove=treatment_tags_to_remove,
865 treatment_outer_priority=15,
866 treatment_outer_vid=0,
867 treatment_outer_tpid_de=0,
868
869 treatment_inner_priority=treatment_inner_priority,
870 treatment_inner_vid=treatment_inner_vid,
871 treatment_inner_tpid_de=4
872 )
873 )
874 frame = OmciFrame(
875 transaction_id=self.get_tx_id(),
876 message_type=OmciSet.message_id,
877 omci_message=OmciSet(
878 entity_class=
879 ExtendedVlanTaggingOperationConfigurationData.class_id,
880 entity_id=entity_id,
881 attributes_mask=
882 ExtendedVlanTaggingOperationConfigurationData.mask_for(
883 *data.keys()),
884 data=data
885 )
886 )
887 self.send_omci_message(frame)
888
Steve Crooks9e85ce82017-03-20 12:00:53 -0400889 def send_create_multicast_operations_profile(self,
890 entity_id,
891 igmp_ver):
892 frame = OmciFrame(
893 transaction_id=self.get_tx_id(),
894 message_type=OmciCreate.message_id,
895 omci_message=OmciCreate(
896 entity_class=
897 MulticastOperationsProfile.class_id,
898 entity_id=entity_id,
899 data=dict(
900 igmp_version=igmp_ver,
901 igmp_function=0,
902 immediate_leave=0
903 )
904 )
905 )
906 self.send_omci_message(frame)
907
908 def send_set_multicast_operations_profile_acl_row0(self,
909 entity_id,
910 acl_table,
911 row_key,
912 gem_port,
913 vlan,
914 src_ip,
915 dst_ip_start,
916 dst_ip_end):
917 row0 = AccessControlRow0(
918 set_ctrl=1,
919 row_part_id=0,
920 test=0,
921 row_key=row_key,
922 gem_port_id=gem_port,
923 vlan_id=vlan,
924 src_ip=src_ip,
925 dst_ip_start=dst_ip_start,
926 dst_ip_end=dst_ip_end,
927 ipm_group_bw=0
928 )
929
930 if acl_table == 'dynamic':
931 data = dict(
932 dynamic_access_control_list_table=row0
933 )
934 else:
935 data = dict(
936 static_access_control_list_table=row0
937 )
938
939 frame = OmciFrame(
940 transaction_id=self.get_tx_id(),
941 message_type=OmciSet.message_id,
942 omci_message=OmciSet(
943 entity_class=MulticastOperationsProfile.class_id,
944 entity_id=entity_id,
945 attributes_mask=MulticastOperationsProfile.mask_for(
946 *data.keys()),
947 data=data
948 )
949 )
950 self.send_omci_message(frame)
951
952 def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self,
953 entity_id,
954 ctrl_type,
955 tci):
956 data = dict(
957 ds_igmp_mcast_tci=
958 DownstreamIgmpMulticastTci(
959 ctrl_type=ctrl_type,
960 tci=tci
961 )
962 )
963 frame = OmciFrame(
964 transaction_id=self.get_tx_id(),
965 message_type=OmciSet.message_id,
966 omci_message=OmciSet(
967 entity_class=MulticastOperationsProfile.class_id,
968 entity_id=entity_id,
969 attributes_mask=MulticastOperationsProfile.mask_for(
970 *data.keys()),
971 data=data
972 )
973 )
974 self.send_omci_message(frame)
975
976 def send_create_multicast_subscriber_config_info(self,
977 entity_id,
978 me_type,
979 mcast_oper_profile):
980 frame = OmciFrame(
981 transaction_id=self.get_tx_id(),
982 message_type=OmciCreate.message_id,
983 omci_message=OmciCreate(
984 entity_class=
985 MulticastSubscriberConfigInfo.class_id,
986 entity_id=entity_id,
987 data=dict(
988 me_type=me_type,
989 mcast_operations_profile_pointer=mcast_oper_profile
990 )
991 )
992 )
993 self.send_omci_message(frame)
994
995 def send_set_multicast_subscriber_config_info(self,
996 entity_id,
997 max_groups=0,
998 max_mcast_bw=0,
999 bw_enforcement=0):
1000 data = dict(
1001 max_simultaneous_groups=max_groups,
1002 max_multicast_bandwidth=max_mcast_bw,
1003 bandwidth_enforcement=bw_enforcement
1004 )
1005 frame = OmciFrame(
1006 transaction_id=self.get_tx_id(),
1007 message_type=OmciSet.message_id,
1008 omci_message=OmciSet(
1009 entity_class=MulticastSubscriberConfigInfo.class_id,
1010 entity_id=entity_id,
1011 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1012 *data.keys()),
1013 data=data
1014 )
1015 )
1016 self.send_omci_message(frame)
1017
1018 def send_set_multicast_service_package(self,
1019 entity_id,
1020 row_key,
1021 vid_uni,
1022 max_groups,
1023 max_mcast_bw,
1024 mcast_oper_profile):
1025 data = dict(
1026 multicast_service_package_table=
1027 MulticastServicePackage(
1028 set_ctrl=1,
1029 row_key=row_key,
1030
1031 vid_uni=vid_uni,
1032 max_simultaneous_groups=max_groups,
1033 max_multicast_bw=max_mcast_bw,
1034 mcast_operations_profile_pointer=mcast_oper_profile
1035 )
1036 )
1037 frame = OmciFrame(
1038 transaction_id=self.get_tx_id(),
1039 message_type=OmciSet.message_id,
1040 omci_message=OmciSet(
1041 entity_class=MulticastSubscriberConfigInfo.class_id,
1042 entity_id=entity_id,
1043 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1044 *data.keys()),
1045 data=data
1046 )
1047 )
1048 self.send_omci_message(frame)
1049
1050 def send_set_multicast_allowed_preview_groups_row0(self,
1051 entity_id,
1052 row_key,
1053 src_ip,
1054 vlan_id_ani,
1055 vlan_id_uni):
1056 data = dict(
1057 allowed_preview_groups_table=
1058 AllowedPreviewGroupsRow0(
1059 set_ctrl=1,
1060 row_part_id=0,
1061 row_key=row_key,
1062
1063 src_ip=src_ip,
1064 vlan_id_ani=vlan_id_ani,
1065 vlan_id_uni=vlan_id_uni
1066 )
1067 )
1068 frame = OmciFrame(
1069 transaction_id=self.get_tx_id(),
1070 message_type=OmciSet.message_id,
1071 omci_message=OmciSet(
1072 entity_class=MulticastSubscriberConfigInfo.class_id,
1073 entity_id=entity_id,
1074 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1075 *data.keys()),
1076 data=data
1077 )
1078 )
1079 self.send_omci_message(frame)
1080
1081 def send_set_multicast_allowed_preview_groups_row1(self,
1082 entity_id,
1083 row_key,
1084 dst_ip,
1085 duration,
1086 time_left):
1087 data = dict(
1088 allowed_preview_groups_table=
1089 AllowedPreviewGroupsRow1(
1090 set_ctrl=1,
1091 row_part_id=1,
1092 row_key=row_key,
1093
1094 dst_ip=dst_ip,
1095 duration=duration,
1096 time_left=time_left
1097 )
1098 )
1099 frame = OmciFrame(
1100 transaction_id=self.get_tx_id(),
1101 message_type=OmciSet.message_id,
1102 omci_message=OmciSet(
1103 entity_class=MulticastSubscriberConfigInfo.class_id,
1104 entity_id=entity_id,
1105 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1106 *data.keys()),
1107 data=data
1108 )
1109 )
1110 self.send_omci_message(frame)
1111
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001112 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -06001113 def wait_for_response(self):
1114 log.info('wait-for-response')
1115 try:
1116 response = yield self.incoming_messages.get()
Steve Crooks9e85ce82017-03-20 12:00:53 -04001117 log.info('got-response')
1118 # resp = OmciFrame(response)
1119 # resp.show()
Steve Crooks3c2c7582017-01-10 15:02:26 -06001120 except Exception as e:
1121 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001122
Steve Crooks3c2c7582017-01-10 15:02:26 -06001123 @inlineCallbacks
Steve Crooks9b160d72017-03-31 10:48:29 -05001124 def message_exchange(self, onu, gem, cvid):
1125 log.info('message_exchange', onu=onu, gem=gem, cvid=cvid)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001126 # reset incoming message queue
1127 while self.incoming_messages.pending:
1128 _ = yield self.incoming_messages.get()
1129
Steve Crooks9b160d72017-03-31 10:48:29 -05001130 tcont = gem
1131
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001132 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -06001133 # MIB Reset - OntData - 0
1134 self.send_mib_reset()
1135 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001136
Steve Crooks3c2c7582017-01-10 15:02:26 -06001137 # Create AR - GalEthernetProfile - 1
1138 self.send_create_gal_ethernet_profile(1, 48)
1139 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001140
Steve Crooks9b160d72017-03-31 10:48:29 -05001141 # TCONT config
1142 # Set AR - TCont - 32769 - (1025 or 1026)
1143 self.send_set_tcont(0x8001, tcont)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001144 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001145
Steve Crooks9b160d72017-03-31 10:48:29 -05001146 # Mapper Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001147 # Create AR - 802.1pMapperServiceProfile - 32769
1148 self.send_create_8021p_mapper_service_profile(0x8001)
1149 yield self.wait_for_response()
1150
Steve Crooks9b160d72017-03-31 10:48:29 -05001151 # MAC Bridge Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001152 # Create AR - MacBridgeServiceProfile - 513
1153 self.send_create_mac_bridge_service_profile(0x201)
1154 yield self.wait_for_response()
1155
Steve Crooks9b160d72017-03-31 10:48:29 -05001156 # GEM Port Network CTP config
1157 # Create AR - GemPortNetworkCtp - 257 - <gem> - 32769
1158 self.send_create_gem_port_network_ctp(0x101, gem, 0x8001, "bi-directional", 0x100)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001159 yield self.wait_for_response()
1160
1161 # Create AR - GemPortNetworkCtp - 260 - 4000 - 0
1162 self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001163 yield self.wait_for_response()
1164
Steve Crooks9b160d72017-03-31 10:48:29 -05001165 # Multicast GEM Interworking config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001166 # Create AR - MulticastGemInterworkingTp - 6 - 260
1167 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
1168 yield self.wait_for_response()
1169
Steve Crooks9b160d72017-03-31 10:48:29 -05001170 # GEM Interworking config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001171 # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1
1172 self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001)
1173 yield self.wait_for_response()
1174
Steve Crooks9b160d72017-03-31 10:48:29 -05001175 # Mapper Service Profile config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001176 # Set AR - 802.1pMapperServiceProfile - 32769 - 32770
1177 self.send_set_8021p_mapper_service_profile(0x8001, 0x8002)
1178 yield self.wait_for_response()
1179
Steve Crooks9b160d72017-03-31 10:48:29 -05001180 # MAC Bridge Port config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001181 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
1182 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
1183 yield self.wait_for_response()
1184
Steve Crooks3c2c7582017-01-10 15:02:26 -06001185 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
1186 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
1187 yield self.wait_for_response()
1188
Steve Crooks9b160d72017-03-31 10:48:29 -05001189 # VLAN Tagging Filter config
1190 # Create AR - VlanTaggingFilterData - 8450 - c-vid
1191 self.send_create_vlan_tagging_filter_data(0x2102, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001192 yield self.wait_for_response()
1193
Steve Crooks9b160d72017-03-31 10:48:29 -05001194 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001195 # Create AR - MulticastOperationsProfile
1196 self.send_create_multicast_operations_profile(0x201, 3)
1197 yield self.wait_for_response()
1198
1199 # Set AR - MulticastOperationsProfile - Dynamic Access Control List table
1200 self.send_set_multicast_operations_profile_acl_row0(0x201,
1201 'dynamic',
1202 0,
1203 0x0fa0,
1204 0x0fa0,
1205 '0.0.0.0',
1206 '224.0.0.0',
1207 '239.255.255.255')
1208 yield self.wait_for_response()
1209
Steve Crooks9b160d72017-03-31 10:48:29 -05001210 # Multicast Subscriber config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001211 # Create AR - MulticastSubscriberConfigInfo
1212 self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201)
1213 yield self.wait_for_response()
1214
Steve Crooks9b160d72017-03-31 10:48:29 -05001215 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001216 # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI
Steve Crooks9b160d72017-03-31 10:48:29 -05001217 self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001218 yield self.wait_for_response()
1219
Steve Crooks9b160d72017-03-31 10:48:29 -05001220 # Port 2
1221 # Extended VLAN Tagging Operation config
1222 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102
1223 # TODO: add entry here for additional UNI interfaces
Steve Crooks9e85ce82017-03-20 12:00:53 -04001224 self.send_create_extended_vlan_tagging_operation_configuration_data(0x202, 2, 0x102)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001225 yield self.wait_for_response()
1226
1227 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
Steve Crooks46d64302017-03-10 15:11:06 -05001228 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001229 yield self.wait_for_response()
1230
Steve Crooks46d64302017-03-10 15:11:06 -05001231 # Set AR - ExtendedVlanTaggingOperationConfigData
Steve Crooks9b160d72017-03-31 10:48:29 -05001232 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1233 #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 -04001234 #yield self.wait_for_response()
1235
1236 # Set AR - ExtendedVlanTaggingOperationConfigData
Steve Crooks9b160d72017-03-31 10:48:29 -05001237 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1238 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001239 yield self.wait_for_response()
1240
Steve Crooks9b160d72017-03-31 10:48:29 -05001241 # MAC Bridge Port config
1242 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102
1243 # TODO: add more entries here for other UNI ports
1244 self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 2, 1, 0x102)
1245 yield self.wait_for_response()
1246
1247 # Port 5
1248 # Extended VLAN Tagging Operation config
1249 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102
1250 # TODO: add entry here for additional UNI interfaces
1251 self.send_create_extended_vlan_tagging_operation_configuration_data(0x205, 2, 0x105)
1252 yield self.wait_for_response()
1253
1254 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1255 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x205, 0x8100, 0x8100)
1256 yield self.wait_for_response()
1257
1258 # Set AR - ExtendedVlanTaggingOperationConfigData
1259 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1260 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0, 1, 8, cvid)
1261 #yield self.wait_for_response()
1262
1263 # Set AR - ExtendedVlanTaggingOperationConfigData
1264 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1265 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x205, 0x1000, cvid)
1266 yield self.wait_for_response()
1267
1268 # MAC Bridge Port config
1269 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102
1270 # TODO: add more entries here for other UNI ports
1271 self.send_create_mac_bridge_port_configuration_data(0x205, 0x201, 5, 1, 0x105)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001272 yield self.wait_for_response()
rshettyc26a3c32017-07-27 11:06:38 +05301273
1274 def create_interface(self, data):
1275 self.log.info('Not Implemented yet')
1276 return;
1277
1278 def update_interface(self, data):
1279 self.log.info('Not Implemented yet')
1280 return;
1281
1282 def remove_interface(self, data):
1283 self.log.info('Not Implemented yet')
1284 return;