Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[orchagent]: Remove the global variable gPortsOrch in orch.cpp file #366

Merged
merged 1 commit into from
Nov 2, 2017
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
8 changes: 3 additions & 5 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ sai_object_id_t AclRuleL3::getRedirectObjectId(const string& redirect_value)

// Try to parse physical port and LAG first
Port port;
if(m_pAclOrch->m_portOrch->getPort(target, port))
if (gPortsOrch->getPort(target, port))
{
if (port.m_type == Port::PHY)
{
Expand Down Expand Up @@ -1211,7 +1211,6 @@ bool AclRange::remove()

AclOrch::AclOrch(DBConnector *db, vector<string> tableNames, PortsOrch *portOrch, MirrorOrch *mirrorOrch, NeighOrch *neighOrch, RouteOrch *routeOrch) :
Orch(db, tableNames),
m_portOrch(portOrch),
m_mirrorOrch(mirrorOrch),
m_neighOrch(neighOrch),
m_routeOrch(routeOrch)
Expand Down Expand Up @@ -1275,9 +1274,8 @@ void AclOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!m_portOrch->isInitDone())
if (!gPortsOrch->isInitDone())
{
/* Wait for ports initialization */
return;
}

Expand Down Expand Up @@ -1586,7 +1584,7 @@ bool AclOrch::processPorts(string portsList, std::function<void (sai_object_id_t
for (const auto& alias : strList)
{
Port port;
if (!m_portOrch->getPort(alias, port))
if (!gPortsOrch->getPort(alias, port))
{
SWSS_LOG_ERROR("Failed to process port. Port %s doesn't exist", alias.c_str());
return false;
Expand Down
1 change: 0 additions & 1 deletion orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ class AclOrch : public Orch, public Observer
}

// FIXME: Add getters for them? I'd better to add a common directory of orch objects and use it everywhere
PortsOrch *m_portOrch;
MirrorOrch *m_mirrorOrch;
NeighOrch *m_neighOrch;
RouteOrch *m_routeOrch;
Expand Down
6 changes: 6 additions & 0 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,12 @@ task_process_status BufferOrch::processEgressBufferProfileList(Consumer &consume
void BufferOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
10 changes: 9 additions & 1 deletion orchagent/copporch.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "sai.h"
#include "tokenize.h"
#include "copporch.h"
#include "portsorch.h"
#include "tokenize.h"
#include "logger.h"

#include <sstream>
Expand All @@ -12,7 +13,9 @@ using namespace std;
extern sai_hostif_api_t* sai_hostif_api;
extern sai_policer_api_t* sai_policer_api;
extern sai_switch_api_t* sai_switch_api;

extern sai_object_id_t gSwitchId;
extern PortsOrch* gPortsOrch;

map<string, sai_meter_type_t> policer_meter_map = {
{"packets", SAI_METER_TYPE_PACKETS},
Expand Down Expand Up @@ -585,6 +588,11 @@ void CoppOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
10 changes: 8 additions & 2 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#include "tokenize.h"
#include "fdborch.h"

extern sai_object_id_t gSwitchId;
extern sai_fdb_api_t *sai_fdb_api;

extern sai_fdb_api_t *sai_fdb_api;
extern sai_object_id_t gSwitchId;
extern PortsOrch* gPortsOrch;

void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_object_id_t bridge_port_id)
{
Expand Down Expand Up @@ -80,6 +81,11 @@ void FdbOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
5 changes: 5 additions & 0 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ void IntfsOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
9 changes: 8 additions & 1 deletion orchagent/mirrororch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#define MLNX_PLATFORM "mlnx"

extern sai_mirror_api_t *sai_mirror_api;
extern sai_object_id_t gSwitchId;

extern sai_object_id_t gSwitchId;
extern PortsOrch* gPortsOrch;

using namespace std::rel_ops;

Expand Down Expand Up @@ -866,6 +868,11 @@ void MirrorOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
5 changes: 5 additions & 0 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ void NeighOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
3 changes: 0 additions & 3 deletions orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ ref_resolve_status Orch::resolveFieldRefValue(

void Orch::doTask()
{
if (!gPortsOrch->isInitDone())
return;

for(auto &it : m_consumerMap)
{
if (!it.second.m_toSync.empty())
Expand Down
6 changes: 6 additions & 0 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

extern sai_port_api_t *sai_port_api;
extern sai_queue_api_t *sai_queue_api;

extern PortsOrch *gPortsOrch;

template <typename DropHandler, typename ForwardHandler>
Expand All @@ -40,6 +41,11 @@ void PfcWdOrch<DropHandler, ForwardHandler>::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
47 changes: 31 additions & 16 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,7 @@ void PortsOrch::doPortTask(Consumer &consumer)

void PortsOrch::doVlanTask(Consumer &consumer)
{
if (!isInitDone())
return;
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
Expand Down Expand Up @@ -957,8 +956,7 @@ void PortsOrch::doVlanTask(Consumer &consumer)

void PortsOrch::doVlanMemberTask(Consumer &consumer)
{
if (!isInitDone())
return;
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
Expand Down Expand Up @@ -1075,8 +1073,7 @@ void PortsOrch::doVlanMemberTask(Consumer &consumer)

void PortsOrch::doLagTask(Consumer &consumer)
{
if (!isInitDone())
return;
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
Expand Down Expand Up @@ -1125,8 +1122,7 @@ void PortsOrch::doLagTask(Consumer &consumer)

void PortsOrch::doLagMemberTask(Consumer &consumer)
{
if (!isInitDone())
return;
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
Expand Down Expand Up @@ -1241,15 +1237,34 @@ void PortsOrch::doTask(Consumer &consumer)
string table_name = consumer.m_consumer->getTableName();

if (table_name == APP_PORT_TABLE_NAME)
{
doPortTask(consumer);
else if (table_name == APP_VLAN_TABLE_NAME)
doVlanTask(consumer);
else if (table_name == APP_VLAN_MEMBER_TABLE_NAME)
doVlanMemberTask(consumer);
else if (table_name == APP_LAG_TABLE_NAME)
doLagTask(consumer);
else if (table_name == APP_LAG_MEMBER_TABLE_NAME)
doLagMemberTask(consumer);
}
else
{
/* Wait for all ports to be initialized */
if (!isInitDone())
{
return;
}

if (table_name == APP_VLAN_TABLE_NAME)
{
doVlanTask(consumer);
}
else if (table_name == APP_VLAN_MEMBER_TABLE_NAME)
{
doVlanMemberTask(consumer);
}
else if (table_name == APP_LAG_TABLE_NAME)
{
doLagTask(consumer);
}
else if (table_name == APP_LAG_MEMBER_TABLE_NAME)
{
doLagMemberTask(consumer);
}
}
}

void PortsOrch::initializeQueues(Port &port)
Expand Down
6 changes: 6 additions & 0 deletions orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,12 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer)
void QosOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
5 changes: 5 additions & 0 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ void RouteOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down
1 change: 0 additions & 1 deletion orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void SwitchOrch::doTask(Consumer &consumer)
while (it != consumer.m_toSync.end())
{
auto t = it->second;

auto op = kfvOp(t);

if (op == SET_COMMAND)
Expand Down
17 changes: 10 additions & 7 deletions orchagent/tunneldecaporch.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#include <string.h>
#include "tunneldecaporch.h"
#include "portsorch.h"
#include "logger.h"
#include "swssnet.h"

extern sai_tunnel_api_t* sai_tunnel_api;
extern sai_router_interface_api_t* sai_router_intfs_api;

extern sai_object_id_t gVirtualRouterId;
extern sai_object_id_t gUnderlayIfId;
extern sai_object_id_t gSwitchId;
extern sai_object_id_t gVirtualRouterId;
extern sai_object_id_t gUnderlayIfId;
extern sai_object_id_t gSwitchId;
extern PortsOrch* gPortsOrch;

TunnelDecapOrch::TunnelDecapOrch(DBConnector *db, string tableName) : Orch(db, tableName)
{
SWSS_LOG_ENTER();
}

/**
* Function Description:
* @brief reads from APP_DB and creates tunnel
*/
void TunnelDecapOrch::doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isInitDone())
{
return;
}

auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down