Skip to content

[vslib/vpp] Implement SAI packet trimming (DROP_AND_TRIM) translation to VPP sonic_ext - #2017

Draft
aaronber0614 wants to merge 2 commits into
sonic-net:masterfrom
aaronber0614:vpp-packet-trimming
Draft

[vslib/vpp] Implement SAI packet trimming (DROP_AND_TRIM) translation to VPP sonic_ext#2017
aaronber0614 wants to merge 2 commits into
sonic-net:masterfrom
aaronber0614:vpp-packet-trimming

Conversation

@aaronber0614

@aaronber0614 aaronber0614 commented Aug 3, 2026

Copy link
Copy Markdown

What / Why

Implements the SAI packet-trimming (DROP_AND_TRIM) translation in the VPP
vslib so orchagent's trimming configuration is programmed onto the sonic_ext
VPP 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 and
    buffer-profile DROP_AND_TRIM eligibility into VPP global trim policy and
    per-{port,queue} admission programming; resolve the switch-wide
    DSCP-to-queue table from bound QoS maps.
  • vslib/vpp/vppxlate/SaiVppXlate.{c,h}: binary-API wrappers for the new
    sonic_ext trim messages, propagating the VPP reply retval so failures
    surface to orchagent for retry.
  • unittest/vslib/TestSwitchVpp.cpp: unit coverage for the translation.

Testing

  • TestSwitchVpp unit tests.
  • End-to-end PTF stages 1–2 pass on a t1-lag-vpp testbed with the companion
    sonic-platform-vpp and sonic-mgmt changes.

Draft: opened for review only; depends on the companion
sonic-platform-vpp sonic_ext plugin PR (shared binary-API definition).


🤖 Co-authored with GitHub Copilot.

aaronber0614 and others added 2 commits July 30, 2026 20:05
…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>
Copilot AI review requested due to automatic review settings August 3, 2026 18:51
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@aaronber0614

Copy link
Copy Markdown
Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_trim global 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 thread vslib/vpp/SwitchVpp.cpp
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 thread vslib/vpp/SwitchVpp.cpp
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];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants