[SAI] Enhance Packet Trimming logic to support TC_VALUE fallback for … #2249
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…Dynamic Queue Resolution
This PR proposes a refinement to the packet trimming logic within the Switch Abstraction Interface.
The Problem:
Currently, when QUEUE_RESOLUTION is set to DYNAMIC and DSCP_RESOLUTION is set to DSCP_VALUE, the logic attempts to derive the Promoted_tc (Traffic Class) using a DSCP_TO_TC mapping. If this mapping is null (not defined), the logic defaults the Promoted_tc to 0.
This behavior makes it impossible for a user to predict or control the resulting queue_index when using dynamic mode without a global DSCP-to-TC map. There is currently no mechanism to utilize the explicitly programmed TC_VALUE attribute as a fallback in this specific scenario.
Proposed Solution:
Modify the logic so that if DSCP_RESOLUTION is DSCP_VALUE but no mapping exists (dscp_to_tc is null), the system utilizes the attr(TC_VALUE) provided by the SAI attribute. This ensures that the TC_VALUE attribute is not only useful for FROM_TC resolution modes but also serves as a valid source for deriving a dynamic queue index when DSCP resolution is insufficient.
Logic Comparison:
Current Logic:
`// Step 1: Derive Remarked DSCP
Remark_dscp = (attr(DSCP_RESOLUTION) == mode(DSCP_VALUE)) ?
attr(DSCP_VALUE) :
TC_TO_DSCP(attr(TC_VALUE));
// Step 2: Derive Queue Index
if (attr(QUEUE_RESOLUTION) == mode(STATIC)) {
queue_index = attr(QUEUE_INDEX);
} else { // mode(DYNAMIC)
if (attr(DSCP_RESOLUTION) == mode(DSCP_VALUE)) {
if (dscp_to_tc is not null) {
Promoted_tc = DSCP_TO_TC(Remark_dscp);
} else {
// ISSUE: Defaults to 0, ignoring user-defined TC_VALUE
Promoted_tc = 0;
}
} else { // attr(DSCP_RESOLUTION) == mode(FROM_TC)
Promoted_tc = attr(TC_VALUE);
}
queue_index = TC_TO_QUEUE(Promoted_tc);
}`
Proposed Logic:
`// Step 1: Derive Remarked DSCP (No Change)
Remark_dscp = (attr(DSCP_RESOLUTION) == DSCP_VALUE) ?
attr(DSCP_VALUE) :
TC_TO_DSCP(attr(TC_VALUE));
// Step 2: Derive Queue Index
if (attr(QUEUE_RESOLUTION) == STATIC) {
queue_index = attr(QUEUE_INDEX);
} else { // mode(DYNAMIC)
if (attr(DSCP_RESOLUTION) == DSCP_VALUE) {
if (dscp_to_tc is not null) {
Promoted_tc = DSCP_TO_TC(Remark_dscp);
} else {
// IMPROVEMENT: Use attr(TC_VALUE) as fallback for predictability
Promoted_tc = attr(TC_VALUE);
}
} else { // attr(DSCP_RESOLUTION) == FROM_TC
Promoted_tc = attr(TC_VALUE);
}
queue_index = TC_TO_QUEUE(Promoted_tc);
}`
Impact:
Predictability: Users can now explicitly define the Traffic Class via TC_VALUE to influence the dynamic queue index even when DSCP_RESOLUTION is active.
Consistency: Aligns the behavior of TC_VALUE across different resolution modes.
Backward Compatibility: This change does not break existing STATIC configurations or valid DSCP_TO_TC mappings.