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

[MACsec]: Support switchId and portId for gearbox #1717

Merged
merged 1 commit into from
Jun 22, 2021
Merged
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
24 changes: 20 additions & 4 deletions orchagent/macsecorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,14 @@ class MACsecOrchContext
{
return nullptr;
}
m_port_id = std::make_unique<sai_object_id_t>(port->m_port_id);
// TODO: If the MACsec was enabled at the gearbox, should use line port id as the port id.
if (port->m_line_side_id != SAI_NULL_OBJECT_ID)
{
m_port_id = std::make_unique<sai_object_id_t>(port->m_line_side_id);
}
else
{
m_port_id = std::make_unique<sai_object_id_t>(port->m_port_id);
}
}
return m_port_id.get();
}
Expand All @@ -241,12 +247,22 @@ class MACsecOrchContext
{
if (m_switch_id == nullptr)
{
if (gSwitchId == SAI_NULL_OBJECT_ID)
auto port = get_port();
sai_object_id_t switchId;
if (port == nullptr || port->m_switch_id == SAI_NULL_OBJECT_ID)
{
switchId = gSwitchId;
}
else
{
switchId = port->m_switch_id;
}
if (switchId == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("Switch ID cannot be found");
return nullptr;
}
m_switch_id = std::make_unique<sai_object_id_t>(gSwitchId);
m_switch_id = std::make_unique<sai_object_id_t>(switchId);
}
return m_switch_id.get();
}
Expand Down
3 changes: 3 additions & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ class Port
SystemPortInfo m_system_port_info;
SystemLagInfo m_system_lag_info;

sai_object_id_t m_switch_id = 0;
sai_object_id_t m_line_side_id = 0;

bool m_fec_cfg = false;
bool m_an_cfg = false;
};
Expand Down
4 changes: 4 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5140,6 +5140,9 @@ bool PortsOrch::initGearboxPort(Port &port)

sai_deserialize_object_id(phyOidStr, phyOid);

SWSS_LOG_NOTICE("BOX: Gearbox port %s assigned phyOid 0x%" PRIx64, port.m_alias.c_str(), phyOid);
port.m_switch_id = phyOid;

/* Create SYSTEM-SIDE port */
attrs.clear();

Expand Down Expand Up @@ -5305,6 +5308,7 @@ bool PortsOrch::initGearboxPort(Port &port)

SWSS_LOG_NOTICE("BOX: Connected Gearbox ports; system-side:0x%" PRIx64 " to line-side:0x%" PRIx64, systemPort, linePort);
m_gearboxPortListLaneMap[port.m_port_id] = make_tuple(systemPort, linePort);
port.m_line_side_id = linePort;
}
}

Expand Down