Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions mclagsyncd/mclaglink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using namespace std;
void MclagLink::getOidToPortNameMap(std::unordered_map<std::string, std:: string> & port_map)
{
std::unordered_map<std::string, std:: string>::iterator it;
auto hash = p_redisClient_to_counters->hgetall("COUNTERS_PORT_NAME_MAP");
auto hash = p_counters_db->hgetall("COUNTERS_PORT_NAME_MAP");

for (it = hash.begin(); it != hash.end(); ++it)
port_map.insert(pair<string, string>(it->second, it->first));
Expand All @@ -53,14 +53,14 @@ void MclagLink::getBridgePortIdToAttrPortIdMap(std::map<std::string, std:: strin

std::unordered_map<string, string>::iterator attr_port_id;

auto keys = p_redisClient_to_asic->keys("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT:*");
auto keys = p_asic_db->keys("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT:*");

for (auto& key : keys)
{
pos1 = key.find("oid:", 0);
bridge_port_id = key.substr(pos1);

auto hash = p_redisClient_to_asic->hgetall(key);
auto hash = p_asic_db->hgetall(key);
attr_port_id = hash.find("SAI_BRIDGE_PORT_ATTR_PORT_ID");
if (attr_port_id == hash.end())
{
Expand All @@ -81,7 +81,7 @@ void MclagLink::getVidByBvid(std::string &bvid, std::string &vlanid)
std::string pre = "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:";
std::string key = pre + bvid;

auto hash = p_redisClient_to_asic->hgetall(key.c_str());
auto hash = p_asic_db->hgetall(key.c_str());

attr_vlan_id = hash.find("SAI_VLAN_ATTR_VLAN_ID");
if (attr_vlan_id == hash.end())
Expand Down Expand Up @@ -109,7 +109,7 @@ void MclagLink::getFdbSet(std::set<mclag_fdb> *fdb_set)
std::map<std::string, std::string>::iterator brPortId_to_attrPortId_it;
std::unordered_map<std::string, std::string>::iterator oid_to_portName_it;

auto keys = p_redisClient_to_asic->keys("ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*");
auto keys = p_asic_db->keys("ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*");

for (auto& key : keys)
{
Expand All @@ -136,7 +136,7 @@ void MclagLink::getFdbSet(std::set<mclag_fdb> *fdb_set)
mac = key.substr(pos1, pos2 - pos1 + 1);

/*get type*/
auto hash = p_redisClient_to_asic->hgetall(key);
auto hash = p_asic_db->hgetall(key);
type_it = hash.find("SAI_FDB_ENTRY_ATTR_TYPE");
if (type_it == hash.end())
{
Expand Down
4 changes: 2 additions & 2 deletions mclagsyncd/mclaglink.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class MclagLink : public Selectable {
ProducerStateTable *p_acl_table_tbl;
ProducerStateTable *p_acl_rule_tbl;
DBConnector *p_appl_db;
RedisClient *p_redisClient_to_asic;/*redis client access to ASIC_DB*/
RedisClient *p_redisClient_to_counters;/*redis client access to COUNTERS_DB*/
DBConnector *p_asic_db; /*redis client access to ASIC_DB*/
DBConnector *p_counters_db; /*redis client access to COUNTERS_DB*/
std::set <mclag_fdb> *p_old_fdb;

MclagLink(uint16_t port = MCLAG_DEFAULT_PORT);
Expand Down
6 changes: 2 additions & 4 deletions mclagsyncd/mclagsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ int main(int argc, char **argv)
ProducerStateTable fdb_tbl(&appl_db, APP_FDB_TABLE_NAME);
ProducerStateTable acl_table_tbl(&appl_db, APP_ACL_TABLE_TABLE_NAME);
ProducerStateTable acl_rule_tbl(&appl_db, APP_ACL_RULE_TABLE_NAME);
RedisClient redisClient_to_asicDb(&asic_db);
RedisClient redisClient_to_countersDb(&counters_db);
map <string, string> isolate;
RedisPipeline pipeline(&appl_db);
set <mclag_fdb> old_fdb;
Expand All @@ -62,8 +60,8 @@ int main(int argc, char **argv)
mclag.p_acl_table_tbl = &acl_table_tbl;
mclag.p_acl_rule_tbl = &acl_rule_tbl;
mclag.p_appl_db = &appl_db;
mclag.p_redisClient_to_asic = &redisClient_to_asicDb;
mclag.p_redisClient_to_counters = &redisClient_to_countersDb;
mclag.p_asic_db = &asic_db;
mclag.p_counters_db = &counters_db;
mclag.p_old_fdb = &old_fdb;

cout << "Waiting for connection..." << endl;
Expand Down
7 changes: 3 additions & 4 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ BufferOrch::BufferOrch(DBConnector *db, vector<string> &tableNames) :
m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)),
m_flexCounterTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_TABLE)),
m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)),
m_countersDb(new DBConnector("COUNTERS_DB", 0)),
m_countersDbRedisClient(m_countersDb.get())
m_countersDb(new DBConnector("COUNTERS_DB", 0))
{
SWSS_LOG_ENTER();
initTableHandlers();
Expand Down Expand Up @@ -342,7 +341,7 @@ task_process_status BufferOrch::processBufferPool(Consumer &consumer)
// Specifically, we push the buffer pool name to oid mapping upon the creation of the oid
// In pg and queue case, this mapping installment is deferred to FlexCounterOrch at a reception of field
// "FLEX_COUNTER_STATUS"
m_countersDbRedisClient.hset(COUNTERS_BUFFER_POOL_NAME_MAP, object_name, sai_serialize_object_id(sai_object));
m_countersDb->hset(COUNTERS_BUFFER_POOL_NAME_MAP, object_name, sai_serialize_object_id(sai_object));
}
}
else if (op == DEL_COMMAND)
Expand All @@ -356,7 +355,7 @@ task_process_status BufferOrch::processBufferPool(Consumer &consumer)
SWSS_LOG_NOTICE("Removed buffer pool %s with type %s", object_name.c_str(), map_type_name.c_str());
auto it_to_delete = (m_buffer_type_maps[map_type_name])->find(object_name);
(m_buffer_type_maps[map_type_name])->erase(it_to_delete);
m_countersDbRedisClient.hdel(COUNTERS_BUFFER_POOL_NAME_MAP, object_name);
m_countersDb->hdel(COUNTERS_BUFFER_POOL_NAME_MAP, object_name);
}
else
{
Expand Down
1 change: 0 additions & 1 deletion orchagent/bufferorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class BufferOrch : public Orch
unique_ptr<ProducerTable> m_flexCounterTable;

unique_ptr<DBConnector> m_countersDb;
RedisClient m_countersDbRedisClient;

bool m_isBufferPoolWatermarkCounterIdListGenerated = false;
};
Expand Down
3 changes: 1 addition & 2 deletions orchagent/countercheckorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,12 @@ QueueMcCounters CounterCheckOrch::getQueueMcCounters(

vector<FieldValueTuple> fieldValues;
QueueMcCounters counters;
RedisClient redisClient(m_countersDb.get());

for (uint8_t prio = 0; prio < port.m_queue_ids.size(); prio++)
{
sai_object_id_t queueId = port.m_queue_ids[prio];
auto queueIdStr = sai_serialize_object_id(queueId);
auto queueType = redisClient.hget(COUNTERS_QUEUE_TYPE_MAP, queueIdStr);
auto queueType = m_countersDb->hget(COUNTERS_QUEUE_TYPE_MAP, queueIdStr);

if (queueType.get() == nullptr || *queueType != "SAI_QUEUE_TYPE_MULTICAST" || !m_countersTable->get(queueIdStr, fieldValues))
{
Expand Down
21 changes: 8 additions & 13 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,8 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::disableBigRedSwitchMode()
}

auto queueId = entry.first;
RedisClient redisClient(this->getCountersDb().get());
string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator() + sai_serialize_object_id(queueId);
redisClient.hdel(countersKey, "BIG_RED_SWITCH_MODE");
this->getCountersDb()->hdel(countersKey, "BIG_RED_SWITCH_MODE");
}

m_brsEntryMap.clear();
Expand Down Expand Up @@ -633,9 +632,8 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::unregisterFromWdDb(const Port& po
m_entryMap.erase(queueId);

// Clean up
RedisClient redisClient(this->getCountersDb().get());
string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator() + sai_serialize_object_id(queueId);
redisClient.hdel(countersKey, {"PFC_WD_DETECTION_TIME", "PFC_WD_RESTORATION_TIME", "PFC_WD_ACTION", "PFC_WD_STATUS"});
this->getCountersDb()->hdel(countersKey, {"PFC_WD_DETECTION_TIME", "PFC_WD_RESTORATION_TIME", "PFC_WD_ACTION", "PFC_WD_STATUS"});
}

}
Expand All @@ -657,8 +655,7 @@ PfcWdSwOrch<DropHandler, ForwardHandler>::PfcWdSwOrch(
c_queueAttrIds(queueAttrIds),
m_pollInterval(pollInterval),
m_applDb(make_shared<DBConnector>("APPL_DB", 0)),
m_applTable(make_shared<Table>(m_applDb.get(), APP_PFC_WD_TABLE_NAME "_INSTORM")),
m_applDbRedisClient(m_applDb.get())
m_applTable(make_shared<Table>(m_applDb.get(), APP_PFC_WD_TABLE_NAME "_INSTORM"))
{
SWSS_LOG_ENTER();

Expand Down Expand Up @@ -934,7 +931,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::startWdActionOnQueue(const string
entry->second.handler->initCounters();
// Log storm event to APPL_DB for warm-reboot purpose
string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias;
m_applDbRedisClient.hset(key, to_string(entry->second.index), PFC_WD_IN_STORM);
m_applDb->hset(key, to_string(entry->second.index), PFC_WD_IN_STORM);
}
}
else if (entry->second.action == PfcWdAction::PFC_WD_ACTION_DROP)
Expand All @@ -956,7 +953,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::startWdActionOnQueue(const string
entry->second.handler->initCounters();
// Log storm event to APPL_DB for warm-reboot purpose
string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias;
m_applDbRedisClient.hset(key, to_string(entry->second.index), PFC_WD_IN_STORM);
m_applDb->hset(key, to_string(entry->second.index), PFC_WD_IN_STORM);
}
}
else if (entry->second.action == PfcWdAction::PFC_WD_ACTION_FORWARD)
Expand All @@ -978,7 +975,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::startWdActionOnQueue(const string
entry->second.handler->initCounters();
// Log storm event to APPL_DB for warm-reboot purpose
string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias;
m_applDbRedisClient.hset(key, to_string(entry->second.index), PFC_WD_IN_STORM);
m_applDb->hset(key, to_string(entry->second.index), PFC_WD_IN_STORM);
}
}
else
Expand All @@ -1002,7 +999,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::startWdActionOnQueue(const string
entry->second.handler = nullptr;
// Remove storm status in APPL_DB for warm-reboot purpose
string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias;
m_applDbRedisClient.hdel(key, to_string(entry->second.index));
m_applDb->hdel(key, to_string(entry->second.index));
}
}
else
Expand All @@ -1019,8 +1016,6 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::bake()
{
// clean all *_last and *_LEFT fields in COUNTERS_TABLE
// to allow warm-reboot pfc detect & restore state machine to enter the same init state as cold-reboot
RedisClient redisClient(this->getCountersDb().get());

vector<string> cKeys;
this->getCountersTable()->getKeys(cKeys);
for (const auto &key : cKeys)
Expand All @@ -1037,7 +1032,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::bake()
}
if (!wLasts.empty())
{
redisClient.hdel(
this->getCountersDb()->hdel(
this->getCountersTable()->getTableName()
+ this->getCountersTable()->getTableNameSeparator()
+ key,
Expand Down
2 changes: 0 additions & 2 deletions orchagent/pfcwdorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ class PfcWdSwOrch: public PfcWdOrch<DropHandler, ForwardHandler>
shared_ptr<DBConnector> m_applDb = nullptr;
// Track queues in storm
shared_ptr<Table> m_applTable = nullptr;
// used for hset and hdel
RedisClient m_applDbRedisClient;
};

#endif
3 changes: 1 addition & 2 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1894,8 +1894,7 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id)
port_stat_manager.clearCounterIdList(p.m_port_id);

/* remove port name map from counter table */
RedisClient redisClient(m_counter_db.get());
redisClient.hdel(COUNTERS_PORT_NAME_MAP, alias);
m_counter_db->hdel(COUNTERS_PORT_NAME_MAP, alias);

m_portList[alias].m_init = false;
SWSS_LOG_NOTICE("De-Initialized port %s", alias.c_str());
Expand Down