mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1 | /* |
Joey Armstrong | e8c091f | 2023-01-17 16:56:26 -0500 | [diff] [blame] | 2 | * Copyright 2020-2023 Open Networking Foundation (ONF) and the ONF Contributors |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 17 | //Package avcfg provides anig and vlan configuration functionality |
| 18 | package avcfg |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "context" |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 22 | "encoding/binary" |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 23 | "fmt" |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 24 | "net" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 25 | "strconv" |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 26 | "sync" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 27 | "time" |
| 28 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 29 | "github.com/cevaris/ordered_map" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 30 | "github.com/looplab/fsm" |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 31 | "github.com/opencord/omci-lib-go/v2" |
| 32 | me "github.com/opencord/omci-lib-go/v2/generated" |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 33 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 34 | |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 35 | //ic "github.com/opencord/voltha-protos/v5/go/inter_container" |
| 36 | //"github.com/opencord/voltha-protos/v5/go/openflow_13" |
| 37 | //"github.com/opencord/voltha-protos/v5/go/voltha" |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 38 | cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common" |
| 39 | "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 40 | ) |
| 41 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 42 | const ( |
| 43 | // events of config PON ANI port FSM |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 44 | aniEvStart = "aniEvStart" |
| 45 | aniEvStartConfig = "aniEvStartConfig" |
| 46 | aniEvRxDot1pmapCResp = "aniEvRxDot1pmapCResp" |
| 47 | aniEvRxMbpcdResp = "aniEvRxMbpcdResp" |
| 48 | aniEvRxTcontsResp = "aniEvRxTcontsResp" |
| 49 | aniEvRxGemntcpsResp = "aniEvRxGemntcpsResp" |
| 50 | aniEvRxGemiwsResp = "aniEvRxGemiwsResp" |
| 51 | aniEvRxPrioqsResp = "aniEvRxPrioqsResp" |
| 52 | aniEvRxDot1pmapSResp = "aniEvRxDot1pmapSResp" |
| 53 | aniEvRemGemiw = "aniEvRemGemiw" |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 54 | aniEvWaitFlowRem = "aniEvWaitFlowRem" |
| 55 | aniEvFlowRemDone = "aniEvFlowRemDone" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 56 | aniEvRxRemGemiwResp = "aniEvRxRemGemiwResp" |
| 57 | aniEvRxRemGemntpResp = "aniEvRxRemGemntpResp" |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 58 | aniEvRxRemTdResp = "aniEvRxRemTdResp" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 59 | aniEvRemTcontPath = "aniEvRemTcontPath" |
| 60 | aniEvRxResetTcontResp = "aniEvRxResetTcontResp" |
| 61 | aniEvRxRem1pMapperResp = "aniEvRxRem1pMapperResp" |
| 62 | aniEvRxRemAniBPCDResp = "aniEvRxRemAniBPCDResp" |
| 63 | aniEvTimeoutSimple = "aniEvTimeoutSimple" |
| 64 | aniEvTimeoutMids = "aniEvTimeoutMids" |
| 65 | aniEvReset = "aniEvReset" |
| 66 | aniEvRestart = "aniEvRestart" |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 67 | aniEvSkipOmciConfig = "aniEvSkipOmciConfig" |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 68 | aniEvRemGemDone = "aniEvRemGemDone" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 69 | ) |
| 70 | const ( |
| 71 | // states of config PON ANI port FSM |
| 72 | aniStDisabled = "aniStDisabled" |
| 73 | aniStStarting = "aniStStarting" |
| 74 | aniStCreatingDot1PMapper = "aniStCreatingDot1PMapper" |
| 75 | aniStCreatingMBPCD = "aniStCreatingMBPCD" |
| 76 | aniStSettingTconts = "aniStSettingTconts" |
| 77 | aniStCreatingGemNCTPs = "aniStCreatingGemNCTPs" |
| 78 | aniStCreatingGemIWs = "aniStCreatingGemIWs" |
| 79 | aniStSettingPQs = "aniStSettingPQs" |
| 80 | aniStSettingDot1PMapper = "aniStSettingDot1PMapper" |
| 81 | aniStConfigDone = "aniStConfigDone" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 82 | aniStRemovingGemIW = "aniStRemovingGemIW" |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 83 | aniStWaitingFlowRem = "aniStWaitingFlowRem" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 84 | aniStRemovingGemNCTP = "aniStRemovingGemNCTP" |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 85 | aniStRemovingTD = "aniStRemovingTD" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 86 | aniStResetTcont = "aniStResetTcont" |
| 87 | aniStRemDot1PMapper = "aniStRemDot1PMapper" |
| 88 | aniStRemAniBPCD = "aniStRemAniBPCD" |
| 89 | aniStRemoveDone = "aniStRemoveDone" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 90 | aniStResetting = "aniStResetting" |
| 91 | ) |
| 92 | |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 93 | const ( |
| 94 | bitTrafficSchedulerPtrSetPermitted = 0x0002 // Refer section 9.1.2 ONU-2G, table for "Quality of service (QoS) configuration flexibility" IE |
| 95 | ) |
Holger Hildebrandt | c408f49 | 2022-07-14 08:39:24 +0000 | [diff] [blame] | 96 | const cTechProfileTypeXgsPon = "XGS-PON" |
| 97 | |
| 98 | // definitions as per G.988 |
| 99 | // Gem Encryption Key Ring |
| 100 | const ( |
| 101 | // No encryption. The downstream key index is ignored, and upstream traffic is transmitted with key index 0. |
| 102 | GemEncryptKeyRingNoEncrypt = 0 |
| 103 | // Unicast payload encryption in both directions. Keys are generated by the ONU and transmitted to the OLT via the PLOAM channel. |
| 104 | GemEncryptKeyRingUnicastPayload = 1 |
| 105 | // Broadcast (multicast) encryption. Keys are generated by the OLT and distributed via the OMCI. |
| 106 | GemEncryptKeyRingBroadcastMulticast = 2 |
| 107 | // Unicast encryption, downstream only. Keys are generated by the ONU and transmitted to the OLT via the PLOAM channel. |
| 108 | GemEncryptKeyRingUnicastDownstreamOnly = 3 |
| 109 | ) |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 110 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 111 | // CAniFsmIdleState - TODO: add comment |
| 112 | const CAniFsmIdleState = aniStConfigDone |
| 113 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 114 | type ponAniGemPortAttribs struct { |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 115 | gemPortID uint16 |
| 116 | upQueueID uint16 |
| 117 | downQueueID uint16 |
| 118 | direction uint8 |
| 119 | qosPolicy string |
| 120 | weight uint8 |
| 121 | pbitString string |
| 122 | isMulticast bool |
| 123 | multicastGemID uint16 |
| 124 | staticACL string |
| 125 | dynamicACL string |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 128 | //UniPonAniConfigFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI |
| 129 | type UniPonAniConfigFsm struct { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 130 | deviceID string |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 131 | pDeviceHandler cmn.IdeviceHandler |
| 132 | pOnuDeviceEntry cmn.IonuDeviceEntry |
| 133 | pOmciCC *cmn.OmciCC |
| 134 | pOnuUniPort *cmn.OnuUniPort |
| 135 | pUniTechProf *OnuUniTechProf |
| 136 | pOnuDB *devdb.OnuDeviceDB |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 137 | techProfileID uint8 |
Holger Hildebrandt | c408f49 | 2022-07-14 08:39:24 +0000 | [diff] [blame] | 138 | techProfileType string |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 139 | uniTpKey uniTP |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 140 | requestEvent cmn.OnuDeviceEvent |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 141 | mutexIsAwaitingResponse sync.RWMutex |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 142 | isCanceled bool |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 143 | isAwaitingResponse bool |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 144 | omciMIdsResponseReceived chan bool //separate channel needed for checking multiInstance OMCI message responses |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 145 | PAdaptFsm *cmn.AdapterFsm |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 146 | chSuccess chan<- uint8 |
| 147 | procStep uint8 |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 148 | mutexChanSet sync.RWMutex |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 149 | chanSet bool |
| 150 | mapperSP0ID uint16 |
| 151 | macBPCD0ID uint16 |
| 152 | tcont0ID uint16 |
| 153 | alloc0ID uint16 |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 154 | gemPortAttribsSlice []ponAniGemPortAttribs |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 155 | mutexPLastTxMeInstance sync.RWMutex |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 156 | pLastTxMeInstance *me.ManagedEntity |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 157 | requestEventOffset uint8 //used to indicate ConfigDone or Removed using successor (enum) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 158 | isWaitingForFlowDelete bool |
| 159 | waitFlowDeleteChannel chan bool |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 160 | tcontSetBefore bool |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 163 | //NewUniPonAniConfigFsm is the 'constructor' for the state machine to config the PON ANI ports of ONU UNI ports via OMCI |
| 164 | func NewUniPonAniConfigFsm(ctx context.Context, apDevOmciCC *cmn.OmciCC, apUniPort *cmn.OnuUniPort, apUniTechProf *OnuUniTechProf, |
Holger Hildebrandt | c408f49 | 2022-07-14 08:39:24 +0000 | [diff] [blame] | 165 | apOnuDB *devdb.OnuDeviceDB, aTechProfileID uint8, aTechProfileType string, aRequestEvent cmn.OnuDeviceEvent, aName string, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 166 | apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, aCommChannel chan cmn.Message) *UniPonAniConfigFsm { |
| 167 | instFsm := &UniPonAniConfigFsm{ |
| 168 | pDeviceHandler: apDeviceHandler, |
| 169 | pOnuDeviceEntry: apOnuDeviceEntry, |
| 170 | deviceID: apDeviceHandler.GetDeviceID(), |
| 171 | pOmciCC: apDevOmciCC, |
| 172 | pOnuUniPort: apUniPort, |
| 173 | pUniTechProf: apUniTechProf, |
| 174 | pOnuDB: apOnuDB, |
| 175 | techProfileID: aTechProfileID, |
Holger Hildebrandt | c408f49 | 2022-07-14 08:39:24 +0000 | [diff] [blame] | 176 | techProfileType: aTechProfileType, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 177 | requestEvent: aRequestEvent, |
| 178 | chanSet: false, |
| 179 | tcontSetBefore: false, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 180 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 181 | instFsm.uniTpKey = uniTP{uniID: apUniPort.UniID, tpID: aTechProfileID} |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 182 | instFsm.waitFlowDeleteChannel = make(chan bool) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 183 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 184 | instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel) |
| 185 | if instFsm.PAdaptFsm == nil { |
| 186 | logger.Errorw(ctx, "UniPonAniConfigFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 187 | "device-id": instFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 188 | return nil |
| 189 | } |
| 190 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 191 | instFsm.PAdaptFsm.PFsm = fsm.NewFSM( |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 192 | aniStDisabled, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 193 | fsm.Events{ |
| 194 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 195 | {Name: aniEvStart, Src: []string{aniStDisabled}, Dst: aniStStarting}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 196 | |
| 197 | //Note: .1p-Mapper and MBPCD might also have multi instances (per T-Cont) - by now only one 1 T-Cont considered! |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 198 | {Name: aniEvStartConfig, Src: []string{aniStStarting}, Dst: aniStCreatingDot1PMapper}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 199 | {Name: aniEvRxDot1pmapCResp, Src: []string{aniStCreatingDot1PMapper}, Dst: aniStCreatingMBPCD}, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 200 | {Name: aniEvRxMbpcdResp, Src: []string{aniStCreatingMBPCD}, Dst: aniStSettingTconts}, |
| 201 | {Name: aniEvRxTcontsResp, Src: []string{aniStSettingTconts}, Dst: aniStCreatingGemNCTPs}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 202 | // the creatingGemNCTPs state is used for multi ME config if required for all configured/available GemPorts |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 203 | {Name: aniEvRxGemntcpsResp, Src: []string{aniStCreatingGemNCTPs}, Dst: aniStCreatingGemIWs}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 204 | // the creatingGemIWs state is used for multi ME config if required for all configured/available GemPorts |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 205 | {Name: aniEvRxGemiwsResp, Src: []string{aniStCreatingGemIWs}, Dst: aniStSettingPQs}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 206 | // the settingPQs state is used for multi ME config if required for all configured/available upstream PriorityQueues |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 207 | {Name: aniEvRxPrioqsResp, Src: []string{aniStSettingPQs}, Dst: aniStSettingDot1PMapper}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 208 | {Name: aniEvRxDot1pmapSResp, Src: []string{aniStSettingDot1PMapper}, Dst: aniStConfigDone}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 209 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 210 | //for removing Gem related resources |
| 211 | {Name: aniEvRemGemiw, Src: []string{aniStConfigDone}, Dst: aniStRemovingGemIW}, |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 212 | {Name: aniEvWaitFlowRem, Src: []string{aniStRemovingGemIW}, Dst: aniStWaitingFlowRem}, |
| 213 | {Name: aniEvFlowRemDone, Src: []string{aniStWaitingFlowRem}, Dst: aniStRemovingGemIW}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 214 | {Name: aniEvRxRemGemiwResp, Src: []string{aniStRemovingGemIW}, Dst: aniStRemovingGemNCTP}, |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 215 | {Name: aniEvRxRemGemntpResp, Src: []string{aniStRemovingGemNCTP}, Dst: aniStRemovingTD}, |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 216 | {Name: aniEvRxRemTdResp, Src: []string{aniStRemovingTD}, Dst: aniStRemDot1PMapper}, |
| 217 | {Name: aniEvRemGemDone, Src: []string{aniStRemDot1PMapper}, Dst: aniStConfigDone}, |
| 218 | {Name: aniEvRxRem1pMapperResp, Src: []string{aniStRemDot1PMapper}, Dst: aniStRemAniBPCD}, |
| 219 | {Name: aniEvRxRemAniBPCDResp, Src: []string{aniStRemAniBPCD}, Dst: aniStRemoveDone}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 220 | |
| 221 | //for removing TCONT related resources |
| 222 | {Name: aniEvRemTcontPath, Src: []string{aniStConfigDone}, Dst: aniStResetTcont}, |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 223 | {Name: aniEvRxResetTcontResp, Src: []string{aniStResetTcont}, Dst: aniStConfigDone}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 224 | |
| 225 | {Name: aniEvTimeoutSimple, Src: []string{aniStCreatingDot1PMapper, aniStCreatingMBPCD, aniStSettingTconts, aniStSettingDot1PMapper, |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 226 | aniStRemovingGemIW, aniStRemovingGemNCTP, aniStRemovingTD, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 227 | aniStResetTcont, aniStRemDot1PMapper, aniStRemAniBPCD, aniStRemoveDone}, Dst: aniStStarting}, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 228 | {Name: aniEvTimeoutMids, Src: []string{ |
| 229 | aniStCreatingGemNCTPs, aniStCreatingGemIWs, aniStSettingPQs}, Dst: aniStStarting}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 230 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 231 | // exceptional treatment for all states except aniStResetting |
| 232 | {Name: aniEvReset, Src: []string{aniStStarting, aniStCreatingDot1PMapper, aniStCreatingMBPCD, |
| 233 | aniStSettingTconts, aniStCreatingGemNCTPs, aniStCreatingGemIWs, aniStSettingPQs, aniStSettingDot1PMapper, |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 234 | aniStConfigDone, aniStRemovingGemIW, aniStWaitingFlowRem, aniStRemovingGemNCTP, aniStRemovingTD, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 235 | aniStResetTcont, aniStRemDot1PMapper, aniStRemAniBPCD, aniStRemoveDone}, Dst: aniStResetting}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 236 | // the only way to get to resource-cleared disabled state again is via "resseting" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 237 | {Name: aniEvRestart, Src: []string{aniStResetting}, Dst: aniStDisabled}, |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 238 | {Name: aniEvSkipOmciConfig, Src: []string{aniStStarting}, Dst: aniStConfigDone}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 239 | }, |
| 240 | |
| 241 | fsm.Callbacks{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 242 | "enter_state": func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) }, |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 243 | ("enter_" + aniStStarting): func(e *fsm.Event) { instFsm.enterConfigStartingState(ctx, e) }, |
| 244 | ("enter_" + aniStCreatingDot1PMapper): func(e *fsm.Event) { instFsm.enterCreatingDot1PMapper(ctx, e) }, |
| 245 | ("enter_" + aniStCreatingMBPCD): func(e *fsm.Event) { instFsm.enterCreatingMBPCD(ctx, e) }, |
| 246 | ("enter_" + aniStSettingTconts): func(e *fsm.Event) { instFsm.enterSettingTconts(ctx, e) }, |
| 247 | ("enter_" + aniStCreatingGemNCTPs): func(e *fsm.Event) { instFsm.enterCreatingGemNCTPs(ctx, e) }, |
| 248 | ("enter_" + aniStCreatingGemIWs): func(e *fsm.Event) { instFsm.enterCreatingGemIWs(ctx, e) }, |
| 249 | ("enter_" + aniStSettingPQs): func(e *fsm.Event) { instFsm.enterSettingPQs(ctx, e) }, |
| 250 | ("enter_" + aniStSettingDot1PMapper): func(e *fsm.Event) { instFsm.enterSettingDot1PMapper(ctx, e) }, |
| 251 | ("enter_" + aniStConfigDone): func(e *fsm.Event) { instFsm.enterAniConfigDone(ctx, e) }, |
| 252 | ("enter_" + aniStRemovingGemIW): func(e *fsm.Event) { instFsm.enterRemovingGemIW(ctx, e) }, |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 253 | ("enter_" + aniStWaitingFlowRem): func(e *fsm.Event) { instFsm.enterWaitingFlowRem(ctx, e) }, |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 254 | ("enter_" + aniStRemovingGemNCTP): func(e *fsm.Event) { instFsm.enterRemovingGemNCTP(ctx, e) }, |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 255 | ("enter_" + aniStRemovingTD): func(e *fsm.Event) { instFsm.enterRemovingTD(ctx, e) }, |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 256 | ("enter_" + aniStResetTcont): func(e *fsm.Event) { instFsm.enterResettingTcont(ctx, e) }, |
| 257 | ("enter_" + aniStRemDot1PMapper): func(e *fsm.Event) { instFsm.enterRemoving1pMapper(ctx, e) }, |
| 258 | ("enter_" + aniStRemAniBPCD): func(e *fsm.Event) { instFsm.enterRemovingAniBPCD(ctx, e) }, |
| 259 | ("enter_" + aniStRemoveDone): func(e *fsm.Event) { instFsm.enterAniRemoveDone(ctx, e) }, |
| 260 | ("enter_" + aniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) }, |
| 261 | ("enter_" + aniStDisabled): func(e *fsm.Event) { instFsm.enterDisabledState(ctx, e) }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 262 | }, |
| 263 | ) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 264 | if instFsm.PAdaptFsm.PFsm == nil { |
| 265 | logger.Errorw(ctx, "UniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 266 | "device-id": instFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 267 | return nil |
| 268 | } |
| 269 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 270 | logger.Debugw(ctx, "UniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 271 | return instFsm |
| 272 | } |
| 273 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 274 | //setFsmCompleteChannel sets the requested channel and channel result for transfer on success |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 275 | func (oFsm *UniPonAniConfigFsm) setFsmCompleteChannel(aChSuccess chan<- uint8, aProcStep uint8) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 276 | oFsm.chSuccess = aChSuccess |
| 277 | oFsm.procStep = aProcStep |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 278 | oFsm.setChanSet(true) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 279 | } |
| 280 | |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 281 | //CancelProcessing ensures that suspended processing at waiting on some response is aborted and reset of FSM |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 282 | func (oFsm *UniPonAniConfigFsm) CancelProcessing(ctx context.Context) { |
Holger Hildebrandt | 12609a1 | 2022-03-25 13:23:25 +0000 | [diff] [blame] | 283 | logger.Debugw(ctx, "CancelProcessing entered", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 284 | //early indication about started reset processing |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 285 | oFsm.pUniTechProf.setProfileResetting(ctx, oFsm.pOnuUniPort.UniID, oFsm.techProfileID, true) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 286 | //mutex protection is required for possible concurrent access to FSM members |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 287 | oFsm.mutexIsAwaitingResponse.Lock() |
| 288 | oFsm.isCanceled = true |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 289 | if oFsm.isAwaitingResponse { |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 290 | //attention: for an unbuffered channel the sender is blocked until the value is received (processed)! |
| 291 | // accordingly the mutex must be released before sending to channel here (mutex acquired in receiver) |
| 292 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 293 | //use channel to indicate that the response waiting shall be aborted |
| 294 | oFsm.omciMIdsResponseReceived <- false |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 295 | } else { |
| 296 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 297 | } |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 298 | |
| 299 | oFsm.mutexIsAwaitingResponse.Lock() |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 300 | if oFsm.isWaitingForFlowDelete { |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 301 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 302 | //use channel to indicate that the response waiting shall be aborted |
| 303 | oFsm.waitFlowDeleteChannel <- false |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 304 | } else { |
| 305 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 306 | } |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 307 | |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 308 | // in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 309 | PAdaptFsm := oFsm.PAdaptFsm |
| 310 | if PAdaptFsm != nil { |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 311 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 312 | go func(aPAFsm *cmn.AdapterFsm) { |
| 313 | if aPAFsm.PFsm != nil { |
| 314 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 315 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 316 | }(PAdaptFsm) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 317 | } |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 318 | |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 319 | // possible access conflicts on internal data by next needed data clearance |
| 320 | // are avoided by using mutexTPState also from within clearAniSideConfig |
| 321 | // do not try to lock TpProcMutex here as done in previous code version |
| 322 | // as it may result in deadlock situations (as observed at soft-reboot handling where |
| 323 | // TpProcMutex is already locked by some ongoing TechProfile config/removal processing |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 324 | //remove all TechProf related internal data to allow for new configuration |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 325 | oFsm.pUniTechProf.clearAniSideConfig(ctx, oFsm.pOnuUniPort.UniID, oFsm.techProfileID) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 326 | } |
| 327 | |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 328 | //nolint: gocyclo |
| 329 | //TODO:visit here for refactoring for gocyclo |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 330 | func (oFsm *UniPonAniConfigFsm) prepareAndEnterConfigState(ctx context.Context, aPAFsm *cmn.AdapterFsm) { |
| 331 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 332 | var err error |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 333 | oFsm.mapperSP0ID, err = cmn.GenerateIeeMaperServiceProfileEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.techProfileID)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 334 | if err != nil { |
| 335 | logger.Errorw(ctx, "error generating maper id", log.Fields{"device-id": oFsm.deviceID, |
| 336 | "techProfileID": oFsm.techProfileID, "error": err}) |
| 337 | return |
| 338 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 339 | oFsm.macBPCD0ID, err = cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.techProfileID)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 340 | if err != nil { |
| 341 | logger.Errorw(ctx, "error generating mbpcd id", log.Fields{"device-id": oFsm.deviceID, |
| 342 | "techProfileID": oFsm.techProfileID, "error": err}) |
| 343 | return |
| 344 | } |
| 345 | logger.Debugw(ctx, "generated ids for ani config", log.Fields{"mapperSP0ID": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
| 346 | "macBPCD0ID": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16), "device-id": oFsm.deviceID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 347 | "macBpNo": oFsm.pOnuUniPort.MacBpNo, "techProfileID": oFsm.techProfileID}) |
| 348 | if oFsm.pOnuDeviceEntry == nil { |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 349 | logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": oFsm.deviceID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 350 | return |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 351 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 352 | tcontInstID, tcontAlreadyExist, err := oFsm.pOnuDeviceEntry.AllocateFreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID) |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 353 | if err != nil { |
| 354 | logger.Errorw(ctx, "No TCont instances found", log.Fields{"device-id": oFsm.deviceID, "err": err}) |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 355 | //reset the state machine to enable usage on subsequent requests |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 356 | _ = aPAFsm.PFsm.Event(aniEvReset) |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 357 | return |
| 358 | } |
| 359 | oFsm.tcont0ID = tcontInstID |
| 360 | oFsm.tcontSetBefore = tcontAlreadyExist |
| 361 | logger.Debugw(ctx, "used-tcont-instance-id", log.Fields{"tcont-inst-id": oFsm.tcont0ID, |
| 362 | "alloc-id": oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID, |
| 363 | "tcontAlreadyExist": tcontAlreadyExist, |
| 364 | "device-id": oFsm.deviceID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 365 | |
| 366 | // Access critical state with lock |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 367 | oFsm.pUniTechProf.mutexTPState.RLock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 368 | oFsm.alloc0ID = oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID |
| 369 | mapGemPortParams := oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].mapGemPortParams |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 370 | oFsm.pUniTechProf.mutexTPState.RUnlock() |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 371 | |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 372 | //for all TechProfile set GemIndices |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 373 | for _, gemEntry := range mapGemPortParams { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 374 | loGemPortAttribs := ponAniGemPortAttribs{} |
| 375 | |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 376 | //collect all GemConfigData in a separate Fsm related slice (needed also to avoid mix-up with unsorted mapPonAniConfig) |
| 377 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 378 | if queueInstKeys := oFsm.pOnuDB.GetSortedInstKeys(ctx, me.PriorityQueueClassID); len(queueInstKeys) > 0 { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 379 | |
| 380 | loGemPortAttribs.gemPortID = gemEntry.gemPortID |
| 381 | // MibDb usage: upstream PrioQueue.RelatedPort = xxxxyyyy with xxxx=TCont.Entity(incl. slot) and yyyy=prio |
| 382 | // i.e.: search PrioQueue list with xxxx=actual T-Cont.Entity, |
| 383 | // from that list use the PrioQueue.Entity with gemEntry.prioQueueIndex == yyyy (expect 0..7) |
| 384 | usQrelPortMask := uint32((((uint32)(oFsm.tcont0ID)) << 16) + uint32(gemEntry.prioQueueIndex)) |
| 385 | |
| 386 | // MibDb usage: downstream PrioQueue.RelatedPort = xxyyzzzz with xx=slot, yy=UniPort and zzzz=prio |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 387 | // i.e.: search PrioQueue list with yy=actual pOnuUniPort.UniID, |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 388 | // from that list use the PrioQueue.Entity with gemEntry.prioQueueIndex == zzzz (expect 0..7) |
Holger Hildebrandt | 5ba6c13 | 2022-10-06 13:53:14 +0000 | [diff] [blame] | 389 | // Note: As we do not maintain any slot numbering, slot number will be excluded from search pattern. |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 390 | // Furthermore OMCI Onu port-Id is expected to start with 1 (not 0). |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 391 | dsQrelPortMask := uint32((((uint32)(oFsm.pOnuUniPort.UniID + 1)) << 16) + uint32(gemEntry.prioQueueIndex)) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 392 | |
| 393 | usQueueFound := false |
| 394 | dsQueueFound := false |
| 395 | for _, mgmtEntityID := range queueInstKeys { |
| 396 | if meAttributes := oFsm.pOnuDB.GetMe(me.PriorityQueueClassID, mgmtEntityID); meAttributes != nil { |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 397 | returnVal := meAttributes[me.PriorityQueue_RelatedPort] |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 398 | if returnVal != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 399 | if relatedPort, err := oFsm.pOnuDB.GetUint32Attrib(returnVal); err == nil { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 400 | if relatedPort == usQrelPortMask { |
| 401 | loGemPortAttribs.upQueueID = mgmtEntityID |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 402 | logger.Debugw(ctx, "UpQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 403 | "upQueueID": strconv.FormatInt(int64(loGemPortAttribs.upQueueID), 16), "device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 404 | usQueueFound = true |
| 405 | } else if (relatedPort&0xFFFFFF) == dsQrelPortMask && mgmtEntityID < 0x8000 { |
| 406 | loGemPortAttribs.downQueueID = mgmtEntityID |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 407 | logger.Debugw(ctx, "DownQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 408 | "downQueueID": strconv.FormatInt(int64(loGemPortAttribs.downQueueID), 16), "device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 409 | dsQueueFound = true |
| 410 | } |
| 411 | if usQueueFound && dsQueueFound { |
| 412 | break |
| 413 | } |
| 414 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 415 | logger.Warnw(ctx, "Could not convert attribute value", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 416 | } |
| 417 | } else { |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 418 | logger.Warnw(ctx, "PrioQueue.RelatedPort not found in meAttributes:", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 419 | } |
| 420 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 421 | logger.Warnw(ctx, "No attributes available in DB:", log.Fields{"meClassID": me.PriorityQueueClassID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 422 | "mgmtEntityID": mgmtEntityID, "device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 423 | } |
| 424 | } |
| 425 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 426 | logger.Warnw(ctx, "No PriorityQueue instances found", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 427 | } |
| 428 | loGemPortAttribs.direction = gemEntry.direction |
| 429 | loGemPortAttribs.qosPolicy = gemEntry.queueSchedPolicy |
| 430 | loGemPortAttribs.weight = gemEntry.queueWeight |
| 431 | loGemPortAttribs.pbitString = gemEntry.pbitString |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 432 | |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 433 | if gemEntry.isMulticast { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 434 | //TODO this might effectively ignore the for loop starting at line 316 |
| 435 | loGemPortAttribs.gemPortID = gemEntry.multicastGemPortID |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 436 | loGemPortAttribs.isMulticast = true |
| 437 | loGemPortAttribs.multicastGemID = gemEntry.multicastGemPortID |
| 438 | loGemPortAttribs.staticACL = gemEntry.staticACL |
| 439 | loGemPortAttribs.dynamicACL = gemEntry.dynamicACL |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 440 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 441 | logger.Debugw(ctx, "Multicast GemPort attributes:", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 442 | "gemPortID": loGemPortAttribs.gemPortID, |
| 443 | "isMulticast": loGemPortAttribs.isMulticast, |
| 444 | "multicastGemID": loGemPortAttribs.multicastGemID, |
| 445 | "staticACL": loGemPortAttribs.staticACL, |
| 446 | "dynamicACL": loGemPortAttribs.dynamicACL, |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 447 | "device-id": oFsm.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 448 | }) |
| 449 | |
| 450 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 451 | logger.Debugw(ctx, "Upstream GemPort attributes:", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 452 | "gemPortID": loGemPortAttribs.gemPortID, |
| 453 | "upQueueID": loGemPortAttribs.upQueueID, |
| 454 | "downQueueID": loGemPortAttribs.downQueueID, |
| 455 | "pbitString": loGemPortAttribs.pbitString, |
| 456 | "prioQueueIndex": gemEntry.prioQueueIndex, |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 457 | "device-id": oFsm.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 458 | }) |
| 459 | } |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 460 | |
| 461 | oFsm.gemPortAttribsSlice = append(oFsm.gemPortAttribsSlice, loGemPortAttribs) |
| 462 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 463 | if !oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
| 464 | _ = aPAFsm.PFsm.Event(aniEvStartConfig) |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 465 | } else { |
| 466 | logger.Debugw(ctx, "reconciling - skip omci-config of ANI side ", log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 467 | _ = aPAFsm.PFsm.Event(aniEvSkipOmciConfig) |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 468 | } |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 469 | } |
| 470 | } |
| 471 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 472 | func (oFsm *UniPonAniConfigFsm) enterConfigStartingState(ctx context.Context, e *fsm.Event) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 473 | logger.Debugw(ctx, "UniPonAniConfigFsm start", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 474 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 475 | // in case the used channel is not yet defined (can be re-used after restarts) |
| 476 | if oFsm.omciMIdsResponseReceived == nil { |
| 477 | oFsm.omciMIdsResponseReceived = make(chan bool) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 478 | logger.Debug(ctx, "UniPonAniConfigFsm - OMCI multiInstance RxChannel defined") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 479 | } else { |
| 480 | // as we may 're-use' this instance of FSM and the connected channel |
| 481 | // make sure there is no 'lingering' request in the already existing channel: |
| 482 | // (simple loop sufficient as we are the only receiver) |
| 483 | for len(oFsm.omciMIdsResponseReceived) > 0 { |
| 484 | <-oFsm.omciMIdsResponseReceived |
| 485 | } |
| 486 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 487 | //ensure internal slices are empty (which might be set from previous run) - release memory |
| 488 | oFsm.gemPortAttribsSlice = nil |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 489 | oFsm.mutexIsAwaitingResponse.Lock() |
| 490 | //reset the canceled state possibly existing from previous reset |
| 491 | oFsm.isCanceled = false |
| 492 | oFsm.mutexIsAwaitingResponse.Unlock() |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 493 | |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 494 | // start go routine for processing of ANI config messages |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 495 | go oFsm.processOmciAniMessages(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 496 | |
| 497 | //let the state machine run forward from here directly |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 498 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 499 | if pConfigAniStateAFsm != nil { |
| 500 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 501 | go oFsm.prepareAndEnterConfigState(ctx, pConfigAniStateAFsm) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 502 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 506 | func (oFsm *UniPonAniConfigFsm) enterCreatingDot1PMapper(ctx context.Context, e *fsm.Event) { |
| 507 | logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 508 | "EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 509 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 510 | oFsm.requestEventOffset = 0 //0 offset for last config request activity |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 511 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 512 | meInstance, err := oFsm.pOmciCC.SendCreateDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 513 | oFsm.mapperSP0ID, oFsm.PAdaptFsm.CommChan) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 514 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 515 | logger.Errorw(ctx, "Dot1PMapper create failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 516 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 517 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 518 | if pConfigAniStateAFsm != nil { |
| 519 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 520 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 521 | go func(aPAFsm *cmn.AdapterFsm) { |
| 522 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 523 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 524 | } |
| 525 | }(pConfigAniStateAFsm) |
| 526 | return |
| 527 | } |
| 528 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 529 | //accept also nil as (error) return value for writing to LastTx |
| 530 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 531 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 532 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 533 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 534 | } |
| 535 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 536 | func (oFsm *UniPonAniConfigFsm) enterCreatingMBPCD(ctx context.Context, e *fsm.Event) { |
| 537 | logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::MBPCD", log.Fields{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 538 | "EntitytId": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16), |
| 539 | "TPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 540 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
| 541 | bridgePtr := cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo) //cmp also omci_cc.go::sendCreateMBServiceProfile |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 542 | meParams := me.ParamData{ |
| 543 | EntityID: oFsm.macBPCD0ID, |
| 544 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 545 | me.MacBridgePortConfigurationData_BridgeIdPointer: bridgePtr, |
| 546 | me.MacBridgePortConfigurationData_PortNum: 0xFF, //fixed unique ANI side indication |
| 547 | me.MacBridgePortConfigurationData_TpType: 3, //for .1PMapper |
| 548 | me.MacBridgePortConfigurationData_TpPointer: oFsm.mapperSP0ID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 549 | }, |
| 550 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 551 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 552 | meInstance, err := oFsm.pOmciCC.SendCreateMBPConfigDataVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 553 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 554 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 555 | logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 556 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 557 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 558 | if pConfigAniStateAFsm != nil { |
| 559 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 560 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 561 | go func(aPAFsm *cmn.AdapterFsm) { |
| 562 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 563 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 564 | } |
| 565 | }(pConfigAniStateAFsm) |
| 566 | return |
| 567 | } |
| 568 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 569 | //accept also nil as (error) return value for writing to LastTx |
| 570 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 571 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 572 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 573 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 574 | } |
| 575 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 576 | func (oFsm *UniPonAniConfigFsm) enterSettingTconts(ctx context.Context, e *fsm.Event) { |
| 577 | logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::Tcont", log.Fields{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 578 | "EntitytId": strconv.FormatInt(int64(oFsm.tcont0ID), 16), |
| 579 | "AllocId": strconv.FormatInt(int64(oFsm.alloc0ID), 16), |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 580 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 581 | "tcontExist": oFsm.tcontSetBefore}) |
| 582 | //If tcont was set before, then no need to set it again. Let state machine to proceed. |
| 583 | if oFsm.tcontSetBefore { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 584 | go func(aPAFsm *cmn.AdapterFsm) { |
| 585 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 586 | _ = aPAFsm.PFsm.Event(aniEvRxTcontsResp) |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 587 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 588 | }(oFsm.PAdaptFsm) |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 589 | return |
| 590 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 591 | meParams := me.ParamData{ |
| 592 | EntityID: oFsm.tcont0ID, |
| 593 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 594 | me.TCont_AllocId: oFsm.alloc0ID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 595 | }, |
| 596 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 597 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 598 | meInstance, err := oFsm.pOmciCC.SendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 599 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 600 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 601 | logger.Errorw(ctx, "TcontVar set failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 602 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 603 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 604 | if pConfigAniStateAFsm != nil { |
| 605 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 606 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 607 | go func(aPAFsm *cmn.AdapterFsm) { |
| 608 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 609 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 610 | } |
| 611 | }(pConfigAniStateAFsm) |
| 612 | return |
| 613 | } |
| 614 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 615 | //accept also nil as (error) return value for writing to LastTx |
| 616 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 617 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 618 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 619 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 620 | } |
| 621 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 622 | func (oFsm *UniPonAniConfigFsm) enterCreatingGemNCTPs(ctx context.Context, e *fsm.Event) { |
| 623 | logger.Debugw(ctx, "UniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{ |
| 624 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 625 | go oFsm.performCreatingGemNCTPs(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 628 | func (oFsm *UniPonAniConfigFsm) enterCreatingGemIWs(ctx context.Context, e *fsm.Event) { |
| 629 | logger.Debugw(ctx, "UniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{ |
| 630 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 631 | go oFsm.performCreatingGemIWs(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 632 | } |
| 633 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 634 | func (oFsm *UniPonAniConfigFsm) enterSettingPQs(ctx context.Context, e *fsm.Event) { |
| 635 | logger.Debugw(ctx, "UniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 636 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 637 | go oFsm.performSettingPQs(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 638 | } |
| 639 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 640 | func (oFsm *UniPonAniConfigFsm) enterSettingDot1PMapper(ctx context.Context, e *fsm.Event) { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 641 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 642 | logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::.1pMapper with all PBits set", log.Fields{"EntitytId": 0x8042, /*cmp above*/ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 643 | "toGemIw": 1024, /* cmp above */ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 644 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 645 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 646 | logger.Debugw(ctx, "UniPonAniConfigFsm Tx Set::1pMapper", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 647 | "EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 648 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 649 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 650 | meParams := me.ParamData{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 651 | EntityID: oFsm.mapperSP0ID, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 652 | Attributes: make(me.AttributeValueMap), |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 653 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 654 | |
| 655 | //assign the GemPorts according to the configured Prio |
| 656 | var loPrioGemPortArray [8]uint16 |
| 657 | for _, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 658 | if gemPortAttribs.isMulticast { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 659 | logger.Debugw(ctx, "UniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 660 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
| 661 | "prioString": gemPortAttribs.pbitString}) |
| 662 | continue |
| 663 | } |
| 664 | if gemPortAttribs.pbitString == "" { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 665 | logger.Warnw(ctx, "UniPonAniConfigFsm PrioString empty string error", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 666 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
| 667 | "prioString": gemPortAttribs.pbitString}) |
| 668 | continue |
| 669 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 670 | for i := 0; i < 8; i++ { |
| 671 | // "lenOfPbitMap(8) - i + 1" will give i-th pbit value from LSB position in the pbit map string |
| 672 | if prio, err := strconv.Atoi(string(gemPortAttribs.pbitString[7-i])); err == nil { |
| 673 | if prio == 1 { // Check this p-bit is set |
| 674 | if loPrioGemPortArray[i] == 0 { |
| 675 | loPrioGemPortArray[i] = gemPortAttribs.gemPortID //gemPortId=EntityID and unique |
| 676 | } else { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 677 | logger.Warnw(ctx, "UniPonAniConfigFsm PrioString not unique", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 678 | "device-id": oFsm.deviceID, "IgnoredGemPort": gemPortAttribs.gemPortID, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 679 | "SetGemPort": loPrioGemPortArray[i]}) |
| 680 | } |
| 681 | } |
| 682 | } else { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 683 | logger.Warnw(ctx, "UniPonAniConfigFsm PrioString evaluation error", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 684 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 685 | "prioString": gemPortAttribs.pbitString, "position": i}) |
| 686 | } |
| 687 | |
| 688 | } |
| 689 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 690 | |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 691 | var foundIwPtr = false |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 692 | for index, value := range loPrioGemPortArray { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 693 | meAttribute := fmt.Sprintf("InterworkTpPointerForPBitPriority%d", index) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 694 | if value != 0 { |
| 695 | foundIwPtr = true |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 696 | meParams.Attributes[meAttribute] = value |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 697 | logger.Debugw(ctx, "UniPonAniConfigFsm Set::1pMapper", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 698 | "for Prio": index, |
| 699 | "IwPtr": strconv.FormatInt(int64(value), 16), |
| 700 | "device-id": oFsm.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 701 | } else { |
| 702 | // The null pointer 0xFFFF specifies that frames with the associated priority are to be discarded. |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 703 | // setting this parameter is not strictly needed anymore with the ensured .1pMapper create default setting |
| 704 | // but except for processing effort does not really harm - left to keep changes low |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 705 | meParams.Attributes[meAttribute] = 0xffff |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 706 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 707 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 708 | // The TP type value 0 also indicates bridging mapping, and the TP pointer should be set to 0xFFFF |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 709 | // setting this parameter is not strictly needed anymore with the ensured .1pMapper create default setting |
| 710 | // but except for processing effort does not really harm - left to keep changes low |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 711 | meParams.Attributes[me.Ieee8021PMapperServiceProfile_TpPointer] = 0xffff |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 712 | |
| 713 | if !foundIwPtr { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 714 | logger.Debugw(ctx, "UniPonAniConfigFsm no GemIwPtr found for .1pMapper - abort", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 715 | "device-id": oFsm.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 716 | //TODO With multicast is possible that no upstream gem ports are not present in the tech profile, |
| 717 | // this reset needs to be performed only if the tech profile provides upstream gem ports but no priority is set |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 718 | //let's reset the state machine in order to release all resources now |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 719 | //pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 720 | //if pConfigAniStateAFsm != nil { |
| 721 | // // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 722 | // go func(aPAFsm *cmn.AdapterFsm) { |
| 723 | // if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 724 | // _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 725 | // } |
| 726 | // }(pConfigAniStateAFsm) |
| 727 | //} |
| 728 | //Moving forward the FSM as if the response was received correctly. |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 729 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 730 | if pConfigAniStateAFsm != nil { |
| 731 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 732 | go func(aPAFsm *cmn.AdapterFsm) { |
| 733 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 734 | _ = aPAFsm.PFsm.Event(aniEvRxDot1pmapSResp) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 735 | } |
| 736 | }(pConfigAniStateAFsm) |
| 737 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 738 | } else { |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 739 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 740 | meInstance, err := oFsm.pOmciCC.SendSetDot1PMapperVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 741 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 742 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 743 | logger.Errorw(ctx, "Dot1PMapperVar set failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 744 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 745 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 746 | if pConfigAniStateAFsm != nil { |
| 747 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 748 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 749 | go func(aPAFsm *cmn.AdapterFsm) { |
| 750 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 751 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 752 | } |
| 753 | }(pConfigAniStateAFsm) |
| 754 | return |
| 755 | } |
| 756 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 757 | //accept also nil as (error) return value for writing to LastTx |
| 758 | // - this avoids misinterpretation of new received OMCI messages |
| 759 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 760 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 761 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 762 | } |
| 763 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 764 | func (oFsm *UniPonAniConfigFsm) enterAniConfigDone(ctx context.Context, e *fsm.Event) { |
| 765 | logger.Debugw(ctx, "UniPonAniConfigFsm ani config done", log.Fields{ |
| 766 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 767 | //store that the UNI related techProfile processing is done for the given Profile and Uni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 768 | oFsm.pUniTechProf.setConfigDone(oFsm.pOnuUniPort.UniID, oFsm.techProfileID, true) |
| 769 | if !oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 770 | //use DeviceHandler event notification directly |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 771 | oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset))) |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 772 | //if techProfile processing is done it must be checked, if some prior/parallel flow configuration is pending |
| 773 | // but only in case the techProfile was configured (not deleted) |
| 774 | if oFsm.requestEventOffset == 0 { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 775 | go oFsm.pDeviceHandler.VerifyUniVlanConfigRequest(ctx, oFsm.pOnuUniPort, oFsm.techProfileID) |
Holger Hildebrandt | 01bc3bf | 2021-04-26 09:59:01 +0000 | [diff] [blame] | 776 | } |
| 777 | } else { |
| 778 | logger.Debugw(ctx, "reconciling - skip AniConfigDone processing", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 779 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 780 | if oFsm.isChanSet() { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 781 | // indicate processing done to the caller |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 782 | logger.Debugw(ctx, "UniPonAniConfigFsm processingDone on channel", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 783 | "ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 784 | oFsm.chSuccess <- oFsm.procStep |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 785 | oFsm.setChanSet(false) //reset the internal channel state |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 786 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 787 | |
| 788 | //the FSM is left active in this state as long as no specific reset or remove is requested from outside |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 791 | func (oFsm *UniPonAniConfigFsm) enterRemovingGemIW(ctx context.Context, e *fsm.Event) { |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 792 | // no need to protect access to oFsm.waitFlowDeleteChannel, only used in synchronized state entries |
| 793 | // or CancelProcessing() that uses separate isWaitingForFlowDelete to write to the channel |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 794 | //flush the waitFlowDeleteChannel - possibly already/still set by some previous activity |
| 795 | select { |
| 796 | case <-oFsm.waitFlowDeleteChannel: |
| 797 | logger.Debug(ctx, "flushed waitFlowDeleteChannel") |
| 798 | default: |
| 799 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 800 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 801 | uniVlanConfigFsm := oFsm.pDeviceHandler.GetUniVlanConfigFsm(oFsm.pOnuUniPort.UniID) |
| 802 | if uniVlanConfigFsm != nil { |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 803 | // ensure mutexTPState not locked before calling some VlanConfigFsm activity (that might already be pending on it) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 804 | if uniVlanConfigFsm.IsFlowRemovePending(ctx, oFsm.waitFlowDeleteChannel) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 805 | logger.Debugw(ctx, "flow remove pending - wait before processing gem port delete", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 806 | log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 807 | // if flow remove is pending then wait for flow remove to finish first before proceeding with gem port delete |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 808 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 809 | if pConfigAniStateAFsm != nil { |
| 810 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 811 | go func(aPAFsm *cmn.AdapterFsm) { |
| 812 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 813 | _ = aPAFsm.PFsm.Event(aniEvWaitFlowRem) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 814 | } |
| 815 | }(pConfigAniStateAFsm) |
| 816 | } else { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 817 | logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 818 | } |
| 819 | return |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 820 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 821 | } else { |
| 822 | logger.Debugw(ctx, "uni vlan config doesn't exist - no flow remove could be pending", |
| 823 | log.Fields{"device-id": oFsm.deviceID, "techProfile-id": oFsm.techProfileID}) |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 824 | } |
| 825 | |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 826 | oFsm.pUniTechProf.mutexTPState.RLock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 827 | // get the related GemPort entity Id from pUniTechProf, OMCI Gem* entityID is set to be equal to GemPortId! |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 828 | loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 829 | oFsm.pUniTechProf.mutexTPState.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 830 | logger.Debugw(ctx, "UniPonAniConfigFsm - start removing one GemIwTP", log.Fields{ |
| 831 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 832 | "GemIwTp-entity-id": loGemPortID}) |
| 833 | oFsm.requestEventOffset = 1 //offset 1 to indicate last activity = remove |
| 834 | |
| 835 | // this state entry is only expected in a suitable state (checked outside in onu_uni_tp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 836 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 837 | meInstance, err := oFsm.pOmciCC.SendDeleteGemIWTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 838 | oFsm.PAdaptFsm.CommChan, loGemPortID) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 839 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 840 | logger.Errorw(ctx, "GemIWTP delete failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 841 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 842 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 843 | if pConfigAniStateAFsm != nil { |
| 844 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 845 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 846 | go func(aPAFsm *cmn.AdapterFsm) { |
| 847 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 848 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 849 | } |
| 850 | }(pConfigAniStateAFsm) |
| 851 | return |
| 852 | } |
| 853 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 854 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 855 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 856 | } |
| 857 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 858 | func (oFsm *UniPonAniConfigFsm) enterWaitingFlowRem(ctx context.Context, e *fsm.Event) { |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 859 | oFsm.mutexIsAwaitingResponse.Lock() |
| 860 | oFsm.isWaitingForFlowDelete = true |
| 861 | oFsm.mutexIsAwaitingResponse.Unlock() |
| 862 | select { |
| 863 | // maybe be also some outside cancel (but no context modeled for the moment ...) |
| 864 | // case <-ctx.Done(): |
| 865 | // logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 866 | case <-time.After(2 * oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //give flow processing enough time to finish (but try to be less than rwCore flow timeouts) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 867 | logger.Warnw(ctx, "UniPonAniConfigFsm WaitingFlowRem timeout", log.Fields{ |
| 868 | "for device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 869 | oFsm.mutexIsAwaitingResponse.Lock() |
| 870 | oFsm.isWaitingForFlowDelete = false |
| 871 | oFsm.mutexIsAwaitingResponse.Unlock() |
| 872 | //if the flow is not removed as expected we just try to continue with GemPort removal and hope things are clearing up afterwards |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 873 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 874 | if pConfigAniStateAFsm != nil { |
| 875 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 876 | go func(aPAFsm *cmn.AdapterFsm) { |
| 877 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 878 | _ = aPAFsm.PFsm.Event(aniEvFlowRemDone) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 879 | } |
| 880 | }(pConfigAniStateAFsm) |
| 881 | } else { |
| 882 | logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 883 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 884 | } |
| 885 | return |
| 886 | |
| 887 | case success := <-oFsm.waitFlowDeleteChannel: |
| 888 | if success { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 889 | logger.Debugw(ctx, "UniPonAniConfigFsm flow removed info received", log.Fields{ |
| 890 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 891 | oFsm.mutexIsAwaitingResponse.Lock() |
| 892 | oFsm.isWaitingForFlowDelete = false |
| 893 | oFsm.mutexIsAwaitingResponse.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 894 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 895 | if pConfigAniStateAFsm != nil { |
| 896 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 897 | go func(aPAFsm *cmn.AdapterFsm) { |
| 898 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 899 | _ = aPAFsm.PFsm.Event(aniEvFlowRemDone) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 900 | } |
| 901 | }(pConfigAniStateAFsm) |
| 902 | } else { |
| 903 | logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 904 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 905 | } |
| 906 | return |
| 907 | } |
| 908 | // waiting was aborted (probably on external request) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 909 | logger.Debugw(ctx, "UniPonAniConfigFsm WaitingFlowRem aborted", log.Fields{ |
| 910 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "techProfile-id": oFsm.techProfileID}) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 911 | oFsm.mutexIsAwaitingResponse.Lock() |
| 912 | oFsm.isWaitingForFlowDelete = false |
| 913 | oFsm.mutexIsAwaitingResponse.Unlock() |
| 914 | //to be sure we can just generate the reset-event to ensure leaving this state towards 'reset' |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 915 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 916 | if pConfigAniStateAFsm != nil { |
| 917 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 918 | go func(aPAFsm *cmn.AdapterFsm) { |
| 919 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 920 | _ = aPAFsm.PFsm.Event(aniEvReset) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 921 | } |
| 922 | }(pConfigAniStateAFsm) |
| 923 | } |
| 924 | return |
| 925 | } |
| 926 | } |
| 927 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 928 | func (oFsm *UniPonAniConfigFsm) enterRemovingGemNCTP(ctx context.Context, e *fsm.Event) { |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 929 | oFsm.pUniTechProf.mutexTPState.RLock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 930 | loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 931 | oFsm.pUniTechProf.mutexTPState.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 932 | logger.Debugw(ctx, "UniPonAniConfigFsm - start removing one GemNCTP", log.Fields{ |
| 933 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 934 | "GemNCTP-entity-id": loGemPortID}) |
| 935 | // this state entry is only expected in a suitable state (checked outside in onu_uni_tp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 936 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 937 | meInstance, err := oFsm.pOmciCC.SendDeleteGemNCTP(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 938 | oFsm.PAdaptFsm.CommChan, loGemPortID) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 939 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 940 | logger.Errorw(ctx, "GemNCTP delete failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 941 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 942 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 943 | if pConfigAniStateAFsm != nil { |
| 944 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 945 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 946 | go func(aPAFsm *cmn.AdapterFsm) { |
| 947 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 948 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 949 | } |
| 950 | }(pConfigAniStateAFsm) |
| 951 | return |
| 952 | } |
| 953 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 954 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 955 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 956 | |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 957 | // Mark the gem port to be removed for Performance History monitoring |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 958 | OnuMetricsManager := oFsm.pDeviceHandler.GetOnuMetricsManager() |
| 959 | if OnuMetricsManager != nil { |
| 960 | OnuMetricsManager.RemoveGemPortForPerfMonitoring(ctx, loGemPortID) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 961 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 962 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 963 | func (oFsm *UniPonAniConfigFsm) enterRemovingTD(ctx context.Context, e *fsm.Event) { |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 964 | oFsm.pUniTechProf.mutexTPState.RLock() |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 965 | loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 966 | oFsm.pUniTechProf.mutexTPState.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 967 | logger.Debugw(ctx, "UniPonAniConfigFsm - start removing Traffic Descriptor", log.Fields{ |
| 968 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 969 | "TD-entity-id": loGemPortID}) |
| 970 | |
| 971 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 972 | meInstance, err := oFsm.pOmciCC.SendDeleteTD(log.WithSpanFromContext(context.TODO(), ctx), |
| 973 | oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, loGemPortID) |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 974 | |
| 975 | if err != nil { |
| 976 | logger.Errorw(ctx, "TD delete failed - proceed fsm", |
| 977 | log.Fields{"device-id": oFsm.deviceID, "gemPortID": loGemPortID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 978 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 979 | if pConfigAniStateAFsm != nil { |
| 980 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 981 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 982 | go func(aPAFsm *cmn.AdapterFsm) { |
| 983 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 984 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 985 | } |
| 986 | }(pConfigAniStateAFsm) |
| 987 | return |
| 988 | } |
| 989 | } |
| 990 | oFsm.pLastTxMeInstance = meInstance |
| 991 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 992 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 993 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 994 | func (oFsm *UniPonAniConfigFsm) enterResettingTcont(ctx context.Context, e *fsm.Event) { |
| 995 | logger.Debugw(ctx, "UniPonAniConfigFsm - start resetting the TCont", log.Fields{ |
| 996 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 997 | |
| 998 | oFsm.requestEventOffset = 1 //offset 1 for last remove activity |
| 999 | // this state entry is only expected in a suitable state (checked outside in onu_uni_tp) |
| 1000 | meParams := me.ParamData{ |
| 1001 | EntityID: oFsm.tcont0ID, |
| 1002 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1003 | me.TCont_AllocId: cmn.UnusedTcontAllocID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1004 | }, |
| 1005 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1006 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1007 | meInstance, err := oFsm.pOmciCC.SendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1008 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1009 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1010 | logger.Errorw(ctx, "TcontVar set failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1011 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1012 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1013 | if pConfigAniStateAFsm != nil { |
| 1014 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 1015 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1016 | go func(aPAFsm *cmn.AdapterFsm) { |
| 1017 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 1018 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1019 | } |
| 1020 | }(pConfigAniStateAFsm) |
| 1021 | return |
| 1022 | } |
| 1023 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1024 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1025 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 1026 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1027 | } |
| 1028 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1029 | func (oFsm *UniPonAniConfigFsm) enterRemoving1pMapper(ctx context.Context, e *fsm.Event) { |
| 1030 | logger.Debugw(ctx, "UniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{ |
| 1031 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 1032 | mapGemPortParams := oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].mapGemPortParams |
| 1033 | unicastGemCount := 0 |
| 1034 | for _, gemEntry := range mapGemPortParams { |
| 1035 | if !gemEntry.isMulticast { |
| 1036 | unicastGemCount++ |
| 1037 | } |
| 1038 | } |
| 1039 | if unicastGemCount > 1 { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1040 | logger.Debugw(ctx, "UniPonAniConfigFsm - Not the last gem in fsm. Skip the rest", log.Fields{ |
| 1041 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)}) |
| 1042 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 1043 | if pConfigAniStateAFsm != nil { |
| 1044 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1045 | go func(aPAFsm *cmn.AdapterFsm) { |
| 1046 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 1047 | _ = aPAFsm.PFsm.Event(aniEvRemGemDone) |
Mahir Gunyel | 9545be2 | 2021-07-04 15:53:16 -0700 | [diff] [blame] | 1048 | } |
| 1049 | }(pConfigAniStateAFsm) |
| 1050 | return |
| 1051 | } |
| 1052 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1053 | logger.Debugw(ctx, "UniPonAniConfigFsm - Last gem in fsm. Continue with Mapper removal", log.Fields{ |
| 1054 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, "unicast-gem-count": unicastGemCount, "gem-count": len(mapGemPortParams)}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1055 | |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1056 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1057 | meInstance, err := oFsm.pOmciCC.SendDeleteDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1058 | oFsm.PAdaptFsm.CommChan, oFsm.mapperSP0ID) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1059 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1060 | logger.Errorw(ctx, "Dot1Mapper delete failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1061 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1062 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1063 | if pConfigAniStateAFsm != nil { |
| 1064 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 1065 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1066 | go func(aPAFsm *cmn.AdapterFsm) { |
| 1067 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 1068 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1069 | } |
| 1070 | }(pConfigAniStateAFsm) |
| 1071 | return |
| 1072 | } |
| 1073 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1074 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1075 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 1076 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1077 | } |
| 1078 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1079 | func (oFsm *UniPonAniConfigFsm) enterRemovingAniBPCD(ctx context.Context, e *fsm.Event) { |
| 1080 | logger.Debugw(ctx, "UniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{ |
| 1081 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1082 | |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1083 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1084 | meInstance, err := oFsm.pOmciCC.SendDeleteMBPConfigData(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1085 | oFsm.PAdaptFsm.CommChan, oFsm.macBPCD0ID) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1086 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1087 | logger.Errorw(ctx, "MBPConfigData delete failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1088 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1089 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1090 | if pConfigAniStateAFsm != nil { |
| 1091 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 1092 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1093 | go func(aPAFsm *cmn.AdapterFsm) { |
| 1094 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 1095 | _ = aPAFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1096 | } |
| 1097 | }(pConfigAniStateAFsm) |
| 1098 | return |
| 1099 | } |
| 1100 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1101 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1102 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1103 | } |
| 1104 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1105 | func (oFsm *UniPonAniConfigFsm) enterAniRemoveDone(ctx context.Context, e *fsm.Event) { |
| 1106 | logger.Debugw(ctx, "UniPonAniConfigFsm ani removal done", log.Fields{ |
| 1107 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1108 | //use DeviceHandler event notification directly |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1109 | oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset))) |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1110 | if oFsm.isChanSet() { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1111 | // indicate processing done to the caller |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1112 | logger.Debugw(ctx, "UniPonAniConfigFsm processingDone on channel", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1113 | "ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 1114 | oFsm.chSuccess <- oFsm.procStep |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1115 | oFsm.setChanSet(false) //reset the internal channel state |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1116 | } |
| 1117 | |
| 1118 | //let's reset the state machine in order to release all resources now |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1119 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1120 | if pConfigAniStateAFsm != nil { |
| 1121 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1122 | go func(aPAFsm *cmn.AdapterFsm) { |
| 1123 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 1124 | _ = aPAFsm.PFsm.Event(aniEvReset) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1125 | } |
| 1126 | }(pConfigAniStateAFsm) |
| 1127 | } |
| 1128 | } |
| 1129 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1130 | func (oFsm *UniPonAniConfigFsm) enterResettingState(ctx context.Context, e *fsm.Event) { |
| 1131 | logger.Debugw(ctx, "UniPonAniConfigFsm resetting", log.Fields{ |
| 1132 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1133 | |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 1134 | if oFsm.isChanSet() { |
| 1135 | // indicate processing error to the caller (in case there was still some open request) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1136 | logger.Debugw(ctx, "UniPonAniConfigFsm processingError on channel", log.Fields{ |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 1137 | "ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 1138 | //use non-blocking channel send to avoid blocking because of non-existing receiver |
| 1139 | // (even though the channel is checked on 'set', the outside receiver channel might (theoretically) already be deleted) |
| 1140 | select { |
| 1141 | case oFsm.chSuccess <- 0: |
| 1142 | default: |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1143 | logger.Debugw(ctx, "UniPonAniConfigFsm processingError not send on channel (no receiver)", log.Fields{ |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 1144 | "device-id": oFsm.deviceID}) |
| 1145 | } |
| 1146 | oFsm.setChanSet(false) //reset the internal channel state |
| 1147 | } |
| 1148 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1149 | pConfigAniStateAFsm := oFsm.PAdaptFsm |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1150 | if pConfigAniStateAFsm != nil { |
| 1151 | // abort running message processing |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1152 | fsmAbortMsg := cmn.Message{ |
| 1153 | Type: cmn.TestMsg, |
| 1154 | Data: cmn.TestMessage{ |
| 1155 | TestMessageVal: cmn.AbortMessageProcessing, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1156 | }, |
| 1157 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1158 | pConfigAniStateAFsm.CommChan <- fsmAbortMsg |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1159 | |
| 1160 | //try to restart the FSM to 'disabled', decouple event transfer |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1161 | go func(aPAFsm *cmn.AdapterFsm) { |
| 1162 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 1163 | _ = aPAFsm.PFsm.Event(aniEvRestart) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1164 | } |
| 1165 | }(pConfigAniStateAFsm) |
| 1166 | } |
| 1167 | } |
| 1168 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1169 | func (oFsm *UniPonAniConfigFsm) enterDisabledState(ctx context.Context, e *fsm.Event) { |
| 1170 | logger.Debugw(ctx, "UniPonAniConfigFsm enters disabled state", log.Fields{ |
| 1171 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1172 | oFsm.mutexPLastTxMeInstance.Lock() |
| 1173 | defer oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1174 | oFsm.pLastTxMeInstance = nil |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 1175 | } |
| 1176 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1177 | func (oFsm *UniPonAniConfigFsm) processOmciAniMessages(ctx context.Context) { |
| 1178 | logger.Debugw(ctx, "Start UniPonAniConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1179 | loop: |
| 1180 | for { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1181 | // case <-ctx.Done(): |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1182 | // logger.Info("MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1183 | // break loop |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1184 | message, ok := <-oFsm.PAdaptFsm.CommChan |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1185 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1186 | logger.Info(ctx, "UniPonAniConfigFsm Rx Msg - could not read from channel", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1187 | // but then we have to ensure a restart of the FSM as well - as exceptional procedure |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1188 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1189 | break loop |
| 1190 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1191 | logger.Debugw(ctx, "UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1192 | |
| 1193 | switch message.Type { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1194 | case cmn.TestMsg: |
| 1195 | msg, _ := message.Data.(cmn.TestMessage) |
| 1196 | if msg.TestMessageVal == cmn.AbortMessageProcessing { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1197 | logger.Infow(ctx, "UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1198 | break loop |
| 1199 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1200 | logger.Warnw(ctx, "UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1201 | case cmn.OMCI: |
| 1202 | msg, _ := message.Data.(cmn.OmciMessage) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1203 | oFsm.handleOmciAniConfigMessage(ctx, msg) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1204 | default: |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1205 | logger.Warn(ctx, "UniPonAniConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1206 | "message.Type": message.Type}) |
| 1207 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1208 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1209 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1210 | logger.Infow(ctx, "End UniPonAniConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1211 | } |
| 1212 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1213 | func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(ctx context.Context, msg cmn.OmciMessage) { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1214 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse) |
| 1215 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1216 | logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1217 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1218 | return |
| 1219 | } |
| 1220 | msgObj, msgOk := msgLayer.(*omci.CreateResponse) |
| 1221 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1222 | logger.Errorw(ctx, "Omci Msg layer could not be assigned for CreateResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1223 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1224 | return |
| 1225 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1226 | logger.Debugw(ctx, "CreateResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1227 | if msgObj.Result == me.Success || msgObj.Result == me.InstanceExists { |
| 1228 | //if the result is ok or Instance already exists (latest needed at least as long as we do not clear the OMCI techProfile data) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1229 | oFsm.mutexPLastTxMeInstance.RLock() |
| 1230 | if oFsm.pLastTxMeInstance != nil { |
| 1231 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 1232 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 1233 | // maybe we can use just the same eventName for different state transitions like "forward" |
| 1234 | // - might be checked, but so far I go for sure and have to inspect the concrete state events ... |
| 1235 | switch oFsm.pLastTxMeInstance.GetName() { |
| 1236 | case "Ieee8021PMapperServiceProfile": |
| 1237 | { // let the FSM proceed ... |
| 1238 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1239 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxDot1pmapCResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1240 | } |
| 1241 | case "MacBridgePortConfigurationData": |
| 1242 | { // let the FSM proceed ... |
| 1243 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1244 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxMbpcdResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1245 | } |
| 1246 | case "GemPortNetworkCtp", "GemInterworkingTerminationPoint", "MulticastGemInterworkingTerminationPoint": |
| 1247 | { // let aniConfig Multi-Id processing proceed by stopping the wait function |
| 1248 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1249 | oFsm.omciMIdsResponseReceived <- true |
| 1250 | } |
| 1251 | default: |
| 1252 | { |
| 1253 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1254 | logger.Warnw(ctx, "Unsupported ME name received!", |
| 1255 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID}) |
| 1256 | } |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1257 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1258 | } else { |
| 1259 | oFsm.mutexPLastTxMeInstance.RUnlock() |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1260 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1261 | } else { |
| 1262 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1263 | logger.Warnw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1264 | } |
| 1265 | } else { |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1266 | logger.Errorw(ctx, "Omci CreateResponse Error - later: drive FSM to abort state ?", |
| 1267 | log.Fields{"Error": msgObj.Result, "device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1268 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
| 1269 | return |
| 1270 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1271 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1272 | func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigSetFailResponseMessage(ctx context.Context, msgObj *omci.SetResponse) { |
Mahir Gunyel | 01034b6 | 2021-06-29 11:25:09 -0700 | [diff] [blame] | 1273 | //If TCONT fails, then we need to revert the allocated TCONT in DB. |
| 1274 | //Because FSMs are running sequentially, we don't expect the same TCONT hit by another tech-profile FSM while this FSM is running. |
| 1275 | oFsm.mutexPLastTxMeInstance.RLock() |
| 1276 | defer oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1277 | if oFsm.pLastTxMeInstance != nil && msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 1278 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 1279 | switch oFsm.pLastTxMeInstance.GetName() { |
| 1280 | case "TCont": |
| 1281 | //If this is for TCONT creation(requestEventOffset=0) and this is the first allocation of TCONT(so noone else is using the same TCONT) |
| 1282 | //We should revert DB |
| 1283 | if oFsm.requestEventOffset == 0 && !oFsm.tcontSetBefore && oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey] != nil { |
| 1284 | logger.Debugw(ctx, "UniPonAniConfigFsm TCONT creation failed on device. Freeing alloc id", log.Fields{"device-id": oFsm.deviceID, |
| 1285 | "alloc-id": oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID, "uni-tp": oFsm.uniTpKey}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1286 | if oFsm.pOnuDeviceEntry != nil { |
| 1287 | oFsm.pOnuDeviceEntry.FreeTcont(ctx, oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID) |
Mahir Gunyel | 01034b6 | 2021-06-29 11:25:09 -0700 | [diff] [blame] | 1288 | } else { |
| 1289 | logger.Warnw(ctx, "Unable to get device entry! couldn't free tcont", |
| 1290 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID}) |
| 1291 | } |
| 1292 | } |
| 1293 | default: |
| 1294 | logger.Warnw(ctx, "Unsupported ME name received with error!", |
| 1295 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "result": msgObj.Result, "device-id": oFsm.deviceID}) |
| 1296 | } |
| 1297 | } |
| 1298 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1299 | func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(ctx context.Context, msg cmn.OmciMessage) { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1300 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse) |
| 1301 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1302 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1303 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1304 | return |
| 1305 | } |
| 1306 | msgObj, msgOk := msgLayer.(*omci.SetResponse) |
| 1307 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1308 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be assigned for SetResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1309 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1310 | return |
| 1311 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1312 | logger.Debugw(ctx, "UniPonAniConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1313 | if msgObj.Result != me.Success { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1314 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci SetResponse Error - later: drive FSM to abort state ?", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1315 | log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1316 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 1317 | |
Mahir Gunyel | 01034b6 | 2021-06-29 11:25:09 -0700 | [diff] [blame] | 1318 | oFsm.handleOmciAniConfigSetFailResponseMessage(ctx, msgObj) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1319 | return |
| 1320 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1321 | oFsm.mutexPLastTxMeInstance.RLock() |
| 1322 | if oFsm.pLastTxMeInstance != nil { |
| 1323 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 1324 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 1325 | //store the created ME into DB //TODO??? obviously the Python code does not store the config ... |
| 1326 | // if, then something like: |
| 1327 | //oFsm.pOnuDB.StoreMe(msgObj) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1328 | |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1329 | switch oFsm.pLastTxMeInstance.GetName() { |
| 1330 | case "TCont": |
| 1331 | { // let the FSM proceed ... |
| 1332 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1333 | if oFsm.requestEventOffset == 0 { //from TCont config request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1334 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxTcontsResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1335 | } else { // from T-Cont reset request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1336 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxResetTcontResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1337 | } |
| 1338 | } |
| 1339 | case "PriorityQueue", "MulticastGemInterworkingTerminationPoint": |
| 1340 | { // let the PrioQueue init proceed by stopping the wait function |
| 1341 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1342 | oFsm.omciMIdsResponseReceived <- true |
| 1343 | } |
| 1344 | case "Ieee8021PMapperServiceProfile": |
| 1345 | { // let the FSM proceed ... |
| 1346 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1347 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxDot1pmapSResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1348 | } |
| 1349 | default: |
| 1350 | { |
| 1351 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1352 | logger.Warnw(ctx, "Unsupported ME name received!", |
| 1353 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1354 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1355 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1356 | } else { |
| 1357 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1358 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1359 | } else { |
| 1360 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1361 | logger.Warnw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1362 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1363 | } |
| 1364 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1365 | func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(ctx context.Context, msg cmn.OmciMessage) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1366 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeDeleteResponse) |
| 1367 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1368 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for DeleteResponse", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1369 | log.Fields{"device-id": oFsm.deviceID}) |
| 1370 | return |
| 1371 | } |
| 1372 | msgObj, msgOk := msgLayer.(*omci.DeleteResponse) |
| 1373 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1374 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be assigned for DeleteResponse", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1375 | log.Fields{"device-id": oFsm.deviceID}) |
| 1376 | return |
| 1377 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1378 | logger.Debugw(ctx, "UniPonAniConfigFsm DeleteResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1379 | if msgObj.Result != me.Success { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1380 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci DeleteResponse Error", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1381 | log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result}) |
| 1382 | //TODO: - later: possibly force FSM into abort or ignore some errors for some messages? |
| 1383 | // store error for mgmt display? |
| 1384 | return |
| 1385 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1386 | oFsm.mutexPLastTxMeInstance.RLock() |
| 1387 | if oFsm.pLastTxMeInstance != nil { |
| 1388 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 1389 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 1390 | //remove ME from DB //TODO??? obviously the Python code does not store/remove the config ... |
| 1391 | // if, then something like: oFsm.pOnuDB.XyyMe(msgObj) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1392 | |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1393 | switch oFsm.pLastTxMeInstance.GetName() { |
| 1394 | case "GemInterworkingTerminationPoint": |
| 1395 | { // let the FSM proceed ... |
| 1396 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1397 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemGemiwResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1398 | } |
| 1399 | case "GemPortNetworkCtp": |
| 1400 | { // let the FSM proceed ... |
| 1401 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1402 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemGemntpResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1403 | } |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 1404 | case "TrafficDescriptor": |
| 1405 | { // let the FSM proceed ... |
| 1406 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1407 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemTdResp) |
ozgecanetsia | a88b5ca | 2021-06-28 21:00:16 +0300 | [diff] [blame] | 1408 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1409 | case "Ieee8021PMapperServiceProfile": |
| 1410 | { // let the FSM proceed ... |
| 1411 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1412 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRem1pMapperResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1413 | } |
| 1414 | case "MacBridgePortConfigurationData": |
| 1415 | { // this is the last event of the T-Cont cleanup procedure, FSM may be reset here |
| 1416 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1417 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxRemAniBPCDResp) |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1418 | } |
| 1419 | default: |
| 1420 | { |
| 1421 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1422 | logger.Warnw(ctx, "Unsupported ME name received!", |
| 1423 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID}) |
| 1424 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1425 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1426 | } else { |
| 1427 | oFsm.mutexPLastTxMeInstance.RUnlock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1428 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1429 | } else { |
| 1430 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 1431 | logger.Warnw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1432 | } |
| 1433 | } |
| 1434 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1435 | func (oFsm *UniPonAniConfigFsm) handleOmciAniConfigMessage(ctx context.Context, msg cmn.OmciMessage) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1436 | logger.Debugw(ctx, "Rx OMCI UniPonAniConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1437 | "msgType": msg.OmciMsg.MessageType}) |
| 1438 | |
| 1439 | switch msg.OmciMsg.MessageType { |
| 1440 | case omci.CreateResponseType: |
| 1441 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1442 | oFsm.handleOmciAniConfigCreateResponseMessage(ctx, msg) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1443 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1444 | } //CreateResponseType |
| 1445 | case omci.SetResponseType: |
| 1446 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1447 | oFsm.handleOmciAniConfigSetResponseMessage(ctx, msg) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1448 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1449 | } //SetResponseType |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1450 | case omci.DeleteResponseType: |
| 1451 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1452 | oFsm.handleOmciAniConfigDeleteResponseMessage(ctx, msg) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1453 | |
ozgecanetsia | 72e1c9f | 2021-05-26 17:26:29 +0300 | [diff] [blame] | 1454 | } //DeleteResponseType |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1455 | default: |
| 1456 | { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1457 | logger.Errorw(ctx, "UniPonAniConfigFsm - Rx OMCI unhandled MsgType", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1458 | log.Fields{"omciMsgType": msg.OmciMsg.MessageType, "device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1459 | return |
| 1460 | } |
| 1461 | } |
| 1462 | } |
| 1463 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1464 | func (oFsm *UniPonAniConfigFsm) performCreatingGemNCTPs(ctx context.Context) { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1465 | // for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice |
| 1466 | for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1467 | logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1468 | "EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16), |
| 1469 | "TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1470 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1471 | meParams := me.ParamData{ |
| 1472 | EntityID: gemPortAttribs.gemPortID, //unique, same as PortId |
| 1473 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1474 | me.GemPortNetworkCtp_PortId: gemPortAttribs.gemPortID, |
| 1475 | me.GemPortNetworkCtp_TContPointer: oFsm.tcont0ID, |
| 1476 | me.GemPortNetworkCtp_Direction: gemPortAttribs.direction, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1477 | //ONU-G.TrafficManagementOption dependency ->PrioQueue or TCont |
| 1478 | // TODO!! verify dependency and QueueId in case of Multi-GemPort setup! |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1479 | me.GemPortNetworkCtp_TrafficManagementPointerForUpstream: gemPortAttribs.upQueueID, //might be different in wrr-only Setup - tcont0ID |
| 1480 | me.GemPortNetworkCtp_PriorityQueuePointerForDownStream: gemPortAttribs.downQueueID, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1481 | }, |
| 1482 | } |
Holger Hildebrandt | c408f49 | 2022-07-14 08:39:24 +0000 | [diff] [blame] | 1483 | if oFsm.techProfileType == cTechProfileTypeXgsPon { |
| 1484 | meParams.Attributes[me.GemPortNetworkCtp_EncryptionKeyRing] = GemEncryptKeyRingUnicastDownstreamOnly |
| 1485 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1486 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1487 | meInstance, err := oFsm.pOmciCC.SendCreateGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1488 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1489 | if err != nil { |
| 1490 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1491 | logger.Errorw(ctx, "GemNCTPVar create failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1492 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1493 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1494 | return |
| 1495 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1496 | //accept also nil as (error) return value for writing to LastTx |
| 1497 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1498 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1499 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1500 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1501 | err = oFsm.waitforOmciResponse(ctx) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1502 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1503 | logger.Errorw(ctx, "GemNWCtp create failed, aborting AniConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1504 | log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1505 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1506 | return |
| 1507 | } |
Girish Gowdra | 50e5642 | 2021-06-01 16:46:04 -0700 | [diff] [blame] | 1508 | // Mark the gem port to be added for Performance History monitoring |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1509 | OnuMetricsManager := oFsm.pDeviceHandler.GetOnuMetricsManager() |
| 1510 | if OnuMetricsManager != nil { |
| 1511 | OnuMetricsManager.AddGemPortForPerfMonitoring(ctx, gemPortAttribs.gemPortID) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 1512 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1513 | } //for all GemPorts of this T-Cont |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1514 | |
| 1515 | // if Config has been done for all GemPort instances let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1516 | logger.Debugw(ctx, "GemNWCtp create loop finished", log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1517 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxGemntcpsResp) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1518 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1519 | func (oFsm *UniPonAniConfigFsm) hasMulticastGem(ctx context.Context) bool { |
ozgecanetsia | 72e1c9f | 2021-05-26 17:26:29 +0300 | [diff] [blame] | 1520 | for _, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
| 1521 | if gemPortAttribs.isMulticast { |
| 1522 | logger.Debugw(ctx, "Found multicast gem", log.Fields{"device-id": oFsm.deviceID}) |
| 1523 | return true |
| 1524 | } |
| 1525 | } |
| 1526 | return false |
| 1527 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1528 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1529 | func (oFsm *UniPonAniConfigFsm) performCreatingGemIWs(ctx context.Context) { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1530 | // for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice |
| 1531 | for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1532 | logger.Debugw(ctx, "UniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1533 | "EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16), |
| 1534 | "SPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1535 | "device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1536 | |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1537 | //TODO if the port has only downstream direction the isMulticast flag can be removed. |
| 1538 | if gemPortAttribs.isMulticast { |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1539 | |
| 1540 | meParams := me.ParamData{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1541 | EntityID: gemPortAttribs.multicastGemID, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1542 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1543 | me.MulticastGemInterworkingTerminationPoint_GemPortNetworkCtpConnectivityPointer: gemPortAttribs.multicastGemID, |
| 1544 | me.MulticastGemInterworkingTerminationPoint_InterworkingOption: 0, // Don't Care |
| 1545 | me.MulticastGemInterworkingTerminationPoint_ServiceProfilePointer: 0, // Don't Care |
| 1546 | me.MulticastGemInterworkingTerminationPoint_GalProfilePointer: cmn.GalEthernetEID, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1547 | }, |
| 1548 | } |
ozgecanetsia | 72e1c9f | 2021-05-26 17:26:29 +0300 | [diff] [blame] | 1549 | if oFsm.pUniTechProf.multicastConfiguredForOtherUniTps(ctx, oFsm.uniTpKey) { |
| 1550 | logger.Debugw(ctx, "MulticastGemInterworkingTP already exist", log.Fields{"device-id": oFsm.deviceID, "multicast-gem-id": gemPortAttribs.multicastGemID}) |
| 1551 | continue |
| 1552 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1553 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1554 | meInstance, err := oFsm.pOmciCC.SendCreateMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), |
| 1555 | true, oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1556 | if err != nil { |
| 1557 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1558 | logger.Errorw(ctx, "MulticastGemIWTPVar create failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1559 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1560 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1561 | return |
| 1562 | |
| 1563 | } |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1564 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1565 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1566 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1567 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1568 | if err != nil { |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1569 | logger.Errorw(ctx, "MulticastGemIWTP create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1570 | log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1571 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1572 | return |
| 1573 | } |
| 1574 | ipv4MulticastTable := make([]uint8, 12) |
| 1575 | //Gem Port ID |
| 1576 | binary.BigEndian.PutUint16(ipv4MulticastTable[0:], gemPortAttribs.multicastGemID) |
| 1577 | //Secondary Key |
| 1578 | binary.BigEndian.PutUint16(ipv4MulticastTable[2:], 0) |
| 1579 | // Multicast IP range start This is the 224.0.0.1 address |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1580 | binary.BigEndian.PutUint32(ipv4MulticastTable[4:], cmn.IPToInt32(net.IPv4(224, 0, 0, 0))) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1581 | // MulticastIp range stop |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1582 | binary.BigEndian.PutUint32(ipv4MulticastTable[8:], cmn.IPToInt32(net.IPv4(239, 255, 255, 255))) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1583 | |
| 1584 | meIPV4MCTableParams := me.ParamData{ |
| 1585 | EntityID: gemPortAttribs.multicastGemID, |
| 1586 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1587 | me.MulticastGemInterworkingTerminationPoint_Ipv4MulticastAddressTable: ipv4MulticastTable, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1588 | }, |
| 1589 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1590 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1591 | meIPV4MCTableInstance, err := oFsm.pOmciCC.SendSetMulticastGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), |
| 1592 | true, oFsm.PAdaptFsm.CommChan, meIPV4MCTableParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1593 | if err != nil { |
| 1594 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1595 | logger.Errorw(ctx, "MulticastGemIWTPVar set failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1596 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1597 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1598 | return |
| 1599 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1600 | oFsm.pLastTxMeInstance = meIPV4MCTableInstance |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1601 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1602 | |
| 1603 | } else { |
| 1604 | meParams := me.ParamData{ |
| 1605 | EntityID: gemPortAttribs.gemPortID, |
| 1606 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1607 | me.GemInterworkingTerminationPoint_GemPortNetworkCtpConnectivityPointer: gemPortAttribs.gemPortID, //same as EntityID, see above |
| 1608 | me.GemInterworkingTerminationPoint_InterworkingOption: 5, //fixed model:: G.998 .1pMapper |
| 1609 | me.GemInterworkingTerminationPoint_ServiceProfilePointer: oFsm.mapperSP0ID, |
| 1610 | me.GemInterworkingTerminationPoint_InterworkingTerminationPointPointer: 0, //not used with .1PMapper Mac bridge |
| 1611 | me.GemInterworkingTerminationPoint_GalProfilePointer: cmn.GalEthernetEID, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1612 | }, |
| 1613 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1614 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1615 | meInstance, err := oFsm.pOmciCC.SendCreateGemIWTPVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1616 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1617 | if err != nil { |
| 1618 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1619 | logger.Errorw(ctx, "GEMIWTPVar create failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1620 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1621 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1622 | return |
| 1623 | } |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1624 | //accept also nil as (error) return value for writing to LastTx |
| 1625 | // - this avoids misinterpretation of new received OMCI messages |
| 1626 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1627 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1628 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1629 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1630 | err := oFsm.waitforOmciResponse(ctx) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1631 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1632 | logger.Errorw(ctx, "GemTP create failed, aborting AniConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1633 | log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1634 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1635 | return |
| 1636 | } |
| 1637 | } //for all GemPort's of this T-Cont |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1638 | |
| 1639 | // if Config has been done for all GemPort instances let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1640 | logger.Debugw(ctx, "GemIwTp create loop finished", log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1641 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxGemiwsResp) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1642 | } |
| 1643 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1644 | func (oFsm *UniPonAniConfigFsm) performSettingPQs(ctx context.Context) { |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 1645 | //If upstream PQs were set before, then no need to set them again. Let state machine to proceed. |
| 1646 | if oFsm.tcontSetBefore { |
| 1647 | logger.Debugw(ctx, "No need to set PQs again.", log.Fields{ |
| 1648 | "device-id": oFsm.deviceID, "tcont": oFsm.alloc0ID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1649 | "uni-id": oFsm.pOnuUniPort.UniID, |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 1650 | "techProfile-id": oFsm.techProfileID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1651 | go func(aPAFsm *cmn.AdapterFsm) { |
| 1652 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
| 1653 | _ = aPAFsm.PFsm.Event(aniEvRxPrioqsResp) |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 1654 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1655 | }(oFsm.PAdaptFsm) |
Mahir Gunyel | 7f4483a | 2021-05-06 12:53:43 -0700 | [diff] [blame] | 1656 | return |
| 1657 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1658 | const cu16StrictPrioWeight uint16 = 0xFFFF |
| 1659 | //find all upstream PrioQueues related to this T-Cont |
| 1660 | loQueueMap := ordered_map.NewOrderedMap() |
| 1661 | for _, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1662 | if gemPortAttribs.isMulticast { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1663 | logger.Debugw(ctx, "UniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1664 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
| 1665 | "prioString": gemPortAttribs.pbitString}) |
| 1666 | continue |
| 1667 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1668 | if gemPortAttribs.qosPolicy == "WRR" { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1669 | if _, ok := loQueueMap.Get(gemPortAttribs.upQueueID); !ok { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1670 | //key does not yet exist |
| 1671 | loQueueMap.Set(gemPortAttribs.upQueueID, uint16(gemPortAttribs.weight)) |
| 1672 | } |
| 1673 | } else { |
| 1674 | loQueueMap.Set(gemPortAttribs.upQueueID, cu16StrictPrioWeight) //use invalid weight value to indicate SP |
| 1675 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1676 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1677 | |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1678 | trafficSchedPtrSetSupported := false |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1679 | loOnu2g := oFsm.pOnuDB.GetMe(me.Onu2GClassID, cmn.Onu2gMeID) |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1680 | if loOnu2g == nil { |
| 1681 | logger.Errorw(ctx, "onu2g is nil, cannot read qos configuration flexibility parameter", |
| 1682 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1683 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1684 | return |
| 1685 | } |
| 1686 | returnVal := loOnu2g["QualityOfServiceQosConfigurationFlexibility"] |
| 1687 | if returnVal != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1688 | if qosCfgFlexParam, err := oFsm.pOnuDB.GetUint16Attrib(returnVal); err == nil { |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1689 | trafficSchedPtrSetSupported = qosCfgFlexParam&bitTrafficSchedulerPtrSetPermitted == bitTrafficSchedulerPtrSetPermitted |
| 1690 | logger.Debugw(ctx, "trafficSchedPtrSetSupported set", |
| 1691 | log.Fields{"qosCfgFlexParam": qosCfgFlexParam, "trafficSchedPtrSetSupported": trafficSchedPtrSetSupported}) |
| 1692 | } else { |
| 1693 | logger.Errorw(ctx, "Cannot extract qos configuration flexibility parameter", |
| 1694 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1695 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1696 | return |
| 1697 | } |
| 1698 | } else { |
| 1699 | logger.Errorw(ctx, "Cannot read qos configuration flexibility parameter", |
| 1700 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1701 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1702 | return |
| 1703 | } |
| 1704 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1705 | //TODO: assumption here is that ONU data uses SP setting in the T-Cont and WRR in the TrafficScheduler |
| 1706 | // if that is not the case, the reverse case could be checked and reacted accordingly or if the |
| 1707 | // complete chain is not valid, then some error should be thrown and configuration can be aborted |
| 1708 | // or even be finished without correct SP/WRR setting |
| 1709 | |
| 1710 | //TODO: search for the (WRR)trafficScheduler related to the T-Cont of this queue |
| 1711 | //By now assume fixed value 0x8000, which is the only announce BBSIM TrafficScheduler, |
| 1712 | // even though its T-Cont seems to be wrong ... |
| 1713 | loTrafficSchedulerEID := 0x8000 |
| 1714 | //for all found queues |
| 1715 | iter := loQueueMap.IterFunc() |
| 1716 | for kv, ok := iter(); ok; kv, ok = iter() { |
| 1717 | queueIndex := (kv.Key).(uint16) |
| 1718 | meParams := me.ParamData{ |
| 1719 | EntityID: queueIndex, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1720 | Attributes: make(me.AttributeValueMap), |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1721 | } |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1722 | if trafficSchedPtrSetSupported { |
| 1723 | if (kv.Value).(uint16) == cu16StrictPrioWeight { |
| 1724 | //StrictPrio indication |
| 1725 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to StrictPrio", log.Fields{ |
| 1726 | "EntitytId": strconv.FormatInt(int64(queueIndex), 16), |
| 1727 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1728 | meParams.Attributes[me.PriorityQueue_TrafficSchedulerPointer] = 0 //ensure T-Cont defined StrictPrio scheduling |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1729 | } else { |
| 1730 | //WRR indication |
| 1731 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to WRR", log.Fields{ |
| 1732 | "EntitytId": strconv.FormatInt(int64(queueIndex), 16), |
| 1733 | "Weight": kv.Value, |
| 1734 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1735 | meParams.Attributes[me.PriorityQueue_TrafficSchedulerPointer] = loTrafficSchedulerEID //ensure assignment of the relevant trafficScheduler |
| 1736 | meParams.Attributes[me.PriorityQueue_Weight] = uint8(kv.Value.(uint16)) |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1737 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1738 | } else { |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 1739 | // setting Traffic Scheduler (TS) pointer is not supported unless we point to another TS that points to the same TCONT. |
| 1740 | // For now lets use TS that is hardwired in the ONU and just update the weight in case of WRR, which in fact is all we need at the moment. |
| 1741 | // The code could get unnecessarily convoluted if we provide the flexibility try to find and point to another TS that points to the same TCONT. |
| 1742 | if (kv.Value).(uint16) == cu16StrictPrioWeight { // SP case, nothing to be done. Proceed to the next queue |
| 1743 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to StrictPrio, traffic sched ptr set unsupported", log.Fields{ |
| 1744 | "EntitytId": strconv.FormatInt(int64(queueIndex), 16), |
| 1745 | "device-id": oFsm.deviceID}) |
| 1746 | continue |
| 1747 | } |
| 1748 | // WRR case, update weight. |
| 1749 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to WRR, traffic sched ptr set unsupported", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1750 | "EntitytId": strconv.FormatInt(int64(queueIndex), 16), |
| 1751 | "Weight": kv.Value, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1752 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1753 | meParams.Attributes[me.PriorityQueue_Weight] = uint8(kv.Value.(uint16)) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1754 | } |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1755 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1756 | meInstance, err := oFsm.pOmciCC.SendSetPrioQueueVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1757 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1758 | if err != nil { |
| 1759 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1760 | logger.Errorw(ctx, "PrioQueueVar set failed, aborting UniPonAniConfigFsm!", |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1761 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1762 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1763 | return |
| 1764 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1765 | //accept also nil as (error) return value for writing to LastTx |
| 1766 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1767 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 9902b2b | 2021-04-21 14:52:32 +0000 | [diff] [blame] | 1768 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1769 | |
| 1770 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1771 | err = oFsm.waitforOmciResponse(ctx) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1772 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1773 | logger.Errorw(ctx, "PrioQueue set failed, aborting AniConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1774 | log.Fields{"device-id": oFsm.deviceID, "QueueId": strconv.FormatInt(int64(queueIndex), 16)}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1775 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvReset) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1776 | return |
| 1777 | } |
| 1778 | |
| 1779 | //TODO: In case of WRR setting of the GemPort/PrioQueue it might further be necessary to |
| 1780 | // write the assigned trafficScheduler with the requested Prio to be considered in the StrictPrio scheduling |
| 1781 | // of the (next upstream) assigned T-Cont, which is f(prioQueue[priority]) - in relation to other SP prioQueues |
| 1782 | // not yet done because of BBSIM TrafficScheduler issues (and not done in py code as well) |
| 1783 | |
| 1784 | } //for all upstream prioQueues |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1785 | |
| 1786 | // if Config has been done for all PrioQueue instances let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1787 | logger.Debugw(ctx, "PrioQueue set loop finished", log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1788 | _ = oFsm.PAdaptFsm.PFsm.Event(aniEvRxPrioqsResp) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1789 | } |
| 1790 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1791 | func (oFsm *UniPonAniConfigFsm) waitforOmciResponse(ctx context.Context) error { |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 1792 | oFsm.mutexIsAwaitingResponse.Lock() |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 1793 | if oFsm.isCanceled { |
| 1794 | // FSM already canceled before entering wait |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1795 | logger.Debugw(ctx, "UniPonAniConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 1796 | oFsm.mutexIsAwaitingResponse.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1797 | return fmt.Errorf(cmn.CErrWaitAborted) |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 1798 | } |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 1799 | oFsm.isAwaitingResponse = true |
| 1800 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1801 | select { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1802 | // maybe be also some outside cancel (but no context modeled for the moment ...) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1803 | // case <-ctx.Done(): |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1804 | // logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 1805 | case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //3s was detected to be to less in 8*8 bbsim test with debug Info/Debug |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1806 | logger.Warnw(ctx, "UniPonAniConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 1807 | oFsm.mutexIsAwaitingResponse.Lock() |
| 1808 | oFsm.isAwaitingResponse = false |
| 1809 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1810 | return fmt.Errorf("uniPonAniConfigFsm multi entity timeout %s", oFsm.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1811 | case success := <-oFsm.omciMIdsResponseReceived: |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1812 | if success { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1813 | logger.Debugw(ctx, "UniPonAniConfigFsm multi entity response received", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 1814 | oFsm.mutexIsAwaitingResponse.Lock() |
| 1815 | oFsm.isAwaitingResponse = false |
| 1816 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1817 | return nil |
| 1818 | } |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 1819 | // waiting was aborted (probably on external request) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1820 | logger.Debugw(ctx, "UniPonAniConfigFsm wait-for-multi-entity-response aborted", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 1821 | oFsm.mutexIsAwaitingResponse.Lock() |
| 1822 | oFsm.isAwaitingResponse = false |
| 1823 | oFsm.mutexIsAwaitingResponse.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1824 | return fmt.Errorf(cmn.CErrWaitAborted) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1825 | } |
| 1826 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1827 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1828 | func (oFsm *UniPonAniConfigFsm) setChanSet(flagValue bool) { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1829 | oFsm.mutexChanSet.Lock() |
| 1830 | oFsm.chanSet = flagValue |
| 1831 | oFsm.mutexChanSet.Unlock() |
| 1832 | } |
| 1833 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1834 | func (oFsm *UniPonAniConfigFsm) isChanSet() bool { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1835 | oFsm.mutexChanSet.RLock() |
| 1836 | flagValue := oFsm.chanSet |
| 1837 | oFsm.mutexChanSet.RUnlock() |
| 1838 | return flagValue |
| 1839 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 1840 | |
| 1841 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 1842 | func (oFsm *UniPonAniConfigFsm) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 1843 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": oFsm.deviceID}) |
| 1844 | oFsm.pDeviceHandler = nil |
| 1845 | oFsm.pOnuDeviceEntry = nil |
| 1846 | oFsm.pOmciCC = nil |
| 1847 | } |