Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 3 | # |
| 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 18 | Broadcom OLT/ONU adapter. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 19 | """ |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 20 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 21 | from uuid import uuid4 |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 22 | import structlog |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 23 | from twisted.internet import reactor, task |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 24 | from twisted.internet.defer import DeferredQueue, inlineCallbacks |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 25 | from zope.interface import implementer |
| 26 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 27 | from voltha.adapters.interface import IAdapterInterface |
| 28 | from voltha.core.logical_device_agent import mac_str_to_tuple |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 29 | import voltha.core.flow_decomposer as fd |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 30 | from voltha.protos import third_party |
| 31 | from voltha.protos.adapter_pb2 import Adapter |
| 32 | from voltha.protos.adapter_pb2 import AdapterConfig |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 33 | from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \ |
| 34 | AdminState |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 35 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 36 | from voltha.protos.health_pb2 import HealthStatus |
| 37 | from voltha.protos.logical_device_pb2 import LogicalPort |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 38 | from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD, OFPPS_LINK_DOWN |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 39 | from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 40 | from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 41 | from voltha.protos.bbf_fiber_traffic_descriptor_profile_body_pb2 import \ |
| 42 | TrafficDescriptorProfileData |
| 43 | from voltha.protos.bbf_fiber_tcont_body_pb2 import TcontsConfigData |
| 44 | from voltha.protos.bbf_fiber_gemport_body_pb2 import GemportsConfigData |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 45 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 46 | from common.frameio.frameio import hexify |
| 47 | from voltha.extensions.omci.omci import * |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 48 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 49 | _ = third_party |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 50 | log = structlog.get_logger() |
| 51 | |
| 52 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 53 | BRDCM_DEFAULT_VLAN = 4091 |
sathishg | 5e21cd9 | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 54 | ADMIN_STATE_LOCK = 1 |
| 55 | ADMIN_STATE_UNLOCK = 0 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 56 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 57 | @implementer(IAdapterInterface) |
| 58 | class BroadcomOnuAdapter(object): |
| 59 | |
| 60 | name = 'broadcom_onu' |
| 61 | |
| 62 | supported_device_types = [ |
| 63 | DeviceType( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 64 | id=name, |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 65 | vendor_id='BRCM', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 66 | 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', |
sathishg | f4880c7 | 2018-01-10 10:48:45 +0530 | [diff] [blame^] | 77 | version='0.43', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 78 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 79 | ) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 80 | self.devices_handlers = dict() # device_id -> BroadcomOnuHandler() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 81 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 82 | # register for adapter messages |
| 83 | self.adapter_agent.register_for_inter_adapter_messages() |
| 84 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 85 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 106 | log.info('adopt_device', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 107 | self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id) |
| 108 | reactor.callLater(0, self.devices_handlers[device.id].activate, device) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 109 | return device |
| 110 | |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 111 | def reconcile_device(self, device): |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 112 | 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) |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 115 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 116 | def abandon_device(self, device): |
| 117 | raise NotImplementedError() |
| 118 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 119 | def disable_device(self, device): |
sathishg | 5e21cd9 | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 120 | 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 Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 125 | |
| 126 | def reenable_device(self, device): |
sathishg | 5e21cd9 | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 127 | 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 Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 132 | |
| 133 | def reboot_device(self, device): |
| 134 | raise NotImplementedError() |
| 135 | |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 136 | 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 | |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 151 | 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 Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 160 | def delete_device(self, device): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 161 | 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 Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 168 | |
| 169 | def get_device_details(self, device): |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 170 | raise NotImplementedError() |
| 171 | |
Sergio Slobodrian | ec864c6 | 2017-03-09 11:41:43 -0500 | [diff] [blame] | 172 | def update_pm_config(self, device, pm_configs): |
| 173 | raise NotImplementedError() |
| 174 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 175 | def update_flows_bulk(self, device, flows, groups): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 176 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 177 | log.info('bulk-flow-update', device_id=device.id, |
| 178 | flows=flows, groups=groups) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 179 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 180 | assert len(groups.items) == 0 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 181 | handler = self.devices_handlers[device.id] |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 182 | return handler.update_flow_table(device, flows.items) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 183 | |
| 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)) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 193 | # 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 200 | |
| 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 Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 205 | def receive_inter_adapter_message(self, msg): |
| 206 | log.info('receive_inter_adapter_message', msg=msg) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 207 | proxy_address = msg['proxy_address'] |
| 208 | assert proxy_address is not None |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 209 | # 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 Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 216 | |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 217 | def create_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 218 | log.info('create-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 219 | if device.id in self.devices_handlers: |
| 220 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 221 | if handler is not None: |
| 222 | handler.create_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 223 | |
| 224 | def update_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 225 | log.info('update-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 226 | if device.id in self.devices_handlers: |
| 227 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 228 | if handler is not None: |
| 229 | handler.update_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 230 | |
| 231 | def remove_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 232 | log.info('remove-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 233 | if device.id in self.devices_handlers: |
| 234 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 235 | if handler is not None: |
| 236 | handler.remove_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 237 | |
| 238 | def receive_onu_detect_state(self, device_id, state): |
| 239 | raise NotImplementedError() |
| 240 | |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 241 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 242 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 247 | |
| 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): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 252 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 257 | |
| 258 | def create_gemport(self, device, data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 259 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 264 | |
| 265 | def update_gemport(self, device, data): |
| 266 | raise NotImplementedError() |
| 267 | |
| 268 | def remove_gemport(self, device, data): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 269 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 274 | |
| 275 | def create_multicast_gemport(self, device, data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 276 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 281 | |
| 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 Barbarie | 980a091 | 2017-05-11 11:27:06 -0400 | [diff] [blame] | 300 | def unsuppress_alarm(self, filter): |
| 301 | raise NotImplementedError() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 302 | |
| 303 | class 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 Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 311 | self.event_messages = DeferredQueue() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 312 | self.proxy_address = None |
| 313 | self.tx_id = 0 |
| 314 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 315 | # 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 322 | def receive_message(self, msg): |
| 323 | self.incoming_messages.put(msg) |
| 324 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 325 | @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 |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 334 | yield self.message_exchange( |
| 335 | self.proxy_address.onu_id, |
| 336 | self.proxy_address.onu_session_id, |
| 337 | port_no) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 338 | |
| 339 | device = self.adapter_agent.get_device(self.device_id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 340 | device.connect_status = ConnectStatus.REACHABLE |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 341 | 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 | |
Girish | 9663160 | 2017-12-14 21:52:59 +0530 | [diff] [blame] | 354 | 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 Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 360 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 376 | def activate(self, device): |
| 377 | self.log.info('activating') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 378 | |
| 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 382 | #assert device.proxy_address.channel_id # c-vid |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 383 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 384 | # 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 Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 388 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 389 | # populate device info |
| 390 | device.root = True |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 391 | device.vendor = 'Broadcom' |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 392 | device.model = 'n/a' |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 393 | device.hardware_version = 'to be filled' |
| 394 | device.firmware_version = 'to be filled' |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 395 | device.images.image.extend([ |
| 396 | Image(version="to be filled") |
| 397 | ]) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 398 | device.connect_status = ConnectStatus.REACHABLE |
| 399 | self.adapter_agent.update_device(device) |
| 400 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 401 | self.adapter_agent.add_port(device.id, Port( |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 402 | port_no=100, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 403 | 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 Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 415 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 416 | logical_device_id = parent_device.parent_id |
| 417 | assert logical_device_id |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 418 | device = self.adapter_agent.get_device(device.id) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 419 | device.oper_status = OperStatus.DISCOVERED |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 420 | self.adapter_agent.update_device(device) |
| 421 | |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 422 | 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 | |
sathishg | f4880c7 | 2018-01-10 10:48:45 +0530 | [diff] [blame^] | 439 | 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 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 448 | @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 |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 466 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 467 | @inlineCallbacks |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 468 | 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 | # |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 473 | #self.log.info('bulk-flow-update', device_id=device.id, flows=flows) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 474 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 475 | def is_downstream(port): |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 476 | return port == 100 # Need a better way |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 477 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 478 | def is_upstream(port): |
| 479 | return not is_downstream(port) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 480 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 481 | for flow in flows: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 482 | _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 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 494 | self.log.info('bulk-flow-update', device_id=device.id, flow=flow) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 495 | try: |
| 496 | _in_port = fd.get_in_port(flow) |
| 497 | assert _in_port is not None |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 498 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 499 | 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 556 | _metadata = field.table_metadata |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 557 | 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 590 | _set_vlan_vid = _field.vlan_vid & 0xfff |
| 591 | self.log.info('set-field-type-valn-vid', _set_vlan_vid) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 592 | 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 | # |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 602 | if _vlan_vid == 0 and _set_vlan_vid != None and _set_vlan_vid != 0: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 603 | # allow priority tagged packets |
| 604 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 605 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 606 | |
| 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 617 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 618 | 1, 8, _set_vlan_vid) |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 619 | yield self.wait_for_response() |
| 620 | |
| 621 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 622 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 623 | ''' |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 624 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0, |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 625 | 1, 8, _set_vlan_vid) |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 626 | yield self.wait_for_response() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 627 | ''' |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 628 | |
| 629 | except Exception as e: |
| 630 | log.exception('failed-to-install-flow', e=e, flow=flow) |
| 631 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 632 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 668 | def send_create_gal_ethernet_profile(self, |
| 669 | entity_id, |
| 670 | max_gem_payload_size): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 671 | 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 | |
sathishg | 5e21cd9 | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 684 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 702 | def send_set_tcont(self, |
| 703 | entity_id, |
| 704 | alloc_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 705 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 713 | entity_id=entity_id, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 714 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 715 | data=data |
| 716 | ) |
| 717 | ) |
| 718 | self.send_omci_message(frame) |
| 719 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 720 | def send_create_8021p_mapper_service_profile(self, |
| 721 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 722 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 723 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 724 | 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 731 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 738 | ) |
| 739 | ) |
| 740 | ) |
| 741 | self.send_omci_message(frame) |
| 742 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 743 | def send_create_mac_bridge_service_profile(self, |
| 744 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 745 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 746 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 747 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 764 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 777 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 778 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 779 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 786 | direction=_direction, |
| 787 | traffic_management_pointer_upstream=tm |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 788 | ) |
| 789 | ) |
| 790 | ) |
| 791 | self.send_omci_message(frame) |
| 792 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 793 | def send_create_multicast_gem_interworking_tp(self, |
| 794 | entity_id, |
| 795 | gem_port_net_ctp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 796 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 797 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 798 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 805 | service_profile_pointer=0x1 |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 806 | ) |
| 807 | ) |
| 808 | ) |
| 809 | self.send_omci_message(frame) |
| 810 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 811 | def send_create_gem_inteworking_tp(self, |
| 812 | entity_id, |
| 813 | gem_port_net_ctp_id, |
| 814 | service_profile_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 815 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 816 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 817 | 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 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 832 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 845 | def send_set_8021p_mapper_service_profile(self, |
| 846 | entity_id, |
| 847 | interwork_tp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 848 | data = dict( |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 849 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 857 | ) |
| 858 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 859 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 860 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 887 | tp_pointer=tp_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 888 | ) |
| 889 | ) |
| 890 | ) |
| 891 | self.send_omci_message(frame) |
| 892 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 893 | def send_create_vlan_tagging_filter_data(self, |
| 894 | entity_id, |
| 895 | vlan_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 896 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 897 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 898 | 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 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 911 | 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 Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 945 | def send_create_extended_vlan_tagging_operation_configuration_data(self, |
| 946 | entity_id, |
| 947 | assoc_type, |
| 948 | assoc_me): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 949 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 950 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 951 | 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 Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 957 | association_type=assoc_type, |
| 958 | associated_me_pointer=assoc_me |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 959 | ) |
| 960 | ) |
| 961 | ) |
| 962 | self.send_omci_message(frame) |
| 963 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 964 | def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, |
| 965 | entity_id, |
| 966 | input_tpid, |
| 967 | output_tpid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 968 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 969 | input_tpid=input_tpid, |
| 970 | output_tpid=output_tpid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 971 | downstream_mode=0, # inverse of upstream |
| 972 | ) |
| 973 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 974 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 975 | message_type=OmciSet.message_id, |
| 976 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 977 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 978 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 979 | entity_id=entity_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 980 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 981 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 982 | *data.keys()), |
| 983 | data=data |
| 984 | ) |
| 985 | ) |
| 986 | self.send_omci_message(frame) |
| 987 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 988 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self, |
| 989 | entity_id, |
| 990 | filter_inner_vid, |
| 991 | treatment_inner_vid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 992 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 993 | received_frame_vlan_tagging_operation_table= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 994 | VlanTaggingOperation( |
| 995 | filter_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 996 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1002 | filter_ether_type=0, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1003 | |
| 1004 | treatment_tags_to_remove=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1005 | treatment_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1006 | treatment_outer_vid=0, |
| 1007 | treatment_outer_tpid_de=0, |
| 1008 | |
| 1009 | treatment_inner_priority=0, |
| 1010 | treatment_inner_vid=treatment_inner_vid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1011 | treatment_inner_tpid_de=4 |
| 1012 | ) |
| 1013 | ) |
| 1014 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1015 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1016 | message_type=OmciSet.message_id, |
| 1017 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1018 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1019 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1020 | entity_id=entity_id, |
| 1021 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1022 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 1023 | *data.keys()), |
| 1024 | data=data |
| 1025 | ) |
| 1026 | ) |
| 1027 | self.send_omci_message(frame) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1028 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 1029 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1074 | 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 Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1297 | @inlineCallbacks |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1298 | def wait_for_response(self): |
| 1299 | log.info('wait-for-response') |
| 1300 | try: |
| 1301 | response = yield self.incoming_messages.get() |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1302 | log.info('got-response') |
| 1303 | # resp = OmciFrame(response) |
| 1304 | # resp.show() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1305 | except Exception as e: |
| 1306 | self.log.info('wait-for-response-exception', exc=str(e)) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1307 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1308 | @inlineCallbacks |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1309 | def message_exchange(self, onu, gem, cvid): |
| 1310 | log.info('message_exchange', onu=onu, gem=gem, cvid=cvid) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1311 | # reset incoming message queue |
| 1312 | while self.incoming_messages.pending: |
| 1313 | _ = yield self.incoming_messages.get() |
| 1314 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1315 | cvid = BRDCM_DEFAULT_VLAN |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1316 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1317 | # construct message |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1318 | # MIB Reset - OntData - 0 |
| 1319 | self.send_mib_reset() |
| 1320 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1321 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1322 | # Create AR - GalEthernetProfile - 1 |
| 1323 | self.send_create_gal_ethernet_profile(1, 48) |
| 1324 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1325 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1326 | # 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1331 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1332 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1333 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100 |
| 1334 | self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1335 | yield self.wait_for_response() |
| 1336 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1337 | # MAC Bridge Service config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1338 | # Create AR - MacBridgeServiceProfile - 513 |
| 1339 | self.send_create_mac_bridge_service_profile(0x201) |
| 1340 | yield self.wait_for_response() |
| 1341 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1342 | # 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1348 | yield self.wait_for_response() |
| 1349 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1350 | # Mapper Service config |
| 1351 | # Create AR - 802.1pMapperServiceProfile - 32769 |
| 1352 | self.send_create_8021p_mapper_service_profile(0x8001) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1353 | yield self.wait_for_response() |
| 1354 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1355 | # MAC Bridge Port config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1356 | # 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1360 | # VLAN Tagging Filter config |
| 1361 | # Create AR - VlanTaggingFilterData - 8450 - c-vid |
| 1362 | self.send_create_vlan_tagging_filter_data(0x2102, cvid) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1363 | yield self.wait_for_response() |
| 1364 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1365 | # 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1381 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1382 | # Create AR - MulticastOperationsProfile |
| 1383 | self.send_create_multicast_operations_profile(0x201, 3) |
| 1384 | yield self.wait_for_response() |
| 1385 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1386 | # 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1400 | 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1410 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1411 | # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1412 | self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 4, cvid) |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1413 | yield self.wait_for_response() |
| 1414 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1415 | ''' |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1416 | # 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1441 | yield self.wait_for_response() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1442 | ''' |
| 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 | )) |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1488 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1489 | 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 | |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1509 | def create_interface(self, data): |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1510 | 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 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1520 | 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: |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1527 | 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 |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1549 | |
| 1550 | def update_interface(self, data): |
| 1551 | self.log.info('Not Implemented yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1552 | return |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1553 | |
| 1554 | def remove_interface(self, data): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1555 | 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') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1572 | return |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1573 | |
| 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 |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1605 | 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 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1623 | 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 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1634 | @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 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1640 | def create_multicast_gemport(self, data): |
| 1641 | self.log.info('Send relevant OMCI message') |
sathishg | 5e21cd9 | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1642 | |
| 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 | |