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