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