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