Update celestica onu to latest tef code

Change-Id: I89ffb034aa6c25a0f73b9c5a66cfd38e1ba1e0ab
diff --git a/voltha/adapters/tlgs_onu/tlgs_constants.py b/voltha/adapters/tlgs_onu/tlgs_constants.py
deleted file mode 100644
index 0729b42..0000000
--- a/voltha/adapters/tlgs_onu/tlgs_constants.py
+++ /dev/null
@@ -1,300 +0,0 @@
-#
-# Copyright 2017 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from enum import Enum
-
-"""
-PAS5211 Constants
-"""
-
-# from enum PON_true_false_t
-PON_FALSE = 0
-PON_TRUE = 1
-
-# from enum PON_enable_disable_t
-PON_DISABLE = 0
-PON_ENABLE = 1
-
-# from enym PON_mac_t
-PON_MII = 0
-PON_GMII = 1
-PON_TBI = 2
-
-PON_POLARITY_ACTIVE_LOW = 0
-PON_POLARITY_ACTIVE_HIGH = 1
-
-PON_OPTICS_VOLTAGE_IF_UNDEFINED = 0
-PON_OPTICS_VOLTAGE_IF_CML = 1
-PON_OPTICS_VOLTAGE_IF_LVPECL = 2
-
-PON_SD_SOURCE_LASER_SD = 0
-PON_SD_SOURCE_BCDR_LOCK = 1
-PON_SD_SOURCE_BCDR_SD = 2
-
-PON_RESET_TYPE_DELAY_BASED = 0
-PON_RESET_TYPE_SINGLE_RESET = 1
-PON_RESET_TYPE_DOUBLE_RESET = 2
-
-PON_RESET_TYPE_NORMAL_START_BURST_BASED = 0
-PON_RESET_TYPE_NORMAL_END_BURST_BASED = 1
-
-PON_GPIO_LINE_0 = 0
-PON_GPIO_LINE_1 = 1
-PON_GPIO_LINE_2 = 2
-PON_GPIO_LINE_3 = 3
-PON_GPIO_LINE_4 = 4
-PON_GPIO_LINE_5 = 5
-PON_GPIO_LINE_6 = 6
-PON_GPIO_LINE_7 = 7
-def PON_EXT_GPIO_LINE(line):
-    return line + 8
-
-PON_ALARM_SOFTWARE_ERROR = 0
-PON_ALARM_LOS = 1
-PON_ALARM_LOSI = 2
-PON_ALARM_DOWI = 3
-PON_ALARM_LOFI = 4
-PON_ALARM_RDII = 5
-PON_ALARM_LOAMI = 6
-PON_ALARM_LCDGI = 7
-PON_ALARM_LOAI = 8
-PON_ALARM_SDI = 9
-PON_ALARM_SFI = 10
-PON_ALARM_PEE = 11
-PON_ALARM_DGI = 12
-PON_ALARM_LOKI = 13
-PON_ALARM_TIWI = 14
-PON_ALARM_TIA = 15
-PON_ALARM_AUTH_FAILED_IN_REGISTRATION_ID_MODE = 20
-PON_ALARM_SUFI = 21
-
-PON_ALARM_VIRTUAL_SCOPE_ONU_LASER_ALWAYS_ON = 16
-PON_ALARM_VIRTUAL_SCOPE_ONU_SIGNAL_DEGRADATION = 17
-PON_ALARM_VIRTUAL_SCOPE_ONU_EOL = 18
-PON_ALARM_VIRTUAL_SCOPE_ONU_EOL_DATABASE_IS_FULL = 19
-
-PON_ALARM_LAST_ALARM = 22
-
-# from enum PON_general_parameters_type_t
-PON_COMBINED_LOSI_LOFI = 1000
-PON_TX_ENABLE_DEFAULT = 1001
-
-# Enable or disable False queue full event from DBA
-PON_FALSE_Q_FULL_EVENT_MODE = 1002
-
-# Set PID_AID_MISMATCH min silence period. 0 - disable, Else - period in secs
-PON_PID_AID_MISMATCH_MIN_SILENCE_PERIOD = 1003
-
-# Set if FW generate clear alarm. 0 - generate clear alarm, Else - don't
-# generate clear alarm
-PON_ENABLE_CLEAR_ALARM = 1004
-
-# Enable or disabl send assign alloc id ploam. 0 - disable, 1 - enable
-PON_ASSIGN_ALLOC_ID_PLOAM = 1005
-
-# BIP error polling period, 200 - 65000, 0 - Disabled, Recommended: 5000
-# (default)
-PON_BIP_ERR_POLLING_PERIOD_MS = 1006
-
-# Ignore SN when decatived 0 - consider SN (deactivate the onu if received
-# same SN when activated (default)	1 - Ignore
-PON_IGNORE_SN_WHEN_ACTIVE = 1007
-
-# 0xffffffff - Disabled (default). Any other value (0 - 0xfffe) indicates
-# that PA delay is enabled, with the specified delay value and included in
-# the US_OVERHEAD PLOAM
-PON_ONU_PRE_ASSIGNED_DELAY = 1008
-
-# Enable or disable DS fragmentation, 0 disable, 1 enable
-PON_DS_FRAGMENTATION = 1009
-
-# Set if fw report rei alarm when errors is 0, 0 disable (default), 1 enable
-PON_REI_ERRORS_REPORT_ALL = 1010
-
-# Set if igonre sfi deactivation, 0 disable (default), 1 enable
-PON_IGNORE_SFI_DEACTIVATION = 1011
-
-# Allows to override the allocation overhead set by optic-params
-# configuration. This configuration is only allowed when the the pon channel
-# is disabled
-PON_OVERRIDE_ALLOCATION_OVERHEAD = 1012
-
-# Optics timeline offset, -128-127, : this parameter is very sensitive and
-# requires coordination with PMC
-PON_OPTICS_TIMELINE_OFFSET = 1013
-
-# Last general meter
-PON_LAST_GENERAL_PARAMETER = PON_OPTICS_TIMELINE_OFFSET
-
-# from enum PON_dba_mode_t
-PON_DBA_MODE_NOT_LOADED = 0
-PON_DBA_MODE_LOADED_NOT_RUNNING = 1
-PON_DBA_MODE_RUNNING = 2
-PON_DBA_MODE_LAST = 3
-
-# from enum type typedef enum PON_port_frame_destination_t
-PON_PORT_PON = 0
-PON_PORT_SYSTEM = 1
-
-PON_PORT_TYPE_GEM  = 0
-PON_PORT_TYPE_TDM  = 1
-PON_PORT_TYPE_OMCI = 2
-
-PON_PORT_DESTINATION_CNI0 = 0
-PON_PORT_DESTINATION_CNI1 = 1
-PON_PORT_DESTINATION_CNI2 = 2
-PON_PORT_DESTINATION_CPU  = 3
-
-# from enum PON_olt_hw_classification_t
-
-PON_OLT_HW_CLASSIFICATION_PAUSE = 0
-PON_OLT_HW_CLASSIFICATION_LINK_CONSTRAINT = 1
-PON_OLT_HW_CLASSIFICATION_IGMP = 2
-PON_OLT_HW_CLASSIFICATION_MPCP = 3
-PON_OLT_HW_CLASSIFICATION_OAM = 4
-PON_OLT_HW_CLASSIFICATION_802_1X = 5
-PON_OLT_HW_CLASSIFICATION_PPPOE_DISCOVERY = 6
-PON_OLT_HW_CLASSIFICATION_PPPOE_SESSION = 7
-PON_OLT_HW_CLASSIFICATION_DHCP_V4 = 8
-PON_OLT_HW_CLASSIFICATION_PIM  = 9
-PON_OLT_HW_CLASSIFICATION_DHCP_V6 = 10
-PON_OLT_HW_CLASSIFICATION_ICMP_V4 = 11
-PON_OLT_HW_CLASSIFICATION_MLD = 12
-PON_OLT_HW_CLASSIFICATION_ARP = 13
-PON_OLT_HW_CLASSIFICATION_CONF_DA = 14
-PON_OLT_HW_CLASSIFICATION_CONF_RULE = 15
-PON_OLT_HW_CLASSIFICATION_DA_EQ_SA = 16
-PON_OLT_HW_CLASSIFICATION_DA_EQ_MAC = 17
-PON_OLT_HW_CLASSIFICATION_DA_EQ_SEC_MAC = 18
-PON_OLT_HW_CLASSIFICATION_SA_EQ_MAC = 19
-PON_OLT_HW_CLASSIFICATION_SA_EQ_SEC_MAC = 20
-PON_OLT_HW_CLASSIFICATION_ETHERNET_MANAGEMENT = 100
-PON_OLT_HW_CLASSIFICATION_IPV4_LOCAL_MULTICAST = 101
-PON_OLT_HW_CLASSIFICATION_IPV4_MANAGEMENT = 102
-PON_OLT_HW_CLASSIFICATION_ALL_IPV4_MULTICAST  = 103
-PON_OLT_HW_CLASSIFICATION_IPV6_LOCAL_MULTICAST = 104
-PON_OLT_HW_CLASSIFICATION_IPV6_MANAGEMENT = 105
-PON_OLT_HW_CLASSIFICATION_ALL_IPV6_MULTICAST = 106
-PON_OLT_HW_CLASSIFICATION_OTHER	 = 107
-PON_OLT_HW_CLASSIFICATION_LAST_RULE  = 108
-
-PON_ACTIVATION_AUTH_AUTO = 0
-PON_ACTIVATION_AUTH_HOST_CONTROLLED_SEPARATE_EVENTS = 1 # Host controlled: Separate events
-PON_ACTIVATION_AUTH_HOST_CONTROLLED_LUMPED_SN = 2 # Host controlled: Lumped-SN-Response
-PON_ACTIVATION_AUTH_REGISTRATION_ID_RAW = 3 # Registration-ID Raw
-PON_ACTIVATION_AUTH_REGISTRATION_ID_LEARN = 4  # Registration-ID Learn
-
-PON_LOGICAL_OBJECT_TYPE_ALLOC_ID = 0
-PON_LOGICAL_OBJECT_TYPE_ONU_ID_BY_ALLOC_ID  = 1
-PON_LOGICAL_OBJECT_TYPE_MAX	= PON_LOGICAL_OBJECT_TYPE_ONU_ID_BY_ALLOC_ID
-
-PMC_OFAL_MAX_BI_DIRECTIONAL_FLOW_PER_ONU = 16
-PMC_OFAL_START_FLOW_ID_BASE = 1000
-
-PON_DL_VLAN_SVLAN_REMOVE = 3
-PON_DL_VLAN_CVLAN_NO_CHANGE = 0
-
-PON_VLAN_DONT_CHANGE_TAG = 0
-PON_VLAN_CHANGE_TAG = 1
-PON_VLAN_CHANGE_OTHER_TAG = 2
-PON_VLAN_CHANGE_REMOVE_TAG = 3
-
-PON_VLAN_UNUSED_TAG = -1
-PON_VLAN_DEST_DATAPATH = 1
-PON_VLAN_UNCHANGED_PRIORITY = -1
-PON_VLAN_REPLACE_PRIORITY = -2
-PON_VLAN_UNUSED_PRIORITY = -1
-
-PON_OUTPUT_VLAN_PRIO_HANDLE_DONT_CHANGE = 0
-PON_OUTPUT_VLAN_PRIO_HANDLE_INCOMING_VLAN = 1
-PON_OUTPUT_VLAN_PRIO_HANDLE_DL_VLAN_TABLE  = 2
-
-PON_N_TO_1_VLAN_MODE = 0
-PON_1_TO_1_VLAN_MODE = 1
-
-# OMCI
-
-OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME = 1
-OMCI_8021P_MSP_TP_TYPE_NULL = 0
-
-# GEM interworking option for MAC Bridge LAN
-OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER = 5
-#LLC frame encapsulation method
-OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC = 1
-# Frame Check Sequence will forward
-OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED = 0
-# in DS, perform the inverse of US operation
-OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE = 0
-# Physical path termination point Ethernet UNI
-OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI = 2
-
-# GEM Port Network CTP
-
-# Direction definitions
-GEM_DIR_BIDIRECT = 3 # bi-directional
-
-# PMC
-PMC_UPSTREAM_PORT = 129
-
-# SLA
-
-PYTHAGORAS_UPDATE_AID_SLA = 21
-PYTHAGORAS_DBA_DATA_COS = 0
-PYTHAGORAS_DBA_STATUS_REPORT_NSR = 0
-PYTHAGORAS_SET_SLA_RESP_SIZE = 10
-
-# Random values found in PMC code
-SLA_gr_bw_gros = 30
-SLA_be_bw_gros = 300
-SLA_gr_bw_fine = 0
-SLA_be_bw_fine = 0
-
-PON_MAX_DS_POLICING_CONFIGURATION_INDEX = 255
-PMC_OFAL_NO_POLICY = PON_MAX_DS_POLICING_CONFIGURATION_INDEX+1
-
-#Enum classes to set alarm parameters
-
-class AlarmEventType(Enum):
-    COMMUNICATION = 0
-    ENVIRONMENT = 1
-    EQUIPTMENT = 2
-    SERVICE = 3
-    PROCESSING = 4
-    SECURITY = 5
-
-class AlarmEventCategory(Enum):
-    PON = 0
-
-class AlarmEventState(Enum):
-    RAISED = 1
-    CLEARED = 0
-
-class AlarmEventSeverity(Enum):
-    INDETERMINATE = 0
-    WARNING = 1
-    MINOR = 2
-    MAJOR = 3
-    CRITICAL = 4
-
-AlarmEventStateDefault = 1
-
-UPSTREAM = 1
-DOWNSTREAM = 2
-
-PASCOMM_RETRIES = 5
-
-# Number of ONU LAN PORTS
-PORT_NUMBER = 1
-
diff --git a/voltha/adapters/tlgs_onu/tlgs_onu.py b/voltha/adapters/tlgs_onu/tlgs_onu.py
index 11fff22..e899eed 100644
--- a/voltha/adapters/tlgs_onu/tlgs_onu.py
+++ b/voltha/adapters/tlgs_onu/tlgs_onu.py
@@ -25,10 +25,34 @@
 import voltha.core.flow_decomposer as fd
 
 from voltha.adapters.interface import IAdapterInterface
