Skip to content

[trim]: Add Packet Trimming Asym DSCP to OA#3705

Merged
prsunny merged 1 commit intosonic-net:masterfrom
nazariig:master-trim-asym
Jul 14, 2025
Merged

[trim]: Add Packet Trimming Asym DSCP to OA#3705
prsunny merged 1 commit intosonic-net:masterfrom
nazariig:master-trim-asym

Conversation

@nazariig
Copy link
Collaborator

@nazariig nazariig commented Jun 12, 2025

Signed-off-by: Nazarii Hnydyn nazariig@nvidia.com

DEPENDS:

  1. [trim]: Add Packet Trimming Asym DSCP to VS lib sonic-sairedis#1610
  2. [trim]: Add Packet Trimming to OA #3594

HLD: sonic-net/SONiC#1988

What I did

  • Implemented Packet Trimming Asymmetric DSCP feature

Why I did it

  • Implementation is done according to the Packet Trimming Asymmetric DSCP HLD

How I verified it

  1. Run Packet Trimming VS UTs

Details if related

  • N/A

A picture of a cute animal (not mandatory but encouraged)

      .---.        .-----------
     /     \  __  /    ------
    / /     \(  )/    -----
   //////   ' \/ `   ---
  //// / // :    : ---
 // /   /  /`    '--
//          //..\\
       ====UU====UU====
           '//||\\`
             ''``

@mssonicbld
Copy link
Collaborator

/azp run

@nazariig nazariig requested review from kperumalbfn and r12f June 12, 2025 14:33
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@nazariig nazariig marked this pull request as ready for review June 12, 2025 16:03
@zhangyanzhao zhangyanzhao requested a review from developfast June 27, 2025 04:08
@kperumalbfn
Copy link
Contributor

@nazariig could you resolve the conflicts

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@nazariig nazariig force-pushed the master-trim-asym branch from 2709cc6 to 10211ef Compare July 1, 2025 18:31
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

