Skip to content

Commit

Permalink
Merge pull request #2 from renukamanavalan/removeLog
Browse files Browse the repository at this point in the history
Remove handle from signature and make externs
  • Loading branch information
zbud-msft committed Sep 14, 2022
2 parents 460a7ec + 082a260 commit e7d4d4d
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 38 deletions.
7 changes: 3 additions & 4 deletions orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern sai_object_id_t gSwitchId;
extern sai_switch_api_t *sai_switch_api;
extern sai_acl_api_t *sai_acl_api;
extern event_handle_t g_events_handle;

using namespace std;
using namespace swss;
Expand Down Expand Up @@ -241,9 +242,8 @@ const map<string, CrmResourceType> crmUsedCntsTableMap =
{ "crm_stats_nexthop_group_map_used", CrmResourceType::CRM_NEXTHOP_GROUP_MAP },
};

CrmOrch::CrmOrch(DBConnector *db, string tableName, event_handle_t handle):
CrmOrch::CrmOrch(DBConnector *db, string tableName):
Orch(db, tableName),
m_events_handle(handle),
m_countersDb(new DBConnector("COUNTERS_DB", 0)),
m_countersCrmTable(new Table(m_countersDb.get(), COUNTERS_CRM_TABLE)),
m_timer(new SelectableTimer(timespec { .tv_sec = CRM_POLLING_INTERVAL_DEFAULT, .tv_nsec = 0 }))
Expand Down Expand Up @@ -772,8 +772,7 @@ void CrmOrch::checkCrmThresholds()
SWSS_LOG_WARN("%s THRESHOLD_EXCEEDED for %s %u%% Used count %u free count %u",
res.name.c_str(), threshType.c_str(), percentageUtil, cnt.usedCounter, cnt.availableCounter);

event_publish(m_events_handle, "chk_crm_threshold", &params);

event_publish(g_events_handle, "chk_crm_threshold", &params);
res.exceededLogCounter++;
}
else if ((utilization <= res.lowThreshold) && (res.exceededLogCounter > 0) && (res.highThreshold != res.lowThreshold))
Expand Down
3 changes: 1 addition & 2 deletions orchagent/crmorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum class CrmResourceStatus
class CrmOrch : public Orch
{
public:
CrmOrch(swss::DBConnector *db, std::string tableName, event_handle_t handle = NULL);
CrmOrch(swss::DBConnector *db, std::string tableName);
void incCrmResUsedCounter(CrmResourceType resource);
void decCrmResUsedCounter(CrmResourceType resource);
// Increment "used" counter for the ACL table/group CRM resources
Expand All @@ -65,7 +65,6 @@ class CrmOrch : public Orch
void decCrmAclTableUsedCounter(CrmResourceType resource, sai_object_id_t tableId);

private:
event_handle_t m_events_handle;
std::shared_ptr<swss::DBConnector> m_countersDb = nullptr;
std::shared_ptr<swss::Table> m_countersCrmTable = nullptr;
swss::SelectableTimer *m_timer = nullptr;
Expand Down
28 changes: 11 additions & 17 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ FlowCounterRouteOrch *gFlowCounterRouteOrch;
DebugCounterOrch *gDebugCounterOrch;

bool gIsNatSupported = false;
event_handle_t g_events_handle;

#define DEFAULT_MAX_BULK_SIZE 1000
size_t gMaxBulkSize = DEFAULT_MAX_BULK_SIZE;

OrchDaemon::OrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *stateDb, DBConnector *chassisAppDb) :
m_events_handle(NULL),
m_applDb(applDb),
m_configDb(configDb),
m_stateDb(stateDb),
Expand Down Expand Up @@ -91,7 +91,7 @@ OrchDaemon::~OrchDaemon()
}
delete m_select;

events_deinit_publisher(m_events_handle);
events_deinit_publisher(g_events_handle);
}

bool OrchDaemon::init()
Expand All @@ -100,9 +100,9 @@ bool OrchDaemon::init()

string platform = getenv("platform") ? getenv("platform") : "";

m_events_handle = events_init_publisher("sonic-events-swss");
g_events_handle = events_init_publisher("sonic-events-swss");

gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME, m_events_handle);
gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME);

TableConnector stateDbSwitchTable(m_stateDb, "SWITCH_CAPABILITY");
TableConnector app_switch_table(m_applDb, APP_SWITCH_TABLE_NAME);
Expand Down Expand Up @@ -131,7 +131,7 @@ bool OrchDaemon::init()
{ APP_MCLAG_FDB_TABLE_NAME, FdbOrch::fdborch_pri}
};

gPortsOrch = new PortsOrch(m_applDb, m_stateDb, ports_tables, m_chassisAppDb, m_events_handle);
gPortsOrch = new PortsOrch(m_applDb, m_stateDb, ports_tables, m_chassisAppDb);
TableConnector stateDbFdb(m_stateDb, STATE_FDB_TABLE_NAME);
TableConnector stateMclagDbFdb(m_stateDb, STATE_MCLAG_REMOTE_FDB_TABLE_NAME);
gFdbOrch = new FdbOrch(m_applDb, app_fdb_tables, stateDbFdb, stateMclagDbFdb, gPortsOrch);
Expand Down Expand Up @@ -513,8 +513,7 @@ bool OrchDaemon::init()
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS,
m_events_handle));
PFC_WD_POLL_MSECS));
}
else if ((platform == INVM_PLATFORM_SUBSTRING)
|| (platform == BFN_PLATFORM_SUBSTRING)
Expand Down Expand Up @@ -557,8 +556,7 @@ bool OrchDaemon::init()
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS,
m_events_handle));
PFC_WD_POLL_MSECS));
}
else if (platform == BFN_PLATFORM_SUBSTRING)
{
Expand All @@ -568,8 +566,7 @@ bool OrchDaemon::init()
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS,
m_events_handle));
PFC_WD_POLL_MSECS));
}
}
else if (platform == BRCM_PLATFORM_SUBSTRING)
Expand Down Expand Up @@ -613,8 +610,7 @@ bool OrchDaemon::init()
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS,
m_events_handle));
PFC_WD_POLL_MSECS));
}
else
{
Expand All @@ -624,8 +620,7 @@ bool OrchDaemon::init()
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS,
m_events_handle));
PFC_WD_POLL_MSECS));
}
} else if (platform == CISCO_8000_PLATFORM_SUBSTRING)
{
Expand All @@ -647,8 +642,7 @@ bool OrchDaemon::init()
portStatIds,
queueStatIds,
queueAttrIds,
PFC_WD_POLL_MSECS,
m_events_handle));
PFC_WD_POLL_MSECS));
}

