Initil implementation of PMC ONU Adapter.
OLTs can now detect pmc ONUs and advertise them to
the voltha core. The Adapter itself is still a shell.
Change-Id: I6ce3f3b8180f61de978a33d6e4d78792de5267a6
diff --git a/voltha/adapters/microsemi/ActivationWatcher.py b/voltha/adapters/microsemi_olt/ActivationWatcher.py
similarity index 92%
rename from voltha/adapters/microsemi/ActivationWatcher.py
rename to voltha/adapters/microsemi_olt/ActivationWatcher.py
index 8036b1d..7fe30cd 100644
--- a/voltha/adapters/microsemi/ActivationWatcher.py
+++ b/voltha/adapters/microsemi_olt/ActivationWatcher.py
@@ -15,8 +15,8 @@
#
from scapy.automaton import ATMT
import structlog
-from voltha.adapters.microsemi.BaseOltAutomaton import BaseOltAutomaton
-from voltha.adapters.microsemi.PAS5211 import PAS5211EventOnuActivation, PAS5211MsgGetActivationAuthMode, \
+from voltha.adapters.microsemi_olt.BaseOltAutomaton import BaseOltAutomaton
+from voltha.adapters.microsemi_olt.PAS5211 import PAS5211EventOnuActivation, PAS5211MsgGetActivationAuthMode, \
PAS5211MsgGetActivationAuthModeResponse, PON_ACTIVATION_AUTH_AUTO, PON_ENABLE, PAS5211MsgSetOnuOmciPortId, \
PAS5211MsgSetOnuOmciPortIdResponse, PAS5211MsgSendFrame, PON_PORT_PON, PAS5211MsgSendFrameResponse
from voltha.extensions.omci.omci_entities import CircuitPack
@@ -97,8 +97,7 @@
Utility Methods
"""
- def create_port(self, pkt):
- vendor = pkt['OmciGetResponse'].data['vendor_id']
+ def create_port(self, vendor):
port = Port(port_no=self.port_id,
label="{} ONU".format(vendor),
type=Port.ETHERNET_UNI,
@@ -193,7 +192,7 @@
@ATMT.receive_condition(wait_send_frame)
def wait_for_send_frame(self, pkt):
- if pkt.opcode == PAS5211MsgSendFrameResponse.opcode:
+ if PAS5211MsgSendFrameResponse in pkt:
raise self.wait_omci_get()
# Transitions from wait_omci_get
@@ -205,9 +204,16 @@
@ATMT.receive_condition(wait_omci_get)
def wait_for_omci_get(self, pkt):
if OmciGetResponse in pkt:
- log.info("Activated {} ONT".format(pkt['OmciGetResponse'].data['vendor_id']))
- self.create_port(pkt)
- # TODO: create onu proxy device
+ vendor = pkt['OmciGetResponse'].data['vendor_id']
+ log.info("Activated {} ONT".format(vendor))
+ self.create_port(vendor)
+
+ self.device.onu_detected(
+ parent_port_no=self.channel_id,
+ child_device_type='%s_onu' % vendor.lower(),
+ onu_id=self.port_id,
+ )
+
raise self.end()
diff --git a/voltha/adapters/microsemi/BaseOltAutomaton.py b/voltha/adapters/microsemi_olt/BaseOltAutomaton.py
similarity index 100%
rename from voltha/adapters/microsemi/BaseOltAutomaton.py
rename to voltha/adapters/microsemi_olt/BaseOltAutomaton.py
diff --git a/voltha/adapters/microsemi/DeviceManager.py b/voltha/adapters/microsemi_olt/DeviceManager.py
similarity index 88%
rename from voltha/adapters/microsemi/DeviceManager.py
rename to voltha/adapters/microsemi_olt/DeviceManager.py
index c785c58..ea2b607 100644
--- a/voltha/adapters/microsemi/DeviceManager.py
+++ b/voltha/adapters/microsemi_olt/DeviceManager.py
@@ -16,6 +16,7 @@
from uuid import uuid4
import structlog
from voltha.protos.common_pb2 import ConnectStatus, OperStatus
+from voltha.protos.device_pb2 import Device
from voltha.protos.logical_device_pb2 import LogicalDevice, LogicalPort
from voltha.protos.openflow_13_pb2 import ofp_desc, ofp_switch_features, OFPC_FLOW_STATS, OFPC_TABLE_STATS, \
OFPC_PORT_STATS, OFPC_GROUP_STATS, ofp_port, OFPPS_LIVE, OFPPF_10GB_FD, OFPPF_FIBER
@@ -101,6 +102,20 @@
self.adapter_agent.add_logical_port(self.logical_device.id,
logical_port)
+ def onu_detected(self, parent_port_no=None,
+ child_device_type=None,
+ onu_id=None):
+ self.adapter_agent.child_device_detected(
+ parent_device_id=self.device.id,
+ parent_port_no=parent_port_no,
+ child_device_type=child_device_type,
+ proxy_address=Device.ProxyAddress(
+ device_id=self.device.id,
+ channel_id=onu_id
+ ),
+ vlan=0
+ )
+
def activate(self):
self.device = self.adapter_agent.get_device(self.device.id)
self.device.parent_id = self.logical_device.id
diff --git a/voltha/adapters/microsemi/OltStateMachine.py b/voltha/adapters/microsemi_olt/OltStateMachine.py
similarity index 97%
rename from voltha/adapters/microsemi/OltStateMachine.py
rename to voltha/adapters/microsemi_olt/OltStateMachine.py
index 0913247..3c77415 100644
--- a/voltha/adapters/microsemi/OltStateMachine.py
+++ b/voltha/adapters/microsemi_olt/OltStateMachine.py
@@ -15,8 +15,8 @@
#
from scapy.automaton import ATMT
import structlog
-from voltha.adapters.microsemi.BaseOltAutomaton import BaseOltAutomaton
-from voltha.adapters.microsemi.PAS5211 import PAS5211MsgGetProtocolVersion, PAS5211MsgGetOltVersion, \
+from voltha.adapters.microsemi_olt.BaseOltAutomaton import BaseOltAutomaton
+from voltha.adapters.microsemi_olt.PAS5211 import PAS5211MsgGetProtocolVersion, PAS5211MsgGetOltVersion, \
PAS5211MsgGetOltVersionResponse, PAS5211MsgGetProtocolVersionResponse, \
SnrBurstDelay, RngBurstDelay, GeneralOpticsParams, ResetValues, ResetTimingCtrl, PreambleParams, \
PAS5211MsgSetOltOpticsResponse, CHANNELS, PON_OPTICS_VOLTAGE_IF_LVPECL, PON_ENABLE, PON_POLARITY_ACTIVE_HIGH, \
@@ -26,7 +26,7 @@
PAS5211MsgGetDbaModeResponse, PON_DBA_MODE_LOADED_NOT_RUNNING, PAS5211MsgStartDbaAlgorithm, \
PAS5211MsgStartDbaAlgorithmResponse, PON_DBA_MODE_RUNNING, PAS5211MsgSetOltChannelActivationPeriod, \
PAS5211MsgSetOltChannelActivationPeriodResponse
-from voltha.adapters.microsemi.PAS5211_utils import general_param, olt_optics_pkt, burst_timing, io_ctrl_optics, \
+from voltha.adapters.microsemi_olt.PAS5211_utils import general_param, olt_optics_pkt, burst_timing, io_ctrl_optics, \
alarm_config
import structlog
@@ -265,7 +265,6 @@
@ATMT.receive_condition(wait_olt_optics)
def receive_set_optics_response(self, pkt):
if PAS5211MsgSetOltOpticsResponse in pkt:
- print "GOT OPTICS RESP"
self.send_state[pkt.channel_id] = True
if self.check_channel_state():
raise self.got_olt_optics()
diff --git a/voltha/adapters/microsemi/PAS5211.py b/voltha/adapters/microsemi_olt/PAS5211.py
similarity index 99%
rename from voltha/adapters/microsemi/PAS5211.py
rename to voltha/adapters/microsemi_olt/PAS5211.py
index 7939e91..e564a99 100644
--- a/voltha/adapters/microsemi/PAS5211.py
+++ b/voltha/adapters/microsemi_olt/PAS5211.py
@@ -585,7 +585,7 @@
class PAS5211MsgGetActivationAuthModeResponse(PAS5211Msg):
opcode = 10385
- name = "PAS5211MsgGetActivationAuthMode"
+ name = "PAS5211MsgGetActivationAuthModeResponse"
fields_desc = [
LEShortField("mode", 0),
LEShortField("reserved", 0),
diff --git a/voltha/adapters/microsemi/PAS5211_comm.py b/voltha/adapters/microsemi_olt/PAS5211_comm.py
similarity index 95%
rename from voltha/adapters/microsemi/PAS5211_comm.py
rename to voltha/adapters/microsemi_olt/PAS5211_comm.py
index 62ad573..e7cc36d 100644
--- a/voltha/adapters/microsemi/PAS5211_comm.py
+++ b/voltha/adapters/microsemi_olt/PAS5211_comm.py
@@ -16,7 +16,7 @@
import netifaces
from scapy.layers.l2 import Dot3
import structlog
-from voltha.adapters.microsemi.PAS5211 import PAS5211Msg, PAS5211MsgHeader, PAS5211FrameHeader
+from voltha.adapters.microsemi_olt.PAS5211 import PAS5211Msg, PAS5211MsgHeader, PAS5211FrameHeader
log = structlog.get_logger()
diff --git a/voltha/adapters/microsemi/PAS5211_constants.py b/voltha/adapters/microsemi_olt/PAS5211_constants.py
similarity index 100%
rename from voltha/adapters/microsemi/PAS5211_constants.py
rename to voltha/adapters/microsemi_olt/PAS5211_constants.py
diff --git a/voltha/adapters/microsemi/PAS5211_hardware.py b/voltha/adapters/microsemi_olt/PAS5211_hardware.py
similarity index 100%
rename from voltha/adapters/microsemi/PAS5211_hardware.py
rename to voltha/adapters/microsemi_olt/PAS5211_hardware.py
diff --git a/voltha/adapters/microsemi/PAS5211_utils.py b/voltha/adapters/microsemi_olt/PAS5211_utils.py
similarity index 94%
rename from voltha/adapters/microsemi/PAS5211_utils.py
rename to voltha/adapters/microsemi_olt/PAS5211_utils.py
index 3d0d507..709af3f 100644
--- a/voltha/adapters/microsemi/PAS5211_utils.py
+++ b/voltha/adapters/microsemi_olt/PAS5211_utils.py
@@ -14,12 +14,12 @@
# limitations under the License.
#
-from voltha.adapters.microsemi.PAS5211 import PAS5211MsgGetGeneralParam, PON_POLARITY_ACTIVE_LOW, \
+from voltha.adapters.microsemi_olt.PAS5211 import PAS5211MsgGetGeneralParam, PON_POLARITY_ACTIVE_LOW, \
PON_POLARITY_ACTIVE_HIGH, PAS5211MsgSetOpticsIoControl, BurstTimingCtrl, PAS5211MsgSetOltOptics, PON_ALARM_LOS, \
PON_ALARM_LOSI, PON_ALARM_DOWI, PON_ALARM_LOFI, PON_ALARM_RDII, PON_ALARM_LOAMI, PON_ALARM_LCDGI, PON_ALARM_LOAI, \
PON_ALARM_SDI, PON_ALARM_SFI, PON_ALARM_PEE, PON_ALARM_DGI, PON_ALARM_LOKI, PON_ALARM_TIWI, PON_ALARM_TIA, \
PAS5211MsgSetAlarmConfig
-from voltha.adapters.microsemi.PAS5211_hardware import PON_ALARM_CODE_LOS, PON_ALARM_CODE_LOSI, PON_ALARM_CODE_DOWI, \
+from voltha.adapters.microsemi_olt.PAS5211_hardware import PON_ALARM_CODE_LOS, PON_ALARM_CODE_LOSI, PON_ALARM_CODE_DOWI, \
PON_ALARM_CODE_LOFI, PON_ALARM_CODE_RDII, PON_ALARM_CODE_LOAMI, PON_ALARM_CODE_LCDGI, PON_ALARM_CODE_LOAI, \
PON_ALARM_CODE_SDI, PON_ALARM_CODE_SFI, PON_ALARM_CODE_PEE, PON_ALARM_CODE_DGI, PON_ALARM_CODE_LOKI, \
PON_ALARM_CODE_TIWI, PON_ALARM_CODE_TIA, PON_ALARM_CODE_LAST_ALARM
diff --git a/voltha/adapters/microsemi/README.md b/voltha/adapters/microsemi_olt/README.md
similarity index 100%
rename from voltha/adapters/microsemi/README.md
rename to voltha/adapters/microsemi_olt/README.md
diff --git a/voltha/adapters/microsemi/__init__.py b/voltha/adapters/microsemi_olt/__init__.py
similarity index 100%
rename from voltha/adapters/microsemi/__init__.py
rename to voltha/adapters/microsemi_olt/__init__.py
diff --git a/voltha/adapters/microsemi/main.py b/voltha/adapters/microsemi_olt/main.py
similarity index 98%
rename from voltha/adapters/microsemi/main.py
rename to voltha/adapters/microsemi_olt/main.py
index 22e4b38..6a539dc 100644
--- a/voltha/adapters/microsemi/main.py
+++ b/voltha/adapters/microsemi_olt/main.py
@@ -20,7 +20,7 @@
from common.utils.dockerhelpers import get_my_containers_name
import os
from twisted.internet import reactor
-from voltha.adapters.microsemi.microsemi import RubyAdapter
+from voltha.adapters.microsemi_olt.microsemi import RubyAdapter
import yaml
defs = dict(
diff --git a/voltha/adapters/microsemi/microsemi.py b/voltha/adapters/microsemi_olt/microsemi_olt.py
similarity index 91%
rename from voltha/adapters/microsemi/microsemi.py
rename to voltha/adapters/microsemi_olt/microsemi_olt.py
index 418ec1e..86026f4 100644
--- a/voltha/adapters/microsemi/microsemi.py
+++ b/voltha/adapters/microsemi_olt/microsemi_olt.py
@@ -25,10 +25,10 @@
from voltha.adapters.interface import IAdapterInterface
-from voltha.adapters.microsemi.ActivationWatcher import ActivationWatcher
-from voltha.adapters.microsemi.DeviceManager import DeviceManager
-from voltha.adapters.microsemi.OltStateMachine import OltStateMachine
-from voltha.adapters.microsemi.PAS5211_comm import PAS5211Communication
+from voltha.adapters.microsemi_olt.ActivationWatcher import ActivationWatcher
+from voltha.adapters.microsemi_olt.DeviceManager import DeviceManager
+from voltha.adapters.microsemi_olt.OltStateMachine import OltStateMachine
+from voltha.adapters.microsemi_olt.PAS5211_comm import PAS5211Communication
from voltha.protos import third_party
from voltha.protos.adapter_pb2 import Adapter, AdapterConfig
from voltha.protos.common_pb2 import LogLevel
@@ -45,11 +45,11 @@
@implementer(IAdapterInterface)
class RubyAdapter(object):
- name = "microsemi"
+ name = "microsemi_olt"
supported_device_types = [
DeviceType(
- id='microsemi',
+ id=name,
adapter=name,
accepts_bulk_flow_update=True
)
@@ -139,6 +139,7 @@
olt, activation = self.olts[target]
olt.stop()
activation.stop()
+ del self.olts[target]
diff --git a/voltha/adapters/microsemi/pcaps/olt-with-onu.pcap b/voltha/adapters/microsemi_olt/pcaps/olt-with-onu.pcap
similarity index 100%
rename from voltha/adapters/microsemi/pcaps/olt-with-onu.pcap
rename to voltha/adapters/microsemi_olt/pcaps/olt-with-onu.pcap
Binary files differ
diff --git a/voltha/adapters/microsemi/pcaps/olt.pcap b/voltha/adapters/microsemi_olt/pcaps/olt.pcap
similarity index 100%
rename from voltha/adapters/microsemi/pcaps/olt.pcap
rename to voltha/adapters/microsemi_olt/pcaps/olt.pcap
Binary files differ
diff --git a/voltha/adapters/microsemi/ruby.yml b/voltha/adapters/microsemi_olt/ruby.yml
similarity index 100%
rename from voltha/adapters/microsemi/ruby.yml
rename to voltha/adapters/microsemi_olt/ruby.yml
diff --git a/voltha/adapters/microsemi/test_chat.py b/voltha/adapters/microsemi_olt/test_chat.py
similarity index 100%
rename from voltha/adapters/microsemi/test_chat.py
rename to voltha/adapters/microsemi_olt/test_chat.py
diff --git a/voltha/adapters/microsemi/__init__.py b/voltha/adapters/pmcs_onu/__init__.py
similarity index 100%
copy from voltha/adapters/microsemi/__init__.py
copy to voltha/adapters/pmcs_onu/__init__.py
diff --git a/voltha/adapters/pmcs_onu/pmcs_onu.py b/voltha/adapters/pmcs_onu/pmcs_onu.py
new file mode 100644
index 0000000..3e5149a
--- /dev/null
+++ b/voltha/adapters/pmcs_onu/pmcs_onu.py
@@ -0,0 +1,104 @@
+#
+# 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.
+#
+
+"""
+PMC Sierra ONU adapter
+"""
+
+import structlog
+from twisted.internet import reactor
+from zope.interface import implementer
+
+from voltha.adapters.interface import IAdapterInterface
+from voltha.protos import third_party
+from voltha.protos.adapter_pb2 import Adapter
+from voltha.protos.adapter_pb2 import AdapterConfig
+from voltha.protos.common_pb2 import LogLevel
+from voltha.protos.device_pb2 import DeviceType, DeviceTypes
+from voltha.protos.health_pb2 import HealthStatus
+
+_ = third_party
+log = structlog.get_logger()
+
+@implementer(IAdapterInterface)
+class PmcsOnu(object):
+
+ name = 'pmcs_onu'
+
+ supported_device_types = [
+ DeviceType(
+ id=name,
+ adapter=name,
+ accepts_bulk_flow_update=True
+ )
+ ]
+
+ def __init__(self, adapter_agent, config):
+ self.adapter_agent = adapter_agent
+ self.config = config
+ self.descriptor = Adapter(
+ id=self.name,
+ vendor='PMCS',
+ version='0.1',
+ config=AdapterConfig(log_level=LogLevel.INFO)
+ )
+
+ def start(self):
+ log.debug('starting')
+ log.info('started')
+
+ def stop(self):
+ log.debug('stopping')
+ log.info('stopped')
+
+ def adapter_descriptor(self):
+ return self.descriptor
+
+ def device_types(self):
+ return DeviceTypes(items=self.supported_device_types)
+
+ def health(self):
+ return HealthStatus(state=HealthStatus.HealthState.HEALTHY)
+
+ def change_master_state(self, master):
+ raise NotImplementedError()
+
+ def adopt_device(self, device):
+ return device
+
+ def abandon_device(self, device):
+ raise NotImplementedError()
+
+ def deactivate_device(self, device):
+ raise NotImplementedError()
+
+ def update_flows_bulk(self, device, flows, groups):
+ log.info('bulk-flow-update', device_id=device.id,
+ flows=flows, groups=groups)
+
+ def update_flows_incrementally(self, device, flow_changes, group_changes):
+ raise NotImplementedError()
+
+ def send_proxied_message(self, proxy_address, msg):
+ log.info('send-proxied-message', proxy_address=proxy_address, msg=msg)
+
+ def receive_proxied_message(self, proxy_address, msg):
+ log.info('receive-proxied-message', proxy_address=proxy_address,
+ device_id=proxy_address.device_id, msg=msg)
+
+ def receive_packet_out(self, logical_device_id, egress_port_no, msg):
+ log.info('packet-out', logical_device_id=logical_device_id,
+ egress_port_no=egress_port_no, msg_len=len(msg))
\ No newline at end of file