Skip to content

Commit

Permalink
Fix internal CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
noaOrMlnx committed Oct 22, 2023
1 parent 7ea6a2d commit 68ccc1d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 58 deletions.
3 changes: 0 additions & 3 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ typedef enum

typedef std::pair<swss::DBConnector *, std::string> TableConnector;
typedef std::pair<swss::DBConnector *, std::vector<std::string>> TablesConnector;
typedef std::pair<swss::DBConnector *, const std::vector<table_name_with_pri_t> &> PriTablesConnector;

class Orch
{
Expand All @@ -223,8 +222,6 @@ class Orch
Orch(swss::DBConnector *db, const std::vector<std::string> &tableNames);
Orch(swss::DBConnector *db, const std::vector<table_name_with_pri_t> &tableNameWithPri);
Orch(const std::vector<TableConnector>& tables);
Orch(const std::vector<PriTablesConnector> &dbsTablesWithPri);

virtual ~Orch() = default;

std::vector<swss::Selectable*> getSelectables();
Expand Down
18 changes: 2 additions & 16 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,13 @@ bool OrchDaemon::init()
{ APP_LAG_MEMBER_TABLE_NAME, portsorch_base_pri }
};

vector<table_name_with_pri_t> state_transceiver_tables = {
{STATE_TRANSCEIVER_INFO_TABLE_NAME, portsorch_base_pri}
};

// PriTablesConnector appPriTables(m_applDb, ports_tables);
// PriTablesConnector statePriTables(m_stateDb, state_transceiver_tables);

// vector<PriTablesConnector> portsOrchTables = {
// appPriTables,
// statePriTables
// };

gPortsOrch = new PortsOrch(m_applDb, m_stateDb, ports_tables, m_chassisAppDb);
// gPortsOrch = new PortsOrch(m_applDb, m_stateDb, portsOrchTables, m_chassisAppDb);

vector<table_name_with_pri_t> app_fdb_tables = {
{ APP_FDB_TABLE_NAME, FdbOrch::fdborch_pri},
{ APP_VXLAN_FDB_TABLE_NAME, FdbOrch::fdborch_pri},
{ APP_MCLAG_FDB_TABLE_NAME, FdbOrch::fdborch_pri}
};

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 @@ -187,7 +173,7 @@ bool OrchDaemon::init()
gDirectory.set(vnet_rt_orch);
VRFOrch *vrf_orch = new VRFOrch(m_applDb, APP_VRF_TABLE_NAME, m_stateDb, STATE_VRF_OBJECT_TABLE_NAME);
gDirectory.set(vrf_orch);
gMonitorOrch = new MonitorOrch(m_stateDb, STATE_VNET_MONITOR_TABLE_NAME);
gMonitorOrch = new MonitorOrch(m_stateDb, STATE_VNET_MONITOR_TABLE_NAME);
gDirectory.set(gMonitorOrch);

const vector<string> chassis_frontend_tables = {
Expand Down
61 changes: 27 additions & 34 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ static void getPortSerdesAttr(PortSerdesAttrMap_t &map, const PortConfig &port)
*/


// PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<PriTablesConnector> &tables, DBConnector *chassisAppDb) :
// Orch(tables),
PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_with_pri_t> &tableNames, DBConnector *chassisAppDb) :
Orch(db, tableNames),
m_portStateTable(stateDb, STATE_PORT_TABLE_NAME),
Expand Down Expand Up @@ -505,14 +503,18 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
// Query whether SAI supports Host Tx Signal and Host Tx Notification

sai_attr_capability_t capability;

bool saiHwTxSignalSupported = false;
bool saiTxReadyNotifySupported = false;

if (sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_PORT,
SAI_PORT_ATTR_HOST_TX_SIGNAL_ENABLE,
&capability) == SAI_STATUS_SUCCESS)
{
if (capability.create_implemented == true)
{
SWSS_LOG_DEBUG("SAI_PORT_ATTR_HOST_TX_SIGNAL_ENABLE is true");
m_saiHwTxSignalSupported = true;
saiHwTxSignalSupported = true;
}
}

Expand All @@ -523,16 +525,15 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
if (capability.create_implemented == true)
{
SWSS_LOG_DEBUG("SAI_SWITCH_ATTR_PORT_HOST_TX_READY_NOTIFY is true");
m_saiTxReadyNotifySupported = true;
saiTxReadyNotifySupported = true;
}
}

