mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-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 adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
| 19 | |
| 20 | import ( |
| 21 | "context" |
| 22 | "encoding/json" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 23 | "errors" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 24 | "strconv" |
| 25 | "strings" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 26 | "sync" |
| 27 | |
| 28 | "github.com/opencord/voltha-lib-go/v3/pkg/db" |
| 29 | "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore" |
| 30 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 31 | tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile" |
| 32 | ) |
| 33 | |
| 34 | const cBasePathTechProfileKVStore = "service/voltha/technology_profiles" |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 35 | |
| 36 | //definitions for TechProfileProcessing - copied from OltAdapter:openolt_flowmgr.go |
| 37 | // could perhaps be defined more globally |
| 38 | const ( |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 39 | // binaryStringPrefix is binary string prefix |
| 40 | binaryStringPrefix = "0b" |
| 41 | // binaryBit1 is binary bit 1 expressed as a character |
| 42 | //binaryBit1 = '1' |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 43 | ) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 44 | |
| 45 | type resourceEntry int |
| 46 | |
| 47 | const ( |
| 48 | cResourceGemPort resourceEntry = 1 |
| 49 | cResourceTcont resourceEntry = 2 |
| 50 | ) |
| 51 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 52 | type tTechProfileIndication struct { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 53 | techProfileType string |
| 54 | techProfileID uint16 |
| 55 | techProfileConfigDone bool |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | type tcontParamStruct struct { |
| 59 | allocID uint16 |
| 60 | schedPolicy uint8 |
| 61 | } |
| 62 | type gemPortParamStruct struct { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 63 | //ponOmciCC bool |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 64 | gemPortID uint16 |
| 65 | direction uint8 |
| 66 | gemPortEncState uint8 |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 67 | prioQueueIndex uint8 |
| 68 | pbitString string |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 69 | discardPolicy string |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 70 | //could also be a queue specific parameter, not used that way here |
| 71 | //maxQueueSize uint16 |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 72 | queueSchedPolicy string |
| 73 | queueWeight uint8 |
| 74 | } |
| 75 | |
| 76 | //refers to one tcont and its properties and all assigned GemPorts and their properties |
| 77 | type tcontGemList struct { |
| 78 | tcontParams tcontParamStruct |
| 79 | mapGemPortParams map[uint16]*gemPortParamStruct |
| 80 | } |
| 81 | |
| 82 | //refers to all tcont and their Tcont/GemPort Parameters |
| 83 | type tMapPonAniConfig map[uint16]*tcontGemList |
| 84 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 85 | //onuUniTechProf structure holds information about the TechProfiles attached to Uni Ports of the ONU |
| 86 | type onuUniTechProf struct { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 87 | deviceID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 88 | baseDeviceHandler *deviceHandler |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 89 | tpProcMutex sync.RWMutex |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 90 | techProfileKVStore *db.Backend |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 91 | chTpConfigProcessingStep chan uint8 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 92 | mapUniTpIndication map[uint8]*tTechProfileIndication //use pointer values to ease assignments to the map |
| 93 | mapPonAniConfig map[uint8]*tMapPonAniConfig //per UNI: use pointer values to ease assignments to the map |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 94 | pAniConfigFsm *uniPonAniConfigFsm |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 95 | procResult error //error indication of processing |
| 96 | mutexTPState sync.Mutex |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 99 | //newOnuUniTechProf returns the instance of a OnuUniTechProf |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 100 | //(one instance per ONU/deviceHandler for all possible UNI's) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 101 | func newOnuUniTechProf(ctx context.Context, aDeviceID string, aDeviceHandler *deviceHandler) *onuUniTechProf { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 102 | logger.Infow("init-OnuUniTechProf", log.Fields{"device-id": aDeviceID}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 103 | var onuTP onuUniTechProf |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 104 | onuTP.deviceID = aDeviceID |
| 105 | onuTP.baseDeviceHandler = aDeviceHandler |
| 106 | onuTP.tpProcMutex = sync.RWMutex{} |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 107 | onuTP.chTpConfigProcessingStep = make(chan uint8) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 108 | onuTP.mapUniTpIndication = make(map[uint8]*tTechProfileIndication) |
| 109 | onuTP.mapPonAniConfig = make(map[uint8]*tMapPonAniConfig) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 110 | onuTP.procResult = nil //default assumption processing done with success |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 111 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 112 | onuTP.techProfileKVStore = aDeviceHandler.setBackend(cBasePathTechProfileKVStore) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 113 | if onuTP.techProfileKVStore == nil { |
| 114 | logger.Errorw("Can't access techProfileKVStore - no backend connection to service", |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 115 | log.Fields{"device-id": aDeviceID, "service": cBasePathTechProfileKVStore}) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 116 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 117 | |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 118 | return &onuTP |
| 119 | } |
| 120 | |
| 121 | // lockTpProcMutex locks OnuUniTechProf processing mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 122 | func (onuTP *onuUniTechProf) lockTpProcMutex() { |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 123 | onuTP.tpProcMutex.Lock() |
| 124 | } |
| 125 | |
| 126 | // unlockTpProcMutex unlocks OnuUniTechProf processing mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 127 | func (onuTP *onuUniTechProf) unlockTpProcMutex() { |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 128 | onuTP.tpProcMutex.Unlock() |
| 129 | } |
| 130 | |
Holger Hildebrandt | 47555e7 | 2020-09-21 11:07:24 +0000 | [diff] [blame^] | 131 | // resetTpProcessingErrorIndication resets the internal error indication |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 132 | // need to be called before evaluation of any subsequent processing (given by waitForTpCompletion()) |
Holger Hildebrandt | 47555e7 | 2020-09-21 11:07:24 +0000 | [diff] [blame^] | 133 | func (onuTP *onuUniTechProf) resetTpProcessingErrorIndication() { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 134 | onuTP.procResult = nil |
| 135 | } |
| 136 | |
Holger Hildebrandt | 47555e7 | 2020-09-21 11:07:24 +0000 | [diff] [blame^] | 137 | func (onuTP *onuUniTechProf) getTpProcessingErrorIndication() error { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 138 | return onuTP.procResult |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | // configureUniTp checks existing tp resources to delete and starts the corresponding OMCI configuation of the UNI port |
| 142 | // all possibly blocking processing must be run in background to allow for deadline supervision! |
| 143 | // but take care on sequential background processing when needed (logical dependencies) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 144 | // use waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) for internal synchronization |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 145 | func (onuTP *onuUniTechProf) configureUniTp(ctx context.Context, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 146 | aUniID uint8, aPathString string, wg *sync.WaitGroup) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 147 | defer wg.Done() //always decrement the waitGroup on return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 148 | logger.Debugw("configure the Uni according to TpPath", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 149 | "device-id": onuTP.deviceID, "uniID": aUniID, "path": aPathString}) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 150 | |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 151 | if onuTP.techProfileKVStore == nil { |
| 152 | logger.Debug("techProfileKVStore not set - abort") |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 153 | onuTP.procResult = errors.New("techProfile config aborted: techProfileKVStore not set") |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 154 | return |
| 155 | } |
| 156 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 157 | //ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 158 | var pCurrentUniPort *onuUniPort |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 159 | for _, uniPort := range onuTP.baseDeviceHandler.uniEntityMap { |
| 160 | // only if this port is validated for operState transfer |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 161 | if uniPort.uniID == uint8(aUniID) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 162 | pCurrentUniPort = uniPort |
| 163 | break //found - end search loop |
| 164 | } |
| 165 | } |
| 166 | if pCurrentUniPort == nil { |
| 167 | logger.Errorw("TechProfile configuration aborted: requested uniID not found in PortDB", |
| 168 | log.Fields{"device-id": onuTP.deviceID, "uniID": aUniID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 169 | onuTP.procResult = errors.New("techProfile config aborted: requested uniID not found") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 170 | return |
| 171 | } |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 172 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 173 | var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 174 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 175 | //according to updateOnuUniTpPath() logic the assumption here is, that this configuration is only called |
| 176 | // in case the KVPath has changed for the given UNI, |
| 177 | // as T-Cont and Gem-Id's are dependent on TechProfile-Id this means, that possibly previously existing |
| 178 | // (ANI) configuration of this port has to be removed first |
| 179 | // (moreover in this case a possibly existing flow configuration is also not valid anymore and needs clean-up as well) |
| 180 | // existence of configuration can be detected based on tp stored TCONT's |
| 181 | //TODO!!!: |
| 182 | /* if tcontMap not empty { |
| 183 | go onuTP.deleteAniSideConfig(ctx, aUniID, processingStep) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 184 | if !onuTP.waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 185 | //timeout or error detected |
| 186 | return |
| 187 | } |
| 188 | clear tcontMap |
| 189 | } |
| 190 | |
| 191 | processingStep++ |
| 192 | */ |
| 193 | go onuTP.readAniSideConfigFromTechProfile(ctx, aUniID, aPathString, processingStep) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 194 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 195 | //timeout or error detected |
| 196 | logger.Debugw("tech-profile related configuration aborted on read", |
| 197 | log.Fields{"device-id": onuTP.deviceID, "UniId": aUniID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 198 | onuTP.procResult = errors.New("techProfile config aborted: tech-profile read issue") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 199 | return |
| 200 | } |
| 201 | |
| 202 | processingStep++ |
| 203 | if valuePA, existPA := onuTP.mapPonAniConfig[aUniID]; existPA { |
| 204 | if _, existTG := (*valuePA)[0]; existTG { |
| 205 | //Config data for this uni and and at least TCont Index 0 exist |
| 206 | go onuTP.setAniSideConfigFromTechProfile(ctx, aUniID, pCurrentUniPort, processingStep) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 207 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 208 | //timeout or error detected |
| 209 | logger.Debugw("tech-profile related configuration aborted on set", |
| 210 | log.Fields{"device-id": onuTP.deviceID, "UniId": aUniID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 211 | onuTP.procResult = errors.New("techProfile config aborted: Omci AniSideConfig failed") |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 212 | //this issue here means that the AniConfigFsm has not finished successfully |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 213 | //which requires to reset it to allow for new usage, e.g. also on a different UNI |
| 214 | //(without that it would be reset on device down indication latest) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 215 | _ = onuTP.pAniConfigFsm.pAdaptFsm.pFsm.Event(aniEvReset) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 216 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 217 | } |
| 218 | } else { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 219 | // strange: UNI entry exists, but no ANI data, maybe such situation should be cleared up (if observed) |
| 220 | logger.Debugw("no Tcont/Gem data for this UNI found - abort", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 221 | "device-id": onuTP.deviceID, "uniID": aUniID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 222 | onuTP.procResult = errors.New("techProfile config aborted: no Tcont/Gem data found for this UNI") |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 223 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 224 | } |
| 225 | } else { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 226 | logger.Debugw("no PonAni data for this UNI found - abort", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 227 | "device-id": onuTP.deviceID, "uniID": aUniID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 228 | onuTP.procResult = errors.New("techProfile config aborted: no AniSide data found for this UNI") |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 229 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 233 | /* internal methods *********************/ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 234 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 235 | func (onuTP *onuUniTechProf) readAniSideConfigFromTechProfile( |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 236 | ctx context.Context, aUniID uint8, aPathString string, aProcessingStep uint8) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 237 | var tpInst tp.TechProfile |
| 238 | |
| 239 | //store profile type and identifier for later usage within the OMCI identifier and possibly ME setup |
| 240 | //pathstring is defined to be in the form of <ProfType>/<profID>/<Interface/../Identifier> |
| 241 | subStringSlice := strings.Split(aPathString, "/") |
| 242 | if len(subStringSlice) <= 2 { |
| 243 | logger.Errorw("invalid path name format", |
| 244 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 245 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 246 | return |
| 247 | } |
| 248 | |
| 249 | //just some logical check to avoid unexpected behavior |
| 250 | //at this point it is assumed that a new TechProfile is assigned to the UNI |
| 251 | //expectation is that no TPIndication entry exists here, if yes, |
| 252 | // then we throw a warning and remove it (and the possible ANIConfig) simply |
| 253 | // note that the ONU config state may be ambivalent in such a case |
| 254 | // also note, that the PonAniConfig map is not checked additionally |
| 255 | // consistency to TPIndication is assumed |
| 256 | if _, existTP := onuTP.mapUniTpIndication[aUniID]; existTP { |
| 257 | logger.Warnw("Some active profile entry at reading new TechProfile", |
| 258 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID, |
| 259 | "UniId": aUniID, "wrongProfile": onuTP.mapUniTpIndication[aUniID].techProfileID}) |
| 260 | //delete on the mapUniTpIndication map not needed, just overwritten later |
| 261 | //delete on the PonAniConfig map should be safe, even if not existing |
| 262 | delete(onuTP.mapPonAniConfig, aUniID) |
| 263 | } else { |
| 264 | // this is normal processing |
| 265 | onuTP.mapUniTpIndication[aUniID] = &tTechProfileIndication{} //need to assign some (empty) struct memory first! |
| 266 | } |
| 267 | |
| 268 | onuTP.mapUniTpIndication[aUniID].techProfileType = subStringSlice[0] |
| 269 | profID, err := strconv.ParseUint(subStringSlice[1], 10, 32) |
| 270 | if err != nil { |
| 271 | logger.Errorw("invalid ProfileId from path", |
| 272 | log.Fields{"ParseErr": err}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 273 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 274 | return |
| 275 | } |
| 276 | |
| 277 | //note the limitation on ID range (probably even more limited) - based on usage within OMCI EntityID |
| 278 | onuTP.mapUniTpIndication[aUniID].techProfileID = uint16(profID) |
| 279 | logger.Debugw("tech-profile path indications", |
| 280 | log.Fields{"device-id": onuTP.deviceID, "UniId": aUniID, |
| 281 | "profType": onuTP.mapUniTpIndication[aUniID].techProfileType, |
| 282 | "profID": onuTP.mapUniTpIndication[aUniID].techProfileID}) |
| 283 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 284 | Value, err := onuTP.techProfileKVStore.Get(ctx, aPathString) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 285 | if err == nil { |
| 286 | if Value != nil { |
| 287 | logger.Debugw("tech-profile read", |
| 288 | log.Fields{"Key": Value.Key, "device-id": onuTP.deviceID}) |
| 289 | tpTmpBytes, _ := kvstore.ToByte(Value.Value) |
| 290 | |
| 291 | if err = json.Unmarshal(tpTmpBytes, &tpInst); err != nil { |
| 292 | logger.Errorw("TechProf - Failed to unmarshal tech-profile into tpInst", |
| 293 | log.Fields{"error": err, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 294 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 295 | return |
| 296 | } |
| 297 | logger.Debugw("TechProf - tpInst", log.Fields{"tpInst": tpInst}) |
| 298 | // access examples |
| 299 | logger.Debugw("TechProf content", log.Fields{"Name": tpInst.Name, |
| 300 | "MaxGemPayloadSize": tpInst.InstanceCtrl.MaxGemPayloadSize, |
| 301 | "DownstreamGemDiscardmaxThreshold": tpInst.DownstreamGemPortAttributeList[0].DiscardConfig.MaxThreshold}) |
| 302 | } else { |
| 303 | logger.Errorw("No tech-profile found", |
| 304 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 305 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 306 | return |
| 307 | } |
| 308 | } else { |
| 309 | logger.Errorw("kvstore-get failed for path", |
| 310 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 311 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 312 | return |
| 313 | } |
| 314 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 315 | //default start with 1Tcont1Gem profile, later extend for multi GemPerTcont and perhaps even MultiTcontMultiGem |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 316 | localMapGemPortParams := make(map[uint16]*gemPortParamStruct) |
| 317 | localMapGemPortParams[0] = &gemPortParamStruct{} |
| 318 | localMapPonAniConfig := make(map[uint16]*tcontGemList) |
| 319 | localMapPonAniConfig[0] = &tcontGemList{tcontParamStruct{}, localMapGemPortParams} |
| 320 | onuTP.mapPonAniConfig[aUniID] = (*tMapPonAniConfig)(&localMapPonAniConfig) |
| 321 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 322 | //note: the code is currently restricted to one TCcont per Onu (index [0]) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 323 | //get the relevant values from the profile and store to mapPonAniConfig |
| 324 | (*(onuTP.mapPonAniConfig[aUniID]))[0].tcontParams.allocID = uint16(tpInst.UsScheduler.AllocID) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 325 | //maybe tCont scheduling not (yet) needed - just to basically have it for future |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 326 | // (would only be relevant in case of ONU-2G QOS configuration flexibility) |
| 327 | if tpInst.UsScheduler.QSchedPolicy == "StrictPrio" { |
| 328 | (*(onuTP.mapPonAniConfig[aUniID]))[0].tcontParams.schedPolicy = 1 //for the moment fixed value acc. G.988 //TODO: defines! |
| 329 | } else { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 330 | //default profile defines "Hybrid" - which probably comes down to WRR with some weigthts for SP |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 331 | (*(onuTP.mapPonAniConfig[aUniID]))[0].tcontParams.schedPolicy = 2 //for G.988 WRR |
| 332 | } |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 333 | loNumGemPorts := tpInst.NumGemPorts |
| 334 | loGemPortRead := false |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 335 | for pos, content := range tpInst.UpstreamGemPortAttributeList { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 336 | if uint32(pos) == loNumGemPorts { |
| 337 | logger.Debugw("PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts", |
| 338 | log.Fields{"device-id": onuTP.deviceID, "index": pos, "NumGem": loNumGemPorts}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 339 | break |
| 340 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 341 | if pos == 0 { |
| 342 | //at least one upstream GemPort should always exist (else traffic profile makes no sense) |
| 343 | loGemPortRead = true |
| 344 | } else { |
| 345 | //for all further GemPorts we need to extend the mapGemPortParams |
| 346 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)] = &gemPortParamStruct{} |
| 347 | } |
| 348 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].gemPortID = |
| 349 | uint16(content.GemportID) |
| 350 | //direction can be correlated later with Downstream list, |
| 351 | // for now just assume bidirectional (upstream never exists alone) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 352 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].direction = 3 //as defined in G.988 |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 353 | // expected Prio-Queue values 0..7 with 7 for highest PrioQueue, QueueIndex=Prio = 0..7 |
| 354 | if 7 < content.PriorityQueue { |
| 355 | logger.Errorw("PonAniConfig reject on GemPortList - PrioQueue value invalid", |
| 356 | log.Fields{"device-id": onuTP.deviceID, "index": pos, "PrioQueue": content.PriorityQueue}) |
| 357 | //remove PonAniConfig as done so far, delete map should be safe, even if not existing |
| 358 | delete(onuTP.mapPonAniConfig, aUniID) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 359 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 360 | return |
| 361 | } |
| 362 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].prioQueueIndex = |
| 363 | uint8(content.PriorityQueue) |
| 364 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].pbitString = |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 365 | strings.TrimPrefix(content.PbitMap, binaryStringPrefix) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 366 | if content.AesEncryption == "True" { |
| 367 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].gemPortEncState = 1 |
| 368 | } else { |
| 369 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].gemPortEncState = 0 |
| 370 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 371 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].discardPolicy = |
| 372 | content.DiscardPolicy |
| 373 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].queueSchedPolicy = |
| 374 | content.SchedulingPolicy |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 375 | //'GemWeight' looks strange in default profile, for now we just copy the weight to first queue |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 376 | (*(onuTP.mapPonAniConfig[aUniID]))[0].mapGemPortParams[uint16(pos)].queueWeight = |
| 377 | uint8(content.Weight) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 378 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 379 | if !loGemPortRead { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 380 | logger.Errorw("PonAniConfig reject - no GemPort could be read from TechProfile", |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 381 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 382 | //remove PonAniConfig as done so far, delete map should be safe, even if not existing |
| 383 | delete(onuTP.mapPonAniConfig, aUniID) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 384 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 385 | return |
| 386 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 387 | //TODO!! MC (downstream) GemPorts can be set using DownstreamGemPortAttributeList separately |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 388 | |
| 389 | //logger does not simply output the given structures, just give some example debug values |
| 390 | logger.Debugw("PonAniConfig read from TechProfile", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 391 | "device-id": onuTP.deviceID, |
| 392 | "AllocId": (*(onuTP.mapPonAniConfig[aUniID]))[0].tcontParams.allocID}) |
| 393 | for gemIndex, gemEntry := range (*(onuTP.mapPonAniConfig[0]))[0].mapGemPortParams { |
| 394 | logger.Debugw("PonAniConfig read from TechProfile", log.Fields{ |
| 395 | "GemIndex": gemIndex, |
| 396 | "GemPort": gemEntry.gemPortID, |
| 397 | "QueueScheduling": gemEntry.queueSchedPolicy}) |
| 398 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 399 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 400 | onuTP.chTpConfigProcessingStep <- aProcessingStep //done |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 401 | } |
| 402 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 403 | func (onuTP *onuUniTechProf) setAniSideConfigFromTechProfile( |
| 404 | ctx context.Context, aUniID uint8, apCurrentUniPort *onuUniPort, aProcessingStep uint8) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 405 | |
| 406 | //OMCI transfer of ANI data acc. to mapPonAniConfig |
| 407 | // also the FSM's are running in background, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 408 | // hence we have to make sure they indicate 'success' success on chTpConfigProcessingStep with aProcessingStep |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 409 | if onuTP.pAniConfigFsm == nil { |
| 410 | onuTP.createAniConfigFsm(aUniID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep) |
| 411 | } else { //AniConfigFsm already init |
| 412 | onuTP.runAniConfigFsm(aProcessingStep) |
| 413 | } |
| 414 | } |
| 415 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 416 | func (onuTP *onuUniTechProf) waitForTimeoutOrCompletion( |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 417 | ctx context.Context, aChTpProcessingStep <-chan uint8, aProcessingStep uint8) bool { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 418 | select { |
| 419 | case <-ctx.Done(): |
| 420 | logger.Warnw("processing not completed in-time: force release of TpProcMutex!", |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 421 | log.Fields{"device-id": onuTP.deviceID, "error": ctx.Err()}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 422 | return false |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 423 | case rxStep := <-aChTpProcessingStep: |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 424 | if rxStep == aProcessingStep { |
| 425 | return true |
| 426 | } |
| 427 | //all other values are not accepted - including 0 for error indication |
| 428 | logger.Warnw("Invalid processing step received: abort and force release of TpProcMutex!", |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 429 | log.Fields{"device-id": onuTP.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 430 | "wantedStep": aProcessingStep, "haveStep": rxStep}) |
| 431 | return false |
| 432 | } |
| 433 | } |
| 434 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 435 | // createUniLockFsm initializes and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 436 | func (onuTP *onuUniTechProf) createAniConfigFsm(aUniID uint8, |
| 437 | apCurrentUniPort *onuUniPort, devEvent OnuDeviceEvent, aProcessingStep uint8) { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 438 | logger.Debugw("createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 439 | chAniConfigFsm := make(chan Message, 2048) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 440 | pDevEntry := onuTP.baseDeviceHandler.getOnuDeviceEntry(true) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 441 | if pDevEntry == nil { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 442 | logger.Errorw("No valid OnuDevice - aborting", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 443 | return |
| 444 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 445 | pAniCfgFsm := newUniPonAniConfigFsm(pDevEntry.PDevOmciCC, apCurrentUniPort, onuTP, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 446 | pDevEntry.pOnuDB, onuTP.mapUniTpIndication[aUniID].techProfileID, devEvent, |
| 447 | "AniConfigFsm", onuTP.deviceID, chAniConfigFsm) |
| 448 | if pAniCfgFsm != nil { |
| 449 | onuTP.pAniConfigFsm = pAniCfgFsm |
| 450 | onuTP.runAniConfigFsm(aProcessingStep) |
| 451 | } else { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 452 | logger.Errorw("AniConfigFSM could not be created - abort!!", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
| 456 | // runAniConfigFsm starts the AniConfig FSM to transfer the OMCI related commands for ANI side configuration |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 457 | func (onuTP *onuUniTechProf) runAniConfigFsm(aProcessingStep uint8) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 458 | /* Uni related ANI config procedure - |
| 459 | ***** should run via 'aniConfigDone' state and generate the argument requested event ***** |
| 460 | */ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 461 | pACStatemachine := onuTP.pAniConfigFsm.pAdaptFsm.pFsm |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 462 | if pACStatemachine != nil { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 463 | if pACStatemachine.Is(aniStDisabled) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 464 | //FSM init requirement to get informed abou FSM completion! (otherwise timeout of the TechProf config) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 465 | onuTP.pAniConfigFsm.setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 466 | if err := pACStatemachine.Event(aniEvStart); err != nil { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 467 | logger.Warnw("AniConfigFSM: can't start", log.Fields{"err": err}) |
| 468 | // maybe try a FSM reset and then again ... - TODO!!! |
| 469 | } else { |
| 470 | /***** AniConfigFSM started */ |
| 471 | logger.Debugw("AniConfigFSM started", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 472 | "state": pACStatemachine.Current(), "device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 473 | } |
| 474 | } else { |
| 475 | logger.Warnw("wrong state of AniConfigFSM - want: disabled", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 476 | "have": pACStatemachine.Current(), "device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 477 | // maybe try a FSM reset and then again ... - TODO!!! |
| 478 | } |
| 479 | } else { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 480 | logger.Errorw("AniConfigFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 481 | // maybe try a FSM reset and then again ... - TODO!!! |
| 482 | } |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 483 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 484 | |
| 485 | // setConfigDone sets the requested techProfile config state (if possible) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 486 | func (onuTP *onuUniTechProf) setConfigDone(aUniID uint8, aState bool) { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 487 | if _, existTP := onuTP.mapUniTpIndication[aUniID]; existTP { |
| 488 | onuTP.mutexTPState.Lock() |
| 489 | onuTP.mapUniTpIndication[aUniID].techProfileConfigDone = aState |
| 490 | onuTP.mutexTPState.Unlock() |
| 491 | } //else: the state is just ignored (does not exist) |
| 492 | } |
| 493 | |
| 494 | // getTechProfileDone checks if the Techprofile processing with the requested TechProfile ID was done |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 495 | func (onuTP *onuUniTechProf) getTechProfileDone(aUniID uint8, aTpID uint16) bool { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 496 | if _, existTP := onuTP.mapUniTpIndication[aUniID]; existTP { |
| 497 | if onuTP.mapUniTpIndication[aUniID].techProfileID == aTpID { |
| 498 | onuTP.mutexTPState.Lock() |
| 499 | defer onuTP.mutexTPState.Unlock() |
| 500 | return onuTP.mapUniTpIndication[aUniID].techProfileConfigDone |
| 501 | } |
| 502 | } |
| 503 | //for all other constellations indicate false = Config not done |
| 504 | return false |
| 505 | } |