Skip to content

Commit

Permalink
[MACsec]: Support switchId and portId for gearbox (sonic-net#1717)
Browse files Browse the repository at this point in the history
Signed-off-by: Boyang Yu <byu@arista.com>
  • Loading branch information
byu343 authored Jun 22, 2021
1 parent b8b2df2 commit edc0883
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
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 @@ -162,6 +162,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 @@ -5650,6 +5650,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 @@ -5815,6 +5818,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

0 comments on commit edc0883

Please sign in to comment.