+from voltha.adapters.microsemi_olt.DeviceManager import mac_str_to_tuple
+from voltha.adapters.microsemi_olt.PAS5211 import PAS5211GetOnuAllocs, PAS5211GetOnuAllocsResponse, PAS5211GetSnInfo, \
+    PAS5211GetSnInfoResponse, PAS5211GetOnusRange, PAS5211GetOnusRangeResponse, PAS5211MsgSetOnuOmciPortId, \
+    PAS5211MsgSetOnuOmciPortIdResponse, PAS5211MsgSetOnuAllocId, PAS5211MsgSetOnuAllocIdResponse, \
+    PAS5211SetSVlanAtConfig, PAS5211SetSVlanAtConfigResponse, PAS5211SetVlanDownConfig, \
+    PAS5211SetVlanDownConfigResponse, PAS5211SetDownVlanHandl, PAS5211SetDownVlanHandlResponse, \
+    PAS5211SetUplinkVlanHandl, PAS5211SetDownstreamPolicingConfigResponse, PAS5211SetDownstreamPolicingConfig, \
+    PAS5211SetPortIdPolicingConfig, PAS5211UnsetPortIdPolicingConfig, \
+    PAS5211MsgSendDbaAlgorithmMsg, PAS5211MsgSendDbaAlgorithmMsgResponse, \
+    PAS5211SetUpstreamPolicingConfigResponse, PAS5211SetUpstreamPolicingConfig, \
+    PAS5211MsgSetPortIdConfig, PAS5211MsgSetPortIdConfigResponse, \
+    PAS5211MsgGetOnuIdByPortId, PAS5211MsgGetOnuIdByPortIdResponse, \
+    PAS5211SetVlanUplinkConfiguration, PAS5211SetVlanUplinkConfigurationResponse, PAS5211SetUplinkVlanHandlResponse, PAS5211SetVlanGenConfig, PAS5211SetVlanGenConfigResponse, \
+    PAS5211GetPortIdDownstreamPolicingConfig, PAS5211GetPortIdDownstreamPolicingConfigResponse, PAS5211RemoveDownstreamPolicingConfig, \
+    PAS5211MsgHeader, PAS5211UnsetPortIdPolicingConfigResponse, PAS5211RemoveDownstreamPolicingConfigResponse, \
+    PAS5211SetPortIdPolicingConfigResponse
+from voltha.adapters.microsemi_olt.PAS5211_constants import OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER, PON_FALSE, \
+    PON_1_TO_1_VLAN_MODE, PON_TRUE, PON_VLAN_UNUSED_TAG, PON_VLAN_UNUSED_PRIORITY, PON_VLAN_REPLACE_PRIORITY, \
+    PON_OUTPUT_VLAN_PRIO_HANDLE_INCOMING_VLAN, PON_VLAN_UNCHANGED_PRIORITY, PON_OUTPUT_VLAN_PRIO_HANDLE_DONT_CHANGE, \
+    PON_OUTPUT_VLAN_PRIO_HANDLE_DL_VLAN_TABLE, PON_DL_VLAN_SVLAN_REMOVE, PON_DL_VLAN_CVLAN_NO_CHANGE, \
+    PON_VLAN_DEST_DATAPATH, GEM_DIR_BIDIRECT, OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED, \
+    OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC, OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME, OMCI_8021P_MSP_TP_TYPE_NULL, \
+    OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI, OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE, PMC_UPSTREAM_PORT, \
+    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, \
+    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, \
+    PMC_OFAL_NO_POLICY, UPSTREAM, DOWNSTREAM
 
 from voltha.extensions.omci.omci_frame import OmciFrame
