Skip to content

Add packet trimming counter #2177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged

Conversation

running-h
Copy link
Contributor

@running-h running-h commented Jun 18, 2025

This PR adds the following:

SAI_PORT_STAT_DROPPED_TRIM_PACKETS
SAI_PORT_STAT_TX_TRIM_PACKETS
SAI_QUEUE_STAT_DROPPED_TRIM_PACKETS
SAI_QUEUE_STAT_TX_TRIM_PACKETS
SAI_SWITCH_STAT_DROPPED_TRIM_PACKETS
SAI_SWITCH_STAT_TX_TRIM_PACKETS

@running-h running-h force-pushed the master branch 2 times, most recently from 68dd6ac to d5a3896 Compare June 19, 2025 07:00
inc/saiswitch.h Outdated
SAI_SWITCH_STAT_START,

/** Packets trimmed but dropped due to failed shared buffer admission on a new queue */
SAI_SWITCH_STAT_TRIM_DROPPED_PACKETS = SAI_SWITCH_STAT_START,
Copy link
Collaborator

Choose a reason for hiding this comment

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

please follow concept on other ranges if that the range name

SAI_SWITCH_STAT_TRIM_DROPPED_PACKETS_RANGE_BASE = SAI_SWITCH_STAT_START
...
SAI_SWITCH_STAT_TRIM_DROPPED_PACKETS_RANGE_END = 0x00000fff

or introduce other range, are you sure your stat type dont fit any existing range ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

the existing switch stats belong to clear group - in drop reasons (Debug counters), out drop reasons (debug counters) or fabric
While the trim stats are "regular" group
I don't see we keep regular group in other places like port or queue, nor do we group every stat to a group
in the future we may add other regular stats

@r12f
Copy link
Contributor

r12f commented Jun 24, 2025

hi @running-h , do you mind to rebase this PR and submit it again? The CI is somehow stuck.

inc/saiswitch.h Outdated
/** Switch stat range start */
SAI_SWITCH_STAT_START,

/** Packets trimmed but dropped due to failed shared buffer admission on a new queue */
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the comment to show this stat is a global-wise dropped trimmed packets for all original trim-enabled queues.

Choose a reason for hiding this comment

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

Please update the comment to show this stat is a global-wise dropped trimmed packets for all original trim-enabled queues.

we will change to "Global counter of packets trimmed but dropped due to failed shared buffer admission on a new queue for trimmed packets". OK ?

inc/saiport.h Outdated
@@ -3368,6 +3368,12 @@ typedef enum _sai_port_stat_t
/** Packets trimmed due to failed shared buffer admission [uint64_t] */
SAI_PORT_STAT_TRIM_PACKETS,

/** Packets trimmed but dropped due to failed shared buffer admission on a new queue for trimmed packets */
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this "new queue" sam as the "trim-queue" ?

Choose a reason for hiding this comment

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

Is this "new queue" sam as the "trim-queue" ?

Distinguish between trimming-eligible queue (where trimming instead of tail-drop is done) and queue where trimmed packets from all trimming-eligible queues are sent (new queue)

inc/saiswitch.h Outdated
SAI_SWITCH_STAT_START,

/** Packets trimmed but dropped due to failed shared buffer admission on a new queue */
SAI_SWITCH_STAT_TRIM_DROPPED_PACKETS = SAI_SWITCH_STAT_START,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the new enums be inserted at the end, and have an appropriate (new-range) base, instead of adding at the top ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

i have already answered to kamil
The in/out drop reasons are in group to be able to support a bigger range of debug counters. There are 8 pre-defined in/out counters, but application can create more than that, so we need a range
whomever decided to add fabric, did it with a range
but i don't see a reason to do that, nor do we do it in all other objects we use counters, we are not grouping every counter subject into a range, and all regular counters are always at the beginning

