Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update orchagent to support new field pfcwd_sw_enable #2171

Merged
merged 17 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions cfgmgr/buffermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ using namespace swss;
BufferMgr::BufferMgr(DBConnector *cfgDb, DBConnector *applDb, string pg_lookup_file, const vector<string> &tableNames) :
Orch(cfgDb, tableNames),
m_cfgPortTable(cfgDb, CFG_PORT_TABLE_NAME),
m_cfgPortQosMapTable(cfgDb, CFG_PORT_QOS_MAP_TABLE_NAME),
m_cfgCableLenTable(cfgDb, CFG_PORT_CABLE_LEN_TABLE_NAME),
m_cfgBufferProfileTable(cfgDb, CFG_BUFFER_PROFILE_TABLE_NAME),
m_cfgBufferPgTable(cfgDb, CFG_BUFFER_PG_TABLE_NAME),
Expand Down Expand Up @@ -133,7 +134,7 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
}
}
*/
task_process_status BufferMgr::doSpeedUpdateTask(string port, bool admin_up)
task_process_status BufferMgr::doSpeedUpdateTask(string port, bool admin_up, const string& pfc_enable)
{
string cable;
string speed;
Expand All @@ -156,7 +157,7 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port, bool admin_up)
string buffer_profile_key = "pg_lossless_" + speed + "_" + cable + "_profile";
string profile_ref = buffer_profile_key;

vector<string> lossless_pgs = tokenize(LOSSLESS_PGS, ',');
vector<string> lossless_pgs = tokenize(pfc_enable, ',');
for (auto lossless_pg : lossless_pgs)
{
vector<FieldValueTuple> fvVectorPg, fvVectorProfile;
Expand Down Expand Up @@ -350,6 +351,21 @@ void BufferMgr::doBufferMetaTask(Consumer &consumer)
}
}

/*
Read pfc_enable entry from PORT_QOS_MAP to decide on which queue to
apply lossless PG.
Return the hardcoded value '3-4' if failed to get that value
*/
string BufferMgr::getPfcEnableQueuesForPort(std::string port)
{
string pfc_enable;
if (!m_cfgPortQosMapTable.hget(port, "pfc_enable", pfc_enable))
{
return LOSSLESS_PGS;
}
return pfc_enable;
}

void BufferMgr::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -442,7 +458,8 @@ void BufferMgr::doTask(Consumer &consumer)
if (m_speedLookup.count(port) != 0)
{
// create/update profile for port
task_status = doSpeedUpdateTask(port, admin_up);
string lossless_pgs = getPfcEnableQueuesForPort(port);
bingwang-ms marked this conversation as resolved.
Show resolved Hide resolved
task_status = doSpeedUpdateTask(port, admin_up, lossless_pgs);
}

if (task_status != task_process_status::task_success)
Expand Down
6 changes: 4 additions & 2 deletions cfgmgr/buffermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace swss {

#define INGRESS_LOSSLESS_PG_POOL_NAME "ingress_lossless_pool"
#define LOSSLESS_PGS "2,3-4,6"
#define LOSSLESS_PGS "3-4"

#define BUFFERMGR_TIMER_PERIOD 10

Expand Down Expand Up @@ -43,6 +43,7 @@ class BufferMgr : public Orch
Table m_cfgBufferProfileTable;
Table m_cfgBufferPgTable;
Table m_cfgLosslessPgPoolTable;
Table m_cfgPortQosMapTable;

ProducerStateTable m_applBufferProfileTable;
ProducerStateTable m_applBufferPgTable;
Expand All @@ -60,13 +61,14 @@ class BufferMgr : public Orch
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, bool admin_up);
task_process_status doSpeedUpdateTask(std::string port, bool admin_up, const std::string &pfc_enable);
void doBufferTableTask(Consumer &consumer, ProducerStateTable &applTable);

void transformSeperator(std::string &name);

void doTask(Consumer &consumer);
void doBufferMetaTask(Consumer &consumer);
std::string getPfcEnableQueuesForPort(std::string port);
};

}
Expand Down
11 changes: 8 additions & 3 deletions tests/test_buffer_traditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class TestBuffer(object):
LOSSLESS_PGS = [2, 3, 4, 6]
lossless_pgs = []
INTF = "Ethernet0"

def setup_db(self, dvs):
Expand All @@ -14,6 +14,10 @@ def setup_db(self, dvs):

# enable PG watermark
self.set_pg_wm_status('enable')

def get_pfc_enable_queues(self):
qos_map = self.config_db.get_entry("PORT_QOS_MAP", self.INTF)
self.lossless_pgs = qos_map['pfc_enable'].split(',')

def get_pg_oid(self, pg):
fvs = dict()
Expand Down Expand Up @@ -61,7 +65,7 @@ def setup_teardown_test(self, dvs):
try:
self.setup_db(dvs)
pg_name_map = dict()
for pg in self.LOSSLESS_PGS:
for pg in self.lossless_pgs:
pg_name = "{}:{}".format(self.INTF, pg)
pg_name_map[pg_name] = self.get_pg_oid(pg_name)
yield pg_name_map
Expand Down Expand Up @@ -119,7 +123,8 @@ def test_zero_cable_len_profile_update(self, dvs, setup_teardown_test):
self.app_db.wait_for_deleted_entry("BUFFER_PROFILE_TABLE", test_lossless_profile)

# buffer pgs should still point to the original buffer profile
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", self.INTF + ":3-4", {"profile": orig_lossless_profile})
for pg in self.lossless_pgs:
self.app_db.wait_for_field_match("BUFFER_PG_TABLE", self.INTF + ":" + pg, {"profile": orig_lossless_profile})
fvs = dict()
for pg in self.pg_name_map:
fvs["SAI_INGRESS_PRIORITY_GROUP_ATTR_BUFFER_PROFILE"] = self.buf_pg_profile[pg]
Expand Down