From b7d8746cdfc8f759901bfd7d94c40d79c0fa4204 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Thu, 15 Feb 2018 10:22:31 -0800 Subject: [PATCH] [swss - buffer manager] set xon_offset when available in lookup table (#443) Signed-off-by: Ying Xie --- cfgmgr/buffermgr.cpp | 18 ++++++++++++++---- cfgmgr/buffermgr.h | 1 + cfgmgr/buffermgrd.cpp | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cfgmgr/buffermgr.cpp b/cfgmgr/buffermgr.cpp index 1802c72bcbff..6e396700f350 100644 --- a/cfgmgr/buffermgr.cpp +++ b/cfgmgr/buffermgr.cpp @@ -25,8 +25,8 @@ BufferMgr::BufferMgr(DBConnector *cfgDb, DBConnector *stateDb, string pg_lookup_ readPgProfileLookupFile(pg_lookup_file); } -//# speed, cable, size, xon, xoff, threshold -// 40000 5m 34816 18432 16384 1 +//# speed, cable, size, xon, xoff, threshold, xon_offset +// 40000 5m 34816 18432 16384 1 2496 void BufferMgr::readPgProfileLookupFile(string file) { SWSS_LOG_NOTICE("Read lookup configuration file..."); @@ -55,12 +55,17 @@ void BufferMgr::readPgProfileLookupFile(string file) iss >> m_pgProfileLookup[speed][cable].xoff; iss >> m_pgProfileLookup[speed][cable].threshold; - SWSS_LOG_NOTICE("PG profile for speed %s and cable %s is: size:%s, xon:%s xoff:%s th:%s", + // Not all lookup table contains xon_offset values. Set default to empty + m_pgProfileLookup[speed][cable].xon_offset = ""; + iss >> m_pgProfileLookup[speed][cable].xon_offset; + + SWSS_LOG_NOTICE("PG profile for speed %s and cable %s is: size:%s, xon:%s, xoff:%s, th:%s, xon_offset:%s", speed.c_str(), cable.c_str(), m_pgProfileLookup[speed][cable].size.c_str(), m_pgProfileLookup[speed][cable].xon.c_str(), m_pgProfileLookup[speed][cable].xoff.c_str(), - m_pgProfileLookup[speed][cable].threshold.c_str() + m_pgProfileLookup[speed][cable].threshold.c_str(), + m_pgProfileLookup[speed][cable].xon_offset.c_str() ); } @@ -91,6 +96,7 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer ( "pg_lossless_100G_300m_profile": { "pool":"[BUFFER_POOL_TABLE:ingress_lossless_pool]", "xon":"18432", + "xon_offset":"2496", "xoff":"165888", "size":"184320", "dynamic_th":"1" @@ -146,6 +152,10 @@ void BufferMgr::doSpeedUpdateTask(string port, string speed) string pg_pool_reference = string(CFG_BUFFER_POOL_TABLE_NAME) + CONFIGDB_TABLE_NAME_SEPARATOR + INGRESS_LOSSLESS_PG_POOL_NAME; fvVector.push_back(make_pair("pool", "[" + pg_pool_reference + "]")); fvVector.push_back(make_pair("xon", m_pgProfileLookup[speed][cable].xon)); + if (m_pgProfileLookup[speed][cable].xon_offset.length() > 0) { + fvVector.push_back(make_pair("xon_offset", + m_pgProfileLookup[speed][cable].xon_offset)); + } fvVector.push_back(make_pair("xoff", m_pgProfileLookup[speed][cable].xoff)); fvVector.push_back(make_pair("size", m_pgProfileLookup[speed][cable].size)); fvVector.push_back(make_pair(mode, m_pgProfileLookup[speed][cable].threshold)); diff --git a/cfgmgr/buffermgr.h b/cfgmgr/buffermgr.h index 0386dc5acc5b..9263aa6a4f15 100644 --- a/cfgmgr/buffermgr.h +++ b/cfgmgr/buffermgr.h @@ -16,6 +16,7 @@ namespace swss { typedef struct{ string size; string xon; + string xon_offset; string xoff; string threshold; } pg_profile_t; diff --git a/cfgmgr/buffermgrd.cpp b/cfgmgr/buffermgrd.cpp index 4d4eab3eb9a0..e9224b5f51ab 100644 --- a/cfgmgr/buffermgrd.cpp +++ b/cfgmgr/buffermgrd.cpp @@ -37,7 +37,7 @@ void usage() cout << "Usage: buffermgrd -l pg_lookup.ini" << endl; cout << " -l pg_lookup.ini: PG profile look up table file (mandatory)" << endl; cout << " format: csv" << endl; - cout << " values: 'speed, cable, size, xon, xoff, dynamic_threshold'" << endl; + cout << " values: 'speed, cable, size, xon, xoff, dynamic_threshold, xon_offset'" << endl; } int main(int argc, char **argv)