Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | """ |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 18 | Broadcom OLT/ONU adapter. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 19 | """ |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 20 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 21 | from uuid import uuid4 |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 22 | import structlog |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 23 | from twisted.internet import reactor, task |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 24 | from twisted.internet.defer import DeferredQueue, inlineCallbacks |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 25 | from zope.interface import implementer |
| 26 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 27 | from voltha.adapters.interface import IAdapterInterface |
| 28 | from voltha.core.logical_device_agent import mac_str_to_tuple |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 29 | import voltha.core.flow_decomposer as fd |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 30 | from voltha.protos import third_party |
| 31 | from voltha.protos.adapter_pb2 import Adapter |
| 32 | from voltha.protos.adapter_pb2 import AdapterConfig |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 33 | from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \ |
| 34 | AdminState |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 35 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port, Image |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 36 | from voltha.protos.health_pb2 import HealthStatus |
| 37 | from voltha.protos.logical_device_pb2 import LogicalPort |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 38 | from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD, OFPPS_LINK_DOWN |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 39 | from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 40 | from voltha.protos.bbf_fiber_base_pb2 import VEnetConfig |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 41 | from voltha.protos.bbf_fiber_traffic_descriptor_profile_body_pb2 import \ |
| 42 | TrafficDescriptorProfileData |
| 43 | from voltha.protos.bbf_fiber_tcont_body_pb2 import TcontsConfigData |
| 44 | from voltha.protos.bbf_fiber_gemport_body_pb2 import GemportsConfigData |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 45 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 46 | from common.frameio.frameio import hexify |
| 47 | from voltha.extensions.omci.omci import * |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 48 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 49 | _ = third_party |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 50 | log = structlog.get_logger() |
| 51 | |
| 52 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 53 | BRDCM_DEFAULT_VLAN = 4091 |
| 54 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 55 | @implementer(IAdapterInterface) |
| 56 | class BroadcomOnuAdapter(object): |
| 57 | |
| 58 | name = 'broadcom_onu' |
| 59 | |
| 60 | supported_device_types = [ |
| 61 | DeviceType( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 62 | id=name, |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 63 | vendor_id='BRCM', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 64 | adapter=name, |
| 65 | accepts_bulk_flow_update=True |
| 66 | ) |
| 67 | ] |
| 68 | |
| 69 | def __init__(self, adapter_agent, config): |
| 70 | self.adapter_agent = adapter_agent |
| 71 | self.config = config |
| 72 | self.descriptor = Adapter( |
| 73 | id=self.name, |
| 74 | vendor='Voltha project', |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 75 | version='0.4', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 76 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 77 | ) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 78 | self.devices_handlers = dict() # device_id -> BroadcomOnuHandler() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 79 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 80 | # register for adapter messages |
| 81 | self.adapter_agent.register_for_inter_adapter_messages() |
| 82 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 83 | def start(self): |
| 84 | log.debug('starting') |
| 85 | log.info('started') |
| 86 | |
| 87 | def stop(self): |
| 88 | log.debug('stopping') |
| 89 | log.info('stopped') |
| 90 | |
| 91 | def adapter_descriptor(self): |
| 92 | return self.descriptor |
| 93 | |
| 94 | def device_types(self): |
| 95 | return DeviceTypes(items=self.supported_device_types) |
| 96 | |
| 97 | def health(self): |
| 98 | return HealthStatus(state=HealthStatus.HealthState.HEALTHY) |
| 99 | |
| 100 | def change_master_state(self, master): |
| 101 | raise NotImplementedError() |
| 102 | |
| 103 | def adopt_device(self, device): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 104 | log.info('adopt_device', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 105 | self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id) |
| 106 | reactor.callLater(0, self.devices_handlers[device.id].activate, device) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 107 | return device |
| 108 | |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 109 | def reconcile_device(self, device): |
sathishg | c2ef54a | 2017-11-03 18:32:11 +0530 | [diff] [blame^] | 110 | log.info('reconcile-device', device_id=device.id) |
| 111 | self.devices_handlers[device.id] = BroadcomOnuHandler(self, device.id) |
| 112 | reactor.callLater(0, self.devices_handlers[device.id].reconcile, device) |
khenaidoo | 032d330 | 2017-06-09 14:50:04 -0400 | [diff] [blame] | 113 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 114 | def abandon_device(self, device): |
| 115 | raise NotImplementedError() |
| 116 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 117 | def disable_device(self, device): |
| 118 | raise NotImplementedError() |
| 119 | |
| 120 | def reenable_device(self, device): |
| 121 | raise NotImplementedError() |
| 122 | |
| 123 | def reboot_device(self, device): |
| 124 | raise NotImplementedError() |
| 125 | |
Lydia Fang | 01f2e85 | 2017-06-28 17:24:58 -0700 | [diff] [blame] | 126 | def download_image(self, device, request): |
| 127 | raise NotImplementedError() |
| 128 | |
| 129 | def get_image_download_status(self, device, request): |
| 130 | raise NotImplementedError() |
| 131 | |
| 132 | def cancel_image_download(self, device, request): |
| 133 | raise NotImplementedError() |
| 134 | |
| 135 | def activate_image_update(self, device, request): |
| 136 | raise NotImplementedError() |
| 137 | |
| 138 | def revert_image_update(self, device, request): |
| 139 | raise NotImplementedError() |
| 140 | |
sathishg | 5ae8622 | 2017-06-28 15:16:29 +0530 | [diff] [blame] | 141 | def self_test_device(self, device): |
| 142 | """ |
| 143 | This is called to Self a device based on a NBI call. |
| 144 | :param device: A Voltha.Device object. |
| 145 | :return: Will return result of self test |
| 146 | """ |
| 147 | log.info('self-test-device', device=device.id) |
| 148 | raise NotImplementedError() |
| 149 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 150 | def delete_device(self, device): |
| 151 | raise NotImplementedError() |
| 152 | |
| 153 | def get_device_details(self, device): |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 154 | raise NotImplementedError() |
| 155 | |
Sergio Slobodrian | ec864c6 | 2017-03-09 11:41:43 -0500 | [diff] [blame] | 156 | def update_pm_config(self, device, pm_configs): |
| 157 | raise NotImplementedError() |
| 158 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 159 | def update_flows_bulk(self, device, flows, groups): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 160 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 161 | log.info('bulk-flow-update', device_id=device.id, |
| 162 | flows=flows, groups=groups) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 163 | ''' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 164 | assert len(groups.items) == 0 |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 165 | handler = self.devices_handlers[device.id] |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 166 | return handler.update_flow_table(device, flows.items) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 167 | |
| 168 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 169 | raise NotImplementedError() |
| 170 | |
| 171 | def send_proxied_message(self, proxy_address, msg): |
| 172 | log.info('send-proxied-message', proxy_address=proxy_address, msg=msg) |
| 173 | |
| 174 | def receive_proxied_message(self, proxy_address, msg): |
| 175 | log.info('receive-proxied-message', proxy_address=proxy_address, |
| 176 | device_id=proxy_address.device_id, msg=hexify(msg)) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 177 | # Device_id from the proxy_address is the olt device id. We need to |
| 178 | # get the onu device id using the port number in the proxy_address |
| 179 | device = self.adapter_agent. \ |
| 180 | get_child_device_with_proxy_address(proxy_address) |
| 181 | if device: |
| 182 | handler = self.devices_handlers[device.id] |
| 183 | handler.receive_message(msg) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 184 | |
| 185 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 186 | log.info('packet-out', logical_device_id=logical_device_id, |
| 187 | egress_port_no=egress_port_no, msg_len=len(msg)) |
| 188 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 189 | def receive_inter_adapter_message(self, msg): |
| 190 | log.info('receive_inter_adapter_message', msg=msg) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 191 | proxy_address = msg['proxy_address'] |
| 192 | assert proxy_address is not None |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 193 | # Device_id from the proxy_address is the olt device id. We need to |
| 194 | # get the onu device id using the port number in the proxy_address |
| 195 | device = self.adapter_agent. \ |
| 196 | get_child_device_with_proxy_address(proxy_address) |
| 197 | if device: |
| 198 | handler = self.devices_handlers[device.id] |
| 199 | handler.event_messages.put(msg) |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 200 | |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 201 | def create_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 202 | log.info('create-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 203 | if device.id in self.devices_handlers: |
| 204 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 205 | if handler is not None: |
| 206 | handler.create_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 207 | |
| 208 | def update_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 209 | log.info('update-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 210 | if device.id in self.devices_handlers: |
| 211 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 212 | if handler is not None: |
| 213 | handler.update_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 214 | |
| 215 | def remove_interface(self, device, data): |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 216 | log.info('remove-interface', device_id=device.id) |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 217 | if device.id in self.devices_handlers: |
| 218 | handler = self.devices_handlers[device.id] |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 219 | if handler is not None: |
| 220 | handler.remove_interface(data) |
Nikolay Titov | 89004ec | 2017-06-19 18:22:42 -0400 | [diff] [blame] | 221 | |
| 222 | def receive_onu_detect_state(self, device_id, state): |
| 223 | raise NotImplementedError() |
| 224 | |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 225 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 226 | log.info('create-tcont', device_id=device.id) |
| 227 | if device.id in self.devices_handlers: |
| 228 | handler = self.devices_handlers[device.id] |
| 229 | if handler is not None: |
| 230 | handler.create_tcont(tcont_data, traffic_descriptor_data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 231 | |
| 232 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 233 | raise NotImplementedError() |
| 234 | |
| 235 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 236 | raise NotImplementedError() |
| 237 | |
| 238 | def create_gemport(self, device, data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 239 | log.info('create-gemport', device_id=device.id) |
| 240 | if device.id in self.devices_handlers: |
| 241 | handler = self.devices_handlers[device.id] |
| 242 | if handler is not None: |
| 243 | handler.create_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 244 | |
| 245 | def update_gemport(self, device, data): |
| 246 | raise NotImplementedError() |
| 247 | |
| 248 | def remove_gemport(self, device, data): |
| 249 | raise NotImplementedError() |
| 250 | |
| 251 | def create_multicast_gemport(self, device, data): |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 252 | log.info('create-multicast-gemport', device_id=device.id) |
| 253 | if device.id in self.devices_handlers: |
| 254 | handler = self.devices_handlers[device.id] |
| 255 | if handler is not None: |
| 256 | handler.create_multicast_gemport(data) |
Nikolay Titov | 176f1db | 2017-08-10 12:38:43 -0400 | [diff] [blame] | 257 | |
| 258 | def update_multicast_gemport(self, device, data): |
| 259 | raise NotImplementedError() |
| 260 | |
| 261 | def remove_multicast_gemport(self, device, data): |
| 262 | raise NotImplementedError() |
| 263 | |
| 264 | def create_multicast_distribution_set(self, device, data): |
| 265 | raise NotImplementedError() |
| 266 | |
| 267 | def update_multicast_distribution_set(self, device, data): |
| 268 | raise NotImplementedError() |
| 269 | |
| 270 | def remove_multicast_distribution_set(self, device, data): |
| 271 | raise NotImplementedError() |
| 272 | |
| 273 | def suppress_alarm(self, filter): |
| 274 | raise NotImplementedError() |
| 275 | |
Stephane Barbarie | 980a091 | 2017-05-11 11:27:06 -0400 | [diff] [blame] | 276 | def unsuppress_alarm(self, filter): |
| 277 | raise NotImplementedError() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 278 | |
| 279 | class BroadcomOnuHandler(object): |
| 280 | |
| 281 | def __init__(self, adapter, device_id): |
| 282 | self.adapter = adapter |
| 283 | self.adapter_agent = adapter.adapter_agent |
| 284 | self.device_id = device_id |
| 285 | self.log = structlog.get_logger(device_id=device_id) |
| 286 | self.incoming_messages = DeferredQueue() |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 287 | self.event_messages = DeferredQueue() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 288 | self.proxy_address = None |
| 289 | self.tx_id = 0 |
| 290 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 291 | # Need to query ONU for number of supported uni ports |
| 292 | # For now, temporarily set number of ports to 1 - port #2 |
| 293 | self.uni_ports = (2,) |
| 294 | |
| 295 | # Handle received ONU event messages |
| 296 | reactor.callLater(0, self.handle_onu_events) |
| 297 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 298 | def receive_message(self, msg): |
| 299 | self.incoming_messages.put(msg) |
| 300 | |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 301 | @inlineCallbacks |
| 302 | def handle_onu_events(self): |
| 303 | event_msg = yield self.event_messages.get() |
| 304 | |
| 305 | if event_msg['event'] == 'activation-completed': |
| 306 | |
| 307 | if event_msg['event_data']['activation_successful'] == True: |
| 308 | for uni in self.uni_ports: |
| 309 | port_no = self.proxy_address.channel_id + uni |
| 310 | reactor.callLater(1, |
| 311 | self.message_exchange, |
| 312 | self.proxy_address.onu_id, |
| 313 | self.proxy_address.onu_session_id, |
| 314 | port_no) |
| 315 | |
| 316 | device = self.adapter_agent.get_device(self.device_id) |
| 317 | device.oper_status = OperStatus.ACTIVE |
| 318 | self.adapter_agent.update_device(device) |
| 319 | |
| 320 | else: |
| 321 | device = self.adapter_agent.get_device(self.device_id) |
| 322 | device.oper_status = OperStatus.FAILED |
| 323 | self.adapter_agent.update_device(device) |
| 324 | |
| 325 | elif event_msg['event'] == 'deactivation-completed': |
| 326 | device = self.adapter_agent.get_device(self.device_id) |
| 327 | device.oper_status = OperStatus.DISCOVERED |
| 328 | self.adapter_agent.update_device(device) |
| 329 | |
| 330 | elif event_msg['event'] == 'ranging-completed': |
| 331 | |
| 332 | if event_msg['event_data']['ranging_successful'] == True: |
| 333 | device = self.adapter_agent.get_device(self.device_id) |
| 334 | device.oper_status = OperStatus.ACTIVATING |
| 335 | self.adapter_agent.update_device(device) |
| 336 | |
| 337 | else: |
| 338 | device = self.adapter_agent.get_device(self.device_id) |
| 339 | device.oper_status = OperStatus.FAILED |
| 340 | self.adapter_agent.update_device(device) |
| 341 | |
| 342 | # Handle next event |
| 343 | reactor.callLater(0, self.handle_onu_events) |
| 344 | |
| 345 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 346 | def activate(self, device): |
| 347 | self.log.info('activating') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 348 | |
| 349 | # first we verify that we got parent reference and proxy info |
| 350 | assert device.parent_id |
| 351 | assert device.proxy_address.device_id |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 352 | #assert device.proxy_address.channel_id # c-vid |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 353 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 354 | # register for proxied messages right away |
| 355 | self.proxy_address = device.proxy_address |
| 356 | self.adapter_agent.register_for_proxied_messages(device.proxy_address) |
| 357 | |
Peter Shafik | 9107f2e | 2017-05-02 15:54:39 -0400 | [diff] [blame] | 358 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 359 | # populate device info |
| 360 | device.root = True |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 361 | device.vendor = 'Broadcom' |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 362 | device.model = 'n/a' |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 363 | device.hardware_version = 'to be filled' |
| 364 | device.firmware_version = 'to be filled' |
ggowdru | 236bd95 | 2017-06-20 20:32:55 -0700 | [diff] [blame] | 365 | device.images.image.extend([ |
| 366 | Image(version="to be filled") |
| 367 | ]) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 368 | device.connect_status = ConnectStatus.REACHABLE |
| 369 | self.adapter_agent.update_device(device) |
| 370 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 371 | self.adapter_agent.add_port(device.id, Port( |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 372 | port_no=100, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 373 | label='PON port', |
| 374 | type=Port.PON_ONU, |
| 375 | admin_state=AdminState.ENABLED, |
| 376 | oper_status=OperStatus.ACTIVE, |
| 377 | peers=[ |
| 378 | Port.PeerPort( |
| 379 | device_id=device.parent_id, |
| 380 | port_no=device.parent_port_no |
| 381 | ) |
| 382 | ] |
| 383 | )) |
| 384 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 385 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 386 | logical_device_id = parent_device.parent_id |
| 387 | assert logical_device_id |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 388 | device = self.adapter_agent.get_device(device.id) |
Peter Shafik | d7f3377 | 2017-05-17 13:56:34 -0400 | [diff] [blame] | 389 | device.oper_status = OperStatus.DISCOVERED |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 390 | self.adapter_agent.update_device(device) |
| 391 | |
sathishg | c2ef54a | 2017-11-03 18:32:11 +0530 | [diff] [blame^] | 392 | def reconcile(self, device): |
| 393 | |
| 394 | log.info('reconciling-broadcom-onu-device-starts') |
| 395 | |
| 396 | # first we verify that we got parent reference and proxy info |
| 397 | assert device.parent_id |
| 398 | assert device.proxy_address.device_id |
| 399 | |
| 400 | # register for proxied messages right away |
| 401 | self.proxy_address = device.proxy_address |
| 402 | self.adapter_agent.register_for_proxied_messages(device.proxy_address) |
| 403 | |
| 404 | # TODO: Query ONU current status after reconcile and update. |
| 405 | # To be addressed in future commits. |
| 406 | |
| 407 | log.info('reconciling-broadcom-onu-device-ends') |
| 408 | |
| 409 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 410 | @inlineCallbacks |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 411 | def update_flow_table(self, device, flows): |
| 412 | # |
| 413 | # We need to proxy through the OLT to get to the ONU |
| 414 | # Configuration from here should be using OMCI |
| 415 | # |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 416 | #self.log.info('bulk-flow-update', device_id=device.id, flows=flows) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 417 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 418 | def is_downstream(port): |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 419 | return port == 100 # Need a better way |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 420 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 421 | def is_upstream(port): |
| 422 | return not is_downstream(port) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 423 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 424 | for flow in flows: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 425 | _type = None |
| 426 | _port = None |
| 427 | _vlan_vid = None |
| 428 | _udp_dst = None |
| 429 | _udp_src = None |
| 430 | _ipv4_dst = None |
| 431 | _ipv4_src = None |
| 432 | _metadata = None |
| 433 | _output = None |
| 434 | _push_tpid = None |
| 435 | _field = None |
| 436 | _set_vlan_vid = None |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 437 | self.log.info('bulk-flow-update', device_id=device.id, flow=flow) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 438 | try: |
| 439 | _in_port = fd.get_in_port(flow) |
| 440 | assert _in_port is not None |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 441 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 442 | if is_downstream(_in_port): |
| 443 | self.log.info('downstream-flow') |
| 444 | elif is_upstream(_in_port): |
| 445 | self.log.info('upstream-flow') |
| 446 | else: |
| 447 | raise Exception('port should be 1 or 2 by our convention') |
| 448 | |
| 449 | _out_port = fd.get_out_port(flow) # may be None |
| 450 | self.log.info('out-port', out_port=_out_port) |
| 451 | |
| 452 | for field in fd.get_ofb_fields(flow): |
| 453 | if field.type == fd.ETH_TYPE: |
| 454 | _type = field.eth_type |
| 455 | self.log.info('field-type-eth-type', |
| 456 | eth_type=_type) |
| 457 | |
| 458 | elif field.type == fd.IP_PROTO: |
| 459 | _proto = field.ip_proto |
| 460 | self.log.info('field-type-ip-proto', |
| 461 | ip_proto=_proto) |
| 462 | |
| 463 | elif field.type == fd.IN_PORT: |
| 464 | _port = field.port |
| 465 | self.log.info('field-type-in-port', |
| 466 | in_port=_port) |
| 467 | |
| 468 | elif field.type == fd.VLAN_VID: |
| 469 | _vlan_vid = field.vlan_vid & 0xfff |
| 470 | self.log.info('field-type-vlan-vid', |
| 471 | vlan=_vlan_vid) |
| 472 | |
| 473 | elif field.type == fd.VLAN_PCP: |
| 474 | _vlan_pcp = field.vlan_pcp |
| 475 | self.log.info('field-type-vlan-pcp', |
| 476 | pcp=_vlan_pcp) |
| 477 | |
| 478 | elif field.type == fd.UDP_DST: |
| 479 | _udp_dst = field.udp_dst |
| 480 | self.log.info('field-type-udp-dst', |
| 481 | udp_dst=_udp_dst) |
| 482 | |
| 483 | elif field.type == fd.UDP_SRC: |
| 484 | _udp_src = field.udp_src |
| 485 | self.log.info('field-type-udp-src', |
| 486 | udp_src=_udp_src) |
| 487 | |
| 488 | elif field.type == fd.IPV4_DST: |
| 489 | _ipv4_dst = field.ipv4_dst |
| 490 | self.log.info('field-type-ipv4-dst', |
| 491 | ipv4_dst=_ipv4_dst) |
| 492 | |
| 493 | elif field.type == fd.IPV4_SRC: |
| 494 | _ipv4_src = field.ipv4_src |
| 495 | self.log.info('field-type-ipv4-src', |
| 496 | ipv4_dst=_ipv4_src) |
| 497 | |
| 498 | elif field.type == fd.METADATA: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 499 | _metadata = field.table_metadata |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 500 | self.log.info('field-type-metadata', |
| 501 | metadata=_metadata) |
| 502 | |
| 503 | else: |
| 504 | raise NotImplementedError('field.type={}'.format( |
| 505 | field.type)) |
| 506 | |
| 507 | for action in fd.get_actions(flow): |
| 508 | |
| 509 | if action.type == fd.OUTPUT: |
| 510 | _output = action.output.port |
| 511 | self.log.info('action-type-output', |
| 512 | output=_output, in_port=_in_port) |
| 513 | |
| 514 | elif action.type == fd.POP_VLAN: |
| 515 | self.log.info('action-type-pop-vlan', |
| 516 | in_port=_in_port) |
| 517 | |
| 518 | elif action.type == fd.PUSH_VLAN: |
| 519 | _push_tpid = action.push.ethertype |
| 520 | log.info('action-type-push-vlan', |
| 521 | push_tpid=_push_tpid, in_port=_in_port) |
| 522 | if action.push.ethertype != 0x8100: |
| 523 | self.log.error('unhandled-tpid', |
| 524 | ethertype=action.push.ethertype) |
| 525 | |
| 526 | elif action.type == fd.SET_FIELD: |
| 527 | _field = action.set_field.field.ofb_field |
| 528 | assert (action.set_field.field.oxm_class == |
| 529 | OFPXMC_OPENFLOW_BASIC) |
| 530 | self.log.info('action-type-set-field', |
| 531 | field=_field, in_port=_in_port) |
| 532 | if _field.type == fd.VLAN_VID: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 533 | _set_vlan_vid = _field.vlan_vid & 0xfff |
| 534 | self.log.info('set-field-type-valn-vid', _set_vlan_vid) |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 535 | else: |
| 536 | self.log.error('unsupported-action-set-field-type', |
| 537 | field_type=_field.type) |
| 538 | else: |
| 539 | log.error('unsupported-action-type', |
| 540 | action_type=action.type, in_port=_in_port) |
| 541 | |
| 542 | # |
| 543 | # All flows created from ONU adapter should be OMCI based |
| 544 | # |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 545 | if _vlan_vid == 0 and _set_vlan_vid != None and _set_vlan_vid != 0: |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 546 | # allow priority tagged packets |
| 547 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 548 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 549 | |
| 550 | self.send_delete_vlan_tagging_filter_data(0x2102) |
| 551 | yield self.wait_for_response() |
| 552 | |
| 553 | #self.send_set_vlan_tagging_filter_data(0x2102, _set_vlan_vid) |
| 554 | self.send_create_vlan_tagging_filter_data(0x2102, _set_vlan_vid) |
| 555 | yield self.wait_for_response() |
| 556 | |
| 557 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, _set_vlan_vid) |
| 558 | yield self.wait_for_response() |
| 559 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 560 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 561 | 1, 8, _set_vlan_vid) |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 562 | yield self.wait_for_response() |
| 563 | |
| 564 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 565 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 566 | ''' |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 567 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0, |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 568 | 1, 8, _set_vlan_vid) |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 569 | yield self.wait_for_response() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 570 | ''' |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 571 | |
| 572 | except Exception as e: |
| 573 | log.exception('failed-to-install-flow', e=e, flow=flow) |
| 574 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 575 | def get_tx_id(self): |
| 576 | self.tx_id += 1 |
| 577 | return self.tx_id |
| 578 | |
| 579 | def send_omci_message(self, frame): |
| 580 | _frame = hexify(str(frame)) |
| 581 | self.log.info('send-omci-message-%s' % _frame) |
| 582 | device = self.adapter_agent.get_device(self.device_id) |
| 583 | try: |
| 584 | self.adapter_agent.send_proxied_message(device.proxy_address, _frame) |
| 585 | except Exception as e: |
| 586 | self.log.info('send-omci-message-exception', exc=str(e)) |
| 587 | |
| 588 | def send_get_circuit_pack(self, entity_id=0): |
| 589 | frame = OmciFrame( |
| 590 | transaction_id=self.get_tx_id(), |
| 591 | message_type=OmciGet.message_id, |
| 592 | omci_message=OmciGet( |
| 593 | entity_class=CircuitPack.class_id, |
| 594 | entity_id=entity_id, |
| 595 | attributes_mask=CircuitPack.mask_for('vendor_id') |
| 596 | ) |
| 597 | ) |
| 598 | self.send_omci_message(frame) |
| 599 | |
| 600 | def send_mib_reset(self, entity_id=0): |
| 601 | frame = OmciFrame( |
| 602 | transaction_id=self.get_tx_id(), |
| 603 | message_type=OmciMibReset.message_id, |
| 604 | omci_message=OmciMibReset( |
| 605 | entity_class=OntData.class_id, |
| 606 | entity_id=entity_id |
| 607 | ) |
| 608 | ) |
| 609 | self.send_omci_message(frame) |
| 610 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 611 | def send_create_gal_ethernet_profile(self, |
| 612 | entity_id, |
| 613 | max_gem_payload_size): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 614 | frame = OmciFrame( |
| 615 | transaction_id=self.get_tx_id(), |
| 616 | message_type=OmciCreate.message_id, |
| 617 | omci_message=OmciCreate( |
| 618 | entity_class=GalEthernetProfile.class_id, |
| 619 | entity_id=entity_id, |
| 620 | data=dict( |
| 621 | max_gem_payload_size=max_gem_payload_size |
| 622 | ) |
| 623 | ) |
| 624 | ) |
| 625 | self.send_omci_message(frame) |
| 626 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 627 | def send_set_tcont(self, |
| 628 | entity_id, |
| 629 | alloc_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 630 | data = dict( |
| 631 | alloc_id=alloc_id |
| 632 | ) |
| 633 | frame = OmciFrame( |
| 634 | transaction_id=self.get_tx_id(), |
| 635 | message_type=OmciSet.message_id, |
| 636 | omci_message=OmciSet( |
| 637 | entity_class=Tcont.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 638 | entity_id=entity_id, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 639 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 640 | data=data |
| 641 | ) |
| 642 | ) |
| 643 | self.send_omci_message(frame) |
| 644 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 645 | def send_create_8021p_mapper_service_profile(self, |
| 646 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 647 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 648 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 649 | message_type=OmciCreate.message_id, |
| 650 | omci_message=OmciCreate( |
| 651 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 652 | entity_id=entity_id, |
| 653 | data=dict( |
| 654 | tp_pointer=OmciNullPointer, |
| 655 | interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer, |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 656 | interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer, |
| 657 | interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer, |
| 658 | interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer, |
| 659 | interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer, |
| 660 | interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer, |
| 661 | interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer, |
| 662 | interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 663 | ) |
| 664 | ) |
| 665 | ) |
| 666 | self.send_omci_message(frame) |
| 667 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 668 | def send_create_mac_bridge_service_profile(self, |
| 669 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 670 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 671 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 672 | message_type=OmciCreate.message_id, |
| 673 | omci_message=OmciCreate( |
| 674 | entity_class=MacBridgeServiceProfile.class_id, |
| 675 | entity_id=entity_id, |
| 676 | data=dict( |
| 677 | spanning_tree_ind=False, |
| 678 | learning_ind=True, |
| 679 | priority=0x8000, |
| 680 | max_age=20 * 256, |
| 681 | hello_time=2 * 256, |
| 682 | forward_delay=15 * 256, |
| 683 | unknown_mac_address_discard=True |
| 684 | ) |
| 685 | ) |
| 686 | ) |
| 687 | self.send_omci_message(frame) |
| 688 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 689 | def send_create_gem_port_network_ctp(self, |
| 690 | entity_id, |
| 691 | port_id, |
| 692 | tcont_id, |
| 693 | direction, |
| 694 | tm): |
| 695 | _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3} |
| 696 | if _directions.has_key(direction): |
| 697 | _direction = _directions[direction] |
| 698 | else: |
| 699 | self.log.error('invalid-gem-port-direction', direction=direction) |
| 700 | raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction)) |
| 701 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 702 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 703 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 704 | message_type=OmciCreate.message_id, |
| 705 | omci_message=OmciCreate( |
| 706 | entity_class=GemPortNetworkCtp.class_id, |
| 707 | entity_id=entity_id, |
| 708 | data=dict( |
| 709 | port_id=port_id, |
| 710 | tcont_pointer=tcont_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 711 | direction=_direction, |
| 712 | traffic_management_pointer_upstream=tm |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 713 | ) |
| 714 | ) |
| 715 | ) |
| 716 | self.send_omci_message(frame) |
| 717 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 718 | def send_create_multicast_gem_interworking_tp(self, |
| 719 | entity_id, |
| 720 | gem_port_net_ctp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 721 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 722 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 723 | message_type=OmciCreate.message_id, |
| 724 | omci_message=OmciCreate( |
| 725 | entity_class=MulticastGemInterworkingTp.class_id, |
| 726 | entity_id=entity_id, |
| 727 | data=dict( |
| 728 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 729 | interworking_option=0, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 730 | service_profile_pointer=0x1 |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 731 | ) |
| 732 | ) |
| 733 | ) |
| 734 | self.send_omci_message(frame) |
| 735 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 736 | def send_create_gem_inteworking_tp(self, |
| 737 | entity_id, |
| 738 | gem_port_net_ctp_id, |
| 739 | service_profile_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 740 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 741 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 742 | message_type=OmciCreate.message_id, |
| 743 | omci_message=OmciCreate( |
| 744 | entity_class=GemInterworkingTp.class_id, |
| 745 | entity_id=entity_id, |
| 746 | data=dict( |
| 747 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 748 | interworking_option=5, |
| 749 | service_profile_pointer=service_profile_id, |
| 750 | interworking_tp_pointer=0x0, |
| 751 | gal_profile_pointer=0x1 |
| 752 | ) |
| 753 | ) |
| 754 | ) |
| 755 | self.send_omci_message(frame) |
| 756 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 757 | def send_set_8021p_mapper_service_profile(self, |
| 758 | entity_id, |
| 759 | interwork_tp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 760 | data = dict( |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 761 | interwork_tp_pointer_for_p_bit_priority_0=interwork_tp_id, |
| 762 | interwork_tp_pointer_for_p_bit_priority_1=interwork_tp_id, |
| 763 | interwork_tp_pointer_for_p_bit_priority_2=interwork_tp_id, |
| 764 | interwork_tp_pointer_for_p_bit_priority_3=interwork_tp_id, |
| 765 | interwork_tp_pointer_for_p_bit_priority_4=interwork_tp_id, |
| 766 | interwork_tp_pointer_for_p_bit_priority_5=interwork_tp_id, |
| 767 | interwork_tp_pointer_for_p_bit_priority_6=interwork_tp_id, |
| 768 | interwork_tp_pointer_for_p_bit_priority_7=interwork_tp_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 769 | ) |
| 770 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 771 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 772 | message_type=OmciSet.message_id, |
| 773 | omci_message=OmciSet( |
| 774 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 775 | entity_id=entity_id, |
| 776 | attributes_mask=Ieee8021pMapperServiceProfile.mask_for( |
| 777 | *data.keys()), |
| 778 | data=data |
| 779 | ) |
| 780 | ) |
| 781 | self.send_omci_message(frame) |
| 782 | |
| 783 | def send_create_mac_bridge_port_configuration_data(self, |
| 784 | entity_id, |
| 785 | bridge_id, |
| 786 | port_id, |
| 787 | tp_type, |
| 788 | tp_id): |
| 789 | frame = OmciFrame( |
| 790 | transaction_id=self.get_tx_id(), |
| 791 | message_type=OmciCreate.message_id, |
| 792 | omci_message=OmciCreate( |
| 793 | entity_class=MacBridgePortConfigurationData.class_id, |
| 794 | entity_id=entity_id, |
| 795 | data=dict( |
| 796 | bridge_id_pointer = bridge_id, |
| 797 | port_num=port_id, |
| 798 | tp_type=tp_type, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 799 | tp_pointer=tp_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 800 | ) |
| 801 | ) |
| 802 | ) |
| 803 | self.send_omci_message(frame) |
| 804 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 805 | def send_create_vlan_tagging_filter_data(self, |
| 806 | entity_id, |
| 807 | vlan_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 808 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 809 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 810 | message_type=OmciCreate.message_id, |
| 811 | omci_message=OmciCreate( |
| 812 | entity_class=VlanTaggingFilterData.class_id, |
| 813 | entity_id=entity_id, |
| 814 | data=dict( |
| 815 | vlan_filter_0=vlan_id, |
| 816 | forward_operation=0x10, |
| 817 | number_of_entries=1 |
| 818 | ) |
| 819 | ) |
| 820 | ) |
| 821 | self.send_omci_message(frame) |
| 822 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 823 | def send_set_vlan_tagging_filter_data(self, |
| 824 | entity_id, |
| 825 | vlan_id): |
| 826 | data = dict( |
| 827 | vlan_filter_0=vlan_id, |
| 828 | forward_operation=0x10, |
| 829 | number_of_entries=1 |
| 830 | ) |
| 831 | |
| 832 | frame = OmciFrame( |
| 833 | transaction_id=self.get_tx_id(), |
| 834 | message_type=OmciSet.message_id, |
| 835 | omci_message=OmciSet( |
| 836 | entity_class=VlanTaggingFilterData.class_id, |
| 837 | entity_id=entity_id, |
| 838 | attributes_mask=VlanTaggingFilterData.mask_for( |
| 839 | *data.keys()), |
| 840 | data=data |
| 841 | ) |
| 842 | ) |
| 843 | self.send_omci_message(frame) |
| 844 | |
| 845 | def send_delete_vlan_tagging_filter_data(self, |
| 846 | entity_id): |
| 847 | frame = OmciFrame( |
| 848 | transaction_id=self.get_tx_id(), |
| 849 | message_type=OmciDelete.message_id, |
| 850 | omci_message=OmciDelete( |
| 851 | entity_class=VlanTaggingFilterData.class_id, |
| 852 | entity_id=entity_id |
| 853 | ) |
| 854 | ) |
| 855 | self.send_omci_message(frame) |
| 856 | |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 857 | def send_create_extended_vlan_tagging_operation_configuration_data(self, |
| 858 | entity_id, |
| 859 | assoc_type, |
| 860 | assoc_me): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 861 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 862 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 863 | message_type=OmciCreate.message_id, |
| 864 | omci_message=OmciCreate( |
| 865 | entity_class= |
| 866 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 867 | entity_id=entity_id, |
| 868 | data=dict( |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 869 | association_type=assoc_type, |
| 870 | associated_me_pointer=assoc_me |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 871 | ) |
| 872 | ) |
| 873 | ) |
| 874 | self.send_omci_message(frame) |
| 875 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 876 | def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, |
| 877 | entity_id, |
| 878 | input_tpid, |
| 879 | output_tpid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 880 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 881 | input_tpid=input_tpid, |
| 882 | output_tpid=output_tpid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 883 | downstream_mode=0, # inverse of upstream |
| 884 | ) |
| 885 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 886 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 887 | message_type=OmciSet.message_id, |
| 888 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 889 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 890 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 891 | entity_id=entity_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 892 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 893 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 894 | *data.keys()), |
| 895 | data=data |
| 896 | ) |
| 897 | ) |
| 898 | self.send_omci_message(frame) |
| 899 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 900 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self, |
| 901 | entity_id, |
| 902 | filter_inner_vid, |
| 903 | treatment_inner_vid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 904 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 905 | received_frame_vlan_tagging_operation_table= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 906 | VlanTaggingOperation( |
| 907 | filter_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 908 | filter_outer_vid=4096, |
| 909 | filter_outer_tpid_de=0, |
| 910 | |
| 911 | filter_inner_priority=15, |
| 912 | filter_inner_vid=filter_inner_vid, |
| 913 | filter_inner_tpid_de=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 914 | filter_ether_type=0, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 915 | |
| 916 | treatment_tags_to_remove=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 917 | treatment_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 918 | treatment_outer_vid=0, |
| 919 | treatment_outer_tpid_de=0, |
| 920 | |
| 921 | treatment_inner_priority=0, |
| 922 | treatment_inner_vid=treatment_inner_vid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 923 | treatment_inner_tpid_de=4 |
| 924 | ) |
| 925 | ) |
| 926 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 927 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 928 | message_type=OmciSet.message_id, |
| 929 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 930 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 931 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 932 | entity_id=entity_id, |
| 933 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 934 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 935 | *data.keys()), |
| 936 | data=data |
| 937 | ) |
| 938 | ) |
| 939 | self.send_omci_message(frame) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 940 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame] | 941 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self, |
| 942 | entity_id, |
| 943 | filter_inner_priority, |
| 944 | filter_inner_vid, |
| 945 | filter_inner_tpid_de, |
| 946 | treatment_tags_to_remove, |
| 947 | treatment_inner_priority, |
| 948 | treatment_inner_vid): |
| 949 | data = dict( |
| 950 | received_frame_vlan_tagging_operation_table= |
| 951 | VlanTaggingOperation( |
| 952 | filter_outer_priority=15, |
| 953 | filter_outer_vid=4096, |
| 954 | filter_outer_tpid_de=0, |
| 955 | |
| 956 | filter_inner_priority=filter_inner_priority, |
| 957 | filter_inner_vid=filter_inner_vid, |
| 958 | filter_inner_tpid_de=filter_inner_tpid_de, |
| 959 | filter_ether_type=0, |
| 960 | |
| 961 | treatment_tags_to_remove=treatment_tags_to_remove, |
| 962 | treatment_outer_priority=15, |
| 963 | treatment_outer_vid=0, |
| 964 | treatment_outer_tpid_de=0, |
| 965 | |
| 966 | treatment_inner_priority=treatment_inner_priority, |
| 967 | treatment_inner_vid=treatment_inner_vid, |
| 968 | treatment_inner_tpid_de=4 |
| 969 | ) |
| 970 | ) |
| 971 | frame = OmciFrame( |
| 972 | transaction_id=self.get_tx_id(), |
| 973 | message_type=OmciSet.message_id, |
| 974 | omci_message=OmciSet( |
| 975 | entity_class= |
| 976 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 977 | entity_id=entity_id, |
| 978 | attributes_mask= |
| 979 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 980 | *data.keys()), |
| 981 | data=data |
| 982 | ) |
| 983 | ) |
| 984 | self.send_omci_message(frame) |
| 985 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 986 | def send_create_multicast_operations_profile(self, |
| 987 | entity_id, |
| 988 | igmp_ver): |
| 989 | frame = OmciFrame( |
| 990 | transaction_id=self.get_tx_id(), |
| 991 | message_type=OmciCreate.message_id, |
| 992 | omci_message=OmciCreate( |
| 993 | entity_class= |
| 994 | MulticastOperationsProfile.class_id, |
| 995 | entity_id=entity_id, |
| 996 | data=dict( |
| 997 | igmp_version=igmp_ver, |
| 998 | igmp_function=0, |
| 999 | immediate_leave=0 |
| 1000 | ) |
| 1001 | ) |
| 1002 | ) |
| 1003 | self.send_omci_message(frame) |
| 1004 | |
| 1005 | def send_set_multicast_operations_profile_acl_row0(self, |
| 1006 | entity_id, |
| 1007 | acl_table, |
| 1008 | row_key, |
| 1009 | gem_port, |
| 1010 | vlan, |
| 1011 | src_ip, |
| 1012 | dst_ip_start, |
| 1013 | dst_ip_end): |
| 1014 | row0 = AccessControlRow0( |
| 1015 | set_ctrl=1, |
| 1016 | row_part_id=0, |
| 1017 | test=0, |
| 1018 | row_key=row_key, |
| 1019 | gem_port_id=gem_port, |
| 1020 | vlan_id=vlan, |
| 1021 | src_ip=src_ip, |
| 1022 | dst_ip_start=dst_ip_start, |
| 1023 | dst_ip_end=dst_ip_end, |
| 1024 | ipm_group_bw=0 |
| 1025 | ) |
| 1026 | |
| 1027 | if acl_table == 'dynamic': |
| 1028 | data = dict( |
| 1029 | dynamic_access_control_list_table=row0 |
| 1030 | ) |
| 1031 | else: |
| 1032 | data = dict( |
| 1033 | static_access_control_list_table=row0 |
| 1034 | ) |
| 1035 | |
| 1036 | frame = OmciFrame( |
| 1037 | transaction_id=self.get_tx_id(), |
| 1038 | message_type=OmciSet.message_id, |
| 1039 | omci_message=OmciSet( |
| 1040 | entity_class=MulticastOperationsProfile.class_id, |
| 1041 | entity_id=entity_id, |
| 1042 | attributes_mask=MulticastOperationsProfile.mask_for( |
| 1043 | *data.keys()), |
| 1044 | data=data |
| 1045 | ) |
| 1046 | ) |
| 1047 | self.send_omci_message(frame) |
| 1048 | |
| 1049 | def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self, |
| 1050 | entity_id, |
| 1051 | ctrl_type, |
| 1052 | tci): |
| 1053 | data = dict( |
| 1054 | ds_igmp_mcast_tci= |
| 1055 | DownstreamIgmpMulticastTci( |
| 1056 | ctrl_type=ctrl_type, |
| 1057 | tci=tci |
| 1058 | ) |
| 1059 | ) |
| 1060 | frame = OmciFrame( |
| 1061 | transaction_id=self.get_tx_id(), |
| 1062 | message_type=OmciSet.message_id, |
| 1063 | omci_message=OmciSet( |
| 1064 | entity_class=MulticastOperationsProfile.class_id, |
| 1065 | entity_id=entity_id, |
| 1066 | attributes_mask=MulticastOperationsProfile.mask_for( |
| 1067 | *data.keys()), |
| 1068 | data=data |
| 1069 | ) |
| 1070 | ) |
| 1071 | self.send_omci_message(frame) |
| 1072 | |
| 1073 | def send_create_multicast_subscriber_config_info(self, |
| 1074 | entity_id, |
| 1075 | me_type, |
| 1076 | mcast_oper_profile): |
| 1077 | frame = OmciFrame( |
| 1078 | transaction_id=self.get_tx_id(), |
| 1079 | message_type=OmciCreate.message_id, |
| 1080 | omci_message=OmciCreate( |
| 1081 | entity_class= |
| 1082 | MulticastSubscriberConfigInfo.class_id, |
| 1083 | entity_id=entity_id, |
| 1084 | data=dict( |
| 1085 | me_type=me_type, |
| 1086 | mcast_operations_profile_pointer=mcast_oper_profile |
| 1087 | ) |
| 1088 | ) |
| 1089 | ) |
| 1090 | self.send_omci_message(frame) |
| 1091 | |
| 1092 | def send_set_multicast_subscriber_config_info(self, |
| 1093 | entity_id, |
| 1094 | max_groups=0, |
| 1095 | max_mcast_bw=0, |
| 1096 | bw_enforcement=0): |
| 1097 | data = dict( |
| 1098 | max_simultaneous_groups=max_groups, |
| 1099 | max_multicast_bandwidth=max_mcast_bw, |
| 1100 | bandwidth_enforcement=bw_enforcement |
| 1101 | ) |
| 1102 | frame = OmciFrame( |
| 1103 | transaction_id=self.get_tx_id(), |
| 1104 | message_type=OmciSet.message_id, |
| 1105 | omci_message=OmciSet( |
| 1106 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1107 | entity_id=entity_id, |
| 1108 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1109 | *data.keys()), |
| 1110 | data=data |
| 1111 | ) |
| 1112 | ) |
| 1113 | self.send_omci_message(frame) |
| 1114 | |
| 1115 | def send_set_multicast_service_package(self, |
| 1116 | entity_id, |
| 1117 | row_key, |
| 1118 | vid_uni, |
| 1119 | max_groups, |
| 1120 | max_mcast_bw, |
| 1121 | mcast_oper_profile): |
| 1122 | data = dict( |
| 1123 | multicast_service_package_table= |
| 1124 | MulticastServicePackage( |
| 1125 | set_ctrl=1, |
| 1126 | row_key=row_key, |
| 1127 | |
| 1128 | vid_uni=vid_uni, |
| 1129 | max_simultaneous_groups=max_groups, |
| 1130 | max_multicast_bw=max_mcast_bw, |
| 1131 | mcast_operations_profile_pointer=mcast_oper_profile |
| 1132 | ) |
| 1133 | ) |
| 1134 | frame = OmciFrame( |
| 1135 | transaction_id=self.get_tx_id(), |
| 1136 | message_type=OmciSet.message_id, |
| 1137 | omci_message=OmciSet( |
| 1138 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1139 | entity_id=entity_id, |
| 1140 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1141 | *data.keys()), |
| 1142 | data=data |
| 1143 | ) |
| 1144 | ) |
| 1145 | self.send_omci_message(frame) |
| 1146 | |
| 1147 | def send_set_multicast_allowed_preview_groups_row0(self, |
| 1148 | entity_id, |
| 1149 | row_key, |
| 1150 | src_ip, |
| 1151 | vlan_id_ani, |
| 1152 | vlan_id_uni): |
| 1153 | data = dict( |
| 1154 | allowed_preview_groups_table= |
| 1155 | AllowedPreviewGroupsRow0( |
| 1156 | set_ctrl=1, |
| 1157 | row_part_id=0, |
| 1158 | row_key=row_key, |
| 1159 | |
| 1160 | src_ip=src_ip, |
| 1161 | vlan_id_ani=vlan_id_ani, |
| 1162 | vlan_id_uni=vlan_id_uni |
| 1163 | ) |
| 1164 | ) |
| 1165 | frame = OmciFrame( |
| 1166 | transaction_id=self.get_tx_id(), |
| 1167 | message_type=OmciSet.message_id, |
| 1168 | omci_message=OmciSet( |
| 1169 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1170 | entity_id=entity_id, |
| 1171 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1172 | *data.keys()), |
| 1173 | data=data |
| 1174 | ) |
| 1175 | ) |
| 1176 | self.send_omci_message(frame) |
| 1177 | |
| 1178 | def send_set_multicast_allowed_preview_groups_row1(self, |
| 1179 | entity_id, |
| 1180 | row_key, |
| 1181 | dst_ip, |
| 1182 | duration, |
| 1183 | time_left): |
| 1184 | data = dict( |
| 1185 | allowed_preview_groups_table= |
| 1186 | AllowedPreviewGroupsRow1( |
| 1187 | set_ctrl=1, |
| 1188 | row_part_id=1, |
| 1189 | row_key=row_key, |
| 1190 | |
| 1191 | dst_ip=dst_ip, |
| 1192 | duration=duration, |
| 1193 | time_left=time_left |
| 1194 | ) |
| 1195 | ) |
| 1196 | frame = OmciFrame( |
| 1197 | transaction_id=self.get_tx_id(), |
| 1198 | message_type=OmciSet.message_id, |
| 1199 | omci_message=OmciSet( |
| 1200 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 1201 | entity_id=entity_id, |
| 1202 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 1203 | *data.keys()), |
| 1204 | data=data |
| 1205 | ) |
| 1206 | ) |
| 1207 | self.send_omci_message(frame) |
| 1208 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1209 | @inlineCallbacks |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1210 | def wait_for_response(self): |
| 1211 | log.info('wait-for-response') |
| 1212 | try: |
| 1213 | response = yield self.incoming_messages.get() |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1214 | log.info('got-response') |
| 1215 | # resp = OmciFrame(response) |
| 1216 | # resp.show() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1217 | except Exception as e: |
| 1218 | self.log.info('wait-for-response-exception', exc=str(e)) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1219 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1220 | @inlineCallbacks |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1221 | def message_exchange(self, onu, gem, cvid): |
| 1222 | log.info('message_exchange', onu=onu, gem=gem, cvid=cvid) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1223 | # reset incoming message queue |
| 1224 | while self.incoming_messages.pending: |
| 1225 | _ = yield self.incoming_messages.get() |
| 1226 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1227 | cvid = BRDCM_DEFAULT_VLAN |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1228 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1229 | # construct message |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1230 | # MIB Reset - OntData - 0 |
| 1231 | self.send_mib_reset() |
| 1232 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1233 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1234 | # Create AR - GalEthernetProfile - 1 |
| 1235 | self.send_create_gal_ethernet_profile(1, 48) |
| 1236 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1237 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1238 | # Port 2 |
| 1239 | # Extended VLAN Tagging Operation config |
| 1240 | # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102(Uni-Port-Num) |
| 1241 | # TODO: add entry here for additional UNI interfaces |
| 1242 | self.send_create_extended_vlan_tagging_operation_configuration_data(0x202, 2, 0x102) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1243 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1244 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1245 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100 |
| 1246 | self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1247 | yield self.wait_for_response() |
| 1248 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1249 | # MAC Bridge Service config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1250 | # Create AR - MacBridgeServiceProfile - 513 |
| 1251 | self.send_create_mac_bridge_service_profile(0x201) |
| 1252 | yield self.wait_for_response() |
| 1253 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1254 | # Create AR - MacBridgePortConfigData - Entity_id - |
| 1255 | # bridge ID - |
| 1256 | # port num - |
| 1257 | # tp_type - |
| 1258 | # IEEE MApper poniter |
| 1259 | self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 2, 1, 0x102) |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1260 | yield self.wait_for_response() |
| 1261 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1262 | # Mapper Service config |
| 1263 | # Create AR - 802.1pMapperServiceProfile - 32769 |
| 1264 | self.send_create_8021p_mapper_service_profile(0x8001) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1265 | yield self.wait_for_response() |
| 1266 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1267 | # MAC Bridge Port config |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1268 | # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769 |
| 1269 | self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001) |
| 1270 | yield self.wait_for_response() |
| 1271 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1272 | # VLAN Tagging Filter config |
| 1273 | # Create AR - VlanTaggingFilterData - 8450 - c-vid |
| 1274 | self.send_create_vlan_tagging_filter_data(0x2102, cvid) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1275 | yield self.wait_for_response() |
| 1276 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1277 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1278 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
| 1279 | #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 8, 0, 0, 1, 8, cvid) |
| 1280 | #yield self.wait_for_response() |
| 1281 | |
| 1282 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1283 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid |
| 1284 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, cvid) |
| 1285 | yield self.wait_for_response() |
| 1286 | |
| 1287 | # Multicast related MEs |
| 1288 | # Set AR - MulticastOperationsProfile - Dynamic Access Control List table |
| 1289 | # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6 |
| 1290 | self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6) |
| 1291 | yield self.wait_for_response() |
| 1292 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1293 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1294 | # Create AR - MulticastOperationsProfile |
| 1295 | self.send_create_multicast_operations_profile(0x201, 3) |
| 1296 | yield self.wait_for_response() |
| 1297 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1298 | # Multicast Subscriber config |
| 1299 | # Create AR - MulticastSubscriberConfigInfo |
| 1300 | self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201) |
| 1301 | yield self.wait_for_response() |
| 1302 | |
| 1303 | # Create AR - GemPortNetworkCtp - 260 - 4000 - 0 Multicast |
| 1304 | self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0) |
| 1305 | yield self.wait_for_response() |
| 1306 | |
| 1307 | # Multicast GEM Interworking config Multicast |
| 1308 | # Create AR - MulticastGemInterworkingTp - 6 - 260 |
| 1309 | self.send_create_multicast_gem_interworking_tp(0x6, 0x104) |
| 1310 | yield self.wait_for_response() |
| 1311 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1312 | self.send_set_multicast_operations_profile_acl_row0(0x201, |
| 1313 | 'dynamic', |
| 1314 | 0, |
| 1315 | 0x0fa0, |
| 1316 | 0x0fa0, |
| 1317 | '0.0.0.0', |
| 1318 | '224.0.0.0', |
| 1319 | '239.255.255.255') |
| 1320 | yield self.wait_for_response() |
| 1321 | |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1322 | # Multicast Operation Profile config |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1323 | # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1324 | 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] | 1325 | yield self.wait_for_response() |
| 1326 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1327 | ''' |
Steve Crooks | 9b160d7 | 2017-03-31 10:48:29 -0500 | [diff] [blame] | 1328 | # Port 5 |
| 1329 | # Extended VLAN Tagging Operation config |
| 1330 | # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x102 |
| 1331 | # TODO: add entry here for additional UNI interfaces |
| 1332 | self.send_create_extended_vlan_tagging_operation_configuration_data(0x205, 2, 0x105) |
| 1333 | yield self.wait_for_response() |
| 1334 | |
| 1335 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100 |
| 1336 | self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x205, 0x8100, 0x8100) |
| 1337 | yield self.wait_for_response() |
| 1338 | |
| 1339 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1340 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to priority tagged pkts - c-vid |
| 1341 | #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x205, 8, 0, 0, 1, 8, cvid) |
| 1342 | #yield self.wait_for_response() |
| 1343 | |
| 1344 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1345 | # 514 - RxVlanTaggingOperationTable - add VLAN <cvid> to untagged pkts - c-vid |
| 1346 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x205, 0x1000, cvid) |
| 1347 | yield self.wait_for_response() |
| 1348 | |
| 1349 | # MAC Bridge Port config |
| 1350 | # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x102 |
| 1351 | # TODO: add more entries here for other UNI ports |
| 1352 | self.send_create_mac_bridge_port_configuration_data(0x205, 0x201, 5, 1, 0x105) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1353 | yield self.wait_for_response() |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1354 | ''' |
| 1355 | |
| 1356 | def add_uni_port(self, device, parent_logical_device_id, |
| 1357 | name, parent_port_num=None): |
| 1358 | self.log.info('adding-logical-port', device_id=device.id, |
| 1359 | logical_device_id=parent_logical_device_id, |
| 1360 | name=name) |
| 1361 | if parent_port_num is not None: |
| 1362 | uni = parent_port_num |
| 1363 | port_no = parent_port_num |
| 1364 | else: |
| 1365 | uni = self.uni_ports[0] |
| 1366 | port_no = device.proxy_address.channel_id + uni |
| 1367 | # register physical ports |
| 1368 | uni_port = Port( |
| 1369 | port_no=uni, |
| 1370 | label='UNI facing Ethernet port '+str(uni), |
| 1371 | type=Port.ETHERNET_UNI, |
| 1372 | admin_state=AdminState.ENABLED, |
| 1373 | oper_status=OperStatus.ACTIVE |
| 1374 | ) |
| 1375 | self.adapter_agent.add_port(device.id, uni_port) |
| 1376 | # add uni port to logical device |
| 1377 | cap = OFPPF_1GB_FD | OFPPF_FIBER |
| 1378 | self.adapter_agent.add_logical_port(parent_logical_device_id, |
| 1379 | LogicalPort( |
| 1380 | id='uni-{}'.format(port_no), |
| 1381 | ofp_port=ofp_port( |
| 1382 | port_no=port_no, |
| 1383 | hw_addr=mac_str_to_tuple('00:00:00:%02x:%02x:%02x' % |
| 1384 | (device.proxy_address.onu_id & 0xff, |
| 1385 | (port_no >> 8) & 0xff, |
| 1386 | port_no & 0xff)), |
| 1387 | #name='uni-{}'.format(port_no), |
| 1388 | name=name, |
| 1389 | config=0, |
| 1390 | state=OFPPS_LIVE, |
| 1391 | curr=cap, |
| 1392 | advertised=cap, |
| 1393 | peer=cap, |
| 1394 | curr_speed=OFPPF_1GB_FD, |
| 1395 | max_speed=OFPPF_1GB_FD |
| 1396 | ), |
| 1397 | device_id=device.id, |
| 1398 | device_port_no=uni_port.port_no |
| 1399 | )) |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1400 | |
| 1401 | def create_interface(self, data): |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1402 | if isinstance(data, VEnetConfig): |
| 1403 | parent_port_num = None |
| 1404 | onu_device = self.adapter_agent.get_device(self.device_id) |
| 1405 | ports = self.adapter_agent.get_ports(onu_device.parent_id, Port.ETHERNET_UNI) |
| 1406 | parent_port_num = None |
| 1407 | for port in ports: |
| 1408 | if port.label == data.interface.name: |
| 1409 | parent_port_num = port.port_no |
| 1410 | break |
| 1411 | |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1412 | parent_device = self.adapter_agent.get_device(onu_device.parent_id) |
| 1413 | logical_device_id = parent_device.parent_id |
| 1414 | assert logical_device_id |
| 1415 | self.add_uni_port(onu_device, logical_device_id, |
| 1416 | data.name, parent_port_num) |
| 1417 | |
| 1418 | if parent_port_num is None: |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1419 | self.log.error("matching-parent-uni-port-num-not-found") |
| 1420 | return |
| 1421 | |
| 1422 | onu_ports = self.adapter_agent.get_ports(self.device_id, Port.PON_ONU) |
| 1423 | if onu_ports: |
| 1424 | # To-Do : |
| 1425 | # Assumed only one PON port and UNI port per ONU. |
| 1426 | pon_port = onu_ports[0] |
| 1427 | else: |
| 1428 | self.log.error("No-Pon-port-configured-yet") |
| 1429 | return |
| 1430 | |
| 1431 | self.adapter_agent.delete_port_reference_from_parent(self.device_id, |
| 1432 | pon_port) |
| 1433 | |
| 1434 | pon_port.peers[0].device_id = onu_device.parent_id |
| 1435 | pon_port.peers[0].port_no = parent_port_num |
| 1436 | self.adapter_agent.add_port_reference_to_parent(self.device_id, |
| 1437 | pon_port) |
| 1438 | else: |
| 1439 | self.log.info('Not handled Yet') |
| 1440 | return |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1441 | |
| 1442 | def update_interface(self, data): |
| 1443 | self.log.info('Not Implemented yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1444 | return |
rshetty | c26a3c3 | 2017-07-27 11:06:38 +0530 | [diff] [blame] | 1445 | |
| 1446 | def remove_interface(self, data): |
| 1447 | self.log.info('Not Implemented yet') |
rshetty | 1cc7398 | 2017-09-02 03:31:12 +0530 | [diff] [blame] | 1448 | return |
rshetty | f4bf19e | 2017-09-19 01:28:27 +0530 | [diff] [blame] | 1449 | |
| 1450 | @inlineCallbacks |
| 1451 | def create_gemport(self, data): |
| 1452 | log.info('create-gemport') |
| 1453 | gem_port= GemportsConfigData() |
| 1454 | gem_port.CopyFrom(data) |
| 1455 | if gem_port.tcont_ref is None: |
| 1456 | self.log.info('Recevied NULL Gem Port Data') |
| 1457 | else: |
| 1458 | #To-Do Need to see how the valuse 0x8001 is derived |
| 1459 | self.send_create_gem_port_network_ctp(gem_port.gemport_id, |
| 1460 | gem_port.gemport_id, 0x8001, |
| 1461 | "bi-directional", 0x100) |
| 1462 | yield self.wait_for_response() |
| 1463 | |
| 1464 | # GEM Interworking config |
| 1465 | # Create AR - GemInterworkingTp - Gem_port,TP_pointer - |
| 1466 | # Gem port CTP pointer - |
| 1467 | # Mapper service profile id |
| 1468 | self.send_create_gem_inteworking_tp(gem_port.gemport_id, |
| 1469 | gem_port.gemport_id, 0x8001) |
| 1470 | yield self.wait_for_response() |
| 1471 | |
| 1472 | # Mapper Service Profile config |
| 1473 | # Set AR - 802.1pMapperServiceProfile - Mapper_ profile_id - |
| 1474 | # gem_port_tp pointer |
| 1475 | self.send_set_8021p_mapper_service_profile(0x8001, |
| 1476 | gem_port.gemport_id) |
| 1477 | yield self.wait_for_response() |
| 1478 | |
| 1479 | |
| 1480 | @inlineCallbacks |
| 1481 | def create_tcont(self, tcont_data, traffic_descriptor_data): |
| 1482 | log.info('create-tcont') |
| 1483 | tcont = TcontsConfigData() |
| 1484 | tcont.CopyFrom(tcont_data) |
| 1485 | if (tcont.interface_reference is not None): |
| 1486 | self.log.info('tcont created is', tcont= tcont.alloc_id) |
| 1487 | self.send_set_tcont(0x8001, tcont.alloc_id) |
| 1488 | yield self.wait_for_response() |
| 1489 | else: |
| 1490 | self.log.info('Recevied NULL tcont Data', tcont= tcont.alloc_id) |
| 1491 | |
| 1492 | def create_multicast_gemport(self, data): |
| 1493 | self.log.info('Send relevant OMCI message') |