Skip to content

Commit

Permalink
Rm pfcwd_hw attributes
Browse files Browse the repository at this point in the history
Signed-off-by: bingwang <bingwang@microsoft.com>
  • Loading branch information
bingwang-ms committed Mar 11, 2022
1 parent 87edb68 commit 0408e94
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 40 deletions.
2 changes: 1 addition & 1 deletion orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::registerInWdDb(const Port& port,

uint8_t pfcMask = 0;

if (!gPortsOrch->getPortPfcWatchdogStatus(port.m_port_id, PFC_WD_SW, &pfcMask))
if (!gPortsOrch->getPortPfcWatchdogStatus(port.m_port_id, &pfcMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return false;
Expand Down
1 change: 0 additions & 1 deletion orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class Port
sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
uint8_t m_pfc_bitmask = 0; // PFC enable bit mask
uint8_t m_pfcwd_sw_bitmask = 0; // PFC software watchdog enable
uint8_t m_pfcwd_hw_bitmask = 0; // PFC hardware watchdog enable
uint16_t m_tpid = DEFAULT_TPID;
uint32_t m_nat_zone_id = 0;
uint32_t m_vnid = VNID_NONE;
Expand Down
28 changes: 8 additions & 20 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ bool PortsOrch::setPortPfc(sai_object_id_t portId, uint8_t pfc_bitmask)
return true;
}

bool PortsOrch::setPortPfcWatchdogStatus(sai_object_id_t portId, PfcWatchDogType type, uint8_t pfcwd_bitmask)
bool PortsOrch::setPortPfcWatchdogStatus(sai_object_id_t portId, uint8_t pfcwd_bitmask)
{
SWSS_LOG_ENTER();

Expand All @@ -1204,22 +1204,16 @@ bool PortsOrch::setPortPfcWatchdogStatus(sai_object_id_t portId, PfcWatchDogType
SWSS_LOG_ERROR("Failed to get port object for port id 0x%" PRIx64, portId);
return false;
}
if (type == PFC_WD_SW)
{
p.m_pfcwd_sw_bitmask = pfcwd_bitmask;
}
else
{
p.m_pfcwd_hw_bitmask = pfcwd_bitmask;
}


p.m_pfcwd_sw_bitmask = pfcwd_bitmask;

m_portList[p.m_alias] = p;

SWSS_LOG_INFO("Set PFC watchdog port id=0x%" PRIx64 ", bitmast=0x%x, type=%d", portId, pfcwd_bitmask, type);
SWSS_LOG_INFO("Set PFC watchdog port id=0x%" PRIx64 ", bitmast=0x%x", portId, pfcwd_bitmask);
return true;
}

bool PortsOrch::getPortPfcWatchdogStatus(sai_object_id_t portId, PfcWatchDogType type, uint8_t *pfcwd_bitmask)
bool PortsOrch::getPortPfcWatchdogStatus(sai_object_id_t portId, uint8_t *pfcwd_bitmask)
{
SWSS_LOG_ENTER();

Expand All @@ -1230,14 +1224,8 @@ bool PortsOrch::getPortPfcWatchdogStatus(sai_object_id_t portId, PfcWatchDogType
SWSS_LOG_ERROR("Failed to get port object for port id 0x%" PRIx64, portId);
return false;
}
if (type == PFC_WD_SW)
{
*pfcwd_bitmask = p.m_pfcwd_sw_bitmask;
}
else
{
*pfcwd_bitmask = p.m_pfcwd_hw_bitmask;
}

*pfcwd_bitmask = p.m_pfcwd_sw_bitmask;

return true;
}
Expand Down
9 changes: 2 additions & 7 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ struct VlanMemberUpdate
bool add;
};

enum PfcWatchDogType
{
PFC_WD_SW = 0, // PFC watchdog by software
PFC_WD_HW // PFC watchdog by hardware
};
class PortsOrch : public Orch, public Subject
{
public:
Expand Down Expand Up @@ -129,8 +124,8 @@ class PortsOrch : public Orch, public Subject
bool getPortPfc(sai_object_id_t portId, uint8_t *pfc_bitmask);
bool setPortPfc(sai_object_id_t portId, uint8_t pfc_bitmask);

bool setPortPfcWatchdogStatus(sai_object_id_t portId, PfcWatchDogType type, uint8_t pfc_bitmask);
bool getPortPfcWatchdogStatus(sai_object_id_t portId, PfcWatchDogType type, uint8_t *pfc_bitmask);
bool setPortPfcWatchdogStatus(sai_object_id_t portId, uint8_t pfc_bitmask);
bool getPortPfcWatchdogStatus(sai_object_id_t portId, uint8_t *pfc_bitmask);

void generateQueueMap();
void generatePriorityGroupMap();
Expand Down
12 changes: 3 additions & 9 deletions orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,6 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer)

sai_uint8_t pfc_enable = 0;
sai_uint8_t pfcwd_sw_enable = 0;
sai_uint8_t pfcwd_hw_enable = 0;
map<sai_port_attr_t, pair<string, sai_object_id_t>> update_list;
for (auto it = kfvFieldsValues(tuple).begin(); it != kfvFieldsValues(tuple).end(); it++)
{
Expand All @@ -1650,7 +1649,7 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer)
update_list[qos_to_attr_map[map_type_name]] = make_pair(map_name, id);
}

