Skip to content

Commit

Permalink
Merge branch 'master' into vxlan-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prsunny authored Jan 6, 2025
2 parents 86d1383 + eadb549 commit bf11f1f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
4 changes: 4 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,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 @@ -2430,6 +2438,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

0 comments on commit bf11f1f

Please sign in to comment.