devices

package
v1.12.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Default mode = iota
	OnlyONU
	OnlyPON
	Both
)

Constants for Controlled Activation modes

View Source
const (
	//InternalState FSM states and transitions
	OltInternalStateCreated     = "created"
	OltInternalStateInitialized = "initialized"
	OltInternalStateEnabled     = "enabled"
	OltInternalStateDisabled    = "disabled"
	OltInternalStateDeleted     = "deleted"

	OltInternalTxInitialize = "initialize"
	OltInternalTxEnable     = "enable"
	OltInternalTxDisable    = "disable"
	OltInternalTxDelete     = "delete"
)
View Source
const (
	// ONU transitions
	OnuTxInitialize            = "initialize"
	OnuTxDiscover              = "discover"
	OnuTxEnable                = "enable"
	OnuTxDisable               = "disable"
	OnuTxPonDisable            = "pon_disable"
	OnuTxStartImageDownload    = "start_image_download"
	OnuTxProgressImageDownload = "progress_image_download"
	OnuTxCompleteImageDownload = "complete_image_download"
	OnuTxFailImageDownload     = "fail_image_download"
	OnuTxActivateImage         = "activate_image"
	OnuTxCommitImage           = "commit_image"

	// ONU States
	OnuStateCreated                 = "created"
	OnuStateInitialized             = "initialized"
	OnuStateDiscovered              = "discovered"
	OnuStateEnabled                 = "enabled"
	OnuStateDisabled                = "disabled"
	OnuStatePonDisabled             = "pon_disabled"
	OnuStateImageDownloadStarted    = "image_download_started"
	OnuStateImageDownloadInProgress = "image_download_in_progress"
	OnuStateImageDownloadComplete   = "image_download_completed"
	OnuStateImageDownloadError      = "image_download_error"
	OnuStateImageActivated          = "software_image_activated"
	OnuStateImageCommitted          = "software_image_committed"

	// BBR ONU States and Transitions
	BbrOnuTxSendEapolFlow    = "send_eapol_flow"
	BbrOnuStateEapolFlowSent = "eapol_flow_sent"
	BbrOnuTxSendDhcpFlow     = "send_dhcp_flow"
	BbrOnuStateDhcpFlowSent  = "dhcp_flow_sent"
)
View Source
const (
	PotsStateUp   = "up"
	PotsStateDown = "down"
)
View Source
const (
	ServiceStateCreated     = "created"
	ServiceStateInitialized = "initialized"
	ServiceStateDisabled    = "disabled"

	ServiceTxInitialize = "initialize"
	ServiceTxDisable    = "disable"
)
View Source
const (
	UniStateUp   = "up"
	UniStateDown = "down"
)

Variables

View Source
var ControlledActivationModes = map[string]mode{
	"default":  Default,
	"only-onu": OnlyONU,
	"only-pon": OnlyPON,
	"both":     Both,
}

ControlledActivationModes maps string to int value of mode

Functions

func InterfaceIDToPortNo added in v0.0.19

func InterfaceIDToPortNo(intfID uint32, intfType string) uint32

InterfaceIDToPortNo converts InterfaceID to voltha PortID Refer openolt adapter code(master) voltha-openolt-adapter/adaptercore/olt_platform.go: IntfIDToPortNo()

func NewSN added in v1.5.2

func NewSN(oltid int, intfid uint32, onuid uint32) *openolt.SerialNumber

Types

type AllocIDKey added in v1.10.4

type AllocIDKey struct {
	PonID    uint32
	OnuID    uint32
	EntityID uint16
}

type AllocIDVal added in v1.11.0

type AllocIDVal struct {
	OnuSn   *openolt.SerialNumber
	AllocID uint16
}

type FlowAddSpy added in v0.0.5

type FlowAddSpy struct {
	CallCount int
	Calls     map[int]*openolt.Flow
}

type FlowKey added in v0.0.18

type FlowKey struct {
	ID uint64
}

type NniPort

type NniPort struct {
	// BBSIM Internals
	ID  uint32
	Olt *OltDevice

	// PON Attributes
	OperState   *fsm.FSM
	Type        string
	PacketCount uint64 // dummy value for the stats
}

func CreateNNI

