[VOL-4420] Add support for POTS UNI ports to bbsim
Change-Id: Ibb817ced6086c3ef3001f338d98513101ce64c1c
diff --git a/internal/bbsim/api/onus_handler.go b/internal/bbsim/api/onus_handler.go
index 92ab912..2638bf5 100644
--- a/internal/bbsim/api/onus_handler.go
+++ b/internal/bbsim/api/onus_handler.go
@@ -48,7 +48,7 @@
ImageSoftwareExpectedSections: int32(o.ImageSoftwareExpectedSections),
ActiveImageEntityId: int32(o.ActiveImageEntityId),
CommittedImageEntityId: int32(o.CommittedImageEntityId),
- Unis: convertBBsimUniPortsToProtoUniPorts(o.UniPorts),
+ Unis: append(convertBBsimUniPortsToProtoUniPorts(o.UniPorts), convertBBsimPotsPortsToProtoUniPorts(o.PotsPorts)...),
}
onus.Items = append(onus.Items, &onu)
}
@@ -71,7 +71,7 @@
OperState: onu.OperState.Current(),
InternalState: onu.InternalState.Current(),
PonPortID: int32(onu.PonPortID),
- Unis: convertBBsimUniPortsToProtoUniPorts(onu.UniPorts),
+ Unis: append(convertBBsimUniPortsToProtoUniPorts(onu.UniPorts), convertBBsimPotsPortsToProtoUniPorts(onu.PotsPorts)...),
}
return &res, nil
}
diff --git a/internal/bbsim/api/uni_handler.go b/internal/bbsim/api/uni_handler.go
index 50b9911..89115aa 100644
--- a/internal/bbsim/api/uni_handler.go
+++ b/internal/bbsim/api/uni_handler.go
@@ -18,6 +18,7 @@
import (
"context"
+
"github.com/opencord/bbsim/api/bbsim"
"github.com/opencord/bbsim/internal/bbsim/devices"
)
@@ -31,6 +32,19 @@
PortNo: int32(u.PortNo),
OperState: u.OperState.Current(),
Services: convertBBsimServicesToProtoServices(u.Services),
+ Type: bbsim.UniType_ETH,
+ }
+}
+
+func convertBBSimPotsPortToProtoUniPort(u *devices.PotsPort) *bbsim.UNI {
+ return &bbsim.UNI{
+ ID: int32(u.ID),
+ OnuID: int32(u.Onu.ID),
+ OnuSn: u.Onu.Sn(),
+ MeID: uint32(u.MeId.ToUint16()),
+ PortNo: int32(u.PortNo),
+ OperState: u.OperState.Current(),
+ Type: bbsim.UniType_POTS,
}
}
@@ -43,6 +57,15 @@
return unis
}
+func convertBBsimPotsPortsToProtoUniPorts(list []devices.PotsPortIf) []*bbsim.UNI {
+ unis := []*bbsim.UNI{}
+ for _, u := range list {
+ uni := u.(*devices.PotsPort)
+ unis = append(unis, convertBBSimPotsPortToProtoUniPort(uni))
+ }
+ return unis
+}
+
func (s BBSimServer) GetOnuUnis(ctx context.Context, req *bbsim.ONURequest) (*bbsim.UNIs, error) {
onu, err := s.GetONU(ctx, req)
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index cf658eb..8520bf2 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -20,12 +20,13 @@
"context"
"encoding/hex"
"fmt"
- "github.com/opencord/voltha-protos/v5/go/extension"
"net"
"strconv"
"sync"
"time"
+ "github.com/opencord/voltha-protos/v5/go/extension"
+
"github.com/opencord/bbsim/internal/bbsim/responders/dhcp"
"github.com/opencord/bbsim/internal/bbsim/types"
omcilib "github.com/opencord/bbsim/internal/common/omci"
@@ -79,6 +80,7 @@
NumPon int
NumOnuPerPon int
NumUni int
+ NumPots int
InternalState *fsm.FSM
channel chan types.Message
dhcpServer dhcp.DHCPServerIf
@@ -124,6 +126,7 @@
"NumPon": options.Olt.PonPorts,
"NumOnuPerPon": options.Olt.OnusPonPort,
"NumUni": options.Olt.UniPorts,
+ "NumPots": options.Olt.PotsPorts,
}).Debug("CreateOLT")
olt = OltDevice{
@@ -136,6 +139,7 @@
NumPon: int(options.Olt.PonPorts),
NumOnuPerPon: int(options.Olt.OnusPonPort),
NumUni: int(options.Olt.UniPorts),
+ NumPots: int(options.Olt.PotsPorts),
Pons: []*PonPort{},
Nnis: []*NniPort{},
Delay: options.BBSim.Delay,
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index 97c1adc..cfc7099 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -108,9 +108,10 @@
Backoff *backoff.Backoff
// ONU State
- UniPorts []UniPortIf
- Flows []FlowKey
- FlowIds []uint64 // keep track of the flows we currently have in the ONU
+ UniPorts []UniPortIf
+ PotsPorts []PotsPortIf
+ Flows []FlowKey
+ FlowIds []uint64 // keep track of the flows we currently have in the ONU
OperState *fsm.FSM
SerialNumber *openolt.SerialNumber
@@ -290,6 +291,11 @@
_ = uni.Disable()
}
+ // disable the POTS UNI ports
+ for _, pots := range o.PotsPorts {
+ _ = pots.Disable()
+ }
+
// verify all the flows removes are handled and
// terminate the ONU's ProcessOnuMessages Go routine
// NOTE may need to wait for the UNIs to be down too before shutting down the channel
@@ -316,11 +322,14 @@
},
)
onuLogger.WithFields(log.Fields{
- "OnuId": o.ID,
- "IntfId": o.PonPortID,
- "OnuSn": o.Sn(),
- "NumUni": olt.NumUni,
+ "OnuId": o.ID,
+ "IntfId": o.PonPortID,
+ "OnuSn": o.Sn(),
+ "NumUni": olt.NumUni,
+ "NumPots": olt.NumPots,
}).Debug("creating-uni-ports")
+
+ // create Ethernet UNIs
for i := 0; i < olt.NumUni; i++ {
uni, err := NewUniPort(uint32(i), &o, nextCtag, nextStag)
if err != nil {
@@ -333,8 +342,21 @@
}
o.UniPorts = append(o.UniPorts, uni)
}
+ // create POTS UNIs, with progressive IDs
+ for i := olt.NumUni; i < (olt.NumUni + olt.NumPots); i++ {
+ pots, err := NewPotsPort(uint32(i), &o)
+ if err != nil {
+ onuLogger.WithFields(log.Fields{
+ "OnuId": o.ID,
+ "IntfId": o.PonPortID,
+ "OnuSn": o.Sn(),
+ "Err": err,
+ }).Fatal("cannot-create-pots-port")
+ }
+ o.PotsPorts = append(o.PotsPorts, pots)
+ }
- mibDb, err := omcilib.GenerateMibDatabase(len(o.UniPorts))
+ mibDb, err := omcilib.GenerateMibDatabase(len(o.UniPorts), len(o.PotsPorts))
if err != nil {
onuLogger.WithFields(log.Fields{
"OnuId": o.ID,
@@ -827,6 +849,33 @@
}).Warn("cannot-change-uni-status")
}
}
+ case me.PhysicalPathTerminationPointPotsUniClassID:
+ // if we're Setting a PPTP state
+ // we need to send the appropriate alarm (handled in the POTS struct)
+ pots, err := o.FindPotsByEntityId(msgObj.EntityInstance)
+ if err != nil {
+ onuLogger.Error(err)
+ success = false
+ } else {
+ // 1 locks the UNI, 0 unlocks it
+ adminState := msgObj.Attributes["AdministrativeState"].(uint8)
+ var err error
+ if adminState == 1 {
+ err = pots.Disable()
+ } else {
+ err = pots.Enable()
+ }
+ if err != nil {
+ onuLogger.WithFields(log.Fields{
+ "IntfId": o.PonPortID,
+ "OnuId": o.ID,
+ "PotsMeId": pots.MeId,
+ "PotsId": pots.ID,
+ "SerialNumber": o.Sn(),
+ "Err": err.Error(),
+ }).Warn("cannot-change-pots-status")
+ }
+ }
case me.OnuGClassID:
o.AdminLockState = msgObj.Attributes["AdministrativeState"].(uint8)
onuLogger.WithFields(log.Fields{
@@ -1239,6 +1288,17 @@
return nil, fmt.Errorf("cannot-find-uni-with-id-%d-on-onu-%s", uniID, o.Sn())
}
+// FindPotsById retrieves a POTS port by ID
+func (o *Onu) FindPotsById(uniID uint32) (*PotsPort, error) {
+ for _, p := range o.PotsPorts {
+ pots := p.(*PotsPort)
+ if pots.ID == uniID {
+ return pots, nil
+ }
+ }
+ return nil, fmt.Errorf("cannot-find-pots-with-id-%d-on-onu-%s", uniID, o.Sn())
+}
+
// FindUniByEntityId retrieves a uni by MeID (the OMCI entity ID)
func (o *Onu) FindUniByEntityId(meId uint16) (*UniPort, error) {
entityId := omcilib.EntityID{}.FromUint16(meId)
@@ -1251,6 +1311,18 @@
return nil, fmt.Errorf("cannot-find-uni-with-meid-%s-on-onu-%s", entityId.ToString(), o.Sn())
}
+// FindPotsByEntityId retrieves a POTS uni by MeID (the OMCI entity ID)
+func (o *Onu) FindPotsByEntityId(meId uint16) (*PotsPort, error) {
+ entityId := omcilib.EntityID{}.FromUint16(meId)
+ for _, p := range o.PotsPorts {
+ pots := p.(*PotsPort)
+ if pots.MeId.Equals(entityId) {
+ return pots, nil
+ }
+ }
+ return nil, fmt.Errorf("cannot-find-pots-with-meid-%s-on-onu-%s", entityId.ToString(), o.Sn())
+}
+
func (o *Onu) SetID(id uint32) {
onuLogger.WithFields(log.Fields{
"IntfId": o.PonPortID,
diff --git a/internal/bbsim/devices/onu_test.go b/internal/bbsim/devices/onu_test.go
index bb5f0c1..35f0c28 100644
--- a/internal/bbsim/devices/onu_test.go
+++ b/internal/bbsim/devices/onu_test.go
@@ -17,8 +17,9 @@
package devices
import (
- "github.com/stretchr/testify/assert"
"testing"
+
+ "github.com/stretchr/testify/assert"
)
func Test_Onu_CreateOnu(t *testing.T) {
@@ -26,8 +27,9 @@
nextStag := map[string]int{}
olt := OltDevice{
- ID: 0,
- NumUni: 4,
+ ID: 0,
+ NumUni: 4,
+ NumPots: 1,
}
pon := PonPort{
ID: 1,
@@ -38,4 +40,5 @@
assert.Equal(t, "BBSM00000101", onu.Sn())
assert.Equal(t, 4, len(onu.UniPorts))
+ assert.Equal(t, 1, len(onu.PotsPorts))
}
diff --git a/internal/bbsim/devices/pots_port.go b/internal/bbsim/devices/pots_port.go
new file mode 100644
index 0000000..820f723
--- /dev/null
+++ b/internal/bbsim/devices/pots_port.go
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
+
+package devices
+
+import (
+ "fmt"
+
+ "github.com/looplab/fsm"
+ bbsimTypes "github.com/opencord/bbsim/internal/bbsim/types"
+ omcilib "github.com/opencord/bbsim/internal/common/omci"
+ log "github.com/sirupsen/logrus"
+)
+
+var potsLogger = log.WithFields(log.Fields{
+ "module": "POTS",
+})
+
+const (
+ PotsStateUp = "up"
+ PotsStateDown = "down"
+
+ potsTxEnable = "enable"
+ potsTxDisable = "disable"
+)
+
+type PotsPortIf interface {
+ Enable() error
+ Disable() error
+}
+
+type PotsPort struct {
+ ID uint32
+ MeId omcilib.EntityID
+ PortNo uint32
+ OperState *fsm.FSM
+ Onu *Onu
+ logger *log.Entry
+}
+
+func NewPotsPort(ID uint32, onu *Onu) (*PotsPort, error) {
+ pots := PotsPort{
+ ID: ID,
+ Onu: onu,
+ MeId: omcilib.GenerateUniPortEntityId(ID + 1),
+ }
+
+ pots.logger = potsLogger.WithFields(log.Fields{
+ "PotsUniId": pots.ID,
+ "OnuSn": onu.Sn(),
+ })
+
+ pots.OperState = fsm.NewFSM(
+ PotsStateDown,
+ fsm.Events{
+ {Name: potsTxEnable, Src: []string{PotsStateDown}, Dst: PotsStateUp},
+ {Name: potsTxDisable, Src: []string{PotsStateUp}, Dst: PotsStateDown},
+ },
+ fsm.Callbacks{
+ "enter_state": func(e *fsm.Event) {
+ pots.logger.Debugf("changing-pots-operstate-from-%s-to-%s", e.Src, e.Dst)
+ },
+ fmt.Sprintf("enter_%s", PotsStateUp): func(e *fsm.Event) {
+ msg := bbsimTypes.Message{
+ Type: bbsimTypes.UniStatusAlarm,
+ Data: bbsimTypes.UniStatusAlarmMessage{
+ OnuSN: pots.Onu.SerialNumber,
+ OnuID: pots.Onu.ID,
+ AdminState: 0,
+ EntityID: pots.MeId.ToUint16(),
+ RaiseOMCIAlarm: false, // never raise an LOS when enabling a UNI
+ },
+ }
+ pots.Onu.Channel <- msg
+ },
+ fmt.Sprintf("enter_%s", PotsStateDown): func(e *fsm.Event) {
+ msg := bbsimTypes.Message{
+ Type: bbsimTypes.UniStatusAlarm,
+ Data: bbsimTypes.UniStatusAlarmMessage{
+ OnuSN: pots.Onu.SerialNumber,
+ OnuID: pots.Onu.ID,
+ AdminState: 1,
+ EntityID: pots.MeId.ToUint16(),
+ RaiseOMCIAlarm: true, // raise an LOS when disabling a UNI
+ },
+ }
+ pots.Onu.Channel <- msg
+ },
+ },
+ )
+
+ return &pots, nil
+}
+
+func (u *PotsPort) StorePortNo(portNo uint32) {
+ u.PortNo = portNo
+ u.logger.WithFields(log.Fields{
+ "PortNo": portNo,
+ }).Debug("logical-port-number-added-to-pots")
+}
+
+func (u *PotsPort) Enable() error {
+ return u.OperState.Event(potsTxEnable)
+}
+
+func (u *PotsPort) Disable() error {
+ if u.OperState.Is(PotsStateDown) {
+ return nil
+ }
+ return u.OperState.Event(potsTxDisable)
+}
diff --git a/internal/bbsim/devices/pots_port_test.go b/internal/bbsim/devices/pots_port_test.go
new file mode 100644
index 0000000..6a23b76
--- /dev/null
+++ b/internal/bbsim/devices/pots_port_test.go
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
+
+package devices
+
+import (
+ "testing"
+
+ bbsimTypes "github.com/opencord/bbsim/internal/bbsim/types"
+ "github.com/stretchr/testify/assert"
+)
+
+func createTestPots() (*PotsPort, error) {
+ onu := &Onu{
+ ID: 0,
+ SerialNumber: NewSN(1, 1, 1),
+ PonPortID: 0,
+ Channel: make(chan bbsimTypes.Message),
+ }
+
+ pots, err := NewPotsPort(1, onu)
+
+ return pots, err
+}
+
+func Test_Pots_Create(t *testing.T) {
+ pots, err := createTestPots()
+
+ assert.Nil(t, err)
+ assert.NotNil(t, pots)
+
+ // check initial operational state
+ assert.Equal(t, pots.OperState.Current(), PotsStateDown)
+}
+
+func Test_Pots_OperationalState(t *testing.T) {
+ pots, _ := createTestPots()
+
+ assert.Equal(t, pots.OperState.Current(), PotsStateDown)
+
+ go func() {
+ //When it will be enabled
+ msg, ok := <-pots.Onu.Channel
+ assert.True(t, ok)
+ assert.Equal(t, uint8(0), msg.Data.(bbsimTypes.UniStatusAlarmMessage).AdminState)
+
+ //When it will be disabled
+ msg, ok = <-pots.Onu.Channel
+ assert.True(t, ok)
+ assert.Equal(t, uint8(1), msg.Data.(bbsimTypes.UniStatusAlarmMessage).AdminState)
+ }()
+
+ err := pots.Enable()
+ assert.Nil(t, err)
+ assert.Equal(t, PotsStateUp, pots.OperState.Current())
+
+ err = pots.Disable()
+ assert.Nil(t, err)
+ assert.Equal(t, PotsStateDown, pots.OperState.Current())
+}
diff --git a/internal/bbsimctl/commands/uni.go b/internal/bbsimctl/commands/uni.go
index b025e72..073c088 100644
--- a/internal/bbsimctl/commands/uni.go
+++ b/internal/bbsimctl/commands/uni.go
@@ -32,8 +32,8 @@
)
const (
- DEFAULT_UNI_HEADER_FORMAT = "table{{ .OnuSn }}\t{{ .OnuID }}\t{{ .ID }}\t{{ .MeID }}\t{{ .PortNo }}\t{{ .OperState }}"
- DEFAULT_UNI_HEADER_FORMAT_WITH_SERVICES = "table{{ .OnuSn }}\t{{ .OnuID }}\t{{ .ID }}\t{{ .MeID }}\t{{ .PortNo }}\t{{ .OperState }}\t{{ .Services }}"
+ DEFAULT_UNI_HEADER_FORMAT = "table{{ .OnuSn }}\t{{ .OnuID }}\t{{ .ID }}\t{{ .MeID }}\t{{ .PortNo }}\t{{ .OperState }}\t{{ .Type }}"
+ DEFAULT_UNI_HEADER_FORMAT_WITH_SERVICES = "table{{ .OnuSn }}\t{{ .OnuID }}\t{{ .ID }}\t{{ .MeID }}\t{{ .PortNo }}\t{{ .OperState }}\t{{ .Type }}\t{{ .Services }}"
)
type UniIdInt string
diff --git a/internal/common/omci/get.go b/internal/common/omci/get.go
index a8fc6d7..1f76a0d 100644
--- a/internal/common/omci/get.go
+++ b/internal/common/omci/get.go
@@ -20,13 +20,14 @@
"encoding/hex"
"errors"
"fmt"
+ "math/rand"
+ "strconv"
+
"github.com/google/gopacket"
"github.com/opencord/omci-lib-go/v2"
me "github.com/opencord/omci-lib-go/v2/generated"
"github.com/opencord/voltha-protos/v5/go/openolt"
log "github.com/sirupsen/logrus"
- "math/rand"
- "strconv"
)
func ParseGetRequest(omciPkt gopacket.Packet) (*omci.GetRequest, error) {
@@ -72,10 +73,14 @@
activeImageEntityId, committedImageEntityId, standbyImageVersion, activeImageVersion, committedImageVersion)
case me.IpHostConfigDataClassID:
response = createIpHostResponse(msgObj.AttributeMask, msgObj.EntityInstance)
+ case me.VoipConfigDataClassID:
+ response = createVoipConfigDataResponse(msgObj.AttributeMask, msgObj.EntityInstance)
case me.UniGClassID:
response = createUnigResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuDown)
case me.PhysicalPathTerminationPointEthernetUniClassID:
- response = createPptpResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuDown)
+ response = createPptpEthernetResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuDown)
+ case me.PhysicalPathTerminationPointPotsUniClassID:
+ response = createPptpPotsResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuDown)
case me.AniGClassID:
response = createAnigResponse(msgObj.AttributeMask, msgObj.EntityInstance)
case me.OnuDataClassID:
@@ -281,6 +286,28 @@
}
}
+func createVoipConfigDataResponse(attributeMask uint16, entityInstance uint16) *omci.GetResponse {
+ return &omci.GetResponse{
+ MeBasePacket: omci.MeBasePacket{
+ EntityClass: me.VoipConfigDataClassID,
+ EntityInstance: entityInstance,
+ },
+ Attributes: me.AttributeValueMap{
+ "ManagedEntityId": 0,
+ "AvailableSignallingProtocols": 1,
+ "SignallingProtocolUsed": 1,
+ "AvailableVoipConfigurationMethods": 1,
+ "VoipConfigurationMethodUsed": 1,
+ "VoipConfigurationAddressPointer": 0xFFFF,
+ "VoipConfigurationState": 0,
+ "RetrieveProfile": 0,
+ "ProfileVersion": 0,
+ },
+ Result: me.Success,
+ AttributeMask: attributeMask,
+ }
+}
+
func createUnigResponse(attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse {
// Valid values for uni_admin_state are 0 (unlocks) and 1 (locks)
omciAdminState := 1
@@ -315,7 +342,7 @@
}
}
-func createPptpResponse(attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse {
+func createPptpEthernetResponse(attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse {
// Valid values for oper_state are 0 (enabled) and 1 (disabled)
// Valid values for uni_admin_state are 0 (unlocks) and 1 (locks)
onuAdminState := 1
@@ -361,6 +388,50 @@
}
}
+func createPptpPotsResponse(attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse {
+ // Valid values for oper_state are 0 (enabled) and 1 (disabled)
+ // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks)
+ onuAdminState := 1
+ if !onuDown {
+ onuAdminState = 0
+ }
+ onuOperState := onuAdminState // For now make the assumption that oper state reflects the admin state
+ managedEntity, meErr := me.NewPhysicalPathTerminationPointPotsUni(me.ParamData{
+ EntityID: entityID,
+ Attributes: me.AttributeValueMap{
+ "ManagedEntityId": entityID,
+ "AdministrativeState": onuAdminState,
+ "Deprecated": 0,
+ "Arc": 0,
+ "ArcInterval": 0,
+ "Impedance": 0,
+ "TransmissionPath": 0,
+ "RxGain": 0,
+ "TxGain": 0,
+ "OperationalState": onuOperState,
+ "HookState": 0,
+ "PotsHoldoverTime": 0,
+ "NominalFeedVoltage": 0,
+ "LossOfSoftswitch": 0,
+ },
+ })
+
+ if meErr.GetError() != nil {
+ omciLogger.Errorf("NewPhysicalPathTerminationPointPotsUni %v", meErr.Error())
+ return nil
+ }
+
+ return &omci.GetResponse{
+ MeBasePacket: omci.MeBasePacket{
+ EntityClass: me.PhysicalPathTerminationPointPotsUniClassID,
+ EntityInstance: entityID,
+ },
+ Attributes: managedEntity.GetAttributeValueMap(),
+ AttributeMask: attributeMask,
+ Result: me.Success,
+ }
+}
+
func createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(me.ParamData{
EntityID: entityID,
diff --git a/internal/common/omci/onu_mib_db.go b/internal/common/omci/onu_mib_db.go
index 2a41c81..79ba3a5 100644
--- a/internal/common/omci/onu_mib_db.go
+++ b/internal/common/omci/onu_mib_db.go
@@ -20,6 +20,7 @@
"bytes"
"encoding/binary"
"encoding/hex"
+
me "github.com/opencord/omci-lib-go/v2/generated"
)
@@ -69,6 +70,7 @@
cardHolderOnuType byte = 0x01 // ONU is a single piece of integrated equipment
ethernetUnitType byte = 0x2f // Ethernet BASE-T
xgsPonUnitType byte = 0xee // XG-PON10G10
+ potsUnitType byte = 0x20 // POTS
cardHolderSlotID byte = 0x01
tcontSlotId byte = 0x80 // why is this not the same as the cardHolderSlotID, it does not point to anything
aniGId byte = 0x01
@@ -90,7 +92,7 @@
// creates a MIB database for a ONU
// CircuitPack and CardHolder are static, everything else can be configured
-func GenerateMibDatabase(uniPortCount int) (*MibDb, error) {
+func GenerateMibDatabase(ethUniPortCount int, potsUniPortCount int) (*MibDb, error) {
mibDb := MibDb{
items: []MibDbEntry{},
@@ -129,7 +131,7 @@
me.CircuitPackClassID,
circuitPackEntityID,
me.AttributeValueMap{
- "VendorId": "ONF",
+ "VendorId": ToOctets("ONF", 4),
"AdministrativeState": 0,
"OperationalState": 0,
"BridgedOrIpInd": 0,
@@ -185,7 +187,7 @@
circuitPackEntityID,
me.AttributeValueMap{
"Type": ethernetUnitType,
- "NumberOfPorts": uniPortCount,
+ "NumberOfPorts": ethUniPortCount,
"SerialNumber": ToOctets("BBSM-Circuit-Pack", 20),
"Version": ToOctets("v0.0.1", 20),
},
@@ -194,7 +196,7 @@
me.CircuitPackClassID,
circuitPackEntityID,
me.AttributeValueMap{
- "VendorId": "ONF",
+ "VendorId": ToOctets("ONF", 4),
"AdministrativeState": 0,
"OperationalState": 0,
"BridgedOrIpInd": 0,
@@ -219,33 +221,101 @@
},
})
+ if potsUniPortCount > 0 {
+ // circuitPack POTS
+ // NOTE the circuit pack is divided in multiple messages as too big to fit in a single one
+ mibDb.items = append(mibDb.items, MibDbEntry{
+ me.CircuitPackClassID,
+ circuitPackEntityID,
+ me.AttributeValueMap{
+ "Type": potsUnitType,
+ "NumberOfPorts": potsUniPortCount,
+ "SerialNumber": ToOctets("BBSM-Circuit-Pack", 20),
+ "Version": ToOctets("v0.0.1", 20),
+ },
+ })
+ mibDb.items = append(mibDb.items, MibDbEntry{
+ me.CircuitPackClassID,
+ circuitPackEntityID,
+ me.AttributeValueMap{
+ "VendorId": ToOctets("ONF", 4),
+ "AdministrativeState": 0,
+ "OperationalState": 0,
+ "BridgedOrIpInd": 0,
+ },
+ })
+ mibDb.items = append(mibDb.items, MibDbEntry{
+ me.CircuitPackClassID,
+ circuitPackEntityID,
+ me.AttributeValueMap{
+ "EquipmentId": ToOctets("BBSM-Circuit-Pack", 20),
+ "CardConfiguration": 0,
+ "TotalTContBufferNumber": 8,
+ "TotalPriorityQueueNumber": 8,
+ "TotalTrafficSchedulerNumber": 16,
+ },
+ })
+ mibDb.items = append(mibDb.items, MibDbEntry{
+ me.CircuitPackClassID,
+ circuitPackEntityID,
+ me.AttributeValueMap{
+ "PowerShedOverride": uint32(0),
+ },
+ })
+ }
+
// PPTP and UNI-Gs
// NOTE this are dependent on the number of UNI this ONU supports
// Through an identical ID, the UNI-G ME is implicitly linked to an instance of a PPTP
- for i := 1; i <= uniPortCount; i++ {
+ totalPortsCount := ethUniPortCount + potsUniPortCount
+ for i := 1; i <= totalPortsCount; i++ {
uniEntityId := GenerateUniPortEntityId(uint32(i))
- mibDb.items = append(mibDb.items, MibDbEntry{
- me.PhysicalPathTerminationPointEthernetUniClassID,
- uniEntityId,
- me.AttributeValueMap{
- "ExpectedType": 0,
- "SensedType": ethernetUnitType,
- "AutoDetectionConfiguration": 0,
- "EthernetLoopbackConfiguration": 0,
- "AdministrativeState": 0,
- "OperationalState": 0,
- "ConfigurationInd": 3,
- "MaxFrameSize": 1518,
- "DteOrDceInd": 0,
- "PauseTime": 0,
- "BridgedOrIpInd": 2,
- "Arc": 0,
- "ArcInterval": 0,
- "PppoeFilter": 0,
- "PowerControl": 0,
- },
- })
+ if i <= ethUniPortCount {
+ // first, create the correct amount of ethernet UNIs, the same is done in onu.go
+ mibDb.items = append(mibDb.items, MibDbEntry{
+ me.PhysicalPathTerminationPointEthernetUniClassID,
+ uniEntityId,
+ me.AttributeValueMap{
+ "ExpectedType": 0,
+ "SensedType": ethernetUnitType,
+ "AutoDetectionConfiguration": 0,
+ "EthernetLoopbackConfiguration": 0,
+ "AdministrativeState": 0,
+ "OperationalState": 0,
+ "ConfigurationInd": 3,
+ "MaxFrameSize": 1518,
+ "DteOrDceInd": 0,
+ "PauseTime": 0,
+ "BridgedOrIpInd": 2,
+ "Arc": 0,
+ "ArcInterval": 0,
+ "PppoeFilter": 0,
+ "PowerControl": 0,
+ },
+ })
+ } else {
+ // the remaining ones are pots UNIs, the same is done in onu.go
+ mibDb.items = append(mibDb.items, MibDbEntry{
+ me.PhysicalPathTerminationPointPotsUniClassID,
+ uniEntityId,
+ me.AttributeValueMap{
+ "AdministrativeState": 0,
+ "Deprecated": 0,
+ "Arc": 0,
+ "ArcInterval": 0,
+ "Impedance": 0,
+ "TransmissionPath": 0,
+ "RxGain": 0,
+ "TxGain": 0,
+ "OperationalState": 0,
+ "HookState": 0,
+ "PotsHoldoverTime": 0,
+ "NominalFeedVoltage": 0,
+ "LossOfSoftswitch": 0,
+ },
+ })
+ }
mibDb.items = append(mibDb.items, MibDbEntry{
me.UniGClassID,
diff --git a/internal/common/omci/onu_mib_db_test.go b/internal/common/omci/onu_mib_db_test.go
index aefbae5..378ac6e 100644
--- a/internal/common/omci/onu_mib_db_test.go
+++ b/internal/common/omci/onu_mib_db_test.go
@@ -17,10 +17,11 @@
package omci
import (
+ "testing"
+
"github.com/opencord/omci-lib-go/v2"
me "github.com/opencord/omci-lib-go/v2/generated"
"github.com/stretchr/testify/assert"
- "testing"
)
func TestEntityID_ToUint16(t *testing.T) {
@@ -55,7 +56,7 @@
func Test_GenerateMibDatabase(t *testing.T) {
const uniPortCount = 4
- mibDb, err := GenerateMibDatabase(uniPortCount)
+ mibDb, err := GenerateMibDatabase(uniPortCount, 0)
expectedItems := 9 //ONU-G + 2 Circuit Packs (4 messages each)
expectedItems += 2 * uniPortCount // 1 PPTP and 1 UniG per UNI
@@ -89,3 +90,41 @@
}
}
+
+func Test_GenerateMibDatabase_withPots(t *testing.T) {
+ const uniPortCount = 4
+ const potsPortCount = 1
+ mibDb, err := GenerateMibDatabase(uniPortCount, potsPortCount)
+
+ expectedItems := 13 //ONU-G + 3 Circuit Packs (4 messages each)
+ expectedItems += 2 * (uniPortCount + potsPortCount) // 1 PPTP and 1 UniG per UNI
+ expectedItems += 1 // ANI-G
+ expectedItems += 2 * tconts // T-CONT and traffic schedulers
+ expectedItems += 1 // ONU-2g
+ expectedItems += 2 * 8 * tconts // 8 upstream queues for each T-CONT, and we report each queue twice
+ expectedItems += 2 * 16 * (uniPortCount + potsPortCount) // 16 downstream queues for each T-CONT, and we report each queue twice
+
+ assert.NoError(t, err)
+ assert.NotNil(t, mibDb)
+ assert.Equal(t, expectedItems, int(mibDb.NumberOfCommands))
+
+ // now try to serialize all messages to check on the attributes
+ for _, entry := range mibDb.items {
+ reportedMe, meErr := me.LoadManagedEntityDefinition(entry.classId, me.ParamData{
+ EntityID: entry.entityId.ToUint16(),
+ Attributes: entry.params,
+ })
+ assert.NoError(t, meErr.GetError())
+
+ response := &omci.MibUploadNextResponse{
+ MeBasePacket: omci.MeBasePacket{
+ EntityClass: me.OnuDataClassID,
+ },
+ ReportedME: *reportedMe,
+ }
+
+ _, err := Serialize(omci.MibUploadNextResponseType, response, uint16(10))
+ assert.NoError(t, err)
+ }
+
+}
diff --git a/internal/common/options.go b/internal/common/options.go
index 83b5b56..c0798ae 100644
--- a/internal/common/options.go
+++ b/internal/common/options.go
@@ -93,6 +93,7 @@
PortStatsInterval int `yaml:"port_stats_interval"`
OmciResponseRate uint8 `yaml:"omci_response_rate"`
UniPorts uint32 `yaml:"uni_ports"`
+ PotsPorts uint32 `yaml:"pots_ports"`
}
type BBSimConfig struct {
@@ -231,7 +232,8 @@
nni := flag.Int("nni", int(conf.Olt.NniPorts), "Number of NNI ports per OLT device to be emulated")
pon := flag.Int("pon", int(conf.Olt.PonPorts), "Number of PON ports per OLT device to be emulated")
onu := flag.Int("onu", int(conf.Olt.OnusPonPort), "Number of ONU devices per PON port to be emulated")
- uni := flag.Int("uni", int(conf.Olt.UniPorts), "Number of UNI Ports per ONU device to be emulated")
+ uni := flag.Int("uni", int(conf.Olt.UniPorts), "Number of Ethernet UNI Ports per ONU device to be emulated")
+ pots := flag.Int("pots", int(conf.Olt.PotsPorts), "Number of POTS UNI Ports per ONU device to be emulated")
oltRebootDelay := flag.Int("oltRebootDelay", conf.Olt.OltRebootDelay, "Time that BBSim should before restarting after a reboot")
omci_response_rate := flag.Int("omci_response_rate", int(conf.Olt.OmciResponseRate), "Amount of OMCI messages to respond to")
@@ -262,6 +264,7 @@
conf.Olt.NniPorts = uint32(*nni)
conf.Olt.PonPorts = uint32(*pon)
conf.Olt.UniPorts = uint32(*uni)
+ conf.Olt.PotsPorts = uint32(*pots)
conf.Olt.OnusPonPort = uint32(*onu)
conf.Olt.OltRebootDelay = *oltRebootDelay
conf.Olt.OmciResponseRate = uint8(*omci_response_rate)
@@ -338,6 +341,7 @@
PortStatsInterval: 20,
OmciResponseRate: 10,
UniPorts: 4,
+ PotsPorts: 0,
},
BBRConfig{
LogLevel: "debug",