Skip to content

Commit

Permalink
Merge branch 'master' into neighbor_bulk
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndancejic authored May 24, 2024
2 parents 1569b59 + 0adbe25 commit 17f7e38
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ libsairedis_la_SOURCES = \
sai_redis_ars.cpp \
sai_redis_ars_profile.cpp \
sai_redis_twamp.cpp \
sai_redis_poe.cpp \
sai_redis_dash_meter.cpp

libSaiRedis_a_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
Expand Down
1 change: 1 addition & 0 deletions lib/sai_redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ PRIVATE extern const sai_my_mac_api_t redis_my_mac_api;
PRIVATE extern const sai_ipsec_api_t redis_ipsec_api;
PRIVATE extern const sai_twamp_api_t redis_twamp_api;
PRIVATE extern const sai_dash_meter_api_t redis_dash_meter_api;
PRIVATE extern const sai_poe_api_t redis_poe_api;

PRIVATE extern std::shared_ptr<sairedis::SaiInterface> redis_sai;

Expand Down
1 change: 1 addition & 0 deletions lib/sai_redis_interfacequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static sai_apis_t redis_apis = {
API(ars),
API(ars_profile),
API(twamp),
API(poe),
API(bmtor),
API(dash_acl),
API(dash_direction_lookup),
Expand Down
12 changes: 12 additions & 0 deletions lib/sai_redis_poe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "sai_redis.h"

REDIS_GENERIC_QUAD(POE_DEVICE,poe_device);
REDIS_GENERIC_QUAD(POE_PSE,poe_pse);
REDIS_GENERIC_QUAD(POE_PORT,poe_port);

const sai_poe_api_t redis_poe_api = {

REDIS_GENERIC_QUAD_API(poe_device)
REDIS_GENERIC_QUAD_API(poe_pse)
REDIS_GENERIC_QUAD_API(poe_port)
};
122 changes: 114 additions & 8 deletions meta/SaiSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ sai_status_t transfer_attribute(
transfer_primitive(src_attr.value.u16, dst_attr.value.u16);
break;

// case SAI_ATTR_VALUE_TYPE_INT16:
// transfer_primitive(src_attr.value.s16, dst_attr.value.s16);
// break;
case SAI_ATTR_VALUE_TYPE_INT16:
transfer_primitive(src_attr.value.s16, dst_attr.value.s16);
break;

case SAI_ATTR_VALUE_TYPE_UINT32:
transfer_primitive(src_attr.value.u32, dst_attr.value.u32);
Expand Down Expand Up @@ -510,6 +510,10 @@ sai_status_t transfer_attribute(
RETURN_ON_ERROR(transfer_list(src_attr.value.aclchainlist, dst_attr.value.aclchainlist, countOnly));
break;

case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION:
transfer_primitive(src_attr.value.portpowerconsumption, dst_attr.value.portpowerconsumption);
break;

default:
SWSS_LOG_THROW("sai attr value %s is not implemented, FIXME", sai_serialize_attr_value_type(serialization_type).c_str());
}
Expand Down Expand Up @@ -1977,8 +1981,8 @@ std::string sai_serialize_attr_value(
case SAI_ATTR_VALUE_TYPE_JSON:
return sai_serialize_json(attr.value.json);

// case SAI_ATTR_VALUE_TYPE_INT16:
// return sai_serialize_number(attr.value.s16);
case SAI_ATTR_VALUE_TYPE_INT16:
return sai_serialize_number(attr.value.s16);

case SAI_ATTR_VALUE_TYPE_UINT32:
return sai_serialize_number(attr.value.u32);
Expand Down Expand Up @@ -2131,6 +2135,9 @@ std::string sai_serialize_attr_value(
case SAI_ATTR_VALUE_TYPE_IP_PREFIX_LIST:
return sai_serialize_ip_prefix_list(attr.value.ipprefixlist, countOnly);

case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION:
return sai_serialize_poe_port_power_consumption(attr.value.portpowerconsumption);

default:
SWSS_LOG_THROW("sai attr value type %s is not implemented, FIXME", sai_serialize_attr_value_type(meta.attrvaluetype).c_str());
}
Expand Down Expand Up @@ -2779,6 +2786,51 @@ std::string sai_serialize_redis_link_event_damping_aied_config(
return j.dump();
}

std::string sai_serialize_poe_port_active_channel_type(
_In_ const sai_poe_port_active_channel_type_t value)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(value, &sai_metadata_enum_sai_poe_port_active_channel_type_t);
}

std::string sai_serialize_poe_port_class_method_type(
_In_ const sai_poe_port_class_method_type_t value)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(value, &sai_metadata_enum_sai_poe_port_class_method_type_t);
}

std::string sai_serialzie_poe_port_signature_type(
_In_ const sai_poe_port_signature_type_t value)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(value, &sai_metadata_enum_sai_poe_port_signature_type_t);
}

