Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | """ |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 18 | Broadcom OLT/ONU adapter. |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 19 | """ |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 20 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 21 | from uuid import uuid4 |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 22 | import structlog |
| 23 | from twisted.internet import reactor |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 24 | from twisted.internet.defer import DeferredQueue, inlineCallbacks |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 25 | from zope.interface import implementer |
| 26 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 27 | from voltha.adapters.interface import IAdapterInterface |
| 28 | from voltha.core.logical_device_agent import mac_str_to_tuple |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 29 | import voltha.core.flow_decomposer as fd |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 30 | from voltha.protos import third_party |
| 31 | from voltha.protos.adapter_pb2 import Adapter |
| 32 | from voltha.protos.adapter_pb2 import AdapterConfig |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 33 | from voltha.protos.common_pb2 import LogLevel, OperStatus, ConnectStatus, \ |
| 34 | AdminState |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 35 | from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port |
| 36 | from voltha.protos.health_pb2 import HealthStatus |
| 37 | from voltha.protos.logical_device_pb2 import LogicalPort |
| 38 | from voltha.protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, OFPPF_1GB_FD |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 39 | from voltha.protos.openflow_13_pb2 import OFPXMC_OPENFLOW_BASIC, ofp_port |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 40 | from common.frameio.frameio import hexify |
| 41 | from voltha.extensions.omci.omci import * |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 42 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 43 | _ = third_party |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 44 | log = structlog.get_logger() |
| 45 | |
| 46 | |
| 47 | @implementer(IAdapterInterface) |
| 48 | class BroadcomOnuAdapter(object): |
| 49 | |
| 50 | name = 'broadcom_onu' |
| 51 | |
| 52 | supported_device_types = [ |
| 53 | DeviceType( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 54 | id=name, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 55 | adapter=name, |
| 56 | accepts_bulk_flow_update=True |
| 57 | ) |
| 58 | ] |
| 59 | |
| 60 | def __init__(self, adapter_agent, config): |
| 61 | self.adapter_agent = adapter_agent |
| 62 | self.config = config |
| 63 | self.descriptor = Adapter( |
| 64 | id=self.name, |
| 65 | vendor='Voltha project', |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 66 | version='0.4', |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 67 | config=AdapterConfig(log_level=LogLevel.INFO) |
| 68 | ) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 69 | self.devices_handlers = dict() # device_id -> BroadcomOnuHandler() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 70 | |
| 71 | def start(self): |
| 72 | log.debug('starting') |
| 73 | log.info('started') |
| 74 | |
| 75 | def stop(self): |
| 76 | log.debug('stopping') |
| 77 | log.info('stopped') |
| 78 | |
| 79 | def adapter_descriptor(self): |
| 80 | return self.descriptor |
| 81 | |
| 82 | def device_types(self): |
| 83 | return DeviceTypes(items=self.supported_device_types) |
| 84 | |
| 85 | def health(self): |
| 86 | return HealthStatus(state=HealthStatus.HealthState.HEALTHY) |
| 87 | |
| 88 | def change_master_state(self, master): |
| 89 | raise NotImplementedError() |
| 90 | |
| 91 | def adopt_device(self, device): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 92 | log.info('adopt_device', device_id=device.id) |
| 93 | self.devices_handlers[device.proxy_address.channel_id] = BroadcomOnuHandler(self, device.id) |
| 94 | reactor.callLater(0, self.devices_handlers[device.proxy_address.channel_id].activate, device) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 95 | return device |
| 96 | |
| 97 | def abandon_device(self, device): |
| 98 | raise NotImplementedError() |
| 99 | |
Khen Nursimulu | d068d81 | 2017-03-06 11:44:18 -0500 | [diff] [blame] | 100 | def disable_device(self, device): |
| 101 | raise NotImplementedError() |
| 102 | |
| 103 | def reenable_device(self, device): |
| 104 | raise NotImplementedError() |
| 105 | |
| 106 | def reboot_device(self, device): |
| 107 | raise NotImplementedError() |
| 108 | |
| 109 | def delete_device(self, device): |
| 110 | raise NotImplementedError() |
| 111 | |
| 112 | def get_device_details(self, device): |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 113 | raise NotImplementedError() |
| 114 | |
Sergio Slobodrian | ec864c6 | 2017-03-09 11:41:43 -0500 | [diff] [blame] | 115 | def update_pm_config(self, device, pm_configs): |
| 116 | raise NotImplementedError() |
| 117 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 118 | def update_flows_bulk(self, device, flows, groups): |
| 119 | log.info('bulk-flow-update', device_id=device.id, |
| 120 | flows=flows, groups=groups) |
| 121 | assert len(groups.items) == 0 |
| 122 | handler = self.devices_handlers[device.proxy_address.channel_id] |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 123 | return handler.update_flow_table(device, flows.items) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 124 | |
| 125 | def update_flows_incrementally(self, device, flow_changes, group_changes): |
| 126 | raise NotImplementedError() |
| 127 | |
| 128 | def send_proxied_message(self, proxy_address, msg): |
| 129 | log.info('send-proxied-message', proxy_address=proxy_address, msg=msg) |
| 130 | |
| 131 | def receive_proxied_message(self, proxy_address, msg): |
| 132 | log.info('receive-proxied-message', proxy_address=proxy_address, |
| 133 | device_id=proxy_address.device_id, msg=hexify(msg)) |
| 134 | handler = self.devices_handlers[proxy_address.channel_id] |
| 135 | handler.receive_message(msg) |
| 136 | |
| 137 | def receive_packet_out(self, logical_device_id, egress_port_no, msg): |
| 138 | log.info('packet-out', logical_device_id=logical_device_id, |
| 139 | egress_port_no=egress_port_no, msg_len=len(msg)) |
| 140 | |
| 141 | |
| 142 | class BroadcomOnuHandler(object): |
| 143 | |
| 144 | def __init__(self, adapter, device_id): |
| 145 | self.adapter = adapter |
| 146 | self.adapter_agent = adapter.adapter_agent |
| 147 | self.device_id = device_id |
| 148 | self.log = structlog.get_logger(device_id=device_id) |
| 149 | self.incoming_messages = DeferredQueue() |
| 150 | self.proxy_address = None |
| 151 | self.tx_id = 0 |
| 152 | |
| 153 | def receive_message(self, msg): |
| 154 | self.incoming_messages.put(msg) |
| 155 | |
| 156 | def activate(self, device): |
| 157 | self.log.info('activating') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 158 | |
| 159 | # first we verify that we got parent reference and proxy info |
| 160 | assert device.parent_id |
| 161 | assert device.proxy_address.device_id |
| 162 | assert device.proxy_address.channel_id |
| 163 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 164 | # register for proxied messages right away |
| 165 | self.proxy_address = device.proxy_address |
| 166 | self.adapter_agent.register_for_proxied_messages(device.proxy_address) |
| 167 | |
| 168 | # populate device info |
| 169 | device.root = True |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 170 | device.vendor = 'Broadcom' |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 171 | device.model = 'n/a' |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 172 | device.hardware_version = 'to be filled' |
| 173 | device.firmware_version = 'to be filled' |
| 174 | device.software_version = 'to be filled' |
| 175 | device.serial_number = uuid4().hex |
| 176 | device.connect_status = ConnectStatus.REACHABLE |
| 177 | self.adapter_agent.update_device(device) |
| 178 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 179 | # register physical ports |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 180 | uni_port = Port( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 181 | port_no=2, |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 182 | label='UNI facing Ethernet port', |
| 183 | type=Port.ETHERNET_UNI, |
| 184 | admin_state=AdminState.ENABLED, |
| 185 | oper_status=OperStatus.ACTIVE |
| 186 | ) |
| 187 | self.adapter_agent.add_port(device.id, uni_port) |
| 188 | self.adapter_agent.add_port(device.id, Port( |
| 189 | port_no=1, |
| 190 | label='PON port', |
| 191 | type=Port.PON_ONU, |
| 192 | admin_state=AdminState.ENABLED, |
| 193 | oper_status=OperStatus.ACTIVE, |
| 194 | peers=[ |
| 195 | Port.PeerPort( |
| 196 | device_id=device.parent_id, |
| 197 | port_no=device.parent_port_no |
| 198 | ) |
| 199 | ] |
| 200 | )) |
| 201 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 202 | # add uni port to logical device |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 203 | parent_device = self.adapter_agent.get_device(device.parent_id) |
| 204 | logical_device_id = parent_device.parent_id |
| 205 | assert logical_device_id |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 206 | port_no = device.proxy_address.channel_id |
| 207 | cap = OFPPF_1GB_FD | OFPPF_FIBER |
| 208 | self.adapter_agent.add_logical_port(logical_device_id, LogicalPort( |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 209 | id='uni-{}'.format(port_no), |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 210 | ofp_port=ofp_port( |
| 211 | port_no=port_no, |
Steve Crooks | 77334a7 | 2017-01-25 20:29:37 -0500 | [diff] [blame] | 212 | hw_addr=mac_str_to_tuple('00:00:00:00:%02x:%02x' % ((port_no >> 8) & 0xff, port_no & 0xff)), |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 213 | name='uni-{}'.format(port_no), |
| 214 | config=0, |
| 215 | state=OFPPS_LIVE, |
| 216 | curr=cap, |
| 217 | advertised=cap, |
| 218 | peer=cap, |
| 219 | curr_speed=OFPPF_1GB_FD, |
| 220 | max_speed=OFPPF_1GB_FD |
| 221 | ), |
| 222 | device_id=device.id, |
| 223 | device_port_no=uni_port.port_no |
| 224 | )) |
| 225 | |
Steve Crooks | 77334a7 | 2017-01-25 20:29:37 -0500 | [diff] [blame] | 226 | reactor.callLater(10, self.message_exchange) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 227 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 228 | device = self.adapter_agent.get_device(device.id) |
| 229 | device.oper_status = OperStatus.ACTIVE |
| 230 | self.adapter_agent.update_device(device) |
| 231 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 232 | @inlineCallbacks |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 233 | def update_flow_table(self, device, flows): |
| 234 | # |
| 235 | # We need to proxy through the OLT to get to the ONU |
| 236 | # Configuration from here should be using OMCI |
| 237 | # |
| 238 | self.log.info('bulk-flow-update', device_id=device.id, flows=flows) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 239 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 240 | def is_downstream(port): |
| 241 | return port == 2 # Need a better way |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 242 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 243 | def is_upstream(port): |
| 244 | return not is_downstream(port) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 245 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 246 | for flow in flows: |
| 247 | try: |
| 248 | _in_port = fd.get_in_port(flow) |
| 249 | assert _in_port is not None |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 250 | |
Steve Crooks | f248e18 | 2017-02-07 10:50:24 -0500 | [diff] [blame] | 251 | if is_downstream(_in_port): |
| 252 | self.log.info('downstream-flow') |
| 253 | elif is_upstream(_in_port): |
| 254 | self.log.info('upstream-flow') |
| 255 | else: |
| 256 | raise Exception('port should be 1 or 2 by our convention') |
| 257 | |
| 258 | _out_port = fd.get_out_port(flow) # may be None |
| 259 | self.log.info('out-port', out_port=_out_port) |
| 260 | |
| 261 | for field in fd.get_ofb_fields(flow): |
| 262 | if field.type == fd.ETH_TYPE: |
| 263 | _type = field.eth_type |
| 264 | self.log.info('field-type-eth-type', |
| 265 | eth_type=_type) |
| 266 | |
| 267 | elif field.type == fd.IP_PROTO: |
| 268 | _proto = field.ip_proto |
| 269 | self.log.info('field-type-ip-proto', |
| 270 | ip_proto=_proto) |
| 271 | |
| 272 | elif field.type == fd.IN_PORT: |
| 273 | _port = field.port |
| 274 | self.log.info('field-type-in-port', |
| 275 | in_port=_port) |
| 276 | |
| 277 | elif field.type == fd.VLAN_VID: |
| 278 | _vlan_vid = field.vlan_vid & 0xfff |
| 279 | self.log.info('field-type-vlan-vid', |
| 280 | vlan=_vlan_vid) |
| 281 | |
| 282 | elif field.type == fd.VLAN_PCP: |
| 283 | _vlan_pcp = field.vlan_pcp |
| 284 | self.log.info('field-type-vlan-pcp', |
| 285 | pcp=_vlan_pcp) |
| 286 | |
| 287 | elif field.type == fd.UDP_DST: |
| 288 | _udp_dst = field.udp_dst |
| 289 | self.log.info('field-type-udp-dst', |
| 290 | udp_dst=_udp_dst) |
| 291 | |
| 292 | elif field.type == fd.UDP_SRC: |
| 293 | _udp_src = field.udp_src |
| 294 | self.log.info('field-type-udp-src', |
| 295 | udp_src=_udp_src) |
| 296 | |
| 297 | elif field.type == fd.IPV4_DST: |
| 298 | _ipv4_dst = field.ipv4_dst |
| 299 | self.log.info('field-type-ipv4-dst', |
| 300 | ipv4_dst=_ipv4_dst) |
| 301 | |
| 302 | elif field.type == fd.IPV4_SRC: |
| 303 | _ipv4_src = field.ipv4_src |
| 304 | self.log.info('field-type-ipv4-src', |
| 305 | ipv4_dst=_ipv4_src) |
| 306 | |
| 307 | elif field.type == fd.METADATA: |
| 308 | _metadata = field.metadata |
| 309 | self.log.info('field-type-metadata', |
| 310 | metadata=_metadata) |
| 311 | |
| 312 | else: |
| 313 | raise NotImplementedError('field.type={}'.format( |
| 314 | field.type)) |
| 315 | |
| 316 | for action in fd.get_actions(flow): |
| 317 | |
| 318 | if action.type == fd.OUTPUT: |
| 319 | _output = action.output.port |
| 320 | self.log.info('action-type-output', |
| 321 | output=_output, in_port=_in_port) |
| 322 | |
| 323 | elif action.type == fd.POP_VLAN: |
| 324 | self.log.info('action-type-pop-vlan', |
| 325 | in_port=_in_port) |
| 326 | |
| 327 | elif action.type == fd.PUSH_VLAN: |
| 328 | _push_tpid = action.push.ethertype |
| 329 | log.info('action-type-push-vlan', |
| 330 | push_tpid=_push_tpid, in_port=_in_port) |
| 331 | if action.push.ethertype != 0x8100: |
| 332 | self.log.error('unhandled-tpid', |
| 333 | ethertype=action.push.ethertype) |
| 334 | |
| 335 | elif action.type == fd.SET_FIELD: |
| 336 | _field = action.set_field.field.ofb_field |
| 337 | assert (action.set_field.field.oxm_class == |
| 338 | OFPXMC_OPENFLOW_BASIC) |
| 339 | self.log.info('action-type-set-field', |
| 340 | field=_field, in_port=_in_port) |
| 341 | if _field.type == fd.VLAN_VID: |
| 342 | self.log.info('set-field-type-valn-vid', |
| 343 | vlan_vid=_field.vlan_vid & 0xfff) |
| 344 | else: |
| 345 | self.log.error('unsupported-action-set-field-type', |
| 346 | field_type=_field.type) |
| 347 | else: |
| 348 | log.error('unsupported-action-type', |
| 349 | action_type=action.type, in_port=_in_port) |
| 350 | |
| 351 | # |
| 352 | # All flows created from ONU adapter should be OMCI based |
| 353 | # |
| 354 | |
| 355 | except Exception as e: |
| 356 | log.exception('failed-to-install-flow', e=e, flow=flow) |
| 357 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 358 | def get_tx_id(self): |
| 359 | self.tx_id += 1 |
| 360 | return self.tx_id |
| 361 | |
| 362 | def send_omci_message(self, frame): |
| 363 | _frame = hexify(str(frame)) |
| 364 | self.log.info('send-omci-message-%s' % _frame) |
| 365 | device = self.adapter_agent.get_device(self.device_id) |
| 366 | try: |
| 367 | self.adapter_agent.send_proxied_message(device.proxy_address, _frame) |
| 368 | except Exception as e: |
| 369 | self.log.info('send-omci-message-exception', exc=str(e)) |
| 370 | |
| 371 | def send_get_circuit_pack(self, entity_id=0): |
| 372 | frame = OmciFrame( |
| 373 | transaction_id=self.get_tx_id(), |
| 374 | message_type=OmciGet.message_id, |
| 375 | omci_message=OmciGet( |
| 376 | entity_class=CircuitPack.class_id, |
| 377 | entity_id=entity_id, |
| 378 | attributes_mask=CircuitPack.mask_for('vendor_id') |
| 379 | ) |
| 380 | ) |
| 381 | self.send_omci_message(frame) |
| 382 | |
| 383 | def send_mib_reset(self, entity_id=0): |
| 384 | frame = OmciFrame( |
| 385 | transaction_id=self.get_tx_id(), |
| 386 | message_type=OmciMibReset.message_id, |
| 387 | omci_message=OmciMibReset( |
| 388 | entity_class=OntData.class_id, |
| 389 | entity_id=entity_id |
| 390 | ) |
| 391 | ) |
| 392 | self.send_omci_message(frame) |
| 393 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 394 | def send_create_gal_ethernet_profile(self, |
| 395 | entity_id, |
| 396 | max_gem_payload_size): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 397 | frame = OmciFrame( |
| 398 | transaction_id=self.get_tx_id(), |
| 399 | message_type=OmciCreate.message_id, |
| 400 | omci_message=OmciCreate( |
| 401 | entity_class=GalEthernetProfile.class_id, |
| 402 | entity_id=entity_id, |
| 403 | data=dict( |
| 404 | max_gem_payload_size=max_gem_payload_size |
| 405 | ) |
| 406 | ) |
| 407 | ) |
| 408 | self.send_omci_message(frame) |
| 409 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 410 | def send_set_tcont(self, |
| 411 | entity_id, |
| 412 | alloc_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 413 | data = dict( |
| 414 | alloc_id=alloc_id |
| 415 | ) |
| 416 | frame = OmciFrame( |
| 417 | transaction_id=self.get_tx_id(), |
| 418 | message_type=OmciSet.message_id, |
| 419 | omci_message=OmciSet( |
| 420 | entity_class=Tcont.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 421 | entity_id=entity_id, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 422 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 423 | data=data |
| 424 | ) |
| 425 | ) |
| 426 | self.send_omci_message(frame) |
| 427 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 428 | def send_create_8021p_mapper_service_profile(self, |
| 429 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 430 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 431 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 432 | message_type=OmciCreate.message_id, |
| 433 | omci_message=OmciCreate( |
| 434 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 435 | entity_id=entity_id, |
| 436 | data=dict( |
| 437 | tp_pointer=OmciNullPointer, |
| 438 | interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer, |
| 439 | ) |
| 440 | ) |
| 441 | ) |
| 442 | self.send_omci_message(frame) |
| 443 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 444 | def send_create_mac_bridge_service_profile(self, |
| 445 | entity_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 446 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 447 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 448 | message_type=OmciCreate.message_id, |
| 449 | omci_message=OmciCreate( |
| 450 | entity_class=MacBridgeServiceProfile.class_id, |
| 451 | entity_id=entity_id, |
| 452 | data=dict( |
| 453 | spanning_tree_ind=False, |
| 454 | learning_ind=True, |
| 455 | priority=0x8000, |
| 456 | max_age=20 * 256, |
| 457 | hello_time=2 * 256, |
| 458 | forward_delay=15 * 256, |
| 459 | unknown_mac_address_discard=True |
| 460 | ) |
| 461 | ) |
| 462 | ) |
| 463 | self.send_omci_message(frame) |
| 464 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 465 | def send_create_gem_port_network_ctp(self, |
| 466 | entity_id, |
| 467 | port_id, |
| 468 | tcont_id, |
| 469 | direction, |
| 470 | tm): |
| 471 | _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3} |
| 472 | if _directions.has_key(direction): |
| 473 | _direction = _directions[direction] |
| 474 | else: |
| 475 | self.log.error('invalid-gem-port-direction', direction=direction) |
| 476 | raise ValueError('Invalid GEM port direction: {_dir}'.format(_dir=direction)) |
| 477 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 478 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 479 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 480 | message_type=OmciCreate.message_id, |
| 481 | omci_message=OmciCreate( |
| 482 | entity_class=GemPortNetworkCtp.class_id, |
| 483 | entity_id=entity_id, |
| 484 | data=dict( |
| 485 | port_id=port_id, |
| 486 | tcont_pointer=tcont_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 487 | direction=_direction, |
| 488 | traffic_management_pointer_upstream=tm |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 489 | ) |
| 490 | ) |
| 491 | ) |
| 492 | self.send_omci_message(frame) |
| 493 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 494 | def send_create_multicast_gem_interworking_tp(self, |
| 495 | entity_id, |
| 496 | gem_port_net_ctp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 497 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 498 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 499 | message_type=OmciCreate.message_id, |
| 500 | omci_message=OmciCreate( |
| 501 | entity_class=MulticastGemInterworkingTp.class_id, |
| 502 | entity_id=entity_id, |
| 503 | data=dict( |
| 504 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 505 | interworking_option=0, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 506 | service_profile_pointer=0x1 |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 507 | ) |
| 508 | ) |
| 509 | ) |
| 510 | self.send_omci_message(frame) |
| 511 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 512 | def send_create_gem_inteworking_tp(self, |
| 513 | entity_id, |
| 514 | gem_port_net_ctp_id, |
| 515 | service_profile_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 516 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 517 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 518 | message_type=OmciCreate.message_id, |
| 519 | omci_message=OmciCreate( |
| 520 | entity_class=GemInterworkingTp.class_id, |
| 521 | entity_id=entity_id, |
| 522 | data=dict( |
| 523 | gem_port_network_ctp_pointer=gem_port_net_ctp_id, |
| 524 | interworking_option=5, |
| 525 | service_profile_pointer=service_profile_id, |
| 526 | interworking_tp_pointer=0x0, |
| 527 | gal_profile_pointer=0x1 |
| 528 | ) |
| 529 | ) |
| 530 | ) |
| 531 | self.send_omci_message(frame) |
| 532 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 533 | def send_set_8021p_mapper_service_profile(self, |
| 534 | entity_id, |
| 535 | interwork_tp_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 536 | data = dict( |
| 537 | interwork_tp_pointer_for_p_bit_priority_0 = interwork_tp_id |
| 538 | ) |
| 539 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 540 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 541 | message_type=OmciSet.message_id, |
| 542 | omci_message=OmciSet( |
| 543 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 544 | entity_id=entity_id, |
| 545 | attributes_mask=Ieee8021pMapperServiceProfile.mask_for( |
| 546 | *data.keys()), |
| 547 | data=data |
| 548 | ) |
| 549 | ) |
| 550 | self.send_omci_message(frame) |
| 551 | |
| 552 | def send_create_mac_bridge_port_configuration_data(self, |
| 553 | entity_id, |
| 554 | bridge_id, |
| 555 | port_id, |
| 556 | tp_type, |
| 557 | tp_id): |
| 558 | frame = OmciFrame( |
| 559 | transaction_id=self.get_tx_id(), |
| 560 | message_type=OmciCreate.message_id, |
| 561 | omci_message=OmciCreate( |
| 562 | entity_class=MacBridgePortConfigurationData.class_id, |
| 563 | entity_id=entity_id, |
| 564 | data=dict( |
| 565 | bridge_id_pointer = bridge_id, |
| 566 | port_num=port_id, |
| 567 | tp_type=tp_type, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 568 | tp_pointer=tp_id |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 569 | ) |
| 570 | ) |
| 571 | ) |
| 572 | self.send_omci_message(frame) |
| 573 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 574 | def send_create_vlan_tagging_filter_data(self, |
| 575 | entity_id, |
| 576 | vlan_id): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 577 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 578 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 579 | message_type=OmciCreate.message_id, |
| 580 | omci_message=OmciCreate( |
| 581 | entity_class=VlanTaggingFilterData.class_id, |
| 582 | entity_id=entity_id, |
| 583 | data=dict( |
| 584 | vlan_filter_0=vlan_id, |
| 585 | forward_operation=0x10, |
| 586 | number_of_entries=1 |
| 587 | ) |
| 588 | ) |
| 589 | ) |
| 590 | self.send_omci_message(frame) |
| 591 | |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 592 | def send_create_extended_vlan_tagging_operation_configuration_data(self, |
| 593 | entity_id, |
| 594 | assoc_type, |
| 595 | assoc_me): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 596 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 597 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 598 | message_type=OmciCreate.message_id, |
| 599 | omci_message=OmciCreate( |
| 600 | entity_class= |
| 601 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 602 | entity_id=entity_id, |
| 603 | data=dict( |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 604 | association_type=assoc_type, |
| 605 | associated_me_pointer=assoc_me |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 606 | ) |
| 607 | ) |
| 608 | ) |
| 609 | self.send_omci_message(frame) |
| 610 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 611 | def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, |
| 612 | entity_id, |
| 613 | input_tpid, |
| 614 | output_tpid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 615 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 616 | input_tpid=input_tpid, |
| 617 | output_tpid=output_tpid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 618 | downstream_mode=0, # inverse of upstream |
| 619 | ) |
| 620 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 621 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 622 | message_type=OmciSet.message_id, |
| 623 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 624 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 625 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 626 | entity_id=entity_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 627 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 628 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 629 | *data.keys()), |
| 630 | data=data |
| 631 | ) |
| 632 | ) |
| 633 | self.send_omci_message(frame) |
| 634 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame^] | 635 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(self, |
| 636 | entity_id, |
| 637 | filter_inner_vid, |
| 638 | treatment_inner_vid): |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 639 | data = dict( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 640 | received_frame_vlan_tagging_operation_table= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 641 | VlanTaggingOperation( |
| 642 | filter_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 643 | filter_outer_vid=4096, |
| 644 | filter_outer_tpid_de=0, |
| 645 | |
| 646 | filter_inner_priority=15, |
| 647 | filter_inner_vid=filter_inner_vid, |
| 648 | filter_inner_tpid_de=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 649 | filter_ether_type=0, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 650 | |
| 651 | treatment_tags_to_remove=0, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 652 | treatment_outer_priority=15, |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 653 | treatment_outer_vid=0, |
| 654 | treatment_outer_tpid_de=0, |
| 655 | |
| 656 | treatment_inner_priority=0, |
| 657 | treatment_inner_vid=treatment_inner_vid, |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 658 | treatment_inner_tpid_de=4 |
| 659 | ) |
| 660 | ) |
| 661 | frame = OmciFrame( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 662 | transaction_id=self.get_tx_id(), |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 663 | message_type=OmciSet.message_id, |
| 664 | omci_message=OmciSet( |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 665 | entity_class= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 666 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 667 | entity_id=entity_id, |
| 668 | attributes_mask= |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 669 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 670 | *data.keys()), |
| 671 | data=data |
| 672 | ) |
| 673 | ) |
| 674 | self.send_omci_message(frame) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 675 | |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame^] | 676 | def send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(self, |
| 677 | entity_id, |
| 678 | filter_inner_priority, |
| 679 | filter_inner_vid, |
| 680 | filter_inner_tpid_de, |
| 681 | treatment_tags_to_remove, |
| 682 | treatment_inner_priority, |
| 683 | treatment_inner_vid): |
| 684 | data = dict( |
| 685 | received_frame_vlan_tagging_operation_table= |
| 686 | VlanTaggingOperation( |
| 687 | filter_outer_priority=15, |
| 688 | filter_outer_vid=4096, |
| 689 | filter_outer_tpid_de=0, |
| 690 | |
| 691 | filter_inner_priority=filter_inner_priority, |
| 692 | filter_inner_vid=filter_inner_vid, |
| 693 | filter_inner_tpid_de=filter_inner_tpid_de, |
| 694 | filter_ether_type=0, |
| 695 | |
| 696 | treatment_tags_to_remove=treatment_tags_to_remove, |
| 697 | treatment_outer_priority=15, |
| 698 | treatment_outer_vid=0, |
| 699 | treatment_outer_tpid_de=0, |
| 700 | |
| 701 | treatment_inner_priority=treatment_inner_priority, |
| 702 | treatment_inner_vid=treatment_inner_vid, |
| 703 | treatment_inner_tpid_de=4 |
| 704 | ) |
| 705 | ) |
| 706 | frame = OmciFrame( |
| 707 | transaction_id=self.get_tx_id(), |
| 708 | message_type=OmciSet.message_id, |
| 709 | omci_message=OmciSet( |
| 710 | entity_class= |
| 711 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 712 | entity_id=entity_id, |
| 713 | attributes_mask= |
| 714 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 715 | *data.keys()), |
| 716 | data=data |
| 717 | ) |
| 718 | ) |
| 719 | self.send_omci_message(frame) |
| 720 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 721 | def send_create_multicast_operations_profile(self, |
| 722 | entity_id, |
| 723 | igmp_ver): |
| 724 | frame = OmciFrame( |
| 725 | transaction_id=self.get_tx_id(), |
| 726 | message_type=OmciCreate.message_id, |
| 727 | omci_message=OmciCreate( |
| 728 | entity_class= |
| 729 | MulticastOperationsProfile.class_id, |
| 730 | entity_id=entity_id, |
| 731 | data=dict( |
| 732 | igmp_version=igmp_ver, |
| 733 | igmp_function=0, |
| 734 | immediate_leave=0 |
| 735 | ) |
| 736 | ) |
| 737 | ) |
| 738 | self.send_omci_message(frame) |
| 739 | |
| 740 | def send_set_multicast_operations_profile_acl_row0(self, |
| 741 | entity_id, |
| 742 | acl_table, |
| 743 | row_key, |
| 744 | gem_port, |
| 745 | vlan, |
| 746 | src_ip, |
| 747 | dst_ip_start, |
| 748 | dst_ip_end): |
| 749 | row0 = AccessControlRow0( |
| 750 | set_ctrl=1, |
| 751 | row_part_id=0, |
| 752 | test=0, |
| 753 | row_key=row_key, |
| 754 | gem_port_id=gem_port, |
| 755 | vlan_id=vlan, |
| 756 | src_ip=src_ip, |
| 757 | dst_ip_start=dst_ip_start, |
| 758 | dst_ip_end=dst_ip_end, |
| 759 | ipm_group_bw=0 |
| 760 | ) |
| 761 | |
| 762 | if acl_table == 'dynamic': |
| 763 | data = dict( |
| 764 | dynamic_access_control_list_table=row0 |
| 765 | ) |
| 766 | else: |
| 767 | data = dict( |
| 768 | static_access_control_list_table=row0 |
| 769 | ) |
| 770 | |
| 771 | frame = OmciFrame( |
| 772 | transaction_id=self.get_tx_id(), |
| 773 | message_type=OmciSet.message_id, |
| 774 | omci_message=OmciSet( |
| 775 | entity_class=MulticastOperationsProfile.class_id, |
| 776 | entity_id=entity_id, |
| 777 | attributes_mask=MulticastOperationsProfile.mask_for( |
| 778 | *data.keys()), |
| 779 | data=data |
| 780 | ) |
| 781 | ) |
| 782 | self.send_omci_message(frame) |
| 783 | |
| 784 | def send_set_multicast_operations_profile_ds_igmp_mcast_tci(self, |
| 785 | entity_id, |
| 786 | ctrl_type, |
| 787 | tci): |
| 788 | data = dict( |
| 789 | ds_igmp_mcast_tci= |
| 790 | DownstreamIgmpMulticastTci( |
| 791 | ctrl_type=ctrl_type, |
| 792 | tci=tci |
| 793 | ) |
| 794 | ) |
| 795 | frame = OmciFrame( |
| 796 | transaction_id=self.get_tx_id(), |
| 797 | message_type=OmciSet.message_id, |
| 798 | omci_message=OmciSet( |
| 799 | entity_class=MulticastOperationsProfile.class_id, |
| 800 | entity_id=entity_id, |
| 801 | attributes_mask=MulticastOperationsProfile.mask_for( |
| 802 | *data.keys()), |
| 803 | data=data |
| 804 | ) |
| 805 | ) |
| 806 | self.send_omci_message(frame) |
| 807 | |
| 808 | def send_create_multicast_subscriber_config_info(self, |
| 809 | entity_id, |
| 810 | me_type, |
| 811 | mcast_oper_profile): |
| 812 | frame = OmciFrame( |
| 813 | transaction_id=self.get_tx_id(), |
| 814 | message_type=OmciCreate.message_id, |
| 815 | omci_message=OmciCreate( |
| 816 | entity_class= |
| 817 | MulticastSubscriberConfigInfo.class_id, |
| 818 | entity_id=entity_id, |
| 819 | data=dict( |
| 820 | me_type=me_type, |
| 821 | mcast_operations_profile_pointer=mcast_oper_profile |
| 822 | ) |
| 823 | ) |
| 824 | ) |
| 825 | self.send_omci_message(frame) |
| 826 | |
| 827 | def send_set_multicast_subscriber_config_info(self, |
| 828 | entity_id, |
| 829 | max_groups=0, |
| 830 | max_mcast_bw=0, |
| 831 | bw_enforcement=0): |
| 832 | data = dict( |
| 833 | max_simultaneous_groups=max_groups, |
| 834 | max_multicast_bandwidth=max_mcast_bw, |
| 835 | bandwidth_enforcement=bw_enforcement |
| 836 | ) |
| 837 | frame = OmciFrame( |
| 838 | transaction_id=self.get_tx_id(), |
| 839 | message_type=OmciSet.message_id, |
| 840 | omci_message=OmciSet( |
| 841 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 842 | entity_id=entity_id, |
| 843 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 844 | *data.keys()), |
| 845 | data=data |
| 846 | ) |
| 847 | ) |
| 848 | self.send_omci_message(frame) |
| 849 | |
| 850 | def send_set_multicast_service_package(self, |
| 851 | entity_id, |
| 852 | row_key, |
| 853 | vid_uni, |
| 854 | max_groups, |
| 855 | max_mcast_bw, |
| 856 | mcast_oper_profile): |
| 857 | data = dict( |
| 858 | multicast_service_package_table= |
| 859 | MulticastServicePackage( |
| 860 | set_ctrl=1, |
| 861 | row_key=row_key, |
| 862 | |
| 863 | vid_uni=vid_uni, |
| 864 | max_simultaneous_groups=max_groups, |
| 865 | max_multicast_bw=max_mcast_bw, |
| 866 | mcast_operations_profile_pointer=mcast_oper_profile |
| 867 | ) |
| 868 | ) |
| 869 | frame = OmciFrame( |
| 870 | transaction_id=self.get_tx_id(), |
| 871 | message_type=OmciSet.message_id, |
| 872 | omci_message=OmciSet( |
| 873 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 874 | entity_id=entity_id, |
| 875 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 876 | *data.keys()), |
| 877 | data=data |
| 878 | ) |
| 879 | ) |
| 880 | self.send_omci_message(frame) |
| 881 | |
| 882 | def send_set_multicast_allowed_preview_groups_row0(self, |
| 883 | entity_id, |
| 884 | row_key, |
| 885 | src_ip, |
| 886 | vlan_id_ani, |
| 887 | vlan_id_uni): |
| 888 | data = dict( |
| 889 | allowed_preview_groups_table= |
| 890 | AllowedPreviewGroupsRow0( |
| 891 | set_ctrl=1, |
| 892 | row_part_id=0, |
| 893 | row_key=row_key, |
| 894 | |
| 895 | src_ip=src_ip, |
| 896 | vlan_id_ani=vlan_id_ani, |
| 897 | vlan_id_uni=vlan_id_uni |
| 898 | ) |
| 899 | ) |
| 900 | frame = OmciFrame( |
| 901 | transaction_id=self.get_tx_id(), |
| 902 | message_type=OmciSet.message_id, |
| 903 | omci_message=OmciSet( |
| 904 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 905 | entity_id=entity_id, |
| 906 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 907 | *data.keys()), |
| 908 | data=data |
| 909 | ) |
| 910 | ) |
| 911 | self.send_omci_message(frame) |
| 912 | |
| 913 | def send_set_multicast_allowed_preview_groups_row1(self, |
| 914 | entity_id, |
| 915 | row_key, |
| 916 | dst_ip, |
| 917 | duration, |
| 918 | time_left): |
| 919 | data = dict( |
| 920 | allowed_preview_groups_table= |
| 921 | AllowedPreviewGroupsRow1( |
| 922 | set_ctrl=1, |
| 923 | row_part_id=1, |
| 924 | row_key=row_key, |
| 925 | |
| 926 | dst_ip=dst_ip, |
| 927 | duration=duration, |
| 928 | time_left=time_left |
| 929 | ) |
| 930 | ) |
| 931 | frame = OmciFrame( |
| 932 | transaction_id=self.get_tx_id(), |
| 933 | message_type=OmciSet.message_id, |
| 934 | omci_message=OmciSet( |
| 935 | entity_class=MulticastSubscriberConfigInfo.class_id, |
| 936 | entity_id=entity_id, |
| 937 | attributes_mask=MulticastSubscriberConfigInfo.mask_for( |
| 938 | *data.keys()), |
| 939 | data=data |
| 940 | ) |
| 941 | ) |
| 942 | self.send_omci_message(frame) |
| 943 | |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 944 | @inlineCallbacks |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 945 | def wait_for_response(self): |
| 946 | log.info('wait-for-response') |
| 947 | try: |
| 948 | response = yield self.incoming_messages.get() |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 949 | log.info('got-response') |
| 950 | # resp = OmciFrame(response) |
| 951 | # resp.show() |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 952 | except Exception as e: |
| 953 | self.log.info('wait-for-response-exception', exc=str(e)) |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 954 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 955 | @inlineCallbacks |
| 956 | def message_exchange(self): |
| 957 | log.info('message_exchange') |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 958 | # reset incoming message queue |
| 959 | while self.incoming_messages.pending: |
| 960 | _ = yield self.incoming_messages.get() |
| 961 | |
| 962 | # construct message |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 963 | # MIB Reset - OntData - 0 |
| 964 | self.send_mib_reset() |
| 965 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 966 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 967 | # Create AR - GalEthernetProfile - 1 |
| 968 | self.send_create_gal_ethernet_profile(1, 48) |
| 969 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 970 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 971 | # Set AR - TCont - 32768 - 1024 |
| 972 | self.send_set_tcont(0x8000, 0x400) |
| 973 | yield self.wait_for_response() |
Zsolt Haraszti | cc153aa | 2016-12-14 02:28:59 -0800 | [diff] [blame] | 974 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 975 | # Set AR - TCont - 32769 - 1025 |
| 976 | self.send_set_tcont(0x8001, 0x401) |
| 977 | yield self.wait_for_response() |
Zsolt Haraszti | 656ecc6 | 2016-12-28 15:08:23 -0800 | [diff] [blame] | 978 | |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 979 | # Set AR - TCont - 32770 - 1026 |
| 980 | self.send_set_tcont(0x8002, 0x402) |
| 981 | yield self.wait_for_response() |
| 982 | |
| 983 | # Set AR - TCont - 32771 - 1027 |
| 984 | self.send_set_tcont(0x8003, 0x403) |
| 985 | yield self.wait_for_response() |
| 986 | |
| 987 | # Create AR - 802.1pMapperServiceProfile - 32768 |
| 988 | self.send_create_8021p_mapper_service_profile(0x8000) |
| 989 | yield self.wait_for_response() |
| 990 | |
| 991 | # Create AR - 802.1pMapperServiceProfile - 32769 |
| 992 | self.send_create_8021p_mapper_service_profile(0x8001) |
| 993 | yield self.wait_for_response() |
| 994 | |
| 995 | # Create AR - 802.1pMapperServiceProfile - 32770 |
| 996 | self.send_create_8021p_mapper_service_profile(0x8002) |
| 997 | yield self.wait_for_response() |
| 998 | |
| 999 | # Create AR - 802.1pMapperServiceProfile - 32771 |
| 1000 | self.send_create_8021p_mapper_service_profile(0x8003) |
| 1001 | yield self.wait_for_response() |
| 1002 | |
| 1003 | # Create AR - MacBridgeServiceProfile - 513 |
| 1004 | self.send_create_mac_bridge_service_profile(0x201) |
| 1005 | yield self.wait_for_response() |
| 1006 | |
| 1007 | # Create AR - GemPortNetworkCtp - 256 - 1024 - 32768 |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1008 | self.send_create_gem_port_network_ctp(0x100, 0x400, 0x8000, "bi-directional", 0x100) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1009 | yield self.wait_for_response() |
| 1010 | |
| 1011 | # Create AR - GemPortNetworkCtp - 257 - 1025 - 32769 |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1012 | self.send_create_gem_port_network_ctp(0x101, 0x401, 0x8001, "bi-directional", 0x100) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1013 | yield self.wait_for_response() |
| 1014 | |
| 1015 | # Create AR - GemPortNetworkCtp - 258 - 1026 - 32770 |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1016 | self.send_create_gem_port_network_ctp(0x102, 0x402, 0x8002, "bi-directional", 0x100) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1017 | yield self.wait_for_response() |
| 1018 | |
| 1019 | # Create AR - GemPortNetworkCtp - 259 - 1027 - 32771 |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1020 | self.send_create_gem_port_network_ctp(0x103, 0x403, 0x8003, "bi-directional", 0x100) |
| 1021 | yield self.wait_for_response() |
| 1022 | |
| 1023 | # Create AR - GemPortNetworkCtp - 260 - 4000 - 0 |
| 1024 | self.send_create_gem_port_network_ctp(0x104, 0x0FA0, 0, "downstream", 0) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1025 | yield self.wait_for_response() |
| 1026 | |
| 1027 | # Create AR - MulticastGemInterworkingTp - 6 - 260 |
| 1028 | self.send_create_multicast_gem_interworking_tp(0x6, 0x104) |
| 1029 | yield self.wait_for_response() |
| 1030 | |
| 1031 | # Create AR - GemInterworkingTp - 32769 - 256 -32768 - 1 |
| 1032 | self.send_create_gem_inteworking_tp(0x8001, 0x100, 0x8000) |
| 1033 | yield self.wait_for_response() |
| 1034 | |
| 1035 | # Create AR - GemInterworkingTp - 32770 - 257 -32769 - 1 |
| 1036 | self.send_create_gem_inteworking_tp(0x8002, 0x101, 0x8001) |
| 1037 | yield self.wait_for_response() |
| 1038 | |
| 1039 | # Create AR - GemInterworkingTp - 32771 - 258 -32770 - 1 |
| 1040 | self.send_create_gem_inteworking_tp(0x8003, 0x102, 0x8002) |
| 1041 | yield self.wait_for_response() |
| 1042 | |
| 1043 | # Create AR - GemInterworkingTp - 32772 - 259 -32771 - 1 |
| 1044 | self.send_create_gem_inteworking_tp(0x8004, 0x103, 0x8003) |
| 1045 | yield self.wait_for_response() |
| 1046 | |
| 1047 | # Set AR - 802.1pMapperServiceProfile - 32768 - 32769 |
| 1048 | self.send_set_8021p_mapper_service_profile(0x8000, 0x8001) |
| 1049 | yield self.wait_for_response() |
| 1050 | |
| 1051 | # Set AR - 802.1pMapperServiceProfile - 32769 - 32770 |
| 1052 | self.send_set_8021p_mapper_service_profile(0x8001, 0x8002) |
| 1053 | yield self.wait_for_response() |
| 1054 | |
| 1055 | # Set AR - 802.1pMapperServiceProfile - 32770 - 32771 |
| 1056 | self.send_set_8021p_mapper_service_profile(0x8002, 0x8003) |
| 1057 | yield self.wait_for_response() |
| 1058 | |
| 1059 | # Set AR - 802.1pMapperServiceProfile - 32771 - 32772 |
| 1060 | self.send_set_8021p_mapper_service_profile(0x8003, 0x8004) |
| 1061 | yield self.wait_for_response() |
| 1062 | |
| 1063 | # Create AR - MacBridgePortConfigData - 8449 - 513 - 2 - 3 - 32768 |
| 1064 | self.send_create_mac_bridge_port_configuration_data(0x2101, 0x201, 2, 3, 0x8000) |
| 1065 | yield self.wait_for_response() |
| 1066 | |
| 1067 | # Create AR - MacBridgePortConfigData - 8450 - 513 - 3 - 3 - 32769 |
| 1068 | self.send_create_mac_bridge_port_configuration_data(0x2102, 0x201, 3, 3, 0x8001) |
| 1069 | yield self.wait_for_response() |
| 1070 | |
| 1071 | # Create AR - MacBridgePortConfigData - 8451 - 513 - 4 - 3 - 32770 |
| 1072 | self.send_create_mac_bridge_port_configuration_data(0x2103, 0x201, 4, 3, 0x8002) |
| 1073 | yield self.wait_for_response() |
| 1074 | |
| 1075 | # Create AR - MacBridgePortConfigData - 8452 - 513 - 5 - 3 - 32771 |
| 1076 | self.send_create_mac_bridge_port_configuration_data(0x2104, 0x201, 5, 3, 0x8003) |
| 1077 | yield self.wait_for_response() |
| 1078 | |
| 1079 | # Create AR - MacBridgePortConfigData - 9000 - 513 - 6 - 6 - 6 |
| 1080 | self.send_create_mac_bridge_port_configuration_data(0x2328, 0x201, 6, 6, 6) |
| 1081 | yield self.wait_for_response() |
| 1082 | |
| 1083 | # Create AR - VlanTaggingFilterData - 8449 - 040000000000000000000000000000000000000000000000 |
| 1084 | self.send_create_vlan_tagging_filter_data(0x2101, 0x0400) |
| 1085 | yield self.wait_for_response() |
| 1086 | |
| 1087 | # Create AR - VlanTaggingFilterData - 8450 - 040100000000000000000000000000000000000000000000 |
| 1088 | self.send_create_vlan_tagging_filter_data(0x2102, 0x0401) |
| 1089 | yield self.wait_for_response() |
| 1090 | |
| 1091 | # Create AR - VlanTaggingFilterData - 8451 - 040200000000000000000000000000000000000000000000 |
| 1092 | self.send_create_vlan_tagging_filter_data(0x2103, 0x0402) |
| 1093 | yield self.wait_for_response() |
| 1094 | |
| 1095 | # Create AR - VlanTaggingFilterData - 8452 - 040300000000000000000000000000000000000000000000 |
| 1096 | self.send_create_vlan_tagging_filter_data(0x2104, 0x0403) |
| 1097 | yield self.wait_for_response() |
| 1098 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1099 | # Create AR - MulticastOperationsProfile |
| 1100 | self.send_create_multicast_operations_profile(0x201, 3) |
| 1101 | yield self.wait_for_response() |
| 1102 | |
| 1103 | # Set AR - MulticastOperationsProfile - Dynamic Access Control List table |
| 1104 | self.send_set_multicast_operations_profile_acl_row0(0x201, |
| 1105 | 'dynamic', |
| 1106 | 0, |
| 1107 | 0x0fa0, |
| 1108 | 0x0fa0, |
| 1109 | '0.0.0.0', |
| 1110 | '224.0.0.0', |
| 1111 | '239.255.255.255') |
| 1112 | yield self.wait_for_response() |
| 1113 | |
| 1114 | # Create AR - MulticastSubscriberConfigInfo |
| 1115 | self.send_create_multicast_subscriber_config_info(0x201, 0, 0x201) |
| 1116 | yield self.wait_for_response() |
| 1117 | |
| 1118 | # Set AR - MulticastOperationsProfile - Downstream IGMP Multicast TCI |
| 1119 | self.send_set_multicast_operations_profile_ds_igmp_mcast_tci(0x201, 3, 0x401) |
| 1120 | yield self.wait_for_response() |
| 1121 | |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1122 | # Create AR - ExtendedVlanTaggingOperationConfigData - 514 - 2 - 0x105 |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1123 | self.send_create_extended_vlan_tagging_operation_configuration_data(0x202, 2, 0x102) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1124 | yield self.wait_for_response() |
| 1125 | |
| 1126 | # Set AR - ExtendedVlanTaggingOperationConfigData - 514 - 8100 - 8100 |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1127 | self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1128 | yield self.wait_for_response() |
| 1129 | |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1130 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1131 | # 514 - RxVlanTaggingOperationTable - add VLAN 1025 to untagged pkts |
Steve Crooks | a9d0a7c | 2017-03-28 22:40:01 -0400 | [diff] [blame^] | 1132 | #self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_untagged(0x202, 0x1000, 0x401) |
| 1133 | #yield self.wait_for_response() |
| 1134 | |
| 1135 | # Set AR - ExtendedVlanTaggingOperationConfigData |
| 1136 | # 514 - RxVlanTaggingOperationTable - add VLAN 1025 to priority tagged pkts |
| 1137 | self.send_set_extended_vlan_tagging_operation_vlan_configuration_data_single_tag(0x202, 0, 0, 0, 1, 8, 0x401) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1138 | yield self.wait_for_response() |
| 1139 | |
Steve Crooks | 46d6430 | 2017-03-10 15:11:06 -0500 | [diff] [blame] | 1140 | # Create AR - MacBridgePortConfigData - 513 - 513 - 1 - 1 - 0x105 |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 1141 | self.send_create_mac_bridge_port_configuration_data(0x201, 0x201, 1, 1, 0x102) |
Steve Crooks | 3c2c758 | 2017-01-10 15:02:26 -0600 | [diff] [blame] | 1142 | yield self.wait_for_response() |