diff --git a/syncd/ComparisonLogic.cpp b/syncd/ComparisonLogic.cpp index 99f45c23950c..0f1cef14ea32 100644 --- a/syncd/ComparisonLogic.cpp +++ b/syncd/ComparisonLogic.cpp @@ -2333,6 +2333,7 @@ void ComparisonLogic::populateExistingObjects( auto coldBootDiscoveredVids = m_switch->getColdBootDiscoveredVids(); auto warmBootDiscoveredVids = m_switch->getWarmBootDiscoveredVids(); + auto warmBootNewDiscoveredVids = m_switch->getWarmBootNewDiscoveredVids(); /* * If some objects that are existing objects on switch are not present in @@ -2455,6 +2456,22 @@ void ComparisonLogic::populateExistingObjects( } } + if (warmBootNewDiscoveredVids.size()) + { + // We have some new discovered VIDs after warm boot, we need to + // create temporary objects from them, so comparison logic will not + // get confused and will not remove them. + // + // TODO: there could be potential issue here, when user will remove + // one of the new discovered object in init view phase, then we + // can't put that object to DB, and it should be removed. + + performColdCheck = false; + + SWSS_LOG_NOTICE("creating and matching %zu new discovered WARM BOOT objects", + warmBootNewDiscoveredVids.size()); + } + if (performColdCheck && coldBootDiscoveredVids.find(vid) == coldBootDiscoveredVids.end()) { SWSS_LOG_INFO("object is not on default existing list: %s RID %s VID %s", diff --git a/syncd/SaiSwitch.cpp b/syncd/SaiSwitch.cpp index 09194df0028b..839969f3b279 100644 --- a/syncd/SaiSwitch.cpp +++ b/syncd/SaiSwitch.cpp @@ -69,8 +69,6 @@ SaiSwitch::SaiSwitch( helperLoadColdVids(); - helperPopulateWarmBootVids(); - if (getSwitchType() == SAI_SWITCH_TYPE_NPU) { saiGetMacAddress(m_default_mac_address); @@ -899,46 +897,6 @@ sai_object_id_t SaiSwitch::getDefaultValueForOidAttr( return ita->second; } -void SaiSwitch::helperPopulateWarmBootVids() -{ - SWSS_LOG_ENTER(); - - if (!m_warmBoot) - return; - - SWSS_LOG_NOTICE("populate warm boot VIDs"); - - // It may happen, that after warm boot some new oids were discovered that - // were not present on warm shutdown, this may happen during vendor SAI - // update and for example introducing some new default objects on switch or - // queues on cpu. In this case, translator will create new VID/RID pair on - // database and local memory. - - auto rid2vid = getRidToVidMap(); - - for (sai_object_id_t rid: m_discovered_rids) - { - sai_object_id_t vid = m_translator->translateRidToVid(rid, m_switch_vid); - - m_warmBootDiscoveredVids.insert(vid); - - if (rid2vid.find(rid) == rid2vid.end()) - { - SWSS_LOG_NOTICE("spotted new RID %s (VID %s) on WARM BOOT", - sai_serialize_object_id(rid).c_str(), - sai_serialize_object_id(vid).c_str()); - - m_warmBootNewDiscoveredVids.insert(vid); - - // this means that some new objects were discovered but they are - // not present in current ASIC_VIEW, and we need to create dummy - // entries for them - - redisSetDummyAsicStateForRealObjectId(rid); - } - } -} - std::vector SaiSwitch::saiGetPortLanes( _In_ sai_object_id_t port_rid) { @@ -1088,6 +1046,21 @@ void SaiSwitch::collectPortRelatedObjects( related.insert(objlist.begin(), objlist.end()); } + // treat port serdes as related object + + sai_attribute_t attr; + + attr.id = SAI_PORT_ATTR_PORT_SERDES_ID; + + auto status = m_vendorSai->get(SAI_OBJECT_TYPE_PORT, portRid, 1, &attr); + + if (status == SAI_STATUS_SUCCESS && attr.value.oid != SAI_NULL_OBJECT_ID) + { + // some platforms not support PORT SERDES, so get it only on success + + related.insert(attr.value.oid); + } + SWSS_LOG_NOTICE("obtained %zu port %s related RIDs", related.size(), sai_serialize_object_id(portRid).c_str()); @@ -1165,44 +1138,61 @@ void SaiSwitch::checkWarmBootDiscoveredRids() { SWSS_LOG_ENTER(); - /* + if (!m_warmBoot) + { + return; + } + + SWSS_LOG_NOTICE("check warm boot RIDs"); + + /** + * It may happen, that after warm boot some new oids were discovered that + * were not present on warm shutdown, this may happen during vendor SAI + * update and for example introducing some new default objects on switch or + * queues on cpu. In this case, translator will create new VID/RID pair on + * database and local memory. + * * After switch was created, rid discovery method was called, and all * discovered RIDs should be present in current RID2VID map in redis - * database. If any RID is missing, then ether there is bug in vendor code, - * and after warm boot some RID values changed or we have a bug and forgot - * to put rid/vid pair to redis. + * database. If any RID is missing, then ether: + * - there is bug in vendor code and after warm boot some RID values changed + * - or we have a bug and forgot to put rid/vid pair to redis + * - or we new objects was actually introduced with new firmware like for + * example PORT_SERDES * * Assumption here is that during warm boot ASIC state will not change. */ auto rid2vid = getRidToVidMap(); - bool success = true; - - for (auto rid: getDiscoveredRids()) + for (sai_object_id_t rid: getDiscoveredRids()) { - if (rid2vid.find(rid) != rid2vid.end()) - continue; + sai_object_id_t vid = m_translator->translateRidToVid(rid, m_switch_vid); + + m_warmBootDiscoveredVids.insert(vid); - auto ot = m_vendorSai->objectTypeQuery(rid); + if (rid2vid.find(rid) == rid2vid.end()) + { + auto ot = m_vendorSai->objectTypeQuery(rid); - // SWSS_LOG_ERROR("RID %s (%s) is missing from current RID2VID map after WARM boot!", - SWSS_LOG_WARN("RID %s (%s) is missing from current RID2VID map after WARM boot!", - sai_serialize_object_id(rid).c_str(), - sai_serialize_object_type(ot).c_str()); + SWSS_LOG_NOTICE("spotted new RID %s missing from current RID2VID (new VID %s) (%s) on WARM BOOT", + sai_serialize_object_id(rid).c_str(), + sai_serialize_object_id(vid).c_str(), + sai_serialize_object_type(ot).c_str()); - // XXX workaround, put discovered object in database + m_warmBootNewDiscoveredVids.insert(vid); - redisSetDummyAsicStateForRealObjectId(rid); + // this means that some new objects were discovered but they are + // not present in current ASIC_VIEW, and we need to create dummy + // entries for them - success = false; + redisSetDummyAsicStateForRealObjectId(rid); + } } - if (!success) + if (m_warmBootNewDiscoveredVids.size()) { - // XXX workaround - //SWSS_LOG_THROW("FATAL, some discovered RIDs are not present in current RID2VID map, bug"); - SWSS_LOG_ERROR("FATAL, some discovered RIDs are not present in current RID2VID map, WORKAROUND, inserting them to ASIC_DB"); + SWSS_LOG_NOTICE("discovered %zu new RIDs on WARM BOOT, new firmware? or bug", m_warmBootNewDiscoveredVids.size()); } SWSS_LOG_NOTICE("all discovered RIDs are present in current RID2VID map for switch VID %s", diff --git a/syncd/SaiSwitch.h b/syncd/SaiSwitch.h index ee372e8acba8..523e1fe1de1c 100644 --- a/syncd/SaiSwitch.h +++ b/syncd/SaiSwitch.h @@ -286,8 +286,6 @@ namespace syncd void helperLoadColdVids(); - void helperPopulateWarmBootVids(); - /* * Other Methods. */ diff --git a/tests/BCM56850.pl b/tests/BCM56850.pl index 842b19bf790a..74d6a3a10dc7 100755 --- a/tests/BCM56850.pl +++ b/tests/BCM56850.pl @@ -705,8 +705,54 @@ sub test_buffer_profile_get play "buffer_profile_get_B.rec"; } +sub test_brcm_warm_new_object_port_serdes +{ + fresh_start; + + play "empty_sw.rec"; + + print "port serdes objects in ASIC_DB: "; + print `redis-cli -n 1 keys "*_SERDES*" | wc -l`; + + request_warm_shutdown; + + # remove port serdes from asic db to simulate + # previous boot didn't contained serdes objects + + print "port serdes entries (objects and attributes) in sai_warmboot.bin: "; + print `cat sai_warmboot.bin | grep _SERDES_| wc -l`; + + print "removed port serdes objects from ASIC_DB: "; + print `redis-cli -n 1 --scan --pattern '*SERDES*' |xargs redis-cli -n 1 DEL`; + + # need to handle rid2vid map + + print "removed port serdes from VIDTORID map: "; + print `redis-cli -n 1 HKEYS VIDTORID |grep oid:0x5700 | xargs redis-cli -n 1 HDEL VIDTORID`; + print "removed remove serdes from RIDTOVID map: "; + print `redis-cli -n 1 HKEYS RIDTOVID |grep oid:0x5700 | xargs redis-cli -n 1 HDEL RIDTOVID`; + + start_syncd_warm; + + play "empty_sw.rec", 0; + + print "check ASIC_DB for serdes\n"; + print "RIDTOVID: ", `redis-cli -n 1 HKEYS RIDTOVID |grep oid:0x5700 |wc -l`; + print "VIDTORID: ", `redis-cli -n 1 HKEYS VIDTORID |grep oid:0x5700 |wc -l`; + print "ASIC_DB: ", `redis-cli -n 1 keys "*_SERDES*"| wc -l`; +} + +sub test_remove_port_serdes +{ + fresh_start; + + play "test_remove_port_serdes.rec"; +} + # RUN TESTS +test_remove_port_serdes; +test_brcm_warm_new_object_port_serdes; test_buffer_profile_get; test_multi_switch_key; test_ignore_attributes; diff --git a/tests/BCM56850/remove_create_port.rec b/tests/BCM56850/remove_create_port.rec index 2c0c4c38001f..854b335a60ba 100644 --- a/tests/BCM56850/remove_create_port.rec +++ b/tests/BCM56850/remove_create_port.rec @@ -11,6 +11,9 @@ 2018-08-06.22:34:50.355829|G|SAI_STATUS_SUCCESS|SAI_BRIDGE_ATTR_PORT_LIST=32:oid:0x3a000000000002,oid:0x3a000000000003,oid:0x3a000000000004,oid:0x3a000000000005,oid:0x3a000000000006,oid:0x3a000000000007,oid:0x3a000000000008,oid:0x3a000000000009,oid:0x3a00000000000a,oid:0x3a00000000000b,oid:0x3a00000000000c,oid:0x3a00000000000d,oid:0x3a00000000000e,oid:0x3a00000000000f,oid:0x3a000000000010,oid:0x3a000000000011,oid:0x3a000000000012,oid:0x3a000000000013,oid:0x3a000000000014,oid:0x3a000000000015,oid:0x3a000000000016,oid:0x3a000000000017,oid:0x3a000000000018,oid:0x3a000000000019,oid:0x3a00000000001a,oid:0x3a00000000001b,oid:0x3a00000000001c,oid:0x3a00000000001d,oid:0x3a00000000001e,oid:0x3a00000000001f,oid:0x3a000000000020,oid:0x3a000000000021 2018-08-06.22:34:50.347983|r|SAI_OBJECT_TYPE_VLAN_MEMBER:oid:0x27000000000002 2018-08-06.22:34:50.360742|r|SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000000002 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002 2017-06-14.01:56:05.520538|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_LIST=31:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 2017-06-14.01:56:05.525938|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST=31:oid:0x1000000000003,oid:0x1000000000004,oid:0x1000000000005,oid:0x1000000000006,oid:0x1000000000007,oid:0x1000000000008,oid:0x1000000000009,oid:0x100000000000a,oid:0x100000000000b,oid:0x100000000000c,oid:0x100000000000d,oid:0x100000000000e,oid:0x100000000000f,oid:0x1000000000010,oid:0x1000000000011,oid:0x1000000000012,oid:0x1000000000013,oid:0x1000000000014,oid:0x1000000000015,oid:0x1000000000016,oid:0x1000000000017,oid:0x1000000000018,oid:0x1000000000019,oid:0x100000000001a,oid:0x100000000001b,oid:0x100000000001c,oid:0x100000000001d,oid:0x100000000001e,oid:0x100000000001f,oid:0x1000000000020,oid:0x1000000000021 diff --git a/tests/BCM56850/remove_port.rec b/tests/BCM56850/remove_port.rec index df81c4067f1b..ee354500b124 100644 --- a/tests/BCM56850/remove_port.rec +++ b/tests/BCM56850/remove_port.rec @@ -21,14 +21,29 @@ 2018-08-06.22:34:50.355829|G|SAI_STATUS_SUCCESS|SAI_BRIDGE_ATTR_PORT_LIST=32:oid:0x3a000000000002,oid:0x3a000000000003,oid:0x3a000000000004,oid:0x3a000000000005,oid:0x3a000000000006,oid:0x3a000000000007,oid:0x3a000000000008,oid:0x3a000000000009,oid:0x3a00000000000a,oid:0x3a00000000000b,oid:0x3a00000000000c,oid:0x3a00000000000d,oid:0x3a00000000000e,oid:0x3a00000000000f,oid:0x3a000000000010,oid:0x3a000000000011,oid:0x3a000000000012,oid:0x3a000000000013,oid:0x3a000000000014,oid:0x3a000000000015,oid:0x3a000000000016,oid:0x3a000000000017,oid:0x3a000000000018,oid:0x3a000000000019,oid:0x3a00000000001a,oid:0x3a00000000001b,oid:0x3a00000000001c,oid:0x3a00000000001d,oid:0x3a00000000001e,oid:0x3a00000000001f,oid:0x3a000000000020,oid:0x3a000000000021 2018-08-06.22:34:50.347983|r|SAI_OBJECT_TYPE_VLAN_MEMBER:oid:0x27000000000002 2018-08-06.22:34:50.360742|r|SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000000002 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002 2017-06-14.01:56:11.535437|c|SAI_OBJECT_TYPE_PORT:oid:0x1000000000022|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:202 2017-06-14.01:56:11.535437|c|SAI_OBJECT_TYPE_PORT:oid:0x1000000000023|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:203 2017-06-14.01:56:11.535437|c|SAI_OBJECT_TYPE_PORT:oid:0x1000000000024|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:204 2017-06-14.01:56:11.535437|c|SAI_OBJECT_TYPE_PORT:oid:0x1000000000025|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:205 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000022|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000022 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000023|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000023 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000024|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000024 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000025|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000025 2017-06-14.01:56:06.151337|a|APPLY_VIEW 2017-06-14.01:56:06.156740|A|SAI_STATUS_SUCCESS diff --git a/tests/BCM56850/test_remove_port_serdes.rec b/tests/BCM56850/test_remove_port_serdes.rec new file mode 100644 index 000000000000..94ff9360d8af --- /dev/null +++ b/tests/BCM56850/test_remove_port_serdes.rec @@ -0,0 +1,20 @@ +2017-06-14.01:55:46.541806|#|recording on: ./sairedis.2017-06-14.01:55:46.541389.rec +2017-06-14.01:55:46.543987|a|INIT_VIEW +2017-06-14.01:55:46.551164|A|SAI_STATUS_SUCCESS +2017-06-14.01:55:46.555975|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true +2017-06-14.01:56:05.520538|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 +2017-06-14.01:56:05.525938|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST=32:oid:0x1000000000002,oid:0x1000000000003,oid:0x1000000000004,oid:0x1000000000005,oid:0x1000000000006,oid:0x1000000000007,oid:0x1000000000008,oid:0x1000000000009,oid:0x100000000000a,oid:0x100000000000b,oid:0x100000000000c,oid:0x100000000000d,oid:0x100000000000e,oid:0x100000000000f,oid:0x1000000000010,oid:0x1000000000011,oid:0x1000000000012,oid:0x1000000000013,oid:0x1000000000014,oid:0x1000000000015,oid:0x1000000000016,oid:0x1000000000017,oid:0x1000000000018,oid:0x1000000000019,oid:0x100000000001a,oid:0x100000000001b,oid:0x100000000001c,oid:0x100000000001d,oid:0x100000000001e,oid:0x100000000001f,oid:0x1000000000020,oid:0x1000000000021 +2018-08-06.22:34:50.344893|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_DEFAULT_1Q_BRIDGE_ID=oid:0x0|SAI_SWITCH_ATTR_DEFAULT_VLAN_ID=oid:0x0 +2018-08-06.22:34:50.345605|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_DEFAULT_1Q_BRIDGE_ID=oid:0x39000000000001|SAI_SWITCH_ATTR_DEFAULT_VLAN_ID=oid:0x26000000000001 +2018-08-06.22:34:50.345660|g|SAI_OBJECT_TYPE_VLAN:oid:0x26000000000001|SAI_VLAN_ATTR_MEMBER_LIST=32:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 +2018-08-06.22:34:50.347858|G|SAI_STATUS_SUCCESS|SAI_VLAN_ATTR_MEMBER_LIST=32:oid:0x27000000000002,oid:0x27000000000003,oid:0x27000000000004,oid:0x27000000000005,oid:0x27000000000006,oid:0x27000000000007,oid:0x27000000000008,oid:0x27000000000009,oid:0x2700000000000a,oid:0x2700000000000b,oid:0x2700000000000c,oid:0x2700000000000d,oid:0x2700000000000e,oid:0x2700000000000f,oid:0x27000000000010,oid:0x27000000000011,oid:0x27000000000012,oid:0x27000000000013,oid:0x27000000000014,oid:0x27000000000015,oid:0x27000000000016,oid:0x27000000000017,oid:0x27000000000018,oid:0x27000000000019,oid:0x2700000000001a,oid:0x2700000000001b,oid:0x2700000000001c,oid:0x2700000000001d,oid:0x2700000000001e,oid:0x2700000000001f,oid:0x27000000000020,oid:0x27000000000021 +2018-08-06.22:34:50.351789|g|SAI_OBJECT_TYPE_BRIDGE:oid:0x39000000000001|SAI_BRIDGE_ATTR_PORT_LIST=32:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 +2018-08-06.22:34:50.355829|G|SAI_STATUS_SUCCESS|SAI_BRIDGE_ATTR_PORT_LIST=32:oid:0x3a000000000002,oid:0x3a000000000003,oid:0x3a000000000004,oid:0x3a000000000005,oid:0x3a000000000006,oid:0x3a000000000007,oid:0x3a000000000008,oid:0x3a000000000009,oid:0x3a00000000000a,oid:0x3a00000000000b,oid:0x3a00000000000c,oid:0x3a00000000000d,oid:0x3a00000000000e,oid:0x3a00000000000f,oid:0x3a000000000010,oid:0x3a000000000011,oid:0x3a000000000012,oid:0x3a000000000013,oid:0x3a000000000014,oid:0x3a000000000015,oid:0x3a000000000016,oid:0x3a000000000017,oid:0x3a000000000018,oid:0x3a000000000019,oid:0x3a00000000001a,oid:0x3a00000000001b,oid:0x3a00000000001c,oid:0x3a00000000001d,oid:0x3a00000000001e,oid:0x3a00000000001f,oid:0x3a000000000020,oid:0x3a000000000021 +2018-08-06.22:34:50.347983|r|SAI_OBJECT_TYPE_VLAN_MEMBER:oid:0x27000000000002 +2018-08-06.22:34:50.360742|r|SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000000002 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 +2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002 +2017-06-14.01:56:06.151337|a|APPLY_VIEW +2017-06-14.01:56:06.156740|A|SAI_STATUS_SUCCESS diff --git a/tests/BCM56850/wb_port_create_a.rec b/tests/BCM56850/wb_port_create_a.rec index fa5282e229d4..17e198251bf1 100644 --- a/tests/BCM56850/wb_port_create_a.rec +++ b/tests/BCM56850/wb_port_create_a.rec @@ -11,6 +11,9 @@ 2018-08-06.22:34:50.355829|G|SAI_STATUS_SUCCESS|SAI_BRIDGE_ATTR_PORT_LIST=32:oid:0x3a000000000002,oid:0x3a000000000003,oid:0x3a000000000004,oid:0x3a000000000005,oid:0x3a000000000006,oid:0x3a000000000007,oid:0x3a000000000008,oid:0x3a000000000009,oid:0x3a00000000000a,oid:0x3a00000000000b,oid:0x3a00000000000c,oid:0x3a00000000000d,oid:0x3a00000000000e,oid:0x3a00000000000f,oid:0x3a000000000010,oid:0x3a000000000011,oid:0x3a000000000012,oid:0x3a000000000013,oid:0x3a000000000014,oid:0x3a000000000015,oid:0x3a000000000016,oid:0x3a000000000017,oid:0x3a000000000018,oid:0x3a000000000019,oid:0x3a00000000001a,oid:0x3a00000000001b,oid:0x3a00000000001c,oid:0x3a00000000001d,oid:0x3a00000000001e,oid:0x3a00000000001f,oid:0x3a000000000020,oid:0x3a000000000021 2018-08-06.22:34:50.347983|r|SAI_OBJECT_TYPE_VLAN_MEMBER:oid:0x27000000000002 2018-08-06.22:34:50.360742|r|SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000000002 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002 2017-06-14.01:56:11.535437|c|SAI_OBJECT_TYPE_PORT:oid:0x1000000000022|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:202 2017-06-14.01:56:11.535437|c|SAI_OBJECT_TYPE_PORT:oid:0x1000000000023|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:203 diff --git a/tests/BCM56850/wb_port_remove_a.rec b/tests/BCM56850/wb_port_remove_a.rec index 01f594fcfbee..54449c9a1b13 100644 --- a/tests/BCM56850/wb_port_remove_a.rec +++ b/tests/BCM56850/wb_port_remove_a.rec @@ -11,6 +11,9 @@ 2018-08-06.22:34:50.355829|G|SAI_STATUS_SUCCESS|SAI_BRIDGE_ATTR_PORT_LIST=32:oid:0x3a000000000002,oid:0x3a000000000003,oid:0x3a000000000004,oid:0x3a000000000005,oid:0x3a000000000006,oid:0x3a000000000007,oid:0x3a000000000008,oid:0x3a000000000009,oid:0x3a00000000000a,oid:0x3a00000000000b,oid:0x3a00000000000c,oid:0x3a00000000000d,oid:0x3a00000000000e,oid:0x3a00000000000f,oid:0x3a000000000010,oid:0x3a000000000011,oid:0x3a000000000012,oid:0x3a000000000013,oid:0x3a000000000014,oid:0x3a000000000015,oid:0x3a000000000016,oid:0x3a000000000017,oid:0x3a000000000018,oid:0x3a000000000019,oid:0x3a00000000001a,oid:0x3a00000000001b,oid:0x3a00000000001c,oid:0x3a00000000001d,oid:0x3a00000000001e,oid:0x3a00000000001f,oid:0x3a000000000020,oid:0x3a000000000021 2018-08-06.22:34:50.347983|r|SAI_OBJECT_TYPE_VLAN_MEMBER:oid:0x27000000000002 2018-08-06.22:34:50.360742|r|SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000000002 +2022-02-18.20:30:58.867607|g|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x0 +2022-02-18.20:30:58.868642|G|SAI_STATUS_SUCCESS|SAI_PORT_ATTR_PORT_SERDES_ID=oid:0x570000000005a7 +2022-02-18.20:30:58.868723|r|SAI_OBJECT_TYPE_PORT_SERDES:oid:0x570000000005a7 2017-06-14.01:56:11.535437|r|SAI_OBJECT_TYPE_PORT:oid:0x1000000000002 2017-06-14.01:56:05.520538|g|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_PORT_LIST=31:oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0,oid:0x0 2017-06-14.01:56:05.525938|G|SAI_STATUS_SUCCESS|SAI_SWITCH_ATTR_PORT_LIST=31:oid:0x1000000000003,oid:0x1000000000004,oid:0x1000000000005,oid:0x1000000000006,oid:0x1000000000007,oid:0x1000000000008,oid:0x1000000000009,oid:0x100000000000a,oid:0x100000000000b,oid:0x100000000000c,oid:0x100000000000d,oid:0x100000000000e,oid:0x100000000000f,oid:0x1000000000010,oid:0x1000000000011,oid:0x1000000000012,oid:0x1000000000013,oid:0x1000000000014,oid:0x1000000000015,oid:0x1000000000016,oid:0x1000000000017,oid:0x1000000000018,oid:0x1000000000019,oid:0x100000000001a,oid:0x100000000001b,oid:0x100000000001c,oid:0x100000000001d,oid:0x100000000001e,oid:0x100000000001f,oid:0x1000000000020,oid:0x1000000000021 diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index f0720a002056..51b892f5043c 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -353,6 +353,8 @@ SCs sdk SDK selectable +serdes +SERDES setBuffered setMinPrio setPortCounterList diff --git a/vslib/SwitchBCM56850.cpp b/vslib/SwitchBCM56850.cpp index a2880a426943..3ff0d520ca0b 100644 --- a/vslib/SwitchBCM56850.cpp +++ b/vslib/SwitchBCM56850.cpp @@ -146,6 +146,45 @@ sai_status_t SwitchBCM56850::create_qos_queues() return SAI_STATUS_SUCCESS; } +sai_status_t SwitchBCM56850::create_port_serdes() +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_INFO("create port serdes for all ports"); + + for (auto &port_id: m_port_list) + { + CHECK_STATUS(create_port_serdes_per_port(port_id)); + } + + return SAI_STATUS_SUCCESS; +} + +sai_status_t SwitchBCM56850::create_port_serdes_per_port( + _In_ sai_object_id_t port_id) +{ + SWSS_LOG_ENTER(); + + sai_object_id_t port_serdes_id; + + sai_attribute_t attr; + + // create port serdes fir specific port + + attr.id = SAI_PORT_SERDES_ATTR_PORT_ID; + attr.value.oid = port_id; + + CHECK_STATUS(create(SAI_OBJECT_TYPE_PORT_SERDES, &port_serdes_id, m_switch_id, 1, &attr)); + + // set port serdes read only value + + attr.id = SAI_PORT_ATTR_PORT_SERDES_ID; + attr.value.oid = port_serdes_id; + + CHECK_STATUS(set(SAI_OBJECT_TYPE_PORT, port_id, &attr)); + + return SAI_STATUS_SUCCESS; +} sai_status_t SwitchBCM56850::create_scheduler_group_tree( _In_ const std::vector& sgs, diff --git a/vslib/SwitchBCM56850.h b/vslib/SwitchBCM56850.h index f122f57e53f9..ce3651425f53 100644 --- a/vslib/SwitchBCM56850.h +++ b/vslib/SwitchBCM56850.h @@ -46,5 +46,10 @@ namespace saivs _In_ sai_object_id_t bridge_id) override; virtual sai_status_t warm_update_queues() override; + + virtual sai_status_t create_port_serdes() override; + + virtual sai_status_t create_port_serdes_per_port( + _In_ sai_object_id_t port_id) override; }; } diff --git a/vslib/SwitchMLNX2700.cpp b/vslib/SwitchMLNX2700.cpp index de709e6f9ae7..3d09cd1dfab8 100644 --- a/vslib/SwitchMLNX2700.cpp +++ b/vslib/SwitchMLNX2700.cpp @@ -458,3 +458,22 @@ sai_status_t SwitchMLNX2700::queryTunnelPeerModeCapability( enum_values_capability->list[0] = SAI_TUNNEL_PEER_MODE_P2MP; return SAI_STATUS_SUCCESS; } + +sai_status_t SwitchMLNX2700::create_port_serdes() +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_NOTICE("currently not used"); + + return SAI_STATUS_SUCCESS; +} + +sai_status_t SwitchMLNX2700::create_port_serdes_per_port( + _In_ sai_object_id_t port_id) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_NOTICE("currently not used"); + + return SAI_STATUS_SUCCESS; +} diff --git a/vslib/SwitchMLNX2700.h b/vslib/SwitchMLNX2700.h index 9ef0f9f07a25..461071f97b11 100644 --- a/vslib/SwitchMLNX2700.h +++ b/vslib/SwitchMLNX2700.h @@ -44,6 +44,11 @@ namespace saivs virtual sai_status_t warm_update_queues() override; + virtual sai_status_t create_port_serdes() override; + + virtual sai_status_t create_port_serdes_per_port( + _In_ sai_object_id_t port_id) override; + protected: virtual sai_status_t queryTunnelPeerModeCapability( _Inout_ sai_s32_list_t *enum_values_capability) override; diff --git a/vslib/SwitchStateBase.cpp b/vslib/SwitchStateBase.cpp index 7f4c99e4d4a3..e9539ae80d08 100644 --- a/vslib/SwitchStateBase.cpp +++ b/vslib/SwitchStateBase.cpp @@ -405,6 +405,8 @@ sai_status_t SwitchStateBase::remove_internal( { SWSS_LOG_ENTER(); + SWSS_LOG_INFO("removing object: %s", serializedObjectId.c_str()); + auto &objectHash = m_objectHash.at(object_type); auto it = objectHash.find(serializedObjectId); @@ -1553,6 +1555,25 @@ sai_status_t SwitchStateBase::set_number_of_ecmp_groups() return set(SAI_OBJECT_TYPE_SWITCH, m_switch_id, &attr); } +sai_status_t SwitchStateBase::create_port_serdes() +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("implement in child class"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t SwitchStateBase::create_port_serdes_per_port( + _In_ sai_object_id_t port_id) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("implement in child class"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + sai_status_t SwitchStateBase::initialize_default_objects( _In_ uint32_t attr_count, _In_ const sai_attribute_t *attr_list) @@ -1567,6 +1588,7 @@ sai_status_t SwitchStateBase::initialize_default_objects( CHECK_STATUS(create_default_1q_bridge()); CHECK_STATUS(create_default_trap_group()); CHECK_STATUS(create_ports()); + CHECK_STATUS(create_port_serdes()); CHECK_STATUS(set_port_list()); CHECK_STATUS(create_bridge_ports()); CHECK_STATUS(create_vlan_members()); @@ -1612,6 +1634,7 @@ sai_status_t SwitchStateBase::create_port_dependencies( CHECK_STATUS(create_ingress_priority_groups_per_port(port_id)); CHECK_STATUS(create_qos_queues_per_port(port_id)); CHECK_STATUS(create_scheduler_groups_per_port(port_id)); + CHECK_STATUS(create_port_serdes_per_port(port_id)); // XXX should bridge ports should also be created when new port is created? // this needs to be checked on real ASIC and updated here @@ -2105,6 +2128,51 @@ sai_status_t SwitchStateBase::refresh_macsec_sa_stat( return SAI_STATUS_SUCCESS; } +sai_status_t SwitchStateBase::refresh_port_serdes_id( + _In_ sai_object_id_t port_id) +{ + SWSS_LOG_ENTER(); + + // port serdes could be removed by user explicitly, so try to find port + // serdes object with this specific port + + sai_attribute_t attr; + + attr.id = SAI_PORT_ATTR_PORT_SERDES_ID; + attr.value.oid = SAI_NULL_OBJECT_ID; + + auto* meta = sai_metadata_get_attr_metadata(SAI_OBJECT_TYPE_PORT_SERDES, SAI_PORT_SERDES_ATTR_PORT_ID); + + // loop via all port serdes objects + + auto &serdeses = m_objectHash.at(SAI_OBJECT_TYPE_PORT_SERDES); + + auto strPortId = sai_serialize_object_id(port_id); + + for (auto& kvp: serdeses) + { + if (kvp.second.find(meta->attridname) != kvp.second.end()) + { + if (kvp.second.at(meta->attridname)->getAttrStrValue() != strPortId) + { + // this is not the port we are looking for + continue; + } + + SWSS_LOG_INFO("found corresponding port serdes %s for port %s", + kvp.first.c_str(), + sai_serialize_object_id(port_id).c_str()); + + sai_deserialize_object_id(kvp.first, attr.value.oid); + break; + } + } + + CHECK_STATUS(set(SAI_OBJECT_TYPE_PORT, port_id, &attr)); + + return SAI_STATUS_SUCCESS; +} + // XXX extra work may be needed on GET api if N on list will be > then actual /* @@ -2211,6 +2279,9 @@ sai_status_t SwitchStateBase::refresh_read_only( case SAI_PORT_ATTR_FABRIC_ATTACHED: return SAI_STATUS_SUCCESS; + + case SAI_PORT_ATTR_PORT_SERDES_ID: + return refresh_port_serdes_id(object_id); } } @@ -2363,6 +2434,8 @@ bool SwitchStateBase::check_port_reference_count( { SWSS_LOG_ENTER(); + // TODO make generic + // TODO currently when switch is initialized, there is no metadata yet // and objects are created without reference count, this needs to be // addressed in refactoring metadata and meta_create_oid to correct @@ -2395,6 +2468,28 @@ bool SwitchStateBase::check_port_reference_count( } } + auto& serdeses = m_objectHash.at(SAI_OBJECT_TYPE_PORT_SERDES); + + meta = sai_metadata_get_attr_metadata(SAI_OBJECT_TYPE_PORT_SERDES, SAI_PORT_SERDES_ATTR_PORT_ID); + + for (auto& ps: serdeses) + { + for (auto&attr: ps.second) + { + if (attr.first != meta->attridname) + continue; // not this attribute + + if (attr.second->getAttr()->value.oid == port_id) + { + SWSS_LOG_ERROR("port id %s is in use on port serdes %s", + sai_serialize_object_id(port_id).c_str(), + ps.first.c_str()); + + return false; + } + } + } + return true; } @@ -2456,7 +2551,6 @@ sai_status_t SwitchStateBase::check_port_dependencies( return SAI_STATUS_FAILURE; } - // obtain objects to examine std::vector queues; @@ -2635,6 +2729,9 @@ bool SwitchStateBase::check_object_default_state( if (!meta->isoidattribute) continue; + if (meta->ismandatoryoncreate && meta->iscreateonly) + continue; + // those attributes must be skipped since those dependencies will be automatically broken if (meta->objecttype == SAI_OBJECT_TYPE_SCHEDULER_GROUP && meta->attrid == SAI_SCHEDULER_GROUP_ATTR_PORT_ID) continue; diff --git a/vslib/SwitchStateBase.h b/vslib/SwitchStateBase.h index a258e2204707..dd53e0310858 100644 --- a/vslib/SwitchStateBase.h +++ b/vslib/SwitchStateBase.h @@ -160,6 +160,9 @@ namespace saivs virtual sai_status_t refresh_macsec_sa_stat( _In_ sai_object_id_t object_id); + virtual sai_status_t refresh_port_serdes_id( + _In_ sai_object_id_t bridge_id); + public: virtual sai_status_t warm_boot_initialize_objects(); @@ -201,6 +204,11 @@ namespace saivs virtual sai_status_t create_scheduler_groups(); + virtual sai_status_t create_port_serdes(); + + virtual sai_status_t create_port_serdes_per_port( + _In_ sai_object_id_t port_id); + protected: // will generate new OID virtual sai_status_t create(