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

Add Port from chassis config file #3

Open
wants to merge 23 commits into
base: main-nikss
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Merge branch 'main-nikss' into AddPort"
This reverts commit ddbec7f, reversing
changes made to 89b3777.
  • Loading branch information
Kinnyeo committed Nov 7, 2023
commit fb4b6c22a80d1b0c5ca41330599945a297a4262a
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -65,7 +65,3 @@ __pycache__/
# SSL certificates
tools/tls/certs/
.srl

# Dockerfiles in stratum
/stratum/Dockerfile*

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

FROM stratumproject/build:build

ARG USER_NAME=labs
ARG USER_NAME=stratum
ARG USER_ID=1000

RUN useradd -ms /bin/bash -l -u $USER_ID $USER_NAME && \
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

FROM stratumproject/build:build

ARG USER_NAME=labs
ARG USER_NAME=default
ARG USER_ID=1000
ARG GIT_GLOBAL_NAME=
ARG GIT_GLOBAL_EMAIL=
5 changes: 0 additions & 5 deletions script.py

This file was deleted.

29 changes: 0 additions & 29 deletions setup.sh

This file was deleted.

11 changes: 1 addition & 10 deletions setup_dev_env.sh
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@ Usage: $0
[--git-email <email>] use the provided email for git commits
[--git-editor <editor command>] use the provided editor for git
[--np4-intel] create NP4 Intel build environment
[]
[-- [Docker options]] additional Docker options for running the container
EOF
}
@@ -48,10 +47,6 @@ do
PULL_DOCKER=YES
shift
;;
--nikss)
NIKSS_SWITCH=YES
shift
;;
--mount-ssh)
MOUNT_SSH=YES
shift
@@ -125,8 +120,7 @@ fi
DOCKER_RUN_OPTIONS="--rm -ti -v $THIS_DIR:/stratum -w /stratum"
DOCKER_GID=$(id -g $USER)
if [ -n "$DOCKER_GID" ]; then
#DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS --user $USER:$DOCKER_GID"
:
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS --user $USER:$DOCKER_GID"
fi
if [ "$MOUNT_SSH" == YES ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -v $HOME/.ssh:/home/$USER/.ssh"
@@ -141,9 +135,6 @@ fi
if [ "$NP4_INTEL" == YES ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -v /dev/intel-fpga-fme.0:/dev/intel-fpga-fme.0"
fi
if [ "$NIKSS_SWITCH" == YES ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS --privileged -v /sys/fs/bpf:/sys/fs/bpf"
fi
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS $@"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to add the line here

docker run $DOCKER_RUN_OPTIONS $IMAGE_NAME bash
119 changes: 18 additions & 101 deletions stratum/hal/bin/nikss/BUILD
Original file line number Diff line number Diff line change
@@ -1,113 +1,30 @@
load(
"//bazel:rules.bzl",
"STRATUM_INTERNAL",
"stratum_cc_library",
)
load("//bazel:rules.bzl", "HOST_ARCHES", "stratum_cc_binary", "stratum_license_tar")
load("@rules_pkg//:pkg.bzl", "pkg_deb", "pkg_tar")

licenses(["notice"]) # Apache v2

package(
default_visibility = STRATUM_INTERNAL,
)

stratum_cc_library(
name = "nikss_switch",
srcs = ["nikss_switch.cc"],
hdrs = ["nikss_switch.h"],
deps = [
":nikss_chassis_manager",
":nikss_node",
"//stratum/glue:integral_types",
"//stratum/glue:logging",
"//stratum/glue/gtl:map_util",
"//stratum/glue/status:status_macros",
"//stratum/hal/lib/common:phal_interface",
"//stratum/hal/lib/common:switch_interface",
"//stratum/lib:constants",
"//stratum/lib:macros",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_googleapis//google/rpc:status_cc_proto",
]
)

stratum_cc_library(
name = "nikss_chassis_manager",
srcs = ["nikss_chassis_manager.cc"],
hdrs = ["nikss_chassis_manager.h"],
deps = [
"//stratum/glue:integral_types",
"//stratum/glue:logging",
"//stratum/glue/gtl:map_util",
"//stratum/glue/status:status_macros",
"//stratum/hal/lib/common:phal_interface",
"//stratum/hal/lib/common:switch_interface",
"//stratum/hal/lib/nikss:nikss_interface",
"//stratum/lib:constants",
"//stratum/lib:macros",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/synchronization",
"@com_google_googleapis//google/rpc:status_cc_proto",
"@local_nikss_bin//:nikss",
]
default_visibility = ["//visibility:public"],
)

stratum_cc_library(
name = "nikss_interface",
hdrs = ["nikss_interface.h"],
deps = [
"//stratum/glue:integral_types",
"//stratum/glue/status",
"//stratum/glue/status:statusor",
"//stratum/hal/lib/common:common_cc_proto",
"//stratum/hal/lib/common:utils",
"//stratum/lib/channel",
"@com_google_absl//absl/base:core_headers",
stratum_cc_binary(
name = "stratum_nikss",
srcs = [
"main.cc",
],
)

stratum_cc_library(
name = "nikss_wrapper",
srcs = ["nikss_wrapper.cc"],
hdrs = ["nikss_wrapper.h"],
arches = HOST_ARCHES,
deps = [
":nikss_interface",
"//stratum/glue:integral_types",
"//stratum/glue:init_google",
"//stratum/glue:logging",
"//stratum/glue/gtl:map_util",
"//stratum/glue/gtl:stl_util",
"//stratum/glue/status",
"//stratum/glue/status:statusor",
"//stratum/hal/lib/common:common_cc_proto",
"//stratum/hal/lib/p4:utils",
"//stratum/lib:constants",
"//stratum/lib:utils",
"//stratum/lib/channel",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/container:flat_hash_map",
"@local_nikss_bin//:nikss",
"//stratum/hal/lib/nikss:nikss_chassis_manager",
"//stratum/hal/lib/nikss:nikss_wrapper",
"//stratum/hal/lib/nikss:nikss_node",
"//stratum/hal/lib/nikss:nikss_switch",
"//stratum/hal/lib/common:hal",
"//stratum/hal/lib/phal:phal_sim",
"//stratum/lib/security:auth_policy_checker",
"//stratum/lib/security:credentials_manager",
"@com_github_google_glog//:glog",
],
)

stratum_cc_library(
name = "nikss_node",
srcs = ["nikss_node.cc"],
hdrs = ["nikss_node.h"],
deps = [
":nikss_interface",
":nikss_chassis_manager",
"//stratum/glue:integral_types",
"//stratum/glue:logging",
"//stratum/glue/status:status_macros",
"//stratum/hal/lib/common:common_cc_proto",
"//stratum/hal/lib/common:proto_oneof_writer_wrapper",
"//stratum/hal/lib/common:writer_interface",
"//stratum/lib:constants",
"//stratum/lib:macros",
"//stratum/lib:utils",
"//stratum/public/proto:error_cc_proto",
"@com_github_p4lang_p4runtime//:p4runtime_cc_grpc",
"@com_google_googleapis//google/rpc:status_cc_proto",
],
)
2 changes: 1 addition & 1 deletion stratum/hal/bin/nikss/main.cc
Original file line number Diff line number Diff line change
@@ -68,4 +68,4 @@ ::util::Status Main(int argc, char* argv[]) {

int main(int argc, char* argv[]) {
return stratum::hal::nikss::Main(argc, argv).error_code();
}
}
5 changes: 2 additions & 3 deletions stratum/hal/lib/nikss/nikss_chassis_manager.cc
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@ std::unique_ptr<NikssChassisManager> NikssChassisManager::CreateInstance(

::util::Status NikssChassisManager::PushChassisConfig(
const ChassisConfig& config) {

::util::Status status = ::util::OkStatus(); // errors to keep track of.
::util::Status status = ::util::OkStatus(); // errors to keep track of.

std::map<uint64, std::map<uint32, PortConfig>> chassis_config;

@@ -64,4 +63,4 @@ ::util::StatusOr<std::map<uint64, std::map<uint32, NikssChassisManager::PortConf

} // namespace nikss
} // namespace hal
} // namespace stratum
} // namespace stratum
2 changes: 1 addition & 1 deletion stratum/hal/lib/nikss/nikss_chassis_manager.h
Original file line number Diff line number Diff line change
@@ -64,4 +64,4 @@ class NikssChassisManager {
} // namespace stratum


#endif // STRATUM_HAL_LIB_NIKSS_NIKSS_CHASSIS_MANAGER_H_
#endif // STRATUM_HAL_LIB_NIKSS_NIKSS_CHASSIS_MANAGER_H_
2 changes: 1 addition & 1 deletion stratum/hal/lib/nikss/nikss_interface.h
Original file line number Diff line number Diff line change
@@ -26,4 +26,4 @@ class NikssInterface {
} // namespace hal
} // namespace stratum

#endif // STRATUM_HAL_LIB_NIKSS_NIKSS_INTERFACE_H_
#endif // STRATUM_HAL_LIB_NIKSS_NIKSS_INTERFACE_H_
6 changes: 3 additions & 3 deletions stratum/hal/lib/nikss/nikss_node.cc
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ namespace nikss {
NikssNode::NikssNode(NikssInterface* nikss_interface, uint64 node_id)
: config_(),
nikss_interface_(ABSL_DIE_IF_NULL(nikss_interface)),
//nikss_switch_(ABSL_DIE_IF_NULL(nikss_switch)),
node_id_(node_id) {}

NikssNode::NikssNode()
@@ -53,7 +52,8 @@ ::util::Status NikssNode::CommitForwardingPipelineConfig(std::map<uint64, std::m
NikssChassisManager::PortConfig config = it->second;
LOG(INFO) << "Adding new port with name " << config.name << ".";
RETURN_IF_ERROR(nikss_interface_->AddPort(node_id_, config.name));
}
}

return ::util::OkStatus();
}

@@ -66,4 +66,4 @@ ::util::Status NikssNode::VerifyForwardingPipelineConfig(

} // namespace nikss
} // namespace hal
} // namespace stratum
} // namespace stratum
2 changes: 1 addition & 1 deletion stratum/hal/lib/nikss/nikss_node.h
Original file line number Diff line number Diff line change
@@ -67,4 +67,4 @@ class NikssNode {
} // namespace hal
} // namespace stratum

#endif // STRATUM_HAL_LIB_NIKSS_NIKSS_NODE_H_
#endif // STRATUM_HAL_LIB_NIKSS_NIKSS_NODE_H_
Loading