blob: 5c8b345a8bd61ea8ed474292cf9f453fe9319c53 [file] [log] [blame]
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +05301/*
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
17package core
18
19import (
20 "errors"
Girish Gowdrad4bdd372020-03-09 14:56:15 -070021 "strings"
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +053022
Thiyagarajan Subramanic4f8da82020-02-05 16:08:26 +053023 "github.com/opencord/openolt-scale-tester/config"
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030024 "github.com/opencord/voltha-lib-go/v3/pkg/log"
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +030025 oop "github.com/opencord/voltha-protos/v3/go/openolt"
26 tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile"
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +053027 "golang.org/x/net/context"
28)
29
30func init() {
31 _, _ = log.AddPackage(log.JSON, log.DebugLevel, nil)
32}
33
34// A dummy struct to comply with the WorkFlow interface.
35type DtWorkFlow struct {
36}
37
Thiyagarajan Subramanic4f8da82020-02-05 16:08:26 +053038func ProvisionDtNniTrapFlow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error {
39 _ = AddLldpFlow(oo, config, rsrMgr)
40
41 return nil
42}
43
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +053044func (dt DtWorkFlow) ProvisionScheds(subs *Subscriber) error {
45 var trafficSched []*tp_pb.TrafficScheduler
46
47 log.Info("provisioning-scheds")
48
49 if trafficSched = getTrafficSched(subs, tp_pb.Direction_DOWNSTREAM); trafficSched == nil {
50 log.Error("ds-traffic-sched-is-nil")
51 return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED))
52 }
53
54 log.Debugw("Sending Traffic scheduler create to device",
55 log.Fields{"Direction": tp_pb.Direction_DOWNSTREAM, "TrafficScheds": trafficSched})
56 if _, err := subs.OpenOltClient.CreateTrafficSchedulers(context.Background(), &tp_pb.TrafficSchedulers{
57 IntfId: subs.PonIntf, OnuId: subs.OnuID,
58 UniId: subs.UniID, PortNo: subs.UniPortNo,
59 TrafficScheds: trafficSched}); err != nil {
60 log.Errorw("Failed to create traffic schedulers", log.Fields{"error": err})
61 return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED))
62 }
63
64 if trafficSched = getTrafficSched(subs, tp_pb.Direction_UPSTREAM); trafficSched == nil {
65 log.Error("us-traffic-sched-is-nil")
66 return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED))
67 }
68
69 log.Debugw("Sending Traffic scheduler create to device",
70 log.Fields{"Direction": tp_pb.Direction_UPSTREAM, "TrafficScheds": trafficSched})
71 if _, err := subs.OpenOltClient.CreateTrafficSchedulers(context.Background(), &tp_pb.TrafficSchedulers{
72 IntfId: subs.PonIntf, OnuId: subs.OnuID,
73 UniId: subs.UniID, PortNo: subs.UniPortNo,
74 TrafficScheds: trafficSched}); err != nil {
75 log.Errorw("Failed to create traffic schedulers", log.Fields{"error": err})
76 return errors.New(ReasonCodeToReasonString(SCHED_CREATION_FAILED))
77 }
78
79 return nil
80}
81
82func (dt DtWorkFlow) ProvisionQueues(subs *Subscriber) error {
83 log.Info("provisioning-queues")
84
85 var trafficQueues []*tp_pb.TrafficQueue
86 if trafficQueues = getTrafficQueues(subs, tp_pb.Direction_DOWNSTREAM); trafficQueues == nil {
87 log.Error("Failed to create traffic queues")
88 return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED))
89 }
90
91 // On receiving the CreateTrafficQueues request, the driver should create corresponding
92 // downstream queues.
93 log.Debugw("Sending Traffic Queues create to device",
94 log.Fields{"Direction": tp_pb.Direction_DOWNSTREAM, "TrafficQueues": trafficQueues})
95 if _, err := subs.OpenOltClient.CreateTrafficQueues(context.Background(),
96 &tp_pb.TrafficQueues{IntfId: subs.PonIntf, OnuId: subs.OnuID,
97 UniId: subs.UniID, PortNo: subs.UniPortNo,
98 TrafficQueues: trafficQueues}); err != nil {
99 log.Errorw("Failed to create traffic queues in device", log.Fields{"error": err})
100 return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED))
101 }
102
103 if trafficQueues = getTrafficQueues(subs, tp_pb.Direction_UPSTREAM); trafficQueues == nil {
104 log.Error("Failed to create traffic queues")
105 return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED))
106 }
107
108 // On receiving the CreateTrafficQueues request, the driver should create corresponding
109 // upstream queues.
110 log.Debugw("Sending Traffic Queues create to device",
111 log.Fields{"Direction": tp_pb.Direction_UPSTREAM, "TrafficQueues": trafficQueues})
112 if _, err := subs.OpenOltClient.CreateTrafficQueues(context.Background(),
113 &tp_pb.TrafficQueues{IntfId: subs.PonIntf, OnuId: subs.OnuID,
114 UniId: subs.UniID, PortNo: subs.UniPortNo,
115 TrafficQueues: trafficQueues}); err != nil {
116 log.Errorw("Failed to create traffic queues in device", log.Fields{"error": err})
117 return errors.New(ReasonCodeToReasonString(QUEUE_CREATION_FAILED))
118 }
119
120 return nil
121}
122
123func (dt DtWorkFlow) ProvisionEapFlow(subs *Subscriber) error {
124 log.Info("dt-workflow-does-not-require-eap-support--nothing-to-do")
125 return nil
126}
127
Girish Gowdraef1b7c42020-01-23 16:27:48 +0530128func (dt DtWorkFlow) ProvisionDhcpIPV4Flow(subs *Subscriber) error {
129 log.Info("dt-workflow-does-not-require-dhcp-ipv4-support--nothing-to-do")
130 return nil
131}
132
133func (dt DtWorkFlow) ProvisionDhcpIPV6Flow(subs *Subscriber) error {
134 log.Info("dt-workflow-does-not-require-dhcp-ipv6-support--nothing-to-do")
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +0530135 return nil
136}
137
138func (dt DtWorkFlow) ProvisionIgmpFlow(subs *Subscriber) error {
139 log.Info("dt-workflow-does-not-support-igmp-yet--nothing-to-do")
140 return nil
141}
142
143func (dt DtWorkFlow) ProvisionHsiaFlow(subs *Subscriber) error {
144 var err error
Girish Gowdraaeceb842020-08-21 12:10:39 -0700145 var flowID uint32
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +0530146 var gemPortIDs []uint32
147
148 var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID
149 for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList {
150 gemPortIDs = append(gemPortIDs, gem.GemportID)
151 }
152
Girish Gowdrad4bdd372020-03-09 14:56:15 -0700153 for idx, gemID := range gemPortIDs {
154 pBitMap := subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList[idx].PbitMap
155 for pos, pbitSet := range strings.TrimPrefix(pBitMap, "0b") {
156 if pbitSet == '1' {
157 pcp := uint32(len(strings.TrimPrefix(pBitMap, "0b"))) - 1 - uint32(pos)
Girish Gowdraaeceb842020-08-21 12:10:39 -0700158 if flowID, err = subs.RsrMgr.GetFlowID(context.Background(), uint32(subs.PonIntf)); err != nil {
Girish Gowdrad4bdd372020-03-09 14:56:15 -0700159 return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED))
160 } else {
Girish Gowdraaeceb842020-08-21 12:10:39 -0700161 if err := AddFlow(subs, HsiaFlow, Upstream, flowID, allocID, gemID, pcp); err != nil {
Girish Gowdrad4bdd372020-03-09 14:56:15 -0700162 return err
163 }
Girish Gowdraaeceb842020-08-21 12:10:39 -0700164 if err := AddFlow(subs, HsiaFlow, Downstream, flowID, allocID, gemID, pcp); err != nil {
Girish Gowdrad4bdd372020-03-09 14:56:15 -0700165 return err
166 }
167 }
Thiyagarajan Subramanib83b0432020-01-08 13:43:28 +0530168 }
169 }
170 }
171 return nil
172}
Orhan Kupusoglu66b00d82020-03-13 12:06:33 +0300173
174func (dt DtWorkFlow) ProvisionVoipFlow(subs *Subscriber) error {
175 log.Info("dt-workflow-does-not-support-voip-yet--nothing-to-do")
176 return nil
177}
178
179func (dt DtWorkFlow) ProvisionVodFlow(subs *Subscriber) error {
180 log.Info("dt-workflow-does-not-support-vod-yet--nothing-to-do")
181 return nil
182}
183
184func (dt DtWorkFlow) ProvisionMgmtFlow(subs *Subscriber) error {
185 log.Info("dt-workflow-does-not-support-mgmt-yet--nothing-to-do")
186 return nil
187}
188
189func (dt DtWorkFlow) ProvisionMulticastFlow(subs *Subscriber) error {
190 log.Info("dt-workflow-does-not-support-multicast-yet--nothing-to-do")
191 return nil
192}