Skip to content

[Hw PFCWD feature] Skeleton hw pfcwd#4403

Open
abhishek-nexthop wants to merge 5 commits into
sonic-net:masterfrom
nexthop-ai:skeleton-hw-pfcwd
Open

[Hw PFCWD feature] Skeleton hw pfcwd#4403
abhishek-nexthop wants to merge 5 commits into
sonic-net:masterfrom
nexthop-ai:skeleton-hw-pfcwd

Conversation

@abhishek-nexthop

Copy link
Copy Markdown

What I did
Added hardware-based PFC watchdog support with SKU-specific enablement. Created PfcWdHwOrch skeleton class that inherits from PfcWdBaseOrch, refactored shared functionality into the base class, and implemented runtime SKU detection to automatically choose between hardware and software watchdog implementations.

Why I did it
Modern switch ASICs support hardware-based PFC deadlock detection/recovery which is more efficient than software-based approaches. Need infrastructure to:
• Enable hardware watchdog only on supported SKUs
• Share common code between software and hardware implementations
• Gracefully fall back to software watchdog on unsupported platforms

How I verified it

  1. Code compiles successfully with new files added to Makefile
  2. SKU detection logic correctly identifies supported hardware:
    • Check logs: grep "PFC hardware watchdog" /var/log/syslog
    • Supported SKU shows: "HWSKU 'nh-4010' supports PFC hardware watchdog"
    • Unsupported SKU shows: "does not support PFC hardware watchdog"
  3. Correct watchdog instance created based on SKU and DLR init flag

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@abhishek-nexthop abhishek-nexthop changed the title Skeleton hw pfcwd [Hw PFCWD feature] Skeleton hw pfcwd Mar 28, 2026
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Abhishek <abhishek@nexthop.ai>
… functions.

Signed-off-by: Abhishek <abhishek@nexthop.ai>
Signed-off-by: Abhishek <abhishek@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vmittal-msft

Copy link
Copy Markdown
Contributor

@abhishek-nexthop please help resolve conflicts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an initial framework for hardware-based PFC watchdog (PFCWD) support in orchagent. It refactors existing PFCWD logic into a new PfcWdBaseOrch, moves the software watchdog implementation into PfcWdSwOrch, adds a skeleton PfcWdHwOrch, and wires runtime SKU detection to select HW vs SW watchdog at startup.

Changes:

  • Refactor PFC watchdog common logic into PfcWdBaseOrch and move software watchdog into new pfcwdsworch.* files.
  • Add PfcWdHwOrch skeleton and build plumbing (Makefiles, includes) for HW watchdog compilation.
  • Add HWSKU read + regex-based SKU support check in SwitchOrch, and select HW vs SW watchdog in OrchDaemon::init().

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/mock_tests/mock_orchagent_main.h Includes SW PFCWD header for mock test builds.
tests/mock_tests/Makefile.am Adds new PFCWD SW/HW source files to mock test build.
orchagent/switchorch.h Exposes HWSKU getter and HW PFCWD SKU support query.
orchagent/switchorch.cpp Implements HWSKU read from CONFIG_DB and SKU regex match helper.
orchagent/pfcwdsworch.h Introduces PfcWdSwOrch (software watchdog) as a separate class.
orchagent/pfcwdsworch.cpp Contains the migrated software watchdog implementation.
orchagent/pfcwdorch.h Introduces PfcWdBaseOrch to host shared PFCWD logic.
orchagent/pfcwdorch.cpp Implements the new base class and moves shared helpers into it.
orchagent/pfcwdhworch.h Adds HW PFCWD orchestrator class declaration (skeleton).
orchagent/pfcwdhworch.cpp Adds HW PFCWD orchestrator stub implementation (TODOs).
orchagent/orchdaemon.h Wires in new SW/HW PFCWD headers for orchagent build.
orchagent/orchdaemon.cpp Chooses HW vs SW watchdog based on SKU + DLR INIT enablement.
orchagent/Makefile.am Adds new SW/HW PFCWD source files to orchagent build.
Comments suppressed due to low confidence (1)

