mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
| 19 | |
| 20 | import ( |
| 21 | "context" |
| 22 | "encoding/json" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 23 | "errors" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 24 | "fmt" |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 25 | "strconv" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 26 | "strings" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 27 | "sync" |
| 28 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 29 | "github.com/opencord/voltha-lib-go/v4/pkg/db" |
| 30 | "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore" |
| 31 | "github.com/opencord/voltha-lib-go/v4/pkg/log" |
| 32 | tp "github.com/opencord/voltha-lib-go/v4/pkg/techprofile" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 33 | ) |
| 34 | |
Matteo Scandolo | f1f39a7 | 2020-11-24 12:08:11 -0800 | [diff] [blame] | 35 | const cBasePathTechProfileKVStore = "%s/technology_profiles" |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 36 | |
| 37 | //definitions for TechProfileProcessing - copied from OltAdapter:openolt_flowmgr.go |
| 38 | // could perhaps be defined more globally |
| 39 | const ( |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 40 | // binaryStringPrefix is binary string prefix |
| 41 | binaryStringPrefix = "0b" |
| 42 | // binaryBit1 is binary bit 1 expressed as a character |
| 43 | //binaryBit1 = '1' |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 44 | ) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 45 | |
| 46 | type resourceEntry int |
| 47 | |
| 48 | const ( |
| 49 | cResourceGemPort resourceEntry = 1 |
| 50 | cResourceTcont resourceEntry = 2 |
| 51 | ) |
| 52 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 53 | type tTechProfileIndication struct { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 54 | techProfileType string |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 55 | techProfileID uint8 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 56 | techProfileConfigDone bool |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 57 | techProfileToDelete bool |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | type tcontParamStruct struct { |
| 61 | allocID uint16 |
| 62 | schedPolicy uint8 |
| 63 | } |
| 64 | type gemPortParamStruct struct { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 65 | //ponOmciCC bool |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 66 | gemPortID uint16 |
| 67 | direction uint8 |
| 68 | gemPortEncState uint8 |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 69 | prioQueueIndex uint8 |
| 70 | pbitString string |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 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 |
| 75 | queueWeight uint8 |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 76 | removeGemID uint16 |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 77 | isMulticast bool |
| 78 | //TODO check if this has any value/difference from gemPortId |
| 79 | multicastGemPortID uint16 |
| 80 | staticACL string |
| 81 | dynamicACL string |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | //refers to one tcont and its properties and all assigned GemPorts and their properties |
| 85 | type tcontGemList struct { |
| 86 | tcontParams tcontParamStruct |
| 87 | mapGemPortParams map[uint16]*gemPortParamStruct |
| 88 | } |
| 89 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 90 | // refers a unique combination of uniID and tpID for a given ONU. |
| 91 | type uniTP struct { |
| 92 | uniID uint8 |
| 93 | tpID uint8 |
| 94 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 95 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 96 | //onuUniTechProf structure holds information about the TechProfiles attached to Uni Ports of the ONU |
| 97 | type onuUniTechProf struct { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 98 | baseDeviceHandler *deviceHandler |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 99 | deviceID string |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 100 | tpProcMutex sync.RWMutex |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 101 | techProfileKVStore *db.Backend |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 102 | chTpConfigProcessingStep chan uint8 |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 103 | mapUniTpIndication map[uniTP]*tTechProfileIndication //use pointer values to ease assignments to the map |
| 104 | mapPonAniConfig map[uniTP]*tcontGemList //per UNI: use pointer values to ease assignments to the map |
| 105 | pAniConfigFsm map[uniTP]*uniPonAniConfigFsm |
| 106 | procResult map[uniTP]error //error indication of processing |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 107 | mutexTPState sync.Mutex |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 108 | tpProfileExists map[uniTP]bool |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 109 | mapRemoveGemEntry map[uniTP]*gemPortParamStruct //per UNI: pointer to GemEntry to be removed |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 112 | //newOnuUniTechProf returns the instance of a OnuUniTechProf |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 113 | //(one instance per ONU/deviceHandler for all possible UNI's) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 114 | func newOnuUniTechProf(ctx context.Context, aDeviceHandler *deviceHandler) *onuUniTechProf { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 115 | logger.Debugw(ctx, "init-OnuUniTechProf", log.Fields{"device-id": aDeviceHandler.deviceID}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 116 | var onuTP onuUniTechProf |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 117 | onuTP.baseDeviceHandler = aDeviceHandler |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 118 | onuTP.deviceID = aDeviceHandler.deviceID |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 119 | onuTP.tpProcMutex = sync.RWMutex{} |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 120 | onuTP.chTpConfigProcessingStep = make(chan uint8) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 121 | onuTP.mapUniTpIndication = make(map[uniTP]*tTechProfileIndication) |
| 122 | onuTP.mapPonAniConfig = make(map[uniTP]*tcontGemList) |
| 123 | onuTP.procResult = make(map[uniTP]error) |
| 124 | onuTP.tpProfileExists = make(map[uniTP]bool) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 125 | onuTP.mapRemoveGemEntry = make(map[uniTP]*gemPortParamStruct) |
Matteo Scandolo | f1f39a7 | 2020-11-24 12:08:11 -0800 | [diff] [blame] | 126 | baseKvStorePath := fmt.Sprintf(cBasePathTechProfileKVStore, aDeviceHandler.pOpenOnuAc.cm.Backend.PathPrefix) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 127 | onuTP.techProfileKVStore = aDeviceHandler.setBackend(ctx, baseKvStorePath) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 128 | if onuTP.techProfileKVStore == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 129 | logger.Errorw(ctx, "Can't access techProfileKVStore - no backend connection to service", |
Matteo Scandolo | f1f39a7 | 2020-11-24 12:08:11 -0800 | [diff] [blame] | 130 | log.Fields{"device-id": aDeviceHandler.deviceID, "service": baseKvStorePath}) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 131 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 132 | |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 133 | return &onuTP |
| 134 | } |
| 135 | |
| 136 | // lockTpProcMutex locks OnuUniTechProf processing mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 137 | func (onuTP *onuUniTechProf) lockTpProcMutex() { |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 138 | onuTP.tpProcMutex.Lock() |
| 139 | } |
| 140 | |
| 141 | // unlockTpProcMutex unlocks OnuUniTechProf processing mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 142 | func (onuTP *onuUniTechProf) unlockTpProcMutex() { |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 143 | onuTP.tpProcMutex.Unlock() |
| 144 | } |
| 145 | |
Holger Hildebrandt | 47555e7 | 2020-09-21 11:07:24 +0000 | [diff] [blame] | 146 | // resetTpProcessingErrorIndication resets the internal error indication |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 147 | // need to be called before evaluation of any subsequent processing (given by waitForTpCompletion()) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 148 | func (onuTP *onuUniTechProf) resetTpProcessingErrorIndication(aUniID uint8, aTpID uint8) { |
| 149 | onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}] = nil |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 152 | func (onuTP *onuUniTechProf) getTpProcessingErrorIndication(aUniID uint8, aTpID uint8) error { |
| 153 | return onuTP.procResult[uniTP{uniID: aUniID, tpID: aTpID}] |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 154 | } |
| 155 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 156 | // 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] | 157 | // all possibly blocking processing must be run in background to allow for deadline supervision! |
| 158 | // but take care on sequential background processing when needed (logical dependencies) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 159 | // use waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) for internal synchronization |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 160 | func (onuTP *onuUniTechProf) configureUniTp(ctx context.Context, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 161 | aUniID uint8, aPathString string, wg *sync.WaitGroup) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 162 | defer wg.Done() //always decrement the waitGroup on return |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 163 | logger.Debugw(ctx, "configure the Uni according to TpPath", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 164 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 165 | tpID, err := GetTpIDFromTpPath(aPathString) |
| 166 | uniTpKey := uniTP{uniID: aUniID, tpID: tpID} |
| 167 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 168 | 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] | 169 | return |
| 170 | } |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 171 | if onuTP.techProfileKVStore == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 172 | logger.Errorw(ctx, "techProfileKVStore not set - abort", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 173 | log.Fields{"device-id": onuTP.deviceID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 174 | onuTP.procResult[uniTpKey] = errors.New("techProfile config aborted: techProfileKVStore not set") |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 175 | return |
| 176 | } |
| 177 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 178 | //ensure that the given uniID is available (configured) in the UniPort class (used for OMCI entities) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 179 | var pCurrentUniPort *onuUniPort |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 180 | for _, uniPort := range onuTP.baseDeviceHandler.uniEntityMap { |
| 181 | // only if this port is validated for operState transfer |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 182 | if uniPort.uniID == aUniID { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 183 | pCurrentUniPort = uniPort |
| 184 | break //found - end search loop |
| 185 | } |
| 186 | } |
| 187 | if pCurrentUniPort == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 188 | logger.Errorw(ctx, "TechProfile configuration aborted: requested uniID not found in PortDB", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 189 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 190 | 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] | 191 | aUniID, onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 192 | return |
| 193 | } |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 194 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 195 | var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 196 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 197 | //according to updateOnuUniTpPath() logic the assumption here is, that this configuration is only called |
| 198 | // in case the KVPath has changed for the given UNI, |
| 199 | // as T-Cont and Gem-Id's are dependent on TechProfile-Id this means, that possibly previously existing |
| 200 | // (ANI) configuration of this port has to be removed first |
| 201 | // (moreover in this case a possibly existing flow configuration is also not valid anymore and needs clean-up as well) |
| 202 | // existence of configuration can be detected based on tp stored TCONT's |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 203 | //TODO: |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 204 | /* if tcontMap not empty { |
| 205 | go onuTP.deleteAniSideConfig(ctx, aUniID, processingStep) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 206 | if !onuTP.waitForTimeoutOrCompletion(ctx, chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 207 | //timeout or error detected |
| 208 | return |
| 209 | } |
| 210 | clear tcontMap |
| 211 | } |
| 212 | |
| 213 | processingStep++ |
| 214 | */ |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 215 | go onuTP.readAniSideConfigFromTechProfile(ctx, aUniID, tpID, aPathString, processingStep) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 216 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 217 | //timeout or error detected |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 218 | if onuTP.tpProfileExists[uniTpKey] { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 219 | //ignore the internal error in case the new profile is already configured |
| 220 | // and abort the processing here |
| 221 | return |
| 222 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 223 | logger.Errorw(ctx, "tech-profile related configuration aborted on read", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 224 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 225 | 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] | 226 | aUniID, onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 227 | return |
| 228 | } |
| 229 | |
| 230 | processingStep++ |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 231 | |
| 232 | valuePA, existPA := onuTP.mapPonAniConfig[uniTpKey] |
| 233 | |
| 234 | if existPA { |
| 235 | if valuePA != nil { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 236 | //Config data for this uni and and at least TCont Index 0 exist |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 237 | if err := onuTP.setAniSideConfigFromTechProfile(ctx, aUniID, tpID, pCurrentUniPort, processingStep); err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 238 | logger.Errorw(ctx, "tech-profile related FSM could not be started", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 239 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 240 | onuTP.procResult[uniTpKey] = err |
| 241 | return |
| 242 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 243 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 244 | //timeout or error detected |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 245 | logger.Errorw(ctx, "tech-profile related configuration aborted on set", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 246 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 247 | |
| 248 | 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] | 249 | aUniID, onuTP.deviceID) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 250 | //this issue here means that the AniConfigFsm has not finished successfully |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 251 | //which requires to reset it to allow for new usage, e.g. also on a different UNI |
| 252 | //(without that it would be reset on device down indication latest) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 253 | _ = onuTP.pAniConfigFsm[uniTpKey].pAdaptFsm.pFsm.Event(aniEvReset) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 254 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 255 | } |
| 256 | } else { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 257 | // 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] | 258 | 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] | 259 | "device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 260 | |
| 261 | 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] | 262 | aUniID, onuTP.deviceID) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 263 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 264 | } |
| 265 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 266 | logger.Errorw(ctx, "no PonAni data for this UNI found - abort", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 267 | "device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 268 | |
| 269 | 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] | 270 | aUniID, onuTP.deviceID) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 271 | return |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 275 | /* internal methods *********************/ |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 276 | // nolint: gocyclo |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 277 | func (onuTP *onuUniTechProf) readAniSideConfigFromTechProfile( |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 278 | ctx context.Context, aUniID uint8, aTpID uint8, aPathString string, aProcessingStep uint8) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 279 | var tpInst tp.TechProfile |
| 280 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 281 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 282 | |
| 283 | onuTP.tpProfileExists[uniTP{uniID: aUniID, tpID: aTpID}] = false |
| 284 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 285 | //store profile type and identifier for later usage within the OMCI identifier and possibly ME setup |
| 286 | //pathstring is defined to be in the form of <ProfType>/<profID>/<Interface/../Identifier> |
| 287 | subStringSlice := strings.Split(aPathString, "/") |
| 288 | if len(subStringSlice) <= 2 { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 289 | logger.Errorw(ctx, "invalid path name format", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 290 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 291 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 292 | return |
| 293 | } |
| 294 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 295 | //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] | 296 | //expectation is that no TPIndication entry exists here, if exists and with the same TPId |
| 297 | // then we throw a warning, set an internal error and abort with error, |
| 298 | // which is later re-defined to success response to OLT adapter |
| 299 | // if TPId has changed, current data is removed (note that the ONU config state may be |
| 300 | // ambivalent in such a case) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 301 | if _, existTP := onuTP.mapUniTpIndication[uniTPKey]; existTP { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 302 | logger.Warnw(ctx, "Some active profile entry at reading new TechProfile", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 303 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID, |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 304 | "uni-id": aUniID, "wrongProfile": onuTP.mapUniTpIndication[uniTPKey].techProfileID}) |
| 305 | if aTpID == onuTP.mapUniTpIndication[uniTPKey].techProfileID { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 306 | // ProfId not changed - assume profile to be still the same |
| 307 | // anyway this should not appear after full support of profile (Gem/TCont) removal |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 308 | logger.Warnw(ctx, "New TechProfile already exists - aborting configuration", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 309 | log.Fields{"device-id": onuTP.deviceID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 310 | onuTP.tpProfileExists[uniTPKey] = true |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 311 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
| 312 | return |
| 313 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 314 | //delete on the mapUniTpIndication map not needed, just overwritten later |
| 315 | //delete on the PonAniConfig map should be safe, even if not existing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 316 | delete(onuTP.mapPonAniConfig, uniTPKey) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 317 | } else { |
| 318 | // this is normal processing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 319 | onuTP.mapUniTpIndication[uniTPKey] = &tTechProfileIndication{} //need to assign some (empty) struct memory first! |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 320 | } |
| 321 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 322 | onuTP.mapUniTpIndication[uniTPKey].techProfileType = subStringSlice[0] |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 323 | //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] | 324 | onuTP.mapUniTpIndication[uniTPKey].techProfileID = aTpID |
| 325 | onuTP.mapUniTpIndication[uniTPKey].techProfileConfigDone = false |
| 326 | onuTP.mapUniTpIndication[uniTPKey].techProfileToDelete = false |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 327 | logger.Debugw(ctx, "tech-profile path indications", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 328 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 329 | "profType": onuTP.mapUniTpIndication[uniTPKey].techProfileType, |
| 330 | "profID": onuTP.mapUniTpIndication[uniTPKey].techProfileID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 331 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 332 | Value, err := onuTP.techProfileKVStore.Get(ctx, aPathString) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 333 | if err == nil { |
| 334 | if Value != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 335 | logger.Debugw(ctx, "tech-profile read", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 336 | log.Fields{"Key": Value.Key, "device-id": onuTP.deviceID}) |
| 337 | tpTmpBytes, _ := kvstore.ToByte(Value.Value) |
| 338 | |
| 339 | if err = json.Unmarshal(tpTmpBytes, &tpInst); err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 340 | logger.Errorw(ctx, "TechProf - Failed to unmarshal tech-profile into tpInst", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 341 | log.Fields{"error": err, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 342 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 343 | return |
| 344 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 345 | logger.Debugw(ctx, "TechProf - tpInst", log.Fields{"tpInst": tpInst}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 346 | // access examples |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 347 | logger.Debugw(ctx, "TechProf content", log.Fields{"Name": tpInst.Name, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 348 | "MaxGemPayloadSize": tpInst.InstanceCtrl.MaxGemPayloadSize, |
| 349 | "DownstreamGemDiscardmaxThreshold": tpInst.DownstreamGemPortAttributeList[0].DiscardConfig.MaxThreshold}) |
| 350 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 351 | logger.Errorw(ctx, "No tech-profile found", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 352 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 353 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 354 | return |
| 355 | } |
| 356 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 357 | logger.Errorw(ctx, "kvstore-get failed for path", |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 358 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 359 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 360 | return |
| 361 | } |
| 362 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 363 | //default start with 1Tcont profile, later perhaps extend to MultiTcontMultiGem |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 364 | localMapGemPortParams := make(map[uint16]*gemPortParamStruct) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 365 | onuTP.mapPonAniConfig[uniTPKey] = &tcontGemList{tcontParamStruct{}, localMapGemPortParams} |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 366 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 367 | //note: the code is currently restricted to one TCcont per Onu (index [0]) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 368 | //get the relevant values from the profile and store to mapPonAniConfig |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 369 | onuTP.mapPonAniConfig[uniTPKey].tcontParams.allocID = uint16(tpInst.UsScheduler.AllocID) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 370 | //maybe tCont scheduling not (yet) needed - just to basically have it for future |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 371 | // (would only be relevant in case of ONU-2G QOS configuration flexibility) |
| 372 | if tpInst.UsScheduler.QSchedPolicy == "StrictPrio" { |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 373 | 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] | 374 | } else { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 375 | //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] | 376 | onuTP.mapPonAniConfig[uniTPKey].tcontParams.schedPolicy = 2 //for G.988 WRR |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 377 | } |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 378 | loNumGemPorts := tpInst.NumGemPorts |
| 379 | loGemPortRead := false |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 380 | for pos, content := range tpInst.UpstreamGemPortAttributeList { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 381 | if uint32(pos) == loNumGemPorts { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 382 | logger.Debugw(ctx, "PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts", |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 383 | log.Fields{"device-id": onuTP.deviceID, "index": pos, "NumGem": loNumGemPorts}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 384 | break |
| 385 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 386 | if pos == 0 { |
| 387 | //at least one upstream GemPort should always exist (else traffic profile makes no sense) |
| 388 | loGemPortRead = true |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 389 | } |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 390 | //for all GemPorts we need to extend the mapGemPortParams |
| 391 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)] = &gemPortParamStruct{} |
| 392 | |
| 393 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].gemPortID = |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 394 | uint16(content.GemportID) |
| 395 | //direction can be correlated later with Downstream list, |
| 396 | // for now just assume bidirectional (upstream never exists alone) |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 397 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].direction = 3 //as defined in G.988 |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 398 | // expected Prio-Queue values 0..7 with 7 for highest PrioQueue, QueueIndex=Prio = 0..7 |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 399 | if content.PriorityQueue > 7 { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 400 | logger.Errorw(ctx, "PonAniConfig reject on GemPortList - PrioQueue value invalid", |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 401 | log.Fields{"device-id": onuTP.deviceID, "index": pos, "PrioQueue": content.PriorityQueue}) |
| 402 | //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] | 403 | delete(onuTP.mapPonAniConfig, uniTPKey) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 404 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 405 | return |
| 406 | } |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 407 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].prioQueueIndex = |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 408 | uint8(content.PriorityQueue) |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 409 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].pbitString = |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 410 | strings.TrimPrefix(content.PbitMap, binaryStringPrefix) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 411 | if content.AesEncryption == "True" { |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 412 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].gemPortEncState = 1 |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 413 | } else { |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 414 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].gemPortEncState = 0 |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 415 | } |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 416 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].discardPolicy = |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 417 | content.DiscardPolicy |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 418 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].queueSchedPolicy = |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 419 | content.SchedulingPolicy |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 420 | //'GemWeight' looks strange in default profile, for now we just copy the weight to first queue |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 421 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[uint16(content.GemportID)].queueWeight = |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 422 | uint8(content.Weight) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 423 | } |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 424 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 425 | for _, downstreamContent := range tpInst.DownstreamGemPortAttributeList { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 426 | logger.Debugw(ctx, "Operating on Downstream Gem Port", log.Fields{"downstream-gem": downstreamContent}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 427 | //Commenting this out due to faliure, needs investigation |
| 428 | //if uint32(pos) == loNumGemPorts { |
| 429 | // logger.Debugw("PonAniConfig abort GemPortList - GemList exceeds set NumberOfGemPorts", |
| 430 | // log.Fields{"device-id": onuTP.deviceID, "index": pos, "NumGem": loNumGemPorts}) |
| 431 | // break |
| 432 | //} |
| 433 | isMulticast := false |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 434 | //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] | 435 | if downstreamContent.IsMulticast != "" { |
| 436 | isMulticast, err = strconv.ParseBool(downstreamContent.IsMulticast) |
| 437 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 438 | logger.Errorw(ctx, "multicast-error-config-unknown-flag-in-technology-profile", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 439 | log.Fields{"UniTpKey": uniTPKey, "downstream-gem": downstreamContent, "error": err}) |
| 440 | continue |
| 441 | } |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 442 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 443 | logger.Infow(ctx, "Gem Port is multicast", log.Fields{"isMulticast": isMulticast}) |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 444 | if isMulticast { |
| 445 | mcastGemID := uint16(downstreamContent.McastGemID) |
| 446 | _, existing := onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID] |
| 447 | if existing { |
| 448 | //GEM port was previously configured, avoid setting multicast attributes |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 449 | logger.Errorw(ctx, "multicast-error-config-existing-gem-port-config", log.Fields{"UniTpKey": uniTPKey, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 450 | "downstream-gem": downstreamContent, "key": mcastGemID}) |
| 451 | continue |
| 452 | } else { |
| 453 | //GEM port is not configured, setting multicast attributes |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 454 | logger.Infow(ctx, "creating-multicast-gem-port", log.Fields{"uniTpKey": uniTPKey, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 455 | "gemPortId": mcastGemID, "key": mcastGemID}) |
| 456 | |
| 457 | //for all further GemPorts we need to extend the mapGemPortParams |
| 458 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID] = &gemPortParamStruct{} |
| 459 | |
| 460 | //Separate McastGemId is derived from OMCI-lib-go, if not needed first needs to be removed there. |
| 461 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].gemPortID = mcastGemID |
| 462 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].direction = 2 // for ANI to UNI as defined in G.988 |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 463 | |
| 464 | if downstreamContent.AesEncryption == "True" { |
| 465 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].gemPortEncState = 1 |
| 466 | } else { |
| 467 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].gemPortEncState = 0 |
| 468 | } |
| 469 | |
| 470 | // expected Prio-Queue values 0..7 with 7 for highest PrioQueue, QueueIndex=Prio = 0..7 |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 471 | if downstreamContent.PriorityQueue > 7 { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 472 | logger.Errorw(ctx, "PonAniConfig reject on GemPortList - PrioQueue value invalid", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 473 | log.Fields{"device-id": onuTP.deviceID, "index": mcastGemID, "PrioQueue": downstreamContent.PriorityQueue}) |
| 474 | //remove PonAniConfig as done so far, delete map should be safe, even if not existing |
| 475 | delete(onuTP.mapPonAniConfig, uniTPKey) |
| 476 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
| 477 | return |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 478 | } |
| 479 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].prioQueueIndex = |
| 480 | uint8(downstreamContent.PriorityQueue) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 481 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].pbitString = |
| 482 | strings.TrimPrefix(downstreamContent.PbitMap, binaryStringPrefix) |
| 483 | |
| 484 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].discardPolicy = |
| 485 | downstreamContent.DiscardPolicy |
| 486 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].queueSchedPolicy = |
| 487 | downstreamContent.SchedulingPolicy |
| 488 | //'GemWeight' looks strange in default profile, for now we just copy the weight to first queue |
| 489 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].queueWeight = |
| 490 | uint8(downstreamContent.Weight) |
| 491 | |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 492 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].isMulticast = isMulticast |
| 493 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].multicastGemPortID = |
| 494 | uint16(downstreamContent.McastGemID) |
| 495 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].staticACL = downstreamContent.SControlList |
| 496 | onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams[mcastGemID].dynamicACL = downstreamContent.DControlList |
| 497 | } |
| 498 | } |
| 499 | } |
| 500 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 501 | if !loGemPortRead { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 502 | logger.Errorw(ctx, "PonAniConfig reject - no GemPort could be read from TechProfile", |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 503 | log.Fields{"path": aPathString, "device-id": onuTP.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 504 | //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] | 505 | delete(onuTP.mapPonAniConfig, uniTPKey) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 506 | onuTP.chTpConfigProcessingStep <- 0 //error indication |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 507 | return |
| 508 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 509 | //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] | 510 | logger.Debugw(ctx, "PonAniConfig read from TechProfile", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 511 | "device-id": onuTP.deviceID, "uni-id": aUniID, |
| 512 | "AllocId": onuTP.mapPonAniConfig[uniTPKey].tcontParams.allocID}) |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 513 | for gemPortID, gemEntry := range onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 514 | logger.Debugw(ctx, "PonAniConfig read from TechProfile", log.Fields{ |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 515 | "GemPort": gemPortID, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 516 | "QueueScheduling": gemEntry.queueSchedPolicy}) |
| 517 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 518 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 519 | onuTP.chTpConfigProcessingStep <- aProcessingStep //done |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 522 | func (onuTP *onuUniTechProf) setAniSideConfigFromTechProfile( |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 523 | ctx context.Context, aUniID uint8, aTpID uint8, apCurrentUniPort *onuUniPort, aProcessingStep uint8) error { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 524 | |
| 525 | //OMCI transfer of ANI data acc. to mapPonAniConfig |
| 526 | // also the FSM's are running in background, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 527 | // hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 528 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 529 | if onuTP.pAniConfigFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 530 | return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 531 | } else if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 532 | return onuTP.createAniConfigFsm(ctx, aUniID, aTpID, apCurrentUniPort, OmciAniConfigDone, aProcessingStep) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 533 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 534 | //AniConfigFsm already init |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 535 | return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | // deleteTpResource removes Resources from the ONU's specified Uni |
| 539 | func (onuTP *onuUniTechProf) deleteTpResource(ctx context.Context, |
| 540 | aUniID uint8, aTpID uint8, aPathString string, aResource resourceEntry, aEntryID uint32, |
| 541 | wg *sync.WaitGroup) { |
| 542 | defer wg.Done() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 543 | logger.Debugw(ctx, "will remove TP resources from ONU's UNI", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 544 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "Resource": aResource}) |
| 545 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 546 | |
| 547 | if cResourceGemPort == aResource { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 548 | 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] | 549 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "GemPort": aEntryID}) |
| 550 | |
| 551 | // check if the requested GemPort exists in the DB, indicate it to the FSM |
| 552 | // store locally to remove it from DB later on success |
| 553 | pLocAniConfigOnUni := onuTP.mapPonAniConfig[uniTPKey] |
| 554 | if pLocAniConfigOnUni == nil { |
| 555 | // No relevant entry exists anymore - acknowledge success |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 556 | logger.Debugw(ctx, "AniConfig or GemEntry do not exists in DB", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 557 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 558 | return |
| 559 | } |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 560 | for gemPortID, gemEntry := range pLocAniConfigOnUni.mapGemPortParams { |
| 561 | if gemPortID == uint16(aEntryID) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 562 | //GemEntry to be deleted found |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 563 | gemEntry.removeGemID = gemPortID //store the index for later removal |
| 564 | onuTP.mapRemoveGemEntry[uniTPKey] = pLocAniConfigOnUni.mapGemPortParams[gemPortID] |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 565 | logger.Debugw(ctx, "Remove-GemEntry stored", log.Fields{ |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 566 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "GemPort": aEntryID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 567 | break //abort loop, always only one GemPort to remove |
| 568 | } |
| 569 | } |
| 570 | if onuTP.mapRemoveGemEntry[uniTPKey] == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 571 | logger.Errorw(ctx, "GemPort removal aborted - GemPort not found", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 572 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "GemPort": aEntryID}) |
| 573 | /* Do not set some error indication to the outside system interface on delete |
| 574 | assume there is nothing to be deleted internally and hope a new config request will recover the situation |
| 575 | onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: GemPort not found %d for %d on %s", |
| 576 | aEntryID, aUniID, onuTP.deviceID) |
| 577 | */ |
| 578 | return |
| 579 | } |
| 580 | if onuTP.baseDeviceHandler.ReadyForSpecificOmciConfig { |
| 581 | // check that the TpConfigRequest was done before |
| 582 | // -> that is implicitly done using the AniConfigFsm, |
| 583 | // which must be in the according state to remove something |
| 584 | // initiate OMCI GemPort related removal |
| 585 | var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep |
| 586 | // hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep |
| 587 | if onuTP.pAniConfigFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 588 | logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 589 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 590 | /* Do not set some error indication to the outside system interface on delete (see above) |
| 591 | onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: no AniConfigFsm available %d on %s", |
| 592 | aUniID, onuTP.deviceID) |
| 593 | */ |
| 594 | //if the FSM is not valid, also TP related remove data should not be valid: |
| 595 | // remove GemPort from config DB |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 596 | delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 597 | // remove the removeEntry |
| 598 | delete(onuTP.mapRemoveGemEntry, uniTPKey) |
| 599 | return |
| 600 | } |
| 601 | if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 602 | logger.Errorw(ctx, "abort GemPort removal - no AniConfigFsm available for this uni/tp", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 603 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 604 | /* Do not set some error indication to the outside system interface on delete (see above) |
| 605 | onuTP.procResult[uniTpKey] = fmt.Errorf("GemPort removal aborted: no AniConfigFsm available %d on %s for tpid", |
| 606 | aUniID, onuTP.deviceID, aTpID) |
| 607 | */ |
| 608 | //if the FSM is not valid, also TP related remove data should not be valid: |
| 609 | // remove GemPort from config DB |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 610 | delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 611 | // remove the removeEntry |
| 612 | delete(onuTP.mapRemoveGemEntry, uniTPKey) |
| 613 | return |
| 614 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 615 | if nil != onuTP.runAniConfigFsm(ctx, aniEvRemGemiw, processingStep, aUniID, aTpID) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 616 | //even if the FSM invocation did not work we don't indicate a problem within procResult |
| 617 | //errors could exist also because there was nothing to delete - so we just accept that as 'deleted' |
| 618 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 619 | return |
| 620 | } |
| 621 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
| 622 | //timeout or error detected |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 623 | logger.Errorw(ctx, "GemPort removal aborted - Omci AniSideConfig failed", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 624 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 625 | //even if the FSM delete execution did not work we don't indicate a problem within procResult |
| 626 | //we should never respond to delete with error ... |
| 627 | //this issue here means that the AniConfigFsm has not finished successfully |
| 628 | //which requires to reset it to allow for new usage, e.g. also on a different UNI |
| 629 | //(without that it would be reset on device down indication latest) |
| 630 | _ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset) |
| 631 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 632 | return |
| 633 | } |
| 634 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 635 | logger.Debugw(ctx, "uniPonAniConfigFsm delete Gem on OMCI skipped based on device state", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 636 | "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.deviceReason}) |
| 637 | } |
| 638 | // remove GemPort from config DB |
Himani Chawla | 1c13690 | 2020-12-10 16:30:59 +0530 | [diff] [blame] | 639 | delete(onuTP.mapPonAniConfig[uniTPKey].mapGemPortParams, onuTP.mapRemoveGemEntry[uniTPKey].removeGemID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 640 | // remove the removeEntry |
| 641 | delete(onuTP.mapRemoveGemEntry, uniTPKey) |
| 642 | // deviceHandler StatusEvent (reason update) (see end of function) is only generated in case some element really was removed |
| 643 | } else { //if cResourceTcont == aResource { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 644 | logger.Debugw(ctx, "reset TCont with AllocId", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 645 | "device-id": onuTP.deviceID, "uni-id": aUniID, "path": aPathString, "allocId": aEntryID}) |
| 646 | |
| 647 | // check if the TCont with the indicated AllocId exists in the DB, indicate its EntityId to the FSM |
| 648 | pLocAniConfigOnUni := onuTP.mapPonAniConfig[uniTPKey] |
| 649 | if pLocAniConfigOnUni == nil { |
| 650 | // No relevant entry exists anymore - acknowledge success |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 651 | 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] | 652 | "device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 653 | return |
| 654 | } |
| 655 | if pLocAniConfigOnUni.tcontParams.allocID != uint16(aEntryID) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 656 | logger.Errorw(ctx, "TCont removal aborted - indicated AllocId not found", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 657 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID, "AllocId": aEntryID}) |
| 658 | /* Do not set some error indication to the outside system interface on delete |
| 659 | assume there is nothing to be deleted internally and hope a new config request will recover the situation |
| 660 | onuTP.procResult[uniTpKey] = fmt.Errorf("TCont removal aborted: AllocId not found %d for %d on %s", |
| 661 | aEntryID, aUniID, onuTP.deviceID) |
| 662 | */ |
| 663 | return |
| 664 | } |
| 665 | //T-Cont to be reset found |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 666 | logger.Debugw(ctx, "Reset-T-Cont AllocId found - valid", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 667 | "device-id": onuTP.deviceID, "uni-id": aUniID, "AllocId": aEntryID}) |
| 668 | if onuTP.pAniConfigFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 669 | logger.Errorw(ctx, "no TCont removal on OMCI - no AniConfigFsm available", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 670 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 671 | /* Do not set some error indication to the outside system interface on delete (see above) |
| 672 | onuTP.procResult[uniTpKey] = fmt.Errorf("TCont cleanup aborted: no AniConfigFsm available %d on %s", |
| 673 | aUniID, onuTP.deviceID) |
| 674 | */ |
| 675 | //if the FSM is not valid, also TP related data should not be valid - clear the internal store profile data |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 676 | onuTP.clearAniSideConfig(ctx, aUniID, aTpID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 677 | return |
| 678 | } |
| 679 | if _, ok := onuTP.pAniConfigFsm[uniTPKey]; !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 680 | 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] | 681 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID, "tp-id": aTpID}) |
| 682 | //even if the FSM invocation did not work we don't indicate a problem within procResult |
| 683 | //errors could exist also because there was nothing to delete - so we just accept that as 'deleted' |
| 684 | //if the FSM is not valid, also TP related data should not be valid - clear the internal store profile data |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 685 | onuTP.clearAniSideConfig(ctx, aUniID, aTpID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 686 | return |
| 687 | } |
| 688 | if onuTP.baseDeviceHandler.ReadyForSpecificOmciConfig { |
| 689 | // check that the TpConfigRequest was done before |
| 690 | // -> that is implicitly done using the AniConfigFsm, |
| 691 | // which must be in the according state to remove something |
| 692 | // initiate OMCI TCont related cleanup |
| 693 | var processingStep uint8 = 1 // used to synchronize the different processing steps with chTpConfigProcessingStep |
| 694 | // hence we have to make sure they indicate 'success' on chTpConfigProcessingStep with aProcessingStep |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 695 | if nil != onuTP.runAniConfigFsm(ctx, aniEvRemTcontPath, processingStep, aUniID, aTpID) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 696 | //even if the FSM invocation did not work we don't indicate a problem within procResult |
| 697 | //errors could exist also because there was nothing to delete - so we just accept that as 'deleted' |
| 698 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 699 | return |
| 700 | } |
| 701 | if !onuTP.waitForTimeoutOrCompletion(ctx, onuTP.chTpConfigProcessingStep, processingStep) { |
| 702 | //timeout or error detected |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 703 | logger.Errorw(ctx, "TCont cleanup aborted - Omci AniSideConfig failed", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 704 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 705 | //even if the FSM delete execution did not work we don't indicate a problem within procResult |
| 706 | //we should never respond to delete with error ... |
| 707 | //this issue here means that the AniConfigFsm has not finished successfully |
| 708 | //which requires to reset it to allow for new usage, e.g. also on a different UNI |
| 709 | //(without that it would be reset on device down indication latest) |
| 710 | _ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset) |
| 711 | //TP related data cleared by FSM error treatment or re-used by FSM error-recovery (if implemented) |
| 712 | return |
| 713 | } |
| 714 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 715 | logger.Debugw(ctx, "uniPonAniConfigFsm TCont cleanup on OMCI skipped based on device state", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 716 | "device-id": onuTP.deviceID, "device-state": onuTP.baseDeviceHandler.deviceReason}) |
| 717 | } |
| 718 | //clear the internal store profile data |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 719 | onuTP.clearAniSideConfig(ctx, aUniID, aTpID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 720 | // reset also the FSM in order to admit a new OMCI configuration in case a new profile is created |
| 721 | // FSM stop maybe encapsulated as OnuTP method - perhaps later in context of module splitting |
| 722 | _ = onuTP.pAniConfigFsm[uniTPKey].pAdaptFsm.pFsm.Event(aniEvReset) |
| 723 | } |
| 724 | // generate deviceHandler StatusEvent in case the FSM was not invoked |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 725 | go onuTP.baseDeviceHandler.deviceProcStatusUpdate(ctx, OmciAniResourceRemoved) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 728 | func (onuTP *onuUniTechProf) waitForTimeoutOrCompletion( |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 729 | ctx context.Context, aChTpProcessingStep <-chan uint8, aProcessingStep uint8) bool { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 730 | select { |
| 731 | case <-ctx.Done(): |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 732 | logger.Warnw(ctx, "processing not completed in-time: force release of TpProcMutex!", |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 733 | log.Fields{"device-id": onuTP.deviceID, "error": ctx.Err()}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 734 | return false |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 735 | case rxStep := <-aChTpProcessingStep: |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 736 | if rxStep == aProcessingStep { |
| 737 | return true |
| 738 | } |
| 739 | //all other values are not accepted - including 0 for error indication |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 740 | logger.Warnw(ctx, "Invalid processing step received: abort and force release of TpProcMutex!", |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 741 | log.Fields{"device-id": onuTP.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 742 | "wantedStep": aProcessingStep, "haveStep": rxStep}) |
| 743 | return false |
| 744 | } |
| 745 | } |
| 746 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 747 | // createUniLockFsm initializes and runs the AniConfig FSM to transfer the OMCI related commands for ANI side configuration |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 748 | func (onuTP *onuUniTechProf) createAniConfigFsm(ctx context.Context, aUniID uint8, aTpID uint8, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 749 | apCurrentUniPort *onuUniPort, devEvent OnuDeviceEvent, aProcessingStep uint8) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 750 | logger.Debugw(ctx, "createAniConfigFsm", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 751 | chAniConfigFsm := make(chan Message, 2048) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 752 | uniTPKey := uniTP{uniID: aUniID, tpID: aTpID} |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 753 | pDevEntry := onuTP.baseDeviceHandler.getOnuDeviceEntry(ctx, true) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 754 | if pDevEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 755 | logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 756 | return fmt.Errorf("no valid OnuDevice: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 757 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 758 | pAniCfgFsm := newUniPonAniConfigFsm(ctx, pDevEntry.PDevOmciCC, apCurrentUniPort, onuTP, |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 759 | pDevEntry.pOnuDB, aTpID, devEvent, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 760 | "AniConfigFsm", onuTP.baseDeviceHandler, chAniConfigFsm) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 761 | if pAniCfgFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 762 | 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] | 763 | return fmt.Errorf("could not create AniConfigFSM: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 764 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 765 | if onuTP.pAniConfigFsm == nil { |
| 766 | onuTP.pAniConfigFsm = make(map[uniTP]*uniPonAniConfigFsm) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 767 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 768 | onuTP.pAniConfigFsm[uniTPKey] = pAniCfgFsm |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 769 | return onuTP.runAniConfigFsm(ctx, aniEvStart, aProcessingStep, aUniID, aTpID) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 770 | } |
| 771 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 772 | // runAniConfigFsm starts the AniConfig FSM to transfer the OMCI related commands for ANI side configuration |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 773 | 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] | 774 | /* Uni related ANI config procedure - |
| 775 | ***** should run via 'aniConfigDone' state and generate the argument requested event ***** |
| 776 | */ |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 777 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 778 | |
| 779 | pACStatemachine := onuTP.pAniConfigFsm[uniTpKey].pAdaptFsm.pFsm |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 780 | if pACStatemachine != nil { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 781 | if aEvent == aniEvStart { |
| 782 | if !pACStatemachine.Is(aniStDisabled) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 783 | logger.Errorw(ctx, "wrong state of AniConfigFSM to start - want: Disabled", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 784 | "have": pACStatemachine.Current(), "device-id": onuTP.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 785 | // maybe try a FSM reset and then again ... - TODO!!! |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 786 | return fmt.Errorf("wrong state of AniConfigFSM to start: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 787 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 788 | } else if !pACStatemachine.Is(aniStConfigDone) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 789 | logger.Errorw(ctx, "wrong state of AniConfigFSM to remove - want: ConfigDone", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 790 | "have": pACStatemachine.Current(), "device-id": onuTP.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 791 | return fmt.Errorf("wrong state of AniConfigFSM to remove: %s", onuTP.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 792 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 793 | //FSM init requirement to get informed about FSM completion! (otherwise timeout of the TechProf config) |
| 794 | onuTP.pAniConfigFsm[uniTpKey].setFsmCompleteChannel(onuTP.chTpConfigProcessingStep, aProcessingStep) |
| 795 | if err := pACStatemachine.Event(aEvent); err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 796 | logger.Errorw(ctx, "AniConfigFSM: can't trigger event", log.Fields{"err": err}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 797 | return fmt.Errorf("can't trigger event in AniConfigFSM: %s", onuTP.deviceID) |
| 798 | } |
| 799 | /***** AniConfigFSM event notified */ |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 800 | logger.Debugw(ctx, "AniConfigFSM event notified", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 801 | "state": pACStatemachine.Current(), "device-id": onuTP.deviceID, "event": aEvent}) |
| 802 | return nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 803 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 804 | logger.Errorw(ctx, "AniConfigFSM StateMachine invalid - cannot be executed!!", log.Fields{"device-id": onuTP.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 805 | // maybe try a FSM reset and then again ... - TODO!!! |
| 806 | return fmt.Errorf("stateMachine AniConfigFSM invalid: %s", onuTP.deviceID) |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 807 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 808 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 809 | // clearAniSideConfig deletes internal TechProfile related data connected to the requested UniPort and TpID |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 810 | func (onuTP *onuUniTechProf) clearAniSideConfig(ctx context.Context, aUniID uint8, aTpID uint8) { |
| 811 | logger.Debugw(ctx, "removing TpIndication and PonAniConfig data", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 812 | "device-id": onuTP.deviceID, "uni-id": aUniID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 813 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 814 | |
| 815 | onuTP.mutexTPState.Lock() |
| 816 | defer onuTP.mutexTPState.Unlock() |
| 817 | delete(onuTP.mapUniTpIndication, uniTpKey) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 818 | //delete on the PonAniConfig map of this UNI should be safe, even if not existing |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 819 | delete(onuTP.mapPonAniConfig, uniTpKey) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 820 | } |
| 821 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 822 | // setConfigDone sets the requested techProfile config state (if possible) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 823 | func (onuTP *onuUniTechProf) setConfigDone(aUniID uint8, aTpID uint8, aState bool) { |
| 824 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 825 | onuTP.mutexTPState.Lock() |
| 826 | defer onuTP.mutexTPState.Unlock() |
| 827 | if _, existTP := onuTP.mapUniTpIndication[uniTpKey]; existTP { |
| 828 | onuTP.mapUniTpIndication[uniTpKey].techProfileConfigDone = aState |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 829 | } //else: the state is just ignored (does not exist) |
| 830 | } |
| 831 | |
| 832 | // getTechProfileDone checks if the Techprofile processing with the requested TechProfile ID was done |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 833 | func (onuTP *onuUniTechProf) getTechProfileDone(ctx context.Context, aUniID uint8, aTpID uint8) bool { |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 834 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 835 | onuTP.mutexTPState.Lock() |
| 836 | defer onuTP.mutexTPState.Unlock() |
| 837 | if _, existTP := onuTP.mapUniTpIndication[uniTpKey]; existTP { |
| 838 | if onuTP.mapUniTpIndication[uniTpKey].techProfileID == aTpID { |
| 839 | if onuTP.mapUniTpIndication[uniTpKey].techProfileToDelete { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 840 | logger.Debugw(ctx, "TechProfile not relevant for requested flow config - waiting on delete", |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 841 | log.Fields{"device-id": onuTP.deviceID, "uni-id": aUniID}) |
| 842 | return false //still waiting for removal of this techProfile first |
| 843 | } |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 844 | return onuTP.mapUniTpIndication[uniTpKey].techProfileConfigDone |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 845 | } |
| 846 | } |
| 847 | //for all other constellations indicate false = Config not done |
| 848 | return false |
| 849 | } |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 850 | |
| 851 | // setProfileToDelete sets the requested techProfile toDelete state (if possible) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 852 | func (onuTP *onuUniTechProf) setProfileToDelete(aUniID uint8, aTpID uint8, aState bool) { |
| 853 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 854 | onuTP.mutexTPState.Lock() |
| 855 | defer onuTP.mutexTPState.Unlock() |
| 856 | if _, existTP := onuTP.mapUniTpIndication[uniTpKey]; existTP { |
| 857 | onuTP.mapUniTpIndication[uniTpKey].techProfileToDelete = aState |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 858 | } //else: the state is just ignored (does not exist) |
| 859 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 860 | |
| 861 | // setProfileToDelete sets the requested techProfile toDelete state (if possible) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 862 | func (onuTP *onuUniTechProf) getMulticastGemPorts(ctx context.Context, aUniID uint8, aTpID uint8) []uint16 { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 863 | uniTpKey := uniTP{uniID: aUniID, tpID: aTpID} |
| 864 | onuTP.mutexTPState.Lock() |
| 865 | defer onuTP.mutexTPState.Unlock() |
| 866 | gemPortIds := make([]uint16, 0) |
| 867 | if techProfile, existTP := onuTP.mapPonAniConfig[uniTpKey]; existTP { |
| 868 | for _, gemPortParam := range techProfile.mapGemPortParams { |
| 869 | if gemPortParam.isMulticast { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 870 | logger.Debugw(ctx, "Detected multicast gemPort", log.Fields{"device-id": onuTP.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 871 | "aUniID": aUniID, "aTPID": aTpID, "uniTPKey": uniTpKey, |
| 872 | "mcastGemId": gemPortParam.multicastGemPortID}) |
| 873 | gemPortIds = append(gemPortIds, gemPortParam.multicastGemPortID) |
| 874 | } |
| 875 | } |
| 876 | } //else: the state is just ignored (does not exist) |
| 877 | return gemPortIds |
| 878 | } |