Skip to content

Conversation

@sriharsha-nexthop
Copy link

@sriharsha-nexthop sriharsha-nexthop commented Nov 4, 2025

Fixes : #3986

What I did

  1. While setting the capabilities check for SAI_SWITCH_ATTR_ECMP/LAG_HASH_IPV4/6 if SAI_SWITCH_ATTR_ECMP/LAG_HASH fails.
  2. Introduced a new flag platformSupportsOnlyV4V6. It will be set if unable to get the oid for SAI_SWITCH_ATTR_ECMP/LAG_HASH.
  3. When setting hash-fields for the first time (v4Oid or v6Oid == NULL), clear out the default field-list, create new object to get the oids and use them for subsequent hash-field settings.

Why I did it
For setting the global hash-fields, SONIC currently uses SAI_SWITCH_ATTR_ECMP/LAG_HASH.
However, Broadcom SAI only supports SAI_SWITCH_ATTR_ECMP/LAG_HASH_IPV4/6.
Hence, enhancing the hash-field support to include Broadcom SAI.

Also, Broadcom platform doesn't accept setting the fields with SAI_NULL_OBJECT_ID.
It needs the SONIC to create hash objects (for v4 and v6) and use them to set the hash-fields.
Also, since Broadcom SAI would've set some default values, they need to be cleared before setting new field-list.

How I verified it
Since this can not be verified on VS, I ran the command on Broadcom platform and used bcm shell commands to verify that correct fields are set.
Before the change

admin@gold230:~$ show switch-hash capabilities
+--------+---------------------------------+
| Hash   | Capabilities                    |
+========+=================================+
| ECMP   | +---------------+-------------+ |
|        | | Hash Field    | Algorithm   | |
|        | |---------------+-------------| |
|        | | not supported | CRC         | |
|        | |               | XOR         | |
|        | |               | CRC_32LO    | |
|        | |               | CRC_32HI    | |
|        | |               | CRC_CCITT   | |
|        | |               | CRC_XOR     | |
|        | +---------------+-------------+ |
+--------+---------------------------------+
| LAG    | +---------------+-------------+ |
|        | | Hash Field    | Algorithm   | |
|        | |---------------+-------------| |
|        | | not supported | CRC         | |
|        | |               | XOR         | |
|        | |               | CRC_32LO    | |
|        | |               | CRC_32HI    | |
|        | |               | CRC_CCITT   | |
|        | |               | CRC_XOR     | |
|        | +---------------+-------------+ |
+--------+---------------------------------+

After the change

admin@gold230-dut:~$ show switch-hash capabilities 
+--------+-------------------------------------------------------------------+
| Hash   | Capabilities                                                      |
+========+===================================================================+
| ECMP   | +-----------------+-------------+---------------+---------------+ |
|        | | Hash Field      | Algorithm   | Seed          | Offset        | |
|        | |-----------------+-------------+---------------+---------------| |
|        | | SRC_IP          | CRC         | not supported | not supported | |
|        | | DST_IP          | XOR         |               |               | |
|        | | VLAN_ID         | CRC_32LO    |               |               | |
|        | | IP_PROTOCOL     | CRC_32HI    |               |               | |
|        | | ETHERTYPE       | CRC_CCITT   |               |               | |
|        | | L4_SRC_PORT     | CRC_XOR     |               |               | |
|        | | L4_DST_PORT     |             |               |               | |
|        | | SRC_MAC         |             |               |               | |
|        | | DST_MAC         |             |               |               | |
|        | | IN_PORT         |             |               |               | |
|        | | IPV6_FLOW_LABEL |             |               |               | |
|        | +-----------------+-------------+---------------+---------------+ |
+--------+-------------------------------------------------------------------+
| LAG    | +-----------------+-------------+---------------+---------------+ |
|        | | Hash Field      | Algorithm   | Seed          | Offset        | |
|        | |-----------------+-------------+---------------+---------------| |
|        | | SRC_IP          | CRC         | not supported | not supported | |
|        | | DST_IP          | XOR         |               |               | |
|        | | VLAN_ID         | CRC_32LO    |               |               | |
|        | | IP_PROTOCOL     | CRC_32HI    |               |               | |
|        | | ETHERTYPE       | CRC_CCITT   |               |               | |
|        | | L4_SRC_PORT     | CRC_XOR     |               |               | |
|        | | L4_DST_PORT     |             |               |               | |
|        | | SRC_MAC         |             |               |               | |
|        | | DST_MAC         |             |               |               | |
|        | | IN_PORT         |             |               |               | |
|        | | IPV6_FLOW_LABEL |             |               |               | |
|        | +-----------------+-------------+---------------+---------------+ |
+--------+-------------------------------------------------------------------+

admin@gold230-dut:~$ sudo config switch-hash global ecmp-hash DST_IP L4_SRC_PORT
admin@gold230-dut:~$ sudo config switch-hash global lag-hash SRC_IP L4_DST_PORT
admin@gold230-dut:~$ show switch-hash  global
+--------+----------------------------------------------------+
| Hash   | Configuration                                      |
+========+====================================================+
| ECMP   | +--------------+-------------+--------+----------+ |
|        | | Hash Field   | Algorithm   | Seed   | Offset   | |
|        | |--------------+-------------+--------+----------| |
|        | | DST_IP       | N/A         | N/A    | N/A      | |
|        | | L4_SRC_PORT  |             |        |          | |
|        | +--------------+-------------+--------+----------+ |
+--------+----------------------------------------------------+
| LAG    | +--------------+-------------+--------+----------+ |
|        | | Hash Field   | Algorithm   | Seed   | Offset   | |
|        | |--------------+-------------+--------+----------| |
|        | | SRC_IP       | N/A         | N/A    | N/A      | |
|        | | L4_DST_PORT  |             |        |          | |
|        | +--------------+-------------+--------+----------+ |
+--------+----------------------------------------------------+

Details if related

@mssonicbld
Copy link
Collaborator

/azp run

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 4, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: sriharsha-nexthop / name: Sriharsha (5afa2ca)

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@venkit-nexthop
Copy link
Contributor

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@venkit-nexthop
Copy link
Contributor

@prsunny @lguohan
Could you approve the test for this PR?

@sriharsha-nexthop
Copy link
Author

resending ...
@prsunny @lguohan
Could you approve the workflow for this PR ? It is saying "workflow requires approval from a maintainer"

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sriharsha-nexthop sriharsha-nexthop marked this pull request as ready for review November 10, 2025 04:13
@sriharsha-nexthop sriharsha-nexthop force-pushed the sriharsha.v4v6-hash-changes branch from 7183033 to 5afa2ca Compare November 10, 2025 04:13
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sriharsha-nexthop
Copy link
Author

/azpw run Azure.sonic-swss

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-swss

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

Current hash-fields setting does not use SAI_SWITCH_ATTR_ECMP/LAG_HASH_IPV4/V6 attribute(s)

3 participants