Skip to content

Commit

Permalink
Merge branch 'master' into sag-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
superchild authored Oct 21, 2021
2 parents 007854e + d95823d commit a0de06d
Show file tree
Hide file tree
Showing 112 changed files with 12,969 additions and 3,068 deletions.
1 change: 1 addition & 0 deletions .azure-pipelines/build_and_install_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function build_and_install_kmodule()
echo CONFIG_MACSEC=m >> .config
echo CONFIG_NET_VENDOR_MICROSOFT=y >> .config
echo CONFIG_MICROSOFT_MANA=m >> .config
echo CONFIG_SYSTEM_REVOCATION_LIST=n >> .config
make VERSION=$VERSION PATCHLEVEL=$PATCHLEVEL SUBLEVEL=$SUBLEVEL EXTRAVERSION=-${EXTRAVERSION} LOCALVERSION=-${LOCALVERSION} modules_prepare
make M=drivers/net/team
mv drivers/net/Makefile drivers/net/Makefile.bak
Expand Down
6 changes: 3 additions & 3 deletions cfgmgr/buffer_check_headroom_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ end
table.insert(debuginfo, 'debug:other overhead:' .. accumulative_size)
local pg_keys = redis.call('KEYS', 'BUFFER_PG_TABLE:' .. port .. ':*')
for i = 1, #pg_keys do
local profile = string.sub(redis.call('HGET', pg_keys[i], 'profile'), 2, -2)
local profile = redis.call('HGET', pg_keys[i], 'profile')
local current_profile_size
if profile ~= 'BUFFER_PROFILE_TABLE:ingress_lossy_profile' and (no_input_pg or new_pg ~= pg_keys[i]) then
if profile ~= 'ingress_lossy_profile' and (no_input_pg or new_pg ~= pg_keys[i]) then
if profile ~= input_profile_name and not no_input_pg then
local referenced_profile = redis.call('HGETALL', profile)
local referenced_profile = redis.call('HGETALL', 'BUFFER_PROFILE_TABLE:' .. profile)
for j = 1, #referenced_profile, 2 do
if referenced_profile[j] == 'size' then
current_profile_size = tonumber(referenced_profile[j+1])
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/buffer_pool_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ local function iterate_all_items(all_items, check_lossless)
if not profile_name then
return 1
end
profile_name = string.sub(profile_name, 2, -2)
profile_name = "BUFFER_PROFILE_TABLE:" .. profile_name
local profile_ref_count = profiles[profile_name]
if profile_ref_count == nil then
-- Indicate an error in case the referenced profile hasn't been inserted or has been removed
Expand Down
100 changes: 55 additions & 45 deletions cfgmgr/buffermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ BufferMgr::BufferMgr(DBConnector *cfgDb, DBConnector *applDb, string pg_lookup_f
m_applBufferEgressProfileListTable(applDb, APP_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME)
{
readPgProfileLookupFile(pg_lookup_file);
dynamic_buffer_model = false;
}

//# speed, cable, size, xon, xoff, threshold, xon_offset
Expand Down Expand Up @@ -107,7 +108,7 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
"BUFFER_PROFILE": {
"pg_lossless_100G_300m_profile": {
"pool":"[BUFFER_POOL_TABLE:ingress_lossless_pool]",
"pool":"ingress_lossless_pool",
"xon":"18432",
"xon_offset":"2496",
"xoff":"165888",
Expand All @@ -117,7 +118,7 @@ Create/update two tables: profile (in m_cfgBufferProfileTable) and port buffer (
}
"BUFFER_PG" :{
Ethernet44|3-4": {
"profile" : "[BUFFER_PROFILE:pg_lossless_100000_300m_profile]"
"profile" : "pg_lossless_100000_300m_profile"
}
}
*/
Expand Down Expand Up @@ -168,11 +169,8 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port)

// profile threshold field name
mode += "_th";
string pg_pool_reference = string(CFG_BUFFER_POOL_TABLE_NAME) +
m_cfgBufferProfileTable.getTableNameSeparator() +
INGRESS_LOSSLESS_PG_POOL_NAME;

fvVector.push_back(make_pair("pool", "[" + pg_pool_reference + "]"));
fvVector.push_back(make_pair("pool", INGRESS_LOSSLESS_PG_POOL_NAME));
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",
Expand All @@ -192,11 +190,7 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port)

string buffer_pg_key = port + m_cfgBufferPgTable.getTableNameSeparator() + LOSSLESS_PGS;

string profile_ref = string("[") +
CFG_BUFFER_PROFILE_TABLE_NAME +
m_cfgBufferPgTable.getTableNameSeparator() +
buffer_profile_key +
"]";
string profile_ref = buffer_profile_key;

/* Check if PG Mapping is already then log message and return. */
m_cfgBufferPgTable.get(buffer_pg_key, fvVector);
Expand Down Expand Up @@ -224,32 +218,6 @@ void BufferMgr::transformSeperator(string &name)
name.replace(pos, 1, ":");
}

