-
Notifications
You must be signed in to change notification settings - Fork 93
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
[dpapp] Initial dpapp implementation being a vpp plugin #609
Open
jimmyzhai
wants to merge
9
commits into
sonic-net:main
Choose a base branch
from
jimmyzhai:dp_app_add_vpp_plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,380
−29
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
74332c6
Add fixture use_flow
jimmyzhai 0605bce
Add set_internal_config
jimmyzhai 162580e
Add dpapp_mac
jimmyzhai 7bc506d
dpapp_mac -> cpu_mac, host0_mac -> neighbor_mac
jimmyzhai 1c75e5a
Add dpapp
jimmyzhai 321d836
Add ptf test saidashdpapp_sanity.py
jimmyzhai e8b0454
Build, run and test dpapp in workflow dash-bmv2-ci
jimmyzhai e84b2ac
check p4 flow table for test case verification
jimmyzhai 27c84a6
Update dpapp/dpapp.sh
jimmyzhai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(dash-plugin) | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I /SAI/SAI/inc -I /SAI/SAI/experimental") | ||
|
||
find_package(VPP) | ||
|
||
add_subdirectory(dash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
SHELL=/bin/bash | ||
BUILD_DIR=build | ||
CMAKE_ARGS= | ||
|
||
ifeq ($(V),1) | ||
CMAKE_ARGS += --verbose | ||
endif | ||
|
||
all: dpapp | ||
|
||
.PHONY:configure install clean | ||
|
||
configure: | ||
@cmake $(CMAKE_ARGS) -G Ninja -S . -B $(BUILD_DIR) | ||
|
||
dpapp: configure | ||
@cmake --build $(BUILD_DIR) $(CMAKE_ARGS) | ||
|
||
clean: | ||
@cmake --build $(BUILD_DIR) $(CMAKE_ARGS) -- clean | ||
|
||
install: | ||
@sudo cmake --build $(BUILD_DIR) $(CMAKE_ARGS) -- install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2018 Cisco and/or its affiliates. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
include_directories(${CMAKE_SOURCE_DIR}) | ||
|
||
# for generated API headers: | ||
include_directories(${CMAKE_BINARY_DIR}) | ||
|
||
add_vpp_plugin(dash | ||
SOURCES | ||
node.c | ||
dash.c | ||
flow.c | ||
saiapi.c | ||
|
||
MULTIARCH_SOURCES | ||
node.c | ||
|
||
API_FILES | ||
dash.api | ||
|
||
API_TEST_SOURCES | ||
dash_test.c | ||
|
||
COMPONENT vpp-plugin-dash | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Hey Emacs use -*- mode: C -*- */ | ||
/* | ||
* Copyright (c) 2015 Cisco and/or its affiliates. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* Define a simple binary API to control the feature */ | ||
|
||
option version = "0.1.0"; | ||
import "vnet/interface_types.api"; | ||
|
||
autoreply define dash_enable_disable { | ||
/* Client identifier, set from api_main.my_client_index */ | ||
u32 client_index; | ||
|
||
/* Arbitrary context, so client can match reply to request */ | ||
u32 context; | ||
|
||
/* Enable / disable the feature */ | ||
bool enable_disable; | ||
|
||
/* Interface handle */ | ||
vl_api_interface_index_t sw_if_index; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
/* | ||
* Copyright (c) 2015 Cisco and/or its affiliates. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* @file | ||
* @brief Dash Plugin, plugin API / trace / CLI handling. | ||
*/ | ||
|
||
#include <vnet/vnet.h> | ||
#include <vnet/plugin/plugin.h> | ||
#include <dash/dash.h> | ||
|
||
#include <vlibapi/api.h> | ||
#include <vlibmemory/api.h> | ||
|
||
#include <dash/dash.api_enum.h> | ||
#include <dash/dash.api_types.h> | ||
|
||
#define REPLY_MSG_ID_BASE sm->msg_id_base | ||
#include <vlibapi/api_helper_macros.h> | ||
|
||
/* *INDENT-OFF* */ | ||
VLIB_PLUGIN_REGISTER () = { | ||
.version = DASH_PLUGIN_BUILD_VER, | ||
.description = "Dash of VPP Plugin", | ||
}; | ||
/* *INDENT-ON* */ | ||
|
||
VLIB_REGISTER_LOG_CLASS (dash_log) = { | ||
.class_name = "dash", | ||
}; | ||
|
||
dash_main_t dash_main; | ||
|
||
/** | ||
* @brief Enable/disable the dash plugin. | ||
* | ||
* Action function shared between message handler and debug CLI. | ||
*/ | ||
|
||
int dash_enable_disable (dash_main_t * sm, u32 sw_if_index, | ||
int enable_disable) | ||
{ | ||
vnet_sw_interface_t * sw; | ||
int rv = 0; | ||
|
||
/* Utterly wrong? */ | ||
if (pool_is_free_index (sm->vnet_main->interface_main.sw_interfaces, | ||
sw_if_index)) | ||
return VNET_API_ERROR_INVALID_SW_IF_INDEX; | ||
|
||
/* Not a physical port? */ | ||
sw = vnet_get_sw_interface (sm->vnet_main, sw_if_index); | ||
if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE) | ||
return VNET_API_ERROR_INVALID_SW_IF_INDEX; | ||
|
||
vnet_feature_enable_disable ("dash-pipeline", "dash-pipeline-input", | ||
sw_if_index, enable_disable, 0, 0); | ||
|
||
return rv; | ||
} | ||
|
||
static clib_error_t * | ||
dash_cmd_set_enable_disable_fn (vlib_main_t * vm, | ||
unformat_input_t * input, | ||
vlib_cli_command_t * cmd) | ||
{ | ||
dash_main_t * sm = &dash_main; | ||
u32 sw_if_index = ~0; | ||
int enable_disable = 1; | ||
int rv; | ||
|
||
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { | ||
if (unformat (input, "disable")) | ||
enable_disable = 0; | ||
else if (unformat (input, "%U", unformat_vnet_sw_interface, | ||
sm->vnet_main, &sw_if_index)) | ||
; | ||
else | ||
break; | ||
} | ||
|
||
if (sw_if_index == ~0) | ||
return clib_error_return (0, "Please specify an interface..."); | ||
|
||
rv = dash_enable_disable (sm, sw_if_index, enable_disable); | ||
|
||
switch(rv) { | ||
case 0: | ||
break; | ||
|
||
case VNET_API_ERROR_INVALID_SW_IF_INDEX: | ||
return clib_error_return | ||
(0, "Invalid interface, only works on physical ports"); | ||
break; | ||
|
||
case VNET_API_ERROR_UNIMPLEMENTED: | ||
return clib_error_return (0, "Device driver doesn't support redirection"); | ||
break; | ||
|
||
default: | ||
return clib_error_return (0, "dash_enable_disable returned %d", | ||
rv); | ||
} | ||
return 0; | ||
} | ||
|
||
/** | ||
* @brief CLI command to enable/disable the dash plugin. | ||
*/ | ||
VLIB_CLI_COMMAND (dash_set_command, static) = { | ||
.path = "set dash", | ||
.short_help = | ||
"set dash <interface-name> [disable]", | ||
.function = dash_cmd_set_enable_disable_fn, | ||
}; | ||
|
||
/** | ||
* @brief Plugin API message handler. | ||
*/ | ||
static void vl_api_dash_enable_disable_t_handler | ||
(vl_api_dash_enable_disable_t * mp) | ||
{ | ||
vl_api_dash_enable_disable_reply_t * rmp; | ||
dash_main_t * sm = &dash_main; | ||
int rv; | ||
|
||
rv = dash_enable_disable (sm, ntohl(mp->sw_if_index), | ||
(int) (mp->enable_disable)); | ||
|
||
REPLY_MACRO(VL_API_DASH_ENABLE_DISABLE_REPLY); | ||
} | ||
|
||
/* API definitions */ | ||
#include <dash/dash.api.c> | ||
|
||
/** | ||
* @brief Initialize the dash plugin. | ||
*/ | ||
static clib_error_t * dash_init (vlib_main_t * vm) | ||
{ | ||
dash_main_t * sm = &dash_main; | ||
|
||
sm->vnet_main = vnet_get_main (); | ||
|
||
/* Add our API messages to the global name_crc hash table */ | ||
sm->msg_id_base = setup_message_id_table (); | ||
|
||
/* Reuse SECURE_DATA (0x876D) for dash metadata */ | ||
ethernet_register_input_type (vm, ETHERNET_TYPE_SECURE_DATA, dash_node.index); | ||
|
||
dash_flow_table_init(dash_flow_table_get()); | ||
|
||
dash_sai_init(); | ||
|
||
return 0; | ||
} | ||
|
||
VLIB_INIT_FUNCTION (dash_init); | ||
|
||
/** | ||
* @brief Hook the dash plugin into the VPP graph hierarchy. | ||
*/ | ||
VNET_FEATURE_ARC_INIT (dash_pipeline, static) = | ||
{ | ||
.arc_name = "dash-pipeline", | ||
.start_nodes = VNET_FEATURES ("dash-pipeline-input"), | ||
.last_in_arc = "error-drop", | ||
.arc_index_ptr = &dash_main.feature_arc_index, | ||
}; | ||
|
||
static uword | ||
dash_timer_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) | ||
{ | ||
|
||
int i; | ||
f64 sleep_duration = 1.0; | ||
|
||
unix_sleep (5.0); /* FIXME: delay 5s */ | ||
|
||
while (1) | ||
{ | ||
/* FIXME: Use time-wheel per-worker thread later */ | ||
//for (i = 1; i < vlib_get_n_threads(); i++) { | ||
vlib_node_set_interrupt_pending (vlib_get_main_by_index(1), | ||
dash_flow_scan_node.index); | ||
//} | ||
|
||
vlib_process_suspend (vm, sleep_duration); | ||
} | ||
return 0; | ||
} | ||
|
||
/* *INDENT-OFF* */ | ||
VLIB_REGISTER_NODE (dash_timer_node,static) = { | ||
.function = dash_timer_process, | ||
.name = "dash-timer-process", | ||
.type = VLIB_NODE_TYPE_PROCESS, | ||
}; | ||
/* *INDENT-ON* */ | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mind to add a README here to help people getting started on it?