blob: d4216900a052e895a7131479a331cc837d860080 [file] [log] [blame]
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001#
Zsolt Haraszti3eb27a52017-01-03 21:56:48 -08002# Copyright 2017 the original author or authors.
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17"""
Steve Crooks3c2c7582017-01-10 15:02:26 -060018Broadcom OLT/ONU adapter.
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080019"""
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080020
Steve Crooks3c2c7582017-01-10 15:02:26 -060021from uuid import uuid4
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080022import structlog
Peter Shafikd7f33772017-05-17 13:56:34 -040023from twisted.internet import reactor, task
Steve Crooks3c2c7582017-01-10 15:02:26 -060024from twisted.internet.defer import DeferredQueue, inlineCallbacks
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080025from zope.interface import implementer
26
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080027from voltha.adapters.interface import IAdapterInterface
28from voltha.core.logical_device_agent import mac_str_to_tuple
Steve Crooksf248e182017-02-07 10:50:24 -050029import voltha.core.flow_decomposer as fd
Steve Crooks3c2c7582017-01-10 15:02:26 -060030from voltha.protos import third_party
31from voltha.protos.adapter_pb2 import Adapter
32from voltha.protos.adapter_pb2 import AdapterConfig
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080033from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \
34 AdminState
ggowdru236bd952017-06-20 20:32:55 -070035from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image
Steve Crooks3c2c7582017-01-10 15:02:26 -060036from voltha.protos.health_pb2 import HealthStatus
37from voltha.protos.logical_device_pb2 import LogicalPort
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
rshetty1cc73982017-09-02 03:31:12 +053040from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig
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
sathishg5e21cd92017-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',
sathishgf4880c72018-01-10 10:48:45 +053077 version='0.43',
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):
sathishg5e21cd92017-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):
sathishg5e21cd92017-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):
134 raise NotImplementedError()
135
Lydia Fang01f2e852017-06-28 17:24:58 -0700136 def download_image(self, device, request):
137 raise NotImplementedError()
138
139 def get_image_download_status(self, device, request):
140 raise NotImplementedError()
141
142 def cancel_image_download(self, device, request):
143 raise NotImplementedError()
144
145 def activate_image_update(self, device, request):
146 raise NotImplementedError()
147
148 def revert_image_update(self, device, request):
149 raise NotImplementedError()
150
sathishg5ae86222017-06-28 15:16:29 +0530151 def self_test_device(self, device):
152 """
153 This is called to Self a device based on a NBI call.
154 :param device: A Voltha.Device object.
155 :return: Will return result of self test
156 """
157 log.info('self-test-device', device=device.id)
158 raise NotImplementedError()
159
Khen Nursimulud068d812017-03-06 11:44:18 -0500160 def delete_device(self, device):
Girishd5823672017-11-23 12:15:14 +0530161 log.info('delete-device', device_id=device.id)
162 if device.id in self.devices_handlers:
163 handler = self.devices_handlers[device.id]
164 if handler is not None:
165 handler.delete(device)
166 del self.devices_handlers[device.id]
167 return
Khen Nursimulud068d812017-03-06 11:44:18 -0500168
169 def get_device_details(self, device):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800170 raise NotImplementedError()
171
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500172 def update_pm_config(self, device, pm_configs):
173 raise NotImplementedError()
174
Steve Crooks3c2c7582017-01-10 15:02:26 -0600175 def update_flows_bulk(self, device, flows, groups):
rshettyf4bf19e2017-09-19 01:28:27 +0530176 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600177 log.info('bulk-flow-update', device_id=device.id,
178 flows=flows, groups=groups)
rshettyf4bf19e2017-09-19 01:28:27 +0530179 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600180 assert len(groups.items) == 0
rshettyf4bf19e2017-09-19 01:28:27 +0530181 handler = self.devices_handlers[device.id]
Steve Crooksf248e182017-02-07 10:50:24 -0500182 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600183
184 def update_flows_incrementally(self, device, flow_changes, group_changes):
185 raise NotImplementedError()
186
187 def send_proxied_message(self, proxy_address, msg):
188 log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
189
190 def receive_proxied_message(self, proxy_address, msg):
191 log.info('receive-proxied-message', proxy_address=proxy_address,
192 device_id=proxy_address.device_id, msg=hexify(msg))
rshettyf4bf19e2017-09-19 01:28:27 +0530193 # Device_id from the proxy_address is the olt device id. We need to
194 # get the onu device id using the port number in the proxy_address
195 device = self.adapter_agent. \
196 get_child_device_with_proxy_address(proxy_address)
197 if device:
198 handler = self.devices_handlers[device.id]
199 handler.receive_message(msg)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600200
201 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
202 log.info('packet-out', logical_device_id=logical_device_id,
203 egress_port_no=egress_port_no, msg_len=len(msg))
204
Peter Shafik9107f2e2017-05-02 15:54:39 -0400205 def receive_inter_adapter_message(self, msg):
206 log.info('receive_inter_adapter_message', msg=msg)
Peter Shafikd7f33772017-05-17 13:56:34 -0400207 proxy_address = msg['proxy_address']
208 assert proxy_address is not None
rshettyf4bf19e2017-09-19 01:28:27 +0530209 # Device_id from the proxy_address is the olt device id. We need to
210 # get the onu device id using the port number in the proxy_address
211 device = self.adapter_agent. \
212 get_child_device_with_proxy_address(proxy_address)
213 if device:
214 handler = self.devices_handlers[device.id]
215 handler.event_messages.put(msg)
Peter Shafik9107f2e2017-05-02 15:54:39 -0400216
Nikolay Titov89004ec2017-06-19 18:22:42 -0400217 def create_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530218 log.info('create-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530219 if device.id in self.devices_handlers:
220 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530221 if handler is not None:
222 handler.create_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400223
224 def update_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530225 log.info('update-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.update_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400230
231 def remove_interface(self, device, data):
rshettyc26a3c32017-07-27 11:06:38 +0530232 log.info('remove-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.remove_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400237
238 def receive_onu_detect_state(self, device_id, state):
239 raise NotImplementedError()
240
Nikolay Titov176f1db2017-08-10 12:38:43 -0400241 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
rshettyf4bf19e2017-09-19 01:28:27 +0530242 log.info('create-tcont', device_id=device.id)
243 if device.id in self.devices_handlers:
244 handler = self.devices_handlers[device.id]
245 if handler is not None:
246 handler.create_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400247
248 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
249 raise NotImplementedError()
250
251 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
Girishd5823672017-11-23 12:15:14 +0530252 log.info('remove-tcont', device_id=device.id)
253 if device.id in self.devices_handlers:
254 handler = self.devices_handlers[device.id]
255 if handler is not None:
256 handler.remove_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400257
258 def create_gemport(self, device, data):
rshettyf4bf19e2017-09-19 01:28:27 +0530259 log.info('create-gemport', 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.create_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400264
265 def update_gemport(self, device, data):
266 raise NotImplementedError()
267
268 def remove_gemport(self, device, data):
Girishd5823672017-11-23 12:15:14 +0530269 log.info('remove-gemport', device_id=device.id)
270 if device.id in self.devices_handlers:
271 handler = self.devices_handlers[device.id]
272 if handler is not None:
273 handler.remove_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400274
275 def create_multicast_gemport(self, device, data):
rshettyf4bf19e2017-09-19 01:28:27 +0530276 log.info('create-multicast-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.create_multicast_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400281
282 def update_multicast_gemport(self, device, data):
283 raise NotImplementedError()
284
285 def remove_multicast_gemport(self, device, data):
286 raise NotImplementedError()
287
288 def create_multicast_distribution_set(self, device, data):
289 raise NotImplementedError()
290
291 def update_multicast_distribution_set(self, device, data):
292 raise NotImplementedError()
293
294 def remove_multicast_distribution_set(self, device, data):
295 raise NotImplementedError()
296
297 def suppress_alarm(self, filter):
298 raise NotImplementedError()
299
Stephane Barbarie980a0912017-05-11 11:27:06 -0400300 def unsuppress_alarm(self, filter):
301 raise NotImplementedError()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600302
303class BroadcomOnuHandler(object):
304
305 def __init__(self, adapter, device_id):
306 self.adapter = adapter
307 self.adapter_agent = adapter.adapter_agent
308 self.device_id = device_id
309 self.log = structlog.get_logger(device_id=device_id)
310 self.incoming_messages = DeferredQueue()
Peter Shafikd7f33772017-05-17 13:56:34 -0400311 self.event_messages = DeferredQueue()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600312 self.proxy_address = None
313 self.tx_id = 0
314
Peter Shafikd7f33772017-05-17 13:56:34 -0400315 # Need to query ONU for number of supported uni ports
316 # For now, temporarily set number of ports to 1 - port #2
317 self.uni_ports = (2,)
318
319 # Handle received ONU event messages
320 reactor.callLater(0, self.handle_onu_events)
321
Steve Crooks3c2c7582017-01-10 15:02:26 -0600322 def receive_message(self, msg):
323 self.incoming_messages.put(msg)
324
Peter Shafikd7f33772017-05-17 13:56:34 -0400325 @inlineCallbacks
326 def handle_onu_events(self):
327 event_msg = yield self.event_messages.get()
328
329 if event_msg['event'] == 'activation-completed':
330
331 if event_msg['event_data']['activation_successful'] == True:
332 for uni in self.uni_ports:
333 port_no = self.proxy_address.channel_id + uni
Girishd5823672017-11-23 12:15:14 +0530334 yield self.message_exchange(
335 self.proxy_address.onu_id,
336 self.proxy_address.onu_session_id,
337 port_no)
Peter Shafikd7f33772017-05-17 13:56:34 -0400338
339 device = self.adapter_agent.get_device(self.device_id)
Girishd5823672017-11-23 12:15:14 +0530340 device.connect_status = ConnectStatus.REACHABLE
Peter Shafikd7f33772017-05-17 13:56:34 -0400341 device.oper_status = OperStatus.ACTIVE
342 self.adapter_agent.update_device(device)
343
344 else:
345 device = self.adapter_agent.get_device(self.device_id)
346 device.oper_status = OperStatus.FAILED
347 self.adapter_agent.update_device(device)
348
349 elif event_msg['event'] == 'deactivation-completed':
350 device = self.adapter_agent.get_device(self.device_id)
351 device.oper_status = OperStatus.DISCOVERED
352 self.adapter_agent.update_device(device)
353
Girish96631602017-12-14 21:52:59 +0530354 elif (event_msg['event'] == 'deactivate-onu'):
355 device = self.adapter_agent.get_device(self.device_id)
356 device.connect_status = ConnectStatus.UNREACHABLE
357 device.oper_status = OperStatus.DISCOVERED
358 self.adapter_agent.update_device(device)
359
Peter Shafikd7f33772017-05-17 13:56:34 -0400360 elif event_msg['event'] == 'ranging-completed':
361
362 if event_msg['event_data']['ranging_successful'] == True:
363 device = self.adapter_agent.get_device(self.device_id)
364 device.oper_status = OperStatus.ACTIVATING
365 self.adapter_agent.update_device(device)
366
367 else:
368 device = self.adapter_agent.get_device(self.device_id)
369 device.oper_status = OperStatus.FAILED
370 self.adapter_agent.update_device(device)
371
372 # Handle next event
373 reactor.callLater(0, self.handle_onu_events)
374
375
Steve Crooks3c2c7582017-01-10 15:02:26 -0600376 def activate(self, device):
377 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800378
379 # first we verify that we got parent reference and proxy info
380 assert device.parent_id
381 assert device.proxy_address.device_id
Steve Crooks9b160d72017-03-31 10:48:29 -0500382 #assert device.proxy_address.channel_id # c-vid
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800383
Steve Crooks3c2c7582017-01-10 15:02:26 -0600384 # register for proxied messages right away
385 self.proxy_address = device.proxy_address
386 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
387
Peter Shafik9107f2e2017-05-02 15:54:39 -0400388
Steve Crooks3c2c7582017-01-10 15:02:26 -0600389 # populate device info
390 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800391 device.vendor = 'Broadcom'
Steve Crooks9e85ce82017-03-20 12:00:53 -0400392 device.model = 'n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800393 device.hardware_version = 'to be filled'
394 device.firmware_version = 'to be filled'
ggowdru236bd952017-06-20 20:32:55 -0700395 device.images.image.extend([
396 Image(version="to be filled")
397 ])
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800398 device.connect_status = ConnectStatus.REACHABLE
399 self.adapter_agent.update_device(device)
400
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800401 self.adapter_agent.add_port(device.id, Port(
Steve Crooks9b160d72017-03-31 10:48:29 -0500402 port_no=100,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800403 label='PON port',
404 type=Port.PON_ONU,
405 admin_state=AdminState.ENABLED,
406 oper_status=OperStatus.ACTIVE,
407 peers=[
408 Port.PeerPort(
409 device_id=device.parent_id,
410 port_no=device.parent_port_no
411 )
412 ]
413 ))
414
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800415 parent_device = self.adapter_agent.get_device(device.parent_id)
416 logical_device_id = parent_device.parent_id
417 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800418 device = self.adapter_agent.get_device(device.id)
Peter Shafikd7f33772017-05-17 13:56:34 -0400419 device.oper_status = OperStatus.DISCOVERED
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800420 self.adapter_agent.update_device(device)
421
sathishg01ca0802017-11-03 18:32:11 +0530422 def reconcile(self, device):
423
424 log.info('reconciling-broadcom-onu-device-starts')
425
426 # first we verify that we got parent reference and proxy info
427 assert device.parent_id
428 assert device.proxy_address.device_id
429
430 # register for proxied messages right away
431 self.proxy_address = device.proxy_address
432 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
433
434 # TODO: Query ONU current status after reconcile and update.
435 # To be addressed in future commits.
436
437 log.info('reconciling-broadcom-onu-device-ends')
438
sathishgf4880c72018-01-10 10:48:45 +0530439 def update_logical_port(self, logical_device_id, port_id, state):
440 self.log.info('updating-logical-port', logical_port_id=port_id,
441 logical_device_id=logical_device_id, state=state)
442 logical_port = self.adapter_agent.get_logical_port(logical_device_id,
443 port_id)
444 logical_port.ofp_port.state = state
445 self.adapter_agent.update_logical_port(logical_device_id,
446 logical_port)
447
Girishd5823672017-11-23 12:15:14 +0530448 @inlineCallbacks
449 def delete(self, device):
450 self.log.info('delete-onu')
451
452 # construct message
453 # MIB Reset - OntData - 0
454 self.send_mib_reset()
455 yield self.wait_for_response()
456
457 self.proxy_address = device.proxy_address
458 self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
459
460 ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
461 if ports is not None:
462 for port in ports:
463 if port.label == 'PON port':
464 self.adapter_agent.delete_port(self.device_id, port)
465 break
sathishg01ca0802017-11-03 18:32:11 +0530466
Steve Crooks3c2c7582017-01-10 15:02:26 -0600467 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500468 def update_flow_table(self, device, flows):
469 #
470 # We need to proxy through the OLT to get to the ONU
471 # Configuration from here should be using OMCI
472 #
rshettyf4bf19e2017-09-19 01:28:27 +0530473 #self.log.info('bulk-flow-update', device_id=device.id, flows=flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800474
Steve Crooksf248e182017-02-07 10:50:24 -0500475 def is_downstream(port):
Steve Crooks9b160d72017-03-31 10:48:29 -0500476 return port == 100 # Need a better way
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800477
Steve Crooksf248e182017-02-07 10:50:24 -0500478 def is_upstream(port):
479 return not is_downstream(port)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800480
Steve Crooksf248e182017-02-07 10:50:24 -0500481 for flow in flows:
Steve Crooks9b160d72017-03-31 10:48:29 -0500482 _type = None
483 _port = None
484 _vlan_vid = None
485 _udp_dst = None
486 _udp_src = None
487 _ipv4_dst = None
488 _ipv4_src = None
489 _metadata = None
490 _output = None
491 _push_tpid = None
492 _field = None
493 _set_vlan_vid = None
rshettyf4bf19e2017-09-19 01:28:27 +0530494 self.log.info('bulk-flow-update', device_id=device.id, flow=flow)
Steve Crooksf248e182017-02-07 10:50:24 -0500495 try:
496 _in_port = fd.get_in_port(flow)
497 assert _in_port is not None
Steve Crooks3c2c7582017-01-10 15:02:26 -0600498
Steve Crooksf248e182017-02-07 10:50:24 -0500499 if is_downstream(_in_port):
500 self.log.info('downstream-flow')
501 elif is_upstream(_in_port):
502 self.log.info('upstream-flow')
503 else:
504 raise Exception('port should be 1 or 2 by our convention')
505
506 _out_port = fd.get_out_port(flow) # may be None
507 self.log.info('out-port', out_port=_out_port)
508
509 for field in fd.get_ofb_fields(flow):
510 if field.type == fd.ETH_TYPE:
511 _type = field.eth_type
512 self.log.info('field-type-eth-type',
513 eth_type=_type)
514
515 elif field.type == fd.IP_PROTO:
516 _proto = field.ip_proto
517 self.log.info('field-type-ip-proto',
518 ip_proto=_proto)
519
520 elif field.type == fd.IN_PORT:
521 _port = field.port
522 self.log.info('field-type-in-port',
523 in_port=_port)
524
525 elif field.type == fd.VLAN_VID:
526 _vlan_vid = field.vlan_vid & 0xfff
527 self.log.info('field-type-vlan-vid',
528 vlan=_vlan_vid)
529
530 elif field.type == fd.VLAN_PCP:
531 _vlan_pcp = field.vlan_pcp
532 self.log.info('field-type-vlan-pcp',
533 pcp=_vlan_pcp)
534
535 elif field.type == fd.UDP_DST:
536 _udp_dst = field.udp_dst
537 self.log.info('field-type-udp-dst',
538 udp_dst=_udp_dst)
539
540 elif field.type == fd.UDP_SRC:
541 _udp_src = field.udp_src
542 self.log.info('field-type-udp-src',
543 udp_src=_udp_src)
544
545 elif field.type == fd.IPV4_DST:
546 _ipv4_dst = field.ipv4_dst
547 self.log.info('field-type-ipv4-dst',
548 ipv4_dst=_ipv4_dst)
549
550 elif field.type == fd.IPV4_SRC:
551 _ipv4_src = field.ipv4_src
552 self.log.info('field-type-ipv4-src',
553 ipv4_dst=_ipv4_src)
554
555 elif field.type == fd.METADATA:
Steve Crooks9b160d72017-03-31 10:48:29 -0500556 _metadata = field.table_metadata
Steve Crooksf248e182017-02-07 10:50:24 -0500557 self.log.info('field-type-metadata',
558 metadata=_metadata)
559
560 else:
561 raise NotImplementedError('field.type={}'.format(
562 field.type))
563
564 for action in fd.get_actions(flow):
565
566 if action.type == fd.OUTPUT:
567 _output = action.output.port
568 self.log.info('action-type-output',
569 output=_output, in_port=_in_port)
570
571 elif action.type == fd.POP_VLAN:
572 self.log.info('action-type-pop-vlan',
573 in_port=_in_port)
574
575 elif action.type == fd.PUSH_VLAN:
576 _push_tpid = action.push.ethertype
577 log.info('action-type-push-vlan',
578 push_tpid=_push_tpid, in_port=_in_port)
579 if action.push.ethertype != 0x8100:
580 self.log.error('unhandled-tpid',
581 ethertype=action.push.ethertype)
582
583 elif action.type == fd.SET_FIELD:
584 _field = action.set_field.field.ofb_field
585 assert (action.set_field.field.oxm_class ==
586 OFPXMC_OPENFLOW_BASIC)
587 self.log.info('action-type-set-field',
588 field=_field, in_port=_in_port)
589 if _field.type == fd.VLAN_VID:
Steve Crooks9b160d72017-03-31 10:48:29 -0500590 _set_vlan_vid = _field.vlan_vid & 0xfff
591 self.log.info('set-field-type-valn-vid', _set_vlan_vid)
Steve Crooksf248e182017-02-07 10:50:24 -0500592 else:
593 self.log.error('unsupported-action-set-field-type',
594 field_type=_field.type)
595 else:
596 log.error('unsupported-action-type',
597 action_type=action.type, in_port=_in_port)
598
599 #
600 # All flows created from ONU adapter should be OMCI based
601 #
rshettyf4bf19e2017-09-19 01:28:27 +0530602 if _vlan_vid == 0 and _set_vlan_vid != None and _set_vlan_vid != 0:
Steve Crooks9b160d72017-03-31 10:48:29 -0500603 # allow priority tagged packets
604 # Set AR - ExtendedVlanTaggingOperationConfigData
605 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
rshettyf4bf19e2017-09-19 01:28:27 +0530606
607 self.send_delete_vlan_tagging_filter_data(0x2102)
608 yield self.wait_for_response()
609
610 #self.send_set_vlan_tagging_filter_data(0x2102, _set_vlan_vid)
611 self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid)
612 yield self.wait_for_response()
613
614 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, _set_vlan_vid)
615 yield self.wait_for_response()
616
Steve Crooks9b160d72017-03-31 10:48:29 -0500617 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0,
rshettyf4bf19e2017-09-19 01:28:27 +0530618 1, 8, _set_vlan_vid)
Steve Crooks9b160d72017-03-31 10:48:29 -0500619 yield self.wait_for_response()
620
621 # Set AR - ExtendedVlanTaggingOperationConfigData
622 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
rshettyf4bf19e2017-09-19 01:28:27 +0530623 '''
Steve Crooks9b160d72017-03-31 10:48:29 -0500624 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0,
rshettyf4bf19e2017-09-19 01:28:27 +0530625 1, 8, _set_vlan_vid)
Steve Crooks9b160d72017-03-31 10:48:29 -0500626 yield self.wait_for_response()
rshettyf4bf19e2017-09-19 01:28:27 +0530627 '''
Steve Crooksf248e182017-02-07 10:50:24 -0500628
629 except Exception as e:
630 log.exception('failed-to-install-flow', e=e, flow=flow)
631
Steve Crooks3c2c7582017-01-10 15:02:26 -0600632 def get_tx_id(self):
633 self.tx_id += 1
634 return self.tx_id
635
636 def send_omci_message(self, frame):
637 _frame = hexify(str(frame))
638 self.log.info('send-omci-message-%s' % _frame)
639 device = self.adapter_agent.get_device(self.device_id)
640 try:
641 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
642 except Exception as e:
643 self.log.info('send-omci-message-exception', exc=str(e))
644
645 def send_get_circuit_pack(self, entity_id=0):
646 frame = OmciFrame(
647 transaction_id=self.get_tx_id(),
648 message_type=OmciGet.message_id,
649 omci_message=OmciGet(
650 entity_class=CircuitPack.class_id,
651 entity_id=entity_id,
652 attributes_mask=CircuitPack.mask_for('vendor_id')
653 )
654 )
655 self.send_omci_message(frame)
656
657 def send_mib_reset(self, entity_id=0):
658 frame = OmciFrame(
659 transaction_id=self.get_tx_id(),
660 message_type=OmciMibReset.message_id,
661 omci_message=OmciMibReset(
662 entity_class=OntData.class_id,
663 entity_id=entity_id
664 )
665 )
666 self.send_omci_message(frame)
667
Steve Crooks9e85ce82017-03-20 12:00:53 -0400668 def send_create_gal_ethernet_profile(self,
669 entity_id,
670 max_gem_payload_size):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600671 frame = OmciFrame(
672 transaction_id=self.get_tx_id(),
673 message_type=OmciCreate.message_id,
674 omci_message=OmciCreate(
675 entity_class=GalEthernetProfile.class_id,
676 entity_id=entity_id,
677 data=dict(
678 max_gem_payload_size=max_gem_payload_size
679 )
680 )
681 )
682 self.send_omci_message(frame)
683
sathishg5e21cd92017-12-21 12:19:19 +0530684 def send_set_admin_state(self,
685 entity_id,
686 admin_state):
687 data = dict(
688 administrative_state=admin_state
689 )
690 frame = OmciFrame(
691 transaction_id=self.get_tx_id(),
692 message_type=OmciSet.message_id,
693 omci_message=OmciSet(
694 entity_class=OntG.class_id,
695 entity_id=entity_id,
696 attributes_mask=OntG.mask_for(*data.keys()),
697 data=data
698 )
699 )
700 self.send_omci_message(frame)
701
Steve Crooks9e85ce82017-03-20 12:00:53 -0400702 def send_set_tcont(self,
703 entity_id,
704 alloc_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600705 data = dict(
706 alloc_id=alloc_id
707 )
708 frame = OmciFrame(
709 transaction_id=self.get_tx_id(),
710 message_type=OmciSet.message_id,
711 omci_message=OmciSet(
712 entity_class=Tcont.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400713 entity_id=entity_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600714 attributes_mask=Tcont.mask_for(*data.keys()),
715 data=data
716 )
717 )
718 self.send_omci_message(frame)
719
Steve Crooks9e85ce82017-03-20 12:00:53 -0400720 def send_create_8021p_mapper_service_profile(self,
721 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600722 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400723 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600724 message_type=OmciCreate.message_id,
725 omci_message=OmciCreate(
726 entity_class=Ieee8021pMapperServiceProfile.class_id,
727 entity_id=entity_id,
728 data=dict(
729 tp_pointer=OmciNullPointer,
730 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
Steve Crooks9b160d72017-03-31 10:48:29 -0500731 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
732 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
733 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
734 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
735 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
736 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
737 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
Steve Crooks3c2c7582017-01-10 15:02:26 -0600738 )
739 )
740 )
741 self.send_omci_message(frame)
742
Steve Crooks9e85ce82017-03-20 12:00:53 -0400743 def send_create_mac_bridge_service_profile(self,
744 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600745 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400746 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600747 message_type=OmciCreate.message_id,
748 omci_message=OmciCreate(
749 entity_class=MacBridgeServiceProfile.class_id,
750 entity_id=entity_id,
751 data=dict(
752 spanning_tree_ind=False,
753 learning_ind=True,
754 priority=0x8000,
755 max_age=20 * 256,
756 hello_time=2 * 256,
757 forward_delay=15 * 256,
758 unknown_mac_address_discard=True
759 )
760 )
761 )
762 self.send_omci_message(frame)
763
Steve Crooks9e85ce82017-03-20 12:00:53 -0400764 def send_create_gem_port_network_ctp(self,
765 entity_id,
766 port_id,
767 tcont_id,
768 direction,
769 tm):
770 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
771 if _directions.has_key(direction):
772 _direction = _directions[direction]
773 else:
774 self.log.error('invalid-gem-port-direction', direction=direction)
775 raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction))
776
Steve Crooks3c2c7582017-01-10 15:02:26 -0600777 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400778 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600779 message_type=OmciCreate.message_id,
780 omci_message=OmciCreate(
781 entity_class=GemPortNetworkCtp.class_id,
782 entity_id=entity_id,
783 data=dict(
784 port_id=port_id,
785 tcont_pointer=tcont_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400786 direction=_direction,
787 traffic_management_pointer_upstream=tm
Steve Crooks3c2c7582017-01-10 15:02:26 -0600788 )
789 )
790 )
791 self.send_omci_message(frame)
792
Steve Crooks9e85ce82017-03-20 12:00:53 -0400793 def send_create_multicast_gem_interworking_tp(self,
794 entity_id,
795 gem_port_net_ctp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600796 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400797 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600798 message_type=OmciCreate.message_id,
799 omci_message=OmciCreate(
800 entity_class=MulticastGemInterworkingTp.class_id,
801 entity_id=entity_id,
802 data=dict(
803 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
804 interworking_option=0,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400805 service_profile_pointer=0x1
Steve Crooks3c2c7582017-01-10 15:02:26 -0600806 )
807 )
808 )
809 self.send_omci_message(frame)
810
Steve Crooks9e85ce82017-03-20 12:00:53 -0400811 def send_create_gem_inteworking_tp(self,
812 entity_id,
813 gem_port_net_ctp_id,
814 service_profile_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600815 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400816 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600817 message_type=OmciCreate.message_id,
818 omci_message=OmciCreate(
819 entity_class=GemInterworkingTp.class_id,
820 entity_id=entity_id,
821 data=dict(
822 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
823 interworking_option=5,
824 service_profile_pointer=service_profile_id,
825 interworking_tp_pointer=0x0,
826 gal_profile_pointer=0x1
827 )
828 )
829 )
830 self.send_omci_message(frame)
831
Girishd5823672017-11-23 12:15:14 +0530832 def send_delete_omci_mesage(self,
833 class_id,
834 entity_id):
835 frame = OmciFrame(
836 transaction_id=self.get_tx_id(),
837 message_type=OmciDelete.message_id,
838 omci_message=OmciDelete(
839 entity_class=class_id,
840 entity_id=entity_id
841 )
842 )
843 self.send_omci_message(frame)
844
Steve Crooks9e85ce82017-03-20 12:00:53 -0400845 def send_set_8021p_mapper_service_profile(self,
846 entity_id,
847 interwork_tp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600848 data = dict(
Steve Crooks9b160d72017-03-31 10:48:29 -0500849 interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id,
850 interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id,
851 interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id,
852 interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id,
853 interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id,
854 interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id,
855 interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id,
856 interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600857 )
858 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400859 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600860 message_type=OmciSet.message_id,
861 omci_message=OmciSet(
862 entity_class=Ieee8021pMapperServiceProfile.class_id,
863 entity_id=entity_id,
864 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
865 *data.keys()),
866 data=data
867 )
868 )
869 self.send_omci_message(frame)
870
871 def send_create_mac_bridge_port_configuration_data(self,
872 entity_id,
873 bridge_id,
874 port_id,
875 tp_type,
876 tp_id):
877 frame = OmciFrame(
878 transaction_id=self.get_tx_id(),
879 message_type=OmciCreate.message_id,
880 omci_message=OmciCreate(
881 entity_class=MacBridgePortConfigurationData.class_id,
882 entity_id=entity_id,
883 data=dict(
884 bridge_id_pointer = bridge_id,
885 port_num=port_id,
886 tp_type=tp_type,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400887 tp_pointer=tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600888 )
889 )
890 )
891 self.send_omci_message(frame)
892
Steve Crooks9e85ce82017-03-20 12:00:53 -0400893 def send_create_vlan_tagging_filter_data(self,
894 entity_id,
895 vlan_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600896 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400897 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600898 message_type=OmciCreate.message_id,
899 omci_message=OmciCreate(
900 entity_class=VlanTaggingFilterData.class_id,
901 entity_id=entity_id,
902 data=dict(
903 vlan_filter_0=vlan_id,
904 forward_operation=0x10,
905 number_of_entries=1
906 )
907 )
908 )
909 self.send_omci_message(frame)
910
rshettyf4bf19e2017-09-19 01:28:27 +0530911 def send_set_vlan_tagging_filter_data(self,
912 entity_id,
913 vlan_id):
914 data = dict(
915 vlan_filter_0=vlan_id,
916 forward_operation=0x10,
917 number_of_entries=1
918 )
919
920 frame = OmciFrame(
921 transaction_id=self.get_tx_id(),
922 message_type=OmciSet.message_id,
923 omci_message=OmciSet(
924 entity_class=VlanTaggingFilterData.class_id,
925 entity_id=entity_id,
926 attributes_mask=VlanTaggingFilterData.mask_for(
927 *data.keys()),
928 data=data
929 )
930 )
931 self.send_omci_message(frame)
932
933 def send_delete_vlan_tagging_filter_data(self,
934 entity_id):
935 frame = OmciFrame(
936 transaction_id=self.get_tx_id(),
937 message_type=OmciDelete.message_id,
938 omci_message=OmciDelete(
939 entity_class=VlanTaggingFilterData.class_id,
940 entity_id=entity_id
941 )
942 )
943 self.send_omci_message(frame)
944
Steve Crooks46d64302017-03-10 15:11:06 -0500945 def send_create_extended_vlan_tagging_operation_configuration_data(self,
946 entity_id,
947 assoc_type,
948 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600949 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400950 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600951 message_type=OmciCreate.message_id,
952 omci_message=OmciCreate(
953 entity_class=
954 ExtendedVlanTaggingOperationConfigurationData.class_id,
955 entity_id=entity_id,
956 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500957 association_type=assoc_type,
958 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600959 )
960 )
961 )
962 self.send_omci_message(frame)
963
Steve Crooks9e85ce82017-03-20 12:00:53 -0400964 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self,
965 entity_id,
966 input_tpid,
967 output_tpid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600968 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400969 input_tpid=input_tpid,
970 output_tpid=output_tpid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600971 downstream_mode=0, # inverse of upstream
972 )
973 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400974 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600975 message_type=OmciSet.message_id,
976 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400977 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600978 ExtendedVlanTaggingOperationConfigurationData.class_id,
979 entity_id=entity_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400980 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600981 ExtendedVlanTaggingOperationConfigurationData.mask_for(
982 *data.keys()),
983 data=data
984 )
985 )
986 self.send_omci_message(frame)
987
Steve Crooksa9d0a7c2017-03-28 22:40:01 -0400988 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
989 entity_id,
990 filter_inner_vid,
991 treatment_inner_vid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600992 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400993 received_frame_vlan_tagging_operation_table=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600994 VlanTaggingOperation(
995 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -0500996 filter_outer_vid=4096,
997 filter_outer_tpid_de=0,
998
999 filter_inner_priority=15,
1000 filter_inner_vid=filter_inner_vid,
1001 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001002 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -05001003
1004 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001005 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -05001006 treatment_outer_vid=0,
1007 treatment_outer_tpid_de=0,
1008
1009 treatment_inner_priority=0,
1010 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001011 treatment_inner_tpid_de=4
1012 )
1013 )
1014 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001015 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -06001016 message_type=OmciSet.message_id,
1017 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001018 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001019 ExtendedVlanTaggingOperationConfigurationData.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -04001020 entity_id=entity_id,
1021 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001022 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1023 *data.keys()),
1024 data=data
1025 )
1026 )
1027 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001028
Steve Crooksa9d0a7c2017-03-28 22:40:01 -04001029 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
1030 entity_id,
1031 filter_inner_priority,
1032 filter_inner_vid,
1033 filter_inner_tpid_de,
1034 treatment_tags_to_remove,
1035 treatment_inner_priority,
1036 treatment_inner_vid):
1037 data = dict(
1038 received_frame_vlan_tagging_operation_table=
1039 VlanTaggingOperation(
1040 filter_outer_priority=15,
1041 filter_outer_vid=4096,
1042 filter_outer_tpid_de=0,
1043
1044 filter_inner_priority=filter_inner_priority,
1045 filter_inner_vid=filter_inner_vid,
1046 filter_inner_tpid_de=filter_inner_tpid_de,
1047 filter_ether_type=0,
1048
1049 treatment_tags_to_remove=treatment_tags_to_remove,
1050 treatment_outer_priority=15,
1051 treatment_outer_vid=0,
1052 treatment_outer_tpid_de=0,
1053
1054 treatment_inner_priority=treatment_inner_priority,
1055 treatment_inner_vid=treatment_inner_vid,
1056 treatment_inner_tpid_de=4
1057 )
1058 )
1059 frame = OmciFrame(
1060 transaction_id=self.get_tx_id(),
1061 message_type=OmciSet.message_id,
1062 omci_message=OmciSet(
1063 entity_class=
1064 ExtendedVlanTaggingOperationConfigurationData.class_id,
1065 entity_id=entity_id,
1066 attributes_mask=
1067 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1068 *data.keys()),
1069 data=data
1070 )
1071 )
1072 self.send_omci_message(frame)
1073
Steve Crooks9e85ce82017-03-20 12:00:53 -04001074 def send_create_multicast_operations_profile(self,
1075 entity_id,
1076 igmp_ver):
1077 frame = OmciFrame(
1078 transaction_id=self.get_tx_id(),
1079 message_type=OmciCreate.message_id,
1080 omci_message=OmciCreate(
1081 entity_class=
1082 MulticastOperationsProfile.class_id,
1083 entity_id=entity_id,
1084 data=dict(
1085 igmp_version=igmp_ver,
1086 igmp_function=0,
1087 immediate_leave=0
1088 )
1089 )
1090 )
1091 self.send_omci_message(frame)
1092
1093 def send_set_multicast_operations_profile_acl_row0(self,
1094 entity_id,
1095 acl_table,
1096 row_key,
1097 gem_port,
1098 vlan,
1099 src_ip,
1100 dst_ip_start,
1101 dst_ip_end):
1102 row0 = AccessControlRow0(
1103 set_ctrl=1,
1104 row_part_id=0,
1105 test=0,
1106 row_key=row_key,
1107 gem_port_id=gem_port,
1108 vlan_id=vlan,
1109 src_ip=src_ip,
1110 dst_ip_start=dst_ip_start,
1111 dst_ip_end=dst_ip_end,
1112 ipm_group_bw=0
1113 )
1114
1115 if acl_table == 'dynamic':
1116 data = dict(
1117 dynamic_access_control_list_table=row0
1118 )
1119 else:
1120 data = dict(
1121 static_access_control_list_table=row0
1122 )
1123
1124 frame = OmciFrame(
1125 transaction_id=self.get_tx_id(),
1126 message_type=OmciSet.message_id,
1127 omci_message=OmciSet(
1128 entity_class=MulticastOperationsProfile.class_id,
1129 entity_id=entity_id,
1130 attributes_mask=MulticastOperationsProfile.mask_for(
1131 *data.keys()),
1132 data=data
1133 )
1134 )
1135 self.send_omci_message(frame)
1136
1137 def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self,
1138 entity_id,
1139 ctrl_type,
1140 tci):
1141 data = dict(
1142 ds_igmp_mcast_tci=
1143 DownstreamIgmpMulticastTci(
1144 ctrl_type=ctrl_type,
1145 tci=tci
1146 )
1147 )
1148 frame = OmciFrame(
1149 transaction_id=self.get_tx_id(),
1150 message_type=OmciSet.message_id,
1151 omci_message=OmciSet(
1152 entity_class=MulticastOperationsProfile.class_id,
1153 entity_id=entity_id,
1154 attributes_mask=MulticastOperationsProfile.mask_for(
1155 *data.keys()),
1156 data=data
1157 )
1158 )
1159 self.send_omci_message(frame)
1160
1161 def send_create_multicast_subscriber_config_info(self,
1162 entity_id,
1163 me_type,
1164 mcast_oper_profile):
1165 frame = OmciFrame(
1166 transaction_id=self.get_tx_id(),
1167 message_type=OmciCreate.message_id,
1168 omci_message=OmciCreate(
1169 entity_class=
1170 MulticastSubscriberConfigInfo.class_id,
1171 entity_id=entity_id,
1172 data=dict(
1173 me_type=me_type,
1174 mcast_operations_profile_pointer=mcast_oper_profile
1175 )
1176 )
1177 )
1178 self.send_omci_message(frame)
1179
1180 def send_set_multicast_subscriber_config_info(self,
1181 entity_id,
1182 max_groups=0,
1183 max_mcast_bw=0,
1184 bw_enforcement=0):
1185 data = dict(
1186 max_simultaneous_groups=max_groups,
1187 max_multicast_bandwidth=max_mcast_bw,
1188 bandwidth_enforcement=bw_enforcement
1189 )
1190 frame = OmciFrame(
1191 transaction_id=self.get_tx_id(),
1192 message_type=OmciSet.message_id,
1193 omci_message=OmciSet(
1194 entity_class=MulticastSubscriberConfigInfo.class_id,
1195 entity_id=entity_id,
1196 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1197 *data.keys()),
1198 data=data
1199 )
1200 )
1201 self.send_omci_message(frame)
1202
1203 def send_set_multicast_service_package(self,
1204 entity_id,
1205 row_key,
1206 vid_uni,
1207 max_groups,
1208 max_mcast_bw,
1209 mcast_oper_profile):
1210 data = dict(
1211 multicast_service_package_table=
1212 MulticastServicePackage(
1213 set_ctrl=1,
1214 row_key=row_key,
1215
1216 vid_uni=vid_uni,
1217 max_simultaneous_groups=max_groups,
1218 max_multicast_bw=max_mcast_bw,
1219 mcast_operations_profile_pointer=mcast_oper_profile
1220 )
1221 )
1222 frame = OmciFrame(
1223 transaction_id=self.get_tx_id(),
1224 message_type=OmciSet.message_id,
1225 omci_message=OmciSet(
1226 entity_class=MulticastSubscriberConfigInfo.class_id,
1227 entity_id=entity_id,
1228 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1229 *data.keys()),
1230 data=data
1231 )
1232 )
1233 self.send_omci_message(frame)
1234
1235 def send_set_multicast_allowed_preview_groups_row0(self,
1236 entity_id,
1237 row_key,
1238 src_ip,
1239 vlan_id_ani,
1240 vlan_id_uni):
1241 data = dict(
1242 allowed_preview_groups_table=
1243 AllowedPreviewGroupsRow0(
1244 set_ctrl=1,
1245 row_part_id=0,
1246 row_key=row_key,
1247
1248 src_ip=src_ip,
1249 vlan_id_ani=vlan_id_ani,
1250 vlan_id_uni=vlan_id_uni
1251 )
1252 )
1253 frame = OmciFrame(
1254 transaction_id=self.get_tx_id(),
1255 message_type=OmciSet.message_id,
1256 omci_message=OmciSet(
1257 entity_class=MulticastSubscriberConfigInfo.class_id,
1258 entity_id=entity_id,
1259 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1260 *data.keys()),
1261 data=data
1262 )
1263 )
1264 self.send_omci_message(frame)
1265
1266 def send_set_multicast_allowed_preview_groups_row1(self,
1267 entity_id,
1268 row_key,
1269 dst_ip,
1270 duration,
1271 time_left):
1272 data = dict(
1273 allowed_preview_groups_table=
1274 AllowedPreviewGroupsRow1(
1275 set_ctrl=1,
1276 row_part_id=1,
1277 row_key=row_key,
1278
1279 dst_ip=dst_ip,
1280 duration=duration,
1281 time_left=time_left
1282 )
1283 )
1284 frame = OmciFrame(
1285 transaction_id=self.get_tx_id(),
1286 message_type=OmciSet.message_id,
1287 omci_message=OmciSet(
1288 entity_class=MulticastSubscriberConfigInfo.class_id,
1289 entity_id=entity_id,
1290 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1291 *data.keys()),
1292 data=data
1293 )
1294 )
1295 self.send_omci_message(frame)
1296
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001297 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -06001298 def wait_for_response(self):
1299 log.info('wait-for-response')
1300 try:
1301 response = yield self.incoming_messages.get()
Steve Crooks9e85ce82017-03-20 12:00:53 -04001302 log.info('got-response')
1303 # resp = OmciFrame(response)
1304 # resp.show()
Steve Crooks3c2c7582017-01-10 15:02:26 -06001305 except Exception as e:
1306 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001307
Steve Crooks3c2c7582017-01-10 15:02:26 -06001308 @inlineCallbacks
Steve Crooks9b160d72017-03-31 10:48:29 -05001309 def message_exchange(self, onu, gem, cvid):
1310 log.info('message_exchange', onu=onu, gem=gem, cvid=cvid)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001311 # reset incoming message queue
1312 while self.incoming_messages.pending:
1313 _ = yield self.incoming_messages.get()
1314
rshettyf4bf19e2017-09-19 01:28:27 +05301315 cvid = BRDCM_DEFAULT_VLAN
Steve Crooks9b160d72017-03-31 10:48:29 -05001316
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001317 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -06001318 # MIB Reset - OntData - 0
1319 self.send_mib_reset()
1320 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001321
Steve Crooks3c2c7582017-01-10 15:02:26 -06001322 # Create AR - GalEthernetProfile - 1
1323 self.send_create_gal_ethernet_profile(1, 48)
1324 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001325
rshettyf4bf19e2017-09-19 01:28:27 +05301326 # Port 2
1327 # Extended VLAN Tagging Operation config
1328 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102(Uni-Port-Num)
1329 # TODO: add entry here for additional UNI interfaces
1330 self.send_create_extended_vlan_tagging_operation_configuration_data(0x202, 2, 0x102)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001331 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001332
rshettyf4bf19e2017-09-19 01:28:27 +05301333 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1334 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001335 yield self.wait_for_response()
1336
Steve Crooks9b160d72017-03-31 10:48:29 -05001337 # MAC Bridge Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001338 # Create AR - MacBridgeServiceProfile - 513
1339 self.send_create_mac_bridge_service_profile(0x201)
1340 yield self.wait_for_response()
1341
rshettyf4bf19e2017-09-19 01:28:27 +05301342 # Create AR - MacBridgePortConfigData - Entity_id -
1343 # bridge ID -
1344 # port num -
1345 # tp_type -
1346 # IEEE MApper poniter
1347 self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 2, 1, 0x102)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001348 yield self.wait_for_response()
1349
rshettyf4bf19e2017-09-19 01:28:27 +05301350 # Mapper Service config
1351 # Create AR - 802.1pMapperServiceProfile - 32769
1352 self.send_create_8021p_mapper_service_profile(0x8001)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001353 yield self.wait_for_response()
1354
Steve Crooks9b160d72017-03-31 10:48:29 -05001355 # MAC Bridge Port config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001356 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
1357 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
1358 yield self.wait_for_response()
1359
Steve Crooks9b160d72017-03-31 10:48:29 -05001360 # VLAN Tagging Filter config
1361 # Create AR - VlanTaggingFilterData - 8450 - c-vid
1362 self.send_create_vlan_tagging_filter_data(0x2102, cvid)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001363 yield self.wait_for_response()
1364
rshettyf4bf19e2017-09-19 01:28:27 +05301365 # Set AR - ExtendedVlanTaggingOperationConfigData
1366 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1367 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, 1, 8, cvid)
1368 #yield self.wait_for_response()
1369
1370 # Set AR - ExtendedVlanTaggingOperationConfigData
1371 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1372 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, cvid)
1373 yield self.wait_for_response()
1374
1375 # Multicast related MEs
1376 # Set AR - MulticastOperationsProfile - Dynamic Access Control List table
1377 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
1378 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
1379 yield self.wait_for_response()
1380
Steve Crooks9b160d72017-03-31 10:48:29 -05001381 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001382 # Create AR - MulticastOperationsProfile
1383 self.send_create_multicast_operations_profile(0x201, 3)
1384 yield self.wait_for_response()
1385
rshettyf4bf19e2017-09-19 01:28:27 +05301386 # Multicast Subscriber config
1387 # Create AR - MulticastSubscriberConfigInfo
1388 self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201)
1389 yield self.wait_for_response()
1390
1391 # Create AR - GemPortNetworkCtp - 260 - 4000 - 0 Multicast
1392 self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0)
1393 yield self.wait_for_response()
1394
1395 # Multicast GEM Interworking config Multicast
1396 # Create AR - MulticastGemInterworkingTp - 6 - 260
1397 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
1398 yield self.wait_for_response()
1399
Steve Crooks9e85ce82017-03-20 12:00:53 -04001400 self.send_set_multicast_operations_profile_acl_row0(0x201,
1401 'dynamic',
1402 0,
1403 0x0fa0,
1404 0x0fa0,
1405 '0.0.0.0',
1406 '224.0.0.0',
1407 '239.255.255.255')
1408 yield self.wait_for_response()
1409
Steve Crooks9b160d72017-03-31 10:48:29 -05001410 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001411 # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI
Steve Crooks9b160d72017-03-31 10:48:29 -05001412 self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001413 yield self.wait_for_response()
1414
rshettyf4bf19e2017-09-19 01:28:27 +05301415 '''
Steve Crooks9b160d72017-03-31 10:48:29 -05001416 # Port 5
1417 # Extended VLAN Tagging Operation config
1418 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102
1419 # TODO: add entry here for additional UNI interfaces
1420 self.send_create_extended_vlan_tagging_operation_configuration_data(0x205, 2, 0x105)
1421 yield self.wait_for_response()
1422
1423 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1424 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x205, 0x8100, 0x8100)
1425 yield self.wait_for_response()
1426
1427 # Set AR - ExtendedVlanTaggingOperationConfigData
1428 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1429 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0, 1, 8, cvid)
1430 #yield self.wait_for_response()
1431
1432 # Set AR - ExtendedVlanTaggingOperationConfigData
1433 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1434 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x205, 0x1000, cvid)
1435 yield self.wait_for_response()
1436
1437 # MAC Bridge Port config
1438 # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102
1439 # TODO: add more entries here for other UNI ports
1440 self.send_create_mac_bridge_port_configuration_data(0x205, 0x201, 5, 1, 0x105)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001441 yield self.wait_for_response()
rshettyf4bf19e2017-09-19 01:28:27 +05301442 '''
1443
1444 def add_uni_port(self, device, parent_logical_device_id,
1445 name, parent_port_num=None):
1446 self.log.info('adding-logical-port', device_id=device.id,
1447 logical_device_id=parent_logical_device_id,
1448 name=name)
1449 if parent_port_num is not None:
1450 uni = parent_port_num
1451 port_no = parent_port_num
1452 else:
1453 uni = self.uni_ports[0]
1454 port_no = device.proxy_address.channel_id + uni
1455 # register physical ports
1456 uni_port = Port(
1457 port_no=uni,
1458 label='UNI facing Ethernet port '+str(uni),
1459 type=Port.ETHERNET_UNI,
1460 admin_state=AdminState.ENABLED,
1461 oper_status=OperStatus.ACTIVE
1462 )
1463 self.adapter_agent.add_port(device.id, uni_port)
1464 # add uni port to logical device
1465 cap = OFPPF_1GB_FD | OFPPF_FIBER
1466 self.adapter_agent.add_logical_port(parent_logical_device_id,
1467 LogicalPort(
1468 id='uni-{}'.format(port_no),
1469 ofp_port=ofp_port(
1470 port_no=port_no,
1471 hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' %
1472 (device.proxy_address.onu_id & 0xff,
1473 (port_no >> 8) & 0xff,
1474 port_no & 0xff)),
1475 #name='uni-{}'.format(port_no),
1476 name=name,
1477 config=0,
1478 state=OFPPS_LIVE,
1479 curr=cap,
1480 advertised=cap,
1481 peer=cap,
1482 curr_speed=OFPPF_1GB_FD,
1483 max_speed=OFPPF_1GB_FD
1484 ),
1485 device_id=device.id,
1486 device_port_no=uni_port.port_no
1487 ))
rshettyc26a3c32017-07-27 11:06:38 +05301488
Girishd5823672017-11-23 12:15:14 +05301489 def del_uni_port(self, device, parent_logical_device_id,
1490 name, parent_port_num=None):
1491 self.log.info('del-uni-port', device_id=device.id,
1492 logical_device_id=parent_logical_device_id,
1493 name=name)
1494 if parent_port_num is not None:
1495 uni = parent_port_num
1496 port_no = parent_port_num
1497 else:
1498 uni = self.uni_ports[0]
1499 port_no = device.proxy_address.channel_id + uni
1500 # register physical ports
1501 ports = self.adapter_agent.get_ports(self.device_id, Port.ETHERNET_UNI)
1502 for port in ports:
1503 if port.label == 'UNI facing Ethernet port '+str(uni):
1504 break
1505 self.adapter_agent.delete_port(self.device_id, port)
1506 self.adapter_agent.delete_logical_port_by_id(parent_logical_device_id,
1507 'uni-{}'.format(port_no))
1508
rshettyc26a3c32017-07-27 11:06:38 +05301509 def create_interface(self, data):
rshetty1cc73982017-09-02 03:31:12 +05301510 if isinstance(data, VEnetConfig):
1511 parent_port_num = None
1512 onu_device = self.adapter_agent.get_device(self.device_id)
1513 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1514 parent_port_num = None
1515 for port in ports:
1516 if port.label == data.interface.name:
1517 parent_port_num = port.port_no
1518 break
1519
rshettyf4bf19e2017-09-19 01:28:27 +05301520 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1521 logical_device_id = parent_device.parent_id
1522 assert logical_device_id
1523 self.add_uni_port(onu_device, logical_device_id,
1524 data.name, parent_port_num)
1525
1526 if parent_port_num is None:
rshetty1cc73982017-09-02 03:31:12 +05301527 self.log.error("matching-parent-uni-port-num-not-found")
1528 return
1529
1530 onu_ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1531 if onu_ports:
1532 # To-Do :
1533 # Assumed only one PON port and UNI port per ONU.
1534 pon_port = onu_ports[0]
1535 else:
1536 self.log.error("No-Pon-port-configured-yet")
1537 return
1538
1539 self.adapter_agent.delete_port_reference_from_parent(self.device_id,
1540 pon_port)
1541
1542 pon_port.peers[0].device_id = onu_device.parent_id
1543 pon_port.peers[0].port_no = parent_port_num
1544 self.adapter_agent.add_port_reference_to_parent(self.device_id,
1545 pon_port)
1546 else:
1547 self.log.info('Not handled Yet')
1548 return
rshettyc26a3c32017-07-27 11:06:38 +05301549
1550 def update_interface(self, data):
1551 self.log.info('Not Implemented yet')
rshetty1cc73982017-09-02 03:31:12 +05301552 return
rshettyc26a3c32017-07-27 11:06:38 +05301553
1554 def remove_interface(self, data):
Girishd5823672017-11-23 12:15:14 +05301555 if isinstance(data, VEnetConfig):
1556 parent_port_num = None
1557 onu_device = self.adapter_agent.get_device(self.device_id)
1558 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1559 parent_port_num = None
1560 for port in ports:
1561 if port.label == data.interface.name:
1562 parent_port_num = port.port_no
1563 break
1564
1565 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1566 logical_device_id = parent_device.parent_id
1567 assert logical_device_id
1568 self.del_uni_port(onu_device, logical_device_id,
1569 data.name, parent_port_num)
1570 else:
1571 self.log.info('Not handled Yet')
rshetty1cc73982017-09-02 03:31:12 +05301572 return
rshettyf4bf19e2017-09-19 01:28:27 +05301573
1574 @inlineCallbacks
1575 def create_gemport(self, data):
1576 log.info('create-gemport')
1577 gem_port= GemportsConfigData()
1578 gem_port.CopyFrom(data)
1579 if gem_port.tcont_ref is None:
1580 self.log.info('Recevied NULL Gem Port Data')
1581 else:
1582 #To-Do Need to see how the valuse 0x8001 is derived
1583 self.send_create_gem_port_network_ctp(gem_port.gemport_id,
1584 gem_port.gemport_id, 0x8001,
1585 "bi-directional", 0x100)
1586 yield self.wait_for_response()
1587
1588 # GEM Interworking config
1589 # Create AR - GemInterworkingTp - Gem_port,TP_pointer -
1590 # Gem port CTP pointer -
1591 # Mapper service profile id
1592 self.send_create_gem_inteworking_tp(gem_port.gemport_id,
1593 gem_port.gemport_id, 0x8001)
1594 yield self.wait_for_response()
1595
1596 # Mapper Service Profile config
1597 # Set AR - 802.1pMapperServiceProfile - Mapper_ profile_id -
1598 # gem_port_tp pointer
1599 self.send_set_8021p_mapper_service_profile(0x8001,
1600 gem_port.gemport_id)
1601 yield self.wait_for_response()
1602
1603
1604 @inlineCallbacks
Girishd5823672017-11-23 12:15:14 +05301605 def remove_gemport(self, data):
1606 log.info('remove-gemport')
1607 gem_port= GemportsConfigData()
1608 gem_port.CopyFrom(data)
1609 self.send_set_8021p_mapper_service_profile(0x8001, 0xFFFF)
1610
1611 yield self.wait_for_response()
1612
1613 self.send_delete_omci_mesage(GemInterworkingTp.class_id,
1614 gem_port.gemport_id)
1615 yield self.wait_for_response()
1616
1617 #To-Do Need to see how the valuse 0x8001 is derived
1618 self.send_delete_omci_mesage(GemPortNetworkCtp.class_id,
1619 gem_port.gemport_id)
1620 yield self.wait_for_response()
1621
1622 @inlineCallbacks
rshettyf4bf19e2017-09-19 01:28:27 +05301623 def create_tcont(self, tcont_data, traffic_descriptor_data):
1624 log.info('create-tcont')
1625 tcont = TcontsConfigData()
1626 tcont.CopyFrom(tcont_data)
1627 if (tcont.interface_reference is not None):
1628 self.log.info('tcont created is', tcont= tcont.alloc_id)
1629 self.send_set_tcont(0x8001, tcont.alloc_id)
1630 yield self.wait_for_response()
1631 else:
1632 self.log.info('Recevied NULL tcont Data', tcont= tcont.alloc_id)
1633
Girishd5823672017-11-23 12:15:14 +05301634 @inlineCallbacks
1635 def remove_tcont(self, tcont_data, traffic_descriptor_data):
1636 log.info('remove-tcont')
1637 self.send_set_tcont(0x8001, 0xFFFF)
1638 yield self.wait_for_response()
1639
rshettyf4bf19e2017-09-19 01:28:27 +05301640 def create_multicast_gemport(self, data):
1641 self.log.info('Send relevant OMCI message')
sathishg5e21cd92017-12-21 12:19:19 +05301642
1643 @inlineCallbacks
1644 def disable(self, device):
1645 try:
1646 self.log.info('sending-admin-state-lock-towards-device', device=device)
1647 self.send_set_admin_state(0x0000, ADMIN_STATE_LOCK)
1648 yield self.wait_for_response()
1649 device = self.adapter_agent.get_device(device.id)
1650 # Disable all ports on that device
1651 self.adapter_agent.disable_all_ports(self.device_id)
1652 parent_device = self.adapter_agent.get_device(device.parent_id)
1653 logical_device_id = parent_device.parent_id
1654 assert logical_device_id
1655 # Mark OF PORT STATE DOWN
1656 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
1657 for port in ports:
1658 state = OFPPS_LINK_DOWN
1659 port_id = 'uni-{}'.format(port.port_no)
1660 self.update_logical_port(logical_device_id, port_id, state)
1661 device.oper_status = OperStatus.UNKNOWN
1662 device.connect_status = ConnectStatus.UNREACHABLE
1663 self.adapter_agent.update_device(device)
1664 except Exception as e:
1665 log.exception('exception-in-onu-disable', exception=e)
1666
1667 @inlineCallbacks
1668 def reenable(self, device):
1669 try:
1670 self.log.info('sending-admin-state-unlock-towards-device', device=device)
1671 self.send_set_admin_state(0x0000, ADMIN_STATE_UNLOCK)
1672 yield self.wait_for_response()
1673 device = self.adapter_agent.get_device(device.id)
1674 # Re-enable the ports on that device
1675 self.adapter_agent.enable_all_ports(device.id)
1676 parent_device = self.adapter_agent.get_device(device.parent_id)
1677 logical_device_id = parent_device.parent_id
1678 assert logical_device_id
1679 # Mark OF PORT STATE UP
1680 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
1681 for port in ports:
1682 state = OFPPS_LIVE
1683 port_id = 'uni-{}'.format(port.port_no)
1684 self.update_logical_port(logical_device_id, port_id, state)
1685 device.oper_status = OperStatus.ACTIVE
1686 device.connect_status = ConnectStatus.REACHABLE
1687 self.adapter_agent.update_device(device)
1688 except Exception as e:
1689 log.exception('exception-in-onu-reenable', exception=e)
1690