{
return ((pgRefCount > 0) || (iBufProfListRefCount > 0) || (eBufProfListRefCount)) ? true : false;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

we could keep all the counts as private and have methods to set/get. Would be clean to set/get by one method instead of direct access

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently not all egress buffer profiles are added to profile list. Could you please check?

https://github.com/sonic-net/sonic-buildimage/pull/22869/files

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we could keep all the counts as private and have methods to set/get. Would be clean to set/get by one method instead of direct access

@kperumalbfn Getter/Setter is a way of doing business logic encapsulation. In this case it is redundant and won't provide any benefits. That was the reason for omitting the implementation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently not all egress buffer profiles are added to profile list. Could you please check?

https://github.com/sonic-net/sonic-buildimage/pull/22869/files

The current implementation relies on application db events, meaning all buffer profiles are processed in a single place - bufferorch. Please elaborate on how this relates to the current validation case ?

{
auto &map = cfg.fieldValueMap;

const auto &cit = map.find(BUFFER_PORT_INGRESS_PROFILE_LIST_PROFILE_LIST);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does bufferorch use ingress/egress buffer profile list for trim eligible validation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kperumalbfn validation is currently implemented for the next cases:

  1. Buffer Profile is attached to either Ingress PG or Ingress/Egress Buffer Profile List and user tries to set trimming eligibility
  2. Buffer Profile is configured as trimming eligible and user tries to attach it either to Ingress PG or Ingress/Egress Buffer Profile list

In both cases the error will be generated.
This guarantees that trimming eligible Buffer Profile can be used only with the Queue objects.


inline bool isTrimmingProhibited() const
{
return ((pgRefCount > 0) || (iBufProfListRefCount > 0) || (eBufProfListRefCount)) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid this refcount to determine the trim eligibility?

Copy link
Contributor

Choose a reason for hiding this comment

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

if possible, buffer_profile-->buffer_pool(check ingress/egress)?

Copy link
Contributor

Choose a reason for hiding this comment

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

@stephenxs any other option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can we avoid this refcount to determine the trim eligibility?

@kperumalbfn currently the most reliable way. Checking counter value is a low cost operation comparing to collection iteration/search

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if possible, buffer_profile-->buffer_pool(check ingress/egress)?

@kperumalbfn Buffer Profile to Buffer Pool relation check (resolveFieldRefArray) is implemented as part of:
task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tuple)
task_process_status BufferOrch::processIngressBufferProfileList(KeyOpFieldsValuesTuple &tuple)
task_process_status BufferOrch::processEgressBufferProfileList(KeyOpFieldsValuesTuple &tuple)

Trimming eligibility validation serves different purposes and takes place long after this check, so it is not relevant

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not using the pools that the buffer profiles reference? That will be much easier to maintain.

SWSS_LOG_ERROR("Failed to set switch trimming TC value in SAI");
return false;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: empty new lines, pls check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kperumalbfn new line is added after if statement. No extra spaces are observed. Please elaborate on the issue

}
else
{
SWSS_LOG_WARN("Skip setting switch trimming TC value for symmetric DSCP mode");
Copy link
Contributor

Choose a reason for hiding this comment

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

return from here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kperumalbfn the implementation is by design. If the user tries to set TC value while operating in symmetric DSCP mode, SWSS will save the new value to cache and print the warning message. Later on if the mode will be switched to asymmetric, the cached value will be set to SAI.

The warning message is printed only once - in case if a new (differs from the value stored in the cache) TC value is configured.
That helps to maintain the minimal informative level while avoiding the log pollution (in case user/controller sets the same value for multiple times).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Nazarii Hnydyn <nazariig@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Collaborator

@prsunny prsunny left a comment

Choose a reason for hiding this comment

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

approving for merge. Code reviewed by SMEs

@prsunny prsunny merged commit ad80fa5 into sonic-net:master Jul 14, 2025
15 checks passed
@r12f
Copy link

r12f commented Jul 15, 2025

hi @nazariig , do you mind to help create a manual cherry pick to 202412 for this PR?

@dgsudharsan
Copy link
Collaborator

@r12f Here is the PR Azure/sonic-swss.msft#105

@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202505: #3765

bobby-nexthop pushed a commit to bobby-nexthop/sonic-swss that referenced this pull request Jul 24, 2025
DEPENDS:

[trim]: Add Packet Trimming Asym DSCP to VS lib sonic-sairedis#1610
[trim]: Add Packet Trimming to OA sonic-net#3594
HLD: sonic-net/SONiC#1988

What I did

Implemented Packet Trimming Asymmetric DSCP feature
Why I did it

Implementation is done according to the Packet Trimming Asymmetric DSCP HLD
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to msft-202506: Azure/sonic-swss.msft#120

Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
DEPENDS:

[trim]: Add Packet Trimming Asym DSCP to VS lib sonic-sairedis#1610
[trim]: Add Packet Trimming to OA sonic-net#3594
HLD: sonic-net/SONiC#1988

What I did

Implemented Packet Trimming Asymmetric DSCP feature
Why I did it

Implementation is done according to the Packet Trimming Asymmetric DSCP HLD
balanokia pushed a commit to balanokia/sonic-swss that referenced this pull request Nov 17, 2025
DEPENDS:

[trim]: Add Packet Trimming Asym DSCP to VS lib sonic-sairedis#1610
[trim]: Add Packet Trimming to OA sonic-net#3594
HLD: sonic-net/SONiC#1988

What I did

Implemented Packet Trimming Asymmetric DSCP feature
Why I did it

Implementation is done according to the Packet Trimming Asymmetric DSCP HLD
theasianpianist pushed a commit to theasianpianist/sonic-swss that referenced this pull request Feb 4, 2026
DEPENDS:

[trim]: Add Packet Trimming Asym DSCP to VS lib sonic-sairedis#1610
[trim]: Add Packet Trimming to OA sonic-net#3594
HLD: sonic-net/SONiC#1988

What I did

Implemented Packet Trimming Asymmetric DSCP feature
Why I did it

Implementation is done according to the Packet Trimming Asymmetric DSCP HLD

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
baorliu pushed a commit to baorliu/sonic-swss that referenced this pull request Feb 23, 2026
DEPENDS:

[trim]: Add Packet Trimming Asym DSCP to VS lib sonic-sairedis#1610
[trim]: Add Packet Trimming to OA sonic-net#3594
HLD: sonic-net/SONiC#1988

What I did

Implemented Packet Trimming Asymmetric DSCP feature
Why I did it

Implementation is done according to the Packet Trimming Asymmetric DSCP HLD

Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants