Skip to content

Commit

Permalink
Support bulk remove API
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Jun 17, 2024
1 parent c1934e0 commit 864f778
Show file tree
Hide file tree
Showing 50 changed files with 17 additions and 115 deletions.
13 changes: 6 additions & 7 deletions dataplane/apigen/ccgen/ccgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func createCCData(meta *saiast.FuncMetadata, apiName string, sai *saiast.SAIAPI,
}
case "remove_bulk":
convertFn = nil
opFn.EntryVar = strings.TrimPrefix(opFn.EntryVar, "*") // Usual entry is pointer, but for remove_bulk it's an array.
for _, attr := range info.Attrs[meta.TypeName].CreateFields {
name := sanitizeProtoName(attr.MemberName)
smt, err := protoFieldSetter(attr.SaiType, "", name, "attr_list[i].value", info)
Expand Down Expand Up @@ -535,7 +536,7 @@ extern const {{ .APIType }} l_{{ .APIName }};
#endif // {{ .IncludeGuard }}
`))
ccTmpl = template.Must(template.New("cc").Parse(`
{{ define "getattr" }}
{{- define "getattr" }}
{{ $parent := . }}
switch ({{ .Var }}) {
{{ range .Attrs }}
Expand All @@ -557,7 +558,7 @@ switch ({{ .Var }}) {
{{- end }}
}
{{ end }}
{{ define "setattr" }}
{{- define "setattr" }}
{{ $parent := . }}
switch ({{ .Var }}) {
{{ range .Attrs }}
Expand All @@ -573,9 +574,7 @@ switch ({{ .Var }}) {
break;
{{- end }}
}
{{ end }}
{{ end -}}
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -718,8 +717,8 @@ return msg;
grpc::ClientContext context;
for (uint32_t i = 0; i < object_count; i++) {
{{ if .OidVar -}} req.add_reqs().set_oid(object_id[i]); {{ end }}
{{ if .EntryVar }} *req.add_reqs()->mutable_entry() = {{ .EntryConversionFunc }}({{ printf "" .EntryVar }}[i]); {{ end }}
{{ if .OidVar -}} req.add_reqs()->set_oid(object_id[i]); {{ end }}
{{ if .EntryVar }} *req.add_reqs()->mutable_entry() = {{ .EntryConversionFunc }}({{ .EntryVar }}[i]); {{ end }}
}
grpc::Status status = {{ .Client }}->{{ .RPCMethod }}(&context, req, &resp);
Expand Down
2 changes: 1 addition & 1 deletion dataplane/standalone/pkthandler/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ pkg_deb(
preinst = "preinst",
prerm = "prerm",
tags = ["manual"],
version = "1.0-0",
version = "1.2-0",
)
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/acl.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/bfd.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/bmtor.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/bridge.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/buffer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/counter.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/debug_counter.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/dtel.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/fdb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/generic_programmable.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/hash.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/hostif.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/ipmc.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/ipmc_group.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/ipsec.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/isolation_group.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/l2mc.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/l2mc_group.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 1 addition & 3 deletions dataplane/standalone/sai/lag.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -389,7 +387,7 @@ sai_status_t l_remove_lag_members(uint32_t object_count,
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
req.add_reqs().set_oid(object_id[i]);
req.add_reqs()->set_oid(object_id[i]);
}

grpc::Status status = lag->RemoveLagMembers(&context, req, &resp);
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/macsec.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/mcast_fdb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/mirror.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/mpls.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/my_mac.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/nat.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 1 addition & 3 deletions dataplane/standalone/sai/neighbor.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -268,7 +266,7 @@ sai_status_t l_remove_neighbor_entries(

for (uint32_t i = 0; i < object_count; i++) {
*req.add_reqs()->mutable_entry() =
convert_from_neighbor_entry(*neighbor_entry[i]);
convert_from_neighbor_entry(neighbor_entry[i]);
}

grpc::Status status = neighbor->RemoveNeighborEntries(&context, req, &resp);
Expand Down
4 changes: 1 addition & 3 deletions dataplane/standalone/sai/next_hop.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -322,7 +320,7 @@ sai_status_t l_remove_next_hops(uint32_t object_count,
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
req.add_reqs().set_oid(object_id[i]);
req.add_reqs()->set_oid(object_id[i]);
}

grpc::Status status = next_hop->RemoveNextHops(&context, req, &resp);
Expand Down
4 changes: 1 addition & 3 deletions dataplane/standalone/sai/next_hop_group.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -441,7 +439,7 @@ sai_status_t l_remove_next_hop_group_members(uint32_t object_count,
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
req.add_reqs().set_oid(object_id[i]);
req.add_reqs()->set_oid(object_id[i]);
}

grpc::Status status =
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/policer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 1 addition & 3 deletions dataplane/standalone/sai/port.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -1866,7 +1864,7 @@ sai_status_t l_remove_ports(uint32_t object_count,
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
req.add_reqs().set_oid(object_id[i]);
req.add_reqs()->set_oid(object_id[i]);
}

grpc::Status status = port->RemovePorts(&context, req, &resp);
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/qos_map.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/queue.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
5 changes: 1 addition & 4 deletions dataplane/standalone/sai/route.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -228,8 +226,7 @@ sai_status_t l_remove_route_entries(uint32_t object_count,
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
*req.add_reqs()->mutable_entry() =
convert_from_route_entry(*route_entry[i]);
*req.add_reqs()->mutable_entry() = convert_from_route_entry(route_entry[i]);
}

grpc::Status status = route->RemoveRouteEntries(&context, req, &resp);
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/router_interface.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/rpf_group.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/samplepacket.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/scheduler.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/scheduler_group.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 1 addition & 3 deletions dataplane/standalone/sai/srv6.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -220,7 +218,7 @@ sai_status_t l_remove_srv6_sidlists(uint32_t object_count,
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
req.add_reqs().set_oid(object_id[i]);
req.add_reqs()->set_oid(object_id[i]);
}

grpc::Status status = srv6->RemoveSrv6Sidlists(&context, req, &resp);
Expand Down
4 changes: 1 addition & 3 deletions dataplane/standalone/sai/stp.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -292,7 +290,7 @@ sai_status_t l_remove_stp_ports(uint32_t object_count,
grpc::ClientContext context;

for (uint32_t i = 0; i < object_count; i++) {
req.add_reqs().set_oid(object_id[i]);
req.add_reqs()->set_oid(object_id[i]);
}

grpc::Status status = stp->RemoveStpPorts(&context, req, &resp);
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/switch.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/system_port.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions dataplane/standalone/sai/tam.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading

0 comments on commit 864f778

Please sign in to comment.