if (m_saiHwTxSignalSupported && m_saiTxReadyNotifySupported)
if (saiHwTxSignalSupported && saiTxReadyNotifySupported)
{
SWSS_LOG_DEBUG("m_cmisModuleAsicSyncSupported is true");
m_cmisModuleAsicSyncSupported = true;
auto transceiverInfoTableName = STATE_TRANSCEIVER_INFO_TABLE_NAME;
Orch::addExecutor(new Consumer(new SubscriberStateTable(stateDb, transceiverInfoTableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, transceiverInfoTableName));
Orch::addExecutor(new Consumer(new SubscriberStateTable(stateDb, STATE_TRANSCEIVER_INFO_TABLE_NAME, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0), this, STATE_TRANSCEIVER_INFO_TABLE_NAME));
}

if (gMySwitchType != "dpu")
Expand Down Expand Up @@ -810,7 +811,7 @@ bool PortsOrch::addPortBulk(const std::vector<PortConfig> &portList)
attr.value.booldata = false;
attrList.push_back(attr);
}

attrDataList.push_back(attrList);
attrCountList.push_back(static_cast<std::uint32_t>(attrDataList.back().size()));
attrPtrList.push_back(attrDataList.back().data());
Expand Down Expand Up @@ -1434,6 +1435,7 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
SWSS_LOG_ERROR("Failed to set admin status %s for port %s."
" Setting host_tx_ready as false",
state ? "UP" : "DOWN", port.m_alias.c_str());

if (!m_cmisModuleAsicSyncSupported)
{
m_portStateTable.hset(port.m_alias, "host_tx_ready", "false");
Expand Down Expand Up @@ -1464,7 +1466,7 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
return true;
}

void PortsOrch::setHostTxReady(sai_object_id_t portId, std::string status)
void PortsOrch::setHostTxReady(sai_object_id_t portId, const std::string &status)
{
Port p;

Expand Down Expand Up @@ -1513,6 +1515,7 @@ bool PortsOrch::getPortHostTxReady(const Port& port, bool &hostTxReadyVal)
sai_status_t status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr);
if (status != SAI_STATUS_SUCCESS)
{
hostTxReadyVal = false;
return false;
}

Expand Down Expand Up @@ -4472,34 +4475,34 @@ void PortsOrch::doTransceiverInfoTableTask(Consumer &consumer)
if (op == SET_COMMAND)
{
SWSS_LOG_DEBUG("TRANSCEIVER_INFO table has changed - SET command for port %s", alias.c_str());

if (m_pluggedModulesPort.find(alias) == m_pluggedModulesPort.end())
{
m_pluggedModulesPort[alias] = m_portList[alias];

SWSS_LOG_DEBUG("Setting host_tx_signal allow for port %s", alias.c_str());
setSaiHostTxSignal(m_pluggedModulesPort[alias], true);
}
}
else if (op == DEL_COMMAND)
{
SWSS_LOG_DEBUG("TRANSCEIVER_INFO table has changed - DEL command for port %s", alias.c_str());

Port p;
if (m_pluggedModulesPort.find(alias) != m_pluggedModulesPort.end())
{
p = m_pluggedModulesPort[alias];
m_pluggedModulesPort.erase(alias);
SWSS_LOG_DEBUG("Setting host_tx_signal NOT allow for port %s", alias.c_str());
setSaiHostTxSignal(p, false);
}
SWSS_LOG_DEBUG("Setting host_tx_signal NOT allow for port %s", alias.c_str());
setSaiHostTxSignal(p, false);
}

it = consumer.m_toSync.erase(it);
}
}

bool PortsOrch::setSaiHostTxSignal(Port port, bool enable)
bool PortsOrch::setSaiHostTxSignal(const Port &port, bool enable)
{
sai_attribute_t attr;
attr.id = SAI_PORT_ATTR_HOST_TX_SIGNAL_ENABLE;
Expand All @@ -4508,7 +4511,7 @@ bool PortsOrch::setSaiHostTxSignal(Port port, bool enable)

if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Could not set port {} attribute {}");
SWSS_LOG_ERROR("Could not setSAI_PORT_ATTR_HOST_TX_SIGNAL_ENABLE to port 0x%" PRIx64, port.m_port_id);
return false;
}

