Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin-1/main' into patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
marian-pritsak committed Apr 30, 2024
2 parents cc43c75 + 51df513 commit e10428d
Show file tree
Hide file tree
Showing 83 changed files with 2,818 additions and 882 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dash-md-spellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Spellcheck
uses: rojopolis/spellcheck-github-actions@0.26.0
uses: rojopolis/spellcheck-github-actions@0.35.0
9 changes: 9 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Accton
ACK
Ack
ack
ack'ed
acl
ACL
ACLs
Expand Down Expand Up @@ -37,6 +38,7 @@ AspNet
assignees
asyncE
atlassian
attr
ATTR
auditability
autogenerate
Expand Down Expand Up @@ -304,6 +306,7 @@ IxLoad
ixload
IxNetwork
IxNetworkWeb
Jiang
Jinja
jitter
journaled
Expand Down Expand Up @@ -372,6 +375,7 @@ NonSynStateful
NorthBound
Novus
NPL
NPU
NPUS
NSG
NSGs
Expand Down Expand Up @@ -421,6 +425,7 @@ performant
pingmesh
PIR
pluggable
PLS
PLVision's
PKTS
pmon
Expand Down Expand Up @@ -471,11 +476,13 @@ README
READMEs
README's
reconvergence
RECV
RedirectRuleResimulatedUf
redis
renderer
repo
repos
REQ
resimulated
resimulation
responder
Expand Down Expand Up @@ -528,12 +535,14 @@ sharding
SInce
SKU
SKUs
SLA
SLB
SMAC
SmartAppliances
SmartNIC
SmartNic
SmartNICs
SmartSwitch
SmartSwitches
snappi
SNAT
Expand Down
2 changes: 1 addition & 1 deletion dash-pipeline/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ sai-submodule:
# P4 Source code compile TARGETS
######################################

