Skip to content

Commit

Permalink
Merge branch 'master' into evpn-mh
Browse files Browse the repository at this point in the history
  • Loading branch information
srj102 authored Nov 13, 2024
2 parents 67ddc09 + a0aa5a3 commit 8164439
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ GEN_SAIRPC_OPTS?=
# Passed to meta/Makefile via "make saithrift-build, can specify add'l libraries along with libsai
SAIRPC_EXTRA_LIBS?=

SAI_HEADER_DIR=../../inc

.PHONY: test doc clean

doc: meta/xml
Expand All @@ -46,7 +48,7 @@ test:
make -C test

saithrift-build:
SAIRPC_EXTRA_LIBS="$(SAIRPC_EXTRA_LIBS)" GEN_SAIRPC_OPTS="$(GEN_SAIRPC_OPTS)" make -C $(SAITHRIFT_PATH)
SAIRPC_EXTRA_LIBS="$(SAIRPC_EXTRA_LIBS)" GEN_SAIRPC_OPTS="$(GEN_SAIRPC_OPTS)" SAI_HEADER_DIR="$(SAI_HEADER_DIR)" make -C $(SAITHRIFT_PATH)

saithrift-install: saithrift-build
make -C $(SAITHRIFT_PATH) install
Expand Down
85 changes: 85 additions & 0 deletions doc/ECMP/NextHopGroup_with_members.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
### Next hop group with members

Introduce a new type of Next hop group, that is created/modified by specifying the list of next hop members along with their weights.

### Motivation

The existing workflow to create Next hop groups involves these steps
* Create a Next hop group
* Add next hop to this group

Next hop groups can be modified by
* Removing existing next hop group members
* Modifying attributes of existing next hop group members
* Adding new next hop group members

This multi-step process to modify Next hop groups can lead to the Next hop group to be in intermediate state(s) before finally matching the application intent. The sequence of add/modify/delete must ensure that the number of next hop group members do not exceed the maximum size of the Next hop group. The group should not be unintentionally empty. This sequence may lead to the Next hop group to have less forwarding capacity in the intermediate states.

If we could instead specify the current list of next hop group members, we could modify the Next hop group in one step.

### Proposal

* Introduce a new type of Next hop group
* Add a new Next hop group attribute for the list of Next hops
* Add a new Next hop group attribute for the list of weights
* Create/modify the Next hop group by specifying both of the above lists

No next hop group member objects will be created in this workflow.
Any modification of the next hop group will need the application to pass in the
current list of next hops.
The member next hops need not be removed before removing the next hop group.

### Example

Create a next hop group.

```
std::vector<sai_object_id_t> nh_oids{nh1, nh2, nh3};
std::vector<uint32_t> weights{1, 2, 1};
std::vector<sai_attribute_t> group_attr;
attr.id = SAI_NEXT_HOP_GROUP_ATTR_TYPE;
attr.value.s32 = SAI_NEXT_HOP_GROUP_TYPE_ECMP_WITH_MEMBERS;
group_attr.push_back(attr);
attr.id = SAI_NEXT_HOP_GROUP_ATTR_NEXT_HOP_MEMBER_WEIGHT_LIST;
attr.value.u32list.count = (uint32_t)weights.size();
attr.value.u32list.list = weights.data();
group_attr.push_back(attr);
attr.id = SAI_NEXT_HOP_GROUP_ATTR_NEXT_HOP_LIST;
attr.value.objlist.count = (uint32_t)nh_oids.size();
attr.value.objlist.list = nh_oids.data();
group_attr.push_back(attr);
sai_status_t status =
sai_next_hop_group_api->create_next_hop_group(&group_oid, switchid,
(uint32_t)group_attr.size(), group_attr.data());
```

Modify follows the same pattern by specifying the new list of next hops and weights via the bulk set api

