blob: 44bbe48cfaefbbcfbc6477af12a7653d862d0622 [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
rshetty1cc73982017-09-02 03:31:12 +053040from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig
41
Steve Crooks3c2c7582017-01-10 15:02:26 -060042from common.frameio.frameio import hexify
43from voltha.extensions.omci.omci import *
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080044
Steve Crooks3c2c7582017-01-10 15:02:26 -060045_ = third_party
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080046log = structlog.get_logger()
47
48
49@implementer(IAdapterInterface)
50class BroadcomOnuAdapter(object):
51
52 name = 'broadcom_onu'
53
54 supported_device_types = [
55 DeviceType(
Steve Crooks3c2c7582017-01-10 15:02:26 -060056 id=name,
rshettyc26a3c32017-07-27 11:06:38 +053057 vendor_id='BRCM',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080058 adapter=name,
59 accepts_bulk_flow_update=True
60 )
61 ]
62
63 def __init__(self, adapter_agent, config):
64 self.adapter_agent = adapter_agent
65 self.config = config
66 self.descriptor = Adapter(
67 id=self.name,
68 vendor='Voltha project',
Steve Crooks3c2c7582017-01-10 15:02:26 -060069 version='0.4',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080070 config=AdapterConfig(log_level=LogLevel.INFO)
71 )
Steve Crooks3c2c7582017-01-10 15:02:26 -060072 self.devices_handlers = dict() # device_id -> BroadcomOnuHandler()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080073
Peter Shafik9107f2e2017-05-02 15:54:39 -040074 # register for adapter messages
75 self.adapter_agent.register_for_inter_adapter_messages()
76
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080077 def start(self):
78 log.debug('starting')
79 log.info('started')
80
81 def stop(self):
82 log.debug('stopping')
83 log.info('stopped')
84
85 def adapter_descriptor(self):
86 return self.descriptor
87
88 def device_types(self):
89 return DeviceTypes(items=self.supported_device_types)
90
91 def health(self):
92 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
93
94 def change_master_state(self, master):
95 raise NotImplementedError()
96
97 def adopt_device(self, device):
Steve Crooks3c2c7582017-01-10 15:02:26 -060098 log.info('adopt_device', device_id=device.id)
99 self.devices_handlers[device.proxy_address.channel_id] = BroadcomOnuHandler(self, device.id)
100 reactor.callLater(0, self.devices_handlers[device.proxy_address.channel_id].activate, device)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800101 return device
102
khenaidoo032d3302017-06-09 14:50:04 -0400103 def reconcile_device(self, device):
104 raise NotImplementedError()
105
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800106 def abandon_device(self, device):
107 raise NotImplementedError()
108
Khen Nursimulud068d812017-03-06 11:44:18 -0500109 def disable_device(self, device):
110 raise NotImplementedError()
111
112 def reenable_device(self, device):
113 raise NotImplementedError()
114
115 def reboot_device(self, device):
116 raise NotImplementedError()
117
Lydia Fang01f2e852017-06-28 17:24:58 -0700118 def download_image(self, device, request):
119 raise NotImplementedError()
120
121 def get_image_download_status(self, device, request):
122 raise NotImplementedError()
123
124 def cancel_image_download(self, device, request):
125 raise NotImplementedError()
126
127 def activate_image_update(self, device, request):
128 raise NotImplementedError()
129
130 def revert_image_update(self, device, request):
131 raise NotImplementedError()
132
sathishg5ae86222017-06-28 15:16:29 +0530133 def self_test_device(self, device):
134 """
135 This is called to Self a device based on a NBI call.
136 :param device: A Voltha.Device object.
137 :return: Will return result of self test
138 """
139 log.info('self-test-device', device=device.id)
140 raise NotImplementedError()
141
Khen Nursimulud068d812017-03-06 11:44:18 -0500142 def delete_device(self, device):
143 raise NotImplementedError()
144
145 def get_device_details(self, device):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800146 raise NotImplementedError()
147
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500148 def update_pm_config(self, device, pm_configs):
149 raise NotImplementedError()
150
Steve Crooks3c2c7582017-01-10 15:02:26 -0600151 def update_flows_bulk(self, device, flows, groups):
152 log.info('bulk-flow-update', device_id=device.id,
153 flows=flows, groups=groups)
154 assert len(groups.items) == 0
155 handler = self.devices_handlers[device.proxy_address.channel_id]
Steve Crooksf248e182017-02-07 10:50:24 -0500156 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600157
158 def update_flows_incrementally(self, device, flow_changes, group_changes):
159 raise NotImplementedError()
160
161 def send_proxied_message(self, proxy_address, msg):
162 log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
163
164 def receive_proxied_message(self, proxy_address, msg):
165 log.info('receive-proxied-message', proxy_address=proxy_address,
166 device_id=proxy_address.device_id, msg=hexify(msg))
167 handler = self.devices_handlers[proxy_address.channel_id]
168 handler.receive_message(msg)
169
170 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
171 log.info('packet-out', logical_device_id=logical_device_id,
172 egress_port_no=egress_port_no, msg_len=len(msg))
173
Peter Shafik9107f2e2017-05-02 15:54:39 -0400174 def receive_inter_adapter_message(self, msg):
175 log.info('receive_inter_adapter_message', msg=msg)
Peter Shafikd7f33772017-05-17 13:56:34 -0400176 proxy_address = msg['proxy_address']
177 assert proxy_address is not None
178
rshettyc26a3c32017-07-27 11:06:38 +0530179 if proxy_address.channel_id in self.devices_handlers:
180 handler = self.devices_handlers[proxy_address.channel_id]
181 if handler is not None:
182 handler.event_messages.put(msg)
Peter Shafik9107f2e2017-05-02 15:54:39 -0400183
Nikolay Titov89004ec2017-06-19 18:22:42 -0400184 def create_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530185 log.info('create-interface', device_id=device.id)
186 if device.proxy_address.channel_id in self.devices_handlers:
187 handler = self.devices_handlers[device.proxy_address.channel_id]
188 if handler is not None:
189 handler.create_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400190
191 def update_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530192 log.info('update-interface', device_id=device.id)
193 if device.proxy_address.channel_id in self.devices_handlers:
194 handler = self.devices_handlers[device.proxy_address.channel_id]
195 if handler is not None:
196 handler.update_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400197
198 def remove_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530199 log.info('remove-interface', device_id=device.id)
200 if device.proxy_address.channel_id in self.devices_handlers:
201 handler = self.devices_handlers[device.proxy_address.channel_id]
202 if handler is not None:
203 handler.remove_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400204
205 def receive_onu_detect_state(self, device_id, state):
206 raise NotImplementedError()
207
Nikolay Titov176f1db2017-08-10 12:38:43 -0400208 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
rshetty1cc73982017-09-02 03:31:12 +0530209 log.info('Not implemented Yet', device_id=device.id)
210 #raise NotImplementedError()
Nikolay Titov176f1db2017-08-10 12:38:43 -0400211
212 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
213 raise NotImplementedError()
214
215 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
216 raise NotImplementedError()
217
218 def create_gemport(self, device, data):
rshetty1cc73982017-09-02 03:31:12 +0530219 log.info('Not implemented Yet', device_id=device.id)
220 #raise NotImplementedError()
Nikolay Titov176f1db2017-08-10 12:38:43 -0400221
222 def update_gemport(self, device, data):
223 raise NotImplementedError()
224
225 def remove_gemport(self, device, data):
226 raise NotImplementedError()
227
228 def create_multicast_gemport(self, device, data):
229 raise NotImplementedError()
230
231 def update_multicast_gemport(self, device, data):
232 raise NotImplementedError()
233
234 def remove_multicast_gemport(self, device, data):
235 raise NotImplementedError()
236
237 def create_multicast_distribution_set(self, device, data):
238 raise NotImplementedError()
239
240 def update_multicast_distribution_set(self, device, data):
241 raise NotImplementedError()
242
243 def remove_multicast_distribution_set(self, device, data):
244 raise NotImplementedError()
245
246 def suppress_alarm(self, filter):
247 raise NotImplementedError()
248
Stephane Barbarie980a0912017-05-11 11:27:06 -0400249 def unsuppress_alarm(self, filter):
250 raise NotImplementedError()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600251
252class BroadcomOnuHandler(object):
253
254 def __init__(self, adapter, device_id):
255 self.adapter = adapter
256 self.adapter_agent = adapter.adapter_agent
257 self.device_id = device_id
258 self.log = structlog.get_logger(device_id=device_id)
259 self.incoming_messages = DeferredQueue()
Peter Shafikd7f33772017-05-17 13:56:34 -0400260 self.event_messages = DeferredQueue()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600261 self.proxy_address = None
262 self.tx_id = 0
263
Peter Shafikd7f33772017-05-17 13:56:34 -0400264 # Need to query ONU for number of supported uni ports
265 # For now, temporarily set number of ports to 1 - port #2
266 self.uni_ports = (2,)
267
268 # Handle received ONU event messages
269 reactor.callLater(0, self.handle_onu_events)
270
Steve Crooks3c2c7582017-01-10 15:02:26 -0600271 def receive_message(self, msg):
272 self.incoming_messages.put(msg)
273
Peter Shafikd7f33772017-05-17 13:56:34 -0400274 @inlineCallbacks
275 def handle_onu_events(self):
276 event_msg = yield self.event_messages.get()
277
278 if event_msg['event'] == 'activation-completed':
279
280 if event_msg['event_data']['activation_successful'] == True:
281 for uni in self.uni_ports:
282 port_no = self.proxy_address.channel_id + uni
283 reactor.callLater(1,
284 self.message_exchange,
285 self.proxy_address.onu_id,
286 self.proxy_address.onu_session_id,
287 port_no)
288
289 device = self.adapter_agent.get_device(self.device_id)
290 device.oper_status = OperStatus.ACTIVE
291 self.adapter_agent.update_device(device)
292
293 else:
294 device = self.adapter_agent.get_device(self.device_id)
295 device.oper_status = OperStatus.FAILED
296 self.adapter_agent.update_device(device)
297
298 elif event_msg['event'] == 'deactivation-completed':
299 device = self.adapter_agent.get_device(self.device_id)
300 device.oper_status = OperStatus.DISCOVERED
301 self.adapter_agent.update_device(device)
302
303 elif event_msg['event'] == 'ranging-completed':
304
305 if event_msg['event_data']['ranging_successful'] == True:
306 device = self.adapter_agent.get_device(self.device_id)
307 device.oper_status = OperStatus.ACTIVATING
308 self.adapter_agent.update_device(device)
309
310 else:
311 device = self.adapter_agent.get_device(self.device_id)
312 device.oper_status = OperStatus.FAILED
313 self.adapter_agent.update_device(device)
314
315 # Handle next event
316 reactor.callLater(0, self.handle_onu_events)
317
318
Steve Crooks3c2c7582017-01-10 15:02:26 -0600319 def activate(self, device):
320 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800321
322 # first we verify that we got parent reference and proxy info
323 assert device.parent_id
324 assert device.proxy_address.device_id
Steve Crooks9b160d72017-03-31 10:48:29 -0500325 #assert device.proxy_address.channel_id # c-vid
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800326
Steve Crooks3c2c7582017-01-10 15:02:26 -0600327 # register for proxied messages right away
328 self.proxy_address = device.proxy_address
329 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
330
Peter Shafik9107f2e2017-05-02 15:54:39 -0400331
Steve Crooks3c2c7582017-01-10 15:02:26 -0600332 # populate device info
333 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800334 device.vendor = 'Broadcom'
Steve Crooks9e85ce82017-03-20 12:00:53 -0400335 device.model = 'n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800336 device.hardware_version = 'to be filled'
337 device.firmware_version = 'to be filled'
ggowdru236bd952017-06-20 20:32:55 -0700338 device.images.image.extend([
339 Image(version="to be filled")
340 ])
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800341 device.connect_status = ConnectStatus.REACHABLE
342 self.adapter_agent.update_device(device)
343
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800344 self.adapter_agent.add_port(device.id, Port(
Steve Crooks9b160d72017-03-31 10:48:29 -0500345 port_no=100,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800346 label='PON port',
347 type=Port.PON_ONU,
348 admin_state=AdminState.ENABLED,
349 oper_status=OperStatus.ACTIVE,
350 peers=[
351 Port.PeerPort(
352 device_id=device.parent_id,
353 port_no=device.parent_port_no
354 )
355 ]
356 ))
357
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800358 parent_device = self.adapter_agent.get_device(device.parent_id)
359 logical_device_id = parent_device.parent_id
360 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800361
Peter Shafikd7f33772017-05-17 13:56:34 -0400362 for uni in self.uni_ports:
Steve Crooks9b160d72017-03-31 10:48:29 -0500363 # register physical ports
364 uni_port = Port(
365 port_no=uni,
366 label='UNI facing Ethernet port '+str(uni),
367 type=Port.ETHERNET_UNI,
368 admin_state=AdminState.ENABLED,
369 oper_status=OperStatus.ACTIVE
370 )
371 self.adapter_agent.add_port(device.id, uni_port)
372
373 # add uni port to logical device
374 port_no = device.proxy_address.channel_id + uni
375 cap = OFPPF_1GB_FD | OFPPF_FIBER
376 self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
377 id='uni-{}'.format(port_no),
378 ofp_port=ofp_port(
379 port_no=port_no,
380 hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' %
381 (device.proxy_address.onu_id & 0xff,
382 (port_no >> 8) & 0xff,
383 port_no & 0xff)),
384 name='uni-{}'.format(port_no),
385 config=0,
386 state=OFPPS_LIVE,
387 curr=cap,
388 advertised=cap,
389 peer=cap,
390 curr_speed=OFPPF_1GB_FD,
391 max_speed=OFPPF_1GB_FD
392 ),
393 device_id=device.id,
394 device_port_no=uni_port.port_no
395 ))
396
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800397 device = self.adapter_agent.get_device(device.id)
Peter Shafikd7f33772017-05-17 13:56:34 -0400398 device.oper_status = OperStatus.DISCOVERED
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800399 self.adapter_agent.update_device(device)
400
Steve Crooks3c2c7582017-01-10 15:02:26 -0600401 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500402 def update_flow_table(self, device, flows):
403 #
404 # We need to proxy through the OLT to get to the ONU
405 # Configuration from here should be using OMCI
406 #
407 self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800408
Steve Crooksf248e182017-02-07 10:50:24 -0500409 def is_downstream(port):
Steve Crooks9b160d72017-03-31 10:48:29 -0500410 return port == 100 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800411
Steve Crooksf248e182017-02-07 10:50:24 -0500412 def is_upstream(port):
413 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800414
Steve Crooksf248e182017-02-07 10:50:24 -0500415 for flow in flows:
Steve Crooks9b160d72017-03-31 10:48:29 -0500416 _type = None
417 _port = None
418 _vlan_vid = None
419 _udp_dst = None
420 _udp_src = None
421 _ipv4_dst = None
422 _ipv4_src = None
423 _metadata = None
424 _output = None
425 _push_tpid = None
426 _field = None
427 _set_vlan_vid = None
Steve Crooksf248e182017-02-07 10:50:24 -0500428 try:
429 _in_port = fd.get_in_port(flow)
430 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600431
Steve Crooksf248e182017-02-07 10:50:24 -0500432 if is_downstream(_in_port):
433 self.log.info('downstream-flow')
434 elif is_upstream(_in_port):
435 self.log.info('upstream-flow')
436 else:
437 raise Exception('port should be 1 or 2 by our convention')
438
439 _out_port = fd.get_out_port(flow) # may be None
440 self.log.info('out-port', out_port=_out_port)
441
442 for field in fd.get_ofb_fields(flow):
443 if field.type == fd.ETH_TYPE:
444 _type = field.eth_type
445 self.log.info('field-type-eth-type',
446 eth_type=_type)
447
448 elif field.type == fd.IP_PROTO:
449 _proto = field.ip_proto
450 self.log.info('field-type-ip-proto',
451 ip_proto=_proto)
452
453 elif field.type == fd.IN_PORT:
454 _port = field.port
455 self.log.info('field-type-in-port',
456 in_port=_port)
457
458 elif field.type == fd.VLAN_VID:
459 _vlan_vid = field.vlan_vid & 0xfff
460 self.log.info('field-type-vlan-vid',
461 vlan=_vlan_vid)
462
463 elif field.type == fd.VLAN_PCP:
464 _vlan_pcp = field.vlan_pcp
465 self.log.info('field-type-vlan-pcp',
466 pcp=_vlan_pcp)
467
468 elif field.type == fd.UDP_DST:
469 _udp_dst = field.udp_dst
470 self.log.info('field-type-udp-dst',
471 udp_dst=_udp_dst)
472
473 elif field.type == fd.UDP_SRC:
474 _udp_src = field.udp_src
475 self.log.info('field-type-udp-src',
476 udp_src=_udp_src)
477
478 elif field.type == fd.IPV4_DST:
479 _ipv4_dst = field.ipv4_dst
480 self.log.info('field-type-ipv4-dst',
481 ipv4_dst=_ipv4_dst)
482
483 elif field.type == fd.IPV4_SRC:
484 _ipv4_src = field.ipv4_src
485 self.log.info('field-type-ipv4-src',
486 ipv4_dst=_ipv4_src)
487
488 elif field.type == fd.METADATA:
Steve Crooks9b160d72017-03-31 10:48:29 -0500489 _metadata = field.table_metadata
Steve Crooksf248e182017-02-07 10:50:24 -0500490 self.log.info('field-type-metadata',
491 metadata=_metadata)
492
493 else:
494 raise NotImplementedError('field.type={}'.format(
495 field.type))
496
497 for action in fd.get_actions(flow):
498
499 if action.type == fd.OUTPUT:
500 _output = action.output.port
501 self.log.info('action-type-output',
502 output=_output, in_port=_in_port)
503
504 elif action.type == fd.POP_VLAN:
505 self.log.info('action-type-pop-vlan',
506 in_port=_in_port)
507
508 elif action.type == fd.PUSH_VLAN:
509 _push_tpid = action.push.ethertype
510 log.info('action-type-push-vlan',
511 push_tpid=_push_tpid, in_port=_in_port)
512 if action.push.ethertype != 0x8100:
513 self.log.error('unhandled-tpid',
514 ethertype=action.push.ethertype)
515
516 elif action.type == fd.SET_FIELD:
517 _field = action.set_field.field.ofb_field
518 assert (action.set_field.field.oxm_class ==
519 OFPXMC_OPENFLOW_BASIC)
520 self.log.info('action-type-set-field',
521 field=_field, in_port=_in_port)
522 if _field.type == fd.VLAN_VID:
Steve Crooks9b160d72017-03-31 10:48:29 -0500523 _set_vlan_vid = _field.vlan_vid & 0xfff
524 self.log.info('set-field-type-valn-vid', _set_vlan_vid)
Steve Crooksf248e182017-02-07 10:50:24 -0500525 else:
526 self.log.error('unsupported-action-set-field-type',
527 field_type=_field.type)
528 else:
529 log.error('unsupported-action-type',
530 action_type=action.type, in_port=_in_port)
531
532 #
533 # All flows created from ONU adapter should be OMCI based
534 #
Steve Crooks9b160d72017-03-31 10:48:29 -0500535 if _vlan_vid == 0:
536 # allow priority tagged packets
537 # Set AR - ExtendedVlanTaggingOperationConfigData
538 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
539 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0,
540 1, 8, _in_port)
541 yield self.wait_for_response()
542
543 # Set AR - ExtendedVlanTaggingOperationConfigData
544 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
545 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0,
546 1, 8, _in_port)
547 yield self.wait_for_response()
Steve Crooksf248e182017-02-07 10:50:24 -0500548
549 except Exception as e:
550 log.exception('failed-to-install-flow', e=e, flow=flow)
551
Steve Crooks3c2c7582017-01-10 15:02:26 -0600552 def get_tx_id(self):
553 self.tx_id += 1
554 return self.tx_id
555
556 def send_omci_message(self, frame):
557 _frame = hexify(str(frame))
558 self.log.info('send-omci-message-%s' % _frame)
559 device = self.adapter_agent.get_device(self.device_id)
560 try:
561 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
562 except Exception as e:
563 self.log.info('send-omci-message-exception', exc=str(e))
564
565 def send_get_circuit_pack(self, entity_id=0):
566 frame = OmciFrame(
567 transaction_id=self.get_tx_id(),
568 message_type=OmciGet.message_id,
569 omci_message=OmciGet(
570 entity_class=CircuitPack.class_id,
571 entity_id=entity_id,
572 attributes_mask=CircuitPack.mask_for('vendor_id')
573 )
574 )
575 self.send_omci_message(frame)
576
577 def send_mib_reset(self, entity_id=0):
578 frame = OmciFrame(
579 transaction_id=self.get_tx_id(),
580 message_type=OmciMibReset.message_id,
581 omci_message=OmciMibReset(
582 entity_class=OntData.class_id,
583 entity_id=entity_id
584 )
585 )
586 self.send_omci_message(frame)
587
Steve Crooks9e85ce82017-03-20 12:00:53 -0400588 def send_create_gal_ethernet_profile(self,
589 entity_id,
590 max_gem_payload_size):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600591 frame = OmciFrame(
592 transaction_id=self.get_tx_id(),
593 message_type=OmciCreate.message_id,
594 omci_message=OmciCreate(
595 entity_class=GalEthernetProfile.class_id,
596 entity_id=entity_id,
597 data=dict(
598 max_gem_payload_size=max_gem_payload_size
599 )
600 )
601 )
602 self.send_omci_message(frame)
603
Steve Crooks9e85ce82017-03-20 12:00:53 -0400604 def send_set_tcont(self,
605 entity_id,
606 alloc_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600607 data = dict(
608 alloc_id=alloc_id
609 )
610 frame = OmciFrame(
611 transaction_id=self.get_tx_id(),
612 message_type=OmciSet.message_id,
613 omci_message=OmciSet(
614 entity_class=Tcont.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400615 entity_id=entity_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600616 attributes_mask=Tcont.mask_for(*data.keys()),
617 data=data
618 )
619 )
620 self.send_omci_message(frame)
621
Steve Crooks9e85ce82017-03-20 12:00:53 -0400622 def send_create_8021p_mapper_service_profile(self,
623 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600624 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400625 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600626 message_type=OmciCreate.message_id,
627 omci_message=OmciCreate(
628 entity_class=Ieee8021pMapperServiceProfile.class_id,
629 entity_id=entity_id,
630 data=dict(
631 tp_pointer=OmciNullPointer,
632 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
Steve Crooks9b160d72017-03-31 10:48:29 -0500633 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
634 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
635 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
636 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
637 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
638 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
639 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
Steve Crooks3c2c7582017-01-10 15:02:26 -0600640 )
641 )
642 )
643 self.send_omci_message(frame)
644
Steve Crooks9e85ce82017-03-20 12:00:53 -0400645 def send_create_mac_bridge_service_profile(self,
646 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600647 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400648 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600649 message_type=OmciCreate.message_id,
650 omci_message=OmciCreate(
651 entity_class=MacBridgeServiceProfile.class_id,
652 entity_id=entity_id,
653 data=dict(
654 spanning_tree_ind=False,
655 learning_ind=True,
656 priority=0x8000,
657 max_age=20 * 256,
658 hello_time=2 * 256,
659 forward_delay=15 * 256,
660 unknown_mac_address_discard=True
661 )
662 )
663 )
664 self.send_omci_message(frame)
665
Steve Crooks9e85ce82017-03-20 12:00:53 -0400666 def send_create_gem_port_network_ctp(self,
667 entity_id,
668 port_id,
669 tcont_id,
670 direction,
671 tm):
672 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
673 if _directions.has_key(direction):
674 _direction = _directions[direction]
675 else:
676 self.log.error('invalid-gem-port-direction', direction=direction)
677 raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction))
678
Steve Crooks3c2c7582017-01-10 15:02:26 -0600679 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400680 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600681 message_type=OmciCreate.message_id,
682 omci_message=OmciCreate(
683 entity_class=GemPortNetworkCtp.class_id,
684 entity_id=entity_id,
685 data=dict(
686 port_id=port_id,
687 tcont_pointer=tcont_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400688 direction=_direction,
689 traffic_management_pointer_upstream=tm
Steve Crooks3c2c7582017-01-10 15:02:26 -0600690 )
691 )
692 )
693 self.send_omci_message(frame)
694
Steve Crooks9e85ce82017-03-20 12:00:53 -0400695 def send_create_multicast_gem_interworking_tp(self,
696 entity_id,
697 gem_port_net_ctp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600698 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400699 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600700 message_type=OmciCreate.message_id,
701 omci_message=OmciCreate(
702 entity_class=MulticastGemInterworkingTp.class_id,
703 entity_id=entity_id,
704 data=dict(
705 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
706 interworking_option=0,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400707 service_profile_pointer=0x1
Steve Crooks3c2c7582017-01-10 15:02:26 -0600708 )
709 )
710 )
711 self.send_omci_message(frame)
712
Steve Crooks9e85ce82017-03-20 12:00:53 -0400713 def send_create_gem_inteworking_tp(self,
714 entity_id,
715 gem_port_net_ctp_id,
716 service_profile_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600717 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400718 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600719 message_type=OmciCreate.message_id,
720 omci_message=OmciCreate(
721 entity_class=GemInterworkingTp.class_id,
722 entity_id=entity_id,
723 data=dict(
724 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
725 interworking_option=5,
726 service_profile_pointer=service_profile_id,
727 interworking_tp_pointer=0x0,
728 gal_profile_pointer=0x1
729 )
730 )
731 )
732 self.send_omci_message(frame)
733
Steve Crooks9e85ce82017-03-20 12:00:53 -0400734 def send_set_8021p_mapper_service_profile(self,
735 entity_id,
736 interwork_tp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600737 data = dict(
Steve Crooks9b160d72017-03-31 10:48:29 -0500738 interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id,
739 interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id,
740 interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id,
741 interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id,
742 interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id,
743 interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id,
744 interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id,
745 interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600746 )
747 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400748 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600749 message_type=OmciSet.message_id,
750 omci_message=OmciSet(
751 entity_class=Ieee8021pMapperServiceProfile.class_id,
752 entity_id=entity_id,
753 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
754 *data.keys()),
755 data=data
756 )
757 )
758 self.send_omci_message(frame)
759
760 def send_create_mac_bridge_port_configuration_data(self,
761 entity_id,
762 bridge_id,
763 port_id,
764 tp_type,
765 tp_id):
766 frame = OmciFrame(
767 transaction_id=self.get_tx_id(),
768 message_type=OmciCreate.message_id,
769 omci_message=OmciCreate(
770 entity_class=MacBridgePortConfigurationData.class_id,
771 entity_id=entity_id,
772 data=dict(
773 bridge_id_pointer = bridge_id,
774 port_num=port_id,
775 tp_type=tp_type,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400776 tp_pointer=tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600777 )
778 )
779 )
780 self.send_omci_message(frame)
781
Steve Crooks9e85ce82017-03-20 12:00:53 -0400782 def send_create_vlan_tagging_filter_data(self,
783 entity_id,
784 vlan_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600785 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400786 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600787 message_type=OmciCreate.message_id,
788 omci_message=OmciCreate(
789 entity_class=VlanTaggingFilterData.class_id,
790 entity_id=entity_id,
791 data=dict(
792 vlan_filter_0=vlan_id,
793 forward_operation=0x10,
794 number_of_entries=1
795 )
796 )
797 )
798 self.send_omci_message(frame)
799
Steve Crooks46d64302017-03-10 15:11:06 -0500800 def send_create_extended_vlan_tagging_operation_configuration_data(self,
801 entity_id,
802 assoc_type,
803 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600804 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400805 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600806 message_type=OmciCreate.message_id,
807 omci_message=OmciCreate(
808 entity_class=
809 ExtendedVlanTaggingOperationConfigurationData.class_id,
810 entity_id=entity_id,
811 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500812 association_type=assoc_type,
813 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600814 )
815 )
816 )
817 self.send_omci_message(frame)
818
Steve Crooks9e85ce82017-03-20 12:00:53 -0400819 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self,
820 entity_id,
821 input_tpid,
822 output_tpid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600823 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400824 input_tpid=input_tpid,
825 output_tpid=output_tpid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600826 downstream_mode=0, # inverse of upstream
827 )
828 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400829 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600830 message_type=OmciSet.message_id,
831 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400832 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600833 ExtendedVlanTaggingOperationConfigurationData.class_id,
834 entity_id=entity_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400835 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600836 ExtendedVlanTaggingOperationConfigurationData.mask_for(
837 *data.keys()),
838 data=data
839 )
840 )
841 self.send_omci_message(frame)
842
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400843 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
844 entity_id,
845 filter_inner_vid,
846 treatment_inner_vid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600847 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400848 received_frame_vlan_tagging_operation_table=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600849 VlanTaggingOperation(
850 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500851 filter_outer_vid=4096,
852 filter_outer_tpid_de=0,
853
854 filter_inner_priority=15,
855 filter_inner_vid=filter_inner_vid,
856 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600857 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -0500858
859 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600860 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500861 treatment_outer_vid=0,
862 treatment_outer_tpid_de=0,
863
864 treatment_inner_priority=0,
865 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600866 treatment_inner_tpid_de=4
867 )
868 )
869 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400870 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600871 message_type=OmciSet.message_id,
872 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400873 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600874 ExtendedVlanTaggingOperationConfigurationData.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400875 entity_id=entity_id,
876 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600877 ExtendedVlanTaggingOperationConfigurationData.mask_for(
878 *data.keys()),
879 data=data
880 )
881 )
882 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800883
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400884 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
885 entity_id,
886 filter_inner_priority,
887 filter_inner_vid,
888 filter_inner_tpid_de,
889 treatment_tags_to_remove,
890 treatment_inner_priority,
891 treatment_inner_vid):
892 data = dict(
893 received_frame_vlan_tagging_operation_table=
894 VlanTaggingOperation(
895 filter_outer_priority=15,
896 filter_outer_vid=4096,
897 filter_outer_tpid_de=0,
898
899 filter_inner_priority=filter_inner_priority,
900 filter_inner_vid=filter_inner_vid,
901 filter_inner_tpid_de=filter_inner_tpid_de,
902 filter_ether_type=0,
903
904 treatment_tags_to_remove=treatment_tags_to_remove,
905 treatment_outer_priority=15,
906 treatment_outer_vid=0,
907 treatment_outer_tpid_de=0,
908
909 treatment_inner_priority=treatment_inner_priority,
910 treatment_inner_vid=treatment_inner_vid,
911 treatment_inner_tpid_de=4
912 )
913 )
914 frame = OmciFrame(
915 transaction_id=self.get_tx_id(),
916 message_type=OmciSet.message_id,
917 omci_message=OmciSet(
918 entity_class=
919 ExtendedVlanTaggingOperationConfigurationData.class_id,
920 entity_id=entity_id,
921 attributes_mask=
922 ExtendedVlanTaggingOperationConfigurationData.mask_for(
923 *data.keys()),
924 data=data
925 )
926 )
927 self.send_omci_message(frame)
928
Steve Crooks9e85ce82017-03-20 12:00:53 -0400929 def send_create_multicast_operations_profile(self,
930 entity_id,
931 igmp_ver):
932 frame = OmciFrame(
933 transaction_id=self.get_tx_id(),
934 message_type=OmciCreate.message_id,
935 omci_message=OmciCreate(
936 entity_class=
937 MulticastOperationsProfile.class_id,
938 entity_id=entity_id,
939 data=dict(
940 igmp_version=igmp_ver,
941 igmp_function=0,
942 immediate_leave=0
943 )
944 )
945 )
946 self.send_omci_message(frame)
947
948 def send_set_multicast_operations_profile_acl_row0(self,
949 entity_id,
950 acl_table,
951 row_key,
952 gem_port,
953 vlan,
954 src_ip,
955 dst_ip_start,
956 dst_ip_end):
957 row0 = AccessControlRow0(
958 set_ctrl=1,
959 row_part_id=0,
960 test=0,
961 row_key=row_key,
962 gem_port_id=gem_port,
963 vlan_id=vlan,
964 src_ip=src_ip,
965 dst_ip_start=dst_ip_start,
966 dst_ip_end=dst_ip_end,
967 ipm_group_bw=0
968 )
969
970 if acl_table == 'dynamic':
971 data = dict(
972 dynamic_access_control_list_table=row0
973 )
974 else:
975 data = dict(
976 static_access_control_list_table=row0
977 )
978
979 frame = OmciFrame(
980 transaction_id=self.get_tx_id(),
981 message_type=OmciSet.message_id,
982 omci_message=OmciSet(
983 entity_class=MulticastOperationsProfile.class_id,
984 entity_id=entity_id,
985 attributes_mask=MulticastOperationsProfile.mask_for(
986 *data.keys()),
987 data=data
988 )
989 )
990 self.send_omci_message(frame)
991
992 def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self,
993 entity_id,
994 ctrl_type,
995 tci):
996 data = dict(
997 ds_igmp_mcast_tci=
998 DownstreamIgmpMulticastTci(
999 ctrl_type=ctrl_type,
1000 tci=tci
1001 )
1002 )
1003 frame = OmciFrame(
1004 transaction_id=self.get_tx_id(),
1005 message_type=OmciSet.message_id,
1006 omci_message=OmciSet(
1007 entity_class=MulticastOperationsProfile.class_id,
1008 entity_id=entity_id,
1009 attributes_mask=MulticastOperationsProfile.mask_for(
1010 *data.keys()),
1011 data=data
1012 )
1013 )
1014 self.send_omci_message(frame)
1015
1016 def send_create_multicast_subscriber_config_info(self,
1017 entity_id,
1018 me_type,
1019 mcast_oper_profile):
1020 frame = OmciFrame(
1021 transaction_id=self.get_tx_id(),
1022 message_type=OmciCreate.message_id,
1023 omci_message=OmciCreate(
1024 entity_class=
1025 MulticastSubscriberConfigInfo.class_id,
1026 entity_id=entity_id,
1027 data=dict(
1028 me_type=me_type,
1029 mcast_operations_profile_pointer=mcast_oper_profile
1030 )
1031 )
1032 )
1033 self.send_omci_message(frame)
1034
1035 def send_set_multicast_subscriber_config_info(self,
1036 entity_id,
1037 max_groups=0,
1038 max_mcast_bw=0,
1039 bw_enforcement=0):
1040 data = dict(
1041 max_simultaneous_groups=max_groups,
1042 max_multicast_bandwidth=max_mcast_bw,
1043 bandwidth_enforcement=bw_enforcement
1044 )
1045 frame = OmciFrame(
1046 transaction_id=self.get_tx_id(),
1047 message_type=OmciSet.message_id,
1048 omci_message=OmciSet(
1049 entity_class=MulticastSubscriberConfigInfo.class_id,
1050 entity_id=entity_id,
1051 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1052 *data.keys()),
1053 data=data
1054 )
1055 )
1056 self.send_omci_message(frame)
1057
1058 def send_set_multicast_service_package(self,
1059 entity_id,
1060 row_key,
1061 vid_uni,
1062 max_groups,
1063 max_mcast_bw,
1064 mcast_oper_profile):
1065 data = dict(
1066 multicast_service_package_table=
1067 MulticastServicePackage(
1068 set_ctrl=1,
1069 row_key=row_key,
1070
1071 vid_uni=vid_uni,
1072 max_simultaneous_groups=max_groups,
1073 max_multicast_bw=max_mcast_bw,
1074 mcast_operations_profile_pointer=mcast_oper_profile
1075 )
1076 )
1077 frame = OmciFrame(
1078 transaction_id=self.get_tx_id(),
1079 message_type=OmciSet.message_id,
1080 omci_message=OmciSet(
1081 entity_class=MulticastSubscriberConfigInfo.class_id,
1082 entity_id=entity_id,
1083 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1084 *data.keys()),
1085 data=data
1086 )
1087 )
1088 self.send_omci_message(frame)
1089
1090 def send_set_multicast_allowed_preview_groups_row0(self,
1091 entity_id,
1092 row_key,
1093 src_ip,
1094 vlan_id_ani,
1095 vlan_id_uni):
1096 data = dict(
1097 allowed_preview_groups_table=
1098 AllowedPreviewGroupsRow0(
1099 set_ctrl=1,
1100 row_part_id=0,
1101 row_key=row_key,
1102
1103 src_ip=src_ip,
1104 vlan_id_ani=vlan_id_ani,
1105 vlan_id_uni=vlan_id_uni
1106 )
1107 )
1108 frame = OmciFrame(
1109 transaction_id=self.get_tx_id(),
1110 message_type=OmciSet.message_id,
1111 omci_message=OmciSet(
1112 entity_class=MulticastSubscriberConfigInfo.class_id,
1113 entity_id=entity_id,
1114 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1115 *data.keys()),
1116 data=data
1117 )
1118 )
1119 self.send_omci_message(frame)
1120
1121 def send_set_multicast_allowed_preview_groups_row1(self,
1122 entity_id,
1123 row_key,
1124 dst_ip,
1125 duration,
1126 time_left):
1127 data = dict(
1128 allowed_preview_groups_table=
1129 AllowedPreviewGroupsRow1(
1130 set_ctrl=1,
1131 row_part_id=1,
1132 row_key=row_key,
1133
1134 dst_ip=dst_ip,
1135 duration=duration,
1136 time_left=time_left
1137 )
1138 )
1139 frame = OmciFrame(
1140 transaction_id=self.get_tx_id(),
1141 message_type=OmciSet.message_id,
1142 omci_message=OmciSet(
1143 entity_class=MulticastSubscriberConfigInfo.class_id,
1144 entity_id=entity_id,
1145 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1146 *data.keys()),
1147 data=data
1148 )
1149 )
1150 self.send_omci_message(frame)
1151
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001152 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -06001153 def wait_for_response(self):
1154 log.info('wait-for-response')
1155 try:
1156 response = yield self.incoming_messages.get()
Steve Crooks9e85ce82017-03-20 12:00:53 -04001157 log.info('got-response')
1158 # resp = OmciFrame(response)
1159 # resp.show()
Steve Crooks3c2c7582017-01-10 15:02:26 -06001160 except Exception as e:
1161 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001162
Steve Crooks3c2c7582017-01-10 15:02:26 -06001163 @inlineCallbacks
Steve Crooks9b160d72017-03-31 10:48:29 -05001164 def message_exchange(self, onu, gem, cvid):
1165 log.info('message_exchange', onu=onu, gem=gem, cvid=cvid)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001166 # reset incoming message queue
1167 while self.incoming_messages.pending:
1168 _ = yield self.incoming_messages.get()
1169
Steve Crooks9b160d72017-03-31 10:48:29 -05001170 tcont = gem
1171
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001172 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -06001173 # MIB Reset - OntData - 0
1174 self.send_mib_reset()
1175 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001176
Steve Crooks3c2c7582017-01-10 15:02:26 -06001177 # Create AR - GalEthernetProfile - 1
1178 self.send_create_gal_ethernet_profile(1, 48)
1179 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001180
Steve Crooks9b160d72017-03-31 10:48:29 -05001181 # TCONT config
1182 # Set AR - TCont - 32769 - (1025 or 1026)
1183 self.send_set_tcont(0x8001, tcont)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001184 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001185
Steve Crooks9b160d72017-03-31 10:48:29 -05001186 # Mapper Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001187 # Create AR - 802.1pMapperServiceProfile - 32769
1188 self.send_create_8021p_mapper_service_profile(0x8001)
1189 yield self.wait_for_response()
1190
Steve Crooks9b160d72017-03-31 10:48:29 -05001191 # MAC Bridge Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001192 # Create AR - MacBridgeServiceProfile - 513
1193 self.send_create_mac_bridge_service_profile(0x201)
1194 yield self.wait_for_response()
1195
Steve Crooks9b160d72017-03-31 10:48:29 -05001196 # GEM Port Network CTP config
1197 # Create AR - GemPortNetworkCtp - 257 - <gem> - 32769
1198 self.send_create_gem_port_network_ctp(0x101, gem, 0x8001, "bi-directional", 0x100)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001199 yield self.wait_for_response()
1200
1201 # Create AR - GemPortNetworkCtp - 260 - 4000 - 0
1202 self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001203 yield self.wait_for_response()
1204
Steve Crooks9b160d72017-03-31 10:48:29 -05001205 # Multicast GEM Interworking config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001206 # Create AR - MulticastGemInterworkingTp - 6 - 260
1207 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
1208 yield self.wait_for_response()
1209
Steve Crooks9b160d72017-03-31 10:48:29 -05001210 # GEM Interworking config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001211 # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1
1212 self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001)
1213 yield self.wait_for_response()
1214
Steve Crooks9b160d72017-03-31 10:48:29 -05001215 # Mapper Service Profile config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001216 # Set AR - 802.1pMapperServiceProfile - 32769 - 32770
1217 self.send_set_8021p_mapper_service_profile(0x8001, 0x8002)
1218 yield self.wait_for_response()
1219
Steve Crooks9b160d72017-03-31 10:48:29 -05001220 # MAC Bridge Port config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001221 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
1222 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
1223 yield self.wait_for_response()
1224
Steve Crooks3c2c7582017-01-10 15:02:26 -06001225 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
1226 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
1227 yield self.wait_for_response()
1228
Steve Crooks9b160d72017-03-31 10:48:29 -05001229 # VLAN Tagging Filter config
1230 # Create AR - VlanTaggingFilterData - 8450 - c-vid
1231 self.send_create_vlan_tagging_filter_data(0x2102, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001232 yield self.wait_for_response()
1233
Steve Crooks9b160d72017-03-31 10:48:29 -05001234 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001235 # Create AR - MulticastOperationsProfile
1236 self.send_create_multicast_operations_profile(0x201, 3)
1237 yield self.wait_for_response()
1238
1239 # Set AR - MulticastOperationsProfile - Dynamic Access Control List table
1240 self.send_set_multicast_operations_profile_acl_row0(0x201,
1241 'dynamic',
1242 0,
1243 0x0fa0,
1244 0x0fa0,
1245 '0.0.0.0',
1246 '224.0.0.0',
1247 '239.255.255.255')
1248 yield self.wait_for_response()
1249
Steve Crooks9b160d72017-03-31 10:48:29 -05001250 # Multicast Subscriber config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001251 # Create AR - MulticastSubscriberConfigInfo
1252 self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201)
1253 yield self.wait_for_response()
1254
Steve Crooks9b160d72017-03-31 10:48:29 -05001255 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001256 # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI
Steve Crooks9b160d72017-03-31 10:48:29 -05001257 self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001258 yield self.wait_for_response()
1259
Steve Crooks9b160d72017-03-31 10:48:29 -05001260 # Port 2
1261 # Extended VLAN Tagging Operation config
1262 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102
1263 # TODO: add entry here for additional UNI interfaces
Steve Crooks9e85ce82017-03-20 12:00:53 -04001264 self.send_create_extended_vlan_tagging_operation_configuration_data(0x202, 2, 0x102)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001265 yield self.wait_for_response()
1266
1267 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
Steve Crooks46d64302017-03-10 15:11:06 -05001268 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001269 yield self.wait_for_response()
1270
Steve Crooks46d64302017-03-10 15:11:06 -05001271 # Set AR - ExtendedVlanTaggingOperationConfigData
Steve Crooks9b160d72017-03-31 10:48:29 -05001272 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1273 #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 -04001274 #yield self.wait_for_response()
1275
1276 # Set AR - ExtendedVlanTaggingOperationConfigData
Steve Crooks9b160d72017-03-31 10:48:29 -05001277 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1278 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001279 yield self.wait_for_response()
1280
Steve Crooks9b160d72017-03-31 10:48:29 -05001281 # MAC Bridge Port config
1282 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102
1283 # TODO: add more entries here for other UNI ports
1284 self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 2, 1, 0x102)
1285 yield self.wait_for_response()
1286
1287 # Port 5
1288 # Extended VLAN Tagging Operation config
1289 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102
1290 # TODO: add entry here for additional UNI interfaces
1291 self.send_create_extended_vlan_tagging_operation_configuration_data(0x205, 2, 0x105)
1292 yield self.wait_for_response()
1293
1294 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1295 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x205, 0x8100, 0x8100)
1296 yield self.wait_for_response()
1297
1298 # Set AR - ExtendedVlanTaggingOperationConfigData
1299 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1300 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0, 1, 8, cvid)
1301 #yield self.wait_for_response()
1302
1303 # Set AR - ExtendedVlanTaggingOperationConfigData
1304 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1305 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x205, 0x1000, cvid)
1306 yield self.wait_for_response()
1307
1308 # MAC Bridge Port config
1309 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102
1310 # TODO: add more entries here for other UNI ports
1311 self.send_create_mac_bridge_port_configuration_data(0x205, 0x201, 5, 1, 0x105)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001312 yield self.wait_for_response()
rshettyc26a3c32017-07-27 11:06:38 +05301313
1314 def create_interface(self, data):
rshetty1cc73982017-09-02 03:31:12 +05301315 if isinstance(data, VEnetConfig):
1316 parent_port_num = None
1317 onu_device = self.adapter_agent.get_device(self.device_id)
1318 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1319 parent_port_num = None
1320 for port in ports:
1321 if port.label == data.interface.name:
1322 parent_port_num = port.port_no
1323 break
1324
1325 if not parent_port_num:
1326 self.log.error("matching-parent-uni-port-num-not-found")
1327 return
1328
1329 onu_ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1330 if onu_ports:
1331 # To-Do :
1332 # Assumed only one PON port and UNI port per ONU.
1333 pon_port = onu_ports[0]
1334 else:
1335 self.log.error("No-Pon-port-configured-yet")
1336 return
1337
1338 self.adapter_agent.delete_port_reference_from_parent(self.device_id,
1339 pon_port)
1340
1341 pon_port.peers[0].device_id = onu_device.parent_id
1342 pon_port.peers[0].port_no = parent_port_num
1343 self.adapter_agent.add_port_reference_to_parent(self.device_id,
1344 pon_port)
1345 else:
1346 self.log.info('Not handled Yet')
1347 return
rshettyc26a3c32017-07-27 11:06:38 +05301348
1349 def update_interface(self, data):
1350 self.log.info('Not Implemented yet')
rshetty1cc73982017-09-02 03:31:12 +05301351 return
rshettyc26a3c32017-07-27 11:06:38 +05301352
1353 def remove_interface(self, data):
1354 self.log.info('Not Implemented yet')
rshetty1cc73982017-09-02 03:31:12 +05301355 return