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