@@ -3599,6 +3605,9 @@ typedef enum _sai_switch_stat_t
/** Switch stat fabric drop reasons range end */
SAI_SWITCH_STAT_FABRIC_DROP_REASON_RANGE_END = 0x00003fff,

/** Switch stat range end */
SAI_SWITCH_STAT_END,
Copy link
Contributor

@bandaru-viswanath bandaru-viswanath Jun 24, 2025

Choose a reason for hiding this comment

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

Along side PORT and QUEUE, why not introduce TRIM_SENT_PACKETS for SWITCH also ? Will be consistent across.

Choose a reason for hiding this comment

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

added. Thanks for suggestion

@bandaru-viswanath
Copy link
Contributor

bandaru-viswanath commented Jun 25, 2025 via email

@running-h running-h force-pushed the master branch 2 times, most recently from 7e29369 to b8013b6 Compare June 26, 2025 07:51
inc/saiport.h Outdated
@@ -3368,6 +3368,12 @@ typedef enum _sai_port_stat_t
/** Packets trimmed due to failed shared buffer admission [uint64_t] */
SAI_PORT_STAT_TRIM_PACKETS,

/** Packets trimmed but dropped due to failed shared buffer admission on a new queue (for trimmed packets) */
SAI_PORT_STAT_TRIM_DROPPED_PACKETS,
Copy link
Contributor

Choose a reason for hiding this comment

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

We are following a fixed nomenclature like TRIM QUEUES, TRIM PACKET and so on.
Keeping consistent with it, please change the attr to
SAI_PORT_STAT_DROPPED_TRIM_PACKETS


/** Packets trimmed and successfully transmitted on port */
SAI_PORT_STAT_TRIM_SENT_PACKETS,

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. Please change it to
SAI_PORT_STAT_TX_TRIM_PACKETS

Choose a reason for hiding this comment

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

@JaiOCP - done

inc/saiqueue.h Outdated
@@ -433,6 +433,12 @@ typedef enum _sai_queue_stat_t
/** Get watermark queue shared occupancy in cells [uint64_t] */
SAI_QUEUE_STAT_SHARED_WATERMARK_CELLS = 0x0000002c,

/** Packets trimmed but failed to be admitted on a new queue (for trimmed packets) due to congestion. Counted on the original trimming-eligible queue [uint64_t] */
SAI_QUEUE_STAT_TRIM_DROPPED_PACKETS = 0x0000002d,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change it to
SAI_QUEUE_STAT_DROPPED_PACKETS

inc/saiqueue.h Outdated
SAI_QUEUE_STAT_TRIM_DROPPED_PACKETS = 0x0000002d,

/** Packets trimmed and successfully transmitted on a new queue (for trimmed packets). Counted on the original trimming-eligible queue [uint64_t] */
SAI_QUEUE_STAT_TRIM_SENT_PACKETS = 0x0000002e,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change it to
SAI_QUEUE_STAT_TX_TRIM_PACKETS

Choose a reason for hiding this comment

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

done

inc/saiswitch.h Outdated
SAI_SWITCH_STAT_START,

/** Global (switch-wise) counter of packets trimmed but dropped due to failed shared buffer admission on a new queue (for trimmed packets) */
SAI_SWITCH_STAT_TRIM_DROPPED_PACKETS = SAI_SWITCH_STAT_START,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change it to
SAI_SWITCH_STAT_DROPPED_TRIM_PACKETS

Choose a reason for hiding this comment

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

done

inc/saiswitch.h Outdated
SAI_SWITCH_STAT_TRIM_DROPPED_PACKETS = SAI_SWITCH_STAT_START,

/** Global (switch-wise) counter of packets trimmed and successfully sent on a new queue (for trimmed packets) */
SAI_SWITCH_STAT_TRIM_SENT_PACKETS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change it to
SAI_SWITCH_STAT_TX_TRIM_PACKETS

Choose a reason for hiding this comment

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

