Skip to content

Commit

Permalink
Update SAI, regen code, delete legacy C++ code
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Sep 20, 2023
1 parent 1a5b211 commit 2e703a7
Show file tree
Hide file tree
Showing 129 changed files with 22,912 additions and 21,025 deletions.
19 changes: 4 additions & 15 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,16 @@ http_archive(
http_archive(
name = "com_github_opencomputeproject_sai",
build_file_content = """
cc_library(
name = "meta",
hdrs = ["meta/saimetadata.h", "meta/saimetadatautils.h", "meta/saiserialize.h", "meta/saimetadatalogger.h"],
srcs = ["meta/saimetadata.c", "meta/saimetadatautils.c", "meta/saiserialize.c"],
deps = ["//:sai"],
includes = ["inc", "experimental"],
visibility = ["//visibility:public"],
)
cc_library(
name = "sai",
hdrs = glob(["meta/saimetadatatypes.h", "inc/*.h","experimental/*.h"]),
hdrs = glob(["inc/*.h","experimental/*.h"]),
includes = ["inc", "experimental"],
visibility = ["//visibility:public"],
)
""",
patch_args = ["-p1"],
patches = ["//patches:sai.patch"],
sha256 = "2eb547dbde2bc8d3ffd2edb1ef6fb282be4994a43cd4886a67dd8ecef002ffa7",
strip_prefix = "SAI-1.9.1",
urls = ["https://github.com/opencomputeproject/SAI/archive/refs/tags/v1.9.1.tar.gz"],
sha256 = "240d0211bbea2758faabfdbfa5e5488d837a47d42839bfe99b4bfbff52ab6c11",
strip_prefix = "SAI-1.11.0",
urls = ["https://github.com/opencomputeproject/SAI/archive/refs/tags/v1.11.0.tar.gz"],
)

http_archive(
Expand Down
56 changes: 0 additions & 56 deletions dataplane/standalone/BUILD
Original file line number Diff line number Diff line change
@@ -1,66 +1,10 @@
cc_library(
name = "translator",
srcs = [
"acl.cc",
"bridge.cc",
"buffer.cc",
"common.cc",
"dtel.cc",
"hostif.cc",
"neighbor.cc",
"next_hop.cc",
"next_hop_group.cc",
"policer.cc",
"port.cc",
"route.cc",
"router_interface.cc",
"switch.cc",
"translator.cc",
"tunnel.cc",
"vlan.cc",
],
hdrs = [
"acl.h",
"bridge.h",
"buffer.h",
"common.h",
"dtel.h",
"hostif.h",
"neighbor.h",
"next_hop.h",
"next_hop_group.h",
"policer.h",
"port.h",
"route.h",
"router_interface.h",
"switch.h",
"translator.h",
"tunnel.h",
"vlan.h",
],
visibility = ["//visibility:public"],
deps = [
"//dataplane/standalone/lucius:lucius_clib",
"//dataplane/standalone/sai:entry",
"//proto/dataplane:dataplane_cc_grpc",
"//proto/dataplane:dataplane_cc_proto",
"//proto/forwarding:forwarding_cc_grpc",
"//proto/forwarding:forwarding_cc_proto",
"@com_github_google_glog//:glog",
"@com_github_grpc_grpc//:grpc++",
"@com_github_opencomputeproject_sai//:meta",
"@com_github_opencomputeproject_sai//:sai",
],
)

cc_library(
name = "entrypoint",
srcs = [
"entrypoint.cc",
],
visibility = ["//visibility:public"],
deps = [
":translator",
"//dataplane/standalone/proto:sai_cc_grpc",
"//dataplane/standalone/sai",
"@com_github_google_glog//:glog",
Expand Down
30 changes: 0 additions & 30 deletions dataplane/standalone/acl.cc

This file was deleted.

44 changes: 0 additions & 44 deletions dataplane/standalone/acl.h

This file was deleted.

9 changes: 7 additions & 2 deletions dataplane/standalone/apigen/ccgen/ccgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func Generate(doc *docparser.SAIInfo, sai *saiast.SAIAPI) (map[string]string, er
for _, fn := range iface.Funcs {
meta := sai.GetFuncMeta(fn)
tf := createCCData(meta, apiName, sai, doc, fn)
ccData.Funcs = append(ccData.Funcs, *tf)
if tf != nil {
ccData.Funcs = append(ccData.Funcs, *tf)
}
}
var headerBuilder, implBuilder strings.Builder
if err := headerTmpl.Execute(&headerBuilder, ccData); err != nil {
Expand All @@ -70,6 +72,10 @@ func sanitizeProtoName(inName string) string {

// createCCData returns a struct with the template data for the given function.
func createCCData(meta *saiast.FuncMetadata, apiName string, sai *saiast.SAIAPI, info *docparser.SAIInfo, fn *saiast.TypeDecl) *templateFunc {
if info.Attrs[meta.TypeName] == nil {
fmt.Printf("no doc info for type: %v\n", meta.TypeName)
return nil
}
tf := &templateFunc{
ReturnType: sai.Funcs[fn.Typ].ReturnType,
Name: meta.Name,
Expand Down Expand Up @@ -463,7 +469,6 @@ switch ({{ .Var }}) {
#include "dataplane/standalone/sai/{{ .Header }}"
#include <glog/logging.h>
#include "dataplane/standalone/sai/common.h"
#include "dataplane/standalone/sai/entry.h"
#include "dataplane/standalone/proto/common.pb.h"
#include "dataplane/standalone/proto/{{ .ProtoInclude }}.h"
Expand Down
23 changes: 23 additions & 0 deletions dataplane/standalone/apigen/protogen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ func generateCommonTypes(docInfo *docparser.SAIInfo) (string, error) {

// populateTmplDataFromFunc populatsd the protobuf template struct from a SAI function call.
func populateTmplDataFromFunc(apis map[string]*protoAPITmplData, docInfo *docparser.SAIInfo, apiName string, meta *saiast.FuncMetadata) error {
if docInfo.Attrs[meta.TypeName] == nil {
fmt.Printf("no doc info for type: %v\n", meta.TypeName)
return nil
}

if _, ok := apis[apiName]; !ok {
apis[apiName] = &protoAPITmplData{
ServiceName: saiast.TrimSAIName(apiName, true, false),
Expand Down Expand Up @@ -467,6 +472,9 @@ var (
"sai_mac_t": {
ProtoType: "bytes",
},
"sai_json_t": {
ProtoType: "bytes",
},
"sai_ip4_t": {
ProtoType: "bytes",
},
Expand Down Expand Up @@ -537,6 +545,21 @@ var (
"sai_ip_address_t": {
ProtoType: "bytes",
},
"sai_latch_status_t": {
ProtoType: "LatchStatus",
MessageDef: `message LatchStatus {
bool current_status = 1;
bool changed = 2;
}`,
},
"sai_port_lane_latch_status_list_t": {
Repeated: true,
ProtoType: "PortLaneLatchStatus",
MessageDef: `message PortLaneLatchStatus {
uint32 lane = 1;
LatchStatus value = 2;
}`,
},
"sai_map_list_t": { // Wrap the map in a message because maps can't be repeated.
Repeated: true,
ProtoType: "UintMap",
Expand Down
34 changes: 0 additions & 34 deletions dataplane/standalone/bridge.cc

This file was deleted.

44 changes: 0 additions & 44 deletions dataplane/standalone/bridge.h

This file was deleted.

41 changes: 0 additions & 41 deletions dataplane/standalone/buffer.cc

This file was deleted.

Loading

0 comments on commit 2e703a7

Please sign in to comment.