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