blob: c2eecbd7bc96930737d0c0fd783f13c4525c4fd5 [file] [log] [blame]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//Package common provides global definitions
18package common
19
20import (
21 "context"
mpagenko101ac942021-11-16 15:01:29 +000022 "sync"
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000023 "time"
24
25 gp "github.com/google/gopacket"
26 "github.com/looplab/fsm"
mpagenko836a1fd2021-11-01 16:12:42 +000027 "github.com/opencord/omci-lib-go/v2"
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000028 vc "github.com/opencord/voltha-protos/v5/go/common"
khenaidoo42dcdfd2021-10-19 17:34:12 -040029 ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000030 "github.com/opencord/voltha-protos/v5/go/voltha"
31)
32
33// MessageType - Message Protocol Type
34type MessageType uint8
35
36const (
37 // TestMsg - Message type for non OMCI messages
38 TestMsg MessageType = iota
39 //OMCI - OMCI protocol type msg
40 OMCI
41)
42
43// String - Return the text representation of the message type based on integer
44func (m MessageType) String() string {
45 names := [...]string{
46 "TestMsg",
47 "OMCI",
48 }
49 return names[m]
50}
51
52// Message - message type and data(OMCI)
53type Message struct {
54 Type MessageType
55 Data interface{}
56}
57
58//TestMessageType - message data for various events
59type TestMessageType uint8
60
61const (
62 // LoadMibTemplateOk - message data for getting mib template successfully
63 LoadMibTemplateOk TestMessageType = iota + 1
64 // LoadMibTemplateFailed - message data for failure for getting mib template
65 LoadMibTemplateFailed
66 // TimeOutOccurred - message data for timeout
67 TimeOutOccurred
68 // AbortMessageProcessing - message data for aborting running message
69 AbortMessageProcessing
70)
71
72//TestMessage - Struct to hold the message data
73//TODO: place holder to have a second interface variant - to be replaced by real variant later on
74type TestMessage struct {
75 TestMessageVal TestMessageType
76}
77
78//OmciMessage - OMCI protocol messages for managing and monitoring ONUs
79type OmciMessage struct {
80 //OnuSN *openolt.SerialNumber
81 //OnuID uint32
82 OmciMsg *omci.OMCI
83 OmciPacket *gp.Packet
84}
85
86///////////////////////////////////////////////////////////
87
88// device reasons
89const (
90 DrUnset = 0
91 DrActivatingOnu = 1
92 DrStartingOpenomci = 2
93 DrDiscoveryMibsyncComplete = 3
94 DrInitialMibDownloaded = 4
95 DrTechProfileConfigDownloadSuccess = 5
96 DrOmciFlowsPushed = 6
97 DrOmciAdminLock = 7
98 DrOnuReenabled = 8
99 DrStoppingOpenomci = 9
100 DrRebooting = 10
101 DrOmciFlowsDeleted = 11
102 DrTechProfileConfigDeleteSuccess = 12
103 DrReconcileFailed = 13
104 DrReconcileMaxTimeout = 14
105 DrReconcileCanceled = 15
106 DrTechProfileConfigDownloadFailed = 16
107)
108
109// DeviceReasonMap holds device reason strings
110var DeviceReasonMap = map[uint8]string{
111 DrUnset: "unset",
112 DrActivatingOnu: "activating-onu",
113 DrStartingOpenomci: "starting-openomci",
114 DrDiscoveryMibsyncComplete: "discovery-mibsync-complete",
115 DrInitialMibDownloaded: "initial-mib-downloaded",
116 DrTechProfileConfigDownloadSuccess: "tech-profile-config-download-success",
117 DrTechProfileConfigDownloadFailed: "tech-profile-config-download-failed",
118 DrOmciFlowsPushed: "omci-flows-pushed",
119 DrOmciAdminLock: "omci-admin-lock",
120 DrOnuReenabled: "onu-reenabled",
121 DrStoppingOpenomci: "stopping-openomci",
122 DrRebooting: "rebooting",
123 DrOmciFlowsDeleted: "omci-flows-deleted",
124 DrTechProfileConfigDeleteSuccess: "tech-profile-config-delete-success",
125 DrReconcileFailed: "reconcile-failed",
126 DrReconcileMaxTimeout: "reconcile-max-timeout",
127 DrReconcileCanceled: "reconciling-canceled",
128}
129
130// UsedOmciConfigFsms type for FSMs dealing with OMCI messages
131type UsedOmciConfigFsms int
132
133// FSMs dealing with OMCI messages
134const (
135 CUploadFsm UsedOmciConfigFsms = iota
136 CDownloadFsm
137 CUniLockFsm
138 CUniUnLockFsm
139 CAniConfigFsm
140 CUniVlanConfigFsm
141 CL2PmFsm
142 COnuUpgradeFsm
143)
144
145// OnuDeviceEvent - TODO: add comment
146type OnuDeviceEvent int
147
148// Events of interest to Device Adapters and OpenOMCI State Machines
149const (
150 // DeviceStatusInit - default start state
151 DeviceStatusInit OnuDeviceEvent = iota
152 // MibDatabaseSync - MIB database sync (upload done)
153 MibDatabaseSync
154 // OmciCapabilitiesDone - OMCI ME and message type capabilities known
155 OmciCapabilitiesDone
156 // MibDownloadDone - // MIB download done
157 MibDownloadDone
158 // UniLockStateDone - Uni ports admin set to lock
159 UniLockStateDone
160 // UniUnlockStateDone - Uni ports admin set to unlock
161 UniUnlockStateDone
162 // UniDisableStateDone - Uni ports admin set to lock based on device disable
163 UniDisableStateDone
164 // UniEnableStateDone - Uni ports admin set to unlock based on device re-enable
165 UniEnableStateDone
Mahir Gunyel50ddea62021-10-22 11:26:42 -0700166 // UniEnableStateFailed - Uni ports admin set to unlock failure based on device re-enable
167 UniEnableStateFailed
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000168 // PortLinkUp - Port link state change
169 PortLinkUp
170 // PortLinkDw - Port link state change
171 PortLinkDw
172 // OmciAniConfigDone - AniSide config according to TechProfile done
173 OmciAniConfigDone
174 // OmciAniResourceRemoved - AniSide TechProfile related resource (Gem/TCont) removed
175 OmciAniResourceRemoved // needs to be the successor of OmciAniConfigDone!
176 // OmciVlanFilterAddDone - Omci Vlan config done according to flow-add with request to write kvStore
177 OmciVlanFilterAddDone
178 // OmciVlanFilterAddDoneNoKvStore - Omci Vlan config done according to flow-add without writing kvStore
179 OmciVlanFilterAddDoneNoKvStore // needs to be the successor of OmciVlanFilterAddDone!
180 // OmciVlanFilterRemDone - Omci Vlan config done according to flow-remove with request to write kvStore
181 OmciVlanFilterRemDone // needs to be the successor of OmciVlanFilterAddDoneNoKvStore!
182 // OmciVlanFilterRemDoneNoKvStore - Omci Vlan config done according to flow-remove without writing kvStore
183 OmciVlanFilterRemDoneNoKvStore // needs to be the successor of OmciVlanFilterRemDone!
184 // OmciOnuSwUpgradeDone - SoftwareUpgrade to ONU finished
185 OmciOnuSwUpgradeDone
186 // Add other events here as needed (alarms separate???)
187)
188
189///////////////////////////////////////////////////////////
190
191//definitions as per G.988 softwareImage::valid ME IDs
192const (
193 FirstSwImageMeID = 0
194 SecondSwImageMeID = 1
195)
196
197//definitions as per G.988 softwareImage::IsCommitted
198const (
199 SwIsUncommitted = 0
200 SwIsCommitted = 1
201)
202
203//definitions as per G.988 softwareImage::IsActive
204const (
205 SwIsInactive = 0
206 SwIsActive = 1
207)
208
209//definitions as per G.988 softwareImage::IsValid
210const (
211 SwIsInvalid = 0
212 SwIsValid = 1
213)
214
215// SEntrySwImageIndication - TODO: add comment
216type SEntrySwImageIndication struct {
217 Valid bool
218 EntityID uint16
219 Version string
220 IsCommitted uint8
221}
222
223// SswImageIndications - TODO: add comment
224type SswImageIndications struct {
225 ActiveEntityEntry SEntrySwImageIndication
226 InActiveEntityEntry SEntrySwImageIndication
227}
228
Holger Hildebrandt8998ed52022-03-23 09:52:37 +0000229// CGenericManagedEntityIDName - generic name string of attribute "ManagedEntityId"
230const CGenericManagedEntityIDName = "ManagedEntityId"
231
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000232///////////////////////////////////////////////////////////
233
234type activityDescr struct {
235 DatabaseClass func(context.Context) error
236 //advertiseEvents bool
237 AuditInterval time.Duration
238 //tasks map[string]func() error
239}
240
241// OmciDeviceFsms - FSM event mapping to database class and time to wait between audits
242type OmciDeviceFsms map[string]activityDescr
243
244// AdapterFsm - Adapter FSM details including channel, event and device
245type AdapterFsm struct {
246 fsmName string
247 deviceID string
248 CommChan chan Message
249 PFsm *fsm.FSM
250}
251
252//CErrWaitAborted - AdapterFsm related error string
253//error string could be checked on waitforOmciResponse() e.g. to avoid misleading error log
254// but not used that way so far (permit error log even for wanted cancellation)
255const CErrWaitAborted = "waitResponse aborted"
256
257///////////////////////////////////////////////////////////
258
259// UniPortType holds possible UNI port types
260type UniPortType uint8
261
262// UniPPTP Interface type - re-use values from G.988 (Chapter 9.3.4) TP type definition (directly used in OMCI!)
263const (
264 // UniPPTP relates to PPTP
265 UniPPTP UniPortType = 1 // relates to PPTP
266 // UniVEIP relates to VEIP
267 UniVEIP UniPortType = 11 // relates to VEIP
268 // UniPPTPPots relates to PPTP POTS
269 UniPPTPPots UniPortType = 4 // relates to IP host config data (for Voice Services)
270)
271
272//OnuUniPort structure holds information about the ONU attached Uni Ports
273type OnuUniPort struct {
274 Enabled bool
275 Name string
276 PortNo uint32
277 PortType UniPortType
278 OfpPortNo string
279 UniID uint8
280 MacBpNo uint8
281 EntityID uint16
282 AdminState vc.AdminState_Types
283 OperState vc.OperStatus_Types
284 PPort *voltha.Port
285}
286
287// OnuUniPortMap - TODO: add comment
288type OnuUniPortMap map[uint32]*OnuUniPort
289
290///////////////////////////////////////////////////////////
291
292const (
293 tpIDStart = 64
294 tpIDEnd = 256
295 tpRange = tpIDEnd - tpIDStart
296 maxUni = 256
297)
298
299// TODO
300const (
301 IeeMaperServiceProfileBaseEID = uint16(0x1001)
302 MacBridgePortAniBaseEID = uint16(0x1001)
303 MacBridgePortUniBaseEID = uint16(0x201)
304 MacBridgePortAniMcastBaseEID = uint16(0xA01)
ozgecanetsia0e3111f2021-10-19 18:04:15 +0300305 VoipUniBaseEID = uint16(0x2001)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000306 GalEthernetEID = uint16(1)
307 MacBridgeServiceProfileEID = uint16(0x201)
308)
309
310// UniVlanRuleParams - TODO: add comment
311type UniVlanRuleParams struct {
312 TpID uint8 `json:"tp_id"`
313 MatchVid uint32 `json:"match_vid"` //use uint32 types for allowing immediate bitshifting
314 MatchPcp uint32 `json:"match_pcp"`
315 TagsToRemove uint32 `json:"tags_to_remove"`
316 SetVid uint32 `json:"set_vid"`
317 SetPcp uint32 `json:"set_pcp"`
Abhilash Laxmeshwar81b5ccf2022-03-17 15:04:18 +0530318 InnerCvlan uint16 `json:"inner_cvlan"`
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000319}
320
321// UniVlanFlowParams - TODO: add comment
322type UniVlanFlowParams struct {
khenaidoo42dcdfd2021-10-19 17:34:12 -0400323 CookieSlice []uint64 `json:"cookie_slice"`
324 VlanRuleParams UniVlanRuleParams `json:"vlan_rule_params"`
325 Meter *ofp.OfpMeterConfig `json:"flow_meter"`
326 RespChan *chan error `json:"-"`
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000327}
328
329///////////////////////////////////////////////////////////
330
331//definitions as per G.988
332const (
333 OnuDataMeID = 0
334 Onu2gMeID = 0
335 OnugMeID = 0
336 IPHostConfigDataMeID = 1
337 OnugSerialNumberLen = 8
338 OmciMacAddressLen = 6
Holger Hildebrandtfdb4bba2022-03-10 12:12:59 +0000339 MdsDefaultMib = 0
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000340)
Holger Hildebrandt60652202021-11-02 11:09:36 +0000341
342///////////////////////////////////////////////////////////
343
344// CBasePathOnuKVStore - kv store path of ONU specific data
345const CBasePathOnuKVStore = "%s/openonu"
mpagenko101ac942021-11-16 15:01:29 +0000346
347///////////////////////////////////////////////////////////
348
349//WaitGroupWithTimeOut definitions to have waitGroup functionality with timeout
350type WaitGroupWithTimeOut struct {
351 sync.WaitGroup
352}
Holger Hildebrandtc56febd2022-02-09 13:23:30 +0000353
354///////////////////////////////////////////////////////////
355
356// event notifications
357const (
358 OnuMibAuditFailureMds = "ONU_MIB_AUDIT_FAILURE_MDS"
359 OnuMibAuditFailureMdsDesc = "MIB audit failed due to MDS value mismatch between ONU and adapter"
360
361 OnuOmciCommunicationFailureConfig = "ONU_OMCI_COMMUNICATION_FAILURE_CONFIG"
362 OnuOmciCommunicationFailureConfigDesc = "OMCI communication during ONU configuration failed"
363
364 OnuOmciCommunicationFailureSwUpgrade = "ONU_OMCI_COMMUNICATION_FAILURE_SW_UPGRADE"
365 OnuOmciCommunicationFailureSwUpgradeDesc = "OMCI communication during ONU SW upgrade failed"
366)