P4_SRC=$(wildcard bmv2/*.p4)
P4_SRC=$(wildcard bmv2/**/*.p4)
P4_MAIN=bmv2/dash_pipeline.p4
P4_OUTDIR=bmv2/dash_pipeline.bmv2
P4_ARTIFACTS=$(P4_OUTDIR)/dash_pipeline.json $(P4_OUTDIR)/dash_pipeline_p4rt.txt
Expand Down
2 changes: 1 addition & 1 deletion dash-pipeline/SAI/SAI
Submodule SAI updated 201 files
2 changes: 2 additions & 0 deletions dash-pipeline/SAI/debian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ libsai-dev_$(VERSION)_amd64.deb: ../SAI/inc/*.h ../SAI/experimental/*.h
dpkg-deb --build --root-owner-group libsai-dev_$(VERSION)_amd64

libsai_$(VERSION)_amd64.deb: ../lib/libsai.so
mkdir -p -m 755 libsai_$(VERSION)_amd64/etc/dash
install -vCD ../../bmv2/dash_pipeline.bmv2/* libsai_$(VERSION)_amd64/etc/dash/
mkdir -p -m 755 libsai_$(VERSION)_amd64/usr/lib/x86_64-linux-gnu/
find -type d |xargs chmod go-w
install -vCD ../lib/libsai.so libsai_$(VERSION)_amd64/usr/lib/x86_64-linux-gnu/libsai.so
Expand Down
14 changes: 10 additions & 4 deletions dash-pipeline/SAI/sai_api_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ def _parse_sai_table_attribute_annotation(self, p4rt_anno_list: Dict[str, Any])
self.skipattr = str(kv['value']['stringValue'])
elif kv['key'] == 'match_type':
self.match_type = str(kv['value']['stringValue'])
elif kv['key'] == 'validonly':
self.validonly = str(kv['value']['stringValue'])
else:
raise ValueError("Unknown attr annotation " + kv['key'])

Expand Down Expand Up @@ -516,6 +518,7 @@ def __init__(self):
self.isreadonly: str = "true"
self.counter_type: str = "bytes"
self.attr_type: str = "stats"
self.no_suffix: bool = ""
self.param_actions: List[str] = []

def parse_p4rt(self, p4rt_counter: Dict[str, Any], var_ref_graph: P4VarRefGraph) -> None:
Expand Down Expand Up @@ -597,6 +600,8 @@ def __parse_sai_counter_annotation(self, p4rt_counter: Dict[str, Any]) -> None:
self.attr_type = str(kv['value']['stringValue'])
if self.attr_type not in ["counter_attr", "counter_id", "stats"]:
raise ValueError(f'Unknown counter attribute type: attr_type={self.attr_type}')
elif kv['key'] == 'no_suffix':
self.no_suffix = str(kv['value']['stringValue']) == "true"
else:
raise ValueError("Unknown attr annotation " + kv['key'])

Expand All @@ -613,10 +618,11 @@ def generate_counter_sai_attributes(self) -> 'Iterator[SAICounter]':
counter = copy.deepcopy(self)

counter.counter_type = counter_type

if counter.attr_type == "counter_attr":
counter.name = f"{counter.name}_{counter.counter_type}_counter"
counter.name = f"{counter.name}_{counter.counter_type}_counter" if not self.no_suffix else f"{counter.name}_counter"
else:
counter.name = f"{counter.name}_{counter.counter_type}"
counter.name = f"{counter.name}_{counter.counter_type}" if not self.no_suffix else counter.name

yield counter

Expand Down Expand Up @@ -695,8 +701,8 @@ def parse_p4rt(self, p4rt_table_action: Dict[str, Any], sai_enums: List[SAIEnum]
},
"params": [
{ "id": 1, "name": "dst_vnet_id", "bitwidth": 16 },
{ "id": 2, "name": "meter_policy_en", "bitwidth": 1 },
{ "id": 3, "name": "meter_class", "bitwidth": 16 }
{ "id": 2, "name": "meter_class_or", "bitwidth": 32 },
{ "id": 3, "name": "meter_class_and", "bitwidth": 32 }
]
}
'''
Expand Down
1 change: 1 addition & 0 deletions dash-pipeline/SAI/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CXXFLAGS_COMMON+= -Wno-switch-default
CXXFLAGS_COMMON+= -Wconversion
CXXFLAGS_COMMON+= -Wno-psabi
CXXFLAGS_COMMON+= -Wno-unused-label
CXXFLAGS_COMMON+= -Wno-unused-result

# Sources from OCP SAI Repo:
SAI_DIR=../SAI/meta/
Expand Down
1 change: 1 addition & 0 deletions dash-pipeline/SAI/src/objectidmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {

#include <set>
#include <map>
#include <string>

namespace dash
{
Expand Down
22 changes: 22 additions & 0 deletions dash-pipeline/SAI/src/sai_dash_buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "saiimpl.h"

DASH_GENERIC_QUAD(BUFFER_POOL,buffer_pool);
DASH_GENERIC_QUAD(INGRESS_PRIORITY_GROUP,ingress_priority_group);
DASH_GENERIC_QUAD(BUFFER_PROFILE,buffer_profile);

sai_buffer_api_t redis_buffer_api = {

DASH_GENERIC_QUAD_API(buffer_pool)

.get_buffer_pool_stats = 0,
.get_buffer_pool_stats_ext = 0,
.clear_buffer_pool_stats = 0,

DASH_GENERIC_QUAD_API(ingress_priority_group)

.get_ingress_priority_group_stats = 0,
.get_ingress_priority_group_stats_ext = 0,
.clear_ingress_priority_group_stats = 0,

DASH_GENERIC_QUAD_API(buffer_profile)
};
16 changes: 16 additions & 0 deletions dash-pipeline/SAI/src/sai_dash_dtel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "saiimpl.h"

DASH_GENERIC_QUAD(DTEL,dtel);
DASH_GENERIC_QUAD(DTEL_QUEUE_REPORT,dtel_queue_report);
DASH_GENERIC_QUAD(DTEL_INT_SESSION,dtel_int_session);
DASH_GENERIC_QUAD(DTEL_REPORT_SESSION,dtel_report_session);
DASH_GENERIC_QUAD(DTEL_EVENT,dtel_event);

sai_dtel_api_t dash_sai_dtel_api = {

DASH_GENERIC_QUAD_API(dtel)
DASH_GENERIC_QUAD_API(dtel_queue_report)
DASH_GENERIC_QUAD_API(dtel_int_session)
DASH_GENERIC_QUAD_API(dtel_report_session)
DASH_GENERIC_QUAD_API(dtel_event)
};
2 changes: 1 addition & 1 deletion dash-pipeline/SAI/templates/headers/sai_stats_enum.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
typedef enum _sai_{{ table.name }}_stat_t
{
{% for stat in table.sai_stats %}
/** DASH {{ table.name | lower }} {{ stat.name | upper }} stat count */
/** DASH {{ table.name | upper }} {{ stat.name | upper }} stat count */
SAI_{{ table.name | upper }}_STAT_{{ stat.name | upper }},

