Skip to content

Commit 3599635

Browse files
authored
[FEC]Auto FEC initial changes (#2893)
* [FEC]Auto FEC initial changes Initial Changes to support Auto FEC feature. Added support for mode "auto" in FEC Why I did it To implement auto FEC feature HLD: sonic-net/SONiC#1416
1 parent 91e7a27 commit 3599635

File tree

11 files changed

+264
-39
lines changed

11 files changed

+264
-39
lines changed

orchagent/p4orch/tests/fake_portorch.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,12 @@ bool PortsOrch::getPortPvid(Port &port, sai_uint32_t &pvid)
537537
return true;
538538
}
539539

540-
bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t fec_mode)
540+
bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t fec_mode, bool override_fec)
541+
{
542+
return true;
543+
}
544+
545+
bool PortsOrch::isFecModeSupported(const Port &port, sai_port_fec_mode_t fec_mode)
541546
{
542547
return true;
543548
}
@@ -581,12 +586,12 @@ bool PortsOrch::getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed)
581586
return true;
582587
}
583588

584-
bool PortsOrch::setGearboxPortsAttr(const Port &port, sai_port_attr_t id, void *value)
589+
bool PortsOrch::setGearboxPortsAttr(const Port &port, sai_port_attr_t id, void *value, bool override_fec)
585590
{
586591
return true;
587592
}
588593

589-
bool PortsOrch::setGearboxPortAttr(const Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value)
594+
bool PortsOrch::setGearboxPortAttr(const Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value, bool override_fec)
590595
{
591596
return true;
592597
}

orchagent/port.h

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class Port
199199
bool m_intf_cfg = false; // Interface type
200200
bool m_adv_intf_cfg = false; // Advertised interface type
201201
bool m_fec_cfg = false; // Forward Error Correction (FEC)
202+
bool m_override_fec = false; // Enable Override FEC
202203
bool m_pfc_asym_cfg = false; // Asymmetric Priority Flow Control (PFC)
203204
bool m_lm_cfg = false; // Forwarding Database (FDB) Learning Mode (LM)
204205
bool m_lt_cfg = false; // Link Training (LT)

orchagent/port/portcnt.h

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class PortConfig final
7070
struct {
7171
sai_port_fec_mode_t value;
7272
bool is_set = false;
73+
bool override_fec = false;
7374
} fec; // Port FEC
7475

7576
struct {

orchagent/port/porthlpr.cpp

+42-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ static const std::unordered_map<std::string, sai_port_fec_mode_t> portFecMap =
7474
{
7575
{ PORT_FEC_NONE, SAI_PORT_FEC_MODE_NONE },
7676
{ PORT_FEC_RS, SAI_PORT_FEC_MODE_RS },
77-
{ PORT_FEC_FC, SAI_PORT_FEC_MODE_FC }
77+
{ PORT_FEC_FC, SAI_PORT_FEC_MODE_FC },
78+
{ PORT_FEC_AUTO, SAI_PORT_FEC_MODE_NONE }
7879
};
7980

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

88+
static const std::unordered_map<std::string, bool> portFecOverrideMap =
89+
{
90+
{ PORT_FEC_NONE, true },
91+
{ PORT_FEC_RS, true },
92+
{ PORT_FEC_FC, true },
93+
{ PORT_FEC_AUTO, false }
94+
};
95+
8796
static const std::unordered_map<std::string, sai_port_priority_flow_control_mode_t> portPfcAsymMap =
8897
{
8998
{ PORT_MODE_ON, SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_SEPARATE },
@@ -146,6 +155,30 @@ bool PortHelper::fecToStr(std::string &str, sai_port_fec_mode_t value) const
146155
return true;
147156
}
148157

158+
bool PortHelper::fecToSaiFecMode(const std::string &str, sai_port_fec_mode_t &value) const
159+
{
160+
const auto &cit = portFecMap.find(str);
161+
if (cit == portFecMap.cend())
162+
{
163+
return false;
164+
}
165+
166+
value = cit->second;
167+
168+
return true;
169+
}
170+
171+
bool PortHelper::fecIsOverrideRequired(const std::string &str) const
172+
{
173+
const auto &cit = portFecMap.find(str);
174+
if (cit == portFecMap.cend())
175+
{
176+
return false;
177+
}
178+
179+
return cit->second;
180+
181+
}
149182
std::string PortHelper::getFieldValueStr(const PortConfig &port, const std::string &field) const
150183
{
151184
static std::string str;
@@ -468,8 +501,16 @@ bool PortHelper::parsePortFec(PortConfig &port, const std::string &field, const
468501
return false;
469502
}
470503

504+
const auto &override_cit = portFecOverrideMap.find(value);
505+
if (override_cit == portFecOverrideMap.cend())
506+
{
507+
SWSS_LOG_ERROR("Failed to parse field(%s): invalid value(%s) in override map", field.c_str(), value.c_str());
508+
return false;
509+
}
510+
471511
port.fec.value = cit->second;
472512
port.fec.is_set = true;
513+
port.fec.override_fec =override_cit->second;
473514

474515
return true;
475516
}

orchagent/port/porthlpr.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class PortHelper final
1515

1616
public:
1717
bool fecToStr(std::string &str, sai_port_fec_mode_t value) const;
18+
bool fecToSaiFecMode(const std::string &str, sai_port_fec_mode_t &value) const;
19+
bool fecIsOverrideRequired(const std::string &str) const;
1820

1921
std::string getAutonegStr(const PortConfig &port) const;
2022
std::string getPortInterfaceTypeStr(const PortConfig &port) const;

orchagent/port/portschema.h

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#define PORT_FEC_NONE "none"
3939
#define PORT_FEC_RS "rs"
4040
#define PORT_FEC_FC "fc"
41+
#define PORT_FEC_AUTO "auto"
4142

4243
#define PORT_LEARN_MODE_DROP "drop"
4344
#define PORT_LEARN_MODE_DISABLE "disable"

0 commit comments

Comments
 (0)