mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 1 | /* |
Joey Armstrong | e8c091f | 2023-01-17 16:56:26 -0500 | [diff] [blame] | 2 | * Copyright 2020-2023 Open Networking Foundation (ONF) and the ONF Contributors |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 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 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 17 | //Package avcfg provides anig and vlan configuration functionality |
| 18 | package avcfg |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "context" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 22 | "fmt" |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 23 | "strconv" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 24 | "strings" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 25 | "sync" |
| 26 | |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 27 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 28 | cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common" |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 29 | "github.com/opencord/voltha-protos/v5/go/tech_profile" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 30 | ) |
| 31 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 32 | //definitions for TechProfileProcessing - copied from OltAdapter:openolt_flowmgr.go |
| 33 | // could perhaps be defined more globally |
| 34 | const ( |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 35 | // binaryStringPrefix is binary string prefix |
| 36 | binaryStringPrefix = "0b" |
| 37 | // binaryBit1 is binary bit 1 expressed as a character |
| 38 | //binaryBit1 = '1' |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 39 | ) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 40 | |
Holger Hildebrandt | 5ba6c13 | 2022-10-06 13:53:14 +0000 | [diff] [blame] | 41 | //as defined in G.988 |
| 42 | const ( |
| 43 | cGemDirUniToAni = 1 |
| 44 | cGemDirAniToUni = 2 |
| 45 | cGemDirBiDirect = 3 |
| 46 | ) |
| 47 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 48 | // ResourceEntry - TODO: add comment |
| 49 | type ResourceEntry int |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 50 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 51 | // TODO: add comment |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 52 | const ( |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 53 | CResourceGemPort ResourceEntry = 1 |
| 54 | CResourceTcont ResourceEntry = 2 |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 55 | ) |
| 56 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 57 | type tTechProfileIndication struct { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 58 | techProfileType string |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 59 | techProfileID uint8 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 60 | techProfileConfigDone bool |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 61 | techProfileToDelete bool |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | type tcontParamStruct struct { |
| 65 | allocID uint16 |
| 66 | schedPolicy uint8 |
| 67 | } |
| 68 | type gemPortParamStruct struct { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 69 | //ponOmciCC bool |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 70 | gemPortID uint16 |
| 71 | direction uint8 |
| 72 | gemPortEncState uint8 |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 73 | prioQueueIndex uint8 |
| 74 | pbitString string |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 75 | discardPolicy string |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 76 | //could also be a queue specific parameter, not used that way here |
| 77 | //maxQueueSize uint16 |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 78 | queueSchedPolicy string |
| 79 | queueWeight uint8 |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 80 | removeGemID uint16 |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 81 | isMulticast bool |
| 82 | //TODO check if this has any value/difference from gemPortId |
| 83 | multicastGemPortID uint16 |
| 84 | staticACL string |
| 85 | dynamicACL string |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | //refers to one tcont and its properties and all assigned GemPorts and their properties |
| 89 | type tcontGemList struct { |
| 90 | tcontParams tcontParamStruct |
| 91 | mapGemPortParams map[uint16]*gemPortParamStruct |
| 92 | } |
| 93 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 94 | // refers a unique combination of uniID and tpID for a given ONU. |
| 95 | type uniTP struct { |
| 96 | uniID uint8 |
| 97 | tpID uint8 |
| 98 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 99 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 100 | //OnuUniTechProf structure holds information about the TechProfiles attached to Uni Ports of the ONU |
| 101 | type OnuUniTechProf struct { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 102 | deviceID string |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 103 | baseDeviceHandler cmn.IdeviceHandler |
| 104 | onuDevice cmn.IonuDeviceEntry |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 105 | tpProcMutex sync.RWMutex |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 106 | chTpConfigProcessingStep chan uint8 |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 107 | mapUniTpIndication map[uniTP]*tTechProfileIndication //use pointer values to ease assignments to the map |
| 108 | mapPonAniConfig map[uniTP]*tcontGemList //per UNI: use pointer values to ease assignments to the map |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 109 | PAniConfigFsm map[uniTP]*UniPonAniConfigFsm |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 110 | procResult map[uniTP]error //error indication of processing |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 111 | mutexTPState sync.RWMutex |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 112 | tpProfileExists map[uniTP]bool |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 113 | tpProfileResetting map[uniTP]bool |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 114 | mapRemoveGemEntry map[uniTP]*gemPortParamStruct //per UNI: pointer to GemEntry to be removed |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 115 | } |
| 116 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 117 | func (onuTP *OnuUniTechProf) multicastConfiguredForOtherUniTps(ctx context.Context, uniTpKey uniTP) bool { |
| 118 | for _, aniFsm := range onuTP.PAniConfigFsm { |
ozgecanetsia | 72e1c9f | 2021-05-26 17:26:29 +0300 | [diff] [blame] | 119 | if aniFsm.uniTpKey.uniID == uniTpKey.uniID && aniFsm.uniTpKey.tpID == uniTpKey.tpID { |
| 120 | continue |
| 121 | } |
| 122 | if aniFsm.hasMulticastGem(ctx) { |
| 123 | return true |
| 124 | } |
| 125 | } |
| 126 | return false |
| 127 | } |
| 128 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 129 | //NewOnuUniTechProf returns the instance of a OnuUniTechProf |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 130 | //(one instance per ONU/deviceHandler for all possible UNI's) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 131 | func NewOnuUniTechProf(ctx context.Context, aDeviceHandler cmn.IdeviceHandler, aOnuDev cmn.IonuDeviceEntry) *OnuUniTechProf { |
| 132 | |
| 133 | var onuTP OnuUniTechProf |
| 134 | onuTP.deviceID = aDeviceHandler.GetDeviceID() |
| 135 | logger.Debugw(ctx, "init-OnuUniTechProf", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 136 | onuTP.baseDeviceHandler = aDeviceHandler |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 137 | onuTP.onuDevice = aOnuDev |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 138 | onuTP.chTpConfigProcessingStep = make(chan uint8) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 139 | onuTP.mapUniTpIndication = make(map[uniTP]*tTechProfileIndication) |
| 140 | onuTP.mapPonAniConfig = make(map[uniTP]*tcontGemList) |
| 141 | onuTP.procResult = make(map[uniTP]error) |
| 142 | onuTP.tpProfileExists = make(map[uniTP]bool) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 143 | onuTP.tpProfileResetting = make(map[uniTP]bool) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 144 | onuTP.mapRemoveGemEntry = make(map[uniTP]*gemPortParamStruct) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 145 | |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 146 | return &onuTP |
| 147 | } |
| 148 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 149 | // LockTpProcMutex locks OnuUniTechProf processing mutex |
| 150 | func (onuTP *OnuUniTechProf) LockTpProcMutex() { |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 151 | onuTP.tpProcMutex.Lock() |
| 152 | } |
| 153 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 154 | // UnlockTpProcMutex unlocks OnuUniTechProf processing mutex |
| 155 | func (onuTP *OnuUniTechProf) UnlockTpProcMutex() { |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 156 | onuTP.tpProcMutex.Unlock() |
| 157 | } |
| 158 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 159 | // ResetTpProcessingErrorIndication resets the internal error indication |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 160 | // need to be called before evaluation of any subsequent processing (given by waitForTpCompletion()) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 161 | func (onuTP *OnuUniTechProf) ResetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 162 | onuTP.mutexTPState.Lock() |
| 163 | defer onuTP.mutexTPState.Unlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 164 | onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}] = nil |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 167 | // GetTpProcessingErrorIndication - TODO: add comment |
| 168 | func (onuTP *OnuUniTechProf) GetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) error { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 169 | onuTP.mutexTPState.RLock() |
| 170 | defer onuTP.mutexTPState.RUnlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 171 | return onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}] |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 174 | // ConfigureUniTp checks existing tp resources to configure and starts the corresponding OMCI configuation of the UNI port |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 175 | // all possibly blocking processing must be run in background to allow for deadline supervision! |
| 176 | // but take care on sequential background processing when needed (logical dependencies) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 177 | // use waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) for internal synchronization |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 178 | func (onuTP *OnuUniTechProf) ConfigureUniTp(ctx context.Context, |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 179 | aUniID uint8, aPathString string, tpInst tech_profile.TechProfileInstance, wg *sync.WaitGroup) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 180 | defer wg.Done() //always decrement the waitGroup on return |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 181 | logger.Debugw(ctx, "configure the Uni according to TpPath", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 182 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 183 | tpID, err := cmn.GetTpIDFromTpPath(aPathString) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 184 | uniTpKey := uniTP{uniID: aUniID, tpID: tpID} |
| 185 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 186 | logger.Errorw(ctx, "error-extracting-tp-id-from-tp-path", log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 187 | return |
| 188 | } |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 189 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 190 | //ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 191 | var pCurrentUniPort *cmn.OnuUniPort |
| 192 | for _, uniPort := range *onuTP.baseDeviceHandler.GetUniEntityMap() { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 193 | // only if this port is validated for operState transfer |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 194 | if uniPort.UniID == aUniID { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 195 | pCurrentUniPort = uniPort |
| 196 | break //found - end search loop |
| 197 | } |
| 198 | } |
| 199 | if pCurrentUniPort == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 200 | logger.Errorw(ctx, "TechProfile configuration aborted: requested uniID not found in PortDB", |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 201 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": uniTpKey.tpID}) |
| 202 | onuTP.mutexTPState.Lock() |
| 203 | defer onuTP.mutexTPState.Unlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 204 | onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: requested uniID not found %d on %s", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 205 | aUniID, onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 206 | return |
| 207 | } |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 208 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 209 | if onuTP.getProfileResetting(uniTpKey) { |
| 210 | logger.Debugw(ctx, "aborting TP configuration, reset requested in parallel", log.Fields{ |
| 211 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": uniTpKey.tpID}) |
| 212 | onuTP.mutexTPState.Lock() |
| 213 | defer onuTP.mutexTPState.Unlock() |
| 214 | onuTP.procResult[uniTpKey] = fmt.Errorf( |
| 215 | "techProfile config aborted - reset requested in parallel - for uniID %d on %s", |
| 216 | aUniID, onuTP.deviceID) |
| 217 | return |
| 218 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 219 | var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 220 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 221 | //according to UpdateOnuUniTpPath() logic the assumption here is, that this configuration is only called |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 222 | // in case the KVPath has changed for the given UNI, |
| 223 | // as T-Cont and Gem-Id's are dependent on TechProfile-Id this means, that possibly previously existing |
| 224 | // (ANI) configuration of this port has to be removed first |
| 225 | // (moreover in this case a possibly existing flow configuration is also not valid anymore and needs clean-up as well) |
| 226 | // existence of configuration can be detected based on tp stored TCONT's |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 227 | //TODO: |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 228 | /* if tcontMap not empty { |
| 229 | go onuTP.deleteAniSideConfig(ctx, aUniID, processingStep) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 230 | if !onuTP.waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 231 | //timeout or error detected |
| 232 | return |
| 233 | } |
| 234 | clear tcontMap |
| 235 | } |
| 236 | |
| 237 | processingStep++ |
| 238 | */ |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 239 | go onuTP.readAniSideConfigFromTechProfile(ctx, aUniID, tpID, aPathString, tpInst, processingStep) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 240 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 241 | //timeout or error detected |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 242 | onuTP.mutexTPState.RLock() |
Girish Gowdra | 24dd113 | 2021-07-06 15:25:40 -0700 | [diff] [blame] | 243 | ok := onuTP.tpProfileExists[uniTpKey] |
| 244 | onuTP.mutexTPState.RUnlock() |
| 245 | if ok { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 246 | //ignore the internal error in case the new profile is already configured |
| 247 | // and abort the processing here |
| 248 | return |
| 249 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 250 | logger.Errorw(ctx, "tech-profile related configuration aborted on read", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 251 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 252 | onuTP.mutexTPState.Lock() |
| 253 | defer onuTP.mutexTPState.Unlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 254 | onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: tech-profile read issue for %d on %s", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 255 | aUniID, onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 256 | return |
| 257 | } |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 258 | if onuTP.getProfileResetting(uniTpKey) { |
| 259 | logger.Debugw(ctx, "aborting TP configuration, reset requested in parallel", log.Fields{ |
| 260 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": uniTpKey.tpID}) |
| 261 | onuTP.mutexTPState.Lock() |
| 262 | defer onuTP.mutexTPState.Unlock() |
| 263 | onuTP.procResult[uniTpKey] = fmt.Errorf( |
| 264 | "techProfile config aborted - reset requested in parallel - for uniID %d on %s", |
| 265 | aUniID, onuTP.deviceID) |
| 266 | return |
| 267 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 268 | processingStep++ |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 269 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 270 | //ensure read protection for access to mapPonAniConfig |
| 271 | onuTP.mutexTPState.RLock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 272 | valuePA, existPA := onuTP.mapPonAniConfig[uniTpKey] |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 273 | onuTP.mutexTPState.RUnlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 274 | if existPA { |
| 275 | if valuePA != nil { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 276 | //Config data for this uni and and at least TCont Index 0 exist |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 277 | if err := onuTP.setAniSideConfigFromTechProfile(ctx, aUniID, tpID, pCurrentUniPort, processingStep); err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 278 | logger.Errorw(ctx, "tech-profile related FSM could not be started", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 279 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 280 | onuTP.mutexTPState.Lock() |
| 281 | defer onuTP.mutexTPState.Unlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 282 | onuTP.procResult[uniTpKey] = err |
| 283 | return |
| 284 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 285 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 286 | //timeout or error detected (included wanted cancellation after e.g. disable device (FsmReset)) |
| 287 | logger.Warnw(ctx, "tech-profile related configuration aborted on set", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 288 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 289 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 290 | onuTP.mutexTPState.Lock() |
| 291 | defer onuTP.mutexTPState.Unlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 292 | onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: Omci AniSideConfig failed %d on %s", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 293 | aUniID, onuTP.deviceID) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 294 | //this issue here means that the AniConfigFsm has not finished successfully |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 295 | //which requires to reset it to allow for new usage, e.g. also on a different UNI |
| 296 | //(without that it would be reset on device down indication latest) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 297 | if _, ok := onuTP.PAniConfigFsm[uniTpKey]; ok { |
| 298 | _ = onuTP.PAniConfigFsm[uniTpKey].PAdaptFsm.PFsm.Event(aniEvReset) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 299 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 300 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 301 | } |
| 302 | } else { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 303 | // strange: UNI entry exists, but no ANI data, maybe such situation should be cleared up (if observed) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 304 | logger.Errorw(ctx, "no Tcont/Gem data for this UNI found - abort", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 305 | "device-id": onuTP.deviceID, "uni-id": aUniID}) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 306 | onuTP.mutexTPState.Lock() |
| 307 | defer onuTP.mutexTPState.Unlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 308 | onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: no Tcont/Gem data found for this UNI %d on %s", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 309 | aUniID, onuTP.deviceID) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 310 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 311 | } |
| 312 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 313 | logger.Errorw(ctx, "no PonAni data for this UNI found - abort", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 314 | "device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 315 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 316 | onuTP.mutexTPState.Lock() |
| 317 | defer onuTP.mutexTPState.Unlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 318 | onuTP.procResult[uniTpKey] = fmt.Errorf("techProfile config aborted: no AniSide data found for this UNI %d on %s", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 319 | aUniID, onuTP.deviceID) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 320 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 324 | /* internal methods *********************/ |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 325 | // nolint: gocyclo |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 326 | func (onuTP *OnuUniTechProf) readAniSideConfigFromTechProfile( |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 327 | ctx context.Context, aUniID uint8, aTpID uint8, aPathString string, tpInst tech_profile.TechProfileInstance, aProcessingStep uint8) { |
| 328 | var err error |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 329 | //store profile type and identifier for later usage within the OMCI identifier and possibly ME setup |
| 330 | //pathstring is defined to be in the form of <ProfType>/<profID>/<Interface/../Identifier> |
| 331 | subStringSlice := strings.Split(aPathString, "/") |
| 332 | if len(subStringSlice) <= 2 { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 333 | logger.Errorw(ctx, "invalid path name format", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 334 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 335 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 336 | return |
| 337 | } |
| 338 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 339 | //ensure write protection for access to used maps |
| 340 | onuTP.mutexTPState.Lock() |
| 341 | defer onuTP.mutexTPState.Unlock() |
| 342 | |
| 343 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 344 | onuTP.tpProfileExists[uniTP{uniID: aUniID, tpID: aTpID}] = false |
| 345 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 346 | //at this point it is assumed that a new TechProfile is assigned to the UNI |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 347 | //expectation is that no TPIndication entry exists here, if exists and with the same TPId |
| 348 | // then we throw a warning, set an internal error and abort with error, |
| 349 | // which is later re-defined to success response to OLT adapter |
| 350 | // if TPId has changed, current data is removed (note that the ONU config state may be |
| 351 | // ambivalent in such a case) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 352 | if _, existTP := onuTP.mapUniTpIndication[uniTPKey]; existTP { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 353 | logger.Warnw(ctx, "Some active profile entry at reading new TechProfile", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 354 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID, |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 355 | "uni-id": aUniID, "wrongProfile": onuTP.mapUniTpIndication[uniTPKey].techProfileID}) |
| 356 | if aTpID == onuTP.mapUniTpIndication[uniTPKey].techProfileID { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 357 | // ProfId not changed - assume profile to be still the same |
| 358 | // anyway this should not appear after full support of profile (Gem/TCont) removal |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 359 | logger.Warnw(ctx, "New TechProfile already exists - aborting configuration", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 360 | log.Fields{"device-id": onuTP.deviceID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 361 | onuTP.tpProfileExists[uniTPKey] = true |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 362 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
| 363 | return |
| 364 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 365 | //delete on the mapUniTpIndication map not needed, just overwritten later |
| 366 | //delete on the PonAniConfig map should be safe, even if not existing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 367 | delete(onuTP.mapPonAniConfig, uniTPKey) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 368 | } else { |
| 369 | // this is normal processing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 370 | onuTP.mapUniTpIndication[uniTPKey] = &tTechProfileIndication{} //need to assign some (empty) struct memory first! |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 373 | onuTP.mapUniTpIndication[uniTPKey].techProfileType = subStringSlice[0] |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 374 | //note the limitation on ID range (probably even more limited) - based on usage within OMCI EntityID |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 375 | onuTP.mapUniTpIndication[uniTPKey].techProfileID = aTpID |
| 376 | onuTP.mapUniTpIndication[uniTPKey].techProfileConfigDone = false |
| 377 | onuTP.mapUniTpIndication[uniTPKey].techProfileToDelete = false |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 378 | logger.Debugw(ctx, "tech-profile path indications", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 379 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 380 | "profType": onuTP.mapUniTpIndication[uniTPKey].techProfileType, |
| 381 | "profID": onuTP.mapUniTpIndication[uniTPKey].techProfileID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 382 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 383 | //default start with 1Tcont profile, later perhaps extend to MultiTcontMultiGem |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 384 | localMapGemPortParams := make(map[uint16]*gemPortParamStruct) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 385 | onuTP.mapPonAniConfig[uniTPKey] = &tcontGemList{tcontParamStruct{}, localMapGemPortParams} |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 386 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 387 | //note: the code is currently restricted to one TCcont per Onu (index [0]) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 388 | //get the relevant values from the profile and store to mapPonAniConfig |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 389 | onuTP.mapPonAniConfig[uniTPKey].tcontParams.allocID = uint16(tpInst.UsScheduler.AllocId) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 390 | //maybe tCont scheduling not (yet) needed - just to basically have it for future |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 391 | // (would only be relevant in case of ONU-2G QOS configuration flexibility) |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 392 | if tpInst.UsScheduler.QSchedPolicy == tech_profile.SchedulingPolicy_StrictPriority { |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 393 | onuTP.mapPonAniConfig[uniTPKey].tcontParams.schedPolicy = 1 //for the moment fixed value acc. G.988 //TODO: defines! |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 394 | } else { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 395 | //default profile defines "Hybrid" - which probably comes down to WRR with some weigthts for SP |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 396 | onuTP.mapPonAniConfig[uniTPKey].tcontParams.schedPolicy = 2 //for G.988 WRR |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 397 | } |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 398 | loNumGemPorts := tpInst.NumGemPorts |
| 399 | loGemPortRead := false |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 400 | for pos, content := range tpInst.UpstreamGemPortAttributeList { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 401 | if uint32(pos) == loNumGemPorts { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 402 | logger.Debugw(ctx, "PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts", |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 403 | log.Fields{"device-id": onuTP.deviceID, "index": pos, "NumGem": loNumGemPorts}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 404 | break |
| 405 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 406 | if pos == 0 { |
| 407 | //at least one upstream GemPort should always exist (else traffic profile makes no sense) |
| 408 | loGemPortRead = true |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 409 | } |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 410 | //for all GemPorts we need to extend the mapGemPortParams |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 411 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)] = &gemPortParamStruct{} |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 412 | |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 413 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].gemPortID = |
| 414 | uint16(content.GemportId) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 415 | //direction can be correlated later with Downstream list, |
| 416 | // for now just assume bidirectional (upstream never exists alone) |
Holger Hildebrandt | 5ba6c13 | 2022-10-06 13:53:14 +0000 | [diff] [blame] | 417 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].direction = cGemDirBiDirect |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 418 | // expected Prio-Queue values 0..7 with 7 for highest PrioQueue, QueueIndex=Prio = 0..7 |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 419 | if content.PriorityQ > 7 { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 420 | logger.Errorw(ctx, "PonAniConfig reject on GemPortList - PrioQueue value invalid", |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 421 | log.Fields{"device-id": onuTP.deviceID, "index": pos, "PrioQueue": content.PriorityQ}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 422 | //remove PonAniConfig as done so far, delete map should be safe, even if not existing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 423 | delete(onuTP.mapPonAniConfig, uniTPKey) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 424 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 425 | return |
| 426 | } |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 427 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].prioQueueIndex = |
| 428 | uint8(content.PriorityQ) |
| 429 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].pbitString = |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 430 | strings.TrimPrefix(content.PbitMap, binaryStringPrefix) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 431 | if content.AesEncryption == "True" { |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 432 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].gemPortEncState = 1 |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 433 | } else { |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 434 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].gemPortEncState = 0 |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 435 | } |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 436 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].discardPolicy = |
| 437 | content.DiscardPolicy.String() |
| 438 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].queueSchedPolicy = |
| 439 | content.SchedulingPolicy.String() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 440 | //'GemWeight' looks strange in default profile, for now we just copy the weight to first queue |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 441 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportId)].queueWeight = |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 442 | uint8(content.Weight) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 443 | } |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 444 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 445 | for _, downstreamContent := range tpInst.DownstreamGemPortAttributeList { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 446 | logger.Debugw(ctx, "Operating on Downstream Gem Port", log.Fields{"downstream-gem": downstreamContent}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 447 | //Commenting this out due to faliure, needs investigation |
| 448 | //if uint32(pos) == loNumGemPorts { |
| 449 | // logger.Debugw("PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts", |
| 450 | // log.Fields{"device-id": onuTP.deviceID, "index": pos, "NumGem": loNumGemPorts}) |
| 451 | // break |
| 452 | //} |
| 453 | isMulticast := false |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 454 | //Flag is defined as string in the TP in voltha-lib-go, parsing it from string |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 455 | if downstreamContent.IsMulticast != "" { |
| 456 | isMulticast, err = strconv.ParseBool(downstreamContent.IsMulticast) |
| 457 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 458 | logger.Errorw(ctx, "multicast-error-config-unknown-flag-in-technology-profile", |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 459 | log.Fields{"device-id": onuTP.deviceID, "UniTpKey": uniTPKey, "downstream-gem": downstreamContent, "error": err}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 460 | continue |
| 461 | } |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 462 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 463 | logger.Infow(ctx, "Gem Port is multicast", log.Fields{"isMulticast": isMulticast}) |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 464 | if isMulticast { |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 465 | mcastGemID := uint16(downstreamContent.MulticastGemId) |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 466 | _, existing := onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID] |
| 467 | if existing { |
| 468 | //GEM port was previously configured, avoid setting multicast attributes |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 469 | logger.Errorw(ctx, "multicast-error-config-existing-gem-port-config", log.Fields{"device-id": onuTP.deviceID, |
| 470 | "UniTpKey": uniTPKey, "downstream-gem": downstreamContent, "key": mcastGemID}) |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 471 | continue |
| 472 | } else { |
| 473 | //GEM port is not configured, setting multicast attributes |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 474 | logger.Infow(ctx, "creating-multicast-gem-port", log.Fields{"uniTpKey": uniTPKey, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 475 | "gemPortId": mcastGemID, "key": mcastGemID}) |
| 476 | |
| 477 | //for all further GemPorts we need to extend the mapGemPortParams |
| 478 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID] = &gemPortParamStruct{} |
| 479 | |
| 480 | //Separate McastGemId is derived from OMCI-lib-go, if not needed first needs to be removed there. |
| 481 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].gemPortID = mcastGemID |
Holger Hildebrandt | 5ba6c13 | 2022-10-06 13:53:14 +0000 | [diff] [blame] | 482 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].direction = cGemDirAniToUni |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 483 | |
| 484 | if downstreamContent.AesEncryption == "True" { |
| 485 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].gemPortEncState = 1 |
| 486 | } else { |
| 487 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].gemPortEncState = 0 |
| 488 | } |
| 489 | |
| 490 | // expected Prio-Queue values 0..7 with 7 for highest PrioQueue, QueueIndex=Prio = 0..7 |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 491 | if downstreamContent.PriorityQ > 7 { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 492 | logger.Errorw(ctx, "PonAniConfig reject on GemPortList - PrioQueue value invalid", |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 493 | log.Fields{"device-id": onuTP.deviceID, "index": mcastGemID, "PrioQueue": downstreamContent.PriorityQ}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 494 | //remove PonAniConfig as done so far, delete map should be safe, even if not existing |
| 495 | delete(onuTP.mapPonAniConfig, uniTPKey) |
| 496 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
| 497 | return |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 498 | } |
| 499 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].prioQueueIndex = |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 500 | uint8(downstreamContent.PriorityQ) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 501 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].pbitString = |
| 502 | strings.TrimPrefix(downstreamContent.PbitMap, binaryStringPrefix) |
| 503 | |
| 504 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].discardPolicy = |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 505 | downstreamContent.DiscardPolicy.String() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 506 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].queueSchedPolicy = |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 507 | downstreamContent.SchedulingPolicy.String() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 508 | //'GemWeight' looks strange in default profile, for now we just copy the weight to first queue |
| 509 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].queueWeight = |
| 510 | uint8(downstreamContent.Weight) |
| 511 | |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 512 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].isMulticast = isMulticast |
| 513 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].multicastGemPortID = |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 514 | uint16(downstreamContent.MulticastGemId) |
| 515 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].staticACL = downstreamContent.StaticAccessControlList |
| 516 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].dynamicACL = downstreamContent.DynamicAccessControlList |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | } |
| 520 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 521 | if !loGemPortRead { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 522 | logger.Errorw(ctx, "PonAniConfig reject - no GemPort could be read from TechProfile", |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 523 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 524 | //remove PonAniConfig as done so far, delete map should be safe, even if not existing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 525 | delete(onuTP.mapPonAniConfig, uniTPKey) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 526 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 527 | return |
| 528 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 529 | //logger does not simply output the given structures, just give some example debug values |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 530 | logger.Debugw(ctx, "PonAniConfig read from TechProfile", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 531 | "device-id": onuTP.deviceID, "uni-id": aUniID, |
| 532 | "AllocId": onuTP.mapPonAniConfig[uniTPKey].tcontParams.allocID}) |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 533 | for gemPortID, gemEntry := range onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 534 | logger.Debugw(ctx, "PonAniConfig read from TechProfile", log.Fields{ |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 535 | "GemPort": gemPortID, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 536 | "QueueScheduling": gemEntry.queueSchedPolicy}) |
| 537 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 538 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 539 | onuTP.chTpConfigProcessingStep <- aProcessingStep //done |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 540 | } |
| 541 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 542 | func (onuTP *OnuUniTechProf) setAniSideConfigFromTechProfile( |
| 543 | ctx context.Context, aUniID uint8, aTpID uint8, apCurrentUniPort *cmn.OnuUniPort, aProcessingStep uint8) error { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 544 | |
| 545 | //OMCI transfer of ANI data acc. to mapPonAniConfig |
| 546 | // also the FSM's are running in background, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 547 | // hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 548 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 549 | if onuTP.PAniConfigFsm == nil { |
| 550 | return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, cmn.OmciAniConfigDone, aProcessingStep) |
| 551 | } else if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok { |
| 552 | return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, cmn.OmciAniConfigDone, aProcessingStep) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 553 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 554 | //AniConfigFsm already init |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 555 | return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 558 | // DeleteTpResource removes Resources from the ONU's specified Uni |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 559 | // nolint: gocyclo |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 560 | func (onuTP *OnuUniTechProf) DeleteTpResource(ctx context.Context, |
| 561 | aUniID uint8, aTpID uint8, aPathString string, aResource ResourceEntry, aEntryID uint32, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 562 | wg *sync.WaitGroup) { |
| 563 | defer wg.Done() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 564 | logger.Debugw(ctx, "will remove TP resources from ONU's UNI", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 565 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "Resource": aResource}) |
| 566 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 567 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 568 | if CResourceGemPort == aResource { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 569 | logger.Debugw(ctx, "remove GemPort from the list of existing ones of the TP", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 570 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "GemPort": aEntryID}) |
| 571 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 572 | //ensure read protection for access to mapPonAniConfig |
| 573 | onuTP.mutexTPState.RLock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 574 | // check if the requested GemPort exists in the DB, indicate it to the FSM |
| 575 | // store locally to remove it from DB later on success |
| 576 | pLocAniConfigOnUni := onuTP.mapPonAniConfig[uniTPKey] |
| 577 | if pLocAniConfigOnUni == nil { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 578 | onuTP.mutexTPState.RUnlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 579 | // No relevant entry exists anymore - acknowledge success |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 580 | logger.Debugw(ctx, "AniConfig or GemEntry do not exists in DB", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 581 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 582 | return |
| 583 | } |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 584 | onuTP.mutexTPState.RUnlock() |
| 585 | |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 586 | for gemPortID, gemEntry := range pLocAniConfigOnUni.mapGemPortParams { |
| 587 | if gemPortID == uint16(aEntryID) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 588 | //GemEntry to be deleted found |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 589 | gemEntry.removeGemID = gemPortID //store the index for later removal |
| 590 | onuTP.mapRemoveGemEntry[uniTPKey] = pLocAniConfigOnUni.mapGemPortParams[gemPortID] |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 591 | logger.Debugw(ctx, "Remove-GemEntry stored", log.Fields{ |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 592 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "GemPort": aEntryID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 593 | break //abort loop, always only one GemPort to remove |
| 594 | } |
| 595 | } |
| 596 | if onuTP.mapRemoveGemEntry[uniTPKey] == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 597 | logger.Errorw(ctx, "GemPort removal aborted - GemPort not found", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 598 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "GemPort": aEntryID}) |
| 599 | /* Do not set some error indication to the outside system interface on delete |
| 600 | assume there is nothing to be deleted internally and hope a new config request will recover the situation |
| 601 | onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: GemPort not found %d for %d on %s", |
| 602 | aEntryID, aUniID, onuTP.deviceID) |
| 603 | */ |
| 604 | return |
| 605 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 606 | if onuTP.baseDeviceHandler.IsReadyForOmciConfig() { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 607 | // check that the TpConfigRequest was done before |
| 608 | // -> that is implicitly done using the AniConfigFsm, |
| 609 | // which must be in the according state to remove something |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 610 | if onuTP.PAniConfigFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 611 | logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 612 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 613 | /* Do not set some error indication to the outside system interface on delete (see above) |
| 614 | onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: no AniConfigFsm available %d on %s", |
| 615 | aUniID, onuTP.deviceID) |
| 616 | */ |
| 617 | //if the FSM is not valid, also TP related remove data should not be valid: |
| 618 | // remove GemPort from config DB |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 619 | //ensure write protection for access to mapPonAniConfig |
| 620 | onuTP.mutexTPState.Lock() |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 621 | delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 622 | // remove the removeEntry |
| 623 | delete(onuTP.mapRemoveGemEntry, uniTPKey) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 624 | onuTP.mutexTPState.Unlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 625 | return |
| 626 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 627 | if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 628 | logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available for this uni/tp", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 629 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 630 | /* Do not set some error indication to the outside system interface on delete (see above) |
| 631 | onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: no AniConfigFsm available %d on %s for tpid", |
| 632 | aUniID, onuTP.deviceID, aTpID) |
| 633 | */ |
| 634 | //if the FSM is not valid, also TP related remove data should not be valid: |
| 635 | // remove GemPort from config DB |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 636 | //ensure write protection for access to mapPonAniConfig |
| 637 | onuTP.mutexTPState.Lock() |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 638 | delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 639 | // remove the removeEntry |
| 640 | delete(onuTP.mapRemoveGemEntry, uniTPKey) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 641 | onuTP.mutexTPState.Unlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 642 | return |
| 643 | } |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 644 | if onuTP.getProfileResetting(uniTPKey) { |
| 645 | logger.Debugw(ctx, "aborting GemRemoval on FSM, reset requested in parallel", log.Fields{ |
| 646 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 647 | //ensure write protection for access to mapPonAniConfig |
| 648 | onuTP.mutexTPState.Lock() |
| 649 | delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID) |
| 650 | // remove the removeEntry |
| 651 | delete(onuTP.mapRemoveGemEntry, uniTPKey) |
| 652 | onuTP.mutexTPState.Unlock() |
| 653 | return |
| 654 | } |
| 655 | // initiate OMCI GemPort related removal |
| 656 | var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep |
| 657 | // hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 658 | if nil != onuTP.runAniConfigFsm(ctx, aniEvRemGemiw, processingStep, aUniID, aTpID) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 659 | //even if the FSM invocation did not work we don't indicate a problem within procResult |
| 660 | //errors could exist also because there was nothing to delete - so we just accept that as 'deleted' |
| 661 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 662 | return |
| 663 | } |
| 664 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 665 | //timeout or error detected (included wanted cancellation after e.g. disable device (FsmReset)) |
| 666 | logger.Warnw(ctx, "GemPort removal aborted - Omci AniSideConfig failed", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 667 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 668 | //even if the FSM delete execution did not work we don't indicate a problem within procResult |
| 669 | //we should never respond to delete with error ... |
| 670 | //this issue here means that the AniConfigFsm has not finished successfully |
| 671 | //which requires to reset it to allow for new usage, e.g. also on a different UNI |
| 672 | //(without that it would be reset on device down indication latest) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 673 | if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok { |
| 674 | _ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 675 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 676 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 677 | return |
| 678 | } |
| 679 | } else { |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 680 | //if we can't do the OMCI processing we also suppress the ProcStatusUpdate |
| 681 | //this is needed as in the device-down case where all FSM's are getting reset and internal data gets cleared |
| 682 | //as a consequence a possible remove-flow does not see any dependency on the TechProfile anymore and is executed (pro forma) directly |
| 683 | //a later TechProfile removal would cause the device-reason to be updated to 'techProfile-delete-success' which is not the expected state |
| 684 | // and anyway is no real useful information at that stage |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 685 | logger.Debugw(ctx, "UniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{ |
| 686 | "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.GetDeviceReasonString()}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 687 | } |
| 688 | // remove GemPort from config DB |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 689 | //ensure write protection for access to mapPonAniConfig |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 690 | logger.Debugw(ctx, "UniPonAniConfigFsm removing gem from config data and clearing ani FSM", log.Fields{ |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 691 | "device-id": onuTP.deviceID, "gem-id": onuTP.mapRemoveGemEntry[uniTPKey].removeGemID, "uniTPKey": uniTPKey}) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 692 | onuTP.mutexTPState.Lock() |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 693 | delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 694 | // remove the removeEntry |
| 695 | delete(onuTP.mapRemoveGemEntry, uniTPKey) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 696 | onuTP.mutexTPState.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 697 | } else { //if CResourceTcont == aResource { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 698 | logger.Debugw(ctx, "reset TCont with AllocId", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 699 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "allocId": aEntryID}) |
| 700 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 701 | //ensure read protection for access to mapPonAniConfig |
| 702 | onuTP.mutexTPState.RLock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 703 | // check if the TCont with the indicated AllocId exists in the DB, indicate its EntityId to the FSM |
| 704 | pLocAniConfigOnUni := onuTP.mapPonAniConfig[uniTPKey] |
| 705 | if pLocAniConfigOnUni == nil { |
| 706 | // No relevant entry exists anymore - acknowledge success |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 707 | onuTP.mutexTPState.RUnlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 708 | logger.Debugw(ctx, "AniConfig or TCont entry do not exists in DB", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 709 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 710 | return |
| 711 | } |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 712 | onuTP.mutexTPState.RUnlock() |
| 713 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 714 | if pLocAniConfigOnUni.tcontParams.allocID != uint16(aEntryID) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 715 | logger.Errorw(ctx, "TCont removal aborted - indicated AllocId not found", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 716 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "AllocId": aEntryID}) |
| 717 | /* Do not set some error indication to the outside system interface on delete |
| 718 | assume there is nothing to be deleted internally and hope a new config request will recover the situation |
| 719 | onuTP.procResult[uniTpKey] = fmt.Errorf("TCont removal aborted: AllocId not found %d for %d on %s", |
| 720 | aEntryID, aUniID, onuTP.deviceID) |
| 721 | */ |
| 722 | return |
| 723 | } |
| 724 | //T-Cont to be reset found |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 725 | logger.Debugw(ctx, "Reset-T-Cont AllocId found - valid", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 726 | "device-id": onuTP.deviceID, "uni-id": aUniID, "AllocId": aEntryID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 727 | if onuTP.PAniConfigFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 728 | logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 729 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 730 | /* Do not set some error indication to the outside system interface on delete (see above) |
| 731 | onuTP.procResult[uniTpKey] = fmt.Errorf("TCont cleanup aborted: no AniConfigFsm available %d on %s", |
| 732 | aUniID, onuTP.deviceID) |
| 733 | */ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 734 | return |
| 735 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 736 | if _, ok := onuTP.PAniConfigFsm[uniTPKey]; !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 737 | logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available for this uni/tp", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 738 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 739 | //even if the FSM invocation did not work we don't indicate a problem within procResult |
| 740 | //errors could exist also because there was nothing to delete - so we just accept that as 'deleted' |
| 741 | //if the FSM is not valid, also TP related data should not be valid - clear the internal store profile data |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 742 | return |
| 743 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 744 | if onuTP.baseDeviceHandler.IsReadyForOmciConfig() { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 745 | // check that the TpConfigRequest was done before |
| 746 | // -> that is implicitly done using the AniConfigFsm, |
| 747 | // which must be in the according state to remove something |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 748 | if onuTP.getProfileResetting(uniTPKey) { |
| 749 | logger.Debugw(ctx, "aborting TCont removal on FSM, reset requested in parallel", log.Fields{ |
| 750 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 751 | return |
| 752 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 753 | // initiate OMCI TCont related cleanup |
| 754 | var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep |
| 755 | // hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 756 | if nil != onuTP.runAniConfigFsm(ctx, aniEvRemTcontPath, processingStep, aUniID, aTpID) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 757 | //even if the FSM invocation did not work we don't indicate a problem within procResult |
| 758 | //errors could exist also because there was nothing to delete - so we just accept that as 'deleted' |
| 759 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 760 | return |
| 761 | } |
| 762 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 763 | //timeout or error detected (included wanted cancellation after e.g. disable device (FsmReset)) |
| 764 | logger.Warnw(ctx, "TCont cleanup aborted - Omci AniSideConfig failed", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 765 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 766 | //even if the FSM delete execution did not work we don't indicate a problem within procResult |
| 767 | //we should never respond to delete with error ... |
| 768 | //this issue here means that the AniConfigFsm has not finished successfully |
| 769 | //which requires to reset it to allow for new usage, e.g. also on a different UNI |
| 770 | //(without that it would be reset on device down indication latest) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 771 | if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok { |
| 772 | _ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 773 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 774 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 775 | return |
| 776 | } |
| 777 | } else { |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 778 | //see gemPort comments |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 779 | logger.Debugw(ctx, "UniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{ |
| 780 | "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.GetDeviceReasonString()}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 781 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 782 | } |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 783 | |
| 784 | } |
| 785 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 786 | // IsTechProfileConfigCleared - TODO: add comment |
| 787 | func (onuTP *OnuUniTechProf) IsTechProfileConfigCleared(ctx context.Context, uniID uint8, tpID uint8) bool { |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 788 | uniTPKey := uniTP{uniID: uniID, tpID: tpID} |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 789 | logger.Debugw(ctx, "IsTechProfileConfigCleared", log.Fields{"device-id": onuTP.deviceID}) |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 790 | if onuTP.mapPonAniConfig[uniTPKey] != nil { |
| 791 | mapGemPortParams := onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams |
| 792 | unicastGemCount := 0 |
| 793 | for _, gemEntry := range mapGemPortParams { |
| 794 | if !gemEntry.isMulticast { |
| 795 | unicastGemCount++ |
| 796 | } |
| 797 | } |
| 798 | if unicastGemCount == 0 || onuTP.mapPonAniConfig[uniTPKey].tcontParams.allocID == 0 { |
| 799 | logger.Debugw(ctx, "clearing-ani-side-config", log.Fields{ |
| 800 | "device-id": onuTP.deviceID, "uniTpKey": uniTPKey}) |
| 801 | onuTP.clearAniSideConfig(ctx, uniID, tpID) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 802 | if _, ok := onuTP.PAniConfigFsm[uniTPKey]; ok { |
| 803 | _ = onuTP.PAniConfigFsm[uniTPKey].PAdaptFsm.PFsm.Event(aniEvReset) |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 804 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 805 | go onuTP.baseDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OmciAniResourceRemoved) |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 806 | return true |
| 807 | } |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 808 | } |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 809 | return false |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 810 | } |
| 811 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 812 | func (onuTP *OnuUniTechProf) waitForTimeoutOrCompletion( |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 813 | ctx context.Context, aChTpProcessingStep <-chan uint8, aProcessingStep uint8) bool { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 814 | select { |
| 815 | case <-ctx.Done(): |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 816 | logger.Warnw(ctx, "processing not completed in-time: force release of TpProcMutex!", |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 817 | log.Fields{"device-id": onuTP.deviceID, "error": ctx.Err()}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 818 | return false |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 819 | case rxStep := <-aChTpProcessingStep: |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 820 | if rxStep == aProcessingStep { |
| 821 | return true |
| 822 | } |
| 823 | //all other values are not accepted - including 0 for error indication |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 824 | logger.Warnw(ctx, "Invalid processing step received: abort and force release of TpProcMutex!", |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 825 | log.Fields{"device-id": onuTP.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 826 | "wantedStep": aProcessingStep, "haveStep": rxStep}) |
| 827 | return false |
| 828 | } |
| 829 | } |
| 830 | |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 831 | // createAniConfigFsm initializes and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 832 | func (onuTP *OnuUniTechProf) createAniConfigFsm(ctx context.Context, aUniID uint8, aTpID uint8, |
| 833 | apCurrentUniPort *cmn.OnuUniPort, devEvent cmn.OnuDeviceEvent, aProcessingStep uint8) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 834 | logger.Debugw(ctx, "createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 835 | chAniConfigFsm := make(chan cmn.Message, 2048) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 836 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 837 | if onuTP.onuDevice == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 838 | logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 839 | return fmt.Errorf("no valid OnuDevice: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 840 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 841 | pAniCfgFsm := NewUniPonAniConfigFsm(ctx, onuTP.onuDevice.GetDevOmciCC(), apCurrentUniPort, onuTP, |
Holger Hildebrandt | c408f49 | 2022-07-14 08:39:24 +0000 | [diff] [blame] | 842 | onuTP.onuDevice.GetOnuDB(), aTpID, onuTP.mapUniTpIndication[uniTPKey].techProfileType, devEvent, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 843 | "AniConfigFsm", onuTP.baseDeviceHandler, onuTP.onuDevice, chAniConfigFsm) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 844 | if pAniCfgFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 845 | logger.Errorw(ctx, "AniConfigFSM could not be created - abort!!", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 846 | return fmt.Errorf("could not create AniConfigFSM: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 847 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 848 | if onuTP.PAniConfigFsm == nil { |
| 849 | onuTP.PAniConfigFsm = make(map[uniTP]*UniPonAniConfigFsm) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 850 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 851 | onuTP.PAniConfigFsm[uniTPKey] = pAniCfgFsm |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 852 | return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 853 | } |
| 854 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 855 | // runAniConfigFsm starts the AniConfig FSM to transfer the OMCI related commands for ANI side configuration |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 856 | func (onuTP *OnuUniTechProf) runAniConfigFsm(ctx context.Context, aEvent string, aProcessingStep uint8, aUniID uint8, aTpID uint8) error { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 857 | /* Uni related ANI config procedure - |
| 858 | ***** should run via 'aniConfigDone' state and generate the argument requested event ***** |
| 859 | */ |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 860 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 861 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 862 | pACStatemachine := onuTP.PAniConfigFsm[uniTpKey].PAdaptFsm.PFsm |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 863 | if pACStatemachine != nil { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 864 | if aEvent == aniEvStart { |
| 865 | if !pACStatemachine.Is(aniStDisabled) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 866 | logger.Errorw(ctx, "wrong state of AniConfigFSM to start - want: Disabled", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 867 | "have": pACStatemachine.Current(), "device-id": onuTP.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 868 | // maybe try a FSM reset and then again ... - TODO: add comment!!! |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 869 | return fmt.Errorf("wrong state of AniConfigFSM to start: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 870 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 871 | } else if !pACStatemachine.Is(aniStConfigDone) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 872 | logger.Errorw(ctx, "wrong state of AniConfigFSM to remove - want: ConfigDone", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 873 | "have": pACStatemachine.Current(), "device-id": onuTP.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 874 | return fmt.Errorf("wrong state of AniConfigFSM to remove: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 875 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 876 | //FSM init requirement to get informed about FSM completion! (otherwise timeout of the TechProf config) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 877 | onuTP.PAniConfigFsm[uniTpKey].setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 878 | if err := pACStatemachine.Event(aEvent); err != nil { |
Holger Hildebrandt | abfef03 | 2022-02-25 12:40:20 +0000 | [diff] [blame] | 879 | logger.Errorw(ctx, "AniConfigFSM: can't trigger event", log.Fields{"device-id": onuTP.deviceID, "err": err}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 880 | return fmt.Errorf("can't trigger event in AniConfigFSM: %s", onuTP.deviceID) |
| 881 | } |
| 882 | /***** AniConfigFSM event notified */ |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 883 | logger.Debugw(ctx, "AniConfigFSM event notified", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 884 | "state": pACStatemachine.Current(), "device-id": onuTP.deviceID, "event": aEvent}) |
| 885 | return nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 886 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 887 | logger.Errorw(ctx, "AniConfigFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": onuTP.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 888 | // maybe try a FSM reset and then again ... - TODO: add comment!!! |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 889 | return fmt.Errorf("stateMachine AniConfigFSM invalid: %s", onuTP.deviceID) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 890 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 891 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 892 | // clearAniSideConfig deletes internal TechProfile related data connected to the requested UniPort and TpID |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 893 | func (onuTP *OnuUniTechProf) clearAniSideConfig(ctx context.Context, aUniID uint8, aTpID uint8) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 894 | logger.Debugw(ctx, "removing TpIndication and PonAniConfig data", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 895 | "device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 896 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 897 | |
| 898 | onuTP.mutexTPState.Lock() |
| 899 | defer onuTP.mutexTPState.Unlock() |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 900 | //deleting a map entry should be safe, even if not existing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 901 | delete(onuTP.mapUniTpIndication, uniTpKey) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 902 | delete(onuTP.mapPonAniConfig, uniTpKey) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 903 | delete(onuTP.procResult, uniTpKey) |
| 904 | delete(onuTP.tpProfileExists, uniTpKey) |
| 905 | delete(onuTP.tpProfileResetting, uniTpKey) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 906 | } |
| 907 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 908 | // setConfigDone sets the requested techProfile config state (if possible) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 909 | func (onuTP *OnuUniTechProf) setConfigDone(aUniID uint8, aTpID uint8, aState bool) { |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 910 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 911 | onuTP.mutexTPState.Lock() |
| 912 | defer onuTP.mutexTPState.Unlock() |
| 913 | if _, existTP := onuTP.mapUniTpIndication[uniTpKey]; existTP { |
| 914 | onuTP.mapUniTpIndication[uniTpKey].techProfileConfigDone = aState |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 915 | } //else: the state is just ignored (does not exist) |
| 916 | } |
| 917 | |
| 918 | // getTechProfileDone checks if the Techprofile processing with the requested TechProfile ID was done |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 919 | func (onuTP *OnuUniTechProf) getTechProfileDone(ctx context.Context, aUniID uint8, aTpID uint8) bool { |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 920 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 921 | onuTP.mutexTPState.RLock() |
| 922 | defer onuTP.mutexTPState.RUnlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 923 | if _, existTP := onuTP.mapUniTpIndication[uniTpKey]; existTP { |
| 924 | if onuTP.mapUniTpIndication[uniTpKey].techProfileID == aTpID { |
| 925 | if onuTP.mapUniTpIndication[uniTpKey].techProfileToDelete { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 926 | logger.Debugw(ctx, "TechProfile not relevant for requested flow config - waiting on delete", |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 927 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 928 | return false //still waiting for removal of this techProfile first |
| 929 | } |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 930 | return onuTP.mapUniTpIndication[uniTpKey].techProfileConfigDone |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 931 | } |
| 932 | } |
| 933 | //for all other constellations indicate false = Config not done |
| 934 | return false |
| 935 | } |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 936 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 937 | // SetProfileToDelete sets the requested techProfile toDelete state (if possible) |
| 938 | func (onuTP *OnuUniTechProf) SetProfileToDelete(aUniID uint8, aTpID uint8, aState bool) { |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 939 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 940 | onuTP.mutexTPState.Lock() |
| 941 | defer onuTP.mutexTPState.Unlock() |
| 942 | if _, existTP := onuTP.mapUniTpIndication[uniTpKey]; existTP { |
| 943 | onuTP.mapUniTpIndication[uniTpKey].techProfileToDelete = aState |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 944 | } //else: the state is just ignored (does not exist) |
| 945 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 946 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 947 | func (onuTP *OnuUniTechProf) getMulticastGemPorts(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 948 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 949 | onuTP.mutexTPState.RLock() |
| 950 | defer onuTP.mutexTPState.RUnlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 951 | gemPortIds := make([]uint16, 0) |
| 952 | if techProfile, existTP := onuTP.mapPonAniConfig[uniTpKey]; existTP { |
| 953 | for _, gemPortParam := range techProfile.mapGemPortParams { |
| 954 | if gemPortParam.isMulticast { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 955 | logger.Debugw(ctx, "Detected multicast gemPort", log.Fields{"device-id": onuTP.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 956 | "aUniID": aUniID, "aTPID": aTpID, "uniTPKey": uniTpKey, |
| 957 | "mcastGemId": gemPortParam.multicastGemPortID}) |
| 958 | gemPortIds = append(gemPortIds, gemPortParam.multicastGemPortID) |
| 959 | } |
| 960 | } |
| 961 | } //else: the state is just ignored (does not exist) |
| 962 | return gemPortIds |
| 963 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 964 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 965 | func (onuTP *OnuUniTechProf) getBidirectionalGemPortIDsForTP(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 { |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 966 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 967 | onuTP.mutexTPState.RLock() |
| 968 | defer onuTP.mutexTPState.RUnlock() |
| 969 | gemPortIds := make([]uint16, 0) |
| 970 | if techProfile, existTP := onuTP.mapPonAniConfig[uniTpKey]; existTP { |
| 971 | logger.Debugw(ctx, "TechProfile exist", log.Fields{"device-id": onuTP.deviceID}) |
| 972 | for _, gemPortParam := range techProfile.mapGemPortParams { |
| 973 | if !gemPortParam.isMulticast { |
| 974 | logger.Debugw(ctx, "Detected unicast gemPort", log.Fields{"device-id": onuTP.deviceID, |
| 975 | "aUniID": aUniID, "aTPID": aTpID, "uniTPKey": uniTpKey, |
| 976 | "GemId": gemPortParam.multicastGemPortID}) |
| 977 | gemPortIds = append(gemPortIds, gemPortParam.gemPortID) |
| 978 | } |
| 979 | } |
| 980 | } else { |
| 981 | logger.Debugw(ctx, "TechProfile doesn't exist", log.Fields{"device-id": onuTP.deviceID}) |
| 982 | } //else: the state is just ignored (does not exist) |
| 983 | logger.Debugw(ctx, "Gem PortID list", log.Fields{"device-id": onuTP.deviceID, "gemportList": gemPortIds}) |
| 984 | return gemPortIds |
| 985 | } |
| 986 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 987 | // GetAllBidirectionalGemPortIDsForOnu - TODO: add comment |
| 988 | func (onuTP *OnuUniTechProf) GetAllBidirectionalGemPortIDsForOnu() []uint16 { |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 989 | var gemPortInstIDs []uint16 |
| 990 | onuTP.mutexTPState.RLock() |
| 991 | defer onuTP.mutexTPState.RUnlock() |
| 992 | for _, tcontGemList := range onuTP.mapPonAniConfig { |
| 993 | for gemPortID, gemPortData := range tcontGemList.mapGemPortParams { |
| 994 | if gemPortData != nil && !gemPortData.isMulticast { // only if not multicast gem port |
| 995 | gemPortInstIDs = append(gemPortInstIDs, gemPortID) |
| 996 | } |
| 997 | } |
| 998 | } |
| 999 | return gemPortInstIDs |
| 1000 | } |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 1001 | |
Holger Hildebrandt | 5ba6c13 | 2022-10-06 13:53:14 +0000 | [diff] [blame] | 1002 | // GetNumberOfConfiguredUsGemPorts - provides the number of Gem ports for each UNI/TP combination |
| 1003 | func (onuTP *OnuUniTechProf) GetNumberOfConfiguredUsGemPorts(ctx context.Context) int { |
| 1004 | onuTP.mutexTPState.RLock() |
| 1005 | defer onuTP.mutexTPState.RUnlock() |
| 1006 | usGemPorts := make([]uint16, 0) |
| 1007 | for _, tcontGemList := range onuTP.mapPonAniConfig { |
| 1008 | for gemPortID, gemPortParams := range tcontGemList.mapGemPortParams { |
| 1009 | if gemPortParams.direction == cGemDirBiDirect || gemPortParams.direction == cGemDirUniToAni { |
| 1010 | alreadyConfigured := false |
| 1011 | for _, foundUsGemPortID := range usGemPorts { |
| 1012 | if foundUsGemPortID == gemPortID { |
| 1013 | alreadyConfigured = true |
| 1014 | break |
| 1015 | } |
| 1016 | } |
| 1017 | if !alreadyConfigured { |
| 1018 | usGemPorts = append(usGemPorts, gemPortID) |
| 1019 | } |
| 1020 | } |
| 1021 | } |
| 1022 | } |
| 1023 | return len(usGemPorts) |
| 1024 | } |
| 1025 | |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 1026 | // setProfileResetting sets/resets the indication, that a reset of the TechProfileConfig/Removal is ongoing |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1027 | func (onuTP *OnuUniTechProf) setProfileResetting(ctx context.Context, aUniID uint8, aTpID uint8, aState bool) { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 1028 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 1029 | onuTP.mutexTPState.Lock() |
| 1030 | defer onuTP.mutexTPState.Unlock() |
| 1031 | onuTP.tpProfileResetting[uniTpKey] = aState |
| 1032 | } |
| 1033 | |
| 1034 | // getProfileResetting returns true, if the the according indication for started reset procedure is set |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1035 | func (onuTP *OnuUniTechProf) getProfileResetting(aUniTpKey uniTP) bool { |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 1036 | onuTP.mutexTPState.RLock() |
| 1037 | defer onuTP.mutexTPState.RUnlock() |
| 1038 | if isResetting, exist := onuTP.tpProfileResetting[aUniTpKey]; exist { |
| 1039 | return isResetting |
| 1040 | } |
| 1041 | return false |
| 1042 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 1043 | |
| 1044 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 1045 | func (onuTP *OnuUniTechProf) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 1046 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 1047 | onuTP.baseDeviceHandler = nil |
| 1048 | onuTP.onuDevice = nil |
| 1049 | for k, v := range onuTP.PAniConfigFsm { |
| 1050 | v.PrepareForGarbageCollection(ctx, aDeviceID) |
| 1051 | delete(onuTP.PAniConfigFsm, k) |
| 1052 | } |
| 1053 | } |