-from voltha.extensions.omci.omci_entities import Ieee8021pMapperServiceProfile
-
 from voltha.protos import third_party
 from voltha.protos.adapter_pb2 import Adapter
 from voltha.protos.adapter_pb2 import AdapterConfig
@@ -36,24 +60,16 @@
 from voltha.protos.device_pb2 import DeviceType, DeviceTypes, Port
 from voltha.protos.health_pb2 import HealthStatus
 from voltha.protos.logical_device_pb2 import LogicalPort
-from voltha.protos.openflow_13_pb2 import OFPPF_10GB_FD, OFPPF_FIBER, ofp_port, OFPPS_LIVE, OFPXMC_OPENFLOW_BASIC
+from voltha.protos.openflow_13_pb2 import OFPPF_1GB_FD, OFPPF_FIBER, ofp_port, OFPPS_LIVE, OFPXMC_OPENFLOW_BASIC
 
 from voltha.extensions.omci.omci_messages import OmciGet, OmciGetResponse, OmciCreate, OmciMibResetResponse, OmciSet, \
     OmciSetResponse, OmciCreateResponse, OmciMibReset, OmciDelete, OmciDeleteResponse
-
-from voltha.adapters.microsemi_olt.PAS5211_comm import PAS5211Communication
+from adapters.microsemi_olt.OMCIProxy import OMCIProxy
+from voltha.adapters.microsemi_olt.APIProxy import APIProxy
 from voltha.registry import registry
 from voltha.extensions.omci.omci_entities import VlanTaggingOperation
 from voltha.protos.openflow_13_pb2 import Flows, FlowGroups
 
-from common.frameio.frameio import hexify
-
-from tlgs_constants import OMCI_GEM_IWTP_IW_OPT_8021P_MAPPER, PON_FALSE, \
-    GEM_DIR_BIDIRECT, OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED, \
-    OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC, OMCI_8021P_MSP_UNMARKED_FRAME_TAG_FRAME, OMCI_8021P_MSP_TP_TYPE_NULL, \
-    OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI, OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE, PMC_UPSTREAM_PORT, \
-    SLA_gr_bw_gros, SLA_be_bw_gros, SLA_gr_bw_fine, SLA_be_bw_fine, PORT_NUMBER
-
 import Queue
 from struct import pack, unpack
 
@@ -72,13 +88,14 @@
 OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER = 0
 OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100 = 4
 
+MAX_FLOW_EVENT_RETRIES = 5
+
 def sequence_generator(init):
     num = init
     while True:
         yield num
         num += 1
 
-
 @implementer(IAdapterInterface)
 class TlgsOnuAdapter(object):
 
@@ -109,7 +126,6 @@
         #self.trangen = sequence_generator(1)
 
         # As of broadcom_onu.py
-        # [channel_id] and [onu_id] -> BrcmOnuHandler()
         self.device_handlers = dict()
         # register for adapter messages
         self.adapter_agent.register_for_inter_adapter_messages()
@@ -181,9 +197,11 @@
         if device.proxy_address.channel_id not in self.device_handlers:
             self.device_handlers[device.proxy_address.channel_id] = dict()
 
-        self.device_handlers[device.proxy_address.channel_id] = TlgsOnuHandler(self, device.id)
+        self.device_handlers[device.proxy_address.channel_id][
+            device.proxy_address.onu_id] = TlgsOnuHandler(self, device.id)
 
-        reactor.callLater(1, self.device_handlers[device.proxy_address.channel_id].activate, device)
+        reactor.callLater(1, self.device_handlers[device.proxy_address.channel_id][
+                          device.proxy_address.onu_id].activate, device)
 
         return device
 
@@ -195,13 +213,20 @@
 
     def disable_device(self, device):
         log.debug('disable-device', device=device.id)
-        reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id].deactivate, device)
+
+        reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id][
+            device.proxy_address.onu_id].deactivate, device)
+        #raise NotImplementedError()
 
     def reenable_device(self, device):
         raise NotImplementedError()
 
     def reboot_device(self, device):
-        raise NotImplementedError()
+        log.debug('reboot-device', device=device.id)
+
+        reactor.callLater(0, self.device_handlers[device.proxy_address.channel_id][
+            device.proxy_address.onu_id].reboot, device)
+        # raise NotImplementedError()
 
     def download_image(self, device, request):
         raise NotImplementedError()
@@ -219,12 +244,16 @@
         raise NotImplementedError()
 
     def self_test_device(self, device):
+        """
+        This is called to Self a device based on a NBI call.
+        :param device: A Voltha.Device object.
+        :return: Will return result of self test
+        """
         log.debug('self-test-device', device=device.id)
         raise NotImplementedError()
 
     def delete_device(self, device):
         log.debug('delete-device', device_id=device.id)
-        raise NotImplementedError()
 
     def get_device_details(self, device):
         raise NotImplementedError()
@@ -232,7 +261,7 @@
     def deactivate(self, device):
         try:
             handler = self.device_handlers[
-                device.proxy_address.channel_id]
+                device.proxy_address.channel_id][device.proxy_address.onu_id]
             return handler.deactivate(device)
         except Exception as e:
             log.exception('failed-to-deactivate-onu', e=e)
@@ -241,6 +270,7 @@
     def update_pm_config(self, device, pm_configs):
         raise NotImplementedError()
 
+    # @inlineCallbacks
     def update_flows_bulk(self, device, flows, groups):
         log.debug('onu-bulk-flow-update', device_id=device.id,
             flows=flows, groups=groups)
@@ -248,7 +278,7 @@
         try:
             assert len(groups.items) == 0
             handler = self.device_handlers[
-                device.proxy_address.channel_id]
+                device.proxy_address.channel_id][device.proxy_address.onu_id]
             handler.update_flow_table(device, flows.items)
         except Exception as e:
             log.exception('failed-to-update-flow-table', e=e)
@@ -261,17 +291,16 @@
         log.debug("send-proxied-message in TLGS ONU")
 
     def receive_proxied_message(self, proxy_address, msg):
-        log.debug('receive-proxied-message', msg=hexify(msg))
+        log.debug('receive-proxied-message')
+        # mgs - > onu_id
+        if PAS5211MsgHeader in msg:
+            if msg['PAS5211MsgHeader'].onu_id != -1:
+                handler = self.device_handlers[
+                    proxy_address.channel_id][msg.onu_id]
+                handler.receive_message(msg)
 