{% endfor %}
Expand Down
10 changes: 10 additions & 0 deletions dash-pipeline/SAI/templates/saiapi.cpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ static sai_status_t dash_sai_create_{{ table.name }}(
{% elif key.match_type == 'lpm' %}
auto mf_lpm = mf->mutable_lpm();
{{key.field}}SetVal(tableEntry->{{ key.name | lower }}, mf_lpm, {{key.bitwidth}});
{% elif key.match_type == 'ternary' %}
auto mf_ternary = mf->mutable_ternary();
{{key.field}}SetVal(tableEntry->{{ key.name | lower }}, mf_ternary, {{key.bitwidth}});
{{key.field}}SetMask(tableEntry->{{ key.name | lower }}_mask, mf_ternary, {{key.bitwidth}});
matchActionEntry->set_priority(tableEntry->priority);
{% elif key.match_type == 'list' %}
// BMv2 doesn't support "list" match type, and we are using "optional" match in v1model as our implementation.
// Hence, here we only take the first item from the list and program it as optional match.
Expand Down Expand Up @@ -568,6 +573,11 @@ static sai_status_t dash_sai_remove_{{ table.name }}(
{% elif key.match_type == 'lpm' %}
auto mf_lpm = mf->mutable_lpm();
{{key.field}}SetVal(tableEntry->{{ key.name | lower }}, mf_lpm, {{key.bitwidth}});
{% elif key.match_type == 'ternary' %}
auto mf_ternary = mf->mutable_ternary();
{{key.field}}SetVal(tableEntry->{{ key.name | lower }}, mf_ternary, {{key.bitwidth}});
{{key.field}}SetMask(tableEntry->{{ key.name | lower }}_mask, mf_ternary, {{key.bitwidth}});
matchActionEntry->set_priority(tableEntry->priority);
{% elif key.match_type == 'list' %}
// BMv2 doesn't support "list" match type, and we are using "optional" match in v1model as our implementation.
// Hence, here we only take the first item from the list and program it as optional match.
Expand Down
12 changes: 10 additions & 2 deletions dash-pipeline/SAI/templates/saiapi.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/

{% for table in sai_api.tables %}
{% if table.actions | length > 1 or ((table.actions | length == 1) and (((table.is_object == 'false') or (table['keys'] | length <= 1)) and ((table['action_params'] | length == 0)))) %}
{% if table.actions | length > 1 or table.is_object == 'false' %}
/**
* @brief Attribute data for #SAI_{{ table.name | upper }}_ATTR_ACTION
*/
Expand Down Expand Up @@ -103,7 +103,7 @@ typedef enum _sai_{{ table.name }}_attr_t
SAI_{{ table.name | upper }}_ATTR_START,

{% set ns = namespace(firstattr=false) %}
{% if table.actions | length > 1 or ((table.actions | length == 1) and (((table.is_object == 'false') or (table['keys'] | length <= 1)) and ((table['action_params'] | length == 0)))) %}
{% if table.actions | length > 1 or table.is_object == 'false' %}
/**
* @brief Action
*
Expand Down Expand Up @@ -183,6 +183,9 @@ typedef enum _sai_{{ table.name }}_attr_t

{% endif %}
{% endif %}
{% if sai_attr.validonly | length > 0 %}
* @validonly {{ sai_attr.validonly }}
{% endif %}
{% if sai_attr.isresourcetype == 'true' %}
* @isresourcetype true
{% endif %}
Expand All @@ -208,7 +211,12 @@ typedef enum _sai_{{ table.name }}_attr_t
* @allownull true
* @default SAI_NULL_OBJECT_ID
*/
{% if not ns.firstattr %}
SAI_{{ table.name | upper }}_ATTR_COUNTER_ID = SAI_{{ table.name | upper }}_ATTR_START,
{% set ns.firstattr = true %}
{% else %}
SAI_{{ table.name | upper }}_ATTR_COUNTER_ID,
{% endif %}

{% endif %}
{% if table.is_object == 'true' %}
Expand Down
2 changes: 2 additions & 0 deletions dash-pipeline/SAI/templates/saiimpl.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ DASH_PRIVATE extern sai_policer_api_t dash_sai_policer_api_impl;
DASH_PRIVATE extern sai_port_api_t dash_sai_port_api_impl;
DASH_PRIVATE extern sai_router_interface_api_t dash_sai_router_interface_api_impl;
DASH_PRIVATE extern sai_switch_api_t dash_sai_switch_api_impl;
DASH_PRIVATE extern sai_dtel_api_t dash_sai_dtel_api;
DASH_PRIVATE extern sai_buffer_api_t dash_sai_buffer_api;

{% for api in api_names %}
DASH_PRIVATE extern sai_{{ api }}_api_t dash_sai_{{ api }}_api_impl;
Expand Down
89 changes: 82 additions & 7 deletions dash-pipeline/bmv2/dash_arch_specific.p4
Original file line number Diff line number Diff line change
@@ -1,18 +1,93 @@
#ifndef __DASH_TARGET_SPECIFIC__
#define __DASH_TARGET_SPECIFIC__

#ifdef TARGET_BMV2_V1MODEL
//
// P4 arch/target includes
//
#if defined(TARGET_BMV2_V1MODEL)
#include <v1model.p4>
#elif defined(TARGET_DPDK_PNA) // TARGET_BMV2_V1MODEL
#include <pna.p4>
#endif // TARGET_DPDK_PNA

//
// Counters
// - The counters are defined differently for different arch.
//
#if defined(TARGET_BMV2_V1MODEL)

#define DEFINE_COUNTER(name, count, ...) \
@SaiCounter[__VA_ARGS__] \
counter(count, CounterType.packets_and_bytes) name;

#include <v1model.p4>
#define DIRECT_COUNTER_TABLE_PROPERTY counters
#define DEFINE_PACKET_COUNTER(name, count, ...) \
@SaiCounter[__VA_ARGS__] \
counter(count, CounterType.packets) name;

#endif // TARGET_BMV2_V1MODEL
#define DEFINE_BYTE_COUNTER(name, count, ...) \
@SaiCounter[__VA_ARGS__] \
counter(count, CounterType.bytes) name;

#ifdef TARGET_DPDK_PNA
#define DEFINE_HIT_COUNTER(name, count, ...) \
@SaiCounter[__VA_ARGS__, no_suffix="true"] \
counter(count, CounterType.packets) name;

#include <pna.p4>
#define DIRECT_COUNTER_TABLE_PROPERTY pna_direct_counter
#define UPDATE_COUNTER(name, index) \
name.count((bit<32>)index)

#define DEFINE_TABLE_COUNTER(counter_name) direct_counter(CounterType.packets_and_bytes) counter_name;
#define ATTACH_TABLE_COUNTER(counter_name) counters = counter_name;

#elif defined(TARGET_DPDK_PNA) // TARGET_BMV2_V1MODEL

// Counters are not supported yet for PNA arch in DASH
#define DEFINE_COUNTER(name, count, ...)
#define DEFINE_PACKET_COUNTER(name, count, ...)
#define DEFINE_BYTE_COUNTER(name, count, ...)
#define DEFINE_HIT_COUNTER(name, count, ...)
#define UPDATE_COUNTER(name, index)

#ifdef DPDK_SUPPORTS_DIRECT_COUNTER_ON_WILDCARD_KEY_TABLE
// Omit all direct counters for tables with ternary match keys,
// because the latest version of p4c-dpdk as of 2023-Jan-26 does
// not support this combination of features. If you try to
// compile it with this code enabled, the error message looks like
// this:
//
// [--Werror=target-error] error: Direct counters and direct meters are unsupported for wildcard match table outbound_acl_stage1:dash_acl_rule|dash_acl
//
// This p4c issue is tracking this feature gap in p4c-dpdk:
// https://github.com/p4lang/p4c/issues/3868
#define DEFINE_TABLE_COUNTER(counter_name) DirectCounter<bit<64>>(PNA_CounterType_t.PACKETS_AND_BYTES) counter_name;
#define ATTACH_TABLE_COUNTER(counter_name) pna_direct_counter = counter_name;
#else
#define DEFINE_TABLE_COUNTER(counter_name)
#define ATTACH_TABLE_COUNTER(counter_name)
#endif

#endif // TARGET_DPDK_PNA

//
// DBC (Design By Contract) macros
// - These macros will be used as a replacement for asserts, which makes the precondition and postcondition checks more explicit.
//
#if defined(TARGET_BMV2_V1MODEL)

#define REQUIRES(cond) assert(cond)

#elif defined(TARGET_DPDK_PNA) // TARGET_BMV2_V1MODEL

// NOTE: PNA doesn't support assert, hence all macros are defined as empty
#define REQUIRES(cond)

#endif // TARGET_DPDK_PNA

//
// Utility macros
//

// The second macro will have the value of x expanded before stringification.
#define PP_STR_RAW(x) #x
#define PP_STR(x) PP_STR_RAW(x)

#endif // __DASH_TARGET_SPECIFIC__
Loading

0 comments on commit e10428d

Please sign in to comment.