[VOL-1800] Implement Performance configuration in Voltha Core.
This is a port of the exisiting voltha 1.x funtionality into
the Voltha 2.0 Core.
Change-Id: I87bf8836fd392c1c7f4a2c45e85323d1cbe0079f
diff --git a/adapters/simulated_onu/adaptercore/device_handler.go b/adapters/simulated_onu/adaptercore/device_handler.go
index 61b1c0b..908fdd5 100644
--- a/adapters/simulated_onu/adaptercore/device_handler.go
+++ b/adapters/simulated_onu/adaptercore/device_handler.go
@@ -30,6 +30,21 @@
"time"
)
+// A set of pm names to create the initial pm config. This is used only for testing in this simulated adapter
+var pmNames = []string{
+ "tx_64_pkts",
+ "tx_65_127_pkts",
+ "tx_128_255_pkts",
+ "tx_1024_1518_pkts",
+ "tx_1519_9k_pkts",
+ "rx_64_pkts",
+ "rx_64_pkts",
+ "rx_65_127_pkts",
+ "rx_128_255_pkts",
+ "rx_1024_1518_pkts",
+ "rx_1519_9k_pkts",
+}
+
//DeviceHandler follows the same patterns as ponsim_olt. The only difference is that it does not
// interact with an OLT device.
type DeviceHandler struct {
@@ -42,6 +57,7 @@
ponPort *voltha.Port
exitChannel chan int
lockDevice sync.RWMutex
+ metrics *com.PmMetrics
}
//NewDeviceHandler creates a new device handler
@@ -55,6 +71,13 @@
dh.simulatedOLT = adapter
dh.exitChannel = make(chan int, 1)
dh.lockDevice = sync.RWMutex{}
+ dh.metrics = com.NewPmMetrics(
+ cloned.Id,
+ com.Frequency(150),
+ com.Grouped(false),
+ com.FrequencyOverride(false),
+ com.Metrics(pmNames),
+ )
return &dh
}
@@ -113,6 +136,11 @@
log.Errorw("error-creating-nni-port", log.Fields{"deviceId": device.Id, "error": err})
}
+ // Now, set the initial PM configuration for that device
+ if err := dh.coreProxy.DevicePMConfigUpdate(nil, dh.metrics.ToPmConfigs()); err != nil {
+ log.Errorw("error-updating-PMs", log.Fields{"deviceId": device.Id, "error": err})
+ }
+
// Sleep to mimic the omci management channel creation with the OLT
time.Sleep(10 * time.Millisecond)
@@ -268,3 +296,9 @@
// For now we do nothing with it
return
}
+
+func (dh *DeviceHandler) UpdatePmConfigs(device *voltha.Device, pmConfigs *voltha.PmConfigs) {
+ log.Debugw("UpdatePmConfigs", log.Fields{"deviceId": device.Id, "pmConfigs": pmConfigs})
+ // For now we do nothing with it
+ return
+}
diff --git a/adapters/simulated_onu/adaptercore/simulated_onu.go b/adapters/simulated_onu/adaptercore/simulated_onu.go
index d8d4127..02448f5 100644
--- a/adapters/simulated_onu/adaptercore/simulated_onu.go
+++ b/adapters/simulated_onu/adaptercore/simulated_onu.go
@@ -233,8 +233,17 @@
return nil
}
-func (so *SimulatedONU) Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error {
- return errors.New("UnImplemented")
+func (so *SimulatedONU) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
+ if device == nil {
+ log.Warn("device-is-nil")
+ return errors.New("nil-device")
+ }
+ log.Debugw("update_pm_config", log.Fields{"deviceId": device.Id, "pmConfigs": pmConfigs})
+ var handler *DeviceHandler
+ if handler = so.getDeviceHandler(device.Id); handler != nil {
+ go handler.UpdatePmConfigs(device, pmConfigs)
+ }
+ return nil
}
func (so *SimulatedONU) Receive_packet_out(deviceId string, egress_port_no int, msg *openflow_13.OfpPacketOut) error {