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

[dash] [internal test] Use private SAI #1425

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "SAI"]
path = SAI
url = https://github.com/opencomputeproject/SAI.git
url = https://github.com/jimmyzhai/SAI.git
ignore = dirty
branch = v1.3
4 changes: 4 additions & 0 deletions lib/Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ namespace sairedis
SAI_REDIS_RECORDER_DECLARE_RECORD_CREATE(pa_validation_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_CREATE(outbound_routing_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_CREATE(outbound_ca_to_pa_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_CREATE(flow_entry);

public: // remove ENTRY

Expand All @@ -197,6 +198,7 @@ namespace sairedis
SAI_REDIS_RECORDER_DECLARE_RECORD_REMOVE(pa_validation_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_REMOVE(outbound_routing_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_REMOVE(outbound_ca_to_pa_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_REMOVE(flow_entry);

public: // set ENTRY

Expand All @@ -216,6 +218,7 @@ namespace sairedis
SAI_REDIS_RECORDER_DECLARE_RECORD_SET(pa_validation_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_SET(outbound_routing_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_SET(outbound_ca_to_pa_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_SET(flow_entry);

public: // get ENTRY

Expand All @@ -235,6 +238,7 @@ namespace sairedis
SAI_REDIS_RECORDER_DECLARE_RECORD_GET(pa_validation_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_GET(outbound_routing_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_GET(outbound_ca_to_pa_entry);
SAI_REDIS_RECORDER_DECLARE_RECORD_GET(flow_entry);

public: // SAI stats API

Expand Down
46 changes: 46 additions & 0 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3116,6 +3116,52 @@ sai_status_t Meta::meta_sai_validate_outbound_ca_to_pa_entry(
return SAI_STATUS_SUCCESS;
}

sai_status_t Meta::meta_sai_validate_flow_entry(
_In_ const sai_flow_entry_t* flow_entry,
_In_ bool create,
_In_ bool get)
{
SWSS_LOG_ENTER();

if (flow_entry == NULL)
{
SWSS_LOG_ERROR("flow_entry pointer is NULL");

return SAI_STATUS_INVALID_PARAMETER;
}

sai_object_meta_key_t meta_key_flow_entry = {
.objecttype = (sai_object_type_t)SAI_OBJECT_TYPE_FLOW_ENTRY,
.objectkey = {
.key = { .flow_entry = *flow_entry }
}
};

if (create)
{
if (m_saiObjectCollection.objectExists(meta_key_flow_entry))
{
SWSS_LOG_ERROR("object key %s already exists",
sai_serialize_object_meta_key(meta_key_flow_entry).c_str());

return SAI_STATUS_ITEM_ALREADY_EXISTS;
}

return SAI_STATUS_SUCCESS;
}

// set, get, remove
if (!m_saiObjectCollection.objectExists(meta_key_flow_entry))
{
SWSS_LOG_ERROR("object key %s doesn't exist",
sai_serialize_object_meta_key(meta_key_flow_entry).c_str());

return SAI_STATUS_INVALID_PARAMETER;
}

return SAI_STATUS_SUCCESS;
}

sai_status_t Meta::meta_generic_validation_create(
_In_ const sai_object_meta_key_t& meta_key,
_In_ sai_object_id_t switch_id,
Expand Down
5 changes: 5 additions & 0 deletions meta/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ namespace saimeta
_In_ bool create,
_In_ bool get = false);

sai_status_t meta_sai_validate_flow_entry(
_In_ const sai_flow_entry_t* flow_entry,
_In_ bool create,
_In_ bool get = false);

public:

/*
Expand Down
2 changes: 2 additions & 0 deletions meta/SaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern "C" {
_X(PA_VALIDATION_ENTRY,pa_validation_entry); \
_X(OUTBOUND_ROUTING_ENTRY,outbound_routing_entry); \
_X(OUTBOUND_CA_TO_PA_ENTRY,outbound_ca_to_pa_entry); \
_X(FLOW_ENTRY,flow_entry); \

#define SAIREDIS_DECLARE_EVERY_BULK_ENTRY(_X) \
_X(FDB_ENTRY,fdb_entry); \
Expand All @@ -37,6 +38,7 @@ extern "C" {
_X(PA_VALIDATION_ENTRY,pa_validation_entry); \
_X(OUTBOUND_ROUTING_ENTRY,outbound_routing_entry); \
_X(OUTBOUND_CA_TO_PA_ENTRY,outbound_ca_to_pa_entry); \
_X(FLOW_ENTRY,flow_entry); \

#define SAIREDIS_SAIINTERFACE_DECLARE_QUAD_ENTRY_VIRTUAL(OT,ot) \
virtual sai_status_t create( \
Expand Down
37 changes: 37 additions & 0 deletions meta/SaiSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,25 @@ std::string sai_serialize_outbound_ca_to_pa_entry(
return j.dump();
}

std::string sai_serialize_flow_entry(
_In_ const sai_flow_entry_t &flow_entry)
{
SWSS_LOG_ENTER();

json j;

j["switch_id"] = sai_serialize_object_id(flow_entry.switch_id);
j["eni_mac"] = sai_serialize_mac(flow_entry.eni_mac);
j["vnet_id"] = sai_serialize_number(flow_entry.vnet_id);
j["ip_proto"] = sai_serialize_number(flow_entry.ip_proto);
j["src_ip"] = sai_serialize_ip_address(flow_entry.src_ip);
j["dst_ip"] = sai_serialize_ip_address(flow_entry.dst_ip);
j["src_port"] = sai_serialize_number(flow_entry.src_port);
j["dst_port"] = sai_serialize_number(flow_entry.dst_port);

return j.dump();
}

std::string sai_serialize_system_port_config(
_In_ const sai_attr_metadata_t &meta,
_In_ const sai_system_port_config_t &sysportconfig)
Expand Down Expand Up @@ -4728,6 +4747,24 @@ void sai_deserialize_outbound_ca_to_pa_entry(
sai_deserialize_ip_address(j["dip"], outbound_ca_to_pa_entry.dip);
}

void sai_deserialize_flow_entry(
_In_ const std::string &s,
_Out_ sai_flow_entry_t& flow_entry)
{
SWSS_LOG_ENTER();

json j = json::parse(s);

sai_deserialize_object_id(j["switch_id"], flow_entry.switch_id);
sai_deserialize_mac(j["eni_mac"], flow_entry.eni_mac);
sai_deserialize_number(j["vnet_id"], flow_entry.vnet_id);
sai_deserialize_number(j["ip_proto"], flow_entry.ip_proto);
sai_deserialize_ip_address(j["src_ip"], flow_entry.src_ip);
sai_deserialize_ip_address(j["dst_ip"], flow_entry.dst_ip);
sai_deserialize_number(j["src_port"], flow_entry.src_port);
sai_deserialize_number(j["dst_port"], flow_entry.dst_port);
}

void sai_deserialize_attr_id(
_In_ const std::string& s,
_Out_ const sai_attr_metadata_t** meta)
Expand Down
7 changes: 7 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ std::string sai_serialize_outbound_routing_entry(
std::string sai_serialize_outbound_ca_to_pa_entry(
_In_ const sai_outbound_ca_to_pa_entry_t &outbound_ca_to_pa_entry);

std::string sai_serialize_flow_entry(
_In_ const sai_flow_entry_t &flow_entry);

void sai_deserialize_system_port_config_list(
_In_ const std::string& s,
_Out_ sai_system_port_config_list_t& sysportconfiglist,
Expand Down Expand Up @@ -459,6 +462,10 @@ void sai_deserialize_outbound_ca_to_pa_entry(
_In_ const std::string &s,
_Out_ sai_outbound_ca_to_pa_entry_t& outbound_ca_to_pa_entry);

void sai_deserialize_flow_entry(
_In_ const std::string &s,
_Out_ sai_flow_entry_t& flow_entry);

void sai_deserialize_attr_value(
_In_ const std::string& s,
_In_ const sai_attr_metadata_t& meta,
Expand Down
64 changes: 64 additions & 0 deletions syncd/VendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,33 @@ sai_status_t VendorSai::bulkCreate(
object_statuses);
}

sai_status_t VendorSai::bulkCreate(
_In_ uint32_t object_count,
_In_ const sai_flow_entry_t* entries,
_In_ const uint32_t *attr_count,
_In_ const sai_attribute_t **attr_list,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

if (!m_apis.dash_flow_api->create_flow_entries)
{
SWSS_LOG_INFO("create_flow_entries is not supported");
return SAI_STATUS_NOT_SUPPORTED;
}

return m_apis.dash_flow_api->create_flow_entries(
object_count,
entries,
attr_count,
attr_list,
mode,
object_statuses);
}

// BULK REMOVE

sai_status_t VendorSai::bulkRemove(
Expand Down Expand Up @@ -1300,6 +1327,29 @@ sai_status_t VendorSai::bulkRemove(
object_statuses);
}

sai_status_t VendorSai::bulkRemove(
_In_ uint32_t object_count,
_In_ const sai_flow_entry_t *entries,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

if (!m_apis.dash_flow_api->remove_flow_entries)
{
SWSS_LOG_INFO("remove_flow_entries is not supported");
return SAI_STATUS_NOT_SUPPORTED;
}

return m_apis.dash_flow_api->remove_flow_entries(
object_count,
entries,
mode,
object_statuses);
}

// BULK SET

sai_status_t VendorSai::bulkSet(
Expand Down Expand Up @@ -1550,6 +1600,20 @@ sai_status_t VendorSai::bulkSet(
return SAI_STATUS_NOT_SUPPORTED;
}

sai_status_t VendorSai::bulkSet(
_In_ uint32_t object_count,
_In_ const sai_flow_entry_t *entries,
_In_ const sai_attribute_t *attr_list,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses)
{
MUTEX();
SWSS_LOG_ENTER();
VENDOR_CHECK_API_INITIALIZED();

return SAI_STATUS_NOT_SUPPORTED;
}

// NON QUAD API

sai_status_t VendorSai::flushFdbEntries(
Expand Down
Loading