Skip to content

Commit

Permalink
Revert "[202012][cherry-pick]Update orchagent to support new field `p…
Browse files Browse the repository at this point in the history
…fcwd_sw_enable` (#2245)" (#2265)

This reverts commit cfed8c7.
  • Loading branch information
bingwang-ms authored May 15, 2022
1 parent b9163d3 commit 903d594
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 320 deletions.
181 changes: 51 additions & 130 deletions cfgmgr/buffermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
}
}
*/
task_process_status BufferMgr::doSpeedUpdateTask(string port)
task_process_status BufferMgr::doSpeedUpdateTask(string port, bool admin_up)
{
vector<FieldValueTuple> fvVectorPg, fvVectorProfile;
string cable;
string speed;
string pfc_enable;

if (m_cableLenLookup.count(port) == 0)
{
Expand All @@ -152,25 +152,9 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port)
return task_process_status::task_success;
}

if (m_portStatusLookup.count(port) == 0)
{
// admin_statue is not available yet. This can happen when notification of `PORT_QOS_MAP` table
// comes first.
SWSS_LOG_INFO("pfc_enable status is not available for port %s", port.c_str());
return task_process_status::task_need_retry;
}

if (m_portPfcStatus.count(port) == 0)
{
// PORT_QOS_MAP is not ready yet. The notification is cleared, and buffer pg
// will be handled when `pfc_enable` in `PORT_QOS_MAP` table is available
SWSS_LOG_INFO("pfc_enable status is not available for port %s", port.c_str());
return task_process_status::task_success;
}
pfc_enable = m_portPfcStatus[port];

speed = m_speedLookup[port];


string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator() + LOSSLESS_PGS;
// key format is pg_lossless_<speed>_<cable>_profile
string buffer_profile_key = "pg_lossless_" + speed + "_" + cable + "_profile";
string profile_ref = string("[") +
Expand All @@ -179,49 +163,40 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port)
buffer_profile_key +
"]";


vector<string> lossless_pgs = tokenize(pfc_enable, ',');
m_cfgBufferPgTable.get(buffer_pg_key, fvVectorPg);

if (m_portStatusLookup[port] == "down" && m_platform == "mellanox")
if (!admin_up && m_platform == "mellanox")
{
for (auto lossless_pg : lossless_pgs)
// Remove the entry in BUFFER_PG table if any
if (!fvVectorPg.empty())
{
// Remove the entry in BUFFER_PG table if any
vector<FieldValueTuple> fvVectorPg;
string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator() + lossless_pg;

m_cfgBufferPgTable.get(buffer_pg_key, fvVectorPg);
if (!fvVectorPg.empty())
for (auto &prop : fvVectorPg)
{
for (auto &prop : fvVectorPg)
if (fvField(prop) == "profile")
{
if (fvField(prop) == "profile")
if (fvValue(prop) == profile_ref)
{
if (fvValue(prop) == profile_ref)
{
SWSS_LOG_NOTICE("Removing PG %s from port %s which is administrative down", buffer_pg_key.c_str(), port.c_str());
m_cfgBufferPgTable.del(buffer_pg_key);
}
else
{
SWSS_LOG_NOTICE("Not default profile %s is configured on PG %s, won't reclaim buffer", fvValue(prop).c_str(), buffer_pg_key.c_str());
}
SWSS_LOG_NOTICE("Removing PG %s from port %s which is administrative down", buffer_pg_key.c_str(), port.c_str());
m_cfgBufferPgTable.del(buffer_pg_key);
}
else
{
SWSS_LOG_NOTICE("Not default profile %s is configured on PG %s, won't reclaim buffer", fvValue(prop).c_str(), buffer_pg_key.c_str());
}
}
}
}

return task_process_status::task_success;
}

if (m_pgProfileLookup.count(speed) == 0 || m_pgProfileLookup[speed].count(cable) == 0)
{
SWSS_LOG_ERROR("Unable to create/update PG profile for port %s. No PG profile configured for speed %s and cable length %s",
port.c_str(), speed.c_str(), cable.c_str());
return task_process_status::task_invalid_entry;
SWSS_LOG_ERROR("Unable to create/update PG profile for port %s. No PG profile configured for speed %s and cable length %s",
port.c_str(), speed.c_str(), cable.c_str());
return task_process_status::task_invalid_entry;
}

vector<FieldValueTuple> fvVectorProfile;
// check if profile already exists - if yes - skip creation
m_cfgBufferProfileTable.get(buffer_profile_key, fvVectorProfile);
// Create record in BUFFER_PROFILE table
Expand Down Expand Up @@ -258,29 +233,22 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port)
{
SWSS_LOG_NOTICE("Reusing existing profile '%s'", buffer_profile_key.c_str());
}

for (auto lossless_pg : lossless_pgs)
{
vector<FieldValueTuple> fvVectorPg;
string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator() + lossless_pg;

m_cfgBufferPgTable.get(buffer_pg_key, fvVectorPg);

/* Check if PG Mapping is already then log message and return. */
for (auto& prop : fvVectorPg)
/* Check if PG Mapping is already then log message and return. */
for (auto& prop : fvVectorPg)
{
if ((fvField(prop) == "profile") && (profile_ref == fvValue(prop)))
{
if ((fvField(prop) == "profile") && (profile_ref == fvValue(prop)))
{
SWSS_LOG_NOTICE("PG to Buffer Profile Mapping %s already present", buffer_pg_key.c_str());
continue;
}
SWSS_LOG_NOTICE("PG to Buffer Profile Mapping %s already present", buffer_pg_key.c_str());
return task_process_status::task_success;
}
}

fvVectorPg.clear();
fvVectorPg.clear();

fvVectorPg.push_back(make_pair("profile", profile_ref));
m_cfgBufferPgTable.set(buffer_pg_key, fvVectorPg);
}
fvVectorPg.push_back(make_pair("profile", profile_ref));
SWSS_LOG_INFO("Setting buffer profile to PG %s", buffer_pg_key.c_str());
m_cfgBufferPgTable.set(buffer_pg_key, fvVectorPg);
return task_process_status::task_success;
}

Expand Down Expand Up @@ -420,47 +388,6 @@ void BufferMgr::doBufferMetaTask(Consumer &consumer)
}
}

/*
Parse PORT_QOS_MAP to retrieve on which queue PFC is enable, and
cached in a map
*/
void BufferMgr::doPortQosTableTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple tuple = it->second;
string port_name = kfvKey(tuple);
string op = kfvOp(tuple);
if (op == SET_COMMAND)
{
bool update_pfc_enable = false;
for (auto itp : kfvFieldsValues(tuple))
{
if (fvField(itp) == "pfc_enable")
{
if (m_portPfcStatus.count(port_name) == 0 || m_portPfcStatus[port_name] != fvValue(itp))
{
m_portPfcStatus[port_name] = fvValue(itp);
update_pfc_enable = true;
}
SWSS_LOG_INFO("Got pfc enable status for port %s status %s", port_name.c_str(), fvValue(itp).c_str());
break;
}
}
if (update_pfc_enable)
{
// The return status is ignored
doSpeedUpdateTask(port_name);
}
}
it = consumer.m_toSync.erase(it);
}

}

void BufferMgr::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -514,12 +441,6 @@ void BufferMgr::doTask(Consumer &consumer)
return;
}

if (table_name == CFG_PORT_QOS_MAP_TABLE_NAME)
{
doPortQosTableTask(consumer);
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down Expand Up @@ -552,37 +473,37 @@ void BufferMgr::doTask(Consumer &consumer)
}
if (fvField(i) == "admin_status")
{
m_portStatusLookup[port] = fvValue(i);
admin_up = ("up" == fvValue(i));
}
}

if (m_speedLookup.count(port) != 0)
{
// create/update profile for port
SWSS_LOG_DEBUG("Port %s Speed %s admin status %d", port.c_str(), m_speedLookup[port].c_str(), admin_up);
task_status = doSpeedUpdateTask(port);
task_status = doSpeedUpdateTask(port, admin_up);
SWSS_LOG_DEBUG("Return code for doSpeedUpdateTask %d", task_status);
}

}
}

switch (task_status)
{
case task_process_status::task_failed:
SWSS_LOG_ERROR("Failed to process table update");
return;
case task_process_status::task_need_retry:
SWSS_LOG_INFO("Unable to process table update. Will retry...");
++it;
break;
case task_process_status::task_invalid_entry:
SWSS_LOG_ERROR("Failed to process invalid entry, drop it");
it = consumer.m_toSync.erase(it);
break;
default:
it = consumer.m_toSync.erase(it);
break;
}
switch (task_status)
{
case task_process_status::task_failed:
SWSS_LOG_ERROR("Failed to process table update");
return;
case task_process_status::task_need_retry:
SWSS_LOG_INFO("Unable to process table update. Will retry...");
++it;
break;
case task_process_status::task_invalid_entry:
SWSS_LOG_ERROR("Failed to process invalid entry, drop it");
it = consumer.m_toSync.erase(it);
break;
default:
it = consumer.m_toSync.erase(it);
break;
}
}
}
9 changes: 2 additions & 7 deletions cfgmgr/buffermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace swss {

#define INGRESS_LOSSLESS_PG_POOL_NAME "ingress_lossless_pool"
#define LOSSLESS_PGS "3-4"

#define BUFFERMGR_TIMER_PERIOD 10

Expand All @@ -27,8 +28,6 @@ typedef std::map<std::string, speed_map_t> pg_profile_lookup_t;

typedef std::map<std::string, std::string> port_cable_length_t;
typedef std::map<std::string, std::string> port_speed_t;
typedef std::map<std::string, std::string> port_pfc_status_t;
typedef std::map<std::string, std::string> port_admin_status_t;

class BufferMgr : public Orch
{
Expand Down Expand Up @@ -57,22 +56,18 @@ class BufferMgr : public Orch

pg_profile_lookup_t m_pgProfileLookup;
port_cable_length_t m_cableLenLookup;
port_admin_status_t m_portStatusLookup;
port_speed_t m_speedLookup;
std::string getPgPoolMode();
void readPgProfileLookupFile(std::string);
task_process_status doCableTask(std::string port, std::string cable_length);
task_process_status doSpeedUpdateTask(std::string port);
task_process_status doSpeedUpdateTask(std::string port, bool admin_up);
void doBufferTableTask(Consumer &consumer, ProducerStateTable &applTable);

void transformSeperator(std::string &name);
void transformReference(std::string &name);

void doTask(Consumer &consumer);
void doBufferMetaTask(Consumer &consumer);

port_pfc_status_t m_portPfcStatus;
void doPortQosTableTask(Consumer &consumer);
};

}
Expand Down
3 changes: 1 addition & 2 deletions cfgmgr/buffermgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ int main(int argc, char **argv)
CFG_BUFFER_QUEUE_TABLE_NAME,
CFG_BUFFER_PORT_INGRESS_PROFILE_LIST_NAME,
CFG_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME,
CFG_DEVICE_METADATA_TABLE_NAME,
CFG_PORT_QOS_MAP_TABLE_NAME
CFG_DEVICE_METADATA_TABLE_NAME
};
cfgOrchList.emplace_back(new BufferMgr(&cfgDb, &applDb, pg_lookup_file, cfg_buffer_tables));
}
Expand Down
10 changes: 5 additions & 5 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::enableBigRedSwitchMode()
continue;
}

if (!gPortsOrch->getPortPfcWatchdogStatus(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
{
SWSS_LOG_ERROR("Failed to get PFC watchdog mask on port %s", port.m_alias.c_str());
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return;
}

Expand Down Expand Up @@ -443,9 +443,9 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::enableBigRedSwitchMode()
continue;
}

if (!gPortsOrch->getPortPfcWatchdogStatus(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
{
SWSS_LOG_ERROR("Failed to get PFC watchdog mask on port %s", port.m_alias.c_str());
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return;
}

Expand Down Expand Up @@ -489,7 +489,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::registerInWdDb(const Port& port,

uint8_t pfcMask = 0;

if (!gPortsOrch->getPortPfcWatchdogStatus(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return false;
Expand Down
3 changes: 1 addition & 2 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ class Port
std::vector<sai_object_id_t> m_queue_ids;
std::vector<sai_object_id_t> m_priority_group_ids;
sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
uint8_t m_pfc_bitmask = 0; // PFC enable bit mask
uint8_t m_pfcwd_sw_bitmask = 0; // PFC software watchdog enable
uint8_t m_pfc_bitmask = 0;
uint32_t m_nat_zone_id = 0;
uint32_t m_vnid = VNID_NONE;
uint32_t m_fdb_count = 0;
Expand Down
Loading

0 comments on commit 903d594

Please sign in to comment.