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

[switchorch]: Add support of ECMP and LAG hash seed attribute #324

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Changes from all commits
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
36 changes: 28 additions & 8 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <map>

#include "switchorch.h"
#include "converter.h"

using namespace std;
using namespace swss;
Expand All @@ -12,7 +13,9 @@ const map<string, sai_switch_attr_t> switch_attribute_map =
{
{"fdb_unicast_miss_packet_action", SAI_SWITCH_ATTR_FDB_UNICAST_MISS_PACKET_ACTION},
{"fdb_broadcast_miss_packet_action", SAI_SWITCH_ATTR_FDB_BROADCAST_MISS_PACKET_ACTION},
{"fdb_multicast_miss_packet_action", SAI_SWITCH_ATTR_FDB_MULTICAST_MISS_PACKET_ACTION}
{"fdb_multicast_miss_packet_action", SAI_SWITCH_ATTR_FDB_MULTICAST_MISS_PACKET_ACTION},
{"ecmp_hash_seed", SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_SEED},
{"lag_hash_seed", SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_SEED}
};

const map<string, sai_packet_action_t> packet_action_map =
Expand Down Expand Up @@ -52,16 +55,32 @@ void SwitchOrch::doTask(Consumer &consumer)
}

auto value = fvValue(i);
if (packet_action_map.find(value) == packet_action_map.end())
{
SWSS_LOG_ERROR("Unsupported packet action %s", value.c_str());
it = consumer.m_toSync.erase(it);
continue;
}

sai_attribute_t attr;
attr.id = switch_attribute_map.at(attribute);
attr.value.s32 = packet_action_map.at(value);

switch (attr.id)
{
case SAI_SWITCH_ATTR_FDB_UNICAST_MISS_PACKET_ACTION:
case SAI_SWITCH_ATTR_FDB_BROADCAST_MISS_PACKET_ACTION:
case SAI_SWITCH_ATTR_FDB_MULTICAST_MISS_PACKET_ACTION:
if (packet_action_map.find(value) == packet_action_map.end())
{
SWSS_LOG_ERROR("Unsupported packet action %s", value.c_str());
it = consumer.m_toSync.erase(it);
continue;
}
attr.value.s32 = packet_action_map.at(value);
break;

case SAI_SWITCH_ATTR_ECMP_DEFAULT_HASH_SEED:
case SAI_SWITCH_ATTR_LAG_DEFAULT_HASH_SEED:
attr.value.u32 = to_uint<uint32_t>(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have test cases for different hash seeds?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as far as I know, we don't have.

break;

default:
break;
}

sai_status_t status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
if (status != SAI_STATUS_SUCCESS)
Expand All @@ -83,3 +102,4 @@ void SwitchOrch::doTask(Consumer &consumer)
}
}
}