[vpp] Add sonic_ext packet-trim admission shim (SAI DROP_AND_TRIM datapath) - #269
Draft
aaronber0614 wants to merge 3 commits into
Draft
[vpp] Add sonic_ext packet-trim admission shim (SAI DROP_AND_TRIM datapath)#269aaronber0614 wants to merge 3 commits into
aaronber0614 wants to merge 3 commits into
Conversation
The KVM/DPDK VPP backend has no native egress QoS/admission substrate, so
add a software packet-trimming datapath to the sonic_ext plugin:
- trim_admission_node.c: per-{port,queue} software admission shim (token
bucket driven by the SONiC scheduler rate and buffer-profile capacity) on
the interface-output arc.
- trim_node.c: trim action (truncate -> DSCP rewrite -> static trim-queue
retry -> counters), including the multi-segment/jumbo fix that clears
VLIB_BUFFER_EXT_HDR_VALID on the severed segment so the virtio PMD does not
re-append the freed tail.
- trim_api.c, sonic_ext_trim.api, trim_cli.c: binary API and debug CLI used
to drive trimming from SAI-VPP.
- sonic_ext.{c,h}, CMakeLists.txt: register the trim nodes/API.
- rules/vpp.mk: bump VPP_VERSION for the plugin content change.
Validated end to end on vms-kvm-vpp-t1-lag (single-segment and jumbo).
Tracking: sonic-net/sonic-buildimage#25789
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
Address code-review gap H1 in the packet-trimming plugin: - sonic_ext_trim_enable_disable now returns int so callers can observe vnet_feature_enable_disable() failures instead of silently ignoring them. - sonic_ext_trim_queue_program transition-guards the interface-output feature-arc toggle on a new per-port feature_enabled flag: it computes any_eligible across all queues and only enables/disables on an actual eligibility transition. vnet_feature_enable_disable() is not idempotent, so this prevents refcount stacking (arc stuck enabled) and guarantees the arc is removed once no queue is trim-eligible. - rules/vpp.mk: bump VPP_VERSION 0.6 -> 0.7 for the plugin content change so downstream sonic-buildimage does not pull stale cached debs. Validated on the dev-VM t1-lag-vpp testbed: sonic-ext-trim-admission appears exactly once on an eligible egress port and is removed (count 0) once its queues become ineligible. Tracking: sonic-net/sonic-buildimage#25789 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
…s to the API caller Previously sonic_ext_trim_queue_program() returned void and only logged a clib_warning when the interface-output feature-arc enable/disable transition failed. The binary-API handler left rv=0 regardless, so SAI-VPP never saw the failure and could not retry, contradicting HLD REQ-12 (feature-arc enable failures must surface to the caller). Make the helper return int (0 on success, the vnet_feature_enable_disable error otherwise, and VNET_API_ERROR_INVALID_VALUE for an out-of-range queue), capture that in the queue_set handler so REPLY_MACRO forwards it as the reply retval, and surface it from the debug CLI. The queue state itself is still always programmed; only the eligibility feature-arc transition can fail, and port->feature_enabled is left untouched on failure so the next queue_set retries the transition. Bump VPP_VERSION suffix so downstream sonic-buildimage rebuilds the changed plugin instead of pulling a stale cached deb. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
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
There was a problem hiding this comment.
Pull request overview
Adds a new sonic_ext VPP plugin datapath implementing SAI DROP_AND_TRIM packet-trimming semantics for SONiC-VPP by introducing a software egress “admission shim” on the interface-output feature arc and a trim action node to rewrite DSCP, truncate, and re-queue to a static trim queue.
Changes:
- Introduces per-(port,queue) software token-bucket admission (
sonic-ext-trim-admission) and trim action (sonic-ext-trim) nodes. - Adds a binary API + debug CLI to program global trim policy, DSCP→queue mapping, and per-queue admission parameters, plus counters.
- Bumps
VPP_VERSIONcache key to force rebuild of modified custom plugins/patches.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| vppbld/plugins/sonic_ext/trim_admission_node.c | New interface-output feature node implementing software admission and divert-to-trim on rejection. |
| vppbld/plugins/sonic_ext/trim_node.c | New trim action node: DSCP rewrite, packet truncation, and enqueue to interface-output-arc-end / drop. |
| vppbld/plugins/sonic_ext/trim_api.c | New binary API handlers and shared admission helpers (port state, token-bucket admit, feature toggling). |
| vppbld/plugins/sonic_ext/trim_cli.c | New debug CLI for configuring and dumping trim policy, admission state, and counters. |
| vppbld/plugins/sonic_ext/sonic_ext_trim.api | New API definition for global policy, DSCP map, queue admission config, and counters. |
| vppbld/plugins/sonic_ext/sonic_ext.h | Adds trim state to sonic_ext_main_t, per-buffer orig_queue, and shared L3 parsing/DSCP rewrite inlines. |
| vppbld/plugins/sonic_ext/sonic_ext.c | Registers trim API hookup during plugin init and updates plugin description. |
| vppbld/plugins/sonic_ext/CMakeLists.txt | Adds new trim sources and API file; ensures include paths for generated API headers. |
| rules/vpp.mk | Updates VPP_VERSION suffix and clarifies when to bump it (patches + custom plugins). |
Comment on lines
+406
to
+409
| u32 v = | ||
| clib_net_to_host_u32 (ip->ip_version_traffic_class_and_flow_label); | ||
| v = (v & ~(0x3full << 22)) | (((u32) (new_dscp & 0x3f)) << 22); | ||
| ip->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32 (v); |
Comment on lines
+127
to
+137
| if (size != ~0) | ||
| sem->trim_size = size; | ||
| if (dscp != ~0) | ||
| sem->trim_dscp_value = dscp & 0x3f; | ||
| if (tc != ~0) | ||
| sem->trim_tc = tc; | ||
| if (queue != ~0) | ||
| sem->trim_queue = queue & (SONIC_EXT_TRIM_MAX_QUEUES - 1); | ||
| if (mode != -1) | ||
| sem->trim_dscp_mode = mode; | ||
| sem->trim_configured = 1; |
Comment on lines
+165
to
+180
| if (mp->is_enable) | ||
| { | ||
| sem->trim_size = ntohs (mp->trim_size); | ||
| sem->trim_dscp_mode = mp->dscp_mode; | ||
| sem->trim_dscp_value = mp->dscp_value & 0x3f; | ||
| sem->trim_tc = mp->tc_value; | ||
| sem->trim_queue = mp->trim_queue & (SONIC_EXT_TRIM_MAX_QUEUES - 1); | ||
| sem->trim_configured = 1; | ||
| } | ||
| else | ||
| { | ||
| sem->trim_configured = 0; | ||
| sem->trim_size = 0; | ||
| } | ||
|
|
||
| REPLY_MACRO (VL_API_SONIC_EXT_TRIM_GLOBAL_SET_REPLY); |
Comment on lines
+192
to
+196
| for (i = 0; i < 64; i++) | ||
| sem->dscp_to_queue[i] = | ||
| mp->dscp_to_queue[i] & (SONIC_EXT_TRIM_MAX_QUEUES - 1); | ||
|
|
||
| REPLY_MACRO (VL_API_SONIC_EXT_TRIM_DSCP_MAP_SET_REPLY); |
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
Adds the
sonic_extVPP plugin datapath that implements the SAIDROP_AND_TRIMpacket-trimming behavior for the SONiC-VPP platform.Because SONiC-VPP has no hardware queue-admission engine, trimming is
implemented as a software admission shim on the
interface-outputfeature arc. When a trim-eligible egress queue cannot admit a packet, the shim
truncates it to the configured size, rewrites DSCP, and re-queues it on the
configured static trim queue on the same physical egress; non-eligible or
unconfigured queues are passed straight through unpoliced (forwarding
unchanged).
Part of the SONiC packet-trimming enablement tracked in
sonic-net/sonic-buildimage#25789.
Changes
sonic_extplugin sources:trim_admission_node.c,trim_node.c,trim_api.c,trim_cli.c,sonic_ext_trim.api, andsonic_ext.hstate.{port,queue}admission/eligibility state.
rules/vpp.mkVPP_VERSION suffix bump so sonic-buildimage rebuilds thechanged plugin instead of pulling a stale cached deb.
Testing
t1-lag-vpptestbed(paired with the companion sonic-sairedis and sonic-mgmt changes).
Deferred (by design, tracked in the HLD)
Asymmetric
FROM_TCDSCP, dynamic queue resolution, ACLDISABLE_TRIM,per-port/queue SAI counter sourcing, and multi-worker bucket sharding.
🤖 Co-authored with GitHub Copilot.