blob: 9504a922dcc6b76107f4252232187d8b68bc7746 [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
rshettyf4bf19e2017-09-19 01:28:27 +053056
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080057@implementer(IAdapterInterface)
58class BroadcomOnuAdapter(object):
59
60 name = 'broadcom_onu'
61
62 supported_device_types = [
63 DeviceType(
Steve Crooks3c2c7582017-01-10 15:02:26 -060064 id=name,
rshettyc26a3c32017-07-27 11:06:38 +053065 vendor_id='BRCM',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080066 adapter=name,
67 accepts_bulk_flow_update=True
68 )
69 ]
70
71 def __init__(self, adapter_agent, config):
72 self.adapter_agent = adapter_agent
73 self.config = config
74 self.descriptor = Adapter(
75 id=self.name,
76 vendor='Voltha project',
Girish61687212018-01-08 12:48:58 +053077 version='0.44',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080078 config=AdapterConfig(log_level=LogLevel.INFO)
79 )
Steve Crooks3c2c7582017-01-10 15:02:26 -060080 self.devices_handlers = dict() # device_id -> BroadcomOnuHandler()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080081
Peter Shafik9107f2e2017-05-02 15:54:39 -040082 # register for adapter messages
83 self.adapter_agent.register_for_inter_adapter_messages()
84
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080085 def start(self):
86 log.debug('starting')
87 log.info('started')
88
89 def stop(self):
90 log.debug('stopping')
91 log.info('stopped')
92
93 def adapter_descriptor(self):
94 return self.descriptor
95
96 def device_types(self):
97 return DeviceTypes(items=self.supported_device_types)
98
99 def health(self):
100 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
101
102 def change_master_state(self, master):
103 raise NotImplementedError()
104
105 def adopt_device(self, device):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600106 log.info('adopt_device', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530107 self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id)
108 reactor.callLater(0, self.devices_handlers[device.id].activate, device)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800109 return device
110
khenaidoo032d3302017-06-09 14:50:04 -0400111 def reconcile_device(self, device):
sathishg01ca0802017-11-03 18:32:11 +0530112 log.info('reconcile-device', device_id=device.id)
113 self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id)
114 reactor.callLater(0, self.devices_handlers[device.id].reconcile, device)
khenaidoo032d3302017-06-09 14:50:04 -0400115
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800116 def abandon_device(self, device):
117 raise NotImplementedError()
118
Khen Nursimulud068d812017-03-06 11:44:18 -0500119 def disable_device(self, device):
sathishgff102eb2017-12-21 12:19:19 +0530120 log.info('disable-onu-device', device_id=device.id)
121 if device.id in self.devices_handlers:
122 handler = self.devices_handlers[device.id]
123 if handler is not None:
124 handler.disable(device)
Khen Nursimulud068d812017-03-06 11:44:18 -0500125
126 def reenable_device(self, device):
sathishgff102eb2017-12-21 12:19:19 +0530127 log.info('reenable-onu-device', device_id=device.id)
128 if device.id in self.devices_handlers:
129 handler = self.devices_handlers[device.id]
130 if handler is not None:
131 handler.reenable(device)
Khen Nursimulud068d812017-03-06 11:44:18 -0500132
133 def reboot_device(self, device):
Girish61687212018-01-08 12:48:58 +0530134 log.info('reboot-device', device_id=device.id)
135 if device.id in self.devices_handlers:
136 handler = self.devices_handlers[device.id]
137 if handler is not None:
138 handler.reboot()
Khen Nursimulud068d812017-03-06 11:44:18 -0500139
Lydia Fang01f2e852017-06-28 17:24:58 -0700140 def download_image(self, device, request):
141 raise NotImplementedError()
142
143 def get_image_download_status(self, device, request):
144 raise NotImplementedError()
145
146 def cancel_image_download(self, device, request):
147 raise NotImplementedError()
148
149 def activate_image_update(self, device, request):
150 raise NotImplementedError()
151
152 def revert_image_update(self, device, request):
153 raise NotImplementedError()
154
sathishg5ae86222017-06-28 15:16:29 +0530155 def self_test_device(self, device):
156 """
157 This is called to Self a device based on a NBI call.
158 :param device: A Voltha.Device object.
159 :return: Will return result of self test
160 """
161 log.info('self-test-device', device=device.id)
162 raise NotImplementedError()
163
Khen Nursimulud068d812017-03-06 11:44:18 -0500164 def delete_device(self, device):
Girishd5823672017-11-23 12:15:14 +0530165 log.info('delete-device', device_id=device.id)
166 if device.id in self.devices_handlers:
167 handler = self.devices_handlers[device.id]
168 if handler is not None:
169 handler.delete(device)
170 del self.devices_handlers[device.id]
171 return
Khen Nursimulud068d812017-03-06 11:44:18 -0500172
173 def get_device_details(self, device):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800174 raise NotImplementedError()
175
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500176 def update_pm_config(self, device, pm_configs):
177 raise NotImplementedError()
178
Steve Crooks3c2c7582017-01-10 15:02:26 -0600179 def update_flows_bulk(self, device, flows, groups):
rshettyf4bf19e2017-09-19 01:28:27 +0530180 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600181 log.info('bulk-flow-update', device_id=device.id,
182 flows=flows, groups=groups)
rshettyf4bf19e2017-09-19 01:28:27 +0530183 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600184 assert len(groups.items) == 0
rshettyf4bf19e2017-09-19 01:28:27 +0530185 handler = self.devices_handlers[device.id]
Steve Crooksf248e182017-02-07 10:50:24 -0500186 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600187
188 def update_flows_incrementally(self, device, flow_changes, group_changes):
189 raise NotImplementedError()
190
191 def send_proxied_message(self, proxy_address, msg):
192 log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
193
194 def receive_proxied_message(self, proxy_address, msg):
195 log.info('receive-proxied-message', proxy_address=proxy_address,
196 device_id=proxy_address.device_id, msg=hexify(msg))
rshettyf4bf19e2017-09-19 01:28:27 +0530197 # Device_id from the proxy_address is the olt device id. We need to
198 # get the onu device id using the port number in the proxy_address
199 device = self.adapter_agent. \
200 get_child_device_with_proxy_address(proxy_address)
201 if device:
202 handler = self.devices_handlers[device.id]
203 handler.receive_message(msg)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600204
205 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
206 log.info('packet-out', logical_device_id=logical_device_id,
207 egress_port_no=egress_port_no, msg_len=len(msg))
208
Peter Shafik9107f2e2017-05-02 15:54:39 -0400209 def receive_inter_adapter_message(self, msg):
210 log.info('receive_inter_adapter_message', msg=msg)
Peter Shafikd7f33772017-05-17 13:56:34 -0400211 proxy_address = msg['proxy_address']
212 assert proxy_address is not None
rshettyf4bf19e2017-09-19 01:28:27 +0530213 # Device_id from the proxy_address is the olt device id. We need to
214 # get the onu device id using the port number in the proxy_address
215 device = self.adapter_agent. \
216 get_child_device_with_proxy_address(proxy_address)
217 if device:
218 handler = self.devices_handlers[device.id]
219 handler.event_messages.put(msg)
Girish61687212018-01-08 12:48:58 +0530220 else:
221 log.error("device-not-found")
Peter Shafik9107f2e2017-05-02 15:54:39 -0400222
Nikolay Titov89004ec2017-06-19 18:22:42 -0400223 def create_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530224 log.info('create-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530225 if device.id in self.devices_handlers:
226 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530227 if handler is not None:
228 handler.create_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400229
230 def update_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530231 log.info('update-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530232 if device.id in self.devices_handlers:
233 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530234 if handler is not None:
235 handler.update_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400236
237 def remove_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530238 log.info('remove-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530239 if device.id in self.devices_handlers:
240 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530241 if handler is not None:
242 handler.remove_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400243
244 def receive_onu_detect_state(self, device_id, state):
245 raise NotImplementedError()
246
Nikolay Titov176f1db2017-08-10 12:38:43 -0400247 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
rshettyf4bf19e2017-09-19 01:28:27 +0530248 log.info('create-tcont', device_id=device.id)
249 if device.id in self.devices_handlers:
250 handler = self.devices_handlers[device.id]
251 if handler is not None:
252 handler.create_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400253
254 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
255 raise NotImplementedError()
256
257 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
Girishd5823672017-11-23 12:15:14 +0530258 log.info('remove-tcont', device_id=device.id)
259 if device.id in self.devices_handlers:
260 handler = self.devices_handlers[device.id]
261 if handler is not None:
262 handler.remove_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400263
264 def create_gemport(self, device, data):
rshettyf4bf19e2017-09-19 01:28:27 +0530265 log.info('create-gemport', device_id=device.id)
266 if device.id in self.devices_handlers:
267 handler = self.devices_handlers[device.id]
268 if handler is not None:
269 handler.create_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400270
271 def update_gemport(self, device, data):
272 raise NotImplementedError()
273
274 def remove_gemport(self, device, data):
Girishd5823672017-11-23 12:15:14 +0530275 log.info('remove-gemport', device_id=device.id)
276 if device.id in self.devices_handlers:
277 handler = self.devices_handlers[device.id]
278 if handler is not None:
279 handler.remove_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400280
281 def create_multicast_gemport(self, device, data):
rshettyf4bf19e2017-09-19 01:28:27 +0530282 log.info('create-multicast-gemport', device_id=device.id)
283 if device.id in self.devices_handlers:
284 handler = self.devices_handlers[device.id]
285 if handler is not None:
286 handler.create_multicast_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400287
288 def update_multicast_gemport(self, device, data):
289 raise NotImplementedError()
290
291 def remove_multicast_gemport(self, device, data):
292 raise NotImplementedError()
293
294 def create_multicast_distribution_set(self, device, data):
295 raise NotImplementedError()
296
297 def update_multicast_distribution_set(self, device, data):
298 raise NotImplementedError()
299
300 def remove_multicast_distribution_set(self, device, data):
301 raise NotImplementedError()
302
303 def suppress_alarm(self, filter):
304 raise NotImplementedError()
305
Stephane Barbarie980a0912017-05-11 11:27:06 -0400306 def unsuppress_alarm(self, filter):
307 raise NotImplementedError()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600308
309class BroadcomOnuHandler(object):
310
311 def __init__(self, adapter, device_id):
312 self.adapter = adapter
313 self.adapter_agent = adapter.adapter_agent
314 self.device_id = device_id
315 self.log = structlog.get_logger(device_id=device_id)
316 self.incoming_messages = DeferredQueue()
Peter Shafikd7f33772017-05-17 13:56:34 -0400317 self.event_messages = DeferredQueue()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600318 self.proxy_address = None
319 self.tx_id = 0
320
Peter Shafikd7f33772017-05-17 13:56:34 -0400321 # Need to query ONU for number of supported uni ports
322 # For now, temporarily set number of ports to 1 - port #2
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500323 self.uni_ports = (1, 2, 3, 4, 5)
Peter Shafikd7f33772017-05-17 13:56:34 -0400324
325 # Handle received ONU event messages
326 reactor.callLater(0, self.handle_onu_events)
327
Steve Crooks3c2c7582017-01-10 15:02:26 -0600328 def receive_message(self, msg):
329 self.incoming_messages.put(msg)
330
Peter Shafikd7f33772017-05-17 13:56:34 -0400331 @inlineCallbacks
332 def handle_onu_events(self):
333 event_msg = yield self.event_messages.get()
334
335 if event_msg['event'] == 'activation-completed':
336
337 if event_msg['event_data']['activation_successful'] == True:
338 for uni in self.uni_ports:
339 port_no = self.proxy_address.channel_id + uni
Girishd5823672017-11-23 12:15:14 +0530340 yield self.message_exchange(
341 self.proxy_address.onu_id,
342 self.proxy_address.onu_session_id,
343 port_no)
Peter Shafikd7f33772017-05-17 13:56:34 -0400344
345 device = self.adapter_agent.get_device(self.device_id)
Girishd5823672017-11-23 12:15:14 +0530346 device.connect_status = ConnectStatus.REACHABLE
Peter Shafikd7f33772017-05-17 13:56:34 -0400347 device.oper_status = OperStatus.ACTIVE
348 self.adapter_agent.update_device(device)
349
350 else:
351 device = self.adapter_agent.get_device(self.device_id)
352 device.oper_status = OperStatus.FAILED
353 self.adapter_agent.update_device(device)
354
355 elif event_msg['event'] == 'deactivation-completed':
356 device = self.adapter_agent.get_device(self.device_id)
357 device.oper_status = OperStatus.DISCOVERED
358 self.adapter_agent.update_device(device)
359
Girish61687212018-01-08 12:48:58 +0530360 elif event_msg['event'] == 'deactivate-onu':
Girisha9eb0212017-12-14 21:52:59 +0530361 device = self.adapter_agent.get_device(self.device_id)
362 device.connect_status = ConnectStatus.UNREACHABLE
363 device.oper_status = OperStatus.DISCOVERED
364 self.adapter_agent.update_device(device)
Girish61687212018-01-08 12:48:58 +0530365 self.disable_ports(device)
Girisha9eb0212017-12-14 21:52:59 +0530366
Peter Shafikd7f33772017-05-17 13:56:34 -0400367 elif event_msg['event'] == 'ranging-completed':
368
369 if event_msg['event_data']['ranging_successful'] == True:
370 device = self.adapter_agent.get_device(self.device_id)
371 device.oper_status = OperStatus.ACTIVATING
372 self.adapter_agent.update_device(device)
373
374 else:
375 device = self.adapter_agent.get_device(self.device_id)
376 device.oper_status = OperStatus.FAILED
377 self.adapter_agent.update_device(device)
378
Shad Ansari2825d012018-02-22 23:57:46 +0000379 elif event_msg['event'] == 'create-tcont':
380 tcont = TcontsConfigData()
381 tcont.alloc_id = event_msg['event_data']['alloc_id']
382 self.create_tcont(tcont, traffic_descriptor_data=None)
383
384 elif event_msg['event'] == 'create-venet':
385 venet = VEnetConfig(name=event_msg['event_data']['uni_name'])
386 venet.interface.name = event_msg['event_data']['interface_name']
387 self.create_interface(venet)
388
389 elif event_msg['event'] == 'create-gemport':
390 gem_port = GemportsConfigData()
391 gem_port.gemport_id = event_msg['event_data']['gemport_id']
392 self.create_gemport(gem_port)
393
Peter Shafikd7f33772017-05-17 13:56:34 -0400394 # Handle next event
395 reactor.callLater(0, self.handle_onu_events)
396
397
Steve Crooks3c2c7582017-01-10 15:02:26 -0600398 def activate(self, device):
399 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800400
401 # first we verify that we got parent reference and proxy info
402 assert device.parent_id
403 assert device.proxy_address.device_id
Steve Crooks9b160d72017-03-31 10:48:29 -0500404 #assert device.proxy_address.channel_id # c-vid
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800405
Steve Crooks3c2c7582017-01-10 15:02:26 -0600406 # register for proxied messages right away
407 self.proxy_address = device.proxy_address
408 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
409
Peter Shafik9107f2e2017-05-02 15:54:39 -0400410
Steve Crooks3c2c7582017-01-10 15:02:26 -0600411 # populate device info
412 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800413 device.vendor = 'Broadcom'
Steve Crooks9e85ce82017-03-20 12:00:53 -0400414 device.model = 'n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800415 device.hardware_version = 'to be filled'
416 device.firmware_version = 'to be filled'
ggowdru236bd952017-06-20 20:32:55 -0700417 device.images.image.extend([
418 Image(version="to be filled")
419 ])
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800420 device.connect_status = ConnectStatus.REACHABLE
421 self.adapter_agent.update_device(device)
422
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800423 self.adapter_agent.add_port(device.id, Port(
Steve Crooks9b160d72017-03-31 10:48:29 -0500424 port_no=100,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800425 label='PON port',
426 type=Port.PON_ONU,
427 admin_state=AdminState.ENABLED,
428 oper_status=OperStatus.ACTIVE,
429 peers=[
430 Port.PeerPort(
431 device_id=device.parent_id,
432 port_no=device.parent_port_no
433 )
434 ]
435 ))
436
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800437 parent_device = self.adapter_agent.get_device(device.parent_id)
438 logical_device_id = parent_device.parent_id
439 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800440 device = self.adapter_agent.get_device(device.id)
Peter Shafikd7f33772017-05-17 13:56:34 -0400441 device.oper_status = OperStatus.DISCOVERED
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800442 self.adapter_agent.update_device(device)
443
sathishg01ca0802017-11-03 18:32:11 +0530444 def reconcile(self, device):
445
Girish61687212018-01-08 12:48:58 +0530446 self.log.info('reconciling-broadcom-onu-device-starts')
sathishg01ca0802017-11-03 18:32:11 +0530447
448 # first we verify that we got parent reference and proxy info
449 assert device.parent_id
450 assert device.proxy_address.device_id
451
452 # register for proxied messages right away
453 self.proxy_address = device.proxy_address
454 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
455
456 # TODO: Query ONU current status after reconcile and update.
457 # To be addressed in future commits.
458
Girish61687212018-01-08 12:48:58 +0530459 self.log.info('reconciling-broadcom-onu-device-ends')
sathishg01ca0802017-11-03 18:32:11 +0530460
sathishg24dad1e2018-01-10 10:48:45 +0530461 def update_logical_port(self, logical_device_id, port_id, state):
462 self.log.info('updating-logical-port', logical_port_id=port_id,
463 logical_device_id=logical_device_id, state=state)
464 logical_port = self.adapter_agent.get_logical_port(logical_device_id,
465 port_id)
466 logical_port.ofp_port.state = state
467 self.adapter_agent.update_logical_port(logical_device_id,
468 logical_port)
469
Girishd5823672017-11-23 12:15:14 +0530470 def delete(self, device):
471 self.log.info('delete-onu')
Girish61687212018-01-08 12:48:58 +0530472 # The device is already deleted in delete_v_ont_ani(). No more
473 # handling needed here
sathishg01ca0802017-11-03 18:32:11 +0530474
Steve Crooks3c2c7582017-01-10 15:02:26 -0600475 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500476 def update_flow_table(self, device, flows):
477 #
478 # We need to proxy through the OLT to get to the ONU
479 # Configuration from here should be using OMCI
480 #
rshettyf4bf19e2017-09-19 01:28:27 +0530481 #self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800482
Steve Crooksf248e182017-02-07 10:50:24 -0500483 def is_downstream(port):
Steve Crooks9b160d72017-03-31 10:48:29 -0500484 return port == 100 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800485
Steve Crooksf248e182017-02-07 10:50:24 -0500486 def is_upstream(port):
487 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800488
Steve Crooksf248e182017-02-07 10:50:24 -0500489 for flow in flows:
Steve Crooks9b160d72017-03-31 10:48:29 -0500490 _type = None
491 _port = None
492 _vlan_vid = None
493 _udp_dst = None
494 _udp_src = None
495 _ipv4_dst = None
496 _ipv4_src = None
497 _metadata = None
498 _output = None
499 _push_tpid = None
500 _field = None
501 _set_vlan_vid = None
rshettyf4bf19e2017-09-19 01:28:27 +0530502 self.log.info('bulk-flow-update', device_id=device.id, flow=flow)
Steve Crooksf248e182017-02-07 10:50:24 -0500503 try:
504 _in_port = fd.get_in_port(flow)
505 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600506
Steve Crooksf248e182017-02-07 10:50:24 -0500507 if is_downstream(_in_port):
508 self.log.info('downstream-flow')
509 elif is_upstream(_in_port):
510 self.log.info('upstream-flow')
511 else:
512 raise Exception('port should be 1 or 2 by our convention')
513
514 _out_port = fd.get_out_port(flow) # may be None
515 self.log.info('out-port', out_port=_out_port)
516
517 for field in fd.get_ofb_fields(flow):
518 if field.type == fd.ETH_TYPE:
519 _type = field.eth_type
520 self.log.info('field-type-eth-type',
521 eth_type=_type)
522
523 elif field.type == fd.IP_PROTO:
524 _proto = field.ip_proto
525 self.log.info('field-type-ip-proto',
526 ip_proto=_proto)
527
528 elif field.type == fd.IN_PORT:
529 _port = field.port
530 self.log.info('field-type-in-port',
531 in_port=_port)
532
533 elif field.type == fd.VLAN_VID:
534 _vlan_vid = field.vlan_vid & 0xfff
535 self.log.info('field-type-vlan-vid',
536 vlan=_vlan_vid)
537
538 elif field.type == fd.VLAN_PCP:
539 _vlan_pcp = field.vlan_pcp
540 self.log.info('field-type-vlan-pcp',
541 pcp=_vlan_pcp)
542
543 elif field.type == fd.UDP_DST:
544 _udp_dst = field.udp_dst
545 self.log.info('field-type-udp-dst',
546 udp_dst=_udp_dst)
547
548 elif field.type == fd.UDP_SRC:
549 _udp_src = field.udp_src
550 self.log.info('field-type-udp-src',
551 udp_src=_udp_src)
552
553 elif field.type == fd.IPV4_DST:
554 _ipv4_dst = field.ipv4_dst
555 self.log.info('field-type-ipv4-dst',
556 ipv4_dst=_ipv4_dst)
557
558 elif field.type == fd.IPV4_SRC:
559 _ipv4_src = field.ipv4_src
560 self.log.info('field-type-ipv4-src',
561 ipv4_dst=_ipv4_src)
562
563 elif field.type == fd.METADATA:
Steve Crooks9b160d72017-03-31 10:48:29 -0500564 _metadata = field.table_metadata
Steve Crooksf248e182017-02-07 10:50:24 -0500565 self.log.info('field-type-metadata',
566 metadata=_metadata)
567
568 else:
569 raise NotImplementedError('field.type={}'.format(
570 field.type))
571
572 for action in fd.get_actions(flow):
573
574 if action.type == fd.OUTPUT:
575 _output = action.output.port
576 self.log.info('action-type-output',
577 output=_output, in_port=_in_port)
578
579 elif action.type == fd.POP_VLAN:
580 self.log.info('action-type-pop-vlan',
581 in_port=_in_port)
582
583 elif action.type == fd.PUSH_VLAN:
584 _push_tpid = action.push.ethertype
Girish61687212018-01-08 12:48:58 +0530585 self.log.info('action-type-push-vlan',
Steve Crooksf248e182017-02-07 10:50:24 -0500586 push_tpid=_push_tpid, in_port=_in_port)
587 if action.push.ethertype != 0x8100:
588 self.log.error('unhandled-tpid',
589 ethertype=action.push.ethertype)
590
591 elif action.type == fd.SET_FIELD:
592 _field = action.set_field.field.ofb_field
593 assert (action.set_field.field.oxm_class ==
594 OFPXMC_OPENFLOW_BASIC)
595 self.log.info('action-type-set-field',
596 field=_field, in_port=_in_port)
597 if _field.type == fd.VLAN_VID:
Steve Crooks9b160d72017-03-31 10:48:29 -0500598 _set_vlan_vid = _field.vlan_vid & 0xfff
599 self.log.info('set-field-type-valn-vid', _set_vlan_vid)
Steve Crooksf248e182017-02-07 10:50:24 -0500600 else:
601 self.log.error('unsupported-action-set-field-type',
602 field_type=_field.type)
603 else:
Girish61687212018-01-08 12:48:58 +0530604 self.log.error('unsupported-action-type',
Steve Crooksf248e182017-02-07 10:50:24 -0500605 action_type=action.type, in_port=_in_port)
606
607 #
608 # All flows created from ONU adapter should be OMCI based
609 #
rshettyf4bf19e2017-09-19 01:28:27 +0530610 if _vlan_vid == 0 and _set_vlan_vid != None and _set_vlan_vid != 0:
Steve Crooks9b160d72017-03-31 10:48:29 -0500611 # allow priority tagged packets
612 # Set AR - ExtendedVlanTaggingOperationConfigData
613 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
rshettyf4bf19e2017-09-19 01:28:27 +0530614
615 self.send_delete_vlan_tagging_filter_data(0x2102)
616 yield self.wait_for_response()
617
618 #self.send_set_vlan_tagging_filter_data(0x2102, _set_vlan_vid)
619 self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid)
620 yield self.wait_for_response()
621
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500622 for port_id in self.uni_ports:
rshettyf4bf19e2017-09-19 01:28:27 +0530623
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500624 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x200 + port_id, 0x1000, _set_vlan_vid)
625 yield self.wait_for_response()
Steve Crooks9b160d72017-03-31 10:48:29 -0500626
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500627 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x200 + port_id, 8, 0, 0,
628 1, 8, _set_vlan_vid)
629 yield self.wait_for_response()
630
631
Steve Crooksf248e182017-02-07 10:50:24 -0500632
633 except Exception as e:
Girish61687212018-01-08 12:48:58 +0530634 self.log.exception('failed-to-install-flow', e=e, flow=flow)
Steve Crooksf248e182017-02-07 10:50:24 -0500635
Steve Crooks3c2c7582017-01-10 15:02:26 -0600636 def get_tx_id(self):
637 self.tx_id += 1
638 return self.tx_id
639
640 def send_omci_message(self, frame):
641 _frame = hexify(str(frame))
642 self.log.info('send-omci-message-%s' % _frame)
643 device = self.adapter_agent.get_device(self.device_id)
644 try:
645 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
646 except Exception as e:
647 self.log.info('send-omci-message-exception', exc=str(e))
648
649 def send_get_circuit_pack(self, entity_id=0):
650 frame = OmciFrame(
651 transaction_id=self.get_tx_id(),
652 message_type=OmciGet.message_id,
653 omci_message=OmciGet(
654 entity_class=CircuitPack.class_id,
655 entity_id=entity_id,
656 attributes_mask=CircuitPack.mask_for('vendor_id')
657 )
658 )
659 self.send_omci_message(frame)
660
661 def send_mib_reset(self, entity_id=0):
662 frame = OmciFrame(
663 transaction_id=self.get_tx_id(),
664 message_type=OmciMibReset.message_id,
665 omci_message=OmciMibReset(
666 entity_class=OntData.class_id,
667 entity_id=entity_id
668 )
669 )
670 self.send_omci_message(frame)
671
Steve Crooks9e85ce82017-03-20 12:00:53 -0400672 def send_create_gal_ethernet_profile(self,
673 entity_id,
674 max_gem_payload_size):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600675 frame = OmciFrame(
676 transaction_id=self.get_tx_id(),
677 message_type=OmciCreate.message_id,
678 omci_message=OmciCreate(
679 entity_class=GalEthernetProfile.class_id,
680 entity_id=entity_id,
681 data=dict(
682 max_gem_payload_size=max_gem_payload_size
683 )
684 )
685 )
686 self.send_omci_message(frame)
687
sathishgff102eb2017-12-21 12:19:19 +0530688 def send_set_admin_state(self,
689 entity_id,
690 admin_state):
691 data = dict(
692 administrative_state=admin_state
693 )
694 frame = OmciFrame(
695 transaction_id=self.get_tx_id(),
696 message_type=OmciSet.message_id,
697 omci_message=OmciSet(
698 entity_class=OntG.class_id,
699 entity_id=entity_id,
700 attributes_mask=OntG.mask_for(*data.keys()),
701 data=data
702 )
703 )
704 self.send_omci_message(frame)
705
Steve Crooks9e85ce82017-03-20 12:00:53 -0400706 def send_set_tcont(self,
707 entity_id,
708 alloc_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600709 data = dict(
710 alloc_id=alloc_id
711 )
712 frame = OmciFrame(
713 transaction_id=self.get_tx_id(),
714 message_type=OmciSet.message_id,
715 omci_message=OmciSet(
716 entity_class=Tcont.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400717 entity_id=entity_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600718 attributes_mask=Tcont.mask_for(*data.keys()),
719 data=data
720 )
721 )
722 self.send_omci_message(frame)
723
Steve Crooks9e85ce82017-03-20 12:00:53 -0400724 def send_create_8021p_mapper_service_profile(self,
725 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600726 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400727 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600728 message_type=OmciCreate.message_id,
729 omci_message=OmciCreate(
730 entity_class=Ieee8021pMapperServiceProfile.class_id,
731 entity_id=entity_id,
732 data=dict(
733 tp_pointer=OmciNullPointer,
734 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
Steve Crooks9b160d72017-03-31 10:48:29 -0500735 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
736 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
737 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
738 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
739 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
740 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
741 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
Steve Crooks3c2c7582017-01-10 15:02:26 -0600742 )
743 )
744 )
745 self.send_omci_message(frame)
746
Steve Crooks9e85ce82017-03-20 12:00:53 -0400747 def send_create_mac_bridge_service_profile(self,
748 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600749 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400750 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600751 message_type=OmciCreate.message_id,
752 omci_message=OmciCreate(
753 entity_class=MacBridgeServiceProfile.class_id,
754 entity_id=entity_id,
755 data=dict(
756 spanning_tree_ind=False,
757 learning_ind=True,
758 priority=0x8000,
759 max_age=20 * 256,
760 hello_time=2 * 256,
761 forward_delay=15 * 256,
762 unknown_mac_address_discard=True
763 )
764 )
765 )
766 self.send_omci_message(frame)
767
Steve Crooks9e85ce82017-03-20 12:00:53 -0400768 def send_create_gem_port_network_ctp(self,
769 entity_id,
770 port_id,
771 tcont_id,
772 direction,
773 tm):
774 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
775 if _directions.has_key(direction):
776 _direction = _directions[direction]
777 else:
778 self.log.error('invalid-gem-port-direction', direction=direction)
779 raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction))
780
Steve Crooks3c2c7582017-01-10 15:02:26 -0600781 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400782 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600783 message_type=OmciCreate.message_id,
784 omci_message=OmciCreate(
785 entity_class=GemPortNetworkCtp.class_id,
786 entity_id=entity_id,
787 data=dict(
788 port_id=port_id,
789 tcont_pointer=tcont_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400790 direction=_direction,
791 traffic_management_pointer_upstream=tm
Steve Crooks3c2c7582017-01-10 15:02:26 -0600792 )
793 )
794 )
795 self.send_omci_message(frame)
796
Steve Crooks9e85ce82017-03-20 12:00:53 -0400797 def send_create_multicast_gem_interworking_tp(self,
798 entity_id,
799 gem_port_net_ctp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600800 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400801 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600802 message_type=OmciCreate.message_id,
803 omci_message=OmciCreate(
804 entity_class=MulticastGemInterworkingTp.class_id,
805 entity_id=entity_id,
806 data=dict(
807 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
808 interworking_option=0,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400809 service_profile_pointer=0x1
Steve Crooks3c2c7582017-01-10 15:02:26 -0600810 )
811 )
812 )
813 self.send_omci_message(frame)
814
Steve Crooks9e85ce82017-03-20 12:00:53 -0400815 def send_create_gem_inteworking_tp(self,
816 entity_id,
817 gem_port_net_ctp_id,
818 service_profile_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600819 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400820 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600821 message_type=OmciCreate.message_id,
822 omci_message=OmciCreate(
823 entity_class=GemInterworkingTp.class_id,
824 entity_id=entity_id,
825 data=dict(
826 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
827 interworking_option=5,
828 service_profile_pointer=service_profile_id,
829 interworking_tp_pointer=0x0,
830 gal_profile_pointer=0x1
831 )
832 )
833 )
834 self.send_omci_message(frame)
835
Girishd5823672017-11-23 12:15:14 +0530836 def send_delete_omci_mesage(self,
837 class_id,
838 entity_id):
839 frame = OmciFrame(
840 transaction_id=self.get_tx_id(),
841 message_type=OmciDelete.message_id,
842 omci_message=OmciDelete(
843 entity_class=class_id,
844 entity_id=entity_id
845 )
846 )
847 self.send_omci_message(frame)
848
Steve Crooks9e85ce82017-03-20 12:00:53 -0400849 def send_set_8021p_mapper_service_profile(self,
850 entity_id,
851 interwork_tp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600852 data = dict(
Steve Crooks9b160d72017-03-31 10:48:29 -0500853 interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id,
854 interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id,
855 interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id,
856 interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id,
857 interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id,
858 interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id,
859 interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id,
860 interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600861 )
862 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400863 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600864 message_type=OmciSet.message_id,
865 omci_message=OmciSet(
866 entity_class=Ieee8021pMapperServiceProfile.class_id,
867 entity_id=entity_id,
868 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
869 *data.keys()),
870 data=data
871 )
872 )
873 self.send_omci_message(frame)
874
875 def send_create_mac_bridge_port_configuration_data(self,
876 entity_id,
877 bridge_id,
878 port_id,
879 tp_type,
880 tp_id):
881 frame = OmciFrame(
882 transaction_id=self.get_tx_id(),
883 message_type=OmciCreate.message_id,
884 omci_message=OmciCreate(
885 entity_class=MacBridgePortConfigurationData.class_id,
886 entity_id=entity_id,
887 data=dict(
Girish61687212018-01-08 12:48:58 +0530888 bridge_id_pointer=bridge_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600889 port_num=port_id,
890 tp_type=tp_type,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400891 tp_pointer=tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600892 )
893 )
894 )
895 self.send_omci_message(frame)
896
Steve Crooks9e85ce82017-03-20 12:00:53 -0400897 def send_create_vlan_tagging_filter_data(self,
898 entity_id,
899 vlan_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600900 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400901 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600902 message_type=OmciCreate.message_id,
903 omci_message=OmciCreate(
904 entity_class=VlanTaggingFilterData.class_id,
905 entity_id=entity_id,
906 data=dict(
907 vlan_filter_0=vlan_id,
908 forward_operation=0x10,
909 number_of_entries=1
910 )
911 )
912 )
913 self.send_omci_message(frame)
914
rshettyf4bf19e2017-09-19 01:28:27 +0530915 def send_set_vlan_tagging_filter_data(self,
916 entity_id,
917 vlan_id):
918 data = dict(
919 vlan_filter_0=vlan_id,
920 forward_operation=0x10,
921 number_of_entries=1
922 )
923
924 frame = OmciFrame(
925 transaction_id=self.get_tx_id(),
926 message_type=OmciSet.message_id,
927 omci_message=OmciSet(
928 entity_class=VlanTaggingFilterData.class_id,
929 entity_id=entity_id,
930 attributes_mask=VlanTaggingFilterData.mask_for(
931 *data.keys()),
932 data=data
933 )
934 )
935 self.send_omci_message(frame)
936
937 def send_delete_vlan_tagging_filter_data(self,
938 entity_id):
939 frame = OmciFrame(
940 transaction_id=self.get_tx_id(),
941 message_type=OmciDelete.message_id,
942 omci_message=OmciDelete(
943 entity_class=VlanTaggingFilterData.class_id,
944 entity_id=entity_id
945 )
946 )
947 self.send_omci_message(frame)
948
Steve Crooks46d64302017-03-10 15:11:06 -0500949 def send_create_extended_vlan_tagging_operation_configuration_data(self,
950 entity_id,
951 assoc_type,
952 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600953 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400954 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600955 message_type=OmciCreate.message_id,
956 omci_message=OmciCreate(
957 entity_class=
958 ExtendedVlanTaggingOperationConfigurationData.class_id,
959 entity_id=entity_id,
960 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500961 association_type=assoc_type,
962 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600963 )
964 )
965 )
966 self.send_omci_message(frame)
967
Steve Crooks9e85ce82017-03-20 12:00:53 -0400968 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self,
969 entity_id,
970 input_tpid,
971 output_tpid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600972 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400973 input_tpid=input_tpid,
974 output_tpid=output_tpid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600975 downstream_mode=0, # inverse of upstream
976 )
977 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400978 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600979 message_type=OmciSet.message_id,
980 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400981 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600982 ExtendedVlanTaggingOperationConfigurationData.class_id,
983 entity_id=entity_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400984 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600985 ExtendedVlanTaggingOperationConfigurationData.mask_for(
986 *data.keys()),
987 data=data
988 )
989 )
990 self.send_omci_message(frame)
991
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400992 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
993 entity_id,
994 filter_inner_vid,
995 treatment_inner_vid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600996 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400997 received_frame_vlan_tagging_operation_table=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600998 VlanTaggingOperation(
999 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -05001000 filter_outer_vid=4096,
1001 filter_outer_tpid_de=0,
1002
1003 filter_inner_priority=15,
1004 filter_inner_vid=filter_inner_vid,
1005 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001006 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -05001007
1008 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001009 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -05001010 treatment_outer_vid=0,
1011 treatment_outer_tpid_de=0,
1012
1013 treatment_inner_priority=0,
1014 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001015 treatment_inner_tpid_de=4
1016 )
1017 )
1018 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001019 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -06001020 message_type=OmciSet.message_id,
1021 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001022 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001023 ExtendedVlanTaggingOperationConfigurationData.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -04001024 entity_id=entity_id,
1025 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001026 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1027 *data.keys()),
1028 data=data
1029 )
1030 )
1031 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001032
Steve Crooksa9d0a7c2017-03-28 22:40:01 -04001033 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
1034 entity_id,
1035 filter_inner_priority,
1036 filter_inner_vid,
1037 filter_inner_tpid_de,
1038 treatment_tags_to_remove,
1039 treatment_inner_priority,
1040 treatment_inner_vid):
1041 data = dict(
1042 received_frame_vlan_tagging_operation_table=
1043 VlanTaggingOperation(
1044 filter_outer_priority=15,
1045 filter_outer_vid=4096,
1046 filter_outer_tpid_de=0,
1047
1048 filter_inner_priority=filter_inner_priority,
1049 filter_inner_vid=filter_inner_vid,
1050 filter_inner_tpid_de=filter_inner_tpid_de,
1051 filter_ether_type=0,
1052
1053 treatment_tags_to_remove=treatment_tags_to_remove,
1054 treatment_outer_priority=15,
1055 treatment_outer_vid=0,
1056 treatment_outer_tpid_de=0,
1057
1058 treatment_inner_priority=treatment_inner_priority,
1059 treatment_inner_vid=treatment_inner_vid,
1060 treatment_inner_tpid_de=4
1061 )
1062 )
1063 frame = OmciFrame(
1064 transaction_id=self.get_tx_id(),
1065 message_type=OmciSet.message_id,
1066 omci_message=OmciSet(
1067 entity_class=
1068 ExtendedVlanTaggingOperationConfigurationData.class_id,
1069 entity_id=entity_id,
1070 attributes_mask=
1071 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1072 *data.keys()),
1073 data=data
1074 )
1075 )
1076 self.send_omci_message(frame)
1077
Steve Crooks9e85ce82017-03-20 12:00:53 -04001078 def send_create_multicast_operations_profile(self,
1079 entity_id,
1080 igmp_ver):
1081 frame = OmciFrame(
1082 transaction_id=self.get_tx_id(),
1083 message_type=OmciCreate.message_id,
1084 omci_message=OmciCreate(
1085 entity_class=
1086 MulticastOperationsProfile.class_id,
1087 entity_id=entity_id,
1088 data=dict(
1089 igmp_version=igmp_ver,
1090 igmp_function=0,
1091 immediate_leave=0
1092 )
1093 )
1094 )
1095 self.send_omci_message(frame)
1096
1097 def send_set_multicast_operations_profile_acl_row0(self,
1098 entity_id,
1099 acl_table,
1100 row_key,
1101 gem_port,
1102 vlan,
1103 src_ip,
1104 dst_ip_start,
1105 dst_ip_end):
1106 row0 = AccessControlRow0(
1107 set_ctrl=1,
1108 row_part_id=0,
1109 test=0,
1110 row_key=row_key,
1111 gem_port_id=gem_port,
1112 vlan_id=vlan,
1113 src_ip=src_ip,
1114 dst_ip_start=dst_ip_start,
1115 dst_ip_end=dst_ip_end,
1116 ipm_group_bw=0
1117 )
1118
1119 if acl_table == 'dynamic':
1120 data = dict(
1121 dynamic_access_control_list_table=row0
1122 )
1123 else:
1124 data = dict(
1125 static_access_control_list_table=row0
1126 )
1127
1128 frame = OmciFrame(
1129 transaction_id=self.get_tx_id(),
1130 message_type=OmciSet.message_id,
1131 omci_message=OmciSet(
1132 entity_class=MulticastOperationsProfile.class_id,
1133 entity_id=entity_id,
1134 attributes_mask=MulticastOperationsProfile.mask_for(
1135 *data.keys()),
1136 data=data
1137 )
1138 )
1139 self.send_omci_message(frame)
1140
1141 def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self,
1142 entity_id,
1143 ctrl_type,
1144 tci):
1145 data = dict(
1146 ds_igmp_mcast_tci=
1147 DownstreamIgmpMulticastTci(
1148 ctrl_type=ctrl_type,
1149 tci=tci
1150 )
1151 )
1152 frame = OmciFrame(
1153 transaction_id=self.get_tx_id(),
1154 message_type=OmciSet.message_id,
1155 omci_message=OmciSet(
1156 entity_class=MulticastOperationsProfile.class_id,
1157 entity_id=entity_id,
1158 attributes_mask=MulticastOperationsProfile.mask_for(
1159 *data.keys()),
1160 data=data
1161 )
1162 )
1163 self.send_omci_message(frame)
1164
1165 def send_create_multicast_subscriber_config_info(self,
1166 entity_id,
1167 me_type,
1168 mcast_oper_profile):
1169 frame = OmciFrame(
1170 transaction_id=self.get_tx_id(),
1171 message_type=OmciCreate.message_id,
1172 omci_message=OmciCreate(
1173 entity_class=
1174 MulticastSubscriberConfigInfo.class_id,
1175 entity_id=entity_id,
1176 data=dict(
1177 me_type=me_type,
1178 mcast_operations_profile_pointer=mcast_oper_profile
1179 )
1180 )
1181 )
1182 self.send_omci_message(frame)
1183
1184 def send_set_multicast_subscriber_config_info(self,
1185 entity_id,
1186 max_groups=0,
1187 max_mcast_bw=0,
1188 bw_enforcement=0):
1189 data = dict(
1190 max_simultaneous_groups=max_groups,
1191 max_multicast_bandwidth=max_mcast_bw,
1192 bandwidth_enforcement=bw_enforcement
1193 )
1194 frame = OmciFrame(
1195 transaction_id=self.get_tx_id(),
1196 message_type=OmciSet.message_id,
1197 omci_message=OmciSet(
1198 entity_class=MulticastSubscriberConfigInfo.class_id,
1199 entity_id=entity_id,
1200 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1201 *data.keys()),
1202 data=data
1203 )
1204 )
1205 self.send_omci_message(frame)
1206
1207 def send_set_multicast_service_package(self,
1208 entity_id,
1209 row_key,
1210 vid_uni,
1211 max_groups,
1212 max_mcast_bw,
1213 mcast_oper_profile):
1214 data = dict(
1215 multicast_service_package_table=
1216 MulticastServicePackage(
1217 set_ctrl=1,
1218 row_key=row_key,
1219
1220 vid_uni=vid_uni,
1221 max_simultaneous_groups=max_groups,
1222 max_multicast_bw=max_mcast_bw,
1223 mcast_operations_profile_pointer=mcast_oper_profile
1224 )
1225 )
1226 frame = OmciFrame(
1227 transaction_id=self.get_tx_id(),
1228 message_type=OmciSet.message_id,
1229 omci_message=OmciSet(
1230 entity_class=MulticastSubscriberConfigInfo.class_id,
1231 entity_id=entity_id,
1232 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1233 *data.keys()),
1234 data=data
1235 )
1236 )
1237 self.send_omci_message(frame)
1238
1239 def send_set_multicast_allowed_preview_groups_row0(self,
1240 entity_id,
1241 row_key,
1242 src_ip,
1243 vlan_id_ani,
1244 vlan_id_uni):
1245 data = dict(
1246 allowed_preview_groups_table=
1247 AllowedPreviewGroupsRow0(
1248 set_ctrl=1,
1249 row_part_id=0,
1250 row_key=row_key,
1251
1252 src_ip=src_ip,
1253 vlan_id_ani=vlan_id_ani,
1254 vlan_id_uni=vlan_id_uni
1255 )
1256 )
1257 frame = OmciFrame(
1258 transaction_id=self.get_tx_id(),
1259 message_type=OmciSet.message_id,
1260 omci_message=OmciSet(
1261 entity_class=MulticastSubscriberConfigInfo.class_id,
1262 entity_id=entity_id,
1263 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1264 *data.keys()),
1265 data=data
1266 )
1267 )
1268 self.send_omci_message(frame)
1269
1270 def send_set_multicast_allowed_preview_groups_row1(self,
1271 entity_id,
1272 row_key,
1273 dst_ip,
1274 duration,
1275 time_left):
1276 data = dict(
1277 allowed_preview_groups_table=
1278 AllowedPreviewGroupsRow1(
1279 set_ctrl=1,
1280 row_part_id=1,
1281 row_key=row_key,
1282
1283 dst_ip=dst_ip,
1284 duration=duration,
1285 time_left=time_left
1286 )
1287 )
1288 frame = OmciFrame(
1289 transaction_id=self.get_tx_id(),
1290 message_type=OmciSet.message_id,
1291 omci_message=OmciSet(
1292 entity_class=MulticastSubscriberConfigInfo.class_id,
1293 entity_id=entity_id,
1294 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1295 *data.keys()),
1296 data=data
1297 )
1298 )
1299 self.send_omci_message(frame)
1300
Girish61687212018-01-08 12:48:58 +05301301 def send_reboot(self):
1302 frame = OmciFrame(
1303 transaction_id=self.get_tx_id(),
1304 message_type=OmciReboot.message_id,
1305 omci_message=OmciReboot(
1306 entity_class=OntG.class_id,
1307 entity_id=0
1308 )
1309 )
1310 self.send_omci_message(frame)
1311
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001312 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -06001313 def wait_for_response(self):
Girish61687212018-01-08 12:48:58 +05301314 self.log.info('wait-for-response')
Steve Crooks3c2c7582017-01-10 15:02:26 -06001315 try:
1316 response = yield self.incoming_messages.get()
Girish61687212018-01-08 12:48:58 +05301317 self.log.info('got-response')
1318 resp = OmciFrame(response)
1319 resp.show()
1320 returnValue(resp)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001321 except Exception as e:
Girish61687212018-01-08 12:48:58 +05301322 returnValue(None)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001323 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001324
Steve Crooks3c2c7582017-01-10 15:02:26 -06001325 @inlineCallbacks
Steve Crooks9b160d72017-03-31 10:48:29 -05001326 def message_exchange(self, onu, gem, cvid):
Girish61687212018-01-08 12:48:58 +05301327 self.log.info('message_exchange', onu=onu, gem=gem, cvid=cvid)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001328 # reset incoming message queue
1329 while self.incoming_messages.pending:
1330 _ = yield self.incoming_messages.get()
1331
rshettyf4bf19e2017-09-19 01:28:27 +05301332 cvid = BRDCM_DEFAULT_VLAN
Steve Crooks9b160d72017-03-31 10:48:29 -05001333
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001334 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -06001335 # MIB Reset - OntData - 0
1336 self.send_mib_reset()
1337 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001338
Steve Crooks3c2c7582017-01-10 15:02:26 -06001339 # Create AR - GalEthernetProfile - 1
1340 self.send_create_gal_ethernet_profile(1, 48)
1341 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001342
Steve Crooks9b160d72017-03-31 10:48:29 -05001343 # MAC Bridge Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001344 # Create AR - MacBridgeServiceProfile - 513
1345 self.send_create_mac_bridge_service_profile(0x201)
1346 yield self.wait_for_response()
1347
rshettyf4bf19e2017-09-19 01:28:27 +05301348 # Mapper Service config
1349 # Create AR - 802.1pMapperServiceProfile - 32769
1350 self.send_create_8021p_mapper_service_profile(0x8001)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001351 yield self.wait_for_response()
1352
Steve Crooks9b160d72017-03-31 10:48:29 -05001353 # MAC Bridge Port config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001354 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
1355 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
1356 yield self.wait_for_response()
1357
Steve Crooks9b160d72017-03-31 10:48:29 -05001358 # VLAN Tagging Filter config
1359 # Create AR - VlanTaggingFilterData - 8450 - c-vid
1360 self.send_create_vlan_tagging_filter_data(0x2102, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001361 yield self.wait_for_response()
1362
rshettyf4bf19e2017-09-19 01:28:27 +05301363
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -05001364 for port_id in self.uni_ports:
1365 # Extended VLAN Tagging Operation config
1366 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102(Uni-Port-Num)
1367 self.send_create_extended_vlan_tagging_operation_configuration_data(0x200 + port_id, 2, 0x100 + port_id)
1368 yield self.wait_for_response()
1369
1370 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1371 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x200 + port_id, 0x8100, 0x8100)
1372 yield self.wait_for_response()
1373
1374
1375
1376 # Create AR - MacBridgePortConfigData - Entity_id -
1377 # bridge ID -
1378 # port num -
1379 # tp_type -
1380 # IEEE MApper poniter
1381 self.send_create_mac_bridge_port_configuration_data(0x200 + port_id, 0x201, port_id, 1, 0x100 + port_id)
1382 yield self.wait_for_response()
1383
1384
1385
1386
1387
1388 # Set AR - ExtendedVlanTaggingOperationConfigData
1389 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1390 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, 1, 8, cvid)
1391 #yield self.wait_for_response()
1392
1393 # Set AR - ExtendedVlanTaggingOperationConfigData
1394 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1395 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x200 + port_id, 0x1000, cvid)
1396 yield self.wait_for_response()
rshettyf4bf19e2017-09-19 01:28:27 +05301397
1398 # Multicast related MEs
1399 # Set AR - MulticastOperationsProfile - Dynamic Access Control List table
1400 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
1401 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
1402 yield self.wait_for_response()
1403
Steve Crooks9b160d72017-03-31 10:48:29 -05001404 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001405 # Create AR - MulticastOperationsProfile
1406 self.send_create_multicast_operations_profile(0x201, 3)
1407 yield self.wait_for_response()
1408
rshettyf4bf19e2017-09-19 01:28:27 +05301409 # Multicast Subscriber config
1410 # Create AR - MulticastSubscriberConfigInfo
1411 self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201)
1412 yield self.wait_for_response()
1413
1414 # Create AR - GemPortNetworkCtp - 260 - 4000 - 0 Multicast
1415 self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0)
1416 yield self.wait_for_response()
1417
1418 # Multicast GEM Interworking config Multicast
1419 # Create AR - MulticastGemInterworkingTp - 6 - 260
1420 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
1421 yield self.wait_for_response()
1422
Steve Crooks9e85ce82017-03-20 12:00:53 -04001423 self.send_set_multicast_operations_profile_acl_row0(0x201,
1424 'dynamic',
1425 0,
1426 0x0fa0,
1427 0x0fa0,
1428 '0.0.0.0',
1429 '224.0.0.0',
1430 '239.255.255.255')
1431 yield self.wait_for_response()
1432
Steve Crooks9b160d72017-03-31 10:48:29 -05001433 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001434 # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI
Steve Crooks9b160d72017-03-31 10:48:29 -05001435 self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001436 yield self.wait_for_response()
1437
Steve Crooks9b160d72017-03-31 10:48:29 -05001438
rshettyf4bf19e2017-09-19 01:28:27 +05301439
1440 def add_uni_port(self, device, parent_logical_device_id,
1441 name, parent_port_num=None):
1442 self.log.info('adding-logical-port', device_id=device.id,
1443 logical_device_id=parent_logical_device_id,
1444 name=name)
1445 if parent_port_num is not None:
1446 uni = parent_port_num
1447 port_no = parent_port_num
1448 else:
1449 uni = self.uni_ports[0]
1450 port_no = device.proxy_address.channel_id + uni
1451 # register physical ports
1452 uni_port = Port(
1453 port_no=uni,
Shad Ansari2825d012018-02-22 23:57:46 +00001454 label='uni-'+str(uni),
rshettyf4bf19e2017-09-19 01:28:27 +05301455 type=Port.ETHERNET_UNI,
1456 admin_state=AdminState.ENABLED,
1457 oper_status=OperStatus.ACTIVE
1458 )
1459 self.adapter_agent.add_port(device.id, uni_port)
1460 # add uni port to logical device
1461 cap = OFPPF_1GB_FD | OFPPF_FIBER
1462 self.adapter_agent.add_logical_port(parent_logical_device_id,
1463 LogicalPort(
1464 id='uni-{}'.format(port_no),
1465 ofp_port=ofp_port(
1466 port_no=port_no,
1467 hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' %
1468 (device.proxy_address.onu_id & 0xff,
1469 (port_no >> 8) & 0xff,
1470 port_no & 0xff)),
1471 #name='uni-{}'.format(port_no),
1472 name=name,
1473 config=0,
1474 state=OFPPS_LIVE,
1475 curr=cap,
1476 advertised=cap,
1477 peer=cap,
1478 curr_speed=OFPPF_1GB_FD,
1479 max_speed=OFPPF_1GB_FD
1480 ),
1481 device_id=device.id,
1482 device_port_no=uni_port.port_no
1483 ))
rshettyc26a3c32017-07-27 11:06:38 +05301484
Girishd5823672017-11-23 12:15:14 +05301485 def del_uni_port(self, device, parent_logical_device_id,
1486 name, parent_port_num=None):
1487 self.log.info('del-uni-port', device_id=device.id,
1488 logical_device_id=parent_logical_device_id,
1489 name=name)
1490 if parent_port_num is not None:
1491 uni = parent_port_num
1492 port_no = parent_port_num
1493 else:
1494 uni = self.uni_ports[0]
1495 port_no = device.proxy_address.channel_id + uni
1496 # register physical ports
1497 ports = self.adapter_agent.get_ports(self.device_id, Port.ETHERNET_UNI)
1498 for port in ports:
Shad Ansari2825d012018-02-22 23:57:46 +00001499 if port.label == 'uni-'+str(uni):
Girishd5823672017-11-23 12:15:14 +05301500 break
1501 self.adapter_agent.delete_port(self.device_id, port)
1502 self.adapter_agent.delete_logical_port_by_id(parent_logical_device_id,
1503 'uni-{}'.format(port_no))
1504
Girish61687212018-01-08 12:48:58 +05301505
1506 @inlineCallbacks
1507 def delete_v_ont_ani(self, data):
1508 self.log.info('deleting-v_ont_ani')
1509
1510 device = self.adapter_agent.get_device(self.device_id)
1511 # construct message
1512 # MIB Reset - OntData - 0
1513 if device.connect_status != ConnectStatus.REACHABLE:
1514 self.log.error('device-unreachable')
1515 returnValue(None)
1516
1517 self.send_mib_reset()
1518 yield self.wait_for_response()
1519 self.proxy_address = device.proxy_address
1520 self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
1521
1522 ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1523 if ports is not None:
1524 for port in ports:
1525 if port.label == 'PON port':
1526 self.adapter_agent.delete_port(self.device_id, port)
1527 break
1528
rshettyc26a3c32017-07-27 11:06:38 +05301529 def create_interface(self, data):
rshetty1cc73982017-09-02 03:31:12 +05301530 if isinstance(data, VEnetConfig):
1531 parent_port_num = None
1532 onu_device = self.adapter_agent.get_device(self.device_id)
1533 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1534 parent_port_num = None
1535 for port in ports:
1536 if port.label == data.interface.name:
1537 parent_port_num = port.port_no
1538 break
1539
rshettyf4bf19e2017-09-19 01:28:27 +05301540 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1541 logical_device_id = parent_device.parent_id
1542 assert logical_device_id
Girish61687212018-01-08 12:48:58 +05301543 self.add_uni_port(onu_device, logical_device_id,
rshettyf4bf19e2017-09-19 01:28:27 +05301544 data.name, parent_port_num)
1545
1546 if parent_port_num is None:
rshetty1cc73982017-09-02 03:31:12 +05301547 self.log.error("matching-parent-uni-port-num-not-found")
1548 return
1549
1550 onu_ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1551 if onu_ports:
1552 # To-Do :
1553 # Assumed only one PON port and UNI port per ONU.
1554 pon_port = onu_ports[0]
1555 else:
1556 self.log.error("No-Pon-port-configured-yet")
1557 return
1558
1559 self.adapter_agent.delete_port_reference_from_parent(self.device_id,
1560 pon_port)
1561
1562 pon_port.peers[0].device_id = onu_device.parent_id
1563 pon_port.peers[0].port_no = parent_port_num
1564 self.adapter_agent.add_port_reference_to_parent(self.device_id,
1565 pon_port)
1566 else:
Girish61687212018-01-08 12:48:58 +05301567 self.log.info('Not-handled-Yet')
rshetty1cc73982017-09-02 03:31:12 +05301568 return
rshettyc26a3c32017-07-27 11:06:38 +05301569
1570 def update_interface(self, data):
Girish61687212018-01-08 12:48:58 +05301571 self.log.info('Not-Implemented-yet')
rshetty1cc73982017-09-02 03:31:12 +05301572 return
rshettyc26a3c32017-07-27 11:06:38 +05301573
1574 def remove_interface(self, data):
Girishd5823672017-11-23 12:15:14 +05301575 if isinstance(data, VEnetConfig):
1576 parent_port_num = None
1577 onu_device = self.adapter_agent.get_device(self.device_id)
1578 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1579 parent_port_num = None
1580 for port in ports:
1581 if port.label == data.interface.name:
1582 parent_port_num = port.port_no
1583 break
1584
1585 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1586 logical_device_id = parent_device.parent_id
1587 assert logical_device_id
1588 self.del_uni_port(onu_device, logical_device_id,
1589 data.name, parent_port_num)
Girish61687212018-01-08 12:48:58 +05301590 if isinstance(data, VOntaniConfig):
1591 self.delete_v_ont_ani(data)
Girishd5823672017-11-23 12:15:14 +05301592 else:
Girish61687212018-01-08 12:48:58 +05301593 self.log.info('not-handled-yet')
rshetty1cc73982017-09-02 03:31:12 +05301594 return
rshettyf4bf19e2017-09-19 01:28:27 +05301595
1596 @inlineCallbacks
1597 def create_gemport(self, data):
Girish61687212018-01-08 12:48:58 +05301598 self.log.info('create-gemport')
1599 gem_port = GemportsConfigData()
1600 gem_port.CopyFrom(data)
rshettyf4bf19e2017-09-19 01:28:27 +05301601 if gem_port.tcont_ref is None:
Girish61687212018-01-08 12:48:58 +05301602 self.log.error('recevied-null-gem-port-data')
rshettyf4bf19e2017-09-19 01:28:27 +05301603 else:
1604 #To-Do Need to see how the valuse 0x8001 is derived
1605 self.send_create_gem_port_network_ctp(gem_port.gemport_id,
1606 gem_port.gemport_id, 0x8001,
1607 "bi-directional", 0x100)
1608 yield self.wait_for_response()
1609
1610 # GEM Interworking config
1611 # Create AR - GemInterworkingTp - Gem_port,TP_pointer -
1612 # Gem port CTP pointer -
1613 # Mapper service profile id
1614 self.send_create_gem_inteworking_tp(gem_port.gemport_id,
1615 gem_port.gemport_id, 0x8001)
1616 yield self.wait_for_response()
1617
1618 # Mapper Service Profile config
1619 # Set AR - 802.1pMapperServiceProfile - Mapper_ profile_id -
1620 # gem_port_tp pointer
1621 self.send_set_8021p_mapper_service_profile(0x8001,
1622 gem_port.gemport_id)
1623 yield self.wait_for_response()
1624
1625
1626 @inlineCallbacks
Girishd5823672017-11-23 12:15:14 +05301627 def remove_gemport(self, data):
Girish61687212018-01-08 12:48:58 +05301628 self.log.info('remove-gemport')
1629 gem_port = GemportsConfigData()
Girishd5823672017-11-23 12:15:14 +05301630 gem_port.CopyFrom(data)
Girish61687212018-01-08 12:48:58 +05301631 device = self.adapter_agent.get_device(self.device_id)
1632 if device.connect_status != ConnectStatus.REACHABLE:
1633 self.log.error('device-unreachable')
1634 returnValue(None)
Girishd5823672017-11-23 12:15:14 +05301635
Girish61687212018-01-08 12:48:58 +05301636 self.send_set_8021p_mapper_service_profile(0x8001,
1637 0xFFFF)
Girishd5823672017-11-23 12:15:14 +05301638 yield self.wait_for_response()
1639
1640 self.send_delete_omci_mesage(GemInterworkingTp.class_id,
Girish61687212018-01-08 12:48:58 +05301641 gem_port.gemport_id)
Girishd5823672017-11-23 12:15:14 +05301642 yield self.wait_for_response()
1643
1644 #To-Do Need to see how the valuse 0x8001 is derived
1645 self.send_delete_omci_mesage(GemPortNetworkCtp.class_id,
Girish61687212018-01-08 12:48:58 +05301646 gem_port.gemport_id)
Girishd5823672017-11-23 12:15:14 +05301647 yield self.wait_for_response()
1648
1649 @inlineCallbacks
rshettyf4bf19e2017-09-19 01:28:27 +05301650 def create_tcont(self, tcont_data, traffic_descriptor_data):
Girish61687212018-01-08 12:48:58 +05301651 self.log.info('create-tcont')
1652 tcont = TcontsConfigData()
rshettyf4bf19e2017-09-19 01:28:27 +05301653 tcont.CopyFrom(tcont_data)
Girish61687212018-01-08 12:48:58 +05301654 if tcont.interface_reference is not None:
1655 self.log.debug('tcont', tcont=tcont.alloc_id)
1656 self.send_set_tcont(0x8001, tcont.alloc_id)
1657 yield self.wait_for_response()
1658 else:
1659 self.log.info('recevied-null-tcont-data', tcont=tcont.alloc_id)
rshettyf4bf19e2017-09-19 01:28:27 +05301660
Girishd5823672017-11-23 12:15:14 +05301661 @inlineCallbacks
1662 def remove_tcont(self, tcont_data, traffic_descriptor_data):
Girish61687212018-01-08 12:48:58 +05301663 self.log.info('remove-tcont')
1664 device = self.adapter_agent.get_device(self.device_id)
1665 if device.connect_status != ConnectStatus.REACHABLE:
1666 self.log.error('device-unreachable')
1667 returnValue(None)
1668
Girishd5823672017-11-23 12:15:14 +05301669 self.send_set_tcont(0x8001, 0xFFFF)
1670 yield self.wait_for_response()
1671
rshettyf4bf19e2017-09-19 01:28:27 +05301672 def create_multicast_gemport(self, data):
1673 self.log.info('Send relevant OMCI message')
sathishgff102eb2017-12-21 12:19:19 +05301674
1675 @inlineCallbacks
1676 def disable(self, device):
1677 try:
1678 self.log.info('sending-admin-state-lock-towards-device', device=device)
Girish61687212018-01-08 12:48:58 +05301679
sathishgff102eb2017-12-21 12:19:19 +05301680 self.send_set_admin_state(0x0000, ADMIN_STATE_LOCK)
1681 yield self.wait_for_response()
1682 device = self.adapter_agent.get_device(device.id)
1683 # Disable all ports on that device
1684 self.adapter_agent.disable_all_ports(self.device_id)
1685 parent_device = self.adapter_agent.get_device(device.parent_id)
1686 logical_device_id = parent_device.parent_id
1687 assert logical_device_id
1688 # Mark OF PORT STATE DOWN
1689 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
1690 for port in ports:
1691 state = OFPPS_LINK_DOWN
1692 port_id = 'uni-{}'.format(port.port_no)
1693 self.update_logical_port(logical_device_id, port_id, state)
1694 device.oper_status = OperStatus.UNKNOWN
1695 device.connect_status = ConnectStatus.UNREACHABLE
1696 self.adapter_agent.update_device(device)
1697 except Exception as e:
1698 log.exception('exception-in-onu-disable', exception=e)
1699
1700 @inlineCallbacks
1701 def reenable(self, device):
1702 try:
1703 self.log.info('sending-admin-state-unlock-towards-device', device=device)
1704 self.send_set_admin_state(0x0000, ADMIN_STATE_UNLOCK)
1705 yield self.wait_for_response()
1706 device = self.adapter_agent.get_device(device.id)
1707 # Re-enable the ports on that device
1708 self.adapter_agent.enable_all_ports(device.id)
1709 parent_device = self.adapter_agent.get_device(device.parent_id)
1710 logical_device_id = parent_device.parent_id
1711 assert logical_device_id
1712 # Mark OF PORT STATE UP
1713 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
1714 for port in ports:
1715 state = OFPPS_LIVE
1716 port_id = 'uni-{}'.format(port.port_no)
1717 self.update_logical_port(logical_device_id, port_id, state)
1718 device.oper_status = OperStatus.ACTIVE
1719 device.connect_status = ConnectStatus.REACHABLE
1720 self.adapter_agent.update_device(device)
1721 except Exception as e:
1722 log.exception('exception-in-onu-reenable', exception=e)
1723
Girish61687212018-01-08 12:48:58 +05301724 @inlineCallbacks
1725 def reboot(self):
1726 self.log.info('reboot-device')
1727 device = self.adapter_agent.get_device(self.device_id)
1728 if device.connect_status != ConnectStatus.REACHABLE:
1729 self.log.error("device-unreacable")
1730 returnValue(None)
1731
1732 self.send_reboot()
1733 response = yield self.wait_for_response()
1734 if response is not None:
1735 omci_response = response.getfieldval("omci_message")
1736 success_code = omci_response.getfieldval("success_code")
1737 if success_code == 0:
1738 self.log.info("reboot-command-processed-successfully")
1739 # Update the device connection and operation status
1740 device = self.adapter_agent.get_device(self.device_id)
1741 device.connect_status = ConnectStatus.UNREACHABLE
1742 device.oper_status = OperStatus.DISCOVERED
1743 self.adapter_agent.update_device(device)
1744 self.disable_ports(device)
1745 else:
1746 self.log.info("reboot-failed", success_code=success_code)
1747 else:
1748 self.log.info("error-in-processing-reboot-response")
1749
1750 def disable_ports(self, onu_device):
1751 self.log.info('disable-ports', device_id=self.device_id)
1752
1753 # Disable all ports on that device
1754 self.adapter_agent.disable_all_ports(self.device_id)
1755
1756 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1757 assert parent_device
1758 logical_device_id = parent_device.parent_id
1759 assert logical_device_id
1760 ports = self.adapter_agent.get_ports(onu_device.id, Port.ETHERNET_UNI)
1761 for port in ports:
1762 port_id = 'uni-{}'.format(port.port_no)
1763 self.update_logical_port(logical_device_id, port_id, OFPPS_LINK_DOWN)