blob: e899eede5b0a0c78d3460a1cc347ebce719bc230 [file] [log] [blame]
Daniel Velascof75c5802018-05-02 10:52:49 +02001#
2# Copyright 2017 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17"""
18PMC Sierra ONU adapter
19"""
20
21import structlog
22from twisted.internet import reactor
23from twisted.internet.defer import DeferredQueue, inlineCallbacks, returnValue
24from zope.interface import implementer
25import voltha.core.flow_decomposer as fd
26
27from voltha.adapters.interface import IAdapterInterface
Daniel Velasco88846172018-06-08 09:02:23 +020028from voltha.adapters.microsemi_olt.DeviceManager import mac_str_to_tuple
29from voltha.adapters.microsemi_olt.PAS5211 import PAS5211GetOnuAllocs, PAS5211GetOnuAllocsResponse, PAS5211GetSnInfo, \
30 PAS5211GetSnInfoResponse, PAS5211GetOnusRange, PAS5211GetOnusRangeResponse, PAS5211MsgSetOnuOmciPortId, \
31 PAS5211MsgSetOnuOmciPortIdResponse, PAS5211MsgSetOnuAllocId, PAS5211MsgSetOnuAllocIdResponse, \
32 PAS5211SetSVlanAtConfig, PAS5211SetSVlanAtConfigResponse, PAS5211SetVlanDownConfig, \
33 PAS5211SetVlanDownConfigResponse, PAS5211SetDownVlanHandl, PAS5211SetDownVlanHandlResponse, \
34 PAS5211SetUplinkVlanHandl, PAS5211SetDownstreamPolicingConfigResponse, PAS5211SetDownstreamPolicingConfig, \
35 PAS5211SetPortIdPolicingConfig, PAS5211UnsetPortIdPolicingConfig, \
36 PAS5211MsgSendDbaAlgorithmMsg, PAS5211MsgSendDbaAlgorithmMsgResponse, \
37 PAS5211SetUpstreamPolicingConfigResponse, PAS5211SetUpstreamPolicingConfig, \
38 PAS5211MsgSetPortIdConfig, PAS5211MsgSetPortIdConfigResponse, \
39 PAS5211MsgGetOnuIdByPortId, PAS5211MsgGetOnuIdByPortIdResponse, \
40 PAS5211SetVlanUplinkConfiguration, PAS5211SetVlanUplinkConfigurationResponse, PAS5211SetUplinkVlanHandlResponse, PAS5211SetVlanGenConfig, PAS5211SetVlanGenConfigResponse, \
41 PAS5211GetPortIdDownstreamPolicingConfig, PAS5211GetPortIdDownstreamPolicingConfigResponse, PAS5211RemoveDownstreamPolicingConfig, \
42 PAS5211MsgHeader, PAS5211UnsetPortIdPolicingConfigResponse, PAS5211RemoveDownstreamPolicingConfigResponse, \
43 PAS5211SetPortIdPolicingConfigResponse
44from voltha.adapters.microsemi_olt.PAS5211_constants import OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER, PON_FALSE, \
45 PON_1_TO_1_VLAN_MODE, PON_TRUE, PON_VLAN_UNUSED_TAG, PON_VLAN_UNUSED_PRIORITY, PON_VLAN_REPLACE_PRIORITY, \
46 PON_OUTPUT_VLAN_PRIO_HANDLE_INCOMING_VLAN, PON_VLAN_UNCHANGED_PRIORITY, PON_OUTPUT_VLAN_PRIO_HANDLE_DONT_CHANGE, \
47 PON_OUTPUT_VLAN_PRIO_HANDLE_DL_VLAN_TABLE, PON_DL_VLAN_SVLAN_REMOVE, PON_DL_VLAN_CVLAN_NO_CHANGE, \
48 PON_VLAN_DEST_DATAPATH, GEM_DIR_BIDIRECT, OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED, \
49 OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC, OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME, OMCI_8021P_MSP_TP_TYPE_NULL, \
50 OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI, OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE, PMC_UPSTREAM_PORT, \
51 PON_DISABLE, PON_VLAN_CHANGE_TAG, PON_VLAN_DONT_CHANGE_TAG, PON_PORT_TYPE_GEM, PON_PORT_DESTINATION_CNI0, PON_ENABLE, SLA_gr_bw_gros, PYTHAGORAS_UPDATE_AID_SLA, \
52 SLA_gr_bw_gros, SLA_be_bw_gros, SLA_gr_bw_fine, SLA_be_bw_fine, PYTHAGORAS_DBA_DATA_COS, PYTHAGORAS_DBA_STATUS_REPORT_NSR, \
53 PMC_OFAL_NO_POLICY, UPSTREAM, DOWNSTREAM
Daniel Velascof75c5802018-05-02 10:52:49 +020054
55from voltha.extensions.omci.omci_frame import OmciFrame
Daniel Velascof75c5802018-05-02 10:52:49 +020056from voltha.protos import third_party
57from voltha.protos.adapter_pb2 import Adapter
58from voltha.protos.adapter_pb2 import AdapterConfig
59from voltha.protos.common_pb2 import LogLevel, ConnectStatus, AdminState, OperStatus
60from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port
61from voltha.protos.health_pb2 import HealthStatus
62from voltha.protos.logical_device_pb2 import LogicalPort
Daniel Velasco88846172018-06-08 09:02:23 +020063from voltha.protos.openflow_13_pb2 import OFPPF_1GB_FD, OFPPF_FIBER, ofp_port, OFPPS_LIVE, OFPXMC_OPENFLOW_BASIC
Daniel Velascof75c5802018-05-02 10:52:49 +020064
65from voltha.extensions.omci.omci_messages import OmciGet, OmciGetResponse, OmciCreate, OmciMibResetResponse, OmciSet, \
66 OmciSetResponse, OmciCreateResponse, OmciMibReset, OmciDelete, OmciDeleteResponse
Daniel Velasco88846172018-06-08 09:02:23 +020067from adapters.microsemi_olt.OMCIProxy import OMCIProxy
68from voltha.adapters.microsemi_olt.APIProxy import APIProxy
Daniel Velascof75c5802018-05-02 10:52:49 +020069from voltha.registry import registry
70from voltha.extensions.omci.omci_entities import VlanTaggingOperation
71from voltha.protos.openflow_13_pb2 import Flows, FlowGroups
72
Daniel Velascof75c5802018-05-02 10:52:49 +020073import Queue
74from struct import pack, unpack
75
76_ = third_party
77log = structlog.get_logger()
78
79OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG = 15
80OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE = 4096
81OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE = 0
82OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE = 0
83OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT = 14
84OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_8100 = 4
85OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE = 15
86OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER = 1
87OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER = 4096
88OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER = 0
89OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100 = 4
90
Daniel Velasco88846172018-06-08 09:02:23 +020091MAX_FLOW_EVENT_RETRIES = 5
92
Daniel Velascof75c5802018-05-02 10:52:49 +020093def sequence_generator(init):
94 num = init
95 while True:
96 yield num
97 num += 1
98
Daniel Velascof75c5802018-05-02 10:52:49 +020099@implementer(IAdapterInterface)
100class TlgsOnuAdapter(object):
101
102 name = 'tlgs_onu'
103
104 supported_device_types = [
105 DeviceType(
106 id=name,
107 adapter=name,
108 accepts_bulk_flow_update=True
109 )
110 ]
111
112
113 def __init__(self, adapter_agent, config):
114 self.omci_proxy = None
115 self.api_proxy = None
116 self.adapter_agent = adapter_agent
117 self.config = config
118 self.descriptor = Adapter(
119 id=self.name,
120 vendor='TLGS',
121 version='0.1',
122 config=AdapterConfig(log_level=LogLevel.INFO)
123 )
124
125 # self.incoming_messages = DeferredQueue()
126 #self.trangen = sequence_generator(1)
127
128 # As of broadcom_onu.py
Daniel Velascof75c5802018-05-02 10:52:49 +0200129 self.device_handlers = dict()
130 # register for adapter messages
131 self.adapter_agent.register_for_inter_adapter_messages()
132
133 self.interface = registry('main').get_args().interface
134
135 def start(self):
136 log.debug('starting')
137 log.info('started')
138
139 def stop(self):
140 log.debug('stopping')
141 log.info('stopped')
142
143 def adapter_descriptor(self):
144 return self.descriptor
145
146 def device_types(self):
147 return DeviceTypes(items=self.supported_device_types)
148
149 def health(self):
150 return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
151
152 def change_master_state(self, master):
153 raise NotImplementedError()
154
155 def create_tcont(self, device, tcont_data, traffic_descriptor_data):
156 raise NotImplementedError()
157
158 def update_tcont(self, device, tcont_data, traffic_descriptor_data):
159 raise NotImplementedError()
160
161 def remove_tcont(self, device, tcont_data, traffic_descriptor_data):
162 raise NotImplementedError()
163
164 def create_gemport(self, device, data):
165 raise NotImplementedError()
166
167 def update_gemport(self, device, data):
168 raise NotImplementedError()
169
170 def remove_gemport(self, device, data):
171 raise NotImplementedError()
172
173 def create_multicast_gemport(self, device, data):
174 raise NotImplementedError()
175
176 def update_multicast_gemport(self, device, data):
177 raise NotImplementedError()
178
179 def remove_multicast_gemport(self, device, data):
180 raise NotImplementedError()
181
182 def create_multicast_distribution_set(self, device, data):
183 raise NotImplementedError()
184
185 def update_multicast_distribution_set(self, device, data):
186 raise NotImplementedError()
187
188 def remove_multicast_distribution_set(self, device, data):
189 raise NotImplementedError()
190
191 def adopt_device(self, device):
192 log.debug('adopt-device', device=device)
193 # reactor.callLater(0.1, self._onu_device_activation, device)
194 # return device
195 # two level array channel
196
197 if device.proxy_address.channel_id not in self.device_handlers:
198 self.device_handlers[device.proxy_address.channel_id] = dict()
199
Daniel Velasco88846172018-06-08 09:02:23 +0200200 self.device_handlers[device.proxy_address.channel_id][
201 device.proxy_address.onu_id] = TlgsOnuHandler(self, device.id)
Daniel Velascof75c5802018-05-02 10:52:49 +0200202
Daniel Velasco88846172018-06-08 09:02:23 +0200203 reactor.callLater(1, self.device_handlers[device.proxy_address.channel_id][
204 device.proxy_address.onu_id].activate, device)
Daniel Velascof75c5802018-05-02 10:52:49 +0200205
206 return device
207
208 def reconcile_device(self, device):
209 raise NotImplementedError()
210
211 def abandon_device(self, device):
212 raise NotImplementedError()
213
214 def disable_device(self, device):
215 log.debug('disable-device', device=device.id)
Daniel Velasco88846172018-06-08 09:02:23 +0200216
217 reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id][
218 device.proxy_address.onu_id].deactivate, device)
219 #raise NotImplementedError()
Daniel Velascof75c5802018-05-02 10:52:49 +0200220
221 def reenable_device(self, device):
222 raise NotImplementedError()
223
224 def reboot_device(self, device):
Daniel Velasco88846172018-06-08 09:02:23 +0200225 log.debug('reboot-device', device=device.id)
226
227 reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id][
228 device.proxy_address.onu_id].reboot, device)
229 # raise NotImplementedError()
Daniel Velascof75c5802018-05-02 10:52:49 +0200230
231 def download_image(self, device, request):
232 raise NotImplementedError()
233
234 def get_image_download_status(self, device, request):
235 raise NotImplementedError()
236
237 def cancel_image_download(self, device, request):
238 raise NotImplementedError()
239
240 def activate_image_update(self, device, request):
241 raise NotImplementedError()
242
243 def revert_image_update(self, device, request):
244 raise NotImplementedError()
245
246 def self_test_device(self, device):
Daniel Velasco88846172018-06-08 09:02:23 +0200247 """
248 This is called to Self a device based on a NBI call.
249 :param device: A Voltha.Device object.
250 :return: Will return result of self test
251 """
Daniel Velascof75c5802018-05-02 10:52:49 +0200252 log.debug('self-test-device', device=device.id)
253 raise NotImplementedError()
254
255 def delete_device(self, device):
256 log.debug('delete-device', device_id=device.id)
Daniel Velascof75c5802018-05-02 10:52:49 +0200257
258 def get_device_details(self, device):
259 raise NotImplementedError()
260
261 def deactivate(self, device):
262 try:
263 handler = self.device_handlers[
Daniel Velasco88846172018-06-08 09:02:23 +0200264 device.proxy_address.channel_id][device.proxy_address.onu_id]
Daniel Velascof75c5802018-05-02 10:52:49 +0200265 return handler.deactivate(device)
266 except Exception as e:
267 log.exception('failed-to-deactivate-onu', e=e)
268 raise e
269
270 def update_pm_config(self, device, pm_configs):
271 raise NotImplementedError()
272
Daniel Velasco88846172018-06-08 09:02:23 +0200273 # @inlineCallbacks
Daniel Velascof75c5802018-05-02 10:52:49 +0200274 def update_flows_bulk(self, device, flows, groups):
275 log.debug('onu-bulk-flow-update', device_id=device.id,
276 flows=flows, groups=groups)
277 log.debug(str(self.device_handlers.keys))
278 try:
279 assert len(groups.items) == 0
280 handler = self.device_handlers[
Daniel Velasco88846172018-06-08 09:02:23 +0200281 device.proxy_address.channel_id][device.proxy_address.onu_id]
Daniel Velascof75c5802018-05-02 10:52:49 +0200282 handler.update_flow_table(device, flows.items)
283 except Exception as e:
284 log.exception('failed-to-update-flow-table', e=e)
285 raise e
286
287 def update_flows_incrementally(self, device, flow_changes, group_changes):
288 raise NotImplementedError()
289
290 def send_proxied_message(self, proxy_address, msg):
291 log.debug("send-proxied-message in TLGS ONU")
292
293 def receive_proxied_message(self, proxy_address, msg):
Daniel Velasco88846172018-06-08 09:02:23 +0200294 log.debug('receive-proxied-message')
295 # mgs - > onu_id
296 if PAS5211MsgHeader in msg:
297 if msg['PAS5211MsgHeader'].onu_id != -1:
298 handler = self.device_handlers[
299 proxy_address.channel_id][msg.onu_id]
300 handler.receive_message(msg)
Daniel Velascof75c5802018-05-02 10:52:49 +0200301
Daniel Velasco88846172018-06-08 09:02:23 +0200302 # for onu, handler in self.device_handlers[proxy_address.channel_id].iteritems():
303 # handler.receive_message(msg)
Daniel Velascof75c5802018-05-02 10:52:49 +0200304
305 def receive_packet_out(self, logical_device_id, egress_port_no, msg):
306 log.debug('packet-out', logical_device_id=logical_device_id,
307 egress_port_no=egress_port_no, msg_len=len(msg))
308
309 def create_interface(self, device, data):
310 raise NotImplementedError()
311
312 def update_interface(self, device, data):
313 raise NotImplementedError()
314
315 def remove_interface(self, device, data):
316 raise NotImplementedError()
317
318 def receive_onu_detect_state(self, device_id, state):
319 raise NotImplementedError()
320
321 def receive_inter_adapter_message(self, msg):
322 raise NotImplementedError()
323
324 def suppress_alarm(self, filter):
325 raise NotImplementedError()
326
327 def unsuppress_alarm(self, filter):
328 raise NotImplementedError()
329
330 # Not used, delegated to handler
331 def update_flow_table(self, device, flows):
332 log.debug('update-flow-table', device_id=device.id, flows=flows)
333
334class TlgsOnuHandler(object):
335
336 def __init__(self, adapter, device_id):
337 self.adapter = adapter
338 self.adapter_agent = adapter.adapter_agent
339 self.device_id = device_id
340 self.log = structlog.get_logger(device_id=device_id)
Daniel Velasco88846172018-06-08 09:02:23 +0200341 #self.incoming_messages = Queue.Queue()
Daniel Velascof75c5802018-05-02 10:52:49 +0200342 self.incoming_messages = DeferredQueue()
343 self.event_messages = Queue.Queue()
344 self.proxy_address = None
345 self.tx_id = 0
346 self.trangen = sequence_generator(1)
347 self.port_id = None
348 self.alloc_id = None
349 self.cvlan_id = None
Daniel Velasco88846172018-06-08 09:02:23 +0200350 self.subsvlan_id = None
Daniel Velascof75c5802018-05-02 10:52:49 +0200351 self.bandwidth = None
352 self.flows_lock = 0
353 self.flows = None
354 self.policy_id = None
355 self.flow_queue = DeferredQueue()
356
357 def receive_message(self, msg):
Daniel Velasco88846172018-06-08 09:02:23 +0200358 log.debug("receive-message",msg=msg.show(dump=True))
Daniel Velascof75c5802018-05-02 10:52:49 +0200359 self.incoming_messages.put(msg)
360
Daniel Velascof75c5802018-05-02 10:52:49 +0200361 def activate(self, device):
362 log.debug('activate-onu-handler', device=device)
363 try:
Daniel Velasco88846172018-06-08 09:02:23 +0200364
Daniel Velascof75c5802018-05-02 10:52:49 +0200365 # register for proxied messages right away
366 self.proxy_address = device.proxy_address
367 self.adapter_agent.register_for_proxied_messages(device.proxy_address)
368
Daniel Velasco88846172018-06-08 09:02:23 +0200369 # First we verify that we got parent reference and proxy info
370 assert device.parent_id
371 assert device.proxy_address.device_id
372 # == 0 # We want to activate multiple ONT's
373 assert device.proxy_address.channel_id is not None
374 # to get onu_id = device.proxy_address.onu_id
Daniel Velascof75c5802018-05-02 10:52:49 +0200375
Daniel Velasco88846172018-06-08 09:02:23 +0200376 # From PMC code:
377 self.port_id = 1000 + 16 * device.proxy_address.onu_id
378 self.alloc_id = self.port_id
Daniel Velascof75c5802018-05-02 10:52:49 +0200379
Daniel Velasco88846172018-06-08 09:02:23 +0200380 # we are going to use the proxy_address.channel_id as unique number
381 # and name for the virtual ports, as this is guaranteed to be unique
382 # in the context of the OLT port, so it is also unique in the context
383 # of the logical device
Daniel Velascof75c5802018-05-02 10:52:49 +0200384
Daniel Velasco88846172018-06-08 09:02:23 +0200385 device.model = 'GPON ONU'
386 device.hardware_version = 'tbd'
387 device.firmware_version = 'tbd'
Daniel Velascof75c5802018-05-02 10:52:49 +0200388
Daniel Velasco88846172018-06-08 09:02:23 +0200389 device.connect_status = ConnectStatus.REACHABLE
Daniel Velascof75c5802018-05-02 10:52:49 +0200390
Daniel Velasco88846172018-06-08 09:02:23 +0200391 uni_port = Port(port_no=1,
392 label="{} ONU".format('TLGS'),
393 type=Port.ETHERNET_UNI,
394 admin_state=AdminState.ENABLED,
395 oper_status=OperStatus.ACTIVE
Daniel Velascof75c5802018-05-02 10:52:49 +0200396 )
397
Daniel Velasco88846172018-06-08 09:02:23 +0200398 self.adapter_agent.add_port(device.id, uni_port)
Daniel Velascof75c5802018-05-02 10:52:49 +0200399
Daniel Velasco88846172018-06-08 09:02:23 +0200400 log.debug('add-onu-port')
Daniel Velascof75c5802018-05-02 10:52:49 +0200401
Daniel Velasco88846172018-06-08 09:02:23 +0200402 pon_port = Port(
403 port_no=2,
404 label='PON port',
405 type=Port.PON_ONU,
406 admin_state=AdminState.ENABLED,
407 oper_status=OperStatus.ACTIVE,
408 peers=[
409 Port.PeerPort(
410 device_id=device.parent_id,
411 port_no=device.parent_port_no
412 )
413 ]
414 )
Daniel Velascof75c5802018-05-02 10:52:49 +0200415
Daniel Velasco88846172018-06-08 09:02:23 +0200416 self.adapter_agent.add_port(device.id, pon_port)
Daniel Velascof75c5802018-05-02 10:52:49 +0200417
Daniel Velasco88846172018-06-08 09:02:23 +0200418 log.debug('add-onu-port')
Daniel Velascof75c5802018-05-02 10:52:49 +0200419
Daniel Velasco88846172018-06-08 09:02:23 +0200420 # obtain logical device id
421 parent_device = self.adapter_agent.get_device(device.parent_id)
422 logical_device_id = parent_device.parent_id
423 assert logical_device_id
424 port_no = (device.proxy_address.channel_id * 32) + \
425 (device.proxy_address.onu_id + 1)
426 cap = OFPPF_1GB_FD | OFPPF_FIBER
Daniel Velascof75c5802018-05-02 10:52:49 +0200427
Daniel Velasco88846172018-06-08 09:02:23 +0200428 self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
429 id=str(port_no),
430 ofp_port=ofp_port(
431 port_no=port_no,
432 hw_addr=mac_str_to_tuple(device.serial_number)[2:8],
433 # name='uni-{}'.format(port_no),
434 name=device.serial_number[0:6],
435 config=0,
436 state=OFPPS_LIVE,
437 curr=cap,
438 advertised=cap,
439 peer=cap,
440 curr_speed=OFPPF_1GB_FD,
441 max_speed=OFPPF_1GB_FD
442 ),
443 device_id=device.id,
444 device_port_no=uni_port.port_no
445 ))
Daniel Velascof75c5802018-05-02 10:52:49 +0200446
Daniel Velasco88846172018-06-08 09:02:23 +0200447 log.debug('add-onu-logical-port')
Daniel Velascof75c5802018-05-02 10:52:49 +0200448
Daniel Velasco88846172018-06-08 09:02:23 +0200449 # Input logical port from ONT
450 self.port_no = port_no
Daniel Velascof75c5802018-05-02 10:52:49 +0200451
Daniel Velasco88846172018-06-08 09:02:23 +0200452 # Finally update to "ACTIVE"
453 device = self.adapter_agent.get_device(device.id)
454 # In broadcom_onu.py this state is DISCOVERED
455 device.oper_status = OperStatus.ACTIVE
456 self.adapter_agent.update_device(device)
457
458 log.info('activate-onu-end', device=device)
459
460 # # Just in case, pull for existing flows...
461 # flows = self.adapter_agent.root_proxy.get('/devices/{}/flows'.format(device.id))
462
463 # log.debug('flows-got-from-deviceid', flows=flows.items)
464 # reactor.callLater(0, self.update_flow_table, device, flows.items)
465
466 # Listening thread (we wait 5 secs to start reading from queue)
467 reactor.callLater(0, self.wait_for_flow_events, device)
Daniel Velascof75c5802018-05-02 10:52:49 +0200468
469 except Exception as e:
470 log.exception('activate-failed', e=e)
Daniel Velasco88846172018-06-08 09:02:23 +0200471 # raise Exception('Exception during onu activation')
Daniel Velascof75c5802018-05-02 10:52:49 +0200472
473 @inlineCallbacks
474 def wait_for_flow_events(self, device):
475
476 log.debug('wait-for-flow-events')
477 event = yield self.flow_queue.get()
478 log.debug("unqueued-flow-event")
479
480 try:
481 if event['action'] == 'install':
482 response = yield self.install_flows_sequence(device, event['cvlan'], event['subsvlan'])
483 elif event['action'] == 'reinstall':
484 response = yield self.reinstall_flows_sequence(device, event['cvlan'], event['subsvlan'])
485 elif event['action'] == 'remove':
486 response = yield self.uninstall_flows_sequence(device)
487
488 if response:
489 log.debug("Event handled flow successfully")
490 else:
491 log.debug("Error handling flow event")
Daniel Velasco88846172018-06-08 09:02:23 +0200492 # if event['retries'] < MAX_FLOW_EVENT_RETRIES:
493 # # Failed install events are turned into reinstall...
494 # if event['action'] == 'install':
495 # event['action'] = 'reinstall'
496 # event['retries'] += 1
497 # log.debug("Flow event retry")
498 # self.flow_queue.put(event)
499 # else:
500 # log.debug("Max retries done for flow event handling.", event=event)
501 # # If we were trying to install a flow, we remove it...
502 # if event['action'] != 'remove':
503 # event['action'] = 'remove'
504 # event['retries'] = 0
505 # self.flow_queue.put(event)
Daniel Velascof75c5802018-05-02 10:52:49 +0200506
507 except Exception as e:
508 log.exception('wait-for-flow-events-exception', e=e)
509
510 reactor.callLater(0, self.wait_for_flow_events, device)
511
Daniel Velasco88846172018-06-08 09:02:23 +0200512 def reboot(self, device):
513 log.debug('onu-reboot-start', device=device)
514
515 if self.cvlan_id is not None and self.subsvlan_id is not None:
516 flow_event = {'action': 'reinstall', 'cvlan': self.cvlan_id,
517 'subsvlan': self.subsvlan_id, 'retries': 0}
518 self.flow_queue.put(flow_event)
519 log.debug('onu-reinstall-event-created')
520 else:
521 log.debug('onu-reboot-ignored')
522
523 log.debug('onu-reboot-end', device=device)
524
Daniel Velascof75c5802018-05-02 10:52:49 +0200525 def deactivate(self, device):
Daniel Velasco88846172018-06-08 09:02:23 +0200526 try:
527 log.debug('deactivate-onu', device=device)
528 # Check parent reference and proxy info exists
529 assert device.parent_id
530 assert device.proxy_address.device_id
Daniel Velascof75c5802018-05-02 10:52:49 +0200531
Daniel Velasco88846172018-06-08 09:02:23 +0200532 # unregister from proxy messages
533 self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
534 self.proxy_address = None
Daniel Velascof75c5802018-05-02 10:52:49 +0200535
Daniel Velasco88846172018-06-08 09:02:23 +0200536 # Delete references to ports, if any
Daniel Velascof75c5802018-05-02 10:52:49 +0200537
Daniel Velasco88846172018-06-08 09:02:23 +0200538 if self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI):
539 onu_port = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)[0]
540 self.adapter_agent.delete_port_reference_from_parent(device.id, onu_port)
Daniel Velascof75c5802018-05-02 10:52:49 +0200541
Daniel Velasco88846172018-06-08 09:02:23 +0200542 if self.adapter_agent.get_ports(device.id, Port.PON_ONU):
543 pon_port = self.adapter_agent.get_ports(device.id, Port.PON_ONU)[0]
544 self.adapter_agent.delete_port_reference_from_parent(device.id, pon_port)
Daniel Velascof75c5802018-05-02 10:52:49 +0200545
Daniel Velasco88846172018-06-08 09:02:23 +0200546 # Delete device and logical ports
547 parent_device = self.adapter_agent.get_device(device.parent_id)
548 logical_device_id = parent_device.parent_id
549 # logical_device = self.adapter_agent.get_logical_device(logical_device_id)
550 # self.adapter_agent.delete_logical_device(logical_device)
Daniel Velascof75c5802018-05-02 10:52:49 +0200551
Daniel Velasco88846172018-06-08 09:02:23 +0200552 if logical_device_id:
553 logical_port = self.adapter_agent.get_logical_port(logical_device_id, self.port_no)
554 if logical_port:
555 self.adapter_agent.delete_logical_port(logical_device_id, logical_port)
Daniel Velascof75c5802018-05-02 10:52:49 +0200556
Daniel Velasco88846172018-06-08 09:02:23 +0200557 # Finally delete device
558 self.adapter_agent.delete_child_device(
559 parent_device_id=device.proxy_address.device_id,
560 child_device_id=device.id)
Daniel Velascof75c5802018-05-02 10:52:49 +0200561
Daniel Velasco88846172018-06-08 09:02:23 +0200562 log.debug('deactivate-onu-end')
Daniel Velascof75c5802018-05-02 10:52:49 +0200563
Daniel Velasco88846172018-06-08 09:02:23 +0200564 except Exception as e:
565 log.exception('deactivate-failed', e=e)
566 # raise Exception('Exception during onu deactivation')
Daniel Velascof75c5802018-05-02 10:52:49 +0200567
568 # @inlineCallbacks
569 def update_flow_table(self, device, flows):
570 cvlan_found = None
571 subsvlan_found = 0
572
Daniel Velascof75c5802018-05-02 10:52:49 +0200573
Daniel Velasco88846172018-06-08 09:02:23 +0200574 log.debug('onu-update-flow-table', device_id=device.id, flows=flows)
575 port_no = (device.proxy_address.channel_id * 32) + (device.proxy_address.onu_id + 1)
576 log.debug('Checking {} flows for port:{}'.format(len(flows), port_no))
Daniel Velascof75c5802018-05-02 10:52:49 +0200577 try:
578
579 for flow in flows:
580 # Look for inner VLAN:
581 for field in fd.get_ofb_fields(flow):
582
583 if field.type == fd.IN_PORT and field.port == 1:
584 if flow.table_id == 0:
585 if flow.priority == 1000:
586 for action in fd.get_actions(flow):
587 if action.type == fd.SET_FIELD:
588 cvlan_found = action.set_field.field.ofb_field.vlan_vid & 0xfff
589 log.debug('CVLAN found:{}'.format(cvlan_found))
590
Daniel Velascof75c5802018-05-02 10:52:49 +0200591 if cvlan_found:
592 if cvlan_found != self.cvlan_id:
593 if self.cvlan_id:
Daniel Velascof75c5802018-05-02 10:52:49 +0200594 log.debug('Reinstall flow triggered')
595 flow_event = {'action': 'reinstall', 'cvlan': cvlan_found,
Daniel Velasco88846172018-06-08 09:02:23 +0200596 'subsvlan': subsvlan_found, 'retries': 0}
Daniel Velascof75c5802018-05-02 10:52:49 +0200597 self.flow_queue.put(flow_event)
598 else:
599 log.debug('Flows installation triggered')
600 flow_event = {'action': 'install', 'cvlan': cvlan_found,
Daniel Velasco88846172018-06-08 09:02:23 +0200601 'subsvlan': subsvlan_found, 'retries': 0}
Daniel Velascof75c5802018-05-02 10:52:49 +0200602 self.flow_queue.put(flow_event)
603 else:
604 log.debug('Flows already installed')
605 else:
606 if self.cvlan_id:
607 log.debug('Flows deinstallation triggered')
608 flow_event = {'action': 'remove', 'cvlan': self.cvlan_id,
Daniel Velasco88846172018-06-08 09:02:23 +0200609 'subsvlan': self.subsvlan_id, 'retries': 0}
Daniel Velascof75c5802018-05-02 10:52:49 +0200610 self.flow_queue.put(flow_event)
611 else:
612 log.debug('Incomplete flow')
613
614 self.cvlan_id = cvlan_found
615 self.subsvlan_id = subsvlan_found
616
617 except Exception as e:
618 log.exception('failed-to-launch-install-flow', e=e, flow=flows)
619
620 @inlineCallbacks
621 def uninstall_flows_sequence(self, device):
622 log.debug('init-flow-deinstallaton')
623 try:
624 response = yield self.delete_data_flow_omci_config(device)
625 returnValue(response)
626 except Exception as e:
627 log.exception('failed-to-launch-uninstall-flow', e=e)
628
629 @inlineCallbacks
630 def reinstall_flows_sequence(self, device, cvlan_id, subsvlan_id):
631 log.debug('init-flow-reinstallaton')
632 try:
633 response = yield self.uninstall_flows_sequence(device)
634 if response:
635 response = yield self.install_flows_sequence(device, cvlan_id, subsvlan_id)
636 returnValue(response)
637 returnValue(False)
Daniel Velascof75c5802018-05-02 10:52:49 +0200638 except Exception as e:
639 log.exception('failed-to-launch-reinstall-flow', e=e)
640
641 @inlineCallbacks
642 def install_flows_sequence(self, device, cvlan_id, subsvlan_id):
643 log.debug('init-flow-installaton')
644 try:
645 log.debug("ONT flow OMCI config", device=device)
646 response = yield self.create_data_flow_omci_config(device, cvlan_id, subsvlan_id)
647 returnValue(response)
648 except Exception as e:
649 log.exception('failed-to-launch-install-flow', e=e)
650
651 @inlineCallbacks
Daniel Velasco88846172018-06-08 09:02:23 +0200652 def wait_for_response(self):
Daniel Velascof75c5802018-05-02 10:52:49 +0200653 log.debug('wait-for-response')
654 response = yield self.incoming_messages.get()
Daniel Velasco88846172018-06-08 09:02:23 +0200655 log.debug("unqueued-message",msg=response.show(dump=True))
656 returnValue(response)
Daniel Velascof75c5802018-05-02 10:52:49 +0200657
Daniel Velasco88846172018-06-08 09:02:23 +0200658
659 # PMC_OFAL.c line:2554
Daniel Velascof75c5802018-05-02 10:52:49 +0200660 @inlineCallbacks
Daniel Velasco88846172018-06-08 09:02:23 +0200661 def create_data_flow_omci_config(self, device, cvlan_id, subsvlan_id):
Daniel Velascof75c5802018-05-02 10:52:49 +0200662
663 self.OMCI_ont_data_mib_reset(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200664 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200665
666 if OmciMibResetResponse not in response:
667 log.error("Failed to perform a MIB reset for {}".format(
668 device.proxy_address))
669 returnValue(False)
670 log.debug("[RESPONSE] OMCI_ont_data_mib_reset")
671
Daniel Velasco88846172018-06-08 09:02:23 +0200672 self.OMCI_tcont_set(device)
673 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200674 if OmciSetResponse not in response:
675 log.error("Failed to set alloc id for {}".format(
676 device.proxy_address))
677 returnValue(False)
678 log.debug("[RESPONSE] OMCI_tcont_set")
679
680 self.pmc_omci_mac_bridge_sp_me_create(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200681 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200682 if OmciCreateResponse not in response:
683 log.error("Failed to set parameter on {}".format(
684 device.proxy_address))
685 returnValue(False)
686 log.debug("[RESPONSE] OMCI_mac_bridge_sp_me_create")
687
688 self.pmc_omci_mac_bridge_pcd_me_create(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200689 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200690 if OmciCreateResponse not in response:
691 log.error("Failed to set info for {}".format(device.proxy_address))
692 returnValue(False)
693 log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_create")
694
Daniel Velasco88846172018-06-08 09:02:23 +0200695 self.pmc_omci_evto_create(device)
696 response = yield self.wait_for_response()
697 if OmciCreateResponse not in response:
698 log.error("Failed to set association info for {}".format(
699 device.proxy_address))
700 returnValue(False)
701 log.debug("[RESPONSE] OMCI_evto_create")
Daniel Velascof75c5802018-05-02 10:52:49 +0200702
Daniel Velasco88846172018-06-08 09:02:23 +0200703 self.pmc_omci_evto_set(device)
704 response = yield self.wait_for_response()
705 if OmciSetResponse not in response:
706 log.error("Failed to set association tpid info for {}".format(
707 device.proxy_address))
708 returnValue(False)
709 log.debug("[RESPONSE] OMCI_evto_set")
Daniel Velascof75c5802018-05-02 10:52:49 +0200710
Daniel Velasco88846172018-06-08 09:02:23 +0200711 # Reuse create_default_data_flow_omci_config (confirmed from logs)
Daniel Velascof75c5802018-05-02 10:52:49 +0200712 self.pmc_omci_8021p_msp_me_allocate(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200713 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200714 if OmciCreateResponse not in response:
715 log.error("Failed to create 8021p msp on {}".format(
716 device.proxy_address))
717 if response is not None:
Daniel Velasco88846172018-06-08 09:02:23 +0200718 log.error("Response received: {}".format(response.summary()))
Daniel Velascof75c5802018-05-02 10:52:49 +0200719 returnValue(False)
720 log.debug("[RESPONSE] OMCI_8021p_msp_me_allocate")
721
Daniel Velasco88846172018-06-08 09:02:23 +0200722 # Reuse create_default_data_flow_omci_config?
723 self.pmc_omci_mac_bridge_pcd_me_allocate(device)
724 response = yield self.wait_for_response()
725 if OmciCreateResponse not in response:
726 log.error("Failed to create mac bridge pcd on {}".format(
727 device.proxy_address))
728 returnValue(False)
729 log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_allocate")
730
731 response = yield self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(
732 device, cvlan_id, subsvlan_id)
733
734 if not response:
735 returnValue(False)
736 log.debug("[RESPONSE] OMCI_send_set_extended_vlan_tagging")
737
Daniel Velascof75c5802018-05-02 10:52:49 +0200738 self.send_create_vlan_tagging_filter_data(device, cvlan_id)
Daniel Velasco88846172018-06-08 09:02:23 +0200739 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200740 if OmciCreateResponse not in response:
741 log.error("Failed to set vlan tagging filter in {}".format(
742 device.proxy_address))
743 returnValue(False)
744 log.debug("[RESPONSE] OMCI_send_create_vlan_tagging_filter_data")
745
Daniel Velascof75c5802018-05-02 10:52:49 +0200746 self.pmc_omci_gem_nctp_me_allocate(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200747 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200748 if OmciCreateResponse not in response:
749 log.error("Failed to Create gem nctp on {}".format(
750 device.proxy_address))
751 returnValue(False)
752 log.debug("[RESPONSE] OMCI_gem_nctp_me_allocate")
753
754 self.pmc_omci_gem_iwtp_me_allocate(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200755 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200756 if OmciCreateResponse not in response:
757 log.error("Failed to Create gem iwtp on {}".format(
758 device.proxy_address))
759 returnValue(False)
760 log.debug("[RESPONSE] OMCI_gem_iwtp_me_allocate")
761
762 self.pmc_omci_8021p_msp_me_assign(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200763
764 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200765 if OmciSetResponse not in response:
766 log.error("Failed to assign sp {}".format(
767 device.proxy_address))
768 returnValue(False)
769 log.debug("[RESPONSE] OMCI_8021p_msp_me_assign")
770
771 returnValue(True)
772
Daniel Velasco88846172018-06-08 09:02:23 +0200773 # PMC_OFAL.c line:3065
Daniel Velascof75c5802018-05-02 10:52:49 +0200774 @inlineCallbacks
775 def delete_data_flow_omci_config(self, device):
Daniel Velasco88846172018-06-08 09:02:23 +0200776
777 self.pmc_omci_evto_deallocate(device)
778 response = yield self.wait_for_response()
779 if OmciDeleteResponse not in response:
780 log.error(
781 "Failed to deallocate evt for {}".format(device.proxy_address))
782 if response is not None:
783 log.error("Response received: {}".format(response.summary()))
784 returnValue(False)
785 log.debug("[RESPONSE] pmc_omci_evto_deallocate", device=device)
Daniel Velascof75c5802018-05-02 10:52:49 +0200786
787 self.pmc_omci_gem_iwtp_me_deallocate(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200788 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200789 if OmciDeleteResponse not in response:
790 log.error(
791 "Failed to deallocate iwtp for {}".format(device.proxy_address))
792 if response is not None:
Daniel Velasco88846172018-06-08 09:02:23 +0200793 log.error("Response received: {}".format(response.summary()))
Daniel Velascof75c5802018-05-02 10:52:49 +0200794 returnValue(False)
795 log.debug("[RESPONSE] pmc_omci_gem_iwtp_me_deallocate", device=device)
796
797 self.pmc_omci_gem_nctp_me_deallocate(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200798 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200799 if OmciDeleteResponse not in response:
800 log.error(
801 "Failed to deallocate nctp for {}".format(device.proxy_address))
802 returnValue(False)
803 log.debug("[RESPONSE] pmc_omci_gem_nctp_me_deallocate", device=device)
804
805 self.pmc_omci_vlan_tagging_filter_me_deallocate(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200806 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200807 if OmciDeleteResponse not in response:
808 log.error(
809 "Failed to deallocate vlan tagging for {}".format(device.proxy_address))
810 returnValue(False)
811 log.debug("[RESPONSE] pmc_omci_vlan_tagging_filter_me_deallocate", device=device)
812
Daniel Velasco88846172018-06-08 09:02:23 +0200813 self.pmc_omci_mac_bridge_pcd_me_deallocate(device)
814 response = yield self.wait_for_response()
815 if OmciDeleteResponse not in response:
816 log.error(
817 "Failed to deallocate bridge pcd for {}".format(device.proxy_address))
818 returnValue(False)
819 log.debug("[RESPONSE] pmc_omci_mac_bridge_pcd_me_deallocate", device=device)
820
Daniel Velascof75c5802018-05-02 10:52:49 +0200821 self.pmc_omci_8021p_msp_me_deallocate(device)
Daniel Velasco88846172018-06-08 09:02:23 +0200822 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +0200823 if OmciDeleteResponse not in response:
824 log.error(
825 "Failed to deallocate msp for {}".format(device.proxy_address))
826 returnValue(False)
827 log.debug("[RESPONSE] pmc_omci_8021p_msp_me_deallocate", device=device)
828
829 returnValue(True)
830
Daniel Velasco88846172018-06-08 09:02:23 +0200831
832 """ - - - - - - - create_data_flow_omci_config - - - - - - - """
833
Daniel Velascof75c5802018-05-02 10:52:49 +0200834
835 def OMCI_ont_data_mib_reset(self, device):
836 # DO things to the ONU
837 # |###[ OmciFrame ]###
838 # | transaction_id= 1
839 # | message_type= 79
840 # | omci = 10
841 # | \omci_message\
842 # | |###[ OmciMibReset ]###
843 # | | entity_class= 2
844 # | | entity_id = 0
845 # | omci_trailer= 40
846
847 # OmciMibReset
848
849 msg = OmciMibReset(entity_class=2, entity_id=0)
850 frame = OmciFrame(transaction_id=self.trangen.next(),
851 message_type=OmciMibReset.message_id,
852 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +0200853
854 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +0200855 log.debug("[SENT] OMCI_ont_data_mib_reset")
856
Daniel Velasco88846172018-06-08 09:02:23 +0200857 def OMCI_tcont_set(self, device):
Daniel Velascof75c5802018-05-02 10:52:49 +0200858 # | ###[ OmciFrame ]###
859 # | transaction_id = 2
860 # | message_type = 72
861 # | omci = 10
862 # | \omci_message \
863 # | | ###[ OmciSet ]###
864 # | | entity_class = 262
865 # | | entity_id = 32769
866 # | | attributes_mask = 32768
867 # | | data = {'alloc_id': 1000}
868 # | omci_trailer = 40
869
870 # tcont_id = 1; //one tcont for one ONU.
871 # slot_id = 128; /* represent the ONT as a whole entinty */
872 # entity_instance = ((slot_id<<8) | tcont_id); /* Compose entity
873 # instance by the slot-id and t-cont id*/
874
875 # OmciSet
876 # TODO: maskdata
877 msg = OmciSet(entity_class=262, entity_id=32769, attributes_mask=32768,
878 data=dict(
Daniel Velasco88846172018-06-08 09:02:23 +0200879 alloc_id=self.alloc_id
Daniel Velascof75c5802018-05-02 10:52:49 +0200880 ))
881 frame = OmciFrame(transaction_id=self.trangen.next(),
882 message_type=OmciSet.message_id,
883 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +0200884 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +0200885 log.debug("[SENT] OMCI_tcont_set")
886
887 def pmc_omci_mac_bridge_sp_me_create(self, device):
888 # length = 44
889 # port_type = 0
890 # port_id = 0
891 # management_frame = 1
892 # \frame \
893 # | ###[ OmciFrame ]###
894 # | transaction_id = 3
895 # | message_type = 68
896 # | omci = 10
897 # | \omci_message \
898 # | | ###[ OmciCreate ]###
899 # | | entity_class = 45
900 # | | entity_id = 1
901 # | | data = {'max_age': 5120, 'hello_time': 512, 'priority': 32768, 'port_bridging_ind': 0,
902 # 'spanning_tree_ind': 0, 'unknown_mac_address_discard': 0, 'mac_learning_depth': 128,
903 # 'learning_ind': 0, 'forward_delay': 3840}
904 # | | ###[ Raw ]###
905 # | | load = '\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
906 # | omci_trailer = 40
907
908 # Found in method: pmc_omci_mac_bridge_sp_me_create from: PMC_OFAL.c
909 # Params
910 # - priority: The bridge priority set on the LAN card
911 # - max_age: The maximum age for an entry in the spanning tree listing
912 # - hello_time: The time interval between hello packets
913 # - forward_delay: The time that the bridge on the Ethernet card in the ONT retains a packet before forwarding it
914 # - unknown_mac_address_discard: frames with unknown destination addresses will be forwarded to all allowed ports
915
916 msg = OmciCreate(entity_class=45, entity_id=1,
917 data=dict(
918 max_age=5120,
919 hello_time=512,
920 priority=32768,
921 port_bridging_ind=PON_FALSE,
922 spanning_tree_ind=PON_FALSE,
923 unknown_mac_address_discard=0,
924 mac_learning_depth=128,
925 learning_ind=PON_FALSE,
926 forward_delay=3840
927 ))
928 frame = OmciFrame(transaction_id=self.trangen.next(),
929 message_type=OmciCreate.message_id,
930 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +0200931 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +0200932 log.debug("[SENT] pmc_omci_mac_bridge_sp_me_create")
933
934 def pmc_omci_mac_bridge_pcd_me_create(self, device):
935
936 # |###[ OmciFrame ]###
937 # | transaction_id= 4
938 # | message_type= 68
939 # | omci = 10
940 # | \omci_message\
941 # | |###[ OmciCreate ]###
942 # | | entity_class= 47
943 # | | entity_id = 0
944 # | | data = {'tp_pointer': 257, 'encapsulation_methods': 1, 'port_num': 0, 'port_priority': 10, 'tp_type': 1, 'port_path_cost': 100, 'port_spanning_tree_in': 0, 'lan_fcs_ind': 0, 'bridge_id_pointer': 1}
945 # | omci_trailer= 40
946
947 # Found in method: pmc_omci_mac_bridge_pcd_me_create from: PMC_OFAL.c
948 # Params
949 # - port_path_cost: The cost contribution of the port to the path cost towards the spanning tree root bridge
950 # - bridge_id_pointer: MAC bridge controlling the port
951
952 msg = OmciCreate(entity_class=47, entity_id=0,
953 data=dict(
Daniel Velasco88846172018-06-08 09:02:23 +0200954 tp_pointer=257,
Daniel Velascof75c5802018-05-02 10:52:49 +0200955 encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC,
956 port_num=0,
957 port_priority=10,
Daniel Velasco88846172018-06-08 09:02:23 +0200958 tp_type=1,
Daniel Velascof75c5802018-05-02 10:52:49 +0200959 port_path_cost=100,
960 port_spanning_tree_in=PON_FALSE,
961 lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED,
962 bridge_id_pointer=1
963 ))
964
965 frame = OmciFrame(transaction_id=self.trangen.next(),
966 message_type=OmciCreate.message_id,
967 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +0200968
969 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +0200970 log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_create")
971
Daniel Velasco88846172018-06-08 09:02:23 +0200972 def pmc_omci_evto_create(self, device):
Daniel Velascof75c5802018-05-02 10:52:49 +0200973 # |###[ OmciFrame ]###
974 # | transaction_id= 5
975 # | message_type= 68
976 # | omci = 10
977 # | \omci_message\
978 # | |###[ OmciCreate ]###
979 # | | entity_class= 171
980 # | | entity_id = 0
981 # | | data = {'association_type': 2, 'associated_me_pointer': 257}
982 # | omci_trailer= 40
983
984 # Found in method: pmc_omci_evto_create from: PMC_OFAL.c
Daniel Velasco88846172018-06-08 09:02:23 +0200985 msg = OmciCreate(entity_class=171, entity_id=0,
Daniel Velascof75c5802018-05-02 10:52:49 +0200986 data=dict(
987 association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI,
Daniel Velasco88846172018-06-08 09:02:23 +0200988 associated_me_pointer=257
Daniel Velascof75c5802018-05-02 10:52:49 +0200989 ))
990
991 frame = OmciFrame(transaction_id=self.trangen.next(),
992 message_type=OmciCreate.message_id,
993 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +0200994
995 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +0200996 log.debug("[SENT] pmc_omci_evto_create")
997
Daniel Velasco88846172018-06-08 09:02:23 +0200998 def pmc_omci_evto_set(self, device):
Daniel Velascof75c5802018-05-02 10:52:49 +0200999 # |###[ OmciFrame ]###
1000 # | transaction_id= 6
1001 # | message_type= 72
1002 # | omci = 10
1003 # | \omci_message\
1004 # | |###[ OmciSet ]###
1005 # | | entity_class= 171
1006 # | | entity_id = 0
1007 # | | attributes_mask= 47616
1008 # | | data = {'association_type': 2, 'input_tpid': 33024, 'associated_me_pointer': 257, 'downstream_mode': 0, 'output_tpid': 33024}
1009 # | omci_trailer= 40
1010
1011 # Found in method: pmc_omci_evto_set from: PMC_OFAL.c
Daniel Velasco88846172018-06-08 09:02:23 +02001012 msg = OmciSet(entity_class=171, entity_id=0, attributes_mask=47616,
Daniel Velascof75c5802018-05-02 10:52:49 +02001013 data=dict(
1014 association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI,
Daniel Velasco88846172018-06-08 09:02:23 +02001015 input_tpid=33024,
1016 associated_me_pointer=257,
Daniel Velascof75c5802018-05-02 10:52:49 +02001017 downstream_mode=OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE,
Daniel Velasco88846172018-06-08 09:02:23 +02001018 output_tpid=33024
Daniel Velascof75c5802018-05-02 10:52:49 +02001019 ))
1020
1021 frame = OmciFrame(transaction_id=self.trangen.next(),
1022 message_type=OmciSet.message_id,
1023 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001024
1025 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001026 log.debug("[SENT] pmc_omci_evto_set")
1027
Daniel Velascof75c5802018-05-02 10:52:49 +02001028
Daniel Velascof75c5802018-05-02 10:52:49 +02001029
1030 def pmc_omci_8021p_msp_me_allocate(self, device):
1031 # |###[ OmciFrame ]###
1032 # | transaction_id= 7
1033 # | message_type= 68
1034 # | omci = 10
1035 # | \omci_message\
1036 # | |###[ OmciCreate ]###
1037 # | | entity_class= 130
1038 # | | entity_id = 1
1039 # | | data = {'tp_pointer': 65535, 'unmarked_frame_option': 1, 'interwork_tp_pointer_for_p_bit_priority_6': 65535,
1040 # 'interwork_tp_pointer_for_p_bit_priority_7': 65535, 'interwork_tp_pointer_for_p_bit_priority_4': 65535,
1041 # 'interwork_tp_pointer_for_p_bit_priority_5': 65535, 'interwork_tp_pointer_for_p_bit_priority_2': 65535,
1042 # 'interwork_tp_pointer_for_p_bit_priority_3': 65535, 'interwork_tp_pointer_for_p_bit_priority_0': 65535,
1043 # 'interwork_tp_pointer_for_p_bit_priority_1': 65535, 'tp_type': 0, 'default_p_bit_marking': 0}
1044 # | omci_trailer= 40
1045
1046 # Found in method: pmc_omci_8021p_msp_me_create from: PMC_OFAL.c
1047 msg = OmciCreate(entity_class=130, entity_id=1,
1048 data=dict(
1049 tp_pointer=65535,
1050 unmarked_frame_option=OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME,
1051 interwork_tp_pointer_for_p_bit_priority_6=65535,
1052 interwork_tp_pointer_for_p_bit_priority_7=65535,
1053 interwork_tp_pointer_for_p_bit_priority_4=65535,
1054 interwork_tp_pointer_for_p_bit_priority_5=65535,
1055 interwork_tp_pointer_for_p_bit_priority_2=65535,
1056 interwork_tp_pointer_for_p_bit_priority_3=65535,
1057 interwork_tp_pointer_for_p_bit_priority_0=65535,
1058 interwork_tp_pointer_for_p_bit_priority_1=65535,
1059 tp_type=OMCI_8021P_MSP_TP_TYPE_NULL,
1060 default_p_bit_marking=0
1061 ))
1062
1063 frame = OmciFrame(transaction_id=self.trangen.next(),
1064 message_type=OmciCreate.message_id,
1065 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001066
1067 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001068 log.debug("[SENT] pmc_omci_8021p_msp_me_allocate")
1069
Daniel Velasco88846172018-06-08 09:02:23 +02001070 def pmc_omci_mac_bridge_pcd_me_allocate(self, device):
Daniel Velascof75c5802018-05-02 10:52:49 +02001071 # |###[ OmciFrame ]###
1072 # | transaction_id= 8
1073 # | message_type= 68
1074 # | omci = 10
1075 # | \omci_message\
1076 # | |###[ OmciCreate ]###
1077 # | | entity_class= 130
1078 # | | entity_id = 1
1079 # | | data = {'tp_pointer': 1, 'encapsulation_methods': 1, 'port_num': 1, 'port_priority': 3, 'tp_type': 5, 'port_path_cost': 32, 'port_spanning_tree_in': 1, 'lan_fcs_ind': 0, 'bridge_id_pointer': 1}
1080 # | omci_trailer= 40
1081
1082 # Found in method: pmc_omci_mac_bridge_pcd_me_create from: PMC_OFAL.c
1083 # Params
1084 # - port_path_cost: The cost contribution of the port to the path cost towards the spanning tree root bridge
1085 # - bridge_id_pointer: MAC bridge controlling the port
Daniel Velasco88846172018-06-08 09:02:23 +02001086 msg = OmciCreate(entity_class=47, entity_id=1,
Daniel Velascof75c5802018-05-02 10:52:49 +02001087 data=dict(
Daniel Velasco88846172018-06-08 09:02:23 +02001088 tp_pointer=1,
Daniel Velascof75c5802018-05-02 10:52:49 +02001089 encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC,
Daniel Velasco88846172018-06-08 09:02:23 +02001090 port_num=1,
Daniel Velascof75c5802018-05-02 10:52:49 +02001091 port_priority=10,
Daniel Velasco88846172018-06-08 09:02:23 +02001092 tp_type=3,
Daniel Velascof75c5802018-05-02 10:52:49 +02001093 port_path_cost=100,
1094 port_spanning_tree_in=PON_FALSE,
1095 lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED,
1096 bridge_id_pointer=1
1097 ))
1098
1099 frame = OmciFrame(transaction_id=self.trangen.next(),
1100 message_type=OmciCreate.message_id,
1101 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001102
1103 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001104 log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_allocate")
1105
1106 def pmc_omci_gem_nctp_me_allocate(self, device):
1107 # |###[ OmciFrame ]###
1108 # | transaction_id= 9
1109 # | message_type= 68
1110 # | omci = 10
1111 # | \omci_message\
1112 # | |###[ OmciCreate ]###
1113 # | | entity_class= 268
1114 # | | entity_id = 1
1115 # | | data = {'priority_queue_pointer_downstream': 0, 'direction': 3, 'tcont_pointer': 32769, 'traffic_descriptor_profile_pointer': 0, 'traffic_management_pointer_upstream': 4, 'port_id': 1000}
1116 # | omci_trailer= 40
1117
1118 # Found in method: pmc_omci_gem_nctp_create from: PMC_OFAL.c
1119 msg = OmciCreate(entity_class=268, entity_id=1,
1120 data=dict(
1121 priority_queue_pointer_downstream=0, # 0 for default
1122 direction=GEM_DIR_BIDIRECT,
1123 tcont_pointer=32769,
1124 traffic_descriptor_profile_pointer=0,
Daniel Velasco88846172018-06-08 09:02:23 +02001125 traffic_management_pointer_upstream=4, # 4 for feault
Daniel Velascof75c5802018-05-02 10:52:49 +02001126 # Same as GEM port
1127 # port_id=(1000 + device.proxy_address.onu_id)
1128 port_id = self.port_id
1129 ))
1130
1131 frame = OmciFrame(transaction_id=self.trangen.next(),
1132 message_type=OmciCreate.message_id,
1133 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001134
1135 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001136 log.debug("[SENT] pmc_omci_gem_nctp_me_allocate")
1137
1138 def pmc_omci_gem_iwtp_me_allocate(self, device):
1139 # |###[ OmciFrame ]###
1140 # | transaction_id= 10
1141 # | message_type= 68
1142 # | omci = 10
1143 # | \omci_message\
1144 # | |###[ OmciCreate ]###
1145 # | | entity_class= 266
1146 # | | entity_id = 1
1147 # | | data = {'gem_port_network_ctp_pointer': 1, 'gal_profile_pointer': 0, 'service_profile_pointer': 1, 'interworking_option': 5, 'interworking_tp_pointer': 0}
1148 # | omci_trailer= 40
1149
1150 # Found in method: pmc_omci_gem_iwtp_me_create from: PMC_OFAL.c
1151 # Params
1152 # - gem_port_network_ctp_pointer: An instance identifier of the GEM Port Network CTP that is associated with this GEM Interworking Termination Point
1153 # - service_profile_pointer: The service profile type and a pointer to the instance of a service profile
1154 # - interworking_tp_pointer: Used for in the case of Circuit Emulation Services and 802.1p mapper service
1155 # - gal_profile_pointer: A pointer to an instance of the GAL Profile
1156
1157 msg = OmciCreate(entity_class=266, entity_id=1,
1158 data=dict(
1159 gem_port_network_ctp_pointer=1,
1160 gal_profile_pointer=0,
1161 service_profile_pointer=1,
1162 interworking_option=OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER,
1163 interworking_tp_pointer=0
1164 ))
1165
1166 frame = OmciFrame(transaction_id=self.trangen.next(),
1167 message_type=OmciCreate.message_id,
1168 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001169
1170 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001171 log.debug("[SENT] pmc_omci_gem_iwtp_me_allocate")
1172
Daniel Velascof75c5802018-05-02 10:52:49 +02001173
Daniel Velasco88846172018-06-08 09:02:23 +02001174
1175 def send_create_extended_vlan_tagging_operation_configuration_data(self, device):
1176
1177 msg = OmciCreate(entity_class=171,
1178 entity_id=0,
1179 data=dict(
1180 association_type=2,
1181 associated_me_pointer=257
1182 ))
1183
1184 frame = OmciFrame(transaction_id=self.trangen.next(),
1185 message_type=OmciCreate.message_id,
1186 omci_message=msg)
1187
1188 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
1189 log.debug(
1190 "[SENT] create_extended_vlan_tagging_operation_configuration_data")
1191
1192 # self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100)
1193 def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, device):
1194
1195 data = dict(
1196 association_type=2,
1197 input_tpid=33024,
1198 associated_me_pointer=257,
1199 downstream_mode=OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE,
1200 output_tpid=33024,
1201 )
1202
1203 msg = OmciSet(entity_class=171,
1204 entity_id=0,
1205 attributes_mask=47616, # 1024 in broadcom but 47616 observed from PMC
1206 data=data
1207 )
1208
1209 frame = OmciFrame(
1210 transaction_id=self.trangen.next(),
1211 message_type=OmciSet.message_id,
1212 omci_message=msg
1213 )
1214 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
1215 log.debug(
1216 "[SENT] set_extended_vlan_tagging_operation_tpid_configuration_data")
Daniel Velascof75c5802018-05-02 10:52:49 +02001217
1218 @inlineCallbacks
Daniel Velasco88846172018-06-08 09:02:23 +02001219 def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self, device, cvlan_id, subs_vlan):
Daniel Velascof75c5802018-05-02 10:52:49 +02001220 # ###[ PAS5211MsgSendFrame ]###
1221 # length = 44
1222 # port_type = 0
1223 # port_id = 0
1224 # management_frame= 1
1225 # \frame \
1226 # |###[ OmciFrame ]###
1227 # | transaction_id= 14
1228 # | message_type= 72
1229 # | omci = 10
1230 # | \omci_message\
1231 # | |###[ OmciSet ]###
1232 # | | entity_class= 171
1233 # | | entity_id = 0
1234 # | | attributes_mask= 1024
1235 # | | data = {'received_frame_vlan_tagging_operation_table': '\xf8\x00\x00\x00\x00\x00@\x00@\x0f\x00\x04\x00\x00\x00\x0c'}
1236 # | omci_trailer= 40
1237
Daniel Velasco88846172018-06-08 09:02:23 +02001238 # TODO Check filter_inner_priority value
1239 """vlan_oper_table_entry.filter_configuration.filter_inner_tagging.vlan_priority = filter_inner_vlan_pcp;
1240 vlan_oper_table_entry.filter_configuration.filter_inner_tagging.vlan_vid = filter_inner_vlan_id;
1241 """
Daniel Velascof75c5802018-05-02 10:52:49 +02001242 self.send_vlan_tagging_operation_msg(device,
1243 VlanTaggingOperation(
1244 filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
1245 filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
1246 filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
1247
1248 filter_inner_priority=0,
1249 filter_inner_vid=subs_vlan,
1250 filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_8100,
1251 filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
1252
1253 treatment_tags_to_remove=1,
1254 treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
1255 treatment_outer_vid=0,
1256 treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100,
1257
1258 treatment_inner_priority=0,
1259 treatment_inner_vid=cvlan_id,
1260 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100
Daniel Velasco88846172018-06-08 09:02:23 +02001261 )
1262 )
1263 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +02001264
1265 log.debug(
1266 "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1267
1268 if OmciSetResponse not in response:
1269 log.error("Failed to set vlan extended table entry {}".format(
1270 device.proxy_address))
1271 returnValue(False)
1272
1273 log.debug(
1274 "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1275
1276 self.send_vlan_tagging_operation_msg(device,
1277 VlanTaggingOperation(
1278 filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
1279 filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
1280 filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
1281
1282 filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
1283 filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
1284 filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
1285 filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
1286
1287 treatment_tags_to_remove=3,
1288 treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
1289 treatment_outer_vid=0,
1290 treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER,
1291
1292 treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
1293 treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
1294 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
Daniel Velasco88846172018-06-08 09:02:23 +02001295 )
1296 )
Daniel Velascof75c5802018-05-02 10:52:49 +02001297
1298 log.debug(
1299 "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1300
Daniel Velasco88846172018-06-08 09:02:23 +02001301 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +02001302 if OmciSetResponse not in response:
1303 log.error("Failed to set vlan extended table entry {}".format(
1304 device.proxy_address))
1305 returnValue(False)
1306
1307 log.debug(
1308 "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1309
1310 self.send_vlan_tagging_operation_msg(device,
1311 VlanTaggingOperation(
1312 filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
1313 filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
1314 filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
1315
1316 filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT,
1317 filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
1318 filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
1319 filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
1320
1321 treatment_tags_to_remove=3,
1322 treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
1323 treatment_outer_vid=0,
1324 treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER,
1325
1326 treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
1327 treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
1328 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
Daniel Velasco88846172018-06-08 09:02:23 +02001329 )
1330 )
Daniel Velascof75c5802018-05-02 10:52:49 +02001331
1332 log.debug(
1333 "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1334
Daniel Velasco88846172018-06-08 09:02:23 +02001335 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +02001336 if OmciSetResponse not in response:
1337 log.error("Failed to set vlan extended table entry {}".format(
1338 device.proxy_address))
1339 returnValue(False)
1340
1341 log.debug(
1342 "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1343
1344 self.send_vlan_tagging_operation_msg(device,
1345 VlanTaggingOperation(
1346 filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT,
1347 filter_outer_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
1348 filter_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
1349
1350 filter_inner_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_DEFAULT,
1351 filter_inner_vid=OMCI_EX_VLAN_TAG_OCD_FILTER_VID_NONE,
1352 filter_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_FILTER_TPID_DE_NONE,
1353 filter_ether_type=OMCI_EX_VLAN_TAG_OCD_FILTER_ETYPE_NONE,
1354
1355 treatment_tags_to_remove=3,
1356 treatment_outer_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
1357 treatment_outer_vid=0,
1358 treatment_outer_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_OUTER,
1359
1360 treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
1361 treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
1362 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
Daniel Velasco88846172018-06-08 09:02:23 +02001363 )
1364 )
Daniel Velascof75c5802018-05-02 10:52:49 +02001365
1366 log.debug(
1367 "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1368
Daniel Velasco88846172018-06-08 09:02:23 +02001369 response = yield self.wait_for_response()
Daniel Velascof75c5802018-05-02 10:52:49 +02001370 if OmciSetResponse not in response:
1371 log.error("Failed to set vlan extended table entry {}".format(
1372 device.proxy_address))
1373 returnValue(False)
Daniel Velasco88846172018-06-08 09:02:23 +02001374
Daniel Velascof75c5802018-05-02 10:52:49 +02001375 log.debug(
1376 "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
1377
1378 returnValue(True)
1379
Daniel Velasco88846172018-06-08 09:02:23 +02001380
1381 def send_vlan_tagging_operation_msg(self, device, vlan_tagging_operation_table):
Daniel Velascof75c5802018-05-02 10:52:49 +02001382
1383 data = dict(
1384 received_frame_vlan_tagging_operation_table=vlan_tagging_operation_table
1385 )
1386
1387 msg = OmciSet(
1388 entity_class=171,
Daniel Velasco88846172018-06-08 09:02:23 +02001389 entity_id=0,
Daniel Velascof75c5802018-05-02 10:52:49 +02001390 attributes_mask=1024,
1391 data=data
1392 )
1393
1394 frame = OmciFrame(
1395 transaction_id=self.trangen.next(),
1396 message_type=OmciSet.message_id,
1397 omci_message=msg
1398 )
Daniel Velasco88846172018-06-08 09:02:23 +02001399
1400 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001401 log.debug("[SENT] create_vlan_tagging_filter_data")
1402
1403 def send_create_vlan_tagging_filter_data(self, device, cvlan_id):
1404 # ###[ PAS5211MsgSendFrame ]###
1405 # length = 44
1406 # port_type = 0
1407 # port_id = 0
1408 # management_frame= 1
1409 # \frame \
1410 # |###[ OmciFrame ]###
1411 # | transaction_id= 18
1412 # | message_type= 68
1413 # | omci = 10
1414 # | \omci_message\
1415 # | |###[ OmciCreate ]###
1416 # | | entity_class= 84
1417 # | | entity_id = 2
1418 # | | data = {'vlan_filter_0': 1, 'vlan_filter_1': 0, 'vlan_filter_2': 0, 'vlan_filter_3': 0, 'vlan_filter_4': 0, 'vlan_filter_5': 0, 'vlan_filter_6': 0, 'vlan_filter_7': 0, 'vlan_filter_8': 0, 'vlan_filter_9': 0, 'number_of_entries': 1, 'forward_operation': 16, 'vlan_filter_10': 0, 'vlan_filter_11': 0}
1419 # | omci_trailer= 40
1420
1421 data = dict(
1422 vlan_filter_0=cvlan_id,
1423 forward_operation=16,
1424 number_of_entries=1
1425 )
1426
1427 msg = OmciCreate(
1428 entity_class=84,
1429 entity_id=1,
1430 data=data
1431 )
1432
1433 frame = OmciFrame(
1434 transaction_id=self.trangen.next(),
1435 message_type=OmciCreate.message_id,
1436 omci_message=msg
1437 )
Daniel Velasco88846172018-06-08 09:02:23 +02001438
1439 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001440 log.debug("[SENT] create_vlan_tagging_filter_data")
1441
Daniel Velasco88846172018-06-08 09:02:23 +02001442 def pmc_ofal_remove_default_onu_flow_omci(self, device): # TODO
1443 # ###[ PAS5211Dot3 ]###
1444 # dst = 00:0
1445 # c: d5:00: 04:10
1446 # src = 02:00: d3:77: 47:49
1447 # len = 74
1448 # ###[ PAS5211FrameHeader ]###
1449 # part = 1
1450 # total_parts = 1
1451 # size = 68
1452 # magic_number = 0x1234abcd
1453 # ###[ PAS5211MsgHeader ]###
1454 # sequence_number = 201
1455 # opcode = 0x302a
1456 # event_type = 0
1457 # channel_id = 1
1458 # onu_id = 0
1459 # onu_session_id = 1
1460 # ###[ PAS5211MsgSendFrame ]###
1461 # length = 44
1462 # port_type = 0
1463 # port_id = 0
1464 # management_frame = 1
1465 # \frame \
1466 # | ###[ OmciFrame ]###
1467 # | transaction_id = 44
1468 # | message_type = 70
1469 # | omci = 10
1470 # | \omci_message \
1471 # | | ###[ OmciDelete ]###
1472 # | | entity_class = 47
1473 # | | entity_id = 1
1474 # | omci_trailer = 40
1475 log.debug("[SENT] pmc_ofal_remove_default_onu_flow_omci")
1476 pass
1477
1478 def pmc_omci_evto_vlan_oper_table_entry_assign(self, device): # TODO
1479
1480 # /* Fill the set message */
1481 # entity.entity_class = OMCI_ENT_EX_VLAN_TAGGING_OPER_CONFIG_DATA;
1482 # entity.entity_instance = entity_instance;
1483 # set_req_msg.attr_mask = attributes_mask;
1484
1485 # typedef struct OMCI_ex_vlan_tagging_operation_config_me_set_t
1486 # {
1487 # INT8U association_type; /* Association type ,R,W,C (ASSOCIATION_TYPE_)*/
1488 # INT16U input_tpid; /* Input TPID value ,R,W (16 bit value)*/
1489 # INT16U output_tpid; /* Output TPID value ,R,W (16 bit value)*/
1490 # INT8U downstream_mode; /* downstream mode ,R,W (OCD_DS_MODE_)*/
1491 #
1492 # OMCI_ex_vlan_tag_op_table_entry_t /* Operation entry ,R,W (16 bytes) */
1493 # operations_entry;
1494 #
1495 # OMCI_instance_id_t associated_me_ptr;
1496 #
1497 # INT8U dscp2pbit_mapping[OMCI_EX_VLAN_TAG_ATTR_DSCP2PBIT_MAPPING_SIZE];/*dscp-to-pbit mapping ,R,W (24 bytes)*/
1498 #
1499 # } OMCI_ex_vlan_tagging_operation_config_me_set_t;
1500
1501 # attibute_mask = 0
1502 # # attibute_mask |= ( (INT16U)1 << ((OMCI_ATTR_MAX-1)-(OMCI_EX_VLAN_TAG_OCD_ATTR_RX_FRAME_OP_TABLE)))
1503 # msg = OmciSet(entity_class=OMCI_ENT_EX_VLAN_TAGGING_OPER_CONFIG_DATA, entity_id=0, attributes_mask=attibute_mask,
1504 # data=dict(
1505 # association_type=,
1506 # input_tpid=,
1507 # output_tpid=,
1508 # downstream_mode=,
1509 # associated_me_pointer=,
1510 # dscp2pbit_mapping=
1511 # ))
1512
1513 # frame = OmciFrame(transaction_id=self.trangen.next(),
1514 # message_type=OmciSet.message_id,
1515 # omci_message=msg)
1516
1517 # self.adapter_agent.send_proxied_message(device.proxy_address, frame)
1518
1519 # TODO: Sends up to three OMCI Set messages
1520 log.debug("[SENT] pmc_omci_evto_vlan_oper_table_entry_assign")
1521 pass
1522
Daniel Velascof75c5802018-05-02 10:52:49 +02001523 @inlineCallbacks
1524 def pmc_omci_vlan_tagging_filter_me_allocate(self, device): # TODO
1525
1526 self.OMCI_vlan_tagging_filter_get(device)
1527 response = yield self.incoming_messages.get()
1528 if OmciGetResponse not in response:
1529 log.error("Failed to Get vlan tagging filter {}".format(
1530 device.proxy_address))
1531 return
1532
1533 # if: # OMCI Get is sucessfull
1534 # # OMCI_vlan_tagging_filter_create
1535 # else:
1536 # # OMCI_vlan_tagging_filter_set
1537 log.debug("[SENT] pmc_omci_vlan_tagging_filter_me_allocate")
1538 pass
1539
1540 def pmc_omci_8021p_msp_me_assign(self, device):
1541
1542 # ###[ PAS5211MsgSendFrame ]###
1543 # length = 44
1544 # port_type = 0
1545 # port_id = 0
1546 # management_frame= 1
1547 # \frame \
1548 # |###[ OmciFrame ]###
1549 # | transaction_id= 21
1550 # | message_type= 72
1551 # | omci = 10
1552 # | \omci_message\
1553 # | |###[ OmciSet ]###
1554 # | | entity_class= 130
1555 # | | entity_id = 2
1556 # | | attributes_mask= 16472
1557 # | | data = {'tp_type': 0, 'unmarked_frame_option': 1, 'interwork_tp_pointer_for_p_bit_priority_0': 2, 'default_p_bit_marking': 0}
1558 # | omci_trailer= 40
1559
1560 data = dict(tp_type=0,
1561 output_tpid=33024,
1562 unmarked_frame_option=1,
1563 interwork_tp_pointer_for_p_bit_priority_0=1,
1564 default_p_bit_marking=0
1565 )
1566
1567 msg = OmciSet(entity_class=130,
1568 entity_id=1,
1569 attributes_mask=16472,
1570 data=data
1571 )
1572
1573 frame = OmciFrame(
1574 transaction_id=self.trangen.next(),
1575 message_type=OmciSet.message_id,
1576 omci_message=msg
1577 )
Daniel Velasco88846172018-06-08 09:02:23 +02001578 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001579
1580 log.debug("[SENT] pmc_omci_8021p_msp_me_assign")
1581
1582 def pmc_ofal_recover_default_onu_flow_omci(self, device):
1583 log.debug("[SENT] pmc_ofal_recover_default_onu_flow_omci")
1584 pass
1585
1586 def OMCI_vlan_tagging_filter_get(self, device):
1587 # entity_class: OMCI_ENT_VLAN_TAGGING_FILT_DATA
1588 # entity_instance: mac_bridge_pcd
1589 # attr_mask = 0
1590 # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_FILTER_TABLE);
1591 # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_FWD_OP);
1592 # attr_mask | OMCI_ATTR_BIT(OMCI_VLAN_TAG_FILTER_ATTR_NOF_ENTRIES);
1593 log.debug("[SENT] OMCI_vlan_tagging_filter_get")
1594 pass
1595
1596 def OMCI_vlan_tagging_filter_create(self, device): # TODO
1597 log.debug("[SENT] OMCI_vlan_tagging_filter_create")
1598 pass
1599
1600 def OMCI_vlan_tagging_filter_set(self, device): # TODO
1601 log.debug("[SENT] OMCI_vlan_tagging_filter_set")
1602 pass
1603
1604 """ - - - - - - - END create_data_flow_omci_config - - - - - - - """
1605
1606 """ - - - - - - - delete_data_flow_omci_config - - - - - - - """
1607
1608 def pmc_omci_gem_iwtp_me_deallocate(self, device):
1609 # |###[ OmciFrame ]###
1610 # | transaction_id= 34
1611 # | message_type= 70
1612 # | omci = 10
1613 # | \omci_message\
1614 # | |###[ OmciDelete ]###
1615 # | | entity_class= 266
1616 # | | entity_id = 2
1617 # | omci_trailer= 40
1618 msg = OmciDelete(entity_class=266, entity_id=1)
1619
1620 frame = OmciFrame(transaction_id=self.trangen.next(),
1621 message_type=OmciDelete.message_id,
1622 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001623
1624 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001625 log.debug("[SENT] pmc_omci_gem_iwtp_me_deallocate")
1626
1627 def pmc_omci_gem_nctp_me_deallocate(self, device):
1628 # |###[ OmciFrame ]###
1629 # | transaction_id= 35
1630 # | message_type= 70
1631 # | omci = 10
1632 # | \omci_message\
1633 # | |###[ OmciDelete ]###
1634 # | | entity_class= 268
1635 # | | entity_id = 2
1636 # | omci_trailer= 40
1637 msg = OmciDelete(entity_class=268, entity_id=1)
1638
1639 frame = OmciFrame(transaction_id=self.trangen.next(),
1640 message_type=OmciDelete.message_id,
1641 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001642
1643 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001644 log.debug("[SENT] pmc_omci_gem_nctp_me_allocate")
1645
1646 def pmc_omci_vlan_tagging_filter_me_deallocate(self, device):
1647 # |###[ OmciFrame ]###
1648 # | transaction_id= 36
1649 # | message_type= 70
1650 # | omci = 10
1651 # | \omci_message\
1652 # | |###[ OmciDelete ]###
1653 # | | entity_class= 84
1654 # | | entity_id = 2
1655 # | omci_trailer= 40
1656 msg = OmciDelete(entity_class=84, entity_id=1)
1657
1658 frame = OmciFrame(transaction_id=self.trangen.next(),
1659 message_type=OmciDelete.message_id,
1660 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001661
1662 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001663 log.debug("[SENT] pmc_omci_vlan_tagging_filter_me_deallocate")
1664
1665
1666 def pmc_omci_mac_bridge_pcd_me_deallocate(self, device):
1667 # |###[ OmciFrame ]###
1668 # | transaction_id= 37
1669 # | message_type= 70
1670 # | omci = 10
1671 # | \omci_message\
1672 # | |###[ OmciDelete ]###
1673 # | | entity_class= 47
1674 # | | entity_id = 2
1675 # | omci_trailer= 40
1676 msg = OmciDelete(entity_class=47, entity_id=1)
1677
1678 frame = OmciFrame(transaction_id=self.trangen.next(),
1679 message_type=OmciDelete.message_id,
1680 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001681
1682 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001683 log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_deallocate")
1684
1685
1686
1687 def pmc_omci_8021p_msp_me_deallocate(self, device):
1688 # |###[ OmciFrame ]###
1689 # | transaction_id= 38
1690 # | message_type= 70
1691 # | omci = 10
1692 # | \omci_message\
1693 # | |###[ OmciDelete ]###
1694 # | | entity_class= 130
1695 # | | entity_id = 2
1696 # | omci_trailer= 40
1697 msg = OmciDelete(entity_class=130, entity_id=1)
1698
1699 frame = OmciFrame(transaction_id=self.trangen.next(),
1700 message_type=OmciDelete.message_id,
1701 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001702
1703 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001704 log.debug("[SENT] pmc_omci_8021p_msp_me_deallocate")
1705
Daniel Velasco88846172018-06-08 09:02:23 +02001706 def pmc_omci_evto_deallocate(self, device):
Daniel Velascof75c5802018-05-02 10:52:49 +02001707
Daniel Velasco88846172018-06-08 09:02:23 +02001708 msg = OmciDelete(entity_class=171, entity_id=1)
Daniel Velascof75c5802018-05-02 10:52:49 +02001709
1710 frame = OmciFrame(transaction_id=self.trangen.next(),
1711 message_type=OmciDelete.message_id,
1712 omci_message=msg)
Daniel Velasco88846172018-06-08 09:02:23 +02001713 self.adapter_agent.send_proxied_message(device.proxy_address, frame)
Daniel Velascof75c5802018-05-02 10:52:49 +02001714 log.debug("[SENT] pmc_omci_evto_deallocate")
1715
1716
Daniel Velasco88846172018-06-08 09:02:23 +02001717
Daniel Velascof75c5802018-05-02 10:52:49 +02001718 """ - - - - - - - END delete_data_flow_omci_config - - - - - - - """
1719
Daniel Velasco88846172018-06-08 09:02:23 +02001720
1721
1722
1723