-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into rpmarvell_wred_statistics_swss_changes
- Loading branch information
Showing
81 changed files
with
4,888 additions
and
1,126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#include "logger.h" | ||
#include "dbconnector.h" | ||
#include "producerstatetable.h" | ||
#include "tokenize.h" | ||
#include "ipprefix.h" | ||
#include "fabricmgr.h" | ||
#include "exec.h" | ||
#include "shellcmd.h" | ||
#include <swss/redisutility.h> | ||
|
||
using namespace std; | ||
using namespace swss; | ||
|
||
FabricMgr::FabricMgr(DBConnector *cfgDb, DBConnector *appDb, const vector<string> &tableNames) : | ||
Orch(cfgDb, tableNames), | ||
m_cfgFabricMonitorTable(cfgDb, CFG_FABRIC_MONITOR_DATA_TABLE_NAME), | ||
m_cfgFabricPortTable(cfgDb, CFG_FABRIC_MONITOR_PORT_TABLE_NAME), | ||
m_appFabricMonitorTable(appDb, APP_FABRIC_MONITOR_DATA_TABLE_NAME), | ||
m_appFabricPortTable(appDb, APP_FABRIC_MONITOR_PORT_TABLE_NAME) | ||
{ | ||
} | ||
|
||
void FabricMgr::doTask(Consumer &consumer) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
auto table = consumer.getTableName(); | ||
|
||
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) | ||
{ | ||
|
||
string monErrThreshCrcCells, monErrThreshRxCells; | ||
string monPollThreshRecovery, monPollThreshIsolation; | ||
string isolateStatus; | ||
string alias, lanes; | ||
std::vector<FieldValueTuple> field_values; | ||
string value; | ||
|
||
for (auto i : kfvFieldsValues(t)) | ||
{ | ||
if (fvField(i) == "monErrThreshCrcCells") | ||
{ | ||
monErrThreshCrcCells = fvValue(i); | ||
writeConfigToAppDb(key, "monErrThreshCrcCells", monErrThreshCrcCells); | ||
} | ||
else if (fvField(i) == "monErrThreshRxCells") | ||
{ | ||
monErrThreshRxCells = fvValue(i); | ||
writeConfigToAppDb(key, "monErrThreshRxCells", monErrThreshRxCells); | ||
} | ||
else if (fvField(i) == "monPollThreshRecovery") | ||
{ | ||
monPollThreshRecovery = fvValue(i); | ||
writeConfigToAppDb(key, "monPollThreshRecovery", monPollThreshRecovery); | ||
} | ||
else if (fvField(i) == "monPollThreshIsolation") | ||
{ | ||
monPollThreshIsolation = fvValue(i); | ||
writeConfigToAppDb(key, "monPollThreshIsolation", monPollThreshIsolation); | ||
} | ||
else if (fvField(i) == "alias") | ||
{ | ||
alias = fvValue(i); | ||
writeConfigToAppDb(key, "alias", alias); | ||
} | ||
else if (fvField(i) == "lanes") | ||
{ | ||
lanes = fvValue(i); | ||
writeConfigToAppDb(key, "lanes", lanes); | ||
} | ||
else if (fvField(i) == "isolateStatus") | ||
{ | ||
isolateStatus = fvValue(i); | ||
writeConfigToAppDb(key, "isolateStatus", isolateStatus); | ||
} | ||
else | ||
{ | ||
field_values.emplace_back(i); | ||
} | ||
} | ||
|
||
for (auto &entry : field_values) | ||
{ | ||
writeConfigToAppDb(key, fvField(entry), fvValue(entry)); | ||
} | ||
|
||
} | ||
it = consumer.m_toSync.erase(it); | ||
} | ||
} | ||
|
||
bool FabricMgr::writeConfigToAppDb(const std::string &key, const std::string &field, const std::string &value) | ||
{ | ||
vector<FieldValueTuple> fvs; | ||
FieldValueTuple fv(field, value); | ||
fvs.push_back(fv); | ||
if (key == "FABRIC_MONITOR_DATA") | ||
{ | ||
m_appFabricMonitorTable.set(key, fvs); | ||
SWSS_LOG_NOTICE("Write FABRIC_MONITOR:%s %s to %s", key.c_str(), field.c_str(), value.c_str()); | ||
} | ||
else | ||
{ | ||
m_appFabricPortTable.set(key, fvs); | ||
SWSS_LOG_NOTICE("Write FABRIC_PORT:%s %s to %s", key.c_str(), field.c_str(), value.c_str()); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "dbconnector.h" | ||
#include "orch.h" | ||
#include "producerstatetable.h" | ||
|
||
#include <map> | ||
#include <set> | ||
#include <string> | ||
|
||
namespace swss { | ||
|
||
|
||
class FabricMgr : public Orch | ||
{ | ||
public: | ||
FabricMgr(DBConnector *cfgDb, DBConnector *appDb, const std::vector<std::string> &tableNames); | ||
|
||
using Orch::doTask; | ||
private: | ||
Table m_cfgFabricMonitorTable; | ||
Table m_cfgFabricPortTable; | ||
Table m_appFabricMonitorTable; | ||
Table m_appFabricPortTable; | ||
|
||
void doTask(Consumer &consumer); | ||
bool writeConfigToAppDb(const std::string &alias, const std::string &field, const std::string &value); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <fstream> | ||
#include <iostream> | ||
#include <mutex> | ||
#include <unistd.h> | ||
#include <vector> | ||
|
||
#include "exec.h" | ||
#include "fabricmgr.h" | ||
#include "schema.h" | ||
#include "select.h" | ||
|
||
using namespace std; | ||
using namespace swss; | ||
|
||
/* select() function timeout retry time, in millisecond */ | ||
#define SELECT_TIMEOUT 1000 | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
Logger::linkToDbNative("fabricmgrd"); | ||
SWSS_LOG_ENTER(); | ||
|
||
SWSS_LOG_NOTICE("--- Starting fabricmgrd ---"); | ||
|
||
try | ||
{ | ||
vector<string> cfg_fabric_tables = { | ||
CFG_FABRIC_MONITOR_DATA_TABLE_NAME, | ||
CFG_FABRIC_MONITOR_PORT_TABLE_NAME, | ||
}; | ||
|
||
DBConnector cfgDb("CONFIG_DB", 0); | ||
DBConnector appDb("APPL_DB", 0); | ||
|
||
FabricMgr fabricmgr(&cfgDb, &appDb, cfg_fabric_tables); | ||
|
||
// TODO: add tables in stateDB which interface depends on to monitor list | ||
vector<Orch *> cfgOrchList = {&fabricmgr}; | ||
|
||
swss::Select s; | ||
for (Orch *o : cfgOrchList) | ||
{ | ||
s.addSelectables(o->getSelectables()); | ||
} | ||
|
||
while (true) | ||
{ | ||
Selectable *sel; | ||
int ret; | ||
|
||
ret = s.select(&sel, SELECT_TIMEOUT); | ||
if (ret == Select::ERROR) | ||
{ | ||
SWSS_LOG_NOTICE("Error: %s!", strerror(errno)); | ||
continue; | ||
} | ||
if (ret == Select::TIMEOUT) | ||
{ | ||
fabricmgr.doTask(); | ||
continue; | ||
} | ||
|
||
auto *c = (Executor *)sel; | ||
c->execute(); | ||
} | ||
} | ||
catch (const exception &e) | ||
{ | ||
SWSS_LOG_ERROR("Runtime error: %s", e.what()); | ||
} | ||
return -1; | ||
} | ||
|
Oops, something went wrong.