Skip to content

Commit

Permalink
Merge branch 'master' into srv6_pt_midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cscarpitta committed Oct 12, 2023
2 parents 441fa95 + 966c5bb commit 6883ab9
Show file tree
Hide file tree
Showing 18 changed files with 445 additions and 65 deletions.
4 changes: 2 additions & 2 deletions orchagent/dash/dashaclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void DashAclOrch::doTask(ConsumerBase &consumer)
const static TaskMap TaskMap = {
PbWorker<AclIn>::makeMemberTask(APP_DASH_ACL_IN_TABLE_NAME, SET_COMMAND, &DashAclOrch::taskUpdateDashAclIn, this),
KeyOnlyWorker::makeMemberTask(APP_DASH_ACL_IN_TABLE_NAME, DEL_COMMAND, &DashAclOrch::taskRemoveDashAclIn, this),
PbWorker<AclOut>::makeMemberTask(APP_DASH_ACL_IN_TABLE_NAME, SET_COMMAND, &DashAclOrch::taskUpdateDashAclOut, this),
KeyOnlyWorker::makeMemberTask(APP_DASH_ACL_IN_TABLE_NAME, DEL_COMMAND, &DashAclOrch::taskRemoveDashAclOut, this),
PbWorker<AclOut>::makeMemberTask(APP_DASH_ACL_OUT_TABLE_NAME, SET_COMMAND, &DashAclOrch::taskUpdateDashAclOut, this),
KeyOnlyWorker::makeMemberTask(APP_DASH_ACL_OUT_TABLE_NAME, DEL_COMMAND, &DashAclOrch::taskRemoveDashAclOut, this),
PbWorker<AclGroup>::makeMemberTask(APP_DASH_ACL_GROUP_TABLE_NAME, SET_COMMAND, &DashAclOrch::taskUpdateDashAclGroup, this),
KeyOnlyWorker::makeMemberTask(APP_DASH_ACL_GROUP_TABLE_NAME, DEL_COMMAND, &DashAclOrch::taskRemoveDashAclGroup, this),
PbWorker<AclRule>::makeMemberTask(APP_DASH_ACL_RULE_TABLE_NAME, SET_COMMAND, &DashAclOrch::taskUpdateDashAclRule, this),
Expand Down
39 changes: 39 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector<string> &tableNames):
m_flexCounterConfigTable(db, CFG_FLEX_COUNTER_TABLE_NAME),
m_bufferQueueConfigTable(db, CFG_BUFFER_QUEUE_TABLE_NAME),
m_bufferPgConfigTable(db, CFG_BUFFER_PG_TABLE_NAME),
m_deviceMetadataConfigTable(db, CFG_DEVICE_METADATA_TABLE_NAME),
m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)),
m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)),
m_gbflexCounterDb(new DBConnector("GB_FLEX_COUNTER_DB", 0)),
Expand Down Expand Up @@ -328,11 +329,41 @@ bool FlexCounterOrch::bake()
return consumer->addToSync(entries);
}

static bool isCreateOnlyConfigDbBuffers(Table& deviceMetadataConfigTable)
{
std::string createOnlyConfigDbBuffersValue;

try
{
if (deviceMetadataConfigTable.hget("localhost", "create_only_config_db_buffers", createOnlyConfigDbBuffersValue))
{
if (createOnlyConfigDbBuffersValue == "true")
{
return true;
}
}
}
catch(const std::system_error& e)
{
SWSS_LOG_ERROR("System error: %s", e.what());
}

return false;
}