func CreateNNI(olt *OltDevice) (NniPort, error)

type OltDevice

type OltDevice struct {
	sync.Mutex
	OltServer *grpc.Server

	// BBSIM Internals
	ID             int
	SerialNumber   string
	NumNni         int
	NniSpeed       uint32
	NumPon         int
	NumOnuPerPon   int
	NumUni         int
	NumPots        int
	NniDhcpTrapVid int
	InternalState  *fsm.FSM

	Flows                sync.Map
	Delay                int
	ControlledActivation mode
	EventChannel         chan common.Event
	PublishEvents        bool
	PortStatsInterval    int
	PreviouslyConnected  bool

	Pons []*PonPort
	Nnis []*NniPort

	// OLT Attributes
	OperState *fsm.FSM

	OpenoltStream openolt.Openolt_EnableIndicationServer

	// Allocated Resources
	// this data are to verify that the openolt adapter does not duplicate resources
	AllocIDsLock     sync.RWMutex
	AllocIDs         map[uint32]map[uint32]map[uint32]map[int32]map[uint64]bool // map[ponPortId]map[OnuId]map[PortNo]map[AllocIds]map[FlowId]bool
	GemPortIDsLock   sync.RWMutex
	GemPortIDs       map[uint32]map[uint32]map[uint32]map[int32]map[uint64]bool // map[ponPortId]map[OnuId]map[PortNo]map[GemPortIDs]map[FlowId]bool
	OmciResponseRate uint8
	// contains filtered or unexported fields
}

func CreateOLT

func CreateOLT(options common.GlobalConfig, services []common.ServiceYaml, isMock bool) *OltDevice

func GetOLT

func GetOLT() *OltDevice

func (*OltDevice) ActivateOnu

func (o *OltDevice) ActivateOnu(context context.Context, onu *openolt.Onu) (*openolt.Empty, error)

func (*OltDevice) CollectStatistics

func (o *OltDevice) CollectStatistics(context.Context, *openolt.Empty) (*openolt.Empty, error)

func (*OltDevice) CreateTrafficQueues

func (s *OltDevice) CreateTrafficQueues(context.Context, *tech_profile.TrafficQueues) (*openolt.Empty, error)

func (*OltDevice) CreateTrafficSchedulers

func (s *OltDevice) CreateTrafficSchedulers(_ context.Context, trafficSchedulers *tech_profile.TrafficSchedulers) (*openolt.Empty, error)

func (*OltDevice) DeactivateOnu

func (o *OltDevice) DeactivateOnu(_ context.Context, onu *openolt.Onu) (*openolt.Empty, error)

func (*OltDevice) DeleteGroup added in v1.0.0

func (o *OltDevice) DeleteGroup(ctx context.Context, group *openolt.Group) (*openolt.Empty, error)

func (*OltDevice) DeleteOnu

func (o *OltDevice) DeleteOnu(_ context.Context, onu *openolt.Onu) (*openolt.Empty, error)

func (*OltDevice) DisableOlt

func (o *OltDevice) DisableOlt(context.Context, *openolt.Empty) (*openolt.Empty, error)

func (*OltDevice) DisablePonIf

func (o *OltDevice) DisablePonIf(_ context.Context, intf *openolt.Interface) (*openolt.Empty, error)

func (*OltDevice) Enable

Enable implements the OpenOLT EnableIndicationServer functionality

func (*OltDevice) EnableIndication

func (o *OltDevice) EnableIndication(_ *openolt.Empty, stream openolt.Openolt_EnableIndicationServer) error

func (*OltDevice) EnablePonIf

func (o *OltDevice) EnablePonIf(_ context.Context, intf *openolt.Interface) (*openolt.Empty, error)

func (*OltDevice) FindOnuById added in v0.0.2

func (o *OltDevice) FindOnuById(intfId uint32, onuId uint32) (*Onu, error)

returns an ONU with a given interface/Onu Id

func (*OltDevice) FindOnuBySn added in v0.0.2

func (o *OltDevice) FindOnuBySn(serialNumber string) (*Onu, error)

returns an ONU with a given Serial Number

func (*OltDevice) FindServiceByMacAddress added in v1.0.0

