[hash] Add ECMP/LAG Hash Algorithm YANG model (#17079)

- Why I did it
Added YANG model as part of Generic Hash feature development

- How I did it
Added YANG model

- How to verify it
1. Add UT
2. Verified manually with the feature qualification

Signed-off-by: Nazarii Hnydyn <nazariig@nvidia.com>
This commit is contained in:
Nazarii Hnydyn 2023-11-20 17:43:58 +02:00 committed by GitHub
parent c43ea1c904
commit c99ec1f80a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 4 deletions

View File

@ -1194,7 +1194,7 @@ The FG_NHG_PREFIX table provides the FG_NHG_PREFIX for which FG behavior is desi
### Hash
Generic hash allows user to configure which hash fields are suppose to be used by a hashing algorithm.
Generic hash allows user to configure various aspects of hashing algorithm.
The configuration is applied globally for each ECMP and LAG on a switch.
***ECMP/LAG HASH***
@ -1238,7 +1238,9 @@ The configuration is applied globally for each ECMP and LAG on a switch.
"INNER_SRC_IP",
"INNER_L4_DST_PORT",
"INNER_L4_SRC_PORT"
]
],
"ecmp_hash_algorithm": "CRC",
"lag_hash_algorithm": "CRC"
}
}
}

View File

@ -339,7 +339,9 @@
"L4_SRC_PORT",
"INNER_DST_IP",
"INNER_SRC_IP"
]
],
"ecmp_hash_algorithm": "CRC",
"lag_hash_algorithm": "XOR"
}
},
"DEVICE_METADATA": {

View File

@ -9,5 +9,13 @@
"SWITCH_HASH_INVALID_LAG_HASH": {
"desc": "Configure invalid LAG_HASH in SWITCH_HASH.",
"eStrKey": "InvalidValue"
},
"SWITCH_HASH_INVALID_ECMP_HASH_ALGORITHM": {
"desc": "Configure invalid ECMP_HASH_ALGORITHM in SWITCH_HASH.",
"eStrKey": "InvalidValue"
},
"SWITCH_HASH_INVALID_LAG_HASH_ALGORITHM": {
"desc": "Configure invalid LAG_HASH_ALGORITHM in SWITCH_HASH.",
"eStrKey": "InvalidValue"
}
}

View File

@ -20,7 +20,9 @@
"L4_SRC_PORT",
"INNER_DST_IP",
"INNER_SRC_IP"
]
],
"ecmp_hash_algorithm": "CRC",
"lag_hash_algorithm": "XOR"
}
}
}
@ -46,5 +48,23 @@
}
}
}
},
"SWITCH_HASH_INVALID_ECMP_HASH_ALGORITHM": {
"sonic-hash:sonic-hash": {
"sonic-hash:SWITCH_HASH": {
"sonic-hash:GLOBAL": {
"ecmp_hash_algorithm": "INVALID_VALUE"
}
}
}
},
"SWITCH_HASH_INVALID_LAG_HASH_ALGORITHM": {
"sonic-hash:sonic-hash": {
"sonic-hash:SWITCH_HASH": {
"sonic-hash:GLOBAL": {
"lag_hash_algorithm": "INVALID_VALUE"
}
}
}
}
}

View File

@ -11,6 +11,10 @@ module sonic-hash {
description "HASH YANG Module for SONiC OS";
revision 2023-09-25 {
description "Added hashing algorithm configuration";
}
revision 2022-09-05 {
description "First Revision";
}
@ -57,6 +61,16 @@ module sonic-hash {
type hash:hash-field;
}
leaf ecmp_hash_algorithm {
description "Hash algorithm for hashing packets going through ECMP";
type stypes:hash-algorithm;
}
leaf lag_hash_algorithm {
description "Hash algorithm for hashing packets going through LAG";
type stypes:hash-algorithm;
}
}
/* end of container GLOBAL */
}

View File

@ -334,6 +334,19 @@ module sonic-types {
}
}
typedef hash-algorithm {
description "Represents hash algorithm";
type enumeration {
enum CRC;
enum XOR;
enum RANDOM;
enum CRC_32LO;
enum CRC_32HI;
enum CRC_CCITT;
enum CRC_XOR;
}
}
typedef timezone-name-type {
type string;
description