Skip to content

[FEC]Auto FEC initial changes #2893

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

Merged
merged 17 commits into from
Oct 5, 2023
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
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 @@ -146,6 +155,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 @@ -468,8 +501,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