Skip to content

Commit 84b32af

Browse files
Merge branch 'master' into master-dash-merge
2 parents 3bb7180 + ca72820 commit 84b32af

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

orchagent/portsorch.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,18 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
514514

515515
if (gMySwitchType != "dpu")
516516
{
517+
sai_attr_capability_t attr_cap;
518+
if (sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_PORT,
519+
SAI_PORT_ATTR_AUTO_NEG_FEC_MODE_OVERRIDE,
520+
&attr_cap) != SAI_STATUS_SUCCESS)
521+
{
522+
SWSS_LOG_NOTICE("Unable to query autoneg fec mode override");
523+
}
524+
else if (attr_cap.set_implemented && attr_cap.create_implemented)
525+
{
526+
fec_override_sup = true;
527+
}
528+
517529
/* Get default 1Q bridge and default VLAN */
518530
sai_status_t status;
519531
sai_attribute_t attr;
@@ -1508,6 +1520,28 @@ bool PortsOrch::setPortTpid(Port &port, sai_uint16_t tpid)
15081520
return true;
15091521
}
15101522

1523+
bool PortsOrch::setPortFecOverride(sai_object_id_t port_obj, bool fec_override)
1524+
{
1525+
sai_attribute_t attr;
1526+
sai_status_t status;
1527+
1528+
attr.id = SAI_PORT_ATTR_AUTO_NEG_FEC_MODE_OVERRIDE;
1529+
attr.value.booldata = fec_override;
1530+
1531+
status = sai_port_api->set_port_attribute(port_obj, &attr);
1532+
if (status != SAI_STATUS_SUCCESS)
1533+
{
1534+
SWSS_LOG_ERROR("Failed to set fec override %d to port pid:%" PRIx64, attr.value.booldata, port_obj);
1535+
task_process_status handle_status = handleSaiSetStatus(SAI_API_PORT, status);
1536+
if (handle_status != task_success)
1537+
{
1538+
return parseHandleSaiStatusFailure(handle_status);
1539+
}
1540+
}
1541+
SWSS_LOG_INFO("Set fec override %d to port pid:%" PRIx64, attr.value.booldata, port_obj);
1542+
return true;
1543+
}
1544+
15111545
bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t fec_mode)
15121546
{
15131547
SWSS_LOG_ENTER();
@@ -1527,6 +1561,10 @@ bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t fec_mode)
15271561
}
15281562
}
15291563

1564+
if (fec_override_sup && !setPortFecOverride(port.m_port_id, true))
1565+
{
1566+
return false;
1567+
}
15301568
setGearboxPortsAttr(port, SAI_PORT_ATTR_FEC_MODE, &fec_mode);
15311569

15321570
SWSS_LOG_NOTICE("Set port %s FEC mode %d", port.m_alias.c_str(), fec_mode);
@@ -2530,6 +2568,10 @@ bool PortsOrch::setGearboxPortAttr(const Port &port, dest_port_type_t port_type,
25302568
m_gearboxTable->hset(key, speed_attr, to_string(speed));
25312569
SWSS_LOG_NOTICE("BOX: Updated APPL_DB key:%s %s %d", key.c_str(), speed_attr.c_str(), speed);
25322570
}
2571+
else if (id == SAI_PORT_ATTR_FEC_MODE && fec_override_sup && !setPortFecOverride(dest_port_id, true))
2572+
{
2573+
return false;
2574+
}
25332575
}
25342576
else
25352577
{

orchagent/portsorch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ class PortsOrch : public Orch, public Subject
322322
map<string, uint32_t> m_bridge_port_ref_count;
323323

324324
NotificationConsumer* m_portStatusNotificationConsumer;
325+
bool fec_override_sup = false;
325326

326327
swss::SelectableTimer *m_port_state_poller = nullptr;
327328

@@ -379,6 +380,7 @@ class PortsOrch : public Orch, public Subject
379380
bool setPortPvid (Port &port, sai_uint32_t pvid);
380381
bool getPortPvid(Port &port, sai_uint32_t &pvid);
381382
bool setPortFec(Port &port, sai_port_fec_mode_t fec_mode);
383+
bool setPortFecOverride(sai_object_id_t port_obj, bool fec_override);
382384
bool setPortPfcAsym(Port &port, sai_port_priority_flow_control_mode_t pfc_asym);
383385
bool getDestPortId(sai_object_id_t src_port_id, dest_port_type_t port_type, sai_object_id_t &des_port_id);
384386

tests/test_port_fec_override.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import time
2+
import os
3+
import pytest
4+
5+
from swsscommon import swsscommon
6+
7+
DVS_ENV = ["HWSKU=Mellanox-SN2700"]
8+
9+
class TestPort(object):
10+
def test_PortFecOverride(self, dvs, testlog):
11+
db = swsscommon.DBConnector(0, dvs.redis_sock, 0)
12+
adb = dvs.get_asic_db()
13+
14+
ptbl = swsscommon.ProducerStateTable(db, "PORT_TABLE")
15+
16+
# set fec
17+
fvs = swsscommon.FieldValuePairs([("fec","rs")])
18+
ptbl.set("Ethernet4", fvs)
19+
20+
# validate if fec rs is pushed to asic db when set first time
21+
port_oid = adb.port_name_map["Ethernet4"]
22+
expected_fields = {"SAI_PORT_ATTR_FEC_MODE":"SAI_PORT_FEC_MODE_RS", "SAI_PORT_ATTR_AUTO_NEG_FEC_MODE_OVERRIDE":"true"}
23+
adb.wait_for_field_match("ASIC_STATE:SAI_OBJECT_TYPE_PORT", port_oid, expected_fields)
24+
25+
26+
# Add Dummy always-pass test at end as workaroud
27+
# for issue when Flaky fail on final test it invokes module tear-down before retrying
28+
def test_nonflaky_dummy():
29+
pass
30+

0 commit comments

Comments
 (0)