void BufferMgr::transformReference(string &name)
{
auto references = tokenize(name, list_item_delimiter);
int ref_index = 0;

name = "";

for (auto &reference : references)
{
if (ref_index != 0)
name += list_item_delimiter;
ref_index ++;

auto keys = tokenize(reference, config_db_key_delimiter);
int key_index = 0;
for (auto &key : keys)
{
if (key_index == 0)
name += key + "_TABLE";
else
name += delimiter + key;
key_index ++;
}
}
}

/*
* This function copies the data from tables in CONFIG_DB to APPL_DB.
* With dynamically buffer calculation supported, the following tables
Expand Down Expand Up @@ -292,14 +260,6 @@ void BufferMgr::doBufferTableTask(Consumer &consumer, ProducerStateTable &applTa

for (auto i : kfvFieldsValues(t))
{
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
//transform the separator in values from "|" to ":"
if (fvField(i) == "pool")
transformReference(fvValue(i));
if (fvField(i) == "profile")
transformReference(fvValue(i));
if (fvField(i) == "profile_list")
transformReference(fvValue(i));
fvVector.emplace_back(FieldValueTuple(fvField(i), fvValue(i)));
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
}
Expand All @@ -314,12 +274,62 @@ void BufferMgr::doBufferTableTask(Consumer &consumer, ProducerStateTable &applTa
}
}

void BufferMgr::doBufferMetaTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;
string key = kfvKey(t);

string op = kfvOp(t);
if (op == SET_COMMAND)
{
vector<FieldValueTuple> fvVector;

for (auto i : kfvFieldsValues(t))
{
if (fvField(i) == "buffer_model")
{
if (fvValue(i) == "dynamic")
{
dynamic_buffer_model = true;
}
else
{
dynamic_buffer_model = false;
}
break;
}
}
}
else if (op == DEL_COMMAND)
{
dynamic_buffer_model = false;
}
it = consumer.m_toSync.erase(it);
}
}

void BufferMgr::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

string table_name = consumer.getTableName();

if (table_name == CFG_DEVICE_METADATA_TABLE_NAME)
{
doBufferMetaTask(consumer);
return;
}

if (dynamic_buffer_model)
{
SWSS_LOG_DEBUG("Dynamic buffer model enabled. Skipping further processing");
return;
}
if (table_name == CFG_BUFFER_POOL_TABLE_NAME)
{
doBufferTableTask(consumer, m_applBufferPoolTable);
Expand Down
3 changes: 2 additions & 1 deletion cfgmgr/buffermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class BufferMgr : public Orch
ProducerStateTable m_applBufferEgressProfileListTable;

bool m_pgfile_processed;
bool dynamic_buffer_model;

pg_profile_lookup_t m_pgProfileLookup;
port_cable_length_t m_cableLenLookup;
Expand All @@ -61,9 +62,9 @@ class BufferMgr : public Orch
void doBufferTableTask(Consumer &consumer, ProducerStateTable &applTable);

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

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

}
Expand Down
3 changes: 2 additions & 1 deletion cfgmgr/buffermgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ int main(int argc, char **argv)
CFG_BUFFER_PG_TABLE_NAME,
CFG_BUFFER_QUEUE_TABLE_NAME,
CFG_BUFFER_PORT_INGRESS_PROFILE_LIST_NAME,
CFG_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME
CFG_BUFFER_PORT_EGRESS_PROFILE_LIST_NAME,
CFG_DEVICE_METADATA_TABLE_NAME
};
cfgOrchList.emplace_back(new BufferMgr(&cfgDb, &applDb, pg_lookup_file, cfg_buffer_tables));
}
Expand Down
60 changes: 4 additions & 56 deletions cfgmgr/buffermgrdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,32 +202,6 @@ void BufferMgrDynamic::transformSeperator(string &name)
name.replace(pos, 1, ":");
}

void BufferMgrDynamic::transformReference(string &name)
{
auto references = tokenize(name, list_item_delimiter);
int ref_index = 0;

name = "";

for (auto &reference : references)
{
if (ref_index != 0)
name += list_item_delimiter;
ref_index ++;

auto keys = tokenize(reference, config_db_key_delimiter);
int key_index = 0;
for (auto &key : keys)
{
if (key_index == 0)
name += key + "_TABLE";
else
name += delimiter + key;
key_index ++;
}
}
}

// For string "TABLE_NAME|objectname", returns "objectname"
string BufferMgrDynamic::parseObjectNameFromKey(const string &key, size_t pos = 0)
{
Expand All @@ -240,13 +214,6 @@ string BufferMgrDynamic::parseObjectNameFromKey(const string &key, size_t pos =
return keys[pos];
}

// For string "[foo]", returns "foo"
string BufferMgrDynamic::parseObjectNameFromReference(const string &reference)
{
auto objName = reference.substr(1, reference.size() - 2);
return parseObjectNameFromKey(objName, 1);
}

string BufferMgrDynamic::getDynamicProfileName(const string &speed, const string &cable, const string &mtu, const string &threshold, const string &gearbox_model, long lane_count)
{
string buffer_profile_key;
Expand Down Expand Up @@ -619,17 +586,14 @@ void BufferMgrDynamic::updateBufferProfileToDb(const string &name, const buffer_

// profile threshold field name
mode += "_th";
string pg_pool_reference = string(APP_BUFFER_POOL_TABLE_NAME) +
m_applBufferProfileTable.getTableNameSeparator() +
INGRESS_LOSSLESS_PG_POOL_NAME;

fvVector.emplace_back("xon", profile.xon);
if (!profile.xon_offset.empty()) {
fvVector.emplace_back("xon_offset", profile.xon_offset);
}
fvVector.emplace_back("xoff", profile.xoff);
fvVector.emplace_back("size", profile.size);
fvVector.emplace_back("pool", "[" + pg_pool_reference + "]");
fvVector.emplace_back("pool", INGRESS_LOSSLESS_PG_POOL_NAME);
fvVector.emplace_back(mode, profile.threshold);

m_applBufferProfileTable.set(name, fvVector);
Expand All @@ -646,15 +610,7 @@ void BufferMgrDynamic::updateBufferPgToDb(const string &key, const string &profi

fvVector.clear();

string profile_ref = string("[") +
APP_BUFFER_PROFILE_TABLE_NAME +
m_applBufferPgTable.getTableNameSeparator() +
profile +
"]";

fvVector.clear();

fvVector.push_back(make_pair("profile", profile_ref));
fvVector.push_back(make_pair("profile", profile));
m_applBufferPgTable.set(key, fvVector);
}
else
Expand Down Expand Up @@ -1779,8 +1735,7 @@ task_process_status BufferMgrDynamic::handleBufferProfileTable(KeyOpFieldsValues
{
if (!value.empty())
{
transformReference(value);
auto poolName = parseObjectNameFromReference(value);
auto poolName = value;
if (poolName.empty())
{
SWSS_LOG_ERROR("BUFFER_PROFILE: Invalid format of reference to pool: %s", value.c_str());
Expand Down Expand Up @@ -1953,8 +1908,7 @@ task_process_status BufferMgrDynamic::handleOneBufferPgEntry(const string &key,
{
// Headroom override
pureDynamic = false;
transformReference(value);
string profileName = parseObjectNameFromReference(value);
string profileName = value;
if (profileName.empty())
{
SWSS_LOG_ERROR("BUFFER_PG: Invalid format of reference to profile: %s", value.c_str());
Expand Down Expand Up @@ -2170,12 +2124,6 @@ task_process_status BufferMgrDynamic::doBufferTableTask(KeyOpFieldsValuesTuple &
for (auto i : kfvFieldsValues(tuple))
{
// Transform the separator in values from "|" to ":"
if (fvField(i) == "pool")
transformReference(fvValue(i));
if (fvField(i) == "profile")
transformReference(fvValue(i));
if (fvField(i) == "profile_list")
transformReference(fvValue(i));
fvVector.emplace_back(fvField(i), fvValue(i));
SWSS_LOG_INFO("Inserting field %s value %s", fvField(i).c_str(), fvValue(i).c_str());
}
Expand Down
2 changes: 0 additions & 2 deletions cfgmgr/buffermgrdyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ class BufferMgrDynamic : public Orch
// Tool functions to parse keys and references
std::string getPgPoolMode();
void transformSeperator(std::string &name);
void transformReference(std::string &name);
std::string parseObjectNameFromKey(const std::string &key, size_t pos/* = 1*/);
std::string parseObjectNameFromReference(const std::string &reference);
std::string getDynamicProfileName(const std::string &speed, const std::string &cable, const std::string &mtu, const std::string &threshold, const std::string &gearbox_model, long lane_count);
inline bool isNonZero(const std::string &value) const
{
Expand Down
6 changes: 6 additions & 0 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "shellcmd.h"
#include "macaddress.h"
#include "warm_restart.h"
#include <swss/redisutility.h>

using namespace std;
using namespace swss;
Expand Down Expand Up @@ -442,6 +443,11 @@ bool IntfMgr::isIntfStateOk(const string &alias)
}
else if (m_statePortTable.get(alias, temp))
{
auto state_opt = swss::fvsGetValue(temp, "state", true);
if (!state_opt)
{
return false;
}
SWSS_LOG_DEBUG("Port %s is ready", alias.c_str());
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions cfgmgr/portmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "portmgr.h"
#include "exec.h"
#include "shellcmd.h"
#include <swss/redisutility.h>

using namespace std;
using namespace swss;
Expand Down Expand Up @@ -87,6 +88,12 @@ bool PortMgr::isPortStateOk(const string &alias)

if (m_statePortTable.get(alias, temp))
{
auto state_opt = swss::fvsGetValue(temp, "state", true);
if (!state_opt)
{
return false;
}

SWSS_LOG_INFO("Port %s is ready", alias.c_str());
return true;
}
Expand Down
Loading

0 comments on commit a0de06d

Please sign in to comment.