|
6 | 6 |
|
7 | 7 | #include "vppxlate/SaiIntfStats.h" |
8 | 8 |
|
| 9 | +#include "SwitchVppUtils.h" |
| 10 | + |
| 11 | +#include <vector> |
| 12 | + |
9 | 13 | using namespace saivs; |
10 | 14 |
|
11 | 15 | // TODO init vpp |
@@ -1038,7 +1042,26 @@ sai_status_t SwitchVpp::createPort( |
1038 | 1042 |
|
1039 | 1043 | auto sid = sai_serialize_object_id(object_id); |
1040 | 1044 |
|
1041 | | - CHECK_STATUS(create_internal(SAI_OBJECT_TYPE_PORT, sid, switch_id, attr_count, attr_list)); |
| 1045 | + const sai_attribute_value_t *oper_status; |
| 1046 | + uint32_t attr_index; |
| 1047 | + sai_status_t status = find_attrib_in_list(attr_count, attr_list, |
| 1048 | + SAI_PORT_ATTR_OPER_STATUS, &oper_status, &attr_index); |
| 1049 | + |
| 1050 | + if (status == SAI_STATUS_ITEM_NOT_FOUND) { |
| 1051 | + // SAI_PORT_ATTR_OPER_STATUS not found, create a copy of attr_list and add it |
| 1052 | + std::vector<sai_attribute_t> modified_attr_list(attr_list, attr_list + attr_count); |
| 1053 | + |
| 1054 | + // Add the missing SAI_PORT_ATTR_OPER_STATUS attribute |
| 1055 | + sai_attribute_t oper_status_attr; |
| 1056 | + oper_status_attr.id = SAI_PORT_ATTR_OPER_STATUS; |
| 1057 | + oper_status_attr.value.s32 = SAI_PORT_OPER_STATUS_UNKNOWN; |
| 1058 | + modified_attr_list.push_back(oper_status_attr); |
| 1059 | + |
| 1060 | + CHECK_STATUS(create_internal(SAI_OBJECT_TYPE_PORT, sid, switch_id, |
| 1061 | + static_cast<uint32_t>(modified_attr_list.size()), modified_attr_list.data())); |
| 1062 | + } else { |
| 1063 | + CHECK_STATUS(create_internal(SAI_OBJECT_TYPE_PORT, sid, switch_id, attr_count, attr_list)); |
| 1064 | + } |
1042 | 1065 |
|
1043 | 1066 | return create_port_dependencies(object_id); |
1044 | 1067 | } |
@@ -1436,7 +1459,7 @@ sai_status_t SwitchVpp::get( |
1436 | 1459 |
|
1437 | 1460 | if (it == objectHash.end()) |
1438 | 1461 | { |
1439 | | - SWSS_LOG_ERROR("not found %s:%s", |
| 1462 | + SWSS_LOG_INFO("not found %s:%s", |
1440 | 1463 | sai_serialize_object_type(objectType).c_str(), |
1441 | 1464 | serializedObjectId.c_str()); |
1442 | 1465 |
|
@@ -1815,3 +1838,28 @@ sai_status_t SwitchVpp::querySwitchHashAlgorithmCapability( |
1815 | 1838 |
|
1816 | 1839 | return SAI_STATUS_SUCCESS; |
1817 | 1840 | } |
| 1841 | + |
| 1842 | +sai_status_t SwitchVpp::refresh_read_only( |
| 1843 | + _In_ const sai_attr_metadata_t *meta, |
| 1844 | + _In_ sai_object_id_t object_id) |
| 1845 | +{ |
| 1846 | + SWSS_LOG_ENTER(); |
| 1847 | + |
| 1848 | + // Handle VPP-specific refresh read-only logic first |
| 1849 | + if (meta->objecttype == SAI_OBJECT_TYPE_BFD_SESSION) |
| 1850 | + { |
| 1851 | + switch (meta->attrid) |
| 1852 | + { |
| 1853 | + case SAI_BFD_SESSION_ATTR_STATE: |
| 1854 | + // VPP stores BFD session state in m_objectHash and will update it |
| 1855 | + // when BFD state changed. So we don't need to refresh. |
| 1856 | + return SAI_STATUS_SUCCESS; |
| 1857 | + |
| 1858 | + default: |
| 1859 | + break; |
| 1860 | + } |
| 1861 | + } |
| 1862 | + |
| 1863 | + // For all other cases, delegate to the base class implementation |
| 1864 | + return SwitchStateBase::refresh_read_only(meta, object_id); |
| 1865 | +} |
0 commit comments