manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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 | |
Scott Baker | dbd960e | 2020-02-28 08:57:51 -0800 | [diff] [blame] | 17 | //Package core provides the utility for olt devices, flows and statistics |
| 18 | package core |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "context" |
Matteo Scandolo | 6056e82 | 2019-11-13 14:05:29 -0800 | [diff] [blame] | 22 | "encoding/hex" |
Girish Gowdra | cefae19 | 2020-03-19 18:14:10 -0700 | [diff] [blame] | 23 | "errors" |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 24 | "fmt" |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 25 | "strconv" |
serkant.uluderya | 4aff186 | 2020-09-17 23:35:26 +0300 | [diff] [blame] | 26 | "strings" |
| 27 | "sync" |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 28 | "time" |
serkant.uluderya | 4aff186 | 2020-09-17 23:35:26 +0300 | [diff] [blame] | 29 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 30 | "github.com/opencord/voltha-lib-go/v7/pkg/meters" |
Mahir Gunyel | 199570a | 2021-07-04 15:39:36 -0700 | [diff] [blame] | 31 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 32 | "github.com/opencord/voltha-lib-go/v7/pkg/flows" |
| 33 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 34 | plt "github.com/opencord/voltha-lib-go/v7/pkg/platform" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 35 | tp "github.com/opencord/voltha-lib-go/v7/pkg/techprofile" |
Scott Baker | dbd960e | 2020-02-28 08:57:51 -0800 | [diff] [blame] | 36 | rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 37 | "github.com/opencord/voltha-protos/v5/go/common" |
| 38 | ic "github.com/opencord/voltha-protos/v5/go/inter_container" |
| 39 | ofp "github.com/opencord/voltha-protos/v5/go/openflow_13" |
| 40 | openoltpb2 "github.com/opencord/voltha-protos/v5/go/openolt" |
| 41 | tp_pb "github.com/opencord/voltha-protos/v5/go/tech_profile" |
| 42 | "github.com/opencord/voltha-protos/v5/go/voltha" |
Chaitrashree G S | 579fe73 | 2019-08-20 20:50:47 -0400 | [diff] [blame] | 43 | |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 44 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors" |
Daniele Rossi | 22db98e | 2019-07-11 11:50:00 +0000 | [diff] [blame] | 45 | "google.golang.org/grpc/codes" |
| 46 | "google.golang.org/grpc/status" |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 47 | ) |
| 48 | |
| 49 | const ( |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 50 | //IPProtoDhcp flow category |
| 51 | IPProtoDhcp = 17 |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 52 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 53 | //IgmpProto proto value |
| 54 | IgmpProto = 2 |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 55 | |
| 56 | //EapEthType eapethtype value |
| 57 | EapEthType = 0x888e |
| 58 | //LldpEthType lldp ethtype value |
| 59 | LldpEthType = 0x88cc |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 60 | //IPv4EthType IPv4 ethernet type value |
| 61 | IPv4EthType = 0x800 |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 62 | //PPPoEDEthType PPPoE discovery ethernet type value |
| 63 | PPPoEDEthType = 0x8863 |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 64 | |
Andrea Campanella | 7acc0b9 | 2020-02-14 09:20:49 +0100 | [diff] [blame] | 65 | //ReservedVlan Transparent Vlan (Masked Vlan, VLAN_ANY in ONOS Flows) |
| 66 | ReservedVlan = 4096 |
Harsh Awasthi | ea45af7 | 2019-08-26 02:39:00 -0400 | [diff] [blame] | 67 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 68 | //DefaultMgmtVlan default vlan value |
| 69 | DefaultMgmtVlan = 4091 |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 70 | |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 71 | // Openolt Flow |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 72 | |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 73 | //Upstream constant |
| 74 | Upstream = "upstream" |
| 75 | //Downstream constant |
| 76 | Downstream = "downstream" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 77 | //Multicast constant |
| 78 | Multicast = "multicast" |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 79 | //PacketTagType constant |
| 80 | PacketTagType = "pkt_tag_type" |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 81 | //Untagged constant |
| 82 | Untagged = "untagged" |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 83 | //SingleTag constant |
| 84 | SingleTag = "single_tag" |
| 85 | //DoubleTag constant |
| 86 | DoubleTag = "double_tag" |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 87 | |
| 88 | // classifierInfo |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 89 | |
| 90 | //EthType constant |
| 91 | EthType = "eth_type" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 92 | //EthDst constant |
| 93 | EthDst = "eth_dst" |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 94 | //TPID constant |
| 95 | TPID = "tpid" |
| 96 | //IPProto constant |
| 97 | IPProto = "ip_proto" |
| 98 | //InPort constant |
| 99 | InPort = "in_port" |
| 100 | //VlanVid constant |
| 101 | VlanVid = "vlan_vid" |
| 102 | //VlanPcp constant |
| 103 | VlanPcp = "vlan_pcp" |
| 104 | |
| 105 | //UDPDst constant |
| 106 | UDPDst = "udp_dst" |
| 107 | //UDPSrc constant |
| 108 | UDPSrc = "udp_src" |
| 109 | //Ipv4Dst constant |
| 110 | Ipv4Dst = "ipv4_dst" |
| 111 | //Ipv4Src constant |
| 112 | Ipv4Src = "ipv4_src" |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 113 | //Metadata constant |
| 114 | Metadata = "metadata" |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 115 | //TunnelID constant |
| 116 | TunnelID = "tunnel_id" |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 117 | //Output constant |
| 118 | Output = "output" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 119 | //GroupID constant |
| 120 | GroupID = "group_id" |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 121 | // Actions |
| 122 | |
| 123 | //PopVlan constant |
| 124 | PopVlan = "pop_vlan" |
| 125 | //PushVlan constant |
| 126 | PushVlan = "push_vlan" |
| 127 | //TrapToHost constant |
| 128 | TrapToHost = "trap_to_host" |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 129 | //MaxMeterBand constant |
| 130 | MaxMeterBand = 2 |
| 131 | //VlanPCPMask contant |
| 132 | VlanPCPMask = 0xFF |
| 133 | //VlanvIDMask constant |
| 134 | VlanvIDMask = 0xFFF |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 135 | //IntfID constant |
| 136 | IntfID = "intfId" |
| 137 | //OnuID constant |
| 138 | OnuID = "onuId" |
| 139 | //UniID constant |
| 140 | UniID = "uniId" |
| 141 | //PortNo constant |
| 142 | PortNo = "portNo" |
| 143 | //AllocID constant |
| 144 | AllocID = "allocId" |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 145 | //GemID constant |
| 146 | GemID = "gemId" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 147 | |
| 148 | //NoneOnuID constant |
| 149 | NoneOnuID = -1 |
| 150 | //NoneUniID constant |
| 151 | NoneUniID = -1 |
Matteo Scandolo | 738c52a | 2020-08-03 11:14:22 -0700 | [diff] [blame] | 152 | |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 153 | // Max number of flows that can be queued per ONU |
| 154 | maxConcurrentFlowsPerOnu = 20 |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 155 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 156 | bitMapPrefix = "0b" |
| 157 | pbit1 = '1' |
| 158 | ) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 159 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 160 | type schedQueue struct { |
| 161 | direction tp_pb.Direction |
| 162 | intfID uint32 |
| 163 | onuID uint32 |
| 164 | uniID uint32 |
| 165 | tpID uint32 |
| 166 | uniPort uint32 |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 167 | tpInst interface{} |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 168 | meterID uint32 |
| 169 | flowMetadata *voltha.FlowMetadata |
| 170 | } |
| 171 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 172 | type flowContext struct { |
| 173 | intfID uint32 |
| 174 | onuID uint32 |
| 175 | uniID uint32 |
| 176 | portNo uint32 |
| 177 | classifier map[string]interface{} |
| 178 | action map[string]interface{} |
| 179 | logicalFlow *ofp.OfpFlowStats |
| 180 | allocID uint32 |
| 181 | gemPortID uint32 |
| 182 | tpID uint32 |
| 183 | pbitToGem map[uint32]uint32 |
| 184 | gemToAes map[uint32]bool |
| 185 | } |
| 186 | |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 187 | // This control block is created per flow add/remove and pushed on the incomingFlows channel slice |
| 188 | // The flowControlBlock is then picked by the perOnuFlowHandlerRoutine for further processing. |
| 189 | // There is on perOnuFlowHandlerRoutine routine per ONU that constantly monitors for any incoming |
| 190 | // flow and processes it serially |
| 191 | type flowControlBlock struct { |
| 192 | ctx context.Context // Flow handler context |
| 193 | addFlow bool // if true flow to be added, else removed |
| 194 | flow *voltha.OfpFlowStats // Flow message |
| 195 | flowMetadata *voltha.FlowMetadata // FlowMetadata that contains flow meter information. This can be nil for Flow remove |
| 196 | errChan *chan error // channel to report the Flow handling error |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 199 | //OpenOltFlowMgr creates the Structure of OpenOltFlowMgr obj |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 200 | type OpenOltFlowMgr struct { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 201 | ponPortIdx uint32 // Pon Port this FlowManager is responsible for |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 202 | techprofile tp.TechProfileIf |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 203 | deviceHandler *DeviceHandler |
| 204 | grpMgr *OpenOltGroupMgr |
| 205 | resourceMgr *rsrcMgr.OpenOltResourceMgr |
| 206 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 207 | gemToFlowIDs map[uint32][]uint64 // gem port id to flow ids |
| 208 | gemToFlowIDsKey sync.RWMutex // lock to be used to access the gemToFlowIDs map |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 209 | |
| 210 | packetInGemPort map[rsrcMgr.PacketInInfoKey]uint32 //packet in gem port local cache |
| 211 | packetInGemPortLock sync.RWMutex |
| 212 | |
Matteo Scandolo | 2c0d274 | 2020-06-10 11:28:42 -0700 | [diff] [blame] | 213 | // TODO create a type rsrcMgr.OnuGemInfos to be used instead of []rsrcMgr.OnuGemInfo |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 214 | onuGemInfoMap map[uint32]*rsrcMgr.OnuGemInfo //onu, gem and uni info local cache -> map of onuID to OnuGemInfo |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 215 | // We need to have a global lock on the onuGemInfo map |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 216 | onuGemInfoLock sync.RWMutex |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 217 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 218 | flowIDToGems map[uint64][]uint32 |
| 219 | flowIDToGemsLock sync.RWMutex |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 220 | |
| 221 | // Slice of channels. Each channel in slice, index by ONU ID, queues flows per ONU. |
| 222 | // A go routine per ONU, waits on the unique channel (indexed by ONU ID) for incoming flows (add/remove) |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 223 | incomingFlows []chan flowControlBlock |
| 224 | stopFlowHandlerRoutine []chan bool |
| 225 | flowHandlerRoutineActive []bool |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 226 | } |
| 227 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 228 | //NewFlowManager creates OpenOltFlowMgr object and initializes the parameters |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 229 | func NewFlowManager(ctx context.Context, dh *DeviceHandler, rMgr *rsrcMgr.OpenOltResourceMgr, grpMgr *OpenOltGroupMgr, ponPortIdx uint32) *OpenOltFlowMgr { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 230 | logger.Infow(ctx, "initializing-flow-manager", log.Fields{"device-id": dh.device.Id}) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 231 | var flowMgr OpenOltFlowMgr |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 232 | var err error |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 233 | |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 234 | flowMgr.deviceHandler = dh |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 235 | flowMgr.ponPortIdx = ponPortIdx |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 236 | flowMgr.grpMgr = grpMgr |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 237 | flowMgr.resourceMgr = rMgr |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 238 | if err = flowMgr.populateTechProfileForCurrentPonPort(ctx); err != nil { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 239 | logger.Errorw(ctx, "error-while-populating-tech-profile-mgr", log.Fields{"err": err}) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 240 | return nil |
| 241 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 242 | flowMgr.gemToFlowIDs = make(map[uint32][]uint64) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 243 | flowMgr.packetInGemPort = make(map[rsrcMgr.PacketInInfoKey]uint32) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 244 | flowMgr.flowIDToGems = make(map[uint64][]uint32) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 245 | |
| 246 | // Create a slice of buffered channels for handling concurrent flows per ONU. |
| 247 | // The additional entry (+1) is to handle the NNI trap flows on a separate channel from individual ONUs channel |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 248 | flowMgr.incomingFlows = make([]chan flowControlBlock, plt.MaxOnusPerPon+1) |
| 249 | flowMgr.stopFlowHandlerRoutine = make([]chan bool, plt.MaxOnusPerPon+1) |
| 250 | flowMgr.flowHandlerRoutineActive = make([]bool, plt.MaxOnusPerPon+1) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 251 | for i := range flowMgr.incomingFlows { |
| 252 | flowMgr.incomingFlows[i] = make(chan flowControlBlock, maxConcurrentFlowsPerOnu) |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 253 | flowMgr.stopFlowHandlerRoutine[i] = make(chan bool, 1) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 254 | // Spin up a go routine to handling incoming flows (add/remove). |
| 255 | // There will be on go routine per ONU. |
| 256 | // This routine will be blocked on the flowMgr.incomingFlows[onu-id] channel for incoming flows. |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 257 | flowMgr.flowHandlerRoutineActive[i] = true |
| 258 | go flowMgr.perOnuFlowHandlerRoutine(i, flowMgr.incomingFlows[i], flowMgr.stopFlowHandlerRoutine[i]) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 259 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 260 | flowMgr.onuGemInfoMap = make(map[uint32]*rsrcMgr.OnuGemInfo) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 261 | //Load the onugem info cache from kv store on flowmanager start |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 262 | onuIDStart := flowMgr.deviceHandler.deviceInfo.OnuIdStart |
| 263 | onuIDEnd := flowMgr.deviceHandler.deviceInfo.OnuIdEnd |
| 264 | for onuID := onuIDStart; onuID <= onuIDEnd; onuID++ { |
| 265 | // check for a valid serial number in onuGem as GetOnuGemInfo can return nil error in case of nothing found in the path. |
Gamze Abaka | 6f345c1 | 2021-09-08 01:14:33 +0000 | [diff] [blame] | 266 | onugem, err := rMgr.GetOnuGemInfo(ctx, ponPortIdx, onuID) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 267 | if err == nil && onugem != nil && onugem.SerialNumber != "" { |
| 268 | flowMgr.onuGemInfoMap[onuID] = onugem |
| 269 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 270 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 271 | |
| 272 | //Load flowID list per gem map And gemIDs per flow per interface from the kvstore. |
| 273 | flowMgr.loadFlowIDsForGemAndGemIDsForFlow(ctx) |
| 274 | |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 275 | //load interface to multicast queue map from kv store |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 276 | flowMgr.grpMgr.LoadInterfaceToMulticastQueueMap(ctx) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 277 | logger.Info(ctx, "initialization-of-flow-manager-success") |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 278 | return &flowMgr |
| 279 | } |
| 280 | |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 281 | func (f *OpenOltFlowMgr) registerFlow(ctx context.Context, flowFromCore *ofp.OfpFlowStats, deviceFlow *openoltpb2.Flow) error { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 282 | if !deviceFlow.ReplicateFlow && deviceFlow.GemportId > 0 { |
| 283 | // Flow is not replicated in this case, we need to register the flow for a single gem-port |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 284 | return f.registerFlowIDForGemAndGemIDForFlow(ctx, uint32(deviceFlow.AccessIntfId), uint32(deviceFlow.GemportId), flowFromCore) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 285 | } else if deviceFlow.ReplicateFlow && len(deviceFlow.PbitToGemport) > 0 { |
| 286 | // Flow is replicated in this case. We need to register the flow for all the gem-ports it is replicated to. |
| 287 | for _, gemPort := range deviceFlow.PbitToGemport { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 288 | if err := f.registerFlowIDForGemAndGemIDForFlow(ctx, uint32(deviceFlow.AccessIntfId), gemPort, flowFromCore); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 289 | return err |
| 290 | } |
Matteo Scandolo | 738c52a | 2020-08-03 11:14:22 -0700 | [diff] [blame] | 291 | } |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 292 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 293 | return nil |
| 294 | } |
| 295 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 296 | func (f *OpenOltFlowMgr) registerFlowIDForGemAndGemIDForFlow(ctx context.Context, accessIntfID uint32, gemPortID uint32, flowFromCore *ofp.OfpFlowStats) error { |
| 297 | // update gem->flows map |
| 298 | f.gemToFlowIDsKey.Lock() |
| 299 | flowIDList, ok := f.gemToFlowIDs[gemPortID] |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 300 | if !ok { |
| 301 | flowIDList = []uint64{flowFromCore.Id} |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 302 | } else { |
| 303 | flowIDList = appendUnique64bit(flowIDList, flowFromCore.Id) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 304 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 305 | f.gemToFlowIDs[gemPortID] = flowIDList |
| 306 | f.gemToFlowIDsKey.Unlock() |
| 307 | |
| 308 | // update flow->gems map |
| 309 | f.flowIDToGemsLock.Lock() |
| 310 | if _, ok := f.flowIDToGems[flowFromCore.Id]; !ok { |
| 311 | f.flowIDToGems[flowFromCore.Id] = []uint32{gemPortID} |
| 312 | } else { |
| 313 | f.flowIDToGems[flowFromCore.Id] = appendUnique32bit(f.flowIDToGems[flowFromCore.Id], gemPortID) |
| 314 | } |
| 315 | f.flowIDToGemsLock.Unlock() |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 316 | |
| 317 | // update the flowids for a gem to the KVstore |
| 318 | return f.resourceMgr.UpdateFlowIDsForGem(ctx, accessIntfID, gemPortID, flowIDList) |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 319 | } |
| 320 | |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 321 | func (f *OpenOltFlowMgr) processAddFlow(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, portNo uint32, |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 322 | classifierInfo map[string]interface{}, actionInfo map[string]interface{}, flow *ofp.OfpFlowStats, TpID uint32, |
Andrea Campanella | bfe0843 | 2020-09-11 17:07:03 +0200 | [diff] [blame] | 323 | UsMeterID uint32, DsMeterID uint32, flowMetadata *voltha.FlowMetadata) error { |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 324 | var allocID uint32 |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 325 | var gemPorts []uint32 |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 326 | var TpInst interface{} |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 327 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 328 | logger.Infow(ctx, "dividing-flow", log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 329 | "device-id": f.deviceHandler.device.Id, |
| 330 | "intf-id": intfID, |
| 331 | "onu-id": onuID, |
| 332 | "uni-id": uniID, |
| 333 | "port-no": portNo, |
Matteo Scandolo | d625b4c | 2020-04-02 16:16:01 -0700 | [diff] [blame] | 334 | "classifier": classifierInfo, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 335 | "action": actionInfo, |
| 336 | "usmeter-iD": UsMeterID, |
| 337 | "dsmeter-iD": DsMeterID, |
| 338 | "tp-id": TpID}) |
Matt Jeanneret | 7719961 | 2019-07-26 18:08:35 -0400 | [diff] [blame] | 339 | // only create tcont/gemports if there is actually an onu id. otherwise BAL throws an error. Usually this |
| 340 | // is because the flow is an NNI flow and there would be no onu resources associated with it |
| 341 | // TODO: properly deal with NNI flows |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 342 | if onuID == 0 { |
Andrea Campanella | bfe0843 | 2020-09-11 17:07:03 +0200 | [diff] [blame] | 343 | cause := "no-onu-id-for-flow" |
| 344 | fields := log.Fields{ |
| 345 | "onu": onuID, |
| 346 | "port-no": portNo, |
| 347 | "classifer": classifierInfo, |
| 348 | "action": actionInfo, |
| 349 | "device-id": f.deviceHandler.device.Id} |
| 350 | logger.Errorw(ctx, cause, fields) |
| 351 | return olterrors.NewErrNotFound(cause, fields, nil) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 352 | } |
| 353 | |
Matteo Scandolo | d625b4c | 2020-04-02 16:16:01 -0700 | [diff] [blame] | 354 | uni := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID)) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 355 | logger.Debugw(ctx, "uni-port-path", log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 356 | "uni": uni, |
| 357 | "device-id": f.deviceHandler.device.Id}) |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 358 | |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 359 | logger.Debugw(ctx, "dividing-flow-create-tcont-gem-ports", log.Fields{ |
| 360 | "device-id": f.deviceHandler.device.Id, |
| 361 | "intf-id": intfID, |
| 362 | "onu-id": onuID, |
| 363 | "uni-id": uniID, |
| 364 | "port-no": portNo, |
| 365 | "classifier": classifierInfo, |
| 366 | "action": actionInfo, |
| 367 | "usmeter-id": UsMeterID, |
| 368 | "dsmeter-id": DsMeterID, |
| 369 | "tp-id": TpID}) |
| 370 | allocID, gemPorts, TpInst = f.createTcontGemports(ctx, intfID, onuID, uniID, uni, portNo, TpID, UsMeterID, DsMeterID, flowMetadata) |
| 371 | if allocID == 0 || gemPorts == nil || TpInst == nil { |
| 372 | logger.Error(ctx, "alloc-id-gem-ports-tp-unavailable") |
| 373 | return olterrors.NewErrNotFound( |
| 374 | "alloc-id-gem-ports-tp-unavailable", |
| 375 | nil, nil) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 376 | } |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 377 | args := make(map[string]uint32) |
| 378 | args[IntfID] = intfID |
| 379 | args[OnuID] = onuID |
| 380 | args[UniID] = uniID |
| 381 | args[PortNo] = portNo |
| 382 | args[AllocID] = allocID |
| 383 | |
| 384 | /* Flows can be added specific to gemport if p-bits are received. |
| 385 | * If no pbit mentioned then adding flows for all gemports |
| 386 | */ |
| 387 | f.checkAndAddFlow(ctx, args, classifierInfo, actionInfo, flow, TpInst, gemPorts, TpID, uni) |
| 388 | |
Andrea Campanella | bfe0843 | 2020-09-11 17:07:03 +0200 | [diff] [blame] | 389 | return nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 390 | } |
| 391 | |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 392 | // CreateSchedulerQueues creates traffic schedulers on the device with the given scheduler configuration and traffic shaping info |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 393 | func (f *OpenOltFlowMgr) CreateSchedulerQueues(ctx context.Context, sq schedQueue) error { |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 394 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 395 | logger.Debugw(ctx, "CreateSchedulerQueues", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 396 | log.Fields{"dir": sq.direction, |
| 397 | "intf-id": sq.intfID, |
| 398 | "onu-id": sq.onuID, |
| 399 | "uni-id": sq.uniID, |
| 400 | "tp-id": sq.tpID, |
| 401 | "meter-id": sq.meterID, |
| 402 | "tp-inst": sq.tpInst, |
| 403 | "flowmetadata": sq.flowMetadata, |
| 404 | "device-id": f.deviceHandler.device.Id}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 405 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 406 | Direction, err := verifyMeterIDAndGetDirection(sq.meterID, sq.direction) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 407 | if err != nil { |
| 408 | return err |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | /* Lets make a simple assumption that if the meter-id is present on the KV store, |
| 412 | * then the scheduler and queues configuration is applied on the OLT device |
| 413 | * in the given direction. |
| 414 | */ |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 415 | |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 416 | var SchedCfg *tp_pb.SchedulerConfig |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 417 | meterInfo, err := f.resourceMgr.GetMeterInfoForOnu(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 418 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 419 | return olterrors.NewErrNotFound("meter", |
| 420 | log.Fields{"intf-id": sq.intfID, |
| 421 | "onu-id": sq.onuID, |
| 422 | "uni-id": sq.uniID, |
| 423 | "device-id": f.deviceHandler.device.Id}, err) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 424 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 425 | |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 426 | if meterInfo != nil { |
| 427 | logger.Debugw(ctx, "scheduler-already-created-for-upstream", log.Fields{"device-id": f.deviceHandler.device.Id, "meter-id": sq.meterID}) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 428 | if meterInfo.MeterID == sq.meterID { |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 429 | if err := f.resourceMgr.HandleMeterInfoRefCntUpdate(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID, true); err != nil { |
| 430 | return err |
| 431 | } |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 432 | return nil |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 433 | } |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 434 | return olterrors.NewErrInvalidValue(log.Fields{ |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 435 | "unsupported": "meter-id", |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 436 | "kv-store-meter-id": meterInfo.MeterID, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 437 | "meter-id-in-flow": sq.meterID, |
| 438 | "device-id": f.deviceHandler.device.Id}, nil) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 439 | } |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 440 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 441 | logger.Debugw(ctx, "meter-does-not-exist-creating-new", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 442 | log.Fields{ |
| 443 | "meter-id": sq.meterID, |
| 444 | "direction": Direction, |
| 445 | "device-id": f.deviceHandler.device.Id}) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 446 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 447 | if sq.direction == tp_pb.Direction_UPSTREAM { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 448 | SchedCfg = f.techprofile.GetUsScheduler(sq.tpInst.(*tp_pb.TechProfileInstance)) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 449 | } else if sq.direction == tp_pb.Direction_DOWNSTREAM { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 450 | SchedCfg = f.techprofile.GetDsScheduler(sq.tpInst.(*tp_pb.TechProfileInstance)) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 453 | found := false |
| 454 | meterInfo = &rsrcMgr.MeterInfo{} |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 455 | if sq.flowMetadata != nil { |
| 456 | for _, meter := range sq.flowMetadata.Meters { |
| 457 | if sq.meterID == meter.MeterId { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 458 | meterInfo.MeterID = meter.MeterId |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 459 | meterInfo.RefCnt = 1 // initialize it to 1, since this is the first flow that referenced the meter id. |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 460 | logger.Debugw(ctx, "found-meter-config-from-flowmetadata", |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 461 | log.Fields{"meter": meter, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 462 | "device-id": f.deviceHandler.device.Id}) |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 463 | found = true |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 464 | break |
| 465 | } |
| 466 | } |
| 467 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 468 | logger.Errorw(ctx, "flow-metadata-not-present-in-flow", log.Fields{"device-id": f.deviceHandler.device.Id}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 469 | } |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 470 | if !found { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 471 | return olterrors.NewErrNotFound("meterbands", log.Fields{ |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 472 | "reason": "Could-not-get-meterbands-from-flowMetadata", |
| 473 | "flow-metadata": sq.flowMetadata, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 474 | "meter-id": sq.meterID, |
| 475 | "device-id": f.deviceHandler.device.Id}, nil) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 476 | } |
Gamze Abaka | 0117442 | 2021-03-10 06:55:27 +0000 | [diff] [blame] | 477 | |
| 478 | var TrafficShaping *tp_pb.TrafficShapingInfo |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 479 | if TrafficShaping, err = meters.GetTrafficShapingInfo(ctx, sq.flowMetadata.Meters[0]); err != nil { |
Gamze Abaka | 0117442 | 2021-03-10 06:55:27 +0000 | [diff] [blame] | 480 | return olterrors.NewErrInvalidValue(log.Fields{ |
| 481 | "reason": "invalid-meter-config", |
| 482 | "meter-id": sq.meterID, |
| 483 | "device-id": f.deviceHandler.device.Id}, nil) |
| 484 | } |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 485 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 486 | TrafficSched := []*tp_pb.TrafficScheduler{f.techprofile.GetTrafficScheduler(sq.tpInst.(*tp_pb.TechProfileInstance), SchedCfg, TrafficShaping)} |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 487 | TrafficSched[0].TechProfileId = sq.tpID |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 488 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 489 | if err := f.pushSchedulerQueuesToDevice(ctx, sq, TrafficSched); err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 490 | return olterrors.NewErrAdapter("failure-pushing-traffic-scheduler-and-queues-to-device", |
| 491 | log.Fields{"intf-id": sq.intfID, |
| 492 | "direction": sq.direction, |
| 493 | "device-id": f.deviceHandler.device.Id}, err) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 494 | } |
| 495 | |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 496 | /* After we successfully applied the scheduler configuration on the OLT device, |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 497 | * store the meter id on the KV store, for further reference. |
| 498 | */ |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 499 | if err := f.resourceMgr.StoreMeterInfoForOnu(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID, meterInfo); err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 500 | return olterrors.NewErrAdapter("failed-updating-meter-id", |
| 501 | log.Fields{"onu-id": sq.onuID, |
| 502 | "meter-id": sq.meterID, |
| 503 | "device-id": f.deviceHandler.device.Id}, err) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 504 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 505 | logger.Infow(ctx, "updated-meter-info-into-kv-store-successfully", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 506 | log.Fields{"direction": Direction, |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 507 | "meter-info": meterInfo, |
| 508 | "device-id": f.deviceHandler.device.Id}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 509 | return nil |
| 510 | } |
| 511 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 512 | func (f *OpenOltFlowMgr) pushSchedulerQueuesToDevice(ctx context.Context, sq schedQueue, TrafficSched []*tp_pb.TrafficScheduler) error { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 513 | trafficQueues, err := f.techprofile.GetTrafficQueues(ctx, sq.tpInst.(*tp_pb.TechProfileInstance), sq.direction) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 514 | |
| 515 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 516 | return olterrors.NewErrAdapter("unable-to-construct-traffic-queue-configuration", |
| 517 | log.Fields{"intf-id": sq.intfID, |
| 518 | "direction": sq.direction, |
| 519 | "device-id": f.deviceHandler.device.Id}, err) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 522 | if allocExists := f.isAllocUsedByAnotherUNI(ctx, sq); !allocExists { |
| 523 | logger.Debugw(ctx, "sending-traffic-scheduler-create-to-device", |
| 524 | log.Fields{ |
| 525 | "direction": sq.direction, |
| 526 | "TrafficScheds": TrafficSched, |
| 527 | "device-id": f.deviceHandler.device.Id, |
| 528 | "intfID": sq.intfID, |
| 529 | "onuID": sq.onuID, |
| 530 | "uniID": sq.uniID}) |
| 531 | if _, err := f.deviceHandler.Client.CreateTrafficSchedulers(ctx, &tp_pb.TrafficSchedulers{ |
| 532 | IntfId: sq.intfID, OnuId: sq.onuID, |
| 533 | UniId: sq.uniID, PortNo: sq.uniPort, |
| 534 | TrafficScheds: TrafficSched}); err != nil { |
| 535 | return olterrors.NewErrAdapter("failed-to-create-traffic-schedulers-in-device", log.Fields{"TrafficScheds": TrafficSched}, err) |
| 536 | } |
| 537 | logger.Infow(ctx, "successfully-created-traffic-schedulers", log.Fields{ |
| 538 | "direction": sq.direction, |
| 539 | "traffic-queues": trafficQueues, |
| 540 | "device-id": f.deviceHandler.device.Id}) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | // On receiving the CreateTrafficQueues request, the driver should create corresponding |
| 544 | // downstream queues. |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 545 | logger.Debugw(ctx, "sending-traffic-queues-create-to-device", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 546 | log.Fields{"direction": sq.direction, |
| 547 | "traffic-queues": trafficQueues, |
| 548 | "device-id": f.deviceHandler.device.Id}) |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 549 | if _, err := f.deviceHandler.Client.CreateTrafficQueues(ctx, |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 550 | &tp_pb.TrafficQueues{IntfId: sq.intfID, OnuId: sq.onuID, |
| 551 | UniId: sq.uniID, PortNo: sq.uniPort, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 552 | TrafficQueues: trafficQueues, |
| 553 | TechProfileId: TrafficSched[0].TechProfileId}); err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 554 | return olterrors.NewErrAdapter("failed-to-create-traffic-queues-in-device", log.Fields{"traffic-queues": trafficQueues}, err) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 555 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 556 | logger.Infow(ctx, "successfully-created-traffic-schedulers", log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 557 | "direction": sq.direction, |
| 558 | "traffic-queues": trafficQueues, |
| 559 | "device-id": f.deviceHandler.device.Id}) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 560 | |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 561 | if sq.direction == tp_pb.Direction_DOWNSTREAM { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 562 | multicastTrafficQueues := f.techprofile.GetMulticastTrafficQueues(ctx, sq.tpInst.(*tp_pb.TechProfileInstance)) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 563 | if len(multicastTrafficQueues) > 0 { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 564 | if _, present := f.grpMgr.GetInterfaceToMcastQueueMap(sq.intfID); !present { //assumed that there is only one queue per PON for the multicast service |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 565 | //the default queue with multicastQueuePerPonPort.Priority per a pon interface is used for multicast service |
| 566 | //just put it in interfaceToMcastQueueMap to use for building group members |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 567 | logger.Debugw(ctx, "multicast-traffic-queues", log.Fields{"device-id": f.deviceHandler.device.Id}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 568 | multicastQueuePerPonPort := multicastTrafficQueues[0] |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 569 | val := &QueueInfoBrief{ |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 570 | gemPortID: multicastQueuePerPonPort.GemportId, |
| 571 | servicePriority: multicastQueuePerPonPort.Priority, |
| 572 | } |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 573 | f.grpMgr.UpdateInterfaceToMcastQueueMap(sq.intfID, val) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 574 | //also store the queue info in kv store |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 575 | if err := f.resourceMgr.AddMcastQueueForIntf(ctx, sq.intfID, multicastQueuePerPonPort.GemportId, multicastQueuePerPonPort.Priority); err != nil { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 576 | logger.Errorw(ctx, "failed-to-add-mcast-queue", log.Fields{"err": err}) |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 577 | return err |
| 578 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 579 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 580 | logger.Infow(ctx, "multicast-queues-successfully-updated", log.Fields{"device-id": f.deviceHandler.device.Id}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 581 | } |
| 582 | } |
| 583 | } |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 584 | return nil |
| 585 | } |
| 586 | |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 587 | // RemoveSchedulerQueues removes the traffic schedulers from the device based on the given scheduler configuration and traffic shaping info |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 588 | func (f *OpenOltFlowMgr) RemoveSchedulerQueues(ctx context.Context, sq schedQueue) error { |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 589 | |
| 590 | var Direction string |
| 591 | var SchedCfg *tp_pb.SchedulerConfig |
| 592 | var err error |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 593 | logger.Infow(ctx, "removing-schedulers-and-queues-in-olt", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 594 | log.Fields{ |
| 595 | "direction": sq.direction, |
| 596 | "intf-id": sq.intfID, |
| 597 | "onu-id": sq.onuID, |
| 598 | "uni-id": sq.uniID, |
| 599 | "uni-port": sq.uniPort, |
| 600 | "device-id": f.deviceHandler.device.Id}) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 601 | if sq.direction == tp_pb.Direction_UPSTREAM { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 602 | SchedCfg = f.techprofile.GetUsScheduler(sq.tpInst.(*tp_pb.TechProfileInstance)) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 603 | Direction = "upstream" |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 604 | } else if sq.direction == tp_pb.Direction_DOWNSTREAM { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 605 | SchedCfg = f.techprofile.GetDsScheduler(sq.tpInst.(*tp_pb.TechProfileInstance)) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 606 | Direction = "downstream" |
| 607 | } |
| 608 | |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 609 | TrafficShaping := &tp_pb.TrafficShapingInfo{} // this info is not really useful for the agent during flow removal. Just use default values. |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 610 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 611 | TrafficSched := []*tp_pb.TrafficScheduler{f.techprofile.GetTrafficScheduler(sq.tpInst.(*tp_pb.TechProfileInstance), SchedCfg, TrafficShaping)} |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 612 | TrafficSched[0].TechProfileId = sq.tpID |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 613 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 614 | TrafficQueues, err := f.techprofile.GetTrafficQueues(ctx, sq.tpInst.(*tp_pb.TechProfileInstance), sq.direction) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 615 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 616 | return olterrors.NewErrAdapter("unable-to-construct-traffic-queue-configuration", |
| 617 | log.Fields{ |
| 618 | "intf-id": sq.intfID, |
| 619 | "direction": sq.direction, |
| 620 | "device-id": f.deviceHandler.device.Id}, err) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 621 | } |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 622 | |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 623 | if _, err = f.deviceHandler.Client.RemoveTrafficQueues(ctx, |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 624 | &tp_pb.TrafficQueues{IntfId: sq.intfID, OnuId: sq.onuID, |
| 625 | UniId: sq.uniID, PortNo: sq.uniPort, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 626 | TrafficQueues: TrafficQueues, |
| 627 | TechProfileId: TrafficSched[0].TechProfileId}); err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 628 | return olterrors.NewErrAdapter("unable-to-remove-traffic-queues-from-device", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 629 | log.Fields{ |
| 630 | "intf-id": sq.intfID, |
| 631 | "traffic-queues": TrafficQueues, |
| 632 | "device-id": f.deviceHandler.device.Id}, err) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 633 | } |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 634 | logger.Infow(ctx, "removed-traffic-queues-successfully", log.Fields{"device-id": f.deviceHandler.device.Id, "trafficQueues": TrafficQueues}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 635 | |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 636 | if allocExists := f.isAllocUsedByAnotherUNI(ctx, sq); !allocExists { |
| 637 | if _, err = f.deviceHandler.Client.RemoveTrafficSchedulers(ctx, &tp_pb.TrafficSchedulers{ |
| 638 | IntfId: sq.intfID, OnuId: sq.onuID, |
| 639 | UniId: sq.uniID, PortNo: sq.uniPort, |
| 640 | TrafficScheds: TrafficSched}); err != nil { |
| 641 | return olterrors.NewErrAdapter("unable-to-remove-traffic-schedulers-from-device", |
| 642 | log.Fields{ |
| 643 | "intf-id": sq.intfID, |
| 644 | "traffic-schedulers": TrafficSched, |
| 645 | "onu-id": sq.onuID, |
| 646 | "uni-id": sq.uniID, |
| 647 | "uni-port": sq.uniPort}, err) |
| 648 | } |
| 649 | |
| 650 | logger.Infow(ctx, "removed-traffic-schedulers-successfully", |
| 651 | log.Fields{"device-id": f.deviceHandler.device.Id, |
| 652 | "intf-id": sq.intfID, |
| 653 | "onu-id": sq.onuID, |
| 654 | "uni-id": sq.uniID, |
| 655 | "uni-port": sq.uniPort}) |
| 656 | |
| 657 | if sq.direction == tp_pb.Direction_UPSTREAM { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 658 | allocID := sq.tpInst.(*tp_pb.TechProfileInstance).UsScheduler.AllocId |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 659 | f.resourceMgr.FreeAllocID(ctx, sq.intfID, sq.onuID, sq.uniID, allocID) |
| 660 | // Delete the TCONT on the ONU. |
| 661 | uni := getUniPortPath(f.deviceHandler.device.Id, sq.intfID, int32(sq.onuID), int32(sq.uniID)) |
| 662 | tpPath := f.getTPpath(ctx, sq.intfID, uni, sq.tpID) |
| 663 | if err := f.sendDeleteTcontToChild(ctx, sq.intfID, sq.onuID, sq.uniID, allocID, tpPath); err != nil { |
| 664 | logger.Errorw(ctx, "error-processing-delete-tcont-towards-onu", |
| 665 | log.Fields{ |
| 666 | "intf": sq.intfID, |
| 667 | "onu-id": sq.onuID, |
| 668 | "uni-id": sq.uniID, |
| 669 | "device-id": f.deviceHandler.device.Id, |
| 670 | "alloc-id": allocID}) |
| 671 | } |
| 672 | } |
| 673 | } |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 674 | |
| 675 | /* After we successfully remove the scheduler configuration on the OLT device, |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 676 | * delete the meter id on the KV store. |
| 677 | */ |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 678 | err = f.resourceMgr.RemoveMeterInfoForOnu(ctx, Direction, sq.intfID, sq.onuID, sq.uniID, sq.tpID) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 679 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 680 | return olterrors.NewErrAdapter("unable-to-remove-meter", |
| 681 | log.Fields{ |
| 682 | "onu": sq.onuID, |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 683 | "device-id": f.deviceHandler.device.Id, |
| 684 | "intf-id": sq.intfID, |
| 685 | "onu-id": sq.onuID, |
| 686 | "uni-id": sq.uniID, |
| 687 | "uni-port": sq.uniPort}, err) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 688 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 689 | logger.Infow(ctx, "removed-meter-from-KV-store-successfully", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 690 | log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 691 | "dir": Direction, |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 692 | "device-id": f.deviceHandler.device.Id, |
| 693 | "intf-id": sq.intfID, |
| 694 | "onu-id": sq.onuID, |
| 695 | "uni-id": sq.uniID, |
| 696 | "uni-port": sq.uniPort}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 697 | return err |
| 698 | } |
| 699 | |
Girish Gowdra | 197acc1 | 2021-08-16 10:59:45 -0700 | [diff] [blame] | 700 | // We are trying to force remove the schedulers and queues here if one exists for the given key. |
| 701 | // We ignore any errors encountered in the process. The errors most likely are encountered when |
| 702 | // the schedulers and queues are already cleared for the given key. |
| 703 | func (f *OpenOltFlowMgr) forceRemoveSchedulerQueues(ctx context.Context, sq schedQueue) { |
| 704 | |
| 705 | var schedCfg *tp_pb.SchedulerConfig |
| 706 | var err error |
| 707 | logger.Infow(ctx, "removing-schedulers-and-queues-in-olt", |
| 708 | log.Fields{ |
| 709 | "direction": sq.direction, |
| 710 | "intf-id": sq.intfID, |
| 711 | "onu-id": sq.onuID, |
| 712 | "uni-id": sq.uniID, |
| 713 | "uni-port": sq.uniPort, |
| 714 | "tp-id": sq.tpID, |
| 715 | "device-id": f.deviceHandler.device.Id}) |
| 716 | if sq.direction == tp_pb.Direction_UPSTREAM { |
| 717 | schedCfg = f.techprofile.GetUsScheduler(sq.tpInst.(*tp_pb.TechProfileInstance)) |
| 718 | } else if sq.direction == tp_pb.Direction_DOWNSTREAM { |
| 719 | schedCfg = f.techprofile.GetDsScheduler(sq.tpInst.(*tp_pb.TechProfileInstance)) |
| 720 | } |
| 721 | |
| 722 | TrafficShaping := &tp_pb.TrafficShapingInfo{} // this info is not really useful for the agent during flow removal. Just use default values. |
| 723 | TrafficSched := []*tp_pb.TrafficScheduler{f.techprofile.GetTrafficScheduler(sq.tpInst.(*tp_pb.TechProfileInstance), schedCfg, TrafficShaping)} |
| 724 | TrafficSched[0].TechProfileId = sq.tpID |
| 725 | |
| 726 | // Remove traffic queues. Ignore any errors, just log them. |
| 727 | if TrafficQueues, err := f.techprofile.GetTrafficQueues(ctx, sq.tpInst.(*tp_pb.TechProfileInstance), sq.direction); err != nil { |
| 728 | logger.Errorw(ctx, "error retrieving traffic queue", log.Fields{ |
| 729 | "direction": sq.direction, |
| 730 | "intf-id": sq.intfID, |
| 731 | "onu-id": sq.onuID, |
| 732 | "uni-id": sq.uniID, |
| 733 | "uni-port": sq.uniPort, |
| 734 | "tp-id": sq.tpID, |
| 735 | "device-id": f.deviceHandler.device.Id, |
| 736 | "err": err}) |
| 737 | } else { |
| 738 | if _, err = f.deviceHandler.Client.RemoveTrafficQueues(ctx, |
| 739 | &tp_pb.TrafficQueues{IntfId: sq.intfID, OnuId: sq.onuID, |
| 740 | UniId: sq.uniID, PortNo: sq.uniPort, |
| 741 | TrafficQueues: TrafficQueues, |
| 742 | TechProfileId: TrafficSched[0].TechProfileId}); err != nil { |
| 743 | logger.Warnw(ctx, "error removing traffic queue", log.Fields{ |
| 744 | "direction": sq.direction, |
| 745 | "intf-id": sq.intfID, |
| 746 | "onu-id": sq.onuID, |
| 747 | "uni-id": sq.uniID, |
| 748 | "uni-port": sq.uniPort, |
| 749 | "tp-id": sq.tpID, |
| 750 | "device-id": f.deviceHandler.device.Id, |
| 751 | "err": err}) |
| 752 | |
| 753 | } else { |
| 754 | logger.Infow(ctx, "removed-traffic-queues-successfully", log.Fields{"device-id": f.deviceHandler.device.Id, |
| 755 | "direction": sq.direction, |
| 756 | "intf-id": sq.intfID, |
| 757 | "onu-id": sq.onuID, |
| 758 | "uni-id": sq.uniID, |
| 759 | "uni-port": sq.uniPort, |
| 760 | "tp-id": sq.tpID}) |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | // Remove traffic schedulers. Ignore any errors, just log them. |
| 765 | if _, err = f.deviceHandler.Client.RemoveTrafficSchedulers(ctx, &tp_pb.TrafficSchedulers{ |
| 766 | IntfId: sq.intfID, OnuId: sq.onuID, |
| 767 | UniId: sq.uniID, PortNo: sq.uniPort, |
| 768 | TrafficScheds: TrafficSched}); err != nil { |
| 769 | logger.Warnw(ctx, "error removing traffic scheduler", log.Fields{ |
| 770 | "direction": sq.direction, |
| 771 | "intf-id": sq.intfID, |
| 772 | "onu-id": sq.onuID, |
| 773 | "uni-id": sq.uniID, |
| 774 | "uni-port": sq.uniPort, |
| 775 | "tp-id": sq.tpID, |
| 776 | "device-id": f.deviceHandler.device.Id, |
| 777 | "err": err}) |
| 778 | } else { |
| 779 | logger.Infow(ctx, "removed-traffic-schedulers-successfully", log.Fields{"device-id": f.deviceHandler.device.Id, |
| 780 | "direction": sq.direction, |
| 781 | "intf-id": sq.intfID, |
| 782 | "onu-id": sq.onuID, |
| 783 | "uni-id": sq.uniID, |
| 784 | "uni-port": sq.uniPort, |
| 785 | "tp-id": sq.tpID}) |
| 786 | } |
| 787 | } |
| 788 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 789 | // This function allocates tconts and GEM ports for an ONU |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 790 | func (f *OpenOltFlowMgr) createTcontGemports(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, uni string, uniPort uint32, TpID uint32, UsMeterID uint32, DsMeterID uint32, flowMetadata *voltha.FlowMetadata) (uint32, []uint32, interface{}) { |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 791 | var allocIDs []uint32 |
| 792 | var allgemPortIDs []uint32 |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 793 | var gemPortIDs []uint32 |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 794 | tpInstanceExists := false |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 795 | var err error |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 796 | allocIDs = f.resourceMgr.GetCurrentAllocIDsForOnu(ctx, intfID, onuID, uniID) |
| 797 | allgemPortIDs = f.resourceMgr.GetCurrentGEMPortIDsForOnu(ctx, intfID, onuID, uniID) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 798 | tpPath := f.getTPpath(ctx, intfID, uni, TpID) |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 799 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 800 | logger.Debugw(ctx, "creating-new-tcont-and-gem", log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 801 | "intf-id": intfID, |
| 802 | "onu-id": onuID, |
| 803 | "uni-id": uniID, |
| 804 | "device-id": f.deviceHandler.device.Id, |
| 805 | "tp-id": TpID}) |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 806 | |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 807 | // Check tech profile instance already exists for derived port name |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 808 | techProfileInstance, _ := f.techprofile.GetTPInstance(ctx, tpPath) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 809 | if techProfileInstance == nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 810 | logger.Infow(ctx, "tp-instance-not-found--creating-new", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 811 | log.Fields{ |
| 812 | "path": tpPath, |
| 813 | "device-id": f.deviceHandler.device.Id}) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 814 | techProfileInstance, err = f.techprofile.CreateTechProfileInstance(ctx, TpID, uni, intfID) |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 815 | if err != nil { |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 816 | // This should not happen, something wrong in KV backend transaction |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 817 | logger.Errorw(ctx, "tp-instance-create-failed", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 818 | log.Fields{ |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 819 | "err": err, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 820 | "tp-id": TpID, |
| 821 | "device-id": f.deviceHandler.device.Id}) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 822 | return 0, nil, nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 823 | } |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 824 | if err := f.resourceMgr.UpdateTechProfileIDForOnu(ctx, intfID, onuID, uniID, TpID); err != nil { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 825 | logger.Warnw(ctx, "failed-to-update-tech-profile-id", log.Fields{"err": err}) |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 826 | } |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 827 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 828 | logger.Debugw(ctx, "tech-profile-instance-already-exist-for-given port-name", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 829 | log.Fields{ |
| 830 | "uni": uni, |
| 831 | "device-id": f.deviceHandler.device.Id}) |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 832 | tpInstanceExists = true |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 833 | } |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 834 | |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 835 | switch tpInst := techProfileInstance.(type) { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 836 | case *tp_pb.TechProfileInstance: |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 837 | if UsMeterID != 0 { |
| 838 | sq := schedQueue{direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: onuID, uniID: uniID, tpID: TpID, |
| 839 | uniPort: uniPort, tpInst: techProfileInstance, meterID: UsMeterID, flowMetadata: flowMetadata} |
| 840 | if err := f.CreateSchedulerQueues(ctx, sq); err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 841 | logger.Errorw(ctx, "CreateSchedulerQueues-failed-upstream", |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 842 | log.Fields{ |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 843 | "err": err, |
Matteo Scandolo | 2f6b5bc | 2020-09-17 13:58:10 -0700 | [diff] [blame] | 844 | "onu-id": onuID, |
| 845 | "uni-id": uniID, |
| 846 | "intf-id": intfID, |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 847 | "meter-id": UsMeterID, |
| 848 | "device-id": f.deviceHandler.device.Id}) |
| 849 | return 0, nil, nil |
| 850 | } |
| 851 | } |
| 852 | if DsMeterID != 0 { |
| 853 | sq := schedQueue{direction: tp_pb.Direction_DOWNSTREAM, intfID: intfID, onuID: onuID, uniID: uniID, tpID: TpID, |
| 854 | uniPort: uniPort, tpInst: techProfileInstance, meterID: DsMeterID, flowMetadata: flowMetadata} |
| 855 | if err := f.CreateSchedulerQueues(ctx, sq); err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 856 | logger.Errorw(ctx, "CreateSchedulerQueues-failed-downstream", |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 857 | log.Fields{ |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 858 | "err": err, |
Matteo Scandolo | 2f6b5bc | 2020-09-17 13:58:10 -0700 | [diff] [blame] | 859 | "onu-id": onuID, |
| 860 | "uni-id": uniID, |
| 861 | "intf-id": intfID, |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 862 | "meter-id": DsMeterID, |
| 863 | "device-id": f.deviceHandler.device.Id}) |
| 864 | return 0, nil, nil |
| 865 | } |
| 866 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 867 | allocID := tpInst.UsScheduler.AllocId |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 868 | for _, gem := range tpInst.UpstreamGemPortAttributeList { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 869 | gemPortIDs = append(gemPortIDs, gem.GemportId) |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 870 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 871 | allocIDs = appendUnique32bit(allocIDs, allocID) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 872 | |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 873 | if tpInstanceExists { |
| 874 | return allocID, gemPortIDs, techProfileInstance |
| 875 | } |
| 876 | |
| 877 | for _, gemPortID := range gemPortIDs { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 878 | allgemPortIDs = appendUnique32bit(allgemPortIDs, gemPortID) |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 879 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 880 | logger.Infow(ctx, "allocated-tcont-and-gem-ports", |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 881 | log.Fields{ |
Matteo Scandolo | 8458537 | 2021-03-18 14:21:22 -0700 | [diff] [blame] | 882 | "intf-id": intfID, |
| 883 | "onu-id": onuID, |
| 884 | "uni-id": uniID, |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 885 | "alloc-ids": allocIDs, |
| 886 | "gemports": allgemPortIDs, |
| 887 | "device-id": f.deviceHandler.device.Id}) |
| 888 | // Send Tconts and GEM ports to KV store |
| 889 | f.storeTcontsGEMPortsIntoKVStore(ctx, intfID, onuID, uniID, allocIDs, allgemPortIDs) |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 890 | return allocID, gemPortIDs, techProfileInstance |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 891 | case *openoltpb2.EponTechProfileInstance: |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 892 | // CreateSchedulerQueues for EPON needs to be implemented here |
| 893 | // when voltha-protos for EPON is completed. |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 894 | allocID := tpInst.AllocId |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 895 | for _, gem := range tpInst.UpstreamQueueAttributeList { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 896 | gemPortIDs = append(gemPortIDs, gem.GemportId) |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 897 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 898 | allocIDs = appendUnique32bit(allocIDs, allocID) |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 899 | |
| 900 | if tpInstanceExists { |
| 901 | return allocID, gemPortIDs, techProfileInstance |
| 902 | } |
| 903 | |
| 904 | for _, gemPortID := range gemPortIDs { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 905 | allgemPortIDs = appendUnique32bit(allgemPortIDs, gemPortID) |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 906 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 907 | logger.Infow(ctx, "allocated-tcont-and-gem-ports", |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 908 | log.Fields{ |
| 909 | "alloc-ids": allocIDs, |
| 910 | "gemports": allgemPortIDs, |
| 911 | "device-id": f.deviceHandler.device.Id}) |
| 912 | // Send Tconts and GEM ports to KV store |
| 913 | f.storeTcontsGEMPortsIntoKVStore(ctx, intfID, onuID, uniID, allocIDs, allgemPortIDs) |
| 914 | return allocID, gemPortIDs, techProfileInstance |
| 915 | default: |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 916 | logger.Errorw(ctx, "unknown-tech", |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 917 | log.Fields{ |
| 918 | "tpInst": tpInst}) |
| 919 | return 0, nil, nil |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 920 | } |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 921 | } |
| 922 | |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 923 | func (f *OpenOltFlowMgr) storeTcontsGEMPortsIntoKVStore(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, allocID []uint32, gemPortIDs []uint32) { |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 924 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 925 | logger.Debugw(ctx, "storing-allocated-tconts-and-gem-ports-into-KV-store", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 926 | log.Fields{ |
| 927 | "intf-id": intfID, |
| 928 | "onu-id": onuID, |
| 929 | "uni-id": uniID, |
| 930 | "alloc-id": allocID, |
| 931 | "gemport-ids": gemPortIDs, |
| 932 | "device-id": f.deviceHandler.device.Id}) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 933 | /* Update the allocated alloc_id and gem_port_id for the ONU/UNI to KV store */ |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 934 | if err := f.resourceMgr.UpdateAllocIdsForOnu(ctx, intfID, onuID, uniID, allocID); err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 935 | logger.Errorw(ctx, "error-while-uploading-allocid-to-kv-store", log.Fields{"device-id": f.deviceHandler.device.Id}) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 936 | } |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 937 | if err := f.resourceMgr.UpdateGEMPortIDsForOnu(ctx, intfID, onuID, uniID, gemPortIDs); err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 938 | logger.Errorw(ctx, "error-while-uploading-gemports-to-kv-store", log.Fields{"device-id": f.deviceHandler.device.Id}) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 939 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 940 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 941 | logger.Infow(ctx, "stored-tconts-and-gem-into-kv-store-successfully", log.Fields{"device-id": f.deviceHandler.device.Id}) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 942 | for _, gemPort := range gemPortIDs { |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 943 | f.addGemPortToOnuInfoMap(ctx, intfID, onuID, gemPort) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 944 | } |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 945 | } |
| 946 | |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 947 | func (f *OpenOltFlowMgr) populateTechProfileForCurrentPonPort(ctx context.Context) error { |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 948 | for _, techRange := range f.resourceMgr.DevInfo.Ranges { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 949 | for _, intfID := range techRange.IntfIds { |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 950 | if intfID == f.ponPortIdx { // initialize only for the pon port that this flow manager is managing |
| 951 | var err error |
| 952 | f.techprofile, err = tp.NewTechProfile(ctx, f.resourceMgr.PonRsrMgr, f.resourceMgr.PonRsrMgr.Backend, |
| 953 | f.resourceMgr.PonRsrMgr.Address, f.deviceHandler.cm.Backend.PathPrefix) |
| 954 | if err != nil || f.techprofile == nil { |
| 955 | logger.Errorw(ctx, "failed-to-allocate-to-techprofile-for-pon-port", log.Fields{"intfID": intfID, "err": err}) |
| 956 | return fmt.Errorf("failed-to-allocate-tech-profile-for-pon-port--pon-%v-err-%v", intfID, err) |
| 957 | } |
| 958 | logger.Debugw(ctx, "init-tech-profile-done", |
| 959 | log.Fields{ |
| 960 | "intf-id": intfID, |
| 961 | "device-id": f.deviceHandler.device.Id}) |
| 962 | return nil |
Girish Gowdra | 4c3d460 | 2021-07-22 16:33:37 -0700 | [diff] [blame] | 963 | } |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 964 | } |
| 965 | } |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 966 | logger.Errorw(ctx, "pon port not found in the the device pon port range", log.Fields{"intfID": f.ponPortIdx}) |
| 967 | return fmt.Errorf("pon-port-idx-not-found-in-the-device-info-pon-port-range-%v", f.ponPortIdx) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 968 | } |
| 969 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 970 | func (f *OpenOltFlowMgr) addUpstreamDataPathFlow(ctx context.Context, flowContext *flowContext) error { |
| 971 | flowContext.classifier[PacketTagType] = SingleTag |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 972 | logger.Debugw(ctx, "adding-upstream-data-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 973 | log.Fields{ |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 974 | "uplinkClassifier": flowContext.classifier, |
| 975 | "uplinkAction": flowContext.action}) |
| 976 | return f.addSymmetricDataPathFlow(ctx, flowContext, Upstream) |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 977 | /* TODO: Install Secondary EAP on the subscriber vlan */ |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 978 | } |
| 979 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 980 | func (f *OpenOltFlowMgr) addDownstreamDataPathFlow(ctx context.Context, flowContext *flowContext) error { |
| 981 | downlinkClassifier := flowContext.classifier |
| 982 | downlinkAction := flowContext.action |
| 983 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 984 | downlinkClassifier[PacketTagType] = DoubleTag |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 985 | logger.Debugw(ctx, "adding-downstream-data-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 986 | log.Fields{ |
| 987 | "downlinkClassifier": downlinkClassifier, |
| 988 | "downlinkAction": downlinkAction}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 989 | // Ignore Downlink trap flow given by core, cannot do anything with this flow */ |
| 990 | if vlan, exists := downlinkClassifier[VlanVid]; exists { |
| 991 | if vlan.(uint32) == (uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 4000) { //private VLAN given by core |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 992 | if metadata, exists := downlinkClassifier[Metadata]; exists { // inport is filled in metadata by core |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 993 | if uint32(metadata.(uint64)) == plt.MkUniPortNum(ctx, flowContext.intfID, flowContext.onuID, flowContext.uniID) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 994 | logger.Infow(ctx, "ignoring-dl-trap-device-flow-from-core", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 995 | log.Fields{ |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 996 | "flow": flowContext.logicalFlow, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 997 | "device-id": f.deviceHandler.device.Id, |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 998 | "onu-id": flowContext.onuID, |
| 999 | "intf-id": flowContext.intfID}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1000 | return nil |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 1001 | } |
| 1002 | } |
| 1003 | } |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 1004 | } |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 1005 | |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 1006 | /* Already this info available classifier? */ |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1007 | downlinkAction[PopVlan] = true |
Matt Jeanneret | ed16b7c | 2019-11-01 13:31:35 -0400 | [diff] [blame] | 1008 | // vlan_vid is a uint32. must be type asserted as such or conversion fails |
| 1009 | dlClVid, ok := downlinkClassifier[VlanVid].(uint32) |
Girish Gowdra | 26f344b | 2019-10-23 14:39:13 +0530 | [diff] [blame] | 1010 | if ok { |
| 1011 | downlinkAction[VlanVid] = dlClVid & 0xfff |
| 1012 | } else { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 1013 | return olterrors.NewErrInvalidValue(log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1014 | "reason": "failed-to-convert-vlanid-classifier", |
| 1015 | "vlan-id": VlanVid, |
| 1016 | "device-id": f.deviceHandler.device.Id}, nil).Log() |
Girish Gowdra | 26f344b | 2019-10-23 14:39:13 +0530 | [diff] [blame] | 1017 | } |
| 1018 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1019 | return f.addSymmetricDataPathFlow(ctx, flowContext, Downstream) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1020 | } |
| 1021 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1022 | func (f *OpenOltFlowMgr) addSymmetricDataPathFlow(ctx context.Context, flowContext *flowContext, direction string) error { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1023 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1024 | intfID := flowContext.intfID |
| 1025 | onuID := flowContext.onuID |
| 1026 | uniID := flowContext.uniID |
| 1027 | classifier := flowContext.classifier |
| 1028 | action := flowContext.action |
| 1029 | allocID := flowContext.allocID |
| 1030 | gemPortID := flowContext.gemPortID |
| 1031 | tpID := flowContext.tpID |
| 1032 | logicalFlow := flowContext.logicalFlow |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1033 | logger.Infow(ctx, "adding-hsia-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1034 | log.Fields{ |
| 1035 | "intf-id": intfID, |
| 1036 | "onu-id": onuID, |
| 1037 | "uni-id": uniID, |
| 1038 | "device-id": f.deviceHandler.device.Id, |
| 1039 | "classifier": classifier, |
| 1040 | "action": action, |
| 1041 | "direction": direction, |
| 1042 | "alloc-id": allocID, |
| 1043 | "gemport-id": gemPortID, |
| 1044 | "logicalflow": *logicalFlow}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1045 | |
| 1046 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, intfID, int32(onuID), int32(uniID), logicalFlow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1047 | logger.Infow(ctx, "flow-already-exists", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1048 | log.Fields{ |
| 1049 | "device-id": f.deviceHandler.device.Id, |
| 1050 | "intf-id": intfID, |
| 1051 | "onu-id": onuID}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1052 | return nil |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 1053 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1054 | classifierProto, err := makeOpenOltClassifierField(classifier) |
| 1055 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1056 | return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier, "device-id": f.deviceHandler.device.Id}, err).Log() |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 1057 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1058 | logger.Debugw(ctx, "created-classifier-proto", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1059 | log.Fields{ |
| 1060 | "classifier": *classifierProto, |
| 1061 | "device-id": f.deviceHandler.device.Id}) |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1062 | actionProto, err := makeOpenOltActionField(action, classifier) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1063 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1064 | return olterrors.NewErrInvalidValue(log.Fields{"action": action, "device-id": f.deviceHandler.device.Id}, err).Log() |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 1065 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1066 | logger.Debugw(ctx, "created-action-proto", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1067 | log.Fields{ |
| 1068 | "action": *actionProto, |
| 1069 | "device-id": f.deviceHandler.device.Id}) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1070 | networkIntfID, err := getNniIntfID(ctx, classifier, action) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 1071 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 1072 | return olterrors.NewErrNotFound("nni-interface-id", |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1073 | log.Fields{ |
| 1074 | "classifier": classifier, |
| 1075 | "action": action, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1076 | "device-id": f.deviceHandler.device.Id, |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1077 | }, err).Log() |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 1078 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1079 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1080 | flow := openoltpb2.Flow{AccessIntfId: int32(intfID), |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1081 | OnuId: int32(onuID), |
| 1082 | UniId: int32(uniID), |
| 1083 | FlowId: logicalFlow.Id, |
| 1084 | FlowType: direction, |
| 1085 | AllocId: int32(allocID), |
| 1086 | NetworkIntfId: int32(networkIntfID), |
| 1087 | GemportId: int32(gemPortID), |
| 1088 | Classifier: classifierProto, |
| 1089 | Action: actionProto, |
| 1090 | Priority: int32(logicalFlow.Priority), |
| 1091 | Cookie: logicalFlow.Cookie, |
| 1092 | PortNo: flowContext.portNo, |
| 1093 | TechProfileId: tpID, |
| 1094 | ReplicateFlow: len(flowContext.pbitToGem) > 0, |
| 1095 | PbitToGemport: flowContext.pbitToGem, |
| 1096 | GemportToAes: flowContext.gemToAes, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 1097 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1098 | if err := f.addFlowToDevice(ctx, logicalFlow, &flow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1099 | return olterrors.NewErrFlowOp("add", logicalFlow.Id, nil, err).Log() |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 1100 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1101 | logger.Infow(ctx, "hsia-flow-added-to-device-successfully", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1102 | log.Fields{"direction": direction, |
| 1103 | "device-id": f.deviceHandler.device.Id, |
| 1104 | "flow": flow, |
| 1105 | "intf-id": intfID, |
| 1106 | "onu-id": onuID}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1107 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1108 | return nil |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 1109 | } |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1110 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1111 | func (f *OpenOltFlowMgr) addDHCPTrapFlow(ctx context.Context, flowContext *flowContext) error { |
| 1112 | |
| 1113 | intfID := flowContext.intfID |
| 1114 | onuID := flowContext.onuID |
| 1115 | uniID := flowContext.uniID |
| 1116 | logicalFlow := flowContext.logicalFlow |
| 1117 | classifier := flowContext.classifier |
| 1118 | action := flowContext.action |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1119 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1120 | networkIntfID, err := getNniIntfID(ctx, classifier, action) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 1121 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 1122 | return olterrors.NewErrNotFound("nni-interface-id", log.Fields{ |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1123 | "classifier": classifier, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1124 | "action": action, |
| 1125 | "device-id": f.deviceHandler.device.Id}, |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1126 | err).Log() |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 1127 | } |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1128 | |
| 1129 | // Clear the action map |
| 1130 | for k := range action { |
| 1131 | delete(action, k) |
| 1132 | } |
| 1133 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1134 | action[TrapToHost] = true |
| 1135 | classifier[UDPSrc] = uint32(68) |
| 1136 | classifier[UDPDst] = uint32(67) |
| 1137 | classifier[PacketTagType] = SingleTag |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1138 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1139 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, intfID, int32(onuID), int32(uniID), logicalFlow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1140 | logger.Infow(ctx, "flow-exists--not-re-adding", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1141 | log.Fields{ |
| 1142 | "device-id": f.deviceHandler.device.Id, |
| 1143 | "intf-id": intfID, |
| 1144 | "onu-id": onuID}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1145 | return nil |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 1146 | } |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1147 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1148 | logger.Debugw(ctx, "creating-ul-dhcp-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1149 | log.Fields{ |
| 1150 | "ul_classifier": classifier, |
| 1151 | "ul_action": action, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1152 | "uplinkFlowId": logicalFlow.Id, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1153 | "intf-id": intfID, |
| 1154 | "onu-id": onuID, |
| 1155 | "device-id": f.deviceHandler.device.Id}) |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1156 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1157 | classifierProto, err := makeOpenOltClassifierField(classifier) |
| 1158 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 1159 | return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier}, err).Log() |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1160 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1161 | logger.Debugw(ctx, "created-classifier-proto", log.Fields{"classifier": *classifierProto}) |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1162 | actionProto, err := makeOpenOltActionField(action, classifier) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1163 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 1164 | return olterrors.NewErrInvalidValue(log.Fields{"action": action}, err).Log() |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1165 | } |
| 1166 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1167 | dhcpFlow := openoltpb2.Flow{AccessIntfId: int32(intfID), |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1168 | OnuId: int32(onuID), |
| 1169 | UniId: int32(uniID), |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1170 | FlowId: logicalFlow.Id, |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 1171 | FlowType: Upstream, |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1172 | AllocId: int32(flowContext.allocID), |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1173 | NetworkIntfId: int32(networkIntfID), |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1174 | GemportId: int32(flowContext.gemPortID), |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1175 | Classifier: classifierProto, |
| 1176 | Action: actionProto, |
| 1177 | Priority: int32(logicalFlow.Priority), |
| 1178 | Cookie: logicalFlow.Cookie, |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1179 | PortNo: flowContext.portNo, |
| 1180 | TechProfileId: flowContext.tpID, |
| 1181 | ReplicateFlow: len(flowContext.pbitToGem) > 0, |
| 1182 | PbitToGemport: flowContext.pbitToGem, |
| 1183 | GemportToAes: flowContext.gemToAes, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 1184 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1185 | if err := f.addFlowToDevice(ctx, logicalFlow, &dhcpFlow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1186 | return olterrors.NewErrFlowOp("add", logicalFlow.Id, log.Fields{"dhcp-flow": dhcpFlow}, err).Log() |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1187 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1188 | logger.Infow(ctx, "dhcp-ul-flow-added-to-device-successfully", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1189 | log.Fields{ |
| 1190 | "device-id": f.deviceHandler.device.Id, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1191 | "flow-id": logicalFlow.Id, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1192 | "intf-id": intfID, |
| 1193 | "onu-id": onuID}) |
Manjunath Vanarajulu | adc57d1 | 2019-04-23 11:07:21 +0530 | [diff] [blame] | 1194 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1195 | return nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1196 | } |
| 1197 | |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1198 | //addIGMPTrapFlow creates IGMP trap-to-host flow |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1199 | func (f *OpenOltFlowMgr) addIGMPTrapFlow(ctx context.Context, flowContext *flowContext) error { |
| 1200 | delete(flowContext.classifier, VlanVid) |
| 1201 | return f.addUpstreamTrapFlow(ctx, flowContext) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | //addUpstreamTrapFlow creates a trap-to-host flow |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1205 | func (f *OpenOltFlowMgr) addUpstreamTrapFlow(ctx context.Context, flowContext *flowContext) error { |
| 1206 | |
| 1207 | intfID := flowContext.intfID |
| 1208 | onuID := flowContext.onuID |
| 1209 | uniID := flowContext.uniID |
| 1210 | logicalFlow := flowContext.logicalFlow |
| 1211 | classifier := flowContext.classifier |
| 1212 | action := flowContext.action |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1213 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1214 | networkIntfID, err := getNniIntfID(ctx, classifier, action) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1215 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1216 | return olterrors.NewErrNotFound("nni-interface-id", |
| 1217 | log.Fields{ |
| 1218 | "classifier": classifier, |
| 1219 | "action": action, |
| 1220 | "device-id": f.deviceHandler.device.Id}, |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1221 | err).Log() |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | // Clear the action map |
| 1225 | for k := range action { |
| 1226 | delete(action, k) |
| 1227 | } |
| 1228 | |
| 1229 | action[TrapToHost] = true |
| 1230 | classifier[PacketTagType] = SingleTag |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1231 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1232 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, networkIntfID, int32(onuID), int32(uniID), logicalFlow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1233 | logger.Infow(ctx, "flow-exists-not-re-adding", log.Fields{"device-id": f.deviceHandler.device.Id}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1234 | return nil |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1235 | } |
| 1236 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1237 | logger.Debugw(ctx, "creating-upstream-trap-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1238 | log.Fields{ |
| 1239 | "ul_classifier": classifier, |
| 1240 | "ul_action": action, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1241 | "uplinkFlowId": logicalFlow.Id, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1242 | "device-id": f.deviceHandler.device.Id, |
| 1243 | "intf-id": intfID, |
| 1244 | "onu-id": onuID}) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1245 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1246 | classifierProto, err := makeOpenOltClassifierField(classifier) |
| 1247 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1248 | return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier, "device-id": f.deviceHandler.device.Id}, err).Log() |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1249 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1250 | logger.Debugw(ctx, "created-classifier-proto", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1251 | log.Fields{ |
| 1252 | "classifier": *classifierProto, |
| 1253 | "device-id": f.deviceHandler.device.Id}) |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1254 | actionProto, err := makeOpenOltActionField(action, classifier) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1255 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1256 | return olterrors.NewErrInvalidValue(log.Fields{"action": action, "device-id": f.deviceHandler.device.Id}, err).Log() |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1259 | flow := openoltpb2.Flow{AccessIntfId: int32(intfID), |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1260 | OnuId: int32(onuID), |
| 1261 | UniId: int32(uniID), |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1262 | FlowId: logicalFlow.Id, |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1263 | FlowType: Upstream, |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1264 | AllocId: int32(flowContext.allocID), |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1265 | NetworkIntfId: int32(networkIntfID), |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1266 | GemportId: int32(flowContext.gemPortID), |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1267 | Classifier: classifierProto, |
| 1268 | Action: actionProto, |
| 1269 | Priority: int32(logicalFlow.Priority), |
| 1270 | Cookie: logicalFlow.Cookie, |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1271 | PortNo: flowContext.portNo, |
| 1272 | TechProfileId: flowContext.tpID, |
| 1273 | ReplicateFlow: len(flowContext.pbitToGem) > 0, |
| 1274 | PbitToGemport: flowContext.pbitToGem, |
| 1275 | GemportToAes: flowContext.gemToAes, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 1276 | } |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1277 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1278 | if err := f.addFlowToDevice(ctx, logicalFlow, &flow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1279 | return olterrors.NewErrFlowOp("add", logicalFlow.Id, log.Fields{"flow": flow, "device-id": f.deviceHandler.device.Id}, err).Log() |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1280 | } |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1281 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1282 | return nil |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 1285 | // Add EthType flow to device with mac, vlanId as classifier for upstream and downstream |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1286 | func (f *OpenOltFlowMgr) addEthTypeBasedFlow(ctx context.Context, flowContext *flowContext, vlanID uint32, ethType uint32) error { |
| 1287 | intfID := flowContext.intfID |
| 1288 | onuID := flowContext.onuID |
| 1289 | uniID := flowContext.uniID |
| 1290 | portNo := flowContext.portNo |
| 1291 | allocID := flowContext.allocID |
| 1292 | gemPortID := flowContext.gemPortID |
| 1293 | logicalFlow := flowContext.logicalFlow |
| 1294 | classifier := flowContext.classifier |
| 1295 | action := flowContext.action |
| 1296 | |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 1297 | logger.Infow(ctx, "adding-ethType-flow-to-device", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1298 | log.Fields{ |
| 1299 | "intf-id": intfID, |
| 1300 | "onu-id": onuID, |
| 1301 | "port-no": portNo, |
| 1302 | "alloc-id": allocID, |
| 1303 | "gemport-id": gemPortID, |
| 1304 | "vlan-id": vlanID, |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 1305 | "flow": logicalFlow, |
| 1306 | "ethType": ethType}) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1307 | |
| 1308 | uplinkClassifier := make(map[string]interface{}) |
| 1309 | uplinkAction := make(map[string]interface{}) |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 1310 | |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1311 | // Fill Classfier |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1312 | uplinkClassifier[EthType] = ethType |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1313 | uplinkClassifier[PacketTagType] = SingleTag |
| 1314 | uplinkClassifier[VlanVid] = vlanID |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1315 | uplinkClassifier[VlanPcp] = classifier[VlanPcp] |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1316 | // Fill action |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1317 | uplinkAction[TrapToHost] = true |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1318 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, intfID, int32(onuID), int32(uniID), logicalFlow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1319 | logger.Infow(ctx, "flow-exists-not-re-adding", log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1320 | "device-id": f.deviceHandler.device.Id, |
| 1321 | "onu-id": onuID, |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 1322 | "intf-id": intfID, |
| 1323 | "ethType": ethType}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1324 | return nil |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 1325 | } |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 1326 | //Add Uplink EthType Flow |
| 1327 | logger.Debugw(ctx, "creating-ul-ethType-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1328 | log.Fields{ |
| 1329 | "ul_classifier": uplinkClassifier, |
| 1330 | "ul_action": uplinkAction, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1331 | "uplinkFlowId": logicalFlow.Id, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1332 | "device-id": f.deviceHandler.device.Id, |
| 1333 | "intf-id": intfID, |
| 1334 | "onu-id": onuID}) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1335 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1336 | classifierProto, err := makeOpenOltClassifierField(uplinkClassifier) |
| 1337 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1338 | return olterrors.NewErrInvalidValue(log.Fields{ |
| 1339 | "classifier": uplinkClassifier, |
| 1340 | "device-id": f.deviceHandler.device.Id}, err).Log() |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1341 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1342 | logger.Debugw(ctx, "created-classifier-proto", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1343 | log.Fields{ |
| 1344 | "classifier": *classifierProto, |
| 1345 | "device-id": f.deviceHandler.device.Id}) |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1346 | actionProto, err := makeOpenOltActionField(uplinkAction, uplinkClassifier) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1347 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1348 | return olterrors.NewErrInvalidValue(log.Fields{"action": uplinkAction, "device-id": f.deviceHandler.device.Id}, err).Log() |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1349 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1350 | logger.Debugw(ctx, "created-action-proto", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1351 | log.Fields{ |
| 1352 | "action": *actionProto, |
| 1353 | "device-id": f.deviceHandler.device.Id}) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1354 | networkIntfID, err := getNniIntfID(ctx, classifier, action) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 1355 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 1356 | return olterrors.NewErrNotFound("nni-interface-id", log.Fields{ |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1357 | "classifier": classifier, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1358 | "action": action, |
| 1359 | "device-id": f.deviceHandler.device.Id}, |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1360 | err).Log() |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 1361 | } |
| 1362 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1363 | upstreamFlow := openoltpb2.Flow{AccessIntfId: int32(intfID), |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1364 | OnuId: int32(onuID), |
| 1365 | UniId: int32(uniID), |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1366 | FlowId: logicalFlow.Id, |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 1367 | FlowType: Upstream, |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1368 | AllocId: int32(allocID), |
| 1369 | NetworkIntfId: int32(networkIntfID), |
| 1370 | GemportId: int32(gemPortID), |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1371 | Classifier: classifierProto, |
| 1372 | Action: actionProto, |
| 1373 | Priority: int32(logicalFlow.Priority), |
| 1374 | Cookie: logicalFlow.Cookie, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 1375 | PortNo: portNo, |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 1376 | TechProfileId: flowContext.tpID, |
| 1377 | ReplicateFlow: len(flowContext.pbitToGem) > 0, |
| 1378 | PbitToGemport: flowContext.pbitToGem, |
| 1379 | GemportToAes: flowContext.gemToAes, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 1380 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1381 | if err := f.addFlowToDevice(ctx, logicalFlow, &upstreamFlow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1382 | return olterrors.NewErrFlowOp("add", logicalFlow.Id, log.Fields{"flow": upstreamFlow}, err).Log() |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1383 | } |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 1384 | logger.Infow(ctx, "ethType-ul-flow-added-to-device-successfully", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1385 | log.Fields{ |
| 1386 | "device-id": f.deviceHandler.device.Id, |
| 1387 | "onu-id": onuID, |
| 1388 | "intf-id": intfID, |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 1389 | "ethType": ethType, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1390 | }) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1391 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1392 | return nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1393 | } |
| 1394 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1395 | func makeOpenOltClassifierField(classifierInfo map[string]interface{}) (*openoltpb2.Classifier, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1396 | var classifier openoltpb2.Classifier |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 1397 | |
| 1398 | classifier.EthType, _ = classifierInfo[EthType].(uint32) |
| 1399 | classifier.IpProto, _ = classifierInfo[IPProto].(uint32) |
| 1400 | if vlanID, ok := classifierInfo[VlanVid].(uint32); ok { |
Andrea Campanella | 7acc0b9 | 2020-02-14 09:20:49 +0100 | [diff] [blame] | 1401 | if vlanID != ReservedVlan { |
| 1402 | vid := vlanID & VlanvIDMask |
Harsh Awasthi | ea45af7 | 2019-08-26 02:39:00 -0400 | [diff] [blame] | 1403 | classifier.OVid = vid |
| 1404 | } |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1405 | } |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 1406 | if metadata, ok := classifierInfo[Metadata].(uint64); ok { |
| 1407 | vid := uint32(metadata) |
| 1408 | if vid != ReservedVlan { |
Harsh Awasthi | ea45af7 | 2019-08-26 02:39:00 -0400 | [diff] [blame] | 1409 | classifier.IVid = vid |
| 1410 | } |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1411 | } |
Girish Gowdra | fae935c | 2020-02-17 19:21:44 +0530 | [diff] [blame] | 1412 | // Use VlanPCPMask (0xff) to signify NO PCP. Else use valid PCP (0 to 7) |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 1413 | if vlanPcp, ok := classifierInfo[VlanPcp].(uint32); ok { |
Girish Gowdra | fae935c | 2020-02-17 19:21:44 +0530 | [diff] [blame] | 1414 | classifier.OPbits = vlanPcp |
| 1415 | } else { |
| 1416 | classifier.OPbits = VlanPCPMask |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1417 | } |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 1418 | classifier.SrcPort, _ = classifierInfo[UDPSrc].(uint32) |
| 1419 | classifier.DstPort, _ = classifierInfo[UDPDst].(uint32) |
| 1420 | classifier.DstIp, _ = classifierInfo[Ipv4Dst].(uint32) |
| 1421 | classifier.SrcIp, _ = classifierInfo[Ipv4Src].(uint32) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 1422 | classifier.DstMac, _ = classifierInfo[EthDst].([]uint8) |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 1423 | if pktTagType, ok := classifierInfo[PacketTagType].(string); ok { |
| 1424 | classifier.PktTagType = pktTagType |
| 1425 | |
| 1426 | switch pktTagType { |
| 1427 | case SingleTag: |
| 1428 | case DoubleTag: |
| 1429 | case Untagged: |
| 1430 | default: |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 1431 | return nil, olterrors.NewErrInvalidValue(log.Fields{"packet-tag-type": pktTagType}, nil) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1432 | } |
| 1433 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1434 | return &classifier, nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1435 | } |
| 1436 | |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1437 | func makeOpenOltActionField(actionInfo map[string]interface{}, classifierInfo map[string]interface{}) (*openoltpb2.Action, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1438 | var actionCmd openoltpb2.ActionCmd |
| 1439 | var action openoltpb2.Action |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1440 | action.Cmd = &actionCmd |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1441 | if _, ok := actionInfo[PopVlan]; ok { |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1442 | action.Cmd.RemoveOuterTag = true |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1443 | if _, ok := actionInfo[VlanPcp]; ok { |
| 1444 | action.Cmd.RemarkInnerPbits = true |
| 1445 | action.IPbits = actionInfo[VlanPcp].(uint32) |
| 1446 | if _, ok := actionInfo[VlanVid]; ok { |
| 1447 | action.Cmd.TranslateInnerTag = true |
| 1448 | action.IVid = actionInfo[VlanVid].(uint32) |
| 1449 | } |
| 1450 | } |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1451 | } else if _, ok := actionInfo[PushVlan]; ok { |
| 1452 | action.OVid = actionInfo[VlanVid].(uint32) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1453 | action.Cmd.AddOuterTag = true |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1454 | if _, ok := actionInfo[VlanPcp]; ok { |
| 1455 | action.OPbits = actionInfo[VlanPcp].(uint32) |
| 1456 | action.Cmd.RemarkOuterPbits = true |
| 1457 | if _, ok := classifierInfo[VlanVid]; ok { |
| 1458 | action.IVid = classifierInfo[VlanVid].(uint32) |
| 1459 | action.Cmd.TranslateInnerTag = true |
| 1460 | } |
| 1461 | } |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1462 | } else if _, ok := actionInfo[TrapToHost]; ok { |
| 1463 | action.Cmd.TrapToHost = actionInfo[TrapToHost].(bool) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1464 | } else { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 1465 | return nil, olterrors.NewErrInvalidValue(log.Fields{"action-command": actionInfo}, nil) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1466 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1467 | return &action, nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1468 | } |
| 1469 | |
Matteo Scandolo | d625b4c | 2020-04-02 16:16:01 -0700 | [diff] [blame] | 1470 | // getTPpath return the ETCD path for a given UNI port |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1471 | func (f *OpenOltFlowMgr) getTPpath(ctx context.Context, intfID uint32, uniPath string, TpID uint32) string { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1472 | return f.techprofile.GetTechProfileInstanceKey(ctx, TpID, uniPath) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1473 | } |
| 1474 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1475 | // DeleteTechProfileInstances removes the tech profile instances from persistent storage |
Girish Gowdra | 197acc1 | 2021-08-16 10:59:45 -0700 | [diff] [blame] | 1476 | // We also force release scheduler and queues associated with the tp instance. Theoretically there could be |
| 1477 | // an issue if the upstream scheduler (DBA) is shared across multiple UNI and we force release it, given that |
| 1478 | // this function is only meant to clean up TP instances of a given UNI. But in practicality this routine |
| 1479 | // is only meant to be called when the clean up of resource for the whole ONU is taking place. |
| 1480 | // The reason for introducing the force cleanup of scheduler and queues (on the OLT) was introduced here |
| 1481 | // because it was observed that if the ONU device was deleted too soon after the flows were |
| 1482 | // unprovisioned on that ONU, the scheduler and queue removal pertinent to that ONU would remain |
| 1483 | // uncleaned on the OLT. So we force clean up here and ignore any error that OLT returns during the |
| 1484 | // force cleanup (possible if the OLT has already cleared those resources). |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1485 | func (f *OpenOltFlowMgr) DeleteTechProfileInstances(ctx context.Context, intfID uint32, onuID uint32, uniID uint32) error { |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 1486 | tpIDList := f.resourceMgr.GetTechProfileIDForOnu(ctx, intfID, onuID, uniID) |
Matteo Scandolo | d625b4c | 2020-04-02 16:16:01 -0700 | [diff] [blame] | 1487 | uniPortName := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID)) |
| 1488 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1489 | for _, tpID := range tpIDList { |
Girish Gowdra | 197acc1 | 2021-08-16 10:59:45 -0700 | [diff] [blame] | 1490 | |
| 1491 | // Force cleanup scheduler/queues -- start |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 1492 | uniPortNum := plt.MkUniPortNum(ctx, intfID, onuID, uniID) |
Girish Gowdra | 197acc1 | 2021-08-16 10:59:45 -0700 | [diff] [blame] | 1493 | uni := getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID)) |
| 1494 | tpPath := f.getTPpath(ctx, intfID, uni, tpID) |
| 1495 | tpInst, err := f.techprofile.GetTPInstance(ctx, tpPath) |
| 1496 | if err != nil || tpInst == nil { // This should not happen, something wrong in KV backend transaction |
| 1497 | logger.Warnw(ctx, "tech-profile-not-in-kv-store", |
| 1498 | log.Fields{ |
| 1499 | "tp-id": tpID, |
| 1500 | "path": tpPath}) |
| 1501 | } |
| 1502 | switch tpInstance := tpInst.(type) { |
| 1503 | case *tp_pb.TechProfileInstance: |
| 1504 | f.forceRemoveSchedulerQueues(ctx, schedQueue{direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: onuID, uniID: uniID, tpID: tpID, uniPort: uniPortNum, tpInst: tpInstance}) |
| 1505 | f.forceRemoveSchedulerQueues(ctx, schedQueue{direction: tp_pb.Direction_DOWNSTREAM, intfID: intfID, onuID: onuID, uniID: uniID, tpID: tpID, uniPort: uniPortNum, tpInst: tpInstance}) |
| 1506 | } |
| 1507 | // Force cleanup scheduler/queues -- end |
| 1508 | |
| 1509 | // Now remove the tp instance |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 1510 | if err := f.DeleteTechProfileInstance(ctx, intfID, onuID, uniID, uniPortName, tpID); err != nil { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1511 | logger.Errorw(ctx, "delete-tech-profile-failed", log.Fields{"err": err, "device-id": f.deviceHandler.device.Id}) |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 1512 | // return err |
| 1513 | // We should continue to delete tech-profile instances for other TP IDs |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1514 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1515 | logger.Debugw(ctx, "tech-profile-instance-deleted", log.Fields{"device-id": f.deviceHandler.device.Id, "uniPortName": uniPortName, "tp-id": tpID}) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1516 | } |
| 1517 | return nil |
| 1518 | } |
| 1519 | |
| 1520 | // DeleteTechProfileInstance removes the tech profile instance from persistent storage |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 1521 | func (f *OpenOltFlowMgr) DeleteTechProfileInstance(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, uniPortName string, tpID uint32) error { |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1522 | if uniPortName == "" { |
Matteo Scandolo | d625b4c | 2020-04-02 16:16:01 -0700 | [diff] [blame] | 1523 | uniPortName = getUniPortPath(f.deviceHandler.device.Id, intfID, int32(onuID), int32(uniID)) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1524 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1525 | if err := f.techprofile.DeleteTechProfileInstance(ctx, tpID, uniPortName); err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1526 | return olterrors.NewErrAdapter("failed-to-delete-tp-instance-from-kv-store", |
| 1527 | log.Fields{ |
| 1528 | "tp-id": tpID, |
| 1529 | "uni-port-name": uniPortName, |
| 1530 | "device-id": f.deviceHandler.device.Id}, err) |
Devmalya Paul | 495b94a | 2019-08-27 19:42:00 -0400 | [diff] [blame] | 1531 | } |
| 1532 | return nil |
| 1533 | } |
| 1534 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1535 | func (f *OpenOltFlowMgr) addFlowToDevice(ctx context.Context, logicalFlow *ofp.OfpFlowStats, deviceFlow *openoltpb2.Flow) error { |
Daniele Rossi | 22db98e | 2019-07-11 11:50:00 +0000 | [diff] [blame] | 1536 | |
| 1537 | var intfID uint32 |
| 1538 | /* For flows which trap out of the NNI, the AccessIntfId is invalid |
| 1539 | (set to -1). In such cases, we need to refer to the NetworkIntfId . |
| 1540 | */ |
| 1541 | if deviceFlow.AccessIntfId != -1 { |
| 1542 | intfID = uint32(deviceFlow.AccessIntfId) |
| 1543 | } else { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1544 | // We need to log the valid interface ID. |
| 1545 | // For trap-on-nni flows, the access_intf_id is invalid (-1), so choose the network_intf_id. |
Daniele Rossi | 22db98e | 2019-07-11 11:50:00 +0000 | [diff] [blame] | 1546 | intfID = uint32(deviceFlow.NetworkIntfId) |
| 1547 | } |
| 1548 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1549 | logger.Debugw(ctx, "sending-flow-to-device-via-grpc", log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1550 | "flow": *deviceFlow, |
| 1551 | "device-id": f.deviceHandler.device.Id, |
| 1552 | "intf-id": intfID}) |
Neha Sharma | 8f4e432 | 2020-08-06 10:51:53 +0000 | [diff] [blame] | 1553 | _, err := f.deviceHandler.Client.FlowAdd(log.WithSpanFromContext(context.Background(), ctx), deviceFlow) |
Daniele Rossi | 22db98e | 2019-07-11 11:50:00 +0000 | [diff] [blame] | 1554 | |
| 1555 | st, _ := status.FromError(err) |
| 1556 | if st.Code() == codes.AlreadyExists { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1557 | logger.Debug(ctx, "flow-already-exists", log.Fields{ |
Matteo Scandolo | d625b4c | 2020-04-02 16:16:01 -0700 | [diff] [blame] | 1558 | "err": err, |
| 1559 | "deviceFlow": deviceFlow, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1560 | "device-id": f.deviceHandler.device.Id, |
| 1561 | "intf-id": intfID}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1562 | return nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1563 | } |
Daniele Rossi | 22db98e | 2019-07-11 11:50:00 +0000 | [diff] [blame] | 1564 | |
| 1565 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1566 | logger.Errorw(ctx, "failed-to-add-flow-to-device", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1567 | log.Fields{"err": err, |
| 1568 | "device-flow": deviceFlow, |
| 1569 | "device-id": f.deviceHandler.device.Id, |
| 1570 | "intf-id": intfID}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1571 | return err |
Daniele Rossi | 22db98e | 2019-07-11 11:50:00 +0000 | [diff] [blame] | 1572 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1573 | logger.Infow(ctx, "flow-added-to-device-successfully ", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1574 | log.Fields{ |
| 1575 | "flow": *deviceFlow, |
| 1576 | "device-id": f.deviceHandler.device.Id, |
| 1577 | "intf-id": intfID}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1578 | |
| 1579 | // Case of trap-on-nni flow when deviceFlow.AccessIntfId is invalid (-1) |
| 1580 | if deviceFlow.AccessIntfId != -1 { |
| 1581 | // No need to register the flow if it is a trap on nni flow. |
| 1582 | if err := f.registerFlow(ctx, logicalFlow, deviceFlow); err != nil { |
| 1583 | logger.Errorw(ctx, "failed-to-register-flow", log.Fields{"err": err}) |
| 1584 | return err |
| 1585 | } |
| 1586 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1587 | return nil |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 1588 | } |
| 1589 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1590 | func (f *OpenOltFlowMgr) removeFlowFromDevice(ctx context.Context, deviceFlow *openoltpb2.Flow, ofFlowID uint64) error { |
| 1591 | logger.Debugw(ctx, "sending-flow-to-device-via-grpc", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1592 | log.Fields{ |
| 1593 | "flow": *deviceFlow, |
| 1594 | "device-id": f.deviceHandler.device.Id}) |
Neha Sharma | 8f4e432 | 2020-08-06 10:51:53 +0000 | [diff] [blame] | 1595 | _, err := f.deviceHandler.Client.FlowRemove(log.WithSpanFromContext(context.Background(), ctx), deviceFlow) |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 1596 | if err != nil { |
serkant.uluderya | 245caba | 2019-09-24 23:15:29 -0700 | [diff] [blame] | 1597 | if f.deviceHandler.device.ConnectStatus == common.ConnectStatus_UNREACHABLE { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1598 | logger.Warnw(ctx, "can-not-remove-flow-from-device--unreachable", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1599 | log.Fields{ |
| 1600 | "err": err, |
| 1601 | "deviceFlow": deviceFlow, |
| 1602 | "device-id": f.deviceHandler.device.Id}) |
serkant.uluderya | 245caba | 2019-09-24 23:15:29 -0700 | [diff] [blame] | 1603 | //Assume the flow is removed |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1604 | return nil |
serkant.uluderya | 245caba | 2019-09-24 23:15:29 -0700 | [diff] [blame] | 1605 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 1606 | return olterrors.NewErrFlowOp("remove", deviceFlow.FlowId, log.Fields{"deviceFlow": deviceFlow}, err) |
serkant.uluderya | 245caba | 2019-09-24 23:15:29 -0700 | [diff] [blame] | 1607 | |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 1608 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1609 | logger.Infow(ctx, "flow-removed-from-device-successfully", log.Fields{ |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 1610 | "of-flow-id": ofFlowID, |
| 1611 | "flow": *deviceFlow, |
| 1612 | "device-id": f.deviceHandler.device.Id, |
| 1613 | }) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1614 | return nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1615 | } |
| 1616 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1617 | func (f *OpenOltFlowMgr) addLLDPFlow(ctx context.Context, flow *ofp.OfpFlowStats, portNo uint32) error { |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1618 | |
| 1619 | classifierInfo := make(map[string]interface{}) |
| 1620 | actionInfo := make(map[string]interface{}) |
| 1621 | |
| 1622 | classifierInfo[EthType] = uint32(LldpEthType) |
| 1623 | classifierInfo[PacketTagType] = Untagged |
| 1624 | actionInfo[TrapToHost] = true |
| 1625 | |
| 1626 | // LLDP flow is installed to trap LLDP packets on the NNI port. |
| 1627 | // We manage flow_id resource pool on per PON port basis. |
| 1628 | // Since this situation is tricky, as a hack, we pass the NNI port |
| 1629 | // index (network_intf_id) as PON port Index for the flow_id resource |
| 1630 | // pool. Also, there is no ONU Id available for trapping LLDP packets |
| 1631 | // on NNI port, use onu_id as -1 (invalid) |
| 1632 | // ****************** CAVEAT ******************* |
| 1633 | // This logic works if the NNI Port Id falls within the same valid |
| 1634 | // range of PON Port Ids. If this doesn't work for some OLT Vendor |
| 1635 | // we need to have a re-look at this. |
| 1636 | // ********************************************* |
| 1637 | |
| 1638 | var onuID = -1 |
| 1639 | var uniID = -1 |
| 1640 | var gemPortID = -1 |
| 1641 | |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 1642 | networkInterfaceID, err := plt.IntfIDFromNniPortNum(ctx, portNo) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1643 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 1644 | return olterrors.NewErrInvalidValue(log.Fields{"nni-port-number": portNo}, err).Log() |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1645 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1646 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, networkInterfaceID, int32(onuID), int32(uniID), flow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1647 | logger.Infow(ctx, "flow-exists--not-re-adding", log.Fields{"device-id": f.deviceHandler.device.Id}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1648 | return nil |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1649 | } |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1650 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1651 | classifierProto, err := makeOpenOltClassifierField(classifierInfo) |
| 1652 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1653 | return olterrors.NewErrInvalidValue( |
| 1654 | log.Fields{ |
| 1655 | "classifier": classifierInfo, |
| 1656 | "device-id": f.deviceHandler.device.Id}, err) |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1657 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1658 | logger.Debugw(ctx, "created-classifier-proto", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1659 | log.Fields{ |
| 1660 | "classifier": *classifierProto, |
| 1661 | "device-id": f.deviceHandler.device.Id}) |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 1662 | actionProto, err := makeOpenOltActionField(actionInfo, classifierInfo) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1663 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1664 | return olterrors.NewErrInvalidValue( |
| 1665 | log.Fields{ |
| 1666 | "action": actionInfo, |
| 1667 | "device-id": f.deviceHandler.device.Id}, err) |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1668 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1669 | logger.Debugw(ctx, "created-action-proto", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1670 | log.Fields{ |
| 1671 | "action": *actionProto, |
| 1672 | "device-id": f.deviceHandler.device.Id}) |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1673 | |
| 1674 | downstreamflow := openoltpb2.Flow{AccessIntfId: int32(-1), // AccessIntfId not required |
| 1675 | OnuId: int32(onuID), // OnuId not required |
| 1676 | UniId: int32(uniID), // UniId not used |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1677 | FlowId: flow.Id, |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1678 | FlowType: Downstream, |
| 1679 | NetworkIntfId: int32(networkInterfaceID), |
| 1680 | GemportId: int32(gemPortID), |
| 1681 | Classifier: classifierProto, |
| 1682 | Action: actionProto, |
| 1683 | Priority: int32(flow.Priority), |
| 1684 | Cookie: flow.Cookie, |
| 1685 | PortNo: portNo} |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1686 | if err := f.addFlowToDevice(ctx, flow, &downstreamflow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1687 | return olterrors.NewErrFlowOp("add", flow.Id, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1688 | log.Fields{ |
| 1689 | "flow": downstreamflow, |
| 1690 | "device-id": f.deviceHandler.device.Id}, err) |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 1691 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1692 | logger.Infow(ctx, "lldp-trap-on-nni-flow-added-to-device-successfully", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1693 | log.Fields{ |
| 1694 | "device-id": f.deviceHandler.device.Id, |
| 1695 | "onu-id": onuID, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1696 | "flow-id": flow.Id}) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1697 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1698 | return nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1699 | } |
| 1700 | |
Matteo Scandolo | d625b4c | 2020-04-02 16:16:01 -0700 | [diff] [blame] | 1701 | func getUniPortPath(oltID string, intfID uint32, onuID int32, uniID int32) string { |
| 1702 | return fmt.Sprintf("olt-{%s}/pon-{%d}/onu-{%d}/uni-{%d}", oltID, intfID, onuID, uniID) |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 1703 | } |
| 1704 | |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1705 | //getOnuDevice to fetch onu from cache or core. |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1706 | func (f *OpenOltFlowMgr) getOnuDevice(ctx context.Context, intfID uint32, onuID uint32) (*OnuDevice, error) { |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1707 | onuKey := f.deviceHandler.formOnuKey(intfID, onuID) |
| 1708 | onuDev, ok := f.deviceHandler.onus.Load(onuKey) |
| 1709 | if !ok { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1710 | logger.Debugw(ctx, "couldnt-find-onu-in-cache", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1711 | log.Fields{ |
| 1712 | "intf-id": intfID, |
| 1713 | "onu-id": onuID, |
| 1714 | "device-id": f.deviceHandler.device.Id}) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1715 | onuDevice, err := f.getChildDevice(ctx, intfID, onuID) |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1716 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1717 | return nil, olterrors.NewErrNotFound("onu-child-device", |
| 1718 | log.Fields{ |
| 1719 | "onu-id": onuID, |
| 1720 | "intf-id": intfID, |
| 1721 | "device-id": f.deviceHandler.device.Id}, err) |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1722 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1723 | onuDev = NewOnuDevice(onuDevice.Id, onuDevice.Type, onuDevice.SerialNumber, onuDevice.ProxyAddress.OnuId, onuDevice.ProxyAddress.ChannelId, onuDevice.ProxyAddress.DeviceId, false, onuDevice.AdapterEndpoint) |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1724 | //better to ad the device to cache here. |
| 1725 | f.deviceHandler.StoreOnuDevice(onuDev.(*OnuDevice)) |
| 1726 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1727 | logger.Debugw(ctx, "found-onu-in-cache", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1728 | log.Fields{ |
| 1729 | "intf-id": intfID, |
| 1730 | "onu-id": onuID, |
| 1731 | "device-id": f.deviceHandler.device.Id}) |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1732 | } |
| 1733 | |
| 1734 | return onuDev.(*OnuDevice), nil |
| 1735 | } |
| 1736 | |
| 1737 | //getChildDevice to fetch onu |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1738 | func (f *OpenOltFlowMgr) getChildDevice(ctx context.Context, intfID uint32, onuID uint32) (*voltha.Device, error) { |
| 1739 | logger.Infow(ctx, "GetChildDevice", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1740 | log.Fields{ |
| 1741 | "pon-port": intfID, |
| 1742 | "onu-id": onuID, |
| 1743 | "device-id": f.deviceHandler.device.Id}) |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 1744 | parentPortNo := plt.IntfIDToPortNo(intfID, voltha.Port_PON_OLT) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1745 | onuDevice, err := f.deviceHandler.GetChildDevice(ctx, parentPortNo, onuID) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 1746 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1747 | return nil, olterrors.NewErrNotFound("onu", |
| 1748 | log.Fields{ |
| 1749 | "interface-id": parentPortNo, |
| 1750 | "onu-id": onuID, |
| 1751 | "device-id": f.deviceHandler.device.Id}, |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 1752 | err) |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1753 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1754 | logger.Infow(ctx, "successfully-received-child-device-from-core", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1755 | log.Fields{ |
| 1756 | "device-id": f.deviceHandler.device.Id, |
| 1757 | "child_device_id": onuDevice.Id, |
| 1758 | "child_device_sn": onuDevice.SerialNumber}) |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 1759 | return onuDevice, nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 1760 | } |
| 1761 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1762 | func (f *OpenOltFlowMgr) sendDeleteGemPortToChild(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, gemPortID uint32, tpPath string) error { |
| 1763 | onuDev, err := f.getOnuDevice(ctx, intfID, onuID) |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1764 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1765 | logger.Debugw(ctx, "couldnt-find-onu-child-device", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1766 | log.Fields{ |
| 1767 | "intf-id": intfID, |
| 1768 | "onu-id": onuID, |
| 1769 | "uni-id": uniID, |
| 1770 | "device-id": f.deviceHandler.device.Id}) |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1771 | return err |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1772 | } |
| 1773 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1774 | delGemPortMsg := &ic.DeleteGemPortMessage{ |
| 1775 | DeviceId: onuDev.deviceID, |
| 1776 | UniId: uniID, |
| 1777 | TpInstancePath: tpPath, |
| 1778 | GemPortId: gemPortID, |
| 1779 | } |
| 1780 | logger.Debugw(ctx, "sending-gem-port-delete-to-openonu-adapter", log.Fields{"msg": *delGemPortMsg, "child-device-id": onuDev.deviceID}) |
| 1781 | |
| 1782 | if err := f.deviceHandler.sendDeleteGemPortToChildAdapter(ctx, onuDev.adapterEndpoint, delGemPortMsg); err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1783 | return olterrors.NewErrCommunication("send-delete-gem-port-to-onu-adapter", |
| 1784 | log.Fields{ |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1785 | "from-adapter": f.deviceHandler.openOLT.config.AdapterEndpoint, |
| 1786 | "to-adapter": onuDev.adapterEndpoint, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1787 | "onu-id": onuDev.deviceID, |
| 1788 | "proxyDeviceID": onuDev.proxyDeviceID, |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1789 | "device-id": f.deviceHandler.device.Id}, err) |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1790 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1791 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1792 | logger.Infow(ctx, "success-sending-del-gem-port-to-onu-adapter", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1793 | log.Fields{ |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1794 | "msg": delGemPortMsg, |
| 1795 | "from-adapter": f.deviceHandler.device.Type, |
| 1796 | "to-adapter": onuDev.deviceType, |
| 1797 | "device-id": f.deviceHandler.device.Id, |
| 1798 | "child-device-id": onuDev.deviceID}) |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1799 | return nil |
| 1800 | } |
| 1801 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1802 | func (f *OpenOltFlowMgr) sendDeleteTcontToChild(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, allocID uint32, tpPath string) error { |
| 1803 | onuDev, err := f.getOnuDevice(ctx, intfID, onuID) |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1804 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1805 | logger.Warnw(ctx, "couldnt-find-onu-child-device", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1806 | log.Fields{ |
| 1807 | "intf-id": intfID, |
| 1808 | "onu-id": onuID, |
| 1809 | "uni-id": uniID, |
| 1810 | "device-id": f.deviceHandler.device.Id}) |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 1811 | return err |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1812 | } |
| 1813 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1814 | delTcontMsg := &ic.DeleteTcontMessage{ |
| 1815 | DeviceId: onuDev.deviceID, |
| 1816 | UniId: uniID, |
| 1817 | TpInstancePath: tpPath, |
| 1818 | AllocId: allocID, |
| 1819 | } |
| 1820 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1821 | logger.Debugw(ctx, "sending-tcont-delete-to-openonu-adapter", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1822 | log.Fields{ |
| 1823 | "msg": *delTcontMsg, |
| 1824 | "device-id": f.deviceHandler.device.Id}) |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1825 | |
| 1826 | if err := f.deviceHandler.sendDeleteTContToChildAdapter(ctx, onuDev.adapterEndpoint, delTcontMsg); err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1827 | return olterrors.NewErrCommunication("send-delete-tcont-to-onu-adapter", |
| 1828 | log.Fields{ |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1829 | "from-adapter": f.deviceHandler.openOLT.config.AdapterEndpoint, |
| 1830 | "to-adapter": onuDev.adapterEndpoint, |
| 1831 | "onu-id": onuDev.deviceID, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1832 | "proxyDeviceID": onuDev.proxyDeviceID, |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1833 | "device-id": f.deviceHandler.device.Id}, err) |
| 1834 | |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1835 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1836 | logger.Infow(ctx, "success-sending-del-tcont-to-onu-adapter", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1837 | log.Fields{ |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1838 | "msg": delTcontMsg, |
| 1839 | "device-id": f.deviceHandler.device.Id, |
| 1840 | "child-device-id": onuDev.deviceID}) |
Girish Gowdra | 6b13058 | 2019-11-20 16:45:20 +0530 | [diff] [blame] | 1841 | return nil |
| 1842 | } |
| 1843 | |
Girish Gowdra | c303740 | 2020-01-22 20:29:53 +0530 | [diff] [blame] | 1844 | // Once the gemport is released for a given onu, it also has to be cleared from local cache |
| 1845 | // which was used for deriving the gemport->logicalPortNo during packet-in. |
| 1846 | // Otherwise stale info continues to exist after gemport is freed and wrong logicalPortNo |
| 1847 | // is conveyed to ONOS during packet-in OF message. |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1848 | func (f *OpenOltFlowMgr) deleteGemPortFromLocalCache(ctx context.Context, intfID uint32, onuID uint32, gemPortID uint32) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 1849 | logger.Infow(ctx, "deleting-gem-from-local-cache", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1850 | log.Fields{ |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 1851 | "gem-port-id": gemPortID, |
| 1852 | "intf-id": intfID, |
| 1853 | "onu-id": onuID, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1854 | "device-id": f.deviceHandler.device.Id}) |
| 1855 | f.onuGemInfoLock.RLock() |
| 1856 | onugem, ok := f.onuGemInfoMap[onuID] |
| 1857 | f.onuGemInfoLock.RUnlock() |
| 1858 | if !ok { |
| 1859 | logger.Warnw(ctx, "onu gem info already cleared from cache", log.Fields{ |
| 1860 | "gem-port-id": gemPortID, |
| 1861 | "intf-id": intfID, |
| 1862 | "onu-id": onuID, |
| 1863 | "device-id": f.deviceHandler.device.Id}) |
| 1864 | return |
| 1865 | } |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 1866 | deleteLoop: |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1867 | for j, gem := range onugem.GemPorts { |
| 1868 | // If the gemport is found, delete it from local cache. |
| 1869 | if gem == gemPortID { |
| 1870 | onugem.GemPorts = append(onugem.GemPorts[:j], onugem.GemPorts[j+1:]...) |
| 1871 | f.onuGemInfoLock.Lock() |
| 1872 | f.onuGemInfoMap[onuID] = onugem |
| 1873 | f.onuGemInfoLock.Unlock() |
| 1874 | logger.Infow(ctx, "removed-gemport-from-local-cache", |
| 1875 | log.Fields{ |
| 1876 | "intf-id": intfID, |
| 1877 | "onu-id": onuID, |
| 1878 | "deletedgemport-id": gemPortID, |
| 1879 | "gemports": onugem.GemPorts, |
| 1880 | "device-id": f.deviceHandler.device.Id}) |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 1881 | break deleteLoop |
Girish Gowdra | c303740 | 2020-01-22 20:29:53 +0530 | [diff] [blame] | 1882 | } |
| 1883 | } |
| 1884 | } |
| 1885 | |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 1886 | //clearResources clears pon resources in kv store and the device |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 1887 | // nolint: gocyclo |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1888 | func (f *OpenOltFlowMgr) clearResources(ctx context.Context, intfID uint32, onuID int32, uniID int32, |
Girish Gowdra | 82c8098 | 2021-03-26 16:22:02 -0700 | [diff] [blame] | 1889 | gemPortID int32, flowID uint64, portNum uint32, tpID uint32) error { |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1890 | |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1891 | uni := getUniPortPath(f.deviceHandler.device.Id, intfID, onuID, uniID) |
| 1892 | tpPath := f.getTPpath(ctx, intfID, uni, tpID) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1893 | logger.Debugw(ctx, "getting-techprofile-instance-for-subscriber", |
| 1894 | log.Fields{ |
| 1895 | "tpPath": tpPath, |
| 1896 | "device-id": f.deviceHandler.device.Id}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1897 | |
| 1898 | used := f.isGemPortUsedByAnotherFlow(uint32(gemPortID)) |
| 1899 | |
| 1900 | if used { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1901 | f.gemToFlowIDsKey.RLock() |
| 1902 | flowIDs := f.gemToFlowIDs[uint32(gemPortID)] |
| 1903 | f.gemToFlowIDsKey.RUnlock() |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1904 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1905 | for i, flowIDinMap := range flowIDs { |
| 1906 | if flowIDinMap == flowID { |
| 1907 | flowIDs = append(flowIDs[:i], flowIDs[i+1:]...) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1908 | f.gemToFlowIDsKey.Lock() |
| 1909 | f.gemToFlowIDs[uint32(gemPortID)] = flowIDs |
| 1910 | f.gemToFlowIDsKey.Unlock() |
| 1911 | // everytime gemToFlowIDs cache is updated the same should be updated |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1912 | // in kv store by calling UpdateFlowIDsForGem |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1913 | if err := f.resourceMgr.UpdateFlowIDsForGem(ctx, intfID, uint32(gemPortID), flowIDs); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1914 | return err |
| 1915 | } |
| 1916 | break |
| 1917 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 1918 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1919 | logger.Debugw(ctx, "gem-port-id-is-still-used-by-other-flows", |
| 1920 | log.Fields{ |
| 1921 | "gemport-id": gemPortID, |
| 1922 | "usedByFlows": flowIDs, |
| 1923 | "device-id": f.deviceHandler.device.Id}) |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1924 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1925 | return nil |
| 1926 | } |
| 1927 | logger.Debugf(ctx, "gem-port-id %d is-not-used-by-another-flow--releasing-the-gem-port", gemPortID) |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1928 | f.deleteGemPortFromLocalCache(ctx, intfID, uint32(onuID), uint32(gemPortID)) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1929 | _ = f.resourceMgr.RemoveGemFromOnuGemInfo(ctx, intfID, uint32(onuID), uint32(gemPortID)) // ignore error and proceed. |
| 1930 | //everytime an entry is deleted from gemToFlowIDs cache, the same should be updated in kv as well |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1931 | // by calling DeleteFlowIDsForGem |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1932 | f.gemToFlowIDsKey.Lock() |
| 1933 | delete(f.gemToFlowIDs, uint32(gemPortID)) |
| 1934 | f.gemToFlowIDsKey.Unlock() |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1935 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1936 | f.resourceMgr.DeleteFlowIDsForGem(ctx, intfID, uint32(gemPortID)) |
| 1937 | |
| 1938 | f.resourceMgr.FreeGemPortID(ctx, intfID, uint32(onuID), uint32(uniID), uint32(gemPortID)) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1939 | |
Mahir Gunyel | 199570a | 2021-07-04 15:39:36 -0700 | [diff] [blame] | 1940 | //First remove TCONT from child if needed. Then remove the GEM. |
| 1941 | //It is expected from child to clean ani side conf if all GEMs of TP are deleted. |
| 1942 | //Before this, ensure that the related TCONT deletions are informed to child. |
| 1943 | //Refer to VOL-4215. |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1944 | techprofileInst, err := f.techprofile.GetTPInstance(ctx, tpPath) |
Girish Gowdra | 78fd63d | 2021-10-18 14:34:53 -0700 | [diff] [blame] | 1945 | if err != nil || techprofileInst == nil { |
| 1946 | // The child device is possibly deleted which in turn had cleaned up all the resources (including tp instances), check.. |
| 1947 | childDevice, _ := f.getChildDevice(ctx, intfID, uint32(onuID)) // do not care about the error code |
| 1948 | if childDevice == nil { |
| 1949 | // happens when subscriber un-provision is immediately followed by child device delete |
| 1950 | // before all the flow removes are processed, the child device delete has already arrived and cleaned up all the resources |
| 1951 | logger.Warnw(ctx, "child device and its associated resources are already cleared", log.Fields{"intfID": intfID, "onuID": onuID, "uniID": uniID}) |
| 1952 | return nil |
| 1953 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1954 | return olterrors.NewErrNotFound("tech-profile-in-kv-store", |
| 1955 | log.Fields{ |
| 1956 | "tp-id": tpID, |
| 1957 | "path": tpPath}, err) |
| 1958 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1959 | switch techprofileInst := techprofileInst.(type) { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1960 | case *tp_pb.TechProfileInstance: |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 1961 | ok, _ := f.isTechProfileUsedByAnotherGem(ctx, intfID, uint32(onuID), uint32(uniID), techprofileInst, uint32(gemPortID)) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1962 | if !ok { |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1963 | if err := f.resourceMgr.RemoveTechProfileIDForOnu(ctx, intfID, uint32(onuID), uint32(uniID), tpID); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1964 | logger.Warn(ctx, err) |
| 1965 | } |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1966 | if err := f.DeleteTechProfileInstance(ctx, intfID, uint32(onuID), uint32(uniID), "", tpID); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1967 | logger.Warn(ctx, err) |
| 1968 | } |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1969 | if err := f.RemoveSchedulerQueues(ctx, schedQueue{direction: tp_pb.Direction_UPSTREAM, intfID: intfID, onuID: uint32(onuID), uniID: uint32(uniID), tpID: tpID, uniPort: portNum, tpInst: techprofileInst}); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1970 | logger.Warn(ctx, err) |
| 1971 | } |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1972 | if err := f.RemoveSchedulerQueues(ctx, schedQueue{direction: tp_pb.Direction_DOWNSTREAM, intfID: intfID, onuID: uint32(onuID), uniID: uint32(uniID), tpID: tpID, uniPort: portNum, tpInst: techprofileInst}); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1973 | logger.Warn(ctx, err) |
| 1974 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1975 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1976 | case *tp_pb.EponTechProfileInstance: |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1977 | if err := f.resourceMgr.RemoveTechProfileIDForOnu(ctx, intfID, uint32(onuID), uint32(uniID), tpID); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1978 | logger.Warn(ctx, err) |
| 1979 | } |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1980 | if err := f.DeleteTechProfileInstance(ctx, intfID, uint32(onuID), uint32(uniID), "", tpID); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1981 | logger.Warn(ctx, err) |
| 1982 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1983 | f.resourceMgr.FreeAllocID(ctx, intfID, uint32(onuID), uint32(uniID), techprofileInst.AllocId) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1984 | // Delete the TCONT on the ONU. |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 1985 | if err := f.sendDeleteTcontToChild(ctx, intfID, uint32(onuID), uint32(uniID), techprofileInst.AllocId, tpPath); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1986 | logger.Errorw(ctx, "error-processing-delete-tcont-towards-onu", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1987 | log.Fields{ |
Girish Gowdra | a482f27 | 2021-03-24 23:04:19 -0700 | [diff] [blame] | 1988 | "intf": intfID, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 1989 | "onu-id": onuID, |
| 1990 | "uni-id": uniID, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1991 | "device-id": f.deviceHandler.device.Id, |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1992 | "alloc-id": techprofileInst.AllocId, |
| 1993 | "error": err}) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 1994 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 1995 | default: |
| 1996 | logger.Errorw(ctx, "error-unknown-tech", |
| 1997 | log.Fields{ |
| 1998 | "techprofileInst": techprofileInst}) |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 1999 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2000 | |
Mahir Gunyel | 199570a | 2021-07-04 15:39:36 -0700 | [diff] [blame] | 2001 | // Delete the gem port on the ONU. Send Gem Removal After TCONT removal. |
| 2002 | if err := f.sendDeleteGemPortToChild(ctx, intfID, uint32(onuID), uint32(uniID), uint32(gemPortID), tpPath); err != nil { |
| 2003 | logger.Errorw(ctx, "error-processing-delete-gem-port-towards-onu", |
| 2004 | log.Fields{ |
| 2005 | "err": err, |
| 2006 | "intfID": intfID, |
| 2007 | "onu-id": onuID, |
| 2008 | "uni-id": uniID, |
| 2009 | "device-id": f.deviceHandler.device.Id, |
| 2010 | "gemport-id": gemPortID}) |
| 2011 | } |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2012 | return nil |
| 2013 | } |
| 2014 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2015 | // nolint: gocyclo |
Girish Gowdra | e8f473b | 2020-10-16 11:07:21 -0700 | [diff] [blame] | 2016 | func (f *OpenOltFlowMgr) clearFlowFromDeviceAndResourceManager(ctx context.Context, flow *ofp.OfpFlowStats, flowDirection string) error { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2017 | logger.Infow(ctx, "clear-flow-from-resource-manager", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2018 | log.Fields{ |
| 2019 | "flowDirection": flowDirection, |
| 2020 | "flow": *flow, |
| 2021 | "device-id": f.deviceHandler.device.Id}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2022 | |
| 2023 | if flowDirection == Multicast { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2024 | return f.clearMulticastFlowFromResourceManager(ctx, flow) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2025 | } |
| 2026 | |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2027 | classifierInfo := make(map[string]interface{}) |
| 2028 | |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2029 | portNum, Intf, onu, uni, inPort, ethType, err := plt.FlowExtractInfo(ctx, flow, flowDirection) |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2030 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2031 | logger.Error(ctx, err) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2032 | return err |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2033 | } |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 2034 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2035 | onuID := int32(onu) |
| 2036 | uniID := int32(uni) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2037 | tpID, err := getTpIDFromFlow(ctx, flow) |
| 2038 | if err != nil { |
| 2039 | return olterrors.NewErrNotFound("tp-id", |
| 2040 | log.Fields{ |
| 2041 | "flow": flow, |
| 2042 | "intf-id": Intf, |
| 2043 | "onu-id": onuID, |
| 2044 | "uni-id": uniID, |
| 2045 | "device-id": f.deviceHandler.device.Id}, err) |
| 2046 | } |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2047 | |
| 2048 | for _, field := range flows.GetOfbFields(flow) { |
| 2049 | if field.Type == flows.IP_PROTO { |
| 2050 | classifierInfo[IPProto] = field.GetIpProto() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2051 | logger.Debugw(ctx, "field-type-ip-proto", log.Fields{"classifierInfo[IP_PROTO]": classifierInfo[IPProto].(uint32)}) |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2052 | } |
| 2053 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2054 | logger.Infow(ctx, "extracted-access-info-from-flow-to-be-deleted", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2055 | log.Fields{ |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 2056 | "flow-id": flow.Id, |
| 2057 | "intf-id": Intf, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2058 | "onu-id": onuID, |
| 2059 | "uni-id": uniID}) |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2060 | |
| 2061 | if ethType == LldpEthType || ((classifierInfo[IPProto] == IPProtoDhcp) && (flowDirection == "downstream")) { |
| 2062 | onuID = -1 |
| 2063 | uniID = -1 |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2064 | logger.Debug(ctx, "trap-on-nni-flow-set-oni--uni-to- -1") |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2065 | Intf, err = plt.IntfIDFromNniPortNum(ctx, inPort) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2066 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2067 | logger.Errorw(ctx, "invalid-in-port-number", |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2068 | log.Fields{ |
| 2069 | "port-number": inPort, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2070 | "err": err}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2071 | return err |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2072 | } |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2073 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2074 | |
| 2075 | removeFlowMessage := openoltpb2.Flow{FlowId: flow.Id, AccessIntfId: int32(Intf), OnuId: onuID, UniId: uniID, TechProfileId: tpID, FlowType: flowDirection} |
| 2076 | logger.Debugw(ctx, "flow-to-be-deleted", log.Fields{"flow": flow}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2077 | if err = f.removeFlowFromDevice(ctx, &removeFlowMessage, flow.Id); err != nil { |
| 2078 | return err |
| 2079 | } |
Girish Gowdra | 82c8098 | 2021-03-26 16:22:02 -0700 | [diff] [blame] | 2080 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2081 | f.flowIDToGemsLock.Lock() |
| 2082 | gems, ok := f.flowIDToGems[flow.Id] |
| 2083 | if !ok { |
| 2084 | logger.Errorw(ctx, "flow-id-to-gem-map-not-found", log.Fields{"flowID": flow.Id}) |
| 2085 | f.flowIDToGemsLock.Unlock() |
| 2086 | return olterrors.NewErrNotFound("flow-id-to-gem-map-not-found", log.Fields{"flowID": flow.Id}, nil) |
| 2087 | } |
| 2088 | copyOfGems := make([]uint32, len(gems)) |
| 2089 | _ = copy(copyOfGems, gems) |
| 2090 | // Delete the flow-id to gemport list entry from the map now the flow is deleted. |
| 2091 | delete(f.flowIDToGems, flow.Id) |
| 2092 | f.flowIDToGemsLock.Unlock() |
| 2093 | |
| 2094 | logger.Debugw(ctx, "gems-to-be-cleared", log.Fields{"gems": copyOfGems}) |
| 2095 | for _, gem := range copyOfGems { |
| 2096 | if err = f.clearResources(ctx, Intf, onuID, uniID, int32(gem), flow.Id, portNum, tpID); err != nil { |
Girish Gowdra | 0aca498 | 2021-01-04 12:44:27 -0800 | [diff] [blame] | 2097 | logger.Errorw(ctx, "failed-to-clear-resources-for-flow", log.Fields{ |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2098 | "flow-id": flow.Id, |
| 2099 | "device-id": f.deviceHandler.device.Id, |
| 2100 | "onu-id": onuID, |
| 2101 | "intf": Intf, |
| 2102 | "gem": gem, |
| 2103 | "err": err, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2104 | }) |
| 2105 | return err |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2106 | } |
Abhilash Laxmeshwar | b7300fe | 2019-11-13 03:38:33 +0530 | [diff] [blame] | 2107 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2108 | |
Girish Gowdra | 82c8098 | 2021-03-26 16:22:02 -0700 | [diff] [blame] | 2109 | // Decrement reference count for the meter associated with the given <(pon_id, onu_id, uni_id)>/<tp_id>/meter_id/<direction> |
| 2110 | if err := f.resourceMgr.HandleMeterInfoRefCntUpdate(ctx, flowDirection, Intf, uint32(onuID), uint32(uniID), tpID, false); err != nil { |
| 2111 | return err |
| 2112 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2113 | return nil |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 2114 | } |
| 2115 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2116 | //RemoveFlow removes the flow from the device |
Girish Gowdra | cefae19 | 2020-03-19 18:14:10 -0700 | [diff] [blame] | 2117 | func (f *OpenOltFlowMgr) RemoveFlow(ctx context.Context, flow *ofp.OfpFlowStats) error { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2118 | |
Matteo Scandolo | f16389e | 2021-05-18 00:47:08 +0000 | [diff] [blame] | 2119 | logger.Infow(ctx, "removing-flow", log.Fields{"flow": *flow}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2120 | var direction string |
| 2121 | actionInfo := make(map[string]interface{}) |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 2122 | |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2123 | for _, action := range flows.GetActions(flow) { |
| 2124 | if action.Type == flows.OUTPUT { |
| 2125 | if out := action.GetOutput(); out != nil { |
| 2126 | actionInfo[Output] = out.GetPort() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2127 | logger.Debugw(ctx, "action-type-output", log.Fields{"out_port": actionInfo[Output].(uint32)}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2128 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2129 | logger.Error(ctx, "invalid-output-port-in-action") |
Girish Gowdra | cefae19 | 2020-03-19 18:14:10 -0700 | [diff] [blame] | 2130 | return olterrors.NewErrInvalidValue(log.Fields{"invalid-out-port-action": 0}, nil) |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 2131 | } |
| 2132 | } |
| 2133 | } |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2134 | |
| 2135 | if flows.HasGroup(flow) { |
| 2136 | direction = Multicast |
Girish Gowdra | e8f473b | 2020-10-16 11:07:21 -0700 | [diff] [blame] | 2137 | return f.clearFlowFromDeviceAndResourceManager(ctx, flow, direction) |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2138 | } else if plt.IsUpstream(actionInfo[Output].(uint32)) { |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2139 | direction = Upstream |
| 2140 | } else { |
| 2141 | direction = Downstream |
| 2142 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2143 | |
Girish Gowdra | cefae19 | 2020-03-19 18:14:10 -0700 | [diff] [blame] | 2144 | // Serialize flow removes on a per subscriber basis |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2145 | err := f.clearFlowFromDeviceAndResourceManager(ctx, flow, direction) |
Girish Gowdra | cefae19 | 2020-03-19 18:14:10 -0700 | [diff] [blame] | 2146 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2147 | return err |
Manjunath Vanarajulu | 28c3e82 | 2019-05-16 11:14:28 -0400 | [diff] [blame] | 2148 | } |
| 2149 | |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2150 | //isIgmpTrapDownstreamFlow return true if the flow is a downsteam IGMP trap-to-host flow; false otherwise |
| 2151 | func isIgmpTrapDownstreamFlow(classifierInfo map[string]interface{}) bool { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2152 | if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_ETHERNET_NNI { |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2153 | if ethType, ok := classifierInfo[EthType]; ok { |
| 2154 | if ethType.(uint32) == IPv4EthType { |
| 2155 | if ipProto, ok := classifierInfo[IPProto]; ok { |
| 2156 | if ipProto.(uint32) == IgmpProto { |
| 2157 | return true |
| 2158 | } |
| 2159 | } |
| 2160 | } |
| 2161 | } |
| 2162 | } |
| 2163 | return false |
| 2164 | } |
| 2165 | |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2166 | // RouteFlowToOnuChannel routes incoming flow to ONU specific channel |
| 2167 | func (f *OpenOltFlowMgr) RouteFlowToOnuChannel(ctx context.Context, flow *voltha.OfpFlowStats, addFlow bool, flowMetadata *voltha.FlowMetadata) error { |
| 2168 | // Step1 : Fill flowControlBlock |
| 2169 | // Step2 : Push the flowControlBlock to ONU channel |
| 2170 | // Step3 : Wait on response channel for response |
| 2171 | // Step4 : Return error value |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2172 | startTime := time.Now() |
| 2173 | logger.Infow(ctx, "process-flow", log.Fields{"flow": flow, "addFlow": addFlow}) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2174 | errChan := make(chan error) |
| 2175 | flowCb := flowControlBlock{ |
| 2176 | ctx: ctx, |
| 2177 | addFlow: addFlow, |
| 2178 | flow: flow, |
| 2179 | flowMetadata: flowMetadata, |
| 2180 | errChan: &errChan, |
| 2181 | } |
| 2182 | inPort, outPort := getPorts(flow) |
| 2183 | var onuID uint32 |
| 2184 | if inPort != InvalidPort && outPort != InvalidPort { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2185 | _, _, onuID, _ = plt.ExtractAccessFromFlow(inPort, outPort) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2186 | } |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 2187 | if f.flowHandlerRoutineActive[onuID] { |
| 2188 | // inPort or outPort is InvalidPort for trap-from-nni flows. |
| 2189 | // In the that case onuID is 0 which is the reserved index for trap-from-nni flows in the f.incomingFlows slice |
| 2190 | // Send the flowCb on the ONU flow channel |
| 2191 | f.incomingFlows[onuID] <- flowCb |
| 2192 | // Wait on the channel for flow handlers return value |
| 2193 | err := <-errChan |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 2194 | logger.Infow(ctx, "process-flow-received-resp", log.Fields{"err": err, "totalTimeSeconds": time.Since(startTime).Seconds()}) |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 2195 | return err |
| 2196 | } |
| 2197 | logger.Errorw(ctx, "flow handler routine not active for onu", log.Fields{"onuID": onuID, "ponPortIdx": f.ponPortIdx}) |
| 2198 | return fmt.Errorf("flow-handler-routine-not-active-for-onu-%v-pon-%d", onuID, f.ponPortIdx) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2199 | } |
| 2200 | |
| 2201 | // This routine is unique per ONU ID and blocks on flowControlBlock channel for incoming flows |
| 2202 | // Each incoming flow is processed in a synchronous manner, i.e., the flow is processed to completion before picking another |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 2203 | func (f *OpenOltFlowMgr) perOnuFlowHandlerRoutine(handlerRoutineIndex int, subscriberFlowChannel chan flowControlBlock, stopHandler chan bool) { |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2204 | for { |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 2205 | select { |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2206 | // block on the channel to receive an incoming flow |
| 2207 | // process the flow completely before proceeding to handle the next flow |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 2208 | case flowCb := <-subscriberFlowChannel: |
| 2209 | if flowCb.addFlow { |
| 2210 | logger.Info(flowCb.ctx, "adding-flow-start") |
| 2211 | startTime := time.Now() |
| 2212 | err := f.AddFlow(flowCb.ctx, flowCb.flow, flowCb.flowMetadata) |
| 2213 | logger.Infow(flowCb.ctx, "adding-flow-complete", log.Fields{"processTimeSecs": time.Since(startTime).Seconds()}) |
| 2214 | // Pass the return value over the return channel |
| 2215 | *flowCb.errChan <- err |
| 2216 | } else { |
| 2217 | logger.Info(flowCb.ctx, "removing-flow-start") |
| 2218 | startTime := time.Now() |
| 2219 | err := f.RemoveFlow(flowCb.ctx, flowCb.flow) |
| 2220 | logger.Infow(flowCb.ctx, "removing-flow-complete", log.Fields{"processTimeSecs": time.Since(startTime).Seconds()}) |
| 2221 | // Pass the return value over the return channel |
| 2222 | *flowCb.errChan <- err |
| 2223 | } |
| 2224 | case <-stopHandler: |
| 2225 | f.flowHandlerRoutineActive[handlerRoutineIndex] = false |
| 2226 | return |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 2227 | } |
| 2228 | } |
| 2229 | } |
| 2230 | |
Girish Gowdra | 4736e5c | 2021-08-25 15:19:10 -0700 | [diff] [blame] | 2231 | // StopAllFlowHandlerRoutines stops all flow handler routines. Call this when device is being rebooted or deleted |
| 2232 | func (f *OpenOltFlowMgr) StopAllFlowHandlerRoutines(ctx context.Context) { |
| 2233 | for i, v := range f.stopFlowHandlerRoutine { |
| 2234 | if f.flowHandlerRoutineActive[i] { |
| 2235 | v <- true |
| 2236 | } |
| 2237 | } |
| 2238 | logger.Debugw(ctx, "stopped all flow handler routines", log.Fields{"ponPortIdx": f.ponPortIdx}) |
| 2239 | } |
| 2240 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2241 | // AddFlow add flow to device |
Naga Manjunath | b8438aa | 2020-01-02 17:52:33 +0530 | [diff] [blame] | 2242 | // nolint: gocyclo |
Andrea Campanella | c63bba9 | 2020-03-10 17:01:04 +0100 | [diff] [blame] | 2243 | func (f *OpenOltFlowMgr) AddFlow(ctx context.Context, flow *ofp.OfpFlowStats, flowMetadata *voltha.FlowMetadata) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2244 | classifierInfo := make(map[string]interface{}) |
| 2245 | actionInfo := make(map[string]interface{}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 2246 | var UsMeterID uint32 |
| 2247 | var DsMeterID uint32 |
| 2248 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2249 | logger.Infow(ctx, "adding-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2250 | log.Fields{ |
| 2251 | "flow": flow, |
Matteo Scandolo | f16389e | 2021-05-18 00:47:08 +0000 | [diff] [blame] | 2252 | "flowmetadata": flowMetadata}) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2253 | formulateClassifierInfoFromFlow(ctx, classifierInfo, flow) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2254 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2255 | err := formulateActionInfoFromFlow(ctx, actionInfo, classifierInfo, flow) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2256 | if err != nil { |
| 2257 | // Error logging is already done in the called function |
| 2258 | // So just return in case of error |
Andrea Campanella | c63bba9 | 2020-03-10 17:01:04 +0100 | [diff] [blame] | 2259 | return err |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 2260 | } |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2261 | |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2262 | if flows.HasGroup(flow) { |
| 2263 | // handle multicast flow |
Andrea Campanella | c63bba9 | 2020-03-10 17:01:04 +0100 | [diff] [blame] | 2264 | return f.handleFlowWithGroup(ctx, actionInfo, classifierInfo, flow) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2265 | } |
| 2266 | |
manikkaraj k | 17652a7 | 2019-05-06 09:06:36 -0400 | [diff] [blame] | 2267 | /* Controller bound trap flows */ |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2268 | err = formulateControllerBoundTrapFlowInfo(ctx, actionInfo, classifierInfo, flow) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2269 | if err != nil { |
| 2270 | // error if any, already logged in the called function |
Andrea Campanella | c63bba9 | 2020-03-10 17:01:04 +0100 | [diff] [blame] | 2271 | return err |
manikkaraj k | 17652a7 | 2019-05-06 09:06:36 -0400 | [diff] [blame] | 2272 | } |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2273 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2274 | logger.Debugw(ctx, "flow-ports", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2275 | log.Fields{ |
| 2276 | "classifierinfo_inport": classifierInfo[InPort], |
| 2277 | "action_output": actionInfo[Output]}) |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2278 | portNo, intfID, onuID, uniID := plt.ExtractAccessFromFlow(classifierInfo[InPort].(uint32), actionInfo[Output].(uint32)) |
A R Karthick | 1f85b80 | 2019-10-11 05:06:05 +0000 | [diff] [blame] | 2279 | |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 2280 | if ethType, ok := classifierInfo[EthType]; ok { |
| 2281 | if ethType.(uint32) == LldpEthType { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2282 | logger.Info(ctx, "adding-lldp-flow") |
Andrea Campanella | c63bba9 | 2020-03-10 17:01:04 +0100 | [diff] [blame] | 2283 | return f.addLLDPFlow(ctx, flow, portNo) |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 2284 | } |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2285 | if ethType.(uint32) == PPPoEDEthType { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2286 | if voltha.Port_ETHERNET_NNI == plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)) { |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2287 | logger.Debug(ctx, "trap-pppoed-from-nni-flow") |
| 2288 | return f.addTrapFlowOnNNI(ctx, flow, classifierInfo, portNo) |
| 2289 | } |
| 2290 | } |
Humera Kouser | 94d7a84 | 2019-08-25 19:04:32 -0400 | [diff] [blame] | 2291 | } |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2292 | if ipProto, ok := classifierInfo[IPProto]; ok { |
| 2293 | if ipProto.(uint32) == IPProtoDhcp { |
| 2294 | if udpSrc, ok := classifierInfo[UDPSrc]; ok { |
Naga Manjunath | b8438aa | 2020-01-02 17:52:33 +0530 | [diff] [blame] | 2295 | if udpSrc.(uint32) == uint32(67) || udpSrc.(uint32) == uint32(546) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2296 | logger.Debug(ctx, "trap-dhcp-from-nni-flow") |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2297 | return f.addTrapFlowOnNNI(ctx, flow, classifierInfo, portNo) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2298 | } |
| 2299 | } |
| 2300 | } |
| 2301 | } |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2302 | if isIgmpTrapDownstreamFlow(classifierInfo) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2303 | logger.Debug(ctx, "trap-igmp-from-nni-flow") |
Andrea Campanella | c63bba9 | 2020-03-10 17:01:04 +0100 | [diff] [blame] | 2304 | return f.addIgmpTrapFlowOnNNI(ctx, flow, classifierInfo, portNo) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2305 | } |
A R Karthick | 1f85b80 | 2019-10-11 05:06:05 +0000 | [diff] [blame] | 2306 | |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 2307 | f.resourceMgr.AddUniPortToOnuInfo(ctx, intfID, onuID, portNo) |
Girish Gowdra | bcf98af | 2021-07-01 08:24:42 -0700 | [diff] [blame] | 2308 | // also update flowmgr cache |
| 2309 | f.onuGemInfoLock.Lock() |
| 2310 | onugem, ok := f.onuGemInfoMap[onuID] |
| 2311 | if ok { |
| 2312 | found := false |
| 2313 | for _, uni := range onugem.UniPorts { |
| 2314 | if uni == portNo { |
| 2315 | found = true |
| 2316 | break |
| 2317 | } |
| 2318 | } |
| 2319 | if !found { |
| 2320 | onugem.UniPorts = append(onugem.UniPorts, portNo) |
| 2321 | f.onuGemInfoMap[onuID] = onugem |
| 2322 | logger.Infow(ctx, "added uni port to onugem cache", log.Fields{"uni": portNo}) |
| 2323 | } |
| 2324 | } |
| 2325 | f.onuGemInfoLock.Unlock() |
A R Karthick | 1f85b80 | 2019-10-11 05:06:05 +0000 | [diff] [blame] | 2326 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2327 | TpID, err := getTpIDFromFlow(ctx, flow) |
Chaitrashree G S | 90a1795 | 2019-11-14 21:51:21 -0500 | [diff] [blame] | 2328 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2329 | return olterrors.NewErrNotFound("tpid-for-flow", |
| 2330 | log.Fields{ |
| 2331 | "flow": flow, |
| 2332 | "intf-id": IntfID, |
| 2333 | "onu-id": onuID, |
| 2334 | "uni-id": uniID}, err) |
Chaitrashree G S | 90a1795 | 2019-11-14 21:51:21 -0500 | [diff] [blame] | 2335 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2336 | logger.Debugw(ctx, "tpid-for-this-subcriber", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2337 | log.Fields{ |
| 2338 | "tp-id": TpID, |
| 2339 | "intf-id": intfID, |
| 2340 | "onu-id": onuID, |
| 2341 | "uni-id": uniID}) |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2342 | if plt.IsUpstream(actionInfo[Output].(uint32)) { |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 2343 | UsMeterID = flows.GetMeterIdFromFlow(flow) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2344 | logger.Debugw(ctx, "upstream-flow-meter-id", log.Fields{"us-meter-id": UsMeterID}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 2345 | } else { |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 2346 | DsMeterID = flows.GetMeterIdFromFlow(flow) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2347 | logger.Debugw(ctx, "downstream-flow-meter-id", log.Fields{"ds-meter-id": DsMeterID}) |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 2348 | |
| 2349 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2350 | return f.processAddFlow(ctx, intfID, onuID, uniID, portNo, classifierInfo, actionInfo, flow, TpID, UsMeterID, DsMeterID, flowMetadata) |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 2351 | } |
Girish Gowdra | 3d63303 | 2019-12-10 16:37:05 +0530 | [diff] [blame] | 2352 | |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2353 | // handleFlowWithGroup adds multicast flow to the device. |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2354 | func (f *OpenOltFlowMgr) handleFlowWithGroup(ctx context.Context, actionInfo, classifierInfo map[string]interface{}, flow *ofp.OfpFlowStats) error { |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2355 | classifierInfo[PacketTagType] = DoubleTag |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2356 | logger.Debugw(ctx, "add-multicast-flow", log.Fields{ |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2357 | "classifier-info": classifierInfo, |
| 2358 | "actionInfo": actionInfo}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2359 | |
Esin Karaman | 65409d8 | 2020-03-18 10:58:18 +0000 | [diff] [blame] | 2360 | networkInterfaceID, err := f.getNNIInterfaceIDOfMulticastFlow(ctx, classifierInfo) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2361 | if err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2362 | return olterrors.NewErrNotFound("multicast-in-port", log.Fields{"classifier": classifierInfo}, err) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2363 | } |
Esin Karaman | fcddfcf | 2020-03-04 13:34:38 +0000 | [diff] [blame] | 2364 | |
Esin Karaman | fcddfcf | 2020-03-04 13:34:38 +0000 | [diff] [blame] | 2365 | delete(classifierInfo, EthType) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2366 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2367 | onuID := NoneOnuID |
| 2368 | uniID := NoneUniID |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2369 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2370 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, networkInterfaceID, int32(onuID), int32(uniID), flow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2371 | logger.Infow(ctx, "multicast-flow-exists-not-re-adding", log.Fields{"classifier-info": classifierInfo}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2372 | return nil |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2373 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2374 | classifierProto, err := makeOpenOltClassifierField(classifierInfo) |
| 2375 | if err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2376 | return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifierInfo}, err) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2377 | } |
| 2378 | groupID := actionInfo[GroupID].(uint32) |
| 2379 | multicastFlow := openoltpb2.Flow{ |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2380 | FlowId: flow.Id, |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2381 | FlowType: Multicast, |
| 2382 | NetworkIntfId: int32(networkInterfaceID), |
| 2383 | GroupId: groupID, |
| 2384 | Classifier: classifierProto, |
| 2385 | Priority: int32(flow.Priority), |
| 2386 | Cookie: flow.Cookie} |
| 2387 | |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 2388 | if err := f.addFlowToDevice(ctx, flow, &multicastFlow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2389 | return olterrors.NewErrFlowOp("add", flow.Id, log.Fields{"flow": multicastFlow}, err) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2390 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2391 | logger.Info(ctx, "multicast-flow-added-to-device-successfully") |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2392 | //get cached group |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 2393 | if group, _, err := f.grpMgr.getFlowGroupFromKVStore(ctx, groupID, true); err == nil { |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2394 | //calling groupAdd to set group members after multicast flow creation |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 2395 | if err := f.grpMgr.ModifyGroup(ctx, group); err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2396 | return olterrors.NewErrGroupOp("modify", groupID, log.Fields{"group": group}, err) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2397 | } |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 2398 | //cached group can be removed now |
| 2399 | if err := f.resourceMgr.RemoveFlowGroupFromKVStore(ctx, groupID, true); err != nil { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2400 | logger.Warnw(ctx, "failed-to-remove-flow-group", log.Fields{"group-id": groupID, "err": err}) |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 2401 | } |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2402 | } |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2403 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2404 | return nil |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2405 | } |
| 2406 | |
Esin Karaman | 65409d8 | 2020-03-18 10:58:18 +0000 | [diff] [blame] | 2407 | //getNNIInterfaceIDOfMulticastFlow returns associated NNI interface id of the inPort criterion if exists; returns the first NNI interface of the device otherwise |
| 2408 | func (f *OpenOltFlowMgr) getNNIInterfaceIDOfMulticastFlow(ctx context.Context, classifierInfo map[string]interface{}) (uint32, error) { |
| 2409 | if inPort, ok := classifierInfo[InPort]; ok { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2410 | nniInterfaceID, err := plt.IntfIDFromNniPortNum(ctx, inPort.(uint32)) |
Esin Karaman | 65409d8 | 2020-03-18 10:58:18 +0000 | [diff] [blame] | 2411 | if err != nil { |
| 2412 | return 0, olterrors.NewErrInvalidValue(log.Fields{"nni-in-port-number": inPort}, err) |
| 2413 | } |
| 2414 | return nniInterfaceID, nil |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2415 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2416 | |
| 2417 | // TODO: For now we support only one NNI port in VOLTHA. We shall use only the first NNI port, i.e., interface-id 0. |
| 2418 | return 0, nil |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 2419 | } |
| 2420 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2421 | //sendTPDownloadMsgToChild send payload |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2422 | func (f *OpenOltFlowMgr) sendTPDownloadMsgToChild(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, uni string, TpID uint32, tpInst tp_pb.TechProfileInstance) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2423 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2424 | onuDev, err := f.getOnuDevice(ctx, intfID, onuID) |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 2425 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2426 | logger.Errorw(ctx, "couldnt-find-onu-child-device", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2427 | log.Fields{ |
| 2428 | "intf-id": intfID, |
| 2429 | "onu-id": onuID, |
| 2430 | "uni-id": uniID}) |
Mahir Gunyel | 0f89fd2 | 2020-04-11 18:24:42 -0700 | [diff] [blame] | 2431 | return err |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 2432 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2433 | logger.Debugw(ctx, "got-child-device-from-olt-device-handler", log.Fields{"onu-id": onuDev.deviceID}) |
manikkaraj k | 17652a7 | 2019-05-06 09:06:36 -0400 | [diff] [blame] | 2434 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2435 | tpPath := f.getTPpath(ctx, intfID, uni, TpID) |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 2436 | tpDownloadMsg := &ic.TechProfileDownloadMessage{ |
| 2437 | DeviceId: onuDev.deviceID, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2438 | UniId: uniID, |
| 2439 | TpInstancePath: tpPath, |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 2440 | TechTpInstance: &ic.TechProfileDownloadMessage_TpInstance{TpInstance: &tpInst}, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2441 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2442 | logger.Debugw(ctx, "sending-load-tech-profile-request-to-brcm-onu-adapter", log.Fields{"tpDownloadMsg": *tpDownloadMsg}) |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 2443 | |
| 2444 | err = f.deviceHandler.sendDownloadTechProfileToChildAdapter(ctx, onuDev.adapterEndpoint, tpDownloadMsg) |
| 2445 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2446 | return olterrors.NewErrCommunication("send-techprofile-download-request", |
| 2447 | log.Fields{ |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 2448 | "from-adapter": f.deviceHandler.openOLT.config.AdapterEndpoint, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2449 | "to-adapter": onuDev.deviceType, |
| 2450 | "onu-id": onuDev.deviceID, |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 2451 | "proxyDeviceID": onuDev.proxyDeviceID}, err) |
manikkaraj k | 17652a7 | 2019-05-06 09:06:36 -0400 | [diff] [blame] | 2452 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2453 | logger.Infow(ctx, "success-sending-load-tech-profile-request-to-brcm-onu-adapter", log.Fields{"tpDownloadMsg": *tpDownloadMsg}) |
Manikkaraj k | 884c124 | 2019-04-11 16:26:42 +0530 | [diff] [blame] | 2454 | return nil |
manikkaraj k | bf256be | 2019-03-25 00:13:48 +0530 | [diff] [blame] | 2455 | } |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2456 | |
Girish Gowdra | 197acc1 | 2021-08-16 10:59:45 -0700 | [diff] [blame] | 2457 | //AddOnuInfoToFlowMgrCacheAndKvStore function adds onu info to cache and kvstore |
| 2458 | func (f *OpenOltFlowMgr) AddOnuInfoToFlowMgrCacheAndKvStore(ctx context.Context, intfID uint32, onuID uint32, serialNum string) error { |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2459 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2460 | f.onuGemInfoLock.RLock() |
| 2461 | _, ok := f.onuGemInfoMap[onuID] |
| 2462 | f.onuGemInfoLock.RUnlock() |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 2463 | // If the ONU already exists in onuGemInfo list, nothing to do |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2464 | if ok { |
| 2465 | logger.Debugw(ctx, "onu-id-already-exists-in-cache", |
| 2466 | log.Fields{"onuID": onuID, |
| 2467 | "serialNum": serialNum}) |
| 2468 | return nil |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 2469 | } |
Matteo Scandolo | 2c0d274 | 2020-06-10 11:28:42 -0700 | [diff] [blame] | 2470 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2471 | onuGemInfo := rsrcMgr.OnuGemInfo{OnuID: onuID, SerialNumber: serialNum, IntfID: intfID} |
| 2472 | f.onuGemInfoLock.Lock() |
| 2473 | f.onuGemInfoMap[onuID] = &onuGemInfo |
| 2474 | f.onuGemInfoLock.Unlock() |
| 2475 | if err := f.resourceMgr.AddOnuGemInfo(ctx, intfID, onuID, onuGemInfo); err != nil { |
Andrea Campanella | b83b39d | 2020-03-30 11:41:16 +0200 | [diff] [blame] | 2476 | return err |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2477 | } |
Girish Gowdra | 197acc1 | 2021-08-16 10:59:45 -0700 | [diff] [blame] | 2478 | logger.Infow(ctx, "added-onuinfo", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2479 | log.Fields{ |
| 2480 | "intf-id": intfID, |
| 2481 | "onu-id": onuID, |
| 2482 | "serial-num": serialNum, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2483 | "onu": onuGemInfo, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2484 | "device-id": f.deviceHandler.device.Id}) |
Andrea Campanella | b83b39d | 2020-03-30 11:41:16 +0200 | [diff] [blame] | 2485 | return nil |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2486 | } |
| 2487 | |
Girish Gowdra | 197acc1 | 2021-08-16 10:59:45 -0700 | [diff] [blame] | 2488 | //RemoveOnuInfoFromFlowMgrCacheAndKvStore function adds onu info to cache and kvstore |
| 2489 | func (f *OpenOltFlowMgr) RemoveOnuInfoFromFlowMgrCacheAndKvStore(ctx context.Context, intfID uint32, onuID uint32) error { |
| 2490 | |
| 2491 | f.onuGemInfoLock.Lock() |
| 2492 | delete(f.onuGemInfoMap, onuID) |
| 2493 | f.onuGemInfoLock.Unlock() |
| 2494 | |
| 2495 | if err := f.resourceMgr.DelOnuGemInfo(ctx, intfID, onuID); err != nil { |
| 2496 | return err |
| 2497 | } |
| 2498 | logger.Infow(ctx, "deleted-onuinfo", |
| 2499 | log.Fields{ |
| 2500 | "intf-id": intfID, |
| 2501 | "onu-id": onuID, |
| 2502 | "device-id": f.deviceHandler.device.Id}) |
| 2503 | return nil |
| 2504 | } |
| 2505 | |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2506 | //addGemPortToOnuInfoMap function adds GEMport to ONU map |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 2507 | func (f *OpenOltFlowMgr) addGemPortToOnuInfoMap(ctx context.Context, intfID uint32, onuID uint32, gemPort uint32) { |
Matteo Scandolo | 2c0d274 | 2020-06-10 11:28:42 -0700 | [diff] [blame] | 2508 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2509 | logger.Infow(ctx, "adding-gem-to-onu-info-map", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2510 | log.Fields{ |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 2511 | "gem-port-id": gemPort, |
| 2512 | "intf-id": intfID, |
| 2513 | "onu-id": onuID, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2514 | "device-id": f.deviceHandler.device.Id}) |
| 2515 | f.onuGemInfoLock.RLock() |
| 2516 | onugem, ok := f.onuGemInfoMap[onuID] |
| 2517 | f.onuGemInfoLock.RUnlock() |
| 2518 | if !ok { |
| 2519 | logger.Warnw(ctx, "onu gem info is missing", log.Fields{ |
| 2520 | "gem-port-id": gemPort, |
| 2521 | "intf-id": intfID, |
| 2522 | "onu-id": onuID, |
| 2523 | "device-id": f.deviceHandler.device.Id}) |
| 2524 | return |
| 2525 | } |
| 2526 | |
| 2527 | if onugem.OnuID == onuID { |
| 2528 | // check if gem already exists , else update the cache and kvstore |
| 2529 | for _, gem := range onugem.GemPorts { |
| 2530 | if gem == gemPort { |
| 2531 | logger.Debugw(ctx, "gem-already-in-cache-no-need-to-update-cache-and-kv-store", |
| 2532 | log.Fields{ |
| 2533 | "gem": gemPort, |
| 2534 | "device-id": f.deviceHandler.device.Id}) |
| 2535 | return |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2536 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2537 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2538 | onugem.GemPorts = append(onugem.GemPorts, gemPort) |
| 2539 | f.onuGemInfoLock.Lock() |
| 2540 | f.onuGemInfoMap[onuID] = onugem |
| 2541 | f.onuGemInfoLock.Unlock() |
Girish Gowdra | bcf98af | 2021-07-01 08:24:42 -0700 | [diff] [blame] | 2542 | logger.Debugw(ctx, "updated onu gem info from cache", log.Fields{"onugem": onugem}) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2543 | } else { |
| 2544 | logger.Warnw(ctx, "mismatched onu id", log.Fields{ |
| 2545 | "gem-port-id": gemPort, |
| 2546 | "intf-id": intfID, |
| 2547 | "onu-id": onuID, |
| 2548 | "device-id": f.deviceHandler.device.Id}) |
| 2549 | return |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2550 | } |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 2551 | err := f.resourceMgr.AddGemToOnuGemInfo(ctx, intfID, onuID, gemPort) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2552 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2553 | logger.Errorw(ctx, "failed-to-add-gem-to-onu", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2554 | log.Fields{ |
| 2555 | "intf-id": intfID, |
| 2556 | "onu-id": onuID, |
| 2557 | "gemPort": gemPort, |
| 2558 | "device-id": f.deviceHandler.device.Id}) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2559 | return |
| 2560 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2561 | logger.Infow(ctx, "gem-added-to-onu-info-map", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2562 | log.Fields{ |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 2563 | "gem-port-id": gemPort, |
| 2564 | "intf-id": intfID, |
| 2565 | "onu-id": onuID, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2566 | "device-id": f.deviceHandler.device.Id}) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2567 | } |
| 2568 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2569 | //GetLogicalPortFromPacketIn function computes logical port UNI/NNI port from packet-in indication and returns the same |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 2570 | func (f *OpenOltFlowMgr) GetLogicalPortFromPacketIn(ctx context.Context, packetIn *openoltpb2.PacketIndication) (uint32, error) { |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2571 | var logicalPortNum uint32 |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2572 | |
| 2573 | if packetIn.IntfType == "pon" { |
| 2574 | // packet indication does not have serial number , so sending as nil |
Esin Karaman | df392e1 | 2020-12-16 13:33:09 +0000 | [diff] [blame] | 2575 | // get onu and uni ids associated with the given pon and gem ports |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2576 | onuID, uniID := packetIn.OnuId, packetIn.UniId |
| 2577 | logger.Debugf(ctx, "retrieved ONU and UNI IDs [%d, %d] by interface:%d, gem:%d", packetIn.OnuId, packetIn.UniId, packetIn.GemportId) |
Esin Karaman | df392e1 | 2020-12-16 13:33:09 +0000 | [diff] [blame] | 2578 | |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2579 | if packetIn.PortNo != 0 { |
| 2580 | logicalPortNum = packetIn.PortNo |
| 2581 | } else { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2582 | logicalPortNum = plt.MkUniPortNum(ctx, packetIn.IntfId, onuID, uniID) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2583 | } |
| 2584 | // Store the gem port through which the packet_in came. Use the same gem port for packet_out |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 2585 | f.UpdateGemPortForPktIn(ctx, packetIn.IntfId, onuID, logicalPortNum, packetIn.GemportId, packetIn.Pkt) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2586 | } else if packetIn.IntfType == "nni" { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2587 | logicalPortNum = plt.IntfIDToPortNo(packetIn.IntfId, voltha.Port_ETHERNET_NNI) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2588 | } |
Girish Gowdra | eb45029 | 2020-10-26 10:03:39 -0700 | [diff] [blame] | 2589 | |
| 2590 | if logger.V(log.DebugLevel) { |
| 2591 | logger.Debugw(ctx, "retrieved-logicalport-from-packet-in", |
| 2592 | log.Fields{ |
| 2593 | "logical-port-num": logicalPortNum, |
| 2594 | "intf-type": packetIn.IntfType, |
| 2595 | "packet": hex.EncodeToString(packetIn.Pkt), |
| 2596 | }) |
| 2597 | } |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2598 | return logicalPortNum, nil |
| 2599 | } |
| 2600 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2601 | //GetPacketOutGemPortID returns gemPortId |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 2602 | func (f *OpenOltFlowMgr) GetPacketOutGemPortID(ctx context.Context, intfID uint32, onuID uint32, portNum uint32, packet []byte) (uint32, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2603 | var gemPortID uint32 |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 2604 | |
| 2605 | ctag, priority, err := getCTagFromPacket(ctx, packet) |
| 2606 | if err != nil { |
| 2607 | return 0, err |
| 2608 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2609 | |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 2610 | pktInkey := rsrcMgr.PacketInInfoKey{IntfID: intfID, OnuID: onuID, LogicalPort: portNum, VlanID: ctag, Priority: priority} |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 2611 | var ok bool |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2612 | f.packetInGemPortLock.RLock() |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 2613 | gemPortID, ok = f.packetInGemPort[pktInkey] |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2614 | f.packetInGemPortLock.RUnlock() |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2615 | if ok { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2616 | logger.Debugw(ctx, "found-gemport-for-pktin-key", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2617 | log.Fields{ |
| 2618 | "pktinkey": pktInkey, |
| 2619 | "gem": gemPortID}) |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 2620 | |
| 2621 | return gemPortID, nil |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2622 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2623 | //If gem is not found in cache try to get it from kv store, if found in kv store, update the cache and return. |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 2624 | gemPortID, err = f.resourceMgr.GetGemPortFromOnuPktIn(ctx, pktInkey) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2625 | if err == nil { |
| 2626 | if gemPortID != 0 { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2627 | f.packetInGemPortLock.Lock() |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2628 | f.packetInGemPort[pktInkey] = gemPortID |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2629 | f.packetInGemPortLock.Unlock() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2630 | logger.Infow(ctx, "found-gem-port-from-kv-store-and-updating-cache-with-gemport", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2631 | log.Fields{ |
| 2632 | "pktinkey": pktInkey, |
| 2633 | "gem": gemPortID}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2634 | return gemPortID, nil |
| 2635 | } |
| 2636 | } |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2637 | return uint32(0), olterrors.NewErrNotFound("gem-port", |
| 2638 | log.Fields{ |
| 2639 | "pktinkey": pktInkey, |
| 2640 | "gem": gemPortID}, err) |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 2641 | |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2642 | } |
| 2643 | |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2644 | func (f *OpenOltFlowMgr) addTrapFlowOnNNI(ctx context.Context, logicalFlow *ofp.OfpFlowStats, classifier map[string]interface{}, portNo uint32) error { |
| 2645 | logger.Debug(ctx, "adding-trap-of-nni-flow") |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2646 | action := make(map[string]interface{}) |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2647 | classifier[PacketTagType] = DoubleTag |
| 2648 | action[TrapToHost] = true |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2649 | /* We manage flowId resource pool on per PON port basis. |
| 2650 | Since this situation is tricky, as a hack, we pass the NNI port |
| 2651 | index (network_intf_id) as PON port Index for the flowId resource |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2652 | pool. Also, there is no ONU Id available for trapping packets |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2653 | on NNI port, use onu_id as -1 (invalid) |
| 2654 | ****************** CAVEAT ******************* |
| 2655 | This logic works if the NNI Port Id falls within the same valid |
| 2656 | range of PON Port Ids. If this doesn't work for some OLT Vendor |
| 2657 | we need to have a re-look at this. |
| 2658 | ********************************************* |
| 2659 | */ |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2660 | onuID := -1 |
| 2661 | uniID := -1 |
| 2662 | gemPortID := -1 |
| 2663 | allocID := -1 |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2664 | networkInterfaceID, err := getNniIntfID(ctx, classifier, action) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2665 | if err != nil { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2666 | return olterrors.NewErrNotFound("nni-intreface-id", |
| 2667 | log.Fields{ |
| 2668 | "classifier": classifier, |
| 2669 | "action": action}, |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2670 | err) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 2671 | } |
| 2672 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2673 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, networkInterfaceID, int32(onuID), int32(uniID), logicalFlow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2674 | logger.Info(ctx, "flow-exists-not-re-adding") |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2675 | return nil |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2676 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2677 | |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2678 | logger.Debugw(ctx, "creating-trap-of-nni-flow", |
| 2679 | log.Fields{ |
| 2680 | "classifier": classifier, |
| 2681 | "action": action, |
| 2682 | "flowId": logicalFlow.Id, |
| 2683 | "intf-id": networkInterfaceID}) |
| 2684 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2685 | classifierProto, err := makeOpenOltClassifierField(classifier) |
| 2686 | if err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2687 | return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier}, err) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2688 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2689 | logger.Debugw(ctx, "created-classifier-proto", log.Fields{"classifier": *classifierProto}) |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 2690 | actionProto, err := makeOpenOltActionField(action, classifier) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2691 | if err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2692 | return olterrors.NewErrInvalidValue(log.Fields{"action": action}, err) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2693 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2694 | logger.Debugw(ctx, "created-action-proto", log.Fields{"action": *actionProto}) |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2695 | downstreamflow := openoltpb2.Flow{AccessIntfId: int32(-1), // AccessIntfId not required |
| 2696 | OnuId: int32(onuID), // OnuId not required |
| 2697 | UniId: int32(uniID), // UniId not used |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2698 | FlowId: logicalFlow.Id, |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 2699 | FlowType: Downstream, |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 2700 | AllocId: int32(allocID), // AllocId not used |
| 2701 | NetworkIntfId: int32(networkInterfaceID), |
| 2702 | GemportId: int32(gemPortID), // GemportId not used |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2703 | Classifier: classifierProto, |
| 2704 | Action: actionProto, |
| 2705 | Priority: int32(logicalFlow.Priority), |
| 2706 | Cookie: logicalFlow.Cookie, |
| 2707 | PortNo: portNo} |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2708 | if err := f.addFlowToDevice(ctx, logicalFlow, &downstreamflow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2709 | return olterrors.NewErrFlowOp("add", logicalFlow.Id, log.Fields{"flow": downstreamflow}, err) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2710 | } |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2711 | logger.Info(ctx, "trap-on-nni-flow-added–to-device-successfully") |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2712 | return nil |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 2713 | } |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2714 | |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2715 | //getPacketTypeFromClassifiers finds and returns packet type of a flow by checking flow classifiers |
| 2716 | func getPacketTypeFromClassifiers(classifierInfo map[string]interface{}) string { |
| 2717 | var packetType string |
| 2718 | ovid, ivid := false, false |
| 2719 | if vlanID, ok := classifierInfo[VlanVid].(uint32); ok { |
| 2720 | vid := vlanID & VlanvIDMask |
| 2721 | if vid != ReservedVlan { |
| 2722 | ovid = true |
| 2723 | } |
| 2724 | } |
| 2725 | if metadata, ok := classifierInfo[Metadata].(uint64); ok { |
| 2726 | vid := uint32(metadata) |
| 2727 | if vid != ReservedVlan { |
| 2728 | ivid = true |
| 2729 | } |
| 2730 | } |
| 2731 | if ovid && ivid { |
| 2732 | packetType = DoubleTag |
| 2733 | } else if !ovid && !ivid { |
| 2734 | packetType = Untagged |
| 2735 | } else { |
| 2736 | packetType = SingleTag |
| 2737 | } |
| 2738 | return packetType |
| 2739 | } |
| 2740 | |
| 2741 | //addIgmpTrapFlowOnNNI adds a trap-to-host flow on NNI |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2742 | func (f *OpenOltFlowMgr) addIgmpTrapFlowOnNNI(ctx context.Context, logicalFlow *ofp.OfpFlowStats, classifier map[string]interface{}, portNo uint32) error { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2743 | logger.Infow(ctx, "adding-igmp-trap-of-nni-flow", log.Fields{"classifier-info": classifier}) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2744 | action := make(map[string]interface{}) |
| 2745 | classifier[PacketTagType] = getPacketTypeFromClassifiers(classifier) |
| 2746 | action[TrapToHost] = true |
| 2747 | /* We manage flowId resource pool on per PON port basis. |
| 2748 | Since this situation is tricky, as a hack, we pass the NNI port |
| 2749 | index (network_intf_id) as PON port Index for the flowId resource |
| 2750 | pool. Also, there is no ONU Id available for trapping packets |
| 2751 | on NNI port, use onu_id as -1 (invalid) |
| 2752 | ****************** CAVEAT ******************* |
| 2753 | This logic works if the NNI Port Id falls within the same valid |
| 2754 | range of PON Port Ids. If this doesn't work for some OLT Vendor |
| 2755 | we need to have a re-look at this. |
| 2756 | ********************************************* |
| 2757 | */ |
| 2758 | onuID := -1 |
| 2759 | uniID := -1 |
| 2760 | gemPortID := -1 |
| 2761 | allocID := -1 |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2762 | networkInterfaceID, err := getNniIntfID(ctx, classifier, action) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2763 | if err != nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 2764 | return olterrors.NewErrNotFound("nni-interface-id", log.Fields{ |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2765 | "classifier": classifier, |
| 2766 | "action": action}, |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2767 | err) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2768 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2769 | if present := f.resourceMgr.IsFlowOnKvStore(ctx, networkInterfaceID, int32(onuID), int32(uniID), logicalFlow.Id); present { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2770 | logger.Info(ctx, "igmp-flow-exists-not-re-adding") |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2771 | return nil |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2772 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2773 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2774 | classifierProto, err := makeOpenOltClassifierField(classifier) |
| 2775 | if err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2776 | return olterrors.NewErrInvalidValue(log.Fields{"classifier": classifier}, err) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2777 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2778 | logger.Debugw(ctx, "created-classifier-proto-for-the-igmp-flow", log.Fields{"classifier": *classifierProto}) |
Gamze Abaka | 724d085 | 2020-03-18 12:10:24 +0000 | [diff] [blame] | 2779 | actionProto, err := makeOpenOltActionField(action, classifier) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2780 | if err != nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 2781 | return olterrors.NewErrInvalidValue(log.Fields{"action": action}, err) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2782 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2783 | logger.Debugw(ctx, "created-action-proto-for-the-igmp-flow", log.Fields{"action": *actionProto}) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2784 | downstreamflow := openoltpb2.Flow{AccessIntfId: int32(-1), // AccessIntfId not required |
| 2785 | OnuId: int32(onuID), // OnuId not required |
| 2786 | UniId: int32(uniID), // UniId not used |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2787 | FlowId: logicalFlow.Id, |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2788 | FlowType: Downstream, |
| 2789 | AllocId: int32(allocID), // AllocId not used |
| 2790 | NetworkIntfId: int32(networkInterfaceID), |
| 2791 | GemportId: int32(gemPortID), // GemportId not used |
| 2792 | Classifier: classifierProto, |
| 2793 | Action: actionProto, |
| 2794 | Priority: int32(logicalFlow.Priority), |
| 2795 | Cookie: logicalFlow.Cookie, |
| 2796 | PortNo: portNo} |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2797 | if err := f.addFlowToDevice(ctx, logicalFlow, &downstreamflow); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2798 | return olterrors.NewErrFlowOp("add", logicalFlow.Id, log.Fields{"flow": downstreamflow}, err) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2799 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2800 | logger.Info(ctx, "igmp-trap-on-nni-flow-added-to-device-successfully") |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2801 | |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 2802 | return nil |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2803 | } |
| 2804 | |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2805 | func verifyMeterIDAndGetDirection(MeterID uint32, Dir tp_pb.Direction) (string, error) { |
| 2806 | if MeterID == 0 { // This should never happen |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 2807 | return "", olterrors.NewErrInvalidValue(log.Fields{"meter-id": MeterID}, nil).Log() |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2808 | } |
| 2809 | if Dir == tp_pb.Direction_UPSTREAM { |
| 2810 | return "upstream", nil |
| 2811 | } else if Dir == tp_pb.Direction_DOWNSTREAM { |
| 2812 | return "downstream", nil |
| 2813 | } |
| 2814 | return "", nil |
| 2815 | } |
| 2816 | |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 2817 | // nolint: gocyclo |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 2818 | func (f *OpenOltFlowMgr) checkAndAddFlow(ctx context.Context, args map[string]uint32, classifierInfo map[string]interface{}, |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 2819 | actionInfo map[string]interface{}, flow *ofp.OfpFlowStats, TpInst interface{}, gemPorts []uint32, |
Gamze Abaka | 78a1d2a | 2020-04-27 10:17:27 +0000 | [diff] [blame] | 2820 | tpID uint32, uni string) { |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2821 | var gemPortID uint32 |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 2822 | intfID := args[IntfID] |
| 2823 | onuID := args[OnuID] |
| 2824 | uniID := args[UniID] |
| 2825 | portNo := args[PortNo] |
Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 2826 | allocID := args[AllocID] |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2827 | pbitToGem := make(map[uint32]uint32) |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2828 | gemToAes := make(map[uint32]bool) |
| 2829 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2830 | var attributes []*tp_pb.GemPortAttributes |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2831 | var direction = tp_pb.Direction_UPSTREAM |
| 2832 | switch TpInst := TpInst.(type) { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2833 | case *tp_pb.TechProfileInstance: |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 2834 | if plt.IsUpstream(actionInfo[Output].(uint32)) { |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2835 | attributes = TpInst.UpstreamGemPortAttributeList |
| 2836 | } else { |
| 2837 | attributes = TpInst.DownstreamGemPortAttributeList |
| 2838 | direction = tp_pb.Direction_DOWNSTREAM |
| 2839 | } |
| 2840 | default: |
| 2841 | logger.Errorw(ctx, "unsupported-tech", log.Fields{"tpInst": TpInst}) |
| 2842 | return |
| 2843 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2844 | |
| 2845 | if len(gemPorts) == 1 { |
| 2846 | // If there is only single gemport use that and do not populate pbitToGem map |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2847 | gemPortID = gemPorts[0] |
| 2848 | gemToAes[gemPortID], _ = strconv.ParseBool(attributes[0].AesEncryption) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2849 | } else if pcp, ok := classifierInfo[VlanPcp]; !ok { |
| 2850 | for idx, gemID := range gemPorts { |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2851 | pBitMap := attributes[idx].PbitMap |
| 2852 | // Trim the bitMapPrefix form the binary string and then iterate each character in the binary string. |
| 2853 | // If the character is set to pbit1, extract the pcp value from the position of this character in the string. |
| 2854 | // Update the pbitToGem map with key being the pcp bit and the value being the gemPortID that consumes |
| 2855 | // this pcp bit traffic. |
| 2856 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, bitMapPrefix) { |
| 2857 | if pbitSet == pbit1 { |
| 2858 | pcp := uint32(len(strings.TrimPrefix(pBitMap, bitMapPrefix))) - 1 - uint32(pos) |
| 2859 | pbitToGem[pcp] = gemID |
| 2860 | gemToAes[gemID], _ = strconv.ParseBool(attributes[idx].AesEncryption) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2861 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2862 | } |
| 2863 | } |
| 2864 | } else { // Extract the exact gemport which maps to the PCP classifier in the flow |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2865 | if gem := f.techprofile.GetGemportForPbit(ctx, TpInst, direction, pcp.(uint32)); gem != nil { |
| 2866 | gemPortID = gem.(*tp_pb.GemPortAttributes).GemportId |
| 2867 | gemToAes[gemPortID], _ = strconv.ParseBool(gem.(*tp_pb.GemPortAttributes).AesEncryption) |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2868 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2869 | } |
| 2870 | |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2871 | flowContext := &flowContext{intfID, onuID, uniID, portNo, classifierInfo, actionInfo, |
| 2872 | flow, allocID, gemPortID, tpID, pbitToGem, gemToAes} |
| 2873 | |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2874 | if ipProto, ok := classifierInfo[IPProto]; ok { |
| 2875 | if ipProto.(uint32) == IPProtoDhcp { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2876 | logger.Infow(ctx, "adding-dhcp-flow", log.Fields{ |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 2877 | "tp-id": tpID, |
| 2878 | "alloc-id": allocID, |
| 2879 | "intf-id": intfID, |
| 2880 | "onu-id": onuID, |
| 2881 | "uni-id": uniID, |
| 2882 | }) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2883 | //Adding DHCP upstream flow |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2884 | if err := f.addDHCPTrapFlow(ctx, flowContext); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2885 | logger.Warn(ctx, err) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2886 | } |
| 2887 | |
Girish Gowdra | 3262521 | 2020-04-29 11:26:35 -0700 | [diff] [blame] | 2888 | } else if ipProto.(uint32) == IgmpProto { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2889 | logger.Infow(ctx, "adding-us-igmp-flow", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2890 | log.Fields{ |
| 2891 | "intf-id": intfID, |
| 2892 | "onu-id": onuID, |
| 2893 | "uni-id": uniID, |
| 2894 | "classifier-info:": classifierInfo}) |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2895 | if err := f.addIGMPTrapFlow(ctx, flowContext); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2896 | logger.Warn(ctx, err) |
Esin Karaman | ae41e2b | 2019-12-17 18:13:13 +0000 | [diff] [blame] | 2897 | } |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2898 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2899 | logger.Errorw(ctx, "invalid-classifier-to-handle", log.Fields{"classifier": classifierInfo, "action": actionInfo}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2900 | return |
| 2901 | } |
| 2902 | } else if ethType, ok := classifierInfo[EthType]; ok { |
Marcos Aurelio Carrero (Furukawa) | 1dc2bfb | 2021-02-17 15:10:12 -0300 | [diff] [blame] | 2903 | if ethType.(uint32) == EapEthType { |
| 2904 | logger.Infow(ctx, "adding-eapol-flow", log.Fields{ |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 2905 | "intf-id": intfID, |
| 2906 | "onu-id": onuID, |
| 2907 | "uni-id": uniID, |
Marcos Aurelio Carrero (Furukawa) | 388fb0a | 2021-02-04 18:05:11 -0300 | [diff] [blame] | 2908 | "ethType": ethType, |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 2909 | }) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2910 | var vlanID uint32 |
| 2911 | if val, ok := classifierInfo[VlanVid]; ok { |
| 2912 | vlanID = (val.(uint32)) & VlanvIDMask |
| 2913 | } else { |
| 2914 | vlanID = DefaultMgmtVlan |
| 2915 | } |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2916 | if err := f.addEthTypeBasedFlow(ctx, flowContext, vlanID, ethType.(uint32)); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2917 | logger.Warn(ctx, err) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2918 | } |
Marcos Aurelio Carrero (Furukawa) | 1dc2bfb | 2021-02-17 15:10:12 -0300 | [diff] [blame] | 2919 | } else if ethType.(uint32) == PPPoEDEthType { |
| 2920 | logger.Infow(ctx, "adding-pppoed-flow", log.Fields{ |
| 2921 | "tp-id": tpID, |
| 2922 | "alloc-id": allocID, |
| 2923 | "intf-id": intfID, |
| 2924 | "onu-id": onuID, |
| 2925 | "uni-id": uniID, |
| 2926 | }) |
| 2927 | //Adding PPPOED upstream flow |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2928 | if err := f.addUpstreamTrapFlow(ctx, flowContext); err != nil { |
Marcos Aurelio Carrero (Furukawa) | 1dc2bfb | 2021-02-17 15:10:12 -0300 | [diff] [blame] | 2929 | logger.Warn(ctx, err) |
| 2930 | } |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2931 | } |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2932 | } else if direction == tp_pb.Direction_UPSTREAM { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2933 | logger.Infow(ctx, "adding-upstream-data-rule", log.Fields{ |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 2934 | "intf-id": intfID, |
| 2935 | "onu-id": onuID, |
| 2936 | "uni-id": uniID, |
| 2937 | }) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2938 | //Adding HSIA upstream flow |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2939 | if err := f.addUpstreamDataPathFlow(ctx, flowContext); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2940 | logger.Warn(ctx, err) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2941 | } |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2942 | } else if direction == tp_pb.Direction_DOWNSTREAM { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2943 | logger.Infow(ctx, "adding-downstream-data-rule", log.Fields{ |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 2944 | "intf-id": intfID, |
| 2945 | "onu-id": onuID, |
| 2946 | "uni-id": uniID, |
| 2947 | }) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2948 | //Adding HSIA downstream flow |
Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 2949 | if err := f.addDownstreamDataPathFlow(ctx, flowContext); err != nil { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2950 | logger.Warn(ctx, err) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2951 | } |
| 2952 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2953 | logger.Errorw(ctx, "invalid-flow-type-to-handle", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2954 | log.Fields{ |
Matteo Scandolo | 9218624 | 2020-06-12 10:54:18 -0700 | [diff] [blame] | 2955 | "intf-id": intfID, |
| 2956 | "onu-id": onuID, |
| 2957 | "uni-id": uniID, |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 2958 | "classifier": classifierInfo, |
| 2959 | "action": actionInfo, |
| 2960 | "flow": flow}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2961 | return |
| 2962 | } |
| 2963 | // Send Techprofile download event to child device in go routine as it takes time |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 2964 | go func() { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2965 | if err := f.sendTPDownloadMsgToChild(ctx, intfID, onuID, uniID, uni, tpID, *(TpInst.(*tp_pb.TechProfileInstance))); err != nil { |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 2966 | logger.Warn(ctx, err) |
| 2967 | } |
| 2968 | }() |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 2969 | } |
| 2970 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2971 | func (f *OpenOltFlowMgr) isGemPortUsedByAnotherFlow(gemPortID uint32) bool { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2972 | f.gemToFlowIDsKey.RLock() |
| 2973 | flowIDList := f.gemToFlowIDs[gemPortID] |
| 2974 | f.gemToFlowIDsKey.RUnlock() |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 2975 | return len(flowIDList) > 1 |
| 2976 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 2977 | } |
| 2978 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2979 | func (f *OpenOltFlowMgr) isTechProfileUsedByAnotherGem(ctx context.Context, ponIntf uint32, onuID uint32, uniID uint32, tpInst *tp_pb.TechProfileInstance, gemPortID uint32) (bool, uint32) { |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 2980 | currentGemPorts := f.resourceMgr.GetCurrentGEMPortIDsForOnu(ctx, ponIntf, onuID, uniID) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 2981 | tpGemPorts := tpInst.UpstreamGemPortAttributeList |
| 2982 | for _, currentGemPort := range currentGemPorts { |
| 2983 | for _, tpGemPort := range tpGemPorts { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2984 | if (currentGemPort == tpGemPort.GemportId) && (currentGemPort != gemPortID) { |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 2985 | return true, currentGemPort |
| 2986 | } |
| 2987 | } |
| 2988 | } |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 2989 | logger.Debug(ctx, "tech-profile-is-not-in-use-by-any-gem") |
| 2990 | return false, 0 |
| 2991 | } |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 2992 | |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 2993 | func (f *OpenOltFlowMgr) isAllocUsedByAnotherUNI(ctx context.Context, sq schedQueue) bool { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 2994 | tpInst := sq.tpInst.(*tp_pb.TechProfileInstance) |
| 2995 | if tpInst.InstanceControl.Onu == "single-instance" && sq.direction == tp_pb.Direction_UPSTREAM { |
| 2996 | tpInstances := f.techprofile.FindAllTpInstances(ctx, f.deviceHandler.device.Id, sq.tpID, sq.intfID, sq.onuID).([]tp_pb.TechProfileInstance) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 2997 | logger.Debugw(ctx, "got-single-instance-tp-instances", log.Fields{"tp-instances": tpInstances}) |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 2998 | for i := 0; i < len(tpInstances); i++ { |
| 2999 | tpI := tpInstances[i] |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 3000 | if tpI.SubscriberIdentifier != tpInst.SubscriberIdentifier && |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3001 | tpI.UsScheduler.AllocId == tpInst.UsScheduler.AllocId { |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 3002 | logger.Debugw(ctx, "alloc-is-in-use", |
| 3003 | log.Fields{ |
| 3004 | "device-id": f.deviceHandler.device.Id, |
| 3005 | "intfID": sq.intfID, |
| 3006 | "onuID": sq.onuID, |
| 3007 | "uniID": sq.uniID, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3008 | "allocID": tpI.UsScheduler.AllocId, |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 3009 | }) |
| 3010 | return true |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 3011 | } |
| 3012 | } |
| 3013 | } |
Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 3014 | return false |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 3015 | } |
| 3016 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3017 | func formulateClassifierInfoFromFlow(ctx context.Context, classifierInfo map[string]interface{}, flow *ofp.OfpFlowStats) { |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3018 | for _, field := range flows.GetOfbFields(flow) { |
| 3019 | if field.Type == flows.ETH_TYPE { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3020 | classifierInfo[EthType] = field.GetEthType() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3021 | logger.Debug(ctx, "field-type-eth-type", log.Fields{"classifierInfo[ETH_TYPE]": classifierInfo[EthType].(uint32)}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3022 | } else if field.Type == flows.ETH_DST { |
| 3023 | classifierInfo[EthDst] = field.GetEthDst() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3024 | logger.Debug(ctx, "field-type-eth-type", log.Fields{"classifierInfo[ETH_DST]": classifierInfo[EthDst].([]uint8)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3025 | } else if field.Type == flows.IP_PROTO { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3026 | classifierInfo[IPProto] = field.GetIpProto() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3027 | logger.Debug(ctx, "field-type-ip-proto", log.Fields{"classifierInfo[IP_PROTO]": classifierInfo[IPProto].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3028 | } else if field.Type == flows.IN_PORT { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3029 | classifierInfo[InPort] = field.GetPort() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3030 | logger.Debug(ctx, "field-type-in-port", log.Fields{"classifierInfo[IN_PORT]": classifierInfo[InPort].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3031 | } else if field.Type == flows.VLAN_VID { |
Girish Gowdra | 26f344b | 2019-10-23 14:39:13 +0530 | [diff] [blame] | 3032 | classifierInfo[VlanVid] = field.GetVlanVid() & 0xfff |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3033 | logger.Debug(ctx, "field-type-vlan-vid", log.Fields{"classifierInfo[VLAN_VID]": classifierInfo[VlanVid].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3034 | } else if field.Type == flows.VLAN_PCP { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3035 | classifierInfo[VlanPcp] = field.GetVlanPcp() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3036 | logger.Debug(ctx, "field-type-vlan-pcp", log.Fields{"classifierInfo[VLAN_PCP]": classifierInfo[VlanPcp].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3037 | } else if field.Type == flows.UDP_DST { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3038 | classifierInfo[UDPDst] = field.GetUdpDst() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3039 | logger.Debug(ctx, "field-type-udp-dst", log.Fields{"classifierInfo[UDP_DST]": classifierInfo[UDPDst].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3040 | } else if field.Type == flows.UDP_SRC { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3041 | classifierInfo[UDPSrc] = field.GetUdpSrc() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3042 | logger.Debug(ctx, "field-type-udp-src", log.Fields{"classifierInfo[UDP_SRC]": classifierInfo[UDPSrc].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3043 | } else if field.Type == flows.IPV4_DST { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3044 | classifierInfo[Ipv4Dst] = field.GetIpv4Dst() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3045 | logger.Debug(ctx, "field-type-ipv4-dst", log.Fields{"classifierInfo[IPV4_DST]": classifierInfo[Ipv4Dst].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3046 | } else if field.Type == flows.IPV4_SRC { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3047 | classifierInfo[Ipv4Src] = field.GetIpv4Src() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3048 | logger.Debug(ctx, "field-type-ipv4-src", log.Fields{"classifierInfo[IPV4_SRC]": classifierInfo[Ipv4Src].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3049 | } else if field.Type == flows.METADATA { |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 3050 | classifierInfo[Metadata] = field.GetTableMetadata() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3051 | logger.Debug(ctx, "field-type-metadata", log.Fields{"classifierInfo[Metadata]": classifierInfo[Metadata].(uint64)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3052 | } else if field.Type == flows.TUNNEL_ID { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3053 | classifierInfo[TunnelID] = field.GetTunnelId() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3054 | logger.Debug(ctx, "field-type-tunnelId", log.Fields{"classifierInfo[TUNNEL_ID]": classifierInfo[TunnelID].(uint64)}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3055 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3056 | logger.Errorw(ctx, "un-supported-field-type", log.Fields{"type": field.Type}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3057 | return |
| 3058 | } |
| 3059 | } |
| 3060 | } |
| 3061 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3062 | func formulateActionInfoFromFlow(ctx context.Context, actionInfo, classifierInfo map[string]interface{}, flow *ofp.OfpFlowStats) error { |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3063 | for _, action := range flows.GetActions(flow) { |
| 3064 | if action.Type == flows.OUTPUT { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3065 | if out := action.GetOutput(); out != nil { |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 3066 | actionInfo[Output] = out.GetPort() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3067 | logger.Debugw(ctx, "action-type-output", log.Fields{"out-port": actionInfo[Output].(uint32)}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3068 | } else { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 3069 | return olterrors.NewErrInvalidValue(log.Fields{"output-port": nil}, nil) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3070 | } |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3071 | } else if action.Type == flows.POP_VLAN { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3072 | actionInfo[PopVlan] = true |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3073 | logger.Debugw(ctx, "action-type-pop-vlan", log.Fields{"in_port": classifierInfo[InPort].(uint32)}) |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3074 | } else if action.Type == flows.PUSH_VLAN { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3075 | if out := action.GetPush(); out != nil { |
| 3076 | if tpid := out.GetEthertype(); tpid != 0x8100 { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3077 | logger.Errorw(ctx, "invalid ethertype in push action", log.Fields{"ethertype": actionInfo[PushVlan].(int32)}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3078 | } else { |
| 3079 | actionInfo[PushVlan] = true |
| 3080 | actionInfo[TPID] = tpid |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3081 | logger.Debugw(ctx, "action-type-push-vlan", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3082 | log.Fields{ |
| 3083 | "push-tpid": actionInfo[TPID].(uint32), |
| 3084 | "in-port": classifierInfo[InPort].(uint32)}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3085 | } |
| 3086 | } |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3087 | } else if action.Type == flows.SET_FIELD { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3088 | if out := action.GetSetField(); out != nil { |
| 3089 | if field := out.GetField(); field != nil { |
| 3090 | if ofClass := field.GetOxmClass(); ofClass != ofp.OfpOxmClass_OFPXMC_OPENFLOW_BASIC { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 3091 | return olterrors.NewErrInvalidValue(log.Fields{"openflow-class": ofClass}, nil) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3092 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3093 | /*logger.Debugw(ctx, "action-type-set-field",log.Fields{"field": field, "in_port": classifierInfo[IN_PORT].(uint32)})*/ |
| 3094 | formulateSetFieldActionInfoFromFlow(ctx, field, actionInfo) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3095 | } |
| 3096 | } |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3097 | } else if action.Type == flows.GROUP { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3098 | formulateGroupActionInfoFromFlow(ctx, action, actionInfo) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3099 | } else { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 3100 | return olterrors.NewErrInvalidValue(log.Fields{"action-type": action.Type}, nil) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3101 | } |
| 3102 | } |
| 3103 | return nil |
| 3104 | } |
| 3105 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3106 | func formulateSetFieldActionInfoFromFlow(ctx context.Context, field *ofp.OfpOxmField, actionInfo map[string]interface{}) { |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3107 | if ofbField := field.GetOfbField(); ofbField != nil { |
Gamze Abaka | c43a66e | 2020-05-11 11:00:42 +0000 | [diff] [blame] | 3108 | fieldtype := ofbField.GetType() |
| 3109 | if fieldtype == ofp.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_VID { |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3110 | if vlan := ofbField.GetVlanVid(); vlan != 0 { |
| 3111 | actionInfo[VlanVid] = vlan & 0xfff |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3112 | logger.Debugw(ctx, "action-set-vlan-vid", log.Fields{"actionInfo[VLAN_VID]": actionInfo[VlanVid].(uint32)}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3113 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3114 | logger.Error(ctx, "no-invalid-vlan-id-in-set-vlan-vid-action") |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3115 | } |
Gamze Abaka | c43a66e | 2020-05-11 11:00:42 +0000 | [diff] [blame] | 3116 | } else if fieldtype == ofp.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_PCP { |
| 3117 | pcp := ofbField.GetVlanPcp() |
| 3118 | actionInfo[VlanPcp] = pcp |
Girish Kumar | a1ea2aa | 2020-08-19 18:14:22 +0000 | [diff] [blame] | 3119 | logger.Debugw(ctx, "action-set-vlan-pcp", log.Fields{"actionInfo[VLAN_PCP]": actionInfo[VlanPcp].(uint32)}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3120 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3121 | logger.Errorw(ctx, "unsupported-action-set-field-type", log.Fields{"type": fieldtype}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3122 | } |
| 3123 | } |
| 3124 | } |
| 3125 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3126 | func formulateGroupActionInfoFromFlow(ctx context.Context, action *ofp.OfpAction, actionInfo map[string]interface{}) { |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3127 | if action.GetGroup() == nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3128 | logger.Warn(ctx, "no-group-entry-found-in-the-group-action") |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3129 | } else { |
| 3130 | actionInfo[GroupID] = action.GetGroup().GroupId |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3131 | logger.Debugw(ctx, "action-group-id", log.Fields{"actionInfo[GroupID]": actionInfo[GroupID].(uint32)}) |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3132 | } |
| 3133 | } |
| 3134 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3135 | func formulateControllerBoundTrapFlowInfo(ctx context.Context, actionInfo, classifierInfo map[string]interface{}, flow *ofp.OfpFlowStats) error { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 3136 | if isControllerFlow := plt.IsControllerBoundFlow(actionInfo[Output].(uint32)); isControllerFlow { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3137 | logger.Debug(ctx, "controller-bound-trap-flows--getting-inport-from-tunnelid") |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3138 | /* Get UNI port/ IN Port from tunnel ID field for upstream controller bound flows */ |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 3139 | if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT { |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3140 | if uniPort := flows.GetChildPortFromTunnelId(flow); uniPort != 0 { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3141 | classifierInfo[InPort] = uniPort |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3142 | logger.Debugw(ctx, "upstream-pon-to-controller-flow--inport-in-tunnelid", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3143 | log.Fields{ |
| 3144 | "newinport": classifierInfo[InPort].(uint32), |
| 3145 | "outport": actionInfo[Output].(uint32)}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3146 | } else { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3147 | return olterrors.NewErrNotFound("child-in-port", |
| 3148 | log.Fields{ |
| 3149 | "reason": "upstream-pon-to-controller-flow--no-inport-in-tunnelid", |
| 3150 | "flow": flow}, nil) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3151 | } |
| 3152 | } |
| 3153 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3154 | logger.Debug(ctx, "non-controller-flows--getting-uniport-from-tunnelid") |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3155 | // Downstream flow from NNI to PON port , Use tunnel ID as new OUT port / UNI port |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 3156 | if portType := plt.IntfIDToPortTypeName(actionInfo[Output].(uint32)); portType == voltha.Port_PON_OLT { |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3157 | if uniPort := flows.GetChildPortFromTunnelId(flow); uniPort != 0 { |
David K. Bainbridge | 82efc49 | 2019-09-04 09:57:11 -0700 | [diff] [blame] | 3158 | actionInfo[Output] = uniPort |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3159 | logger.Debugw(ctx, "downstream-nni-to-pon-port-flow, outport-in-tunnelid", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3160 | log.Fields{ |
| 3161 | "newoutport": actionInfo[Output].(uint32), |
| 3162 | "outport": actionInfo[Output].(uint32)}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3163 | } else { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3164 | return olterrors.NewErrNotFound("out-port", |
| 3165 | log.Fields{ |
| 3166 | "reason": "downstream-nni-to-pon-port-flow--no-outport-in-tunnelid", |
| 3167 | "flow": flow}, nil) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3168 | } |
| 3169 | // Upstream flow from PON to NNI port , Use tunnel ID as new IN port / UNI port |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 3170 | } else if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_PON_OLT { |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 3171 | if uniPort := flows.GetChildPortFromTunnelId(flow); uniPort != 0 { |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3172 | classifierInfo[InPort] = uniPort |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3173 | logger.Debugw(ctx, "upstream-pon-to-nni-port-flow, inport-in-tunnelid", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3174 | log.Fields{ |
| 3175 | "newinport": actionInfo[Output].(uint32), |
| 3176 | "outport": actionInfo[Output].(uint32)}) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3177 | } else { |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3178 | return olterrors.NewErrNotFound("nni-port", |
| 3179 | log.Fields{ |
| 3180 | "reason": "upstream-pon-to-nni-port-flow--no-inport-in-tunnelid", |
| 3181 | "in-port": classifierInfo[InPort].(uint32), |
| 3182 | "out-port": actionInfo[Output].(uint32), |
| 3183 | "flow": flow}, nil) |
salmansiddiqui | 7ac6213 | 2019-08-22 03:58:50 +0000 | [diff] [blame] | 3184 | } |
| 3185 | } |
| 3186 | } |
| 3187 | return nil |
| 3188 | } |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 3189 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3190 | func getTpIDFromFlow(ctx context.Context, flow *ofp.OfpFlowStats) (uint32, error) { |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 3191 | /* Metadata 8 bytes: |
| 3192 | Most Significant 2 Bytes = Inner VLAN |
| 3193 | Next 2 Bytes = Tech Profile ID(TPID) |
| 3194 | Least Significant 4 Bytes = Port ID |
| 3195 | Flow Metadata carries Tech-Profile (TP) ID and is mandatory in all |
| 3196 | subscriber related flows. |
| 3197 | */ |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3198 | metadata := flows.GetMetadataFromWriteMetadataAction(ctx, flow) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 3199 | if metadata == 0 { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 3200 | return 0, olterrors.NewErrNotFound("metadata", log.Fields{"flow": flow}, nil) |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 3201 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3202 | TpID := flows.GetTechProfileIDFromWriteMetaData(ctx, metadata) |
Chaitrashree G S | 90a1795 | 2019-11-14 21:51:21 -0500 | [diff] [blame] | 3203 | return uint32(TpID), nil |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 3204 | } |
| 3205 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3206 | func appendUnique64bit(slice []uint64, item uint64) []uint64 { |
| 3207 | for _, sliceElement := range slice { |
| 3208 | if sliceElement == item { |
| 3209 | return slice |
| 3210 | } |
| 3211 | } |
| 3212 | return append(slice, item) |
| 3213 | } |
| 3214 | |
| 3215 | func appendUnique32bit(slice []uint32, item uint32) []uint32 { |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 3216 | for _, sliceElement := range slice { |
| 3217 | if sliceElement == item { |
| 3218 | return slice |
| 3219 | } |
| 3220 | } |
| 3221 | return append(slice, item) |
| 3222 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3223 | |
| 3224 | // getNniIntfID gets nni intf id from the flow classifier/action |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3225 | func getNniIntfID(ctx context.Context, classifier map[string]interface{}, action map[string]interface{}) (uint32, error) { |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3226 | |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 3227 | portType := plt.IntfIDToPortTypeName(classifier[InPort].(uint32)) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3228 | if portType == voltha.Port_PON_OLT { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 3229 | intfID, err := plt.IntfIDFromNniPortNum(ctx, action[Output].(uint32)) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 3230 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3231 | logger.Debugw(ctx, "invalid-action-port-number", |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 3232 | log.Fields{ |
| 3233 | "port-number": action[Output].(uint32), |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3234 | "err": err}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 3235 | return uint32(0), err |
| 3236 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3237 | logger.Infow(ctx, "output-nni-intfId-is", log.Fields{"intf-id": intfID}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3238 | return intfID, nil |
| 3239 | } else if portType == voltha.Port_ETHERNET_NNI { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 3240 | intfID, err := plt.IntfIDFromNniPortNum(ctx, classifier[InPort].(uint32)) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 3241 | if err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3242 | logger.Debugw(ctx, "invalid-classifier-port-number", |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 3243 | log.Fields{ |
| 3244 | "port-number": action[Output].(uint32), |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3245 | "err": err}) |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 3246 | return uint32(0), err |
| 3247 | } |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3248 | logger.Infow(ctx, "input-nni-intfId-is", log.Fields{"intf-id": intfID}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3249 | return intfID, nil |
| 3250 | } |
| 3251 | return uint32(0), nil |
| 3252 | } |
| 3253 | |
| 3254 | // UpdateGemPortForPktIn updates gemport for packet-in in to the cache and to the kv store as well. |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 3255 | func (f *OpenOltFlowMgr) UpdateGemPortForPktIn(ctx context.Context, intfID uint32, onuID uint32, logicalPort uint32, gemPort uint32, pkt []byte) { |
| 3256 | cTag, priority, err := getCTagFromPacket(ctx, pkt) |
| 3257 | if err != nil { |
| 3258 | logger.Errorw(ctx, "unable-to-update-gem-port-for-packet-in", |
| 3259 | log.Fields{"intfID": intfID, "onuID": onuID, "logicalPort": logicalPort, "gemPort": gemPort, "err": err}) |
| 3260 | return |
| 3261 | } |
| 3262 | pktInkey := rsrcMgr.PacketInInfoKey{IntfID: intfID, OnuID: onuID, LogicalPort: logicalPort, VlanID: cTag, Priority: priority} |
Matteo Scandolo | abf9c51 | 2020-06-23 19:31:14 -0700 | [diff] [blame] | 3263 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3264 | f.packetInGemPortLock.RLock() |
Matt Jeanneret | 1719a07 | 2019-12-20 14:50:14 -0500 | [diff] [blame] | 3265 | lookupGemPort, ok := f.packetInGemPort[pktInkey] |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3266 | f.packetInGemPortLock.RUnlock() |
| 3267 | |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3268 | if ok { |
Matt Jeanneret | 1719a07 | 2019-12-20 14:50:14 -0500 | [diff] [blame] | 3269 | if lookupGemPort == gemPort { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3270 | logger.Infow(ctx, "pktin-key/value-found-in-cache--no-need-to-update-kv--assume-both-in-sync", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3271 | log.Fields{ |
| 3272 | "pktinkey": pktInkey, |
| 3273 | "gem": gemPort}) |
Matt Jeanneret | 1719a07 | 2019-12-20 14:50:14 -0500 | [diff] [blame] | 3274 | return |
| 3275 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3276 | } |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3277 | f.packetInGemPortLock.Lock() |
Matt Jeanneret | 1719a07 | 2019-12-20 14:50:14 -0500 | [diff] [blame] | 3278 | f.packetInGemPort[pktInkey] = gemPort |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3279 | f.packetInGemPortLock.Unlock() |
Matt Jeanneret | 1719a07 | 2019-12-20 14:50:14 -0500 | [diff] [blame] | 3280 | |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 3281 | f.resourceMgr.UpdateGemPortForPktIn(ctx, pktInkey, gemPort) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 3282 | logger.Infow(ctx, "pktin-key-not-found-in-local-cache-value-is-different--updating-cache-and-kv-store", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 3283 | log.Fields{ |
| 3284 | "pktinkey": pktInkey, |
| 3285 | "gem": gemPort}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3286 | } |
| 3287 | |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 3288 | //getCTagFromPacket retrieves and returns c-tag and priority value from a packet. |
| 3289 | func getCTagFromPacket(ctx context.Context, packet []byte) (uint16, uint8, error) { |
| 3290 | if packet == nil || len(packet) < 18 { |
Girish Kumar | a1ea2aa | 2020-08-19 18:14:22 +0000 | [diff] [blame] | 3291 | logger.Error(ctx, "unable-get-c-tag-from-the-packet--invalid-packet-length ") |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 3292 | return 0, 0, errors.New("invalid packet length") |
| 3293 | } |
| 3294 | outerEthType := (uint16(packet[12]) << 8) | uint16(packet[13]) |
| 3295 | innerEthType := (uint16(packet[16]) << 8) | uint16(packet[17]) |
| 3296 | |
| 3297 | var index int8 |
| 3298 | if outerEthType == 0x8100 { |
| 3299 | if innerEthType == 0x8100 { |
| 3300 | // q-in-q 802.1ad or 802.1q double tagged packet. |
| 3301 | // get the inner vlanId |
| 3302 | index = 18 |
| 3303 | } else { |
| 3304 | index = 14 |
| 3305 | } |
| 3306 | priority := (packet[index] >> 5) & 0x7 |
| 3307 | //13 bits composes vlanId value |
| 3308 | vlan := ((uint16(packet[index]) << 8) & 0x0fff) | uint16(packet[index+1]) |
| 3309 | return vlan, priority, nil |
| 3310 | } |
| 3311 | logger.Debugf(ctx, "No vlanId found in the packet. Returning zero as c-tag") |
| 3312 | return 0, 0, nil |
| 3313 | } |
| 3314 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3315 | func (f *OpenOltFlowMgr) loadFlowIDsForGemAndGemIDsForFlow(ctx context.Context) { |
| 3316 | logger.Debug(ctx, "loadFlowIDsForGemAndGemIDsForFlow - start") |
| 3317 | f.onuGemInfoLock.RLock() |
| 3318 | f.gemToFlowIDsKey.Lock() |
| 3319 | f.flowIDToGemsLock.Lock() |
| 3320 | for _, og := range f.onuGemInfoMap { |
| 3321 | for _, gem := range og.GemPorts { |
| 3322 | flowIDs, err := f.resourceMgr.GetFlowIDsForGem(ctx, f.ponPortIdx, gem) |
Gamze Abaka | 6f345c1 | 2021-09-08 01:14:33 +0000 | [diff] [blame] | 3323 | if err == nil { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3324 | f.gemToFlowIDs[gem] = flowIDs |
| 3325 | for _, flowID := range flowIDs { |
| 3326 | if _, ok := f.flowIDToGems[flowID]; !ok { |
| 3327 | f.flowIDToGems[flowID] = []uint32{gem} |
| 3328 | } else { |
| 3329 | f.flowIDToGems[flowID] = appendUnique32bit(f.flowIDToGems[flowID], gem) |
| 3330 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3331 | } |
| 3332 | } |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 3333 | } |
| 3334 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3335 | f.flowIDToGemsLock.Unlock() |
| 3336 | f.gemToFlowIDsKey.Unlock() |
| 3337 | f.onuGemInfoLock.RUnlock() |
| 3338 | logger.Debug(ctx, "loadFlowIDsForGemAndGemIDsForFlow - end") |
Abhilash Laxmeshwar | 275c074 | 2019-11-25 16:47:02 +0530 | [diff] [blame] | 3339 | } |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3340 | |
Girish Gowdra | 9602eb4 | 2020-09-09 15:50:39 -0700 | [diff] [blame] | 3341 | //clearMulticastFlowFromResourceManager removes a multicast flow from the KV store and |
| 3342 | // clears resources reserved for this multicast flow |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3343 | func (f *OpenOltFlowMgr) clearMulticastFlowFromResourceManager(ctx context.Context, flow *ofp.OfpFlowStats) error { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3344 | removeFlowMessage := openoltpb2.Flow{FlowId: flow.Id, FlowType: Multicast} |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3345 | logger.Debugw(ctx, "multicast-flow-to-be-deleted", |
| 3346 | log.Fields{ |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3347 | "flow": flow, |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3348 | "flow-id": flow.Id, |
| 3349 | "device-id": f.deviceHandler.device.Id}) |
| 3350 | // Remove from device |
| 3351 | if err := f.removeFlowFromDevice(ctx, &removeFlowMessage, flow.Id); err != nil { |
| 3352 | // DKB |
| 3353 | logger.Errorw(ctx, "failed-to-remove-multicast-flow", |
| 3354 | log.Fields{ |
| 3355 | "flow-id": flow.Id, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3356 | "err": err}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3357 | return err |
| 3358 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3359 | |
| 3360 | return nil |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 3361 | } |
| 3362 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3363 | func (f *OpenOltFlowMgr) getTechProfileDownloadMessage(ctx context.Context, tpPath string, uniID uint32, onuDeviceID string) (*ic.TechProfileDownloadMessage, error) { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3364 | tpInst, err := f.techprofile.GetTPInstance(ctx, tpPath) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3365 | if err != nil { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3366 | logger.Errorw(ctx, "error-fetching-tp-instance", log.Fields{"tpPath": tpPath}) |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3367 | return nil, err |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3368 | } |
| 3369 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3370 | switch tpInst := tpInst.(type) { |
| 3371 | case *tp_pb.TechProfileInstance: |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3372 | logger.Debugw(ctx, "fetched-tp-instance-successfully-formulating-tp-download-msg", log.Fields{"tpPath": tpPath}) |
| 3373 | return &ic.TechProfileDownloadMessage{ |
| 3374 | DeviceId: onuDeviceID, |
| 3375 | UniId: uniID, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3376 | TpInstancePath: tpPath, |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3377 | TechTpInstance: &ic.TechProfileDownloadMessage_TpInstance{TpInstance: tpInst}, |
| 3378 | }, nil |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3379 | case *openoltpb2.EponTechProfileInstance: |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3380 | return &ic.TechProfileDownloadMessage{ |
| 3381 | DeviceId: onuDeviceID, |
| 3382 | UniId: uniID, |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3383 | TpInstancePath: tpPath, |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3384 | TechTpInstance: &ic.TechProfileDownloadMessage_EponTpInstance{EponTpInstance: tpInst}, |
| 3385 | }, nil |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3386 | default: |
| 3387 | logger.Errorw(ctx, "unknown-tech", log.Fields{"tpPath": tpPath}) |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3388 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3389 | return &ic.TechProfileDownloadMessage{ |
| 3390 | DeviceId: onuDeviceID, |
| 3391 | UniId: uniID, |
| 3392 | TpInstancePath: tpPath, |
| 3393 | TechTpInstance: nil, |
| 3394 | }, nil |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3395 | } |
| 3396 | |
Girish Gowdra | bcf98af | 2021-07-01 08:24:42 -0700 | [diff] [blame] | 3397 | func (f *OpenOltFlowMgr) getOnuGemInfoList(ctx context.Context) []rsrcMgr.OnuGemInfo { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 3398 | var onuGemInfoLst []rsrcMgr.OnuGemInfo |
| 3399 | f.onuGemInfoLock.RLock() |
| 3400 | defer f.onuGemInfoLock.RUnlock() |
| 3401 | for _, v := range f.onuGemInfoMap { |
| 3402 | onuGemInfoLst = append(onuGemInfoLst, *v) |
| 3403 | } |
| 3404 | return onuGemInfoLst |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 3405 | } |