func (o *OltDevice) FindServiceByMacAddress(mac net.HardwareAddr) (ServiceIf, error)

returns a Service with a given Mac Address

func (*OltDevice) FlowAdd

func (o *OltDevice) FlowAdd(ctx context.Context, flow *openolt.Flow) (*openolt.Empty, error)

func (*OltDevice) FlowRemove

func (o *OltDevice) FlowRemove(_ context.Context, flow *openolt.Flow) (*openolt.Empty, error)

FlowRemove request from VOLTHA

func (*OltDevice) GetDeviceInfo

func (o *OltDevice) GetDeviceInfo(context.Context, *openolt.Empty) (*openolt.DeviceInfo, error)

func (*OltDevice) GetExtValue added in v1.0.0

func (o *OltDevice) GetExtValue(ctx context.Context, in *openolt.ValueParam) (*extension.ReturnValues, error)

func (*OltDevice) GetGemPortStatistics added in v1.5.1

func (o *OltDevice) GetGemPortStatistics(ctx context.Context, in *openolt.OnuPacket) (*openolt.GemPortStatistics, error)

func (*OltDevice) GetLogicalOnuDistance added in v1.0.0

func (o *OltDevice) GetLogicalOnuDistance(ctx context.Context, in *openolt.Onu) (*openolt.OnuLogicalDistance, error)

func (*OltDevice) GetLogicalOnuDistanceZero added in v1.0.0

func (o *OltDevice) GetLogicalOnuDistanceZero(ctx context.Context, in *openolt.Onu) (*openolt.OnuLogicalDistance, error)

func (*OltDevice) GetOnuByFlowId added in v0.2.5

func (o *OltDevice) GetOnuByFlowId(flowId uint64) (*Onu, error)

func (*OltDevice) GetOnuInfo

func (o *OltDevice) GetOnuInfo(context context.Context, packet *openolt.Onu) (*openolt.OnuIndication, error)

func (*OltDevice) GetOnuStatistics added in v1.5.1

func (o *OltDevice) GetOnuStatistics(ctx context.Context, in *openolt.Onu) (*openolt.OnuStatistics, error)

func (*OltDevice) GetPonById added in v0.0.2

func (o *OltDevice) GetPonById(id uint32) (*PonPort, error)

func (*OltDevice) GetPonIf

func (o *OltDevice) GetPonIf(context context.Context, packet *openolt.Interface) (*openolt.IntfIndication, error)

func (*OltDevice) GetPonRxPower added in v1.8.0

func (o *OltDevice) GetPonRxPower(ctx context.Context, in *openolt.Onu) (*openolt.PonRxPowerData, error)

func (*OltDevice) HasNni added in v1.5.0

func (o *OltDevice) HasNni(id uint32) bool

func (*OltDevice) HasPon added in v1.5.0

func (o *OltDevice) HasPon(id uint32) bool

func (*OltDevice) HeartbeatCheck

func (o *OltDevice) HeartbeatCheck(context.Context, *openolt.Empty) (*openolt.Heartbeat, error)

func (*OltDevice) InitOlt added in v0.0.7

func (o *OltDevice) InitOlt()

func (*OltDevice) OmciMsgOut

func (o *OltDevice) OmciMsgOut(ctx context.Context, omci_msg *openolt.OmciMsg) (*openolt.Empty, error)

func (*OltDevice) OnuItuPonAlarmSet added in v1.0.0

func (o *OltDevice) OnuItuPonAlarmSet(ctx context.Context, in *config.OnuItuPonAlarm) (*openolt.Empty, error)

func (*OltDevice) OnuPacketOut

func (o *OltDevice) OnuPacketOut(ctx context.Context, onuPkt *openolt.OnuPacket) (*openolt.Empty, error)

this gRPC methods receives packets from VOLTHA and sends them to the subscriber on the ONU

func (*OltDevice) PerformGroupOperation added in v1.0.0

func (o *OltDevice) PerformGroupOperation(ctx context.Context, group *openolt.Group) (*openolt.Empty, error)

func (*OltDevice) Reboot

func (*OltDevice) ReenableOlt

func (o *OltDevice) ReenableOlt(context.Context, *openolt.Empty) (*openolt.Empty, error)

func (*OltDevice) RemoveTrafficQueues