std::string sai_serialize_poe_port_power_consumption(
_In_ const sai_poe_port_power_consumption_t& value)
{
SWSS_LOG_ENTER();

json j;

j["active_channel"] = sai_serialize_poe_port_active_channel_type(value.active_channel);
j["voltage"] = sai_serialize_number(value.voltage, false);
j["current"] = sai_serialize_number(value.current, false);
j["consumption"] = sai_serialize_number(value.consumption, false);
j["signature_type"] = sai_serialzie_poe_port_signature_type(value.signature_type);
j["class_method"] = sai_serialize_poe_port_class_method_type(value.class_method);
j["measured_class_a"] = sai_serialize_number(value.measured_class_a, false);
j["assigned_class_a"] = sai_serialize_number(value.assigned_class_a, false);
j["measured_class_b"] = sai_serialize_number(value.measured_class_b, false);
j["assigned_class_b"] = sai_serialize_number(value.assigned_class_b, false);

return j.dump();
}

// deserialize

void sai_deserialize_bool(
Expand Down Expand Up @@ -3913,8 +3965,8 @@ void sai_deserialize_attr_value(
case SAI_ATTR_VALUE_TYPE_JSON:
return sai_deserialize_json(s, attr.value.json);

// case SAI_ATTR_VALUE_TYPE_INT16:
// return sai_deserialize_number(s, attr.value.s16);
case SAI_ATTR_VALUE_TYPE_INT16:
return sai_deserialize_number(s, attr.value.s16);

case SAI_ATTR_VALUE_TYPE_UINT32:
return sai_deserialize_number(s, attr.value.u32);
Expand Down Expand Up @@ -4065,8 +4117,12 @@ void sai_deserialize_attr_value(
case SAI_ATTR_VALUE_TYPE_IP_PREFIX_LIST:
return sai_deserialize_ip_prefix_list(s, attr.value.ipprefixlist, countOnly);

case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION:
return sai_deserialize_poe_port_power_consumption(s, attr.value.portpowerconsumption);

default:
SWSS_LOG_THROW("deserialize type %d is not supported yet FIXME", meta.attrvaluetype);
SWSS_LOG_THROW("deserialize type %s is not supported yet FIXME",
sai_serialize_attr_value_type(meta.attrvaluetype).c_str());
}
}

Expand Down Expand Up @@ -5183,11 +5239,61 @@ void sai_deserialize_free_attribute_value(
sai_free_list(attr.value.ipprefixlist);
break;

case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION:
break;

default:
SWSS_LOG_THROW("sai attr value %s is not implemented, FIXME", sai_serialize_attr_value_type(type).c_str());
}
}

void sai_deserialize_poe_port_active_channel_type(
_In_ const std::string& s,
_Out_ sai_poe_port_active_channel_type_t& value)
{
SWSS_LOG_ENTER();

sai_deserialize_enum(s, &sai_metadata_enum_sai_poe_port_active_channel_type_t, (int32_t&)value);
}

void sai_deserialize_poe_port_class_method_type(
_In_ const std::string& s,
_Out_ sai_poe_port_class_method_type_t& value)
{
SWSS_LOG_ENTER();

sai_deserialize_enum(s, &sai_metadata_enum_sai_poe_port_class_method_type_t, (int32_t&)value);
}

void sai_deserialzie_poe_port_signature_type(
_In_ const std::string& s,
_Out_ sai_poe_port_signature_type_t& value)
{
SWSS_LOG_ENTER();

sai_deserialize_enum(s, &sai_metadata_enum_sai_poe_port_signature_type_t, (int32_t&)value);
}

void sai_deserialize_poe_port_power_consumption(
_In_ const std::string& s,
_Out_ sai_poe_port_power_consumption_t& value)
{
SWSS_LOG_ENTER();

json j = json::parse(s);

sai_deserialize_poe_port_active_channel_type(j["active_channel"], value.active_channel);
sai_deserialize_number(j["voltage"], value.voltage);
sai_deserialize_number(j["current"], value.current);
sai_deserialize_number(j["consumption"], value.consumption);
sai_deserialize_poe_port_class_method_type(j["class_method"], value.class_method);
sai_deserialzie_poe_port_signature_type(j["signature_type"],value.signature_type);
sai_deserialize_number(j["measured_class_a"], value.measured_class_a);
sai_deserialize_number(j["assigned_class_a"], value.assigned_class_a);
sai_deserialize_number(j["measured_class_b"], value.measured_class_b);
sai_deserialize_number(j["assigned_class_b"], value.assigned_class_b);
}