orchagent/orchdaemon.h:35

  • Both pfcwdorch.h and countercheckorch.h define PFC_WD_TC_MAX. Since orchdaemon.h includes both, this can trigger a macro redefinition warning (the build uses -Werror/-Wextra) and break the build depending on compiler settings. Consider consolidating the constant in one header; as a minimal mitigation here, undefine the macro before including countercheckorch.h.
#include "pfcwdorch.h"
#include "pfcwdsworch.h"
#include "pfcwdhworch.h"
#include "switchorch.h"
#include "crmorch.h"
#include "vrforch.h"
#include "vxlanorch.h"
#include "vnetorch.h"
#include "countercheckorch.h"

Comment thread orchagent/pfcwdhworch.cpp
Comment on lines +111 to +116
task_process_status PfcWdHwOrch::createEntry(const string& key, const vector<FieldValueTuple>& data)
{
SWSS_LOG_ENTER();
// TODO: Implementation
return task_process_status::task_success;
}
Comment thread orchagent/pfcwdhworch.cpp
Comment on lines +118 to +123
task_process_status PfcWdHwOrch::deleteEntry(const string& key)
{
SWSS_LOG_ENTER();
// TODO: Implementation
return task_process_status::task_success;
}
Comment thread orchagent/pfcwdhworch.cpp
Comment on lines +92 to +95
// TODO: Implementation
PfcWdQueueStats stats;
memset(&stats, 0, sizeof(PfcWdQueueStats));
return stats;
Comment thread orchagent/orchdaemon.cpp
Comment on lines +784 to +805
// Check if SKU supports PFC hardware watchdog
bool pfcHwWdSupportedSku = gSwitchOrch->isHwPfcWdSupportedSku();

if (pfcHwWdSupportedSku)
{
SWSS_LOG_NOTICE("HWSKU '%s' supports PFC hardware watchdog", gSwitchOrch->getHwSku().c_str());
}
else
{
SWSS_LOG_NOTICE("HWSKU '%s' does not support PFC hardware watchdog", gSwitchOrch->getHwSku().c_str());
}

if (pfcDlrInit && pfcHwWdSupportedSku)
{
SWSS_LOG_NOTICE("Starting hardware-based pfc watchdog");
m_orchList.push_back(new PfcWdHwOrch(
m_configDb,
pfc_wd_tables,
portStatIds,
queueStatIds,
queueAttrIds));
}
Comment thread orchagent/switchorch.cpp
Comment on lines +181 to +186
// Read HWSKU from CONFIG_DB
DBConnector configDb("CONFIG_DB", 0);
Table deviceMetadataTable(&configDb, CFG_DEVICE_METADATA_TABLE_NAME);
deviceMetadataTable.hget("localhost", "hwsku", m_hwSku);
SWSS_LOG_NOTICE("HWSKU: %s", m_hwSku.c_str());

@prsunny

prsunny commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

What is this PR about when there are other hw pfcwd PRs.? Folks, if this is experimental, please keep this as "draft".

Signed-off-by: Abhishek <abhishek@nexthop.ai>
Signed-off-by: Abhishek <abhishek@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@abhishek-nexthop

Copy link
Copy Markdown
Author

What is this PR about when there are other hw pfcwd PRs.? Folks, if this is experimental, please keep this as "draft".

@prsunny We have 3 PRs for pfcwd h/w orch.

  1. Refactor the existing code so it can be modularized for sw and hw classes,
  2. Boilerplate code for pfcwd hw orch(this PR)
  3. Implementation of pfcwd hw orch.
    There are other PR which are related to cli/sonic-mgmt/sonic-buildimage Please refer Feature/ PFCWD Hardware Recovery HLD SONiC#2159 for more details on PRs.

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks!

---Powered by SONiC BuildBot

@vmittal-msft

Copy link
Copy Markdown
Contributor

@abhishek-nexthop please take care of copilot comments. once depending PRs are in. we can do further review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants