Skip to content

[trim]: Add Packet Trimming Drop Counters CLI#3993

Merged
qiluo-msft merged 2 commits intosonic-net:masterfrom
nazariig:master-trim-counter
Aug 11, 2025
Merged

[trim]: Add Packet Trimming Drop Counters CLI#3993
qiluo-msft merged 2 commits intosonic-net:masterfrom
nazariig:master-trim-counter

Conversation

@nazariig
Copy link
Collaborator

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

HLD: sonic-net/SONiC#2033

What I did

  • Implemented CLI for Packet Trimming Drop Counters feature

How I did it

  • Integrated Packet Trimming Drop Counters interface into config and show CLI root

How to verify it

  1. Run Packet Trimming CLI UTs

Previous command output (if the output of a command-line utility has changed)

admin@sonic:/home/admin# show interfaces counters trim Ethernet0
    IFACE    STATE    TRIM_PKTS
---------  -------  -----------
Ethernet0        U          100

New command output (if the output of a command-line utility has changed)

admin@sonic:/home/admin# show interfaces counters trim Ethernet0
    IFACE    STATE    TRIM_PKTS    TRIM_TX_PKTS    TRIM_DRP_PKTS
---------  -------  -----------  --------------  ---------------
Ethernet0        U          100              50               50

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

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

@mssonicbld
Copy link
Collaborator

/azp run

@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
Copy link
Collaborator Author

nazariig commented Aug 7, 2025

@kperumalbfn / @r12f this is a blocker for SWSS CI. Can you please help to review & merge?

@nazariig nazariig force-pushed the master-trim-counter branch from 604d80d to 9c182d8 Compare August 8, 2025 09:21
@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-counter branch from 9c182d8 to 6469494 Compare August 8, 2025 10:08
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

kperumalbfn
kperumalbfn previously approved these changes Aug 8, 2025
@kperumalbfn
Copy link
Contributor

@qiluo-msft Could you please merge this PR

@qiluo-msft qiluo-msft requested a review from Copilot August 8, 2025 20:30
Copy link
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

The PR implements CLI for Packet Trimming Drop Counters feature by adding new trimming counters (trimmed sent packets and trimmed dropped packets) in addition to the existing total trimmed packets counter. It extends both interface and switch-level statistics to support the new granular trimming counters.

  • Adds switch-level trimming statistics with new switchstat CLI command
  • Extends interface trimming counters to include sent and dropped packet counts
  • Updates all related utilities, tests, and mock data to support the new counters

Reviewed Changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utilities_common/switchstat.py New module implementing switch-level trimming statistics functionality
utilities_common/portstat.py Extended to support new trimmed sent/dropped packet counters
utilities_common/netstat.py Enhanced format functions to handle raw negative values
tests/switchstat_test.py Comprehensive test suite for new switch statistics CLI
tests/show_test.py Added tests for switch counter CLI integration
tests/portstat_test.py Updated to handle new trimming counter fields
Mock data files Updated to include new SAI counter values for testing
Comments suppressed due to low confidence (1)

utilities_common/portstat.py:47

  • The global constant BUCKET_NUM has been removed but there are still references to it in comments. Consider updating line 47 comment to reflect that the bucket count is now dynamically calculated using len(counter_bucket_dict).
The order and count of statistics mentioned below needs to be in sync with the values in portstat script

Signed-off-by: Nazarii Hnydyn <nazariig@nvidia.com>
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).

@nazariig
Copy link
Collaborator Author

@qiluo-msft review comments are handled. Can you please help to merge?

@nazariig nazariig requested a review from qiluo-msft August 11, 2025 18:11
@qiluo-msft qiluo-msft enabled auto-merge (squash) August 11, 2025 22:37
@qiluo-msft qiluo-msft merged commit c63e9ea into sonic-net:master Aug 11, 2025
7 checks passed
@r12f
Copy link

r12f commented Aug 12, 2025

hi @nazariig , do you mind to help us with a manual cherry pick?

@nazariig
Copy link
Collaborator Author

hi @nazariig , do you mind to help us with a manual cherry pick?

@r12f done

@yejianquan
Copy link
Contributor

Remove 202505 request label since packet trimming feature won't be included into 202505 branch.

mssonicbld added a commit to mssonicbld/sonic-mgmt.msft that referenced this pull request Oct 23, 2025
### Summary: Add packet trimming counter testcase phase1

### Related PR
- Add packet trimming drop counter test plan
sonic-net/sonic-mgmt#19824
- Packet Trimming: Drop Counters HLD
sonic-net/SONiC#2033
- [trim]: Add Packet Trimming Drop Counters YANG model
sonic-net/sonic-buildimage#23422
- [trim]: Add Packet Trimming Drop Counters DB schema
sonic-net/sonic-swss-common#1055
- [trim]: Add Packet Trimming Drop Counters to VS lib
sonic-net/sonic-sairedis#1630
- [trim]: Add Packet Trimming Drop Counters to OA
sonic-net/sonic-swss#3777
- [trim]: Add Packet Trimming Drop Counters CLI
sonic-net/sonic-utilities#3993

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
    - [ ] Skipped for non-supported platforms
- [ ] Test case improvement

### Back port request
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [x] 202505

### Approach
#### What is the motivation for this PR?

#### How did you do it?

#### How did you verify/test it?

#### Any platform specific information?

#### Supported testbed topology if it's a new test case?

### Documentation
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
mssonicbld added a commit to Azure/sonic-mgmt.msft that referenced this pull request Oct 23, 2025
### Summary: Add packet trimming counter testcase phase1

### Related PR
- Add packet trimming drop counter test plan
sonic-net/sonic-mgmt#19824
- Packet Trimming: Drop Counters HLD
sonic-net/SONiC#2033
- [trim]: Add Packet Trimming Drop Counters YANG model
sonic-net/sonic-buildimage#23422
- [trim]: Add Packet Trimming Drop Counters DB schema
sonic-net/sonic-swss-common#1055
- [trim]: Add Packet Trimming Drop Counters to VS lib
sonic-net/sonic-sairedis#1630
- [trim]: Add Packet Trimming Drop Counters to OA
sonic-net/sonic-swss#3777
- [trim]: Add Packet Trimming Drop Counters CLI
sonic-net/sonic-utilities#3993

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
 - [ ] Skipped for non-supported platforms
- [ ] Test case improvement

### Back port request
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [x] 202505

### Approach
#### What is the motivation for this PR?

#### How did you do it?

#### How did you verify/test it?

#### Any platform specific information?

#### Supported testbed topology if it's a new test case?

### Documentation
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
YairRaviv pushed a commit to YairRaviv/sonic-utilities that referenced this pull request Jan 12, 2026
HLD: sonic-net/SONiC#2033

What I did
Implemented CLI for Packet Trimming Drop Counters feature
How I did it
Integrated Packet Trimming Drop Counters interface into config and show CLI root
How to verify it
Run Packet Trimming CLI UTs
Previous command output (if the output of a command-line utility has changed)
admin@sonic:/home/admin# show interfaces counters trim Ethernet0
    IFACE    STATE    TRIM_PKTS
---------  -------  -----------
Ethernet0        U          100
New command output (if the output of a command-line utility has changed)
admin@sonic:/home/admin# show interfaces counters trim Ethernet0
    IFACE    STATE    TRIM_PKTS    TRIM_TX_PKTS    TRIM_DRP_PKTS
---------  -------  -----------  --------------  ---------------
Ethernet0        U          100              50               50
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.

8 participants