Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ECMP and LAG hash offset #3138

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const map<string, sai_switch_attr_t> switch_attribute_map =
{"fdb_aging_time", SAI_SWITCH_ATTR_FDB_AGING_TIME},
{"debug_shell_enable", SAI_SWITCH_ATTR_SWITCH_SHELL_ENABLE},
{"vxlan_port", SAI_SWITCH_ATTR_VXLAN_DEFAULT_PORT},
{"vxlan_router_mac", SAI_SWITCH_ATTR_VXLAN_DEFAULT_ROUTER_MAC}
{"vxlan_router_mac", SAI_SWITCH_ATTR_VXLAN_DEFAULT_ROUTER_MAC},
{"ecmp_hash_offset", SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_OFFSET},
{"lag_hash_offset", SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_OFFSET}
};

const map<string, sai_switch_tunnel_attr_t> switch_tunnel_attribute_map =
Expand Down Expand Up @@ -541,6 +543,8 @@ void SwitchOrch::doAppSwitchTableTask(Consumer &consumer)

MacAddress mac_addr;
bool invalid_attr = false;
bool ret = false;
bool unsupported_attr = false;
switch (attr.id)
{
case SAI_SWITCH_ATTR_FDB_UNICAST_MISS_PACKET_ACTION:
Expand Down Expand Up @@ -578,11 +582,30 @@ void SwitchOrch::doAppSwitchTableTask(Consumer &consumer)
memcpy(attr.value.mac, mac_addr.getMac(), sizeof(sai_mac_t));
break;

case SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_OFFSET:
ret = querySwitchCapability(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_OFFSET);
if(ret == false) {
kperumalbfn marked this conversation as resolved.
Show resolved Hide resolved
SWSS_LOG_INFO("ECMP_HASH_OFFSET attribute is not supported");
kperumalbfn marked this conversation as resolved.
Show resolved Hide resolved
unsupported_attr = true;
} else {
attr.value.u8 = to_uint<uint8_t>(value);
}
break;
case SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_OFFSET:
ret = querySwitchCapability(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_OFFSET);
if(ret == false) {
kperumalbfn marked this conversation as resolved.
Show resolved Hide resolved
SWSS_LOG_INFO("LAG_HASH_OFFSET attribute is not supported");
unsupported_attr = true;
} else {
attr.value.u8 = to_uint<uint8_t>(value);
}
break;

default:
invalid_attr = true;
break;
}
if (invalid_attr)
if (invalid_attr || unsupported_attr)
{
/* break from kfvFieldsValues for loop */
break;
Expand Down
23 changes: 23 additions & 0 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ def vxlan_switch_test(dvs, oid, port, mac, mask, sport):
)


def ecmp_lag_hash_offset_test(dvs, oid, lag_offset, ecmp_offset):
app_db = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0)
create_entry_pst(
app_db,
"SWITCH_TABLE", ':', "switch",
[
("ecmp_hash_offset", ecmp_offset),
("lag_hash_offset", lag_offset)
],
)
time.sleep(2)

asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0)
check_object(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_SWITCH", oid,
{
'SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_OFFSET': ecmp_offset,
'SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_OFFSET': lag_offset,
}
)


class TestSwitch(object):
'''
Test- Check switch attributes
Expand All @@ -75,6 +96,8 @@ def test_switch_attribute(self, dvs, testlog):

vxlan_switch_test(dvs, switch_oid, "56789", "00:0A:0B:0C:0D:0E", "15", "56789")

ecmp_lag_hash_offset_test(dvs, switch_oid, "10", "10")
kperumalbfn marked this conversation as resolved.
Show resolved Hide resolved


# Add Dummy always-pass test at end as workaroud
# for issue when Flaky fail on final test it invokes module tear-down before retrying
Expand Down
Loading