-        handler = self.device_handlers[
-            proxy_address.channel_id]
-
-        omci = OmciFrame(msg)
-        if omci is not None:
-            if omci.message_type in (16, 17):
-                return
-
-        handler.receive_message(msg)
+        # for onu, handler in self.device_handlers[proxy_address.channel_id].iteritems():
+        #     handler.receive_message(msg)
 
     def receive_packet_out(self, logical_device_id, egress_port_no, msg):
         log.debug('packet-out', logical_device_id=logical_device_id,
@@ -309,6 +338,7 @@
         self.adapter_agent = adapter.adapter_agent
         self.device_id = device_id
         self.log = structlog.get_logger(device_id=device_id)
+        #self.incoming_messages = Queue.Queue()
         self.incoming_messages = DeferredQueue()
         self.event_messages = Queue.Queue()
         self.proxy_address = None
@@ -317,7 +347,7 @@
         self.port_id = None
         self.alloc_id = None
         self.cvlan_id = None
-        self.subsvlan_id = 0
+        self.subsvlan_id = None
         self.bandwidth = None
         self.flows_lock = 0
         self.flows = None
@@ -325,112 +355,120 @@
         self.flow_queue = DeferredQueue()
 
     def receive_message(self, msg):
-        log.debug("receive-message")
+        log.debug("receive-message",msg=msg.show(dump=True))
         self.incoming_messages.put(msg)
 
-    @inlineCallbacks
     def activate(self, device):
         log.debug('activate-onu-handler', device=device)
         try:
+
             # register for proxied messages right away
             self.proxy_address = device.proxy_address
             self.adapter_agent.register_for_proxied_messages(device.proxy_address)
 
-            response = yield self.create_common_omci_config(device)
+            # First we verify that we got parent reference and proxy info
+            assert device.parent_id
+            assert device.proxy_address.device_id
+            # == 0 # We want to activate multiple ONT's
+            assert device.proxy_address.channel_id is not None
+            # to get onu_id = device.proxy_address.onu_id
 
-            if response:
-                # First we verify that we got parent reference and proxy info
-                assert device.parent_id
-                assert device.proxy_address.device_id
-                # == 0 # We want to activate multiple ONT's
-                assert device.proxy_address.channel_id is not None
-                # to get onu_id = device.proxy_address.onu_id
+            # From PMC code:
+            self.port_id = 1000 + 16 * device.proxy_address.onu_id
+            self.alloc_id = self.port_id
 
-                # From PMC code:
-                self.port_id = 1000 + 16 * device.proxy_address.onu_id
-                self.alloc_id = self.port_id
+            # we are going to use the proxy_address.channel_id as unique number
+            # and name for the virtual ports, as this is guaranteed to be unique
+            # in the context of the OLT port, so it is also unique in the context
+            # of the logical device
 
-                device.model = 'GPON ONU'
-                device.hardware_version = 'tbd'
-                device.firmware_version = 'tbd'
+            device.model = 'GPON ONU'
+            device.hardware_version = 'tbd'
+            device.firmware_version = 'tbd'
 
-                device.connect_status = ConnectStatus.REACHABLE
+            device.connect_status = ConnectStatus.REACHABLE
 
-                uni_port = Port(port_no=1,
-                                label="{} ONU".format('TLGS'),
-                                type=Port.ETHERNET_UNI,
-                                admin_state=AdminState.ENABLED,
-                                oper_status=OperStatus.ACTIVE
-                                )
-
-                self.adapter_agent.add_port(device.id, uni_port)
-
-                log.debug('add-onu-port')
-
-                pon_port = Port(
-                                port_no=2,
-                                label='PON port',
-                                type=Port.PON_ONU,
-                                admin_state=AdminState.ENABLED,
-                                oper_status=OperStatus.ACTIVE,
-                                peers=[
-                                    Port.PeerPort(
-                                        device_id=device.parent_id,
-                                        port_no=device.parent_port_no
-                                    )
-                                ]
+            uni_port = Port(port_no=1,
+                            label="{} ONU".format('TLGS'),
+                            type=Port.ETHERNET_UNI,
+                            admin_state=AdminState.ENABLED,
+                            oper_status=OperStatus.ACTIVE
                             )
 
-                self.adapter_agent.add_port(device.id, pon_port)
+            self.adapter_agent.add_port(device.id, uni_port)
 
-                log.debug('add-onu-port')
+            log.debug('add-onu-port')
 
-                # obtain logical device id
-                parent_device = self.adapter_agent.get_device(device.parent_id)
-                logical_device_id = parent_device.parent_id
-                assert logical_device_id
-                port_no = device.proxy_address.channel_id
-                cap = OFPPF_10GB_FD | OFPPF_FIBER
+            pon_port = Port(
+                            port_no=2,
+                            label='PON port',
+                            type=Port.PON_ONU,
+                            admin_state=AdminState.ENABLED,
+                            oper_status=OperStatus.ACTIVE,
+                            peers=[
+                                Port.PeerPort(
+                                    device_id=device.parent_id,
+                                    port_no=device.parent_port_no
+                                )
+                            ]
+                        )
 
-                self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
-                    id=str(port_no),
-                    ofp_port=ofp_port(
-                        port_no=port_no,
-                        hw_addr=mac_str_to_tuple(device.mac_address),
-                        name='uni-{}'.format(port_no),
-                        config=0,
-                        state=OFPPS_LIVE,
-                        curr=cap,
-                        advertised=cap,
-                        peer=cap,
-                        curr_speed=OFPPF_10GB_FD,
-                        max_speed=OFPPF_10GB_FD
-                    ),
-                    device_id=device.id,
-                    device_port_no=uni_port.port_no
-                ))
+            self.adapter_agent.add_port(device.id, pon_port)
 
-                log.debug('add-onu-logical-port')
+            log.debug('add-onu-port')
 
-                # Input logical port from ONT
-                self.port_no = port_no
+            # obtain logical device id
+            parent_device = self.adapter_agent.get_device(device.parent_id)
+            logical_device_id = parent_device.parent_id
+            assert logical_device_id
+            port_no = (device.proxy_address.channel_id * 32) + \
+                (device.proxy_address.onu_id + 1)
+            cap = OFPPF_1GB_FD | OFPPF_FIBER
 
-                # Finally update to "ACTIVE"
-                device = self.adapter_agent.get_device(device.id)
-                # In broadcom_onu.py this state is DISCOVERED
-                device.oper_status = OperStatus.ACTIVE
-                self.adapter_agent.update_device(device)
+            self.adapter_agent.add_logical_port(logical_device_id, LogicalPort(
+                id=str(port_no),
+                ofp_port=ofp_port(
+                    port_no=port_no,
+                    hw_addr=mac_str_to_tuple(device.serial_number)[2:8],
+                    # name='uni-{}'.format(port_no),
+                    name=device.serial_number[0:6],
+                    config=0,
+                    state=OFPPS_LIVE,
+                    curr=cap,
+                    advertised=cap,
+                    peer=cap,
+                    curr_speed=OFPPF_1GB_FD,
+                    max_speed=OFPPF_1GB_FD
+                ),
+                device_id=device.id,
+                device_port_no=uni_port.port_no
+            ))
 
-                log.info('Device activated', device=device)
+            log.debug('add-onu-logical-port')
 
-                reactor.callLater(0, self.wait_for_flow_events, device)
+            # Input logical port from ONT
+            self.port_no = port_no
 
-            else:
-                raise Exception('Exception during onu activation')
+            # Finally update to "ACTIVE"
+            device = self.adapter_agent.get_device(device.id)
+            # In broadcom_onu.py this state is DISCOVERED
+            device.oper_status = OperStatus.ACTIVE
+            self.adapter_agent.update_device(device)
+
+            log.info('activate-onu-end', device=device)
+
+            # # Just in case, pull for existing flows...
+            # flows = self.adapter_agent.root_proxy.get('/devices/{}/flows'.format(device.id))
+
+            # log.debug('flows-got-from-deviceid', flows=flows.items)
+            # reactor.callLater(0, self.update_flow_table, device, flows.items)
+
+            # Listening thread (we wait 5 secs to start reading from queue)
+            reactor.callLater(0, self.wait_for_flow_events, device)
 
         except Exception as e:
             log.exception('activate-failed', e=e)
-            raise Exception('Exception during onu activation')
+            # raise Exception('Exception during onu activation')
 
     @inlineCallbacks
     def wait_for_flow_events(self, device):
@@ -451,62 +489,91 @@
                 log.debug("Event handled flow successfully")
             else:
                 log.debug("Error handling flow event")
