Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +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 | |
| 17 | package core |
| 18 | |
| 19 | import ( |
| 20 | "errors" |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 21 | "strings" |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 22 | |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 23 | "github.com/opencord/openolt-scale-tester/config" |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 24 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 25 | "github.com/opencord/voltha-lib-go/v3/pkg/ponresourcemanager" |
| 26 | oop "github.com/opencord/voltha-protos/v3/go/openolt" |
| 27 | tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile" |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 28 | "golang.org/x/net/context" |
| 29 | "google.golang.org/grpc/codes" |
| 30 | "google.golang.org/grpc/status" |
| 31 | ) |
| 32 | |
| 33 | func init() { |
| 34 | _, _ = log.AddPackage(log.JSON, log.DebugLevel, nil) |
| 35 | } |
| 36 | |
| 37 | // A dummy struct to comply with the WorkFlow interface. |
| 38 | type AttWorkFlow struct { |
| 39 | } |
| 40 | |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 41 | func AddDhcpIPV4Flow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error { |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 42 | var flowID []uint32 |
| 43 | var err error |
| 44 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 45 | if flowID, err = rsrMgr.ResourceMgrs[uint32(config.NniIntfID)].GetResourceID(context.Background(), uint32(config.NniIntfID), |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 46 | ponresourcemanager.FLOW_ID, 1); err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 50 | // DHCP IPV4 |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 51 | flowClassifier := &oop.Classifier{EthType: 2048, IpProto: 17, SrcPort: 67, DstPort: 68, PktTagType: "double_tag"} |
| 52 | actionCmd := &oop.ActionCmd{TrapToHost: true} |
| 53 | actionInfo := &oop.Action{Cmd: actionCmd} |
| 54 | |
| 55 | flow := oop.Flow{AccessIntfId: -1, OnuId: -1, UniId: -1, FlowId: flowID[0], |
| 56 | FlowType: "downstream", AllocId: -1, GemportId: -1, |
| 57 | Classifier: flowClassifier, Action: actionInfo, |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 58 | Priority: 1000, PortNo: uint32(config.NniIntfID)} |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 59 | |
| 60 | _, err = oo.FlowAdd(context.Background(), &flow) |
| 61 | |
| 62 | st, _ := status.FromError(err) |
| 63 | if st.Code() == codes.AlreadyExists { |
| 64 | log.Debugw("Flow already exists", log.Fields{"err": err, "deviceFlow": flow}) |
| 65 | return nil |
| 66 | } |
| 67 | |
| 68 | if err != nil { |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 69 | log.Errorw("Failed to Add DHCP IPv4 to device", log.Fields{"err": err, "deviceFlow": flow}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 70 | rsrMgr.ResourceMgrs[uint32(config.NniIntfID)].FreeResourceID(context.Background(), uint32(config.NniIntfID), |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 71 | ponresourcemanager.FLOW_ID, flowID) |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 72 | return err |
| 73 | } |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 74 | log.Debugw("DHCP IPV4 added to device successfully ", log.Fields{"flow": flow}) |
| 75 | |
| 76 | return nil |
| 77 | } |
| 78 | |
| 79 | func AddDhcpIPV6Flow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error { |
| 80 | var flowID []uint32 |
| 81 | var err error |
| 82 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 83 | if flowID, err = rsrMgr.ResourceMgrs[uint32(config.NniIntfID)].GetResourceID(context.Background(), uint32(config.NniIntfID), |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 84 | ponresourcemanager.FLOW_ID, 1); err != nil { |
| 85 | return err |
| 86 | } |
| 87 | |
| 88 | // DHCP IPV6 |
| 89 | flowClassifier := &oop.Classifier{EthType: 34525, IpProto: 17, SrcPort: 546, DstPort: 547, PktTagType: "double_tag"} |
| 90 | actionCmd := &oop.ActionCmd{TrapToHost: true} |
| 91 | actionInfo := &oop.Action{Cmd: actionCmd} |
| 92 | |
| 93 | flow := oop.Flow{AccessIntfId: -1, OnuId: -1, UniId: -1, FlowId: flowID[0], |
| 94 | FlowType: "downstream", AllocId: -1, GemportId: -1, |
| 95 | Classifier: flowClassifier, Action: actionInfo, |
| 96 | Priority: 1000, PortNo: uint32(config.NniIntfID)} |
| 97 | |
| 98 | _, err = oo.FlowAdd(context.Background(), &flow) |
| 99 | |
| 100 | st, _ := status.FromError(err) |
| 101 | if st.Code() == codes.AlreadyExists { |
| 102 | log.Debugw("Flow already exists", log.Fields{"err": err, "deviceFlow": flow}) |
| 103 | return nil |
| 104 | } |
| 105 | |
| 106 | if err != nil { |
| 107 | log.Errorw("Failed to Add DHCP IPV6 to device", log.Fields{"err": err, "deviceFlow": flow}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 108 | rsrMgr.ResourceMgrs[uint32(config.NniIntfID)].FreeResourceID(context.Background(), uint32(config.NniIntfID), |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 109 | ponresourcemanager.FLOW_ID, flowID) |
| 110 | return err |
| 111 | } |
| 112 | log.Debugw("DHCP IPV6 added to device successfully ", log.Fields{"flow": flow}) |
| 113 | |
| 114 | return nil |
| 115 | } |
| 116 | |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 117 | func ProvisionAttNniTrapFlow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error { |
| 118 | _ = AddDhcpIPV4Flow(oo, config, rsrMgr) |
| 119 | _ = AddDhcpIPV6Flow(oo, config, rsrMgr) |
| 120 | _ = AddLldpFlow(oo, config, rsrMgr) |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 121 | |
| 122 | return nil |
| 123 | } |
| 124 | |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 125 | func (att AttWorkFlow) ProvisionScheds(subs *Subscriber) error { |
| 126 | var trafficSched []*tp_pb.TrafficScheduler |
| 127 | |
| 128 | log.Info("provisioning-scheds") |
| 129 | |
| 130 | if trafficSched = getTrafficSched(subs, tp_pb.Direction_DOWNSTREAM); trafficSched == nil { |
| 131 | log.Error("ds-traffic-sched-is-nil") |
| 132 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 133 | } |
| 134 | |
| 135 | log.Debugw("Sending Traffic scheduler create to device", |
| 136 | log.Fields{"Direction": tp_pb.Direction_DOWNSTREAM, "TrafficScheds": trafficSched}) |
| 137 | if _, err := subs.OpenOltClient.CreateTrafficSchedulers(context.Background(), &tp_pb.TrafficSchedulers{ |
| 138 | IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 139 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 140 | TrafficScheds: trafficSched}); err != nil { |
| 141 | log.Errorw("Failed to create traffic schedulers", log.Fields{"error": err}) |
| 142 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 143 | } |
| 144 | |
| 145 | if trafficSched = getTrafficSched(subs, tp_pb.Direction_UPSTREAM); trafficSched == nil { |
| 146 | log.Error("us-traffic-sched-is-nil") |
| 147 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 148 | } |
| 149 | |
| 150 | log.Debugw("Sending Traffic scheduler create to device", |
| 151 | log.Fields{"Direction": tp_pb.Direction_UPSTREAM, "TrafficScheds": trafficSched}) |
| 152 | if _, err := subs.OpenOltClient.CreateTrafficSchedulers(context.Background(), &tp_pb.TrafficSchedulers{ |
| 153 | IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 154 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 155 | TrafficScheds: trafficSched}); err != nil { |
| 156 | log.Errorw("Failed to create traffic schedulers", log.Fields{"error": err}) |
| 157 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 158 | } |
| 159 | |
| 160 | return nil |
| 161 | } |
| 162 | |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 163 | func (att AttWorkFlow) ProvisionQueues(subs *Subscriber) error { |
| 164 | log.Info("provisioning-queues") |
| 165 | |
| 166 | var trafficQueues []*tp_pb.TrafficQueue |
| 167 | if trafficQueues = getTrafficQueues(subs, tp_pb.Direction_DOWNSTREAM); trafficQueues == nil { |
| 168 | log.Error("Failed to create traffic queues") |
| 169 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 170 | } |
| 171 | |
| 172 | // On receiving the CreateTrafficQueues request, the driver should create corresponding |
| 173 | // downstream queues. |
| 174 | log.Debugw("Sending Traffic Queues create to device", |
| 175 | log.Fields{"Direction": tp_pb.Direction_DOWNSTREAM, "TrafficQueues": trafficQueues}) |
| 176 | if _, err := subs.OpenOltClient.CreateTrafficQueues(context.Background(), |
| 177 | &tp_pb.TrafficQueues{IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 178 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 179 | TrafficQueues: trafficQueues}); err != nil { |
| 180 | log.Errorw("Failed to create traffic queues in device", log.Fields{"error": err}) |
| 181 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 182 | } |
| 183 | |
| 184 | if trafficQueues = getTrafficQueues(subs, tp_pb.Direction_UPSTREAM); trafficQueues == nil { |
| 185 | log.Error("Failed to create traffic queues") |
| 186 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 187 | } |
| 188 | |
| 189 | // On receiving the CreateTrafficQueues request, the driver should create corresponding |
| 190 | // upstream queues. |
| 191 | log.Debugw("Sending Traffic Queues create to device", |
| 192 | log.Fields{"Direction": tp_pb.Direction_UPSTREAM, "TrafficQueues": trafficQueues}) |
| 193 | if _, err := subs.OpenOltClient.CreateTrafficQueues(context.Background(), |
| 194 | &tp_pb.TrafficQueues{IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 195 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 196 | TrafficQueues: trafficQueues}); err != nil { |
| 197 | log.Errorw("Failed to create traffic queues in device", log.Fields{"error": err}) |
| 198 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 199 | } |
| 200 | |
| 201 | return nil |
| 202 | } |
| 203 | |
| 204 | func (att AttWorkFlow) ProvisionEapFlow(subs *Subscriber) error { |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 205 | var err error |
| 206 | var flowID []uint32 |
| 207 | var gemPortIDs []uint32 |
| 208 | |
| 209 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 210 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
| 211 | gemPortIDs = append(gemPortIDs, gem.GemportID) |
| 212 | } |
| 213 | |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 214 | for idx, gemID := range gemPortIDs { |
| 215 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 216 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 217 | if pbitSet == '1' { |
| 218 | pcp := uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 219 | if flowID, err = subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].GetResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 220 | ponresourcemanager.FLOW_ID, 1); err != nil { |
| 221 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 222 | } else { |
| 223 | if err := AddFlow(subs, EapolFlow, Upstream, flowID[0], allocID, gemID, pcp); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 224 | subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 225 | ponresourcemanager.FLOW_ID, flowID) |
| 226 | return err |
| 227 | } |
| 228 | } |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 229 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 230 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 231 | } |
| 232 | return nil |
| 233 | } |
| 234 | |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 235 | func (att AttWorkFlow) ProvisionDhcpIPV4Flow(subs *Subscriber) error { |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 236 | var err error |
| 237 | var flowID []uint32 |
| 238 | var gemPortIDs []uint32 |
| 239 | |
| 240 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID |
| 241 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
| 242 | gemPortIDs = append(gemPortIDs, gem.GemportID) |
| 243 | } |
| 244 | |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 245 | for idx, gemID := range gemPortIDs { |
| 246 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 247 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 248 | if pbitSet == '1' { |
| 249 | pcp := uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 250 | if flowID, err = subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].GetResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 251 | ponresourcemanager.FLOW_ID, 1); err != nil { |
| 252 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 253 | } else { |
| 254 | if err := AddFlow(subs, DhcpFlowIPV4, Upstream, flowID[0], allocID, gemID, pcp); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 255 | subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 256 | ponresourcemanager.FLOW_ID, flowID) |
| 257 | return err |
| 258 | } |
| 259 | } |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | } |
| 263 | return nil |
| 264 | } |
| 265 | |
| 266 | func (att AttWorkFlow) ProvisionDhcpIPV6Flow(subs *Subscriber) error { |
| 267 | var err error |
| 268 | var flowID []uint32 |
| 269 | var gemPortIDs []uint32 |
| 270 | |
| 271 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID |
| 272 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
| 273 | gemPortIDs = append(gemPortIDs, gem.GemportID) |
| 274 | } |
| 275 | |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 276 | for idx, gemID := range gemPortIDs { |
| 277 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 278 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 279 | if pbitSet == '1' { |
| 280 | pcp := uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 281 | if flowID, err = subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].GetResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 282 | ponresourcemanager.FLOW_ID, 1); err != nil { |
| 283 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 284 | } else { |
| 285 | if err := AddFlow(subs, DhcpFlowIPV6, Upstream, flowID[0], allocID, gemID, pcp); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 286 | subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 287 | ponresourcemanager.FLOW_ID, flowID) |
| 288 | return err |
| 289 | } |
| 290 | } |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 294 | return nil |
| 295 | } |
| 296 | |
| 297 | func (att AttWorkFlow) ProvisionIgmpFlow(subs *Subscriber) error { |
| 298 | log.Info("att-workflow-does-not-support-igmp-yet--nothing-to-do") |
| 299 | return nil |
| 300 | } |
| 301 | |
| 302 | func (att AttWorkFlow) ProvisionHsiaFlow(subs *Subscriber) error { |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 303 | var err error |
| 304 | var flowID []uint32 |
| 305 | var gemPortIDs []uint32 |
| 306 | |
| 307 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID |
| 308 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
| 309 | gemPortIDs = append(gemPortIDs, gem.GemportID) |
| 310 | } |
| 311 | |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 312 | for idx, gemID := range gemPortIDs { |
| 313 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 314 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 315 | if pbitSet == '1' { |
| 316 | pcp := uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 317 | if flowID, err = subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].GetResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 318 | ponresourcemanager.FLOW_ID, 1); err != nil { |
| 319 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 320 | } else { |
| 321 | var errUs, errDs error |
| 322 | if errUs = AddFlow(subs, HsiaFlow, Upstream, flowID[0], allocID, gemID, pcp); errUs != nil { |
| 323 | log.Errorw("failed to install US HSIA flow", |
| 324 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 325 | } |
| 326 | if errDs = AddFlow(subs, HsiaFlow, Downstream, flowID[0], allocID, gemID, pcp); errDs != nil { |
| 327 | log.Errorw("failed to install US HSIA flow", |
| 328 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 329 | } |
| 330 | if errUs != nil && errDs != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 331 | subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(context.Background(), uint32(subs.PonIntf), |
Girish Gowdra | d4bdd37 | 2020-03-09 14:56:15 -0700 | [diff] [blame] | 332 | ponresourcemanager.FLOW_ID, flowID) |
| 333 | } |
| 334 | if errUs != nil || errDs != nil { |
| 335 | if errUs != nil { |
| 336 | return errUs |
| 337 | } |
| 338 | return errDs |
| 339 | } |
Girish Gowdra | ef1b7c4 | 2020-01-23 16:27:48 +0530 | [diff] [blame] | 340 | } |
Thiyagarajan Subramani | b83b043 | 2020-01-08 13:43:28 +0530 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | } |
Girish Gowdra | 6450343 | 2020-01-07 10:59:10 +0530 | [diff] [blame] | 344 | return nil |
| 345 | } |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 346 | |
| 347 | func (att AttWorkFlow) ProvisionVoipFlow(subs *Subscriber) error { |
| 348 | log.Info("att-workflow-does-not-support-voip-yet--nothing-to-do") |
| 349 | return nil |
| 350 | } |
| 351 | |
| 352 | func (att AttWorkFlow) ProvisionVodFlow(subs *Subscriber) error { |
| 353 | log.Info("att-workflow-does-not-support-vod-yet--nothing-to-do") |
| 354 | return nil |
| 355 | } |
| 356 | |
| 357 | func (att AttWorkFlow) ProvisionMgmtFlow(subs *Subscriber) error { |
| 358 | log.Info("att-workflow-does-not-support-mgmt-yet--nothing-to-do") |
| 359 | return nil |
| 360 | } |
| 361 | |
| 362 | func (att AttWorkFlow) ProvisionMulticastFlow(subs *Subscriber) error { |
| 363 | log.Info("att-workflow-does-not-support-multicast-yet--nothing-to-do") |
| 364 | return nil |
| 365 | } |