-
Notifications
You must be signed in to change notification settings - Fork 90
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
Adds dash underlay routing functionality #402
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
66bbe85
Added dash underlay routing functioanlity
AmithGspn eff4740
DEeleted outbound packet processing png file
AmithGspn af19752
Added dash underlay routing functioanlity
AmithGspn b661e50
Added support for fixed SAI headers
AmithGspn cc61cb8
updated configuration tests
AmithGspn acac0f1
Merge branch 'pr_dash_underlay_2' into pr_dash_underlay3
AmithGspn 382015f
Merge pull request #4 from AmithGspn/pr_dash_underlay3
AmithGspn 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,7 @@ | |
'sai_ip_addr_family_t': 'u32', | ||
'sai_uint32_t': 'u32', | ||
'sai_uint64_t': 'u64', | ||
'sai_mac_t': 'mac', | ||
'sai_ip_prefix_list_t': 'ipprefixlist' | ||
'sai_mac_t': 'mac' | ||
} | ||
|
||
def p4_annotation_to_sai_attr(p4rt, sai_attr): | ||
|
@@ -244,7 +243,6 @@ def get_sai_enums(program): | |
sai_enum = dict() | ||
sai_enum['name'] = enum_name[:-2] | ||
sai_enum['members'] = [] | ||
print(enum_name) | ||
for enum_member in all_enums[enum_name][MEMBERS_TAG]: | ||
member = dict() | ||
member['sai_name'] = enum_member['name'] | ||
|
@@ -362,8 +360,11 @@ def write_sai_impl_files(sai_api): | |
env.add_extension('jinja2.ext.loopcontrols') | ||
env.add_extension('jinja2.ext.do') | ||
sai_impl_tm = env.get_template('/templates/saiapi.cpp.j2') | ||
sai_impl_str = sai_impl_tm.render(tables = sai_api[TABLES_TAG], app_name = sai_api['app_name']) | ||
|
||
if "dash" in sai_api['app_name']: | ||
header_prefix = "experimental" | ||
else: | ||
header_prefix = "" | ||
sai_impl_str = sai_impl_tm.render(tables = sai_api[TABLES_TAG], app_name = sai_api['app_name'], header_prefix = header_prefix) | ||
with open('./lib/sai' + sai_api['app_name'].replace('_', '') + '.cpp', 'w') as o: | ||
o.write(sai_impl_str) | ||
|
||
|
@@ -507,25 +508,21 @@ def write_sai_files(sai_api): | |
for table_name in all_table_names: | ||
if table_ref.endswith(table_name): | ||
key[OBJECT_NAME_TAG] = table_name | ||
|
||
# Write SAI dictionary into SAI API headers | ||
write_sai_files(get_uniq_sai_api(sai_api)) | ||
if "dash" in sai_api['app_name']: | ||
write_sai_files(get_uniq_sai_api(sai_api)) | ||
|
||
# Write SAI implementation | ||
write_sai_impl_files(sai_api) | ||
sai_api_name_list.append(sai_api['app_name'].replace('_', '')) | ||
sai_api_full_name_list.append(sai_api['app_name']) | ||
|
||
env = Environment(loader=FileSystemLoader('.'), trim_blocks=True, lstrip_blocks=True) | ||
env.add_extension('jinja2.ext.loopcontrols') | ||
env.add_extension('jinja2.ext.do') | ||
|
||
final_sai_enums = [] | ||
with open('./SAI/experimental/saitypesextensions.h', 'r') as f: | ||
content = f.read() | ||
for enum in sai_enums: | ||
if enum['name'] not in content: | ||
final_sai_enums.append(enum) | ||
|
||
sai_enums_tm = env.get_template('templates/saienums.j2') | ||
sai_enums_str = sai_enums_tm.render(sai_enums = final_sai_enums) | ||
sai_enums_str = sai_enums_tm.render(sai_enums = sai_enums) | ||
sai_enums_lines = sai_enums_str.split('\n') | ||
|
||
# The SAI object struct for entries | ||
|
@@ -548,4 +545,4 @@ def write_sai_files(sai_api): | |
write_sai_fixed_api_files(sai_api_full_name_list) | ||
|
||
if args.print_sai_lib: | ||
print(json.dumps(sai_api, indent=2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why change this ? |
||
print(json.dumps(sai_api, indent=2)) |
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,76 @@ | ||
#include <core.p4> | ||
#include "dash_headers.p4" | ||
#include "dash_metadata.p4" | ||
|
||
control underlay( | ||
inout headers_t hdr | ||
, inout metadata_t meta | ||
#ifdef TARGET_BMV2_V1MODEL | ||
, inout standard_metadata_t standard_metadata | ||
#endif // TARGET_BMV2_V1MODEL | ||
#ifdef TARGET_DPDK_PNA | ||
, in pna_main_input_metadata_t istd | ||
#endif // TARGET_DPDK_PNA | ||
) | ||
{ | ||
action set_nhop(bit<9> next_hop_id) { | ||
#ifdef TARGET_BMV2_V1MODEL | ||
standard_metadata.egress_spec = next_hop_id; | ||
#endif // TARGET_BMV2_V1MODEL | ||
|
||
#ifdef TARGET_DPDK_PNA | ||
#ifdef DPDK_PNA_SEND_TO_PORT_FIX_MERGED | ||
// As of 2023-Jan-26, the version of the pna.p4 header file | ||
// included with p4c defines send_to_port with a parameter | ||
// that has no 'in' direction. The following commit in the | ||
// public pna repo fixes this, but this fix has not yet been | ||
// copied into the p4c repo. | ||
// https://github.com/p4lang/pna/commit/b9fdfb888e5385472c34ff773914c72b78b63058 | ||
// Until p4c is updated with this fix, the following line will | ||
// give a compile-time error. | ||
istd.input_port = next_hop_id; | ||
send_to_port(istd.input_port); | ||
#endif // DPDK_PNA_SEND_TO_PORT_FIX_MERGED | ||
#endif // TARGET_DPDK_PNA | ||
} | ||
|
||
action def_act() { | ||
#ifdef TARGET_BMV2_V1MODEL | ||
standard_metadata.egress_spec = standard_metadata.ingress_port; | ||
#endif // TARGET_BMV2_V1MODEL | ||
|
||
#ifdef TARGET_DPDK_PNA | ||
#ifdef DPDK_PNA_SEND_TO_PORT_FIX_MERGED | ||
// As of 2023-Jan-26, the version of the pna.p4 header file | ||
// included with p4c defines send_to_port with a parameter | ||
// that has no 'in' direction. The following commit in the | ||
// public pna repo fixes this, but this fix has not yet been | ||
// copied into the p4c repo. | ||
// https://github.com/p4lang/pna/commit/b9fdfb888e5385472c34ff773914c72b78b63058 | ||
// Until p4c is updated with this fix, the following line will | ||
// give a compile-time error. | ||
send_to_port(istd.input_port); | ||
#endif // DPDK_PNA_SEND_TO_PORT_FIX_MERGED | ||
#endif // TARGET_DPDK_PNA | ||
} | ||
|
||
@name("route|route") | ||
// TODO: To add structural annotations (example: @Sai[skipHeaderGen=true]) | ||
table underlay_routing { | ||
key = { | ||
meta.dst_ip_addr : lpm @name("meta.dst_ip_addr:destination"); | ||
} | ||
|
||
actions = { | ||
/* Send packet on different/same port it arrived based on routing */ | ||
set_nhop; | ||
|
||
/* Send packet on same port it arrived (echo) by default */ | ||
@defaultonly def_act; | ||
} | ||
} | ||
|
||
apply { | ||
underlay_routing.apply(); | ||
} | ||
} |
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 we need this removed ?