```
std::vector<sai_object_id_t> nh_oids{nh1, nh3, nh4};
std::vector<uint32_t> weights{1, 2, 3};
std::vector<sai_attribute_t> group_attr;
std::vector<sai_object_id_t> nhg_oids{nhg1, nhg1};
std::vector<sai_status_t> statuses;
attr.id = SAI_NEXT_HOP_GROUP_ATTR_NEXT_HOP_MEMBER_WEIGHT_LIST;
attr.value.u32list.count = (uint32_t)weights.size();
attr.value.u32list.list = weights.data();
group_attr.push_back(attr);
attr.id = SAI_NEXT_HOP_GROUP_ATTR_NEXT_HOP_LIST;
attr.value.objlist.count = (uint32_t)nh_oids.size();
attr.value.objlist.list = nh_oids.data();
group_attr.push_back(attr);
sai_status_t status =
sai_next_hop_group_api->set_next_hop_groups_attribute(
(uint32_t)nhg_oids.size(),
nhg_oids.data(), group_attr.data(),
SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR,
statuses.data());
```
46 changes: 46 additions & 0 deletions inc/sainexthopgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ typedef enum _sai_next_hop_group_type_t
/** Next hop hardware protection group. This is the group backing up the primary in the protection group type and is managed by hardware */
SAI_NEXT_HOP_GROUP_TYPE_HW_PROTECTION,

/** Next hop group is ECMP, with members specified with the group */
SAI_NEXT_HOP_GROUP_TYPE_ECMP_WITH_MEMBERS,

/** Next hop group is for bridge port */
SAI_NEXT_HOP_GROUP_TYPE_BRIDGE_PORT,

Expand Down Expand Up @@ -113,6 +116,8 @@ typedef enum _sai_next_hop_group_attr_t
/**
* @brief Next hop member list
*
* Not valid when SAI_NEXT_HOP_GROUP_ATTR_TYPE == SAI_NEXT_HOP_GROUP_TYPE_ECMP_WITH_MEMBERS
*
* @type sai_object_list_t
* @flags READ_ONLY
* @objects SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MEMBER
Expand Down Expand Up @@ -238,6 +243,42 @@ typedef enum _sai_next_hop_group_attr_t
*/
SAI_NEXT_HOP_GROUP_ATTR_ARS_PORT_REASSIGNMENTS,

/**
* @brief Next hop member list in the order specified by the application
*
* NH OID list length should match weight list length
*
* @type sai_object_list_t
* @flags CREATE_AND_SET
* @objects SAI_OBJECT_TYPE_NEXT_HOP
* @default empty
* @validonly SAI_NEXT_HOP_GROUP_ATTR_TYPE == SAI_NEXT_HOP_GROUP_TYPE_ECMP_WITH_MEMBERS
*/
SAI_NEXT_HOP_GROUP_ATTR_NEXT_HOP_LIST,

/**
* @brief Next hop member weight list
*
* @type sai_u32_list_t
* @flags CREATE_AND_SET
* @default empty
* @validonly SAI_NEXT_HOP_GROUP_ATTR_TYPE == SAI_NEXT_HOP_GROUP_TYPE_ECMP_WITH_MEMBERS
*/
SAI_NEXT_HOP_GROUP_ATTR_NEXT_HOP_MEMBER_WEIGHT_LIST,

/**
* @brief Next hop member counter list
*
* When it is empty, then packet hits won't be counted
*
* @type sai_object_list_t
* @flags CREATE_AND_SET
* @objects SAI_OBJECT_TYPE_COUNTER
* @default empty
* @validonly SAI_NEXT_HOP_GROUP_ATTR_TYPE == SAI_NEXT_HOP_GROUP_TYPE_ECMP_WITH_MEMBERS
*/
SAI_NEXT_HOP_GROUP_ATTR_NEXT_HOP_MEMBER_COUNTER_LIST,

/**
* @brief End of attributes
*/
Expand Down Expand Up @@ -613,6 +654,11 @@ typedef struct _sai_next_hop_group_api_t
sai_get_next_hop_group_map_attribute_fn get_next_hop_group_map_attribute;
sai_bulk_object_set_attribute_fn set_next_hop_group_members_attribute;
sai_bulk_object_get_attribute_fn get_next_hop_group_members_attribute;
sai_bulk_object_create_fn create_next_hop_groups;
sai_bulk_object_remove_fn remove_next_hop_groups;
sai_bulk_object_set_attribute_fn set_next_hop_groups_attribute;
sai_bulk_object_get_attribute_fn get_next_hop_groups_attribute;

} sai_next_hop_group_api_t;

/**
Expand Down

0 comments on commit 8164439

Please sign in to comment.