Skip to content

Commit cfa6f30

Browse files
authored
Merge branch 'master' into nhg-label
2 parents bcf3d74 + a3d6844 commit cfa6f30

21 files changed

Lines changed: 768 additions & 6 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### IP Multicast Group with members
2+
3+
Allow IP Multicast Group to be created/modified by specifying the list of members
4+
5+
### Motivation
6+
7+
The existing IPMC workflow
8+
* Create a IPMC group
9+
* Add/remove members to this group
10+
11+
We describe a sample workflow
12+
* A is added to the group
13+
* B is added to the group
14+
* The path to A goes down, so an alternate member A' is added
15+
* Subsequently the primary path to A is restored, so A' needs to be swapped with A
16+
17+
We have two ways to acheive this.
18+
* remove A' and then add A leading to a small window where no traffic is received by the receiver.
19+
* add A and then remove A' leading to a small window wheret duplicate traffic is received.
20+
21+
We'd like to avoid both of these scenarios.
22+
23+
### Proposal
24+
25+
Specify the full current list of multicast group members at create and update time.
26+
27+
* Introduce an attribute specifying that the IPMC group members are specified upfront.
28+
* Add a IPMC group attribute for the list of members
29+
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# [SAI] Round-robin Hash Algorithm
2+
-------------------------------------------------------------------------------
3+
Title | Round-robin Hash Algorithm
4+
-------------|-----------------------------------------------------------------
5+
Authors | Dhruvkumar Kadia, Ravindranath C K (Marvell)
6+
Status | In review
7+
Type | Standards track
8+
Created | 2024-09-19
9+
SAI-Version | 1.16
10+
-------------------------------------------------------------------------------
11+
12+
## 1.0 Introduction
13+
14+
ECMP or Next hop groups (NHG) and LAG use load balancing techniques to spread the traffic across the various members. The most common load balancing technique is to use hash-based member selection. In this technique, flows are identified by performing a hash on a set of packet fields like the 5-tuple, and then selecting the group member based on the computed hash value.
15+
This technique has been traditionally used since it:
16+
1) ensures packet ordering (since packets of a given flow are always sent out on the same member), and
17+
2) is stateless.
18+
19+
This proposal introduces the new hash algorithm Round-robin.
20+
21+
## 2.0 Behavior
22+
23+
### Existing hash based member selection
24+
For every packet hitting the ECMP/LAG, the egress member is selected based on the computed hash value.
25+
![Hash based member selection](figures/Hash_based.png)
26+
27+
### Existing random member selection
28+
For every packet hitting the ECMP/LAG, the egress member is randomly selected.
29+
![Random member selection](figures/Random.png)
30+
31+
Unlike ARS modes like SAI_ARS_MODE_PER_PACKET_RANDOM, the static member selection modes do not adapt based on the member link status.
32+
33+
### Round-robin member selection
34+
For every packet hitting the ECMP/LAG, the egress member is selected in round robin mode.
35+
![Round-robin member selection](figures/Round_robin.png)
36+
37+
#### Interaction with weighted ECMP
38+
For every packet hitting the ECMP/LAG, the egress member is selected in round robin mode considering the weights of member.
39+
![Round-robin member selection with weighted ecmp](figures/Round_robin_with_weights.png)
40+
41+
## 3.0 SAI Enhancement
42+
43+
A new enums are added to the sai_hash_algorithm_t
44+
New attributes are introduced in the NHG and LAG to allow the user to configure hash algorithm.
45+
Further, an ACL action is introduced to set the hash algorithm.
46+
47+
1) Enum defining the hash algorithm none and round-robin :
48+
```c
49+
/**
50+
* @brief Attribute data for #SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_ALGORITHM
51+
* and #SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_ALGORITHM
52+
*/
53+
typedef enum _sai_hash_algorithm_t
54+
{
55+
...
56+
/** Hash algorithm not set */
57+
SAI_HASH_ALGORITHM_NONE = 7,
58+
59+
/** Round-robin based hash algorithm (per-packet round-robin spraying) */
60+
SAI_HASH_ALGORITHM_ROUND_ROBIN = 8,
61+
62+
} sai_hash_algorithm_t;
63+
```
64+
2) Attributes for ECMP and LAG to set the hash algorithm:
65+
```c
66+
/**
67+
* @brief Attribute id for next hop
68+
*/
69+
typedef enum _sai_next_hop_group_attr_t
70+
{
71+
...
72+
/**
73+
* @brief Next hop group hash algorithm
74+
* Overrides value of SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_ALGORITHM if not set to SAI_HASH_ALGORITHM_NONE
75+
*
76+
* @type sai_hash_algorithm_t
77+
* @flags CREATE_ONLY
78+
* @default SAI_HASH_ALGORITHM_NONE
79+
* @validonly SAI_NEXT_HOP_GROUP_ATTR_TYPE == SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP or SAI_NEXT_HOP_GROUP_ATTR_TYPE == SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_ORDERED_ECMP
80+
*/
81+
SAI_NEXT_HOP_GROUP_ATTR_HASH_ALGORITHM,
82+
...
83+
} sai_next_hop_group_attr_t;
84+
```
85+
86+
```c
87+
/**
88+
* @brief LAG attribute: List of attributes for LAG object
89+
*/
90+
typedef enum _sai_lag_attr_t
91+
{
92+
...
93+
/**
94+
* @brief LAG hash algorithm
95+
* Overrides value of SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_ALGORITHM if not set to SAI_HASH_ALGORITHM_NONE
96+
*
97+
* @type sai_hash_algorithm_t
98+
* @flags CREATE_ONLY
99+
* @default SAI_HASH_ALGORITHM_NONE
100+
*/
101+
SAI_LAG_ATTR_HASH_ALGORITHM,
102+
...
103+
} sai_lag_attr_t;
104+
```
105+
3) ACL action:
106+
```c
107+
/**
108+
* @brief ACL Action Type
109+
*/
110+
typedef enum _sai_acl_action_type_t
111+
{
112+
...
113+
/** Set ECMP hash algorithm */
114+
SAI_ACL_ACTION_TYPE_SET_ECMP_HASH_ALGORITHM = 0x0000003c,
115+
116+
} sai_acl_action_type_t;
117+
118+
/**
119+
* @brief Attribute Id for sai_acl_entry
120+
*
121+
* @flags ranges
122+
*/
123+
typedef enum _sai_acl_entry_attr_t
124+
{
125+
...
126+
/**
127+
* @brief Set ECMP hash algorithm
128+
*
129+
* @type sai_acl_action_data_t sai_hash_algorithm_t
130+
* @flags CREATE_AND_SET
131+
* @default disabled
132+
*/
133+
SAI_ACL_ENTRY_ATTR_ACTION_SET_ECMP_HASH_ALGORITHM = SAI_ACL_ENTRY_ATTR_ACTION_START + 0x3c,
134+
135+
/**
136+
* @brief End of Rule Actions
137+
*/
138+
SAI_ACL_ENTRY_ATTR_ACTION_END = SAI_ACL_ENTRY_ATTR_ACTION_SET_ECMP_HASH_ALGORITHM,
139+
...
140+
} sai_acl_entry_attr_t;
141+
```
142+
143+
## 4.0 API Example
144+
145+
### Create Switch
146+
```c
147+
...(Existing Attribute)
148+
sai_attr_list[attr_count].id = SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_ALGORITHM;
149+
sai_attr_list[attr_count++].value.u32 = SAI_HASH_ALGORITHM_RANDOM;
150+
sai_create_switch_fn(
151+
&switch_id,
152+
attr_count,
153+
sai_attr_list);
154+
```
155+
156+
### Create Next Hop Group
157+
158+
```c
159+
...(Existing Attribute)
160+
sai_attr_list[attr_count].id = SAI_NEXT_HOP_GROUP_ATTR_HASH_ALGORITHM;
161+
sai_attr_list[attr_count++].value.u32 = SAI_HASH_ALGORITHM_ROUND_ROBIN;
162+
163+
sai_create_next_hop_group_fn(
164+
&nhg_oid,
165+
switch_id,
166+
attr_count,
167+
sai_attr_list);
168+
```
169+
170+
### Create LAG
171+
172+
```c
173+
...(Existing Attribute)
174+
sai_attr_list[attr_count].id = SAI_LAG_ATTR_HASH_ALGORITHM;
175+
sai_attr_list[attr_count++].value.u32 = SAI_HASH_ALGORITHM_ROUND_ROBIN;
176+
177+
sai_create_lag_fn(
178+
&lag_oid,
179+
switch_id,
180+
attr_count,
181+
sai_attr_list);
182+
```
183+
### Create ACL table
184+
```c
185+
count = 0;
186+
sai_attr_list[count].id = SAI_ACL_TABLE_ATTR_ACL_STAGE;
187+
sai_attr_list[count++].value.u32 = SAI_ACL_STAGE_INGRESS;
188+
sai_attr_list[count].id = SAI_ACL_TABLE_ATTR_FIELD_DST_IP;
189+
sai_attr_list[count++].value.booldata = 1;
190+
action_attr_list[0] = SAI_ACL_ACTION_TYPE_SET_ECMP_HASH_ALGORITHM;
191+
sai_action_attr_list.list = action_attr_list;
192+
sai_action_attr_list.count = 1;
193+
sai_attr_list[count].id = SAI_ACL_TABLE_ATTR_ACL_ACTION_TYPE_LIST;
194+
sai_attr_list[count++].value.s32list = sai_action_attr_list;
195+
attr_count = count;
196+
sai_create_acl_table_fn(
197+
&acl_table_id,
198+
switch_id,
199+
attr_count,
200+
sai_attr_list);
201+
```
202+
203+
### Create ACL entry
204+
```c
205+
count=0;
206+
sai_attr_list[count].id = SAI_ACL_ENTRY_ATTR_TABLE_ID;
207+
sai_attr_list[count++].value.oid = acl_table_id;
208+
sai_attr_list[count].id = SAI_ACL_ENTRY_ATTR_FIELD_DST_IP;
209+
sai_attr_list[count++].value.aclfield.data.ip4 = 0x0a000002;
210+
sai_attr_list[count].id = SAI_ACL_ENTRY_ATTR_ACTION_SET_ECMP_HASH_ALGORITHM;
211+
sai_attr_list[count++].value.aclfield.data.u32 = SAI_HASH_ALGORITHM_ROUND_ROBIN;
212+
sai_create_acl_entry_fn(
213+
&acl_entry_id,
214+
switch_id,
215+
attr_count,
216+
sai_attr_list);
217+
```

0 commit comments

Comments
 (0)