Expand Down Expand Up @@ -4913,7 +4916,7 @@ void PortsOrch::doTask(Consumer &consumer)

string table_name = consumer.getTableName();

if (table_name == STATE_TRANSCEIVER_INFO_TABLE_NAME && m_cmisModuleAsicSyncSupported)
if (table_name == STATE_TRANSCEIVER_INFO_TABLE_NAME)
{
doTransceiverInfoTableTask(consumer);
}
Expand Down Expand Up @@ -5233,12 +5236,9 @@ bool PortsOrch::initializePort(Port &port)
SWSS_LOG_ERROR("Failed to get host_tx_ready value from SAI to Port %" PRIx64 , port.m_port_id);
}
/* set value to state DB */

string hostTxReadyStr = "false";
if (hostTxReadyVal)
{
hostTxReadyStr = "true";
}

string hostTxReadyStr = hostTxReadyVal ? "true" : "false";

SWSS_LOG_DEBUG("Received host_tx_ready current status: port_id: 0x%" PRIx64 " status: %s", port.m_port_id, hostTxReadyStr.c_str());
m_portStateTable.hset(port.m_alias, "host_tx_ready", hostTxReadyStr);
}
Expand Down Expand Up @@ -7354,22 +7354,15 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
sai_deserialize_free_port_oper_status_ntf(count, portoperstatus);
}
else if (&consumer == m_portHostTxReadyNotificationConsumer && op == "port_host_tx_ready")
{
{
sai_object_id_t port_id;
sai_object_id_t switch_id;
sai_port_host_tx_ready_status_t host_tx_ready_status;

sai_deserialize_port_host_tx_ready_ntf(data, switch_id, port_id, host_tx_ready_status);
SWSS_LOG_DEBUG("Recieved host_tx_ready notification for port 0x%" PRIx64, port_id);

if (host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_READY)
{
setHostTxReady(port_id, "true");
}
else if (host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_NOT_READY)
{
setHostTxReady(port_id, "false");
}
setHostTxReady(port_id, host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_READY ? "true" : "false");

sai_deserialize_free_port_host_tx_ready_ntf(host_tx_ready_status);
}
Expand Down Expand Up @@ -7966,11 +7959,11 @@ bool PortsOrch::initGearboxPort(Port &port)
}
attr.value.s32 = sai_fec;
attrs.push_back(attr);

if (fec_override_sup)
{
attr.id = SAI_PORT_ATTR_AUTO_NEG_FEC_MODE_OVERRIDE;

attr.value.booldata = m_portHlpr.fecIsOverrideRequired(m_gearboxPortMap[port.m_index].system_fec);
attrs.push_back(attr);
}
Expand Down
7 changes: 2 additions & 5 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class PortsOrch : public Orch, public Subject
{
public:
PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_with_pri_t> &tableNames, DBConnector *chassisAppDb);
// PortsOrch(DBConnector *db, DBConnector *stateDb, vector<PriTablesConnector> &tables, DBConnector *chassisAppDb);

bool allPortsReady();
bool isInitDone();
Expand Down Expand Up @@ -332,8 +331,6 @@ class PortsOrch : public Orch, public Subject

swss::SelectableTimer *m_port_state_poller = nullptr;

bool m_saiHwTxSignalSupported = false;
bool m_saiTxReadyNotifySupported = false;
bool m_cmisModuleAsicSyncSupported = false;

void doTask() override;
Expand Down Expand Up @@ -398,9 +395,9 @@ class PortsOrch : public Orch, public Subject

bool setBridgePortAdminStatus(sai_object_id_t id, bool up);

bool setSaiHostTxSignal(Port port, bool enable);
bool setSaiHostTxSignal(const Port &port, bool enable);

void setHostTxReady(sai_object_id_t portId, std::string status);
void setHostTxReady(sai_object_id_t portId, const std::string &status);
// Get supported speeds on system side
bool isSpeedSupported(const std::string& alias, sai_object_id_t port_id, sai_uint32_t speed);
void getPortSupportedSpeeds(const std::string& alias, sai_object_id_t port_id, PortSupportedSpeeds &supported_speeds);
Expand Down

0 comments on commit 68ccc1d

Please sign in to comment.