@JaiOCP - done. Jay, could you please approve the PR if everything is OK ? Thanks in advance

@tjchadaga
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tjchadaga tjchadaga requested a review from kcudnik June 26, 2025 15:30
@tjchadaga tjchadaga added the reviewed PR is discussed in SAI Meeting label Jun 26, 2025
@itaibaz
Copy link
Collaborator

itaibaz commented Jul 1, 2025

@kcudnik @r12f @bandaru-viswanath @JaiOCP
Can you please review the current version and approve or suggest if any further changes are needed ?

Copy link

@developfast developfast left a comment

Choose a reason for hiding this comment

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

as comments

SAI_QUEUE_STAT_DROPPED_TRIM_PACKETS = 0x0000002d,

/** Packets trimmed and successfully transmitted on a new queue (for trimmed packets). Counted on the original trimming-eligible queue [uint64_t] */
SAI_QUEUE_STAT_TX_TRIM_PACKETS = 0x0000002e,

Choose a reason for hiding this comment

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

The functional relationship between DROPPED_TRIM_PACKETS and TX_TRIM_PACKETS isn't clear. If TX_TRIM_PACKETS represents successfully transmitted trimmed packets, consider clarifying whether these are mutually exclusive counts or if there's overlap.

Choose a reason for hiding this comment

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

no overlap.
DROPPED_TRIM_PACKETS == trimmed & not sent
TX_TRIM_PACKETS == trimmed & sent

SAI_SWITCH_STAT_DROPPED_TRIM_PACKETS = SAI_SWITCH_STAT_START,

/** Global (switch-wise) counter of packets trimmed and successfully sent on a new queue (for trimmed packets) */
SAI_SWITCH_STAT_TX_TRIM_PACKETS,

Choose a reason for hiding this comment

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

is this for all ports and therefore queues cumulatively? if so, please make this explicit in the comments

Choose a reason for hiding this comment

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

it is mentioned as "Global (switch-wise)"

inc/saiqueue.h Outdated
@@ -433,6 +433,12 @@ typedef enum _sai_queue_stat_t
/** Get watermark queue shared occupancy in cells [uint64_t] */
SAI_QUEUE_STAT_SHARED_WATERMARK_CELLS = 0x0000002c,

/** Packets trimmed but failed to be admitted on a new queue (for trimmed packets) due to congestion. Counted on the original trimming-eligible queue [uint64_t] */

Choose a reason for hiding this comment

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

The switch enum is the only one getting START/END markers. For consistency, please add similar markers to port and queue enums, if necessary. Moreover, what is the overflow behavior here?

@rajkumar38
Copy link
Contributor

@eddyk-nvidia , pls capture the changes in the document SAI-Proposal-Packet-Trimming.md

@kcudnik
Copy link
Collaborator

kcudnik commented Jul 3, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

This PR adds the following:

SAI_PORT_STAT_DROPPED_TRIM_PACKETS
SAI_PORT_STAT_TX_TRIM_PACKETS
SAI_QUEUE_STAT_DROPPED_TRIM_PACKETS
SAI_QUEUE_STAT_TX_TRIM_PACKETS
SAI_SWITCH_STAT_DROPPED_TRIM_PACKETS
SAI_SWITCH_STAT_TX_TRIM_PACKETS

Signed-off-by: Running Huang <[email protected]>
@r12f
Copy link
Contributor

r12f commented Jul 7, 2025

/azp run opencomputeproject.SAI

Copy link

Commenter does not have sufficient privileges for PR 2177 in repo opencomputeproject/SAI

@tjchadaga
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tjchadaga tjchadaga requested a review from JaiOCP July 7, 2025 18:19
@tjchadaga
Copy link
Collaborator

@JaiOCP, @bandaru-viswanath - could you please help complete the review on this PR?

@tjchadaga tjchadaga merged commit 0bed1a5 into opencomputeproject:master Jul 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewed PR is discussed in SAI Meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.