map<string, FlexCounterQueueStates> FlexCounterOrch::getQueueConfigurations()
{
SWSS_LOG_ENTER();

map<string, FlexCounterQueueStates> queuesStateVector;

if (!isCreateOnlyConfigDbBuffers(m_deviceMetadataConfigTable))
{
FlexCounterQueueStates flexCounterQueueState(0);
queuesStateVector.insert(make_pair(createAllAvailableBuffersStr, flexCounterQueueState));
return queuesStateVector;
}

std::vector<std::string> portQueueKeys;
m_bufferQueueConfigTable.getKeys(portQueueKeys);

Expand Down Expand Up @@ -387,6 +418,14 @@ map<string, FlexCounterPgStates> FlexCounterOrch::getPgConfigurations()
SWSS_LOG_ENTER();

map<string, FlexCounterPgStates> pgsStateVector;

if (!isCreateOnlyConfigDbBuffers(m_deviceMetadataConfigTable))
{
FlexCounterPgStates flexCounterPgState(0);
pgsStateVector.insert(make_pair(createAllAvailableBuffersStr, flexCounterPgState));
return pgsStateVector;
}

std::vector<std::string> portPgKeys;
m_bufferPgConfigTable.getKeys(portPgKeys);

Expand Down
3 changes: 3 additions & 0 deletions orchagent/flexcounterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ extern "C" {
#include "sai.h"
}

const std::string createAllAvailableBuffersStr = "create_all_available_buffers";

class FlexCounterQueueStates
{
public:
Expand Down Expand Up @@ -68,6 +70,7 @@ class FlexCounterOrch: public Orch
Table m_flexCounterConfigTable;
Table m_bufferQueueConfigTable;
Table m_bufferPgConfigTable;
Table m_deviceMetadataConfigTable;
};

#endif
14 changes: 7 additions & 7 deletions orchagent/muxorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,13 +848,6 @@ bool MuxNbrHandler::disable(sai_object_id_t tnh)
return false;
}

neigh = NeighborEntry(it->first, alias_);
if (!gNeighOrch->disableNeighbor(neigh))
{
SWSS_LOG_INFO("Disabling neigh failed for %s", neigh.ip_address.to_string().c_str());
return false;
}

updateTunnelRoute(nh_key, true);

IpPrefix pfx = it->first.to_string();
Expand All @@ -863,6 +856,13 @@ bool MuxNbrHandler::disable(sai_object_id_t tnh)
return false;
}

neigh = NeighborEntry(it->first, alias_);
if (!gNeighOrch->disableNeighbor(neigh))
{
SWSS_LOG_INFO("Disabling neigh failed for %s", neigh.ip_address.to_string().c_str());
return false;
}

it++;
}

Expand Down
3 changes: 2 additions & 1 deletion orchagent/p4orch/tests/fake_flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ FlexCounterOrch::FlexCounterOrch(swss::DBConnector *db, std::vector<std::string>
Orch(db, tableNames),
m_flexCounterConfigTable(db, CFG_FLEX_COUNTER_TABLE_NAME),
m_bufferQueueConfigTable(db, CFG_BUFFER_QUEUE_TABLE_NAME),
m_bufferPgConfigTable(db, CFG_BUFFER_PG_TABLE_NAME)
m_bufferPgConfigTable(db, CFG_BUFFER_PG_TABLE_NAME),
m_deviceMetadataConfigTable(db, CFG_DEVICE_METADATA_TABLE_NAME)
{
}

Expand Down
11 changes: 8 additions & 3 deletions orchagent/p4orch/tests/fake_portorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,12 @@ bool PortsOrch::getPortPvid(Port &port, sai_uint32_t &pvid)
return true;
}

bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t fec_mode)
bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t fec_mode, bool override_fec)
{
return true;
}

bool PortsOrch::isFecModeSupported(const Port &port, sai_port_fec_mode_t fec_mode)
{
return true;
}
Expand Down Expand Up @@ -581,12 +586,12 @@ bool PortsOrch::getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed)
return true;
}

bool PortsOrch::setGearboxPortsAttr(const Port &port, sai_port_attr_t id, void *value)
bool PortsOrch::setGearboxPortsAttr(const Port &port, sai_port_attr_t id, void *value, bool override_fec)
{
return true;
}

