From 7560a79f631c8b09cce264b8409bce345c53a732 Mon Sep 17 00:00:00 2001 From: Kumaresh Perumal Date: Tue, 21 May 2024 12:16:06 -0700 Subject: [PATCH] [swss]: Add default ECMP/LAG hash offset values for T0 and T1 (#18912) To avoid ECMP polarization, hash offset values are set from orchagent. Earlier, vendor SDK sets the hash_offset value internally with the same value as hash_seed. After introduction of SAI attributes(SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_OFFSET/SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_OFFSET), those changes in SDK were removed causing imbalance of traffic in T1s. This change will pass the ECMP/LAG HASH_OFFSET values from orchagent to SAI and set them in ASIC. Different ECMP/LAG hash_offset values are set for T0 and T1 in swss switch.json(ecmp_hash_offset and lag_hash_offset). Values are different for T0 and T1 to avoid ECMP/LAG hash polarization. As part of switch initialization, these values are passed to switch orchagent. Switch orchagent process these values and call SAI switch API to set these values. Will be merged after swss changes: sonic-net/sonic-swss#3138 sonic-mgmt - sonic-net/sonic-mgmt#12765 Microsoft ADO (number only): 25873808 --- dockers/docker-orchagent/switch.json.j2 | 6 ++++++ .../tests/sample_output/t0-switch-masic1.json | 2 ++ .../tests/sample_output/t0-switch-masic3.json | 2 ++ src/sonic-config-engine/tests/sample_output/t0-switch.json | 2 ++ src/sonic-config-engine/tests/sample_output/t1-switch.json | 2 ++ 5 files changed, 14 insertions(+) diff --git a/dockers/docker-orchagent/switch.json.j2 b/dockers/docker-orchagent/switch.json.j2 index 30ad703bc2..62dcb12547 100644 --- a/dockers/docker-orchagent/switch.json.j2 +++ b/dockers/docker-orchagent/switch.json.j2 @@ -2,11 +2,15 @@ {# set default hash seed to 0 #} {% set hash_seed = 0 %} {% set hash_seed_offset = 0 %} +{% set ecmp_hash_offset_value = 0 %} +{% set lag_hash_offset_value = 0 %} {% if DEVICE_METADATA.localhost.type %} {% if "ToRRouter" in DEVICE_METADATA.localhost.type or DEVICE_METADATA.localhost.type in ["EPMS", "MgmtTsToR"] %} {% set hash_seed = 0 %} {% elif "LeafRouter" in DEVICE_METADATA.localhost.type %} {% set hash_seed = 10 %} +{% set ecmp_hash_offset_value = 10 %} +{% set lag_hash_offset_value = 10 %} {% elif "SpineRouter" in DEVICE_METADATA.localhost.type %} {% set hash_seed = 25 %} {% endif %} @@ -21,6 +25,8 @@ "ecmp_hash_seed": "{{ hash_seed_value }}", "lag_hash_seed": "{{ hash_seed_value }}", "fdb_aging_time": "600", + "ecmp_hash_offset": "{{ ecmp_hash_offset_value }}", + "lag_hash_offset": "{{ lag_hash_offset_value }}", {% if DEVICE_METADATA.localhost.type and "LeafRouter" in DEVICE_METADATA.localhost.type %} "ordered_ecmp": "true" {% else %} diff --git a/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json b/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json index 83ca9f50ae..d64c5070fe 100644 --- a/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json +++ b/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json @@ -4,6 +4,8 @@ "ecmp_hash_seed": "11", "lag_hash_seed": "11", "fdb_aging_time": "600", + "ecmp_hash_offset": "10", + "lag_hash_offset": "10", "ordered_ecmp": "true" }, "OP": "SET" diff --git a/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json b/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json index db5d1b6e4a..2f91d5664d 100644 --- a/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json +++ b/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json @@ -4,6 +4,8 @@ "ecmp_hash_seed": "13", "lag_hash_seed": "13", "fdb_aging_time": "600", + "ecmp_hash_offset": "10", + "lag_hash_offset": "10", "ordered_ecmp": "true" }, "OP": "SET" diff --git a/src/sonic-config-engine/tests/sample_output/t0-switch.json b/src/sonic-config-engine/tests/sample_output/t0-switch.json index d585ca2a52..1dda7c549c 100644 --- a/src/sonic-config-engine/tests/sample_output/t0-switch.json +++ b/src/sonic-config-engine/tests/sample_output/t0-switch.json @@ -4,6 +4,8 @@ "ecmp_hash_seed": "0", "lag_hash_seed": "0", "fdb_aging_time": "600", + "ecmp_hash_offset": "0", + "lag_hash_offset": "0", "ordered_ecmp": "false" }, "OP": "SET" diff --git a/src/sonic-config-engine/tests/sample_output/t1-switch.json b/src/sonic-config-engine/tests/sample_output/t1-switch.json index 3b3b795919..bc5a02b216 100644 --- a/src/sonic-config-engine/tests/sample_output/t1-switch.json +++ b/src/sonic-config-engine/tests/sample_output/t1-switch.json @@ -4,6 +4,8 @@ "ecmp_hash_seed": "10", "lag_hash_seed": "10", "fdb_aging_time": "600", + "ecmp_hash_offset": "10", + "lag_hash_offset": "10", "ordered_ecmp": "true" }, "OP": "SET"