+                # if event['retries'] < MAX_FLOW_EVENT_RETRIES:
+                #     # Failed install events are turned into reinstall...
+                #     if event['action'] == 'install':
+                #         event['action'] = 'reinstall'
+                #     event['retries'] += 1
+                #     log.debug("Flow event retry")
+                #     self.flow_queue.put(event)
+                # else:
+                #     log.debug("Max retries done for flow event handling.", event=event)
+                #     # If we were trying to install a flow, we remove it...
+                #     if event['action'] !=  'remove':
+                #         event['action'] = 'remove'
+                #         event['retries'] = 0
+                #         self.flow_queue.put(event)
 
         except Exception as e:
             log.exception('wait-for-flow-events-exception', e=e)
 
         reactor.callLater(0, self.wait_for_flow_events, device)
 
+    def reboot(self, device):
+        log.debug('onu-reboot-start', device=device)
+
+        if self.cvlan_id is not None and self.subsvlan_id is not None:
+            flow_event = {'action': 'reinstall', 'cvlan': self.cvlan_id,
+                    'subsvlan': self.subsvlan_id, 'retries': 0}
+            self.flow_queue.put(flow_event)
+            log.debug('onu-reinstall-event-created')
+        else:
+            log.debug('onu-reboot-ignored')
+
+        log.debug('onu-reboot-end', device=device)
+
     def deactivate(self, device):
-        log.debug('deactivate', device=device)
-        # Check parent reference and proxy info exists
-        assert device.parent_id
-        assert device.proxy_address.device_id
+        try:
+            log.debug('deactivate-onu', device=device)
+            # Check parent reference and proxy info exists
+            assert device.parent_id
+            assert device.proxy_address.device_id
 
-        # unregister from proxy messages
-        self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
-        self.proxy_address = None
+            # unregister from proxy messages
+            self.adapter_agent.unregister_for_proxied_messages(device.proxy_address)
+            self.proxy_address = None
 
-        # Delete references to ports
-        onu_port = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)[0]
-        self.adapter_agent.delete_port_reference_from_parent(device.id, onu_port)
+            # Delete references to ports, if any
 
-        pon_port = self.adapter_agent.get_ports(device.id, Port.PON_ONU)[0]
-        self.adapter_agent.delete_port_reference_from_parent(device.id, pon_port)
+            if self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI):
+                onu_port = self.adapter_agent.get_ports(device.id, Port.ETHERNET_UNI)[0]
+                self.adapter_agent.delete_port_reference_from_parent(device.id, onu_port)
 
-        # Delete device and logical ports
-        parent_device = self.adapter_agent.get_device(device.parent_id)
-        logical_device_id = parent_device.parent_id
-        # logical_device = self.adapter_agent.get_logical_device(logical_device_id)
-        # self.adapter_agent.delete_logical_device(logical_device)
+            if  self.adapter_agent.get_ports(device.id, Port.PON_ONU):
+                pon_port = self.adapter_agent.get_ports(device.id, Port.PON_ONU)[0]
+                self.adapter_agent.delete_port_reference_from_parent(device.id, pon_port)
 
-        logical_port = self.adapter_agent.get_logical_port(logical_device_id, self.port_no)
-        self.adapter_agent.delete_logical_port(logical_device_id, logical_port)
+            # Delete device and logical ports
+            parent_device = self.adapter_agent.get_device(device.parent_id)
+            logical_device_id = parent_device.parent_id
+            # logical_device = self.adapter_agent.get_logical_device(logical_device_id)
+            # self.adapter_agent.delete_logical_device(logical_device)
 
-        device = self.adapter_agent.get_device(device.id)
-        self.adapter_agent.update_child_device_state(device, connect_status=ConnectStatus.UNREACHABLE)
+            if logical_device_id:
+                logical_port = self.adapter_agent.get_logical_port(logical_device_id, self.port_no)
+                if logical_port:
+                    self.adapter_agent.delete_logical_port(logical_device_id, logical_port)
 
-        device = self.adapter_agent.get_device(device.id)
-        self.adapter_agent.update_child_device_state(device, oper_status=OperStatus.FAILED)
-        # device.connect_status = ConnectStatus.UNREACHABLE
-        # self.adapter_agent.update_device(device)
+            # Finally delete device
+            self.adapter_agent.delete_child_device(
+                parent_device_id=device.proxy_address.device_id,
+                child_device_id=device.id)
 
-        # Finally delete device
-        self.adapter_agent.delete_child_device(
-            parent_device_id=device.proxy_address.device_id,
-            child_device_id=device.id)
+            log.debug('deactivate-onu-end')
 
-        log.debug('deactivate ended')
+        except Exception as e:
+            log.exception('deactivate-failed', e=e)
+            # raise Exception('Exception during onu deactivation')
 
     # @inlineCallbacks
     def update_flow_table(self, device, flows):
         cvlan_found = None
         subsvlan_found = 0
 
-        log.debug('onu-update-flow-table', device_id=device.id, flows=flows)
-        port_no = device.proxy_address.channel_id
-        log.debug('Checking {} flows for port:{}'.format(len(flows), port_no))
 
+        log.debug('onu-update-flow-table', device_id=device.id, flows=flows)
+        port_no = (device.proxy_address.channel_id * 32) + (device.proxy_address.onu_id + 1)
+        log.debug('Checking {} flows for port:{}'.format(len(flows), port_no))
         try:
 
             for flow in flows:
@@ -521,19 +588,17 @@
                                         cvlan_found = action.set_field.field.ofb_field.vlan_vid & 0xfff
                                         log.debug('CVLAN found:{}'.format(cvlan_found))
 
-
             if cvlan_found:
                 if cvlan_found != self.cvlan_id:
                     if self.cvlan_id:
-
                         log.debug('Reinstall flow triggered')
                         flow_event = {'action': 'reinstall', 'cvlan': cvlan_found,
-                                'subsvlan': subsvlan_found}
+                                'subsvlan': subsvlan_found, 'retries': 0}
                         self.flow_queue.put(flow_event)
                     else:
                         log.debug('Flows installation triggered')
                         flow_event = {'action': 'install', 'cvlan': cvlan_found,
-                                'subsvlan': subsvlan_found}
+                                'subsvlan': subsvlan_found, 'retries': 0}
                         self.flow_queue.put(flow_event)
                 else:
                     log.debug('Flows already installed')
@@ -541,7 +606,7 @@
                 if self.cvlan_id:
                     log.debug('Flows deinstallation triggered')
                     flow_event = {'action': 'remove', 'cvlan': self.cvlan_id,
-                                'subsvlan': self.subsvlan_id}
+                                'subsvlan': self.subsvlan_id, 'retries': 0}
                     self.flow_queue.put(flow_event)
                 else:
                     log.debug('Incomplete flow')
@@ -570,7 +635,6 @@
                 response = yield self.install_flows_sequence(device, cvlan_id, subsvlan_id)
                 returnValue(response)
             returnValue(False)
-
         except Exception as e:
             log.exception('failed-to-launch-reinstall-flow', e=e)
 
@@ -585,20 +649,19 @@
             log.exception('failed-to-launch-install-flow', e=e)
 
     @inlineCallbacks
-    def wait_for_omci_response(self):
+    def wait_for_response(self):
         log.debug('wait-for-response')
         response = yield self.incoming_messages.get()
-        log.debug("unqueued-message", msg=hexify(response))
-        returnValue(OmciFrame(response))
+        log.debug("unqueued-message",msg=response.show(dump=True))
+        returnValue(response)
 
+
+    # PMC_OFAL.c line:2554
     @inlineCallbacks