bool PortsOrch::setGearboxPortAttr(const Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value)
bool PortsOrch::setGearboxPortAttr(const Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value, bool override_fec)
{
return true;
}
Expand Down
1 change: 1 addition & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class Port
bool m_intf_cfg = false; // Interface type
bool m_adv_intf_cfg = false; // Advertised interface type
bool m_fec_cfg = false; // Forward Error Correction (FEC)
bool m_override_fec = false; // Enable Override FEC
bool m_pfc_asym_cfg = false; // Asymmetric Priority Flow Control (PFC)
bool m_lm_cfg = false; // Forwarding Database (FDB) Learning Mode (LM)
bool m_lt_cfg = false; // Link Training (LT)
Expand Down
1 change: 1 addition & 0 deletions orchagent/port/portcnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class PortConfig final
struct {
sai_port_fec_mode_t value;
bool is_set = false;
bool override_fec = false;
} fec; // Port FEC

struct {
Expand Down
43 changes: 42 additions & 1 deletion orchagent/port/porthlpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ static const std::unordered_map<std::string, sai_port_fec_mode_t> portFecMap =
{
{ PORT_FEC_NONE, SAI_PORT_FEC_MODE_NONE },
{ PORT_FEC_RS, SAI_PORT_FEC_MODE_RS },
{ PORT_FEC_FC, SAI_PORT_FEC_MODE_FC }
{ PORT_FEC_FC, SAI_PORT_FEC_MODE_FC },
{ PORT_FEC_AUTO, SAI_PORT_FEC_MODE_NONE }
};

static const std::unordered_map<sai_port_fec_mode_t, std::string> portFecRevMap =
Expand All @@ -84,6 +85,14 @@ static const std::unordered_map<sai_port_fec_mode_t, std::string> portFecRevMap
{ SAI_PORT_FEC_MODE_FC, PORT_FEC_FC }
};

static const std::unordered_map<std::string, bool> portFecOverrideMap =
{
{ PORT_FEC_NONE, true },
{ PORT_FEC_RS, true },
{ PORT_FEC_FC, true },
{ PORT_FEC_AUTO, false }
};

static const std::unordered_map<std::string, sai_port_priority_flow_control_mode_t> portPfcAsymMap =
{
{ PORT_MODE_ON, SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_SEPARATE },
Expand Down Expand Up @@ -154,6 +163,30 @@ bool PortHelper::fecToStr(std::string &str, sai_port_fec_mode_t value) const
return true;
}

bool PortHelper::fecToSaiFecMode(const std::string &str, sai_port_fec_mode_t &value) const
{
const auto &cit = portFecMap.find(str);
if (cit == portFecMap.cend())
{
return false;
}

value = cit->second;

return true;
}

bool PortHelper::fecIsOverrideRequired(const std::string &str) const
{
const auto &cit = portFecMap.find(str);
if (cit == portFecMap.cend())
{
return false;
}

return cit->second;

}
std::string PortHelper::getFieldValueStr(const PortConfig &port, const std::string &field) const
{
static std::string str;
Expand Down Expand Up @@ -481,8 +514,16 @@ bool PortHelper::parsePortFec(PortConfig &port, const std::string &field, const
return false;
}

const auto &override_cit = portFecOverrideMap.find(value);
if (override_cit == portFecOverrideMap.cend())
{
SWSS_LOG_ERROR("Failed to parse field(%s): invalid value(%s) in override map", field.c_str(), value.c_str());
return false;
}

port.fec.value = cit->second;
port.fec.is_set = true;
port.fec.override_fec =override_cit->second;

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions orchagent/port/porthlpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class PortHelper final

public:
bool fecToStr(std::string &str, sai_port_fec_mode_t value) const;
bool fecToSaiFecMode(const std::string &str, sai_port_fec_mode_t &value) const;
bool fecIsOverrideRequired(const std::string &str) const;

std::string getAutonegStr(const PortConfig &port) const;
std::string getPortInterfaceTypeStr(const PortConfig &port) const;
Expand Down
1 change: 1 addition & 0 deletions orchagent/port/portschema.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#define PORT_FEC_NONE "none"
#define PORT_FEC_RS "rs"
#define PORT_FEC_FC "fc"
#define PORT_FEC_AUTO "auto"

#define PORT_LEARN_MODE_DROP "drop"
#define PORT_LEARN_MODE_DISABLE "disable"
Expand Down
Loading

0 comments on commit 6883ab9

Please sign in to comment.