else if (fvField(*it) == pfc_enable_name || fvField(*it) == pfcwd_sw_enable_name || fvField(*it) == pfcwd_hw_enable_name)
else if (fvField(*it) == pfc_enable_name || fvField(*it) == pfcwd_sw_enable_name)
{
sai_uint8_t bitmask = 0;
vector<string> queue_indexes;
Expand All @@ -1665,13 +1664,9 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer)
{
pfc_enable = bitmask;
}
else if (fvField(*it) == pfcwd_sw_enable_name)
{
pfcwd_sw_enable = bitmask;
}
else
{
pfcwd_hw_enable = bitmask;
pfcwd_sw_enable = bitmask;
}
}
}
Expand Down Expand Up @@ -1726,8 +1721,7 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer)
}

// Save pfd_wd bitmask unconditionally
gPortsOrch->setPortPfcWatchdogStatus(port.m_port_id, PFC_WD_SW, pfcwd_sw_enable);
gPortsOrch->setPortPfcWatchdogStatus(port.m_port_id, PFC_WD_HW, pfcwd_hw_enable);
gPortsOrch->setPortPfcWatchdogStatus(port.m_port_id, pfcwd_sw_enable);
}

SWSS_LOG_NOTICE("Applied QoS maps to ports");
Expand Down
1 change: 0 additions & 1 deletion orchagent/qosorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const string pfc_to_pg_map_name = "pfc_to_pg_map";
const string pfc_to_queue_map_name = "pfc_to_queue_map";
const string pfc_enable_name = "pfc_enable";
const string pfcwd_sw_enable_name = "pfcwd_sw_enable";
const string pfcwd_hw_enable_name = "pfcwd_hw_enable";
const string tc_to_pg_map_field_name = "tc_to_pg_map";
const string tc_to_queue_field_name = "tc_to_queue_map";
const string scheduler_field_name = "scheduler";
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pfcwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _get_bitmask(self, queues):
return str(mask)

def set_ports_pfc(self, status='enable', pfc_queues=[3,4], watchdog_type='software'):
keyname = 'pfcwd_sw_enable' if watchdog_type == 'software' else 'pfcwd_hw_enable'
keyname = 'pfcwd_sw_enable'
for port in self.test_ports:
if 'enable' in status:
queues = ",".join([str(q) for q in pfc_queues])
Expand Down

0 comments on commit 0408e94

Please sign in to comment.