func (s *OltDevice) RemoveTrafficQueues(_ context.Context, tq *tech_profile.TrafficQueues) (*openolt.Empty, error)

func (*OltDevice) RemoveTrafficSchedulers

func (s *OltDevice) RemoveTrafficSchedulers(context context.Context, trafficSchedulers *tech_profile.TrafficSchedulers) (*openolt.Empty, error)

func (*OltDevice) RestartOLT added in v0.0.7

func (o *OltDevice) RestartOLT() error

func (*OltDevice) SetAlarm added in v1.5.0

func (o *OltDevice) SetAlarm(interfaceId uint32, interfaceType string, alarmStatus string) error

func (*OltDevice) StartOltServer added in v1.4.1

func (o *OltDevice) StartOltServer() (*grpc.Server, error)

StartOltServer will create the grpc server that VOLTHA uses to communicate with the device

func (*OltDevice) StopOltServer added in v0.0.8

func (o *OltDevice) StopOltServer()

StopOltServer stops the OpenOLT grpc server

func (*OltDevice) UplinkPacketOut

func (o *OltDevice) UplinkPacketOut(context context.Context, packet *openolt.UplinkPacket) (*openolt.Empty, error)

type Onu

type Onu struct {
	ID                  uint32
	PonPortID           uint32
	PonPort             *PonPort
	InternalState       *fsm.FSM
	DiscoveryRetryDelay time.Duration // this is the time between subsequent Discovery Indication
	DiscoveryDelay      time.Duration // this is the time to send the first Discovery Indication

	Backoff *backoff.Backoff
	// ONU State
	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

	AdminLockState uint8 // 0 is enabled, 1 is disabled.

	Channel chan bbsim.Message // this Channel is to track state changes OMCI messages, EAPOL and DHCP packets

	// OMCI params
	MibDataSync                   uint8
	ImageSoftwareExpectedSections int
	ImageSoftwareReceivedSections int
	ActiveImageEntityId           uint16
	CommittedImageEntityId        uint16
	StandbyImageVersion           string
	ActiveImageVersion            string
	InDownloadImageVersion        string
	CommittedImageVersion         string
	OmciResponseRate              uint8
	OmciMsgCounter                uint8
	ImageSectionData              []byte

	MibDb *omcilib.MibDb

	DoneChannel       chan bool // this channel is used to signal once the onu is complete (when the struct is used by BBR)
	TrafficSchedulers *tech_profile.TrafficSchedulers
	// contains filtered or unexported fields
}

func CreateONU

func CreateONU(olt *OltDevice, pon *PonPort, id uint32, delay time.Duration, nextCtag map[string]int, nextStag map[string]int, isMock bool) *Onu

func (*Onu) DeleteFlow added in v0.0.18

func (onu *Onu) DeleteFlow(key FlowKey)

DeleteFlow method search and delete flowKey from the onu flows slice

func (*Onu) FindPotsByEntityId added in v1.10.0

func (o *Onu) FindPotsByEntityId(meId uint16) (*PotsPort, error)

FindPotsByEntityId retrieves a POTS uni by MeID (the OMCI entity ID)

func (*Onu) FindPotsById added in v1.10.0

func (o *Onu) FindPotsById(uniID uint32) (*PotsPort, error)

FindPotsById retrieves a POTS port by ID

func (*Onu) FindUniByEntityId added in v1.8.0

func (o *Onu) FindUniByEntityId(meId uint16) (*UniPort, error)

FindUniByEntityId retrieves a uni by MeID (the OMCI entity ID)

func (*Onu) FindUniById added in v1.8.0

func (o *Onu) FindUniById(uniID uint32) (*UniPort, error)

FindUniById retrieves a UNI by ID

func (*Onu) HandlePowerOnONU added in v1.5.0

func (o *Onu) HandlePowerOnONU() error

func (*Onu) HandleShutdownONU added in v1.5.0

func (o *Onu) HandleShutdownONU() error

func (*Onu) IncrementAlarmSequenceNumber added in v1.5.2

func (o *Onu) IncrementAlarmSequenceNumber(key omcilib.OnuAlarmInfoMapKey) uint8

func (*Onu) InvalidateMibDataSync added in v1.10.0

func (o *Onu) InvalidateMibDataSync()

func (*Onu) ProcessOnuMessages added in v0.0.2

func (o *Onu) ProcessOnuMessages(ctx context.Context, stream openolt.Openolt_EnableIndicationServer, client openolt.OpenoltClient)

ProcessOnuMessages starts indication channel for each ONU

func (*Onu) ReDiscoverOnu added in v0.3.0

func (onu *Onu) ReDiscoverOnu()

func (*Onu) Reboot added in v1.5.2

func (o *Onu) Reboot(timeout time.Duration) error

func (*Onu) SendOMCIAlarmNotificationMsg added in v1.5.2

func (o *Onu) SendOMCIAlarmNotificationMsg(raiseOMCIAlarm bool, alarmType string)

func (*Onu) SetAlarm added in v1.5.0

func (o *Onu) SetAlarm(alarmType string, status string) error

func (*Onu) SetID added in v0.0.7

func (o *Onu) SetID(id uint32)

func (*Onu) Sn

func (o *Onu) Sn() string

func (*Onu) StartOmci added in v0.0.2

func (o *Onu) StartOmci(client openolt.OpenoltClient)

TODO move this method in responders/omcisim StartOmci is called in BBR to start the OMCI state machine

type PonPort

type PonPort struct {
	// BBSIM Internals
	ID            uint32
	Technology    common.PonTechnology
	NumOnu        int
	Onus          []*Onu
	Olt           *OltDevice
	PacketCount   uint64
	InternalState *fsm.FSM

	// PON Attributes
	OperState *fsm.FSM
	Type      string

	// Allocated resources
	// Some resources (eg: OnuId, AllocId and GemPorts) have to be unique per PON port
	// we are keeping a list so that we can throw an error in cases we receive duplicates
	AllocatedGemPorts map[uint16]*openolt.SerialNumber

	AllocatedOnuIds map[uint32]*openolt.SerialNumber

	AllocatedAllocIds map[AllocIDKey]*AllocIDVal // key is AllocIDKey
	// contains filtered or unexported fields
}

func CreatePonPort added in v0.0.10

func CreatePonPort(olt *OltDevice, id uint32, tech common.PonTechnology) *PonPort

CreatePonPort creates pon port object

func (*PonPort) GetNumOfActiveOnus added in v0.0.19

func (p *PonPort) GetNumOfActiveOnus() uint32

GetNumOfActiveOnus returns number of active ONUs for PON port

func (*PonPort) GetOnuById added in v0.0.2

func (p *PonPort) GetOnuById(id uint32) (*Onu, error)

func (*PonPort) GetOnuBySn added in v0.0.2

func (p *PonPort) GetOnuBySn(sn *openolt.SerialNumber) (*Onu, error)

type PotsPort added in v1.10.0

type PotsPort struct {
	ID        uint32
	MeId      omcilib.EntityID
	PortNo    uint32
	OperState *fsm.FSM
	Onu       *Onu
	// contains filtered or unexported fields
}

func NewPotsPort added in v1.10.0

func NewPotsPort(ID uint32, onu *Onu) (*PotsPort, error)

func (*PotsPort) Disable added in v1.10.0

func (p *PotsPort) Disable() error

func (*PotsPort) Enable added in v1.10.0

func (p *PotsPort) Enable() error

func (*PotsPort) GetID added in v1.12.7

func (p *PotsPort) GetID() uint32

func (*PotsPort) StorePortNo added in v1.10.0

func (p *PotsPort) StorePortNo(portNo uint32)

type PotsPortIf added in v1.10.0

type PotsPortIf interface {
	GetID() uint32
	Enable() error
	Disable() error
}

type Service added in v1.0.0

type Service struct {
	Id                  uint32
	Name                string
	HwAddress           net.HardwareAddr
	UniPort             *UniPort
	CTag                int
	STag                int
	NeedsEapol          bool
	NeedsDhcp           bool
	NeedsIgmp           bool
	NeedsPPPoE          bool
	TechnologyProfileID int
	UniTagMatch         int
	ConfigureMacAddress bool
	EnableMacLearning   bool
	UsPonCTagPriority   uint8
	UsPonSTagPriority   uint8
	DsPonCTagPriority   uint8
	DsPonSTagPriority   uint8

	// state
	GemPort       uint32
	InternalState *fsm.FSM
	EapolState    *fsm.FSM
	DHCPState     *fsm.FSM
	IGMPState     *fsm.FSM
	Channel       chan bbsimTypes.Message          // drive Service lifecycle
	PacketCh      chan bbsimTypes.OnuPacketMessage // handle packets
	Stream        bbsimTypes.Stream                // the gRPC stream to communicate with the adapter, created in the initialize transition
}

func NewService added in v1.0.0

func NewService(id uint32, name string, hwAddress net.HardwareAddr, uni *UniPort, cTag int, sTag int,
	needsEapol bool, needsDchp bool, needsIgmp bool, needsPPPoE bool, tpID int, uniTagMatch int, configMacAddress bool,
	enableMacLearning bool, usPonCTagPriority uint8, usPonSTagPriority uint8, dsPonCTagPriority uint8,
	dsPonSTagPriority uint8) (*Service, error)

func (*Service) Disable added in v1.0.0

func (s *Service) Disable()

func (*Service) HandleAuth added in v1.0.0

func (s *Service) HandleAuth()

HandleAuth is used to start EAPOL for a particular Service when the corresponding flow is received

func (*Service) HandleChannel added in v1.0.0

func (s *Service) HandleChannel()

func (*Service) HandleDhcp added in v1.0.0

func (s *Service) HandleDhcp(oPbit uint8, oVid int)

HandleDhcp is used to start DHCP for a particular Service when the corresponding flow is received

func (*Service) HandlePackets added in v1.0.0

func (s *Service) HandlePackets()

func (*Service) Initialize added in v1.0.0

func (s *Service) Initialize(stream bbsimTypes.Stream)

func (*Service) UpdateStream added in v1.6.0

func (s *Service) UpdateStream(stream bbsimTypes.Stream)

type ServiceIf added in v1.0.0

type ServiceIf interface {
	HandlePackets()                   // start listening on the PacketCh
	HandleAuth()                      // Sends the EapoStart packet
	HandleDhcp(oPbit uint8, oVid int) // Sends the DHCPDiscover packet

	Initialize(stream bbsimTypes.Stream)
	UpdateStream(stream bbsimTypes.Stream)
	Disable()
}

type UniPort added in v1.8.0

type UniPort struct {
	ID        uint32
	MeId      omcilib.EntityID
	PortNo    uint32
	OperState *fsm.FSM
	Onu       *Onu
	Services  []ServiceIf

	PacketCh chan bbsimTypes.OnuPacketMessage // handle packets
	// contains filtered or unexported fields
}

func NewUniPort added in v1.8.0

func NewUniPort(ID uint32, onu *Onu, nextCtag map[string]int, nextStag map[string]int) (*UniPort, error)

func (*UniPort) Disable added in v1.8.0

func (u *UniPort) Disable() error

func (*UniPort) Enable added in v1.8.0

func (u *UniPort) Enable() error

func (*UniPort) GetID added in v1.12.7

func (u *UniPort) GetID() uint32

func (*UniPort) HandleAuth added in v1.8.0

func (u *UniPort) HandleAuth()

func (*UniPort) HandleDhcp added in v1.8.0

func (u *UniPort) HandleDhcp(oPbit uint8, oVid int)

func (*UniPort) HandlePackets added in v1.8.0

func (u *UniPort) HandlePackets()

this method simply forwards the packet to the correct service

func (*UniPort) StorePortNo added in v1.8.0

func (u *UniPort) StorePortNo(portNo uint32)

func (*UniPort) UpdateStream added in v1.8.0

func (u *UniPort) UpdateStream(stream bbsimTypes.Stream)

type UniPortIf added in v1.8.0

type UniPortIf interface {
	GetID() uint32
	StorePortNo(portNo uint32)
	UpdateStream(stream bbsimTypes.Stream)
	Enable() error
	Disable() error

	HandlePackets()                  // start listening on the PacketCh
	HandleAuth()                     // Sends the EapoStart packet
	HandleDhcp(pbit uint8, cTag int) // Sends the DHCPDiscover packet
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL