Skip to content

[Policer] Add per-color DSCP and TC action attributes - #2380

Open
Xungerrrr wants to merge 1 commit into
opencomputeproject:masterfrom
Xungerrrr:policer_color_dscp_tc_action
Open

Xungerrrr wants to merge 1 commit into
opencomputeproject:masterfrom
Xungerrrr:policer_color_dscp_tc_action

Conversation

@Xungerrrr

@Xungerrrr Xungerrrr commented Nov 3, 2026 •

Copy link
Copy Markdown

Add six CREATE_AND_SET policer attributes to inc/saipolicer.h to remark packet DSCP and/or traffic class (TC) per metered color:

  • SAI_POLICER_ATTR_GREEN_PACKET_SET_DSCP
  • SAI_POLICER_ATTR_YELLOW_PACKET_SET_DSCP
  • SAI_POLICER_ATTR_RED_PACKET_SET_DSCP
  • SAI_POLICER_ATTR_GREEN_PACKET_SET_TC
  • SAI_POLICER_ATTR_YELLOW_PACKET_SET_TC
  • SAI_POLICER_ATTR_RED_PACKET_SET_TC

Each attribute uses sai_uint8_t with default 255 = disabled (matching SAI_SWITCH_ATTR_MIRROR_TC). Valid values are 0..63 for DSCP (preserving ECN bits) and 0 .. SAI_SWITCH_ATTR_QOS_MAX_NUMBER_OF_TRAFFIC_CLASSES - 1 for TC.

How is this different from existing QoS map and ACL remark actions?

  • SAI_POLICER_ATTR_{GREEN,YELLOW,RED}_PACKET_ACTION only controls packet disposition (FORWARD, DROP, etc.) and cannot remark DSCP or TC.
  • Port/switch-level SAI_QOS_MAP_TYPE_TC_AND_COLOR_TO_DSCP maps apply uniformly to all traffic on a port for a given (TC, color) pair, whereas per-policer attributes allow different ACL-attached policers on the same port to remark out-of-profile (Yellow/Red) or in-profile (Green) flows to distinct target DSCPs/TCs while leaving unpoliced flows untouched.
  • SAI_ACL_ENTRY_ATTR_ACTION_SET_DSCP and SAI_ACL_ENTRY_ATTR_ACTION_SET_TC apply unconditionally to all packets matching the ACL entry regardless of metered color. When a per-color policer DSCP/TC action is enabled (!= 255) on an ACL-attached policer (SAI_ACL_ENTRY_ATTR_ACTION_SET_POLICER), it takes precedence over the unconditional ACL SET_DSCP / SET_TC action for packets of that color. Across stages, if an ingress-policed packet later matches an egress ACL (SAI_ACL_STAGE_EGRESS), an egress SET_DSCP runs later in the pipeline and overwrites the DSCP set by the ingress policer, whereas an egress SET_TC runs after egress queue selection (already determined by the ingress policer's SET_TC) and only affects post-queue egress QoS maps.

@azure-pipelines

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

Comment thread inc/saipolicer.h Resolved

@JaiOCP JaiOCP 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.

Looks good to me

@tjchadaga tjchadaga added the reviewed PR is discussed in SAI Meeting label Nov 5, 2026
Add six CREATE_AND_SET policer attributes to inc/saipolicer.h to support
remarking packet DSCP and internal traffic class (TC) per metered color
(Green, Yellow, Red), with a default sentinel value of 255 (disabled):

- SAI_POLICER_ATTR_GREEN_PACKET_SET_DSCP
- SAI_POLICER_ATTR_YELLOW_PACKET_SET_DSCP
- SAI_POLICER_ATTR_RED_PACKET_SET_DSCP
- SAI_POLICER_ATTR_GREEN_PACKET_SET_TC
- SAI_POLICER_ATTR_YELLOW_PACKET_SET_TC
- SAI_POLICER_ATTR_RED_PACKET_SET_TC

Signed-off-by: Xunyan Li <xunyanl@google.com>
@Xungerrrr
Xungerrrr force-pushed the policer_color_dscp_tc_action branch from 6fc570a to 26d693b Compare November 6, 2026 23:10
@Xungerrrr

Copy link
Copy Markdown
Author

Hi @tjchadaga @kcudnik @AnandhiDhanabalan, I've updated the PR based on the review feedback and Thursday's OCP SAI community meeting discussion (dropped the _ACTION suffix and clarified interaction with egress ACL DSCP/TC rewrites in the description). Could you please take a look when you get a chance? Thanks!

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor

@Xungerrrr ,

  1. SAI_POLICER_ATTR_* is also used by SAI_PORT_ATTR_POLICER_ID, the storm-control policer attrs and trap-group policers. Could you state in the header which bind points these six attrs apply to, and what an adapter should do for the others (ignore vs SAI_STATUS_ATTR_NOT_SUPPORTED_0)? In storm-control mode (SRTCM) the YELLOW attrs also need a note.

  2. A port with SAI_QOS_MAP_TYPE_TC_AND_COLOR_TO_DSCP bound on egress, plus a egress policer with GREEN/YELLOW/RED_PACKET_SET_DSCP set. Which wins? Also, when a policer changes TC, does DSCP_TO_TC reclassification or the egress QoS map key on the new TC?
    Also in some ASIC family the TC/DP-to-DSCP remarking path has precedence over other remarking, so "policer overrides" may not be implementable everywhere. Please specify the order, or declare it implementation-defined and add a capability hint.

  3. SAI_POLICER_ATTR_OBJECT_STAGE defaults to BOTH, but the description says an egress SET_TC only affects post-queue maps. Should the *_SET_TC attrs be restricted with @validonly SAI_POLICER_ATTR_OBJECT_STAGE (ingress)

  4. This covers DSCP and TC, but a NOS doing per-color mark-down on L2 also needs DOT1P, should we include DOT1P too ?

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.

6 participants