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 | |
| 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
| 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" |
| 26 | "time" |
| 27 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 28 | "github.com/cevaris/ordered_map" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 29 | "github.com/looplab/fsm" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 30 | "github.com/opencord/omci-lib-go" |
| 31 | me "github.com/opencord/omci-lib-go/generated" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 32 | "github.com/opencord/voltha-lib-go/v4/pkg/log" |
| 33 | //ic "github.com/opencord/voltha-protos/v4/go/inter_container" |
| 34 | //"github.com/opencord/voltha-protos/v4/go/openflow_13" |
| 35 | //"github.com/opencord/voltha-protos/v4/go/voltha" |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 36 | ) |
| 37 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 38 | const ( |
| 39 | // events of config PON ANI port FSM |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 40 | aniEvStart = "aniEvStart" |
| 41 | aniEvStartConfig = "aniEvStartConfig" |
| 42 | aniEvRxDot1pmapCResp = "aniEvRxDot1pmapCResp" |
| 43 | aniEvRxMbpcdResp = "aniEvRxMbpcdResp" |
| 44 | aniEvRxTcontsResp = "aniEvRxTcontsResp" |
| 45 | aniEvRxGemntcpsResp = "aniEvRxGemntcpsResp" |
| 46 | aniEvRxGemiwsResp = "aniEvRxGemiwsResp" |
| 47 | aniEvRxPrioqsResp = "aniEvRxPrioqsResp" |
| 48 | aniEvRxDot1pmapSResp = "aniEvRxDot1pmapSResp" |
| 49 | aniEvRemGemiw = "aniEvRemGemiw" |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 50 | aniEvWaitFlowRem = "aniEvWaitFlowRem" |
| 51 | aniEvFlowRemDone = "aniEvFlowRemDone" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 52 | aniEvRxRemGemiwResp = "aniEvRxRemGemiwResp" |
| 53 | aniEvRxRemGemntpResp = "aniEvRxRemGemntpResp" |
| 54 | aniEvRemTcontPath = "aniEvRemTcontPath" |
| 55 | aniEvRxResetTcontResp = "aniEvRxResetTcontResp" |
| 56 | aniEvRxRem1pMapperResp = "aniEvRxRem1pMapperResp" |
| 57 | aniEvRxRemAniBPCDResp = "aniEvRxRemAniBPCDResp" |
| 58 | aniEvTimeoutSimple = "aniEvTimeoutSimple" |
| 59 | aniEvTimeoutMids = "aniEvTimeoutMids" |
| 60 | aniEvReset = "aniEvReset" |
| 61 | aniEvRestart = "aniEvRestart" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 62 | ) |
| 63 | const ( |
| 64 | // states of config PON ANI port FSM |
| 65 | aniStDisabled = "aniStDisabled" |
| 66 | aniStStarting = "aniStStarting" |
| 67 | aniStCreatingDot1PMapper = "aniStCreatingDot1PMapper" |
| 68 | aniStCreatingMBPCD = "aniStCreatingMBPCD" |
| 69 | aniStSettingTconts = "aniStSettingTconts" |
| 70 | aniStCreatingGemNCTPs = "aniStCreatingGemNCTPs" |
| 71 | aniStCreatingGemIWs = "aniStCreatingGemIWs" |
| 72 | aniStSettingPQs = "aniStSettingPQs" |
| 73 | aniStSettingDot1PMapper = "aniStSettingDot1PMapper" |
| 74 | aniStConfigDone = "aniStConfigDone" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 75 | aniStRemovingGemIW = "aniStRemovingGemIW" |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 76 | aniStWaitingFlowRem = "aniStWaitingFlowRem" |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 77 | aniStRemovingGemNCTP = "aniStRemovingGemNCTP" |
| 78 | aniStResetTcont = "aniStResetTcont" |
| 79 | aniStRemDot1PMapper = "aniStRemDot1PMapper" |
| 80 | aniStRemAniBPCD = "aniStRemAniBPCD" |
| 81 | aniStRemoveDone = "aniStRemoveDone" |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 82 | aniStResetting = "aniStResetting" |
| 83 | ) |
Holger Hildebrandt | 10d9819 | 2021-01-27 15:29:31 +0000 | [diff] [blame] | 84 | const cAniFsmIdleState = aniStConfigDone |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 85 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 86 | const ( |
| 87 | tpIDOffset = 64 |
| 88 | ) |
| 89 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 90 | type ponAniGemPortAttribs struct { |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 91 | gemPortID uint16 |
| 92 | upQueueID uint16 |
| 93 | downQueueID uint16 |
| 94 | direction uint8 |
| 95 | qosPolicy string |
| 96 | weight uint8 |
| 97 | pbitString string |
| 98 | isMulticast bool |
| 99 | multicastGemID uint16 |
| 100 | staticACL string |
| 101 | dynamicACL string |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 104 | //uniPonAniConfigFsm defines the structure for the state machine to config the PON ANI ports of ONU UNI ports via OMCI |
| 105 | type uniPonAniConfigFsm struct { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 106 | pDeviceHandler *deviceHandler |
| 107 | deviceID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 108 | pOmciCC *omciCC |
| 109 | pOnuUniPort *onuUniPort |
| 110 | pUniTechProf *onuUniTechProf |
| 111 | pOnuDB *onuDeviceDB |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 112 | techProfileID uint8 |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 113 | uniTpKey uniTP |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 114 | requestEvent OnuDeviceEvent |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 115 | omciMIdsResponseReceived chan bool //separate channel needed for checking multiInstance OMCI message responses |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 116 | pAdaptFsm *AdapterFsm |
| 117 | chSuccess chan<- uint8 |
| 118 | procStep uint8 |
| 119 | chanSet bool |
| 120 | mapperSP0ID uint16 |
| 121 | macBPCD0ID uint16 |
| 122 | tcont0ID uint16 |
| 123 | alloc0ID uint16 |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 124 | gemPortAttribsSlice []ponAniGemPortAttribs |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 125 | pLastTxMeInstance *me.ManagedEntity |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 126 | requestEventOffset uint8 //used to indicate ConfigDone or Removed using successor (enum) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 129 | //newUniPonAniConfigFsm is the 'constructor' for the state machine to config the PON ANI ports of ONU UNI ports via OMCI |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 130 | func newUniPonAniConfigFsm(ctx context.Context, apDevOmciCC *omciCC, apUniPort *onuUniPort, apUniTechProf *onuUniTechProf, |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 131 | apOnuDB *onuDeviceDB, aTechProfileID uint8, aRequestEvent OnuDeviceEvent, aName string, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 132 | apDeviceHandler *deviceHandler, aCommChannel chan Message) *uniPonAniConfigFsm { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 133 | instFsm := &uniPonAniConfigFsm{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 134 | pDeviceHandler: apDeviceHandler, |
| 135 | deviceID: apDeviceHandler.deviceID, |
| 136 | pOmciCC: apDevOmciCC, |
| 137 | pOnuUniPort: apUniPort, |
| 138 | pUniTechProf: apUniTechProf, |
| 139 | pOnuDB: apOnuDB, |
| 140 | techProfileID: aTechProfileID, |
| 141 | requestEvent: aRequestEvent, |
| 142 | chanSet: false, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 143 | } |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 144 | instFsm.uniTpKey = uniTP{uniID: apUniPort.uniID, tpID: aTechProfileID} |
| 145 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 146 | instFsm.pAdaptFsm = NewAdapterFsm(aName, instFsm.deviceID, aCommChannel) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 147 | if instFsm.pAdaptFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 148 | logger.Errorw(ctx, "uniPonAniConfigFsm's AdapterFsm could not be instantiated!!", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 149 | "device-id": instFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 150 | return nil |
| 151 | } |
| 152 | |
| 153 | instFsm.pAdaptFsm.pFsm = fsm.NewFSM( |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 154 | aniStDisabled, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 155 | fsm.Events{ |
| 156 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 157 | {Name: aniEvStart, Src: []string{aniStDisabled}, Dst: aniStStarting}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 158 | |
| 159 | //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] | 160 | {Name: aniEvStartConfig, Src: []string{aniStStarting}, Dst: aniStCreatingDot1PMapper}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 161 | {Name: aniEvRxDot1pmapCResp, Src: []string{aniStCreatingDot1PMapper}, Dst: aniStCreatingMBPCD}, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 162 | {Name: aniEvRxMbpcdResp, Src: []string{aniStCreatingMBPCD}, Dst: aniStSettingTconts}, |
| 163 | {Name: aniEvRxTcontsResp, Src: []string{aniStSettingTconts}, Dst: aniStCreatingGemNCTPs}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 164 | // 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] | 165 | {Name: aniEvRxGemntcpsResp, Src: []string{aniStCreatingGemNCTPs}, Dst: aniStCreatingGemIWs}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 166 | // 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] | 167 | {Name: aniEvRxGemiwsResp, Src: []string{aniStCreatingGemIWs}, Dst: aniStSettingPQs}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 168 | // 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] | 169 | {Name: aniEvRxPrioqsResp, Src: []string{aniStSettingPQs}, Dst: aniStSettingDot1PMapper}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 170 | {Name: aniEvRxDot1pmapSResp, Src: []string{aniStSettingDot1PMapper}, Dst: aniStConfigDone}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 171 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 172 | //for removing Gem related resources |
| 173 | {Name: aniEvRemGemiw, Src: []string{aniStConfigDone}, Dst: aniStRemovingGemIW}, |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 174 | {Name: aniEvWaitFlowRem, Src: []string{aniStRemovingGemIW}, Dst: aniStWaitingFlowRem}, |
| 175 | {Name: aniEvFlowRemDone, Src: []string{aniStWaitingFlowRem}, Dst: aniStRemovingGemIW}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 176 | {Name: aniEvRxRemGemiwResp, Src: []string{aniStRemovingGemIW}, Dst: aniStRemovingGemNCTP}, |
| 177 | {Name: aniEvRxRemGemntpResp, Src: []string{aniStRemovingGemNCTP}, Dst: aniStConfigDone}, |
| 178 | |
| 179 | //for removing TCONT related resources |
| 180 | {Name: aniEvRemTcontPath, Src: []string{aniStConfigDone}, Dst: aniStResetTcont}, |
| 181 | {Name: aniEvRxResetTcontResp, Src: []string{aniStResetTcont}, Dst: aniStRemDot1PMapper}, |
| 182 | {Name: aniEvRxRem1pMapperResp, Src: []string{aniStRemDot1PMapper}, Dst: aniStRemAniBPCD}, |
| 183 | {Name: aniEvRxRemAniBPCDResp, Src: []string{aniStRemAniBPCD}, Dst: aniStRemoveDone}, |
| 184 | |
| 185 | {Name: aniEvTimeoutSimple, Src: []string{aniStCreatingDot1PMapper, aniStCreatingMBPCD, aniStSettingTconts, aniStSettingDot1PMapper, |
| 186 | aniStRemovingGemIW, aniStRemovingGemNCTP, |
| 187 | aniStResetTcont, aniStRemDot1PMapper, aniStRemAniBPCD, aniStRemoveDone}, Dst: aniStStarting}, |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 188 | {Name: aniEvTimeoutMids, Src: []string{ |
| 189 | aniStCreatingGemNCTPs, aniStCreatingGemIWs, aniStSettingPQs}, Dst: aniStStarting}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 190 | |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 191 | // exceptional treatment for all states except aniStResetting |
| 192 | {Name: aniEvReset, Src: []string{aniStStarting, aniStCreatingDot1PMapper, aniStCreatingMBPCD, |
| 193 | aniStSettingTconts, aniStCreatingGemNCTPs, aniStCreatingGemIWs, aniStSettingPQs, aniStSettingDot1PMapper, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 194 | aniStConfigDone, aniStRemovingGemIW, aniStRemovingGemNCTP, |
| 195 | aniStResetTcont, aniStRemDot1PMapper, aniStRemAniBPCD, aniStRemoveDone}, Dst: aniStResetting}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 196 | // 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] | 197 | {Name: aniEvRestart, Src: []string{aniStResetting}, Dst: aniStDisabled}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 198 | }, |
| 199 | |
| 200 | fsm.Callbacks{ |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 201 | "enter_state": func(e *fsm.Event) { instFsm.pAdaptFsm.logFsmStateChange(ctx, e) }, |
| 202 | ("enter_" + aniStStarting): func(e *fsm.Event) { instFsm.enterConfigStartingState(ctx, e) }, |
| 203 | ("enter_" + aniStCreatingDot1PMapper): func(e *fsm.Event) { instFsm.enterCreatingDot1PMapper(ctx, e) }, |
| 204 | ("enter_" + aniStCreatingMBPCD): func(e *fsm.Event) { instFsm.enterCreatingMBPCD(ctx, e) }, |
| 205 | ("enter_" + aniStSettingTconts): func(e *fsm.Event) { instFsm.enterSettingTconts(ctx, e) }, |
| 206 | ("enter_" + aniStCreatingGemNCTPs): func(e *fsm.Event) { instFsm.enterCreatingGemNCTPs(ctx, e) }, |
| 207 | ("enter_" + aniStCreatingGemIWs): func(e *fsm.Event) { instFsm.enterCreatingGemIWs(ctx, e) }, |
| 208 | ("enter_" + aniStSettingPQs): func(e *fsm.Event) { instFsm.enterSettingPQs(ctx, e) }, |
| 209 | ("enter_" + aniStSettingDot1PMapper): func(e *fsm.Event) { instFsm.enterSettingDot1PMapper(ctx, e) }, |
| 210 | ("enter_" + aniStConfigDone): func(e *fsm.Event) { instFsm.enterAniConfigDone(ctx, e) }, |
| 211 | ("enter_" + aniStRemovingGemIW): func(e *fsm.Event) { instFsm.enterRemovingGemIW(ctx, e) }, |
| 212 | ("enter_" + aniStRemovingGemNCTP): func(e *fsm.Event) { instFsm.enterRemovingGemNCTP(ctx, e) }, |
| 213 | ("enter_" + aniStResetTcont): func(e *fsm.Event) { instFsm.enterResettingTcont(ctx, e) }, |
| 214 | ("enter_" + aniStRemDot1PMapper): func(e *fsm.Event) { instFsm.enterRemoving1pMapper(ctx, e) }, |
| 215 | ("enter_" + aniStRemAniBPCD): func(e *fsm.Event) { instFsm.enterRemovingAniBPCD(ctx, e) }, |
| 216 | ("enter_" + aniStRemoveDone): func(e *fsm.Event) { instFsm.enterAniRemoveDone(ctx, e) }, |
| 217 | ("enter_" + aniStResetting): func(e *fsm.Event) { instFsm.enterResettingState(ctx, e) }, |
| 218 | ("enter_" + aniStDisabled): func(e *fsm.Event) { instFsm.enterDisabledState(ctx, e) }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 219 | }, |
| 220 | ) |
| 221 | if instFsm.pAdaptFsm.pFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 222 | logger.Errorw(ctx, "uniPonAniConfigFsm's Base FSM could not be instantiated!!", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 223 | "device-id": instFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 224 | return nil |
| 225 | } |
| 226 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 227 | logger.Debugw(ctx, "uniPonAniConfigFsm created", log.Fields{"device-id": instFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 228 | return instFsm |
| 229 | } |
| 230 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 231 | //setFsmCompleteChannel sets the requested channel and channel result for transfer on success |
| 232 | func (oFsm *uniPonAniConfigFsm) setFsmCompleteChannel(aChSuccess chan<- uint8, aProcStep uint8) { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 233 | oFsm.chSuccess = aChSuccess |
| 234 | oFsm.procStep = aProcStep |
| 235 | oFsm.chanSet = true |
| 236 | } |
| 237 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 238 | func (oFsm *uniPonAniConfigFsm) prepareAndEnterConfigState(ctx context.Context, aPAFsm *AdapterFsm) { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 239 | if aPAFsm != nil && aPAFsm.pFsm != nil { |
| 240 | //stick to pythonAdapter numbering scheme |
| 241 | //index 0 in naming refers to possible usage of multiple instances (later) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 242 | oFsm.mapperSP0ID = ieeeMapperServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo) + uint16(oFsm.techProfileID) |
| 243 | oFsm.macBPCD0ID = macBridgePortAniEID + uint16(oFsm.pOnuUniPort.entityID) + uint16(oFsm.techProfileID) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 244 | |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 245 | /* |
| 246 | // Find a free TCONT Instance ID and use it |
| 247 | foundFreeTcontInstID := false |
| 248 | */ |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 249 | if tcontInstKeys := oFsm.pOnuDB.getSortedInstKeys(ctx, me.TContClassID); len(tcontInstKeys) > 0 { |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 250 | |
| 251 | // FIXME: Ideally the ME configurations on the ONU should constantly be MIB Synced back to the ONU DB |
| 252 | // So, as soon as we use up a TCONT Entity on the ONU, the DB at ONU adapter should know that the TCONT |
| 253 | // entity is used up via MIB Sync procedure and it will not use it for subsequent TCONT on that ONU. |
| 254 | // But, it seems, due to the absence of the constant mib-sync procedure, the TCONT Entities show up as |
| 255 | // free even though they are already reserved on the ONU. It seems the mib is synced only once, initially |
| 256 | // when the ONU is discovered. |
| 257 | /* |
| 258 | for _, tcontInstID := range tcontInstKeys { |
| 259 | tconInst := oFsm.pOnuDB.GetMe(me.TContClassID, tcontInstID) |
| 260 | returnVal := tconInst["AllocId"] |
| 261 | if returnVal != nil { |
| 262 | if allocID, err := oFsm.pOnuDB.getUint16Attrib(returnVal); err == nil { |
| 263 | // If the TCONT Instance ID is set to 0xff or 0xffff, it means it is free to use. |
| 264 | if allocID == 0xff || allocID == 0xffff { |
| 265 | foundFreeTcontInstID = true |
| 266 | oFsm.tcont0ID = uint16(tcontInstID) |
| 267 | logger.Debugw("Used TcontId:", log.Fields{"TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16), |
| 268 | "device-id": oFsm.deviceID}) |
| 269 | break |
| 270 | } |
| 271 | } else { |
| 272 | logger.Errorw("error-converting-alloc-id-to-uint16", log.Fields{"device-id": oFsm.deviceID, "tcont-inst": tcontInstID}) |
| 273 | } |
| 274 | } else { |
| 275 | logger.Errorw("error-extracting-alloc-id-attribute", log.Fields{"device-id": oFsm.deviceID, "tcont-inst": tcontInstID}) |
| 276 | } |
| 277 | } |
| 278 | */ |
| 279 | |
| 280 | // Ensure that the techProfileID is in a valid range so that we can allocate a free Tcont for it. |
| 281 | if oFsm.techProfileID >= tpIDOffset && oFsm.techProfileID < uint8(tpIDOffset+len(tcontInstKeys)) { |
| 282 | // For now, as a dirty workaround, use the tpIDOffset to index the TcontEntityID to be used. |
| 283 | // The first TP ID for the ONU will get the first TcontEntityID, the next will get second and so on. |
| 284 | // Here the assumption is TP ID will always start from 64 (this is also true to Technology Profile Specification) and the |
| 285 | // TP ID will increment in single digit |
| 286 | oFsm.tcont0ID = tcontInstKeys[oFsm.techProfileID-tpIDOffset] |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 287 | logger.Debugw(ctx, "Used TcontId:", log.Fields{"TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16), |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 288 | "device-id": oFsm.deviceID}) |
| 289 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 290 | logger.Errorw(ctx, "tech profile id not in valid range", log.Fields{"device-id": oFsm.deviceID, "tp-id": oFsm.techProfileID, "num-tcont": len(tcontInstKeys)}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 291 | if oFsm.chanSet { |
| 292 | // indicate processing error/abort to the caller |
| 293 | oFsm.chSuccess <- 0 |
| 294 | oFsm.chanSet = false //reset the internal channel state |
| 295 | } |
| 296 | //reset the state machine to enable usage on subsequent requests |
| 297 | _ = aPAFsm.pFsm.Event(aniEvReset) |
| 298 | return |
| 299 | } |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 300 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 301 | logger.Errorw(ctx, "No TCont instances found", log.Fields{"device-id": oFsm.deviceID}) |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 302 | return |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 303 | } |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 304 | /* |
| 305 | if !foundFreeTcontInstID { |
| 306 | // This should never happen. If it does, the behavior is unpredictable. |
| 307 | logger.Warnw("No free TCONT instances found", log.Fields{"device-id": oFsm.deviceID}) |
| 308 | }*/ |
| 309 | |
| 310 | // Access critical state with lock |
| 311 | oFsm.pUniTechProf.mutexTPState.Lock() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 312 | oFsm.alloc0ID = oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].tcontParams.allocID |
| 313 | mapGemPortParams := oFsm.pUniTechProf.mapPonAniConfig[oFsm.uniTpKey].mapGemPortParams |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 314 | oFsm.pUniTechProf.mutexTPState.Unlock() |
| 315 | |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 316 | //for all TechProfile set GemIndices |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 317 | for _, gemEntry := range mapGemPortParams { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 318 | loGemPortAttribs := ponAniGemPortAttribs{} |
| 319 | |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 320 | //collect all GemConfigData in a separate Fsm related slice (needed also to avoid mix-up with unsorted mapPonAniConfig) |
| 321 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 322 | if queueInstKeys := oFsm.pOnuDB.getSortedInstKeys(ctx, me.PriorityQueueClassID); len(queueInstKeys) > 0 { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 323 | |
| 324 | loGemPortAttribs.gemPortID = gemEntry.gemPortID |
| 325 | // MibDb usage: upstream PrioQueue.RelatedPort = xxxxyyyy with xxxx=TCont.Entity(incl. slot) and yyyy=prio |
| 326 | // i.e.: search PrioQueue list with xxxx=actual T-Cont.Entity, |
| 327 | // from that list use the PrioQueue.Entity with gemEntry.prioQueueIndex == yyyy (expect 0..7) |
| 328 | usQrelPortMask := uint32((((uint32)(oFsm.tcont0ID)) << 16) + uint32(gemEntry.prioQueueIndex)) |
| 329 | |
| 330 | // MibDb usage: downstream PrioQueue.RelatedPort = xxyyzzzz with xx=slot, yy=UniPort and zzzz=prio |
| 331 | // i.e.: search PrioQueue list with yy=actual pOnuUniPort.uniID, |
| 332 | // from that list use the PrioQueue.Entity with gemEntry.prioQueueIndex == zzzz (expect 0..7) |
| 333 | // Note: As we do not maintain any slot numbering, slot number will be excluded from seatch pattern. |
| 334 | // Furthermore OMCI Onu port-Id is expected to start with 1 (not 0). |
| 335 | dsQrelPortMask := uint32((((uint32)(oFsm.pOnuUniPort.uniID + 1)) << 16) + uint32(gemEntry.prioQueueIndex)) |
| 336 | |
| 337 | usQueueFound := false |
| 338 | dsQueueFound := false |
| 339 | for _, mgmtEntityID := range queueInstKeys { |
| 340 | if meAttributes := oFsm.pOnuDB.GetMe(me.PriorityQueueClassID, mgmtEntityID); meAttributes != nil { |
| 341 | returnVal := meAttributes["RelatedPort"] |
| 342 | if returnVal != nil { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 343 | if relatedPort, err := oFsm.pOnuDB.getUint32Attrib(returnVal); err == nil { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 344 | if relatedPort == usQrelPortMask { |
| 345 | loGemPortAttribs.upQueueID = mgmtEntityID |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 346 | logger.Debugw(ctx, "UpQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 347 | "upQueueID": strconv.FormatInt(int64(loGemPortAttribs.upQueueID), 16), "device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 348 | usQueueFound = true |
| 349 | } else if (relatedPort&0xFFFFFF) == dsQrelPortMask && mgmtEntityID < 0x8000 { |
| 350 | loGemPortAttribs.downQueueID = mgmtEntityID |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 351 | logger.Debugw(ctx, "DownQueue for GemPort found:", log.Fields{"gemPortID": loGemPortAttribs.gemPortID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 352 | "downQueueID": strconv.FormatInt(int64(loGemPortAttribs.downQueueID), 16), "device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 353 | dsQueueFound = true |
| 354 | } |
| 355 | if usQueueFound && dsQueueFound { |
| 356 | break |
| 357 | } |
| 358 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 359 | 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] | 360 | } |
| 361 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 362 | 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] | 363 | } |
| 364 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 365 | logger.Warnw(ctx, "No attributes available in DB:", log.Fields{"meClassID": me.PriorityQueueClassID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 366 | "mgmtEntityID": mgmtEntityID, "device-id": oFsm.deviceID}) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 370 | 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] | 371 | } |
| 372 | loGemPortAttribs.direction = gemEntry.direction |
| 373 | loGemPortAttribs.qosPolicy = gemEntry.queueSchedPolicy |
| 374 | loGemPortAttribs.weight = gemEntry.queueWeight |
| 375 | loGemPortAttribs.pbitString = gemEntry.pbitString |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 376 | if gemEntry.isMulticast { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 377 | //TODO this might effectively ignore the for loop starting at line 316 |
| 378 | loGemPortAttribs.gemPortID = gemEntry.multicastGemPortID |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 379 | loGemPortAttribs.isMulticast = true |
| 380 | loGemPortAttribs.multicastGemID = gemEntry.multicastGemPortID |
| 381 | loGemPortAttribs.staticACL = gemEntry.staticACL |
| 382 | loGemPortAttribs.dynamicACL = gemEntry.dynamicACL |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 383 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 384 | logger.Debugw(ctx, "Multicast GemPort attributes:", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 385 | "gemPortID": loGemPortAttribs.gemPortID, |
| 386 | "isMulticast": loGemPortAttribs.isMulticast, |
| 387 | "multicastGemID": loGemPortAttribs.multicastGemID, |
| 388 | "staticACL": loGemPortAttribs.staticACL, |
| 389 | "dynamicACL": loGemPortAttribs.dynamicACL, |
| 390 | }) |
| 391 | |
| 392 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 393 | logger.Debugw(ctx, "Upstream GemPort attributes:", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 394 | "gemPortID": loGemPortAttribs.gemPortID, |
| 395 | "upQueueID": loGemPortAttribs.upQueueID, |
| 396 | "downQueueID": loGemPortAttribs.downQueueID, |
| 397 | "pbitString": loGemPortAttribs.pbitString, |
| 398 | "prioQueueIndex": gemEntry.prioQueueIndex, |
| 399 | }) |
| 400 | } |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 401 | |
| 402 | oFsm.gemPortAttribsSlice = append(oFsm.gemPortAttribsSlice, loGemPortAttribs) |
| 403 | } |
| 404 | _ = aPAFsm.pFsm.Event(aniEvStartConfig) |
| 405 | } |
| 406 | } |
| 407 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 408 | func (oFsm *uniPonAniConfigFsm) enterConfigStartingState(ctx context.Context, e *fsm.Event) { |
| 409 | logger.Debugw(ctx, "UniPonAniConfigFsm start", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 410 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 411 | // in case the used channel is not yet defined (can be re-used after restarts) |
| 412 | if oFsm.omciMIdsResponseReceived == nil { |
| 413 | oFsm.omciMIdsResponseReceived = make(chan bool) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 414 | logger.Debug(ctx, "uniPonAniConfigFsm - OMCI multiInstance RxChannel defined") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 415 | } else { |
| 416 | // as we may 're-use' this instance of FSM and the connected channel |
| 417 | // make sure there is no 'lingering' request in the already existing channel: |
| 418 | // (simple loop sufficient as we are the only receiver) |
| 419 | for len(oFsm.omciMIdsResponseReceived) > 0 { |
| 420 | <-oFsm.omciMIdsResponseReceived |
| 421 | } |
| 422 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 423 | //ensure internal slices are empty (which might be set from previous run) - release memory |
| 424 | oFsm.gemPortAttribsSlice = nil |
| 425 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 426 | // start go routine for processing of LockState messages |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 427 | go oFsm.processOmciAniMessages(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 428 | |
| 429 | //let the state machine run forward from here directly |
| 430 | pConfigAniStateAFsm := oFsm.pAdaptFsm |
| 431 | if pConfigAniStateAFsm != nil { |
| 432 | // 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] | 433 | go oFsm.prepareAndEnterConfigState(ctx, pConfigAniStateAFsm) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 434 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 435 | } |
| 436 | } |
| 437 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 438 | func (oFsm *uniPonAniConfigFsm) enterCreatingDot1PMapper(ctx context.Context, e *fsm.Event) { |
| 439 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::Dot1PMapper", log.Fields{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 440 | "EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 441 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
| 442 | oFsm.requestEventOffset = 0 //0 offset for last config request activity |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 443 | meInstance := oFsm.pOmciCC.sendCreateDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 444 | oFsm.mapperSP0ID, oFsm.pAdaptFsm.commChan) |
| 445 | //accept also nil as (error) return value for writing to LastTx |
| 446 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 447 | oFsm.pLastTxMeInstance = meInstance |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 448 | } |
| 449 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 450 | func (oFsm *uniPonAniConfigFsm) enterCreatingMBPCD(ctx context.Context, e *fsm.Event) { |
| 451 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::MBPCD", log.Fields{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 452 | "EntitytId": strconv.FormatInt(int64(oFsm.macBPCD0ID), 16), |
| 453 | "TPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 454 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 455 | bridgePtr := macBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.macBpNo) //cmp also omci_cc.go::sendCreateMBServiceProfile |
| 456 | meParams := me.ParamData{ |
| 457 | EntityID: oFsm.macBPCD0ID, |
| 458 | Attributes: me.AttributeValueMap{ |
| 459 | "BridgeIdPointer": bridgePtr, |
| 460 | "PortNum": 0xFF, //fixed unique ANI side indication |
| 461 | "TpType": 3, //for .1PMapper |
| 462 | "TpPointer": oFsm.mapperSP0ID, |
| 463 | }, |
| 464 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 465 | meInstance := oFsm.pOmciCC.sendCreateMBPConfigDataVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 466 | oFsm.pAdaptFsm.commChan, meParams) |
| 467 | //accept also nil as (error) return value for writing to LastTx |
| 468 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 469 | oFsm.pLastTxMeInstance = meInstance |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 470 | } |
| 471 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 472 | func (oFsm *uniPonAniConfigFsm) enterSettingTconts(ctx context.Context, e *fsm.Event) { |
| 473 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::Tcont", log.Fields{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 474 | "EntitytId": strconv.FormatInt(int64(oFsm.tcont0ID), 16), |
| 475 | "AllocId": strconv.FormatInt(int64(oFsm.alloc0ID), 16), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 476 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 477 | meParams := me.ParamData{ |
| 478 | EntityID: oFsm.tcont0ID, |
| 479 | Attributes: me.AttributeValueMap{ |
| 480 | "AllocId": oFsm.alloc0ID, |
| 481 | }, |
| 482 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 483 | meInstance := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 484 | oFsm.pAdaptFsm.commChan, meParams) |
| 485 | //accept also nil as (error) return value for writing to LastTx |
| 486 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 487 | oFsm.pLastTxMeInstance = meInstance |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 488 | } |
| 489 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 490 | func (oFsm *uniPonAniConfigFsm) enterCreatingGemNCTPs(ctx context.Context, e *fsm.Event) { |
| 491 | logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemNWCtp loop", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 492 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 493 | go oFsm.performCreatingGemNCTPs(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 494 | } |
| 495 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 496 | func (oFsm *uniPonAniConfigFsm) enterCreatingGemIWs(ctx context.Context, e *fsm.Event) { |
| 497 | logger.Debugw(ctx, "uniPonAniConfigFsm - start creating GemIwTP loop", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 498 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 499 | go oFsm.performCreatingGemIWs(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 500 | } |
| 501 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 502 | func (oFsm *uniPonAniConfigFsm) enterSettingPQs(ctx context.Context, e *fsm.Event) { |
| 503 | logger.Debugw(ctx, "uniPonAniConfigFsm - start setting PrioQueue loop", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 504 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 505 | go oFsm.performSettingPQs(ctx) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 506 | } |
| 507 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 508 | func (oFsm *uniPonAniConfigFsm) enterSettingDot1PMapper(ctx context.Context, e *fsm.Event) { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 509 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 510 | 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] | 511 | "toGemIw": 1024, /* cmp above */ |
| 512 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 513 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 514 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::1pMapper", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 515 | "EntitytId": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 516 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 517 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 518 | meParams := me.ParamData{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 519 | EntityID: oFsm.mapperSP0ID, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 520 | Attributes: make(me.AttributeValueMap), |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 521 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 522 | |
| 523 | //assign the GemPorts according to the configured Prio |
| 524 | var loPrioGemPortArray [8]uint16 |
| 525 | for _, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 526 | if gemPortAttribs.isMulticast { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 527 | logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring .1pMapper", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 528 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
| 529 | "prioString": gemPortAttribs.pbitString}) |
| 530 | continue |
| 531 | } |
| 532 | if gemPortAttribs.pbitString == "" { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 533 | logger.Warnw(ctx, "uniPonAniConfigFsm PrioString empty string error", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 534 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
| 535 | "prioString": gemPortAttribs.pbitString}) |
| 536 | continue |
| 537 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 538 | for i := 0; i < 8; i++ { |
| 539 | // "lenOfPbitMap(8) - i + 1" will give i-th pbit value from LSB position in the pbit map string |
| 540 | if prio, err := strconv.Atoi(string(gemPortAttribs.pbitString[7-i])); err == nil { |
| 541 | if prio == 1 { // Check this p-bit is set |
| 542 | if loPrioGemPortArray[i] == 0 { |
| 543 | loPrioGemPortArray[i] = gemPortAttribs.gemPortID //gemPortId=EntityID and unique |
| 544 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 545 | logger.Warnw(ctx, "uniPonAniConfigFsm PrioString not unique", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 546 | "device-id": oFsm.deviceID, "IgnoredGemPort": gemPortAttribs.gemPortID, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 547 | "SetGemPort": loPrioGemPortArray[i]}) |
| 548 | } |
| 549 | } |
| 550 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 551 | logger.Warnw(ctx, "uniPonAniConfigFsm PrioString evaluation error", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 552 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 553 | "prioString": gemPortAttribs.pbitString, "position": i}) |
| 554 | } |
| 555 | |
| 556 | } |
| 557 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 558 | |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 559 | var foundIwPtr = false |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 560 | for index, value := range loPrioGemPortArray { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 561 | meAttribute := fmt.Sprintf("InterworkTpPointerForPBitPriority%d", index) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 562 | if value != 0 { |
| 563 | foundIwPtr = true |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 564 | meParams.Attributes[meAttribute] = value |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 565 | logger.Debugw(ctx, "UniPonAniConfigFsm Set::1pMapper", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 566 | "for Prio": index, |
| 567 | "IwPtr": strconv.FormatInt(int64(value), 16), |
| 568 | "device-id": oFsm.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 569 | } else { |
| 570 | // 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] | 571 | // setting this parameter is not strictly needed anymore with the ensured .1pMapper create default setting |
| 572 | // 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] | 573 | meParams.Attributes[meAttribute] = 0xffff |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 574 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 575 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 576 | // 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] | 577 | // setting this parameter is not strictly needed anymore with the ensured .1pMapper create default setting |
| 578 | // 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] | 579 | meParams.Attributes["TpPointer"] = 0xffff |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 580 | |
| 581 | if !foundIwPtr { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 582 | logger.Debugw(ctx, "UniPonAniConfigFsm no GemIwPtr found for .1pMapper - abort", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 583 | "device-id": oFsm.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 584 | //TODO With multicast is possible that no upstream gem ports are not present in the tech profile, |
| 585 | // 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] | 586 | //let's reset the state machine in order to release all resources now |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 587 | //pConfigAniStateAFsm := oFsm.pAdaptFsm |
| 588 | //if pConfigAniStateAFsm != nil { |
| 589 | // // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
| 590 | // go func(aPAFsm *AdapterFsm) { |
| 591 | // if aPAFsm != nil && aPAFsm.pFsm != nil { |
| 592 | // _ = aPAFsm.pFsm.Event(aniEvReset) |
| 593 | // } |
| 594 | // }(pConfigAniStateAFsm) |
| 595 | //} |
| 596 | //Moving forward the FSM as if the response was received correctly. |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 597 | pConfigAniStateAFsm := oFsm.pAdaptFsm |
| 598 | if pConfigAniStateAFsm != nil { |
| 599 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 600 | go func(aPAFsm *AdapterFsm) { |
| 601 | if aPAFsm != nil && aPAFsm.pFsm != nil { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 602 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapSResp) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 603 | } |
| 604 | }(pConfigAniStateAFsm) |
| 605 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 606 | } else { |
| 607 | meInstance := oFsm.pOmciCC.sendSetDot1PMapperVar(context.TODO(), ConstDefaultOmciTimeout, true, |
| 608 | oFsm.pAdaptFsm.commChan, meParams) |
| 609 | //accept also nil as (error) return value for writing to LastTx |
| 610 | // - this avoids misinterpretation of new received OMCI messages |
| 611 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 612 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 613 | } |
| 614 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 615 | func (oFsm *uniPonAniConfigFsm) enterAniConfigDone(ctx context.Context, e *fsm.Event) { |
| 616 | logger.Debugw(ctx, "uniPonAniConfigFsm ani config done", log.Fields{ |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 617 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 618 | //use DeviceHandler event notification directly |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 619 | oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset))) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 620 | //store that the UNI related techProfile processing is done for the given Profile and Uni |
Girish Gowdra | 041dcb3 | 2020-11-16 16:54:30 -0800 | [diff] [blame] | 621 | oFsm.pUniTechProf.setConfigDone(oFsm.pOnuUniPort.uniID, oFsm.techProfileID, true) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 622 | //if techProfile processing is done it must be checked, if some prior/parallel flow configuration is pending |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 623 | // but only in case the techProfile was configured (not deleted) |
| 624 | if oFsm.requestEventOffset == 0 { |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 625 | go oFsm.pDeviceHandler.verifyUniVlanConfigRequest(ctx, oFsm.pOnuUniPort, oFsm.techProfileID) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 626 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 627 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 628 | if oFsm.chanSet { |
| 629 | // indicate processing done to the caller |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 630 | logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 631 | "ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 632 | oFsm.chSuccess <- oFsm.procStep |
| 633 | oFsm.chanSet = false //reset the internal channel state |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 634 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 635 | |
| 636 | //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] | 637 | } |
| 638 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 639 | func (oFsm *uniPonAniConfigFsm) enterRemovingGemIW(ctx context.Context, e *fsm.Event) { |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 640 | |
| 641 | if oFsm.pDeviceHandler.UniVlanConfigFsmMap[oFsm.pOnuUniPort.uniID].IsFlowRemovePending() { |
| 642 | logger.Debugw(ctx, "flow remove pending - wait before processing gem port delete", |
| 643 | log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID}) |
| 644 | // if flow remove is pending then wait for flow remove to finish first before proceeding with gem port delete |
| 645 | pConfigAniStateAFsm := oFsm.pAdaptFsm |
| 646 | if pConfigAniStateAFsm != nil { |
| 647 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
| 648 | go func(aPAFsm *AdapterFsm) { |
| 649 | if aPAFsm != nil && aPAFsm.pFsm != nil { |
| 650 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvWaitFlowRem) |
| 651 | } |
| 652 | }(pConfigAniStateAFsm) |
| 653 | } else { |
| 654 | logger.Errorw(ctx, "pConfigAniStateAFsm is nil", log.Fields{"device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, "techProfile-id": oFsm.techProfileID}) |
| 655 | } |
| 656 | return |
| 657 | } |
| 658 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 659 | // get the related GemPort entity Id from pUniTechProf, OMCI Gem* entityID is set to be equal to GemPortId! |
| 660 | oFsm.pUniTechProf.mutexTPState.Lock() |
| 661 | loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID |
| 662 | oFsm.pUniTechProf.mutexTPState.Unlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 663 | logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemIwTP", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 664 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, |
| 665 | "GemIwTp-entity-id": loGemPortID}) |
| 666 | oFsm.requestEventOffset = 1 //offset 1 to indicate last activity = remove |
| 667 | |
| 668 | // this state entry is only expected in a suitable state (checked outside in onu_uni_tp) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 669 | meInstance := oFsm.pOmciCC.sendDeleteGemIWTP(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 670 | oFsm.pAdaptFsm.commChan, loGemPortID) |
| 671 | oFsm.pLastTxMeInstance = meInstance |
| 672 | } |
| 673 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 674 | func (oFsm *uniPonAniConfigFsm) enterRemovingGemNCTP(ctx context.Context, e *fsm.Event) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 675 | oFsm.pUniTechProf.mutexTPState.Lock() |
| 676 | loGemPortID := (*(oFsm.pUniTechProf.mapRemoveGemEntry[oFsm.uniTpKey])).gemPortID |
| 677 | oFsm.pUniTechProf.mutexTPState.Unlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 678 | logger.Debugw(ctx, "uniPonAniConfigFsm - start removing one GemNCTP", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 679 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID, |
| 680 | "GemNCTP-entity-id": loGemPortID}) |
| 681 | // this state entry is only expected in a suitable state (checked outside in onu_uni_tp) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 682 | meInstance := oFsm.pOmciCC.sendDeleteGemNCTP(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 683 | oFsm.pAdaptFsm.commChan, loGemPortID) |
| 684 | oFsm.pLastTxMeInstance = meInstance |
| 685 | } |
| 686 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 687 | func (oFsm *uniPonAniConfigFsm) enterResettingTcont(ctx context.Context, e *fsm.Event) { |
| 688 | logger.Debugw(ctx, "uniPonAniConfigFsm - start resetting the TCont", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 689 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
| 690 | |
| 691 | oFsm.requestEventOffset = 1 //offset 1 for last remove activity |
| 692 | // this state entry is only expected in a suitable state (checked outside in onu_uni_tp) |
| 693 | meParams := me.ParamData{ |
| 694 | EntityID: oFsm.tcont0ID, |
| 695 | Attributes: me.AttributeValueMap{ |
| 696 | "AllocId": unusedTcontAllocID, |
| 697 | }, |
| 698 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 699 | meInstance := oFsm.pOmciCC.sendSetTcontVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 700 | oFsm.pAdaptFsm.commChan, meParams) |
| 701 | oFsm.pLastTxMeInstance = meInstance |
| 702 | } |
| 703 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 704 | func (oFsm *uniPonAniConfigFsm) enterRemoving1pMapper(ctx context.Context, e *fsm.Event) { |
| 705 | logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the .1pMapper", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 706 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
| 707 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 708 | meInstance := oFsm.pOmciCC.sendDeleteDot1PMapper(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 709 | oFsm.pAdaptFsm.commChan, oFsm.mapperSP0ID) |
| 710 | oFsm.pLastTxMeInstance = meInstance |
| 711 | } |
| 712 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 713 | func (oFsm *uniPonAniConfigFsm) enterRemovingAniBPCD(ctx context.Context, e *fsm.Event) { |
| 714 | logger.Debugw(ctx, "uniPonAniConfigFsm - start deleting the ANI MBCD", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 715 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
| 716 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 717 | meInstance := oFsm.pOmciCC.sendDeleteMBPConfigData(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 718 | oFsm.pAdaptFsm.commChan, oFsm.macBPCD0ID) |
| 719 | oFsm.pLastTxMeInstance = meInstance |
| 720 | } |
| 721 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 722 | func (oFsm *uniPonAniConfigFsm) enterAniRemoveDone(ctx context.Context, e *fsm.Event) { |
| 723 | logger.Debugw(ctx, "uniPonAniConfigFsm ani removal done", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 724 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
| 725 | //use DeviceHandler event notification directly |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 726 | oFsm.pDeviceHandler.deviceProcStatusUpdate(ctx, OnuDeviceEvent((uint8(oFsm.requestEvent) + oFsm.requestEventOffset))) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 727 | if oFsm.chanSet { |
| 728 | // indicate processing done to the caller |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 729 | logger.Debugw(ctx, "uniPonAniConfigFsm processingDone on channel", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 730 | "ProcessingStep": oFsm.procStep, "from_State": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 731 | oFsm.chSuccess <- oFsm.procStep |
| 732 | oFsm.chanSet = false //reset the internal channel state |
| 733 | } |
| 734 | |
| 735 | //let's reset the state machine in order to release all resources now |
| 736 | pConfigAniStateAFsm := oFsm.pAdaptFsm |
| 737 | if pConfigAniStateAFsm != nil { |
| 738 | // obviously calling some FSM event here directly does not work - so trying to decouple it ... |
| 739 | go func(aPAFsm *AdapterFsm) { |
| 740 | if aPAFsm != nil && aPAFsm.pFsm != nil { |
| 741 | _ = aPAFsm.pFsm.Event(aniEvReset) |
| 742 | } |
| 743 | }(pConfigAniStateAFsm) |
| 744 | } |
| 745 | } |
| 746 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 747 | func (oFsm *uniPonAniConfigFsm) enterResettingState(ctx context.Context, e *fsm.Event) { |
| 748 | logger.Debugw(ctx, "uniPonAniConfigFsm resetting", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 749 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 750 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 751 | pConfigAniStateAFsm := oFsm.pAdaptFsm |
| 752 | if pConfigAniStateAFsm != nil { |
| 753 | // abort running message processing |
| 754 | fsmAbortMsg := Message{ |
| 755 | Type: TestMsg, |
| 756 | Data: TestMessage{ |
| 757 | TestMessageVal: AbortMessageProcessing, |
| 758 | }, |
| 759 | } |
| 760 | pConfigAniStateAFsm.commChan <- fsmAbortMsg |
| 761 | |
| 762 | //try to restart the FSM to 'disabled', decouple event transfer |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 763 | go func(aPAFsm *AdapterFsm) { |
| 764 | if aPAFsm != nil && aPAFsm.pFsm != nil { |
| 765 | _ = aPAFsm.pFsm.Event(aniEvRestart) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 766 | } |
| 767 | }(pConfigAniStateAFsm) |
| 768 | } |
| 769 | } |
| 770 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 771 | func (oFsm *uniPonAniConfigFsm) enterDisabledState(ctx context.Context, e *fsm.Event) { |
| 772 | logger.Debugw(ctx, "uniPonAniConfigFsm enters disabled state", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 773 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.uniID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 774 | oFsm.pLastTxMeInstance = nil |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 775 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 776 | //remove all TechProf related internal data to allow for new configuration (e.g. with disable/enable procedure) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 777 | oFsm.pUniTechProf.clearAniSideConfig(ctx, oFsm.pOnuUniPort.uniID, oFsm.techProfileID) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 778 | } |
| 779 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 780 | func (oFsm *uniPonAniConfigFsm) processOmciAniMessages(ctx context.Context) { |
| 781 | 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] | 782 | loop: |
| 783 | for { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 784 | // case <-ctx.Done(): |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 785 | // 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] | 786 | // break loop |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 787 | message, ok := <-oFsm.pAdaptFsm.commChan |
| 788 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 789 | 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] | 790 | // but then we have to ensure a restart of the FSM as well - as exceptional procedure |
| 791 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset) |
| 792 | break loop |
| 793 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 794 | logger.Debugw(ctx, "UniPonAniConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 795 | |
| 796 | switch message.Type { |
| 797 | case TestMsg: |
| 798 | msg, _ := message.Data.(TestMessage) |
| 799 | if msg.TestMessageVal == AbortMessageProcessing { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 800 | logger.Infow(ctx, "UniPonAniConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 801 | break loop |
| 802 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 803 | logger.Warnw(ctx, "UniPonAniConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 804 | case OMCI: |
| 805 | msg, _ := message.Data.(OmciMessage) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 806 | oFsm.handleOmciAniConfigMessage(ctx, msg) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 807 | default: |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 808 | 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] | 809 | "message.Type": message.Type}) |
| 810 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 811 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 812 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 813 | 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] | 814 | } |
| 815 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 816 | func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigCreateResponseMessage(ctx context.Context, msg OmciMessage) { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 817 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeCreateResponse) |
| 818 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 819 | logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 820 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 821 | return |
| 822 | } |
| 823 | msgObj, msgOk := msgLayer.(*omci.CreateResponse) |
| 824 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 825 | logger.Errorw(ctx, "Omci Msg layer could not be assigned for CreateResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 826 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 827 | return |
| 828 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 829 | 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] | 830 | if msgObj.Result == me.Success || msgObj.Result == me.InstanceExists { |
| 831 | //if the result is ok or Instance already exists (latest needed at least as long as we do not clear the OMCI techProfile data) |
| 832 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 833 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 834 | // maybe we can use just the same eventName for different state transitions like "forward" |
| 835 | // - might be checked, but so far I go for sure and have to inspect the concrete state events ... |
| 836 | switch oFsm.pLastTxMeInstance.GetName() { |
| 837 | case "Ieee8021PMapperServiceProfile": |
| 838 | { // let the FSM proceed ... |
| 839 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapCResp) |
| 840 | } |
| 841 | case "MacBridgePortConfigurationData": |
| 842 | { // let the FSM proceed ... |
| 843 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxMbpcdResp) |
| 844 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 845 | case "GemPortNetworkCtp", "GemInterworkingTerminationPoint", "MulticastGemInterworkingTerminationPoint": |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 846 | { // let aniConfig Multi-Id processing proceed by stopping the wait function |
| 847 | oFsm.omciMIdsResponseReceived <- true |
| 848 | } |
| 849 | } |
| 850 | } |
| 851 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 852 | logger.Errorw(ctx, "Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"Error": msgObj.Result}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 853 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
| 854 | return |
| 855 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 856 | } |
| 857 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 858 | func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigSetResponseMessage(ctx context.Context, msg OmciMessage) { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 859 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse) |
| 860 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 861 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for SetResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 862 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 863 | return |
| 864 | } |
| 865 | msgObj, msgOk := msgLayer.(*omci.SetResponse) |
| 866 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 867 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be assigned for SetResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 868 | log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 869 | return |
| 870 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 871 | 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] | 872 | if msgObj.Result != me.Success { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 873 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci SetResponse Error - later: drive FSM to abort state ?", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 874 | log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 875 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
| 876 | return |
| 877 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 878 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 879 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 880 | //store the created ME into DB //TODO??? obviously the Python code does not store the config ... |
| 881 | // if, then something like: |
| 882 | //oFsm.pOnuDB.StoreMe(msgObj) |
| 883 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 884 | switch oFsm.pLastTxMeInstance.GetName() { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 885 | case "TCont": |
| 886 | { // let the FSM proceed ... |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 887 | if oFsm.requestEventOffset == 0 { //from TCont config request |
| 888 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxTcontsResp) |
| 889 | } else { // from T-Cont reset request |
| 890 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxResetTcontResp) |
| 891 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 892 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 893 | case "PriorityQueue", "MulticastGemInterworkingTerminationPoint": |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 894 | { // let the PrioQueue init proceed by stopping the wait function |
| 895 | oFsm.omciMIdsResponseReceived <- true |
| 896 | } |
| 897 | case "Ieee8021PMapperServiceProfile": |
| 898 | { // let the FSM proceed ... |
| 899 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxDot1pmapSResp) |
| 900 | } |
| 901 | } |
| 902 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 903 | } |
| 904 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 905 | func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigDeleteResponseMessage(ctx context.Context, msg OmciMessage) { |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 906 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeDeleteResponse) |
| 907 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 908 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be detected for DeleteResponse", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 909 | log.Fields{"device-id": oFsm.deviceID}) |
| 910 | return |
| 911 | } |
| 912 | msgObj, msgOk := msgLayer.(*omci.DeleteResponse) |
| 913 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 914 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci Msg layer could not be assigned for DeleteResponse", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 915 | log.Fields{"device-id": oFsm.deviceID}) |
| 916 | return |
| 917 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 918 | 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] | 919 | if msgObj.Result != me.Success { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 920 | logger.Errorw(ctx, "UniPonAniConfigFsm - Omci DeleteResponse Error", |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 921 | log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result}) |
| 922 | //TODO: - later: possibly force FSM into abort or ignore some errors for some messages? |
| 923 | // store error for mgmt display? |
| 924 | return |
| 925 | } |
| 926 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 927 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 928 | //remove ME from DB //TODO??? obviously the Python code does not store/remove the config ... |
| 929 | // if, then something like: oFsm.pOnuDB.XyyMe(msgObj) |
| 930 | |
| 931 | switch oFsm.pLastTxMeInstance.GetName() { |
| 932 | case "GemInterworkingTerminationPoint": |
| 933 | { // let the FSM proceed ... |
| 934 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemGemiwResp) |
| 935 | } |
| 936 | case "GemPortNetworkCtp": |
| 937 | { // let the FSM proceed ... |
| 938 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemGemntpResp) |
| 939 | } |
| 940 | case "Ieee8021PMapperServiceProfile": |
| 941 | { // let the FSM proceed ... |
| 942 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRem1pMapperResp) |
| 943 | } |
| 944 | case "MacBridgePortConfigurationData": |
| 945 | { // this is the last event of the T-Cont cleanup procedure, FSM may be reset here |
| 946 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxRemAniBPCDResp) |
| 947 | } |
| 948 | } |
| 949 | } |
| 950 | } |
| 951 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 952 | func (oFsm *uniPonAniConfigFsm) handleOmciAniConfigMessage(ctx context.Context, msg OmciMessage) { |
| 953 | logger.Debugw(ctx, "Rx OMCI UniPonAniConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 954 | "msgType": msg.OmciMsg.MessageType}) |
| 955 | |
| 956 | switch msg.OmciMsg.MessageType { |
| 957 | case omci.CreateResponseType: |
| 958 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 959 | oFsm.handleOmciAniConfigCreateResponseMessage(ctx, msg) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 960 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 961 | } //CreateResponseType |
| 962 | case omci.SetResponseType: |
| 963 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 964 | oFsm.handleOmciAniConfigSetResponseMessage(ctx, msg) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 965 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 966 | } //SetResponseType |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 967 | case omci.DeleteResponseType: |
| 968 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 969 | oFsm.handleOmciAniConfigDeleteResponseMessage(ctx, msg) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 970 | |
| 971 | } //SetResponseType |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 972 | default: |
| 973 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 974 | logger.Errorw(ctx, "uniPonAniConfigFsm - Rx OMCI unhandled MsgType", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 975 | log.Fields{"omciMsgType": msg.OmciMsg.MessageType, "device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 976 | return |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 981 | func (oFsm *uniPonAniConfigFsm) performCreatingGemNCTPs(ctx context.Context) { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 982 | // for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice |
| 983 | for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 984 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemNWCtp", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 985 | "EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16), |
| 986 | "TcontId": strconv.FormatInt(int64(oFsm.tcont0ID), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 987 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 988 | meParams := me.ParamData{ |
| 989 | EntityID: gemPortAttribs.gemPortID, //unique, same as PortId |
| 990 | Attributes: me.AttributeValueMap{ |
| 991 | "PortId": gemPortAttribs.gemPortID, |
| 992 | "TContPointer": oFsm.tcont0ID, |
| 993 | "Direction": gemPortAttribs.direction, |
| 994 | //ONU-G.TrafficManagementOption dependency ->PrioQueue or TCont |
| 995 | // TODO!! verify dependency and QueueId in case of Multi-GemPort setup! |
| 996 | "TrafficManagementPointerForUpstream": gemPortAttribs.upQueueID, //might be different in wrr-only Setup - tcont0ID |
| 997 | "PriorityQueuePointerForDownStream": gemPortAttribs.downQueueID, |
| 998 | }, |
| 999 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1000 | meInstance := oFsm.pOmciCC.sendCreateGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1001 | oFsm.pAdaptFsm.commChan, meParams) |
| 1002 | //accept also nil as (error) return value for writing to LastTx |
| 1003 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1004 | oFsm.pLastTxMeInstance = meInstance |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1005 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1006 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1007 | err := oFsm.waitforOmciResponse(ctx) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1008 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1009 | logger.Errorw(ctx, "GemNWCtp create failed, aborting AniConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1010 | log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1011 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1012 | return |
| 1013 | } |
| 1014 | } //for all GemPorts of this T-Cont |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1015 | |
| 1016 | // if Config has been done for all GemPort instances let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1017 | logger.Debugw(ctx, "GemNWCtp create loop finished", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1018 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemntcpsResp) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1021 | func (oFsm *uniPonAniConfigFsm) performCreatingGemIWs(ctx context.Context) { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1022 | // for all GemPorts of this T-Cont as given by the size of set gemPortAttribsSlice |
| 1023 | for gemIndex, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1024 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Create::GemIwTp", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1025 | "EntitytId": strconv.FormatInt(int64(gemPortAttribs.gemPortID), 16), |
| 1026 | "SPPtr": strconv.FormatInt(int64(oFsm.mapperSP0ID), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1027 | "device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1028 | |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1029 | //TODO if the port has only downstream direction the isMulticast flag can be removed. |
| 1030 | if gemPortAttribs.isMulticast { |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1031 | |
| 1032 | meParams := me.ParamData{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1033 | EntityID: gemPortAttribs.multicastGemID, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1034 | Attributes: me.AttributeValueMap{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1035 | "GemPortNetworkCtpConnectivityPointer": gemPortAttribs.multicastGemID, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1036 | "InterworkingOption": 0, // Don't Care |
| 1037 | "ServiceProfilePointer": 0, // Don't Care |
| 1038 | "GalProfilePointer": galEthernetEID, |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1039 | }, |
| 1040 | } |
| 1041 | meInstance := oFsm.pOmciCC.sendCreateMulticastGemIWTPVar(context.TODO(), ConstDefaultOmciTimeout, |
| 1042 | true, oFsm.pAdaptFsm.commChan, meParams) |
| 1043 | oFsm.pLastTxMeInstance = meInstance |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1044 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1045 | err := oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1046 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1047 | logger.Errorw(ctx, "GemTP IW multicast create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1048 | log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex}) |
| 1049 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset) |
| 1050 | return |
| 1051 | } |
| 1052 | ipv4MulticastTable := make([]uint8, 12) |
| 1053 | //Gem Port ID |
| 1054 | binary.BigEndian.PutUint16(ipv4MulticastTable[0:], gemPortAttribs.multicastGemID) |
| 1055 | //Secondary Key |
| 1056 | binary.BigEndian.PutUint16(ipv4MulticastTable[2:], 0) |
| 1057 | // Multicast IP range start This is the 224.0.0.1 address |
| 1058 | binary.BigEndian.PutUint32(ipv4MulticastTable[4:], IPToInt32(net.IPv4(224, 0, 0, 0))) |
| 1059 | // MulticastIp range stop |
| 1060 | binary.BigEndian.PutUint32(ipv4MulticastTable[8:], IPToInt32(net.IPv4(239, 255, 255, 255))) |
| 1061 | |
| 1062 | meIPV4MCTableParams := me.ParamData{ |
| 1063 | EntityID: gemPortAttribs.multicastGemID, |
| 1064 | Attributes: me.AttributeValueMap{ |
| 1065 | "Ipv4MulticastAddressTable": ipv4MulticastTable, |
| 1066 | }, |
| 1067 | } |
| 1068 | meIPV4MCTableInstance := oFsm.pOmciCC.sendSetMulticastGemIWTPVar(context.TODO(), ConstDefaultOmciTimeout, |
| 1069 | true, oFsm.pAdaptFsm.commChan, meIPV4MCTableParams) |
| 1070 | oFsm.pLastTxMeInstance = meIPV4MCTableInstance |
ozgecanetsia | 4b23230 | 2020-11-11 10:58:10 +0300 | [diff] [blame] | 1071 | |
| 1072 | } else { |
| 1073 | meParams := me.ParamData{ |
| 1074 | EntityID: gemPortAttribs.gemPortID, |
| 1075 | Attributes: me.AttributeValueMap{ |
| 1076 | "GemPortNetworkCtpConnectivityPointer": gemPortAttribs.gemPortID, //same as EntityID, see above |
| 1077 | "InterworkingOption": 5, //fixed model:: G.998 .1pMapper |
| 1078 | "ServiceProfilePointer": oFsm.mapperSP0ID, |
| 1079 | "InterworkingTerminationPointPointer": 0, //not used with .1PMapper Mac bridge |
| 1080 | "GalProfilePointer": galEthernetEID, |
| 1081 | }, |
| 1082 | } |
| 1083 | meInstance := oFsm.pOmciCC.sendCreateGemIWTPVar(context.TODO(), ConstDefaultOmciTimeout, true, |
| 1084 | oFsm.pAdaptFsm.commChan, meParams) |
| 1085 | //accept also nil as (error) return value for writing to LastTx |
| 1086 | // - this avoids misinterpretation of new received OMCI messages |
| 1087 | oFsm.pLastTxMeInstance = meInstance |
| 1088 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1089 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1090 | err := oFsm.waitforOmciResponse(ctx) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1091 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1092 | logger.Errorw(ctx, "GemTP create failed, aborting AniConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1093 | log.Fields{"device-id": oFsm.deviceID, "GemIndex": gemIndex}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1094 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1095 | return |
| 1096 | } |
| 1097 | } //for all GemPort's of this T-Cont |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1098 | |
| 1099 | // if Config has been done for all GemPort instances let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1100 | logger.Debugw(ctx, "GemIwTp create loop finished", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1101 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxGemiwsResp) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1102 | } |
| 1103 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1104 | func (oFsm *uniPonAniConfigFsm) performSettingPQs(ctx context.Context) { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1105 | const cu16StrictPrioWeight uint16 = 0xFFFF |
| 1106 | //find all upstream PrioQueues related to this T-Cont |
| 1107 | loQueueMap := ordered_map.NewOrderedMap() |
| 1108 | for _, gemPortAttribs := range oFsm.gemPortAttribsSlice { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1109 | if gemPortAttribs.isMulticast { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1110 | logger.Debugw(ctx, "uniPonAniConfigFsm Port is Multicast, ignoring PQs", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1111 | "device-id": oFsm.deviceID, "GemPort": gemPortAttribs.gemPortID, |
| 1112 | "prioString": gemPortAttribs.pbitString}) |
| 1113 | continue |
| 1114 | } |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1115 | if gemPortAttribs.qosPolicy == "WRR" { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1116 | if _, ok := loQueueMap.Get(gemPortAttribs.upQueueID); !ok { |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1117 | //key does not yet exist |
| 1118 | loQueueMap.Set(gemPortAttribs.upQueueID, uint16(gemPortAttribs.weight)) |
| 1119 | } |
| 1120 | } else { |
| 1121 | loQueueMap.Set(gemPortAttribs.upQueueID, cu16StrictPrioWeight) //use invalid weight value to indicate SP |
| 1122 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1123 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1124 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1125 | //TODO: assumption here is that ONU data uses SP setting in the T-Cont and WRR in the TrafficScheduler |
| 1126 | // if that is not the case, the reverse case could be checked and reacted accordingly or if the |
| 1127 | // complete chain is not valid, then some error should be thrown and configuration can be aborted |
| 1128 | // or even be finished without correct SP/WRR setting |
| 1129 | |
| 1130 | //TODO: search for the (WRR)trafficScheduler related to the T-Cont of this queue |
| 1131 | //By now assume fixed value 0x8000, which is the only announce BBSIM TrafficScheduler, |
| 1132 | // even though its T-Cont seems to be wrong ... |
| 1133 | loTrafficSchedulerEID := 0x8000 |
| 1134 | //for all found queues |
| 1135 | iter := loQueueMap.IterFunc() |
| 1136 | for kv, ok := iter(); ok; kv, ok = iter() { |
| 1137 | queueIndex := (kv.Key).(uint16) |
| 1138 | meParams := me.ParamData{ |
| 1139 | EntityID: queueIndex, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1140 | Attributes: make(me.AttributeValueMap), |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1141 | } |
| 1142 | if (kv.Value).(uint16) == cu16StrictPrioWeight { |
| 1143 | //StrictPrio indication |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1144 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to StrictPrio", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1145 | "EntitytId": strconv.FormatInt(int64(queueIndex), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1146 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1147 | meParams.Attributes["TrafficSchedulerPointer"] = 0 //ensure T-Cont defined StrictPrio scheduling |
| 1148 | } else { |
| 1149 | //WRR indication |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1150 | logger.Debugw(ctx, "uniPonAniConfigFsm Tx Set::PrioQueue to WRR", log.Fields{ |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1151 | "EntitytId": strconv.FormatInt(int64(queueIndex), 16), |
| 1152 | "Weight": kv.Value, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1153 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1154 | meParams.Attributes["TrafficSchedulerPointer"] = loTrafficSchedulerEID //ensure assignment of the relevant trafficScheduler |
| 1155 | meParams.Attributes["Weight"] = uint8(kv.Value.(uint16)) |
| 1156 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1157 | meInstance := oFsm.pOmciCC.sendSetPrioQueueVar(log.WithSpanFromContext(context.TODO(), ctx), ConstDefaultOmciTimeout, true, |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1158 | oFsm.pAdaptFsm.commChan, meParams) |
| 1159 | //accept also nil as (error) return value for writing to LastTx |
| 1160 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1161 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1162 | |
| 1163 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1164 | err := oFsm.waitforOmciResponse(ctx) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1165 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1166 | logger.Errorw(ctx, "PrioQueue set failed, aborting AniConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1167 | log.Fields{"device-id": oFsm.deviceID, "QueueId": strconv.FormatInt(int64(queueIndex), 16)}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1168 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvReset) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 1169 | return |
| 1170 | } |
| 1171 | |
| 1172 | //TODO: In case of WRR setting of the GemPort/PrioQueue it might further be necessary to |
| 1173 | // write the assigned trafficScheduler with the requested Prio to be considered in the StrictPrio scheduling |
| 1174 | // of the (next upstream) assigned T-Cont, which is f(prioQueue[priority]) - in relation to other SP prioQueues |
| 1175 | // not yet done because of BBSIM TrafficScheduler issues (and not done in py code as well) |
| 1176 | |
| 1177 | } //for all upstream prioQueues |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1178 | |
| 1179 | // if Config has been done for all PrioQueue instances let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1180 | logger.Debugw(ctx, "PrioQueue set loop finished", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1181 | _ = oFsm.pAdaptFsm.pFsm.Event(aniEvRxPrioqsResp) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1182 | } |
| 1183 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1184 | func (oFsm *uniPonAniConfigFsm) waitforOmciResponse(ctx context.Context) error { |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1185 | select { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1186 | // maybe be also some outside cancel (but no context modeled for the moment ...) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1187 | // case <-ctx.Done(): |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1188 | // logger.Infow("LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1189 | case <-time.After(30 * 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] | 1190 | logger.Warnw(ctx, "UniPonAniConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1191 | return fmt.Errorf("uniPonAniConfigFsm multi entity timeout %s", oFsm.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1192 | case success := <-oFsm.omciMIdsResponseReceived: |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1193 | if success { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1194 | logger.Debug(ctx, "uniPonAniConfigFsm multi entity response received") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1195 | return nil |
| 1196 | } |
| 1197 | // should not happen so far |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1198 | logger.Warnw(ctx, "uniPonAniConfigFsm multi entity response error", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1199 | return fmt.Errorf("uniPonAniConfigFsm multi entity responseError %s", oFsm.deviceID) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1200 | } |
| 1201 | } |