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 |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 24 | from twisted.internet.defer import DeferredQueue, inlineCallbacks, returnValue |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 25 | from zope.interface import implementer |
| 26 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 27 | from common.utils.asleep import asleep |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 28 | from voltha.adapters.interface import IAdapterInterface |
| 29 | from voltha.core.logical_device_agent import mac_str_to_tuple |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 30 | import voltha.core.flow_decomposer as fd |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 31 | from voltha.protos import third_party |
| 32 | from voltha.protos.adapter_pb2 import Adapter |
| 33 | from voltha.protos.adapter_pb2 import AdapterConfig |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 34 | from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \ |
| 35 | AdminState |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 36 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 37 | from voltha.protos.health_pb2 import HealthStatus |
| 38 | from voltha.protos.logical_device_pb2 import LogicalPort |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 39 | from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD, OFPPS_LINK_DOWN |
Nicolas Palpacuer | c246d1b | 2018-06-28 14:00:49 -0400 | [diff] [blame] | 40 | from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port, \ |
| 41 | ofp_port_stats |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 42 | from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig, VOntaniConfig |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 43 | from voltha.protos.bbf_fiber_traffic_descriptor_profile_body_pb2 import \ |
| 44 | TrafficDescriptorProfileData |
| 45 | from voltha.protos.bbf_fiber_tcont_body_pb2 import TcontsConfigData |
| 46 | from voltha.protos.bbf_fiber_gemport_body_pb2 import GemportsConfigData |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 47 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 48 | from common.frameio.frameio import hexify |
| 49 | from voltha.extensions.omci.omci import * |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 50 | |
Jonathan Davis | b45bb37 | 2018-07-19 15:05:15 -0400 | [diff] [blame] | 51 | from voltha.registry import registry |
| 52 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 53 | _ = third_party |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 54 | log = structlog.get_logger() |
| 55 | |
| 56 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 57 | MANAGEMENT_VLAN = 4090 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 58 | BRDCM_DEFAULT_VLAN = 4091 |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 59 | ADMIN_STATE_LOCK = 1 |
| 60 | ADMIN_STATE_UNLOCK = 0 |
ggowdru | 4266262 | 2018-04-16 10:03:31 +0530 | [diff] [blame] | 61 | RESERVED_VLAN_ID = 4095 |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 62 | FLOW_TYPE_EAPOL = 34958 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 63 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 64 | @implementer(IAdapterInterface) |
| 65 | class BroadcomOnuAdapter(object): |
| 66 | |
| 67 | name = 'broadcom_onu' |
| 68 | |
| 69 | supported_device_types = [ |
| 70 | DeviceType( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 71 | id=name, |
Shad Ansari | b980451 | 2018-12-11 14:23:05 -0800 | [diff] [blame] | 72 | vendor_ids=['NONE'], |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 73 | adapter=name, |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 74 | accepts_bulk_flow_update=True, |
| 75 | accepts_add_remove_flow_updates=True |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 76 | ) |
| 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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 85 | version='0.46', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 86 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 87 | ) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 88 | self.devices_handlers = dict() # device_id -> BroadcomOnuHandler() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 89 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 90 | # register for adapter messages |
| 91 | self.adapter_agent.register_for_inter_adapter_messages() |
| 92 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 93 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 114 | log.info('adopt_device', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 115 | self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id) |
| 116 | reactor.callLater(0, self.devices_handlers[device.id].activate, device) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 117 | return device |
| 118 | |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 119 | def reconcile_device(self, device): |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 120 | 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) |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 123 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 124 | def abandon_device(self, device): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 125 | log.info('abadon-device - Not implemented') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 126 | raise NotImplementedError() |
| 127 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 128 | def disable_device(self, device): |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 129 | 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 Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 134 | |
| 135 | def reenable_device(self, device): |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 136 | 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 Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 141 | |
| 142 | def reboot_device(self, device): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 143 | 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 Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 148 | |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 149 | 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 | |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 164 | 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 Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 170 | log.info('self-test-device - Not implemented', device=device.id) |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 171 | raise NotImplementedError() |
| 172 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 173 | def delete_device(self, device): |
Jonathan Davis | b45bb37 | 2018-07-19 15:05:15 -0400 | [diff] [blame] | 174 | log.info('delete-device', device_id=device.id, device_handlers=self.devices_handlers) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 175 | if device.id in self.devices_handlers: |
| 176 | handler = self.devices_handlers[device.id] |
| 177 | if handler is not None: |
Jonathan Davis | b45bb37 | 2018-07-19 15:05:15 -0400 | [diff] [blame] | 178 | log.debug('calling-handler-delete', handler=handler) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 179 | handler.delete(device) |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 180 | del self.devices_handlers[device.id] |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 181 | return |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 182 | |
| 183 | def get_device_details(self, device): |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 184 | raise NotImplementedError() |
| 185 | |
Sergio Slobodrian | ec864c6 | 2017-03-09 11:41:43 -0500 | [diff] [blame] | 186 | def update_pm_config(self, device, pm_configs): |
| 187 | raise NotImplementedError() |
| 188 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 189 | def update_flows_bulk(self, device, flows, groups): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 190 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 191 | log.info('bulk-flow-update', device_id=device.id, |
| 192 | flows=flows, groups=groups) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 193 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 194 | assert len(groups.items) == 0 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 195 | handler = self.devices_handlers[device.id] |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 196 | return handler.update_flow_table(device, flows.items) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 197 | |
| 198 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 199 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 213 | |
| 214 | def send_proxied_message(self, proxy_address, msg): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 215 | log.debug('send-proxied-message', proxy_address=proxy_address, msg=msg) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 216 | |
| 217 | def receive_proxied_message(self, proxy_address, msg): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 218 | log.debug('receive-proxied-message', proxy_address=proxy_address, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 219 | device_id=proxy_address.device_id, msg=hexify(msg)) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 220 | # 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 227 | |
| 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 Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 232 | def receive_inter_adapter_message(self, msg): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 233 | log.debug('receive_inter_adapter_message', msg=msg) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 234 | proxy_address = msg['proxy_address'] |
| 235 | assert proxy_address is not None |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 236 | # 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) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 243 | else: |
| 244 | log.error("device-not-found") |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 245 | |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 246 | def create_interface(self, device, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 247 | log.debug('create-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 248 | if device.id in self.devices_handlers: |
| 249 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 250 | if handler is not None: |
| 251 | handler.create_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 252 | |
| 253 | def update_interface(self, device, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 254 | log.debug('update-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 255 | if device.id in self.devices_handlers: |
| 256 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 257 | if handler is not None: |
| 258 | handler.update_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 259 | |
| 260 | def remove_interface(self, device, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 261 | log.debug('remove-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 262 | if device.id in self.devices_handlers: |
| 263 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 264 | if handler is not None: |
| 265 | handler.remove_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 266 | |
| 267 | def receive_onu_detect_state(self, device_id, state): |
| 268 | raise NotImplementedError() |
| 269 | |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 270 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 271 | log.debug('create-tcont', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 272 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 276 | |
| 277 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 278 | log.info('update_tcont not implemented in onu') |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 279 | |
| 280 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 281 | log.debug('remove-tcont', device_id=device.id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 282 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 286 | |
| 287 | def create_gemport(self, device, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 288 | log.debug('create-gemport', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 289 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 293 | |
| 294 | def update_gemport(self, device, data): |
| 295 | raise NotImplementedError() |
| 296 | |
| 297 | def remove_gemport(self, device, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 298 | log.debug('remove-gemport', device_id=device.id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 299 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 303 | |
| 304 | def create_multicast_gemport(self, device, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 305 | log.debug('create-multicast-gemport', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 306 | 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 Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 310 | |
| 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 Barbarie | 980a091 | 2017-05-11 11:27:06 -0400 | [diff] [blame] | 329 | def unsuppress_alarm(self, filter): |
| 330 | raise NotImplementedError() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 331 | |
Chip Boling | 4c06db9 | 2018-05-24 15:02:26 -0500 | [diff] [blame] | 332 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 333 | class 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 Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 341 | self.event_messages = DeferredQueue() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 342 | self.proxy_address = None |
| 343 | self.tx_id = 0 |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 344 | self.flow_map = dict() |
Jonathan Davis | b45bb37 | 2018-07-19 15:05:15 -0400 | [diff] [blame] | 345 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 346 | # Need to query ONU for number of supported uni ports |
| 347 | # For now, temporarily set number of ports to 1 - port #2 |
Nicolas Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 348 | self.uni_ports = (1, 2, 3, 4, 5) |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 349 | self.flow_config_in_progress = False |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 350 | |
| 351 | # Handle received ONU event messages |
| 352 | reactor.callLater(0, self.handle_onu_events) |
| 353 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 354 | def receive_message(self, msg): |
| 355 | self.incoming_messages.put(msg) |
| 356 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 357 | @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 Palpacuer | ecb3d1e | 2018-03-14 17:00:14 -0400 | [diff] [blame] | 364 | |
| 365 | yield self.message_exchange() |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 366 | |
| 367 | device = self.adapter_agent.get_device(self.device_id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 368 | device.connect_status = ConnectStatus.REACHABLE |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 369 | 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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 374 | self.disable_ports(device) |
| 375 | device.connect_status = ConnectStatus.UNREACHABLE |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 376 | device.oper_status = OperStatus.FAILED |
| 377 | self.adapter_agent.update_device(device) |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 378 | self.flow_map.clear() |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 379 | |
| 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 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 385 | elif event_msg['event'] == 'deactivate-onu': |
Girish | a9eb021 | 2017-12-14 21:52:59 +0530 | [diff] [blame] | 386 | device = self.adapter_agent.get_device(self.device_id) |
ggowdru | 64d738a | 2018-05-10 07:08:06 -0700 | [diff] [blame] | 387 | self.disable_ports(device) |
Girish | a9eb021 | 2017-12-14 21:52:59 +0530 | [diff] [blame] | 388 | device.connect_status = ConnectStatus.UNREACHABLE |
| 389 | device.oper_status = OperStatus.DISCOVERED |
| 390 | self.adapter_agent.update_device(device) |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 391 | self.flow_map.clear() |
ggowdru | 64d738a | 2018-05-10 07:08:06 -0700 | [diff] [blame] | 392 | |
| 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 Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 397 | self.flow_map.clear() |
Girish | a9eb021 | 2017-12-14 21:52:59 +0530 | [diff] [blame] | 398 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 399 | 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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 411 | 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 Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 416 | self.flow_map.clear() |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 417 | |
| 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 Ansari | 2825d01 | 2018-02-22 23:57:46 +0000 | [diff] [blame] | 424 | 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 Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 439 | # Handle next event |
| 440 | reactor.callLater(0, self.handle_onu_events) |
| 441 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 442 | def activate(self, device): |
| 443 | self.log.info('activating') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 444 | |
| 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 448 | #assert device.proxy_address.channel_id # c-vid |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 449 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 450 | # 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 Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 454 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 455 | # populate device info |
| 456 | device.root = True |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 457 | device.vendor = 'Broadcom' |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 458 | device.model = 'n/a' |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 459 | device.hardware_version = 'to be filled' |
| 460 | device.firmware_version = 'to be filled' |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 461 | device.images.image.extend([ |
| 462 | Image(version="to be filled") |
| 463 | ]) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 464 | device.connect_status = ConnectStatus.REACHABLE |
| 465 | self.adapter_agent.update_device(device) |
| 466 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 467 | self.adapter_agent.add_port(device.id, Port( |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 468 | port_no=100, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 469 | 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 Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 481 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 482 | logical_device_id = parent_device.parent_id |
| 483 | assert logical_device_id |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 484 | device = self.adapter_agent.get_device(device.id) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 485 | device.oper_status = OperStatus.DISCOVERED |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 486 | self.adapter_agent.update_device(device) |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 487 | self.log.info('activated') |
| 488 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 489 | |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 490 | def reconcile(self, device): |
| 491 | |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 492 | self.log.debug('reconciling-broadcom-onu-device-starts') |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 493 | |
| 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 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 505 | self.log.info('reconciling-broadcom-onu-device-ends') |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 506 | |
sathishg | 24dad1e | 2018-01-10 10:48:45 +0530 | [diff] [blame] | 507 | def update_logical_port(self, logical_device_id, port_id, state): |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 508 | try: |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 509 | self.log.debug('updating-logical-port', logical_port_id=port_id, |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 510 | 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) |
sathishg | 24dad1e | 2018-01-10 10:48:45 +0530 | [diff] [blame] | 518 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 519 | def delete(self, device): |
Jonathan Davis | b45bb37 | 2018-07-19 15:05:15 -0400 | [diff] [blame] | 520 | 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 Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 525 | self.log.debug('parent-adapter-delete-onu', onu_device=device, |
Jonathan Davis | b45bb37 | 2018-07-19 15:05:15 -0400 | [diff] [blame] | 526 | 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') |
sathishg | 01ca080 | 2017-11-03 18:32:11 +0530 | [diff] [blame] | 532 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 533 | @inlineCallbacks |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 534 | def update_flow_table(self, device, flows): |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 535 | |
| 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 Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 543 | # |
| 544 | # We need to proxy through the OLT to get to the ONU |
| 545 | # Configuration from here should be using OMCI |
| 546 | # |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 547 | 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 Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 551 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 552 | # 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 Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 556 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 557 | # 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 Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 563 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 564 | # Deleting flow from ONU. |
| 565 | yield self._delete_onu_flow(self.flow_map[cookie]) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 566 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 567 | # Removing flow_map entry for deleted flow. |
| 568 | del self.flow_map[cookie] |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 569 | else: |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 570 | self.log.info('ignoring-cookie_received', cookie=cookie) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 571 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 572 | # 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) |
Jeff | 55a2f13 | 2018-08-05 21:10:41 -0700 | [diff] [blame] | 576 | continue |
| 577 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 578 | # Adding flow to ONU. |
| 579 | yield self._add_onu_flow(flow) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 580 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 581 | except Exception as e: |
| 582 | self.log.exception('failed-to-update-flow-table', e=e) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 583 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 584 | self.flow_config_in_progress = False |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 585 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 586 | @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) |
ggowdru | 4266262 | 2018-04-16 10:03:31 +0530 | [diff] [blame] | 604 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 605 | self.flow_config_in_progress = False |
ggowdru | 4266262 | 2018-04-16 10:03:31 +0530 | [diff] [blame] | 606 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 607 | @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 Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 633 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 634 | 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 Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 640 | self.log.debug('send-omci-message-%s' % _frame) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 641 | 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 Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 645 | self.log.warn('send-omci-message-exception', exc=str(e)) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 646 | |
| 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 670 | def send_create_gal_ethernet_profile(self, |
| 671 | entity_id, |
| 672 | max_gem_payload_size): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 673 | 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 | |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 686 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 704 | def send_set_tcont(self, |
| 705 | entity_id, |
| 706 | alloc_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 707 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 715 | entity_id=entity_id, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 716 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 717 | data=data |
| 718 | ) |
| 719 | ) |
| 720 | self.send_omci_message(frame) |
| 721 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 722 | def send_create_8021p_mapper_service_profile(self, |
| 723 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 724 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 725 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 726 | 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 733 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 740 | ) |
| 741 | ) |
| 742 | ) |
| 743 | self.send_omci_message(frame) |
| 744 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 745 | def send_create_mac_bridge_service_profile(self, |
| 746 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 747 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 748 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 749 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 766 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 779 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 780 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 781 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 788 | direction=_direction, |
| 789 | traffic_management_pointer_upstream=tm |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 790 | ) |
| 791 | ) |
| 792 | ) |
| 793 | self.send_omci_message(frame) |
| 794 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 795 | def send_create_multicast_gem_interworking_tp(self, |
| 796 | entity_id, |
| 797 | gem_port_net_ctp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 798 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 799 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 800 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 807 | service_profile_pointer=0x1 |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 808 | ) |
| 809 | ) |
| 810 | ) |
| 811 | self.send_omci_message(frame) |
| 812 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 813 | def send_create_gem_inteworking_tp(self, |
| 814 | entity_id, |
| 815 | gem_port_net_ctp_id, |
| 816 | service_profile_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 817 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 818 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 819 | 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 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 834 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 847 | def send_set_8021p_mapper_service_profile(self, |
| 848 | entity_id, |
Girish Gowdru | d75ef39 | 2018-10-02 10:33:50 -0700 | [diff] [blame] | 849 | interwork_tp_id_0_6=None, |
| 850 | interwork_tp_id_7=None): |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 851 | data = dict() |
Girish Gowdru | d75ef39 | 2018-10-02 10:33:50 -0700 | [diff] [blame] | 852 | 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 Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 869 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 870 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 871 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 872 | 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( |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 896 | bridge_id_pointer=bridge_id, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 897 | port_num=port_id, |
| 898 | tp_type=tp_type, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 899 | tp_pointer=tp_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 900 | ) |
| 901 | ) |
| 902 | ) |
| 903 | self.send_omci_message(frame) |
| 904 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 905 | def send_create_vlan_tagging_filter_data(self, |
| 906 | entity_id, |
ggowdru | 4266262 | 2018-04-16 10:03:31 +0530 | [diff] [blame] | 907 | vlan_id, |
| 908 | fwd_operation): |
Chip Boling | 4c06db9 | 2018-05-24 15:02:26 -0500 | [diff] [blame] | 909 | vlan_filter_list = [0] * 12 |
| 910 | vlan_filter_list[0] = vlan_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 911 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 912 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 913 | message_type=OmciCreate.message_id, |
| 914 | omci_message=OmciCreate( |
| 915 | entity_class=VlanTaggingFilterData.class_id, |
| 916 | entity_id=entity_id, |
| 917 | data=dict( |
Chip Boling | 4c06db9 | 2018-05-24 15:02:26 -0500 | [diff] [blame] | 918 | vlan_filter_list=vlan_filter_list, |
ggowdru | 4266262 | 2018-04-16 10:03:31 +0530 | [diff] [blame] | 919 | forward_operation=fwd_operation, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 920 | number_of_entries=1 |
| 921 | ) |
| 922 | ) |
| 923 | ) |
| 924 | self.send_omci_message(frame) |
| 925 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 926 | def send_set_vlan_tagging_filter_data(self, |
| 927 | entity_id, |
| 928 | vlan_id): |
Chip Boling | 4c06db9 | 2018-05-24 15:02:26 -0500 | [diff] [blame] | 929 | vlan_filter_list = [0] * 12 |
| 930 | vlan_filter_list[0] = vlan_id |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 931 | data = dict( |
Chip Boling | 4c06db9 | 2018-05-24 15:02:26 -0500 | [diff] [blame] | 932 | vlan_filter_list=vlan_filter_list, |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 933 | 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 Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 962 | def send_create_extended_vlan_tagging_operation_configuration_data(self, |
| 963 | entity_id, |
| 964 | assoc_type, |
| 965 | assoc_me): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 966 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 967 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 968 | 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 Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 974 | association_type=assoc_type, |
| 975 | associated_me_pointer=assoc_me |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 976 | ) |
| 977 | ) |
| 978 | ) |
| 979 | self.send_omci_message(frame) |
| 980 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 981 | def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, |
| 982 | entity_id, |
| 983 | input_tpid, |
| 984 | output_tpid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 985 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 986 | input_tpid=input_tpid, |
| 987 | output_tpid=output_tpid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 988 | downstream_mode=0, # inverse of upstream |
| 989 | ) |
| 990 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 991 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 992 | message_type=OmciSet.message_id, |
| 993 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 994 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 995 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 996 | entity_id=entity_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 997 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 998 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 999 | *data.keys()), |
| 1000 | data=data |
| 1001 | ) |
| 1002 | ) |
| 1003 | self.send_omci_message(frame) |
| 1004 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 1005 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self, |
| 1006 | entity_id, |
| 1007 | filter_inner_vid, |
| 1008 | treatment_inner_vid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1009 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1010 | received_frame_vlan_tagging_operation_table= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1011 | VlanTaggingOperation( |
| 1012 | filter_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1013 | 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1019 | filter_ether_type=0, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1020 | |
| 1021 | treatment_tags_to_remove=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1022 | treatment_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1023 | treatment_outer_vid=0, |
| 1024 | treatment_outer_tpid_de=0, |
| 1025 | |
| 1026 | treatment_inner_priority=0, |
| 1027 | treatment_inner_vid=treatment_inner_vid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1028 | treatment_inner_tpid_de=4 |
| 1029 | ) |
| 1030 | ) |
| 1031 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1032 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1033 | message_type=OmciSet.message_id, |
| 1034 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1035 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1036 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1037 | entity_id=entity_id, |
| 1038 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1039 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 1040 | *data.keys()), |
| 1041 | data=data |
| 1042 | ) |
| 1043 | ) |
| 1044 | self.send_omci_message(frame) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1045 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1046 | 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 Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 1058 | 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 Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1103 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1159 | 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 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1382 | def send_reboot(self): |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1383 | self.log.info('send omci reboot message') |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1384 | 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 Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1394 | @inlineCallbacks |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1395 | def wait_for_response(self): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1396 | self.log.debug('wait-for-response') |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1397 | try: |
| 1398 | response = yield self.incoming_messages.get() |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1399 | self.log.debug('got-response') |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1400 | resp = OmciFrame(response) |
| 1401 | resp.show() |
| 1402 | returnValue(resp) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1403 | except Exception as e: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1404 | returnValue(None) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1405 | self.log.info('wait-for-response-exception', exc=str(e)) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1406 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1407 | @inlineCallbacks |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1408 | def message_exchange(self): |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1409 | # reset incoming message queue |
| 1410 | while self.incoming_messages.pending: |
| 1411 | _ = yield self.incoming_messages.get() |
| 1412 | |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1413 | mcvid = MANAGEMENT_VLAN |
| 1414 | cvid = BRDCM_DEFAULT_VLAN |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1415 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1416 | # construct message |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1417 | # MIB Reset - OntData - 0 |
| 1418 | self.send_mib_reset() |
| 1419 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1420 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1421 | # Create AR - GalEthernetProfile - 1 |
| 1422 | self.send_create_gal_ethernet_profile(1, 48) |
| 1423 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1424 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1425 | # MAC Bridge Service config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1426 | # Create AR - MacBridgeServiceProfile - 513 |
| 1427 | self.send_create_mac_bridge_service_profile(0x201) |
| 1428 | yield self.wait_for_response() |
| 1429 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1430 | # Mapper Service config |
| 1431 | # Create AR - 802.1pMapperServiceProfile - 32769 |
| 1432 | self.send_create_8021p_mapper_service_profile(0x8001) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1433 | yield self.wait_for_response() |
| 1434 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1435 | # MAC Bridge Port config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1436 | # 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1440 | # VLAN Tagging Filter config |
| 1441 | # Create AR - VlanTaggingFilterData - 8450 - c-vid |
ggowdru | 4266262 | 2018-04-16 10:03:31 +0530 | [diff] [blame] | 1442 | # 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 Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1444 | yield self.wait_for_response() |
| 1445 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1446 | |
Nicolas Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 1447 | 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 Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 1467 | # Set AR - ExtendedVlanTaggingOperationConfigData |
Girish Gowdru | d75ef39 | 2018-10-02 10:33:50 -0700 | [diff] [blame] | 1468 | # 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 Palpacuer | af5a915 | 2018-02-14 16:55:11 -0500 | [diff] [blame] | 1480 | # 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() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1483 | |
| 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1490 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1491 | # Create AR - MulticastOperationsProfile |
| 1492 | self.send_create_multicast_operations_profile(0x201, 3) |
| 1493 | yield self.wait_for_response() |
| 1494 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1495 | # 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1509 | 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 Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1519 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1520 | # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1521 | 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] | 1522 | yield self.wait_for_response() |
| 1523 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1524 | 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 Ansari | 8de3221 | 2018-07-27 05:52:21 +0000 | [diff] [blame] | 1534 | port_no = device.proxy_address.channel_id + uni |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1535 | # register physical ports |
| 1536 | uni_port = Port( |
| 1537 | port_no=uni, |
Shad Ansari | 2825d01 | 2018-02-22 23:57:46 +0000 | [diff] [blame] | 1538 | label='uni-'+str(uni), |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1539 | 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 | )) |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1568 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1569 | def del_uni_port(self, device, parent_logical_device_id, |
| 1570 | name, parent_port_num=None): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1571 | self.log.debug('del-uni-port', device_id=device.id, |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1572 | 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 Ansari | 2825d01 | 2018-02-22 23:57:46 +0000 | [diff] [blame] | 1583 | if port.label == 'uni-'+str(uni): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1584 | 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 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1589 | 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) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1593 | 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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1603 | # 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 | |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1619 | def create_interface(self, data): |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1620 | 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 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1630 | parent_device = self.adapter_agent.get_device(onu_device.parent_id) |
| 1631 | logical_device_id = parent_device.parent_id |
| 1632 | assert logical_device_id |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1633 | self.add_uni_port(onu_device, logical_device_id, |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1634 | data.name, parent_port_num) |
| 1635 | |
| 1636 | if parent_port_num is None: |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1637 | 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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1654 | pon_port.admin_state = AdminState.ENABLED |
| 1655 | pon_port.oper_status = OperStatus.ACTIVE |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1656 | self.adapter_agent.add_port_reference_to_parent(self.device_id, |
| 1657 | pon_port) |
| 1658 | else: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1659 | self.log.info('Not-handled-Yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1660 | return |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1661 | |
| 1662 | def update_interface(self, data): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1663 | self.log.info('Not-Implemented-yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1664 | return |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1665 | |
| 1666 | def remove_interface(self, data): |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1667 | if isinstance(data, VEnetConfig): |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1668 | parent_port_num = None |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1669 | 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) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1682 | if isinstance(data, VOntaniConfig): |
| 1683 | self.delete_v_ont_ani(data) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1684 | else: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1685 | self.log.info('not-handled-yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1686 | return |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1687 | |
| 1688 | @inlineCallbacks |
| 1689 | def create_gemport(self, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1690 | self.log.debug('create-gemport') |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1691 | gem_port = GemportsConfigData() |
| 1692 | gem_port.CopyFrom(data) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1693 | if gem_port.tcont_ref is None: |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1694 | self.log.error('recevied-null-gem-port-data') |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1695 | 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 Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1713 | |
Girish Gowdru | d75ef39 | 2018-10-02 10:33:50 -0700 | [diff] [blame] | 1714 | 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 Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1720 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1721 | yield self.wait_for_response() |
| 1722 | |
| 1723 | |
| 1724 | @inlineCallbacks |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1725 | def remove_gemport(self, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1726 | self.log.debug('remove-gemport') |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1727 | gem_port = GemportsConfigData() |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1728 | gem_port.CopyFrom(data) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1729 | device = self.adapter_agent.get_device(self.device_id) |
| 1730 | if device.connect_status != ConnectStatus.REACHABLE: |
| 1731 | self.log.error('device-unreachable') |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1732 | return |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1733 | |
Girish Gowdru | d75ef39 | 2018-10-02 10:33:50 -0700 | [diff] [blame] | 1734 | self.send_set_8021p_mapper_service_profile(0x8001, |
| 1735 | interwork_tp_id_0_6=0xFFFF, |
| 1736 | interwork_tp_id_7=0xFFFF) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1737 | yield self.wait_for_response() |
| 1738 | |
| 1739 | self.send_delete_omci_mesage(GemInterworkingTp.class_id, |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1740 | gem_port.gemport_id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1741 | 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, |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1745 | gem_port.gemport_id) |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1746 | yield self.wait_for_response() |
| 1747 | |
| 1748 | @inlineCallbacks |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1749 | def create_tcont(self, tcont_data, traffic_descriptor_data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1750 | self.log.debug('create-tcont') |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1751 | tcont = TcontsConfigData() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1752 | tcont.CopyFrom(tcont_data) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1753 | 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) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1759 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1760 | @inlineCallbacks |
| 1761 | def remove_tcont(self, tcont_data, traffic_descriptor_data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1762 | self.log.debug('remove-tcont') |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1763 | device = self.adapter_agent.get_device(self.device_id) |
| 1764 | if device.connect_status != ConnectStatus.REACHABLE: |
| 1765 | self.log.error('device-unreachable') |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1766 | return |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1767 | |
Girish | d582367 | 2017-11-23 12:15:14 +0530 | [diff] [blame] | 1768 | self.send_set_tcont(0x8001, 0xFFFF) |
| 1769 | yield self.wait_for_response() |
| 1770 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1771 | def create_multicast_gemport(self, data): |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1772 | self.log.info('Send relevant OMCI message - Not implemented yet') |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1773 | |
| 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() |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1780 | # Disable all ports on that device |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1781 | self.disable_ports(device) |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1782 | device.oper_status = OperStatus.UNKNOWN |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1783 | device.connect_status = ConnectStatus.UNREACHABLE |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1784 | 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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1794 | self.enable_ports(device) |
sathishg | ff102eb | 2017-12-21 12:19:19 +0530 | [diff] [blame] | 1795 | 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 | |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1801 | @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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1807 | return |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1808 | |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1809 | 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 Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1816 | self.log.debug("reboot-command-processed-successfully") |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1817 | # 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 Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1823 | self.flow_map.clear() |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1824 | else: |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1825 | self.log.error("reboot-failed", success_code=success_code) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1826 | else: |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1827 | self.log.error("error-in-processing-reboot-response") |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1828 | except Exception as e: |
Nicolas Palpacuer | 324dcae | 2018-08-02 11:12:22 -0400 | [diff] [blame] | 1829 | self.log.error('wait-for-response-exception', exc=str(e)) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1830 | |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1831 | def disable_ports(self, device): |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1832 | 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 Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1837 | parent_device = self.adapter_agent.get_device(device.parent_id) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1838 | assert parent_device |
| 1839 | logical_device_id = parent_device.parent_id |
| 1840 | assert logical_device_id |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1841 | ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI) |
Girish | 6168721 | 2018-01-08 12:48:58 +0530 | [diff] [blame] | 1842 | for port in ports: |
| 1843 | port_id = 'uni-{}'.format(port.port_no) |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1844 | 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) |
ggowdru | 64d738a | 2018-05-10 07:08:06 -0700 | [diff] [blame] | 1851 | |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1852 | def enable_ports(self, device): |
ggowdru | 64d738a | 2018-05-10 07:08:06 -0700 | [diff] [blame] | 1853 | self.log.info('enable-ports', device_id=self.device_id) |
| 1854 | |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1855 | # Enable all ports on that device |
ggowdru | 64d738a | 2018-05-10 07:08:06 -0700 | [diff] [blame] | 1856 | self.adapter_agent.enable_all_ports(self.device_id) |
| 1857 | |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1858 | parent_device = self.adapter_agent.get_device(device.parent_id) |
ggowdru | 64d738a | 2018-05-10 07:08:06 -0700 | [diff] [blame] | 1859 | assert parent_device |
| 1860 | logical_device_id = parent_device.parent_id |
| 1861 | assert logical_device_id |
Girish Gowdru | 1f2f5d3 | 2018-06-14 00:38:33 -0700 | [diff] [blame] | 1862 | ports = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI) |
ggowdru | 64d738a | 2018-05-10 07:08:06 -0700 | [diff] [blame] | 1863 | for port in ports: |
| 1864 | port_id = 'uni-{}'.format(port.port_no) |
Girish Gowdru | 4e854c2 | 2018-09-26 02:51:57 -0700 | [diff] [blame] | 1865 | 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 |