[vslib/vpp] Implement SAI packet trimming (DROP_AND_TRIM) translation to VPP sonic_ext - #2017
Draft
aaronber0614 wants to merge 2 commits into
Draft
[vslib/vpp] Implement SAI packet trimming (DROP_AND_TRIM) translation to VPP sonic_ext#2017aaronber0614 wants to merge 2 commits into
aaronber0614 wants to merge 2 commits into
Conversation
…lane
Translate the SAI switch packet-trimming attributes onto the sonic_ext VPP
trim plugin and source trim counters:
- SwitchVpp.{cpp,h}: setSwitchTrimAttr / isTrimDataplaneAttr push global trim
policy (trim size, DSCP mode/value, trim queue) into VPP, plus capability
and stats handling.
- SaiVppXlate.{c,h}: binary API wrappers for the trim configuration calls.
- unittest/vslib/TestSwitchVpp.cpp: unit coverage for the trim attribute path.
Pairs with the sonic-platform-vpp sonic_ext trim dataplane.
Tracking: sonic-net/sonic-buildimage#25789
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
…fresh Address code-review gaps M1, M2 and H2 in the VPP packet-trim wiring: - M1 (error propagation): programTrimGlobal, refreshTrimDataplaneOnChange, refreshTrimDataplane, refreshTrimQueue and refreshTrimDscpToQueueMap now return sai_status_t and propagate VPP programming failures instead of returning void and swallowing them. A SET surfaces the failure; CREATE keeps it non-fatal so bring-up is not blocked by a transient push error. - M2 (qos-map refresh): isTrimDataplaneAttr now also recognizes the PORT qos-map attributes (DSCP_TO_TC / TC_TO_QUEUE bindings) and QOS_MAP object updates, so runtime qos reconfiguration re-resolves and re-pushes the trim DSCP->queue map and per-queue admission state instead of drifting. - H2 (unit tests): replace isPacketTrimSwitchAttr and isUnsupportedTrimEnumCapability -- which referenced methods that no longer exist and did not compile -- with real coverage for the new static getTrimEnumValuesCapability helper and for isTrimDataplaneAttr. Built clean under -Werror; three in-scope PTF trimming tests pass on the dev-VM t1-lag-vpp testbed. Tracking: sonic-net/sonic-buildimage#25789 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Author
|
Companion PRs (SONiC-VPP packet trimming, tracked in sonic-net/sonic-buildimage#25789):
Suggested review/merge order: HLD → sonic-platform-vpp → sonic-sairedis → sonic-mgmt. |
This was referenced Aug 3, 2026
[packet_trimming] Enable packet-trimming PTF coverage on the vpp platform
sonic-net/sonic-mgmt#26743
Draft
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the VPP-backed vslib (SwitchVpp) to translate SAI packet-trimming configuration (buffer-profile DROP_AND_TRIM + switch trim attributes) into sonic_ext VPP trim plugin programming, so orchagent’s trim configuration is enforced in the VPP admission datapath.
Changes:
- Add VPP binary-API wrappers for
sonic_ext_trimglobal policy, DSCP map, per-queue admission, and trim counters. - Implement switch-global trim policy tracking and idempotent global programming, plus recompute-all refresh of per-(port,queue) trim admission and switch-global DSCP→queue mapping derived from QoS objects.
- Add unit tests for trim-related capability overrides and “trim-relevant attribute” detection.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vslib/vpp/vppxlate/SaiVppXlate.h | Adds declarations for sonic_ext_trim control/counters APIs exposed to vslib. |
| vslib/vpp/vppxlate/SaiVppXlate.c | Implements sonic_ext_trim VPP message wiring, reply handlers, plugin msg-id base lookup, and wrapper functions returning VPP retval. |
| vslib/vpp/SwitchVpp.h | Declares trim policy state + trim programming/refresh helpers and overrides enum-values capability for supported trim modes. |
| vslib/vpp/SwitchVpp.cpp | Implements trim attribute handling, global policy programming, per-queue admission refresh, and DSCP→queue composition from QoS maps. |
| unittest/vslib/TestSwitchVpp.cpp | Adds unit tests for trim enum capability override and trim-dataplane attribute detection. |
Comment on lines
+1159
to
+1162
| case SAI_SWITCH_ATTR_PACKET_TRIM_SIZE: | ||
| m_trim_policy.trim_size = static_cast<uint16_t>(attr->value.u32); | ||
| m_trim_policy.enabled = (attr->value.u32 != 0); | ||
| break; |
Comment on lines
+1612
to
+1617
| uint8_t dscp_to_queue[64]; | ||
| for (int d = 0; d < 64; d++) | ||
| { | ||
| uint8_t tc = tc_by_dscp[d] & 0x3f; | ||
| dscp_to_queue[d] = queue_by_tc[tc]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What / Why
Implements the SAI packet-trimming (
DROP_AND_TRIM) translation in the VPPvslib so orchagent's trimming configuration is programmed onto the
sonic_extVPP admission datapath.
Part of the SONiC packet-trimming enablement tracked in
sonic-net/sonic-buildimage#25789.
Changes
vslib/vpp/SwitchVpp.{cpp,h}: translate SAI switch trim attributes andbuffer-profile
DROP_AND_TRIMeligibility into VPP global trim policy andper-
{port,queue}admission programming; resolve the switch-wideDSCP-to-queue table from bound QoS maps.
vslib/vpp/vppxlate/SaiVppXlate.{c,h}: binary-API wrappers for the newsonic_exttrim messages, propagating the VPP reply retval so failuressurface to orchagent for retry.
unittest/vslib/TestSwitchVpp.cpp: unit coverage for the translation.Testing
TestSwitchVppunit tests.t1-lag-vpptestbed with the companionsonic-platform-vpp and sonic-mgmt changes.
🤖 Co-authored with GitHub Copilot.