@@ -74,7 +74,8 @@ static const std::unordered_map<std::string, sai_port_fec_mode_t> portFecMap =
74
74
{
75
75
{ PORT_FEC_NONE, SAI_PORT_FEC_MODE_NONE },
76
76
{ 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 }
78
79
};
79
80
80
81
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
84
85
{ SAI_PORT_FEC_MODE_FC, PORT_FEC_FC }
85
86
};
86
87
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
+
87
96
static const std::unordered_map<std::string, sai_port_priority_flow_control_mode_t > portPfcAsymMap =
88
97
{
89
98
{ 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
146
155
return true ;
147
156
}
148
157
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
+ }
149
182
std::string PortHelper::getFieldValueStr (const PortConfig &port, const std::string &field) const
150
183
{
151
184
static std::string str;
@@ -468,8 +501,16 @@ bool PortHelper::parsePortFec(PortConfig &port, const std::string &field, const
468
501
return false ;
469
502
}
470
503
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
+
471
511
port.fec .value = cit->second ;
472
512
port.fec .is_set = true ;
513
+ port.fec .override_fec =override_cit->second ;
473
514
474
515
return true ;
475
516
}
0 commit comments