// deserialize free notifications

void sai_deserialize_free_fdb_event(
Expand Down
7 changes: 7 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ std::string sai_serialize_qos_map_item(
std::string sai_serialize_twamp_session_stat(
_In_ const sai_twamp_session_stat_t counter);

std::string sai_serialize_poe_port_power_consumption(
_In_ const sai_poe_port_power_consumption_t& pppc);

// serialize notifications

std::string sai_serialize_fdb_event_ntf(
Expand Down Expand Up @@ -499,6 +502,10 @@ void sai_deserialize_chardata(
_In_ const std::string& s,
_Out_ char chardata[32]);

void sai_deserialize_poe_port_power_consumption(
_In_ const std::string& s,
_Out_ sai_poe_port_power_consumption_t& pppc);

// deserialize notifications

void sai_deserialize_fdb_event_ntf(
Expand Down
1 change: 1 addition & 0 deletions unittest/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ testslibsairedis_SOURCES = main_libsairedis.cpp \
test_sai_redis_hostif.cpp \
test_sai_redis_wred.cpp \
test_sai_redis_ars.cpp \
test_sai_redis_poe.cpp \
test_sai_redis_ars_profile.cpp

testslibsairedis_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
Expand Down
33 changes: 33 additions & 0 deletions unittest/lib/test_sai_redis_poe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <gtest/gtest.h>

extern "C" {
#include "sai.h"
}

#include "swss/logger.h"

TEST(libsairedis, poe)
{
sai_poe_api_t *api = nullptr;

sai_api_query(SAI_API_POE, (void**)&api);

EXPECT_NE(api, nullptr);

sai_object_id_t id;

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_device(&id,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_device(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_device_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_device_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_pse(&id,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_pse(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_pse_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_pse_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_port(&id,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_port(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_port_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_port_attribute(0,0,0));
}
1 change: 1 addition & 0 deletions unittest/vslib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ testslibsaivs_SOURCES = main_libsaivs.cpp \
test_sai_vs_hostif.cpp \
test_sai_vs_wred.cpp \
test_sai_vs_ars.cpp \
test_sai_vs_poe.cpp \
test_sai_vs_ars_profile.cpp

testslibsaivs_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
Expand Down
33 changes: 33 additions & 0 deletions unittest/vslib/test_sai_vs_poe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <gtest/gtest.h>

extern "C" {
#include "sai.h"
}

#include "swss/logger.h"

TEST(libsairedis, poe)
{
sai_poe_api_t *api = nullptr;

sai_api_query(SAI_API_POE, (void**)&api);

EXPECT_NE(api, nullptr);

sai_object_id_t id;

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_device(&id,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_device(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_device_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_device_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_pse(&id,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_pse(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_pse_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_pse_attribute(0,0,0));

EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_port(&id,0,0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_port(0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_port_attribute(0,0));
EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_port_attribute(0,0,0));
}
1 change: 1 addition & 0 deletions vslib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ libsaivs_la_SOURCES = \
sai_vs_ars.cpp \
sai_vs_ars_profile.cpp \
sai_vs_twamp.cpp \
sai_vs_poe.cpp \
sai_vs_dash_meter.cpp

libSaiVS_a_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
Expand Down
1 change: 1 addition & 0 deletions vslib/sai_vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ PRIVATE extern const sai_my_mac_api_t vs_my_mac_api;
PRIVATE extern const sai_ipsec_api_t vs_ipsec_api;
PRIVATE extern const sai_twamp_api_t vs_twamp_api;
PRIVATE extern const sai_dash_meter_api_t vs_dash_meter_api;
PRIVATE extern const sai_poe_api_t vs_poe_api;

PRIVATE extern std::shared_ptr<sairedis::SaiInterface> vs_sai;

Expand Down
1 change: 1 addition & 0 deletions vslib/sai_vs_interfacequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static sai_apis_t vs_apis = {
API(ars),
API(ars_profile),
API(twamp),
API(poe),
API(bmtor),
API(dash_acl),
API(dash_direction_lookup),
Expand Down
12 changes: 12 additions & 0 deletions vslib/sai_vs_poe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "sai_vs.h"

VS_GENERIC_QUAD(POE_DEVICE,poe_device);
VS_GENERIC_QUAD(POE_PSE,poe_pse);
VS_GENERIC_QUAD(POE_PORT,poe_port);

const sai_poe_api_t vs_poe_api = {

VS_GENERIC_QUAD_API(poe_device)
VS_GENERIC_QUAD_API(poe_pse)
VS_GENERIC_QUAD_API(poe_port)
};

0 comments on commit 17f7e38

Please sign in to comment.