-    def create_common_omci_config(self, device):
-        log.debug('create-common-omci-config')
-
-        alloc_id = 0x408 + device.proxy_address.onu_id
+    def create_data_flow_omci_config(self, device, cvlan_id, subsvlan_id):
 
         self.OMCI_ont_data_mib_reset(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
 
         if OmciMibResetResponse not in response:
             log.error("Failed to perform a MIB reset for {}".format(
@@ -606,8 +669,8 @@
             returnValue(False)
         log.debug("[RESPONSE] OMCI_ont_data_mib_reset")
 
-        self.OMCI_tcont_set(device, alloc_id)
-        response = yield self.wait_for_omci_response()
+        self.OMCI_tcont_set(device)
+        response = yield self.wait_for_response()
         if OmciSetResponse not in response:
             log.error("Failed to set alloc id for {}".format(
                 device.proxy_address))
@@ -615,7 +678,7 @@
         log.debug("[RESPONSE] OMCI_tcont_set")
 
         self.pmc_omci_mac_bridge_sp_me_create(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciCreateResponse not in response:
             log.error("Failed to set parameter on {}".format(
                 device.proxy_address))
@@ -623,70 +686,65 @@
         log.debug("[RESPONSE] OMCI_mac_bridge_sp_me_create")
 
         self.pmc_omci_mac_bridge_pcd_me_create(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciCreateResponse not in response:
             log.error("Failed to set info for {}".format(device.proxy_address))
             returnValue(False)
         log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_create")
 
-        for port in range(1, PORT_NUMBER+1):
-            self.pmc_omci_mac_bridge_pcd_me_allocate(device, port)
-            response = yield self.wait_for_omci_response()
-            if OmciCreateResponse not in response:
-                log.error("Failed to create mac bridge pcd on {}".format(
-                    device.proxy_address))
-                returnValue(False)
-            log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_allocate")
+        self.pmc_omci_evto_create(device)
+        response = yield self.wait_for_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to set association info for {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_evto_create")
 
-        returnValue(True)
+        self.pmc_omci_evto_set(device)
+        response = yield self.wait_for_response()
+        if OmciSetResponse not in response:
+            log.error("Failed to set association tpid info for {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_evto_set")
 
-    @inlineCallbacks
-    def create_data_flow_omci_config(self, device, cvlan_id, subsvlan_id):
-
+        # Reuse create_default_data_flow_omci_config (confirmed from logs)
         self.pmc_omci_8021p_msp_me_allocate(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciCreateResponse not in response:
             log.error("Failed to create 8021p msp on {}".format(
                 device.proxy_address))
             if response is not None:
-                log.error("Response received: {}".format(response.summary())) 
+                log.error("Response received: {}".format(response.summary()))
             returnValue(False)
         log.debug("[RESPONSE] OMCI_8021p_msp_me_allocate")
 
+        # Reuse create_default_data_flow_omci_config?
+        self.pmc_omci_mac_bridge_pcd_me_allocate(device)
+        response = yield self.wait_for_response()
+        if OmciCreateResponse not in response:
+            log.error("Failed to create mac bridge pcd on {}".format(
+                device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_mac_bridge_pcd_me_allocate")
+
+        response = yield self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(
+            device, cvlan_id, subsvlan_id)
+
+        if not response:
+            returnValue(False)
+        log.debug("[RESPONSE] OMCI_send_set_extended_vlan_tagging")
+
         self.send_create_vlan_tagging_filter_data(device, cvlan_id)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciCreateResponse not in response:
             log.error("Failed to set vlan tagging filter in {}".format(
                 device.proxy_address))
             returnValue(False)
         log.debug("[RESPONSE] OMCI_send_create_vlan_tagging_filter_data")
 
-        for port in range(1, PORT_NUMBER+1):
-            self.pmc_omci_evto_create(device, port)
-            response = yield self.wait_for_omci_response()
-            if OmciCreateResponse not in response:
-                log.error("Failed to set association info for {}".format(
-                    device.proxy_address))
-                returnValue(False)
-            log.debug("[RESPONSE] OMCI_evto_create")
-
-            self.pmc_omci_evto_set(device, port)
-            response = yield self.wait_for_omci_response()
-            if OmciSetResponse not in response:
-                log.error("Failed to set association tpid info for {}".format(
-                    device.proxy_address))
-                returnValue(False)
-            log.debug("[RESPONSE] OMCI_evto_set")
-
-            response = yield self.send_set_extended_vlan_tagging_operation_vlan_configuration_data(
-            device, cvlan_id, subsvlan_id, port)
-
-            if not response:
-                returnValue(False)
-            log.debug("[RESPONSE] OMCI_send_set_extended_vlan_tagging")
-
         self.pmc_omci_gem_nctp_me_allocate(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciCreateResponse not in response:
             log.error("Failed to Create gem nctp on {}".format(
                 device.proxy_address))
@@ -694,7 +752,7 @@
         log.debug("[RESPONSE] OMCI_gem_nctp_me_allocate")
 
         self.pmc_omci_gem_iwtp_me_allocate(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciCreateResponse not in response:
             log.error("Failed to Create gem iwtp on {}".format(
                 device.proxy_address))
@@ -702,7 +760,8 @@
         log.debug("[RESPONSE] OMCI_gem_iwtp_me_allocate")
 
         self.pmc_omci_8021p_msp_me_assign(device)
-        response = yield self.wait_for_omci_response()
+
+        response = yield self.wait_for_response()
         if OmciSetResponse not in response:
             log.error("Failed to assign sp {}".format(
                 device.proxy_address))
@@ -711,31 +770,32 @@
 
         returnValue(True)
 
+    # PMC_OFAL.c line:3065
     @inlineCallbacks
     def delete_data_flow_omci_config(self, device):
-        for port in range(1, PORT_NUMBER+1):
-            self.pmc_omci_evto_deallocate(device, port)
-            response = yield self.wait_for_omci_response()
-            if OmciDeleteResponse not in response:
-                log.error(
-                    "Failed to deallocate evt for {}".format(device.proxy_address))
-                if response is not None:
-                    log.error("Response received: {}".format(response.summary()))
-                returnValue(False)
-            log.debug("[RESPONSE] pmc_omci_evto_deallocate", device=device)
+
+        self.pmc_omci_evto_deallocate(device)
+        response = yield self.wait_for_response()
+        if OmciDeleteResponse not in response:
+            log.error(
+                "Failed to deallocate evt for {}".format(device.proxy_address))
+            if response is not None:
+                log.error("Response received: {}".format(response.summary()))
+            returnValue(False)
+        log.debug("[RESPONSE] pmc_omci_evto_deallocate", device=device)
 
         self.pmc_omci_gem_iwtp_me_deallocate(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciDeleteResponse not in response:
             log.error(
                 "Failed to deallocate iwtp for {}".format(device.proxy_address))
             if response is not None:
-                log.error("Response received: {}".format(response.summary())) 
+                log.error("Response received: {}".format(response.summary()))
             returnValue(False)
         log.debug("[RESPONSE] pmc_omci_gem_iwtp_me_deallocate", device=device)
 
         self.pmc_omci_gem_nctp_me_deallocate(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciDeleteResponse not in response:
             log.error(
                 "Failed to deallocate nctp for {}".format(device.proxy_address))
@@ -743,15 +803,23 @@
         log.debug("[RESPONSE] pmc_omci_gem_nctp_me_deallocate", device=device)
 
         self.pmc_omci_vlan_tagging_filter_me_deallocate(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciDeleteResponse not in response:
             log.error(
                 "Failed to deallocate vlan tagging for {}".format(device.proxy_address))
             returnValue(False)
         log.debug("[RESPONSE] pmc_omci_vlan_tagging_filter_me_deallocate", device=device)
 
+        self.pmc_omci_mac_bridge_pcd_me_deallocate(device)
+        response = yield self.wait_for_response()
+        if OmciDeleteResponse not in response:
+            log.error(
+                "Failed to deallocate bridge pcd for {}".format(device.proxy_address))
+            returnValue(False)
+        log.debug("[RESPONSE] pmc_omci_mac_bridge_pcd_me_deallocate", device=device)
+
         self.pmc_omci_8021p_msp_me_deallocate(device)
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciDeleteResponse not in response:
             log.error(
                 "Failed to deallocate msp for {}".format(device.proxy_address))
@@ -760,7 +828,9 @@
 
         returnValue(True)
 
-    """ -   -   -   -   -   -   -   create_common_omci_config   -   -   -   -   -   -   - """
+
+    """ -   -   -   -   -   -   -     create_data_flow_omci_config      -   -   -   -   -   -   - """
+
 
     def OMCI_ont_data_mib_reset(self, device):
         # DO things to the ONU
@@ -780,11 +850,11 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciMibReset.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] OMCI_ont_data_mib_reset")
 
-    def OMCI_tcont_set(self, device, alloc_id):
+    def OMCI_tcont_set(self, device):
         # | ###[ OmciFrame ]###
         # | transaction_id = 2
         # | message_type = 72
@@ -806,13 +876,12 @@
         # TODO: maskdata
         msg = OmciSet(entity_class=262, entity_id=32769, attributes_mask=32768,
                       data=dict(
-                          alloc_id=alloc_id
+                          alloc_id=self.alloc_id
                       ))
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciSet.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] OMCI_tcont_set")
 
     def pmc_omci_mac_bridge_sp_me_create(self, device):
@@ -859,8 +928,7 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciCreate.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_mac_bridge_sp_me_create")
 
     def pmc_omci_mac_bridge_pcd_me_create(self, device):
@@ -883,11 +951,11 @@
 
         msg = OmciCreate(entity_class=47, entity_id=0,
                          data=dict(
-                             tp_pointer=1,
+                             tp_pointer=257,
                              encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC,
                              port_num=0,
                              port_priority=10,
-                             tp_type=3,
+                             tp_type=1,
                              port_path_cost=100,
                              port_spanning_tree_in=PON_FALSE,
                              lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED,
@@ -897,11 +965,11 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciCreate.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_create")
 
-    def pmc_omci_evto_create(self, device, port):
+    def pmc_omci_evto_create(self, device):
         # |###[ OmciFrame ]###
         # |  transaction_id= 5
         # |  message_type= 68
@@ -914,20 +982,20 @@
         # |  omci_trailer= 40
 
         # Found in method: pmc_omci_evto_create from: PMC_OFAL.c
-        msg = OmciCreate(entity_class=171, entity_id=port,
+        msg = OmciCreate(entity_class=171, entity_id=0,
                          data=dict(
                              association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI,
-                             associated_me_pointer=0x100+port
+                             associated_me_pointer=257
                          ))
 
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciCreate.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_evto_create")
 
-    def pmc_omci_evto_set(self, device, port):
+    def pmc_omci_evto_set(self, device):
         # |###[ OmciFrame ]###
         # |  transaction_id= 6
         # |  message_type= 72
@@ -941,25 +1009,23 @@
         # |  omci_trailer= 40
 
         # Found in method: pmc_omci_evto_set from: PMC_OFAL.c
-        msg = OmciSet(entity_class=171, entity_id=port, attributes_mask=47616,
+        msg = OmciSet(entity_class=171, entity_id=0, attributes_mask=47616,
                       data=dict(
                           association_type=OMCI_EX_VLAN_TAG_OCD_ASSOCIATION_TYPE_PPTP_ETH_UNI,
-                          input_tpid=0x8100,
-                          associated_me_pointer=0x100+port,
+                          input_tpid=33024,
+                          associated_me_pointer=257,
                           downstream_mode=OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE,
-                          output_tpid=0x8100
+                          output_tpid=33024
                       ))
 
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciSet.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_evto_set")
 
-    """ -   -   -   -   -   -   -     END create_common_omci_config     -   -   -   -   -   -   - """
 
-    """ -   -   -   -   -   -   create_default_data_flow_omci_config    -   -   -   -   -   -   - """
 
     def pmc_omci_8021p_msp_me_allocate(self, device):
         # |###[ OmciFrame ]###
@@ -997,11 +1063,11 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciCreate.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_8021p_msp_me_allocate")
 
-    def pmc_omci_mac_bridge_pcd_me_allocate(self, device, port):
+    def pmc_omci_mac_bridge_pcd_me_allocate(self, device):
         # |###[ OmciFrame ]###
         # |  transaction_id= 8
         # |  message_type= 68
@@ -1017,13 +1083,13 @@
         # Params
         #   - port_path_cost: The cost contribution of the port to the path cost towards the spanning tree root bridge
         #   - bridge_id_pointer: MAC bridge controlling the port
-        msg = OmciCreate(entity_class=47, entity_id=port,
+        msg = OmciCreate(entity_class=47, entity_id=1,
                          data=dict(
-                             tp_pointer=0x100 + port,
+                             tp_pointer=1,
                              encapsulation_methods=OMCI_MAC_BRIDGE_PCD_ENCAP_METHOD_LLC,
-                             port_num=port,
+                             port_num=1,
                              port_priority=10,
-                             tp_type=1,
+                             tp_type=3,
                              port_path_cost=100,
                              port_spanning_tree_in=PON_FALSE,
                              lan_fcs_ind=OMCI_MAC_BRIDGE_PCD_LANFCS_FORWARDED,
@@ -1033,8 +1099,8 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciCreate.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_allocate")
 
     def pmc_omci_gem_nctp_me_allocate(self, device):
@@ -1056,7 +1122,7 @@
                              direction=GEM_DIR_BIDIRECT,
                              tcont_pointer=32769,
                              traffic_descriptor_profile_pointer=0,
-                             traffic_management_pointer_upstream=4,  # 4 for default
+                             traffic_management_pointer_upstream=4,  # 4 for feault
                              # Same as GEM port
                              # port_id=(1000 + device.proxy_address.onu_id)
                              port_id = self.port_id
@@ -1065,8 +1131,8 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciCreate.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_gem_nctp_me_allocate")
 
     def pmc_omci_gem_iwtp_me_allocate(self, device):
@@ -1100,16 +1166,57 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciCreate.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_gem_iwtp_me_allocate")
 
-    """ -   -   -   -   -   -    END create_default_data_flow_omci_config   -   -   -   -   -   - """
 
-    """ -   -   -   -   -   -   -     create_data_flow_omci_config      -   -   -   -   -   -   - """
+
+    def send_create_extended_vlan_tagging_operation_configuration_data(self, device):
+
+        msg = OmciCreate(entity_class=171,
+                         entity_id=0,
+                         data=dict(
+                             association_type=2,
+                             associated_me_pointer=257
+                         ))
+
+        frame = OmciFrame(transaction_id=self.trangen.next(),
+                          message_type=OmciCreate.message_id,
+                          omci_message=msg)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
+        log.debug(
+            "[SENT] create_extended_vlan_tagging_operation_configuration_data")
+
+    # self.send_set_extended_vlan_tagging_operation_tpid_configuration_data(0x202, 0x8100, 0x8100)
+    def send_set_extended_vlan_tagging_operation_tpid_configuration_data(self, device):
+
+        data = dict(
+            association_type=2,
+            input_tpid=33024,
+            associated_me_pointer=257,
+            downstream_mode=OMCI_EX_VLAN_TAG_OCD_DS_MODE_US_INVERSE,
+            output_tpid=33024,
+        )
+
+        msg = OmciSet(entity_class=171,
+                      entity_id=0,
+                      attributes_mask=47616,  # 1024 in broadcom but 47616 observed from PMC
+                      data=data
+                      )
+
+        frame = OmciFrame(
+            transaction_id=self.trangen.next(),
+            message_type=OmciSet.message_id,
+            omci_message=msg
+        )
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
+        log.debug(
+            "[SENT] set_extended_vlan_tagging_operation_tpid_configuration_data")
 
     @inlineCallbacks
-    def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self, device, cvlan_id, subs_vlan, port):
+    def send_set_extended_vlan_tagging_operation_vlan_configuration_data(self, device, cvlan_id, subs_vlan):
         # ###[ PAS5211MsgSendFrame ]###
         #            length    = 44
         #            port_type = 0
@@ -1128,6 +1235,10 @@
         #             |   |  data      = {'received_frame_vlan_tagging_operation_table': '\xf8\x00\x00\x00\x00\x00@\x00@\x0f\x00\x04\x00\x00\x00\x0c'}
         #             |  omci_trailer= 40
 
+        # TODO  Check filter_inner_priority value
+        """vlan_oper_table_entry.filter_configuration.filter_inner_tagging.vlan_priority = filter_inner_vlan_pcp;
+            vlan_oper_table_entry.filter_configuration.filter_inner_tagging.vlan_vid = filter_inner_vlan_id;
+        """
         self.send_vlan_tagging_operation_msg(device,
             VlanTaggingOperation(
                 filter_outer_priority=OMCI_EX_VLAN_TAG_OCD_FILTER_PRIO_NO_TAG,
@@ -1147,8 +1258,9 @@
                 treatment_inner_priority=0,
                 treatment_inner_vid=cvlan_id,
                 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_EQ_8100
-            ), port)
-        response = yield self.wait_for_omci_response()
+            )
+            )
+        response = yield self.wait_for_response()
 
         log.debug(
             "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
@@ -1180,12 +1292,13 @@
                 treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
                 treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
                 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
-            ), port)
+            )
+            )
 
         log.debug(
             "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
 
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciSetResponse not in response:
             log.error("Failed to set vlan extended table entry {}".format(
                 device.proxy_address))
@@ -1213,12 +1326,13 @@
                 treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
                 treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
                 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
-            ), port)
+            )
+            )
 
         log.debug(
             "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
 
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciSetResponse not in response:
             log.error("Failed to set vlan extended table entry {}".format(
                 device.proxy_address))
@@ -1246,22 +1360,25 @@
                 treatment_inner_priority=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_NONE,
                 treatment_inner_vid=OMCI_EX_VLAN_TAG_OCD_TREAT_PRIO_COPY_FROM_INNER,
                 treatment_inner_tpid_de=OMCI_EX_VLAN_TAG_OCD_TREAT_TPID_DE_COPY_FROM_INNER
-            ), port)
+            )
+            )
 
         log.debug(
             "[SENT] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
 
-        response = yield self.wait_for_omci_response()
+        response = yield self.wait_for_response()
         if OmciSetResponse not in response:
             log.error("Failed to set vlan extended table entry {}".format(
                 device.proxy_address))
             returnValue(False)
+
         log.debug(
             "[RESPONSE] send_set_extended_vlan_tagging_operation_vlan_configuration_data")
 
         returnValue(True)
 
-    def send_vlan_tagging_operation_msg(self, device, vlan_tagging_operation_table, port):
+
+    def send_vlan_tagging_operation_msg(self, device, vlan_tagging_operation_table):
 
         data = dict(
             received_frame_vlan_tagging_operation_table=vlan_tagging_operation_table
@@ -1269,7 +1386,7 @@
 
         msg = OmciSet(
             entity_class=171,
-            entity_id=port,
+            entity_id=0,
             attributes_mask=1024,
             data=data
         )
@@ -1279,8 +1396,8 @@
             message_type=OmciSet.message_id,
             omci_message=msg
         )
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] create_vlan_tagging_filter_data")
 
     def send_create_vlan_tagging_filter_data(self, device, cvlan_id):
@@ -1318,10 +1435,91 @@
             message_type=OmciCreate.message_id,
             omci_message=msg
         )
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] create_vlan_tagging_filter_data")
 
+    def pmc_ofal_remove_default_onu_flow_omci(self, device):  # TODO
+        # ###[ PAS5211Dot3 ]###
+        #     dst = 00:0
+        #     c: d5:00: 04:10
+        #     src = 02:00: d3:77: 47:49
+        #     len = 74
+        # ###[ PAS5211FrameHeader ]###
+        #     part = 1
+        #     total_parts = 1
+        #     size = 68
+        #     magic_number = 0x1234abcd
+        # ###[ PAS5211MsgHeader ]###
+        #     sequence_number = 201
+        #     opcode = 0x302a
+        #     event_type = 0
+        #     channel_id = 1
+        #     onu_id = 0
+        #     onu_session_id = 1
+        # ###[ PAS5211MsgSendFrame ]###
+        #     length = 44
+        #     port_type = 0
+        #     port_id = 0
+        #     management_frame = 1
+        #     \frame \
+        #      |  ###[ OmciFrame ]###
+        #         | transaction_id = 44
+        #         | message_type = 70
+        #         | omci = 10
+        #         |   \omci_message \
+        #              | |  ###[ OmciDelete ]###
+        #         | | entity_class = 47
+        #         | | entity_id = 1
+        #     | omci_trailer = 40
+        log.debug("[SENT] pmc_ofal_remove_default_onu_flow_omci")
+        pass
+
+    def pmc_omci_evto_vlan_oper_table_entry_assign(self, device):  # TODO
+
+        # /* Fill the set message */
+        # entity.entity_class    = OMCI_ENT_EX_VLAN_TAGGING_OPER_CONFIG_DATA;
+        # entity.entity_instance = entity_instance;
+        # set_req_msg.attr_mask  = attributes_mask;
+
+        # typedef struct OMCI_ex_vlan_tagging_operation_config_me_set_t
+        # {
+        #     INT8U             association_type;    /* Association type  ,R,W,C  (ASSOCIATION_TYPE_)*/
+        #     INT16U            input_tpid;         /* Input TPID value   ,R,W (16 bit value)*/
+        #     INT16U            output_tpid;        /* Output TPID value  ,R,W (16 bit value)*/
+        #     INT8U             downstream_mode;    /* downstream mode    ,R,W (OCD_DS_MODE_)*/
+        #
+        #     OMCI_ex_vlan_tag_op_table_entry_t       /* Operation entry    ,R,W (16 bytes)    */
+        #                         operations_entry;
+        #
+        #     OMCI_instance_id_t    associated_me_ptr;
+        #
+        #     INT8U               dscp2pbit_mapping[OMCI_EX_VLAN_TAG_ATTR_DSCP2PBIT_MAPPING_SIZE];/*dscp-to-pbit mapping ,R,W (24 bytes)*/
+        #
+        # } OMCI_ex_vlan_tagging_operation_config_me_set_t;
+
+        # attibute_mask = 0
+        # # attibute_mask |= ( (INT16U)1 << ((OMCI_ATTR_MAX-1)-(OMCI_EX_VLAN_TAG_OCD_ATTR_RX_FRAME_OP_TABLE)))
+        # msg = OmciSet(entity_class=OMCI_ENT_EX_VLAN_TAGGING_OPER_CONFIG_DATA, entity_id=0, attributes_mask=attibute_mask,
+        #               data=dict(
+        #                   association_type=,
+        #                   input_tpid=,
+        #                   output_tpid=,
+        #                   downstream_mode=,
+        #                   associated_me_pointer=,
+        #                   dscp2pbit_mapping=
+        #               ))
+
+        # frame = OmciFrame(transaction_id=self.trangen.next(),
+        #                   message_type=OmciSet.message_id,
+        #                   omci_message=msg)
+
+        # self.adapter_agent.send_proxied_message(device.proxy_address, frame)
+
+        # TODO: Sends up to three OMCI Set messages
+        log.debug("[SENT] pmc_omci_evto_vlan_oper_table_entry_assign")
+        pass
+
     @inlineCallbacks
     def pmc_omci_vlan_tagging_filter_me_allocate(self, device):  # TODO
 
@@ -1377,8 +1575,7 @@
             message_type=OmciSet.message_id,
             omci_message=msg
         )
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
 
         log.debug("[SENT] pmc_omci_8021p_msp_me_assign")
 
@@ -1423,8 +1620,8 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciDelete.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_gem_iwtp_me_deallocate")
 
     def pmc_omci_gem_nctp_me_deallocate(self, device):
@@ -1442,8 +1639,8 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciDelete.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_gem_nctp_me_allocate")
 
     def pmc_omci_vlan_tagging_filter_me_deallocate(self, device):
@@ -1461,8 +1658,8 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciDelete.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_vlan_tagging_filter_me_deallocate")
 
 
@@ -1481,8 +1678,8 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciDelete.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_mac_bridge_pcd_me_deallocate")
 
 
@@ -1502,23 +1699,25 @@
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciDelete.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_8021p_msp_me_deallocate")
 
-    def pmc_omci_evto_deallocate(self, device, port):
+    def pmc_omci_evto_deallocate(self, device):
 
-        msg = OmciDelete(entity_class=171, entity_id=port)
+        msg = OmciDelete(entity_class=171, entity_id=1)
 
         frame = OmciFrame(transaction_id=self.trangen.next(),
                           message_type=OmciDelete.message_id,
                           omci_message=msg)
-        _frame = hexify(str(frame))
-        self.adapter_agent.send_proxied_message(device.proxy_address, _frame)
+        self.adapter_agent.send_proxied_message(device.proxy_address, frame)
         log.debug("[SENT] pmc_omci_evto_deallocate")
 
 
+
     """ -   -   -   -   -   -   -   END delete_data_flow_omci_config   -   -   -   -   -   -   - """
 
-def mac_str_to_tuple(mac):
-    return tuple(int(d, 16) for d in mac.split(':'))
+
+
+
+