From b0cfab58252e8720a0c96d51c809719f015c9fa6 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 14 Nov 2025 00:49:28 +0000 Subject: [PATCH] Add queues to Lucius CPU port. --- dataplane/saiserver/ports.go | 44 +++++++++++++++++++++++++++--- dataplane/saiserver/switch_test.go | 28 +++++++++---------- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 8d23c8dfc..9ca4ef5d9 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -109,6 +109,7 @@ func getL2Pipeline() []*fwdpb.ActionDesc { const ( numQueues = 12 + numCpuQueues = 48 numSchedulerGroups = 12 ) @@ -422,12 +423,47 @@ func (port *port) createCPUPort(ctx context.Context) (uint64, error) { return 0, err } + queues := []uint64{} + for i := 0; i < numCpuQueues; i++ { + qResp, err := attrmgr.InvokeAndSave(ctx, port.mgr, port.queue.CreateQueue, &saipb.CreateQueueRequest{ + Type: saipb.QueueType_QUEUE_TYPE_ALL.Enum(), + Port: proto.Uint64(id), + Index: proto.Uint32(uint32(i)), + ParentSchedulerNode: proto.Uint64(id), + WredProfileId: proto.Uint64(0), + BufferProfileId: proto.Uint64(0), + SchedulerProfileId: proto.Uint64(0), + TamObject: []uint64{}, + }) + if err != nil { + return 0, err + } + + queues = append(queues, qResp.GetOid()) + } + + sgs := []uint64{} + for i := 0; i < numCpuQueues; i++ { + sgResp, err := attrmgr.InvokeAndSave(ctx, port.mgr, port.sg.CreateSchedulerGroup, &saipb.CreateSchedulerGroupRequest{ + PortId: proto.Uint64(id), + SchedulerProfileId: proto.Uint64(0), + ParentNode: proto.Uint64(id), + }) + if err != nil { + return 0, err + } + port.mgr.StoreAttributes(sgResp.GetOid(), &saipb.SchedulerGroupAttribute{ + ChildCount: proto.Uint32(1), + ChildList: []uint64{queues[i]}, + }) + sgs = append(sgs, sgResp.GetOid()) + } cpuPort := &saipb.PortAttribute{ Type: saipb.PortType_PORT_TYPE_CPU.Enum(), - QosNumberOfQueues: proto.Uint32(0), - QosQueueList: []uint64{}, - QosNumberOfSchedulerGroups: proto.Uint32(0), - QosSchedulerGroupList: []uint64{}, + QosNumberOfQueues: proto.Uint32(uint32(len(queues))), + QosQueueList: queues, + QosNumberOfSchedulerGroups: proto.Uint32(uint32(len(sgs))), + QosSchedulerGroupList: sgs, IngressPriorityGroupList: []uint64{}, FloodStormControlPolicerId: proto.Uint64(0), BroadcastStormControlPolicerId: proto.Uint64(0), diff --git a/dataplane/saiserver/switch_test.go b/dataplane/saiserver/switch_test.go index 75b504618..5f9483b8a 100644 --- a/dataplane/saiserver/switch_test.go +++ b/dataplane/saiserver/switch_test.go @@ -60,12 +60,12 @@ func TestCreateSwitch(t *testing.T) { NumberOfEcmpGroups: proto.Uint32(1024), PortList: []uint64{}, SwitchHardwareInfo: []int32{}, - DefaultStpInstId: proto.Uint64(3), - DefaultVlanId: proto.Uint64(4), - DefaultVirtualRouterId: proto.Uint64(5), - DefaultOverrideVirtualRouterId: proto.Uint64(5), - Default_1QBridgeId: proto.Uint64(6), - DefaultTrapGroup: proto.Uint64(7), + DefaultStpInstId: proto.Uint64(99), + DefaultVlanId: proto.Uint64(100), + DefaultVirtualRouterId: proto.Uint64(101), + DefaultOverrideVirtualRouterId: proto.Uint64(101), + Default_1QBridgeId: proto.Uint64(102), + DefaultTrapGroup: proto.Uint64(103), IngressAcl: proto.Uint64(0), EgressAcl: proto.Uint64(0), PreIngressAcl: proto.Uint64(0), @@ -91,14 +91,14 @@ func TestCreateSwitch(t *testing.T) { IsActionListMandatory: false, ActionList: []saipb.AclActionType{saipb.AclActionType_ACL_ACTION_TYPE_PACKET_ACTION}, }, - EcmpHash: proto.Uint64(8), - LagHash: proto.Uint64(8), - EcmpHashIpv4: proto.Uint64(8), - EcmpHashIpv4InIpv4: proto.Uint64(8), - EcmpHashIpv6: proto.Uint64(8), - LagHashIpv4: proto.Uint64(8), - LagHashIpv4InIpv4: proto.Uint64(8), - LagHashIpv6: proto.Uint64(8), + EcmpHash: proto.Uint64(104), + LagHash: proto.Uint64(104), + EcmpHashIpv4: proto.Uint64(104), + EcmpHashIpv4InIpv4: proto.Uint64(104), + EcmpHashIpv6: proto.Uint64(104), + LagHashIpv4: proto.Uint64(104), + LagHashIpv4InIpv4: proto.Uint64(104), + LagHashIpv6: proto.Uint64(104), RestartWarm: proto.Bool(false), WarmRecover: proto.Bool(false), LagDefaultHashAlgorithm: saipb.HashAlgorithm_HASH_ALGORITHM_CRC.Enum(),