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 |
| 23 | from twisted.internet import reactor |
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 | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 29 | from voltha.protos import third_party |
| 30 | from voltha.protos.adapter_pb2 import Adapter |
| 31 | from voltha.protos.adapter_pb2 import AdapterConfig |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 32 | from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \ |
| 33 | AdminState |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 34 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port |
| 35 | from voltha.protos.health_pb2 import HealthStatus |
| 36 | from voltha.protos.logical_device_pb2 import LogicalPort |
| 37 | from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD |
| 38 | from voltha.protos.openflow_13_pb2 import ofp_port |
| 39 | from common.frameio.frameio import hexify |
| 40 | from voltha.extensions.omci.omci import * |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 41 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 42 | _ = third_party |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 43 | log = structlog.get_logger() |
| 44 | |
| 45 | |
| 46 | @implementer(IAdapterInterface) |
| 47 | class BroadcomOnuAdapter(object): |
| 48 | |
| 49 | name = 'broadcom_onu' |
| 50 | |
| 51 | supported_device_types = [ |
| 52 | DeviceType( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 53 | id=name, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 54 | adapter=name, |
| 55 | accepts_bulk_flow_update=True |
| 56 | ) |
| 57 | ] |
| 58 | |
| 59 | def __init__(self, adapter_agent, config): |
| 60 | self.adapter_agent = adapter_agent |
| 61 | self.config = config |
| 62 | self.descriptor = Adapter( |
| 63 | id=self.name, |
| 64 | vendor='Voltha project', |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 65 | version='0.4', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 66 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 67 | ) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 68 | self.devices_handlers = dict() # device_id -> BroadcomOnuHandler() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 69 | |
| 70 | def start(self): |
| 71 | log.debug('starting') |
| 72 | log.info('started') |
| 73 | |
| 74 | def stop(self): |
| 75 | log.debug('stopping') |
| 76 | log.info('stopped') |
| 77 | |
| 78 | def adapter_descriptor(self): |
| 79 | return self.descriptor |
| 80 | |
| 81 | def device_types(self): |
| 82 | return DeviceTypes(items=self.supported_device_types) |
| 83 | |
| 84 | def health(self): |
| 85 | return HealthStatus(state=HealthStatus.HealthState.HEALTHY) |
| 86 | |
| 87 | def change_master_state(self, master): |
| 88 | raise NotImplementedError() |
| 89 | |
| 90 | def adopt_device(self, device): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 91 | log.info('adopt_device', device_id=device.id) |
| 92 | self.devices_handlers[device.proxy_address.channel_id] = BroadcomOnuHandler(self, device.id) |
| 93 | reactor.callLater(0, self.devices_handlers[device.proxy_address.channel_id].activate, device) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 94 | return device |
| 95 | |
| 96 | def abandon_device(self, device): |
| 97 | raise NotImplementedError() |
| 98 | |
| 99 | def deactivate_device(self, device): |
| 100 | raise NotImplementedError() |
| 101 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 102 | def update_flows_bulk(self, device, flows, groups): |
| 103 | log.info('bulk-flow-update', device_id=device.id, |
| 104 | flows=flows, groups=groups) |
| 105 | assert len(groups.items) == 0 |
| 106 | handler = self.devices_handlers[device.proxy_address.channel_id] |
| 107 | return handler.update_flow_table(flows.items) |
| 108 | |
| 109 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 110 | raise NotImplementedError() |
| 111 | |
| 112 | def send_proxied_message(self, proxy_address, msg): |
| 113 | log.info('send-proxied-message', proxy_address=proxy_address, msg=msg) |
| 114 | |
| 115 | def receive_proxied_message(self, proxy_address, msg): |
| 116 | log.info('receive-proxied-message', proxy_address=proxy_address, |
| 117 | device_id=proxy_address.device_id, msg=hexify(msg)) |
| 118 | handler = self.devices_handlers[proxy_address.channel_id] |
| 119 | handler.receive_message(msg) |
| 120 | |
| 121 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 122 | log.info('packet-out', logical_device_id=logical_device_id, |
| 123 | egress_port_no=egress_port_no, msg_len=len(msg)) |
| 124 | |
| 125 | |
| 126 | class BroadcomOnuHandler(object): |
| 127 | |
| 128 | def __init__(self, adapter, device_id): |
| 129 | self.adapter = adapter |
| 130 | self.adapter_agent = adapter.adapter_agent |
| 131 | self.device_id = device_id |
| 132 | self.log = structlog.get_logger(device_id=device_id) |
| 133 | self.incoming_messages = DeferredQueue() |
| 134 | self.proxy_address = None |
| 135 | self.tx_id = 0 |
| 136 | |
| 137 | def receive_message(self, msg): |
| 138 | self.incoming_messages.put(msg) |
| 139 | |
| 140 | def activate(self, device): |
| 141 | self.log.info('activating') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 142 | |
| 143 | # first we verify that we got parent reference and proxy info |
| 144 | assert device.parent_id |
| 145 | assert device.proxy_address.device_id |
| 146 | assert device.proxy_address.channel_id |
| 147 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 148 | # register for proxied messages right away |
| 149 | self.proxy_address = device.proxy_address |
| 150 | self.adapter_agent.register_for_proxied_messages(device.proxy_address) |
| 151 | |
| 152 | # populate device info |
| 153 | device.root = True |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 154 | device.vendor = 'Broadcom' |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 155 | device.model ='n/a' |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 156 | device.hardware_version = 'to be filled' |
| 157 | device.firmware_version = 'to be filled' |
| 158 | device.software_version = 'to be filled' |
| 159 | device.serial_number = uuid4().hex |
| 160 | device.connect_status = ConnectStatus.REACHABLE |
| 161 | self.adapter_agent.update_device(device) |
| 162 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 163 | # register physical ports |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 164 | uni_port = Port( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 165 | port_no=2, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 166 | label='UNI facing Ethernet port', |
| 167 | type=Port.ETHERNET_UNI, |
| 168 | admin_state=AdminState.ENABLED, |
| 169 | oper_status=OperStatus.ACTIVE |
| 170 | ) |
| 171 | self.adapter_agent.add_port(device.id, uni_port) |
| 172 | self.adapter_agent.add_port(device.id, Port( |
| 173 | port_no=1, |
| 174 | label='PON port', |
| 175 | type=Port.PON_ONU, |
| 176 | admin_state=AdminState.ENABLED, |
| 177 | oper_status=OperStatus.ACTIVE, |
| 178 | peers=[ |
| 179 | Port.PeerPort( |
| 180 | device_id=device.parent_id, |
| 181 | port_no=device.parent_port_no |
| 182 | ) |
| 183 | ] |
| 184 | )) |
| 185 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 186 | # add uni port to logical device |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 187 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 188 | logical_device_id = parent_device.parent_id |
| 189 | assert logical_device_id |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 190 | port_no = device.proxy_address.channel_id |
| 191 | cap = OFPPF_1GB_FD | OFPPF_FIBER |
| 192 | self.adapter_agent.add_logical_port(logical_device_id, LogicalPort( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 193 | id='uni-{}'.format(port_no), |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 194 | ofp_port=ofp_port( |
| 195 | port_no=port_no, |
| 196 | hw_addr=mac_str_to_tuple('00:00:00:00:00:%02x' % port_no), |
| 197 | name='uni-{}'.format(port_no), |
| 198 | config=0, |
| 199 | state=OFPPS_LIVE, |
| 200 | curr=cap, |
| 201 | advertised=cap, |
| 202 | peer=cap, |
| 203 | curr_speed=OFPPF_1GB_FD, |
| 204 | max_speed=OFPPF_1GB_FD |
| 205 | ), |
| 206 | device_id=device.id, |
| 207 | device_port_no=uni_port.port_no |
| 208 | )) |
| 209 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 210 | reactor.callLater(5, self.message_exchange) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 211 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 212 | device = self.adapter_agent.get_device(device.id) |
| 213 | device.oper_status = OperStatus.ACTIVE |
| 214 | self.adapter_agent.update_device(device) |
| 215 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 216 | @inlineCallbacks |
| 217 | def update_flow_table(self, flows): |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 218 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 219 | # we need to proxy through the OLT to get to the ONU |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 220 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 221 | # reset response queue |
| 222 | while self.incoming_messages.pending: |
| 223 | yield self.incoming_messages.get() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 224 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 225 | msg = FlowTable( |
| 226 | port=self.proxy_address.channel_id, |
| 227 | flows=flows |
| 228 | ) |
| 229 | self.adapter_agent.send_proxied_message(self.proxy_address, msg) |
| 230 | |
| 231 | yield self.incoming_messages.get() |
| 232 | |
| 233 | def get_tx_id(self): |
| 234 | self.tx_id += 1 |
| 235 | return self.tx_id |
| 236 | |
| 237 | def send_omci_message(self, frame): |
| 238 | _frame = hexify(str(frame)) |
| 239 | self.log.info('send-omci-message-%s' % _frame) |
| 240 | device = self.adapter_agent.get_device(self.device_id) |
| 241 | try: |
| 242 | self.adapter_agent.send_proxied_message(device.proxy_address, _frame) |
| 243 | except Exception as e: |
| 244 | self.log.info('send-omci-message-exception', exc=str(e)) |
| 245 | |
| 246 | def send_get_circuit_pack(self, entity_id=0): |
| 247 | frame = OmciFrame( |
| 248 | transaction_id=self.get_tx_id(), |
| 249 | message_type=OmciGet.message_id, |
| 250 | omci_message=OmciGet( |
| 251 | entity_class=CircuitPack.class_id, |
| 252 | entity_id=entity_id, |
| 253 | attributes_mask=CircuitPack.mask_for('vendor_id') |
| 254 | ) |
| 255 | ) |
| 256 | self.send_omci_message(frame) |
| 257 | |
| 258 | def send_mib_reset(self, entity_id=0): |
| 259 | frame = OmciFrame( |
| 260 | transaction_id=self.get_tx_id(), |
| 261 | message_type=OmciMibReset.message_id, |
| 262 | omci_message=OmciMibReset( |
| 263 | entity_class=OntData.class_id, |
| 264 | entity_id=entity_id |
| 265 | ) |
| 266 | ) |
| 267 | self.send_omci_message(frame) |
| 268 | |
| 269 | def send_create_gal_ethernet_profile(self, entity_id, max_gem_payload_size): |
| 270 | frame = OmciFrame( |
| 271 | transaction_id=self.get_tx_id(), |
| 272 | message_type=OmciCreate.message_id, |
| 273 | omci_message=OmciCreate( |
| 274 | entity_class=GalEthernetProfile.class_id, |
| 275 | entity_id=entity_id, |
| 276 | data=dict( |
| 277 | max_gem_payload_size=max_gem_payload_size |
| 278 | ) |
| 279 | ) |
| 280 | ) |
| 281 | self.send_omci_message(frame) |
| 282 | |
| 283 | def send_set_tcont(self, entity_id, alloc_id): |
| 284 | data = dict( |
| 285 | alloc_id=alloc_id |
| 286 | ) |
| 287 | frame = OmciFrame( |
| 288 | transaction_id=self.get_tx_id(), |
| 289 | message_type=OmciSet.message_id, |
| 290 | omci_message=OmciSet( |
| 291 | entity_class=Tcont.class_id, |
| 292 | entity_id = entity_id, |
| 293 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 294 | data=data |
| 295 | ) |
| 296 | ) |
| 297 | self.send_omci_message(frame) |
| 298 | |
| 299 | def send_create_8021p_mapper_service_profile(self, entity_id): |
| 300 | frame = OmciFrame( |
| 301 | transaction_id = self.get_tx_id(), |
| 302 | message_type=OmciCreate.message_id, |
| 303 | omci_message=OmciCreate( |
| 304 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 305 | entity_id=entity_id, |
| 306 | data=dict( |
| 307 | tp_pointer=OmciNullPointer, |
| 308 | interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer, |
| 309 | ) |
| 310 | ) |
| 311 | ) |
| 312 | self.send_omci_message(frame) |
| 313 | |
| 314 | def send_create_mac_bridge_service_profile(self, entity_id): |
| 315 | frame = OmciFrame( |
| 316 | transaction_id = self.get_tx_id(), |
| 317 | message_type=OmciCreate.message_id, |
| 318 | omci_message=OmciCreate( |
| 319 | entity_class=MacBridgeServiceProfile.class_id, |
| 320 | entity_id=entity_id, |
| 321 | data=dict( |
| 322 | spanning_tree_ind=False, |
| 323 | learning_ind=True, |
| 324 | priority=0x8000, |
| 325 | max_age=20 * 256, |
| 326 | hello_time=2 * 256, |
| 327 | forward_delay=15 * 256, |
| 328 | unknown_mac_address_discard=True |
| 329 | ) |
| 330 | ) |
| 331 | ) |
| 332 | self.send_omci_message(frame) |
| 333 | |
| 334 | def send_create_gem_port_network_ctp(self, entity_id, port_id, tcont_id): |
| 335 | frame = OmciFrame( |
| 336 | transaction_id = self.get_tx_id(), |
| 337 | message_type=OmciCreate.message_id, |
| 338 | omci_message=OmciCreate( |
| 339 | entity_class=GemPortNetworkCtp.class_id, |
| 340 | entity_id=entity_id, |
| 341 | data=dict( |
| 342 | port_id=port_id, |
| 343 | tcont_pointer=tcont_id, |
| 344 | direction=3, |
| 345 | traffic_management_pointer_upstream=0x100 |
| 346 | ) |
| 347 | ) |
| 348 | ) |
| 349 | self.send_omci_message(frame) |
| 350 | |
| 351 | def send_create_multicast_gem_interworking_tp(self, entity_id, gem_port_net_ctp_id): |
| 352 | frame = OmciFrame( |
| 353 | transaction_id = self.get_tx_id(), |
| 354 | message_type=OmciCreate.message_id, |
| 355 | omci_message=OmciCreate( |
| 356 | entity_class=MulticastGemInterworkingTp.class_id, |
| 357 | entity_id=entity_id, |
| 358 | data=dict( |
| 359 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 360 | interworking_option=0, |
| 361 | service_profile_pointer=0x1, |
| 362 | ) |
| 363 | ) |
| 364 | ) |
| 365 | self.send_omci_message(frame) |
| 366 | |
| 367 | def send_create_gem_inteworking_tp(self, entity_id, gem_port_net_ctp_id, service_profile_id): |
| 368 | frame = OmciFrame( |
| 369 | transaction_id = self.get_tx_id(), |
| 370 | message_type=OmciCreate.message_id, |
| 371 | omci_message=OmciCreate( |
| 372 | entity_class=GemInterworkingTp.class_id, |
| 373 | entity_id=entity_id, |
| 374 | data=dict( |
| 375 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 376 | interworking_option=5, |
| 377 | service_profile_pointer=service_profile_id, |
| 378 | interworking_tp_pointer=0x0, |
| 379 | gal_profile_pointer=0x1 |
| 380 | ) |
| 381 | ) |
| 382 | ) |
| 383 | self.send_omci_message(frame) |
| 384 | |
| 385 | def send_set_8021p_mapper_service_profile(self, entity_id, interwork_tp_id): |
| 386 | data = dict( |
| 387 | interwork_tp_pointer_for_p_bit_priority_0 = interwork_tp_id |
| 388 | ) |
| 389 | frame = OmciFrame( |
| 390 | transaction_id = self.get_tx_id(), |
| 391 | message_type=OmciSet.message_id, |
| 392 | omci_message=OmciSet( |
| 393 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 394 | entity_id=entity_id, |
| 395 | attributes_mask=Ieee8021pMapperServiceProfile.mask_for( |
| 396 | *data.keys()), |
| 397 | data=data |
| 398 | ) |
| 399 | ) |
| 400 | self.send_omci_message(frame) |
| 401 | |
| 402 | def send_create_mac_bridge_port_configuration_data(self, |
| 403 | entity_id, |
| 404 | bridge_id, |
| 405 | port_id, |
| 406 | tp_type, |
| 407 | tp_id): |
| 408 | frame = OmciFrame( |
| 409 | transaction_id=self.get_tx_id(), |
| 410 | message_type=OmciCreate.message_id, |
| 411 | omci_message=OmciCreate( |
| 412 | entity_class=MacBridgePortConfigurationData.class_id, |
| 413 | entity_id=entity_id, |
| 414 | data=dict( |
| 415 | bridge_id_pointer = bridge_id, |
| 416 | port_num=port_id, |
| 417 | tp_type=tp_type, |
| 418 | tp_pointer = tp_id |
| 419 | ) |
| 420 | ) |
| 421 | ) |
| 422 | self.send_omci_message(frame) |
| 423 | |
| 424 | def send_create_vlan_tagging_filter_data(self, entity_id, vlan_id): |
| 425 | frame = OmciFrame( |
| 426 | transaction_id = self.get_tx_id(), |
| 427 | message_type=OmciCreate.message_id, |
| 428 | omci_message=OmciCreate( |
| 429 | entity_class=VlanTaggingFilterData.class_id, |
| 430 | entity_id=entity_id, |
| 431 | data=dict( |
| 432 | vlan_filter_0=vlan_id, |
| 433 | forward_operation=0x10, |
| 434 | number_of_entries=1 |
| 435 | ) |
| 436 | ) |
| 437 | ) |
| 438 | self.send_omci_message(frame) |
| 439 | |
| 440 | def send_create_extended_vlan_tagging_operation_configuration_data(self, entity_id): |
| 441 | frame = OmciFrame( |
| 442 | transaction_id = self.get_tx_id(), |
| 443 | message_type=OmciCreate.message_id, |
| 444 | omci_message=OmciCreate( |
| 445 | entity_class= |
| 446 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 447 | entity_id=entity_id, |
| 448 | data=dict( |
| 449 | association_type=10, |
| 450 | associated_me_pointer=0x401 |
| 451 | ) |
| 452 | ) |
| 453 | ) |
| 454 | self.send_omci_message(frame) |
| 455 | |
| 456 | def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, entity_id, input_tpid, output_tpid): |
| 457 | data = dict( |
| 458 | input_tpid = input_tpid, |
| 459 | output_tpid = output_tpid, |
| 460 | downstream_mode=0, # inverse of upstream |
| 461 | ) |
| 462 | frame = OmciFrame( |
| 463 | transaction_id = self.get_tx_id(), |
| 464 | message_type=OmciSet.message_id, |
| 465 | omci_message=OmciSet( |
| 466 | entity_class=\ |
| 467 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 468 | entity_id=entity_id, |
| 469 | attributes_mask= \ |
| 470 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 471 | *data.keys()), |
| 472 | data=data |
| 473 | ) |
| 474 | ) |
| 475 | self.send_omci_message(frame) |
| 476 | |
| 477 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self, |
| 478 | entity_id, |
| 479 | filter_inner_vid, |
| 480 | treatment_inner_vid): |
| 481 | data = dict( |
| 482 | received_frame_vlan_tagging_operation_table=\ |
| 483 | VlanTaggingOperation( |
| 484 | filter_outer_priority=15, |
| 485 | filter_inner_priority=8, |
| 486 | filter_inner_vid = filter_inner_vid, |
| 487 | filter_inner_tpid_de=5, |
| 488 | filter_ether_type=0, |
| 489 | treatment_tags_to_remove=1, |
| 490 | pad3=2, |
| 491 | treatment_outer_priority=15, |
| 492 | treatment_inner_priority=8, |
| 493 | treatment_inner_vid = treatment_inner_vid, |
| 494 | treatment_inner_tpid_de=4 |
| 495 | ) |
| 496 | ) |
| 497 | frame = OmciFrame( |
| 498 | transaction_id = self.get_tx_id(), |
| 499 | message_type=OmciSet.message_id, |
| 500 | omci_message=OmciSet( |
| 501 | entity_class=\ |
| 502 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 503 | entity_id = entity_id, |
| 504 | attributes_mask= \ |
| 505 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 506 | *data.keys()), |
| 507 | data=data |
| 508 | ) |
| 509 | ) |
| 510 | self.send_omci_message(frame) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 511 | |
| 512 | @inlineCallbacks |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 513 | def wait_for_response(self): |
| 514 | log.info('wait-for-response') |
| 515 | try: |
| 516 | response = yield self.incoming_messages.get() |
| 517 | resp = OmciFrame(response) |
| 518 | resp.show() |
| 519 | except Exception as e: |
| 520 | self.log.info('wait-for-response-exception', exc=str(e)) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 521 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 522 | @inlineCallbacks |
| 523 | def message_exchange(self): |
| 524 | log.info('message_exchange') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 525 | # reset incoming message queue |
| 526 | while self.incoming_messages.pending: |
| 527 | _ = yield self.incoming_messages.get() |
| 528 | |
| 529 | # construct message |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 530 | # MIB Reset - OntData - 0 |
| 531 | self.send_mib_reset() |
| 532 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 533 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 534 | # Create AR - GalEthernetProfile - 1 |
| 535 | self.send_create_gal_ethernet_profile(1, 48) |
| 536 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 537 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 538 | # Set AR - TCont - 32768 - 1024 |
| 539 | self.send_set_tcont(0x8000, 0x400) |
| 540 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 541 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 542 | # Set AR - TCont - 32769 - 1025 |
| 543 | self.send_set_tcont(0x8001, 0x401) |
| 544 | yield self.wait_for_response() |
Zsolt Haraszti | 656ecc6 | 2016-12-28 15:08:23 -0800 | [diff] [blame] | 545 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 546 | # Set AR - TCont - 32770 - 1026 |
| 547 | self.send_set_tcont(0x8002, 0x402) |
| 548 | yield self.wait_for_response() |
| 549 | |
| 550 | # Set AR - TCont - 32771 - 1027 |
| 551 | self.send_set_tcont(0x8003, 0x403) |
| 552 | yield self.wait_for_response() |
| 553 | |
| 554 | # Create AR - 802.1pMapperServiceProfile - 32768 |
| 555 | self.send_create_8021p_mapper_service_profile(0x8000) |
| 556 | yield self.wait_for_response() |
| 557 | |
| 558 | # Create AR - 802.1pMapperServiceProfile - 32769 |
| 559 | self.send_create_8021p_mapper_service_profile(0x8001) |
| 560 | yield self.wait_for_response() |
| 561 | |
| 562 | # Create AR - 802.1pMapperServiceProfile - 32770 |
| 563 | self.send_create_8021p_mapper_service_profile(0x8002) |
| 564 | yield self.wait_for_response() |
| 565 | |
| 566 | # Create AR - 802.1pMapperServiceProfile - 32771 |
| 567 | self.send_create_8021p_mapper_service_profile(0x8003) |
| 568 | yield self.wait_for_response() |
| 569 | |
| 570 | # Create AR - MacBridgeServiceProfile - 513 |
| 571 | self.send_create_mac_bridge_service_profile(0x201) |
| 572 | yield self.wait_for_response() |
| 573 | |
| 574 | # Create AR - GemPortNetworkCtp - 256 - 1024 - 32768 |
| 575 | self.send_create_gem_port_network_ctp(0x100, 0x400, 0x8000) |
| 576 | yield self.wait_for_response() |
| 577 | |
| 578 | # Create AR - GemPortNetworkCtp - 257 - 1025 - 32769 |
| 579 | self.send_create_gem_port_network_ctp(0x101, 0x401, 0x8001) |
| 580 | yield self.wait_for_response() |
| 581 | |
| 582 | # Create AR - GemPortNetworkCtp - 258 - 1026 - 32770 |
| 583 | self.send_create_gem_port_network_ctp(0x102, 0x402, 0x8002) |
| 584 | yield self.wait_for_response() |
| 585 | |
| 586 | # Create AR - GemPortNetworkCtp - 259 - 1027 - 32771 |
| 587 | self.send_create_gem_port_network_ctp(0x103, 0x403, 0x8003) |
| 588 | yield self.wait_for_response() |
| 589 | |
| 590 | # Create AR - MulticastGemInterworkingTp - 6 - 260 |
| 591 | self.send_create_multicast_gem_interworking_tp(0x6, 0x104) |
| 592 | yield self.wait_for_response() |
| 593 | |
| 594 | # Create AR - GemInterworkingTp - 32769 - 256 -32768 - 1 |
| 595 | self.send_create_gem_inteworking_tp(0x8001, 0x100, 0x8000) |
| 596 | yield self.wait_for_response() |
| 597 | |
| 598 | # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1 |
| 599 | self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001) |
| 600 | yield self.wait_for_response() |
| 601 | |
| 602 | # Create AR - GemInterworkingTp - 32771 - 258 -32770 - 1 |
| 603 | self.send_create_gem_inteworking_tp(0x8003, 0x102, 0x8002) |
| 604 | yield self.wait_for_response() |
| 605 | |
| 606 | # Create AR - GemInterworkingTp - 32772 - 259 -32771 - 1 |
| 607 | self.send_create_gem_inteworking_tp(0x8004, 0x103, 0x8003) |
| 608 | yield self.wait_for_response() |
| 609 | |
| 610 | # Set AR - 802.1pMapperServiceProfile - 32768 - 32769 |
| 611 | self.send_set_8021p_mapper_service_profile(0x8000, 0x8001) |
| 612 | yield self.wait_for_response() |
| 613 | |
| 614 | # Set AR - 802.1pMapperServiceProfile - 32769 - 32770 |
| 615 | self.send_set_8021p_mapper_service_profile(0x8001, 0x8002) |
| 616 | yield self.wait_for_response() |
| 617 | |
| 618 | # Set AR - 802.1pMapperServiceProfile - 32770 - 32771 |
| 619 | self.send_set_8021p_mapper_service_profile(0x8002, 0x8003) |
| 620 | yield self.wait_for_response() |
| 621 | |
| 622 | # Set AR - 802.1pMapperServiceProfile - 32771 - 32772 |
| 623 | self.send_set_8021p_mapper_service_profile(0x8003, 0x8004) |
| 624 | yield self.wait_for_response() |
| 625 | |
| 626 | # Create AR - MacBridgePortConfigData - 8449 - 513 - 2 - 3 - 32768 |
| 627 | self.send_create_mac_bridge_port_configuration_data(0x2101, 0x201, 2, 3, 0x8000) |
| 628 | yield self.wait_for_response() |
| 629 | |
| 630 | # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769 |
| 631 | self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001) |
| 632 | yield self.wait_for_response() |
| 633 | |
| 634 | # Create AR - MacBridgePortConfigData - 8451 - 513 - 4 - 3 - 32770 |
| 635 | self.send_create_mac_bridge_port_configuration_data(0x2103, 0x201, 4, 3, 0x8002) |
| 636 | yield self.wait_for_response() |
| 637 | |
| 638 | # Create AR - MacBridgePortConfigData - 8452 - 513 - 5 - 3 - 32771 |
| 639 | self.send_create_mac_bridge_port_configuration_data(0x2104, 0x201, 5, 3, 0x8003) |
| 640 | yield self.wait_for_response() |
| 641 | |
| 642 | # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6 |
| 643 | self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6) |
| 644 | yield self.wait_for_response() |
| 645 | |
| 646 | # Create AR - VlanTaggingFilterData - 8449 - 040000000000000000000000000000000000000000000000 |
| 647 | self.send_create_vlan_tagging_filter_data(0x2101, 0x0400) |
| 648 | yield self.wait_for_response() |
| 649 | |
| 650 | # Create AR - VlanTaggingFilterData - 8450 - 040100000000000000000000000000000000000000000000 |
| 651 | self.send_create_vlan_tagging_filter_data(0x2102, 0x0401) |
| 652 | yield self.wait_for_response() |
| 653 | |
| 654 | # Create AR - VlanTaggingFilterData - 8451 - 040200000000000000000000000000000000000000000000 |
| 655 | self.send_create_vlan_tagging_filter_data(0x2103, 0x0402) |
| 656 | yield self.wait_for_response() |
| 657 | |
| 658 | # Create AR - VlanTaggingFilterData - 8452 - 040300000000000000000000000000000000000000000000 |
| 659 | self.send_create_vlan_tagging_filter_data(0x2104, 0x0403) |
| 660 | yield self.wait_for_response() |
| 661 | |
| 662 | # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 10 - 1025 |
| 663 | self.send_create_extended_vlan_tagging_operation_configuration_data(0x202) |
| 664 | yield self.wait_for_response() |
| 665 | |
| 666 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100 |
| 667 | self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202,0x8100,0x8100) |
| 668 | yield self.wait_for_response() |
| 669 | |
| 670 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x400 - 5 - 0x400 - 4 |
| 671 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x400, 0x400) |
| 672 | yield self.wait_for_response() |
| 673 | |
| 674 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x401 - 5 - 0x401 - 4 |
| 675 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x401, 0x401) |
| 676 | yield self.wait_for_response() |
| 677 | |
| 678 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x402 - 5 - 0x402 - 4 |
| 679 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x402, 0x402) |
| 680 | yield self.wait_for_response() |
| 681 | |
| 682 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - RxVlanTaggingOperationTable - 0x403 - 5 - 0x403 - 4 |
| 683 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(0x202, 0x403, 0x403) |
| 684 | yield self.wait_for_response() |
| 685 | |
| 686 | # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 11 - 1025 |
| 687 | self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 1, 11, 0x401) |
| 688 | yield self.wait_for_response() |
| 689 | |