Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2018 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 | # |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 16 | |
Matt Jeanneret | 2e3cb8d | 2019-11-16 09:22:41 -0500 | [diff] [blame] | 17 | from __future__ import absolute_import |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 18 | import structlog |
Matt Jeanneret | 72f96fc | 2019-02-11 10:53:05 -0500 | [diff] [blame] | 19 | from pyvoltha.adapters.extensions.omci.tasks.task import Task |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 20 | from twisted.internet import reactor |
| 21 | from twisted.internet.defer import inlineCallbacks, failure, returnValue |
Matt Jeanneret | 72f96fc | 2019-02-11 10:53:05 -0500 | [diff] [blame] | 22 | from pyvoltha.adapters.extensions.omci.omci_defs import ReasonCodes, EntityOperations |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 23 | from pyvoltha.adapters.extensions.omci.omci_entities import VlanTaggingFilterData |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 24 | from pyvoltha.adapters.extensions.omci.omci_me import \ |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 25 | VlanTaggingOperation, VlanTaggingFilterDataFrame, ExtendedVlanTaggingOperationConfigurationDataFrame, \ |
| 26 | ExtendedVlanTaggingOperationConfigurationData |
Matt Jeanneret | 2e3cb8d | 2019-11-16 09:22:41 -0500 | [diff] [blame] | 27 | from uni_port import UniType |
Andrea Campanella | cf916ea | 2020-02-14 10:03:58 +0100 | [diff] [blame] | 28 | from uni_port import RESERVED_TRANSPARENT_VLAN |
Matt Jeanneret | 2e3cb8d | 2019-11-16 09:22:41 -0500 | [diff] [blame] | 29 | from pon_port import DEFAULT_TPID |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 30 | |
| 31 | RC = ReasonCodes |
| 32 | OP = EntityOperations |
| 33 | |
| 34 | |
| 35 | class BrcmVlanFilterException(Exception): |
| 36 | pass |
| 37 | |
| 38 | |
| 39 | class BrcmVlanFilterTask(Task): |
| 40 | """ |
| 41 | Apply Vlan Tagging Filter Data and Extended VLAN Tagging Operation Configuration on an ANI and UNI |
| 42 | """ |
| 43 | task_priority = 200 |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 44 | name = "Broadcom VLAN Filter/Tagging Task" |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 45 | |
Mahir Gunyel | d680cb6 | 2020-02-18 10:28:12 -0800 | [diff] [blame] | 46 | def __init__(self, omci_agent, handler, uni_port, set_vlan_id, |
| 47 | match_vlan=0, set_vlan_pcp=8, add_tag=True, |
| 48 | priority=task_priority, tp_id=0): |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 49 | """ |
| 50 | Class initialization |
| 51 | |
| 52 | :param omci_agent: (OmciAdapterAgent) OMCI Adapter agent |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 53 | :param handler: (BrcmOpenomciOnuHandler) ONU Device Handler Instance |
| 54 | :param uni_port: (UniPort) Object instance representing the uni port and its settings |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 55 | :param set_vlan_id: (int) VLAN to filter for and set |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 56 | :param add_tag: (bool) Flag to identify VLAN Tagging or Untagging |
Girish Gowdra | a73ee45 | 2019-12-20 18:52:17 +0530 | [diff] [blame] | 57 | :param tp_id: (int) TP ID for the flow |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 58 | :param priority: (int) OpenOMCI Task priority (0..255) 255 is the highest |
| 59 | """ |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 60 | super(BrcmVlanFilterTask, self).__init__(BrcmVlanFilterTask.name, |
| 61 | omci_agent, |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 62 | handler.device_id, |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 63 | priority=priority, |
| 64 | exclusive=True) |
Matt Jeanneret | 08a8e86 | 2019-12-20 14:02:32 -0500 | [diff] [blame] | 65 | |
| 66 | self.log = structlog.get_logger(device_id=handler.device_id, |
| 67 | name=BrcmVlanFilterTask.name, |
| 68 | task_id=self._task_id, |
| 69 | entity_id=uni_port.entity_id, |
| 70 | uni_id=uni_port.uni_id, |
| 71 | uni_port=uni_port.port_number, |
| 72 | set_vlan_id=set_vlan_id) |
| 73 | |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 74 | self._onu_handler = handler |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 75 | self._device = omci_agent.get_device(handler.device_id) |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 76 | self._uni_port = uni_port |
| 77 | self._set_vlan_id = set_vlan_id |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 78 | |
| 79 | # If not setting any pbit, copy the pbit from the received vlan tag |
| 80 | if set_vlan_pcp is None: |
| 81 | self._set_vlan_pcp = 8 # Copy from the inner priority of the received frame |
| 82 | else: |
| 83 | self._set_vlan_pcp = set_vlan_pcp |
| 84 | |
| 85 | # If not matching on any vlan do not filter for vlan value. effectively match on untagged |
| 86 | if match_vlan is None: |
| 87 | self._match_vlan = RESERVED_TRANSPARENT_VLAN # Do not filter on the VID |
| 88 | else: |
| 89 | self._match_vlan = match_vlan |
| 90 | |
| 91 | self._vlan_pcp = 8 # Do not filter on priority |
| 92 | |
| 93 | # If the tag is not transparent then need to remove it. |
| 94 | self._treatment_tags_to_remove = 1 |
| 95 | if self._match_vlan == RESERVED_TRANSPARENT_VLAN: # Do not filter on the VID |
| 96 | self._vlan_pcp = 15 # This entry is a no-tag rule; ignore all other VLAN tag filter fields |
| 97 | self._treatment_tags_to_remove = 0 |
| 98 | |
| 99 | # If matching on untagged and trying to copy pbit from non-existent received vlan, set pbit to zero |
| 100 | if self._match_vlan == RESERVED_TRANSPARENT_VLAN and self._set_vlan_pcp == 8: |
| 101 | self._set_vlan_pcp = 0 |
| 102 | |
Mahir Gunyel | a982ec3 | 2020-02-25 12:30:37 -0800 | [diff] [blame] | 103 | self._add_tag = add_tag |
Girish Gowdra | a73ee45 | 2019-12-20 18:52:17 +0530 | [diff] [blame] | 104 | self._tp_id = tp_id |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 105 | self._results = None |
| 106 | self._local_deferred = None |
| 107 | self._config = self._device.configuration |
Matt Jeanneret | 810148b | 2019-09-29 12:44:01 -0400 | [diff] [blame] | 108 | self._input_tpid = DEFAULT_TPID |
| 109 | self._output_tpid = DEFAULT_TPID |
| 110 | |
| 111 | self._mac_bridge_service_profile_entity_id = \ |
| 112 | handler.mac_bridge_service_profile_entity_id |
| 113 | self._ieee_mapper_service_profile_entity_id = \ |
| 114 | handler.pon_port.ieee_mapper_service_profile_entity_id |
| 115 | self._mac_bridge_port_ani_entity_id = \ |
| 116 | handler.pon_port.mac_bridge_port_ani_entity_id |
| 117 | self._gal_enet_profile_entity_id = \ |
| 118 | handler.gal_enet_profile_entity_id |
| 119 | |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 120 | def cancel_deferred(self): |
| 121 | super(BrcmVlanFilterTask, self).cancel_deferred() |
| 122 | |
| 123 | d, self._local_deferred = self._local_deferred, None |
| 124 | try: |
| 125 | if d is not None and not d.called: |
| 126 | d.cancel() |
| 127 | except: |
| 128 | pass |
| 129 | |
| 130 | def start(self): |
| 131 | """ |
| 132 | Start Vlan Tagging Task |
| 133 | """ |
| 134 | super(BrcmVlanFilterTask, self).start() |
| 135 | self._local_deferred = reactor.callLater(0, self.perform_vlan_tagging) |
| 136 | |
| 137 | @inlineCallbacks |
| 138 | def perform_vlan_tagging(self): |
| 139 | """ |
| 140 | Perform the vlan tagging |
| 141 | """ |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 142 | self.log.debug('vlan-filter-tagging-task', uni_port=self._uni_port, set_vlan_id=self._set_vlan_id, |
| 143 | set_vlan_pcp=self._set_vlan_pcp, match_vlan=self._match_vlan, tp_id=self._tp_id, |
| 144 | add_tag=self._add_tag) |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 145 | try: |
Mahir Gunyel | a982ec3 | 2020-02-25 12:30:37 -0800 | [diff] [blame] | 146 | if self._add_tag: |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 147 | if not self._onu_handler.args.accept_incremental_evto_update: |
| 148 | yield self._bulk_update_evto_and_vlan_tag_filter() |
Mahir Gunyel | a982ec3 | 2020-02-25 12:30:37 -0800 | [diff] [blame] | 149 | else: |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 150 | yield self._incremental_update_evto_and_vlan_tag_filter() |
| 151 | else: # addTag = False |
| 152 | if self._onu_handler.args.accept_incremental_evto_update: |
| 153 | self.log.info('removing-vlan-tagging') |
| 154 | yield self._delete_service_flow() |
| 155 | yield self._delete_vlan_filter_entity() |
| 156 | else: |
| 157 | # Will be reset anyway on new vlan tagging operation |
| 158 | self.log.info("not-removing-vlan-tagging") |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 159 | self.deferred.callback(self) |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 160 | except Exception as e: |
| 161 | self.log.exception('setting-vlan-tagging', e=e) |
| 162 | self.deferred.errback(failure.Failure(e)) |
| 163 | |
| 164 | def check_status_and_state(self, results, operation=''): |
| 165 | """ |
| 166 | Check the results of an OMCI response. An exception is thrown |
| 167 | if the task was cancelled or an error was detected. |
| 168 | |
| 169 | :param results: (OmciFrame) OMCI Response frame |
| 170 | :param operation: (str) what operation was being performed |
| 171 | :return: True if successful, False if the entity existed (already created) |
| 172 | """ |
| 173 | |
| 174 | omci_msg = results.fields['omci_message'].fields |
| 175 | status = omci_msg['success_code'] |
| 176 | error_mask = omci_msg.get('parameter_error_attributes_mask', 'n/a') |
| 177 | failed_mask = omci_msg.get('failed_attributes_mask', 'n/a') |
| 178 | unsupported_mask = omci_msg.get('unsupported_attributes_mask', 'n/a') |
| 179 | |
Matt Jeanneret | e8fc53e | 2019-04-13 15:58:33 -0400 | [diff] [blame] | 180 | self.log.debug("OMCI Result", operation=operation, omci_msg=omci_msg, |
Matt Jeanneret | f1e9c5d | 2019-02-08 07:41:29 -0500 | [diff] [blame] | 181 | status=status, error_mask=error_mask, |
| 182 | failed_mask=failed_mask, unsupported_mask=unsupported_mask) |
| 183 | |
| 184 | if status == RC.Success: |
| 185 | self.strobe_watchdog() |
| 186 | return True |
| 187 | |
| 188 | elif status == RC.InstanceExists: |
| 189 | return False |
Harsh Awasthi | b10a708 | 2019-08-26 02:17:33 -0400 | [diff] [blame] | 190 | |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 191 | @inlineCallbacks |
| 192 | def _delete_service_flow(self): |
| 193 | extended_vlan_tagging_entity_id = self._mac_bridge_service_profile_entity_id + \ |
| 194 | self._uni_port.mac_bridge_port_num |
| 195 | |
| 196 | # See G.988 regarding evto row deletes for "default" flows: |
| 197 | # |
| 198 | # As an exception to the rule on ordered processing, these default rules are always |
| 199 | # considered as a last resort for frames that do not match any other rule. Best |
| 200 | # practice dictates that these entries not be deleted by the OLT; however, they |
| 201 | # can be modified to produce the desired default behaviour. |
| 202 | # |
| 203 | # 15, 4096, x, 15, 4096, x, 0, (0, 15, x, x, 15, x, x) – no tags |
| 204 | # 15, 4096, x, 14, 4096, x, 0, (0, 15, x, x, 15, x, x) – 1 tag |
| 205 | # 14, 4096, x, 14, 4096, x, 0, (0, 15, x, x, 15, x, x) – 2 tags |
| 206 | |
| 207 | # outer_prio is 15, outer vid is 4096 inner prio is 15, inner vid is 4096 |
| 208 | # its a default rule... dont delete it. |
| 209 | if self._match_vlan == RESERVED_TRANSPARENT_VLAN and self._vlan_pcp == 15: |
| 210 | self.log.warn("should-not-delete-onu-builtin-no-tag-flow") |
| 211 | return |
| 212 | |
| 213 | # outer_prio is 15, outer vid is 4096 inner prio is 14, inner vid is 4096 |
| 214 | # its a default rule... dont delete it. |
| 215 | if self._match_vlan == RESERVED_TRANSPARENT_VLAN and self._vlan_pcp == 14: |
| 216 | self.log.warn("should-not-delete-onu-builtin-single-tag-flow") |
| 217 | return |
| 218 | |
| 219 | entry = VlanTaggingOperation( |
| 220 | filter_outer_priority=15, |
| 221 | filter_outer_vid=4096, |
| 222 | filter_outer_tpid_de=0, |
| 223 | |
| 224 | filter_inner_priority=self._vlan_pcp, |
| 225 | filter_inner_vid=self._match_vlan, |
| 226 | filter_inner_tpid_de=0, |
| 227 | filter_ether_type=0 |
| 228 | ) |
| 229 | # delete this entry using the filter rules as the key. |
| 230 | # this function automatically fills 0xFF in the last 8 treatment bytes |
| 231 | entry = entry.delete() |
| 232 | attributes = dict(received_frame_vlan_tagging_operation_table=entry) |
| 233 | |
| 234 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 235 | extended_vlan_tagging_entity_id, # Bridge Entity ID |
| 236 | attributes=attributes # See above |
| 237 | ) |
| 238 | frame = msg.set() |
| 239 | self.log.debug('openomci-msg', omci_msg=msg) |
| 240 | results = yield self._device.omci_cc.send(frame) |
| 241 | self.check_status_and_state(results, 'delete-service-flow') |
| 242 | |
| 243 | @inlineCallbacks |
| 244 | def _delete_vlan_filter_entity(self): |
| 245 | vlan_tagging_entity_id = int(self._mac_bridge_port_ani_entity_id + self._uni_port.entity_id |
| 246 | + self._tp_id) |
| 247 | self.log.debug("Vlan tagging filter data frame will be deleted.", |
| 248 | expected_me_id=vlan_tagging_entity_id) |
| 249 | msg = VlanTaggingFilterDataFrame(vlan_tagging_entity_id) |
| 250 | frame = msg.delete() |
| 251 | self.log.debug('openomci-msg', omci_msg=msg) |
| 252 | results = yield self._device.omci_cc.send(frame) |
| 253 | self.check_status_and_state(results, 'flow-delete-vlan-tagging-filter-data') |
| 254 | |
| 255 | @inlineCallbacks |
| 256 | def _create_vlan_filter_entity(self, vlan_tagging_entity_id): |
| 257 | |
| 258 | self.log.debug("Vlan tagging filter data frame will be created.", |
| 259 | expected_me_id=vlan_tagging_entity_id) |
| 260 | vlan_tagging_me = self._device.query_mib(VlanTaggingFilterData.class_id, |
| 261 | instance_id=int(vlan_tagging_entity_id)) |
| 262 | if len(vlan_tagging_me) == 0: |
| 263 | forward_operation = 0x10 # VID investigation |
| 264 | self.log.debug("vlan id isn't reserved") |
| 265 | self.log.debug("forward_operation", forward_operation=forward_operation) |
| 266 | self.log.debug("set_vlan_id", vlan_id=self._set_vlan_id) |
| 267 | # When the PUSH VLAN is RESERVED_VLAN (4095), let ONU be transparent |
| 268 | if self._set_vlan_id == RESERVED_TRANSPARENT_VLAN: |
| 269 | forward_operation = 0x00 # no investigation, ONU transparent |
| 270 | |
| 271 | # Create bridge ani side vlan filter |
| 272 | msg = VlanTaggingFilterDataFrame( |
| 273 | int(vlan_tagging_entity_id), # Entity ID |
| 274 | vlan_tcis=[self._set_vlan_id], # VLAN IDs |
| 275 | forward_operation=forward_operation |
| 276 | ) |
| 277 | |
| 278 | self.log.debug("created vlan tagging data frame msg") |
| 279 | frame = msg.create() |
| 280 | self.log.debug('openomci-msg', omci_msg=msg) |
| 281 | results = yield self._device.omci_cc.send(frame) |
| 282 | self.check_status_and_state(results, 'create-vlan-tagging-filter-data') |
| 283 | |
| 284 | @inlineCallbacks |
| 285 | def _reset_evto_and_vlan_tag_filter(self): |
| 286 | self.log.info("resetting-evto-and-vlan-tag-filter") |
| 287 | # Delete bridge ani side vlan filter |
| 288 | eid = self._mac_bridge_port_ani_entity_id + self._uni_port.entity_id + self._tp_id # Entity ID |
| 289 | msg = VlanTaggingFilterDataFrame(eid) |
| 290 | frame = msg.delete() |
| 291 | self.log.debug('openomci-msg', omci_msg=msg) |
| 292 | self.strobe_watchdog() |
| 293 | results = yield self._device.omci_cc.send(frame) |
| 294 | self.check_status_and_state(results, 'flow-delete-vlan-tagging-filter-data') |
| 295 | |
| 296 | ################################################################################ |
| 297 | # Create Extended VLAN Tagging Operation config (UNI-side) |
| 298 | # |
| 299 | # EntityID relates to the VLAN TCIS later used int vlan filter task. This only |
| 300 | # sets up the inital MIB entry as it relates to port config, it does not set vlan |
| 301 | # that is saved for the vlan filter task |
| 302 | # |
| 303 | # References: |
| 304 | # - PPTP Ethernet or VEIP UNI |
| 305 | # |
| 306 | |
| 307 | # Delete uni side evto |
| 308 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 309 | self._mac_bridge_service_profile_entity_id + self._uni_port.mac_bridge_port_num, |
| 310 | ) |
| 311 | frame = msg.delete() |
| 312 | self.log.debug('openomci-msg', omci_msg=msg) |
| 313 | results = yield self._device.omci_cc.send(frame) |
| 314 | self.check_status_and_state(results, 'delete-extended-vlan-tagging-operation-configuration-data') |
| 315 | |
| 316 | # Re-Create uni side evto |
| 317 | # default to PPTP |
| 318 | association_type = 2 |
| 319 | if self._uni_port.type.value == UniType.VEIP.value: |
| 320 | association_type = 10 |
| 321 | elif self._uni_port.type.value == UniType.PPTP.value: |
| 322 | association_type = 2 |
| 323 | |
| 324 | attributes = dict( |
| 325 | association_type=association_type, # Assoc Type, PPTP/VEIP Ethernet UNI |
| 326 | associated_me_pointer=self._uni_port.entity_id, # Assoc ME, PPTP/VEIP Entity Id |
| 327 | |
| 328 | # See VOL-1311 - Need to set table during create to avoid exception |
| 329 | # trying to read back table during post-create-read-missing-attributes |
| 330 | # But, because this is a R/W attribute. Some ONU may not accept the |
| 331 | # value during create. It is repeated again in a set below. |
| 332 | input_tpid=self._input_tpid, # input TPID |
| 333 | output_tpid=self._output_tpid, # output TPID |
| 334 | ) |
| 335 | |
| 336 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 337 | self._mac_bridge_service_profile_entity_id + self._uni_port.mac_bridge_port_num, # Bridge Entity ID |
| 338 | attributes=attributes |
| 339 | ) |
| 340 | |
| 341 | frame = msg.create() |
| 342 | self.log.debug('openomci-msg', omci_msg=msg) |
| 343 | results = yield self._device.omci_cc.send(frame) |
| 344 | self.check_status_and_state(results, 'create-extended-vlan-tagging-operation-configuration-data') |
| 345 | |
| 346 | @inlineCallbacks |
| 347 | def _incremental_update_evto_and_vlan_tag_filter(self): |
| 348 | self.log.info("incremental-update-evto-and-vlan-tag-filter") |
| 349 | vlan_tagging_entity_id = int(self._mac_bridge_port_ani_entity_id + self._uni_port.entity_id |
| 350 | + self._tp_id) |
| 351 | extended_vlan_tagging_entity_id = self._mac_bridge_service_profile_entity_id + \ |
| 352 | self._uni_port.mac_bridge_port_num |
| 353 | ################################################################################ |
| 354 | # VLAN Tagging Filter config |
| 355 | # |
| 356 | # EntityID will be referenced by: |
| 357 | # - Nothing |
| 358 | # References: |
| 359 | # - MacBridgePortConfigurationData for the ANI/PON side |
| 360 | # |
| 361 | |
| 362 | # TODO: check if its in our local mib first before blindly deleting |
| 363 | if self._tp_id != 0: |
| 364 | yield self._create_vlan_filter_entity(vlan_tagging_entity_id) |
| 365 | |
| 366 | self.log.info('setting-vlan-tagging') |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 367 | |
| 368 | # Onu-Transparent |
| 369 | if self._set_vlan_id == RESERVED_TRANSPARENT_VLAN: |
| 370 | # Transparently send any single tagged packet. |
| 371 | # As the onu is to be transparent, no need to create VlanTaggingFilterData ME. |
| 372 | # Any other specific rules will take priority over this, so not setting any other vlan specific rules |
| 373 | entry = VlanTaggingOperation( |
| 374 | filter_outer_priority=15, # not an outer tag rule, ignore all other outers |
| 375 | filter_outer_vid=4096, # ignore |
| 376 | filter_outer_tpid_de=0, # ignore |
| 377 | filter_inner_priority=14, # default single tagged rule |
| 378 | filter_inner_vid=4096, # do not match on vlan value |
| 379 | filter_inner_tpid_de=0, # do not match on tpid |
| 380 | filter_ether_type=0, # do not filter on untagged ethertype |
| 381 | treatment_tags_to_remove=0, # do not remove any tags |
| 382 | treatment_outer_priority=15, # do not add outer tag |
| 383 | treatment_outer_vid=0, # ignore |
| 384 | treatment_outer_tpid_de=0, # ignore |
| 385 | treatment_inner_priority=15, # do not add inner tag |
| 386 | treatment_inner_vid=0, # ignore |
| 387 | treatment_inner_tpid_de=4 # set TPID 0x8100 |
| 388 | ) |
| 389 | |
| 390 | attributes = dict(received_frame_vlan_tagging_operation_table=entry) |
| 391 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 392 | extended_vlan_tagging_entity_id, # Bridge Entity ID |
| 393 | attributes=attributes |
| 394 | ) |
| 395 | |
| 396 | frame = msg.set() |
| 397 | self.log.debug('openomci-msg', omci_msg=msg) |
| 398 | self.strobe_watchdog() |
| 399 | results = yield self._device.omci_cc.send(frame) |
| 400 | self.check_status_and_state(results, 'set-evto-table-transparent-vlan') |
| 401 | else: |
| 402 | # Update uni side extended vlan filter |
| 403 | # filter for any set vlan - even its match tag is TRANSPARENT. |
| 404 | # For TRANSPARENT match_vlan tag case we modified vlan_pcp and treatment_tags_to_remove values during init. |
| 405 | entry = VlanTaggingOperation( |
| 406 | filter_outer_priority=15, # This entry is not a double-tag rule |
| 407 | filter_outer_vid=4096, # Do not filter on the outer VID value |
| 408 | filter_outer_tpid_de=0, # Do not filter on the outer TPID field |
| 409 | |
| 410 | filter_inner_priority=self._vlan_pcp, # Filter on inner vlan |
| 411 | filter_inner_vid=self._match_vlan, # Look for match vlan |
| 412 | filter_inner_tpid_de=0, # Do not filter on inner TPID field |
| 413 | filter_ether_type=0, # Do not filter on EtherType |
| 414 | |
| 415 | treatment_tags_to_remove=self._treatment_tags_to_remove, |
| 416 | treatment_outer_priority=15, |
| 417 | treatment_outer_vid=0, |
| 418 | treatment_outer_tpid_de=0, |
| 419 | |
| 420 | treatment_inner_priority=self._set_vlan_pcp, # Add an inner priority |
| 421 | treatment_inner_vid=self._set_vlan_id, # use this value as the VID in the inner VLAN tag |
| 422 | treatment_inner_tpid_de=4, # set TPID |
| 423 | ) |
| 424 | |
| 425 | attributes = dict(received_frame_vlan_tagging_operation_table=entry) |
| 426 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 427 | extended_vlan_tagging_entity_id, # Bridge Entity ID |
| 428 | attributes=attributes # See above |
| 429 | ) |
| 430 | frame = msg.set() |
| 431 | self.log.debug('openomci-msg', omci_msg=msg) |
| 432 | self.strobe_watchdog() |
| 433 | results = yield self._device.omci_cc.send(frame) |
| 434 | self.check_status_and_state(results, 'set-evto-table') |
| 435 | |
| 436 | @inlineCallbacks |
| 437 | def _bulk_update_evto_and_vlan_tag_filter(self): |
| 438 | self.log.info("bulk-update-evto-and-vlan-tag-filter") |
| 439 | # First reset any existing config EVTO and vlan tag filter on the ONU |
| 440 | yield self._reset_evto_and_vlan_tag_filter() |
| 441 | |
| 442 | vlan_tagging_entity_id = int(self._mac_bridge_port_ani_entity_id + self._uni_port.entity_id |
| 443 | + self._tp_id) |
| 444 | extended_vlan_tagging_entity_id = self._mac_bridge_service_profile_entity_id + \ |
| 445 | self._uni_port.mac_bridge_port_num |
Mahir Gunyel | 45610b4 | 2020-03-16 17:29:01 -0700 | [diff] [blame] | 446 | |
| 447 | # Onu-Transparent |
| 448 | if self._set_vlan_id == RESERVED_TRANSPARENT_VLAN: |
| 449 | # Transparently send any single tagged packet. |
| 450 | # As the onu is to be transparent, no need to create VlanTaggingFilterData ME. |
| 451 | # Any other specific rules will take priority over this, so not setting any other vlan specific rules |
| 452 | attributes = dict( |
| 453 | received_frame_vlan_tagging_operation_table= |
| 454 | VlanTaggingOperation( |
| 455 | filter_outer_priority=15, |
| 456 | filter_outer_vid=4096, |
| 457 | filter_outer_tpid_de=0, |
| 458 | filter_inner_priority=14, |
| 459 | filter_inner_vid=4096, |
| 460 | filter_inner_tpid_de=0, |
| 461 | filter_ether_type=0, |
| 462 | treatment_tags_to_remove=0, |
| 463 | treatment_outer_priority=15, |
| 464 | treatment_outer_vid=0, |
| 465 | treatment_outer_tpid_de=0, |
| 466 | treatment_inner_priority=15, |
| 467 | treatment_inner_vid=0, |
| 468 | treatment_inner_tpid_de=4 |
| 469 | ) |
| 470 | ) |
| 471 | |
| 472 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 473 | extended_vlan_tagging_entity_id, # Bridge Entity ID |
| 474 | attributes=attributes |
| 475 | ) |
| 476 | |
| 477 | frame = msg.set() |
| 478 | self.log.debug('openomci-msg', omci_msg=msg) |
| 479 | self.strobe_watchdog() |
| 480 | results = yield self._device.omci_cc.send(frame) |
| 481 | self.check_status_and_state(results, 'set-evto-table-transparent-vlan') |
| 482 | |
| 483 | else: |
| 484 | # Re-Create bridge ani side vlan filter |
| 485 | forward_operation = 0x10 # VID investigation |
| 486 | |
| 487 | msg = VlanTaggingFilterDataFrame( |
| 488 | vlan_tagging_entity_id, |
| 489 | vlan_tcis=[self._set_vlan_id], # VLAN IDs |
| 490 | forward_operation=forward_operation |
| 491 | ) |
| 492 | frame = msg.create() |
| 493 | self.log.debug('openomci-msg', omci_msg=msg) |
| 494 | self.strobe_watchdog() |
| 495 | results = yield self._device.omci_cc.send(frame) |
| 496 | self.check_status_and_state(results, 'flow-create-vlan-tagging-filter-data') |
| 497 | # Update uni side extended vlan filter |
| 498 | # filter for untagged |
| 499 | attributes = dict( |
| 500 | received_frame_vlan_tagging_operation_table= |
| 501 | VlanTaggingOperation( |
| 502 | filter_outer_priority=15, |
| 503 | filter_outer_vid=4096, |
| 504 | filter_outer_tpid_de=0, |
| 505 | filter_inner_priority=15, |
| 506 | filter_inner_vid=4096, |
| 507 | filter_inner_tpid_de=0, |
| 508 | filter_ether_type=0, |
| 509 | treatment_tags_to_remove=0, |
| 510 | treatment_outer_priority=15, |
| 511 | treatment_outer_vid=0, |
| 512 | treatment_outer_tpid_de=0, |
| 513 | treatment_inner_priority=0, |
| 514 | treatment_inner_vid=self._set_vlan_id, |
| 515 | treatment_inner_tpid_de=4 |
| 516 | ) |
| 517 | ) |
| 518 | |
| 519 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 520 | extended_vlan_tagging_entity_id, # Bridge Entity ID |
| 521 | attributes=attributes |
| 522 | ) |
| 523 | |
| 524 | frame = msg.set() |
| 525 | self.log.debug('openomci-msg', omci_msg=msg) |
| 526 | self.strobe_watchdog() |
| 527 | results = yield self._device.omci_cc.send(frame) |
| 528 | self.check_status_and_state(results, 'set-evto-table-untagged') |
| 529 | |
| 530 | # Update uni side extended vlan filter |
| 531 | # filter for vlan 0 |
| 532 | attributes = dict( |
| 533 | received_frame_vlan_tagging_operation_table= |
| 534 | VlanTaggingOperation( |
| 535 | filter_outer_priority=15, # This entry is not a double-tag rule |
| 536 | filter_outer_vid=4096, # Do not filter on the outer VID value |
| 537 | filter_outer_tpid_de=0, # Do not filter on the outer TPID field |
| 538 | |
| 539 | filter_inner_priority=8, # Filter on inner vlan |
| 540 | filter_inner_vid=0x0, # Look for vlan 0 |
| 541 | filter_inner_tpid_de=0, # Do not filter on inner TPID field |
| 542 | filter_ether_type=0, # Do not filter on EtherType |
| 543 | |
| 544 | treatment_tags_to_remove=1, |
| 545 | treatment_outer_priority=15, |
| 546 | treatment_outer_vid=0, |
| 547 | treatment_outer_tpid_de=0, |
| 548 | |
| 549 | treatment_inner_priority=8, # Add an inner tag and insert this value as the priority |
| 550 | treatment_inner_vid=self._set_vlan_id, # use this value as the VID in the inner VLAN tag |
| 551 | treatment_inner_tpid_de=4, # set TPID |
| 552 | ) |
| 553 | ) |
| 554 | msg = ExtendedVlanTaggingOperationConfigurationDataFrame( |
| 555 | extended_vlan_tagging_entity_id, # Bridge Entity ID |
| 556 | attributes=attributes # See above |
| 557 | ) |
| 558 | frame = msg.set() |
| 559 | self.log.debug('openomci-msg', omci_msg=msg) |
| 560 | self.strobe_watchdog() |
| 561 | results = yield self._device.omci_cc.send(frame) |
| 562 | self.check_status_and_state(results, 'set-evto-table-zero-tagged') |