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