diff --git a/meta/Meta.cpp b/meta/Meta.cpp index cecec4e86db4..ccb867f29154 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -3351,6 +3351,11 @@ void Meta::meta_generic_validation_post_remove( // no special action required break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + // no special action required + break; + default: META_LOG_THROW(md, "serialization type is not supported yet FIXME"); } @@ -4565,6 +4570,13 @@ sai_status_t Meta::meta_generic_validation_create( break; } + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + VALIDATION_LIST(md, value.sysportconfiglist); + break; + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + break; + default: META_LOG_THROW(md, "serialization type is not supported yet FIXME"); @@ -5196,6 +5208,13 @@ sai_status_t Meta::meta_generic_validation_set( VALIDATION_LIST(md, value.aclcapability.action_list); break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + VALIDATION_LIST(md, value.sysportconfiglist); + break; + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + break; + default: META_LOG_THROW(md, "serialization type is not supported yet FIXME"); @@ -5557,6 +5576,13 @@ sai_status_t Meta::meta_generic_validation_get( VALIDATION_LIST(md, value.aclcapability.action_list); break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + break; + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + VALIDATION_LIST(md, value.sysportconfiglist); + break; + default: // acl capability will is more complex since is in/out we need to check stage @@ -5798,6 +5824,13 @@ void Meta::meta_generic_validation_post_get( break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + break; + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + VALIDATION_LIST_GET(md, value.sysportconfiglist); + break; + default: META_LOG_THROW(md, "serialization type is not supported yet FIXME"); @@ -6679,6 +6712,11 @@ void Meta::meta_generic_validation_post_create( // no special action required break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + // no special action required + break; + default: META_LOG_THROW(md, "serialization type is not supported yet FIXME"); @@ -6906,6 +6944,11 @@ void Meta::meta_generic_validation_post_set( // no special action required break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + // no special action required + break; + default: META_LOG_THROW(md, "serialization type is not supported yet FIXME"); } diff --git a/meta/saiserialize.cpp b/meta/saiserialize.cpp index 672abcd97715..c1b6a7f8d8eb 100644 --- a/meta/saiserialize.cpp +++ b/meta/saiserialize.cpp @@ -400,6 +400,14 @@ sai_status_t transfer_attribute( RETURN_ON_ERROR(transfer_list(src_attr.value.aclcapability.action_list, dst_attr.value.aclcapability.action_list, countOnly)); break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + transfer_primitive(src_attr.value.sysportconfig, dst_attr.value.sysportconfig); + break; + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + RETURN_ON_ERROR(transfer_list(src_attr.value.sysportconfiglist, dst_attr.value.sysportconfiglist, countOnly)); + break; + default: return SAI_STATUS_NOT_IMPLEMENTED; } @@ -1398,6 +1406,73 @@ std::string sai_serialize_acl_capability( return mandatory + ":" + list; } +std::string sai_serialize_system_port_config( + _In_ const sai_attr_metadata_t &meta, + _In_ const sai_system_port_config_t &sysportconfig) +{ + SWSS_LOG_ENTER(); + + json j; + + j["port_id"] = sai_serialize_number(sysportconfig.port_id, false); + j["attached_switch_id"] = sai_serialize_number(sysportconfig.attached_switch_id, false); + j["attached_core_index"] = sai_serialize_number(sysportconfig.attached_core_index, false); + j["attached_core_port_index"] = sai_serialize_number(sysportconfig.attached_core_port_index, false); + j["speed"] = sai_serialize_number(sysportconfig.speed, false); + j["num_voq"] = sai_serialize_number(sysportconfig.num_voq, false); + + return j.dump(); +} + +json sai_serialize_system_port_cfg_list_item( + _In_ const sai_system_port_config_t &sysportconfig) +{ + SWSS_LOG_ENTER(); + + json j; + + j["port_id"] = sai_serialize_number(sysportconfig.port_id, false); + j["attached_switch_id"] = sai_serialize_number(sysportconfig.attached_switch_id, false); + j["attached_core_index"] = sai_serialize_number(sysportconfig.attached_core_index, false); + j["attached_core_port_index"] = sai_serialize_number(sysportconfig.attached_core_port_index, false); + j["speed"] = sai_serialize_number(sysportconfig.speed, false); + j["num_voq"] = sai_serialize_number(sysportconfig.num_voq, false); + + return j; +} + +std::string sai_serialize_system_port_config_list( + _In_ const sai_attr_metadata_t &meta, + _In_ const sai_system_port_config_list_t& sysportconfiglist, + _In_ bool countOnly) +{ + SWSS_LOG_ENTER(); + + json j; + + j["count"] = sysportconfiglist.count; + + if (sysportconfiglist.list == NULL || countOnly) + { + j["list"] = nullptr; + + return j.dump(); + } + + json arr = json::array(); + + for (uint32_t i = 0; i < sysportconfiglist.count; ++i) + { + json item = sai_serialize_system_port_cfg_list_item(sysportconfiglist.list[i]); + + arr.push_back(item); + } + + j["list"] = arr; + + return j.dump(); +} + std::string sai_serialize_attr_value( _In_ const sai_attr_metadata_t& meta, _In_ const sai_attribute_t &attr, @@ -1533,6 +1608,12 @@ std::string sai_serialize_attr_value( case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY: return sai_serialize_acl_capability(meta, attr.value.aclcapability, countOnly); + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + return sai_serialize_system_port_config(meta, attr.value.sysportconfig); + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + return sai_serialize_system_port_config_list(meta, attr.value.sysportconfiglist, countOnly); + default: SWSS_LOG_THROW("FATAL: invalid serialization type %d", meta.attrvaluetype); } @@ -2566,6 +2647,77 @@ void sai_deserialize_acl_capability( sai_deserialize_enum_list(list, &sai_metadata_enum_sai_acl_action_type_t, cap.action_list, false); } +void sai_deserialize_system_port_config( + _In_ const std::string& s, + _Out_ sai_system_port_config_t& sysportconfig) +{ + SWSS_LOG_ENTER(); + + json j = json::parse(s); + + sai_deserialize_number(j["port_id"], sysportconfig.port_id, false); + sai_deserialize_number(j["attached_switch_id"], sysportconfig.attached_switch_id, false); + sai_deserialize_number(j["attached_core_index"], sysportconfig.attached_core_index, false); + sai_deserialize_number(j["attached_core_port_index"], sysportconfig.attached_core_port_index, false); + sai_deserialize_number(j["speed"], sysportconfig.speed, false); + sai_deserialize_number(j["num_voq"], sysportconfig.num_voq, false); + +} + +void sai_deserialize_system_port_cfg_list_item( + _In_ const json& j, + _Out_ sai_system_port_config_t& sysportconfig) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_number(j["port_id"], sysportconfig.port_id, false); + sai_deserialize_number(j["attached_switch_id"], sysportconfig.attached_switch_id, false); + sai_deserialize_number(j["attached_core_index"], sysportconfig.attached_core_index, false); + sai_deserialize_number(j["attached_core_port_index"], sysportconfig.attached_core_port_index, false); + sai_deserialize_number(j["speed"], sysportconfig.speed, false); + sai_deserialize_number(j["num_voq"], sysportconfig.num_voq, false); +} + +void sai_deserialize_system_port_config_list( + _In_ const std::string& s, + _Out_ sai_system_port_config_list_t& sysportconfiglist, + _In_ bool countOnly) +{ + SWSS_LOG_ENTER(); + + json j = json::parse(s); + + sysportconfiglist.count = j["count"]; + + if (countOnly) + { + return; + } + + if (j["list"] == nullptr) + { + sysportconfiglist.list = NULL; + return; + } + + json arr = j["list"]; + + if (arr.size() != (size_t)sysportconfiglist.count) + { + SWSS_LOG_ERROR("system port config list count mismatch %lu vs %u", arr.size(), sysportconfiglist.count); + throw std::runtime_error("system port config list count mismatch"); + } + + sysportconfiglist.list = sai_alloc_n_of_ptr_type(sysportconfiglist.count, sysportconfiglist.list); + + for (uint32_t i = 0; i < sysportconfiglist.count; ++i) + { + const json& item = arr[i]; + + sai_deserialize_system_port_cfg_list_item(item, sysportconfiglist.list[i]); + } +} + void sai_deserialize_attr_value( _In_ const std::string& s, _In_ const sai_attr_metadata_t& meta, @@ -2704,6 +2856,12 @@ void sai_deserialize_attr_value( case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY: return sai_deserialize_acl_capability(s, attr.value.aclcapability); + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + return sai_deserialize_system_port_config(s, attr.value.sysportconfig); + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + return sai_deserialize_system_port_config_list(s, attr.value.sysportconfiglist, countOnly); + default: SWSS_LOG_THROW("deserialize type %d is not supportd yet FIXME", meta.attrvaluetype); } @@ -3269,6 +3427,13 @@ void sai_deserialize_free_attribute_value( sai_free_list(attr.value.aclcapability.action_list); break; + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG: + break; + + case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST: + sai_free_list(attr.value.sysportconfiglist); + break; + default: SWSS_LOG_THROW("unsupported type %d on deserialize free, FIXME", type); }