blob: 3543776d6069a646d939a9113ba3af7461159e6b [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
Girish61687212018-01-08 12:48:58 +053024from twisted.internet.defer import DeferredQueue, inlineCallbacks, returnValue
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
rshettyf4bf19e2017-09-19 01:28:27 +053038from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD, OFPPS_LINK_DOWN
Steve Crooksf248e182017-02-07 10:50:24 -050039from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port
Girish61687212018-01-08 12:48:58 +053040from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig, VOntaniConfig
rshettyf4bf19e2017-09-19 01:28:27 +053041from voltha.protos.bbf_fiber_traffic_descriptor_profile_body_pb2 import \
42 TrafficDescriptorProfileData
43from voltha.protos.bbf_fiber_tcont_body_pb2 import TcontsConfigData
44from voltha.protos.bbf_fiber_gemport_body_pb2 import GemportsConfigData
rshetty1cc73982017-09-02 03:31:12 +053045
Steve Crooks3c2c7582017-01-10 15:02:26 -060046from common.frameio.frameio import hexify
47from voltha.extensions.omci.omci import *
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080048
Steve Crooks3c2c7582017-01-10 15:02:26 -060049_ = third_party
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080050log = structlog.get_logger()
51
52
rshettyf4bf19e2017-09-19 01:28:27 +053053BRDCM_DEFAULT_VLAN = 4091
sathishgff102eb2017-12-21 12:19:19 +053054ADMIN_STATE_LOCK = 1
55ADMIN_STATE_UNLOCK = 0
ggowdru42662622018-04-16 10:03:31 +053056RESERVED_VLAN_ID = 4095
rshettyf4bf19e2017-09-19 01:28:27 +053057
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080058@implementer(IAdapterInterface)
59class BroadcomOnuAdapter(object):
60
61 name = 'broadcom_onu'
62
63 supported_device_types = [
64 DeviceType(
Steve Crooks3c2c7582017-01-10 15:02:26 -060065 id=name,
rshettyc26a3c32017-07-27 11:06:38 +053066 vendor_id='BRCM',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080067 adapter=name,
68 accepts_bulk_flow_update=True
69 )
70 ]
71
72 def __init__(self, adapter_agent, config):
73 self.adapter_agent = adapter_agent
74 self.config = config
75 self.descriptor = Adapter(
76 id=self.name,
77 vendor='Voltha project',
Girish61687212018-01-08 12:48:58 +053078 version='0.44',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080079 config=AdapterConfig(log_level=LogLevel.INFO)
80 )
Steve Crooks3c2c7582017-01-10 15:02:26 -060081 self.devices_handlers = dict() # device_id -> BroadcomOnuHandler()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080082
Peter Shafik9107f2e2017-05-02 15:54:39 -040083 # register for adapter messages
84 self.adapter_agent.register_for_inter_adapter_messages()
85
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080086 def start(self):
87 log.debug('starting')
88 log.info('started')
89
90 def stop(self):
91 log.debug('stopping')
92 log.info('stopped')
93
94 def adapter_descriptor(self):
95 return self.descriptor
96
97 def device_types(self):
98 return DeviceTypes(items=self.supported_device_types)
99
100 def health(self):
101 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
102
103 def change_master_state(self, master):
104 raise NotImplementedError()
105
106 def adopt_device(self, device):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600107 log.info('adopt_device', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530108 self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id)
109 reactor.callLater(0, self.devices_handlers[device.id].activate, device)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800110 return device
111
khenaidoo032d3302017-06-09 14:50:04 -0400112 def reconcile_device(self, device):
sathishg01ca0802017-11-03 18:32:11 +0530113 log.info('reconcile-device', device_id=device.id)
114 self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id)
115 reactor.callLater(0, self.devices_handlers[device.id].reconcile, device)
khenaidoo032d3302017-06-09 14:50:04 -0400116
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800117 def abandon_device(self, device):
118 raise NotImplementedError()
119
Khen Nursimulud068d812017-03-06 11:44:18 -0500120 def disable_device(self, device):
sathishgff102eb2017-12-21 12:19:19 +0530121 log.info('disable-onu-device', device_id=device.id)
122 if device.id in self.devices_handlers:
123 handler = self.devices_handlers[device.id]
124 if handler is not None:
125 handler.disable(device)
Khen Nursimulud068d812017-03-06 11:44:18 -0500126
127 def reenable_device(self, device):
sathishgff102eb2017-12-21 12:19:19 +0530128 log.info('reenable-onu-device', device_id=device.id)
129 if device.id in self.devices_handlers:
130 handler = self.devices_handlers[device.id]
131 if handler is not None:
132 handler.reenable(device)
Khen Nursimulud068d812017-03-06 11:44:18 -0500133
134 def reboot_device(self, device):
Girish61687212018-01-08 12:48:58 +0530135 log.info('reboot-device', device_id=device.id)
136 if device.id in self.devices_handlers:
137 handler = self.devices_handlers[device.id]
138 if handler is not None:
139 handler.reboot()
Khen Nursimulud068d812017-03-06 11:44:18 -0500140
Lydia Fang01f2e852017-06-28 17:24:58 -0700141 def download_image(self, device, request):
142 raise NotImplementedError()
143
144 def get_image_download_status(self, device, request):
145 raise NotImplementedError()
146
147 def cancel_image_download(self, device, request):
148 raise NotImplementedError()
149
150 def activate_image_update(self, device, request):
151 raise NotImplementedError()
152
153 def revert_image_update(self, device, request):
154 raise NotImplementedError()
155
sathishg5ae86222017-06-28 15:16:29 +0530156 def self_test_device(self, device):
157 """
158 This is called to Self a device based on a NBI call.
159 :param device: A Voltha.Device object.
160 :return: Will return result of self test
161 """
162 log.info('self-test-device', device=device.id)
163 raise NotImplementedError()
164
Khen Nursimulud068d812017-03-06 11:44:18 -0500165 def delete_device(self, device):
Girishd5823672017-11-23 12:15:14 +0530166 log.info('delete-device', device_id=device.id)
167 if device.id in self.devices_handlers:
168 handler = self.devices_handlers[device.id]
169 if handler is not None:
170 handler.delete(device)
171 del self.devices_handlers[device.id]
172 return
Khen Nursimulud068d812017-03-06 11:44:18 -0500173
174 def get_device_details(self, device):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800175 raise NotImplementedError()
176
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500177 def update_pm_config(self, device, pm_configs):
178 raise NotImplementedError()
179
Steve Crooks3c2c7582017-01-10 15:02:26 -0600180 def update_flows_bulk(self, device, flows, groups):
rshettyf4bf19e2017-09-19 01:28:27 +0530181 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600182 log.info('bulk-flow-update', device_id=device.id,
183 flows=flows, groups=groups)
rshettyf4bf19e2017-09-19 01:28:27 +0530184 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600185 assert len(groups.items) == 0
rshettyf4bf19e2017-09-19 01:28:27 +0530186 handler = self.devices_handlers[device.id]
Steve Crooksf248e182017-02-07 10:50:24 -0500187 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600188
189 def update_flows_incrementally(self, device, flow_changes, group_changes):
190 raise NotImplementedError()
191
192 def send_proxied_message(self, proxy_address, msg):
193 log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
194
195 def receive_proxied_message(self, proxy_address, msg):
196 log.info('receive-proxied-message', proxy_address=proxy_address,
197 device_id=proxy_address.device_id, msg=hexify(msg))
rshettyf4bf19e2017-09-19 01:28:27 +0530198 # Device_id from the proxy_address is the olt device id. We need to
199 # get the onu device id using the port number in the proxy_address
200 device = self.adapter_agent. \
201 get_child_device_with_proxy_address(proxy_address)
202 if device:
203 handler = self.devices_handlers[device.id]
204 handler.receive_message(msg)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600205
206 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
207 log.info('packet-out', logical_device_id=logical_device_id,
208 egress_port_no=egress_port_no, msg_len=len(msg))
209
Peter Shafik9107f2e2017-05-02 15:54:39 -0400210 def receive_inter_adapter_message(self, msg):
211 log.info('receive_inter_adapter_message', msg=msg)
Peter Shafikd7f33772017-05-17 13:56:34 -0400212 proxy_address = msg['proxy_address']
213 assert proxy_address is not None
rshettyf4bf19e2017-09-19 01:28:27 +0530214 # Device_id from the proxy_address is the olt device id. We need to
215 # get the onu device id using the port number in the proxy_address
216 device = self.adapter_agent. \
217 get_child_device_with_proxy_address(proxy_address)
218 if device:
219 handler = self.devices_handlers[device.id]
220 handler.event_messages.put(msg)
Girish61687212018-01-08 12:48:58 +0530221 else:
222 log.error("device-not-found")
Peter Shafik9107f2e2017-05-02 15:54:39 -0400223
Nikolay Titov89004ec2017-06-19 18:22:42 -0400224 def create_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530225 log.info('create-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530226 if device.id in self.devices_handlers:
227 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530228 if handler is not None:
229 handler.create_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400230
231 def update_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530232 log.info('update-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530233 if device.id in self.devices_handlers:
234 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530235 if handler is not None:
236 handler.update_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400237
238 def remove_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530239 log.info('remove-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530240 if device.id in self.devices_handlers:
241 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530242 if handler is not None:
243 handler.remove_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400244
245 def receive_onu_detect_state(self, device_id, state):
246 raise NotImplementedError()
247
Nikolay Titov176f1db2017-08-10 12:38:43 -0400248 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
rshettyf4bf19e2017-09-19 01:28:27 +0530249 log.info('create-tcont', device_id=device.id)
250 if device.id in self.devices_handlers:
251 handler = self.devices_handlers[device.id]
252 if handler is not None:
253 handler.create_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400254
255 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
256 raise NotImplementedError()
257
258 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
Girishd5823672017-11-23 12:15:14 +0530259 log.info('remove-tcont', device_id=device.id)
260 if device.id in self.devices_handlers:
261 handler = self.devices_handlers[device.id]
262 if handler is not None:
263 handler.remove_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400264
265 def create_gemport(self, device, data):
rshettyf4bf19e2017-09-19 01:28:27 +0530266 log.info('create-gemport', device_id=device.id)
267 if device.id in self.devices_handlers:
268 handler = self.devices_handlers[device.id]
269 if handler is not None:
270 handler.create_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400271
272 def update_gemport(self, device, data):
273 raise NotImplementedError()
274
275 def remove_gemport(self, device, data):
Girishd5823672017-11-23 12:15:14 +0530276 log.info('remove-gemport', device_id=device.id)
277 if device.id in self.devices_handlers:
278 handler = self.devices_handlers[device.id]
279 if handler is not None:
280 handler.remove_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400281
282 def create_multicast_gemport(self, device, data):
rshettyf4bf19e2017-09-19 01:28:27 +0530283 log.info('create-multicast-gemport', device_id=device.id)
284 if device.id in self.devices_handlers:
285 handler = self.devices_handlers[device.id]
286 if handler is not None:
287 handler.create_multicast_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400288
289 def update_multicast_gemport(self, device, data):
290 raise NotImplementedError()
291
292 def remove_multicast_gemport(self, device, data):
293 raise NotImplementedError()
294
295 def create_multicast_distribution_set(self, device, data):
296 raise NotImplementedError()
297
298 def update_multicast_distribution_set(self, device, data):
299 raise NotImplementedError()
300
301 def remove_multicast_distribution_set(self, device, data):
302 raise NotImplementedError()
303
304 def suppress_alarm(self, filter):
305 raise NotImplementedError()
306
Stephane Barbarie980a0912017-05-11 11:27:06 -0400307 def unsuppress_alarm(self, filter):
308 raise NotImplementedError()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600309
310class BroadcomOnuHandler(object):
311
312 def __init__(self, adapter, device_id):
313 self.adapter = adapter
314 self.adapter_agent = adapter.adapter_agent
315 self.device_id = device_id
316 self.log = structlog.get_logger(device_id=device_id)
317 self.incoming_messages = DeferredQueue()
Peter Shafikd7f33772017-05-17 13:56:34 -0400318 self.event_messages = DeferredQueue()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600319 self.proxy_address = None
320 self.tx_id = 0
321
Peter Shafikd7f33772017-05-17 13:56:34 -0400322 # Need to query ONU for number of supported uni ports
323 # For now, temporarily set number of ports to 1 - port #2
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500324 self.uni_ports = (1, 2, 3, 4, 5)
Peter Shafikd7f33772017-05-17 13:56:34 -0400325
326 # Handle received ONU event messages
327 reactor.callLater(0, self.handle_onu_events)
328
Steve Crooks3c2c7582017-01-10 15:02:26 -0600329 def receive_message(self, msg):
330 self.incoming_messages.put(msg)
331
Peter Shafikd7f33772017-05-17 13:56:34 -0400332 @inlineCallbacks
333 def handle_onu_events(self):
334 event_msg = yield self.event_messages.get()
335
336 if event_msg['event'] == 'activation-completed':
337
338 if event_msg['event_data']['activation_successful'] == True:
Nicolas Palpacuerecb3d1e2018-03-14 17:00:14 -0400339
340 yield self.message_exchange()
Peter Shafikd7f33772017-05-17 13:56:34 -0400341
342 device = self.adapter_agent.get_device(self.device_id)
Girishd5823672017-11-23 12:15:14 +0530343 device.connect_status = ConnectStatus.REACHABLE
Peter Shafikd7f33772017-05-17 13:56:34 -0400344 device.oper_status = OperStatus.ACTIVE
345 self.adapter_agent.update_device(device)
346
347 else:
348 device = self.adapter_agent.get_device(self.device_id)
349 device.oper_status = OperStatus.FAILED
350 self.adapter_agent.update_device(device)
351
352 elif event_msg['event'] == 'deactivation-completed':
353 device = self.adapter_agent.get_device(self.device_id)
354 device.oper_status = OperStatus.DISCOVERED
355 self.adapter_agent.update_device(device)
356
Girish61687212018-01-08 12:48:58 +0530357 elif event_msg['event'] == 'deactivate-onu':
Girisha9eb0212017-12-14 21:52:59 +0530358 device = self.adapter_agent.get_device(self.device_id)
359 device.connect_status = ConnectStatus.UNREACHABLE
360 device.oper_status = OperStatus.DISCOVERED
361 self.adapter_agent.update_device(device)
Girish61687212018-01-08 12:48:58 +0530362 self.disable_ports(device)
Girisha9eb0212017-12-14 21:52:59 +0530363
Peter Shafikd7f33772017-05-17 13:56:34 -0400364 elif event_msg['event'] == 'ranging-completed':
365
366 if event_msg['event_data']['ranging_successful'] == True:
367 device = self.adapter_agent.get_device(self.device_id)
368 device.oper_status = OperStatus.ACTIVATING
369 self.adapter_agent.update_device(device)
370
371 else:
372 device = self.adapter_agent.get_device(self.device_id)
373 device.oper_status = OperStatus.FAILED
374 self.adapter_agent.update_device(device)
375
Shad Ansari2825d012018-02-22 23:57:46 +0000376 elif event_msg['event'] == 'create-tcont':
377 tcont = TcontsConfigData()
378 tcont.alloc_id = event_msg['event_data']['alloc_id']
379 self.create_tcont(tcont, traffic_descriptor_data=None)
380
381 elif event_msg['event'] == 'create-venet':
382 venet = VEnetConfig(name=event_msg['event_data']['uni_name'])
383 venet.interface.name = event_msg['event_data']['interface_name']
384 self.create_interface(venet)
385
386 elif event_msg['event'] == 'create-gemport':
387 gem_port = GemportsConfigData()
388 gem_port.gemport_id = event_msg['event_data']['gemport_id']
389 self.create_gemport(gem_port)
390
Peter Shafikd7f33772017-05-17 13:56:34 -0400391 # Handle next event
392 reactor.callLater(0, self.handle_onu_events)
393
394
Steve Crooks3c2c7582017-01-10 15:02:26 -0600395 def activate(self, device):
396 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800397
398 # first we verify that we got parent reference and proxy info
399 assert device.parent_id
400 assert device.proxy_address.device_id
Steve Crooks9b160d72017-03-31 10:48:29 -0500401 #assert device.proxy_address.channel_id # c-vid
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800402
Steve Crooks3c2c7582017-01-10 15:02:26 -0600403 # register for proxied messages right away
404 self.proxy_address = device.proxy_address
405 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
406
Peter Shafik9107f2e2017-05-02 15:54:39 -0400407
Steve Crooks3c2c7582017-01-10 15:02:26 -0600408 # populate device info
409 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800410 device.vendor = 'Broadcom'
Steve Crooks9e85ce82017-03-20 12:00:53 -0400411 device.model = 'n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800412 device.hardware_version = 'to be filled'
413 device.firmware_version = 'to be filled'
ggowdru236bd952017-06-20 20:32:55 -0700414 device.images.image.extend([
415 Image(version="to be filled")
416 ])
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800417 device.connect_status = ConnectStatus.REACHABLE
418 self.adapter_agent.update_device(device)
419
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800420 self.adapter_agent.add_port(device.id, Port(
Steve Crooks9b160d72017-03-31 10:48:29 -0500421 port_no=100,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800422 label='PON port',
423 type=Port.PON_ONU,
424 admin_state=AdminState.ENABLED,
425 oper_status=OperStatus.ACTIVE,
426 peers=[
427 Port.PeerPort(
428 device_id=device.parent_id,
429 port_no=device.parent_port_no
430 )
431 ]
432 ))
433
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800434 parent_device = self.adapter_agent.get_device(device.parent_id)
435 logical_device_id = parent_device.parent_id
436 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800437 device = self.adapter_agent.get_device(device.id)
Peter Shafikd7f33772017-05-17 13:56:34 -0400438 device.oper_status = OperStatus.DISCOVERED
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800439 self.adapter_agent.update_device(device)
440
sathishg01ca0802017-11-03 18:32:11 +0530441 def reconcile(self, device):
442
Girish61687212018-01-08 12:48:58 +0530443 self.log.info('reconciling-broadcom-onu-device-starts')
sathishg01ca0802017-11-03 18:32:11 +0530444
445 # first we verify that we got parent reference and proxy info
446 assert device.parent_id
447 assert device.proxy_address.device_id
448
449 # register for proxied messages right away
450 self.proxy_address = device.proxy_address
451 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
452
453 # TODO: Query ONU current status after reconcile and update.
454 # To be addressed in future commits.
455
Girish61687212018-01-08 12:48:58 +0530456 self.log.info('reconciling-broadcom-onu-device-ends')
sathishg01ca0802017-11-03 18:32:11 +0530457
sathishg24dad1e2018-01-10 10:48:45 +0530458 def update_logical_port(self, logical_device_id, port_id, state):
459 self.log.info('updating-logical-port', logical_port_id=port_id,
460 logical_device_id=logical_device_id, state=state)
461 logical_port = self.adapter_agent.get_logical_port(logical_device_id,
462 port_id)
463 logical_port.ofp_port.state = state
464 self.adapter_agent.update_logical_port(logical_device_id,
465 logical_port)
466
Girishd5823672017-11-23 12:15:14 +0530467 def delete(self, device):
468 self.log.info('delete-onu')
Girish61687212018-01-08 12:48:58 +0530469 # The device is already deleted in delete_v_ont_ani(). No more
470 # handling needed here
sathishg01ca0802017-11-03 18:32:11 +0530471
Steve Crooks3c2c7582017-01-10 15:02:26 -0600472 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500473 def update_flow_table(self, device, flows):
474 #
475 # We need to proxy through the OLT to get to the ONU
476 # Configuration from here should be using OMCI
477 #
rshettyf4bf19e2017-09-19 01:28:27 +0530478 #self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800479
Steve Crooksf248e182017-02-07 10:50:24 -0500480 def is_downstream(port):
Steve Crooks9b160d72017-03-31 10:48:29 -0500481 return port == 100 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800482
Steve Crooksf248e182017-02-07 10:50:24 -0500483 def is_upstream(port):
484 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800485
Steve Crooksf248e182017-02-07 10:50:24 -0500486 for flow in flows:
Steve Crooks9b160d72017-03-31 10:48:29 -0500487 _type = None
488 _port = None
489 _vlan_vid = None
490 _udp_dst = None
491 _udp_src = None
492 _ipv4_dst = None
493 _ipv4_src = None
494 _metadata = None
495 _output = None
496 _push_tpid = None
497 _field = None
498 _set_vlan_vid = None
rshettyf4bf19e2017-09-19 01:28:27 +0530499 self.log.info('bulk-flow-update', device_id=device.id, flow=flow)
Steve Crooksf248e182017-02-07 10:50:24 -0500500 try:
501 _in_port = fd.get_in_port(flow)
502 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600503
Steve Crooksf248e182017-02-07 10:50:24 -0500504 if is_downstream(_in_port):
505 self.log.info('downstream-flow')
506 elif is_upstream(_in_port):
507 self.log.info('upstream-flow')
508 else:
509 raise Exception('port should be 1 or 2 by our convention')
510
511 _out_port = fd.get_out_port(flow) # may be None
512 self.log.info('out-port', out_port=_out_port)
513
514 for field in fd.get_ofb_fields(flow):
515 if field.type == fd.ETH_TYPE:
516 _type = field.eth_type
517 self.log.info('field-type-eth-type',
518 eth_type=_type)
519
520 elif field.type == fd.IP_PROTO:
521 _proto = field.ip_proto
522 self.log.info('field-type-ip-proto',
523 ip_proto=_proto)
524
525 elif field.type == fd.IN_PORT:
526 _port = field.port
527 self.log.info('field-type-in-port',
528 in_port=_port)
529
530 elif field.type == fd.VLAN_VID:
531 _vlan_vid = field.vlan_vid & 0xfff
532 self.log.info('field-type-vlan-vid',
533 vlan=_vlan_vid)
534
535 elif field.type == fd.VLAN_PCP:
536 _vlan_pcp = field.vlan_pcp
537 self.log.info('field-type-vlan-pcp',
538 pcp=_vlan_pcp)
539
540 elif field.type == fd.UDP_DST:
541 _udp_dst = field.udp_dst
542 self.log.info('field-type-udp-dst',
543 udp_dst=_udp_dst)
544
545 elif field.type == fd.UDP_SRC:
546 _udp_src = field.udp_src
547 self.log.info('field-type-udp-src',
548 udp_src=_udp_src)
549
550 elif field.type == fd.IPV4_DST:
551 _ipv4_dst = field.ipv4_dst
552 self.log.info('field-type-ipv4-dst',
553 ipv4_dst=_ipv4_dst)
554
555 elif field.type == fd.IPV4_SRC:
556 _ipv4_src = field.ipv4_src
557 self.log.info('field-type-ipv4-src',
558 ipv4_dst=_ipv4_src)
559
560 elif field.type == fd.METADATA:
Steve Crooks9b160d72017-03-31 10:48:29 -0500561 _metadata = field.table_metadata
Steve Crooksf248e182017-02-07 10:50:24 -0500562 self.log.info('field-type-metadata',
563 metadata=_metadata)
564
565 else:
566 raise NotImplementedError('field.type={}'.format(
567 field.type))
568
569 for action in fd.get_actions(flow):
570
571 if action.type == fd.OUTPUT:
572 _output = action.output.port
573 self.log.info('action-type-output',
574 output=_output, in_port=_in_port)
575
576 elif action.type == fd.POP_VLAN:
577 self.log.info('action-type-pop-vlan',
578 in_port=_in_port)
579
580 elif action.type == fd.PUSH_VLAN:
581 _push_tpid = action.push.ethertype
Girish61687212018-01-08 12:48:58 +0530582 self.log.info('action-type-push-vlan',
Steve Crooksf248e182017-02-07 10:50:24 -0500583 push_tpid=_push_tpid, in_port=_in_port)
584 if action.push.ethertype != 0x8100:
585 self.log.error('unhandled-tpid',
586 ethertype=action.push.ethertype)
587
588 elif action.type == fd.SET_FIELD:
589 _field = action.set_field.field.ofb_field
590 assert (action.set_field.field.oxm_class ==
591 OFPXMC_OPENFLOW_BASIC)
592 self.log.info('action-type-set-field',
593 field=_field, in_port=_in_port)
594 if _field.type == fd.VLAN_VID:
Steve Crooks9b160d72017-03-31 10:48:29 -0500595 _set_vlan_vid = _field.vlan_vid & 0xfff
596 self.log.info('set-field-type-valn-vid', _set_vlan_vid)
Steve Crooksf248e182017-02-07 10:50:24 -0500597 else:
598 self.log.error('unsupported-action-set-field-type',
599 field_type=_field.type)
600 else:
Girish61687212018-01-08 12:48:58 +0530601 self.log.error('unsupported-action-type',
Steve Crooksf248e182017-02-07 10:50:24 -0500602 action_type=action.type, in_port=_in_port)
603
604 #
605 # All flows created from ONU adapter should be OMCI based
606 #
rshettyf4bf19e2017-09-19 01:28:27 +0530607 if _vlan_vid == 0 and _set_vlan_vid != None and _set_vlan_vid != 0:
Steve Crooks9b160d72017-03-31 10:48:29 -0500608 # allow priority tagged packets
609 # Set AR - ExtendedVlanTaggingOperationConfigData
610 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
rshettyf4bf19e2017-09-19 01:28:27 +0530611
612 self.send_delete_vlan_tagging_filter_data(0x2102)
613 yield self.wait_for_response()
614
ggowdru42662622018-04-16 10:03:31 +0530615 # self.send_set_vlan_tagging_filter_data(0x2102, _set_vlan_vid)
616 if _set_vlan_vid != RESERVED_VLAN_ID:
617 # As per G.988 - Table 9.3.11-1 - Forward operation attribute values
618 # Forward action of 0x10 allows VID Investigation
619 self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid, 0x10)
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500620 yield self.wait_for_response()
Steve Crooks9b160d72017-03-31 10:48:29 -0500621
ggowdru42662622018-04-16 10:03:31 +0530622 for port_id in self.uni_ports:
623
624 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(\
625 0x200 + port_id, 0x1000, _set_vlan_vid)
626 yield self.wait_for_response()
627
628 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x200 + port_id, 8, 0, 0,
629 1, 8, _set_vlan_vid)
630 yield self.wait_for_response()
631 else:
632 # As per G.988 - Table 9.3.11-1 - Forward operation attribute values
633 # Forward action of 0x00 does not perform VID Investigation for transparent vlan case
634 self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid, 0x00)
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500635 yield self.wait_for_response()
636
ggowdru42662622018-04-16 10:03:31 +0530637 for port_id in self.uni_ports:
638 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(\
639 0x200 + port_id, 14, 4096, 0, 0, 15, 0)
640 yield self.wait_for_response()
Steve Crooksf248e182017-02-07 10:50:24 -0500641
642 except Exception as e:
Girish61687212018-01-08 12:48:58 +0530643 self.log.exception('failed-to-install-flow', e=e, flow=flow)
Steve Crooksf248e182017-02-07 10:50:24 -0500644
Steve Crooks3c2c7582017-01-10 15:02:26 -0600645 def get_tx_id(self):
646 self.tx_id += 1
647 return self.tx_id
648
649 def send_omci_message(self, frame):
650 _frame = hexify(str(frame))
651 self.log.info('send-omci-message-%s' % _frame)
652 device = self.adapter_agent.get_device(self.device_id)
653 try:
654 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
655 except Exception as e:
656 self.log.info('send-omci-message-exception', exc=str(e))
657
658 def send_get_circuit_pack(self, entity_id=0):
659 frame = OmciFrame(
660 transaction_id=self.get_tx_id(),
661 message_type=OmciGet.message_id,
662 omci_message=OmciGet(
663 entity_class=CircuitPack.class_id,
664 entity_id=entity_id,
665 attributes_mask=CircuitPack.mask_for('vendor_id')
666 )
667 )
668 self.send_omci_message(frame)
669
670 def send_mib_reset(self, entity_id=0):
671 frame = OmciFrame(
672 transaction_id=self.get_tx_id(),
673 message_type=OmciMibReset.message_id,
674 omci_message=OmciMibReset(
675 entity_class=OntData.class_id,
676 entity_id=entity_id
677 )
678 )
679 self.send_omci_message(frame)
680
Steve Crooks9e85ce82017-03-20 12:00:53 -0400681 def send_create_gal_ethernet_profile(self,
682 entity_id,
683 max_gem_payload_size):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600684 frame = OmciFrame(
685 transaction_id=self.get_tx_id(),
686 message_type=OmciCreate.message_id,
687 omci_message=OmciCreate(
688 entity_class=GalEthernetProfile.class_id,
689 entity_id=entity_id,
690 data=dict(
691 max_gem_payload_size=max_gem_payload_size
692 )
693 )
694 )
695 self.send_omci_message(frame)
696
sathishgff102eb2017-12-21 12:19:19 +0530697 def send_set_admin_state(self,
698 entity_id,
699 admin_state):
700 data = dict(
701 administrative_state=admin_state
702 )
703 frame = OmciFrame(
704 transaction_id=self.get_tx_id(),
705 message_type=OmciSet.message_id,
706 omci_message=OmciSet(
707 entity_class=OntG.class_id,
708 entity_id=entity_id,
709 attributes_mask=OntG.mask_for(*data.keys()),
710 data=data
711 )
712 )
713 self.send_omci_message(frame)
714
Steve Crooks9e85ce82017-03-20 12:00:53 -0400715 def send_set_tcont(self,
716 entity_id,
717 alloc_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600718 data = dict(
719 alloc_id=alloc_id
720 )
721 frame = OmciFrame(
722 transaction_id=self.get_tx_id(),
723 message_type=OmciSet.message_id,
724 omci_message=OmciSet(
725 entity_class=Tcont.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400726 entity_id=entity_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600727 attributes_mask=Tcont.mask_for(*data.keys()),
728 data=data
729 )
730 )
731 self.send_omci_message(frame)
732
Steve Crooks9e85ce82017-03-20 12:00:53 -0400733 def send_create_8021p_mapper_service_profile(self,
734 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600735 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400736 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600737 message_type=OmciCreate.message_id,
738 omci_message=OmciCreate(
739 entity_class=Ieee8021pMapperServiceProfile.class_id,
740 entity_id=entity_id,
741 data=dict(
742 tp_pointer=OmciNullPointer,
743 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
Steve Crooks9b160d72017-03-31 10:48:29 -0500744 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
745 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
746 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
747 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
748 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
749 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
750 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
Steve Crooks3c2c7582017-01-10 15:02:26 -0600751 )
752 )
753 )
754 self.send_omci_message(frame)
755
Steve Crooks9e85ce82017-03-20 12:00:53 -0400756 def send_create_mac_bridge_service_profile(self,
757 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600758 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400759 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600760 message_type=OmciCreate.message_id,
761 omci_message=OmciCreate(
762 entity_class=MacBridgeServiceProfile.class_id,
763 entity_id=entity_id,
764 data=dict(
765 spanning_tree_ind=False,
766 learning_ind=True,
767 priority=0x8000,
768 max_age=20 * 256,
769 hello_time=2 * 256,
770 forward_delay=15 * 256,
771 unknown_mac_address_discard=True
772 )
773 )
774 )
775 self.send_omci_message(frame)
776
Steve Crooks9e85ce82017-03-20 12:00:53 -0400777 def send_create_gem_port_network_ctp(self,
778 entity_id,
779 port_id,
780 tcont_id,
781 direction,
782 tm):
783 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
784 if _directions.has_key(direction):
785 _direction = _directions[direction]
786 else:
787 self.log.error('invalid-gem-port-direction', direction=direction)
788 raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction))
789
Steve Crooks3c2c7582017-01-10 15:02:26 -0600790 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400791 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600792 message_type=OmciCreate.message_id,
793 omci_message=OmciCreate(
794 entity_class=GemPortNetworkCtp.class_id,
795 entity_id=entity_id,
796 data=dict(
797 port_id=port_id,
798 tcont_pointer=tcont_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400799 direction=_direction,
800 traffic_management_pointer_upstream=tm
Steve Crooks3c2c7582017-01-10 15:02:26 -0600801 )
802 )
803 )
804 self.send_omci_message(frame)
805
Steve Crooks9e85ce82017-03-20 12:00:53 -0400806 def send_create_multicast_gem_interworking_tp(self,
807 entity_id,
808 gem_port_net_ctp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600809 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400810 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600811 message_type=OmciCreate.message_id,
812 omci_message=OmciCreate(
813 entity_class=MulticastGemInterworkingTp.class_id,
814 entity_id=entity_id,
815 data=dict(
816 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
817 interworking_option=0,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400818 service_profile_pointer=0x1
Steve Crooks3c2c7582017-01-10 15:02:26 -0600819 )
820 )
821 )
822 self.send_omci_message(frame)
823
Steve Crooks9e85ce82017-03-20 12:00:53 -0400824 def send_create_gem_inteworking_tp(self,
825 entity_id,
826 gem_port_net_ctp_id,
827 service_profile_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600828 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=OmciCreate.message_id,
831 omci_message=OmciCreate(
832 entity_class=GemInterworkingTp.class_id,
833 entity_id=entity_id,
834 data=dict(
835 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
836 interworking_option=5,
837 service_profile_pointer=service_profile_id,
838 interworking_tp_pointer=0x0,
839 gal_profile_pointer=0x1
840 )
841 )
842 )
843 self.send_omci_message(frame)
844
Girishd5823672017-11-23 12:15:14 +0530845 def send_delete_omci_mesage(self,
846 class_id,
847 entity_id):
848 frame = OmciFrame(
849 transaction_id=self.get_tx_id(),
850 message_type=OmciDelete.message_id,
851 omci_message=OmciDelete(
852 entity_class=class_id,
853 entity_id=entity_id
854 )
855 )
856 self.send_omci_message(frame)
857
Steve Crooks9e85ce82017-03-20 12:00:53 -0400858 def send_set_8021p_mapper_service_profile(self,
859 entity_id,
860 interwork_tp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600861 data = dict(
Steve Crooks9b160d72017-03-31 10:48:29 -0500862 interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id,
863 interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id,
864 interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id,
865 interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id,
866 interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id,
867 interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id,
868 interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id,
869 interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600870 )
871 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400872 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600873 message_type=OmciSet.message_id,
874 omci_message=OmciSet(
875 entity_class=Ieee8021pMapperServiceProfile.class_id,
876 entity_id=entity_id,
877 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
878 *data.keys()),
879 data=data
880 )
881 )
882 self.send_omci_message(frame)
883
884 def send_create_mac_bridge_port_configuration_data(self,
885 entity_id,
886 bridge_id,
887 port_id,
888 tp_type,
889 tp_id):
890 frame = OmciFrame(
891 transaction_id=self.get_tx_id(),
892 message_type=OmciCreate.message_id,
893 omci_message=OmciCreate(
894 entity_class=MacBridgePortConfigurationData.class_id,
895 entity_id=entity_id,
896 data=dict(
Girish61687212018-01-08 12:48:58 +0530897 bridge_id_pointer=bridge_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600898 port_num=port_id,
899 tp_type=tp_type,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400900 tp_pointer=tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600901 )
902 )
903 )
904 self.send_omci_message(frame)
905
Steve Crooks9e85ce82017-03-20 12:00:53 -0400906 def send_create_vlan_tagging_filter_data(self,
907 entity_id,
ggowdru42662622018-04-16 10:03:31 +0530908 vlan_id,
909 fwd_operation):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600910 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400911 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600912 message_type=OmciCreate.message_id,
913 omci_message=OmciCreate(
914 entity_class=VlanTaggingFilterData.class_id,
915 entity_id=entity_id,
916 data=dict(
917 vlan_filter_0=vlan_id,
ggowdru42662622018-04-16 10:03:31 +0530918 forward_operation=fwd_operation,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600919 number_of_entries=1
920 )
921 )
922 )
923 self.send_omci_message(frame)
924
rshettyf4bf19e2017-09-19 01:28:27 +0530925 def send_set_vlan_tagging_filter_data(self,
926 entity_id,
927 vlan_id):
928 data = dict(
929 vlan_filter_0=vlan_id,
930 forward_operation=0x10,
931 number_of_entries=1
932 )
933
934 frame = OmciFrame(
935 transaction_id=self.get_tx_id(),
936 message_type=OmciSet.message_id,
937 omci_message=OmciSet(
938 entity_class=VlanTaggingFilterData.class_id,
939 entity_id=entity_id,
940 attributes_mask=VlanTaggingFilterData.mask_for(
941 *data.keys()),
942 data=data
943 )
944 )
945 self.send_omci_message(frame)
946
947 def send_delete_vlan_tagging_filter_data(self,
948 entity_id):
949 frame = OmciFrame(
950 transaction_id=self.get_tx_id(),
951 message_type=OmciDelete.message_id,
952 omci_message=OmciDelete(
953 entity_class=VlanTaggingFilterData.class_id,
954 entity_id=entity_id
955 )
956 )
957 self.send_omci_message(frame)
958
Steve Crooks46d64302017-03-10 15:11:06 -0500959 def send_create_extended_vlan_tagging_operation_configuration_data(self,
960 entity_id,
961 assoc_type,
962 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600963 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400964 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600965 message_type=OmciCreate.message_id,
966 omci_message=OmciCreate(
967 entity_class=
968 ExtendedVlanTaggingOperationConfigurationData.class_id,
969 entity_id=entity_id,
970 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500971 association_type=assoc_type,
972 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600973 )
974 )
975 )
976 self.send_omci_message(frame)
977
Steve Crooks9e85ce82017-03-20 12:00:53 -0400978 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self,
979 entity_id,
980 input_tpid,
981 output_tpid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600982 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400983 input_tpid=input_tpid,
984 output_tpid=output_tpid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600985 downstream_mode=0, # inverse of upstream
986 )
987 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400988 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600989 message_type=OmciSet.message_id,
990 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400991 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600992 ExtendedVlanTaggingOperationConfigurationData.class_id,
993 entity_id=entity_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400994 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600995 ExtendedVlanTaggingOperationConfigurationData.mask_for(
996 *data.keys()),
997 data=data
998 )
999 )
1000 self.send_omci_message(frame)
1001
Steve Crooksa9d0a7c2017-03-28 22:40:01 -04001002 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
1003 entity_id,
1004 filter_inner_vid,
1005 treatment_inner_vid):
Steve Crooks3c2c7582017-01-10 15:02:26 -06001006 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001007 received_frame_vlan_tagging_operation_table=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001008 VlanTaggingOperation(
1009 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -05001010 filter_outer_vid=4096,
1011 filter_outer_tpid_de=0,
1012
1013 filter_inner_priority=15,
1014 filter_inner_vid=filter_inner_vid,
1015 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001016 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -05001017
1018 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001019 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -05001020 treatment_outer_vid=0,
1021 treatment_outer_tpid_de=0,
1022
1023 treatment_inner_priority=0,
1024 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001025 treatment_inner_tpid_de=4
1026 )
1027 )
1028 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001029 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -06001030 message_type=OmciSet.message_id,
1031 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001032 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001033 ExtendedVlanTaggingOperationConfigurationData.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -04001034 entity_id=entity_id,
1035 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001036 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1037 *data.keys()),
1038 data=data
1039 )
1040 )
1041 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001042
Steve Crooksa9d0a7c2017-03-28 22:40:01 -04001043 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
1044 entity_id,
1045 filter_inner_priority,
1046 filter_inner_vid,
1047 filter_inner_tpid_de,
1048 treatment_tags_to_remove,
1049 treatment_inner_priority,
1050 treatment_inner_vid):
1051 data = dict(
1052 received_frame_vlan_tagging_operation_table=
1053 VlanTaggingOperation(
1054 filter_outer_priority=15,
1055 filter_outer_vid=4096,
1056 filter_outer_tpid_de=0,
1057
1058 filter_inner_priority=filter_inner_priority,
1059 filter_inner_vid=filter_inner_vid,
1060 filter_inner_tpid_de=filter_inner_tpid_de,
1061 filter_ether_type=0,
1062
1063 treatment_tags_to_remove=treatment_tags_to_remove,
1064 treatment_outer_priority=15,
1065 treatment_outer_vid=0,
1066 treatment_outer_tpid_de=0,
1067
1068 treatment_inner_priority=treatment_inner_priority,
1069 treatment_inner_vid=treatment_inner_vid,
1070 treatment_inner_tpid_de=4
1071 )
1072 )
1073 frame = OmciFrame(
1074 transaction_id=self.get_tx_id(),
1075 message_type=OmciSet.message_id,
1076 omci_message=OmciSet(
1077 entity_class=
1078 ExtendedVlanTaggingOperationConfigurationData.class_id,
1079 entity_id=entity_id,
1080 attributes_mask=
1081 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1082 *data.keys()),
1083 data=data
1084 )
1085 )
1086 self.send_omci_message(frame)
1087
Steve Crooks9e85ce82017-03-20 12:00:53 -04001088 def send_create_multicast_operations_profile(self,
1089 entity_id,
1090 igmp_ver):
1091 frame = OmciFrame(
1092 transaction_id=self.get_tx_id(),
1093 message_type=OmciCreate.message_id,
1094 omci_message=OmciCreate(
1095 entity_class=
1096 MulticastOperationsProfile.class_id,
1097 entity_id=entity_id,
1098 data=dict(
1099 igmp_version=igmp_ver,
1100 igmp_function=0,
1101 immediate_leave=0
1102 )
1103 )
1104 )
1105 self.send_omci_message(frame)
1106
1107 def send_set_multicast_operations_profile_acl_row0(self,
1108 entity_id,
1109 acl_table,
1110 row_key,
1111 gem_port,
1112 vlan,
1113 src_ip,
1114 dst_ip_start,
1115 dst_ip_end):
1116 row0 = AccessControlRow0(
1117 set_ctrl=1,
1118 row_part_id=0,
1119 test=0,
1120 row_key=row_key,
1121 gem_port_id=gem_port,
1122 vlan_id=vlan,
1123 src_ip=src_ip,
1124 dst_ip_start=dst_ip_start,
1125 dst_ip_end=dst_ip_end,
1126 ipm_group_bw=0
1127 )
1128
1129 if acl_table == 'dynamic':
1130 data = dict(
1131 dynamic_access_control_list_table=row0
1132 )
1133 else:
1134 data = dict(
1135 static_access_control_list_table=row0
1136 )
1137
1138 frame = OmciFrame(
1139 transaction_id=self.get_tx_id(),
1140 message_type=OmciSet.message_id,
1141 omci_message=OmciSet(
1142 entity_class=MulticastOperationsProfile.class_id,
1143 entity_id=entity_id,
1144 attributes_mask=MulticastOperationsProfile.mask_for(
1145 *data.keys()),
1146 data=data
1147 )
1148 )
1149 self.send_omci_message(frame)
1150
1151 def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self,
1152 entity_id,
1153 ctrl_type,
1154 tci):
1155 data = dict(
1156 ds_igmp_mcast_tci=
1157 DownstreamIgmpMulticastTci(
1158 ctrl_type=ctrl_type,
1159 tci=tci
1160 )
1161 )
1162 frame = OmciFrame(
1163 transaction_id=self.get_tx_id(),
1164 message_type=OmciSet.message_id,
1165 omci_message=OmciSet(
1166 entity_class=MulticastOperationsProfile.class_id,
1167 entity_id=entity_id,
1168 attributes_mask=MulticastOperationsProfile.mask_for(
1169 *data.keys()),
1170 data=data
1171 )
1172 )
1173 self.send_omci_message(frame)
1174
1175 def send_create_multicast_subscriber_config_info(self,
1176 entity_id,
1177 me_type,
1178 mcast_oper_profile):
1179 frame = OmciFrame(
1180 transaction_id=self.get_tx_id(),
1181 message_type=OmciCreate.message_id,
1182 omci_message=OmciCreate(
1183 entity_class=
1184 MulticastSubscriberConfigInfo.class_id,
1185 entity_id=entity_id,
1186 data=dict(
1187 me_type=me_type,
1188 mcast_operations_profile_pointer=mcast_oper_profile
1189 )
1190 )
1191 )
1192 self.send_omci_message(frame)
1193
1194 def send_set_multicast_subscriber_config_info(self,
1195 entity_id,
1196 max_groups=0,
1197 max_mcast_bw=0,
1198 bw_enforcement=0):
1199 data = dict(
1200 max_simultaneous_groups=max_groups,
1201 max_multicast_bandwidth=max_mcast_bw,
1202 bandwidth_enforcement=bw_enforcement
1203 )
1204 frame = OmciFrame(
1205 transaction_id=self.get_tx_id(),
1206 message_type=OmciSet.message_id,
1207 omci_message=OmciSet(
1208 entity_class=MulticastSubscriberConfigInfo.class_id,
1209 entity_id=entity_id,
1210 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1211 *data.keys()),
1212 data=data
1213 )
1214 )
1215 self.send_omci_message(frame)
1216
1217 def send_set_multicast_service_package(self,
1218 entity_id,
1219 row_key,
1220 vid_uni,
1221 max_groups,
1222 max_mcast_bw,
1223 mcast_oper_profile):
1224 data = dict(
1225 multicast_service_package_table=
1226 MulticastServicePackage(
1227 set_ctrl=1,
1228 row_key=row_key,
1229
1230 vid_uni=vid_uni,
1231 max_simultaneous_groups=max_groups,
1232 max_multicast_bw=max_mcast_bw,
1233 mcast_operations_profile_pointer=mcast_oper_profile
1234 )
1235 )
1236 frame = OmciFrame(
1237 transaction_id=self.get_tx_id(),
1238 message_type=OmciSet.message_id,
1239 omci_message=OmciSet(
1240 entity_class=MulticastSubscriberConfigInfo.class_id,
1241 entity_id=entity_id,
1242 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1243 *data.keys()),
1244 data=data
1245 )
1246 )
1247 self.send_omci_message(frame)
1248
1249 def send_set_multicast_allowed_preview_groups_row0(self,
1250 entity_id,
1251 row_key,
1252 src_ip,
1253 vlan_id_ani,
1254 vlan_id_uni):
1255 data = dict(
1256 allowed_preview_groups_table=
1257 AllowedPreviewGroupsRow0(
1258 set_ctrl=1,
1259 row_part_id=0,
1260 row_key=row_key,
1261
1262 src_ip=src_ip,
1263 vlan_id_ani=vlan_id_ani,
1264 vlan_id_uni=vlan_id_uni
1265 )
1266 )
1267 frame = OmciFrame(
1268 transaction_id=self.get_tx_id(),
1269 message_type=OmciSet.message_id,
1270 omci_message=OmciSet(
1271 entity_class=MulticastSubscriberConfigInfo.class_id,
1272 entity_id=entity_id,
1273 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1274 *data.keys()),
1275 data=data
1276 )
1277 )
1278 self.send_omci_message(frame)
1279
1280 def send_set_multicast_allowed_preview_groups_row1(self,
1281 entity_id,
1282 row_key,
1283 dst_ip,
1284 duration,
1285 time_left):
1286 data = dict(
1287 allowed_preview_groups_table=
1288 AllowedPreviewGroupsRow1(
1289 set_ctrl=1,
1290 row_part_id=1,
1291 row_key=row_key,
1292
1293 dst_ip=dst_ip,
1294 duration=duration,
1295 time_left=time_left
1296 )
1297 )
1298 frame = OmciFrame(
1299 transaction_id=self.get_tx_id(),
1300 message_type=OmciSet.message_id,
1301 omci_message=OmciSet(
1302 entity_class=MulticastSubscriberConfigInfo.class_id,
1303 entity_id=entity_id,
1304 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1305 *data.keys()),
1306 data=data
1307 )
1308 )
1309 self.send_omci_message(frame)
1310
Girish61687212018-01-08 12:48:58 +05301311 def send_reboot(self):
1312 frame = OmciFrame(
1313 transaction_id=self.get_tx_id(),
1314 message_type=OmciReboot.message_id,
1315 omci_message=OmciReboot(
1316 entity_class=OntG.class_id,
1317 entity_id=0
1318 )
1319 )
1320 self.send_omci_message(frame)
1321
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001322 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -06001323 def wait_for_response(self):
Girish61687212018-01-08 12:48:58 +05301324 self.log.info('wait-for-response')
Steve Crooks3c2c7582017-01-10 15:02:26 -06001325 try:
1326 response = yield self.incoming_messages.get()
Girish61687212018-01-08 12:48:58 +05301327 self.log.info('got-response')
1328 resp = OmciFrame(response)
1329 resp.show()
1330 returnValue(resp)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001331 except Exception as e:
Girish61687212018-01-08 12:48:58 +05301332 returnValue(None)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001333 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001334
Steve Crooks3c2c7582017-01-10 15:02:26 -06001335 @inlineCallbacks
Nicolas Palpacuerecb3d1e2018-03-14 17:00:14 -04001336 def message_exchange(self):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001337 # reset incoming message queue
1338 while self.incoming_messages.pending:
1339 _ = yield self.incoming_messages.get()
1340
rshettyf4bf19e2017-09-19 01:28:27 +05301341 cvid = BRDCM_DEFAULT_VLAN
Steve Crooks9b160d72017-03-31 10:48:29 -05001342
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001343 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -06001344 # MIB Reset - OntData - 0
1345 self.send_mib_reset()
1346 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001347
Steve Crooks3c2c7582017-01-10 15:02:26 -06001348 # Create AR - GalEthernetProfile - 1
1349 self.send_create_gal_ethernet_profile(1, 48)
1350 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001351
Steve Crooks9b160d72017-03-31 10:48:29 -05001352 # MAC Bridge Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001353 # Create AR - MacBridgeServiceProfile - 513
1354 self.send_create_mac_bridge_service_profile(0x201)
1355 yield self.wait_for_response()
1356
rshettyf4bf19e2017-09-19 01:28:27 +05301357 # Mapper Service config
1358 # Create AR - 802.1pMapperServiceProfile - 32769
1359 self.send_create_8021p_mapper_service_profile(0x8001)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001360 yield self.wait_for_response()
1361
Steve Crooks9b160d72017-03-31 10:48:29 -05001362 # MAC Bridge Port config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001363 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
1364 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
1365 yield self.wait_for_response()
1366
Steve Crooks9b160d72017-03-31 10:48:29 -05001367 # VLAN Tagging Filter config
1368 # Create AR - VlanTaggingFilterData - 8450 - c-vid
ggowdru42662622018-04-16 10:03:31 +05301369 # As per G.988 - Table 9.3.11-1 - Forward operation attribute values
1370 self.send_create_vlan_tagging_filter_data(0x2102, cvid, 0x10)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001371 yield self.wait_for_response()
1372
rshettyf4bf19e2017-09-19 01:28:27 +05301373
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -05001374 for port_id in self.uni_ports:
1375 # Extended VLAN Tagging Operation config
1376 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102(Uni-Port-Num)
1377 self.send_create_extended_vlan_tagging_operation_configuration_data(0x200 + port_id, 2, 0x100 + port_id)
1378 yield self.wait_for_response()
1379
1380 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1381 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x200 + port_id, 0x8100, 0x8100)
1382 yield self.wait_for_response()
1383
1384
1385
1386 # Create AR - MacBridgePortConfigData - Entity_id -
1387 # bridge ID -
1388 # port num -
1389 # tp_type -
1390 # IEEE MApper poniter
1391 self.send_create_mac_bridge_port_configuration_data(0x200 + port_id, 0x201, port_id, 1, 0x100 + port_id)
1392 yield self.wait_for_response()
1393
1394
1395
1396
1397
1398 # Set AR - ExtendedVlanTaggingOperationConfigData
1399 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1400 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, 1, 8, cvid)
1401 #yield self.wait_for_response()
1402
1403 # Set AR - ExtendedVlanTaggingOperationConfigData
1404 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1405 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x200 + port_id, 0x1000, cvid)
1406 yield self.wait_for_response()
rshettyf4bf19e2017-09-19 01:28:27 +05301407
1408 # Multicast related MEs
1409 # Set AR - MulticastOperationsProfile - Dynamic Access Control List table
1410 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
1411 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
1412 yield self.wait_for_response()
1413
Steve Crooks9b160d72017-03-31 10:48:29 -05001414 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001415 # Create AR - MulticastOperationsProfile
1416 self.send_create_multicast_operations_profile(0x201, 3)
1417 yield self.wait_for_response()
1418
rshettyf4bf19e2017-09-19 01:28:27 +05301419 # Multicast Subscriber config
1420 # Create AR - MulticastSubscriberConfigInfo
1421 self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201)
1422 yield self.wait_for_response()
1423
1424 # Create AR - GemPortNetworkCtp - 260 - 4000 - 0 Multicast
1425 self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0)
1426 yield self.wait_for_response()
1427
1428 # Multicast GEM Interworking config Multicast
1429 # Create AR - MulticastGemInterworkingTp - 6 - 260
1430 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
1431 yield self.wait_for_response()
1432
Steve Crooks9e85ce82017-03-20 12:00:53 -04001433 self.send_set_multicast_operations_profile_acl_row0(0x201,
1434 'dynamic',
1435 0,
1436 0x0fa0,
1437 0x0fa0,
1438 '0.0.0.0',
1439 '224.0.0.0',
1440 '239.255.255.255')
1441 yield self.wait_for_response()
1442
Steve Crooks9b160d72017-03-31 10:48:29 -05001443 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001444 # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI
Steve Crooks9b160d72017-03-31 10:48:29 -05001445 self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001446 yield self.wait_for_response()
1447
Steve Crooks9b160d72017-03-31 10:48:29 -05001448
rshettyf4bf19e2017-09-19 01:28:27 +05301449
1450 def add_uni_port(self, device, parent_logical_device_id,
1451 name, parent_port_num=None):
1452 self.log.info('adding-logical-port', device_id=device.id,
1453 logical_device_id=parent_logical_device_id,
1454 name=name)
1455 if parent_port_num is not None:
1456 uni = parent_port_num
1457 port_no = parent_port_num
1458 else:
1459 uni = self.uni_ports[0]
1460 port_no = device.proxy_address.channel_id + uni
1461 # register physical ports
1462 uni_port = Port(
1463 port_no=uni,
Shad Ansari2825d012018-02-22 23:57:46 +00001464 label='uni-'+str(uni),
rshettyf4bf19e2017-09-19 01:28:27 +05301465 type=Port.ETHERNET_UNI,
1466 admin_state=AdminState.ENABLED,
1467 oper_status=OperStatus.ACTIVE
1468 )
1469 self.adapter_agent.add_port(device.id, uni_port)
1470 # add uni port to logical device
1471 cap = OFPPF_1GB_FD | OFPPF_FIBER
1472 self.adapter_agent.add_logical_port(parent_logical_device_id,
1473 LogicalPort(
1474 id='uni-{}'.format(port_no),
1475 ofp_port=ofp_port(
1476 port_no=port_no,
1477 hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' %
1478 (device.proxy_address.onu_id & 0xff,
1479 (port_no >> 8) & 0xff,
1480 port_no & 0xff)),
1481 #name='uni-{}'.format(port_no),
1482 name=name,
1483 config=0,
1484 state=OFPPS_LIVE,
1485 curr=cap,
1486 advertised=cap,
1487 peer=cap,
1488 curr_speed=OFPPF_1GB_FD,
1489 max_speed=OFPPF_1GB_FD
1490 ),
1491 device_id=device.id,
1492 device_port_no=uni_port.port_no
1493 ))
rshettyc26a3c32017-07-27 11:06:38 +05301494
Girishd5823672017-11-23 12:15:14 +05301495 def del_uni_port(self, device, parent_logical_device_id,
1496 name, parent_port_num=None):
1497 self.log.info('del-uni-port', device_id=device.id,
1498 logical_device_id=parent_logical_device_id,
1499 name=name)
1500 if parent_port_num is not None:
1501 uni = parent_port_num
1502 port_no = parent_port_num
1503 else:
1504 uni = self.uni_ports[0]
1505 port_no = device.proxy_address.channel_id + uni
1506 # register physical ports
1507 ports = self.adapter_agent.get_ports(self.device_id, Port.ETHERNET_UNI)
1508 for port in ports:
Shad Ansari2825d012018-02-22 23:57:46 +00001509 if port.label == 'uni-'+str(uni):
Girishd5823672017-11-23 12:15:14 +05301510 break
1511 self.adapter_agent.delete_port(self.device_id, port)
1512 self.adapter_agent.delete_logical_port_by_id(parent_logical_device_id,
1513 'uni-{}'.format(port_no))
1514
Girish61687212018-01-08 12:48:58 +05301515
1516 @inlineCallbacks
1517 def delete_v_ont_ani(self, data):
1518 self.log.info('deleting-v_ont_ani')
1519
1520 device = self.adapter_agent.get_device(self.device_id)
1521 # construct message
1522 # MIB Reset - OntData - 0
1523 if device.connect_status != ConnectStatus.REACHABLE:
1524 self.log.error('device-unreachable')
1525 returnValue(None)
1526
1527 self.send_mib_reset()
1528 yield self.wait_for_response()
1529 self.proxy_address = device.proxy_address
1530 self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
1531
1532 ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1533 if ports is not None:
1534 for port in ports:
1535 if port.label == 'PON port':
1536 self.adapter_agent.delete_port(self.device_id, port)
1537 break
1538
rshettyc26a3c32017-07-27 11:06:38 +05301539 def create_interface(self, data):
rshetty1cc73982017-09-02 03:31:12 +05301540 if isinstance(data, VEnetConfig):
1541 parent_port_num = None
1542 onu_device = self.adapter_agent.get_device(self.device_id)
1543 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1544 parent_port_num = None
1545 for port in ports:
1546 if port.label == data.interface.name:
1547 parent_port_num = port.port_no
1548 break
1549
rshettyf4bf19e2017-09-19 01:28:27 +05301550 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1551 logical_device_id = parent_device.parent_id
1552 assert logical_device_id
Girish61687212018-01-08 12:48:58 +05301553 self.add_uni_port(onu_device, logical_device_id,
rshettyf4bf19e2017-09-19 01:28:27 +05301554 data.name, parent_port_num)
1555
1556 if parent_port_num is None:
rshetty1cc73982017-09-02 03:31:12 +05301557 self.log.error("matching-parent-uni-port-num-not-found")
1558 return
1559
1560 onu_ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1561 if onu_ports:
1562 # To-Do :
1563 # Assumed only one PON port and UNI port per ONU.
1564 pon_port = onu_ports[0]
1565 else:
1566 self.log.error("No-Pon-port-configured-yet")
1567 return
1568
1569 self.adapter_agent.delete_port_reference_from_parent(self.device_id,
1570 pon_port)
1571
1572 pon_port.peers[0].device_id = onu_device.parent_id
1573 pon_port.peers[0].port_no = parent_port_num
1574 self.adapter_agent.add_port_reference_to_parent(self.device_id,
1575 pon_port)
1576 else:
Girish61687212018-01-08 12:48:58 +05301577 self.log.info('Not-handled-Yet')
rshetty1cc73982017-09-02 03:31:12 +05301578 return
rshettyc26a3c32017-07-27 11:06:38 +05301579
1580 def update_interface(self, data):
Girish61687212018-01-08 12:48:58 +05301581 self.log.info('Not-Implemented-yet')
rshetty1cc73982017-09-02 03:31:12 +05301582 return
rshettyc26a3c32017-07-27 11:06:38 +05301583
1584 def remove_interface(self, data):
Girishd5823672017-11-23 12:15:14 +05301585 if isinstance(data, VEnetConfig):
Girishd5823672017-11-23 12:15:14 +05301586 onu_device = self.adapter_agent.get_device(self.device_id)
1587 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1588 parent_port_num = None
1589 for port in ports:
1590 if port.label == data.interface.name:
1591 parent_port_num = port.port_no
1592 break
1593
1594 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1595 logical_device_id = parent_device.parent_id
1596 assert logical_device_id
1597 self.del_uni_port(onu_device, logical_device_id,
1598 data.name, parent_port_num)
Girish61687212018-01-08 12:48:58 +05301599 if isinstance(data, VOntaniConfig):
1600 self.delete_v_ont_ani(data)
Girishd5823672017-11-23 12:15:14 +05301601 else:
Girish61687212018-01-08 12:48:58 +05301602 self.log.info('not-handled-yet')
rshetty1cc73982017-09-02 03:31:12 +05301603 return
rshettyf4bf19e2017-09-19 01:28:27 +05301604
1605 @inlineCallbacks
1606 def create_gemport(self, data):
Girish61687212018-01-08 12:48:58 +05301607 self.log.info('create-gemport')
1608 gem_port = GemportsConfigData()
1609 gem_port.CopyFrom(data)
rshettyf4bf19e2017-09-19 01:28:27 +05301610 if gem_port.tcont_ref is None:
Girish61687212018-01-08 12:48:58 +05301611 self.log.error('recevied-null-gem-port-data')
rshettyf4bf19e2017-09-19 01:28:27 +05301612 else:
1613 #To-Do Need to see how the valuse 0x8001 is derived
1614 self.send_create_gem_port_network_ctp(gem_port.gemport_id,
1615 gem_port.gemport_id, 0x8001,
1616 "bi-directional", 0x100)
1617 yield self.wait_for_response()
1618
1619 # GEM Interworking config
1620 # Create AR - GemInterworkingTp - Gem_port,TP_pointer -
1621 # Gem port CTP pointer -
1622 # Mapper service profile id
1623 self.send_create_gem_inteworking_tp(gem_port.gemport_id,
1624 gem_port.gemport_id, 0x8001)
1625 yield self.wait_for_response()
1626
1627 # Mapper Service Profile config
1628 # Set AR - 802.1pMapperServiceProfile - Mapper_ profile_id -
1629 # gem_port_tp pointer
1630 self.send_set_8021p_mapper_service_profile(0x8001,
1631 gem_port.gemport_id)
1632 yield self.wait_for_response()
1633
1634
1635 @inlineCallbacks
Girishd5823672017-11-23 12:15:14 +05301636 def remove_gemport(self, data):
Girish61687212018-01-08 12:48:58 +05301637 self.log.info('remove-gemport')
1638 gem_port = GemportsConfigData()
Girishd5823672017-11-23 12:15:14 +05301639 gem_port.CopyFrom(data)
Girish61687212018-01-08 12:48:58 +05301640 device = self.adapter_agent.get_device(self.device_id)
1641 if device.connect_status != ConnectStatus.REACHABLE:
1642 self.log.error('device-unreachable')
1643 returnValue(None)
Girishd5823672017-11-23 12:15:14 +05301644
Girish61687212018-01-08 12:48:58 +05301645 self.send_set_8021p_mapper_service_profile(0x8001,
1646 0xFFFF)
Girishd5823672017-11-23 12:15:14 +05301647 yield self.wait_for_response()
1648
1649 self.send_delete_omci_mesage(GemInterworkingTp.class_id,
Girish61687212018-01-08 12:48:58 +05301650 gem_port.gemport_id)
Girishd5823672017-11-23 12:15:14 +05301651 yield self.wait_for_response()
1652
1653 #To-Do Need to see how the valuse 0x8001 is derived
1654 self.send_delete_omci_mesage(GemPortNetworkCtp.class_id,
Girish61687212018-01-08 12:48:58 +05301655 gem_port.gemport_id)
Girishd5823672017-11-23 12:15:14 +05301656 yield self.wait_for_response()
1657
1658 @inlineCallbacks
rshettyf4bf19e2017-09-19 01:28:27 +05301659 def create_tcont(self, tcont_data, traffic_descriptor_data):
Girish61687212018-01-08 12:48:58 +05301660 self.log.info('create-tcont')
1661 tcont = TcontsConfigData()
rshettyf4bf19e2017-09-19 01:28:27 +05301662 tcont.CopyFrom(tcont_data)
Girish61687212018-01-08 12:48:58 +05301663 if tcont.interface_reference is not None:
1664 self.log.debug('tcont', tcont=tcont.alloc_id)
1665 self.send_set_tcont(0x8001, tcont.alloc_id)
1666 yield self.wait_for_response()
1667 else:
1668 self.log.info('recevied-null-tcont-data', tcont=tcont.alloc_id)
rshettyf4bf19e2017-09-19 01:28:27 +05301669
Girishd5823672017-11-23 12:15:14 +05301670 @inlineCallbacks
1671 def remove_tcont(self, tcont_data, traffic_descriptor_data):
Girish61687212018-01-08 12:48:58 +05301672 self.log.info('remove-tcont')
1673 device = self.adapter_agent.get_device(self.device_id)
1674 if device.connect_status != ConnectStatus.REACHABLE:
1675 self.log.error('device-unreachable')
1676 returnValue(None)
1677
Girishd5823672017-11-23 12:15:14 +05301678 self.send_set_tcont(0x8001, 0xFFFF)
1679 yield self.wait_for_response()
1680
rshettyf4bf19e2017-09-19 01:28:27 +05301681 def create_multicast_gemport(self, data):
1682 self.log.info('Send relevant OMCI message')
sathishgff102eb2017-12-21 12:19:19 +05301683
1684 @inlineCallbacks
1685 def disable(self, device):
1686 try:
1687 self.log.info('sending-admin-state-lock-towards-device', device=device)
Girish61687212018-01-08 12:48:58 +05301688
sathishgff102eb2017-12-21 12:19:19 +05301689 self.send_set_admin_state(0x0000, ADMIN_STATE_LOCK)
1690 yield self.wait_for_response()
1691 device = self.adapter_agent.get_device(device.id)
1692 # Disable all ports on that device
1693 self.adapter_agent.disable_all_ports(self.device_id)
1694 parent_device = self.adapter_agent.get_device(device.parent_id)
1695 logical_device_id = parent_device.parent_id
1696 assert logical_device_id
1697 # Mark OF PORT STATE DOWN
1698 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
1699 for port in ports:
1700 state = OFPPS_LINK_DOWN
1701 port_id = 'uni-{}'.format(port.port_no)
1702 self.update_logical_port(logical_device_id, port_id, state)
1703 device.oper_status = OperStatus.UNKNOWN
1704 device.connect_status = ConnectStatus.UNREACHABLE
1705 self.adapter_agent.update_device(device)
1706 except Exception as e:
1707 log.exception('exception-in-onu-disable', exception=e)
1708
1709 @inlineCallbacks
1710 def reenable(self, device):
1711 try:
1712 self.log.info('sending-admin-state-unlock-towards-device', device=device)
1713 self.send_set_admin_state(0x0000, ADMIN_STATE_UNLOCK)
1714 yield self.wait_for_response()
1715 device = self.adapter_agent.get_device(device.id)
1716 # Re-enable the ports on that device
1717 self.adapter_agent.enable_all_ports(device.id)
1718 parent_device = self.adapter_agent.get_device(device.parent_id)
1719 logical_device_id = parent_device.parent_id
1720 assert logical_device_id
1721 # Mark OF PORT STATE UP
1722 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
1723 for port in ports:
1724 state = OFPPS_LIVE
1725 port_id = 'uni-{}'.format(port.port_no)
1726 self.update_logical_port(logical_device_id, port_id, state)
1727 device.oper_status = OperStatus.ACTIVE
1728 device.connect_status = ConnectStatus.REACHABLE
1729 self.adapter_agent.update_device(device)
1730 except Exception as e:
1731 log.exception('exception-in-onu-reenable', exception=e)
1732
Girish61687212018-01-08 12:48:58 +05301733 @inlineCallbacks
1734 def reboot(self):
1735 self.log.info('reboot-device')
1736 device = self.adapter_agent.get_device(self.device_id)
1737 if device.connect_status != ConnectStatus.REACHABLE:
1738 self.log.error("device-unreacable")
1739 returnValue(None)
1740
1741 self.send_reboot()
1742 response = yield self.wait_for_response()
1743 if response is not None:
1744 omci_response = response.getfieldval("omci_message")
1745 success_code = omci_response.getfieldval("success_code")
1746 if success_code == 0:
1747 self.log.info("reboot-command-processed-successfully")
1748 # Update the device connection and operation status
1749 device = self.adapter_agent.get_device(self.device_id)
1750 device.connect_status = ConnectStatus.UNREACHABLE
1751 device.oper_status = OperStatus.DISCOVERED
1752 self.adapter_agent.update_device(device)
1753 self.disable_ports(device)
1754 else:
1755 self.log.info("reboot-failed", success_code=success_code)
1756 else:
1757 self.log.info("error-in-processing-reboot-response")
1758
1759 def disable_ports(self, onu_device):
1760 self.log.info('disable-ports', device_id=self.device_id)
1761
1762 # Disable all ports on that device
1763 self.adapter_agent.disable_all_ports(self.device_id)
1764
1765 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1766 assert parent_device
1767 logical_device_id = parent_device.parent_id
1768 assert logical_device_id
1769 ports = self.adapter_agent.get_ports(onu_device.id, Port.ETHERNET_UNI)
1770 for port in ports:
1771 port_id = 'uni-{}'.format(port.port_no)
1772 self.update_logical_port(logical_device_id, port_id, OFPPS_LINK_DOWN)