Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Jul 25, 2023
1 parent fa3cab9 commit 9b88dd5
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 181 deletions.
1 change: 0 additions & 1 deletion dataplane/standalone/entrypoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ sai_status_t sai_api_initialize(
google::InstallFailureSignalHandler();
initialize(GoInt(50000));


auto chan = grpc::CreateChannel("localhost:50000",
grpc::InsecureChannelCredentials());
translator = std::make_shared<Translator>(chan);
Expand Down
5 changes: 3 additions & 2 deletions dataplane/standalone/hostif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ sai_status_t HostIf::create(_In_ uint32_t attr_count,
switch (attr.id) {
case SAI_HOSTIF_ATTR_TYPE:
if (attr.value.s32 ==
SAI_HOSTIF_TYPE_GENETLINK) { // TODO: figure what this is.
SAI_HOSTIF_TYPE_GENETLINK) { // TODO(dgrau): figure what this is.
return SAI_STATUS_SUCCESS;
} else if (attr.value.s32 != SAI_HOSTIF_TYPE_NETDEV) {
return SAI_STATUS_NOT_SUPPORTED;
} else
} else {
break;
}
case SAI_HOSTIF_ATTR_OBJ_ID:
external_port = attr.value.oid;
break;
Expand Down
4 changes: 2 additions & 2 deletions dataplane/standalone/hostif.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class HostIfTrap : public APIBase {
class HostIfTrapGroup : public APIBase {
public:
HostIfTrapGroup(std::string id, std::shared_ptr<AttributeManager> mgr,
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
: APIBase(id, mgr, fwd, dplane) {}
~HostIfTrapGroup() = default;
sai_status_t create(_In_ uint32_t attr_count,
Expand Down
4 changes: 2 additions & 2 deletions dataplane/standalone/neighbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ extern "C" {
class Neighbor : public APIBase {
public:
Neighbor(std::string id, std::shared_ptr<AttributeManager> mgr,
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
: APIBase(id, mgr, fwd, dplane) {}
~Neighbor() = default;
sai_status_t create(common_entry_t id, _In_ uint32_t attr_count,
Expand Down
3 changes: 2 additions & 1 deletion dataplane/standalone/next_hop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "dataplane/standalone/next_hop.h"

#include <glog/logging.h>

#include <bitset>
#include <string>
#include <vector>

#include "dataplane/standalone/next_hop.h"
#include "dataplane/standalone/translator.h"

sai_status_t NextHop::create(_In_ uint32_t attr_count,
Expand Down
3 changes: 2 additions & 1 deletion dataplane/standalone/next_hop_group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "dataplane/standalone/next_hop_group.h"

#include <glog/logging.h>

#include <bitset>
#include <string>
#include <vector>

#include "dataplane/standalone/next_hop_group.h"
#include "dataplane/standalone/translator.h"

sai_status_t NextHopGroup::create(_In_ uint32_t attr_count,
Expand Down
2 changes: 1 addition & 1 deletion dataplane/standalone/policer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "dataplane/standalone/translator.h"

sai_status_t Policer::create(_In_ uint32_t attr_count,
_In_ const sai_attribute_t* attr_list) {
_In_ const sai_attribute_t* attr_list) {
std::vector<sai_attribute_t> attrs(attr_list, attr_list + attr_count);
APIBase::create(attrs.size(), attrs.data());
return SAI_STATUS_SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions dataplane/standalone/policer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ extern "C" {
class Policer : public APIBase {
public:
Policer(std::string id, std::shared_ptr<AttributeManager> mgr,
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
: APIBase(id, mgr, fwd, dplane) {}
~Policer() = default;
sai_status_t create(_In_ uint32_t attr_count,
Expand Down
6 changes: 3 additions & 3 deletions dataplane/standalone/port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ sai_status_t Port::create(_In_ uint32_t attr_count,
});
}
attrs.push_back({
.id = SAI_PORT_ATTR_OPER_SPEED,
.value = {.u32= 1024},
.id = SAI_PORT_ATTR_OPER_SPEED,
.value = {.u32 = 1024},
});
attrs.push_back({
.id = SAI_PORT_ATTR_NUMBER_OF_INGRESS_PRIORITY_GROUPS,
Expand Down Expand Up @@ -173,4 +173,4 @@ std::unordered_map<std::string, std::vector<int>> Port::parseLaneMap() {
std::unordered_map<std::string, std::vector<int>> Port::laneMap =
Port::parseLaneMap();

int Port::nextIdx = 2;
int Port::nextIdx = 2;
2 changes: 1 addition & 1 deletion dataplane/standalone/router_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sai_status_t RouterInterface::create(_In_ uint32_t attr_count,
break;
case SAI_ROUTER_INTERFACE_TYPE_LOOPBACK:
ifaceType = lemming::dataplane::INTERFACE_TYPE_LOOPBACK;
return SAI_STATUS_SUCCESS; // TODO: Support these for real.
return SAI_STATUS_SUCCESS; // TODO(dgrau): Support these for real.
break;
default:
return SAI_STATUS_NOT_SUPPORTED;
Expand Down
2 changes: 1 addition & 1 deletion dataplane/standalone/switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

#include "dataplane/standalone/common.h"
#include "dataplane/standalone/port.h"
#include "dataplane/standalone/translator.h"
#include "proto/dataplane/dataplane.grpc.pb.h"
#include "proto/dataplane/dataplane.pb.h"
#include "proto/forwarding/forwarding_service.grpc.pb.h"
#include "proto/forwarding/forwarding_service.pb.h"
#include "dataplane/standalone/translator.h"

extern "C" {
#include "inc/sai.h"
Expand Down
12 changes: 6 additions & 6 deletions dataplane/standalone/translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <string>
#include <unordered_map>

#include "dataplane/standalone/switch.h"
#include "dataplane/standalone/hostif.h"
#include "dataplane/standalone/switch.h"

extern "C" {
#include "inc/sai.h"
Expand All @@ -40,14 +40,14 @@ sai_status_t Translator::create(sai_object_type_t type, sai_object_id_t* id,
switch (type) {
case SAI_OBJECT_TYPE_SWITCH: {
auto sw = std::make_shared<Switch>(std::to_string(*id), this->attrMgr,
this->fwd, this->dataplane,this);
this->fwd, this->dataplane, this);
this->switches[std::to_string(*id)] = sw;
this->apis[std::to_string(*id)] = sw;
status = this->apis[std::to_string(*id)]->create(attr_count, attr_list);
break;
}
case SAI_OBJECT_TYPE_HOSTIF_TRAP_GROUP:
this->apis[std::to_string(*id)] = std::make_unique<HostIfTrapGroup>(
this->apis[std::to_string(*id)] = std::make_unique<HostIfTrapGroup>(
std::to_string(*id), this->attrMgr, this->fwd, this->dataplane);
break;
default:
Expand Down Expand Up @@ -117,8 +117,8 @@ sai_status_t Translator::set_attribute(sai_object_type_t type,
} else {
status = this->apis[std::to_string(id)]->set_attribute(attr);
}
if (status == SAI_STATUS_SUCCESS) {
this->attrMgr->set_attribute(std::to_string(id), attr);
if (status == SAI_STATUS_SUCCESS) {
this->attrMgr->set_attribute(std::to_string(id), attr);
}
return status;
}
Expand All @@ -136,7 +136,7 @@ sai_status_t Translator::set_attribute(sai_object_type_t type,
status = this->apis[idStr]->set_attribute(attr);
}
if (status == SAI_STATUS_SUCCESS) {
this->attrMgr->set_attribute(idStr, attr);
this->attrMgr->set_attribute(idStr, attr);
}
return status;
}
Expand Down
4 changes: 2 additions & 2 deletions dataplane/standalone/tunnel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "dataplane/standalone/translator.h"

sai_status_t Tunnel::create(_In_ uint32_t attr_count,
_In_ const sai_attribute_t* attr_list) {
_In_ const sai_attribute_t* attr_list) {
std::vector<sai_attribute_t> attrs(attr_list, attr_list + attr_count);
APIBase::create(attrs.size(), attrs.data());
return SAI_STATUS_SUCCESS;
Expand All @@ -30,7 +30,7 @@ sai_status_t Tunnel::set_attribute(_In_ const sai_attribute_t* attr) {
}

sai_status_t TunnelTable::create(_In_ uint32_t attr_count,
_In_ const sai_attribute_t* attr_list) {
_In_ const sai_attribute_t* attr_list) {
std::vector<sai_attribute_t> attrs(attr_list, attr_list + attr_count);
APIBase::create(attrs.size(), attrs.data());
return SAI_STATUS_SUCCESS;
Expand Down
8 changes: 4 additions & 4 deletions dataplane/standalone/tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ extern "C" {
class Tunnel : public APIBase {
public:
Tunnel(std::string id, std::shared_ptr<AttributeManager> mgr,
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
: APIBase(id, mgr, fwd, dplane) {}
~Tunnel() = default;
sai_status_t create(_In_ uint32_t attr_count,
Expand All @@ -44,8 +44,8 @@ class Tunnel : public APIBase {
class TunnelTable : public APIBase {
public:
TunnelTable(std::string id, std::shared_ptr<AttributeManager> mgr,
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
std::shared_ptr<forwarding::Forwarding::Stub> fwd,
std::shared_ptr<lemming::dataplane::Dataplane::Stub> dplane)
: APIBase(id, mgr, fwd, dplane) {}
~TunnelTable() = default;
sai_status_t create(_In_ uint32_t attr_count,
Expand Down
Loading

0 comments on commit 9b88dd5

Please sign in to comment.