Skip to content

Commit e37e55f

Browse files
authored
[pfcwd] Enhance DLR_INIT based recovery and DLR_PACKET_ACTION for broadcom platforms (sonic-net#2807)
Signed-off-by: Neetha John <nejo@microsoft.com> What I did This PR contains the following changes * for brcm platforms that support DLR_INIT based recovery, use that method for both drop and forward action * While using DLR_INIT based recovery, do not update the pfc bitmask for that port * Update the logic to handle allowing drop/forward action on all ports without requiring a restart of swss * Mock tests for DLR_INIT and DLR_PACKET action Why I did it To provide support for DLR_INIT based pfcwd recovery on broadcom platforms in certain roles How I verified it * Mock tests * Tested on various brcm platforms (TD3 dual tor, Th2 T1, TD3 single tor) with a custom swss deb along with updated bcm config and verified that the pfcwd recovery mechanism is as expected on 202205 * Tested on td3 dual tor with custom deb along with updated bcm config and verified functionality working fine on internal branch
1 parent 832371e commit e37e55f

File tree

6 files changed

+254
-6
lines changed

6 files changed

+254
-6
lines changed

orchagent/orchdaemon.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ bool OrchDaemon::init()
609609

610610
if(gSwitchOrch->checkPfcDlrInitEnable())
611611
{
612-
m_orchList.push_back(new PfcWdSwOrch<PfcWdDlrHandler, PfcWdLossyHandler>(
612+
m_orchList.push_back(new PfcWdSwOrch<PfcWdDlrHandler, PfcWdDlrHandler>(
613613
m_configDb,
614614
pfc_wd_tables,
615615
portStatIds,

orchagent/pfcactionhandler.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
extern sai_object_id_t gSwitchId;
2727
extern PortsOrch *gPortsOrch;
28+
extern SwitchOrch *gSwitchOrch;
2829
extern AclOrch * gAclOrch;
2930
extern sai_port_api_t *sai_port_api;
3031
extern sai_queue_api_t *sai_queue_api;
@@ -483,7 +484,7 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue
483484
SWSS_LOG_ENTER();
484485

485486
string platform = getenv("platform") ? getenv("platform") : "";
486-
if (platform == CISCO_8000_PLATFORM_SUBSTRING)
487+
if (platform == CISCO_8000_PLATFORM_SUBSTRING || ((platform == BRCM_PLATFORM_SUBSTRING) && (gSwitchOrch->checkPfcDlrInitEnable())))
487488
{
488489
SWSS_LOG_DEBUG("Skipping in constructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64,
489490
platform.c_str(), port);
@@ -510,7 +511,7 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void)
510511
SWSS_LOG_ENTER();
511512

512513
string platform = getenv("platform") ? getenv("platform") : "";
513-
if (platform == CISCO_8000_PLATFORM_SUBSTRING)
514+
if (platform == CISCO_8000_PLATFORM_SUBSTRING || ((platform == BRCM_PLATFORM_SUBSTRING) && (gSwitchOrch->checkPfcDlrInitEnable())))
514515
{
515516
SWSS_LOG_DEBUG("Skipping in destructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64,
516517
platform.c_str(), getPort());

orchagent/pfcwdorch.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ task_process_status PfcWdOrch<DropHandler, ForwardHandler>::createEntry(const st
238238
{
239239
if(gSwitchOrch->checkPfcDlrInitEnable())
240240
{
241-
if(getPfcDlrPacketAction() == PfcWdAction::PFC_WD_ACTION_UNKNOWN)
241+
if(m_pfcwd_ports.empty())
242242
{
243243
sai_attribute_t attr;
244244
attr.id = SAI_SWITCH_ATTR_PFC_DLR_PACKET_ACTION;
245-
attr.value.u32 = (sai_uint32_t)action;
245+
attr.value.u32 = packet_action_map.at(value);
246246

247247
sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
248248
if(status != SAI_STATUS_SUCCESS)
@@ -307,6 +307,7 @@ task_process_status PfcWdOrch<DropHandler, ForwardHandler>::createEntry(const st
307307
}
308308

309309
SWSS_LOG_NOTICE("Started PFC Watchdog on port %s", port.m_alias.c_str());
310+
m_pfcwd_ports.insert(port.m_alias);
310311
return task_process_status::task_success;
311312
}
312313

@@ -325,6 +326,7 @@ task_process_status PfcWdOrch<DropHandler, ForwardHandler>::deleteEntry(const st
325326
}
326327

327328
SWSS_LOG_NOTICE("Stopped PFC Watchdog on port %s", name.c_str());
329+
m_pfcwd_ports.erase(port.m_alias);
328330
return task_process_status::task_success;
329331
}
330332

@@ -1104,5 +1106,5 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::bake()
11041106
// Trick to keep member functions in a separate file
11051107
template class PfcWdSwOrch<PfcWdZeroBufferHandler, PfcWdLossyHandler>;
11061108
template class PfcWdSwOrch<PfcWdAclHandler, PfcWdLossyHandler>;
1107-
template class PfcWdSwOrch<PfcWdDlrHandler, PfcWdLossyHandler>;
1109+
template class PfcWdSwOrch<PfcWdDlrHandler, PfcWdDlrHandler>;
11081110
template class PfcWdSwOrch<PfcWdSaiDlrInitHandler, PfcWdActionHandler>;

orchagent/pfcwdorch.h

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ enum class PfcWdAction
2323
PFC_WD_ACTION_ALERT,
2424
};
2525

26+
static const map<string, sai_packet_action_t> packet_action_map = {
27+
{"drop", SAI_PACKET_ACTION_DROP},
28+
{"forward", SAI_PACKET_ACTION_FORWARD},
29+
{"alert", SAI_PACKET_ACTION_FORWARD}
30+
};
31+
2632
template <typename DropHandler, typename ForwardHandler>
2733
class PfcWdOrch: public Orch
2834
{
@@ -61,6 +67,7 @@ class PfcWdOrch: public Orch
6167
shared_ptr<DBConnector> m_countersDb = nullptr;
6268
shared_ptr<Table> m_countersTable = nullptr;
6369
PfcWdAction PfcDlrPacketAction = PfcWdAction::PFC_WD_ACTION_UNKNOWN;
70+
std::set<std::string> m_pfcwd_ports;
6471
};
6572

6673
template <typename DropHandler, typename ForwardHandler>

tests/mock_tests/mock_orchagent_main.h

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#define private public
1414
#include "bufferorch.h"
1515
#include "qosorch.h"
16+
#define protected public
17+
#include "pfcwdorch.h"
18+
#undef protected
1619
#undef private
1720
#include "vrforch.h"
1821
#include "vnetorch.h"
@@ -52,6 +55,7 @@ extern FdbOrch *gFdbOrch;
5255
extern MirrorOrch *gMirrorOrch;
5356
extern BufferOrch *gBufferOrch;
5457
extern QosOrch *gQosOrch;
58+
template <typename DropHandler, typename ForwardHandler> PfcWdSwOrch<DropHandler, ForwardHandler> *gPfcwdOrch;
5559
extern VRFOrch *gVrfOrch;
5660
extern NhgOrch *gNhgOrch;
5761
extern Srv6Orch *gSrv6Orch;

0 commit comments

Comments
 (0)