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