Skip to content
Closed
Show file tree
Hide file tree
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
44 changes: 40 additions & 4 deletions orchagent/dash/dashhaorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ bool DashHaOrch::register_ha_scope_notifier()
return true;
}

bool DashHaOrch::isHaScopeAdminStateAttrSupported()
{
SWSS_LOG_ENTER();

std::call_once(m_ha_scope_admin_state_attr_once_flag, [this]() {
sai_attr_capability_t capability;
sai_status_t status = sai_query_attribute_capability(
gSwitchId,
(sai_object_type_t)SAI_OBJECT_TYPE_HA_SCOPE,
SAI_HA_SCOPE_ATTR_ADMIN_STATE,
&capability);

if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_WARN("Could not query SAI_HA_SCOPE_ATTR_ADMIN_STATE capability: %d", status);
m_ha_scope_admin_state_attr_supported = false;
}
else
{
m_ha_scope_admin_state_attr_supported =
capability.set_implemented || capability.create_implemented;
}
});

return m_ha_scope_admin_state_attr_supported;
}

std::string DashHaOrch::getHaSetObjectKey(const sai_object_id_t ha_set_oid)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -499,10 +526,13 @@ bool DashHaOrch::addHaScopeEntry(const std::string &key, const dash::ha_scope::H
ha_role_attr.value.u16 = to_sai(entry.ha_role());
ha_scope_attrs.push_back(ha_role_attr);

sai_attribute_t disabled_attr = {};
disabled_attr.id = SAI_HA_SCOPE_ATTR_ADMIN_STATE;
disabled_attr.value.booldata = !entry.disabled();
ha_scope_attrs.push_back(disabled_attr);
if (isHaScopeAdminStateAttrSupported())
{
sai_attribute_t disabled_attr = {};
disabled_attr.id = SAI_HA_SCOPE_ATTR_ADMIN_STATE;
disabled_attr.value.booldata = !entry.disabled();
ha_scope_attrs.push_back(disabled_attr);
}

if (entry.has_vip_v4() && entry.vip_v4().has_ipv4())
{
Expand Down Expand Up @@ -729,6 +759,12 @@ bool DashHaOrch::setHaScopeDisabled(const std::string &key, bool disabled)
{
SWSS_LOG_ENTER();

if (!isHaScopeAdminStateAttrSupported())
{
m_ha_scope_entries[key].metadata.set_disabled(disabled);
return true;
}

sai_object_id_t ha_scope_id = m_ha_scope_entries[key].ha_scope_id;

sai_attribute_t ha_scope_attr;
Expand Down
5 changes: 5 additions & 0 deletions orchagent/dash/dashhaorch.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef DASHHAORCH_H
#define DASHHAORCH_H
#include <map>
#include <mutex>

#include "dbconnector.h"
#include "dashorch.h"
Expand Down Expand Up @@ -71,6 +72,7 @@ class DashHaOrch : public ZmqOrch
bool setHaScopeFlowReconcileRequest(const std::string &key);
bool setHaScopeActivateRoleRequest(const std::string &key);
bool setHaScopeDisabled(const std::string &key, bool disabled);
bool isHaScopeAdminStateAttrSupported();
bool setEniHaScopeId(const sai_object_id_t eni_id, const sai_object_id_t ha_scope_id);
bool register_ha_set_notifier();
bool register_ha_scope_notifier();
Expand Down Expand Up @@ -107,6 +109,9 @@ class DashHaOrch : public ZmqOrch
swss::NotificationConsumer* m_haSetNotificationConsumer;
swss::NotificationConsumer* m_haScopeNotificationConsumer;

bool m_ha_scope_admin_state_attr_supported = false;
std::once_flag m_ha_scope_admin_state_attr_once_flag;

public:
const HaSetTable& getHaSetEntries() const { return m_ha_set_entries; };
const HaScopeTable& getHaScopeEntries() const { return m_ha_scope_entries; };
Expand Down
60 changes: 46 additions & 14 deletions orchagent/dash/dashorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,32 @@ bool DashOrch::hasApplianceEntry()
return !appliance_entries_.empty();
}

bool DashOrch::isHaFlowOwnerAttrSupported()
{
SWSS_LOG_ENTER();

std::call_once(m_ha_flow_owner_attr_once_flag, [this]() {
sai_attr_capability_t capability;
sai_status_t status = sai_query_attribute_capability(
gSwitchId,
(sai_object_type_t)SAI_OBJECT_TYPE_ENI,
SAI_ENI_ATTR_IS_HA_FLOW_OWNER,
&capability);

if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_WARN("Could not query SAI_ENI_ATTR_IS_HA_FLOW_OWNER capability: %d", status);
m_ha_flow_owner_attr_supported = false;
}
else
{
m_ha_flow_owner_attr_supported = capability.set_implemented || capability.create_implemented;
}
});

return m_ha_flow_owner_attr_supported;
}

bool DashOrch::addApplianceEntry(const string& appliance_id, const dash::appliance::Appliance &entry)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -650,25 +676,31 @@ bool DashOrch::addEniObject(const string& eni, EniEntry& entry)
eni_attrs.push_back(eni_attr);
SWSS_LOG_INFO("Setting HA Scope ID %" PRIx64 " for ENI %s", ha_scope_entry.ha_scope_id, eni.c_str());

// Set HA flow owner based on HA role
eni_attr.id = SAI_ENI_ATTR_IS_HA_FLOW_OWNER;
if (ha_scope_entry.metadata.ha_role() == dash::types::HA_ROLE_ACTIVE || ha_scope_entry.metadata.ha_role() == dash::types::HA_ROLE_STANDALONE)
{
eni_attr.value.booldata = true;
SWSS_LOG_INFO("Setting HA flow owner to true (ACTIVE) for ENI %s", eni.c_str());
}
else if (ha_scope_entry.metadata.ha_role() == dash::types::HA_ROLE_STANDBY)
if (isHaFlowOwnerAttrSupported())
{
eni_attr.value.booldata = false;
SWSS_LOG_INFO("Setting HA flow owner to false (STANDBY) for ENI %s", eni.c_str());
eni_attr.id = SAI_ENI_ATTR_IS_HA_FLOW_OWNER;
if (ha_scope_entry.metadata.ha_role() == dash::types::HA_ROLE_ACTIVE || ha_scope_entry.metadata.ha_role() == dash::types::HA_ROLE_STANDALONE)
{
eni_attr.value.booldata = true;
SWSS_LOG_INFO("Setting HA flow owner to true (ACTIVE) for ENI %s", eni.c_str());
}
else if (ha_scope_entry.metadata.ha_role() == dash::types::HA_ROLE_STANDBY)
{
eni_attr.value.booldata = false;
SWSS_LOG_INFO("Setting HA flow owner to false (STANDBY) for ENI %s", eni.c_str());
}
else
{
// For other roles (DEAD, SWITCHING_TO_ACTIVE), default to false
eni_attr.value.booldata = false;
SWSS_LOG_INFO("Setting HA flow owner to false (role: %s) for ENI %s", dash::types::HaRole_Name(ha_scope_entry.metadata.ha_role()).c_str(), eni.c_str());
}
eni_attrs.push_back(eni_attr);
}
else
{
// For other roles (DEAD, SWITCHING_TO_ACTIVE), default to false
eni_attr.value.booldata = false;
SWSS_LOG_INFO("Setting HA flow owner to false (role: %s) for ENI %s", dash::types::HaRole_Name(ha_scope_entry.metadata.ha_role()).c_str(), eni.c_str());
SWSS_LOG_INFO("SAI_ENI_ATTR_IS_HA_FLOW_OWNER not supported, skipping for ENI %s", eni.c_str());
}
eni_attrs.push_back(eni_attr);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions orchagent/dash/dashorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class DashOrch : public ZmqOrch
bool removeQosEntry(const std::string& qos_name);
bool setEniRoute(const std::string& eni, const dash::eni_route::EniRoute& entry);
bool removeEniRoute(const std::string& eni);
bool isHaFlowOwnerAttrSupported();

private:

Expand Down Expand Up @@ -172,6 +173,8 @@ class DashOrch : public ZmqOrch
std::shared_ptr<swss::DBConnector> m_counter_db;
std::shared_ptr<swss::DBConnector> m_asic_db;
DashHaOrch* m_dash_ha_orch = nullptr;
bool m_ha_flow_owner_attr_supported = false;
std::once_flag m_ha_flow_owner_attr_once_flag;

void addEniMapEntry(sai_object_id_t oid, const std::string& name);
void removeEniMapEntry(sai_object_id_t oid, const std::string& name);
Expand Down
Loading