blob: 35b25379fa1487e59ccb1d0236e1e7a0f34077cd [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
Girish Gowdru4e854c22018-09-26 02:51:57 -070027from common.utils.asleep import asleep
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080028from voltha.adapters.interface import IAdapterInterface
29from voltha.core.logical_device_agent import mac_str_to_tuple
Steve Crooksf248e182017-02-07 10:50:24 -050030import voltha.core.flow_decomposer as fd
Steve Crooks3c2c7582017-01-10 15:02:26 -060031from voltha.protos import third_party
32from voltha.protos.adapter_pb2 import Adapter
33from voltha.protos.adapter_pb2 import AdapterConfig
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080034from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \
35 AdminState
ggowdru236bd952017-06-20 20:32:55 -070036from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image
Steve Crooks3c2c7582017-01-10 15:02:26 -060037from voltha.protos.health_pb2 import HealthStatus
38from voltha.protos.logical_device_pb2 import LogicalPort
rshettyf4bf19e2017-09-19 01:28:27 +053039from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD, OFPPS_LINK_DOWN
Nicolas Palpacuerc246d1b2018-06-28 14:00:49 -040040from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port, \
41 ofp_port_stats
Girish61687212018-01-08 12:48:58 +053042from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig, VOntaniConfig
rshettyf4bf19e2017-09-19 01:28:27 +053043from voltha.protos.bbf_fiber_traffic_descriptor_profile_body_pb2 import \
44 TrafficDescriptorProfileData
45from voltha.protos.bbf_fiber_tcont_body_pb2 import TcontsConfigData
46from voltha.protos.bbf_fiber_gemport_body_pb2 import GemportsConfigData
rshetty1cc73982017-09-02 03:31:12 +053047
Steve Crooks3c2c7582017-01-10 15:02:26 -060048from common.frameio.frameio import hexify
49from voltha.extensions.omci.omci import *
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080050
Jonathan Davisb45bb372018-07-19 15:05:15 -040051from voltha.registry import registry
52
Steve Crooks3c2c7582017-01-10 15:02:26 -060053_ = third_party
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080054log = structlog.get_logger()
55
56
Girish Gowdru4e854c22018-09-26 02:51:57 -070057MANAGEMENT_VLAN = 4090
rshettyf4bf19e2017-09-19 01:28:27 +053058BRDCM_DEFAULT_VLAN = 4091
sathishgff102eb2017-12-21 12:19:19 +053059ADMIN_STATE_LOCK = 1
60ADMIN_STATE_UNLOCK = 0
ggowdru42662622018-04-16 10:03:31 +053061RESERVED_VLAN_ID = 4095
Girish Gowdru4e854c22018-09-26 02:51:57 -070062FLOW_TYPE_EAPOL = 34958
rshettyf4bf19e2017-09-19 01:28:27 +053063
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080064@implementer(IAdapterInterface)
65class BroadcomOnuAdapter(object):
66
67 name = 'broadcom_onu'
68
69 supported_device_types = [
70 DeviceType(
Steve Crooks3c2c7582017-01-10 15:02:26 -060071 id=name,
Shad Ansarib9804512018-12-11 14:23:05 -080072 vendor_ids=['NONE'],
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080073 adapter=name,
Girish Gowdru4e854c22018-09-26 02:51:57 -070074 accepts_bulk_flow_update=True,
75 accepts_add_remove_flow_updates=True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080076 )
77 ]
78
79 def __init__(self, adapter_agent, config):
80 self.adapter_agent = adapter_agent
81 self.config = config
82 self.descriptor = Adapter(
83 id=self.name,
84 vendor='Voltha project',
Girish Gowdru1f2f5d32018-06-14 00:38:33 -070085 version='0.46',
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080086 config=AdapterConfig(log_level=LogLevel.INFO)
87 )
Steve Crooks3c2c7582017-01-10 15:02:26 -060088 self.devices_handlers = dict() # device_id -> BroadcomOnuHandler()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080089
Peter Shafik9107f2e2017-05-02 15:54:39 -040090 # register for adapter messages
91 self.adapter_agent.register_for_inter_adapter_messages()
92
Zsolt Haraszticc153aa2016-12-14 02:28:59 -080093 def start(self):
94 log.debug('starting')
95 log.info('started')
96
97 def stop(self):
98 log.debug('stopping')
99 log.info('stopped')
100
101 def adapter_descriptor(self):
102 return self.descriptor
103
104 def device_types(self):
105 return DeviceTypes(items=self.supported_device_types)
106
107 def health(self):
108 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
109
110 def change_master_state(self, master):
111 raise NotImplementedError()
112
113 def adopt_device(self, device):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600114 log.info('adopt_device', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530115 self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id)
116 reactor.callLater(0, self.devices_handlers[device.id].activate, device)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800117 return device
118
khenaidoo032d3302017-06-09 14:50:04 -0400119 def reconcile_device(self, device):
sathishg01ca0802017-11-03 18:32:11 +0530120 log.info('reconcile-device', device_id=device.id)
121 self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id)
122 reactor.callLater(0, self.devices_handlers[device.id].reconcile, device)
khenaidoo032d3302017-06-09 14:50:04 -0400123
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800124 def abandon_device(self, device):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400125 log.info('abadon-device - Not implemented')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800126 raise NotImplementedError()
127
Khen Nursimulud068d812017-03-06 11:44:18 -0500128 def disable_device(self, device):
sathishgff102eb2017-12-21 12:19:19 +0530129 log.info('disable-onu-device', device_id=device.id)
130 if device.id in self.devices_handlers:
131 handler = self.devices_handlers[device.id]
132 if handler is not None:
133 handler.disable(device)
Khen Nursimulud068d812017-03-06 11:44:18 -0500134
135 def reenable_device(self, device):
sathishgff102eb2017-12-21 12:19:19 +0530136 log.info('reenable-onu-device', device_id=device.id)
137 if device.id in self.devices_handlers:
138 handler = self.devices_handlers[device.id]
139 if handler is not None:
140 handler.reenable(device)
Khen Nursimulud068d812017-03-06 11:44:18 -0500141
142 def reboot_device(self, device):
Girish61687212018-01-08 12:48:58 +0530143 log.info('reboot-device', device_id=device.id)
144 if device.id in self.devices_handlers:
145 handler = self.devices_handlers[device.id]
146 if handler is not None:
147 handler.reboot()
Khen Nursimulud068d812017-03-06 11:44:18 -0500148
Lydia Fang01f2e852017-06-28 17:24:58 -0700149 def download_image(self, device, request):
150 raise NotImplementedError()
151
152 def get_image_download_status(self, device, request):
153 raise NotImplementedError()
154
155 def cancel_image_download(self, device, request):
156 raise NotImplementedError()
157
158 def activate_image_update(self, device, request):
159 raise NotImplementedError()
160
161 def revert_image_update(self, device, request):
162 raise NotImplementedError()
163
sathishg5ae86222017-06-28 15:16:29 +0530164 def self_test_device(self, device):
165 """
166 This is called to Self a device based on a NBI call.
167 :param device: A Voltha.Device object.
168 :return: Will return result of self test
169 """
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400170 log.info('self-test-device - Not implemented', device=device.id)
sathishg5ae86222017-06-28 15:16:29 +0530171 raise NotImplementedError()
172
Khen Nursimulud068d812017-03-06 11:44:18 -0500173 def delete_device(self, device):
Jonathan Davisb45bb372018-07-19 15:05:15 -0400174 log.info('delete-device', device_id=device.id, device_handlers=self.devices_handlers)
Girishd5823672017-11-23 12:15:14 +0530175 if device.id in self.devices_handlers:
176 handler = self.devices_handlers[device.id]
177 if handler is not None:
Jonathan Davisb45bb372018-07-19 15:05:15 -0400178 log.debug('calling-handler-delete', handler=handler)
Girishd5823672017-11-23 12:15:14 +0530179 handler.delete(device)
Girish Gowdru4e854c22018-09-26 02:51:57 -0700180 del self.devices_handlers[device.id]
Girishd5823672017-11-23 12:15:14 +0530181 return
Khen Nursimulud068d812017-03-06 11:44:18 -0500182
183 def get_device_details(self, device):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800184 raise NotImplementedError()
185
Sergio Slobodrianec864c62017-03-09 11:41:43 -0500186 def update_pm_config(self, device, pm_configs):
187 raise NotImplementedError()
188
Steve Crooks3c2c7582017-01-10 15:02:26 -0600189 def update_flows_bulk(self, device, flows, groups):
rshettyf4bf19e2017-09-19 01:28:27 +0530190 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600191 log.info('bulk-flow-update', device_id=device.id,
192 flows=flows, groups=groups)
rshettyf4bf19e2017-09-19 01:28:27 +0530193 '''
Steve Crooks3c2c7582017-01-10 15:02:26 -0600194 assert len(groups.items) == 0
rshettyf4bf19e2017-09-19 01:28:27 +0530195 handler = self.devices_handlers[device.id]
Steve Crooksf248e182017-02-07 10:50:24 -0500196 return handler.update_flow_table(device, flows.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600197
198 def update_flows_incrementally(self, device, flow_changes, group_changes):
Girish Gowdru4e854c22018-09-26 02:51:57 -0700199 log.info('incremental-flow-update', device_id=device.id,
200 flows=flow_changes, groups=group_changes)
201 # For now, there is no support for group changes
202 assert len(group_changes.to_add.items) == 0
203 assert len(group_changes.to_remove.items) == 0
204
205 handler = self.devices_handlers[device.id]
206 # Remove flows
207 if len(flow_changes.to_remove.items) != 0:
208 handler.remove_from_flow_table(flow_changes.to_remove.items)
209
210 # Add flows
211 if len(flow_changes.to_add.items) != 0:
212 handler.add_to_flow_table(flow_changes.to_add.items)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600213
214 def send_proxied_message(self, proxy_address, msg):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400215 log.debug('send-proxied-message', proxy_address=proxy_address, msg=msg)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600216
217 def receive_proxied_message(self, proxy_address, msg):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400218 log.debug('receive-proxied-message', proxy_address=proxy_address,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600219 device_id=proxy_address.device_id, msg=hexify(msg))
rshettyf4bf19e2017-09-19 01:28:27 +0530220 # Device_id from the proxy_address is the olt device id. We need to
221 # get the onu device id using the port number in the proxy_address
222 device = self.adapter_agent. \
223 get_child_device_with_proxy_address(proxy_address)
224 if device:
225 handler = self.devices_handlers[device.id]
226 handler.receive_message(msg)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600227
228 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
229 log.info('packet-out', logical_device_id=logical_device_id,
230 egress_port_no=egress_port_no, msg_len=len(msg))
231
Peter Shafik9107f2e2017-05-02 15:54:39 -0400232 def receive_inter_adapter_message(self, msg):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400233 log.debug('receive_inter_adapter_message', msg=msg)
Peter Shafikd7f33772017-05-17 13:56:34 -0400234 proxy_address = msg['proxy_address']
235 assert proxy_address is not None
rshettyf4bf19e2017-09-19 01:28:27 +0530236 # Device_id from the proxy_address is the olt device id. We need to
237 # get the onu device id using the port number in the proxy_address
238 device = self.adapter_agent. \
239 get_child_device_with_proxy_address(proxy_address)
240 if device:
241 handler = self.devices_handlers[device.id]
242 handler.event_messages.put(msg)
Girish61687212018-01-08 12:48:58 +0530243 else:
244 log.error("device-not-found")
Peter Shafik9107f2e2017-05-02 15:54:39 -0400245
Nikolay Titov89004ec2017-06-19 18:22:42 -0400246 def create_interface(self, device, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400247 log.debug('create-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530248 if device.id in self.devices_handlers:
249 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530250 if handler is not None:
251 handler.create_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400252
253 def update_interface(self, device, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400254 log.debug('update-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530255 if device.id in self.devices_handlers:
256 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530257 if handler is not None:
258 handler.update_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400259
260 def remove_interface(self, device, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400261 log.debug('remove-interface', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530262 if device.id in self.devices_handlers:
263 handler = self.devices_handlers[device.id]
rshettyc26a3c32017-07-27 11:06:38 +0530264 if handler is not None:
265 handler.remove_interface(data)
Nikolay Titov89004ec2017-06-19 18:22:42 -0400266
267 def receive_onu_detect_state(self, device_id, state):
268 raise NotImplementedError()
269
Nikolay Titov176f1db2017-08-10 12:38:43 -0400270 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400271 log.debug('create-tcont', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530272 if device.id in self.devices_handlers:
273 handler = self.devices_handlers[device.id]
274 if handler is not None:
275 handler.create_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400276
277 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
Girish Gowdru4e854c22018-09-26 02:51:57 -0700278 log.info('update_tcont not implemented in onu')
Nikolay Titov176f1db2017-08-10 12:38:43 -0400279
280 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400281 log.debug('remove-tcont', device_id=device.id)
Girishd5823672017-11-23 12:15:14 +0530282 if device.id in self.devices_handlers:
283 handler = self.devices_handlers[device.id]
284 if handler is not None:
285 handler.remove_tcont(tcont_data, traffic_descriptor_data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400286
287 def create_gemport(self, device, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400288 log.debug('create-gemport', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530289 if device.id in self.devices_handlers:
290 handler = self.devices_handlers[device.id]
291 if handler is not None:
292 handler.create_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400293
294 def update_gemport(self, device, data):
295 raise NotImplementedError()
296
297 def remove_gemport(self, device, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400298 log.debug('remove-gemport', device_id=device.id)
Girishd5823672017-11-23 12:15:14 +0530299 if device.id in self.devices_handlers:
300 handler = self.devices_handlers[device.id]
301 if handler is not None:
302 handler.remove_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400303
304 def create_multicast_gemport(self, device, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400305 log.debug('create-multicast-gemport', device_id=device.id)
rshettyf4bf19e2017-09-19 01:28:27 +0530306 if device.id in self.devices_handlers:
307 handler = self.devices_handlers[device.id]
308 if handler is not None:
309 handler.create_multicast_gemport(data)
Nikolay Titov176f1db2017-08-10 12:38:43 -0400310
311 def update_multicast_gemport(self, device, data):
312 raise NotImplementedError()
313
314 def remove_multicast_gemport(self, device, data):
315 raise NotImplementedError()
316
317 def create_multicast_distribution_set(self, device, data):
318 raise NotImplementedError()
319
320 def update_multicast_distribution_set(self, device, data):
321 raise NotImplementedError()
322
323 def remove_multicast_distribution_set(self, device, data):
324 raise NotImplementedError()
325
326 def suppress_alarm(self, filter):
327 raise NotImplementedError()
328
Stephane Barbarie980a0912017-05-11 11:27:06 -0400329 def unsuppress_alarm(self, filter):
330 raise NotImplementedError()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600331
Chip Boling4c06db92018-05-24 15:02:26 -0500332
Steve Crooks3c2c7582017-01-10 15:02:26 -0600333class BroadcomOnuHandler(object):
334
335 def __init__(self, adapter, device_id):
336 self.adapter = adapter
337 self.adapter_agent = adapter.adapter_agent
338 self.device_id = device_id
339 self.log = structlog.get_logger(device_id=device_id)
340 self.incoming_messages = DeferredQueue()
Peter Shafikd7f33772017-05-17 13:56:34 -0400341 self.event_messages = DeferredQueue()
Steve Crooks3c2c7582017-01-10 15:02:26 -0600342 self.proxy_address = None
343 self.tx_id = 0
Girish Gowdru4e854c22018-09-26 02:51:57 -0700344 self.flow_map = dict()
Jonathan Davisb45bb372018-07-19 15:05:15 -0400345
Peter Shafikd7f33772017-05-17 13:56:34 -0400346 # Need to query ONU for number of supported uni ports
347 # For now, temporarily set number of ports to 1 - port #2
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -0500348 self.uni_ports = (1, 2, 3, 4, 5)
Girish Gowdru4e854c22018-09-26 02:51:57 -0700349 self.flow_config_in_progress = False
Peter Shafikd7f33772017-05-17 13:56:34 -0400350
351 # Handle received ONU event messages
352 reactor.callLater(0, self.handle_onu_events)
353
Steve Crooks3c2c7582017-01-10 15:02:26 -0600354 def receive_message(self, msg):
355 self.incoming_messages.put(msg)
356
Peter Shafikd7f33772017-05-17 13:56:34 -0400357 @inlineCallbacks
358 def handle_onu_events(self):
359 event_msg = yield self.event_messages.get()
360
361 if event_msg['event'] == 'activation-completed':
362
363 if event_msg['event_data']['activation_successful'] == True:
Nicolas Palpacuerecb3d1e2018-03-14 17:00:14 -0400364
365 yield self.message_exchange()
Peter Shafikd7f33772017-05-17 13:56:34 -0400366
367 device = self.adapter_agent.get_device(self.device_id)
Girishd5823672017-11-23 12:15:14 +0530368 device.connect_status = ConnectStatus.REACHABLE
Peter Shafikd7f33772017-05-17 13:56:34 -0400369 device.oper_status = OperStatus.ACTIVE
370 self.adapter_agent.update_device(device)
371
372 else:
373 device = self.adapter_agent.get_device(self.device_id)
Girish Gowdru1f2f5d32018-06-14 00:38:33 -0700374 self.disable_ports(device)
375 device.connect_status = ConnectStatus.UNREACHABLE
Peter Shafikd7f33772017-05-17 13:56:34 -0400376 device.oper_status = OperStatus.FAILED
377 self.adapter_agent.update_device(device)
Girish Gowdru4e854c22018-09-26 02:51:57 -0700378 self.flow_map.clear()
Peter Shafikd7f33772017-05-17 13:56:34 -0400379
380 elif event_msg['event'] == 'deactivation-completed':
381 device = self.adapter_agent.get_device(self.device_id)
382 device.oper_status = OperStatus.DISCOVERED
383 self.adapter_agent.update_device(device)
384
Girish61687212018-01-08 12:48:58 +0530385 elif event_msg['event'] == 'deactivate-onu':
Girisha9eb0212017-12-14 21:52:59 +0530386 device = self.adapter_agent.get_device(self.device_id)
ggowdru64d738a2018-05-10 07:08:06 -0700387 self.disable_ports(device)
Girisha9eb0212017-12-14 21:52:59 +0530388 device.connect_status = ConnectStatus.UNREACHABLE
389 device.oper_status = OperStatus.DISCOVERED
390 self.adapter_agent.update_device(device)
Girish Gowdru4e854c22018-09-26 02:51:57 -0700391 self.flow_map.clear()
ggowdru64d738a2018-05-10 07:08:06 -0700392
393 elif (event_msg['event'] == 'olt-reboot'):
394 device = self.adapter_agent.get_device(self.device_id)
395 device.connect_status = ConnectStatus.UNREACHABLE
396 self.adapter_agent.update_device(device)
Girish Gowdru4e854c22018-09-26 02:51:57 -0700397 self.flow_map.clear()
Girisha9eb0212017-12-14 21:52:59 +0530398
Peter Shafikd7f33772017-05-17 13:56:34 -0400399 elif event_msg['event'] == 'ranging-completed':
400
401 if event_msg['event_data']['ranging_successful'] == True:
402 device = self.adapter_agent.get_device(self.device_id)
403 device.oper_status = OperStatus.ACTIVATING
404 self.adapter_agent.update_device(device)
405
406 else:
407 device = self.adapter_agent.get_device(self.device_id)
408 device.oper_status = OperStatus.FAILED
409 self.adapter_agent.update_device(device)
410
Girish Gowdru1f2f5d32018-06-14 00:38:33 -0700411 elif event_msg['event'] == 'olt-disabled':
412 self.adapter_agent.disable_all_ports(self.device_id)
413 device = self.adapter_agent.get_device(self.device_id)
414 device.connect_status = ConnectStatus.UNREACHABLE
415 self.adapter_agent.update_device(device)
Girish Gowdru4e854c22018-09-26 02:51:57 -0700416 self.flow_map.clear()
Girish Gowdru1f2f5d32018-06-14 00:38:33 -0700417
418 elif event_msg['event'] == 'olt-enabled':
419 self.adapter_agent.enable_all_ports(self.device_id)
420 device = self.adapter_agent.get_device(self.device_id)
421 device.connect_status = ConnectStatus.REACHABLE
422 self.adapter_agent.update_device(device)
423
Shad Ansari2825d012018-02-22 23:57:46 +0000424 elif event_msg['event'] == 'create-tcont':
425 tcont = TcontsConfigData()
426 tcont.alloc_id = event_msg['event_data']['alloc_id']
427 self.create_tcont(tcont, traffic_descriptor_data=None)
428
429 elif event_msg['event'] == 'create-venet':
430 venet = VEnetConfig(name=event_msg['event_data']['uni_name'])
431 venet.interface.name = event_msg['event_data']['interface_name']
432 self.create_interface(venet)
433
434 elif event_msg['event'] == 'create-gemport':
435 gem_port = GemportsConfigData()
436 gem_port.gemport_id = event_msg['event_data']['gemport_id']
437 self.create_gemport(gem_port)
438
Peter Shafikd7f33772017-05-17 13:56:34 -0400439 # Handle next event
440 reactor.callLater(0, self.handle_onu_events)
441
Steve Crooks3c2c7582017-01-10 15:02:26 -0600442 def activate(self, device):
443 self.log.info('activating')
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800444
445 # first we verify that we got parent reference and proxy info
446 assert device.parent_id
447 assert device.proxy_address.device_id
Steve Crooks9b160d72017-03-31 10:48:29 -0500448 #assert device.proxy_address.channel_id # c-vid
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800449
Steve Crooks3c2c7582017-01-10 15:02:26 -0600450 # register for proxied messages right away
451 self.proxy_address = device.proxy_address
452 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
453
Peter Shafik9107f2e2017-05-02 15:54:39 -0400454
Steve Crooks3c2c7582017-01-10 15:02:26 -0600455 # populate device info
456 device.root = True
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800457 device.vendor = 'Broadcom'
Steve Crooks9e85ce82017-03-20 12:00:53 -0400458 device.model = 'n/a'
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800459 device.hardware_version = 'to be filled'
460 device.firmware_version = 'to be filled'
ggowdru236bd952017-06-20 20:32:55 -0700461 device.images.image.extend([
462 Image(version="to be filled")
463 ])
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800464 device.connect_status = ConnectStatus.REACHABLE
465 self.adapter_agent.update_device(device)
466
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800467 self.adapter_agent.add_port(device.id, Port(
Steve Crooks9b160d72017-03-31 10:48:29 -0500468 port_no=100,
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800469 label='PON port',
470 type=Port.PON_ONU,
471 admin_state=AdminState.ENABLED,
472 oper_status=OperStatus.ACTIVE,
473 peers=[
474 Port.PeerPort(
475 device_id=device.parent_id,
476 port_no=device.parent_port_no
477 )
478 ]
479 ))
480
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800481 parent_device = self.adapter_agent.get_device(device.parent_id)
482 logical_device_id = parent_device.parent_id
483 assert logical_device_id
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800484 device = self.adapter_agent.get_device(device.id)
Peter Shafikd7f33772017-05-17 13:56:34 -0400485 device.oper_status = OperStatus.DISCOVERED
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800486 self.adapter_agent.update_device(device)
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400487 self.log.info('activated')
488
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800489
sathishg01ca0802017-11-03 18:32:11 +0530490 def reconcile(self, device):
491
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400492 self.log.debug('reconciling-broadcom-onu-device-starts')
sathishg01ca0802017-11-03 18:32:11 +0530493
494 # first we verify that we got parent reference and proxy info
495 assert device.parent_id
496 assert device.proxy_address.device_id
497
498 # register for proxied messages right away
499 self.proxy_address = device.proxy_address
500 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
501
502 # TODO: Query ONU current status after reconcile and update.
503 # To be addressed in future commits.
504
Girish61687212018-01-08 12:48:58 +0530505 self.log.info('reconciling-broadcom-onu-device-ends')
sathishg01ca0802017-11-03 18:32:11 +0530506
sathishg24dad1e2018-01-10 10:48:45 +0530507 def update_logical_port(self, logical_device_id, port_id, state):
Girish Gowdru1f2f5d32018-06-14 00:38:33 -0700508 try:
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400509 self.log.debug('updating-logical-port', logical_port_id=port_id,
Girish Gowdru1f2f5d32018-06-14 00:38:33 -0700510 logical_device_id=logical_device_id, state=state)
511 logical_port = self.adapter_agent.get_logical_port(logical_device_id,
512 port_id)
513 logical_port.ofp_port.state = state
514 self.adapter_agent.update_logical_port(logical_device_id,
515 logical_port)
516 except Exception as e:
517 self.log.exception("exception-updating-port",e=e)
sathishg24dad1e2018-01-10 10:48:45 +0530518
Girishd5823672017-11-23 12:15:14 +0530519 def delete(self, device):
Jonathan Davisb45bb372018-07-19 15:05:15 -0400520 self.log.info('delete-onu', device=device)
521
522 parent_device = self.adapter_agent.get_device(device.parent_id)
523 if parent_device.type == 'openolt':
524 parent_adapter = registry('adapter_loader').get_agent(parent_device.adapter).adapter
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400525 self.log.debug('parent-adapter-delete-onu', onu_device=device,
Jonathan Davisb45bb372018-07-19 15:05:15 -0400526 parent_device=parent_device,
527 parent_adapter=parent_adapter)
528 try:
529 parent_adapter.delete_child_device(parent_device.id, device)
530 except AttributeError:
531 self.log.debug('parent-device-delete-child-not-implemented')
sathishg01ca0802017-11-03 18:32:11 +0530532
Steve Crooks3c2c7582017-01-10 15:02:26 -0600533 @inlineCallbacks
Steve Crooksf248e182017-02-07 10:50:24 -0500534 def update_flow_table(self, device, flows):
Girish Gowdru4e854c22018-09-26 02:51:57 -0700535
536 # Twisted code is not inherently thread safe. This API could
537 # be invoked again by reactor while previous one is in progress.
538 # Since we maintain some stateful information here, we better
539 # synchronize parallel invocations on this API.
540 yield self._wait_for_previous_update_flow_to_finish()
541 self.flow_config_in_progress = True
542
Steve Crooksf248e182017-02-07 10:50:24 -0500543 #
544 # We need to proxy through the OLT to get to the ONU
545 # Configuration from here should be using OMCI
546 #
Girish Gowdru4e854c22018-09-26 02:51:57 -0700547 try:
548 # Calculates flows_to_adds and flows_to_delete using
549 # incoming_flows and current_flows.
550 current_flows = set(self.flow_map.keys())
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800551
Girish Gowdru4e854c22018-09-26 02:51:57 -0700552 # Only adding those flows to incoming_flows which are having cookie.
553 incoming_flows = set(flow.cookie for flow in flows if flow.cookie)
554 flows_to_add = incoming_flows.difference(current_flows)
555 flows_to_delete = current_flows.difference(incoming_flows)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800556
Girish Gowdru4e854c22018-09-26 02:51:57 -0700557 # Sends request to delete flows for ONU flows in flows_to_delete list.
558 for cookie in flows_to_delete:
559 if cookie in self.flow_map:
560 c_tag = self.flow_map[cookie]["vlan_id"]
561 self.log.debug("flow-to-delete-cookie",
562 cookie=cookie, c_tag=c_tag)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -0800563
Girish Gowdru4e854c22018-09-26 02:51:57 -0700564 # Deleting flow from ONU.
565 yield self._delete_onu_flow(self.flow_map[cookie])
Steve Crooks3c2c7582017-01-10 15:02:26 -0600566
Girish Gowdru4e854c22018-09-26 02:51:57 -0700567 # Removing flow_map entry for deleted flow.
568 del self.flow_map[cookie]
Steve Crooksf248e182017-02-07 10:50:24 -0500569 else:
Girish Gowdru4e854c22018-09-26 02:51:57 -0700570 self.log.info('ignoring-cookie_received', cookie=cookie)
Steve Crooksf248e182017-02-07 10:50:24 -0500571
Girish Gowdru4e854c22018-09-26 02:51:57 -0700572 # If flow is not in flow_to_add, no need to add flow to ONU.
573 for flow in flows:
574 if flow.cookie not in flows_to_add:
575 self.log.debug("flow-not-to-be-added", cookie=flow.cookie)
Jeff55a2f132018-08-05 21:10:41 -0700576 continue
577
Girish Gowdru4e854c22018-09-26 02:51:57 -0700578 # Adding flow to ONU.
579 yield self._add_onu_flow(flow)
rshettyf4bf19e2017-09-19 01:28:27 +0530580
Girish Gowdru4e854c22018-09-26 02:51:57 -0700581 except Exception as e:
582 self.log.exception('failed-to-update-flow-table', e=e)
rshettyf4bf19e2017-09-19 01:28:27 +0530583
Girish Gowdru4e854c22018-09-26 02:51:57 -0700584 self.flow_config_in_progress = False
Steve Crooks9b160d72017-03-31 10:48:29 -0500585
Girish Gowdru4e854c22018-09-26 02:51:57 -0700586 @inlineCallbacks
587 def add_to_flow_table(self, flows):
588 """
589 This function is called for update_flows_incrementally to add
590 only delta flows to ONU.
591 :param flows: flows to add to ONU.
592 """
593 yield self._wait_for_previous_update_flow_to_finish()
594 self.flow_config_in_progress = True
595 self.log.debug('add-to-flow-table', flows=flows)
596 try:
597 for flow in flows:
598 # if incoming flow contains cookie, then add to ONU
599 if flow.cookie:
600 # Adds flow to ONU.
601 yield self._add_onu_flow(flow)
602 except Exception as e:
603 self.log.exception('failed-to-add-to-flow-table', e=e)
ggowdru42662622018-04-16 10:03:31 +0530604
Girish Gowdru4e854c22018-09-26 02:51:57 -0700605 self.flow_config_in_progress = False
ggowdru42662622018-04-16 10:03:31 +0530606
Girish Gowdru4e854c22018-09-26 02:51:57 -0700607 @inlineCallbacks
608 def remove_from_flow_table(self, flows):
609 """
610 This function is called for update_flow_incrementally to delete
611 only delta flows from ONU.
612 :param flows: flows to delete from ONU
613 """
614 yield self._wait_for_previous_update_flow_to_finish()
615 self.flow_config_in_progress = True
616 self.log.debug('remove-from-flow-table', flows=flows)
617 try:
618 cookies = [flow.cookie for flow in flows]
619 for cookie in cookies:
620 if cookie in self.flow_map:
621 c_tag = self.flow_map[cookie]["vlan_id"]
622 self.log.debug("remove-from-flow-table",
623 cookie=cookie, c_tag=c_tag)
624 # Deleting flow from ONU.
625 yield self._delete_onu_flow(self.flow_map[cookie])
626 # Removing flow_map entry for deleted flow.
627 del self.flow_map[cookie]
628 else:
629 self.log.error('ignoring-cookie_received', cookie=cookie)
630 except Exception as e:
631 self.log.exception('failed-to-remove-from-flow-table', e=e)
632 self.flow_config_in_progress = False
Steve Crooksf248e182017-02-07 10:50:24 -0500633
Steve Crooks3c2c7582017-01-10 15:02:26 -0600634 def get_tx_id(self):
635 self.tx_id += 1
636 return self.tx_id
637
638 def send_omci_message(self, frame):
639 _frame = hexify(str(frame))
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400640 self.log.debug('send-omci-message-%s' % _frame)
Steve Crooks3c2c7582017-01-10 15:02:26 -0600641 device = self.adapter_agent.get_device(self.device_id)
642 try:
643 self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
644 except Exception as e:
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -0400645 self.log.warn('send-omci-message-exception', exc=str(e))
Steve Crooks3c2c7582017-01-10 15:02:26 -0600646
647 def send_get_circuit_pack(self, entity_id=0):
648 frame = OmciFrame(
649 transaction_id=self.get_tx_id(),
650 message_type=OmciGet.message_id,
651 omci_message=OmciGet(
652 entity_class=CircuitPack.class_id,
653 entity_id=entity_id,
654 attributes_mask=CircuitPack.mask_for('vendor_id')
655 )
656 )
657 self.send_omci_message(frame)
658
659 def send_mib_reset(self, entity_id=0):
660 frame = OmciFrame(
661 transaction_id=self.get_tx_id(),
662 message_type=OmciMibReset.message_id,
663 omci_message=OmciMibReset(
664 entity_class=OntData.class_id,
665 entity_id=entity_id
666 )
667 )
668 self.send_omci_message(frame)
669
Steve Crooks9e85ce82017-03-20 12:00:53 -0400670 def send_create_gal_ethernet_profile(self,
671 entity_id,
672 max_gem_payload_size):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600673 frame = OmciFrame(
674 transaction_id=self.get_tx_id(),
675 message_type=OmciCreate.message_id,
676 omci_message=OmciCreate(
677 entity_class=GalEthernetProfile.class_id,
678 entity_id=entity_id,
679 data=dict(
680 max_gem_payload_size=max_gem_payload_size
681 )
682 )
683 )
684 self.send_omci_message(frame)
685
sathishgff102eb2017-12-21 12:19:19 +0530686 def send_set_admin_state(self,
687 entity_id,
688 admin_state):
689 data = dict(
690 administrative_state=admin_state
691 )
692 frame = OmciFrame(
693 transaction_id=self.get_tx_id(),
694 message_type=OmciSet.message_id,
695 omci_message=OmciSet(
696 entity_class=OntG.class_id,
697 entity_id=entity_id,
698 attributes_mask=OntG.mask_for(*data.keys()),
699 data=data
700 )
701 )
702 self.send_omci_message(frame)
703
Steve Crooks9e85ce82017-03-20 12:00:53 -0400704 def send_set_tcont(self,
705 entity_id,
706 alloc_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600707 data = dict(
708 alloc_id=alloc_id
709 )
710 frame = OmciFrame(
711 transaction_id=self.get_tx_id(),
712 message_type=OmciSet.message_id,
713 omci_message=OmciSet(
714 entity_class=Tcont.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400715 entity_id=entity_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600716 attributes_mask=Tcont.mask_for(*data.keys()),
717 data=data
718 )
719 )
720 self.send_omci_message(frame)
721
Steve Crooks9e85ce82017-03-20 12:00:53 -0400722 def send_create_8021p_mapper_service_profile(self,
723 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600724 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400725 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600726 message_type=OmciCreate.message_id,
727 omci_message=OmciCreate(
728 entity_class=Ieee8021pMapperServiceProfile.class_id,
729 entity_id=entity_id,
730 data=dict(
731 tp_pointer=OmciNullPointer,
732 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
Steve Crooks9b160d72017-03-31 10:48:29 -0500733 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
734 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
735 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
736 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
737 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
738 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
739 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
Steve Crooks3c2c7582017-01-10 15:02:26 -0600740 )
741 )
742 )
743 self.send_omci_message(frame)
744
Steve Crooks9e85ce82017-03-20 12:00:53 -0400745 def send_create_mac_bridge_service_profile(self,
746 entity_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600747 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400748 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600749 message_type=OmciCreate.message_id,
750 omci_message=OmciCreate(
751 entity_class=MacBridgeServiceProfile.class_id,
752 entity_id=entity_id,
753 data=dict(
754 spanning_tree_ind=False,
755 learning_ind=True,
756 priority=0x8000,
757 max_age=20 * 256,
758 hello_time=2 * 256,
759 forward_delay=15 * 256,
760 unknown_mac_address_discard=True
761 )
762 )
763 )
764 self.send_omci_message(frame)
765
Steve Crooks9e85ce82017-03-20 12:00:53 -0400766 def send_create_gem_port_network_ctp(self,
767 entity_id,
768 port_id,
769 tcont_id,
770 direction,
771 tm):
772 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
773 if _directions.has_key(direction):
774 _direction = _directions[direction]
775 else:
776 self.log.error('invalid-gem-port-direction', direction=direction)
777 raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction))
778
Steve Crooks3c2c7582017-01-10 15:02:26 -0600779 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400780 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600781 message_type=OmciCreate.message_id,
782 omci_message=OmciCreate(
783 entity_class=GemPortNetworkCtp.class_id,
784 entity_id=entity_id,
785 data=dict(
786 port_id=port_id,
787 tcont_pointer=tcont_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400788 direction=_direction,
789 traffic_management_pointer_upstream=tm
Steve Crooks3c2c7582017-01-10 15:02:26 -0600790 )
791 )
792 )
793 self.send_omci_message(frame)
794
Steve Crooks9e85ce82017-03-20 12:00:53 -0400795 def send_create_multicast_gem_interworking_tp(self,
796 entity_id,
797 gem_port_net_ctp_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600798 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400799 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600800 message_type=OmciCreate.message_id,
801 omci_message=OmciCreate(
802 entity_class=MulticastGemInterworkingTp.class_id,
803 entity_id=entity_id,
804 data=dict(
805 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
806 interworking_option=0,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400807 service_profile_pointer=0x1
Steve Crooks3c2c7582017-01-10 15:02:26 -0600808 )
809 )
810 )
811 self.send_omci_message(frame)
812
Steve Crooks9e85ce82017-03-20 12:00:53 -0400813 def send_create_gem_inteworking_tp(self,
814 entity_id,
815 gem_port_net_ctp_id,
816 service_profile_id):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600817 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400818 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600819 message_type=OmciCreate.message_id,
820 omci_message=OmciCreate(
821 entity_class=GemInterworkingTp.class_id,
822 entity_id=entity_id,
823 data=dict(
824 gem_port_network_ctp_pointer=gem_port_net_ctp_id,
825 interworking_option=5,
826 service_profile_pointer=service_profile_id,
827 interworking_tp_pointer=0x0,
828 gal_profile_pointer=0x1
829 )
830 )
831 )
832 self.send_omci_message(frame)
833
Girishd5823672017-11-23 12:15:14 +0530834 def send_delete_omci_mesage(self,
835 class_id,
836 entity_id):
837 frame = OmciFrame(
838 transaction_id=self.get_tx_id(),
839 message_type=OmciDelete.message_id,
840 omci_message=OmciDelete(
841 entity_class=class_id,
842 entity_id=entity_id
843 )
844 )
845 self.send_omci_message(frame)
846
Steve Crooks9e85ce82017-03-20 12:00:53 -0400847 def send_set_8021p_mapper_service_profile(self,
848 entity_id,
Girish Gowdrud75ef392018-10-02 10:33:50 -0700849 interwork_tp_id_0_6=None,
850 interwork_tp_id_7=None):
Girish Gowdru4e854c22018-09-26 02:51:57 -0700851 data = dict()
Girish Gowdrud75ef392018-10-02 10:33:50 -0700852 if interwork_tp_id_0_6 is not None:
853 data['interwork_tp_pointer_for_p_bit_priority_0']=interwork_tp_id_0_6
854 data['interwork_tp_pointer_for_p_bit_priority_1']=interwork_tp_id_0_6
855 data['interwork_tp_pointer_for_p_bit_priority_2']=interwork_tp_id_0_6
856 data['interwork_tp_pointer_for_p_bit_priority_3']=interwork_tp_id_0_6
857 data['interwork_tp_pointer_for_p_bit_priority_4']=interwork_tp_id_0_6
858 data['interwork_tp_pointer_for_p_bit_priority_5']=interwork_tp_id_0_6
859 data['interwork_tp_pointer_for_p_bit_priority_6']=interwork_tp_id_0_6
860 if interwork_tp_id_7 is not None:
861 data['interwork_tp_pointer_for_p_bit_priority_0']=interwork_tp_id_7
862 data['interwork_tp_pointer_for_p_bit_priority_1']=interwork_tp_id_7
863 data['interwork_tp_pointer_for_p_bit_priority_2']=interwork_tp_id_7
864 data['interwork_tp_pointer_for_p_bit_priority_3']=interwork_tp_id_7
865 data['interwork_tp_pointer_for_p_bit_priority_4']=interwork_tp_id_7
866 data['interwork_tp_pointer_for_p_bit_priority_5']=interwork_tp_id_7
867 data['interwork_tp_pointer_for_p_bit_priority_6']=interwork_tp_id_7
868 data['interwork_tp_pointer_for_p_bit_priority_7']=interwork_tp_id_7
Girish Gowdru4e854c22018-09-26 02:51:57 -0700869
Steve Crooks3c2c7582017-01-10 15:02:26 -0600870 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400871 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600872 message_type=OmciSet.message_id,
873 omci_message=OmciSet(
874 entity_class=Ieee8021pMapperServiceProfile.class_id,
875 entity_id=entity_id,
876 attributes_mask=Ieee8021pMapperServiceProfile.mask_for(
877 *data.keys()),
878 data=data
879 )
880 )
881 self.send_omci_message(frame)
882
883 def send_create_mac_bridge_port_configuration_data(self,
884 entity_id,
885 bridge_id,
886 port_id,
887 tp_type,
888 tp_id):
889 frame = OmciFrame(
890 transaction_id=self.get_tx_id(),
891 message_type=OmciCreate.message_id,
892 omci_message=OmciCreate(
893 entity_class=MacBridgePortConfigurationData.class_id,
894 entity_id=entity_id,
895 data=dict(
Girish61687212018-01-08 12:48:58 +0530896 bridge_id_pointer=bridge_id,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600897 port_num=port_id,
898 tp_type=tp_type,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400899 tp_pointer=tp_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600900 )
901 )
902 )
903 self.send_omci_message(frame)
904
Steve Crooks9e85ce82017-03-20 12:00:53 -0400905 def send_create_vlan_tagging_filter_data(self,
906 entity_id,
ggowdru42662622018-04-16 10:03:31 +0530907 vlan_id,
908 fwd_operation):
Chip Boling4c06db92018-05-24 15:02:26 -0500909 vlan_filter_list = [0] * 12
910 vlan_filter_list[0] = vlan_id
Steve Crooks3c2c7582017-01-10 15:02:26 -0600911 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400912 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600913 message_type=OmciCreate.message_id,
914 omci_message=OmciCreate(
915 entity_class=VlanTaggingFilterData.class_id,
916 entity_id=entity_id,
917 data=dict(
Chip Boling4c06db92018-05-24 15:02:26 -0500918 vlan_filter_list=vlan_filter_list,
ggowdru42662622018-04-16 10:03:31 +0530919 forward_operation=fwd_operation,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600920 number_of_entries=1
921 )
922 )
923 )
924 self.send_omci_message(frame)
925
rshettyf4bf19e2017-09-19 01:28:27 +0530926 def send_set_vlan_tagging_filter_data(self,
927 entity_id,
928 vlan_id):
Chip Boling4c06db92018-05-24 15:02:26 -0500929 vlan_filter_list = [0] * 12
930 vlan_filter_list[0] = vlan_id
rshettyf4bf19e2017-09-19 01:28:27 +0530931 data = dict(
Chip Boling4c06db92018-05-24 15:02:26 -0500932 vlan_filter_list=vlan_filter_list,
rshettyf4bf19e2017-09-19 01:28:27 +0530933 forward_operation=0x10,
934 number_of_entries=1
935 )
936
937 frame = OmciFrame(
938 transaction_id=self.get_tx_id(),
939 message_type=OmciSet.message_id,
940 omci_message=OmciSet(
941 entity_class=VlanTaggingFilterData.class_id,
942 entity_id=entity_id,
943 attributes_mask=VlanTaggingFilterData.mask_for(
944 *data.keys()),
945 data=data
946 )
947 )
948 self.send_omci_message(frame)
949
950 def send_delete_vlan_tagging_filter_data(self,
951 entity_id):
952 frame = OmciFrame(
953 transaction_id=self.get_tx_id(),
954 message_type=OmciDelete.message_id,
955 omci_message=OmciDelete(
956 entity_class=VlanTaggingFilterData.class_id,
957 entity_id=entity_id
958 )
959 )
960 self.send_omci_message(frame)
961
Steve Crooks46d64302017-03-10 15:11:06 -0500962 def send_create_extended_vlan_tagging_operation_configuration_data(self,
963 entity_id,
964 assoc_type,
965 assoc_me):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600966 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400967 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600968 message_type=OmciCreate.message_id,
969 omci_message=OmciCreate(
970 entity_class=
971 ExtendedVlanTaggingOperationConfigurationData.class_id,
972 entity_id=entity_id,
973 data=dict(
Steve Crooks46d64302017-03-10 15:11:06 -0500974 association_type=assoc_type,
975 associated_me_pointer=assoc_me
Steve Crooks3c2c7582017-01-10 15:02:26 -0600976 )
977 )
978 )
979 self.send_omci_message(frame)
980
Steve Crooks9e85ce82017-03-20 12:00:53 -0400981 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self,
982 entity_id,
983 input_tpid,
984 output_tpid):
Steve Crooks3c2c7582017-01-10 15:02:26 -0600985 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400986 input_tpid=input_tpid,
987 output_tpid=output_tpid,
Steve Crooks3c2c7582017-01-10 15:02:26 -0600988 downstream_mode=0, # inverse of upstream
989 )
990 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400991 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -0600992 message_type=OmciSet.message_id,
993 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -0400994 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600995 ExtendedVlanTaggingOperationConfigurationData.class_id,
996 entity_id=entity_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -0400997 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -0600998 ExtendedVlanTaggingOperationConfigurationData.mask_for(
999 *data.keys()),
1000 data=data
1001 )
1002 )
1003 self.send_omci_message(frame)
1004
Steve Crooksa9d0a7c2017-03-28 22:40:01 -04001005 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
1006 entity_id,
1007 filter_inner_vid,
1008 treatment_inner_vid):
Steve Crooks3c2c7582017-01-10 15:02:26 -06001009 data = dict(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001010 received_frame_vlan_tagging_operation_table=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001011 VlanTaggingOperation(
1012 filter_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -05001013 filter_outer_vid=4096,
1014 filter_outer_tpid_de=0,
1015
1016 filter_inner_priority=15,
1017 filter_inner_vid=filter_inner_vid,
1018 filter_inner_tpid_de=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001019 filter_ether_type=0,
Steve Crooks46d64302017-03-10 15:11:06 -05001020
1021 treatment_tags_to_remove=0,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001022 treatment_outer_priority=15,
Steve Crooks46d64302017-03-10 15:11:06 -05001023 treatment_outer_vid=0,
1024 treatment_outer_tpid_de=0,
1025
1026 treatment_inner_priority=0,
1027 treatment_inner_vid=treatment_inner_vid,
Steve Crooks3c2c7582017-01-10 15:02:26 -06001028 treatment_inner_tpid_de=4
1029 )
1030 )
1031 frame = OmciFrame(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001032 transaction_id=self.get_tx_id(),
Steve Crooks3c2c7582017-01-10 15:02:26 -06001033 message_type=OmciSet.message_id,
1034 omci_message=OmciSet(
Steve Crooks9e85ce82017-03-20 12:00:53 -04001035 entity_class=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001036 ExtendedVlanTaggingOperationConfigurationData.class_id,
Steve Crooks9e85ce82017-03-20 12:00:53 -04001037 entity_id=entity_id,
1038 attributes_mask=
Steve Crooks3c2c7582017-01-10 15:02:26 -06001039 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1040 *data.keys()),
1041 data=data
1042 )
1043 )
1044 self.send_omci_message(frame)
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001045
Girish Gowdru4e854c22018-09-26 02:51:57 -07001046 def send_delete_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self,
1047 entity_id):
1048 frame = OmciFrame(
1049 transaction_id=self.get_tx_id(),
1050 message_type=OmciDelete.message_id,
1051 omci_message=OmciDelete(
1052 entity_class=ExtendedVlanTaggingOperationConfigurationData.class_id,
1053 entity_id=entity_id
1054 )
1055 )
1056 self.send_omci_message(frame)
1057
Steve Crooksa9d0a7c2017-03-28 22:40:01 -04001058 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
1059 entity_id,
1060 filter_inner_priority,
1061 filter_inner_vid,
1062 filter_inner_tpid_de,
1063 treatment_tags_to_remove,
1064 treatment_inner_priority,
1065 treatment_inner_vid):
1066 data = dict(
1067 received_frame_vlan_tagging_operation_table=
1068 VlanTaggingOperation(
1069 filter_outer_priority=15,
1070 filter_outer_vid=4096,
1071 filter_outer_tpid_de=0,
1072
1073 filter_inner_priority=filter_inner_priority,
1074 filter_inner_vid=filter_inner_vid,
1075 filter_inner_tpid_de=filter_inner_tpid_de,
1076 filter_ether_type=0,
1077
1078 treatment_tags_to_remove=treatment_tags_to_remove,
1079 treatment_outer_priority=15,
1080 treatment_outer_vid=0,
1081 treatment_outer_tpid_de=0,
1082
1083 treatment_inner_priority=treatment_inner_priority,
1084 treatment_inner_vid=treatment_inner_vid,
1085 treatment_inner_tpid_de=4
1086 )
1087 )
1088 frame = OmciFrame(
1089 transaction_id=self.get_tx_id(),
1090 message_type=OmciSet.message_id,
1091 omci_message=OmciSet(
1092 entity_class=
1093 ExtendedVlanTaggingOperationConfigurationData.class_id,
1094 entity_id=entity_id,
1095 attributes_mask=
1096 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1097 *data.keys()),
1098 data=data
1099 )
1100 )
1101 self.send_omci_message(frame)
1102
Girish Gowdru4e854c22018-09-26 02:51:57 -07001103 def send_set_extended_vlan_tagging_operation_vlan_configuration_data_double_tag(self,
1104 entity_id,
1105 filter_outer_vid,
1106 filter_inner_vid,
1107 treatment_tags_to_remove
1108 ):
1109 # Note: The default values below are meaningful if transparent handling is
1110 # needed for double vlan tagged packets with matching inner and outer vlans.
1111 # If any other handling is needed for double vlan tagged packets, the default
1112 # values may not work and the function needs to be adapted accordingly.
1113 data = dict(
1114 received_frame_vlan_tagging_operation_table=
1115 VlanTaggingOperation(
1116 filter_outer_priority=14,
1117 filter_outer_vid=filter_outer_vid,
1118 filter_outer_tpid_de=0,
1119 filter_inner_priority=14,
1120 filter_inner_vid=filter_inner_vid,
1121 filter_inner_tpid_de=0,
1122 filter_ether_type=0,
1123 treatment_tags_to_remove=treatment_tags_to_remove,
1124 treatment_outer_priority=15,
1125 treatment_outer_vid=0, # N/A
1126 treatment_outer_tpid_de=0, # N/A
1127 treatment_inner_priority=15,
1128 treatment_inner_vid=0, # N/A
1129 treatment_inner_tpid_de=0 # N/A
1130 )
1131 )
1132 frame = OmciFrame(
1133 transaction_id=self.get_tx_id(),
1134 message_type=OmciSet.message_id,
1135 omci_message=OmciSet(
1136 entity_class=
1137 ExtendedVlanTaggingOperationConfigurationData.class_id,
1138 entity_id=entity_id,
1139 attributes_mask=
1140 ExtendedVlanTaggingOperationConfigurationData.mask_for(
1141 *data.keys()),
1142 data=data
1143 )
1144 )
1145 self.send_omci_message(frame)
1146
1147 def send_delete_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self,
1148 entity_id):
1149 frame = OmciFrame(
1150 transaction_id=self.get_tx_id(),
1151 message_type=OmciDelete.message_id,
1152 omci_message=OmciDelete(
1153 entity_class=ExtendedVlanTaggingOperationConfigurationData.class_id,
1154 entity_id=entity_id
1155 )
1156 )
1157 self.send_omci_message(frame)
1158
Steve Crooks9e85ce82017-03-20 12:00:53 -04001159 def send_create_multicast_operations_profile(self,
1160 entity_id,
1161 igmp_ver):
1162 frame = OmciFrame(
1163 transaction_id=self.get_tx_id(),
1164 message_type=OmciCreate.message_id,
1165 omci_message=OmciCreate(
1166 entity_class=
1167 MulticastOperationsProfile.class_id,
1168 entity_id=entity_id,
1169 data=dict(
1170 igmp_version=igmp_ver,
1171 igmp_function=0,
1172 immediate_leave=0
1173 )
1174 )
1175 )
1176 self.send_omci_message(frame)
1177
1178 def send_set_multicast_operations_profile_acl_row0(self,
1179 entity_id,
1180 acl_table,
1181 row_key,
1182 gem_port,
1183 vlan,
1184 src_ip,
1185 dst_ip_start,
1186 dst_ip_end):
1187 row0 = AccessControlRow0(
1188 set_ctrl=1,
1189 row_part_id=0,
1190 test=0,
1191 row_key=row_key,
1192 gem_port_id=gem_port,
1193 vlan_id=vlan,
1194 src_ip=src_ip,
1195 dst_ip_start=dst_ip_start,
1196 dst_ip_end=dst_ip_end,
1197 ipm_group_bw=0
1198 )
1199
1200 if acl_table == 'dynamic':
1201 data = dict(
1202 dynamic_access_control_list_table=row0
1203 )
1204 else:
1205 data = dict(
1206 static_access_control_list_table=row0
1207 )
1208
1209 frame = OmciFrame(
1210 transaction_id=self.get_tx_id(),
1211 message_type=OmciSet.message_id,
1212 omci_message=OmciSet(
1213 entity_class=MulticastOperationsProfile.class_id,
1214 entity_id=entity_id,
1215 attributes_mask=MulticastOperationsProfile.mask_for(
1216 *data.keys()),
1217 data=data
1218 )
1219 )
1220 self.send_omci_message(frame)
1221
1222 def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self,
1223 entity_id,
1224 ctrl_type,
1225 tci):
1226 data = dict(
1227 ds_igmp_mcast_tci=
1228 DownstreamIgmpMulticastTci(
1229 ctrl_type=ctrl_type,
1230 tci=tci
1231 )
1232 )
1233 frame = OmciFrame(
1234 transaction_id=self.get_tx_id(),
1235 message_type=OmciSet.message_id,
1236 omci_message=OmciSet(
1237 entity_class=MulticastOperationsProfile.class_id,
1238 entity_id=entity_id,
1239 attributes_mask=MulticastOperationsProfile.mask_for(
1240 *data.keys()),
1241 data=data
1242 )
1243 )
1244 self.send_omci_message(frame)
1245
1246 def send_create_multicast_subscriber_config_info(self,
1247 entity_id,
1248 me_type,
1249 mcast_oper_profile):
1250 frame = OmciFrame(
1251 transaction_id=self.get_tx_id(),
1252 message_type=OmciCreate.message_id,
1253 omci_message=OmciCreate(
1254 entity_class=
1255 MulticastSubscriberConfigInfo.class_id,
1256 entity_id=entity_id,
1257 data=dict(
1258 me_type=me_type,
1259 mcast_operations_profile_pointer=mcast_oper_profile
1260 )
1261 )
1262 )
1263 self.send_omci_message(frame)
1264
1265 def send_set_multicast_subscriber_config_info(self,
1266 entity_id,
1267 max_groups=0,
1268 max_mcast_bw=0,
1269 bw_enforcement=0):
1270 data = dict(
1271 max_simultaneous_groups=max_groups,
1272 max_multicast_bandwidth=max_mcast_bw,
1273 bandwidth_enforcement=bw_enforcement
1274 )
1275 frame = OmciFrame(
1276 transaction_id=self.get_tx_id(),
1277 message_type=OmciSet.message_id,
1278 omci_message=OmciSet(
1279 entity_class=MulticastSubscriberConfigInfo.class_id,
1280 entity_id=entity_id,
1281 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1282 *data.keys()),
1283 data=data
1284 )
1285 )
1286 self.send_omci_message(frame)
1287
1288 def send_set_multicast_service_package(self,
1289 entity_id,
1290 row_key,
1291 vid_uni,
1292 max_groups,
1293 max_mcast_bw,
1294 mcast_oper_profile):
1295 data = dict(
1296 multicast_service_package_table=
1297 MulticastServicePackage(
1298 set_ctrl=1,
1299 row_key=row_key,
1300
1301 vid_uni=vid_uni,
1302 max_simultaneous_groups=max_groups,
1303 max_multicast_bw=max_mcast_bw,
1304 mcast_operations_profile_pointer=mcast_oper_profile
1305 )
1306 )
1307 frame = OmciFrame(
1308 transaction_id=self.get_tx_id(),
1309 message_type=OmciSet.message_id,
1310 omci_message=OmciSet(
1311 entity_class=MulticastSubscriberConfigInfo.class_id,
1312 entity_id=entity_id,
1313 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1314 *data.keys()),
1315 data=data
1316 )
1317 )
1318 self.send_omci_message(frame)
1319
1320 def send_set_multicast_allowed_preview_groups_row0(self,
1321 entity_id,
1322 row_key,
1323 src_ip,
1324 vlan_id_ani,
1325 vlan_id_uni):
1326 data = dict(
1327 allowed_preview_groups_table=
1328 AllowedPreviewGroupsRow0(
1329 set_ctrl=1,
1330 row_part_id=0,
1331 row_key=row_key,
1332
1333 src_ip=src_ip,
1334 vlan_id_ani=vlan_id_ani,
1335 vlan_id_uni=vlan_id_uni
1336 )
1337 )
1338 frame = OmciFrame(
1339 transaction_id=self.get_tx_id(),
1340 message_type=OmciSet.message_id,
1341 omci_message=OmciSet(
1342 entity_class=MulticastSubscriberConfigInfo.class_id,
1343 entity_id=entity_id,
1344 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1345 *data.keys()),
1346 data=data
1347 )
1348 )
1349 self.send_omci_message(frame)
1350
1351 def send_set_multicast_allowed_preview_groups_row1(self,
1352 entity_id,
1353 row_key,
1354 dst_ip,
1355 duration,
1356 time_left):
1357 data = dict(
1358 allowed_preview_groups_table=
1359 AllowedPreviewGroupsRow1(
1360 set_ctrl=1,
1361 row_part_id=1,
1362 row_key=row_key,
1363
1364 dst_ip=dst_ip,
1365 duration=duration,
1366 time_left=time_left
1367 )
1368 )
1369 frame = OmciFrame(
1370 transaction_id=self.get_tx_id(),
1371 message_type=OmciSet.message_id,
1372 omci_message=OmciSet(
1373 entity_class=MulticastSubscriberConfigInfo.class_id,
1374 entity_id=entity_id,
1375 attributes_mask=MulticastSubscriberConfigInfo.mask_for(
1376 *data.keys()),
1377 data=data
1378 )
1379 )
1380 self.send_omci_message(frame)
1381
Girish61687212018-01-08 12:48:58 +05301382 def send_reboot(self):
Girish Gowdru4e854c22018-09-26 02:51:57 -07001383 self.log.info('send omci reboot message')
Girish61687212018-01-08 12:48:58 +05301384 frame = OmciFrame(
1385 transaction_id=self.get_tx_id(),
1386 message_type=OmciReboot.message_id,
1387 omci_message=OmciReboot(
1388 entity_class=OntG.class_id,
1389 entity_id=0
1390 )
1391 )
1392 self.send_omci_message(frame)
1393
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001394 @inlineCallbacks
Steve Crooks3c2c7582017-01-10 15:02:26 -06001395 def wait_for_response(self):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001396 self.log.debug('wait-for-response')
Steve Crooks3c2c7582017-01-10 15:02:26 -06001397 try:
1398 response = yield self.incoming_messages.get()
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001399 self.log.debug('got-response')
Girish61687212018-01-08 12:48:58 +05301400 resp = OmciFrame(response)
1401 resp.show()
1402 returnValue(resp)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001403 except Exception as e:
Girish61687212018-01-08 12:48:58 +05301404 returnValue(None)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001405 self.log.info('wait-for-response-exception', exc=str(e))
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001406
Steve Crooks3c2c7582017-01-10 15:02:26 -06001407 @inlineCallbacks
Girish Gowdru4e854c22018-09-26 02:51:57 -07001408 def message_exchange(self):
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001409 # reset incoming message queue
1410 while self.incoming_messages.pending:
1411 _ = yield self.incoming_messages.get()
1412
Girish Gowdru4e854c22018-09-26 02:51:57 -07001413 mcvid = MANAGEMENT_VLAN
1414 cvid = BRDCM_DEFAULT_VLAN
Steve Crooks9b160d72017-03-31 10:48:29 -05001415
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001416 # construct message
Steve Crooks3c2c7582017-01-10 15:02:26 -06001417 # MIB Reset - OntData - 0
1418 self.send_mib_reset()
1419 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001420
Steve Crooks3c2c7582017-01-10 15:02:26 -06001421 # Create AR - GalEthernetProfile - 1
1422 self.send_create_gal_ethernet_profile(1, 48)
1423 yield self.wait_for_response()
Zsolt Haraszticc153aa2016-12-14 02:28:59 -08001424
Steve Crooks9b160d72017-03-31 10:48:29 -05001425 # MAC Bridge Service config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001426 # Create AR - MacBridgeServiceProfile - 513
1427 self.send_create_mac_bridge_service_profile(0x201)
1428 yield self.wait_for_response()
1429
rshettyf4bf19e2017-09-19 01:28:27 +05301430 # Mapper Service config
1431 # Create AR - 802.1pMapperServiceProfile - 32769
1432 self.send_create_8021p_mapper_service_profile(0x8001)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001433 yield self.wait_for_response()
1434
Steve Crooks9b160d72017-03-31 10:48:29 -05001435 # MAC Bridge Port config
Steve Crooks3c2c7582017-01-10 15:02:26 -06001436 # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769
1437 self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001)
1438 yield self.wait_for_response()
1439
Steve Crooks9b160d72017-03-31 10:48:29 -05001440 # VLAN Tagging Filter config
1441 # Create AR - VlanTaggingFilterData - 8450 - c-vid
ggowdru42662622018-04-16 10:03:31 +05301442 # As per G.988 - Table 9.3.11-1 - Forward operation attribute values
1443 self.send_create_vlan_tagging_filter_data(0x2102, cvid, 0x10)
Steve Crooks3c2c7582017-01-10 15:02:26 -06001444 yield self.wait_for_response()
1445
rshettyf4bf19e2017-09-19 01:28:27 +05301446
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -05001447 for port_id in self.uni_ports:
1448 # Extended VLAN Tagging Operation config
1449 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102(Uni-Port-Num)
1450 self.send_create_extended_vlan_tagging_operation_configuration_data(0x200 + port_id, 2, 0x100 + port_id)
1451 yield self.wait_for_response()
1452
1453 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
1454 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x200 + port_id, 0x8100, 0x8100)
1455 yield self.wait_for_response()
1456
1457
1458
1459 # Create AR - MacBridgePortConfigData - Entity_id -
1460 # bridge ID -
1461 # port num -
1462 # tp_type -
1463 # IEEE MApper poniter
1464 self.send_create_mac_bridge_port_configuration_data(0x200 + port_id, 0x201, port_id, 1, 0x100 + port_id)
1465 yield self.wait_for_response()
1466
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -05001467 # Set AR - ExtendedVlanTaggingOperationConfigData
Girish Gowdrud75ef392018-10-02 10:33:50 -07001468 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1469 # To be removed once DPU supports sending vlan4090p3 instead of vlan4090p0
1470 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x200 + port_id, 0, mcvid, 0, 1, 7, mcvid)
1471 yield self.wait_for_response()
1472
1473
1474 # Set AR - ExtendedVlanTaggingOperationConfigData
1475 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
1476 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x200 + port_id, 3, mcvid, 0, 1, 7, mcvid)
1477 yield self.wait_for_response()
1478
1479 # Set AR - ExtendedVlanTaggingOperationConfigData
Nicolas Palpacueraf5a9152018-02-14 16:55:11 -05001480 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid
1481 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x200 + port_id, 0x1000, cvid)
1482 yield self.wait_for_response()
rshettyf4bf19e2017-09-19 01:28:27 +05301483
1484 # Multicast related MEs
1485 # Set AR - MulticastOperationsProfile - Dynamic Access Control List table
1486 # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6
1487 self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6)
1488 yield self.wait_for_response()
1489
Steve Crooks9b160d72017-03-31 10:48:29 -05001490 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001491 # Create AR - MulticastOperationsProfile
1492 self.send_create_multicast_operations_profile(0x201, 3)
1493 yield self.wait_for_response()
1494
rshettyf4bf19e2017-09-19 01:28:27 +05301495 # Multicast Subscriber config
1496 # Create AR - MulticastSubscriberConfigInfo
1497 self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201)
1498 yield self.wait_for_response()
1499
1500 # Create AR - GemPortNetworkCtp - 260 - 4000 - 0 Multicast
1501 self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0)
1502 yield self.wait_for_response()
1503
1504 # Multicast GEM Interworking config Multicast
1505 # Create AR - MulticastGemInterworkingTp - 6 - 260
1506 self.send_create_multicast_gem_interworking_tp(0x6, 0x104)
1507 yield self.wait_for_response()
1508
Steve Crooks9e85ce82017-03-20 12:00:53 -04001509 self.send_set_multicast_operations_profile_acl_row0(0x201,
1510 'dynamic',
1511 0,
1512 0x0fa0,
1513 0x0fa0,
1514 '0.0.0.0',
1515 '224.0.0.0',
1516 '239.255.255.255')
1517 yield self.wait_for_response()
1518
Steve Crooks9b160d72017-03-31 10:48:29 -05001519 # Multicast Operation Profile config
Steve Crooks9e85ce82017-03-20 12:00:53 -04001520 # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI
Steve Crooks9b160d72017-03-31 10:48:29 -05001521 self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid)
Steve Crooks9e85ce82017-03-20 12:00:53 -04001522 yield self.wait_for_response()
1523
rshettyf4bf19e2017-09-19 01:28:27 +05301524 def add_uni_port(self, device, parent_logical_device_id,
1525 name, parent_port_num=None):
1526 self.log.info('adding-logical-port', device_id=device.id,
1527 logical_device_id=parent_logical_device_id,
1528 name=name)
1529 if parent_port_num is not None:
1530 uni = parent_port_num
1531 port_no = parent_port_num
1532 else:
1533 uni = self.uni_ports[0]
Shad Ansari8de32212018-07-27 05:52:21 +00001534 port_no = device.proxy_address.channel_id + uni
rshettyf4bf19e2017-09-19 01:28:27 +05301535 # register physical ports
1536 uni_port = Port(
1537 port_no=uni,
Shad Ansari2825d012018-02-22 23:57:46 +00001538 label='uni-'+str(uni),
rshettyf4bf19e2017-09-19 01:28:27 +05301539 type=Port.ETHERNET_UNI,
1540 admin_state=AdminState.ENABLED,
1541 oper_status=OperStatus.ACTIVE
1542 )
1543 self.adapter_agent.add_port(device.id, uni_port)
1544 # add uni port to logical device
1545 cap = OFPPF_1GB_FD | OFPPF_FIBER
1546 self.adapter_agent.add_logical_port(parent_logical_device_id,
1547 LogicalPort(
1548 id='uni-{}'.format(port_no),
1549 ofp_port=ofp_port(
1550 port_no=port_no,
1551 hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' %
1552 (device.proxy_address.onu_id & 0xff,
1553 (port_no >> 8) & 0xff,
1554 port_no & 0xff)),
1555 #name='uni-{}'.format(port_no),
1556 name=name,
1557 config=0,
1558 state=OFPPS_LIVE,
1559 curr=cap,
1560 advertised=cap,
1561 peer=cap,
1562 curr_speed=OFPPF_1GB_FD,
1563 max_speed=OFPPF_1GB_FD
1564 ),
1565 device_id=device.id,
1566 device_port_no=uni_port.port_no
1567 ))
rshettyc26a3c32017-07-27 11:06:38 +05301568
Girishd5823672017-11-23 12:15:14 +05301569 def del_uni_port(self, device, parent_logical_device_id,
1570 name, parent_port_num=None):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001571 self.log.debug('del-uni-port', device_id=device.id,
Girishd5823672017-11-23 12:15:14 +05301572 logical_device_id=parent_logical_device_id,
1573 name=name)
1574 if parent_port_num is not None:
1575 uni = parent_port_num
1576 port_no = parent_port_num
1577 else:
1578 uni = self.uni_ports[0]
1579 port_no = device.proxy_address.channel_id + uni
1580 # register physical ports
1581 ports = self.adapter_agent.get_ports(self.device_id, Port.ETHERNET_UNI)
1582 for port in ports:
Shad Ansari2825d012018-02-22 23:57:46 +00001583 if port.label == 'uni-'+str(uni):
Girishd5823672017-11-23 12:15:14 +05301584 break
1585 self.adapter_agent.delete_port(self.device_id, port)
1586 self.adapter_agent.delete_logical_port_by_id(parent_logical_device_id,
1587 'uni-{}'.format(port_no))
1588
Girish61687212018-01-08 12:48:58 +05301589 def delete_v_ont_ani(self, data):
1590 self.log.info('deleting-v_ont_ani')
1591
1592 device = self.adapter_agent.get_device(self.device_id)
Girish61687212018-01-08 12:48:58 +05301593 self.proxy_address = device.proxy_address
1594 self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
1595
1596 ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1597 if ports is not None:
1598 for port in ports:
1599 if port.label == 'PON port':
1600 self.adapter_agent.delete_port(self.device_id, port)
1601 break
1602
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001603 # construct message
1604 # MIB Reset - OntData - 0
1605 if device.connect_status != ConnectStatus.REACHABLE:
1606 self.log.error('device-unreachable')
1607 return
1608
1609 self.send_mib_reset()
1610
1611 # It is observed that the device is already deleted before the response
1612 # is received. So, there is no point waiting for response.
1613 # Also, currently there is no response validation or timeout.
1614 # Until we move to the OpenOMCI framework, it is ok to ignore this
1615 # response for now.
1616
1617 # yield self.wait_for_response()
1618
rshettyc26a3c32017-07-27 11:06:38 +05301619 def create_interface(self, data):
rshetty1cc73982017-09-02 03:31:12 +05301620 if isinstance(data, VEnetConfig):
1621 parent_port_num = None
1622 onu_device = self.adapter_agent.get_device(self.device_id)
1623 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1624 parent_port_num = None
1625 for port in ports:
1626 if port.label == data.interface.name:
1627 parent_port_num = port.port_no
1628 break
1629
rshettyf4bf19e2017-09-19 01:28:27 +05301630 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1631 logical_device_id = parent_device.parent_id
1632 assert logical_device_id
Girish61687212018-01-08 12:48:58 +05301633 self.add_uni_port(onu_device, logical_device_id,
rshettyf4bf19e2017-09-19 01:28:27 +05301634 data.name, parent_port_num)
1635
1636 if parent_port_num is None:
rshetty1cc73982017-09-02 03:31:12 +05301637 self.log.error("matching-parent-uni-port-num-not-found")
1638 return
1639
1640 onu_ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU)
1641 if onu_ports:
1642 # To-Do :
1643 # Assumed only one PON port and UNI port per ONU.
1644 pon_port = onu_ports[0]
1645 else:
1646 self.log.error("No-Pon-port-configured-yet")
1647 return
1648
1649 self.adapter_agent.delete_port_reference_from_parent(self.device_id,
1650 pon_port)
1651
1652 pon_port.peers[0].device_id = onu_device.parent_id
1653 pon_port.peers[0].port_no = parent_port_num
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001654 pon_port.admin_state = AdminState.ENABLED
1655 pon_port.oper_status = OperStatus.ACTIVE
rshetty1cc73982017-09-02 03:31:12 +05301656 self.adapter_agent.add_port_reference_to_parent(self.device_id,
1657 pon_port)
1658 else:
Girish61687212018-01-08 12:48:58 +05301659 self.log.info('Not-handled-Yet')
rshetty1cc73982017-09-02 03:31:12 +05301660 return
rshettyc26a3c32017-07-27 11:06:38 +05301661
1662 def update_interface(self, data):
Girish61687212018-01-08 12:48:58 +05301663 self.log.info('Not-Implemented-yet')
rshetty1cc73982017-09-02 03:31:12 +05301664 return
rshettyc26a3c32017-07-27 11:06:38 +05301665
1666 def remove_interface(self, data):
Girishd5823672017-11-23 12:15:14 +05301667 if isinstance(data, VEnetConfig):
Girish Gowdru4e854c22018-09-26 02:51:57 -07001668 parent_port_num = None
Girishd5823672017-11-23 12:15:14 +05301669 onu_device = self.adapter_agent.get_device(self.device_id)
1670 ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI)
1671 parent_port_num = None
1672 for port in ports:
1673 if port.label == data.interface.name:
1674 parent_port_num = port.port_no
1675 break
1676
1677 parent_device = self.adapter_agent.get_device(onu_device.parent_id)
1678 logical_device_id = parent_device.parent_id
1679 assert logical_device_id
1680 self.del_uni_port(onu_device, logical_device_id,
1681 data.name, parent_port_num)
Girish61687212018-01-08 12:48:58 +05301682 if isinstance(data, VOntaniConfig):
1683 self.delete_v_ont_ani(data)
Girishd5823672017-11-23 12:15:14 +05301684 else:
Girish61687212018-01-08 12:48:58 +05301685 self.log.info('not-handled-yet')
rshetty1cc73982017-09-02 03:31:12 +05301686 return
rshettyf4bf19e2017-09-19 01:28:27 +05301687
1688 @inlineCallbacks
1689 def create_gemport(self, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001690 self.log.debug('create-gemport')
Girish61687212018-01-08 12:48:58 +05301691 gem_port = GemportsConfigData()
1692 gem_port.CopyFrom(data)
rshettyf4bf19e2017-09-19 01:28:27 +05301693 if gem_port.tcont_ref is None:
Girish61687212018-01-08 12:48:58 +05301694 self.log.error('recevied-null-gem-port-data')
rshettyf4bf19e2017-09-19 01:28:27 +05301695 else:
1696 #To-Do Need to see how the valuse 0x8001 is derived
1697 self.send_create_gem_port_network_ctp(gem_port.gemport_id,
1698 gem_port.gemport_id, 0x8001,
1699 "bi-directional", 0x100)
1700 yield self.wait_for_response()
1701
1702 # GEM Interworking config
1703 # Create AR - GemInterworkingTp - Gem_port,TP_pointer -
1704 # Gem port CTP pointer -
1705 # Mapper service profile id
1706 self.send_create_gem_inteworking_tp(gem_port.gemport_id,
1707 gem_port.gemport_id, 0x8001)
1708 yield self.wait_for_response()
1709
1710 # Mapper Service Profile config
1711 # Set AR - 802.1pMapperServiceProfile - Mapper_ profile_id -
1712 # gem_port_tp pointer
Girish Gowdru4e854c22018-09-26 02:51:57 -07001713
Girish Gowdrud75ef392018-10-02 10:33:50 -07001714 if gem_port.traffic_class == 2:
1715 self.send_set_8021p_mapper_service_profile(0x8001,
1716 interwork_tp_id_7=gem_port.gemport_id)
1717 else:
1718 self.send_set_8021p_mapper_service_profile(0x8001,
1719 interwork_tp_id_0_6=gem_port.gemport_id)
Girish Gowdru4e854c22018-09-26 02:51:57 -07001720
rshettyf4bf19e2017-09-19 01:28:27 +05301721 yield self.wait_for_response()
1722
1723
1724 @inlineCallbacks
Girishd5823672017-11-23 12:15:14 +05301725 def remove_gemport(self, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001726 self.log.debug('remove-gemport')
Girish61687212018-01-08 12:48:58 +05301727 gem_port = GemportsConfigData()
Girishd5823672017-11-23 12:15:14 +05301728 gem_port.CopyFrom(data)
Girish61687212018-01-08 12:48:58 +05301729 device = self.adapter_agent.get_device(self.device_id)
1730 if device.connect_status != ConnectStatus.REACHABLE:
1731 self.log.error('device-unreachable')
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001732 return
Girishd5823672017-11-23 12:15:14 +05301733
Girish Gowdrud75ef392018-10-02 10:33:50 -07001734 self.send_set_8021p_mapper_service_profile(0x8001,
1735 interwork_tp_id_0_6=0xFFFF,
1736 interwork_tp_id_7=0xFFFF)
Girishd5823672017-11-23 12:15:14 +05301737 yield self.wait_for_response()
1738
1739 self.send_delete_omci_mesage(GemInterworkingTp.class_id,
Girish61687212018-01-08 12:48:58 +05301740 gem_port.gemport_id)
Girishd5823672017-11-23 12:15:14 +05301741 yield self.wait_for_response()
1742
1743 #To-Do Need to see how the valuse 0x8001 is derived
1744 self.send_delete_omci_mesage(GemPortNetworkCtp.class_id,
Girish61687212018-01-08 12:48:58 +05301745 gem_port.gemport_id)
Girishd5823672017-11-23 12:15:14 +05301746 yield self.wait_for_response()
1747
1748 @inlineCallbacks
rshettyf4bf19e2017-09-19 01:28:27 +05301749 def create_tcont(self, tcont_data, traffic_descriptor_data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001750 self.log.debug('create-tcont')
Girish61687212018-01-08 12:48:58 +05301751 tcont = TcontsConfigData()
rshettyf4bf19e2017-09-19 01:28:27 +05301752 tcont.CopyFrom(tcont_data)
Girish61687212018-01-08 12:48:58 +05301753 if tcont.interface_reference is not None:
1754 self.log.debug('tcont', tcont=tcont.alloc_id)
1755 self.send_set_tcont(0x8001, tcont.alloc_id)
1756 yield self.wait_for_response()
1757 else:
1758 self.log.info('recevied-null-tcont-data', tcont=tcont.alloc_id)
rshettyf4bf19e2017-09-19 01:28:27 +05301759
Girishd5823672017-11-23 12:15:14 +05301760 @inlineCallbacks
1761 def remove_tcont(self, tcont_data, traffic_descriptor_data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001762 self.log.debug('remove-tcont')
Girish61687212018-01-08 12:48:58 +05301763 device = self.adapter_agent.get_device(self.device_id)
1764 if device.connect_status != ConnectStatus.REACHABLE:
1765 self.log.error('device-unreachable')
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001766 return
Girish61687212018-01-08 12:48:58 +05301767
Girishd5823672017-11-23 12:15:14 +05301768 self.send_set_tcont(0x8001, 0xFFFF)
1769 yield self.wait_for_response()
1770
rshettyf4bf19e2017-09-19 01:28:27 +05301771 def create_multicast_gemport(self, data):
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001772 self.log.info('Send relevant OMCI message - Not implemented yet')
sathishgff102eb2017-12-21 12:19:19 +05301773
1774 @inlineCallbacks
1775 def disable(self, device):
1776 try:
1777 self.log.info('sending-admin-state-lock-towards-device', device=device)
1778 self.send_set_admin_state(0x0000, ADMIN_STATE_LOCK)
1779 yield self.wait_for_response()
sathishgff102eb2017-12-21 12:19:19 +05301780 # Disable all ports on that device
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001781 self.disable_ports(device)
sathishgff102eb2017-12-21 12:19:19 +05301782 device.oper_status = OperStatus.UNKNOWN
Girish Gowdru4e854c22018-09-26 02:51:57 -07001783 device.connect_status = ConnectStatus.UNREACHABLE
sathishgff102eb2017-12-21 12:19:19 +05301784 self.adapter_agent.update_device(device)
1785 except Exception as e:
1786 log.exception('exception-in-onu-disable', exception=e)
1787
1788 @inlineCallbacks
1789 def reenable(self, device):
1790 try:
1791 self.log.info('sending-admin-state-unlock-towards-device', device=device)
1792 self.send_set_admin_state(0x0000, ADMIN_STATE_UNLOCK)
1793 yield self.wait_for_response()
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001794 self.enable_ports(device)
sathishgff102eb2017-12-21 12:19:19 +05301795 device.oper_status = OperStatus.ACTIVE
1796 device.connect_status = ConnectStatus.REACHABLE
1797 self.adapter_agent.update_device(device)
1798 except Exception as e:
1799 log.exception('exception-in-onu-reenable', exception=e)
1800
Girish61687212018-01-08 12:48:58 +05301801 @inlineCallbacks
1802 def reboot(self):
1803 self.log.info('reboot-device')
1804 device = self.adapter_agent.get_device(self.device_id)
1805 if device.connect_status != ConnectStatus.REACHABLE:
1806 self.log.error("device-unreacable")
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001807 return
Girish61687212018-01-08 12:48:58 +05301808
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001809 try:
1810 self.send_reboot()
1811 response = yield self.wait_for_response()
1812 if response is not None:
1813 omci_response = response.getfieldval("omci_message")
1814 success_code = omci_response.getfieldval("success_code")
1815 if success_code == 0:
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001816 self.log.debug("reboot-command-processed-successfully")
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001817 # Update the device connection and operation status
1818 device = self.adapter_agent.get_device(self.device_id)
1819 device.connect_status = ConnectStatus.UNREACHABLE
1820 device.oper_status = OperStatus.DISCOVERED
1821 self.adapter_agent.update_device(device)
1822 self.disable_ports(device)
Girish Gowdru4e854c22018-09-26 02:51:57 -07001823 self.flow_map.clear()
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001824 else:
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001825 self.log.error("reboot-failed", success_code=success_code)
Girish61687212018-01-08 12:48:58 +05301826 else:
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001827 self.log.error("error-in-processing-reboot-response")
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001828 except Exception as e:
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -04001829 self.log.error('wait-for-response-exception', exc=str(e))
Girish61687212018-01-08 12:48:58 +05301830
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001831 def disable_ports(self, device):
Girish61687212018-01-08 12:48:58 +05301832 self.log.info('disable-ports', device_id=self.device_id)
1833
1834 # Disable all ports on that device
1835 self.adapter_agent.disable_all_ports(self.device_id)
1836
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001837 parent_device = self.adapter_agent.get_device(device.parent_id)
Girish61687212018-01-08 12:48:58 +05301838 assert parent_device
1839 logical_device_id = parent_device.parent_id
1840 assert logical_device_id
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001841 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
Girish61687212018-01-08 12:48:58 +05301842 for port in ports:
1843 port_id = 'uni-{}'.format(port.port_no)
Girish Gowdru4e854c22018-09-26 02:51:57 -07001844 try:
1845 lgcl_port = self.adapter_agent.get_logical_port(logical_device_id, port_id)
1846 lgcl_port.ofp_port.state = OFPPS_LINK_DOWN
1847 self.adapter_agent.update_logical_port(logical_device_id, lgcl_port)
1848 except KeyError:
1849 self.log.info('logical-port-not-found', device_id=self.device_id,
1850 portid=port_id)
ggowdru64d738a2018-05-10 07:08:06 -07001851
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001852 def enable_ports(self, device):
ggowdru64d738a2018-05-10 07:08:06 -07001853 self.log.info('enable-ports', device_id=self.device_id)
1854
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001855 # Enable all ports on that device
ggowdru64d738a2018-05-10 07:08:06 -07001856 self.adapter_agent.enable_all_ports(self.device_id)
1857
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001858 parent_device = self.adapter_agent.get_device(device.parent_id)
ggowdru64d738a2018-05-10 07:08:06 -07001859 assert parent_device
1860 logical_device_id = parent_device.parent_id
1861 assert logical_device_id
Girish Gowdru1f2f5d32018-06-14 00:38:33 -07001862 ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)
ggowdru64d738a2018-05-10 07:08:06 -07001863 for port in ports:
1864 port_id = 'uni-{}'.format(port.port_no)
Girish Gowdru4e854c22018-09-26 02:51:57 -07001865 try:
1866 lgcl_port = self.adapter_agent.get_logical_port(logical_device_id, port_id)
1867 lgcl_port.ofp_port.state = OFPPS_LIVE
1868 self.adapter_agent.update_logical_port(logical_device_id, lgcl_port)
1869 except KeyError:
1870 self.log.info('logical-port-not-found', device_id=self.device_id,
1871 portid=port_id)
1872
1873 @inlineCallbacks
1874 def _add_onu_flow(self, flow):
1875 _type = None
1876 _port = None
1877 _vlan_vid = None
1878 _udp_dst = None
1879 _udp_src = None
1880 _ipv4_dst = None
1881 _ipv4_src = None
1882 _metadata = None
1883 _output = None
1884 _push_tpid = None
1885 _field = None
1886 _set_vlan_vid = None
1887 self.log.info('add-flow', flow=flow)
1888
1889 def is_downstream(port):
1890 return port == 100 # Need a better way
1891
1892 def is_upstream(port):
1893 return not is_downstream(port)
1894
1895 try:
1896 _in_port = fd.get_in_port(flow)
1897 assert _in_port is not None
1898
1899 if is_downstream(_in_port):
1900 self.log.info('downstream-flow')
1901 elif is_upstream(_in_port):
1902 self.log.info('upstream-flow')
1903 else:
1904 raise Exception('port should be 1 or 2 by our convention')
1905
1906 _out_port = fd.get_out_port(flow) # may be None
1907 self.log.info('out-port', out_port=_out_port)
1908
1909 for field in fd.get_ofb_fields(flow):
1910 if field.type == fd.ETH_TYPE:
1911 _type = field.eth_type
1912 self.log.info('field-type-eth-type',
1913 eth_type=_type)
1914
1915 elif field.type == fd.IP_PROTO:
1916 _proto = field.ip_proto
1917 self.log.info('field-type-ip-proto',
1918 ip_proto=_proto)
1919
1920 elif field.type == fd.IN_PORT:
1921 _port = field.port
1922 self.log.info('field-type-in-port',
1923 in_port=_port)
1924
1925 elif field.type == fd.VLAN_VID:
1926 _vlan_vid = field.vlan_vid & 0xfff
1927 self.log.info('field-type-vlan-vid',
1928 vlan=_vlan_vid)
1929
1930 elif field.type == fd.VLAN_PCP:
1931 _vlan_pcp = field.vlan_pcp
1932 self.log.info('field-type-vlan-pcp',
1933 pcp=_vlan_pcp)
1934
1935 elif field.type == fd.UDP_DST:
1936 _udp_dst = field.udp_dst
1937 self.log.info('field-type-udp-dst',
1938 udp_dst=_udp_dst)
1939
1940 elif field.type == fd.UDP_SRC:
1941 _udp_src = field.udp_src
1942 self.log.info('field-type-udp-src',
1943 udp_src=_udp_src)
1944
1945 elif field.type == fd.IPV4_DST:
1946 _ipv4_dst = field.ipv4_dst
1947 self.log.info('field-type-ipv4-dst',
1948 ipv4_dst=_ipv4_dst)
1949
1950 elif field.type == fd.IPV4_SRC:
1951 _ipv4_src = field.ipv4_src
1952 self.log.info('field-type-ipv4-src',
1953 ipv4_dst=_ipv4_src)
1954
1955 elif field.type == fd.METADATA:
1956 _metadata = field.table_metadata
1957 self.log.info('field-type-metadata',
1958 metadata=_metadata)
1959
1960 else:
1961 raise NotImplementedError('field.type={}'.format(
1962 field.type))
1963
1964 for action in fd.get_actions(flow):
1965
1966 if action.type == fd.OUTPUT:
1967 _output = action.output.port
1968 self.log.info('action-type-output',
1969 output=_output, in_port=_in_port)
1970
1971 elif action.type == fd.POP_VLAN:
1972 self.log.info('action-type-pop-vlan',
1973 in_port=_in_port)
1974
1975 elif action.type == fd.PUSH_VLAN:
1976 _push_tpid = action.push.ethertype
1977 self.log.info('action-type-push-vlan',
1978 push_tpid=_push_tpid, in_port=_in_port)
1979 if action.push.ethertype != 0x8100:
1980 self.log.error('unhandled-tpid',
1981 ethertype=action.push.ethertype)
1982
1983 elif action.type == fd.SET_FIELD:
1984 _field = action.set_field.field.ofb_field
1985 assert (action.set_field.field.oxm_class ==
1986 OFPXMC_OPENFLOW_BASIC)
1987 self.log.info('action-type-set-field',
1988 field=_field, in_port=_in_port)
1989 if _field.type == fd.VLAN_VID:
1990 _set_vlan_vid = _field.vlan_vid & 0xfff
1991 self.log.info('set-field-type-vlan-vid',vlan=_set_vlan_vid)
1992 else:
1993 self.log.error('unsupported-action-set-field-type',
1994 field_type=_field.type)
1995 else:
1996 self.log.error('unsupported-action-type',
1997 action_type=action.type, in_port=_in_port)
1998
1999 #
2000 # All flows created from ONU adapter should be OMCI based
2001 #
2002 if _vlan_vid == 0 and _set_vlan_vid != None and _set_vlan_vid != 0:
2003 # allow priority tagged packets
2004 # Set AR - ExtendedVlanTaggingOperationConfigData
2005 # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid
2006
2007
2008 if _set_vlan_vid != RESERVED_VLAN_ID:
2009 # As per G.988 - Table 9.3.11-1 - Forward operation attribute values
2010 # Forward action of 0x10 allows VID Investigation
2011 if _type != FLOW_TYPE_EAPOL:
2012 self.log.info("Triggering-extended-vlan-configurations",vlan=_set_vlan_vid,eth_type=_type)
2013 self.send_set_vlan_tagging_filter_data(0x2102, _set_vlan_vid)
2014 #self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid, 0x10)
2015 yield self.wait_for_response()
2016
2017 for port_id in self.uni_ports:
2018
2019 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x200 + port_id, 0x1000, _set_vlan_vid)
2020 yield self.wait_for_response()
2021
2022 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x200 + port_id, 8, 0, 0, 1, 8, _set_vlan_vid)
2023 yield self.wait_for_response()
2024 else:
2025 self.log.info("Use-vlan-4091-for-eapol",eth_type=_type)
2026
2027 else:
2028 # As per G.988 - Table 9.3.11-1 - Forward operation attribute values
2029 # Forward action of 0x00 does not perform VID Investigation for transparent vlan case
2030 self.send_delete_vlan_tagging_filter_data(0x2102)
2031 yield self.wait_for_response()
2032
2033 self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid, 0x00)
2034 yield self.wait_for_response()
2035
2036 for port_id in self.uni_ports:
2037 self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x200 + port_id, 14, 4096, 0, 0, 15, 0)
2038 yield self.wait_for_response()
2039 #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_double_tag( \
2040 # 0x200 + port_id, 4096, 4096, 0)
2041 #yield self.wait_for_response()
2042
2043 # Create the entry in the internal flow table
2044 self.flow_map[flow.cookie] = {"vlan_id": _set_vlan_vid,
2045 "eth_type":_type,
2046 "vlan_tagging_filter_data_entity_id": 0x2102,
2047 "extended_vlan_tagging_filter_data": [0x200 + port_id for port_id in self.uni_ports]}
2048 except Exception as e:
2049 self.log.exception('failed-to-install-flow', e=e, flow=flow)
2050
2051 @inlineCallbacks
2052 def _delete_onu_flow(self, flow_map_value):
2053 # Deletes ONU flows.
2054 try:
2055 if flow_map_value["vlan_id"] != RESERVED_VLAN_ID:
2056 for extended_vlan_tagging_filter_data in flow_map_value["extended_vlan_tagging_filter_data"]:
2057 if flow_map_value["eth_type"] != FLOW_TYPE_EAPOL:
2058 self.send_delete_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(
2059 extended_vlan_tagging_filter_data)
2060 yield self.wait_for_response()
2061
2062 self.send_delete_extended_vlan_tagging_operation_vlan_configuration_data_untagged(
2063 extended_vlan_tagging_filter_data)
2064 yield self.wait_for_response()
2065
2066 else:
2067 for extended_vlan_tagging_filter_data in flow_map_value["extended_vlan_tagging_filter_data"]:
2068 self.send_delete_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(
2069 extended_vlan_tagging_filter_data)
2070 yield self.wait_for_response()
2071
2072 for port_id in self.uni_ports:
2073 # Extended VLAN Tagging Operation config
2074 # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102(Uni-Port-Num)
2075 self.send_create_extended_vlan_tagging_operation_configuration_data(0x200 + port_id, 2, 0x100 + port_id)
2076 yield self.wait_for_response()
2077
2078 # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100
2079 self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x200 + port_id, 0x8100, 0x8100)
2080 yield self.wait_for_response()
2081
2082 except Exception as e:
2083 self.log.exception('failed-to-delete-flow', e=e, flow_map_value=flow_map_value)
2084
2085 @inlineCallbacks
2086 def _wait_for_previous_update_flow_to_finish(self):
2087 while self.flow_config_in_progress:
2088 # non-blocking wait for 200ms
2089 yield asleep(0.2)
2090 return