Skip to content

Commit

Permalink
[vs] Add special warm boot logic to populate default attributes (soni…
Browse files Browse the repository at this point in the history
…c-net#796)

When doing warm boot from older SAI (201811) to master some attributes
maybe not implemented in previous version, but they are expected to be
present on new version. Special logic is required to populate those
default attributes after warm boot.
  • Loading branch information
kcudnik authored Feb 17, 2021
1 parent 8df196e commit 387e578
Show file tree
Hide file tree
Showing 11 changed files with 406 additions and 22 deletions.
4 changes: 4 additions & 0 deletions syncd/ComparisonLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ void ComparisonLogic::checkInternalObjects(
{
SWSS_LOG_ENTER();

SWSS_LOG_NOTICE("check internal objects");

std::vector<sai_object_type_t> ots =
{
SAI_OBJECT_TYPE_QUEUE,
Expand Down Expand Up @@ -2221,6 +2223,8 @@ void ComparisonLogic::populateExistingObjects(
{
SWSS_LOG_ENTER();

SWSS_LOG_NOTICE("populate existing objects");

auto rids = m_switch->getDiscoveredRids();

/*
Expand Down
25 changes: 25 additions & 0 deletions syncd/SaiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,11 +906,36 @@ void SaiSwitch::helperPopulateWarmBootVids()
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);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions syncd/SaiSwitchInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ sai_object_id_t SaiSwitchInterface::getSwitchDefaultAttrOid(

return it->second;
}

std::set<sai_object_id_t> SaiSwitchInterface::getWarmBootNewDiscoveredVids()
{
SWSS_LOG_ENTER();

return m_warmBootNewDiscoveredVids;
}

4 changes: 4 additions & 0 deletions syncd/SaiSwitchInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ namespace syncd

virtual std::set<sai_object_id_t> getWarmBootDiscoveredVids() const = 0;

virtual std::set<sai_object_id_t> getWarmBootNewDiscoveredVids();

virtual void onPostPortCreate(
_In_ sai_object_id_t port_rid,
_In_ sai_object_id_t port_vid) = 0;
Expand Down Expand Up @@ -119,5 +121,7 @@ namespace syncd
std::set<sai_object_id_t> m_coldBootDiscoveredVids;

std::set<sai_object_id_t> m_warmBootDiscoveredVids;

std::set<sai_object_id_t> m_warmBootNewDiscoveredVids;
};
}
2 changes: 2 additions & 0 deletions vslib/inc/SwitchBCM56850.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ namespace saivs
virtual sai_status_t refresh_bridge_port_list(
_In_ const sai_attr_metadata_t *meta,
_In_ sai_object_id_t bridge_id) override;

virtual sai_status_t warm_update_queues() override;
};
}
2 changes: 2 additions & 0 deletions vslib/inc/SwitchMLNX2700.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace saivs
virtual sai_status_t refresh_bridge_port_list(
_In_ const sai_attr_metadata_t *meta,
_In_ sai_object_id_t bridge_id) override;

virtual sai_status_t warm_update_queues() override;
};
}

16 changes: 16 additions & 0 deletions vslib/inc/SwitchStateBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#define DEFAULT_VLAN_NUMBER 1

#define MAX_OBJLIST_LEN 128

#define CHECK_STATUS(status) { \
sai_status_t _status = (status); \
if (_status != SAI_STATUS_SUCCESS) { return _status; } }
Expand Down Expand Up @@ -49,6 +51,8 @@ namespace saivs

virtual sai_status_t set_switch_mac_address();

virtual sai_status_t set_switch_supported_object_types();

virtual sai_status_t set_switch_default_attributes();

virtual sai_status_t create_default_vlan();
Expand Down Expand Up @@ -153,6 +157,18 @@ namespace saivs
_In_ const sai_attr_metadata_t *meta,
_In_ sai_object_id_t object_id);

protected:

virtual sai_status_t warm_update_queues();

virtual sai_status_t warm_update_scheduler_groups();

virtual sai_status_t warm_update_ingress_priority_groups();

virtual sai_status_t warm_update_switch();

virtual sai_status_t warm_update_cpu_queues();

protected: // TODO should be pure

virtual sai_status_t create_cpu_qos_queues(
Expand Down
60 changes: 60 additions & 0 deletions vslib/src/SwitchBCM56850.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,63 @@ sai_status_t SwitchBCM56850::refresh_bridge_port_list(
return set(SAI_OBJECT_TYPE_BRIDGE, bridge_id, &attr);
}

sai_status_t SwitchBCM56850::warm_update_queues()
{
SWSS_LOG_ENTER();

for (auto port: m_port_list)
{
sai_attribute_t attr;

std::vector<sai_object_id_t> list(MAX_OBJLIST_LEN);

// get all queues list on current port

attr.id = SAI_PORT_ATTR_QOS_QUEUE_LIST;

attr.value.objlist.count = MAX_OBJLIST_LEN;
attr.value.objlist.list = list.data();

CHECK_STATUS(get(SAI_OBJECT_TYPE_PORT, port , 1, &attr));

list.resize(attr.value.objlist.count);

uint8_t index = 0;

size_t port_qos_queues_count = list.size();

for (auto queue: list)
{
attr.id = SAI_QUEUE_ATTR_PORT;

if (get(SAI_OBJECT_TYPE_QUEUE, queue, 1, &attr) != SAI_STATUS_SUCCESS)
{
attr.value.oid = port;

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue, &attr));
}

attr.id = SAI_QUEUE_ATTR_INDEX;

if (get(SAI_OBJECT_TYPE_QUEUE, queue, 1, &attr) != SAI_STATUS_SUCCESS)
{
attr.value.u8 = index; // warn, we are guessing index here if it was not defined

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue, &attr));
}

attr.id = SAI_QUEUE_ATTR_TYPE;

if (get(SAI_OBJECT_TYPE_QUEUE, queue, 1, &attr) != SAI_STATUS_SUCCESS)
{
attr.value.s32 = (index < port_qos_queues_count / 2) ? SAI_QUEUE_TYPE_UNICAST : SAI_QUEUE_TYPE_MULTICAST;

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue, &attr));
}

index++;
}
}

return SAI_STATUS_SUCCESS;
}
53 changes: 53 additions & 0 deletions vslib/src/SwitchMLNX2700.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ sai_status_t SwitchMLNX2700::create_qos_queues_per_port(
attr[1].id = SAI_QUEUE_ATTR_PORT;
attr[1].value.oid = port_id;

// TODO add type

CHECK_STATUS(create(SAI_OBJECT_TYPE_QUEUE, &queue_id, m_switch_id, 2, attr));

queues.push_back(queue_id);
Expand Down Expand Up @@ -371,3 +373,54 @@ sai_status_t SwitchMLNX2700::refresh_bridge_port_list(
return set(SAI_OBJECT_TYPE_BRIDGE, bridge_id, &attr);
}

sai_status_t SwitchMLNX2700::warm_update_queues()
{
SWSS_LOG_ENTER();

for (auto port: m_port_list)
{
sai_attribute_t attr;

std::vector<sai_object_id_t> list(MAX_OBJLIST_LEN);

// get all queues list on current port

attr.id = SAI_PORT_ATTR_QOS_QUEUE_LIST;

attr.value.objlist.count = MAX_OBJLIST_LEN;
attr.value.objlist.list = list.data();

CHECK_STATUS(get(SAI_OBJECT_TYPE_PORT, port , 1, &attr));

list.resize(attr.value.objlist.count);

uint8_t index = 0;

for (auto queue: list)
{
attr.id = SAI_QUEUE_ATTR_PORT;

if (get(SAI_OBJECT_TYPE_QUEUE, queue, 1, &attr) != SAI_STATUS_SUCCESS)
{
attr.value.oid = port;

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue, &attr));
}

attr.id = SAI_QUEUE_ATTR_INDEX;

if (get(SAI_OBJECT_TYPE_QUEUE, queue, 1, &attr) != SAI_STATUS_SUCCESS)
{
attr.value.u8 = index; // warn, we are guessing index here if it was not defined

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue, &attr));
}

// TODO add type

index++;
}
}

return SAI_STATUS_SUCCESS;
}
Loading

0 comments on commit 387e578

Please sign in to comment.