[hash] Add Generic Hash YANG model (#13253)
- Why I did it Added YANG model as part of Generic Hash feature development - How I did it Added YANG model and UTs - How to verify it make configure PLATFORM=mellanox make target/sonic-mellanox.bin Signed-off-by: Nazarii Hnydyn <nazariig@nvidia.com>
This commit is contained in:
parent
c7d6b8ddbb
commit
7cedb09c96
@ -27,6 +27,7 @@ Table of Contents
|
||||
* [Device neighbor metada](#device-neighbor-metada)
|
||||
* [DSCP_TO_TC_MAP](#dscp_to_tc_map)
|
||||
* [FLEX_COUNTER_TABLE](#flex_counter_table)
|
||||
* [Hash](#hash)
|
||||
* [KDUMP](#kdump)
|
||||
* [Kubernetes Master](#kubernetes-master)
|
||||
* [L2 Neighbors](#l2-neighbors)
|
||||
@ -936,6 +937,58 @@ instance is supported in SONiC.
|
||||
|
||||
```
|
||||
|
||||
### Hash
|
||||
|
||||
Generic hash allows user to configure which hash fields are suppose to be used by a hashing algorithm.
|
||||
The configuration is applied globally for each ECMP and LAG on a switch.
|
||||
|
||||
***ECMP/LAG HASH***
|
||||
|
||||
```
|
||||
{
|
||||
"SWITCH_HASH": {
|
||||
"GLOBAL": {
|
||||
"ecmp_hash": [
|
||||
"DST_MAC",
|
||||
"SRC_MAC",
|
||||
"ETHERTYPE",
|
||||
"IP_PROTOCOL",
|
||||
"DST_IP",
|
||||
"SRC_IP",
|
||||
"L4_DST_PORT",
|
||||
"L4_SRC_PORT",
|
||||
"INNER_DST_MAC",
|
||||
"INNER_SRC_MAC",
|
||||
"INNER_ETHERTYPE",
|
||||
"INNER_IP_PROTOCOL",
|
||||
"INNER_DST_IP",
|
||||
"INNER_SRC_IP",
|
||||
"INNER_L4_DST_PORT",
|
||||
"INNER_L4_SRC_PORT"
|
||||
],
|
||||
"lag_hash": [
|
||||
"DST_MAC",
|
||||
"SRC_MAC",
|
||||
"ETHERTYPE",
|
||||
"IP_PROTOCOL",
|
||||
"DST_IP",
|
||||
"SRC_IP",
|
||||
"L4_DST_PORT",
|
||||
"L4_SRC_PORT",
|
||||
"INNER_DST_MAC",
|
||||
"INNER_SRC_MAC",
|
||||
"INNER_ETHERTYPE",
|
||||
"INNER_IP_PROTOCOL",
|
||||
"INNER_DST_IP",
|
||||
"INNER_SRC_IP",
|
||||
"INNER_L4_DST_PORT",
|
||||
"INNER_L4_SRC_PORT"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### KDUMP
|
||||
|
||||
```
|
||||
|
@ -116,6 +116,7 @@ setup(
|
||||
'./yang-models/sonic-extension.yang',
|
||||
'./yang-models/sonic-flex_counter.yang',
|
||||
'./yang-models/sonic-feature.yang',
|
||||
'./yang-models/sonic-hash.yang',
|
||||
'./yang-models/sonic-system-defaults.yang',
|
||||
'./yang-models/sonic-interface.yang',
|
||||
'./yang-models/sonic-kdump.yang',
|
||||
@ -200,6 +201,7 @@ setup(
|
||||
'./cvlyang-models/sonic-extension.yang',
|
||||
'./cvlyang-models/sonic-flex_counter.yang',
|
||||
'./cvlyang-models/sonic-feature.yang',
|
||||
'./cvlyang-models/sonic-hash.yang',
|
||||
'./cvlyang-models/sonic-system-defaults.yang',
|
||||
'./cvlyang-models/sonic-interface.yang',
|
||||
'./cvlyang-models/sonic-kdump.yang',
|
||||
|
@ -324,6 +324,28 @@
|
||||
"AETH_SYNDROME": "0x60/0x60"
|
||||
}
|
||||
},
|
||||
"SWITCH_HASH": {
|
||||
"GLOBAL": {
|
||||
"ecmp_hash": [
|
||||
"DST_IP",
|
||||
"SRC_IP",
|
||||
"IP_PROTOCOL",
|
||||
"L4_DST_PORT",
|
||||
"L4_SRC_PORT",
|
||||
"INNER_DST_IP",
|
||||
"INNER_SRC_IP"
|
||||
],
|
||||
"lag_hash": [
|
||||
"DST_IP",
|
||||
"SRC_IP",
|
||||
"IP_PROTOCOL",
|
||||
"L4_DST_PORT",
|
||||
"L4_SRC_PORT",
|
||||
"INNER_DST_IP",
|
||||
"INNER_SRC_IP"
|
||||
]
|
||||
}
|
||||
},
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"type": "ToRRouter",
|
||||
|
13
src/sonic-yang-models/tests/yang_model_tests/tests/hash.json
Normal file
13
src/sonic-yang-models/tests/yang_model_tests/tests/hash.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"SWITCH_HASH_VALID": {
|
||||
"desc": "Configure SWITCH_HASH."
|
||||
},
|
||||
"SWITCH_HASH_INVALID_ECMP_HASH": {
|
||||
"desc": "Configure invalid ECMP_HASH in SWITCH_HASH.",
|
||||
"eStrKey": "InvalidValue"
|
||||
},
|
||||
"SWITCH_HASH_INVALID_LAG_HASH": {
|
||||
"desc": "Configure invalid LAG_HASH in SWITCH_HASH.",
|
||||
"eStrKey": "InvalidValue"
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
{
|
||||
"SWITCH_HASH_VALID": {
|
||||
"sonic-hash:sonic-hash": {
|
||||
"sonic-hash:SWITCH_HASH": {
|
||||
"sonic-hash:GLOBAL": {
|
||||
"ecmp_hash": [
|
||||
"DST_IP",
|
||||
"SRC_IP",
|
||||
"IP_PROTOCOL",
|
||||
"L4_DST_PORT",
|
||||
"L4_SRC_PORT",
|
||||
"INNER_DST_IP",
|
||||
"INNER_SRC_IP"
|
||||
],
|
||||
"lag_hash": [
|
||||
"DST_IP",
|
||||
"SRC_IP",
|
||||
"IP_PROTOCOL",
|
||||
"L4_DST_PORT",
|
||||
"L4_SRC_PORT",
|
||||
"INNER_DST_IP",
|
||||
"INNER_SRC_IP"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"SWITCH_HASH_INVALID_ECMP_HASH": {
|
||||
"sonic-hash:sonic-hash": {
|
||||
"sonic-hash:SWITCH_HASH": {
|
||||
"sonic-hash:GLOBAL": {
|
||||
"ecmp_hash": [
|
||||
"INVALID_VALUE"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"SWITCH_HASH_INVALID_LAG_HASH": {
|
||||
"sonic-hash:sonic-hash": {
|
||||
"sonic-hash:SWITCH_HASH": {
|
||||
"sonic-hash:GLOBAL": {
|
||||
"lag_hash": [
|
||||
"INVALID_VALUE"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
67
src/sonic-yang-models/yang-models/sonic-hash.yang
Normal file
67
src/sonic-yang-models/yang-models/sonic-hash.yang
Normal file
@ -0,0 +1,67 @@
|
||||
module sonic-hash {
|
||||
|
||||
yang-version 1.1;
|
||||
|
||||
namespace "http://github.com/sonic-net/sonic-hash";
|
||||
prefix hash;
|
||||
|
||||
import sonic-types {
|
||||
prefix stypes;
|
||||
}
|
||||
|
||||
description "HASH YANG Module for SONiC OS";
|
||||
|
||||
revision 2022-09-05 {
|
||||
description "First Revision";
|
||||
}
|
||||
|
||||
typedef hash-field {
|
||||
description "Represents native hash field";
|
||||
type stypes:hash-field {
|
||||
enum IN_PORT;
|
||||
enum DST_MAC;
|
||||
enum SRC_MAC;
|
||||
enum ETHERTYPE;
|
||||
enum VLAN_ID;
|
||||
enum IP_PROTOCOL;
|
||||
enum DST_IP;
|
||||
enum SRC_IP;
|
||||
enum L4_DST_PORT;
|
||||
enum L4_SRC_PORT;
|
||||
enum INNER_DST_MAC;
|
||||
enum INNER_SRC_MAC;
|
||||
enum INNER_ETHERTYPE;
|
||||
enum INNER_IP_PROTOCOL;
|
||||
enum INNER_DST_IP;
|
||||
enum INNER_SRC_IP;
|
||||
enum INNER_L4_DST_PORT;
|
||||
enum INNER_L4_SRC_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
container sonic-hash {
|
||||
|
||||
container SWITCH_HASH {
|
||||
|
||||
description "SWITCH_HASH part of config_db.json";
|
||||
|
||||
container GLOBAL {
|
||||
|
||||
leaf-list ecmp_hash {
|
||||
description "Hash fields for hashing packets going through ECMP";
|
||||
type hash:hash-field;
|
||||
}
|
||||
|
||||
leaf-list lag_hash {
|
||||
description "Hash fields for hashing packets going through LAG";
|
||||
type hash:hash-field;
|
||||
}
|
||||
|
||||
}
|
||||
/* end of container GLOBAL */
|
||||
}
|
||||
/* end of container SWITCH_HASH */
|
||||
}
|
||||
/* end of container sonic-hash */
|
||||
}
|
||||
/* end of module sonic-hash */
|
@ -9,6 +9,10 @@ module sonic-pbh {
|
||||
prefix inet;
|
||||
}
|
||||
|
||||
import sonic-types {
|
||||
prefix stypes;
|
||||
}
|
||||
|
||||
import sonic-port {
|
||||
prefix port;
|
||||
}
|
||||
@ -25,7 +29,7 @@ module sonic-pbh {
|
||||
|
||||
typedef hash-field {
|
||||
description "Represents native hash field";
|
||||
type enumeration {
|
||||
type stypes:hash-field {
|
||||
enum INNER_IP_PROTOCOL;
|
||||
enum INNER_L4_DST_PORT;
|
||||
enum INNER_L4_SRC_PORT;
|
||||
|
@ -305,7 +305,33 @@ module sonic-types {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef hash-field {
|
||||
description "Represents native hash field";
|
||||
type enumeration {
|
||||
enum IN_PORT;
|
||||
enum DST_MAC;
|
||||
enum SRC_MAC;
|
||||
enum ETHERTYPE;
|
||||
enum VLAN_ID;
|
||||
enum IP_PROTOCOL;
|
||||
enum DST_IP;
|
||||
enum SRC_IP;
|
||||
enum L4_DST_PORT;
|
||||
enum L4_SRC_PORT;
|
||||
enum INNER_DST_MAC;
|
||||
enum INNER_SRC_MAC;
|
||||
enum INNER_ETHERTYPE;
|
||||
enum INNER_IP_PROTOCOL;
|
||||
enum INNER_DST_IP;
|
||||
enum INNER_DST_IPV4;
|
||||
enum INNER_DST_IPV6;
|
||||
enum INNER_SRC_IP;
|
||||
enum INNER_SRC_IPV4;
|
||||
enum INNER_SRC_IPV6;
|
||||
enum INNER_L4_DST_PORT;
|
||||
enum INNER_L4_SRC_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
{% if yang_model_type == "cvl" %}
|
||||
/* Required for CVL */
|
||||
|
Reference in New Issue
Block a user