VOL-2419: Add DHCP and HSIA flow add support for ATT worflow
VOL-2422: Integrate DT workflow with HSIA flow add support
Change-Id: Id77fbf6adecea759a0ef982399c30b4a4b88593b
diff --git a/core/att_workflow.go b/core/att_workflow.go
index f20d866..0bc0f69 100644
--- a/core/att_workflow.go
+++ b/core/att_workflow.go
@@ -18,6 +18,7 @@
import (
"errors"
+
"github.com/opencord/openolt-scale-tester/config"
"github.com/opencord/voltha-lib-go/v2/pkg/log"
"github.com/opencord/voltha-lib-go/v2/pkg/ponresourcemanager"
@@ -36,7 +37,8 @@
type AttWorkFlow struct {
}
-func ProvisionAttNniTrapFlow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig, rsrMgr *OpenOltResourceMgr) error {
+func ProvisionAttNniTrapFlow(oo oop.OpenoltClient, config *config.OpenOltScaleTesterConfig,
+ rsrMgr *OpenOltResourceMgr) error {
var flowID []uint32
var err error
@@ -64,7 +66,8 @@
if err != nil {
log.Errorw("Failed to Add flow to device", log.Fields{"err": err, "deviceFlow": flow})
- rsrMgr.ResourceMgrs[uint32(config.NniIntfID)].FreeResourceID(uint32(config.NniIntfID), ponresourcemanager.FLOW_ID, flowID)
+ rsrMgr.ResourceMgrs[uint32(config.NniIntfID)].FreeResourceID(uint32(config.NniIntfID),
+ ponresourcemanager.FLOW_ID, flowID)
return err
}
log.Debugw("Flow added to device successfully ", log.Fields{"flow": flow})
@@ -72,34 +75,6 @@
return nil
}
-func getTrafficSched(subs *Subscriber, direction tp_pb.Direction) []*tp_pb.TrafficScheduler {
- var SchedCfg *tp_pb.SchedulerConfig
-
- if direction == tp_pb.Direction_DOWNSTREAM {
- SchedCfg = subs.RsrMgr.ResourceMgrs[subs.PonIntf].TechProfileMgr.
- GetDsScheduler(subs.TpInstance[subs.TestConfig.TpIDList[0]])
-
- } else {
- SchedCfg = subs.RsrMgr.ResourceMgrs[subs.PonIntf].TechProfileMgr.
- GetUsScheduler(subs.TpInstance[subs.TestConfig.TpIDList[0]])
- }
-
- // hard-code for now
- cir := 16000
- cbs := 5000
- eir := 16000
- ebs := 5000
- pir := cir + eir
- pbs := cbs + ebs
-
- TrafficShaping := &tp_pb.TrafficShapingInfo{Cir: uint32(cir), Cbs: uint32(cbs), Pir: uint32(pir), Pbs: uint32(pbs)}
-
- TrafficSched := []*tp_pb.TrafficScheduler{subs.RsrMgr.ResourceMgrs[subs.PonIntf].TechProfileMgr.
- GetTrafficScheduler(subs.TpInstance[subs.TestConfig.TpIDList[0]], SchedCfg, TrafficShaping)}
-
- return TrafficSched
-}
-
func (att AttWorkFlow) ProvisionScheds(subs *Subscriber) error {
var trafficSched []*tp_pb.TrafficScheduler
@@ -138,14 +113,6 @@
return nil
}
-func getTrafficQueues(subs *Subscriber, direction tp_pb.Direction) []*tp_pb.TrafficQueue {
-
- trafficQueues := subs.RsrMgr.ResourceMgrs[subs.PonIntf].TechProfileMgr.
- GetTrafficQueues(subs.TpInstance[subs.TestConfig.TpIDList[0]], direction)
-
- return trafficQueues
-}
-
func (att AttWorkFlow) ProvisionQueues(subs *Subscriber) error {
log.Info("provisioning-queues")
@@ -188,14 +155,11 @@
}
func (att AttWorkFlow) ProvisionEapFlow(subs *Subscriber) error {
- log.Info("provisioning-eap--att")
-
var err error
var flowID []uint32
var gemPortIDs []uint32
var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID
-
for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList {
gemPortIDs = append(gemPortIDs, gem.GemportID)
}
@@ -203,40 +167,40 @@
for _, gemID := range gemPortIDs {
if flowID, err = subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].GetResourceID(uint32(subs.PonIntf),
ponresourcemanager.FLOW_ID, 1); err != nil {
- return errors.New(ReasonCodeToReasonString(FLOW_ADD_FAILED))
+ return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED))
+ } else {
+ if err := AddFlow(subs, EapolFlow, Upstream, flowID[0], allocID, gemID); err != nil {
+ subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(uint32(subs.PonIntf),
+ ponresourcemanager.FLOW_ID, flowID)
+ return err
+ }
}
- flowClassifier := &oop.Classifier{EthType: 34958, OVid: subs.Ctag, PktTagType: "single_tag"}
- actionCmd := &oop.ActionCmd{TrapToHost: true}
- actionInfo := &oop.Action{Cmd: actionCmd}
-
- flow := oop.Flow{AccessIntfId: int32(subs.PonIntf), OnuId: int32(subs.OnuID),
- UniId: int32(subs.UniID), FlowId: flowID[0],
- FlowType: "upstream", AllocId: int32(allocID), GemportId: int32(gemID),
- Classifier: flowClassifier, Action: actionInfo,
- Priority: 1000, PortNo: subs.UniPortNo}
-
- _, err = subs.OpenOltClient.FlowAdd(context.Background(), &flow)
-
- st, _ := status.FromError(err)
- if st.Code() == codes.AlreadyExists {
- log.Debugw("Flow already exists", log.Fields{"err": err, "deviceFlow": flow})
- continue
- }
-
- if err != nil {
- log.Errorw("Failed to Add flow to device", log.Fields{"err": err, "deviceFlow": flow})
- subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(uint32(subs.PonIntf),
- ponresourcemanager.FLOW_ID, flowID)
- return errors.New(ReasonCodeToReasonString(FLOW_ADD_FAILED))
- }
- log.Debugw("Flow added to device successfully ", log.Fields{"flow": flow})
}
return nil
}
func (att AttWorkFlow) ProvisionDhcpFlow(subs *Subscriber) error {
- // TODO
- log.Info("provisioning-dhcp")
+ var err error
+ var flowID []uint32
+ var gemPortIDs []uint32
+
+ var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID
+ for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList {
+ gemPortIDs = append(gemPortIDs, gem.GemportID)
+ }
+
+ for _, gemID := range gemPortIDs {
+ if flowID, err = subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].GetResourceID(uint32(subs.PonIntf),
+ ponresourcemanager.FLOW_ID, 1); err != nil {
+ return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED))
+ } else {
+ if err := AddFlow(subs, DhcpFlow, Upstream, flowID[0], allocID, gemID); err != nil {
+ subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(uint32(subs.PonIntf),
+ ponresourcemanager.FLOW_ID, flowID)
+ return err
+ }
+ }
+ }
return nil
}
@@ -246,7 +210,29 @@
}
func (att AttWorkFlow) ProvisionHsiaFlow(subs *Subscriber) error {
- // TODO
- log.Info("provisioning-hsia")
+ var err error
+ var flowID []uint32
+ var gemPortIDs []uint32
+
+ var allocID = subs.TpInstance[subs.TestConfig.TpIDList[0]].UsScheduler.AllocID
+ for _, gem := range subs.TpInstance[subs.TestConfig.TpIDList[0]].UpstreamGemPortAttributeList {
+ gemPortIDs = append(gemPortIDs, gem.GemportID)
+ }
+
+ for _, gemID := range gemPortIDs {
+ if flowID, err = subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].GetResourceID(uint32(subs.PonIntf),
+ ponresourcemanager.FLOW_ID, 1); err != nil {
+ return errors.New(ReasonCodeToReasonString(FLOW_ID_GENERATION_FAILED))
+ } else {
+ if err := AddFlow(subs, HsiaFlow, Upstream, flowID[0], allocID, gemID); err != nil {
+ subs.RsrMgr.ResourceMgrs[uint32(subs.PonIntf)].FreeResourceID(uint32(subs.PonIntf),
+ ponresourcemanager.FLOW_ID, flowID)
+ return err
+ }
+ if err := AddFlow(subs, HsiaFlow, Downstream, flowID[0], allocID, gemID); err != nil {
+ return err
+ }
+ }
+ }
return nil
}