Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2017 the original author or authors. |
| 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 | """ |
| 18 | PMC Sierra ONU adapter |
| 19 | """ |
| 20 | |
| 21 | import structlog |
| 22 | from twisted.internet import reactor |
| 23 | from twisted.internet.defer import DeferredQueue, inlineCallbacks, returnValue |
| 24 | from zope.interface import implementer |
| 25 | import voltha.core.flow_decomposer as fd |
| 26 | |
| 27 | from voltha.adapters.interface import IAdapterInterface |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 28 | from voltha.adapters.microsemi_olt.DeviceManager import mac_str_to_tuple |
| 29 | from voltha.adapters.microsemi_olt.PAS5211 import PAS5211GetOnuAllocs, PAS5211GetOnuAllocsResponse, PAS5211GetSnInfo, \ |
| 30 | PAS5211GetSnInfoResponse, PAS5211GetOnusRange, PAS5211GetOnusRangeResponse, PAS5211MsgSetOnuOmciPortId, \ |
| 31 | PAS5211MsgSetOnuOmciPortIdResponse, PAS5211MsgSetOnuAllocId, PAS5211MsgSetOnuAllocIdResponse, \ |
| 32 | PAS5211SetSVlanAtConfig, PAS5211SetSVlanAtConfigResponse, PAS5211SetVlanDownConfig, \ |
| 33 | PAS5211SetVlanDownConfigResponse, PAS5211SetDownVlanHandl, PAS5211SetDownVlanHandlResponse, \ |
| 34 | PAS5211SetUplinkVlanHandl, PAS5211SetDownstreamPolicingConfigResponse, PAS5211SetDownstreamPolicingConfig, \ |
| 35 | PAS5211SetPortIdPolicingConfig, PAS5211UnsetPortIdPolicingConfig, \ |
| 36 | PAS5211MsgSendDbaAlgorithmMsg, PAS5211MsgSendDbaAlgorithmMsgResponse, \ |
| 37 | PAS5211SetUpstreamPolicingConfigResponse, PAS5211SetUpstreamPolicingConfig, \ |
| 38 | PAS5211MsgSetPortIdConfig, PAS5211MsgSetPortIdConfigResponse, \ |
| 39 | PAS5211MsgGetOnuIdByPortId, PAS5211MsgGetOnuIdByPortIdResponse, \ |
| 40 | PAS5211SetVlanUplinkConfiguration, PAS5211SetVlanUplinkConfigurationResponse, PAS5211SetUplinkVlanHandlResponse, PAS5211SetVlanGenConfig, PAS5211SetVlanGenConfigResponse, \ |
| 41 | PAS5211GetPortIdDownstreamPolicingConfig, PAS5211GetPortIdDownstreamPolicingConfigResponse, PAS5211RemoveDownstreamPolicingConfig, \ |
| 42 | PAS5211MsgHeader, PAS5211UnsetPortIdPolicingConfigResponse, PAS5211RemoveDownstreamPolicingConfigResponse, \ |
| 43 | PAS5211SetPortIdPolicingConfigResponse |
| 44 | from voltha.adapters.microsemi_olt.PAS5211_constants import OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER, PON_FALSE, \ |
| 45 | PON_1_TO_1_VLAN_MODE, PON_TRUE, PON_VLAN_UNUSED_TAG, PON_VLAN_UNUSED_PRIORITY, PON_VLAN_REPLACE_PRIORITY, \ |
| 46 | PON_OUTPUT_VLAN_PRIO_HANDLE_INCOMING_VLAN, PON_VLAN_UNCHANGED_PRIORITY, PON_OUTPUT_VLAN_PRIO_HANDLE_DONT_CHANGE, \ |
| 47 | PON_OUTPUT_VLAN_PRIO_HANDLE_DL_VLAN_TABLE, PON_DL_VLAN_SVLAN_REMOVE, PON_DL_VLAN_CVLAN_NO_CHANGE, \ |
| 48 | PON_VLAN_DEST_DATAPATH, GEM_DIR_BIDIRECT, OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED, \ |
| 49 | OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC, OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME, OMCI_8021P_MSP_TP_TYPE_NULL, \ |
| 50 | OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI, OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE, PMC_UPSTREAM_PORT, \ |
| 51 | PON_DISABLE, PON_VLAN_CHANGE_TAG, PON_VLAN_DONT_CHANGE_TAG, PON_PORT_TYPE_GEM, PON_PORT_DESTINATION_CNI0, PON_ENABLE, SLA_gr_bw_gros, PYTHAGORAS_UPDATE_AID_SLA, \ |
| 52 | SLA_gr_bw_gros, SLA_be_bw_gros, SLA_gr_bw_fine, SLA_be_bw_fine, PYTHAGORAS_DBA_DATA_COS, PYTHAGORAS_DBA_STATUS_REPORT_NSR, \ |
| 53 | PMC_OFAL_NO_POLICY, UPSTREAM, DOWNSTREAM |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 54 | |
| 55 | from voltha.extensions.omci.omci_frame import OmciFrame |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 56 | from voltha.protos import third_party |
| 57 | from voltha.protos.adapter_pb2 import Adapter |
| 58 | from voltha.protos.adapter_pb2 import AdapterConfig |
| 59 | from voltha.protos.common_pb2 import LogLevel, ConnectStatus, AdminState, OperStatus |
| 60 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port |
| 61 | from voltha.protos.health_pb2 import HealthStatus |
| 62 | from voltha.protos.logical_device_pb2 import LogicalPort |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 63 | from voltha.protos.openflow_13_pb2 import OFPPF_1GB_FD, OFPPF_FIBER, ofp_port, OFPPS_LIVE, OFPXMC_OPENFLOW_BASIC |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 64 | |
| 65 | from voltha.extensions.omci.omci_messages import OmciGet, OmciGetResponse, OmciCreate, OmciMibResetResponse, OmciSet, \ |
| 66 | OmciSetResponse, OmciCreateResponse, OmciMibReset, OmciDelete, OmciDeleteResponse |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 67 | from adapters.microsemi_olt.OMCIProxy import OMCIProxy |
| 68 | from voltha.adapters.microsemi_olt.APIProxy import APIProxy |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 69 | from voltha.registry import registry |
| 70 | from voltha.extensions.omci.omci_entities import VlanTaggingOperation |
| 71 | from voltha.protos.openflow_13_pb2 import Flows, FlowGroups |
| 72 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 73 | import Queue |
| 74 | from struct import pack, unpack |
| 75 | |
| 76 | _ = third_party |
| 77 | log = structlog.get_logger() |
| 78 | |
| 79 | OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG = 15 |
| 80 | OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE = 4096 |
| 81 | OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE = 0 |
| 82 | OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE = 0 |
| 83 | OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT = 14 |
| 84 | OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_8100 = 4 |
| 85 | OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE = 15 |
| 86 | OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER = 1 |
| 87 | OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER = 4096 |
| 88 | OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER = 0 |
| 89 | OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100 = 4 |
| 90 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 91 | MAX_FLOW_EVENT_RETRIES = 5 |
| 92 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 93 | def sequence_generator(init): |
| 94 | num = init |
| 95 | while True: |
| 96 | yield num |
| 97 | num += 1 |
| 98 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 99 | @implementer(IAdapterInterface) |
| 100 | class TlgsOnuAdapter(object): |
| 101 | |
| 102 | name = 'tlgs_onu' |
| 103 | |
| 104 | supported_device_types = [ |
| 105 | DeviceType( |
| 106 | id=name, |
| 107 | adapter=name, |
| 108 | accepts_bulk_flow_update=True |
| 109 | ) |
| 110 | ] |
| 111 | |
| 112 | |
| 113 | def __init__(self, adapter_agent, config): |
| 114 | self.omci_proxy = None |
| 115 | self.api_proxy = None |
| 116 | self.adapter_agent = adapter_agent |
| 117 | self.config = config |
| 118 | self.descriptor = Adapter( |
| 119 | id=self.name, |
| 120 | vendor='TLGS', |
| 121 | version='0.1', |
| 122 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 123 | ) |
| 124 | |
| 125 | # self.incoming_messages = DeferredQueue() |
| 126 | #self.trangen = sequence_generator(1) |
| 127 | |
| 128 | # As of broadcom_onu.py |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 129 | self.device_handlers = dict() |
| 130 | # register for adapter messages |
| 131 | self.adapter_agent.register_for_inter_adapter_messages() |
| 132 | |
| 133 | self.interface = registry('main').get_args().interface |
| 134 | |
| 135 | def start(self): |
| 136 | log.debug('starting') |
| 137 | log.info('started') |
| 138 | |
| 139 | def stop(self): |
| 140 | log.debug('stopping') |
| 141 | log.info('stopped') |
| 142 | |
| 143 | def adapter_descriptor(self): |
| 144 | return self.descriptor |
| 145 | |
| 146 | def device_types(self): |
| 147 | return DeviceTypes(items=self.supported_device_types) |
| 148 | |
| 149 | def health(self): |
| 150 | return HealthStatus(state=HealthStatus.HealthState.HEALTHY) |
| 151 | |
| 152 | def change_master_state(self, master): |
| 153 | raise NotImplementedError() |
| 154 | |
| 155 | def create_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 156 | raise NotImplementedError() |
| 157 | |
| 158 | def update_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 159 | raise NotImplementedError() |
| 160 | |
| 161 | def remove_tcont(self, device, tcont_data, traffic_descriptor_data): |
| 162 | raise NotImplementedError() |
| 163 | |
| 164 | def create_gemport(self, device, data): |
| 165 | raise NotImplementedError() |
| 166 | |
| 167 | def update_gemport(self, device, data): |
| 168 | raise NotImplementedError() |
| 169 | |
| 170 | def remove_gemport(self, device, data): |
| 171 | raise NotImplementedError() |
| 172 | |
| 173 | def create_multicast_gemport(self, device, data): |
| 174 | raise NotImplementedError() |
| 175 | |
| 176 | def update_multicast_gemport(self, device, data): |
| 177 | raise NotImplementedError() |
| 178 | |
| 179 | def remove_multicast_gemport(self, device, data): |
| 180 | raise NotImplementedError() |
| 181 | |
| 182 | def create_multicast_distribution_set(self, device, data): |
| 183 | raise NotImplementedError() |
| 184 | |
| 185 | def update_multicast_distribution_set(self, device, data): |
| 186 | raise NotImplementedError() |
| 187 | |
| 188 | def remove_multicast_distribution_set(self, device, data): |
| 189 | raise NotImplementedError() |
| 190 | |
| 191 | def adopt_device(self, device): |
| 192 | log.debug('adopt-device', device=device) |
| 193 | # reactor.callLater(0.1, self._onu_device_activation, device) |
| 194 | # return device |
| 195 | # two level array channel |
| 196 | |
| 197 | if device.proxy_address.channel_id not in self.device_handlers: |
| 198 | self.device_handlers[device.proxy_address.channel_id] = dict() |
| 199 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 200 | self.device_handlers[device.proxy_address.channel_id][ |
| 201 | device.proxy_address.onu_id] = TlgsOnuHandler(self, device.id) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 202 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 203 | reactor.callLater(1, self.device_handlers[device.proxy_address.channel_id][ |
| 204 | device.proxy_address.onu_id].activate, device) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 205 | |
| 206 | return device |
| 207 | |
| 208 | def reconcile_device(self, device): |
| 209 | raise NotImplementedError() |
| 210 | |
| 211 | def abandon_device(self, device): |
| 212 | raise NotImplementedError() |
| 213 | |
| 214 | def disable_device(self, device): |
| 215 | log.debug('disable-device', device=device.id) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 216 | |
| 217 | reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id][ |
| 218 | device.proxy_address.onu_id].deactivate, device) |
| 219 | #raise NotImplementedError() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 220 | |
| 221 | def reenable_device(self, device): |
| 222 | raise NotImplementedError() |
| 223 | |
| 224 | def reboot_device(self, device): |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 225 | log.debug('reboot-device', device=device.id) |
| 226 | |
| 227 | reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id][ |
| 228 | device.proxy_address.onu_id].reboot, device) |
| 229 | # raise NotImplementedError() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 230 | |
| 231 | def download_image(self, device, request): |
| 232 | raise NotImplementedError() |
| 233 | |
| 234 | def get_image_download_status(self, device, request): |
| 235 | raise NotImplementedError() |
| 236 | |
| 237 | def cancel_image_download(self, device, request): |
| 238 | raise NotImplementedError() |
| 239 | |
| 240 | def activate_image_update(self, device, request): |
| 241 | raise NotImplementedError() |
| 242 | |
| 243 | def revert_image_update(self, device, request): |
| 244 | raise NotImplementedError() |
| 245 | |
| 246 | def self_test_device(self, device): |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 247 | """ |
| 248 | This is called to Self a device based on a NBI call. |
| 249 | :param device: A Voltha.Device object. |
| 250 | :return: Will return result of self test |
| 251 | """ |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 252 | log.debug('self-test-device', device=device.id) |
| 253 | raise NotImplementedError() |
| 254 | |
| 255 | def delete_device(self, device): |
| 256 | log.debug('delete-device', device_id=device.id) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 257 | |
| 258 | def get_device_details(self, device): |
| 259 | raise NotImplementedError() |
| 260 | |
| 261 | def deactivate(self, device): |
| 262 | try: |
| 263 | handler = self.device_handlers[ |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 264 | device.proxy_address.channel_id][device.proxy_address.onu_id] |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 265 | return handler.deactivate(device) |
| 266 | except Exception as e: |
| 267 | log.exception('failed-to-deactivate-onu', e=e) |
| 268 | raise e |
| 269 | |
| 270 | def update_pm_config(self, device, pm_configs): |
| 271 | raise NotImplementedError() |
| 272 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 273 | # @inlineCallbacks |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 274 | def update_flows_bulk(self, device, flows, groups): |
| 275 | log.debug('onu-bulk-flow-update', device_id=device.id, |
| 276 | flows=flows, groups=groups) |
| 277 | log.debug(str(self.device_handlers.keys)) |
| 278 | try: |
| 279 | assert len(groups.items) == 0 |
| 280 | handler = self.device_handlers[ |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 281 | device.proxy_address.channel_id][device.proxy_address.onu_id] |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 282 | handler.update_flow_table(device, flows.items) |
| 283 | except Exception as e: |
| 284 | log.exception('failed-to-update-flow-table', e=e) |
| 285 | raise e |
| 286 | |
| 287 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 288 | raise NotImplementedError() |
| 289 | |
| 290 | def send_proxied_message(self, proxy_address, msg): |
| 291 | log.debug("send-proxied-message in TLGS ONU") |
| 292 | |
| 293 | def receive_proxied_message(self, proxy_address, msg): |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 294 | log.debug('receive-proxied-message') |
| 295 | # mgs - > onu_id |
| 296 | if PAS5211MsgHeader in msg: |
| 297 | if msg['PAS5211MsgHeader'].onu_id != -1: |
| 298 | handler = self.device_handlers[ |
| 299 | proxy_address.channel_id][msg.onu_id] |
| 300 | handler.receive_message(msg) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 301 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 302 | # for onu, handler in self.device_handlers[proxy_address.channel_id].iteritems(): |
| 303 | # handler.receive_message(msg) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 304 | |
| 305 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 306 | log.debug('packet-out', logical_device_id=logical_device_id, |
| 307 | egress_port_no=egress_port_no, msg_len=len(msg)) |
| 308 | |
| 309 | def create_interface(self, device, data): |
| 310 | raise NotImplementedError() |
| 311 | |
| 312 | def update_interface(self, device, data): |
| 313 | raise NotImplementedError() |
| 314 | |
| 315 | def remove_interface(self, device, data): |
| 316 | raise NotImplementedError() |
| 317 | |
| 318 | def receive_onu_detect_state(self, device_id, state): |
| 319 | raise NotImplementedError() |
| 320 | |
| 321 | def receive_inter_adapter_message(self, msg): |
| 322 | raise NotImplementedError() |
| 323 | |
| 324 | def suppress_alarm(self, filter): |
| 325 | raise NotImplementedError() |
| 326 | |
| 327 | def unsuppress_alarm(self, filter): |
| 328 | raise NotImplementedError() |
| 329 | |
| 330 | # Not used, delegated to handler |
| 331 | def update_flow_table(self, device, flows): |
| 332 | log.debug('update-flow-table', device_id=device.id, flows=flows) |
| 333 | |
| 334 | class TlgsOnuHandler(object): |
| 335 | |
| 336 | def __init__(self, adapter, device_id): |
| 337 | self.adapter = adapter |
| 338 | self.adapter_agent = adapter.adapter_agent |
| 339 | self.device_id = device_id |
| 340 | self.log = structlog.get_logger(device_id=device_id) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 341 | #self.incoming_messages = Queue.Queue() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 342 | self.incoming_messages = DeferredQueue() |
| 343 | self.event_messages = Queue.Queue() |
| 344 | self.proxy_address = None |
| 345 | self.tx_id = 0 |
| 346 | self.trangen = sequence_generator(1) |
| 347 | self.port_id = None |
| 348 | self.alloc_id = None |
| 349 | self.cvlan_id = None |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 350 | self.subsvlan_id = None |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 351 | self.bandwidth = None |
| 352 | self.flows_lock = 0 |
| 353 | self.flows = None |
| 354 | self.policy_id = None |
| 355 | self.flow_queue = DeferredQueue() |
| 356 | |
| 357 | def receive_message(self, msg): |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 358 | log.debug("receive-message",msg=msg.show(dump=True)) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 359 | self.incoming_messages.put(msg) |
| 360 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 361 | def activate(self, device): |
| 362 | log.debug('activate-onu-handler', device=device) |
| 363 | try: |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 364 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 365 | # register for proxied messages right away |
| 366 | self.proxy_address = device.proxy_address |
| 367 | self.adapter_agent.register_for_proxied_messages(device.proxy_address) |
| 368 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 369 | # First we verify that we got parent reference and proxy info |
| 370 | assert device.parent_id |
| 371 | assert device.proxy_address.device_id |
| 372 | # == 0 # We want to activate multiple ONT's |
| 373 | assert device.proxy_address.channel_id is not None |
| 374 | # to get onu_id = device.proxy_address.onu_id |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 375 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 376 | # From PMC code: |
| 377 | self.port_id = 1000 + 16 * device.proxy_address.onu_id |
| 378 | self.alloc_id = self.port_id |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 379 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 380 | # we are going to use the proxy_address.channel_id as unique number |
| 381 | # and name for the virtual ports, as this is guaranteed to be unique |
| 382 | # in the context of the OLT port, so it is also unique in the context |
| 383 | # of the logical device |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 384 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 385 | device.model = 'GPON ONU' |
| 386 | device.hardware_version = 'tbd' |
| 387 | device.firmware_version = 'tbd' |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 388 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 389 | device.connect_status = ConnectStatus.REACHABLE |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 390 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 391 | uni_port = Port(port_no=1, |
| 392 | label="{} ONU".format('TLGS'), |
| 393 | type=Port.ETHERNET_UNI, |
| 394 | admin_state=AdminState.ENABLED, |
| 395 | oper_status=OperStatus.ACTIVE |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 396 | ) |
| 397 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 398 | self.adapter_agent.add_port(device.id, uni_port) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 399 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 400 | log.debug('add-onu-port') |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 401 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 402 | pon_port = Port( |
| 403 | port_no=2, |
| 404 | label='PON port', |
| 405 | type=Port.PON_ONU, |
| 406 | admin_state=AdminState.ENABLED, |
| 407 | oper_status=OperStatus.ACTIVE, |
| 408 | peers=[ |
| 409 | Port.PeerPort( |
| 410 | device_id=device.parent_id, |
| 411 | port_no=device.parent_port_no |
| 412 | ) |
| 413 | ] |
| 414 | ) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 415 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 416 | self.adapter_agent.add_port(device.id, pon_port) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 417 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 418 | log.debug('add-onu-port') |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 419 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 420 | # obtain logical device id |
| 421 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 422 | logical_device_id = parent_device.parent_id |
| 423 | assert logical_device_id |
| 424 | port_no = (device.proxy_address.channel_id * 32) + \ |
| 425 | (device.proxy_address.onu_id + 1) |
| 426 | cap = OFPPF_1GB_FD | OFPPF_FIBER |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 427 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 428 | self.adapter_agent.add_logical_port(logical_device_id, LogicalPort( |
| 429 | id=str(port_no), |
| 430 | ofp_port=ofp_port( |
| 431 | port_no=port_no, |
| 432 | hw_addr=mac_str_to_tuple(device.serial_number)[2:8], |
| 433 | # name='uni-{}'.format(port_no), |
| 434 | name=device.serial_number[0:6], |
| 435 | config=0, |
| 436 | state=OFPPS_LIVE, |
| 437 | curr=cap, |
| 438 | advertised=cap, |
| 439 | peer=cap, |
| 440 | curr_speed=OFPPF_1GB_FD, |
| 441 | max_speed=OFPPF_1GB_FD |
| 442 | ), |
| 443 | device_id=device.id, |
| 444 | device_port_no=uni_port.port_no |
| 445 | )) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 446 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 447 | log.debug('add-onu-logical-port') |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 448 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 449 | # Input logical port from ONT |
| 450 | self.port_no = port_no |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 451 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 452 | # Finally update to "ACTIVE" |
| 453 | device = self.adapter_agent.get_device(device.id) |
| 454 | # In broadcom_onu.py this state is DISCOVERED |
| 455 | device.oper_status = OperStatus.ACTIVE |
| 456 | self.adapter_agent.update_device(device) |
| 457 | |
| 458 | log.info('activate-onu-end', device=device) |
| 459 | |
| 460 | # # Just in case, pull for existing flows... |
| 461 | # flows = self.adapter_agent.root_proxy.get('/devices/{}/flows'.format(device.id)) |
| 462 | |
| 463 | # log.debug('flows-got-from-deviceid', flows=flows.items) |
| 464 | # reactor.callLater(0, self.update_flow_table, device, flows.items) |
| 465 | |
| 466 | # Listening thread (we wait 5 secs to start reading from queue) |
| 467 | reactor.callLater(0, self.wait_for_flow_events, device) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 468 | |
| 469 | except Exception as e: |
| 470 | log.exception('activate-failed', e=e) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 471 | # raise Exception('Exception during onu activation') |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 472 | |
| 473 | @inlineCallbacks |
| 474 | def wait_for_flow_events(self, device): |
| 475 | |
| 476 | log.debug('wait-for-flow-events') |
| 477 | event = yield self.flow_queue.get() |
| 478 | log.debug("unqueued-flow-event") |
| 479 | |
| 480 | try: |
| 481 | if event['action'] == 'install': |
| 482 | response = yield self.install_flows_sequence(device, event['cvlan'], event['subsvlan']) |
| 483 | elif event['action'] == 'reinstall': |
| 484 | response = yield self.reinstall_flows_sequence(device, event['cvlan'], event['subsvlan']) |
| 485 | elif event['action'] == 'remove': |
| 486 | response = yield self.uninstall_flows_sequence(device) |
| 487 | |
| 488 | if response: |
| 489 | log.debug("Event handled flow successfully") |
| 490 | else: |
| 491 | log.debug("Error handling flow event") |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 492 | # if event['retries'] < MAX_FLOW_EVENT_RETRIES: |
| 493 | # # Failed install events are turned into reinstall... |
| 494 | # if event['action'] == 'install': |
| 495 | # event['action'] = 'reinstall' |
| 496 | # event['retries'] += 1 |
| 497 | # log.debug("Flow event retry") |
| 498 | # self.flow_queue.put(event) |
| 499 | # else: |
| 500 | # log.debug("Max retries done for flow event handling.", event=event) |
| 501 | # # If we were trying to install a flow, we remove it... |
| 502 | # if event['action'] != 'remove': |
| 503 | # event['action'] = 'remove' |
| 504 | # event['retries'] = 0 |
| 505 | # self.flow_queue.put(event) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 506 | |
| 507 | except Exception as e: |
| 508 | log.exception('wait-for-flow-events-exception', e=e) |
| 509 | |
| 510 | reactor.callLater(0, self.wait_for_flow_events, device) |
| 511 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 512 | def reboot(self, device): |
| 513 | log.debug('onu-reboot-start', device=device) |
| 514 | |
| 515 | if self.cvlan_id is not None and self.subsvlan_id is not None: |
| 516 | flow_event = {'action': 'reinstall', 'cvlan': self.cvlan_id, |
| 517 | 'subsvlan': self.subsvlan_id, 'retries': 0} |
| 518 | self.flow_queue.put(flow_event) |
| 519 | log.debug('onu-reinstall-event-created') |
| 520 | else: |
| 521 | log.debug('onu-reboot-ignored') |
| 522 | |
| 523 | log.debug('onu-reboot-end', device=device) |
| 524 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 525 | def deactivate(self, device): |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 526 | try: |
| 527 | log.debug('deactivate-onu', device=device) |
| 528 | # Check parent reference and proxy info exists |
| 529 | assert device.parent_id |
| 530 | assert device.proxy_address.device_id |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 531 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 532 | # unregister from proxy messages |
| 533 | self.adapter_agent.unregister_for_proxied_messages(device.proxy_address) |
| 534 | self.proxy_address = None |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 535 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 536 | # Delete references to ports, if any |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 537 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 538 | if self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI): |
| 539 | onu_port = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)[0] |
| 540 | self.adapter_agent.delete_port_reference_from_parent(device.id, onu_port) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 541 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 542 | if self.adapter_agent.get_ports(device.id, Port.PON_ONU): |
| 543 | pon_port = self.adapter_agent.get_ports(device.id, Port.PON_ONU)[0] |
| 544 | self.adapter_agent.delete_port_reference_from_parent(device.id, pon_port) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 545 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 546 | # Delete device and logical ports |
| 547 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 548 | logical_device_id = parent_device.parent_id |
| 549 | # logical_device = self.adapter_agent.get_logical_device(logical_device_id) |
| 550 | # self.adapter_agent.delete_logical_device(logical_device) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 551 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 552 | if logical_device_id: |
| 553 | logical_port = self.adapter_agent.get_logical_port(logical_device_id, self.port_no) |
| 554 | if logical_port: |
| 555 | self.adapter_agent.delete_logical_port(logical_device_id, logical_port) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 556 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 557 | # Finally delete device |
| 558 | self.adapter_agent.delete_child_device( |
| 559 | parent_device_id=device.proxy_address.device_id, |
| 560 | child_device_id=device.id) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 561 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 562 | log.debug('deactivate-onu-end') |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 563 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 564 | except Exception as e: |
| 565 | log.exception('deactivate-failed', e=e) |
| 566 | # raise Exception('Exception during onu deactivation') |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 567 | |
| 568 | # @inlineCallbacks |
| 569 | def update_flow_table(self, device, flows): |
| 570 | cvlan_found = None |
| 571 | subsvlan_found = 0 |
| 572 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 573 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 574 | log.debug('onu-update-flow-table', device_id=device.id, flows=flows) |
| 575 | port_no = (device.proxy_address.channel_id * 32) + (device.proxy_address.onu_id + 1) |
| 576 | log.debug('Checking {} flows for port:{}'.format(len(flows), port_no)) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 577 | try: |
| 578 | |
| 579 | for flow in flows: |
| 580 | # Look for inner VLAN: |
| 581 | for field in fd.get_ofb_fields(flow): |
| 582 | |
| 583 | if field.type == fd.IN_PORT and field.port == 1: |
| 584 | if flow.table_id == 0: |
| 585 | if flow.priority == 1000: |
| 586 | for action in fd.get_actions(flow): |
| 587 | if action.type == fd.SET_FIELD: |
| 588 | cvlan_found = action.set_field.field.ofb_field.vlan_vid & 0xfff |
| 589 | log.debug('CVLAN found:{}'.format(cvlan_found)) |
| 590 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 591 | if cvlan_found: |
| 592 | if cvlan_found != self.cvlan_id: |
| 593 | if self.cvlan_id: |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 594 | log.debug('Reinstall flow triggered') |
| 595 | flow_event = {'action': 'reinstall', 'cvlan': cvlan_found, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 596 | 'subsvlan': subsvlan_found, 'retries': 0} |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 597 | self.flow_queue.put(flow_event) |
| 598 | else: |
| 599 | log.debug('Flows installation triggered') |
| 600 | flow_event = {'action': 'install', 'cvlan': cvlan_found, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 601 | 'subsvlan': subsvlan_found, 'retries': 0} |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 602 | self.flow_queue.put(flow_event) |
| 603 | else: |
| 604 | log.debug('Flows already installed') |
| 605 | else: |
| 606 | if self.cvlan_id: |
| 607 | log.debug('Flows deinstallation triggered') |
| 608 | flow_event = {'action': 'remove', 'cvlan': self.cvlan_id, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 609 | 'subsvlan': self.subsvlan_id, 'retries': 0} |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 610 | self.flow_queue.put(flow_event) |
| 611 | else: |
| 612 | log.debug('Incomplete flow') |
| 613 | |
| 614 | self.cvlan_id = cvlan_found |
| 615 | self.subsvlan_id = subsvlan_found |
| 616 | |
| 617 | except Exception as e: |
| 618 | log.exception('failed-to-launch-install-flow', e=e, flow=flows) |
| 619 | |
| 620 | @inlineCallbacks |
| 621 | def uninstall_flows_sequence(self, device): |
| 622 | log.debug('init-flow-deinstallaton') |
| 623 | try: |
| 624 | response = yield self.delete_data_flow_omci_config(device) |
| 625 | returnValue(response) |
| 626 | except Exception as e: |
| 627 | log.exception('failed-to-launch-uninstall-flow', e=e) |
| 628 | |
| 629 | @inlineCallbacks |
| 630 | def reinstall_flows_sequence(self, device, cvlan_id, subsvlan_id): |
| 631 | log.debug('init-flow-reinstallaton') |
| 632 | try: |
| 633 | response = yield self.uninstall_flows_sequence(device) |
| 634 | if response: |
| 635 | response = yield self.install_flows_sequence(device, cvlan_id, subsvlan_id) |
| 636 | returnValue(response) |
| 637 | returnValue(False) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 638 | except Exception as e: |
| 639 | log.exception('failed-to-launch-reinstall-flow', e=e) |
| 640 | |
| 641 | @inlineCallbacks |
| 642 | def install_flows_sequence(self, device, cvlan_id, subsvlan_id): |
| 643 | log.debug('init-flow-installaton') |
| 644 | try: |
| 645 | log.debug("ONT flow OMCI config", device=device) |
| 646 | response = yield self.create_data_flow_omci_config(device, cvlan_id, subsvlan_id) |
| 647 | returnValue(response) |
| 648 | except Exception as e: |
| 649 | log.exception('failed-to-launch-install-flow', e=e) |
| 650 | |
| 651 | @inlineCallbacks |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 652 | def wait_for_response(self): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 653 | log.debug('wait-for-response') |
| 654 | response = yield self.incoming_messages.get() |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 655 | log.debug("unqueued-message",msg=response.show(dump=True)) |
| 656 | returnValue(response) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 657 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 658 | |
| 659 | # PMC_OFAL.c line:2554 |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 660 | @inlineCallbacks |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 661 | def create_data_flow_omci_config(self, device, cvlan_id, subsvlan_id): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 662 | |
| 663 | self.OMCI_ont_data_mib_reset(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 664 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 665 | |
| 666 | if OmciMibResetResponse not in response: |
| 667 | log.error("Failed to perform a MIB reset for {}".format( |
| 668 | device.proxy_address)) |
| 669 | returnValue(False) |
| 670 | log.debug("[RESPONSE] OMCI_ont_data_mib_reset") |
| 671 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 672 | self.OMCI_tcont_set(device) |
| 673 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 674 | if OmciSetResponse not in response: |
| 675 | log.error("Failed to set alloc id for {}".format( |
| 676 | device.proxy_address)) |
| 677 | returnValue(False) |
| 678 | log.debug("[RESPONSE] OMCI_tcont_set") |
| 679 | |
| 680 | self.pmc_omci_mac_bridge_sp_me_create(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 681 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 682 | if OmciCreateResponse not in response: |
| 683 | log.error("Failed to set parameter on {}".format( |
| 684 | device.proxy_address)) |
| 685 | returnValue(False) |
| 686 | log.debug("[RESPONSE] OMCI_mac_bridge_sp_me_create") |
| 687 | |
| 688 | self.pmc_omci_mac_bridge_pcd_me_create(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 689 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 690 | if OmciCreateResponse not in response: |
| 691 | log.error("Failed to set info for {}".format(device.proxy_address)) |
| 692 | returnValue(False) |
| 693 | log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_create") |
| 694 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 695 | self.pmc_omci_evto_create(device) |
| 696 | response = yield self.wait_for_response() |
| 697 | if OmciCreateResponse not in response: |
| 698 | log.error("Failed to set association info for {}".format( |
| 699 | device.proxy_address)) |
| 700 | returnValue(False) |
| 701 | log.debug("[RESPONSE] OMCI_evto_create") |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 702 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 703 | self.pmc_omci_evto_set(device) |
| 704 | response = yield self.wait_for_response() |
| 705 | if OmciSetResponse not in response: |
| 706 | log.error("Failed to set association tpid info for {}".format( |
| 707 | device.proxy_address)) |
| 708 | returnValue(False) |
| 709 | log.debug("[RESPONSE] OMCI_evto_set") |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 710 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 711 | # Reuse create_default_data_flow_omci_config (confirmed from logs) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 712 | self.pmc_omci_8021p_msp_me_allocate(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 713 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 714 | if OmciCreateResponse not in response: |
| 715 | log.error("Failed to create 8021p msp on {}".format( |
| 716 | device.proxy_address)) |
| 717 | if response is not None: |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 718 | log.error("Response received: {}".format(response.summary())) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 719 | returnValue(False) |
| 720 | log.debug("[RESPONSE] OMCI_8021p_msp_me_allocate") |
| 721 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 722 | # Reuse create_default_data_flow_omci_config? |
| 723 | self.pmc_omci_mac_bridge_pcd_me_allocate(device) |
| 724 | response = yield self.wait_for_response() |
| 725 | if OmciCreateResponse not in response: |
| 726 | log.error("Failed to create mac bridge pcd on {}".format( |
| 727 | device.proxy_address)) |
| 728 | returnValue(False) |
| 729 | log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_allocate") |
| 730 | |
| 731 | response = yield self.send_set_extended_vlan_tagging_operation_vlan_configuration_data( |
| 732 | device, cvlan_id, subsvlan_id) |
| 733 | |
| 734 | if not response: |
| 735 | returnValue(False) |
| 736 | log.debug("[RESPONSE] OMCI_send_set_extended_vlan_tagging") |
| 737 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 738 | self.send_create_vlan_tagging_filter_data(device, cvlan_id) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 739 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 740 | if OmciCreateResponse not in response: |
| 741 | log.error("Failed to set vlan tagging filter in {}".format( |
| 742 | device.proxy_address)) |
| 743 | returnValue(False) |
| 744 | log.debug("[RESPONSE] OMCI_send_create_vlan_tagging_filter_data") |
| 745 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 746 | self.pmc_omci_gem_nctp_me_allocate(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 747 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 748 | if OmciCreateResponse not in response: |
| 749 | log.error("Failed to Create gem nctp on {}".format( |
| 750 | device.proxy_address)) |
| 751 | returnValue(False) |
| 752 | log.debug("[RESPONSE] OMCI_gem_nctp_me_allocate") |
| 753 | |
| 754 | self.pmc_omci_gem_iwtp_me_allocate(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 755 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 756 | if OmciCreateResponse not in response: |
| 757 | log.error("Failed to Create gem iwtp on {}".format( |
| 758 | device.proxy_address)) |
| 759 | returnValue(False) |
| 760 | log.debug("[RESPONSE] OMCI_gem_iwtp_me_allocate") |
| 761 | |
| 762 | self.pmc_omci_8021p_msp_me_assign(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 763 | |
| 764 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 765 | if OmciSetResponse not in response: |
| 766 | log.error("Failed to assign sp {}".format( |
| 767 | device.proxy_address)) |
| 768 | returnValue(False) |
| 769 | log.debug("[RESPONSE] OMCI_8021p_msp_me_assign") |
| 770 | |
| 771 | returnValue(True) |
| 772 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 773 | # PMC_OFAL.c line:3065 |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 774 | @inlineCallbacks |
| 775 | def delete_data_flow_omci_config(self, device): |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 776 | |
| 777 | self.pmc_omci_evto_deallocate(device) |
| 778 | response = yield self.wait_for_response() |
| 779 | if OmciDeleteResponse not in response: |
| 780 | log.error( |
| 781 | "Failed to deallocate evt for {}".format(device.proxy_address)) |
| 782 | if response is not None: |
| 783 | log.error("Response received: {}".format(response.summary())) |
| 784 | returnValue(False) |
| 785 | log.debug("[RESPONSE] pmc_omci_evto_deallocate", device=device) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 786 | |
| 787 | self.pmc_omci_gem_iwtp_me_deallocate(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 788 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 789 | if OmciDeleteResponse not in response: |
| 790 | log.error( |
| 791 | "Failed to deallocate iwtp for {}".format(device.proxy_address)) |
| 792 | if response is not None: |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 793 | log.error("Response received: {}".format(response.summary())) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 794 | returnValue(False) |
| 795 | log.debug("[RESPONSE] pmc_omci_gem_iwtp_me_deallocate", device=device) |
| 796 | |
| 797 | self.pmc_omci_gem_nctp_me_deallocate(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 798 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 799 | if OmciDeleteResponse not in response: |
| 800 | log.error( |
| 801 | "Failed to deallocate nctp for {}".format(device.proxy_address)) |
| 802 | returnValue(False) |
| 803 | log.debug("[RESPONSE] pmc_omci_gem_nctp_me_deallocate", device=device) |
| 804 | |
| 805 | self.pmc_omci_vlan_tagging_filter_me_deallocate(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 806 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 807 | if OmciDeleteResponse not in response: |
| 808 | log.error( |
| 809 | "Failed to deallocate vlan tagging for {}".format(device.proxy_address)) |
| 810 | returnValue(False) |
| 811 | log.debug("[RESPONSE] pmc_omci_vlan_tagging_filter_me_deallocate", device=device) |
| 812 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 813 | self.pmc_omci_mac_bridge_pcd_me_deallocate(device) |
| 814 | response = yield self.wait_for_response() |
| 815 | if OmciDeleteResponse not in response: |
| 816 | log.error( |
| 817 | "Failed to deallocate bridge pcd for {}".format(device.proxy_address)) |
| 818 | returnValue(False) |
| 819 | log.debug("[RESPONSE] pmc_omci_mac_bridge_pcd_me_deallocate", device=device) |
| 820 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 821 | self.pmc_omci_8021p_msp_me_deallocate(device) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 822 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 823 | if OmciDeleteResponse not in response: |
| 824 | log.error( |
| 825 | "Failed to deallocate msp for {}".format(device.proxy_address)) |
| 826 | returnValue(False) |
| 827 | log.debug("[RESPONSE] pmc_omci_8021p_msp_me_deallocate", device=device) |
| 828 | |
| 829 | returnValue(True) |
| 830 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 831 | |
| 832 | """ - - - - - - - create_data_flow_omci_config - - - - - - - """ |
| 833 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 834 | |
| 835 | def OMCI_ont_data_mib_reset(self, device): |
| 836 | # DO things to the ONU |
| 837 | # |###[ OmciFrame ]### |
| 838 | # | transaction_id= 1 |
| 839 | # | message_type= 79 |
| 840 | # | omci = 10 |
| 841 | # | \omci_message\ |
| 842 | # | |###[ OmciMibReset ]### |
| 843 | # | | entity_class= 2 |
| 844 | # | | entity_id = 0 |
| 845 | # | omci_trailer= 40 |
| 846 | |
| 847 | # OmciMibReset |
| 848 | |
| 849 | msg = OmciMibReset(entity_class=2, entity_id=0) |
| 850 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 851 | message_type=OmciMibReset.message_id, |
| 852 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 853 | |
| 854 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 855 | log.debug("[SENT] OMCI_ont_data_mib_reset") |
| 856 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 857 | def OMCI_tcont_set(self, device): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 858 | # | ###[ OmciFrame ]### |
| 859 | # | transaction_id = 2 |
| 860 | # | message_type = 72 |
| 861 | # | omci = 10 |
| 862 | # | \omci_message \ |
| 863 | # | | ###[ OmciSet ]### |
| 864 | # | | entity_class = 262 |
| 865 | # | | entity_id = 32769 |
| 866 | # | | attributes_mask = 32768 |
| 867 | # | | data = {'alloc_id': 1000} |
| 868 | # | omci_trailer = 40 |
| 869 | |
| 870 | # tcont_id = 1; //one tcont for one ONU. |
| 871 | # slot_id = 128; /* represent the ONT as a whole entinty */ |
| 872 | # entity_instance = ((slot_id<<8) | tcont_id); /* Compose entity |
| 873 | # instance by the slot-id and t-cont id*/ |
| 874 | |
| 875 | # OmciSet |
| 876 | # TODO: maskdata |
| 877 | msg = OmciSet(entity_class=262, entity_id=32769, attributes_mask=32768, |
| 878 | data=dict( |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 879 | alloc_id=self.alloc_id |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 880 | )) |
| 881 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 882 | message_type=OmciSet.message_id, |
| 883 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 884 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 885 | log.debug("[SENT] OMCI_tcont_set") |
| 886 | |
| 887 | def pmc_omci_mac_bridge_sp_me_create(self, device): |
| 888 | # length = 44 |
| 889 | # port_type = 0 |
| 890 | # port_id = 0 |
| 891 | # management_frame = 1 |
| 892 | # \frame \ |
| 893 | # | ###[ OmciFrame ]### |
| 894 | # | transaction_id = 3 |
| 895 | # | message_type = 68 |
| 896 | # | omci = 10 |
| 897 | # | \omci_message \ |
| 898 | # | | ###[ OmciCreate ]### |
| 899 | # | | entity_class = 45 |
| 900 | # | | entity_id = 1 |
| 901 | # | | data = {'max_age': 5120, 'hello_time': 512, 'priority': 32768, 'port_bridging_ind': 0, |
| 902 | # 'spanning_tree_ind': 0, 'unknown_mac_address_discard': 0, 'mac_learning_depth': 128, |
| 903 | # 'learning_ind': 0, 'forward_delay': 3840} |
| 904 | # | | ###[ Raw ]### |
| 905 | # | | load = '\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
| 906 | # | omci_trailer = 40 |
| 907 | |
| 908 | # Found in method: pmc_omci_mac_bridge_sp_me_create from: PMC_OFAL.c |
| 909 | # Params |
| 910 | # - priority: The bridge priority set on the LAN card |
| 911 | # - max_age: The maximum age for an entry in the spanning tree listing |
| 912 | # - hello_time: The time interval between hello packets |
| 913 | # - forward_delay: The time that the bridge on the Ethernet card in the ONT retains a packet before forwarding it |
| 914 | # - unknown_mac_address_discard: frames with unknown destination addresses will be forwarded to all allowed ports |
| 915 | |
| 916 | msg = OmciCreate(entity_class=45, entity_id=1, |
| 917 | data=dict( |
| 918 | max_age=5120, |
| 919 | hello_time=512, |
| 920 | priority=32768, |
| 921 | port_bridging_ind=PON_FALSE, |
| 922 | spanning_tree_ind=PON_FALSE, |
| 923 | unknown_mac_address_discard=0, |
| 924 | mac_learning_depth=128, |
| 925 | learning_ind=PON_FALSE, |
| 926 | forward_delay=3840 |
| 927 | )) |
| 928 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 929 | message_type=OmciCreate.message_id, |
| 930 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 931 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 932 | log.debug("[SENT] pmc_omci_mac_bridge_sp_me_create") |
| 933 | |
| 934 | def pmc_omci_mac_bridge_pcd_me_create(self, device): |
| 935 | |
| 936 | # |###[ OmciFrame ]### |
| 937 | # | transaction_id= 4 |
| 938 | # | message_type= 68 |
| 939 | # | omci = 10 |
| 940 | # | \omci_message\ |
| 941 | # | |###[ OmciCreate ]### |
| 942 | # | | entity_class= 47 |
| 943 | # | | entity_id = 0 |
| 944 | # | | data = {'tp_pointer': 257, 'encapsulation_methods': 1, 'port_num': 0, 'port_priority': 10, 'tp_type': 1, 'port_path_cost': 100, 'port_spanning_tree_in': 0, 'lan_fcs_ind': 0, 'bridge_id_pointer': 1} |
| 945 | # | omci_trailer= 40 |
| 946 | |
| 947 | # Found in method: pmc_omci_mac_bridge_pcd_me_create from: PMC_OFAL.c |
| 948 | # Params |
| 949 | # - port_path_cost: The cost contribution of the port to the path cost towards the spanning tree root bridge |
| 950 | # - bridge_id_pointer: MAC bridge controlling the port |
| 951 | |
| 952 | msg = OmciCreate(entity_class=47, entity_id=0, |
| 953 | data=dict( |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 954 | tp_pointer=257, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 955 | encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC, |
| 956 | port_num=0, |
| 957 | port_priority=10, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 958 | tp_type=1, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 959 | port_path_cost=100, |
| 960 | port_spanning_tree_in=PON_FALSE, |
| 961 | lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED, |
| 962 | bridge_id_pointer=1 |
| 963 | )) |
| 964 | |
| 965 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 966 | message_type=OmciCreate.message_id, |
| 967 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 968 | |
| 969 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 970 | log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_create") |
| 971 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 972 | def pmc_omci_evto_create(self, device): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 973 | # |###[ OmciFrame ]### |
| 974 | # | transaction_id= 5 |
| 975 | # | message_type= 68 |
| 976 | # | omci = 10 |
| 977 | # | \omci_message\ |
| 978 | # | |###[ OmciCreate ]### |
| 979 | # | | entity_class= 171 |
| 980 | # | | entity_id = 0 |
| 981 | # | | data = {'association_type': 2, 'associated_me_pointer': 257} |
| 982 | # | omci_trailer= 40 |
| 983 | |
| 984 | # Found in method: pmc_omci_evto_create from: PMC_OFAL.c |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 985 | msg = OmciCreate(entity_class=171, entity_id=0, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 986 | data=dict( |
| 987 | association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 988 | associated_me_pointer=257 |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 989 | )) |
| 990 | |
| 991 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 992 | message_type=OmciCreate.message_id, |
| 993 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 994 | |
| 995 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 996 | log.debug("[SENT] pmc_omci_evto_create") |
| 997 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 998 | def pmc_omci_evto_set(self, device): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 999 | # |###[ OmciFrame ]### |
| 1000 | # | transaction_id= 6 |
| 1001 | # | message_type= 72 |
| 1002 | # | omci = 10 |
| 1003 | # | \omci_message\ |
| 1004 | # | |###[ OmciSet ]### |
| 1005 | # | | entity_class= 171 |
| 1006 | # | | entity_id = 0 |
| 1007 | # | | attributes_mask= 47616 |
| 1008 | # | | data = {'association_type': 2, 'input_tpid': 33024, 'associated_me_pointer': 257, 'downstream_mode': 0, 'output_tpid': 33024} |
| 1009 | # | omci_trailer= 40 |
| 1010 | |
| 1011 | # Found in method: pmc_omci_evto_set from: PMC_OFAL.c |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1012 | msg = OmciSet(entity_class=171, entity_id=0, attributes_mask=47616, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1013 | data=dict( |
| 1014 | association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1015 | input_tpid=33024, |
| 1016 | associated_me_pointer=257, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1017 | downstream_mode=OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1018 | output_tpid=33024 |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1019 | )) |
| 1020 | |
| 1021 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1022 | message_type=OmciSet.message_id, |
| 1023 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1024 | |
| 1025 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1026 | log.debug("[SENT] pmc_omci_evto_set") |
| 1027 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1028 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1029 | |
| 1030 | def pmc_omci_8021p_msp_me_allocate(self, device): |
| 1031 | # |###[ OmciFrame ]### |
| 1032 | # | transaction_id= 7 |
| 1033 | # | message_type= 68 |
| 1034 | # | omci = 10 |
| 1035 | # | \omci_message\ |
| 1036 | # | |###[ OmciCreate ]### |
| 1037 | # | | entity_class= 130 |
| 1038 | # | | entity_id = 1 |
| 1039 | # | | data = {'tp_pointer': 65535, 'unmarked_frame_option': 1, 'interwork_tp_pointer_for_p_bit_priority_6': 65535, |
| 1040 | # 'interwork_tp_pointer_for_p_bit_priority_7': 65535, 'interwork_tp_pointer_for_p_bit_priority_4': 65535, |
| 1041 | # 'interwork_tp_pointer_for_p_bit_priority_5': 65535, 'interwork_tp_pointer_for_p_bit_priority_2': 65535, |
| 1042 | # 'interwork_tp_pointer_for_p_bit_priority_3': 65535, 'interwork_tp_pointer_for_p_bit_priority_0': 65535, |
| 1043 | # 'interwork_tp_pointer_for_p_bit_priority_1': 65535, 'tp_type': 0, 'default_p_bit_marking': 0} |
| 1044 | # | omci_trailer= 40 |
| 1045 | |
| 1046 | # Found in method: pmc_omci_8021p_msp_me_create from: PMC_OFAL.c |
| 1047 | msg = OmciCreate(entity_class=130, entity_id=1, |
| 1048 | data=dict( |
| 1049 | tp_pointer=65535, |
| 1050 | unmarked_frame_option=OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME, |
| 1051 | interwork_tp_pointer_for_p_bit_priority_6=65535, |
| 1052 | interwork_tp_pointer_for_p_bit_priority_7=65535, |
| 1053 | interwork_tp_pointer_for_p_bit_priority_4=65535, |
| 1054 | interwork_tp_pointer_for_p_bit_priority_5=65535, |
| 1055 | interwork_tp_pointer_for_p_bit_priority_2=65535, |
| 1056 | interwork_tp_pointer_for_p_bit_priority_3=65535, |
| 1057 | interwork_tp_pointer_for_p_bit_priority_0=65535, |
| 1058 | interwork_tp_pointer_for_p_bit_priority_1=65535, |
| 1059 | tp_type=OMCI_8021P_MSP_TP_TYPE_NULL, |
| 1060 | default_p_bit_marking=0 |
| 1061 | )) |
| 1062 | |
| 1063 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1064 | message_type=OmciCreate.message_id, |
| 1065 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1066 | |
| 1067 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1068 | log.debug("[SENT] pmc_omci_8021p_msp_me_allocate") |
| 1069 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1070 | def pmc_omci_mac_bridge_pcd_me_allocate(self, device): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1071 | # |###[ OmciFrame ]### |
| 1072 | # | transaction_id= 8 |
| 1073 | # | message_type= 68 |
| 1074 | # | omci = 10 |
| 1075 | # | \omci_message\ |
| 1076 | # | |###[ OmciCreate ]### |
| 1077 | # | | entity_class= 130 |
| 1078 | # | | entity_id = 1 |
| 1079 | # | | data = {'tp_pointer': 1, 'encapsulation_methods': 1, 'port_num': 1, 'port_priority': 3, 'tp_type': 5, 'port_path_cost': 32, 'port_spanning_tree_in': 1, 'lan_fcs_ind': 0, 'bridge_id_pointer': 1} |
| 1080 | # | omci_trailer= 40 |
| 1081 | |
| 1082 | # Found in method: pmc_omci_mac_bridge_pcd_me_create from: PMC_OFAL.c |
| 1083 | # Params |
| 1084 | # - port_path_cost: The cost contribution of the port to the path cost towards the spanning tree root bridge |
| 1085 | # - bridge_id_pointer: MAC bridge controlling the port |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1086 | msg = OmciCreate(entity_class=47, entity_id=1, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1087 | data=dict( |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1088 | tp_pointer=1, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1089 | encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1090 | port_num=1, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1091 | port_priority=10, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1092 | tp_type=3, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1093 | port_path_cost=100, |
| 1094 | port_spanning_tree_in=PON_FALSE, |
| 1095 | lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED, |
| 1096 | bridge_id_pointer=1 |
| 1097 | )) |
| 1098 | |
| 1099 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1100 | message_type=OmciCreate.message_id, |
| 1101 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1102 | |
| 1103 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1104 | log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_allocate") |
| 1105 | |
| 1106 | def pmc_omci_gem_nctp_me_allocate(self, device): |
| 1107 | # |###[ OmciFrame ]### |
| 1108 | # | transaction_id= 9 |
| 1109 | # | message_type= 68 |
| 1110 | # | omci = 10 |
| 1111 | # | \omci_message\ |
| 1112 | # | |###[ OmciCreate ]### |
| 1113 | # | | entity_class= 268 |
| 1114 | # | | entity_id = 1 |
| 1115 | # | | data = {'priority_queue_pointer_downstream': 0, 'direction': 3, 'tcont_pointer': 32769, 'traffic_descriptor_profile_pointer': 0, 'traffic_management_pointer_upstream': 4, 'port_id': 1000} |
| 1116 | # | omci_trailer= 40 |
| 1117 | |
| 1118 | # Found in method: pmc_omci_gem_nctp_create from: PMC_OFAL.c |
| 1119 | msg = OmciCreate(entity_class=268, entity_id=1, |
| 1120 | data=dict( |
| 1121 | priority_queue_pointer_downstream=0, # 0 for default |
| 1122 | direction=GEM_DIR_BIDIRECT, |
| 1123 | tcont_pointer=32769, |
| 1124 | traffic_descriptor_profile_pointer=0, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1125 | traffic_management_pointer_upstream=4, # 4 for feault |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1126 | # Same as GEM port |
| 1127 | # port_id=(1000 + device.proxy_address.onu_id) |
| 1128 | port_id = self.port_id |
| 1129 | )) |
| 1130 | |
| 1131 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1132 | message_type=OmciCreate.message_id, |
| 1133 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1134 | |
| 1135 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1136 | log.debug("[SENT] pmc_omci_gem_nctp_me_allocate") |
| 1137 | |
| 1138 | def pmc_omci_gem_iwtp_me_allocate(self, device): |
| 1139 | # |###[ OmciFrame ]### |
| 1140 | # | transaction_id= 10 |
| 1141 | # | message_type= 68 |
| 1142 | # | omci = 10 |
| 1143 | # | \omci_message\ |
| 1144 | # | |###[ OmciCreate ]### |
| 1145 | # | | entity_class= 266 |
| 1146 | # | | entity_id = 1 |
| 1147 | # | | data = {'gem_port_network_ctp_pointer': 1, 'gal_profile_pointer': 0, 'service_profile_pointer': 1, 'interworking_option': 5, 'interworking_tp_pointer': 0} |
| 1148 | # | omci_trailer= 40 |
| 1149 | |
| 1150 | # Found in method: pmc_omci_gem_iwtp_me_create from: PMC_OFAL.c |
| 1151 | # Params |
| 1152 | # - gem_port_network_ctp_pointer: An instance identifier of the GEM Port Network CTP that is associated with this GEM Interworking Termination Point |
| 1153 | # - service_profile_pointer: The service profile type and a pointer to the instance of a service profile |
| 1154 | # - interworking_tp_pointer: Used for in the case of Circuit Emulation Services and 802.1p mapper service |
| 1155 | # - gal_profile_pointer: A pointer to an instance of the GAL Profile |
| 1156 | |
| 1157 | msg = OmciCreate(entity_class=266, entity_id=1, |
| 1158 | data=dict( |
| 1159 | gem_port_network_ctp_pointer=1, |
| 1160 | gal_profile_pointer=0, |
| 1161 | service_profile_pointer=1, |
| 1162 | interworking_option=OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER, |
| 1163 | interworking_tp_pointer=0 |
| 1164 | )) |
| 1165 | |
| 1166 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1167 | message_type=OmciCreate.message_id, |
| 1168 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1169 | |
| 1170 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1171 | log.debug("[SENT] pmc_omci_gem_iwtp_me_allocate") |
| 1172 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1173 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1174 | |
| 1175 | def send_create_extended_vlan_tagging_operation_configuration_data(self, device): |
| 1176 | |
| 1177 | msg = OmciCreate(entity_class=171, |
| 1178 | entity_id=0, |
| 1179 | data=dict( |
| 1180 | association_type=2, |
| 1181 | associated_me_pointer=257 |
| 1182 | )) |
| 1183 | |
| 1184 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1185 | message_type=OmciCreate.message_id, |
| 1186 | omci_message=msg) |
| 1187 | |
| 1188 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
| 1189 | log.debug( |
| 1190 | "[SENT] create_extended_vlan_tagging_operation_configuration_data") |
| 1191 | |
| 1192 | # self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100) |
| 1193 | def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, device): |
| 1194 | |
| 1195 | data = dict( |
| 1196 | association_type=2, |
| 1197 | input_tpid=33024, |
| 1198 | associated_me_pointer=257, |
| 1199 | downstream_mode=OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE, |
| 1200 | output_tpid=33024, |
| 1201 | ) |
| 1202 | |
| 1203 | msg = OmciSet(entity_class=171, |
| 1204 | entity_id=0, |
| 1205 | attributes_mask=47616, # 1024 in broadcom but 47616 observed from PMC |
| 1206 | data=data |
| 1207 | ) |
| 1208 | |
| 1209 | frame = OmciFrame( |
| 1210 | transaction_id=self.trangen.next(), |
| 1211 | message_type=OmciSet.message_id, |
| 1212 | omci_message=msg |
| 1213 | ) |
| 1214 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
| 1215 | log.debug( |
| 1216 | "[SENT] set_extended_vlan_tagging_operation_tpid_configuration_data") |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1217 | |
| 1218 | @inlineCallbacks |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1219 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self, device, cvlan_id, subs_vlan): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1220 | # ###[ PAS5211MsgSendFrame ]### |
| 1221 | # length = 44 |
| 1222 | # port_type = 0 |
| 1223 | # port_id = 0 |
| 1224 | # management_frame= 1 |
| 1225 | # \frame \ |
| 1226 | # |###[ OmciFrame ]### |
| 1227 | # | transaction_id= 14 |
| 1228 | # | message_type= 72 |
| 1229 | # | omci = 10 |
| 1230 | # | \omci_message\ |
| 1231 | # | |###[ OmciSet ]### |
| 1232 | # | | entity_class= 171 |
| 1233 | # | | entity_id = 0 |
| 1234 | # | | attributes_mask= 1024 |
| 1235 | # | | data = {'received_frame_vlan_tagging_operation_table': '\xf8\x00\x00\x00\x00\x00@\x00@\x0f\x00\x04\x00\x00\x00\x0c'} |
| 1236 | # | omci_trailer= 40 |
| 1237 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1238 | # TODO Check filter_inner_priority value |
| 1239 | """vlan_oper_table_entry.filter_configuration.filter_inner_tagging.vlan_priority = filter_inner_vlan_pcp; |
| 1240 | vlan_oper_table_entry.filter_configuration.filter_inner_tagging.vlan_vid = filter_inner_vlan_id; |
| 1241 | """ |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1242 | self.send_vlan_tagging_operation_msg(device, |
| 1243 | VlanTaggingOperation( |
| 1244 | filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG, |
| 1245 | filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE, |
| 1246 | filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE, |
| 1247 | |
| 1248 | filter_inner_priority=0, |
| 1249 | filter_inner_vid=subs_vlan, |
| 1250 | filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_8100, |
| 1251 | filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE, |
| 1252 | |
| 1253 | treatment_tags_to_remove=1, |
| 1254 | treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE, |
| 1255 | treatment_outer_vid=0, |
| 1256 | treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100, |
| 1257 | |
| 1258 | treatment_inner_priority=0, |
| 1259 | treatment_inner_vid=cvlan_id, |
| 1260 | treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100 |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1261 | ) |
| 1262 | ) |
| 1263 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1264 | |
| 1265 | log.debug( |
| 1266 | "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1267 | |
| 1268 | if OmciSetResponse not in response: |
| 1269 | log.error("Failed to set vlan extended table entry {}".format( |
| 1270 | device.proxy_address)) |
| 1271 | returnValue(False) |
| 1272 | |
| 1273 | log.debug( |
| 1274 | "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1275 | |
| 1276 | self.send_vlan_tagging_operation_msg(device, |
| 1277 | VlanTaggingOperation( |
| 1278 | filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG, |
| 1279 | filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE, |
| 1280 | filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE, |
| 1281 | |
| 1282 | filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG, |
| 1283 | filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE, |
| 1284 | filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE, |
| 1285 | filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE, |
| 1286 | |
| 1287 | treatment_tags_to_remove=3, |
| 1288 | treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE, |
| 1289 | treatment_outer_vid=0, |
| 1290 | treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER, |
| 1291 | |
| 1292 | treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE, |
| 1293 | treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER, |
| 1294 | treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1295 | ) |
| 1296 | ) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1297 | |
| 1298 | log.debug( |
| 1299 | "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1300 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1301 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1302 | if OmciSetResponse not in response: |
| 1303 | log.error("Failed to set vlan extended table entry {}".format( |
| 1304 | device.proxy_address)) |
| 1305 | returnValue(False) |
| 1306 | |
| 1307 | log.debug( |
| 1308 | "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1309 | |
| 1310 | self.send_vlan_tagging_operation_msg(device, |
| 1311 | VlanTaggingOperation( |
| 1312 | filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG, |
| 1313 | filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE, |
| 1314 | filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE, |
| 1315 | |
| 1316 | filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT, |
| 1317 | filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE, |
| 1318 | filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE, |
| 1319 | filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE, |
| 1320 | |
| 1321 | treatment_tags_to_remove=3, |
| 1322 | treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE, |
| 1323 | treatment_outer_vid=0, |
| 1324 | treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER, |
| 1325 | |
| 1326 | treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE, |
| 1327 | treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER, |
| 1328 | treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1329 | ) |
| 1330 | ) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1331 | |
| 1332 | log.debug( |
| 1333 | "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1334 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1335 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1336 | if OmciSetResponse not in response: |
| 1337 | log.error("Failed to set vlan extended table entry {}".format( |
| 1338 | device.proxy_address)) |
| 1339 | returnValue(False) |
| 1340 | |
| 1341 | log.debug( |
| 1342 | "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1343 | |
| 1344 | self.send_vlan_tagging_operation_msg(device, |
| 1345 | VlanTaggingOperation( |
| 1346 | filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT, |
| 1347 | filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE, |
| 1348 | filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE, |
| 1349 | |
| 1350 | filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT, |
| 1351 | filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE, |
| 1352 | filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE, |
| 1353 | filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE, |
| 1354 | |
| 1355 | treatment_tags_to_remove=3, |
| 1356 | treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE, |
| 1357 | treatment_outer_vid=0, |
| 1358 | treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER, |
| 1359 | |
| 1360 | treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE, |
| 1361 | treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER, |
| 1362 | treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1363 | ) |
| 1364 | ) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1365 | |
| 1366 | log.debug( |
| 1367 | "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1368 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1369 | response = yield self.wait_for_response() |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1370 | if OmciSetResponse not in response: |
| 1371 | log.error("Failed to set vlan extended table entry {}".format( |
| 1372 | device.proxy_address)) |
| 1373 | returnValue(False) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1374 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1375 | log.debug( |
| 1376 | "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data") |
| 1377 | |
| 1378 | returnValue(True) |
| 1379 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1380 | |
| 1381 | def send_vlan_tagging_operation_msg(self, device, vlan_tagging_operation_table): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1382 | |
| 1383 | data = dict( |
| 1384 | received_frame_vlan_tagging_operation_table=vlan_tagging_operation_table |
| 1385 | ) |
| 1386 | |
| 1387 | msg = OmciSet( |
| 1388 | entity_class=171, |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1389 | entity_id=0, |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1390 | attributes_mask=1024, |
| 1391 | data=data |
| 1392 | ) |
| 1393 | |
| 1394 | frame = OmciFrame( |
| 1395 | transaction_id=self.trangen.next(), |
| 1396 | message_type=OmciSet.message_id, |
| 1397 | omci_message=msg |
| 1398 | ) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1399 | |
| 1400 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1401 | log.debug("[SENT] create_vlan_tagging_filter_data") |
| 1402 | |
| 1403 | def send_create_vlan_tagging_filter_data(self, device, cvlan_id): |
| 1404 | # ###[ PAS5211MsgSendFrame ]### |
| 1405 | # length = 44 |
| 1406 | # port_type = 0 |
| 1407 | # port_id = 0 |
| 1408 | # management_frame= 1 |
| 1409 | # \frame \ |
| 1410 | # |###[ OmciFrame ]### |
| 1411 | # | transaction_id= 18 |
| 1412 | # | message_type= 68 |
| 1413 | # | omci = 10 |
| 1414 | # | \omci_message\ |
| 1415 | # | |###[ OmciCreate ]### |
| 1416 | # | | entity_class= 84 |
| 1417 | # | | entity_id = 2 |
| 1418 | # | | data = {'vlan_filter_0': 1, 'vlan_filter_1': 0, 'vlan_filter_2': 0, 'vlan_filter_3': 0, 'vlan_filter_4': 0, 'vlan_filter_5': 0, 'vlan_filter_6': 0, 'vlan_filter_7': 0, 'vlan_filter_8': 0, 'vlan_filter_9': 0, 'number_of_entries': 1, 'forward_operation': 16, 'vlan_filter_10': 0, 'vlan_filter_11': 0} |
| 1419 | # | omci_trailer= 40 |
| 1420 | |
| 1421 | data = dict( |
| 1422 | vlan_filter_0=cvlan_id, |
| 1423 | forward_operation=16, |
| 1424 | number_of_entries=1 |
| 1425 | ) |
| 1426 | |
| 1427 | msg = OmciCreate( |
| 1428 | entity_class=84, |
| 1429 | entity_id=1, |
| 1430 | data=data |
| 1431 | ) |
| 1432 | |
| 1433 | frame = OmciFrame( |
| 1434 | transaction_id=self.trangen.next(), |
| 1435 | message_type=OmciCreate.message_id, |
| 1436 | omci_message=msg |
| 1437 | ) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1438 | |
| 1439 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1440 | log.debug("[SENT] create_vlan_tagging_filter_data") |
| 1441 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1442 | def pmc_ofal_remove_default_onu_flow_omci(self, device): # TODO |
| 1443 | # ###[ PAS5211Dot3 ]### |
| 1444 | # dst = 00:0 |
| 1445 | # c: d5:00: 04:10 |
| 1446 | # src = 02:00: d3:77: 47:49 |
| 1447 | # len = 74 |
| 1448 | # ###[ PAS5211FrameHeader ]### |
| 1449 | # part = 1 |
| 1450 | # total_parts = 1 |
| 1451 | # size = 68 |
| 1452 | # magic_number = 0x1234abcd |
| 1453 | # ###[ PAS5211MsgHeader ]### |
| 1454 | # sequence_number = 201 |
| 1455 | # opcode = 0x302a |
| 1456 | # event_type = 0 |
| 1457 | # channel_id = 1 |
| 1458 | # onu_id = 0 |
| 1459 | # onu_session_id = 1 |
| 1460 | # ###[ PAS5211MsgSendFrame ]### |
| 1461 | # length = 44 |
| 1462 | # port_type = 0 |
| 1463 | # port_id = 0 |
| 1464 | # management_frame = 1 |
| 1465 | # \frame \ |
| 1466 | # | ###[ OmciFrame ]### |
| 1467 | # | transaction_id = 44 |
| 1468 | # | message_type = 70 |
| 1469 | # | omci = 10 |
| 1470 | # | \omci_message \ |
| 1471 | # | | ###[ OmciDelete ]### |
| 1472 | # | | entity_class = 47 |
| 1473 | # | | entity_id = 1 |
| 1474 | # | omci_trailer = 40 |
| 1475 | log.debug("[SENT] pmc_ofal_remove_default_onu_flow_omci") |
| 1476 | pass |
| 1477 | |
| 1478 | def pmc_omci_evto_vlan_oper_table_entry_assign(self, device): # TODO |
| 1479 | |
| 1480 | # /* Fill the set message */ |
| 1481 | # entity.entity_class = OMCI_ENT_EX_VLAN_TAGGING_OPER_CONFIG_DATA; |
| 1482 | # entity.entity_instance = entity_instance; |
| 1483 | # set_req_msg.attr_mask = attributes_mask; |
| 1484 | |
| 1485 | # typedef struct OMCI_ex_vlan_tagging_operation_config_me_set_t |
| 1486 | # { |
| 1487 | # INT8U association_type; /* Association type ,R,W,C (ASSOCIATION_TYPE_)*/ |
| 1488 | # INT16U input_tpid; /* Input TPID value ,R,W (16 bit value)*/ |
| 1489 | # INT16U output_tpid; /* Output TPID value ,R,W (16 bit value)*/ |
| 1490 | # INT8U downstream_mode; /* downstream mode ,R,W (OCD_DS_MODE_)*/ |
| 1491 | # |
| 1492 | # OMCI_ex_vlan_tag_op_table_entry_t /* Operation entry ,R,W (16 bytes) */ |
| 1493 | # operations_entry; |
| 1494 | # |
| 1495 | # OMCI_instance_id_t associated_me_ptr; |
| 1496 | # |
| 1497 | # INT8U dscp2pbit_mapping[OMCI_EX_VLAN_TAG_ATTR_DSCP2PBIT_MAPPING_SIZE];/*dscp-to-pbit mapping ,R,W (24 bytes)*/ |
| 1498 | # |
| 1499 | # } OMCI_ex_vlan_tagging_operation_config_me_set_t; |
| 1500 | |
| 1501 | # attibute_mask = 0 |
| 1502 | # # attibute_mask |= ( (INT16U)1 << ((OMCI_ATTR_MAX-1)-(OMCI_EX_VLAN_TAG_OCD_ATTR_RX_FRAME_OP_TABLE))) |
| 1503 | # msg = OmciSet(entity_class=OMCI_ENT_EX_VLAN_TAGGING_OPER_CONFIG_DATA, entity_id=0, attributes_mask=attibute_mask, |
| 1504 | # data=dict( |
| 1505 | # association_type=, |
| 1506 | # input_tpid=, |
| 1507 | # output_tpid=, |
| 1508 | # downstream_mode=, |
| 1509 | # associated_me_pointer=, |
| 1510 | # dscp2pbit_mapping= |
| 1511 | # )) |
| 1512 | |
| 1513 | # frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1514 | # message_type=OmciSet.message_id, |
| 1515 | # omci_message=msg) |
| 1516 | |
| 1517 | # self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
| 1518 | |
| 1519 | # TODO: Sends up to three OMCI Set messages |
| 1520 | log.debug("[SENT] pmc_omci_evto_vlan_oper_table_entry_assign") |
| 1521 | pass |
| 1522 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1523 | @inlineCallbacks |
| 1524 | def pmc_omci_vlan_tagging_filter_me_allocate(self, device): # TODO |
| 1525 | |
| 1526 | self.OMCI_vlan_tagging_filter_get(device) |
| 1527 | response = yield self.incoming_messages.get() |
| 1528 | if OmciGetResponse not in response: |
| 1529 | log.error("Failed to Get vlan tagging filter {}".format( |
| 1530 | device.proxy_address)) |
| 1531 | return |
| 1532 | |
| 1533 | # if: # OMCI Get is sucessfull |
| 1534 | # # OMCI_vlan_tagging_filter_create |
| 1535 | # else: |
| 1536 | # # OMCI_vlan_tagging_filter_set |
| 1537 | log.debug("[SENT] pmc_omci_vlan_tagging_filter_me_allocate") |
| 1538 | pass |
| 1539 | |
| 1540 | def pmc_omci_8021p_msp_me_assign(self, device): |
| 1541 | |
| 1542 | # ###[ PAS5211MsgSendFrame ]### |
| 1543 | # length = 44 |
| 1544 | # port_type = 0 |
| 1545 | # port_id = 0 |
| 1546 | # management_frame= 1 |
| 1547 | # \frame \ |
| 1548 | # |###[ OmciFrame ]### |
| 1549 | # | transaction_id= 21 |
| 1550 | # | message_type= 72 |
| 1551 | # | omci = 10 |
| 1552 | # | \omci_message\ |
| 1553 | # | |###[ OmciSet ]### |
| 1554 | # | | entity_class= 130 |
| 1555 | # | | entity_id = 2 |
| 1556 | # | | attributes_mask= 16472 |
| 1557 | # | | data = {'tp_type': 0, 'unmarked_frame_option': 1, 'interwork_tp_pointer_for_p_bit_priority_0': 2, 'default_p_bit_marking': 0} |
| 1558 | # | omci_trailer= 40 |
| 1559 | |
| 1560 | data = dict(tp_type=0, |
| 1561 | output_tpid=33024, |
| 1562 | unmarked_frame_option=1, |
| 1563 | interwork_tp_pointer_for_p_bit_priority_0=1, |
| 1564 | default_p_bit_marking=0 |
| 1565 | ) |
| 1566 | |
| 1567 | msg = OmciSet(entity_class=130, |
| 1568 | entity_id=1, |
| 1569 | attributes_mask=16472, |
| 1570 | data=data |
| 1571 | ) |
| 1572 | |
| 1573 | frame = OmciFrame( |
| 1574 | transaction_id=self.trangen.next(), |
| 1575 | message_type=OmciSet.message_id, |
| 1576 | omci_message=msg |
| 1577 | ) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1578 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1579 | |
| 1580 | log.debug("[SENT] pmc_omci_8021p_msp_me_assign") |
| 1581 | |
| 1582 | def pmc_ofal_recover_default_onu_flow_omci(self, device): |
| 1583 | log.debug("[SENT] pmc_ofal_recover_default_onu_flow_omci") |
| 1584 | pass |
| 1585 | |
| 1586 | def OMCI_vlan_tagging_filter_get(self, device): |
| 1587 | # entity_class: OMCI_ENT_VLAN_TAGGING_FILT_DATA |
| 1588 | # entity_instance: mac_bridge_pcd |
| 1589 | # attr_mask = 0 |
| 1590 | # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_FILTER_TABLE); |
| 1591 | # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_FWD_OP); |
| 1592 | # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_NOF_ENTRIES); |
| 1593 | log.debug("[SENT] OMCI_vlan_tagging_filter_get") |
| 1594 | pass |
| 1595 | |
| 1596 | def OMCI_vlan_tagging_filter_create(self, device): # TODO |
| 1597 | log.debug("[SENT] OMCI_vlan_tagging_filter_create") |
| 1598 | pass |
| 1599 | |
| 1600 | def OMCI_vlan_tagging_filter_set(self, device): # TODO |
| 1601 | log.debug("[SENT] OMCI_vlan_tagging_filter_set") |
| 1602 | pass |
| 1603 | |
| 1604 | """ - - - - - - - END create_data_flow_omci_config - - - - - - - """ |
| 1605 | |
| 1606 | """ - - - - - - - delete_data_flow_omci_config - - - - - - - """ |
| 1607 | |
| 1608 | def pmc_omci_gem_iwtp_me_deallocate(self, device): |
| 1609 | # |###[ OmciFrame ]### |
| 1610 | # | transaction_id= 34 |
| 1611 | # | message_type= 70 |
| 1612 | # | omci = 10 |
| 1613 | # | \omci_message\ |
| 1614 | # | |###[ OmciDelete ]### |
| 1615 | # | | entity_class= 266 |
| 1616 | # | | entity_id = 2 |
| 1617 | # | omci_trailer= 40 |
| 1618 | msg = OmciDelete(entity_class=266, entity_id=1) |
| 1619 | |
| 1620 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1621 | message_type=OmciDelete.message_id, |
| 1622 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1623 | |
| 1624 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1625 | log.debug("[SENT] pmc_omci_gem_iwtp_me_deallocate") |
| 1626 | |
| 1627 | def pmc_omci_gem_nctp_me_deallocate(self, device): |
| 1628 | # |###[ OmciFrame ]### |
| 1629 | # | transaction_id= 35 |
| 1630 | # | message_type= 70 |
| 1631 | # | omci = 10 |
| 1632 | # | \omci_message\ |
| 1633 | # | |###[ OmciDelete ]### |
| 1634 | # | | entity_class= 268 |
| 1635 | # | | entity_id = 2 |
| 1636 | # | omci_trailer= 40 |
| 1637 | msg = OmciDelete(entity_class=268, entity_id=1) |
| 1638 | |
| 1639 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1640 | message_type=OmciDelete.message_id, |
| 1641 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1642 | |
| 1643 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1644 | log.debug("[SENT] pmc_omci_gem_nctp_me_allocate") |
| 1645 | |
| 1646 | def pmc_omci_vlan_tagging_filter_me_deallocate(self, device): |
| 1647 | # |###[ OmciFrame ]### |
| 1648 | # | transaction_id= 36 |
| 1649 | # | message_type= 70 |
| 1650 | # | omci = 10 |
| 1651 | # | \omci_message\ |
| 1652 | # | |###[ OmciDelete ]### |
| 1653 | # | | entity_class= 84 |
| 1654 | # | | entity_id = 2 |
| 1655 | # | omci_trailer= 40 |
| 1656 | msg = OmciDelete(entity_class=84, entity_id=1) |
| 1657 | |
| 1658 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1659 | message_type=OmciDelete.message_id, |
| 1660 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1661 | |
| 1662 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1663 | log.debug("[SENT] pmc_omci_vlan_tagging_filter_me_deallocate") |
| 1664 | |
| 1665 | |
| 1666 | def pmc_omci_mac_bridge_pcd_me_deallocate(self, device): |
| 1667 | # |###[ OmciFrame ]### |
| 1668 | # | transaction_id= 37 |
| 1669 | # | message_type= 70 |
| 1670 | # | omci = 10 |
| 1671 | # | \omci_message\ |
| 1672 | # | |###[ OmciDelete ]### |
| 1673 | # | | entity_class= 47 |
| 1674 | # | | entity_id = 2 |
| 1675 | # | omci_trailer= 40 |
| 1676 | msg = OmciDelete(entity_class=47, entity_id=1) |
| 1677 | |
| 1678 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1679 | message_type=OmciDelete.message_id, |
| 1680 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1681 | |
| 1682 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1683 | log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_deallocate") |
| 1684 | |
| 1685 | |
| 1686 | |
| 1687 | def pmc_omci_8021p_msp_me_deallocate(self, device): |
| 1688 | # |###[ OmciFrame ]### |
| 1689 | # | transaction_id= 38 |
| 1690 | # | message_type= 70 |
| 1691 | # | omci = 10 |
| 1692 | # | \omci_message\ |
| 1693 | # | |###[ OmciDelete ]### |
| 1694 | # | | entity_class= 130 |
| 1695 | # | | entity_id = 2 |
| 1696 | # | omci_trailer= 40 |
| 1697 | msg = OmciDelete(entity_class=130, entity_id=1) |
| 1698 | |
| 1699 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1700 | message_type=OmciDelete.message_id, |
| 1701 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1702 | |
| 1703 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1704 | log.debug("[SENT] pmc_omci_8021p_msp_me_deallocate") |
| 1705 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1706 | def pmc_omci_evto_deallocate(self, device): |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1707 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1708 | msg = OmciDelete(entity_class=171, entity_id=1) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1709 | |
| 1710 | frame = OmciFrame(transaction_id=self.trangen.next(), |
| 1711 | message_type=OmciDelete.message_id, |
| 1712 | omci_message=msg) |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1713 | self.adapter_agent.send_proxied_message(device.proxy_address, frame) |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1714 | log.debug("[SENT] pmc_omci_evto_deallocate") |
| 1715 | |
| 1716 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1717 | |
Daniel Velasco | f75c580 | 2018-05-02 10:52:49 +0200 | [diff] [blame] | 1718 | """ - - - - - - - END delete_data_flow_omci_config - - - - - - - """ |
| 1719 | |
Daniel Velasco | 8884617 | 2018-06-08 09:02:23 +0200 | [diff] [blame^] | 1720 | |
| 1721 | |
| 1722 | |
| 1723 | |