mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 17 | //Package avcfg provides anig and vlan configuration functionality |
| 18 | package avcfg |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "context" |
| 22 | "encoding/binary" |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 23 | "errors" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 24 | "fmt" |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 25 | "net" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 26 | "strconv" |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 27 | "sync" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 28 | "time" |
| 29 | |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 30 | meters "github.com/opencord/voltha-lib-go/v7/pkg/meters" |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 31 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 32 | gp "github.com/google/gopacket" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 33 | "github.com/looplab/fsm" |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 34 | "github.com/opencord/omci-lib-go/v2" |
| 35 | me "github.com/opencord/omci-lib-go/v2/generated" |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 36 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 37 | cmn "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/common" |
| 38 | "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/devdb" |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 39 | of "github.com/opencord/voltha-protos/v5/go/openflow_13" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 40 | ) |
| 41 | |
| 42 | const ( |
| 43 | // internal predefined values |
| 44 | cDefaultDownstreamMode = 0 |
| 45 | cDefaultTpid = 0x8100 |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 46 | cVtfdTableSize = 12 //as per G.988 |
| 47 | cMaxAllowedFlows = cVtfdTableSize //which might be under discussion, for the moment connected to limit of VLAN's within VTFD |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 48 | ) |
| 49 | |
| 50 | const ( |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 51 | // internal offsets for requestEvent according to definition in onu_device_entry::cmn.OnuDeviceEvent |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 52 | cDeviceEventOffsetAddWithKvStore = 0 //OmciVlanFilterAddDone - OmciVlanFilterAddDone cannot use because of lint |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 53 | cDeviceEventOffsetAddNoKvStore = cmn.OmciVlanFilterAddDoneNoKvStore - cmn.OmciVlanFilterAddDone |
| 54 | cDeviceEventOffsetRemoveWithKvStore = cmn.OmciVlanFilterRemDone - cmn.OmciVlanFilterAddDone |
| 55 | cDeviceEventOffsetRemoveNoKvStore = cmn.OmciVlanFilterRemDoneNoKvStore - cmn.OmciVlanFilterAddDone |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 56 | ) |
| 57 | |
| 58 | const ( |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 59 | // bit mask offsets for EVTOCD VlanTaggingOperationTable related to 32 bits (4 bytes) |
| 60 | cFilterPrioOffset = 28 |
| 61 | cFilterVidOffset = 15 |
| 62 | cFilterTpidOffset = 12 |
| 63 | cFilterEtherTypeOffset = 0 |
| 64 | cTreatTTROffset = 30 |
| 65 | cTreatPrioOffset = 16 |
| 66 | cTreatVidOffset = 3 |
| 67 | cTreatTpidOffset = 0 |
| 68 | ) |
| 69 | const ( |
| 70 | // byte offsets for EVTOCD VlanTaggingOperationTable related to overall 16 byte size with slice byte 0 as first Byte (MSB) |
| 71 | cFilterOuterOffset = 0 |
| 72 | cFilterInnerOffset = 4 |
| 73 | cTreatOuterOffset = 8 |
| 74 | cTreatInnerOffset = 12 |
| 75 | ) |
| 76 | const ( |
| 77 | // basic values used within EVTOCD VlanTaggingOperationTable in respect to their bitfields |
| 78 | cPrioIgnoreTag uint32 = 15 |
| 79 | cPrioDefaultFilter uint32 = 14 |
| 80 | cPrioDoNotFilter uint32 = 8 |
| 81 | cDoNotFilterVid uint32 = 4096 |
| 82 | cDoNotFilterTPID uint32 = 0 |
| 83 | cDoNotFilterEtherType uint32 = 0 |
| 84 | cDoNotAddPrio uint32 = 15 |
| 85 | cCopyPrioFromInner uint32 = 8 |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 86 | //cDontCarePrio uint32 = 0 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 87 | cDontCareVid uint32 = 0 |
| 88 | cDontCareTpid uint32 = 0 |
| 89 | cSetOutputTpidCopyDei uint32 = 4 |
| 90 | ) |
| 91 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 92 | // events of config UNI port VLAN FSM |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 93 | const ( |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 94 | VlanEvStart = "VlanEvStart" |
| 95 | VlanEvPrepareDone = "VlanEvPrepareDone" |
| 96 | VlanEvWaitTechProf = "VlanEvWaitTechProf" |
| 97 | VlanEvCancelOutstandingConfig = "VlanEvCancelOutstandingConfig" |
| 98 | VlanEvContinueConfig = "VlanEvContinueConfig" |
| 99 | VlanEvStartConfig = "VlanEvStartConfig" |
| 100 | VlanEvRxConfigVtfd = "VlanEvRxConfigVtfd" |
| 101 | VlanEvRxConfigEvtocd = "VlanEvRxConfigEvtocd" |
| 102 | VlanEvWaitTPIncr = "VlanEvWaitTPIncr" |
| 103 | VlanEvIncrFlowConfig = "VlanEvIncrFlowConfig" |
| 104 | VlanEvRenew = "VlanEvRenew" |
| 105 | VlanEvRemFlowConfig = "VlanEvRemFlowConfig" |
| 106 | VlanEvRemFlowDone = "VlanEvRemFlowDone" |
| 107 | VlanEvFlowDataRemoved = "VlanEvFlowDataRemoved" |
| 108 | //VlanEvTimeoutSimple = "VlanEvTimeoutSimple" |
| 109 | //VlanEvTimeoutMids = "VlanEvTimeoutMids" |
| 110 | VlanEvReset = "VlanEvReset" |
| 111 | VlanEvRestart = "VlanEvRestart" |
| 112 | VlanEvSkipOmciConfig = "VlanEvSkipOmciConfig" |
| 113 | VlanEvSkipIncFlowConfig = "VlanEvSkipIncFlowConfig" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 114 | ) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 115 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 116 | // states of config UNI port VLAN FSM |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 117 | const ( |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 118 | VlanStDisabled = "VlanStDisabled" |
| 119 | VlanStPreparing = "VlanStPreparing" |
| 120 | VlanStStarting = "VlanStStarting" |
| 121 | VlanStWaitingTechProf = "VlanStWaitingTechProf" |
| 122 | VlanStConfigVtfd = "VlanStConfigVtfd" |
| 123 | VlanStConfigEvtocd = "VlanStConfigEvtocd" |
| 124 | VlanStConfigDone = "VlanStConfigDone" |
| 125 | VlanStIncrFlowWaitTP = "VlanStIncrFlowWaitTP" |
| 126 | VlanStConfigIncrFlow = "VlanStConfigIncrFlow" |
| 127 | VlanStRemoveFlow = "VlanStRemoveFlow" |
| 128 | VlanStCleanupDone = "VlanStCleanupDone" |
| 129 | VlanStResetting = "VlanStResetting" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 130 | ) |
| 131 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 132 | // CVlanFsmIdleState - TODO: add comment |
| 133 | const CVlanFsmIdleState = VlanStConfigDone // state where no OMCI activity is done (for a longer time) |
| 134 | // CVlanFsmConfiguredState - TODO: add comment |
| 135 | const CVlanFsmConfiguredState = VlanStConfigDone // state that indicates that at least some valid user related VLAN configuration should exist |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 136 | |
| 137 | type uniRemoveVlanFlowParams struct { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 138 | isSuspendedOnAdd bool |
| 139 | removeChannel chan bool |
| 140 | cookie uint64 //just the last cookie valid for removal |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 141 | vlanRuleParams cmn.UniVlanRuleParams |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 142 | respChan *chan error |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 143 | } |
| 144 | |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 145 | //UniVlanConfigFsm defines the structure for the state machine for configuration of the VLAN related setting via OMCI |
| 146 | // builds upon 'VLAN rules' that are derived from multiple flows |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 147 | type UniVlanConfigFsm struct { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 148 | pDeviceHandler cmn.IdeviceHandler |
| 149 | pOnuDeviceEntry cmn.IonuDeviceEntry |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 150 | deviceID string |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 151 | pOmciCC *cmn.OmciCC |
| 152 | pOnuUniPort *cmn.OnuUniPort |
| 153 | pUniTechProf *OnuUniTechProf |
| 154 | pOnuDB *devdb.OnuDeviceDB |
| 155 | requestEvent cmn.OnuDeviceEvent |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 156 | omciMIdsResponseReceived chan bool //seperate channel needed for checking multiInstance OMCI message responses |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 157 | PAdaptFsm *cmn.AdapterFsm |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 158 | acceptIncrementalEvtoOption bool |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 159 | isCanceled bool |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 160 | isAwaitingResponse bool |
| 161 | mutexIsAwaitingResponse sync.RWMutex |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 162 | mutexFlowParams sync.RWMutex |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 163 | chCookieDeleted chan bool //channel to indicate that a specific cookie (related to the active rule) was deleted |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 164 | actualUniFlowParam cmn.UniVlanFlowParams |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 165 | uniVlanFlowParamsSlice []cmn.UniVlanFlowParams |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 166 | uniRemoveFlowsSlice []uniRemoveVlanFlowParams |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 167 | NumUniFlows uint8 // expected number of flows should be less than 12 |
| 168 | ConfiguredUniFlow uint8 |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 169 | numRemoveFlows uint8 |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 170 | numVlanFilterEntries uint8 |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 171 | vlanFilterList [cVtfdTableSize]uint16 |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 172 | evtocdID uint16 |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 173 | mutexPLastTxMeInstance sync.RWMutex |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 174 | pLastTxMeInstance *me.ManagedEntity |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 175 | requestEventOffset uint8 |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 176 | TpIDWaitingFor uint8 |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 177 | signalOnFlowDelete bool |
| 178 | flowDeleteChannel chan<- bool |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 179 | //cookie value that indicates that a rule to add is delayed by waiting for deletion of some other existing rule with the same cookie |
| 180 | delayNewRuleCookie uint64 |
Andrea Campanella | f66ac6e | 2021-05-24 17:09:20 +0200 | [diff] [blame] | 181 | // Used to indicate if the FSM is for a reconciling flow and if it's the last flow to be reconciled |
| 182 | // thus notification needs to be sent on chan. |
| 183 | lastFlowToReconcile bool |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 184 | } |
| 185 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 186 | //NewUniVlanConfigFsm is the 'constructor' for the state machine to config the PON ANI ports |
| 187 | // of ONU UNI ports via OMCI |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 188 | func NewUniVlanConfigFsm(ctx context.Context, apDeviceHandler cmn.IdeviceHandler, apOnuDeviceEntry cmn.IonuDeviceEntry, apDevOmciCC *cmn.OmciCC, apUniPort *cmn.OnuUniPort, |
| 189 | apUniTechProf *OnuUniTechProf, apOnuDB *devdb.OnuDeviceDB, aTechProfileID uint8, |
| 190 | aRequestEvent cmn.OnuDeviceEvent, aName string, aCommChannel chan cmn.Message, aAcceptIncrementalEvto bool, |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 191 | aCookieSlice []uint64, aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, lastFlowToRec bool, aMeter *of.OfpMeterConfig, respChan *chan error) *UniVlanConfigFsm { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 192 | instFsm := &UniVlanConfigFsm{ |
| 193 | pDeviceHandler: apDeviceHandler, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 194 | pOnuDeviceEntry: apOnuDeviceEntry, |
| 195 | deviceID: apDeviceHandler.GetDeviceID(), |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 196 | pOmciCC: apDevOmciCC, |
| 197 | pOnuUniPort: apUniPort, |
| 198 | pUniTechProf: apUniTechProf, |
| 199 | pOnuDB: apOnuDB, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 200 | requestEvent: aRequestEvent, |
| 201 | acceptIncrementalEvtoOption: aAcceptIncrementalEvto, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 202 | NumUniFlows: 0, |
| 203 | ConfiguredUniFlow: 0, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 204 | numRemoveFlows: 0, |
Andrea Campanella | f66ac6e | 2021-05-24 17:09:20 +0200 | [diff] [blame] | 205 | lastFlowToReconcile: lastFlowToRec, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 208 | instFsm.PAdaptFsm = cmn.NewAdapterFsm(aName, instFsm.deviceID, aCommChannel) |
| 209 | if instFsm.PAdaptFsm == nil { |
| 210 | logger.Errorw(ctx, "UniVlanConfigFsm's cmn.AdapterFsm could not be instantiated!!", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 211 | "device-id": instFsm.deviceID}) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 212 | // Push response on the response channel |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 213 | instFsm.pushReponseOnFlowResponseChannel(ctx, respChan, fmt.Errorf("adapter-fsm-could-not-be-instantiated")) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 214 | return nil |
| 215 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 216 | instFsm.PAdaptFsm.PFsm = fsm.NewFSM( |
| 217 | VlanStDisabled, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 218 | fsm.Events{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 219 | {Name: VlanEvStart, Src: []string{VlanStDisabled}, Dst: VlanStPreparing}, |
| 220 | {Name: VlanEvPrepareDone, Src: []string{VlanStPreparing}, Dst: VlanStStarting}, |
| 221 | {Name: VlanEvWaitTechProf, Src: []string{VlanStStarting}, Dst: VlanStWaitingTechProf}, |
| 222 | {Name: VlanEvCancelOutstandingConfig, Src: []string{VlanStWaitingTechProf}, Dst: VlanStConfigDone}, |
| 223 | {Name: VlanEvContinueConfig, Src: []string{VlanStWaitingTechProf}, Dst: VlanStConfigVtfd}, |
| 224 | {Name: VlanEvStartConfig, Src: []string{VlanStStarting}, Dst: VlanStConfigVtfd}, |
| 225 | {Name: VlanEvRxConfigVtfd, Src: []string{VlanStConfigVtfd}, Dst: VlanStConfigEvtocd}, |
| 226 | {Name: VlanEvRxConfigEvtocd, Src: []string{VlanStConfigEvtocd, VlanStConfigIncrFlow}, |
| 227 | Dst: VlanStConfigDone}, |
| 228 | {Name: VlanEvRenew, Src: []string{VlanStConfigDone}, Dst: VlanStStarting}, |
| 229 | {Name: VlanEvWaitTPIncr, Src: []string{VlanStConfigDone}, Dst: VlanStIncrFlowWaitTP}, |
| 230 | {Name: VlanEvIncrFlowConfig, Src: []string{VlanStConfigDone, VlanStIncrFlowWaitTP}, |
| 231 | Dst: VlanStConfigIncrFlow}, |
| 232 | {Name: VlanEvRemFlowConfig, Src: []string{VlanStConfigDone}, Dst: VlanStRemoveFlow}, |
| 233 | {Name: VlanEvRemFlowDone, Src: []string{VlanStRemoveFlow}, Dst: VlanStCleanupDone}, |
| 234 | {Name: VlanEvFlowDataRemoved, Src: []string{VlanStCleanupDone}, Dst: VlanStConfigDone}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 235 | /* |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 236 | {Name: VlanEvTimeoutSimple, Src: []string{ |
| 237 | VlanStCreatingDot1PMapper, VlanStCreatingMBPCD, VlanStSettingTconts, VlanStSettingDot1PMapper}, Dst: VlanStStarting}, |
| 238 | {Name: VlanEvTimeoutMids, Src: []string{ |
| 239 | VlanStCreatingGemNCTPs, VlanStCreatingGemIWs, VlanStSettingPQs}, Dst: VlanStStarting}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 240 | */ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 241 | // exceptional treatment for all states except VlanStResetting |
| 242 | {Name: VlanEvReset, Src: []string{VlanStStarting, VlanStWaitingTechProf, |
| 243 | VlanStConfigVtfd, VlanStConfigEvtocd, VlanStConfigDone, VlanStConfigIncrFlow, |
| 244 | VlanStRemoveFlow, VlanStCleanupDone}, |
| 245 | Dst: VlanStResetting}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 246 | // the only way to get to resource-cleared disabled state again is via "resseting" |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 247 | {Name: VlanEvRestart, Src: []string{VlanStResetting}, Dst: VlanStDisabled}, |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 248 | // transitions for reconcile handling according to VOL-3834 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 249 | {Name: VlanEvSkipOmciConfig, Src: []string{VlanStPreparing}, Dst: VlanStConfigDone}, |
| 250 | {Name: VlanEvSkipOmciConfig, Src: []string{VlanStConfigDone}, Dst: VlanStConfigIncrFlow}, |
| 251 | {Name: VlanEvSkipIncFlowConfig, Src: []string{VlanStConfigIncrFlow}, Dst: VlanStConfigDone}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 252 | }, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 253 | fsm.Callbacks{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 254 | "enter_state": func(e *fsm.Event) { instFsm.PAdaptFsm.LogFsmStateChange(ctx, e) }, |
| 255 | "enter_" + VlanStPreparing: func(e *fsm.Event) { instFsm.enterPreparing(ctx, e) }, |
| 256 | "enter_" + VlanStStarting: func(e *fsm.Event) { instFsm.enterConfigStarting(ctx, e) }, |
| 257 | "enter_" + VlanStConfigVtfd: func(e *fsm.Event) { instFsm.enterConfigVtfd(ctx, e) }, |
| 258 | "enter_" + VlanStConfigEvtocd: func(e *fsm.Event) { instFsm.enterConfigEvtocd(ctx, e) }, |
| 259 | "enter_" + VlanStConfigDone: func(e *fsm.Event) { instFsm.enterVlanConfigDone(ctx, e) }, |
| 260 | "enter_" + VlanStConfigIncrFlow: func(e *fsm.Event) { instFsm.enterConfigIncrFlow(ctx, e) }, |
| 261 | "enter_" + VlanStRemoveFlow: func(e *fsm.Event) { instFsm.enterRemoveFlow(ctx, e) }, |
| 262 | "enter_" + VlanStCleanupDone: func(e *fsm.Event) { instFsm.enterVlanCleanupDone(ctx, e) }, |
| 263 | "enter_" + VlanStResetting: func(e *fsm.Event) { instFsm.enterResetting(ctx, e) }, |
| 264 | "enter_" + VlanStDisabled: func(e *fsm.Event) { instFsm.enterDisabled(ctx, e) }, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 265 | }, |
| 266 | ) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 267 | if instFsm.PAdaptFsm.PFsm == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 268 | logger.Errorw(ctx, "UniVlanConfigFsm's Base FSM could not be instantiated!!", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 269 | "device-id": instFsm.deviceID}) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 270 | // Push response on the response channel |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 271 | instFsm.pushReponseOnFlowResponseChannel(ctx, respChan, fmt.Errorf("adapter-base-fsm-could-not-be-instantiated")) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 272 | return nil |
| 273 | } |
| 274 | |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 275 | _ = instFsm.initUniFlowParams(ctx, aTechProfileID, aCookieSlice, aMatchVlan, aSetVlan, aSetPcp, aMeter, respChan) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 276 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 277 | logger.Debugw(ctx, "UniVlanConfigFsm created", log.Fields{"device-id": instFsm.deviceID, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 278 | "accIncrEvto": instFsm.acceptIncrementalEvtoOption}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 279 | return instFsm |
| 280 | } |
| 281 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 282 | //initUniFlowParams is a simplified form of SetUniFlowParams() used for first flow parameters configuration |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 283 | func (oFsm *UniVlanConfigFsm) initUniFlowParams(ctx context.Context, aTpID uint8, aCookieSlice []uint64, |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 284 | aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aMeter *of.OfpMeterConfig, respChan *chan error) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 285 | loRuleParams := cmn.UniVlanRuleParams{ |
Holger Hildebrandt | 47555e7 | 2020-09-21 11:07:24 +0000 | [diff] [blame] | 286 | TpID: aTpID, |
| 287 | MatchVid: uint32(aMatchVlan), |
| 288 | SetVid: uint32(aSetVlan), |
| 289 | SetPcp: uint32(aSetPcp), |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 290 | } |
| 291 | // some automatic adjustments on the filter/treat parameters as not specifically configured/ensured by flow configuration parameters |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 292 | loRuleParams.TagsToRemove = 1 //one tag to remove as default setting |
| 293 | loRuleParams.MatchPcp = cPrioDoNotFilter // do not Filter on prio as default |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 294 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 295 | if loRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 296 | //then matchVlan is don't care and should be overwritten to 'transparent' here to avoid unneeded multiple flow entries |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 297 | loRuleParams.MatchVid = uint32(of.OfpVlanId_OFPVID_PRESENT) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 298 | //TODO!!: maybe be needed to be re-checked at flow deletion (but assume all flows are always deleted togehther) |
| 299 | } else { |
| 300 | if !oFsm.acceptIncrementalEvtoOption { |
| 301 | //then matchVlan is don't care and should be overwritten to 'transparent' here to avoid unneeded multiple flow entries |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 302 | loRuleParams.MatchVid = uint32(of.OfpVlanId_OFPVID_PRESENT) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 306 | if loRuleParams.MatchVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 307 | // no prio/vid filtering requested |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 308 | loRuleParams.TagsToRemove = 0 //no tag pop action |
| 309 | loRuleParams.MatchPcp = cPrioIgnoreTag // no vlan tag filtering |
| 310 | if loRuleParams.SetPcp == cCopyPrioFromInner { |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 311 | //in case of no filtering and configured PrioCopy ensure default prio setting to 0 |
| 312 | // which is required for stacking of untagged, but obviously also ensures prio setting for prio/singletagged |
| 313 | // might collide with NoMatchVid/CopyPrio(/setVid) setting |
| 314 | // this was some precondition setting taken over from py adapter .. |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 315 | loRuleParams.SetPcp = 0 |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 316 | } |
| 317 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 318 | |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 319 | loFlowParams := cmn.UniVlanFlowParams{VlanRuleParams: loRuleParams, RespChan: respChan} |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 320 | loFlowParams.CookieSlice = make([]uint64, 0) |
| 321 | loFlowParams.CookieSlice = append(loFlowParams.CookieSlice, aCookieSlice...) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 322 | if aMeter != nil { |
| 323 | loFlowParams.Meter = aMeter |
| 324 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 325 | |
| 326 | //no mutex protection is required for initial access and adding the first flow is always possible |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 327 | oFsm.uniVlanFlowParamsSlice = make([]cmn.UniVlanFlowParams, 0) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 328 | oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 329 | logger.Debugw(ctx, "first UniVlanConfigFsm flow added", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 330 | "Cookies": oFsm.uniVlanFlowParamsSlice[0].CookieSlice, |
| 331 | "MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16), |
| 332 | "SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16), |
| 333 | "SetPcp": loRuleParams.SetPcp, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 334 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
Holger Hildebrandt | 968eb8f | 2021-09-17 07:41:12 +0000 | [diff] [blame] | 335 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 336 | if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
Holger Hildebrandt | 968eb8f | 2021-09-17 07:41:12 +0000 | [diff] [blame] | 337 | oFsm.reconcileVlanFilterList(ctx, uint16(loRuleParams.SetVid)) |
| 338 | } |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 339 | //cmp also usage in EVTOCDE create in omci_cc |
| 340 | oFsm.evtocdID = cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 341 | oFsm.NumUniFlows = 1 |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 342 | oFsm.uniRemoveFlowsSlice = make([]uniRemoveVlanFlowParams, 0) //initially nothing to remove |
| 343 | |
| 344 | //permanently store flow config for reconcile case |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 345 | if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID, |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 346 | &oFsm.uniVlanFlowParamsSlice, true); err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 347 | logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 348 | return err |
| 349 | } |
| 350 | |
| 351 | return nil |
| 352 | } |
| 353 | |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 354 | //CancelProcessing ensures that suspended processing at waiting on some response is aborted and reset of FSM |
mpagenko | 7314399 | 2021-04-09 15:17:10 +0000 | [diff] [blame] | 355 | func (oFsm *UniVlanConfigFsm) CancelProcessing(ctx context.Context) { |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 356 | if oFsm == nil { |
| 357 | logger.Error(ctx, "no valid UniVlanConfigFsm!") |
| 358 | return |
| 359 | } |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 360 | //mutex protection is required for possible concurrent access to FSM members |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 361 | oFsm.mutexIsAwaitingResponse.Lock() |
| 362 | oFsm.isCanceled = true |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 363 | if oFsm.isAwaitingResponse { |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 364 | //attention: for an unbuffered channel the sender is blocked until the value is received (processed)! |
| 365 | // accordingly the mutex must be released before sending to channel here (mutex acquired in receiver) |
| 366 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 367 | //use channel to indicate that the response waiting shall be aborted |
| 368 | oFsm.omciMIdsResponseReceived <- false |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 369 | } else { |
| 370 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 371 | } |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 372 | |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 373 | // in any case (even if it might be automatically requested by above cancellation of waiting) ensure resetting the FSM |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 374 | PAdaptFsm := oFsm.PAdaptFsm |
| 375 | if PAdaptFsm != nil { |
| 376 | if fsmErr := PAdaptFsm.PFsm.Event(VlanEvReset); fsmErr != nil { |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 377 | logger.Errorw(ctx, "reset-event failed in UniVlanConfigFsm!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 378 | log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID}) |
Holger Hildebrandt | b4563ab | 2021-04-14 10:27:20 +0000 | [diff] [blame] | 379 | } |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 380 | } |
| 381 | } |
| 382 | |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 383 | //GetWaitingTpID returns the TpId that the FSM might be waiting for continuation (0 if none) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 384 | func (oFsm *UniVlanConfigFsm) GetWaitingTpID(ctx context.Context) uint8 { |
| 385 | if oFsm == nil { |
| 386 | logger.Error(ctx, "no valid UniVlanConfigFsm!") |
| 387 | return 0 |
| 388 | } |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 389 | //mutex protection is required for possible concurrent access to FSM members |
| 390 | oFsm.mutexFlowParams.RLock() |
| 391 | defer oFsm.mutexFlowParams.RUnlock() |
| 392 | return oFsm.TpIDWaitingFor |
| 393 | } |
| 394 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 395 | //SetUniFlowParams verifies on existence of flow parameters to be configured, |
| 396 | // optionally udates the cookie list or appends a new flow if there is space |
| 397 | // if possible the FSM is trigggerd to start with the processing |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 398 | // ignore complexity by now |
| 399 | // nolint: gocyclo |
| 400 | func (oFsm *UniVlanConfigFsm) SetUniFlowParams(ctx context.Context, aTpID uint8, aCookieSlice []uint64, |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 401 | aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, lastFlowToReconcile bool, aMeter *of.OfpMeterConfig, respChan *chan error) error { |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 402 | if oFsm == nil { |
| 403 | logger.Error(ctx, "no valid UniVlanConfigFsm!") |
| 404 | return fmt.Errorf("no-valid-UniVlanConfigFsm") |
| 405 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 406 | loRuleParams := cmn.UniVlanRuleParams{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 407 | TpID: aTpID, |
| 408 | MatchVid: uint32(aMatchVlan), |
| 409 | SetVid: uint32(aSetVlan), |
| 410 | SetPcp: uint32(aSetPcp), |
| 411 | } |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 412 | var err error |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 413 | // some automatic adjustments on the filter/treat parameters as not specifically configured/ensured by flow configuration parameters |
| 414 | loRuleParams.TagsToRemove = 1 //one tag to remove as default setting |
| 415 | loRuleParams.MatchPcp = cPrioDoNotFilter // do not Filter on prio as default |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 416 | if loRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
| 417 | //then matchVlan is don't care and should be overwritten to 'transparent' here to avoid unneeded multiple flow entries |
| 418 | loRuleParams.MatchVid = uint32(of.OfpVlanId_OFPVID_PRESENT) |
| 419 | //TODO!!: maybe be needed to be re-checked at flow deletion (but assume all flows are always deleted togehther) |
| 420 | } else { |
| 421 | if !oFsm.acceptIncrementalEvtoOption { |
| 422 | //then matchVlan is don't care and should be overwritten to 'transparent' here to avoid unneeded multiple flow entries |
| 423 | loRuleParams.MatchVid = uint32(of.OfpVlanId_OFPVID_PRESENT) |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | if loRuleParams.MatchVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
| 428 | // no prio/vid filtering requested |
| 429 | loRuleParams.TagsToRemove = 0 //no tag pop action |
| 430 | loRuleParams.MatchPcp = cPrioIgnoreTag // no vlan tag filtering |
| 431 | if loRuleParams.SetPcp == cCopyPrioFromInner { |
| 432 | //in case of no filtering and configured PrioCopy ensure default prio setting to 0 |
| 433 | // which is required for stacking of untagged, but obviously also ensures prio setting for prio/singletagged |
| 434 | // might collide with NoMatchVid/CopyPrio(/setVid) setting |
| 435 | // this was some precondition setting taken over from py adapter .. |
| 436 | loRuleParams.SetPcp = 0 |
| 437 | } |
| 438 | } |
| 439 | |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 440 | //check if there is some ongoing delete-request running for this flow. If so, block here until this is finished. |
| 441 | // might be accordingly rwCore processing runs into timeout in specific situations - needs to be observed ... |
| 442 | // this is to protect uniVlanFlowParams from adding new or re-writing the same cookie to the rule currently under deletion |
| 443 | oFsm.mutexFlowParams.RLock() |
| 444 | if len(oFsm.uniRemoveFlowsSlice) > 0 { |
| 445 | for flow, removeUniFlowParams := range oFsm.uniRemoveFlowsSlice { |
| 446 | if removeUniFlowParams.vlanRuleParams == loRuleParams { |
| 447 | // the flow to add is the same as the one already in progress of deleting |
| 448 | logger.Infow(ctx, "UniVlanConfigFsm flow setting - suspending rule-add due to ongoing removal", log.Fields{ |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 449 | "device-id": oFsm.deviceID, "cookie": removeUniFlowParams.cookie, "remove-index": flow}) |
| 450 | if flow >= len(oFsm.uniRemoveFlowsSlice) { |
| 451 | logger.Errorw(ctx, "abort UniVlanConfigFsm flow add - inconsistent RemoveFlowsSlice", log.Fields{ |
| 452 | "device-id": oFsm.deviceID, "slice length": len(oFsm.uniRemoveFlowsSlice)}) |
| 453 | oFsm.mutexFlowParams.RUnlock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 454 | err = fmt.Errorf("abort UniVlanConfigFsm flow add - inconsistent RemoveFlowsSlice %s", oFsm.deviceID) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 455 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, err) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 456 | return err |
| 457 | |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 458 | } |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 459 | pRemoveParams := &oFsm.uniRemoveFlowsSlice[flow] //wants to modify the uniRemoveFlowsSlice element directly! |
| 460 | oFsm.mutexFlowParams.RUnlock() |
| 461 | if err := oFsm.suspendAddRule(ctx, pRemoveParams); err != nil { |
| 462 | logger.Errorw(ctx, "UniVlanConfigFsm suspension on add aborted - abort complete add-request", log.Fields{ |
| 463 | "device-id": oFsm.deviceID, "cookie": removeUniFlowParams.cookie}) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 464 | err = fmt.Errorf("abort UniVlanConfigFsm suspension on add %s", oFsm.deviceID) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 465 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, err) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 466 | return err |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 467 | } |
| 468 | oFsm.mutexFlowParams.RLock() |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 469 | break //this specific rule should only exist once per uniRemoveFlowsSlice |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 470 | } |
| 471 | } |
| 472 | } |
| 473 | oFsm.mutexFlowParams.RUnlock() |
| 474 | |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 475 | flowEntryMatch := false |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 476 | flowCookieModify := false |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 477 | requestAppendRule := false |
Andrea Campanella | f66ac6e | 2021-05-24 17:09:20 +0200 | [diff] [blame] | 478 | oFsm.lastFlowToReconcile = lastFlowToReconcile |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 479 | //mutex protection is required for possible concurrent access to FSM members |
| 480 | oFsm.mutexFlowParams.Lock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 481 | for flow, storedUniFlowParams := range oFsm.uniVlanFlowParamsSlice { |
| 482 | //TODO: Verify if using e.g. hashes for the structures here for comparison may generate |
| 483 | // countable run time optimization (perhaps with including the hash in kvStore storage?) |
| 484 | if storedUniFlowParams.VlanRuleParams == loRuleParams { |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 485 | flowEntryMatch = true |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 486 | logger.Debugw(ctx, "UniVlanConfigFsm flow setting - rule already exists", log.Fields{ |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 487 | "MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16), |
| 488 | "SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16), |
| 489 | "SetPcp": loRuleParams.SetPcp, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 490 | "device-id": oFsm.deviceID, " uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 491 | var cookieMatch bool |
| 492 | for _, newCookie := range aCookieSlice { // for all cookies available in the arguments |
| 493 | cookieMatch = false |
| 494 | for _, cookie := range storedUniFlowParams.CookieSlice { |
| 495 | if cookie == newCookie { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 496 | logger.Debugw(ctx, "UniVlanConfigFsm flow setting - and cookie already exists", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 497 | "device-id": oFsm.deviceID, "cookie": cookie}) |
| 498 | cookieMatch = true |
| 499 | break //found new cookie - no further search for this requested cookie |
| 500 | } |
| 501 | } |
| 502 | if !cookieMatch { |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 503 | delayedCookie := oFsm.delayNewRuleForCookie(ctx, aCookieSlice) |
| 504 | if delayedCookie != 0 { |
| 505 | //a delay for adding the cookie to this rule is requested |
| 506 | // take care of the mutex which is already locked here, need to unlock/lock accordingly to prevent deadlock in suspension |
| 507 | oFsm.mutexFlowParams.Unlock() |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 508 | if deleteSuccess := oFsm.suspendNewRule(ctx); !deleteSuccess { |
| 509 | logger.Errorw(ctx, "UniVlanConfigFsm suspended add-cookie-to-rule aborted", log.Fields{ |
| 510 | "device-id": oFsm.deviceID, "cookie": delayedCookie}) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 511 | err = fmt.Errorf(" UniVlanConfigFsm suspended add-cookie-to-rule aborted %s", oFsm.deviceID) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 512 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, err) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 513 | return err |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 514 | } |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 515 | flowCookieModify, requestAppendRule = oFsm.reviseFlowConstellation(ctx, delayedCookie, loRuleParams) |
mpagenko | d6c0552 | 2021-08-23 15:59:06 +0000 | [diff] [blame] | 516 | oFsm.mutexFlowParams.Lock() |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 517 | } else { |
| 518 | logger.Debugw(ctx, "UniVlanConfigFsm flow setting -adding new cookie", log.Fields{ |
| 519 | "device-id": oFsm.deviceID, "cookie": newCookie}) |
| 520 | //as range works with copies of the slice we have to write to the original slice!! |
| 521 | oFsm.uniVlanFlowParamsSlice[flow].CookieSlice = append(oFsm.uniVlanFlowParamsSlice[flow].CookieSlice, |
| 522 | newCookie) |
| 523 | flowCookieModify = true |
| 524 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 525 | } |
| 526 | } //for all new cookies |
| 527 | break // found rule - no further rule search |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 528 | } |
| 529 | } |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 530 | oFsm.mutexFlowParams.Unlock() |
| 531 | |
| 532 | if !flowEntryMatch { //it is (was) a new rule |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 533 | delayedCookie, deleteSuccess := oFsm.suspendIfRequiredNewRule(ctx, aCookieSlice) |
| 534 | if !deleteSuccess { |
| 535 | logger.Errorw(ctx, "UniVlanConfigFsm suspended add-new-rule aborted", log.Fields{ |
| 536 | "device-id": oFsm.deviceID, "cookie": delayedCookie}) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 537 | err = fmt.Errorf(" UniVlanConfigFsm suspended add-new-rule aborted %s", oFsm.deviceID) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 538 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, err) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 539 | return err |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 540 | } |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 541 | requestAppendRule = true //default assumption here is that rule is to be appended |
| 542 | flowCookieModify = true //and that the the flow data base is to be updated |
| 543 | if delayedCookie != 0 { //it was suspended |
| 544 | flowCookieModify, requestAppendRule = oFsm.reviseFlowConstellation(ctx, delayedCookie, loRuleParams) |
| 545 | } |
| 546 | } |
| 547 | kvStoreWrite := false //default setting is to not write to kvStore immediately - will be done on FSM execution finally |
| 548 | if requestAppendRule { |
| 549 | oFsm.mutexFlowParams.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 550 | if oFsm.NumUniFlows < cMaxAllowedFlows { |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 551 | loFlowParams := cmn.UniVlanFlowParams{VlanRuleParams: loRuleParams, RespChan: respChan} |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 552 | loFlowParams.CookieSlice = make([]uint64, 0) |
| 553 | loFlowParams.CookieSlice = append(loFlowParams.CookieSlice, aCookieSlice...) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 554 | if aMeter != nil { |
| 555 | loFlowParams.Meter = aMeter |
| 556 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 557 | oFsm.uniVlanFlowParamsSlice = append(oFsm.uniVlanFlowParamsSlice, loFlowParams) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 558 | logger.Debugw(ctx, "UniVlanConfigFsm flow add", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 559 | "Cookies": oFsm.uniVlanFlowParamsSlice[oFsm.NumUniFlows].CookieSlice, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 560 | "MatchVid": strconv.FormatInt(int64(loRuleParams.MatchVid), 16), |
| 561 | "SetVid": strconv.FormatInt(int64(loRuleParams.SetVid), 16), |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 562 | "SetPcp": loRuleParams.SetPcp, "numberofFlows": oFsm.NumUniFlows + 1, |
| 563 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 564 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 565 | if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
Holger Hildebrandt | 968eb8f | 2021-09-17 07:41:12 +0000 | [diff] [blame] | 566 | oFsm.reconcileVlanFilterList(ctx, uint16(loRuleParams.SetVid)) |
| 567 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 568 | oFsm.NumUniFlows++ |
| 569 | pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 570 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 571 | if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 572 | logger.Debugw(ctx, "reconciling - skip omci-config of additional vlan rule", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 573 | log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID}) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 574 | //attention: take care to release the mutexFlowParams when calling the FSM directly - |
| 575 | // synchronous FSM 'event/state' functions may rely on this mutex |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 576 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 577 | if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) { |
| 578 | if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvSkipOmciConfig); fsmErr != nil { |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 579 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 580 | log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID}) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 581 | err = fsmErr |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 582 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, err) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 583 | return err |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 584 | } |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 585 | } |
| 586 | return nil |
| 587 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 588 | // note: theoretical it would be possible to clear the same rule from the remove slice |
| 589 | // (for entries that have not yet been started with removal) |
| 590 | // but that is getting quite complicated - maybe a future optimization in case it should prove reasonable |
| 591 | // anyway the precondition here is that the FSM checks for rules to delete first and adds new rules afterwards |
Holger Hildebrandt | 47555e7 | 2020-09-21 11:07:24 +0000 | [diff] [blame] | 592 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 593 | if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) { |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 594 | //have to re-trigger the FSM to proceed with outstanding incremental flow configuration |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 595 | if oFsm.ConfiguredUniFlow == 0 { |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 596 | // this is a restart with a complete new flow, we can re-use the initial flow config control |
| 597 | // including the check, if the related techProfile is (still) available (probably also removed in between) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 598 | //attention: take care to release the mutexFlowParams when calling the FSM directly - |
| 599 | // synchronous FSM 'event/state' functions may rely on this mutex |
| 600 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 601 | if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvRenew); fsmErr != nil { |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 602 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!", |
| 603 | log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID}) |
| 604 | } |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 605 | } else { |
| 606 | //some further flows are to be configured |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 607 | //store the actual rule that shall be worked upon in the following transient states |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 608 | if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.ConfiguredUniFlow) { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 609 | //check introduced after having observed some panic here |
| 610 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm - inconsistent counter", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 611 | log.Fields{"ConfiguredUniFlow": oFsm.ConfiguredUniFlow, |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 612 | "sliceLen": len(oFsm.uniVlanFlowParamsSlice), "device-id": oFsm.deviceID}) |
| 613 | oFsm.mutexFlowParams.Unlock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 614 | err = fmt.Errorf("abort UniVlanConfigFsm on add due to internal counter mismatch %s", oFsm.deviceID) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 615 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, err) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 616 | return err |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 617 | } |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 618 | |
| 619 | oFsm.actualUniFlowParam = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow] |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 620 | //tpId of the next rule to be configured |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 621 | tpID := oFsm.actualUniFlowParam.VlanRuleParams.TpID |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 622 | oFsm.TpIDWaitingFor = tpID |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 623 | loSetVlan := oFsm.actualUniFlowParam.VlanRuleParams.SetVid |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 624 | //attention: take care to release the mutexFlowParams when calling the FSM directly - |
| 625 | // synchronous FSM 'event/state' functions may rely on this mutex |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 626 | // but it must be released already before calling getTechProfileDone() as it may already be locked |
| 627 | // by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 628 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 629 | loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, tpID) |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 630 | logger.Debugw(ctx, "UniVlanConfigFsm - incremental config request (on setConfig)", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 631 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 632 | "set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone}) |
| 633 | |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 634 | var fsmErr error |
| 635 | if loTechProfDone { |
| 636 | // let the vlan processing continue with next rule |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 637 | fsmErr = pConfigVlanStateBaseFsm.Event(VlanEvIncrFlowConfig) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 638 | } else { |
| 639 | // set to waiting for Techprofile |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 640 | fsmErr = pConfigVlanStateBaseFsm.Event(VlanEvWaitTPIncr) |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 641 | } |
| 642 | if fsmErr != nil { |
| 643 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!", |
| 644 | log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID}) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 645 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, fsmErr) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 646 | return fsmErr |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 647 | } |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 648 | } |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 649 | } else { |
| 650 | // if not in the appropriate state a new entry will be automatically considered later |
| 651 | // when the configDone state is reached |
| 652 | oFsm.mutexFlowParams.Unlock() |
| 653 | } |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 654 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 655 | logger.Errorw(ctx, "UniVlanConfigFsm flow limit exceeded", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 656 | "device-id": oFsm.deviceID, "flow-number": oFsm.NumUniFlows}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 657 | oFsm.mutexFlowParams.Unlock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 658 | err = fmt.Errorf(" UniVlanConfigFsm flow limit exceeded %s", oFsm.deviceID) |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 659 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, err) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 660 | return err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 661 | } |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 662 | } else { |
| 663 | // no activity within the FSM for OMCI processing, the deviceReason may be updated immediately |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 664 | kvStoreWrite = true // ensure actual data write to kvStore immediately (no FSM activity) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 665 | // push response on response channel as there is nothing to be done for this flow |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 666 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, nil) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 667 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 668 | oFsm.mutexFlowParams.RLock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 669 | if oFsm.NumUniFlows == oFsm.ConfiguredUniFlow { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 670 | //all requested rules really have been configured |
| 671 | // state transition notification is checked in deviceHandler |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 672 | oFsm.mutexFlowParams.RUnlock() |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 673 | if oFsm.pDeviceHandler != nil { |
| 674 | //also the related TechProfile was already configured |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 675 | logger.Debugw(ctx, "UniVlanConfigFsm rule already set - send immediate add-success event for reason update", log.Fields{ |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 676 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 677 | // success indication without the need to write to kvStore (done already below with updated data from StorePersUniFlowConfig()) |
| 678 | go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetAddNoKvStore)) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 679 | } |
| 680 | } else { |
| 681 | // avoid device reason update as the rule config connected to this flow may still be in progress |
| 682 | // and the device reason should only be updated on success of rule config |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 683 | logger.Debugw(ctx, "UniVlanConfigFsm rule already set but configuration ongoing, suppress early add-success event for reason update", |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 684 | log.Fields{"device-id": oFsm.deviceID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 685 | "NumberofRules": oFsm.NumUniFlows, "Configured rules": oFsm.ConfiguredUniFlow}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 686 | oFsm.mutexFlowParams.RUnlock() |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 687 | } |
| 688 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 689 | |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 690 | if flowCookieModify { // some change was done to the flow entries |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 691 | //permanently store flow config for reconcile case |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 692 | oFsm.mutexFlowParams.RLock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 693 | if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID, |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 694 | &oFsm.uniVlanFlowParamsSlice, kvStoreWrite); err != nil { |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 695 | oFsm.mutexFlowParams.RUnlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 696 | logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 697 | return err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 698 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 699 | oFsm.mutexFlowParams.RUnlock() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 700 | } |
| 701 | return nil |
| 702 | } |
| 703 | |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 704 | func (oFsm *UniVlanConfigFsm) suspendAddRule(ctx context.Context, apRemoveFlowParams *uniRemoveVlanFlowParams) error { |
| 705 | oFsm.mutexFlowParams.Lock() |
| 706 | deleteChannel := apRemoveFlowParams.removeChannel |
| 707 | apRemoveFlowParams.isSuspendedOnAdd = true |
| 708 | oFsm.mutexFlowParams.Unlock() |
| 709 | |
| 710 | // isSuspendedOnAdd is not reset here-after as the assumption is, that after |
| 711 | select { |
| 712 | case success := <-deleteChannel: |
| 713 | //no need to reset isSuspendedOnAdd as in this case the removeElement will be deleted completely |
| 714 | if success { |
| 715 | logger.Infow(ctx, "resume adding this rule after having completed deletion", log.Fields{ |
| 716 | "device-id": oFsm.deviceID}) |
| 717 | return nil |
| 718 | } |
| 719 | return fmt.Errorf("suspend aborted, also aborting add-activity: %s", oFsm.deviceID) |
| 720 | case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): |
| 721 | oFsm.mutexFlowParams.Lock() |
| 722 | if apRemoveFlowParams != nil { |
| 723 | apRemoveFlowParams.isSuspendedOnAdd = false |
| 724 | } |
| 725 | oFsm.mutexFlowParams.Unlock() |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 726 | logger.Errorw(ctx, "timeout waiting for deletion of rule, also aborting add-activity", log.Fields{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 727 | "device-id": oFsm.deviceID}) |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 728 | return fmt.Errorf("suspend aborted on timeout, also aborting add-activity: %s", oFsm.deviceID) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 729 | } |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 730 | } |
| 731 | |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 732 | // VOL-3828 flow config sequence workaround ########### start ########## |
| 733 | func (oFsm *UniVlanConfigFsm) delayNewRuleForCookie(ctx context.Context, aCookieSlice []uint64) uint64 { |
| 734 | //assumes mutexFlowParams.Lock() protection from caller! |
| 735 | if oFsm.delayNewRuleCookie == 0 && len(aCookieSlice) == 1 { |
| 736 | // if not already waiting, limitation for this workaround is to just have one overlapping cookie/rule |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 737 | // suspend check is done only if there is only one cookie in the request |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 738 | // background: more elements only expected in reconcile use case, where no conflicting sequence is to be expected |
| 739 | newCookie := aCookieSlice[0] |
| 740 | for _, storedUniFlowParams := range oFsm.uniVlanFlowParamsSlice { |
| 741 | for _, cookie := range storedUniFlowParams.CookieSlice { |
| 742 | if cookie == newCookie { |
| 743 | logger.Debugw(ctx, "UniVlanConfigFsm flow setting - new cookie still exists for some rule", log.Fields{ |
| 744 | "device-id": oFsm.deviceID, "cookie": cookie, "exists with SetVlan": storedUniFlowParams.VlanRuleParams.SetVid}) |
| 745 | oFsm.delayNewRuleCookie = newCookie |
| 746 | return newCookie //found new cookie in some existing rule |
| 747 | } |
| 748 | } // for all stored cookies of the actual inspected rule |
| 749 | } //for all rules |
| 750 | } |
| 751 | return 0 //no delay requested |
| 752 | } |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 753 | func (oFsm *UniVlanConfigFsm) suspendNewRule(ctx context.Context) bool { |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 754 | oFsm.mutexFlowParams.RLock() |
| 755 | logger.Infow(ctx, "Need to suspend adding this rule as long as the cookie is still connected to some other rule", log.Fields{ |
| 756 | "device-id": oFsm.deviceID, "cookie": oFsm.delayNewRuleCookie}) |
| 757 | oFsm.mutexFlowParams.RUnlock() |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 758 | cookieDeleted := true //default assumption also for timeout (just try to continue as if removed) |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 759 | select { |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 760 | case cookieDeleted = <-oFsm.chCookieDeleted: |
| 761 | logger.Infow(ctx, "resume adding this rule after having deleted cookie in some other rule or abort", log.Fields{ |
| 762 | "device-id": oFsm.deviceID, "cookie": oFsm.delayNewRuleCookie, "deleted": cookieDeleted}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 763 | case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 764 | logger.Errorw(ctx, "timeout waiting for deletion of cookie in some other rule, just try to continue", log.Fields{ |
| 765 | "device-id": oFsm.deviceID, "cookie": oFsm.delayNewRuleCookie}) |
| 766 | } |
| 767 | oFsm.mutexFlowParams.Lock() |
| 768 | oFsm.delayNewRuleCookie = 0 |
| 769 | oFsm.mutexFlowParams.Unlock() |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 770 | return cookieDeleted |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 771 | } |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 772 | func (oFsm *UniVlanConfigFsm) suspendIfRequiredNewRule(ctx context.Context, aCookieSlice []uint64) (uint64, bool) { |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 773 | oFsm.mutexFlowParams.Lock() |
| 774 | delayedCookie := oFsm.delayNewRuleForCookie(ctx, aCookieSlice) |
| 775 | oFsm.mutexFlowParams.Unlock() |
| 776 | |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 777 | deleteSuccess := true |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 778 | if delayedCookie != 0 { |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 779 | deleteSuccess = oFsm.suspendNewRule(ctx) |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 780 | } |
mpagenko | bc4170a | 2021-08-17 16:42:10 +0000 | [diff] [blame] | 781 | return delayedCookie, deleteSuccess |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 782 | } |
| 783 | |
| 784 | //returns flowModified, RuleAppendRequest |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 785 | func (oFsm *UniVlanConfigFsm) reviseFlowConstellation(ctx context.Context, aCookie uint64, aUniVlanRuleParams cmn.UniVlanRuleParams) (bool, bool) { |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 786 | flowEntryMatch := false |
| 787 | oFsm.mutexFlowParams.Lock() |
| 788 | defer oFsm.mutexFlowParams.Unlock() |
| 789 | for flow, storedUniFlowParams := range oFsm.uniVlanFlowParamsSlice { |
| 790 | if storedUniFlowParams.VlanRuleParams == aUniVlanRuleParams { |
| 791 | flowEntryMatch = true |
| 792 | logger.Debugw(ctx, "UniVlanConfigFsm flow revise - rule already exists", log.Fields{ |
| 793 | "device-id": oFsm.deviceID}) |
| 794 | cookieMatch := false |
| 795 | for _, cookie := range storedUniFlowParams.CookieSlice { |
| 796 | if cookie == aCookie { |
| 797 | logger.Debugw(ctx, "UniVlanConfigFsm flow revise - and cookie already exists", log.Fields{ |
| 798 | "device-id": oFsm.deviceID, "cookie": cookie}) |
| 799 | cookieMatch = true |
| 800 | break //found new cookie - no further search for this requested cookie |
| 801 | } |
| 802 | } |
| 803 | if !cookieMatch { |
| 804 | logger.Debugw(ctx, "UniVlanConfigFsm flow revise -adding new cookie", log.Fields{ |
| 805 | "device-id": oFsm.deviceID, "cookie": aCookie}) |
| 806 | //as range works with copies of the slice we have to write to the original slice!! |
| 807 | oFsm.uniVlanFlowParamsSlice[flow].CookieSlice = append(oFsm.uniVlanFlowParamsSlice[flow].CookieSlice, |
| 808 | aCookie) |
| 809 | return true, false //flowModified, NoRuleAppend |
| 810 | } |
| 811 | break // found rule - no further rule search |
| 812 | } |
| 813 | } |
| 814 | if !flowEntryMatch { //it is a new rule |
| 815 | return true, true //flowModified, RuleAppend |
| 816 | } |
| 817 | return false, false //flowNotModified, NoRuleAppend |
| 818 | } |
| 819 | |
| 820 | // VOL-3828 flow config sequence workaround ########### end ########## |
| 821 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 822 | //RemoveUniFlowParams verifies on existence of flow cookie, |
| 823 | // if found removes cookie from flow cookie list and if this is empty |
| 824 | // initiates removal of the flow related configuration from the ONU (via OMCI) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 825 | func (oFsm *UniVlanConfigFsm) RemoveUniFlowParams(ctx context.Context, aCookie uint64, respChan *chan error) error { |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 826 | if oFsm == nil { |
| 827 | logger.Error(ctx, "no valid UniVlanConfigFsm!") |
| 828 | return fmt.Errorf("no-valid-UniVlanConfigFsm") |
| 829 | } |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 830 | var deletedCookie uint64 |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 831 | flowCookieMatch := false |
| 832 | //mutex protection is required for possible concurrent access to FSM members |
| 833 | oFsm.mutexFlowParams.Lock() |
| 834 | defer oFsm.mutexFlowParams.Unlock() |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 835 | remove_loop: |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 836 | for flow, storedUniFlowParams := range oFsm.uniVlanFlowParamsSlice { |
| 837 | for i, cookie := range storedUniFlowParams.CookieSlice { |
| 838 | if cookie == aCookie { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 839 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal - cookie found", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 840 | "device-id": oFsm.deviceID, "cookie": cookie}) |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 841 | deletedCookie = aCookie |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 842 | //remove the cookie from the cookie slice and verify it is getting empty |
| 843 | if len(storedUniFlowParams.CookieSlice) == 1 { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 844 | // had to shift content to function due to sca complexity |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 845 | flowCookieMatch = oFsm.removeRuleComplete(ctx, storedUniFlowParams, aCookie, respChan) |
mpagenko | dee02a6 | 2021-07-21 10:56:10 +0000 | [diff] [blame] | 846 | //persistencyData write is now part of removeRuleComplete() (on success) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 847 | } else { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 848 | flowCookieMatch = true |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 849 | //cut off the requested cookie by slicing out this element |
| 850 | oFsm.uniVlanFlowParamsSlice[flow].CookieSlice = append( |
| 851 | oFsm.uniVlanFlowParamsSlice[flow].CookieSlice[:i], |
| 852 | oFsm.uniVlanFlowParamsSlice[flow].CookieSlice[i+1:]...) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 853 | // no activity within the FSM for OMCI processing, the deviceReason may be updated immediately |
| 854 | // state transition notification is checked in deviceHandler |
| 855 | if oFsm.pDeviceHandler != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 856 | // success indication without the need to write to kvStore (done already below with updated data from StorePersUniFlowConfig()) |
| 857 | go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore)) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 858 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 859 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal - rule persists with still valid cookies", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 860 | "device-id": oFsm.deviceID, "cookies": oFsm.uniVlanFlowParamsSlice[flow].CookieSlice}) |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 861 | if deletedCookie == oFsm.delayNewRuleCookie { |
| 862 | //the delayedNewCookie is the one that is currently deleted, but the rule still exist with other cookies |
| 863 | //as long as there are further cookies for this rule indicate there is still some cookie to be deleted |
| 864 | //simply use the first one |
| 865 | oFsm.delayNewRuleCookie = oFsm.uniVlanFlowParamsSlice[flow].CookieSlice[0] |
| 866 | logger.Debugw(ctx, "UniVlanConfigFsm remaining cookie awaited for deletion before new rule add", log.Fields{ |
| 867 | "device-id": oFsm.deviceID, "cookie": oFsm.delayNewRuleCookie}) |
| 868 | } |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 869 | // Push response on the response channel |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 870 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, nil) |
mpagenko | dee02a6 | 2021-07-21 10:56:10 +0000 | [diff] [blame] | 871 | //permanently store the modified flow config for reconcile case and immediately write to KvStore |
| 872 | if oFsm.pDeviceHandler != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 873 | if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID, |
mpagenko | dee02a6 | 2021-07-21 10:56:10 +0000 | [diff] [blame] | 874 | &oFsm.uniVlanFlowParamsSlice, true); err != nil { |
| 875 | logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID}) |
| 876 | return err |
| 877 | } |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 878 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 879 | } |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 880 | break remove_loop //found the cookie - no further search for this requested cookie |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 881 | } |
| 882 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 883 | } //search all flows |
| 884 | if !flowCookieMatch { //some cookie remove-request for a cookie that does not exist in the FSM data |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 885 | logger.Warnw(ctx, "UniVlanConfigFsm flow removal - remove-cookie not found", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 886 | "device-id": oFsm.deviceID, "remove-cookie": aCookie}) |
| 887 | // but accept the request with success as no such cookie (flow) does exist |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 888 | // no activity within the FSM for OMCI processing, the deviceReason may be updated immediately |
| 889 | // state transition notification is checked in deviceHandler |
| 890 | if oFsm.pDeviceHandler != nil { |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 891 | // success indication without the need to write to kvStore (no change) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 892 | go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(oFsm.requestEvent+cDeviceEventOffsetRemoveNoKvStore)) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 893 | } |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 894 | // Push response on the response channel |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 895 | oFsm.pushReponseOnFlowResponseChannel(ctx, respChan, nil) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 896 | return nil |
| 897 | } //unknown cookie |
| 898 | |
| 899 | return nil |
| 900 | } |
| 901 | |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 902 | // removeRuleComplete initiates the complete removal of a VLAN rule (from single cookie element) |
mpagenko | dee02a6 | 2021-07-21 10:56:10 +0000 | [diff] [blame] | 903 | // requires mutexFlowParams to be locked at call |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 904 | func (oFsm *UniVlanConfigFsm) removeRuleComplete(ctx context.Context, |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 905 | aUniFlowParams cmn.UniVlanFlowParams, aCookie uint64, respChan *chan error) bool { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 906 | pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 907 | var cancelPendingConfig bool = false |
| 908 | var loRemoveParams uniRemoveVlanFlowParams = uniRemoveVlanFlowParams{} |
| 909 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal - full flow removal", log.Fields{ |
| 910 | "device-id": oFsm.deviceID}) |
| 911 | //rwCore flow recovery may be the reason for this delete, in which case the flowToBeDeleted may be the same |
| 912 | // as the one still waiting in the FSM as toAdd but waiting for TechProfileConfig |
| 913 | // so we have to check if we have to abort the outstanding AddRequest and regard the current DelRequest as done |
| 914 | // if the Fsm is in some other transient (config) state, we will reach the DelRequest later and correctly process it then |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 915 | if pConfigVlanStateBaseFsm.Is(VlanStWaitingTechProf) { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 916 | logger.Debugw(ctx, "UniVlanConfigFsm was waiting for TechProf config with add-request, just aborting the outstanding add", |
| 917 | log.Fields{"device-id": oFsm.deviceID}) |
| 918 | cancelPendingConfig = true |
| 919 | } else { |
| 920 | //create a new element for the removeVlanFlow slice |
| 921 | loRemoveParams = uniRemoveVlanFlowParams{ |
| 922 | vlanRuleParams: aUniFlowParams.VlanRuleParams, |
| 923 | cookie: aCookie, |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 924 | respChan: respChan, |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 925 | } |
| 926 | loRemoveParams.removeChannel = make(chan bool) |
| 927 | oFsm.uniRemoveFlowsSlice = append(oFsm.uniRemoveFlowsSlice, loRemoveParams) |
| 928 | } |
| 929 | |
| 930 | usedTpID := aUniFlowParams.VlanRuleParams.TpID |
| 931 | if len(oFsm.uniVlanFlowParamsSlice) <= 1 { |
| 932 | //at this point it is evident that no flow anymore will refer to a still possibly active Techprofile |
| 933 | //request that this profile gets deleted before a new flow add is allowed (except for some aborted add) |
| 934 | if !cancelPendingConfig { |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 935 | // ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it) |
| 936 | oFsm.mutexFlowParams.Unlock() |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 937 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal requested - set TechProfile to-delete", log.Fields{ |
| 938 | "device-id": oFsm.deviceID}) |
| 939 | if oFsm.pUniTechProf != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 940 | oFsm.pUniTechProf.SetProfileToDelete(oFsm.pOnuUniPort.UniID, usedTpID, true) |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 941 | } |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 942 | oFsm.mutexFlowParams.Lock() |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 943 | } |
| 944 | } else { |
| 945 | if !cancelPendingConfig { |
| 946 | oFsm.updateTechProfileToDelete(ctx, usedTpID) |
| 947 | } |
| 948 | } |
| 949 | //trigger the FSM to remove the relevant rule |
| 950 | if cancelPendingConfig { |
| 951 | //as the uniFlow parameters are already stored (for add) but no explicit removal is done anymore |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 952 | // the paramSlice has to be updated with rule-removal, which also then updates NumUniFlows |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 953 | //call from 'non-configured' state of the rules |
| 954 | if err := oFsm.removeFlowFromParamsSlice(ctx, aCookie, false); err != nil { |
| 955 | //something quite inconsistent detected, perhaps just try to recover with FSM reset |
| 956 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 957 | if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvReset); fsmErr != nil { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 958 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!", |
| 959 | log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID}) |
| 960 | } |
| 961 | return false //data base update could not be done, return like cookie not found |
| 962 | } |
| 963 | |
| 964 | oFsm.requestEventOffset = uint8(cDeviceEventOffsetRemoveWithKvStore) //offset for last flow-remove activity (with kvStore request) |
| 965 | //attention: take care to release and re-take the mutexFlowParams when calling the FSM directly - |
| 966 | // synchronous FSM 'event/state' functions may rely on this mutex |
| 967 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 968 | if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvCancelOutstandingConfig); fsmErr != nil { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 969 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!", |
| 970 | log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID}) |
| 971 | } |
| 972 | oFsm.mutexFlowParams.Lock() |
| 973 | return true |
| 974 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 975 | if pConfigVlanStateBaseFsm.Is(VlanStConfigDone) { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 976 | logger.Debugw(ctx, "UniVlanConfigFsm rule removal request", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 977 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 978 | "tp-id": loRemoveParams.vlanRuleParams.TpID, |
| 979 | "set-Vlan": loRemoveParams.vlanRuleParams.SetVid}) |
| 980 | //have to re-trigger the FSM to proceed with outstanding incremental flow configuration |
| 981 | //attention: take care to release and re-take the mutexFlowParams when calling the FSM directly - |
| 982 | // synchronous FSM 'event/state' functions may rely on this mutex |
| 983 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 984 | if fsmErr := pConfigVlanStateBaseFsm.Event(VlanEvRemFlowConfig); fsmErr != nil { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 985 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm!", |
| 986 | log.Fields{"fsmState": pConfigVlanStateBaseFsm.Current(), "error": fsmErr, "device-id": oFsm.deviceID}) |
| 987 | } |
| 988 | oFsm.mutexFlowParams.Lock() |
| 989 | } // if not in the appropriate state a new entry will be automatically considered later |
| 990 | // when the configDone state is reached |
| 991 | return true |
| 992 | } |
| 993 | |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 994 | //removeFlowFromParamsSlice removes a flow from stored uniVlanFlowParamsSlice based on the cookie |
| 995 | // it assumes that adding cookies for this flow (including the actual one to delete) was prevented |
| 996 | // from the start of the deletion request to avoid to much interference |
| 997 | // so when called, there can only be one cookie active for this flow |
| 998 | // requires mutexFlowParams to be locked at call |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 999 | func (oFsm *UniVlanConfigFsm) removeFlowFromParamsSlice(ctx context.Context, aCookie uint64, aWasConfigured bool) error { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1000 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal from ParamsSlice", log.Fields{ |
| 1001 | "device-id": oFsm.deviceID, "cookie": aCookie}) |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1002 | cookieFound := false |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1003 | removeFromSlice_loop: |
| 1004 | for flow, storedUniFlowParams := range oFsm.uniVlanFlowParamsSlice { |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1005 | // if UniFlowParams exists, cookieSlice should always have at least one element |
| 1006 | cookieSliceLen := len(storedUniFlowParams.CookieSlice) |
| 1007 | if cookieSliceLen == 1 { |
| 1008 | if storedUniFlowParams.CookieSlice[0] == aCookie { |
| 1009 | cookieFound = true |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1010 | } |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1011 | } else if cookieSliceLen == 0 { |
| 1012 | errStr := "UniVlanConfigFsm unexpected cookie slice length 0 - removal in uniVlanFlowParamsSlice aborted" |
| 1013 | logger.Errorw(ctx, errStr, log.Fields{"device-id": oFsm.deviceID}) |
| 1014 | return errors.New(errStr) |
| 1015 | } else { |
| 1016 | errStr := "UniVlanConfigFsm flow removal unexpected cookie slice length, but rule removal continued" |
| 1017 | logger.Errorw(ctx, errStr, log.Fields{ |
| 1018 | "cookieSliceLen": len(oFsm.uniVlanFlowParamsSlice), "device-id": oFsm.deviceID}) |
| 1019 | for _, cookie := range storedUniFlowParams.CookieSlice { |
| 1020 | if cookie == aCookie { |
| 1021 | cookieFound = true |
| 1022 | break |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | if cookieFound { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1027 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal from ParamsSlice - cookie found", log.Fields{ |
| 1028 | "device-id": oFsm.deviceID, "cookie": aCookie}) |
| 1029 | //remove the actual element from the addVlanFlow slice |
| 1030 | // oFsm.uniVlanFlowParamsSlice[flow].CookieSlice = nil //automatically done by garbage collector |
| 1031 | if len(oFsm.uniVlanFlowParamsSlice) <= 1 { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1032 | oFsm.NumUniFlows = 0 //no more flows |
| 1033 | oFsm.ConfiguredUniFlow = 0 //no more flows configured |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1034 | oFsm.uniVlanFlowParamsSlice = nil //reset the slice |
| 1035 | //at this point it is evident that no flow anymore refers to a still possibly active Techprofile |
| 1036 | //request that this profile gets deleted before a new flow add is allowed |
| 1037 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal from ParamsSlice - no more flows", log.Fields{ |
| 1038 | "device-id": oFsm.deviceID}) |
| 1039 | } else { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1040 | oFsm.NumUniFlows-- |
| 1041 | if aWasConfigured && oFsm.ConfiguredUniFlow > 0 { |
| 1042 | oFsm.ConfiguredUniFlow-- |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1043 | } |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1044 | if !aWasConfigured { |
| 1045 | // We did not actually process this flow but was removed before that. |
| 1046 | // Indicate success response for the flow to caller who is blocking on a response |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 1047 | oFsm.pushReponseOnFlowResponseChannel(ctx, storedUniFlowParams.RespChan, nil) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1048 | } |
| 1049 | |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1050 | //cut off the requested flow by slicing out this element |
| 1051 | oFsm.uniVlanFlowParamsSlice = append( |
| 1052 | oFsm.uniVlanFlowParamsSlice[:flow], oFsm.uniVlanFlowParamsSlice[flow+1:]...) |
| 1053 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal - specific flow removed from data", log.Fields{ |
| 1054 | "device-id": oFsm.deviceID}) |
| 1055 | } |
| 1056 | break removeFromSlice_loop //found the cookie - no further search for this requested cookie |
| 1057 | } |
| 1058 | } //search all flows |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1059 | if !cookieFound { |
| 1060 | errStr := "UniVlanConfigFsm cookie for removal not found, internal counter not updated" |
| 1061 | logger.Errorw(ctx, errStr, log.Fields{"device-id": oFsm.deviceID}) |
| 1062 | return errors.New(errStr) |
| 1063 | } |
mpagenko | dee02a6 | 2021-07-21 10:56:10 +0000 | [diff] [blame] | 1064 | //if the cookie was found and removed from uniVlanFlowParamsSlice above now write the modified persistency data |
| 1065 | // KVStore update will be done after reaching the requested FSM end state (not immediately here) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1066 | if err := oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID, |
mpagenko | dee02a6 | 2021-07-21 10:56:10 +0000 | [diff] [blame] | 1067 | &oFsm.uniVlanFlowParamsSlice, false); err != nil { |
| 1068 | logger.Errorw(ctx, err.Error(), log.Fields{"device-id": oFsm.deviceID}) |
| 1069 | return err |
| 1070 | } |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1071 | return nil |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | // requires mutexFlowParams to be locked at call |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1075 | func (oFsm *UniVlanConfigFsm) updateTechProfileToDelete(ctx context.Context, usedTpID uint8) { |
| 1076 | //here we have to check, if there are still other flows referencing to the actual ProfileId |
| 1077 | // before we can request that this profile gets deleted before a new flow add is allowed |
| 1078 | tpIDInOtherFlows := false |
| 1079 | for _, tpUniFlowParams := range oFsm.uniVlanFlowParamsSlice { |
| 1080 | if tpUniFlowParams.VlanRuleParams.TpID == usedTpID { |
| 1081 | tpIDInOtherFlows = true |
| 1082 | break // search loop can be left |
| 1083 | } |
| 1084 | } |
| 1085 | if tpIDInOtherFlows { |
| 1086 | logger.Debugw(ctx, "UniVlanConfigFsm tp-id used in deleted flow is still used in other flows", log.Fields{ |
| 1087 | "device-id": oFsm.deviceID, "tp-id": usedTpID}) |
| 1088 | } else { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1089 | logger.Debugw(ctx, "UniVlanConfigFsm tp-id used in deleted flow is not used anymore - set TechProfile to-delete", log.Fields{ |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1090 | "device-id": oFsm.deviceID, "tp-id": usedTpID}) |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 1091 | // ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it) |
| 1092 | oFsm.mutexFlowParams.Unlock() |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1093 | if oFsm.pUniTechProf != nil { |
| 1094 | //request that this profile gets deleted before a new flow add is allowed |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1095 | oFsm.pUniTechProf.SetProfileToDelete(oFsm.pOnuUniPort.UniID, usedTpID, true) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1096 | } |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 1097 | oFsm.mutexFlowParams.Lock() |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1098 | } |
| 1099 | } |
| 1100 | |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1101 | func (oFsm *UniVlanConfigFsm) enterPreparing(ctx context.Context, e *fsm.Event) { |
| 1102 | logger.Debugw(ctx, "UniVlanConfigFsm preparing", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1103 | |
| 1104 | // this FSM is not intended for re-start, needs always new creation for a new run |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1105 | // (self-destroying - compare enterDisabled()) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1106 | oFsm.omciMIdsResponseReceived = make(chan bool) |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1107 | oFsm.chCookieDeleted = make(chan bool) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1108 | // start go routine for processing of LockState messages |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1109 | go oFsm.processOmciVlanMessages(ctx) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1110 | //let the state machine run forward from here directly |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1111 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1112 | if pConfigVlanStateAFsm != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1113 | if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1114 | logger.Debugw(ctx, "reconciling - skip omci-config of vlan rule", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1115 | log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID}) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1116 | // Can't call FSM Event directly, decoupling it |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1117 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1118 | _ = a_pAFsm.PFsm.Event(VlanEvSkipOmciConfig) |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1119 | }(pConfigVlanStateAFsm) |
| 1120 | return |
| 1121 | } |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1122 | // Can't call FSM Event directly, decoupling it |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1123 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1124 | _ = a_pAFsm.PFsm.Event(VlanEvPrepareDone) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1125 | }(pConfigVlanStateAFsm) |
| 1126 | return |
| 1127 | } |
| 1128 | logger.Errorw(ctx, "UniVlanConfigFsm abort: invalid FSM pointer", log.Fields{ |
| 1129 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 1130 | //should never happen, else: recovery would be needed from outside the FSM |
| 1131 | } |
| 1132 | |
| 1133 | func (oFsm *UniVlanConfigFsm) enterConfigStarting(ctx context.Context, e *fsm.Event) { |
| 1134 | logger.Debugw(ctx, "UniVlanConfigFsm start vlan configuration", log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1135 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1136 | if pConfigVlanStateAFsm != nil { |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1137 | oFsm.mutexFlowParams.Lock() |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1138 | //possibly the entry is not valid anymore based on intermediate delete requests |
| 1139 | //just a basic protection ... |
| 1140 | if len(oFsm.uniVlanFlowParamsSlice) == 0 { |
| 1141 | oFsm.mutexFlowParams.Unlock() |
| 1142 | logger.Debugw(ctx, "UniVlanConfigFsm start: no rule entry anymore available", log.Fields{ |
| 1143 | "device-id": oFsm.deviceID}) |
| 1144 | // Can't call FSM Event directly, decoupling it |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1145 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1146 | _ = a_pAFsm.PFsm.Event(VlanEvReset) |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1147 | }(pConfigVlanStateAFsm) |
| 1148 | return |
| 1149 | } |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1150 | //access to uniVlanFlowParamsSlice is done on first element only here per definition |
| 1151 | //store the actual rule that shall be worked upon in the following transient states |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1152 | oFsm.actualUniFlowParam = oFsm.uniVlanFlowParamsSlice[0] |
| 1153 | tpID := oFsm.actualUniFlowParam.VlanRuleParams.TpID |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1154 | oFsm.TpIDWaitingFor = tpID |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1155 | loSetVlan := oFsm.actualUniFlowParam.VlanRuleParams.SetVid |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 1156 | //attention: take care to release the mutexFlowParams when calling the FSM directly - |
| 1157 | // synchronous FSM 'event/state' functions may rely on this mutex |
| 1158 | // but it must be released already before calling getTechProfileDone() as it may already be locked |
| 1159 | // by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207) |
Girish Gowdra | 24dd113 | 2021-07-06 15:25:40 -0700 | [diff] [blame] | 1160 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1161 | loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID)) |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1162 | logger.Debugw(ctx, "UniVlanConfigFsm - start with first rule", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1163 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 1164 | "set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone}) |
Girish Gowdra | 24dd113 | 2021-07-06 15:25:40 -0700 | [diff] [blame] | 1165 | |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1166 | // Can't call FSM Event directly, decoupling it |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1167 | go func(aPAFsm *cmn.AdapterFsm, aTechProfDone bool) { |
| 1168 | if aPAFsm != nil && aPAFsm.PFsm != nil { |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1169 | if aTechProfDone { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1170 | // let the vlan processing begin |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1171 | _ = aPAFsm.PFsm.Event(VlanEvStartConfig) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1172 | } else { |
| 1173 | // set to waiting for Techprofile |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1174 | _ = aPAFsm.PFsm.Event(VlanEvWaitTechProf) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1175 | } |
| 1176 | } |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1177 | }(pConfigVlanStateAFsm, loTechProfDone) |
| 1178 | } else { |
| 1179 | logger.Errorw(ctx, "UniVlanConfigFsm abort: invalid FSM pointer", log.Fields{ |
| 1180 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 1181 | //should never happen, else: recovery would be needed from outside the FSM |
| 1182 | return |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1183 | } |
| 1184 | } |
| 1185 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1186 | func (oFsm *UniVlanConfigFsm) enterConfigVtfd(ctx context.Context, e *fsm.Event) { |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1187 | //mutex protection is required for possible concurrent access to FSM members |
| 1188 | oFsm.mutexFlowParams.Lock() |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1189 | oFsm.TpIDWaitingFor = 0 //reset indication to avoid misinterpretation |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1190 | if oFsm.actualUniFlowParam.VlanRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1191 | // meaning transparent setup - no specific VTFD setting required |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1192 | oFsm.mutexFlowParams.Unlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1193 | logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD config required", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1194 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1195 | // let the FSM proceed ... (from within this state all internal pointers may be expected to be correct) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1196 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1197 | // Can't call FSM Event directly, decoupling it |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1198 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1199 | _ = a_pAFsm.PFsm.Event(VlanEvRxConfigVtfd) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1200 | }(pConfigVlanStateAFsm) |
| 1201 | } else { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1202 | // This attribute uniquely identifies each instance of this managed entity. Through an identical ID, |
| 1203 | // this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME. |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1204 | vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.actualUniFlowParam.VlanRuleParams.TpID)) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1205 | logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1206 | "EntitytId": strconv.FormatInt(int64(vtfdID), 16), |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1207 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID, |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1208 | "macBpNo": oFsm.pOnuUniPort.MacBpNo, "TpID": oFsm.actualUniFlowParam.VlanRuleParams.TpID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1209 | // setVid is assumed to be masked already by the caller to 12 bit |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1210 | oFsm.vlanFilterList[0] = uint16(oFsm.actualUniFlowParam.VlanRuleParams.SetVid) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1211 | oFsm.mutexFlowParams.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1212 | vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1213 | vtfdFilterList[0] = oFsm.vlanFilterList[0] |
| 1214 | oFsm.numVlanFilterEntries = 1 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1215 | meParams := me.ParamData{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1216 | EntityID: vtfdID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1217 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1218 | me.VlanTaggingFilterData_VlanFilterList: vtfdFilterList, //omci lib wants a slice for serialization |
| 1219 | me.VlanTaggingFilterData_ForwardOperation: uint8(0x10), //VID investigation |
| 1220 | me.VlanTaggingFilterData_NumberOfEntries: oFsm.numVlanFilterEntries, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1221 | }, |
| 1222 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1223 | logger.Debugw(ctx, "UniVlanConfigFsm sendcreate VTFD", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1224 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1225 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1226 | meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1227 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1228 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1229 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1230 | logger.Errorw(ctx, "VTFD create failed, aborting UniVlanConfig FSM!", |
| 1231 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1232 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1233 | if pConfigVlanStateAFsm != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1234 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1235 | _ = a_pAFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1236 | }(pConfigVlanStateAFsm) |
| 1237 | } |
| 1238 | return |
| 1239 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1240 | //accept also nil as (error) return value for writing to LastTx |
| 1241 | // - this avoids misinterpretation of new received OMCI messages |
| 1242 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1243 | // send shall return (dual format) error code that can be used here for immediate error treatment |
| 1244 | // (relevant to all used sendXX() methods in this (and other) FSM's) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1245 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1246 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1247 | } |
| 1248 | } |
| 1249 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1250 | func (oFsm *UniVlanConfigFsm) enterConfigEvtocd(ctx context.Context, e *fsm.Event) { |
| 1251 | logger.Debugw(ctx, "UniVlanConfigFsm - start config EVTOCD loop", log.Fields{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1252 | "device-id": oFsm.deviceID}) |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1253 | oFsm.requestEventOffset = uint8(cDeviceEventOffsetAddWithKvStore) //0 offset for last flow-add activity |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1254 | go func() { |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1255 | //using the first element in the slice because it's the first flow per definition here |
| 1256 | errEvto := oFsm.performConfigEvtocdEntries(ctx, 0) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1257 | //This is correct passing scenario |
| 1258 | if errEvto == nil { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1259 | oFsm.mutexFlowParams.RLock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1260 | tpID := oFsm.actualUniFlowParam.VlanRuleParams.TpID |
| 1261 | vlanID := oFsm.actualUniFlowParam.VlanRuleParams.SetVid |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1262 | configuredUniFlows := oFsm.ConfiguredUniFlow |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 1263 | // ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it) |
| 1264 | oFsm.mutexFlowParams.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1265 | for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID)) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1266 | logger.Infow(ctx, "Setting multicast MEs, with first flow", log.Fields{"deviceID": oFsm.deviceID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1267 | "techProfile": tpID, "gemPort": gemPort, "vlanID": vlanID, "ConfiguredUniFlow": configuredUniFlows}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1268 | errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1269 | vlanID) |
| 1270 | if errCreateAllMulticastME != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1271 | logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1272 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1273 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1274 | } |
| 1275 | } |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1276 | //If this first flow contains a meter, then create TD for related gems. |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1277 | if oFsm.actualUniFlowParam.Meter != nil { |
| 1278 | logger.Debugw(ctx, "Creating Traffic Descriptor", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniFlowParam.Meter}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1279 | for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.UniID, tpID) { |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1280 | logger.Debugw(ctx, "Creating Traffic Descriptor for gem", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniFlowParam.Meter, "gem": gemPort}) |
| 1281 | errCreateTrafficDescriptor := oFsm.createTrafficDescriptor(ctx, oFsm.actualUniFlowParam.Meter, tpID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1282 | oFsm.pOnuUniPort.UniID, gemPort) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1283 | if errCreateTrafficDescriptor != nil { |
| 1284 | logger.Errorw(ctx, "Create Traffic Descriptor create failed, aborting Ani Config FSM!", |
| 1285 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1286 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1287 | } |
| 1288 | } |
| 1289 | } |
| 1290 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1291 | //TODO Possibly insert new state for multicast --> possibly another jira/later time. |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1292 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigEvtocd) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1293 | } |
| 1294 | }() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1295 | } |
| 1296 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1297 | func (oFsm *UniVlanConfigFsm) enterVlanConfigDone(ctx context.Context, e *fsm.Event) { |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1298 | |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1299 | oFsm.mutexFlowParams.Lock() |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1300 | |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1301 | logger.Infow(ctx, "UniVlanConfigFsm config done - checking on more flows", log.Fields{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1302 | "device-id": oFsm.deviceID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1303 | "overall-uni-rules": oFsm.NumUniFlows, "configured-uni-rules": oFsm.ConfiguredUniFlow}) |
mpagenko | 101ac94 | 2021-11-16 15:01:29 +0000 | [diff] [blame] | 1304 | if len(oFsm.uniVlanFlowParamsSlice) > 0 && !oFsm.pDeviceHandler.IsReconciling() { |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 1305 | oFsm.pushReponseOnFlowResponseChannel(ctx, oFsm.actualUniFlowParam.RespChan, nil) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1306 | } |
| 1307 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1308 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1309 | if pConfigVlanStateAFsm == nil { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1310 | oFsm.mutexFlowParams.Unlock() |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1311 | logger.Errorw(ctx, "UniVlanConfigFsm abort: invalid FSM pointer", log.Fields{ |
| 1312 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 1313 | //should never happen, else: recovery would be needed from outside the FSM |
| 1314 | return |
| 1315 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1316 | pConfigVlanStateBaseFsm := pConfigVlanStateAFsm.PFsm |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1317 | if len(oFsm.uniRemoveFlowsSlice) > 0 { |
| 1318 | //some further flows are to be removed, removal always starts with the first element |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1319 | logger.Debugw(ctx, "UniVlanConfigFsm rule removal from ConfigDone", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1320 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1321 | "tp-id": oFsm.uniRemoveFlowsSlice[0].vlanRuleParams.TpID, |
| 1322 | "set-Vlan": oFsm.uniRemoveFlowsSlice[0].vlanRuleParams.SetVid}) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1323 | oFsm.mutexFlowParams.Unlock() |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1324 | // Can't call FSM Event directly, decoupling it |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1325 | go func(a_pBaseFsm *fsm.FSM) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1326 | _ = a_pBaseFsm.Event(VlanEvRemFlowConfig) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1327 | }(pConfigVlanStateBaseFsm) |
| 1328 | return |
| 1329 | } |
Holger Hildebrandt | 7741f27 | 2022-01-18 08:17:39 +0000 | [diff] [blame] | 1330 | if oFsm.lastFlowToReconcile { |
| 1331 | //note: lastFlowToReconcile does not mean that this block may run only once within reconcilement here, |
| 1332 | // due to asynchronous event processing from SetUniFlowParams() it may be executed multiple times |
| 1333 | logger.Debugw(ctx, "reconciling - flow processing finished", log.Fields{ |
| 1334 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID}) |
| 1335 | oFsm.pDeviceHandler.SendChUniVlanConfigFinished(uint16(oFsm.pOnuUniPort.UniID)) |
| 1336 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1337 | if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
| 1338 | oFsm.ConfiguredUniFlow = oFsm.NumUniFlows |
Holger Hildebrandt | 1b8f4ad | 2021-03-25 15:53:51 +0000 | [diff] [blame] | 1339 | logger.Debugw(ctx, "reconciling - skip enterVlanConfigDone processing", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1340 | log.Fields{"NumUniFlows": oFsm.NumUniFlows, "ConfiguredUniFlow": oFsm.ConfiguredUniFlow, "device-id": oFsm.deviceID}) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1341 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 1b8f4ad | 2021-03-25 15:53:51 +0000 | [diff] [blame] | 1342 | return |
| 1343 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1344 | if oFsm.NumUniFlows > oFsm.ConfiguredUniFlow { |
| 1345 | if oFsm.ConfiguredUniFlow == 0 { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1346 | oFsm.mutexFlowParams.Unlock() |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1347 | // this is a restart with a complete new flow, we can re-use the initial flow config control |
| 1348 | // including the check, if the related techProfile is (still) available (probably also removed in between) |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1349 | // Can't call FSM Event directly, decoupling it |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1350 | go func(a_pBaseFsm *fsm.FSM) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1351 | _ = a_pBaseFsm.Event(VlanEvRenew) |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1352 | }(pConfigVlanStateBaseFsm) |
| 1353 | return |
| 1354 | } |
| 1355 | |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1356 | //some further flows are to be configured |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1357 | //store the actual rule that shall be worked upon in the following transient states |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1358 | if len(oFsm.uniVlanFlowParamsSlice) < int(oFsm.ConfiguredUniFlow) { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1359 | //check introduced after having observed some panic in this processing |
| 1360 | logger.Errorw(ctx, "error in FsmEvent handling UniVlanConfigFsm in ConfigDone - inconsistent counter", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1361 | log.Fields{"ConfiguredUniFlow": oFsm.ConfiguredUniFlow, |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1362 | "sliceLen": len(oFsm.uniVlanFlowParamsSlice), "device-id": oFsm.deviceID}) |
| 1363 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1364 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1365 | _ = a_pAFsm.PFsm.Event(VlanEvReset) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1366 | }(pConfigVlanStateAFsm) |
| 1367 | return |
| 1368 | } |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1369 | oFsm.actualUniFlowParam = oFsm.uniVlanFlowParamsSlice[oFsm.ConfiguredUniFlow] |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1370 | //tpId of the next rule to be configured |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1371 | tpID := oFsm.actualUniFlowParam.VlanRuleParams.TpID |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1372 | oFsm.TpIDWaitingFor = tpID |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1373 | loSetVlan := oFsm.actualUniFlowParam.VlanRuleParams.SetVid |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 1374 | //attention: take care to release the mutexFlowParams when calling the FSM directly - |
| 1375 | // synchronous FSM 'event/state' functions may rely on this mutex |
| 1376 | // but it must be released already before calling getTechProfileDone() as it may already be locked |
| 1377 | // by the techProfile processing call to VlanFsm.IsFlowRemovePending() (see VOL-4207) |
| 1378 | oFsm.mutexFlowParams.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1379 | loTechProfDone := oFsm.pUniTechProf.getTechProfileDone(ctx, oFsm.pOnuUniPort.UniID, tpID) |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1380 | logger.Debugw(ctx, "UniVlanConfigFsm - incremental config request", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1381 | "device-id": oFsm.deviceID, "uni-id": oFsm.pOnuUniPort.UniID, |
mpagenko | 45cc6a3 | 2021-07-23 10:06:57 +0000 | [diff] [blame] | 1382 | "set-Vlan": loSetVlan, "tp-id": tpID, "ProfDone": loTechProfDone}) |
| 1383 | |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1384 | // Can't call FSM Event directly, decoupling it |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1385 | go func(aPBaseFsm *fsm.FSM, aTechProfDone bool) { |
| 1386 | if aTechProfDone { |
| 1387 | // let the vlan processing continue with next rule |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1388 | _ = aPBaseFsm.Event(VlanEvIncrFlowConfig) |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1389 | } else { |
| 1390 | // set to waiting for Techprofile |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1391 | _ = aPBaseFsm.Event(VlanEvWaitTPIncr) |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1392 | } |
| 1393 | }(pConfigVlanStateBaseFsm, loTechProfDone) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1394 | return |
| 1395 | } |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1396 | oFsm.mutexFlowParams.Unlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1397 | logger.Debugw(ctx, "UniVlanConfigFsm - VLAN config done: send dh event notification", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1398 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1399 | // it might appear that some flows are requested also after 'flowPushed' event has been generated ... |
| 1400 | // state transition notification is checked in deviceHandler |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1401 | // note: 'flowPushed' event is only generated if all 'pending' rules are configured |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1402 | if oFsm.pDeviceHandler != nil { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1403 | //making use of the add->remove successor enum assumption/definition |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1404 | go oFsm.pDeviceHandler.DeviceProcStatusUpdate(ctx, cmn.OnuDeviceEvent(uint8(oFsm.requestEvent)+oFsm.requestEventOffset)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1405 | } |
| 1406 | } |
| 1407 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1408 | func (oFsm *UniVlanConfigFsm) enterConfigIncrFlow(ctx context.Context, e *fsm.Event) { |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1409 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1410 | if oFsm.pDeviceHandler.IsSkipOnuConfigReconciling() { |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1411 | logger.Debugw(ctx, "reconciling - skip further processing for incremental flow", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1412 | log.Fields{"fsmState": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID}) |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1413 | go func(a_pBaseFsm *fsm.FSM) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1414 | _ = a_pBaseFsm.Event(VlanEvSkipIncFlowConfig) |
| 1415 | }(oFsm.PAdaptFsm.PFsm) |
Holger Hildebrandt | be52384 | 2021-03-10 10:47:18 +0000 | [diff] [blame] | 1416 | return |
| 1417 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1418 | oFsm.mutexFlowParams.Lock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1419 | logger.Debugw(ctx, "UniVlanConfigFsm - start config further incremental flow", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1420 | "recent flow-number": oFsm.ConfiguredUniFlow, |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1421 | "device-id": oFsm.deviceID}) |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1422 | oFsm.TpIDWaitingFor = 0 //reset indication to avoid misinterpretation |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1423 | |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1424 | if oFsm.actualUniFlowParam.VlanRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1425 | // meaning transparent setup - no specific VTFD setting required |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1426 | logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD config required", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1427 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1428 | } else { |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 1429 | //TODO!!!: it was not really intended to keep this enter* FSM method waiting on OMCI response (preventing other state transitions) |
| 1430 | // so it would be conceptually better to wait for the response in background like for the other multi-entity processing |
| 1431 | // but as the OMCI sequence must be ensured, a separate new state would be required - perhaps later |
| 1432 | // in practice should have no influence by now as no other state transition is currently accepted (while cancel() is ensured) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1433 | if oFsm.numVlanFilterEntries == 0 { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1434 | // This attribute uniquely identifies each instance of this managed entity. Through an identical ID, |
| 1435 | // this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME. |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1436 | vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.actualUniFlowParam.VlanRuleParams.TpID)) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1437 | //no VTFD yet created |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1438 | logger.Debugw(ctx, "UniVlanConfigFsm create VTFD", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1439 | "EntitytId": strconv.FormatInt(int64(vtfdID), 16), |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1440 | "device-id": oFsm.deviceID, |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1441 | "macBpNo": oFsm.pOnuUniPort.MacBpNo, "TpID": oFsm.actualUniFlowParam.VlanRuleParams.TpID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1442 | // 'SetVid' below is assumed to be masked already by the caller to 12 bit |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1443 | oFsm.vlanFilterList[0] = uint16(oFsm.actualUniFlowParam.VlanRuleParams.SetVid) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1444 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1445 | vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1446 | vtfdFilterList[0] = oFsm.vlanFilterList[0] |
| 1447 | oFsm.numVlanFilterEntries = 1 |
| 1448 | meParams := me.ParamData{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1449 | EntityID: vtfdID, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1450 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1451 | me.VlanTaggingFilterData_VlanFilterList: vtfdFilterList, |
| 1452 | me.VlanTaggingFilterData_ForwardOperation: uint8(0x10), //VID investigation |
| 1453 | me.VlanTaggingFilterData_NumberOfEntries: oFsm.numVlanFilterEntries, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1454 | }, |
| 1455 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1456 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1457 | meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1458 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1459 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1460 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1461 | oFsm.mutexFlowParams.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1462 | logger.Errorw(ctx, "VTFD create failed, aborting UniVlanConfig FSM!", |
| 1463 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1464 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1465 | if pConfigVlanStateAFsm != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1466 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1467 | _ = a_pAFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1468 | }(pConfigVlanStateAFsm) |
| 1469 | } |
| 1470 | return |
| 1471 | } |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1472 | //accept also nil as (error) return value for writing to LastTx |
| 1473 | // - this avoids misinterpretation of new received OMCI messages |
| 1474 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1475 | // send shall return (dual format) error code that can be used here for immediate error treatment |
| 1476 | // (relevant to all used sendXX() methods in this (and other) FSM's) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1477 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1478 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1479 | } else { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1480 | // This attribute uniquely identifies each instance of this managed entity. Through an identical ID, |
| 1481 | // this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME. |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1482 | vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(oFsm.actualUniFlowParam.VlanRuleParams.TpID)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1483 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1484 | logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1485 | "EntitytId": strconv.FormatInt(int64(vtfdID), 16), |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1486 | "device-id": oFsm.deviceID, |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1487 | "macBpNo": oFsm.pOnuUniPort.MacBpNo, "TpID": oFsm.actualUniFlowParam.VlanRuleParams.TpID}) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1488 | // setVid is assumed to be masked already by the caller to 12 bit |
| 1489 | oFsm.vlanFilterList[oFsm.numVlanFilterEntries] = |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1490 | uint16(oFsm.actualUniFlowParam.VlanRuleParams.SetVid) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1491 | vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1492 | |
| 1493 | // FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME |
| 1494 | // VTFD has to be created afresh with a new entity ID that has the same entity ID as the MBPCD ME for every |
| 1495 | // new vlan associated with a different TP. |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1496 | vtfdFilterList[0] = uint16(oFsm.actualUniFlowParam.VlanRuleParams.SetVid) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1497 | |
| 1498 | oFsm.numVlanFilterEntries++ |
| 1499 | meParams := me.ParamData{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1500 | EntityID: vtfdID, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1501 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1502 | me.VlanTaggingFilterData_VlanFilterList: vtfdFilterList, |
| 1503 | me.VlanTaggingFilterData_ForwardOperation: uint8(0x10), //VID investigation |
| 1504 | me.VlanTaggingFilterData_NumberOfEntries: oFsm.numVlanFilterEntries, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1505 | }, |
| 1506 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1507 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1508 | meInstance, err := oFsm.pOmciCC.SendCreateVtfdVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1509 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1510 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1511 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1512 | oFsm.mutexFlowParams.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1513 | logger.Errorw(ctx, "UniVlanFsm create Vlan Tagging Filter ME result error", |
| 1514 | log.Fields{"device-id": oFsm.deviceID, "Error": err}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1515 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1516 | return |
| 1517 | } |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1518 | //accept also nil as (error) return value for writing to LastTx |
| 1519 | // - this avoids misinterpretation of new received OMCI messages |
| 1520 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1521 | // send shall return (dual format) error code that can be used here for immediate error treatment |
| 1522 | // (relevant to all used sendXX() methods in this (and other) FSM's) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1523 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1524 | oFsm.mutexPLastTxMeInstance.Unlock() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1525 | } |
| 1526 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1527 | err := oFsm.waitforOmciResponse(ctx) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1528 | if err != nil { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1529 | oFsm.mutexFlowParams.Unlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1530 | logger.Errorw(ctx, "VTFD create/set failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1531 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1532 | pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1533 | // Can't call FSM Event directly, decoupling it |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1534 | go func(a_pBaseFsm *fsm.FSM) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1535 | _ = a_pBaseFsm.Event(VlanEvReset) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1536 | }(pConfigVlanStateBaseFsm) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1537 | return |
| 1538 | } |
| 1539 | } |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1540 | |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1541 | oFsm.requestEventOffset = uint8(cDeviceEventOffsetAddWithKvStore) //0 offset for last flow-add activity |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1542 | oFsm.mutexFlowParams.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1543 | go func() { |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1544 | oFsm.mutexFlowParams.RLock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1545 | tpID := oFsm.actualUniFlowParam.VlanRuleParams.TpID |
| 1546 | configuredUniFlow := oFsm.ConfiguredUniFlow |
mpagenko | 3ce9fa0 | 2021-07-28 13:26:54 +0000 | [diff] [blame] | 1547 | // ensure mutexFlowParams not locked before calling some TPProcessing activity (that might already be pending on it) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1548 | oFsm.mutexFlowParams.RUnlock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1549 | errEvto := oFsm.performConfigEvtocdEntries(ctx, configuredUniFlow) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1550 | //This is correct passing scenario |
| 1551 | if errEvto == nil { |
| 1552 | //TODO Possibly insert new state for multicast --> possibly another jira/later time. |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1553 | for _, gemPort := range oFsm.pUniTechProf.getMulticastGemPorts(ctx, oFsm.pOnuUniPort.UniID, uint8(tpID)) { |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1554 | oFsm.mutexFlowParams.RLock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1555 | vlanID := oFsm.actualUniFlowParam.VlanRuleParams.SetVid |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1556 | logger.Infow(ctx, "Setting multicast MEs for additional flows", log.Fields{"deviceID": oFsm.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1557 | "techProfile": tpID, "gemPort": gemPort, |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1558 | "vlanID": vlanID, "ConfiguredUniFlow": configuredUniFlow}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1559 | oFsm.mutexFlowParams.RUnlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1560 | errCreateAllMulticastME := oFsm.performSettingMulticastME(ctx, tpID, gemPort, vlanID) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1561 | if errCreateAllMulticastME != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1562 | logger.Errorw(ctx, "Multicast ME create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1563 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1564 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1565 | } |
| 1566 | } |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1567 | //If this incremental flow contains a meter, then create TD for related gems. |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1568 | if oFsm.actualUniFlowParam.Meter != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1569 | for _, gemPort := range oFsm.pUniTechProf.getBidirectionalGemPortIDsForTP(ctx, oFsm.pOnuUniPort.UniID, tpID) { |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1570 | logger.Debugw(ctx, "Creating Traffic Descriptor for gem", log.Fields{"device-id": oFsm.deviceID, "meter": oFsm.actualUniFlowParam.Meter, "gem": gemPort}) |
| 1571 | errCreateTrafficDescriptor := oFsm.createTrafficDescriptor(ctx, oFsm.actualUniFlowParam.Meter, tpID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1572 | oFsm.pOnuUniPort.UniID, gemPort) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1573 | if errCreateTrafficDescriptor != nil { |
| 1574 | logger.Errorw(ctx, "Create Traffic Descriptor create failed, aborting Ani Config FSM!", |
| 1575 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1576 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1577 | } |
| 1578 | } |
| 1579 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1580 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigEvtocd) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1581 | } |
| 1582 | }() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1583 | } |
| 1584 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1585 | func (oFsm *UniVlanConfigFsm) enterRemoveFlow(ctx context.Context, e *fsm.Event) { |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1586 | oFsm.mutexFlowParams.RLock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1587 | logger.Debugw(ctx, "UniVlanConfigFsm - start removing the top remove-flow", log.Fields{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1588 | "with last cookie": oFsm.uniRemoveFlowsSlice[0].cookie, |
| 1589 | "device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1590 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1591 | pConfigVlanStateBaseFsm := oFsm.PAdaptFsm.PFsm |
| 1592 | loAllowSpecificOmciConfig := oFsm.pDeviceHandler.IsReadyForOmciConfig() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1593 | loVlanEntryClear := uint8(0) |
| 1594 | loVlanEntryRmPos := uint8(0x80) //with indication 'invalid' in bit 7 |
| 1595 | //shallow copy is sufficient as no reference variables are used within struct |
| 1596 | loRuleParams := oFsm.uniRemoveFlowsSlice[0].vlanRuleParams |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 1597 | oFsm.mutexFlowParams.RUnlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1598 | logger.Debugw(ctx, "UniVlanConfigFsm - remove-flow parameters are", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1599 | "match vid": loRuleParams.MatchVid, "match Pcp": loRuleParams.MatchPcp, |
| 1600 | "set vid": strconv.FormatInt(int64(loRuleParams.SetVid), 16), |
| 1601 | "device-id": oFsm.deviceID}) |
| 1602 | |
| 1603 | if loRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
| 1604 | // meaning transparent setup - no specific VTFD setting required |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1605 | logger.Debugw(ctx, "UniVlanConfigFsm: no VTFD removal required for transparent flow", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1606 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID}) |
| 1607 | } else { |
| 1608 | vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization and 're-copy' |
| 1609 | if oFsm.numVlanFilterEntries == 1 { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1610 | vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(loRuleParams.TpID)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1611 | //only one active VLAN entry (hopefully the SetVID we want to remove - should be, but not verified ..) |
| 1612 | // so we can just delete the VTFD entry |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1613 | logger.Debugw(ctx, "UniVlanConfigFsm: VTFD delete (no more vlan filters)", |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1614 | log.Fields{"current vlan list": oFsm.vlanFilterList, "EntitytId": strconv.FormatInt(int64(vtfdID), 16), |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1615 | "device-id": oFsm.deviceID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1616 | "macBpNo": oFsm.pOnuUniPort.MacBpNo, "TpID": loRuleParams.TpID}) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1617 | loVlanEntryClear = 1 //full VlanFilter clear request |
| 1618 | if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1619 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1620 | meInstance, err := oFsm.pOmciCC.SendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1621 | oFsm.PAdaptFsm.CommChan, vtfdID) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1622 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1623 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1624 | logger.Errorw(ctx, "UniVlanFsm delete Vlan Tagging Filter ME result error", |
| 1625 | log.Fields{"device-id": oFsm.deviceID, "Error": err}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1626 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1627 | return |
| 1628 | } |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1629 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1630 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1631 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1632 | logger.Debugw(ctx, "UniVlanConfigFsm delete VTFD OMCI handling skipped based on device state", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1633 | "device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.GetDeviceReasonString()}) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1634 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1635 | } else { |
| 1636 | //many VTFD already should exists - find and remove the one concerned by the actual remove rule |
| 1637 | // by updating the VTFD per set command with new valid list |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1638 | logger.Debugw(ctx, "UniVlanConfigFsm: VTFD removal of requested VLAN from the list on OMCI", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1639 | log.Fields{"current vlan list": oFsm.vlanFilterList, |
| 1640 | "set-vlan": loRuleParams.SetVid, "device-id": oFsm.deviceID}) |
| 1641 | for i := uint8(0); i < oFsm.numVlanFilterEntries; i++ { |
| 1642 | if loRuleParams.SetVid == uint32(oFsm.vlanFilterList[i]) { |
| 1643 | loVlanEntryRmPos = i |
| 1644 | break //abort search |
| 1645 | } |
| 1646 | } |
| 1647 | if loVlanEntryRmPos < cVtfdTableSize { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1648 | vtfdID, _ := cmn.GenerateANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo), uint16(loRuleParams.TpID)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1649 | //valid entry was found - to be eclipsed |
| 1650 | loVlanEntryClear = 2 //VlanFilter remove request for a specific entry |
| 1651 | for i := uint8(0); i < oFsm.numVlanFilterEntries; i++ { |
| 1652 | if i < loVlanEntryRmPos { |
| 1653 | vtfdFilterList[i] = oFsm.vlanFilterList[i] //copy original |
| 1654 | } else if i < (cVtfdTableSize - 1) { |
| 1655 | vtfdFilterList[i] = oFsm.vlanFilterList[i+1] //copy successor (including 0 elements) |
| 1656 | } else { |
| 1657 | vtfdFilterList[i] = 0 //set last byte if needed |
| 1658 | } |
| 1659 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1660 | logger.Debugw(ctx, "UniVlanConfigFsm set VTFD", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1661 | "EntitytId": strconv.FormatInt(int64(vtfdID), 16), |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1662 | "new vlan list": vtfdFilterList, "device-id": oFsm.deviceID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1663 | "macBpNo": oFsm.pOnuUniPort.MacBpNo, "TpID": loRuleParams.TpID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1664 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1665 | if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1666 | // FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1667 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1668 | meInstance, err := oFsm.pOmciCC.SendDeleteVtfd(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 1669 | oFsm.PAdaptFsm.CommChan, vtfdID) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1670 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1671 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1672 | logger.Errorw(ctx, "UniVlanFsm delete Vlan Tagging Filter ME result error", |
| 1673 | log.Fields{"device-id": oFsm.deviceID, "Error": err}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1674 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1675 | return |
| 1676 | } |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1677 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 1678 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1679 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1680 | logger.Debugw(ctx, "UniVlanConfigFsm set VTFD OMCI handling skipped based on device state", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1681 | "device-id": oFsm.deviceID, "device-state": oFsm.pDeviceHandler.GetDeviceReasonString()}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1682 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1683 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1684 | logger.Warnw(ctx, "UniVlanConfigFsm: requested VLAN for removal not found in list - ignore and continue (no VTFD set)", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1685 | log.Fields{"device-id": oFsm.deviceID}) |
| 1686 | } |
| 1687 | } |
| 1688 | if loVlanEntryClear > 0 { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1689 | if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state |
| 1690 | //waiting on response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1691 | err := oFsm.waitforOmciResponse(ctx) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1692 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1693 | logger.Errorw(ctx, "VTFD delete/reset failed, aborting VlanConfig FSM!", |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1694 | log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1695 | // Can't call FSM Event directly, decoupling it |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1696 | go func(a_pBaseFsm *fsm.FSM) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1697 | _ = a_pBaseFsm.Event(VlanEvReset) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1698 | }(pConfigVlanStateBaseFsm) |
| 1699 | return |
| 1700 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1701 | } |
| 1702 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1703 | oFsm.mutexFlowParams.Lock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1704 | if loVlanEntryClear == 1 { |
| 1705 | oFsm.vlanFilterList[0] = 0 //first entry is the only that can contain the previous only-one element |
| 1706 | oFsm.numVlanFilterEntries = 0 |
| 1707 | } else if loVlanEntryClear == 2 { |
| 1708 | // new VlanFilterList should be one entry smaller now - copy from last configured entry |
| 1709 | // this loop now includes the 0 element on previous last valid entry |
| 1710 | for i := uint8(0); i <= oFsm.numVlanFilterEntries; i++ { |
| 1711 | oFsm.vlanFilterList[i] = vtfdFilterList[i] |
| 1712 | } |
| 1713 | oFsm.numVlanFilterEntries-- |
| 1714 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 1715 | oFsm.mutexFlowParams.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1716 | } |
| 1717 | } |
| 1718 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1719 | if loAllowSpecificOmciConfig { //specific OMCI config is expected to work acc. to the device state |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1720 | go oFsm.removeEvtocdEntries(ctx, loRuleParams) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1721 | } else { |
| 1722 | // OMCI processing is not done, expectation is to have the ONU in some basic config state accordingly |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1723 | logger.Debugw(ctx, "UniVlanConfigFsm remove EVTOCD OMCI handling skipped based on device state", log.Fields{ |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1724 | "device-id": oFsm.deviceID}) |
mpagenko | 9a304ea | 2020-12-16 15:54:01 +0000 | [diff] [blame] | 1725 | // Can't call FSM Event directly, decoupling it |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1726 | go func(a_pBaseFsm *fsm.FSM) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1727 | _ = a_pBaseFsm.Event(VlanEvRemFlowDone, loRuleParams.TpID) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1728 | }(pConfigVlanStateBaseFsm) |
| 1729 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1730 | } |
| 1731 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1732 | func (oFsm *UniVlanConfigFsm) enterVlanCleanupDone(ctx context.Context, e *fsm.Event) { |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 1733 | var tpID uint8 |
| 1734 | // Extract the tpID |
| 1735 | if len(e.Args) > 0 { |
| 1736 | tpID = e.Args[0].(uint8) |
| 1737 | logger.Debugw(ctx, "UniVlanConfigFsm - flow removed for tp id", log.Fields{"device-id": oFsm.deviceID, "tpID": e.Args[0].(uint8)}) |
| 1738 | } else { |
| 1739 | logger.Warnw(ctx, "UniVlanConfigFsm - tp id not available", log.Fields{"device-id": oFsm.deviceID}) |
| 1740 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1741 | oFsm.mutexFlowParams.Lock() |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1742 | deletedCookie := oFsm.uniRemoveFlowsSlice[0].cookie |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1743 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1744 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1745 | if pConfigVlanStateAFsm == nil { |
| 1746 | logger.Errorw(ctx, "invalid Fsm pointer - unresolvable - abort", |
| 1747 | log.Fields{"device-id": oFsm.deviceID}) |
| 1748 | //would have to be fixed from outside somehow |
| 1749 | return |
| 1750 | } |
| 1751 | |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1752 | // here we need o finally remove the removed data also from uniVlanFlowParamsSlice and possibly have to |
| 1753 | // stop the suspension of a add-activity waiting for the end of removal |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1754 | //call from 'configured' state of the rule |
| 1755 | if err := oFsm.removeFlowFromParamsSlice(ctx, deletedCookie, true); err != nil { |
| 1756 | //something quite inconsistent detected, perhaps just try to recover with FSM reset |
| 1757 | oFsm.mutexFlowParams.Unlock() |
| 1758 | logger.Errorw(ctx, "UniVlanConfigFsm - could not clear database - abort", log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1759 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1760 | _ = a_pAFsm.PFsm.Event(VlanEvReset) |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1761 | }(pConfigVlanStateAFsm) |
| 1762 | return |
| 1763 | } |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1764 | if oFsm.uniRemoveFlowsSlice[0].isSuspendedOnAdd { |
| 1765 | removeChannel := oFsm.uniRemoveFlowsSlice[0].removeChannel |
| 1766 | oFsm.mutexFlowParams.Unlock() |
| 1767 | removeChannel <- true |
| 1768 | oFsm.mutexFlowParams.Lock() |
| 1769 | } |
| 1770 | |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1771 | logger.Debugw(ctx, "UniVlanConfigFsm - removing the removal data", log.Fields{ |
| 1772 | "in state": e.FSM.Current(), "device-id": oFsm.deviceID, |
| 1773 | "removed cookie": deletedCookie, "waitForDeleteCookie": oFsm.delayNewRuleCookie}) |
| 1774 | |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1775 | // Store the reference to the flow response channel before this entry in the slice is deleted |
| 1776 | flowRespChan := oFsm.uniRemoveFlowsSlice[0].respChan |
| 1777 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1778 | if len(oFsm.uniRemoveFlowsSlice) <= 1 { |
| 1779 | oFsm.uniRemoveFlowsSlice = nil //reset the slice |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1780 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal - last remove-flow deleted", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1781 | "device-id": oFsm.deviceID}) |
| 1782 | } else { |
| 1783 | //cut off the actual flow by slicing out the first element |
| 1784 | oFsm.uniRemoveFlowsSlice = append( |
| 1785 | oFsm.uniRemoveFlowsSlice[:0], |
| 1786 | oFsm.uniRemoveFlowsSlice[1:]...) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1787 | logger.Debugw(ctx, "UniVlanConfigFsm flow removal - specific flow deleted from data", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1788 | "device-id": oFsm.deviceID}) |
| 1789 | } |
| 1790 | oFsm.mutexFlowParams.Unlock() |
| 1791 | |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1792 | oFsm.requestEventOffset = uint8(cDeviceEventOffsetRemoveWithKvStore) //offset for last flow-remove activity (with kvStore request) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1793 | //return to the basic config verification state |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1794 | // Can't call FSM Event directly, decoupling it |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1795 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1796 | _ = a_pAFsm.PFsm.Event(VlanEvFlowDataRemoved) |
mpagenko | f582d6a | 2021-06-18 15:58:10 +0000 | [diff] [blame] | 1797 | }(pConfigVlanStateAFsm) |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 1798 | |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 1799 | oFsm.mutexFlowParams.Lock() |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 1800 | noOfFlowRem := len(oFsm.uniRemoveFlowsSlice) |
mpagenko | f1fc386 | 2021-02-16 10:09:52 +0000 | [diff] [blame] | 1801 | if deletedCookie == oFsm.delayNewRuleCookie { |
| 1802 | // flush the channel CookieDeleted to ensure it is not lingering from some previous (aborted) activity |
| 1803 | select { |
| 1804 | case <-oFsm.chCookieDeleted: |
| 1805 | logger.Debug(ctx, "flushed CookieDeleted") |
| 1806 | default: |
| 1807 | } |
| 1808 | oFsm.chCookieDeleted <- true // let the waiting AddFlow thread continue |
| 1809 | } |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 1810 | // If all pending flow-removes are completed and TP ID is valid go on processing any pending TP delete |
| 1811 | if oFsm.signalOnFlowDelete && noOfFlowRem == 0 && tpID > 0 { |
| 1812 | logger.Debugw(ctx, "signal flow removal for pending TP delete", log.Fields{"device-id": oFsm.deviceID, "tpID": tpID}) |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 1813 | // If we are here then all flows are removed. |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 1814 | if len(oFsm.flowDeleteChannel) == 0 { //channel not yet in use |
| 1815 | oFsm.flowDeleteChannel <- true |
| 1816 | oFsm.signalOnFlowDelete = false |
| 1817 | } |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 1818 | } |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 1819 | oFsm.mutexFlowParams.Unlock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 1820 | |
| 1821 | // send response on the response channel for the removed flow. |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 1822 | oFsm.pushReponseOnFlowResponseChannel(ctx, flowRespChan, nil) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1823 | } |
| 1824 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1825 | func (oFsm *UniVlanConfigFsm) enterResetting(ctx context.Context, e *fsm.Event) { |
| 1826 | logger.Debugw(ctx, "UniVlanConfigFsm resetting", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1827 | |
mpagenko | 0f54322 | 2021-11-03 16:24:14 +0000 | [diff] [blame] | 1828 | oFsm.mutexPLastTxMeInstance.Lock() |
| 1829 | oFsm.pLastTxMeInstance = nil //to avoid misinterpretation in case of some lingering frame reception processing |
| 1830 | oFsm.mutexPLastTxMeInstance.Unlock() |
| 1831 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1832 | pConfigVlanStateAFsm := oFsm.PAdaptFsm |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1833 | if pConfigVlanStateAFsm != nil { |
| 1834 | // abort running message processing |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1835 | fsmAbortMsg := cmn.Message{ |
| 1836 | Type: cmn.TestMsg, |
| 1837 | Data: cmn.TestMessage{ |
| 1838 | TestMessageVal: cmn.AbortMessageProcessing, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1839 | }, |
| 1840 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1841 | pConfigVlanStateAFsm.CommChan <- fsmAbortMsg |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1842 | |
mpagenko | 0f54322 | 2021-11-03 16:24:14 +0000 | [diff] [blame] | 1843 | //internal data is not explicitly removed, this is left to garbage collection after complete FSM removal |
| 1844 | // but some channels have to be cleared to avoid unintended waiting for events, that have no meaning anymore now |
| 1845 | |
| 1846 | oFsm.mutexFlowParams.RLock() |
| 1847 | if oFsm.delayNewRuleCookie != 0 { |
| 1848 | // looks like the waiting AddFlow is stuck |
| 1849 | oFsm.mutexFlowParams.RUnlock() |
| 1850 | //use asynchronous channel sending to avoid stucking on non-waiting receiver |
| 1851 | select { |
| 1852 | case oFsm.chCookieDeleted <- false: // let the waiting AddFlow thread terminate |
| 1853 | default: |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1854 | } |
mpagenko | 0f54322 | 2021-11-03 16:24:14 +0000 | [diff] [blame] | 1855 | oFsm.mutexFlowParams.RLock() |
| 1856 | } |
| 1857 | if len(oFsm.uniRemoveFlowsSlice) > 0 { |
| 1858 | for _, removeUniFlowParams := range oFsm.uniRemoveFlowsSlice { |
| 1859 | if removeUniFlowParams.isSuspendedOnAdd { |
| 1860 | removeChannel := removeUniFlowParams.removeChannel |
| 1861 | logger.Debugw(ctx, "UniVlanConfigFsm flow clear-up - abort suspended rule-add", log.Fields{ |
| 1862 | "device-id": oFsm.deviceID, "cookie": removeUniFlowParams.cookie}) |
| 1863 | oFsm.mutexFlowParams.RUnlock() |
| 1864 | //use asynchronous channel sending to avoid stucking on non-waiting receiver |
| 1865 | select { |
| 1866 | case removeChannel <- false: |
| 1867 | default: |
| 1868 | } |
| 1869 | oFsm.mutexFlowParams.RLock() |
| 1870 | } |
| 1871 | // Send response on response channel if the caller is waiting on it. |
| 1872 | var err error = nil |
| 1873 | if !oFsm.isCanceled { |
| 1874 | //only if the FSM is not canceled on external request use some error indication for the respChan |
| 1875 | // so only at real internal FSM abortion some error code is sent back |
| 1876 | // on the deleteFlow with the hope the system may handle such error situation (possibly retrying) |
| 1877 | err = fmt.Errorf("internal-error") |
| 1878 | } |
| 1879 | //if the FSM was cancelled on external request the assumption is, that all processing has to be stopped |
| 1880 | // assumed in connection with some ONU down/removal indication in which case all flows can be considered as removed |
| 1881 | oFsm.pushReponseOnFlowResponseChannel(ctx, removeUniFlowParams.respChan, err) |
| 1882 | } |
| 1883 | } |
| 1884 | |
| 1885 | if oFsm.pDeviceHandler != nil { |
| 1886 | if len(oFsm.uniVlanFlowParamsSlice) > 0 { |
| 1887 | if !oFsm.isCanceled { |
| 1888 | //if the FSM is not canceled on external request use "internal-error" for the respChan |
| 1889 | for _, vlanRule := range oFsm.uniVlanFlowParamsSlice { |
| 1890 | // Send response on response channel if the caller is waiting on it with according error indication. |
| 1891 | oFsm.pushReponseOnFlowResponseChannel(ctx, vlanRule.RespChan, fmt.Errorf("internal-error")) |
| 1892 | } |
| 1893 | //permanently remove possibly stored persistent data |
| 1894 | var emptySlice = make([]cmn.UniVlanFlowParams, 0) |
| 1895 | _ = oFsm.pDeviceHandler.StorePersUniFlowConfig(ctx, oFsm.pOnuUniPort.UniID, &emptySlice, true) //ignore errors |
| 1896 | } else { |
| 1897 | // reset (cancel) of all Fsm is always accompanied by global persistency data removal |
| 1898 | // no need to remove specific data in this case here |
| 1899 | // TODO: cancelation may also abort a running flowAdd activity in which case it would be better |
| 1900 | // to also resopnd on the respChan with some error ("config canceled"), but that is a bit hard to decide here |
| 1901 | // so just left open by now |
| 1902 | logger.Debugw(ctx, "UniVlanConfigFsm persistency data not cleared", log.Fields{"device-id": oFsm.deviceID}) |
| 1903 | } |
| 1904 | } |
| 1905 | oFsm.mutexFlowParams.RUnlock() |
| 1906 | |
| 1907 | //try to let the FSM proceed to 'disabled' |
| 1908 | // Can't call FSM Event directly, decoupling it |
| 1909 | go func(a_pAFsm *cmn.AdapterFsm) { |
| 1910 | if a_pAFsm != nil && a_pAFsm.PFsm != nil { |
| 1911 | _ = a_pAFsm.PFsm.Event(VlanEvRestart) |
| 1912 | } |
| 1913 | }(pConfigVlanStateAFsm) |
| 1914 | return |
| 1915 | } |
| 1916 | oFsm.mutexFlowParams.RUnlock() |
| 1917 | logger.Warnw(ctx, "UniVlanConfigFsm - device handler already vanished", |
| 1918 | log.Fields{"device-id": oFsm.deviceID}) |
| 1919 | return |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1920 | } |
mpagenko | 0f54322 | 2021-11-03 16:24:14 +0000 | [diff] [blame] | 1921 | logger.Warnw(ctx, "UniVlanConfigFsm - FSM pointer already vanished", |
| 1922 | log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1923 | } |
| 1924 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1925 | func (oFsm *UniVlanConfigFsm) enterDisabled(ctx context.Context, e *fsm.Event) { |
| 1926 | logger.Debugw(ctx, "UniVlanConfigFsm enters disabled state", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1927 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1928 | if oFsm.pDeviceHandler != nil { |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 1929 | //request removal of 'reference' in the Handler (completely clear the FSM and its data) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1930 | go oFsm.pDeviceHandler.RemoveVlanFilterFsm(ctx, oFsm.pOnuUniPort) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 1931 | return |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1932 | } |
mpagenko | 0f54322 | 2021-11-03 16:24:14 +0000 | [diff] [blame] | 1933 | logger.Warnw(ctx, "UniVlanConfigFsm - device handler already vanished", |
| 1934 | log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1935 | } |
| 1936 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1937 | func (oFsm *UniVlanConfigFsm) processOmciVlanMessages(ctx context.Context) { //ctx context.Context? |
| 1938 | logger.Debugw(ctx, "Start UniVlanConfigFsm Msg processing", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1939 | loop: |
| 1940 | for { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1941 | // case <-ctx.Done(): |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1942 | // logger.Info(ctx,"MibSync Msg", log.Fields{"Message handling canceled via context for device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1943 | // break loop |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1944 | message, ok := <-oFsm.PAdaptFsm.CommChan |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1945 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1946 | logger.Info(ctx, "UniVlanConfigFsm 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] | 1947 | // but then we have to ensure a restart of the FSM as well - as exceptional procedure |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1948 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1949 | break loop |
| 1950 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1951 | logger.Debugw(ctx, "UniVlanConfigFsm Rx Msg", log.Fields{"device-id": oFsm.deviceID}) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1952 | |
| 1953 | switch message.Type { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1954 | case cmn.TestMsg: |
| 1955 | msg, _ := message.Data.(cmn.TestMessage) |
| 1956 | if msg.TestMessageVal == cmn.AbortMessageProcessing { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1957 | logger.Infow(ctx, "UniVlanConfigFsm abort ProcessMsg", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1958 | break loop |
| 1959 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1960 | logger.Warnw(ctx, "UniVlanConfigFsm unknown TestMessage", log.Fields{"device-id": oFsm.deviceID, "MessageVal": msg.TestMessageVal}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1961 | case cmn.OMCI: |
| 1962 | msg, _ := message.Data.(cmn.OmciMessage) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1963 | oFsm.handleOmciVlanConfigMessage(ctx, msg) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1964 | default: |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1965 | logger.Warn(ctx, "UniVlanConfigFsm Rx unknown message", log.Fields{"device-id": oFsm.deviceID, |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1966 | "message.Type": message.Type}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1967 | } |
| 1968 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1969 | logger.Infow(ctx, "End UniVlanConfigFsm Msg processing", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1970 | } |
| 1971 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1972 | func (oFsm *UniVlanConfigFsm) handleOmciVlanConfigMessage(ctx context.Context, msg cmn.OmciMessage) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1973 | logger.Debugw(ctx, "Rx OMCI UniVlanConfigFsm Msg", log.Fields{"device-id": oFsm.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1974 | "msgType": msg.OmciMsg.MessageType}) |
| 1975 | |
| 1976 | switch msg.OmciMsg.MessageType { |
| 1977 | case omci.CreateResponseType: |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1978 | { // had to shift that to a method to cope with StaticCodeAnalysis restrictions :-( |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1979 | if err := oFsm.handleOmciCreateResponseMessage(ctx, msg.OmciPacket); err != nil { |
| 1980 | logger.Warnw(ctx, "CreateResponse handling aborted", log.Fields{"err": err}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1981 | return |
| 1982 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1983 | } //CreateResponseType |
| 1984 | case omci.SetResponseType: |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1985 | { //leave that here as direct code as most often used |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1986 | msgLayer := (*msg.OmciPacket).Layer(omci.LayerTypeSetResponse) |
| 1987 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1988 | logger.Errorw(ctx, "Omci Msg layer could not be detected for SetResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1989 | log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1990 | return |
| 1991 | } |
| 1992 | msgObj, msgOk := msgLayer.(*omci.SetResponse) |
| 1993 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1994 | logger.Errorw(ctx, "Omci Msg layer could not be assigned for SetResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1995 | log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1996 | return |
| 1997 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1998 | logger.Debugw(ctx, "UniVlanConfigFsm SetResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1999 | if msgObj.Result != me.Success { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2000 | logger.Errorw(ctx, "UniVlanConfigFsm Omci SetResponse Error - later: drive FSM to abort state ?", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2001 | log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2002 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
| 2003 | return |
| 2004 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2005 | oFsm.mutexPLastTxMeInstance.RLock() |
| 2006 | if oFsm.pLastTxMeInstance != nil { |
| 2007 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 2008 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 2009 | switch oFsm.pLastTxMeInstance.GetName() { |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 2010 | case "VlanTaggingFilterData", "ExtendedVlanTaggingOperationConfigurationData", "MulticastOperationsProfile", "GemPortNetworkCtp": |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2011 | { // let the MultiEntity config proceed by stopping the wait function |
| 2012 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 2013 | oFsm.omciMIdsResponseReceived <- true |
| 2014 | return |
| 2015 | } |
| 2016 | default: |
| 2017 | { |
| 2018 | logger.Warnw(ctx, "Unsupported ME name received!", |
| 2019 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID}) |
| 2020 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2021 | } |
| 2022 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2023 | } else { |
| 2024 | logger.Warnw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2025 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2026 | oFsm.mutexPLastTxMeInstance.RUnlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2027 | } //SetResponseType |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2028 | case omci.DeleteResponseType: |
| 2029 | { // had to shift that to a method to cope with StaticCodeAnalysis restrictions :-( |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2030 | if err := oFsm.handleOmciDeleteResponseMessage(ctx, msg.OmciPacket); err != nil { |
| 2031 | logger.Warnw(ctx, "DeleteResponse handling aborted", log.Fields{"err": err}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2032 | return |
| 2033 | } |
| 2034 | } //DeleteResponseType |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2035 | default: |
| 2036 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2037 | logger.Errorw(ctx, "Rx OMCI unhandled MsgType", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2038 | log.Fields{"omciMsgType": msg.OmciMsg.MessageType, "device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2039 | return |
| 2040 | } |
| 2041 | } |
| 2042 | } |
| 2043 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2044 | func (oFsm *UniVlanConfigFsm) handleOmciCreateResponseMessage(ctx context.Context, apOmciPacket *gp.Packet) error { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2045 | msgLayer := (*apOmciPacket).Layer(omci.LayerTypeCreateResponse) |
| 2046 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2047 | logger.Errorw(ctx, "Omci Msg layer could not be detected for CreateResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2048 | log.Fields{"device-id": oFsm.deviceID}) |
| 2049 | return fmt.Errorf("omci msg layer could not be detected for CreateResponse for device-id %x", |
| 2050 | oFsm.deviceID) |
| 2051 | } |
| 2052 | msgObj, msgOk := msgLayer.(*omci.CreateResponse) |
| 2053 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2054 | logger.Errorw(ctx, "Omci Msg layer could not be assigned for CreateResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2055 | log.Fields{"device-id": oFsm.deviceID}) |
| 2056 | return fmt.Errorf("omci msg layer could not be assigned for CreateResponse for device-id %x", |
| 2057 | oFsm.deviceID) |
| 2058 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2059 | logger.Debugw(ctx, "UniVlanConfigFsm CreateResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2060 | if msgObj.Result != me.Success && msgObj.Result != me.InstanceExists { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2061 | logger.Errorw(ctx, "Omci CreateResponse Error - later: drive FSM to abort state ?", log.Fields{"device-id": oFsm.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2062 | "Error": msgObj.Result}) |
| 2063 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
| 2064 | return fmt.Errorf("omci CreateResponse Error for device-id %x", |
| 2065 | oFsm.deviceID) |
| 2066 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2067 | oFsm.mutexPLastTxMeInstance.RLock() |
| 2068 | if oFsm.pLastTxMeInstance != nil { |
| 2069 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 2070 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 2071 | // to satisfy StaticCodeAnalysis I had to move the small processing into a separate method :-( |
| 2072 | switch oFsm.pLastTxMeInstance.GetName() { |
| 2073 | case "VlanTaggingFilterData", "MulticastOperationsProfile", |
| 2074 | "MulticastSubscriberConfigInfo", "MacBridgePortConfigurationData", |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 2075 | "ExtendedVlanTaggingOperationConfigurationData", "TrafficDescriptor": |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2076 | { |
| 2077 | oFsm.mutexPLastTxMeInstance.RUnlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2078 | if oFsm.PAdaptFsm.PFsm.Current() == VlanStConfigVtfd { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2079 | // Only if CreateResponse is received from first flow entry - let the FSM proceed ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2080 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRxConfigVtfd) |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2081 | } else { // let the MultiEntity config proceed by stopping the wait function |
| 2082 | oFsm.omciMIdsResponseReceived <- true |
| 2083 | } |
| 2084 | return nil |
| 2085 | } |
| 2086 | default: |
| 2087 | { |
| 2088 | logger.Warnw(ctx, "Unsupported ME name received!", |
| 2089 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2090 | } |
| 2091 | } |
| 2092 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2093 | } else { |
| 2094 | logger.Warnw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2095 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2096 | oFsm.mutexPLastTxMeInstance.RUnlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2097 | return nil |
| 2098 | } |
| 2099 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2100 | func (oFsm *UniVlanConfigFsm) handleOmciDeleteResponseMessage(ctx context.Context, apOmciPacket *gp.Packet) error { |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2101 | msgLayer := (*apOmciPacket).Layer(omci.LayerTypeDeleteResponse) |
| 2102 | if msgLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2103 | logger.Errorw(ctx, "UniVlanConfigFsm - Omci Msg layer could not be detected for DeleteResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2104 | log.Fields{"device-id": oFsm.deviceID}) |
| 2105 | return fmt.Errorf("omci msg layer could not be detected for DeleteResponse for device-id %x", |
| 2106 | oFsm.deviceID) |
| 2107 | } |
| 2108 | msgObj, msgOk := msgLayer.(*omci.DeleteResponse) |
| 2109 | if !msgOk { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2110 | logger.Errorw(ctx, "UniVlanConfigFsm - Omci Msg layer could not be assigned for DeleteResponse", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2111 | log.Fields{"device-id": oFsm.deviceID}) |
| 2112 | return fmt.Errorf("omci msg layer could not be assigned for DeleteResponse for device-id %x", |
| 2113 | oFsm.deviceID) |
| 2114 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2115 | logger.Debugw(ctx, "UniVlanConfigFsm DeleteResponse Data", log.Fields{"device-id": oFsm.deviceID, "data-fields": msgObj}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2116 | if msgObj.Result != me.Success { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2117 | logger.Errorw(ctx, "UniVlanConfigFsm - Omci DeleteResponse Error - later: drive FSM to abort state ?", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2118 | log.Fields{"device-id": oFsm.deviceID, "Error": msgObj.Result}) |
| 2119 | // possibly force FSM into abort or ignore some errors for some messages? store error for mgmt display? |
| 2120 | return fmt.Errorf("omci DeleteResponse Error for device-id %x", |
| 2121 | oFsm.deviceID) |
| 2122 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2123 | oFsm.mutexPLastTxMeInstance.RLock() |
| 2124 | if oFsm.pLastTxMeInstance != nil { |
| 2125 | if msgObj.EntityClass == oFsm.pLastTxMeInstance.GetClassID() && |
| 2126 | msgObj.EntityInstance == oFsm.pLastTxMeInstance.GetEntityID() { |
| 2127 | switch oFsm.pLastTxMeInstance.GetName() { |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 2128 | case "VlanTaggingFilterData", "ExtendedVlanTaggingOperationConfigurationData", "TrafficDescriptor": |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2129 | { // let the MultiEntity config proceed by stopping the wait function |
| 2130 | oFsm.mutexPLastTxMeInstance.RUnlock() |
| 2131 | oFsm.omciMIdsResponseReceived <- true |
| 2132 | return nil |
| 2133 | } |
| 2134 | default: |
| 2135 | { |
| 2136 | logger.Warnw(ctx, "Unsupported ME name received!", |
| 2137 | log.Fields{"ME name": oFsm.pLastTxMeInstance.GetName(), "device-id": oFsm.deviceID}) |
| 2138 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2139 | } |
| 2140 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2141 | } else { |
| 2142 | logger.Warnw(ctx, "Pointer to last Tx MeInstance is nil!", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2143 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2144 | oFsm.mutexPLastTxMeInstance.RUnlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2145 | return nil |
| 2146 | } |
| 2147 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2148 | func (oFsm *UniVlanConfigFsm) performConfigEvtocdEntries(ctx context.Context, aFlowEntryNo uint8) error { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2149 | oFsm.mutexFlowParams.RLock() |
| 2150 | evtocdID := oFsm.evtocdID |
| 2151 | oFsm.mutexFlowParams.RUnlock() |
| 2152 | |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2153 | if aFlowEntryNo == 0 { |
| 2154 | // EthType set only at first flow element |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2155 | // EVTOCD ME is expected to exist at this point already from MIB-Download (with AssociationType/Pointer) |
| 2156 | // we need to extend the configuration by EthType definition and, to be sure, downstream 'inverse' mode |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2157 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Create::EVTOCD", log.Fields{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2158 | "EntitytId": strconv.FormatInt(int64(evtocdID), 16), |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2159 | "i/oEthType": strconv.FormatInt(int64(cDefaultTpid), 16), |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2160 | "device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2161 | associationType := 2 // default to UniPPTP |
| 2162 | if oFsm.pOnuUniPort.PortType == cmn.UniVEIP { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2163 | associationType = 10 |
| 2164 | } |
| 2165 | // Create the EVTOCD ME |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2166 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2167 | EntityID: evtocdID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2168 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2169 | me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: uint8(associationType), |
| 2170 | me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: oFsm.pOnuUniPort.EntityID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2171 | }, |
| 2172 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2173 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2174 | meInstance, err := oFsm.pOmciCC.SendCreateEvtocdVar(context.TODO(), oFsm.pDeviceHandler.GetOmciTimeout(), |
| 2175 | true, oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2176 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2177 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2178 | logger.Errorw(ctx, "CreateEvtocdVar create failed, aborting UniVlanConfigFsm!", |
| 2179 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2180 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2181 | return fmt.Errorf("evtocd instance create failed %s, error %s", oFsm.deviceID, err) |
| 2182 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2183 | //accept also nil as (error) return value for writing to LastTx |
| 2184 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2185 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2186 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2187 | |
| 2188 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2189 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2190 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2191 | logger.Errorw(ctx, "Evtocd create failed, aborting VlanConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2192 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2193 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2194 | return fmt.Errorf("evtocd create failed %s, error %s", oFsm.deviceID, err) |
| 2195 | } |
| 2196 | |
| 2197 | // Set the EVTOCD ME default params |
| 2198 | meParams = me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2199 | EntityID: evtocdID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2200 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2201 | me.ExtendedVlanTaggingOperationConfigurationData_InputTpid: uint16(cDefaultTpid), //could be possibly retrieved from flow config one day, by now just like py-code base |
| 2202 | me.ExtendedVlanTaggingOperationConfigurationData_OutputTpid: uint16(cDefaultTpid), //could be possibly retrieved from flow config one day, by now just like py-code base |
| 2203 | me.ExtendedVlanTaggingOperationConfigurationData_DownstreamMode: uint8(cDefaultDownstreamMode), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2204 | }, |
| 2205 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2206 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2207 | meInstance, err = oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2208 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2209 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2210 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2211 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2212 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2213 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2214 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2215 | return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err) |
| 2216 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2217 | //accept also nil as (error) return value for writing to LastTx |
| 2218 | // - this avoids misinterpretation of new received OMCI messages |
| 2219 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2220 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2221 | |
| 2222 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2223 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2224 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2225 | logger.Errorw(ctx, "Evtocd set TPID failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2226 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2227 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2228 | return fmt.Errorf("evtocd set TPID failed %s, error %s", oFsm.deviceID, err) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2229 | } |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2230 | } //first flow element |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2231 | |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 2232 | oFsm.mutexFlowParams.RLock() |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 2233 | if oFsm.actualUniFlowParam.VlanRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2234 | //transparent transmission required |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 2235 | oFsm.mutexFlowParams.RUnlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2236 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD single tagged transparent rule", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2237 | "device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2238 | sliceEvtocdRule := make([]uint8, 16) |
| 2239 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2240 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2241 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2242 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2243 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
| 2244 | |
| 2245 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
| 2246 | cPrioDefaultFilter<<cFilterPrioOffset| // default inner-tag rule |
| 2247 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on inner vid |
| 2248 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2249 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
| 2250 | |
| 2251 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], |
| 2252 | 0<<cTreatTTROffset| // Do not pop any tags |
| 2253 | cDoNotAddPrio<<cTreatPrioOffset| // do not add outer tag |
| 2254 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2255 | cDontCareTpid<<cTreatTpidOffset) // Outer TPID field don't care |
| 2256 | |
| 2257 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], |
| 2258 | cDoNotAddPrio<<cTreatPrioOffset| // do not add inner tag |
| 2259 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2260 | cSetOutputTpidCopyDei<<cTreatTpidOffset) // Set TPID = 0x8100 |
| 2261 | |
| 2262 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2263 | EntityID: evtocdID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2264 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2265 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2266 | }, |
| 2267 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2268 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2269 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2270 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2271 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2272 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2273 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2274 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2275 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2276 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2277 | return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err) |
| 2278 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2279 | //accept also nil as (error) return value for writing to LastTx |
| 2280 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2281 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2282 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2283 | |
| 2284 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2285 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2286 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2287 | logger.Errorw(ctx, "Evtocd set transparent singletagged rule failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2288 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2289 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2290 | return fmt.Errorf("evtocd set transparent singletagged rule failed %s, error %s", oFsm.deviceID, err) |
| 2291 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2292 | } |
| 2293 | } else { |
| 2294 | // according to py-code acceptIncrementalEvto program option decides upon stacking or translation scenario |
| 2295 | if oFsm.acceptIncrementalEvtoOption { |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 2296 | matchPcp := oFsm.actualUniFlowParam.VlanRuleParams.MatchPcp |
| 2297 | matchVid := oFsm.actualUniFlowParam.VlanRuleParams.MatchVid |
| 2298 | setPcp := oFsm.actualUniFlowParam.VlanRuleParams.SetPcp |
| 2299 | setVid := oFsm.actualUniFlowParam.VlanRuleParams.SetVid |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2300 | // this defines VID translation scenario: singletagged->singletagged (if not transparent) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2301 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD single tagged translation rule", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2302 | "match-pcp": matchPcp, "match-vid": matchVid, "set-pcp": setPcp, "set-vid:": setVid, "device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2303 | sliceEvtocdRule := make([]uint8, 16) |
| 2304 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2305 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2306 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2307 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2308 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
| 2309 | |
| 2310 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 2311 | oFsm.actualUniFlowParam.VlanRuleParams.MatchPcp<<cFilterPrioOffset| // either DNFonPrio or ignore tag (default) on innerVLAN |
| 2312 | oFsm.actualUniFlowParam.VlanRuleParams.MatchVid<<cFilterVidOffset| // either DNFonVid or real filter VID |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2313 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2314 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
| 2315 | |
| 2316 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 2317 | oFsm.actualUniFlowParam.VlanRuleParams.TagsToRemove<<cTreatTTROffset| // either 1 or 0 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2318 | cDoNotAddPrio<<cTreatPrioOffset| // do not add outer tag |
| 2319 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2320 | cDontCareTpid<<cTreatTpidOffset) // Outer TPID field don't care |
| 2321 | |
| 2322 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 2323 | oFsm.actualUniFlowParam.VlanRuleParams.SetPcp<<cTreatPrioOffset| // as configured in flow |
| 2324 | oFsm.actualUniFlowParam.VlanRuleParams.SetVid<<cTreatVidOffset| //as configured in flow |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2325 | cSetOutputTpidCopyDei<<cTreatTpidOffset) // Set TPID = 0x8100 |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 2326 | oFsm.mutexFlowParams.RUnlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2327 | |
| 2328 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2329 | EntityID: evtocdID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2330 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2331 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2332 | }, |
| 2333 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2334 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2335 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2336 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2337 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2338 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2339 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2340 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2341 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2342 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2343 | return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err) |
| 2344 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2345 | //accept also nil as (error) return value for writing to LastTx |
| 2346 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2347 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2348 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2349 | |
| 2350 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2351 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2352 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2353 | logger.Errorw(ctx, "Evtocd set singletagged translation rule failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2354 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2355 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2356 | return fmt.Errorf("evtocd set singletagged translation rule failed %s, error %s", oFsm.deviceID, err) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2357 | } |
| 2358 | } else { |
| 2359 | //not transparent and not acceptIncrementalEvtoOption untagged/priotagged->singletagged |
| 2360 | { // just for local var's |
| 2361 | // this defines stacking scenario: untagged->singletagged |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2362 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD untagged->singletagged rule", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2363 | "device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2364 | sliceEvtocdRule := make([]uint8, 16) |
| 2365 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2366 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2367 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2368 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2369 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
| 2370 | |
| 2371 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
| 2372 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an inner-tag rule |
| 2373 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on inner vid |
| 2374 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2375 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
| 2376 | |
| 2377 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], |
| 2378 | 0<<cTreatTTROffset| // Do not pop any tags |
| 2379 | cDoNotAddPrio<<cTreatPrioOffset| // do not add outer tag |
| 2380 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2381 | cDontCareTpid<<cTreatTpidOffset) // Outer TPID field don't care |
| 2382 | |
| 2383 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], |
| 2384 | 0<<cTreatPrioOffset| // vlan prio set to 0 |
| 2385 | // (as done in Py code, maybe better option would be setPcp here, which still could be 0?) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 2386 | oFsm.actualUniFlowParam.VlanRuleParams.SetVid<<cTreatVidOffset| // Outer VID don't care |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2387 | cSetOutputTpidCopyDei<<cTreatTpidOffset) // Set TPID = 0x8100 |
| 2388 | |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 2389 | oFsm.mutexFlowParams.RUnlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2390 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2391 | EntityID: evtocdID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2392 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2393 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2394 | }, |
| 2395 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2396 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2397 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2398 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2399 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2400 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2401 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2402 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2403 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2404 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2405 | return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err) |
| 2406 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2407 | //accept also nil as (error) return value for writing to LastTx |
| 2408 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2409 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2410 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2411 | |
| 2412 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2413 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2414 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2415 | logger.Errorw(ctx, "Evtocd set untagged->singletagged rule failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2416 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2417 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2418 | return fmt.Errorf("evtocd set untagged->singletagged rule failed %s, error %s", oFsm.deviceID, err) |
| 2419 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2420 | } |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 2421 | } // just for local var's |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2422 | { // just for local var's |
| 2423 | // this defines 'stacking' scenario: priotagged->singletagged |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2424 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD priotagged->singletagged rule", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2425 | "device-id": oFsm.deviceID}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2426 | sliceEvtocdRule := make([]uint8, 16) |
| 2427 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2428 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2429 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2430 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2431 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
| 2432 | |
| 2433 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
| 2434 | cPrioDoNotFilter<<cFilterPrioOffset| // Do not Filter on innerprio |
| 2435 | 0<<cFilterVidOffset| // filter on inner vid 0 (prioTagged) |
| 2436 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2437 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
| 2438 | |
| 2439 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], |
| 2440 | 1<<cTreatTTROffset| // pop the prio-tag |
| 2441 | cDoNotAddPrio<<cTreatPrioOffset| // do not add outer tag |
| 2442 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2443 | cDontCareTpid<<cTreatTpidOffset) // Outer TPID field don't care |
| 2444 | |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 2445 | oFsm.mutexFlowParams.RLock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2446 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], |
| 2447 | cCopyPrioFromInner<<cTreatPrioOffset| // vlan copy from PrioTag |
| 2448 | // (as done in Py code, maybe better option would be setPcp here, which still could be PrioCopy?) |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 2449 | oFsm.actualUniFlowParam.VlanRuleParams.SetVid<<cTreatVidOffset| // Outer VID as configured |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2450 | cSetOutputTpidCopyDei<<cTreatTpidOffset) // Set TPID = 0x8100 |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 2451 | oFsm.mutexFlowParams.RUnlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2452 | |
| 2453 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2454 | EntityID: evtocdID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2455 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2456 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2457 | }, |
| 2458 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2459 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2460 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2461 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2462 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2463 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2464 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2465 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2466 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2467 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2468 | return fmt.Errorf("evtocd instance set failed %s, error %s", oFsm.deviceID, err) |
| 2469 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2470 | //accept also nil as (error) return value for writing to LastTx |
| 2471 | // - this avoids misinterpretation of new received OMCI messages |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2472 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2473 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2474 | |
| 2475 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2476 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2477 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2478 | logger.Errorw(ctx, "Evtocd set priotagged->singletagged rule failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2479 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2480 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2481 | return fmt.Errorf("evtocd set priotagged->singletagged rule failed %s, error %s", oFsm.deviceID, err) |
| 2482 | |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2483 | } |
| 2484 | } //just for local var's |
| 2485 | } |
| 2486 | } |
| 2487 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 2488 | // if Config has been done for all EVTOCD entries let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2489 | logger.Debugw(ctx, "EVTOCD set loop finished", log.Fields{"device-id": oFsm.deviceID}) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2490 | oFsm.mutexFlowParams.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2491 | oFsm.ConfiguredUniFlow++ // one (more) flow configured |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2492 | oFsm.mutexFlowParams.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2493 | return nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2494 | } |
| 2495 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2496 | func (oFsm *UniVlanConfigFsm) removeEvtocdEntries(ctx context.Context, aRuleParams cmn.UniVlanRuleParams) { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2497 | oFsm.mutexFlowParams.RLock() |
| 2498 | evtocdID := oFsm.evtocdID |
| 2499 | oFsm.mutexFlowParams.RUnlock() |
| 2500 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2501 | // configured Input/Output TPID is not modified again - no influence if no filter is applied |
| 2502 | if aRuleParams.SetVid == uint32(of.OfpVlanId_OFPVID_PRESENT) { |
| 2503 | //transparent transmission was set |
| 2504 | //perhaps the config is not needed for removal, |
| 2505 | // but the specific InnerTpid setting is removed in favor of the real default forwarding rule |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2506 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD reset to default single tagged rule", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2507 | "device-id": oFsm.deviceID}) |
| 2508 | sliceEvtocdRule := make([]uint8, 16) |
| 2509 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2510 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2511 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2512 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2513 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
| 2514 | |
| 2515 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
| 2516 | cPrioDefaultFilter<<cFilterPrioOffset| // default inner-tag rule |
| 2517 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on inner vid |
| 2518 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2519 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
| 2520 | |
| 2521 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], |
| 2522 | 0<<cTreatTTROffset| // Do not pop any tags |
| 2523 | cDoNotAddPrio<<cTreatPrioOffset| // do not add outer tag |
| 2524 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2525 | cDontCareTpid<<cTreatTpidOffset) // Outer TPID field don't care |
| 2526 | |
| 2527 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], |
| 2528 | cDoNotAddPrio<<cTreatPrioOffset| // do not add inner tag |
| 2529 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2530 | cDontCareTpid<<cTreatTpidOffset) // copy TPID and DEI |
| 2531 | |
| 2532 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2533 | EntityID: evtocdID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2534 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2535 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2536 | }, |
| 2537 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2538 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2539 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2540 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2541 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2542 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2543 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2544 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2545 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2546 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2547 | return |
| 2548 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2549 | //accept also nil as (error) return value for writing to LastTx |
| 2550 | // - this avoids misinterpretation of new received OMCI messages |
| 2551 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2552 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2553 | |
| 2554 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2555 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2556 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2557 | logger.Errorw(ctx, "Evtocd reset singletagged rule failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2558 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2559 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2560 | return |
| 2561 | } |
| 2562 | } else { |
| 2563 | // according to py-code acceptIncrementalEvto program option decides upon stacking or translation scenario |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2564 | oFsm.mutexFlowParams.RLock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2565 | if oFsm.acceptIncrementalEvtoOption { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2566 | oFsm.mutexFlowParams.RUnlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2567 | // this defines VID translation scenario: singletagged->singletagged (if not transparent) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2568 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD clear single tagged translation rule", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2569 | "device-id": oFsm.deviceID, "match-vlan": aRuleParams.MatchVid}) |
| 2570 | sliceEvtocdRule := make([]uint8, 16) |
| 2571 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2572 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2573 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2574 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2575 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
| 2576 | |
| 2577 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
| 2578 | aRuleParams.MatchPcp<<cFilterPrioOffset| // either DNFonPrio or ignore tag (default) on innerVLAN |
| 2579 | aRuleParams.MatchVid<<cFilterVidOffset| // either DNFonVid or real filter VID |
| 2580 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2581 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
| 2582 | |
| 2583 | // delete indication for the indicated Filter |
| 2584 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], 0xFFFFFFFF) |
| 2585 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], 0xFFFFFFFF) |
| 2586 | |
| 2587 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2588 | EntityID: evtocdID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2589 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2590 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2591 | }, |
| 2592 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2593 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2594 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2595 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2596 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2597 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2598 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2599 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2600 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2601 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2602 | return |
| 2603 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2604 | //accept also nil as (error) return value for writing to LastTx |
| 2605 | // - this avoids misinterpretation of new received OMCI messages |
| 2606 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2607 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2608 | |
| 2609 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2610 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2611 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2612 | logger.Errorw(ctx, "Evtocd clear singletagged translation rule failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2613 | log.Fields{"device-id": oFsm.deviceID, "match-vlan": aRuleParams.MatchVid}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2614 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2615 | return |
| 2616 | } |
| 2617 | } else { |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2618 | // VOL-3685 |
| 2619 | // NOTE: With ALPHA ONUs it was seen that just resetting a particular entry in the EVTOCD table |
| 2620 | // and re-configuring a new entry would not work. The old entry is removed and new entry is created |
| 2621 | // indeed, but the traffic landing upstream would carry old vlan sometimes. |
| 2622 | // This is only a WORKAROUND which basically deletes the entire EVTOCD ME and re-creates it again |
| 2623 | // later when the flow is being re-installed. |
| 2624 | // Of course this is applicable to case only where single service (or single tcont) is in use and |
| 2625 | // there is only one service vlan (oFsm.acceptIncrementalEvtoOption is false in this case). |
| 2626 | // Interstingly this problem has not been observed in multi-tcont (or multi-service) scenario (in |
| 2627 | // which case the oFsm.acceptIncrementalEvtoOption is set to true). |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2628 | if oFsm.ConfiguredUniFlow == 1 && !oFsm.acceptIncrementalEvtoOption { |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2629 | oFsm.mutexFlowParams.RUnlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2630 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Remove::EVTOCD", log.Fields{"device-id": oFsm.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2631 | // When there are no more EVTOCD vlan configurations on the ONU and acceptIncrementalEvtoOption |
| 2632 | // is not enabled, delete the EVTOCD ME. |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2633 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2634 | EntityID: evtocdID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2635 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2636 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2637 | meInstance, err := oFsm.pOmciCC.SendDeleteEvtocd(log.WithSpanFromContext(context.TODO(), ctx), |
| 2638 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2639 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2640 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2641 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2642 | logger.Errorw(ctx, "DeleteEvtocdVar delete failed, aborting UniVlanConfigFsm!", |
| 2643 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2644 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2645 | return |
| 2646 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2647 | //accept also nil as (error) return value for writing to LastTx |
| 2648 | // - this avoids misinterpretation of new received OMCI messages |
| 2649 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2650 | oFsm.mutexPLastTxMeInstance.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2651 | |
| 2652 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2653 | err = oFsm.waitforOmciResponse(ctx) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2654 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2655 | logger.Errorw(ctx, "Evtocd delete rule failed, aborting VlanConfig FSM!", |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2656 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2657 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2658 | return |
| 2659 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2660 | } else { |
| 2661 | // NOTE : We should ideally never ether this section when oFsm.acceptIncrementalEvtoOption is set to false |
| 2662 | // This is true for only ATT/DT workflow |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2663 | logger.Debugw(ctx, "UniVlanConfigFsm: Remove EVTOCD set operation", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2664 | log.Fields{"configured-flow": oFsm.ConfiguredUniFlow, "incremental-evto": oFsm.acceptIncrementalEvtoOption}) |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2665 | oFsm.mutexFlowParams.RUnlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2666 | //not transparent and not acceptIncrementalEvtoOption: untagged/priotagged->singletagged |
| 2667 | { // just for local var's |
| 2668 | // this defines stacking scenario: untagged->singletagged |
| 2669 | //TODO!! in theory there could be different rules running in setting different PCP/VID'S |
| 2670 | // for untagged/priotagged, last rule wins (and remains the only one), maybe that should be |
| 2671 | // checked already at flow-add (and rejected) - to be observed if such is possible in Voltha |
| 2672 | // delete now assumes there is only one such rule! |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2673 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD reset untagged rule to default", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2674 | "device-id": oFsm.deviceID}) |
| 2675 | sliceEvtocdRule := make([]uint8, 16) |
| 2676 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2677 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2678 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2679 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2680 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2681 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2682 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
| 2683 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an inner-tag rule |
| 2684 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on inner vid |
| 2685 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2686 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2687 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2688 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], |
| 2689 | 0<<cTreatTTROffset| // Do not pop any tags |
| 2690 | cDoNotAddPrio<<cTreatPrioOffset| // do not add outer tag |
| 2691 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2692 | cDontCareTpid<<cTreatTpidOffset) // Outer TPID field don't care |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2693 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2694 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], |
| 2695 | cDoNotAddPrio<<cTreatPrioOffset| // do not add inner tag |
| 2696 | cDontCareVid<<cTreatVidOffset| // Outer VID don't care |
| 2697 | cDontCareTpid<<cTreatTpidOffset) // copy TPID and DEI |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2698 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2699 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2700 | EntityID: evtocdID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2701 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2702 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2703 | }, |
| 2704 | } |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 2705 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2706 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(context.TODO(), |
| 2707 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2708 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2709 | if err != nil { |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 2710 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2711 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2712 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2713 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2714 | return |
| 2715 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2716 | //accept also nil as (error) return value for writing to LastTx |
| 2717 | // - this avoids misinterpretation of new received OMCI messages |
| 2718 | oFsm.pLastTxMeInstance = meInstance |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 2719 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2720 | |
| 2721 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2722 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2723 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2724 | logger.Errorw(ctx, "Evtocd reset untagged rule to default failed, aborting VlanConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2725 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2726 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2727 | return |
| 2728 | } |
| 2729 | } // just for local var's |
| 2730 | { // just for local var's |
| 2731 | // this defines 'stacking' scenario: priotagged->singletagged |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2732 | logger.Debugw(ctx, "UniVlanConfigFsm Tx Set::EVTOCD delete priotagged rule", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2733 | "device-id": oFsm.deviceID}) |
| 2734 | sliceEvtocdRule := make([]uint8, 16) |
| 2735 | // fill vlan tagging operation table bit fields using network=bigEndian order and using slice offset 0 as highest 'word' |
| 2736 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterOuterOffset:], |
| 2737 | cPrioIgnoreTag<<cFilterPrioOffset| // Not an outer-tag rule |
| 2738 | cDoNotFilterVid<<cFilterVidOffset| // Do not filter on outer vid |
| 2739 | cDoNotFilterTPID<<cFilterTpidOffset) // Do not filter on outer TPID field |
| 2740 | |
| 2741 | binary.BigEndian.PutUint32(sliceEvtocdRule[cFilterInnerOffset:], |
| 2742 | cPrioDoNotFilter<<cFilterPrioOffset| // Do not Filter on innerprio |
| 2743 | 0<<cFilterVidOffset| // filter on inner vid 0 (prioTagged) |
| 2744 | cDoNotFilterTPID<<cFilterTpidOffset| // Do not filter on inner TPID field |
| 2745 | cDoNotFilterEtherType<<cFilterEtherTypeOffset) // Do not filter of EtherType |
| 2746 | |
| 2747 | // delete indication for the indicated Filter |
| 2748 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatOuterOffset:], 0xFFFFFFFF) |
| 2749 | binary.BigEndian.PutUint32(sliceEvtocdRule[cTreatInnerOffset:], 0xFFFFFFFF) |
| 2750 | |
| 2751 | meParams := me.ParamData{ |
mpagenko | f1d21d1 | 2021-06-11 13:14:45 +0000 | [diff] [blame] | 2752 | EntityID: evtocdID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2753 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2754 | me.ExtendedVlanTaggingOperationConfigurationData_ReceivedFrameVlanTaggingOperationTable: sliceEvtocdRule, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2755 | }, |
| 2756 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2757 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2758 | meInstance, err := oFsm.pOmciCC.SendSetEvtocdVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 2759 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2760 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2761 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2762 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2763 | logger.Errorw(ctx, "SetEvtocdVar set failed, aborting UniVlanConfigFsm!", |
| 2764 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2765 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2766 | return |
| 2767 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2768 | //accept also nil as (error) return value for writing to LastTx |
| 2769 | // - this avoids misinterpretation of new received OMCI messages |
| 2770 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2771 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2772 | |
| 2773 | //verify response |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2774 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2775 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2776 | logger.Errorw(ctx, "Evtocd delete priotagged rule failed, aborting VlanConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2777 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2778 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2779 | return |
| 2780 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2781 | } |
| 2782 | } //just for local var's |
| 2783 | } |
| 2784 | } |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 2785 | // if Config has been done for all EVTOCD entries let the FSM proceed |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2786 | logger.Debugw(ctx, "EVTOCD filter remove loop finished", log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2787 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvRemFlowDone, aRuleParams.TpID) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2788 | } |
| 2789 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2790 | func (oFsm *UniVlanConfigFsm) waitforOmciResponse(ctx context.Context) error { |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 2791 | oFsm.mutexIsAwaitingResponse.Lock() |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 2792 | if oFsm.isCanceled { |
| 2793 | // FSM already canceled before entering wait |
| 2794 | logger.Debugw(ctx, "UniVlanConfigFsm wait-for-multi-entity-response aborted (on enter)", log.Fields{"for device-id": oFsm.deviceID}) |
| 2795 | oFsm.mutexIsAwaitingResponse.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2796 | return fmt.Errorf(cmn.CErrWaitAborted) |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 2797 | } |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 2798 | oFsm.isAwaitingResponse = true |
| 2799 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2800 | select { |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 2801 | // maybe be also some outside cancel (but no context modeled for the moment ...) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2802 | // case <-ctx.Done(): |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2803 | // logger.Infow(ctx,"LockState-bridge-init message reception canceled", log.Fields{"for device-id": oFsm.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 2804 | case <-time.After(oFsm.pOmciCC.GetMaxOmciTimeoutWithRetries() * time.Second): //AS FOR THE OTHER OMCI FSM's |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2805 | logger.Warnw(ctx, "UniVlanConfigFsm multi entity timeout", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 2806 | oFsm.mutexIsAwaitingResponse.Lock() |
| 2807 | oFsm.isAwaitingResponse = false |
| 2808 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2809 | return fmt.Errorf("uniVlanConfigFsm multi entity timeout %s", oFsm.deviceID) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2810 | case success := <-oFsm.omciMIdsResponseReceived: |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 2811 | if success { |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 2812 | logger.Debugw(ctx, "UniVlanConfigFsm multi entity response received", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 2813 | oFsm.mutexIsAwaitingResponse.Lock() |
| 2814 | oFsm.isAwaitingResponse = false |
| 2815 | oFsm.mutexIsAwaitingResponse.Unlock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2816 | return nil |
| 2817 | } |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 2818 | // waiting was aborted (probably on external request) |
mpagenko | cf48e45 | 2021-04-23 09:23:00 +0000 | [diff] [blame] | 2819 | logger.Debugw(ctx, "UniVlanConfigFsm wait-for-multi-entity-response aborted", log.Fields{"for device-id": oFsm.deviceID}) |
mpagenko | 7d6bb02 | 2021-03-11 15:07:55 +0000 | [diff] [blame] | 2820 | oFsm.mutexIsAwaitingResponse.Lock() |
| 2821 | oFsm.isAwaitingResponse = false |
| 2822 | oFsm.mutexIsAwaitingResponse.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2823 | return fmt.Errorf(cmn.CErrWaitAborted) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 2824 | } |
| 2825 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2826 | |
mpagenko | 551a4d4 | 2020-12-08 18:09:20 +0000 | [diff] [blame] | 2827 | func (oFsm *UniVlanConfigFsm) performSettingMulticastME(ctx context.Context, tpID uint8, multicastGemPortID uint16, vlanID uint32) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2828 | logger.Debugw(ctx, "Setting Multicast MEs", log.Fields{"device-id": oFsm.deviceID, "tpID": tpID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2829 | "multicastGemPortID": multicastGemPortID, "vlanID": vlanID}) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2830 | errCreateMOP := oFsm.performCreatingMulticastOperationProfile(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2831 | if errCreateMOP != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2832 | logger.Errorw(ctx, "MulticastOperationProfile create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2833 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2834 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2835 | return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMOP) |
| 2836 | } |
| 2837 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2838 | errSettingMOP := oFsm.performSettingMulticastOperationProfile(ctx, multicastGemPortID, vlanID) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2839 | if errSettingMOP != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2840 | logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2841 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2842 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2843 | return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errSettingMOP) |
| 2844 | } |
| 2845 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2846 | errCreateMSCI := oFsm.performCreatingMulticastSubscriberConfigInfo(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2847 | if errCreateMSCI != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2848 | logger.Errorw(ctx, "MulticastOperationProfile setting failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2849 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2850 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2851 | return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, errCreateMSCI) |
| 2852 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2853 | macBpCdEID, errMacBpCdEID := cmn.GenerateMcastANISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2854 | if errMacBpCdEID != nil { |
| 2855 | logger.Errorw(ctx, "MulticastMacBridgePortConfigData entity id generation failed, aborting AniConfig FSM!", |
| 2856 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2857 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2858 | return fmt.Errorf("generateMcastANISideMBPCDEID responseError %s, error %s", oFsm.deviceID, errMacBpCdEID) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2859 | |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2860 | } |
| 2861 | logger.Debugw(ctx, "UniVlanConfigFsm set macBpCdEID for mcast", log.Fields{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2862 | "EntitytId": strconv.FormatInt(int64(macBpCdEID), 16), "macBpNo": oFsm.pOnuUniPort.MacBpNo, |
| 2863 | "in state": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2864 | meParams := me.ParamData{ |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2865 | EntityID: macBpCdEID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2866 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2867 | me.MacBridgePortConfigurationData_BridgeIdPointer: cmn.MacBridgeServiceProfileEID + uint16(oFsm.pOnuUniPort.MacBpNo), |
| 2868 | me.MacBridgePortConfigurationData_PortNum: 0xf0, //fixed unique ANI side indication |
| 2869 | me.MacBridgePortConfigurationData_TpType: 6, //MCGemIWTP |
| 2870 | me.MacBridgePortConfigurationData_TpPointer: multicastGemPortID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2871 | }, |
| 2872 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2873 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2874 | meInstance, err := oFsm.pOmciCC.SendCreateMBPConfigDataVar(context.TODO(), |
| 2875 | oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2876 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2877 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2878 | logger.Errorw(ctx, "MBPConfigDataVar create failed, aborting AniConfig FSM!", |
| 2879 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2880 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2881 | return fmt.Errorf("creatingMulticastSubscriberConfigInfo createError #{oFsm.deviceID}, error #{err}") |
| 2882 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2883 | //accept also nil as (error) return value for writing to LastTx |
| 2884 | // - this avoids misinterpretation of new received OMCI messages |
| 2885 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2886 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2887 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2888 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2889 | logger.Errorw(ctx, "CreateMBPConfigData failed, aborting AniConfig FSM!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2890 | log.Fields{"device-id": oFsm.deviceID, "MBPConfigDataID": cmn.MacBridgeServiceProfileEID}) |
| 2891 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2892 | return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s, error %s", oFsm.deviceID, err) |
| 2893 | } |
| 2894 | |
| 2895 | // ==> Start creating VTFD for mcast vlan |
| 2896 | |
| 2897 | // This attribute uniquely identifies each instance of this managed entity. Through an identical ID, |
| 2898 | // this managed entity is implicitly linked to an instance of the MAC bridge port configuration data ME. |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2899 | mcastVtfdID := macBpCdEID |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2900 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2901 | logger.Debugw(ctx, "UniVlanConfigFsm set VTFD for mcast", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2902 | "EntitytId": strconv.FormatInt(int64(mcastVtfdID), 16), "mcastVlanID": vlanID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2903 | "in state": oFsm.PAdaptFsm.PFsm.Current(), "device-id": oFsm.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2904 | vtfdFilterList := make([]uint16, cVtfdTableSize) //needed for parameter serialization |
| 2905 | |
| 2906 | // FIXME: VOL-3685: Issues with resetting a table entry in EVTOCD ME |
| 2907 | // VTFD has to be created afresh with a new entity ID that has the same entity ID as the MBPCD ME for every |
| 2908 | // new vlan associated with a different TP. |
| 2909 | vtfdFilterList[0] = uint16(vlanID) |
| 2910 | |
| 2911 | meParams = me.ParamData{ |
| 2912 | EntityID: mcastVtfdID, |
| 2913 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2914 | me.VlanTaggingFilterData_VlanFilterList: vtfdFilterList, |
| 2915 | me.VlanTaggingFilterData_ForwardOperation: uint8(0x10), //VID investigation |
| 2916 | me.VlanTaggingFilterData_NumberOfEntries: oFsm.numVlanFilterEntries, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2917 | }, |
| 2918 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2919 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2920 | meInstance, err = oFsm.pOmciCC.SendCreateVtfdVar(context.TODO(), |
| 2921 | oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2922 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2923 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2924 | logger.Errorw(ctx, "CreateVtfdVar create failed, aborting UniVlanConfigFsm!", |
| 2925 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2926 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2927 | return fmt.Errorf("createMcastVlanFilterData creationError %s, error %s", oFsm.deviceID, err) |
| 2928 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2929 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2930 | oFsm.mutexPLastTxMeInstance.Unlock() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2931 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2932 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2933 | logger.Errorw(ctx, "CreateMcastVlanFilterData failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2934 | log.Fields{"device-id": oFsm.deviceID, "mcastVtfdID": mcastVtfdID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2935 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2936 | return fmt.Errorf("createMcastVlanFilterData responseError %s, error %s", oFsm.deviceID, err) |
| 2937 | } |
| 2938 | |
| 2939 | return nil |
| 2940 | } |
| 2941 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2942 | func (oFsm *UniVlanConfigFsm) performCreatingMulticastSubscriberConfigInfo(ctx context.Context) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2943 | instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2944 | if err != nil { |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2945 | logger.Errorw(ctx, "error generrating me instance id", |
| 2946 | log.Fields{"device-id": oFsm.deviceID, "error": err}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2947 | return err |
| 2948 | } |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2949 | logger.Debugw(ctx, "UniVlanConfigFsm create MulticastSubscriberConfigInfo", |
| 2950 | log.Fields{"device-id": oFsm.deviceID, "EntityId": instID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2951 | meParams := me.ParamData{ |
| 2952 | EntityID: instID, |
| 2953 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2954 | me.MulticastSubscriberConfigInfo_MeType: 0, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2955 | //Direct reference to the Operation profile |
| 2956 | //TODO ANI side used on UNI side, not the clearest option. |
ozgecanetsia | 5c88b76 | 2021-03-23 10:27:15 +0300 | [diff] [blame] | 2957 | "MulticastOperationsProfilePointer": instID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2958 | }, |
| 2959 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2960 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2961 | meInstance, err := oFsm.pOmciCC.SendCreateMulticastSubConfigInfoVar(context.TODO(), |
| 2962 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 2963 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2964 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2965 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2966 | logger.Errorw(ctx, "CreateMulticastSubConfigInfoVar create failed, aborting UniVlanConfigFSM!", |
| 2967 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2968 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2969 | return fmt.Errorf("creatingMulticastSubscriberConfigInfo interface creationError %s, error %s", |
| 2970 | oFsm.deviceID, err) |
| 2971 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2972 | //accept also nil as (error) return value for writing to LastTx |
| 2973 | // - this avoids misinterpretation of new received OMCI messages |
| 2974 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 2975 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2976 | //verify response |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2977 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2978 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2979 | logger.Errorw(ctx, "CreateMulticastSubConfigInfo create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2980 | log.Fields{"device-id": oFsm.deviceID, "MulticastSubConfigInfo": instID}) |
| 2981 | return fmt.Errorf("creatingMulticastSubscriberConfigInfo responseError %s", oFsm.deviceID) |
| 2982 | } |
| 2983 | return nil |
| 2984 | } |
| 2985 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2986 | func (oFsm *UniVlanConfigFsm) performCreatingMulticastOperationProfile(ctx context.Context) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2987 | instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo)) |
ozgecanetsia | 5c88b76 | 2021-03-23 10:27:15 +0300 | [diff] [blame] | 2988 | if err != nil { |
ozgecanetsia | 72e1c9f | 2021-05-26 17:26:29 +0300 | [diff] [blame] | 2989 | logger.Errorw(ctx, "error generating me instance id", |
| 2990 | log.Fields{"device-id": oFsm.deviceID, "error": err}) |
ozgecanetsia | 5c88b76 | 2021-03-23 10:27:15 +0300 | [diff] [blame] | 2991 | return err |
| 2992 | } |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 2993 | logger.Debugw(ctx, "UniVlanConfigFsm create MulticastOperationProfile", |
| 2994 | log.Fields{"device-id": oFsm.deviceID, "EntityId": instID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2995 | meParams := me.ParamData{ |
| 2996 | EntityID: instID, |
| 2997 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 2998 | me.MulticastOperationsProfile_IgmpVersion: 2, |
| 2999 | me.MulticastOperationsProfile_IgmpFunction: 0, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3000 | //0 means false |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 3001 | me.MulticastOperationsProfile_ImmediateLeave: 0, |
| 3002 | me.MulticastOperationsProfile_Robustness: 2, |
| 3003 | me.MulticastOperationsProfile_QuerierIpAddress: 0, |
| 3004 | me.MulticastOperationsProfile_QueryInterval: 125, |
| 3005 | me.MulticastOperationsProfile_QueryMaxResponseTime: 100, |
| 3006 | me.MulticastOperationsProfile_LastMemberQueryInterval: 10, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3007 | //0 means false |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 3008 | me.MulticastOperationsProfile_UnauthorizedJoinRequestBehaviour: 0, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3009 | }, |
| 3010 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 3011 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3012 | meInstance, err := oFsm.pOmciCC.SendCreateMulticastOperationProfileVar(context.TODO(), |
| 3013 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 3014 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3015 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 3016 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3017 | logger.Errorw(ctx, "CreateMulticastOperationProfileVar create failed, aborting UniVlanConfigFsm!", |
| 3018 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3019 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3020 | return fmt.Errorf("createMulticastOperationProfileVar responseError %s, error %s", oFsm.deviceID, err) |
| 3021 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3022 | //accept also nil as (error) return value for writing to LastTx |
| 3023 | // - this avoids misinterpretation of new received OMCI messages |
| 3024 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 3025 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3026 | //verify response |
ozgecanetsia | 5c88b76 | 2021-03-23 10:27:15 +0300 | [diff] [blame] | 3027 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3028 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 3029 | logger.Errorw(ctx, "CreateMulticastOperationProfile create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3030 | log.Fields{"device-id": oFsm.deviceID, "MulticastOperationProfileID": instID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3031 | return fmt.Errorf("createMulticastOperationProfile responseError %s, error %s", oFsm.deviceID, err) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3032 | } |
| 3033 | return nil |
| 3034 | } |
| 3035 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 3036 | func (oFsm *UniVlanConfigFsm) performSettingMulticastOperationProfile(ctx context.Context, multicastGemPortID uint16, vlanID uint32) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3037 | instID, err := cmn.GenerateUNISideMBPCDEID(uint16(oFsm.pOnuUniPort.MacBpNo)) |
ozgecanetsia | 5c88b76 | 2021-03-23 10:27:15 +0300 | [diff] [blame] | 3038 | if err != nil { |
ozgecanetsia | 72e1c9f | 2021-05-26 17:26:29 +0300 | [diff] [blame] | 3039 | logger.Errorw(ctx, "error generating me instance id", |
| 3040 | log.Fields{"device-id": oFsm.deviceID, "error": err}) |
ozgecanetsia | 5c88b76 | 2021-03-23 10:27:15 +0300 | [diff] [blame] | 3041 | return err |
| 3042 | } |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 3043 | logger.Debugw(ctx, "UniVlanConfigFsm set MulticastOperationProfile", |
| 3044 | log.Fields{"device-id": oFsm.deviceID, "EntityId": instID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3045 | //TODO check that this is correct |
| 3046 | // Table control |
| 3047 | //setCtrl = 1 |
| 3048 | //rowPartId = 0 |
| 3049 | //test = 0 |
| 3050 | //rowKey = 0 |
| 3051 | tableCtrlStr := "0100000000000000" |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3052 | tableCtrl := cmn.AsByteSlice(tableCtrlStr) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3053 | dynamicAccessCL := make([]uint8, 24) |
| 3054 | copy(dynamicAccessCL, tableCtrl) |
| 3055 | //Multicast GemPortId |
| 3056 | binary.BigEndian.PutUint16(dynamicAccessCL[2:], multicastGemPortID) |
| 3057 | // python version waits for installation of flows, see line 723 onward of |
| 3058 | // brcm_openomci_onu_handler.py |
| 3059 | binary.BigEndian.PutUint16(dynamicAccessCL[4:], uint16(vlanID)) |
| 3060 | //Source IP all to 0 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3061 | binary.BigEndian.PutUint32(dynamicAccessCL[6:], cmn.IPToInt32(net.IPv4(0, 0, 0, 0))) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3062 | //TODO start and end are hardcoded, get from TP |
| 3063 | // Destination IP address start of range |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3064 | binary.BigEndian.PutUint32(dynamicAccessCL[10:], cmn.IPToInt32(net.IPv4(225, 0, 0, 0))) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3065 | // Destination IP address end of range |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3066 | binary.BigEndian.PutUint32(dynamicAccessCL[14:], cmn.IPToInt32(net.IPv4(239, 255, 255, 255))) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3067 | //imputed group bandwidth |
| 3068 | binary.BigEndian.PutUint16(dynamicAccessCL[18:], 0) |
| 3069 | |
| 3070 | meParams := me.ParamData{ |
| 3071 | EntityID: instID, |
| 3072 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 3073 | me.MulticastOperationsProfile_DynamicAccessControlListTable: dynamicAccessCL, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3074 | }, |
| 3075 | } |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 3076 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3077 | meInstance, err := oFsm.pOmciCC.SendSetMulticastOperationProfileVar(context.TODO(), |
| 3078 | oFsm.pDeviceHandler.GetOmciTimeout(), true, |
| 3079 | oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3080 | if err != nil { |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 3081 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3082 | logger.Errorw(ctx, "SetMulticastOperationProfileVar set failed, aborting UniVlanConfigFsm!", |
| 3083 | log.Fields{"device-id": oFsm.deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3084 | _ = oFsm.PAdaptFsm.PFsm.Event(VlanEvReset) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3085 | return fmt.Errorf("setMulticastOperationProfile responseError %s, error %s", oFsm.deviceID, err) |
| 3086 | } |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3087 | //accept also nil as (error) return value for writing to LastTx |
| 3088 | // - this avoids misinterpretation of new received OMCI messages |
| 3089 | oFsm.pLastTxMeInstance = meInstance |
Holger Hildebrandt | 0da7e6f | 2021-05-12 13:08:43 +0000 | [diff] [blame] | 3090 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3091 | //verify response |
ozgecanetsia | 5c88b76 | 2021-03-23 10:27:15 +0300 | [diff] [blame] | 3092 | err = oFsm.waitforOmciResponse(ctx) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3093 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 3094 | logger.Errorw(ctx, "CreateMulticastOperationProfile create failed, aborting AniConfig FSM!", |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3095 | log.Fields{"device-id": oFsm.deviceID, "MulticastOperationProfileID": instID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3096 | return fmt.Errorf("createMulticastOperationProfile responseError %s, error %s", oFsm.deviceID, err) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 3097 | } |
| 3098 | return nil |
| 3099 | } |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 3100 | |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 3101 | func (oFsm *UniVlanConfigFsm) createTrafficDescriptor(ctx context.Context, aMeter *of.OfpMeterConfig, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3102 | tpID uint8, uniID uint8, gemPortID uint16) error { |
| 3103 | logger.Infow(ctx, "Starting create traffic descriptor", log.Fields{"device-id": oFsm.deviceID, "uniID": uniID, "tpID": tpID}) |
| 3104 | // uniTPKey generate id to Traffic Descriptor ME. We need to create two of them. They should be unique. Because of that |
| 3105 | // I created unique TD ID by flow direction. |
| 3106 | // TODO! Traffic descriptor ME ID will check |
| 3107 | trafficDescriptorID := gemPortID |
| 3108 | if aMeter == nil { |
| 3109 | return fmt.Errorf("meter not found %s", oFsm.deviceID) |
| 3110 | } |
| 3111 | trafficShapingInfo, err := meters.GetTrafficShapingInfo(ctx, aMeter) |
| 3112 | if err != nil { |
| 3113 | logger.Errorw(ctx, "Traffic Shaping Info get failed", log.Fields{"device-id": oFsm.deviceID}) |
| 3114 | return err |
| 3115 | } |
ozgecanetsia | f5c7684 | 2021-11-18 10:43:47 +0300 | [diff] [blame] | 3116 | cir := (trafficShapingInfo.Cir + trafficShapingInfo.Gir) * 125 // kbps --> bps --> Bps |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3117 | cbs := trafficShapingInfo.Cbs |
ozgecanetsia | f5c7684 | 2021-11-18 10:43:47 +0300 | [diff] [blame] | 3118 | pir := trafficShapingInfo.Pir * 125 // kbps --> bps --> Bps |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3119 | pbs := trafficShapingInfo.Pbs |
| 3120 | |
| 3121 | logger.Infow(ctx, "cir-pir-cbs-pbs", log.Fields{"device-id": oFsm.deviceID, "cir": cir, "pir": pir, "cbs": cbs, "pbs": pbs}) |
| 3122 | meParams := me.ParamData{ |
| 3123 | EntityID: trafficDescriptorID, |
| 3124 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 3125 | me.TrafficDescriptor_Cir: cir, |
| 3126 | me.TrafficDescriptor_Pir: pir, |
| 3127 | me.TrafficDescriptor_Cbs: cbs, |
| 3128 | me.TrafficDescriptor_Pbs: pbs, |
| 3129 | me.TrafficDescriptor_ColourMode: 1, |
| 3130 | me.TrafficDescriptor_IngressColourMarking: 3, |
| 3131 | me.TrafficDescriptor_EgressColourMarking: 3, |
| 3132 | me.TrafficDescriptor_MeterType: 1, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3133 | }, |
| 3134 | } |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 3135 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3136 | meInstance, errCreateTD := oFsm.pOmciCC.SendCreateTDVar(log.WithSpanFromContext(context.TODO(), ctx), oFsm.pDeviceHandler.GetOmciTimeout(), |
| 3137 | true, oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3138 | if errCreateTD != nil { |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 3139 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3140 | logger.Errorw(ctx, "Traffic Descriptor create failed", log.Fields{"device-id": oFsm.deviceID}) |
| 3141 | return err |
| 3142 | } |
| 3143 | oFsm.pLastTxMeInstance = meInstance |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 3144 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3145 | err = oFsm.waitforOmciResponse(ctx) |
| 3146 | if err != nil { |
| 3147 | logger.Errorw(ctx, "Traffic Descriptor create failed, aborting VlanConfig FSM!", log.Fields{"device-id": oFsm.deviceID}) |
| 3148 | return err |
| 3149 | } |
| 3150 | |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 3151 | // Note: in the below request the gemport entity id is same as the gemport id and the traffic descriptor entity id is also same as gemport id |
| 3152 | err = oFsm.setTrafficDescriptorToGemPortNWCTP(ctx, gemPortID, gemPortID) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3153 | if err != nil { |
| 3154 | logger.Errorw(ctx, "Traffic Descriptor set failed to Gem Port Network CTP, aborting VlanConfig FSM!", log.Fields{"device-id": oFsm.deviceID}) |
| 3155 | return err |
| 3156 | } |
| 3157 | logger.Infow(ctx, "Set TD Info to GemPortNWCTP successfully", log.Fields{"device-id": oFsm.deviceID, "gem-port-id": gemPortID, "td-id": trafficDescriptorID}) |
| 3158 | |
| 3159 | return nil |
| 3160 | } |
| 3161 | |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 3162 | func (oFsm *UniVlanConfigFsm) setTrafficDescriptorToGemPortNWCTP(ctx context.Context, gemPortEntityID uint16, trafficDescriptorEntityID uint16) error { |
| 3163 | logger.Debugw(ctx, "Starting Set Traffic Descriptor to GemPortNWCTP", |
| 3164 | log.Fields{"device-id": oFsm.deviceID, "gem-port-entity-id": gemPortEntityID, "traffic-descriptor-entity-id": trafficDescriptorEntityID}) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3165 | meParams := me.ParamData{ |
Girish Gowdra | 09e5f21 | 2021-09-30 16:28:36 -0700 | [diff] [blame] | 3166 | EntityID: gemPortEntityID, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3167 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 3168 | me.GemPortNetworkCtp_TrafficDescriptorProfilePointerForUpstream: trafficDescriptorEntityID, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3169 | }, |
| 3170 | } |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 3171 | oFsm.mutexPLastTxMeInstance.Lock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3172 | meInstance, err := oFsm.pOmciCC.SendSetGemNCTPVar(log.WithSpanFromContext(context.TODO(), ctx), |
| 3173 | oFsm.pDeviceHandler.GetOmciTimeout(), true, oFsm.PAdaptFsm.CommChan, meParams) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3174 | if err != nil { |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 3175 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3176 | logger.Errorw(ctx, "GemNCTP set failed", log.Fields{"device-id": oFsm.deviceID}) |
| 3177 | return err |
| 3178 | } |
| 3179 | oFsm.pLastTxMeInstance = meInstance |
Girish Gowdra | 754ffb1 | 2021-06-30 16:30:12 -0700 | [diff] [blame] | 3180 | oFsm.mutexPLastTxMeInstance.Unlock() |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 3181 | err = oFsm.waitforOmciResponse(ctx) |
| 3182 | if err != nil { |
| 3183 | logger.Errorw(ctx, "Upstream Traffic Descriptor set failed, aborting VlanConfig FSM!", log.Fields{"device-id": oFsm.deviceID}) |
| 3184 | return err |
| 3185 | } |
| 3186 | return nil |
| 3187 | } |
| 3188 | |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 3189 | // IsFlowRemovePending returns true if there are pending flows to remove, else false. |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 3190 | func (oFsm *UniVlanConfigFsm) IsFlowRemovePending(ctx context.Context, aFlowDeleteChannel chan<- bool) bool { |
| 3191 | if oFsm == nil { |
| 3192 | logger.Error(ctx, "no valid UniVlanConfigFsm!") |
| 3193 | return false |
| 3194 | } |
mpagenko | bb47bc2 | 2021-04-20 13:29:09 +0000 | [diff] [blame] | 3195 | oFsm.mutexFlowParams.Lock() |
| 3196 | defer oFsm.mutexFlowParams.Unlock() |
| 3197 | if len(oFsm.uniRemoveFlowsSlice) > 0 { |
| 3198 | //flow removal is still ongoing/pending |
| 3199 | oFsm.signalOnFlowDelete = true |
| 3200 | oFsm.flowDeleteChannel = aFlowDeleteChannel |
| 3201 | return true |
| 3202 | } |
| 3203 | return false |
Girish Gowdra | 26a4092 | 2021-01-29 17:14:34 -0800 | [diff] [blame] | 3204 | } |
Holger Hildebrandt | 968eb8f | 2021-09-17 07:41:12 +0000 | [diff] [blame] | 3205 | |
| 3206 | func (oFsm *UniVlanConfigFsm) reconcileVlanFilterList(ctx context.Context, aSetVid uint16) { |
| 3207 | // VOL-4342 - reconcile vlanFilterList[] for possible later flow removal |
| 3208 | if aSetVid == uint16(of.OfpVlanId_OFPVID_PRESENT) { |
| 3209 | logger.Debugw(ctx, "reconciling - transparent setup: no VTFD config was required", |
| 3210 | log.Fields{"device-id": oFsm.deviceID}) |
| 3211 | } else { |
| 3212 | oFsm.vlanFilterList[oFsm.numVlanFilterEntries] = aSetVid |
| 3213 | logger.Debugw(ctx, "reconciling - Vid of VTFD stored in list", log.Fields{ |
| 3214 | "index": oFsm.numVlanFilterEntries, |
| 3215 | "vid": strconv.FormatInt(int64(oFsm.vlanFilterList[oFsm.numVlanFilterEntries]), 16), |
| 3216 | "device-id": oFsm.deviceID}) |
| 3217 | oFsm.numVlanFilterEntries++ |
| 3218 | } |
| 3219 | } |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 3220 | |
Holger Hildebrandt | c192bc4 | 2021-10-28 14:38:31 +0000 | [diff] [blame] | 3221 | // pushReponseOnFlowResponseChannel pushes response on the response channel if available |
| 3222 | func (oFsm *UniVlanConfigFsm) pushReponseOnFlowResponseChannel(ctx context.Context, respChan *chan error, err error) { |
Girish Gowdra | e95687a | 2021-09-08 16:30:58 -0700 | [diff] [blame] | 3223 | if respChan != nil { |
| 3224 | // Do it in a non blocking fashion, so that in case the flow handler routine has shutdown for any reason, we do not block here |
| 3225 | select { |
| 3226 | case *respChan <- err: |
| 3227 | logger.Debugw(ctx, "submitted-response-for-flow", log.Fields{"device-id": oFsm.deviceID, "err": err}) |
| 3228 | default: |
| 3229 | } |
| 3230 | } |
| 3231 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 3232 | |
| 3233 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 3234 | func (oFsm *UniVlanConfigFsm) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 3235 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 3236 | oFsm.pDeviceHandler = nil |
| 3237 | oFsm.pOnuDeviceEntry = nil |
| 3238 | oFsm.pOmciCC = nil |
| 3239 | } |