Skip to content

[switchorch]: Add sampled mirror and truncation capability discovery#4502

Open
Janetxxx wants to merge 1 commit intosonic-net:masterfrom
Janetxxx:dev/jc/sampled-port-mirror-capability
Open

[switchorch]: Add sampled mirror and truncation capability discovery#4502
Janetxxx wants to merge 1 commit intosonic-net:masterfrom
Janetxxx:dev/jc/sampled-port-mirror-capability

Conversation

@Janetxxx
Copy link
Copy Markdown
Contributor

What I did
Added capability discovery for sampled port mirroring and packet truncation in SwitchOrch. Three new capabilities are queried at startup via sai_query_attribute_capability() and written to STATE_DB
under SWITCH_CAPABILITY|switch:

  • PORT_INGRESS_SAMPLE_MIRROR_CAPABLE — SAI_PORT_ATTR_INGRESS_SAMPLE_MIRROR_SESSION
  • PORT_EGRESS_SAMPLE_MIRROR_CAPABLE — SAI_PORT_ATTR_EGRESS_SAMPLE_MIRROR_SESSION
  • SAMPLEPACKET_TRUNCATION_CAPABLE — SAI_SAMPLEPACKET_ATTR_TRUNCATE_ENABLE

Why I did it
This is part of the sampled port mirroring with truncation feature. MirrorOrch and CLI need to know at runtime whether the platform supports sampled mirroring and truncation, so they can gracefully fall back to full mirroring on platforms that do not support these capabilities.

How I verified it

  • Code follows the existing pattern used by querySwitchPortMirrorCapability() and querySwitchPortEgressSampleCapability()
  • VS test to be added in follow-up
    Details if related

Signed-off-by: Janet Cui <janet970527@gmail.com>
Copilot AI review requested due to automatic review settings April 21, 2026 12:25
@Janetxxx Janetxxx requested a review from prsunny as a code owner April 21, 2026 12:25
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SwitchOrch startup capability discovery for sampled port mirroring and samplepacket truncation, publishing results into SWITCH_CAPABILITY|switch for consumption by other components (e.g., MirrorOrch/CLI) to enable runtime feature gating.

Changes:

  • Introduces new capability keys for ingress/egress sampled mirror and samplepacket truncation in switchorch.h.
  • Adds SwitchOrch::querySwitchSampledMirrorCapability() to query SAI attribute capabilities and store results in STATE_DB.
  • Exposes new SwitchOrch getters for sampled mirror and truncation support flags.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
orchagent/switchorch.h Adds new capability key macros, new public support getters, and a private query method declaration.
orchagent/switchorch.cpp Calls the new query at startup and implements SAI capability discovery + STATE_DB publishing.

Comment thread orchagent/switchorch.h
Comment on lines +36 to +38
#define SWITCH_CAPABILITY_TABLE_PORT_INGRESS_SAMPLE_MIRROR_CAPABLE "PORT_INGRESS_SAMPLE_MIRROR_CAPABLE"
#define SWITCH_CAPABILITY_TABLE_PORT_EGRESS_SAMPLE_MIRROR_CAPABLE "PORT_EGRESS_SAMPLE_MIRROR_CAPABLE"
#define SWITCH_CAPABILITY_TABLE_SAMPLEPACKET_TRUNCATION_CAPABLE "SAMPLEPACKET_TRUNCATION_CAPABLE"
Comment thread orchagent/switchorch.h
void querySwitchTpidCapability();
void querySwitchPortEgressSampleCapability();
void querySwitchPortMirrorCapability();
void querySwitchSampledMirrorCapability();
Comment thread orchagent/switchorch.cpp
Comment on lines +2002 to +2005
}

set_switch_capability(fvVector);
}
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.

3 participants