Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [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" |
| 21 | "strings" |
| 22 | "sync/atomic" |
| 23 | |
| 24 | "github.com/opencord/openolt-scale-tester/config" |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 25 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
| 26 | oop "github.com/opencord/voltha-protos/v5/go/openolt" |
| 27 | tp_pb "github.com/opencord/voltha-protos/v5/go/tech_profile" |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 28 | "golang.org/x/net/context" |
| 29 | "google.golang.org/grpc/codes" |
| 30 | "google.golang.org/grpc/status" |
| 31 | ) |
| 32 | |
| 33 | var lastPonIntf *uint32 = new(uint32) |
| 34 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 35 | // A dummy struct to comply with the WorkFlow interface. |
| 36 | type TtWorkFlow struct { |
| 37 | } |
| 38 | |
| 39 | func AddTtDhcpIPV4Flow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 40 | var flowID uint64 |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 41 | var err error |
| 42 | |
Girish Gowdra | aeceb84 | 2020-08-21 12:10:39 -0700 | [diff] [blame] | 43 | // Allocating flowID from PON0 pool for an trap-from-nni flow |
| 44 | if flowID, err = rsrMgr.GetFlowID(context.Background(), uint32(0)); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 45 | return err |
| 46 | } |
| 47 | |
| 48 | // DHCP IPV4 |
| 49 | flowClassifier := &oop.Classifier{EthType: 2048, IpProto: 17, SrcPort: 67, DstPort: 68, PktTagType: "double_tag"} |
| 50 | actionCmd := &oop.ActionCmd{TrapToHost: true} |
| 51 | actionInfo := &oop.Action{Cmd: actionCmd} |
| 52 | |
Girish Gowdra | aeceb84 | 2020-08-21 12:10:39 -0700 | [diff] [blame] | 53 | flow := oop.Flow{AccessIntfId: -1, OnuId: -1, UniId: -1, FlowId: flowID, |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 54 | FlowType: "downstream", AllocId: -1, GemportId: -1, |
| 55 | Classifier: flowClassifier, Action: actionInfo, |
| 56 | Priority: 1000, PortNo: uint32(config.NniIntfID)} |
| 57 | |
| 58 | _, err = oo.FlowAdd(context.Background(), &flow) |
| 59 | |
| 60 | st, _ := status.FromError(err) |
| 61 | if st.Code() == codes.AlreadyExists { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 62 | logger.Debugw(nil, "Flow already exists", log.Fields{"err": err, "deviceFlow": flow}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 63 | return nil |
| 64 | } |
| 65 | |
| 66 | if err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 67 | logger.Errorw(nil, "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] | 68 | return err |
| 69 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 70 | logger.Debugw(nil, "DHCP IPV4 added to device successfully ", log.Fields{"flow": flow}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 71 | |
| 72 | return nil |
| 73 | } |
| 74 | |
| 75 | func AddTtDhcpIPV6Flow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 76 | logger.Info(nil, "tt-workflow-does-not-require-dhcp-ipv6-support--nothing-to-do") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 77 | return nil |
| 78 | } |
| 79 | |
| 80 | func ProvisionTtNniTrapFlow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error { |
| 81 | _ = AddTtDhcpIPV4Flow(oo, config, rsrMgr) |
| 82 | return nil |
| 83 | } |
| 84 | |
| 85 | func FormatTtClassfierAction(flowType string, direction string, subs *Subscriber) (oop.Classifier, oop.Action) { |
| 86 | var flowClassifier oop.Classifier |
| 87 | var actionCmd oop.ActionCmd |
| 88 | var actionInfo oop.Action |
| 89 | |
| 90 | if direction == Upstream { |
| 91 | switch flowType { |
| 92 | case IgmpFlow: |
| 93 | flowClassifier.EthType = IPv4EthType |
| 94 | flowClassifier.IpProto = IgmpProto |
| 95 | flowClassifier.SrcPort = 0 |
| 96 | flowClassifier.DstPort = 0 |
| 97 | flowClassifier.PktTagType = SingleTag |
| 98 | actionCmd.TrapToHost = true |
| 99 | actionInfo.Cmd = &actionCmd |
| 100 | case HsiaFlow: |
| 101 | actionCmd.AddOuterTag = true |
| 102 | actionInfo.Cmd = &actionCmd |
| 103 | actionInfo.IVid = 33 |
| 104 | actionInfo.OVid = 7 |
| 105 | flowClassifier.IPbits = 255 |
| 106 | flowClassifier.OVid = 33 |
| 107 | flowClassifier.PktTagType = SingleTag |
| 108 | case VoipFlow: |
| 109 | actionCmd.AddOuterTag = true |
| 110 | actionInfo.Cmd = &actionCmd |
| 111 | actionInfo.OPbits = 7 |
| 112 | actionInfo.IVid = 63 |
| 113 | actionInfo.OVid = 10 |
| 114 | flowClassifier.IPbits = 255 |
| 115 | flowClassifier.OPbits = 7 |
| 116 | flowClassifier.OVid = 63 |
| 117 | flowClassifier.PktTagType = SingleTag |
| 118 | case VodFlow: |
| 119 | actionCmd.AddOuterTag = true |
| 120 | actionInfo.Cmd = &actionCmd |
| 121 | actionInfo.OPbits = 5 |
| 122 | actionInfo.IVid = 55 |
| 123 | actionInfo.OVid = 555 |
| 124 | flowClassifier.IPbits = 255 |
| 125 | flowClassifier.OPbits = 5 |
| 126 | flowClassifier.OVid = 55 |
| 127 | flowClassifier.PktTagType = SingleTag |
| 128 | case MgmtFlow: |
| 129 | actionCmd.AddOuterTag = true |
| 130 | actionInfo.Cmd = &actionCmd |
| 131 | actionInfo.OPbits = 7 |
| 132 | actionInfo.IVid = 75 |
| 133 | actionInfo.OVid = 575 |
| 134 | flowClassifier.IPbits = 255 |
| 135 | flowClassifier.OPbits = 7 |
| 136 | flowClassifier.OVid = 75 |
| 137 | flowClassifier.PktTagType = SingleTag |
| 138 | default: |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 139 | logger.Errorw(nil, "Unsupported TT flow type", log.Fields{"flowtype": flowType, |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 140 | "direction": direction}) |
| 141 | } |
| 142 | } else if direction == Downstream { |
| 143 | switch flowType { |
| 144 | case IgmpFlow: |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 145 | logger.Errorw(nil, "Downstream IGMP flows are not required instead we have "+ |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 146 | "IGMP trap flows already installed", log.Fields{"flowtype": flowType, |
| 147 | "direction": direction}) |
| 148 | case HsiaFlow: |
| 149 | actionCmd.RemoveOuterTag = true |
| 150 | actionInfo.Cmd = &actionCmd |
| 151 | actionInfo.IVid = 33 |
| 152 | flowClassifier.IPbits = 255 |
| 153 | flowClassifier.OPbits = 255 |
| 154 | flowClassifier.IVid = 33 |
| 155 | flowClassifier.OVid = 7 |
| 156 | flowClassifier.PktTagType = DoubleTag |
| 157 | case VoipFlow: |
| 158 | actionCmd.RemoveOuterTag = true |
| 159 | actionInfo.Cmd = &actionCmd |
| 160 | actionInfo.IPbits = 7 |
| 161 | actionInfo.IVid = 63 |
| 162 | flowClassifier.IPbits = 255 |
| 163 | flowClassifier.OPbits = 255 |
| 164 | flowClassifier.IVid = 63 |
| 165 | flowClassifier.OVid = 10 |
| 166 | flowClassifier.DstMac = GenerateMac(true) |
| 167 | flowClassifier.PktTagType = DoubleTag |
| 168 | case VodFlow: |
| 169 | actionCmd.RemoveOuterTag = true |
| 170 | actionInfo.Cmd = &actionCmd |
| 171 | actionInfo.IPbits = 5 |
| 172 | actionInfo.IVid = 55 |
| 173 | flowClassifier.IPbits = 255 |
| 174 | flowClassifier.OPbits = 255 |
| 175 | flowClassifier.IVid = 55 |
| 176 | flowClassifier.OVid = 555 |
| 177 | flowClassifier.DstMac = GenerateMac(true) |
| 178 | flowClassifier.PktTagType = DoubleTag |
| 179 | case MgmtFlow: |
| 180 | actionCmd.RemoveOuterTag = true |
| 181 | actionInfo.Cmd = &actionCmd |
| 182 | actionInfo.IPbits = 7 |
| 183 | actionInfo.IVid = 75 |
| 184 | flowClassifier.IPbits = 255 |
| 185 | flowClassifier.OPbits = 255 |
| 186 | flowClassifier.IVid = 75 |
| 187 | flowClassifier.OVid = 575 |
| 188 | flowClassifier.DstMac = GenerateMac(true) |
| 189 | flowClassifier.PktTagType = DoubleTag |
| 190 | default: |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 191 | logger.Errorw(nil, "Unsupported TT flow type", log.Fields{"flowtype": flowType, |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 192 | "direction": direction}) |
| 193 | } |
| 194 | } |
| 195 | return flowClassifier, actionInfo |
| 196 | } |
| 197 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 198 | func AddTtFlow(subs *Subscriber, flowType string, direction string, flowID uint64, |
| 199 | allocID uint32, gemID uint32, pcp uint32, replicateFlow bool, symmetricFlowID uint64, |
| 200 | pbitToGem map[uint32]uint32) error { |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 201 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 202 | var err error |
| 203 | |
| 204 | flowClassifier, actionInfo := FormatTtClassfierAction(flowType, direction, subs) |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 205 | // Update the o_pbit (if valid) for which this flow has to be classified |
| 206 | if pcp != 0xff { |
| 207 | flowClassifier.OPbits = pcp |
| 208 | } |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 209 | flow := oop.Flow{AccessIntfId: int32(subs.PonIntf), OnuId: int32(subs.OnuID), |
| 210 | UniId: int32(subs.UniID), FlowId: flowID, |
| 211 | FlowType: direction, AllocId: int32(allocID), GemportId: int32(gemID), |
| 212 | Classifier: &flowClassifier, Action: &actionInfo, |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 213 | Priority: 1000, PortNo: subs.UniPortNo, |
| 214 | SymmetricFlowId: symmetricFlowID, |
| 215 | ReplicateFlow: replicateFlow, PbitToGemport: pbitToGem} |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 216 | |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 217 | logger.Infow(nil, "adding-flow", log.Fields{"flow": flow}) |
| 218 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 219 | _, err = subs.OpenOltClient.FlowAdd(context.Background(), &flow) |
| 220 | |
| 221 | st, _ := status.FromError(err) |
| 222 | if st.Code() == codes.AlreadyExists { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 223 | logger.Debugw(nil, "Flow already exists", log.Fields{"err": err, "deviceFlow": flow}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 224 | return nil |
| 225 | } |
| 226 | |
| 227 | if err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 228 | logger.Errorw(nil, "Failed to Add flow to device", log.Fields{"err": err, "deviceFlow": flow}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 229 | return errors.New(ReasonCodeToReasonString(FLOW_ADD_FAILED)) |
| 230 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 231 | logger.Debugw(nil, "Flow added to device successfully ", log.Fields{"flow": flow}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 232 | |
| 233 | return nil |
| 234 | } |
| 235 | |
| 236 | func (tt TtWorkFlow) ProvisionScheds(subs *Subscriber) error { |
| 237 | var trafficSched []*tp_pb.TrafficScheduler |
| 238 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 239 | logger.Info(nil, "provisioning-scheds") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 240 | |
| 241 | if trafficSched = getTrafficSched(subs, tp_pb.Direction_DOWNSTREAM); trafficSched == nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 242 | logger.Error(nil, "ds-traffic-sched-is-nil") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 243 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 244 | } |
| 245 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 246 | logger.Debugw(nil, "Sending Traffic scheduler create to device", |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 247 | log.Fields{"Direction": tp_pb.Direction_DOWNSTREAM, "TrafficScheds": trafficSched}) |
| 248 | if _, err := subs.OpenOltClient.CreateTrafficSchedulers(context.Background(), &tp_pb.TrafficSchedulers{ |
| 249 | IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 250 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 251 | TrafficScheds: trafficSched}); err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 252 | logger.Errorw(nil, "Failed to create traffic schedulers", log.Fields{"error": err}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 253 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 254 | } |
| 255 | |
| 256 | if trafficSched = getTrafficSched(subs, tp_pb.Direction_UPSTREAM); trafficSched == nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 257 | logger.Error(nil, "us-traffic-sched-is-nil") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 258 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 259 | } |
| 260 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 261 | logger.Debugw(nil, "Sending Traffic scheduler create to device", |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 262 | log.Fields{"Direction": tp_pb.Direction_UPSTREAM, "TrafficScheds": trafficSched}) |
| 263 | if _, err := subs.OpenOltClient.CreateTrafficSchedulers(context.Background(), &tp_pb.TrafficSchedulers{ |
| 264 | IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 265 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 266 | TrafficScheds: trafficSched}); err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 267 | logger.Errorw(nil, "Failed to create traffic schedulers", log.Fields{"error": err}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 268 | return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED)) |
| 269 | } |
| 270 | return nil |
| 271 | } |
| 272 | |
| 273 | func (tt TtWorkFlow) ProvisionQueues(subs *Subscriber) error { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 274 | logger.Info(nil, "provisioning-queues") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 275 | |
| 276 | var trafficQueues []*tp_pb.TrafficQueue |
| 277 | if trafficQueues = getTrafficQueues(subs, tp_pb.Direction_DOWNSTREAM); trafficQueues == nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 278 | logger.Error(nil, "Failed to create traffic queues") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 279 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 280 | } |
| 281 | |
| 282 | // On receiving the CreateTrafficQueues request, the driver should create corresponding |
| 283 | // downstream queues. |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 284 | logger.Debugw(nil, "Sending Traffic Queues create to device", |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 285 | log.Fields{"Direction": tp_pb.Direction_DOWNSTREAM, "TrafficQueues": trafficQueues}) |
| 286 | if _, err := subs.OpenOltClient.CreateTrafficQueues(context.Background(), |
| 287 | &tp_pb.TrafficQueues{IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 288 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 289 | TrafficQueues: trafficQueues}); err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 290 | logger.Errorw(nil, "Failed to create traffic queues in device", log.Fields{"error": err}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 291 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 292 | } |
| 293 | |
| 294 | if trafficQueues = getTrafficQueues(subs, tp_pb.Direction_UPSTREAM); trafficQueues == nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 295 | logger.Error(nil, "Failed to create traffic queues") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 296 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 297 | } |
| 298 | |
| 299 | // On receiving the CreateTrafficQueues request, the driver should create corresponding |
| 300 | // upstream queues. |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 301 | logger.Debugw(nil, "Sending Traffic Queues create to device", |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 302 | log.Fields{"Direction": tp_pb.Direction_UPSTREAM, "TrafficQueues": trafficQueues}) |
| 303 | if _, err := subs.OpenOltClient.CreateTrafficQueues(context.Background(), |
| 304 | &tp_pb.TrafficQueues{IntfId: subs.PonIntf, OnuId: subs.OnuID, |
| 305 | UniId: subs.UniID, PortNo: subs.UniPortNo, |
| 306 | TrafficQueues: trafficQueues}); err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 307 | logger.Errorw(nil, "Failed to create traffic queues in device", log.Fields{"error": err}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 308 | return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED)) |
| 309 | } |
| 310 | |
| 311 | return nil |
| 312 | } |
| 313 | |
| 314 | func (tt TtWorkFlow) ProvisionEapFlow(subs *Subscriber) error { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 315 | logger.Info(nil, "tt-workflow-does-not-support-eap-yet--nothing-to-do") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 316 | return nil |
| 317 | } |
| 318 | |
| 319 | func (tt TtWorkFlow) ProvisionDhcpIPV4Flow(subs *Subscriber) error { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 320 | logger.Info(nil, "tt-workflow-does-not-require-dhcp-ipv4-yet--nothing-to-do") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 321 | return nil |
| 322 | } |
| 323 | |
| 324 | func (tt TtWorkFlow) ProvisionDhcpIPV6Flow(subs *Subscriber) error { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 325 | logger.Info(nil, "tt-workflow-does-not-require-dhcp-ipv6-support--nothing-to-do") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 326 | return nil |
| 327 | } |
| 328 | |
| 329 | func (tt TtWorkFlow) ProvisionIgmpFlow(subs *Subscriber) error { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 330 | logger.Info(nil, "tt-workflow-does-not-require-igmp-support--nothing-to-do") |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 331 | return nil |
| 332 | } |
| 333 | |
| 334 | func (tt TtWorkFlow) ProvisionHsiaFlow(subs *Subscriber) error { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 335 | var gemPortIDs []uint32 |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 336 | var err error |
| 337 | var flowIDUs, flowIDDs uint64 |
| 338 | pbitToGem := make(map[uint32]uint32) |
| 339 | var pcp uint32 |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 340 | |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 341 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocId |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 342 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 343 | gemPortIDs = append(gemPortIDs, gem.GemportId) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | for idx, gemID := range gemPortIDs { |
| 347 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 348 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 349 | if pbitSet == '1' { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 350 | pcp = uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
| 351 | var errUs, errDs error |
| 352 | if flowIDUs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 353 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 354 | } |
| 355 | if errUs = AddTtFlow(subs, HsiaFlow, Upstream, flowIDUs, allocID, gemID, pcp, false, |
| 356 | 0, pbitToGem); errUs != nil { |
| 357 | logger.Errorw(nil, "failed to install US HSIA flow", |
| 358 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 359 | } |
| 360 | if flowIDDs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 361 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 362 | } |
| 363 | if errDs = AddTtFlow(subs, HsiaFlow, Downstream, flowIDDs, allocID, gemID, pcp, false, |
| 364 | flowIDUs, pbitToGem); errDs != nil { |
| 365 | logger.Errorw(nil, "failed to install DS HSIA flow", |
| 366 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 367 | } |
Girish Gowdra | aeceb84 | 2020-08-21 12:10:39 -0700 | [diff] [blame] | 368 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 369 | if errUs != nil || errDs != nil { |
| 370 | if errUs != nil { |
| 371 | return errUs |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 372 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 373 | return errDs |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 374 | } |
| 375 | } |
| 376 | } |
| 377 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 378 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 379 | return nil |
| 380 | } |
| 381 | |
| 382 | func (tt TtWorkFlow) ProvisionVoipFlow(subs *Subscriber) error { |
| 383 | var err error |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 384 | var gemPortIDs []uint32 |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 385 | var errUs, errDs, errDhcp error |
| 386 | var flowIDUs, flowIDDs, flowIDDhcp uint64 |
| 387 | pbitToGem := make(map[uint32]uint32) |
| 388 | var pcp uint32 |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 389 | |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 390 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocId |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 391 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 392 | gemPortIDs = append(gemPortIDs, gem.GemportId) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | for idx, gemID := range gemPortIDs { |
| 396 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 397 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 398 | if pbitSet == '1' { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 399 | pcp = uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
| 400 | if flowIDUs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 401 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 402 | } |
| 403 | if errUs = AddTtFlow(subs, VoipFlow, Upstream, flowIDUs, allocID, gemID, pcp, false, |
| 404 | 0, pbitToGem); errUs != nil { |
| 405 | logger.Errorw(nil, "failed to install US VOIP flow", |
| 406 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 407 | } |
| 408 | if flowIDDs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 409 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 410 | } |
| 411 | if errDs = AddTtFlow(subs, VoipFlow, Downstream, flowIDDs, allocID, gemID, pcp, false, |
| 412 | flowIDUs, pbitToGem); errDs != nil { |
| 413 | logger.Errorw(nil, "failed to install DS VOIP flow", |
| 414 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 415 | } |
| 416 | if flowIDDhcp, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 417 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 418 | } |
| 419 | if errDhcp = AddFlow(subs, DhcpFlowIPV4, Upstream, flowIDDhcp, allocID, gemID, pcp, false, |
| 420 | 0, pbitToGem); errDhcp != nil { |
| 421 | logger.Errorw(nil, "failed to install US VOIP-DHCP flow", |
| 422 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 423 | } |
Girish Gowdra | aeceb84 | 2020-08-21 12:10:39 -0700 | [diff] [blame] | 424 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 425 | if errUs != nil || errDs != nil || errDhcp != nil { |
| 426 | if errUs != nil { |
| 427 | return errUs |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 428 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 429 | if errDs != nil { |
| 430 | return errDs |
| 431 | } |
| 432 | return errDhcp |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 433 | } |
| 434 | } |
| 435 | } |
| 436 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 437 | |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 438 | return nil |
| 439 | } |
| 440 | |
| 441 | func (tt TtWorkFlow) ProvisionVodFlow(subs *Subscriber) error { |
| 442 | var err error |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 443 | var gemPortIDs []uint32 |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 444 | var errUs, errDs, errDhcp, errIgmp error |
| 445 | var flowIDUs, flowIDDs, flowIDDhcp, flowIDIgmp uint64 |
| 446 | pbitToGem := make(map[uint32]uint32) |
| 447 | var pcp uint32 |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 448 | |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 449 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocId |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 450 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 451 | gemPortIDs = append(gemPortIDs, gem.GemportId) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | for idx, gemID := range gemPortIDs { |
| 455 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 456 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 457 | if pbitSet == '1' { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 458 | pcp = uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
| 459 | if flowIDUs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 460 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 461 | } |
| 462 | if errUs = AddTtFlow(subs, VodFlow, Upstream, flowIDUs, allocID, gemID, pcp, false, |
| 463 | 0, pbitToGem); errUs != nil { |
| 464 | logger.Errorw(nil, "failed to install US VOIP flow", |
| 465 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 466 | } |
| 467 | if flowIDDs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 468 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 469 | } |
| 470 | if errDs = AddTtFlow(subs, VodFlow, Downstream, flowIDDs, allocID, gemID, pcp, false, |
| 471 | flowIDUs, pbitToGem); errDs != nil { |
| 472 | logger.Errorw(nil, "failed to install DS VOIP flow", |
| 473 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 474 | } |
| 475 | if flowIDDhcp, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 476 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 477 | } |
| 478 | if errDhcp = AddFlow(subs, DhcpFlowIPV4, Upstream, flowIDDhcp, allocID, gemID, pcp, false, |
| 479 | 0, pbitToGem); errDhcp != nil { |
| 480 | logger.Errorw(nil, "failed to install US VOIP-DHCP flow", |
| 481 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 482 | } |
| 483 | if flowIDIgmp, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 484 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 485 | } |
| 486 | if errIgmp = AddTtFlow(subs, IgmpFlow, Upstream, flowIDIgmp, allocID, gemID, pcp, false, |
| 487 | 0, pbitToGem); errIgmp != nil { |
| 488 | logger.Errorw(nil, "failed to install US VOIP-IGMP flow", |
| 489 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 490 | } |
Girish Gowdra | aeceb84 | 2020-08-21 12:10:39 -0700 | [diff] [blame] | 491 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 492 | if errUs != nil || errDs != nil || errDhcp != nil || errIgmp != nil { |
| 493 | if errUs != nil { |
| 494 | return errUs |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 495 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 496 | if errDs != nil { |
| 497 | return errDs |
| 498 | } |
| 499 | if errDhcp != nil { |
| 500 | return errDhcp |
| 501 | } |
| 502 | return errIgmp |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | return nil |
| 508 | } |
| 509 | |
| 510 | func (tt TtWorkFlow) ProvisionMgmtFlow(subs *Subscriber) error { |
| 511 | var err error |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 512 | pbitToGem := make(map[uint32]uint32) |
| 513 | var flowIDUs, flowIDDs, flowIDDhcp uint64 |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 514 | var gemPortIDs []uint32 |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 515 | var pcp uint32 |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 516 | |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 517 | var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocId |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 518 | for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList { |
Girish Gowdra | 390f12f | 2021-07-01 15:53:49 -0700 | [diff] [blame^] | 519 | gemPortIDs = append(gemPortIDs, gem.GemportId) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | for idx, gemID := range gemPortIDs { |
| 523 | pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap |
| 524 | for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") { |
| 525 | if pbitSet == '1' { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 526 | pcp = uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos) |
| 527 | var errUs, errDs, errDhcp error |
| 528 | if flowIDUs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 529 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 530 | } |
| 531 | if errUs = AddTtFlow(subs, MgmtFlow, Upstream, flowIDUs, allocID, gemID, pcp, false, |
| 532 | 0, pbitToGem); errUs != nil { |
| 533 | logger.Errorw(nil, "failed to install US MGMT flow", |
| 534 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 535 | } |
| 536 | if flowIDDs, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 537 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 538 | } |
| 539 | if errDs = AddTtFlow(subs, MgmtFlow, Downstream, flowIDDs, allocID, gemID, pcp, false, |
| 540 | flowIDUs, pbitToGem); errDs != nil { |
| 541 | logger.Errorw(nil, "failed to install DS MGMT flow", |
| 542 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 543 | } |
| 544 | if flowIDDhcp, err = subs.RsrMgr.GetFlowID(context.Background(), subs.PonIntf); err != nil { |
| 545 | return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED)) |
| 546 | } |
| 547 | if errDhcp = AddFlow(subs, DhcpFlowIPV4, Upstream, flowIDDhcp, allocID, gemID, pcp, false, |
| 548 | 0, pbitToGem); errDhcp != nil { |
| 549 | logger.Errorw(nil, "failed to install US MGMT-DHCP flow", |
| 550 | log.Fields{"onuID": subs.OnuID, "uniID": subs.UniID, "intf": subs.PonIntf}) |
| 551 | } |
Girish Gowdra | aeceb84 | 2020-08-21 12:10:39 -0700 | [diff] [blame] | 552 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 553 | if errUs != nil || errDs != nil || errDhcp != nil { |
| 554 | if errUs != nil { |
| 555 | return errUs |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 556 | } |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 557 | if errDs != nil { |
| 558 | return errDs |
| 559 | } |
| 560 | return errDhcp |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 561 | } |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | return nil |
| 566 | } |
| 567 | |
| 568 | func (tt TtWorkFlow) ProvisionMulticastFlow(subs *Subscriber) error { |
| 569 | var grp GroupData |
| 570 | var err error |
| 571 | |
| 572 | numOfONUsPerPon := uint32(subs.TestConfig.NumOfOnu / uint(subs.RsrMgr.deviceInfo.GetPonPorts())) |
| 573 | |
| 574 | grp.Subs = *subs |
| 575 | grp.Weight = 20 |
| 576 | grp.Priority = 0 |
| 577 | grp.OnuID = 6666 |
| 578 | grp.UniID = 6666 |
| 579 | grp.AllocID = 0 |
| 580 | grp.GemPortID = 4069 |
| 581 | grp.SchedPolicy = tp_pb.SchedulingPolicy_WRR |
| 582 | |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 583 | logger.Debugw(nil, "Group data", log.Fields{"OnuID": subs.OnuID, "GroupID": grp.GroupID, "numOfONUsPerPon": numOfONUsPerPon}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 584 | |
| 585 | grp.GroupID = subs.OnuID |
| 586 | |
| 587 | if subs.PonIntf == 0 { |
| 588 | grp.AddGroup = true |
| 589 | grp.AddFlow = true |
| 590 | } else { |
| 591 | grp.AddFlow = false |
| 592 | grp.AddGroup = false |
| 593 | } |
| 594 | |
| 595 | if subs.PonIntf == atomic.LoadUint32(lastPonIntf) { |
| 596 | _ = atomic.AddUint32(lastPonIntf, 1) |
| 597 | grp.AddSched = true |
| 598 | grp.AddQueue = true |
| 599 | } else { |
| 600 | grp.AddSched = false |
| 601 | grp.AddQueue = false |
| 602 | } |
| 603 | |
| 604 | grp.AddMember = true |
| 605 | |
| 606 | err = AddMulticastQueueFlow(&grp) |
| 607 | |
| 608 | if err != nil { |
Girish Gowdra | 5d7d644 | 2020-09-08 17:03:11 -0700 | [diff] [blame] | 609 | logger.Errorw(nil, "Failed to add multicast flow", log.Fields{"error": err}) |
Orhan Kupusoglu | 66b00d8 | 2020-03-13 12:06:33 +0300 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | return err |
| 613 | } |