Skip to content
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

[action] [PR:3430] Ignore failure in setPortPfcAsym if SAI_STATUS_NOT_SUPPORTED #3475

Open
wants to merge 1 commit into
base: 202405
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,10 @@ bool PortsOrch::setPortPfcAsym(Port &port, sai_port_priority_flow_control_mode_t
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set PFC mode %d to port id 0x%" PRIx64 " (rc:%d)", pfc_asym, port.m_port_id, status);
if (status == SAI_STATUS_NOT_SUPPORTED)
{
return true;
}
task_process_status handle_status = handleSaiSetStatus(SAI_API_PORT, status);
if (handle_status != task_success)
{
Expand Down
67 changes: 64 additions & 3 deletions tests/mock_tests/portsorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ namespace portsorch_test
uint32_t _sai_set_link_event_damping_algorithm_count;
uint32_t _sai_set_link_event_damping_config_count;
int32_t _sai_link_event_damping_algorithm = 0;
bool set_pfc_asym_not_supported = false;
uint32_t set_pfc_asym_failures;
sai_redis_link_event_damping_algo_aied_config_t _sai_link_event_damping_config = {0, 0, 0, 0, 0};

sai_status_t _ut_stub_sai_set_port_attribute(
Expand All @@ -114,9 +116,15 @@ namespace portsorch_test
/* Simulating failure case */
return SAI_STATUS_FAILURE;
}
else if (attr[0].id == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED)
{
_sai_set_pfc_mode_count++;
else if (attr[0].id == SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_MODE)
{
_sai_set_pfc_mode_count++;
/* Simulating failure case */
if (set_pfc_asym_not_supported)
{
set_pfc_asym_failures++;
return SAI_STATUS_NOT_SUPPORTED;
}
}
else if (attr[0].id == SAI_PORT_ATTR_ADMIN_STATE)
{
Expand Down Expand Up @@ -2272,6 +2280,59 @@ namespace portsorch_test
mock_port_fec_modes = old_mock_port_fec_modes;
_unhook_sai_port_api();
}

/*
* Test case: SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_MODE is not supported by vendor
**/
TEST_F(PortsOrchTest, PortPFCNotSupported)
{
_hook_sai_port_api();
Table portTable = Table(m_app_db.get(), APP_PORT_TABLE_NAME);
std::deque<KeyOpFieldsValuesTuple> entries;

set_pfc_asym_not_supported = true;
// Get SAI default ports to populate DB
auto ports = ut_helper::getInitialSaiPorts();

for (const auto &it : ports)
{
portTable.set(it.first, it.second);
}

// Set PortConfigDone
portTable.set("PortConfigDone", { { "count", to_string(ports.size()) } });

// refill consumer
gPortsOrch->addExistingData(&portTable);

// Apply configuration :
// create ports
static_cast<Orch *>(gPortsOrch)->doTask();

uint32_t current_sai_api_call_count = _sai_set_pfc_mode_count;

entries.push_back({"Ethernet0", "SET",
{
{ "pfc_asym", "off"}
}});
auto consumer = dynamic_cast<Consumer *>(gPortsOrch->getExecutor(APP_PORT_TABLE_NAME));
consumer->addToSync(entries);
static_cast<Orch *>(gPortsOrch)->doTask();
entries.clear();

ASSERT_EQ(_sai_set_pfc_mode_count, ++current_sai_api_call_count);
ASSERT_EQ(set_pfc_asym_failures, 1);

set_pfc_asym_not_supported = false;

vector<string> ts;

gPortsOrch->dumpPendingTasks(ts);
ASSERT_TRUE(ts.empty());

_unhook_sai_port_api();
}

TEST_F(PortsOrchTest, PortTestSAIFailureHandling)
{
_hook_sai_port_api();
Expand Down
Loading