m_orchList.push_back(&CounterCheckOrch::getInstance(m_configDb));
Expand Down
1 change: 0 additions & 1 deletion orchagent/orchdaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class OrchDaemon
m_fabricEnabled = enabled;
}
private:
event_handle_t m_events_handle;
DBConnector *m_applDb;
DBConnector *m_configDb;
DBConnector *m_stateDb;
Expand Down
2 changes: 1 addition & 1 deletion orchagent/p4orch/tests/fake_portorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C"
#define QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000

PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_with_pri_t> &tableNames,
DBConnector *chassisAppDb, event_handle_t)
DBConnector *chassisAppDb)
: Orch(db, tableNames), m_portStateTable(stateDb, STATE_PORT_TABLE_NAME),
port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ,
PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
Expand Down
8 changes: 4 additions & 4 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extern sai_switch_api_t* sai_switch_api;
extern sai_port_api_t *sai_port_api;
extern sai_queue_api_t *sai_queue_api;

extern event_handle_t g_events_handle;

extern SwitchOrch *gSwitchOrch;
extern PortsOrch *gPortsOrch;

Expand Down Expand Up @@ -686,10 +688,8 @@ PfcWdSwOrch<DropHandler, ForwardHandler>::PfcWdSwOrch(
const vector<sai_port_stat_t> &portStatIds,
const vector<sai_queue_stat_t> &queueStatIds,
const vector<sai_queue_attr_t> &queueAttrIds,
int pollInterval,
event_handle_t handle):
int pollInterval):
PfcWdOrch<DropHandler, ForwardHandler>(db, tableNames),
m_events_handle(handle),
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)),
Expand Down Expand Up @@ -952,7 +952,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::report_pfc_storm(
id,
entry->portId);

event_publish(m_events_handle, "pfc-storm", &params);
event_publish(g_events_handle, "pfc-storm", &params);
}

template <typename DropHandler, typename ForwardHandler>
Expand Down
5 changes: 1 addition & 4 deletions orchagent/pfcwdorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class PfcWdSwOrch: public PfcWdOrch<DropHandler, ForwardHandler>
const vector<sai_port_stat_t> &portStatIds,
const vector<sai_queue_stat_t> &queueStatIds,
const vector<sai_queue_attr_t> &queueAttrIds,
int pollInterval,
event_handle_t handle = NULL);
int pollInterval);
virtual ~PfcWdSwOrch(void);

void doTask(Consumer& consumer) override;
Expand All @@ -93,8 +92,6 @@ class PfcWdSwOrch: public PfcWdOrch<DropHandler, ForwardHandler>
bool startWdActionOnQueue(const string &event, sai_object_id_t queueId) override;

private:
event_handle_t m_events_handle;

struct PfcWdQueueEntry
{
PfcWdQueueEntry(
Expand Down
6 changes: 3 additions & 3 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extern string gMySwitchType;
extern int32_t gVoqMySwitchId;
extern string gMyHostName;
extern string gMyAsicName;
extern event_handle_t g_events_handle;

#define DEFAULT_SYSTEM_PORT_MTU 9100
#define VLAN_PREFIX "Vlan"
Expand Down Expand Up @@ -353,9 +354,8 @@ static bool isValidPortTypeForLagMember(const Port& port)
* default VLAN and all ports removed from .1Q bridge.
*/
PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_with_pri_t> &tableNames,
DBConnector *chassisAppDb, event_handle_t events_handle) :
DBConnector *chassisAppDb) :
Orch(db, tableNames),
m_events_handle(events_handle),
m_portStateTable(stateDb, STATE_PORT_TABLE_NAME),
port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false),
gb_port_stat_manager("GB_FLEX_COUNTER_DB",
Expand Down Expand Up @@ -2540,7 +2540,7 @@ bool PortsOrch::setHostIntfsOperStatus(const Port& port, bool isUp) const
isUp ? "UP" : "DOWN", port.m_alias.c_str());

event_params_t params = {{"ifname",port.m_alias},{"status",isUp ? "up" : "down"}};
event_publish(m_events_handle, "if-state", &params);
event_publish(g_events_handle, "if-state", &params);
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct VlanMemberUpdate
class PortsOrch : public Orch, public Subject
{
public:
PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_with_pri_t> &tableNames, DBConnector *chassisAppDb, event_handle_t handle = NULL);
PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_with_pri_t> &tableNames, DBConnector *chassisAppDb);

bool allPortsReady();
bool isInitDone();
Expand Down Expand Up @@ -189,7 +189,6 @@ class PortsOrch : public Orch, public Subject
bool isMACsecPort(sai_object_id_t port_id) const;

private:
event_handle_t m_events_handle;
unique_ptr<Table> m_counterTable;
unique_ptr<Table> m_counterLagTable;
unique_ptr<Table> m_portTable;
Expand Down

0 comments on commit e7d4d4d

Please sign in to comment.