Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate more default values for switch and port #280

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ http_archive(

http_archive(
name = "com_github_opencomputeproject_sai",
patch_args = ["-p1"],
patches = ["//patches:sai.patch"],
build_file_content = """
cc_library(
name = "sai",
Expand Down
66 changes: 63 additions & 3 deletions dataplane/standalone/entrypoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ std::unique_ptr<lemming::dataplane::sai::Entrypoint::Stub> entry;
// TODO(dgrau): implement this without using gRPC.
sai_status_t sai_api_initialize(
_In_ uint64_t flags, _In_ const sai_service_method_table_t *services) {
FLAGS_log_dir = "/var/log";
FLAGS_log_dir = "/var/log/syncd";
google::InitGoogleLogging("lucius");
google::InstallFailureSignalHandler();

Expand Down Expand Up @@ -492,15 +492,75 @@ sai_status_t sai_query_attribute_enum_values_capability(
_In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type,
_In_ sai_attr_id_t attr_id,
_Inout_ sai_s32_list_t *enum_values_capability) {
return SAI_STATUS_SUCCESS;

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_object_type_get_availability(
_In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type,
_In_ uint32_t attr_count, _In_ const sai_attribute_t *attr_list,
_Out_ uint64_t *count) {
*count = 1024;
return SAI_STATUS_SUCCESS;
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_query_stats_capability(
_In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type,
_Inout_ sai_stat_capability_list_t *stats_capability) {
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_get_maximum_attribute_count(_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Out_ uint32_t *count) {
return SAI_STATUS_NOT_IMPLEMENTED;
}
sai_status_t sai_get_object_count(_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Out_ uint32_t *count) {
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_get_object_key(_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_Inout_ uint32_t *object_count,
_Inout_ sai_object_key_t *object_list) {
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_bulk_get_attribute(_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_In_ uint32_t object_count,
_In_ const sai_object_key_t *object_key,
_Inout_ uint32_t *attr_count,
_Inout_ sai_attribute_t **attr_list,
_Inout_ sai_status_t *object_statuses) {
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_bulk_object_get_stats(
_In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type,
_In_ uint32_t object_count, _In_ const sai_object_key_t *object_key,
_In_ uint32_t number_of_counters, _In_ const sai_stat_id_t *counter_ids,
_In_ sai_stats_mode_t mode, _Inout_ sai_status_t *object_statuses,
_Out_ uint64_t *counters) {
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_bulk_object_clear_stats(
_In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type,
_In_ uint32_t object_count, _In_ const sai_object_key_t *object_key,
_In_ uint32_t number_of_counters, _In_ const sai_stat_id_t *counter_ids,
_In_ sai_stats_mode_t mode, _Inout_ sai_status_t *object_statuses) {
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t sai_query_object_stage(_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list,
_Out_ sai_object_stage_t *stage) {
return SAI_STATUS_NOT_IMPLEMENTED;
}

int main() {}
376 changes: 277 additions & 99 deletions dataplane/standalone/proto/next_hop.pb.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dataplane/standalone/proto/next_hop.proto
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,20 @@ message GetNextHopAttributeResponse {
NextHopAttribute attr = 1;
}

message CreateNextHopsRequest {
repeated CreateNextHopRequest reqs = 1;
}

message CreateNextHopsResponse {
repeated CreateNextHopResponse resps = 1;
}

service NextHop {
rpc CreateNextHop(CreateNextHopRequest) returns (CreateNextHopResponse) {}
rpc RemoveNextHop(RemoveNextHopRequest) returns (RemoveNextHopResponse) {}
rpc SetNextHopAttribute(SetNextHopAttributeRequest)
returns (SetNextHopAttributeResponse) {}
rpc GetNextHopAttribute(GetNextHopAttributeRequest)
returns (GetNextHopAttributeResponse) {}
rpc CreateNextHops(CreateNextHopsRequest) returns (CreateNextHopsResponse) {}
}
3 changes: 2 additions & 1 deletion dataplane/standalone/sai/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ lemming::dataplane::sai::NeighborEntry convert_from_neighbor_entry(
sai_neighbor_entry_t convert_to_neighbor_entry(
const lemming::dataplane::sai::NeighborEntry &entry);

void convert_to_acl_capability(sai_acl_capability_t &out,
void convert_to_acl_capability(
sai_acl_capability_t &out,
const lemming::dataplane::sai::ACLCapability &in);

// copy_list copies a scalar proto list to an attribute.
Expand Down
62 changes: 62 additions & 0 deletions dataplane/standalone/sai/next_hop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const sai_next_hop_api_t l_next_hop = {
.remove_next_hop = l_remove_next_hop,
.set_next_hop_attribute = l_set_next_hop_attribute,
.get_next_hop_attribute = l_get_next_hop_attribute,
.create_next_hops = l_create_next_hops,
.remove_next_hops = l_remove_next_hops,
.set_next_hops_attribute = l_set_next_hops_attribute,
.get_next_hops_attribute = l_get_next_hops_attribute,
};

lemming::dataplane::sai::CreateNextHopRequest convert_create_next_hop(
Expand Down Expand Up @@ -272,3 +276,61 @@ sai_status_t l_get_next_hop_attribute(sai_object_id_t next_hop_id,

return SAI_STATUS_SUCCESS;
}

sai_status_t l_create_next_hops(sai_object_id_t switch_id,
uint32_t object_count,
const uint32_t *attr_count,
const sai_attribute_t **attr_list,
sai_bulk_op_error_mode_t mode,
sai_object_id_t *object_id,
sai_status_t *object_statuses) {
LOG(INFO) << "Func: " << __PRETTY_FUNCTION__;

lemming::dataplane::sai::CreateNextHopsRequest req;
lemming::dataplane::sai::CreateNextHopsResponse resp;
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
auto r = convert_create_next_hop(switch_id, attr_count[i], attr_list[i]);
*req.add_reqs() = r;
}

grpc::Status status = next_hop->CreateNextHops(&context, req, &resp);
if (!status.ok()) {
LOG(ERROR) << status.error_message();
return SAI_STATUS_FAILURE;
}
for (uint32_t i = 0; i < object_count; i++) {
switch_id = object_id[i] = resp.resps(i).oid();
object_statuses[i] = SAI_STATUS_SUCCESS;
}

return SAI_STATUS_SUCCESS;
}

sai_status_t l_remove_next_hops(uint32_t object_count,
const sai_object_id_t *object_id,
sai_bulk_op_error_mode_t mode,
sai_status_t *object_statuses) {
LOG(INFO) << "Func: " << __PRETTY_FUNCTION__;
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t l_set_next_hops_attribute(uint32_t object_count,
const sai_object_id_t *object_id,
const sai_attribute_t *attr_list,
sai_bulk_op_error_mode_t mode,
sai_status_t *object_statuses) {
LOG(INFO) << "Func: " << __PRETTY_FUNCTION__;
return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t l_get_next_hops_attribute(uint32_t object_count,
const sai_object_id_t *object_id,
const uint32_t *attr_count,
sai_attribute_t **attr_list,
sai_bulk_op_error_mode_t mode,
sai_status_t *object_statuses) {
LOG(INFO) << "Func: " << __PRETTY_FUNCTION__;
return SAI_STATUS_NOT_IMPLEMENTED;
}
26 changes: 26 additions & 0 deletions dataplane/standalone/sai/next_hop.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,30 @@ sai_status_t l_get_next_hop_attribute(sai_object_id_t next_hop_id,
uint32_t attr_count,
sai_attribute_t *attr_list);

sai_status_t l_create_next_hops(sai_object_id_t switch_id,
uint32_t object_count,
const uint32_t *attr_count,
const sai_attribute_t **attr_list,
sai_bulk_op_error_mode_t mode,
sai_object_id_t *object_id,
sai_status_t *object_statuses);

sai_status_t l_remove_next_hops(uint32_t object_count,
const sai_object_id_t *object_id,
sai_bulk_op_error_mode_t mode,
sai_status_t *object_statuses);

sai_status_t l_set_next_hops_attribute(uint32_t object_count,
const sai_object_id_t *object_id,
const sai_attribute_t *attr_list,
sai_bulk_op_error_mode_t mode,
sai_status_t *object_statuses);

sai_status_t l_get_next_hops_attribute(uint32_t object_count,
const sai_object_id_t *object_id,
const uint32_t *attr_count,
sai_attribute_t **attr_list,
sai_bulk_op_error_mode_t mode,
sai_status_t *object_statuses);

#endif // DATAPLANE_STANDALONE_SAI_NEXT_HOP_H_
117 changes: 108 additions & 9 deletions dataplane/standalone/saiserver/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newPort(mgr *attrmgr.AttrMgr, dataplane portDataplaneAPI, s *grpc.Server) *
mgr: mgr,
dataplane: dataplane,
portToEth: make(map[uint64]string),
nextEth: 2, // Start at eth2
nextEth: 1, // Start at eth1
}
saipb.RegisterPortServer(s, p)
return p
Expand All @@ -68,13 +68,59 @@ func (port *port) CreatePort(ctx context.Context, _ *saipb.CreatePortRequest) (*
port.nextEth++

attrs := &saipb.PortAttribute{
OperSpeed: proto.Uint32(1024),
NumberOfIngressPriorityGroups: proto.Uint32(0),
QosNumberOfQueues: proto.Uint32(0),
QosMaximumHeadroomSize: proto.Uint32(0),
AdminState: proto.Bool(true),
AutoNegMode: proto.Bool(false),
Mtu: proto.Uint32(1514),
QosNumberOfQueues: proto.Uint32(0),
QosQueueList: []uint64{},
QosNumberOfSchedulerGroups: proto.Uint32(0),
QosSchedulerGroupList: []uint64{},
IngressPriorityGroupList: []uint64{},
FloodStormControlPolicerId: proto.Uint64(0),
BroadcastStormControlPolicerId: proto.Uint64(0),
MulticastStormControlPolicerId: proto.Uint64(0),
IngressAcl: proto.Uint64(0),
EgressAcl: proto.Uint64(0),
IngressMacsecAcl: proto.Uint64(0),
EgressMacsecAcl: proto.Uint64(0),
MacsecPortList: []uint64{},
IngressMirrorSession: []uint64{},
EgressMirrorSession: []uint64{},
IngressSamplepacketEnable: proto.Uint64(0),
EgressSamplepacketEnable: proto.Uint64(0),
IngressSampleMirrorSession: []uint64{},
EgressSampleMirrorSession: []uint64{},
PolicerId: proto.Uint64(0),
QosDot1PToTcMap: proto.Uint64(0),
QosDot1PToColorMap: proto.Uint64(0),
QosDscpToTcMap: proto.Uint64(0),
QosDscpToColorMap: proto.Uint64(0),
QosTcToQueueMap: proto.Uint64(0),
QosTcAndColorToDot1PMap: proto.Uint64(0),
QosTcAndColorToDscpMap: proto.Uint64(0),
QosTcToPriorityGroupMap: proto.Uint64(0),
QosPfcPriorityToPriorityGroupMap: proto.Uint64(0),
QosPfcPriorityToQueueMap: proto.Uint64(0),
QosSchedulerProfileId: proto.Uint64(0),
QosIngressBufferProfileList: []uint64{},
QosEgressBufferProfileList: []uint64{},
EgressBlockPortList: []uint64{},
PortPoolList: []uint64{},
IsolationGroup: proto.Uint64(0),
TamObject: []uint64{},
PortSerdesId: proto.Uint64(0),
QosMplsExpToTcMap: proto.Uint64(0),
QosMplsExpToColorMap: proto.Uint64(0),
QosTcAndColorToMplsExpMap: proto.Uint64(0),
SystemPort: proto.Uint64(0),
QosDscpToForwardingClassMap: proto.Uint64(0),
QosMplsExpToForwardingClassMap: proto.Uint64(0),
IpsecPort: proto.Uint64(0),
SupportedSpeed: []uint32{1024},
OperSpeed: proto.Uint32(1024),
SupportedFecMode: []saipb.PortFecMode{saipb.PortFecMode_PORT_FEC_MODE_NONE},
NumberOfIngressPriorityGroups: proto.Uint32(0),
QosMaximumHeadroomSize: proto.Uint32(0),
AdminState: proto.Bool(true),
AutoNegMode: proto.Bool(false),
Mtu: proto.Uint32(1514),
}

// For ports that don't exist, do not create dataplane ports.
Expand Down Expand Up @@ -117,7 +163,60 @@ func (port *port) createCPUPort(ctx context.Context) (uint64, error) {
}

cpuPort := &saipb.PortAttribute{
Type: saipb.PortType_PORT_TYPE_CPU.Enum(),
Type: saipb.PortType_PORT_TYPE_CPU.Enum(),
QosNumberOfQueues: proto.Uint32(0),
QosQueueList: []uint64{},
QosNumberOfSchedulerGroups: proto.Uint32(0),
QosSchedulerGroupList: []uint64{},
IngressPriorityGroupList: []uint64{},
FloodStormControlPolicerId: proto.Uint64(0),
BroadcastStormControlPolicerId: proto.Uint64(0),
MulticastStormControlPolicerId: proto.Uint64(0),
IngressAcl: proto.Uint64(0),
EgressAcl: proto.Uint64(0),
IngressMacsecAcl: proto.Uint64(0),
EgressMacsecAcl: proto.Uint64(0),
MacsecPortList: []uint64{},
IngressMirrorSession: []uint64{},
EgressMirrorSession: []uint64{},
IngressSamplepacketEnable: proto.Uint64(0),
EgressSamplepacketEnable: proto.Uint64(0),
IngressSampleMirrorSession: []uint64{},
EgressSampleMirrorSession: []uint64{},
PolicerId: proto.Uint64(0),
QosDot1PToTcMap: proto.Uint64(0),
QosDot1PToColorMap: proto.Uint64(0),
QosDscpToTcMap: proto.Uint64(0),
QosDscpToColorMap: proto.Uint64(0),
QosTcToQueueMap: proto.Uint64(0),
QosTcAndColorToDot1PMap: proto.Uint64(0),
QosTcAndColorToDscpMap: proto.Uint64(0),
QosTcToPriorityGroupMap: proto.Uint64(0),
QosPfcPriorityToPriorityGroupMap: proto.Uint64(0),
QosPfcPriorityToQueueMap: proto.Uint64(0),
QosSchedulerProfileId: proto.Uint64(0),
QosIngressBufferProfileList: []uint64{},
QosEgressBufferProfileList: []uint64{},
EgressBlockPortList: []uint64{},
PortPoolList: []uint64{},
IsolationGroup: proto.Uint64(0),
TamObject: []uint64{},
PortSerdesId: proto.Uint64(0),
QosMplsExpToTcMap: proto.Uint64(0),
QosMplsExpToColorMap: proto.Uint64(0),
QosTcAndColorToMplsExpMap: proto.Uint64(0),
SystemPort: proto.Uint64(0),
QosDscpToForwardingClassMap: proto.Uint64(0),
QosMplsExpToForwardingClassMap: proto.Uint64(0),
IpsecPort: proto.Uint64(0),
SupportedSpeed: []uint32{1024},
OperSpeed: proto.Uint32(1024),
SupportedFecMode: []saipb.PortFecMode{saipb.PortFecMode_PORT_FEC_MODE_NONE},
NumberOfIngressPriorityGroups: proto.Uint32(0),
QosMaximumHeadroomSize: proto.Uint32(0),
AdminState: proto.Bool(true),
AutoNegMode: proto.Bool(false),
Mtu: proto.Uint32(1514),
}
port.mgr.SetType(fmt.Sprint(id), saipb.ObjectType_OBJECT_TYPE_PORT)
port.mgr.StoreAttributes(id, cpuPort)
Expand Down
Loading