Skip to content

Commit

Permalink
[202211][ppi]: General code cleanup: remove unused methods. (#2868)
Browse files Browse the repository at this point in the history
DEPENDS:

[202211][ppi]: Implement port bulk comparison logic (#2564)  #2821
HLD: sonic-net/SONiC#1084

What I did

Removed unused code
Why I did it

To complete code cleanup
How I verified it

UT tests
VS tests
Details if related

Backport from master: [ppi]: General code cleanup: remove unused methods #2867
  • Loading branch information
nazariig authored Sep 25, 2023
1 parent 1681732 commit 8d76a4e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 67 deletions.
5 changes: 0 additions & 5 deletions orchagent/p4orch/tests/fake_portorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,6 @@ bool PortsOrch::setDistributionOnLagMember(Port &lagMember, bool enableDistribut
return true;
}

bool PortsOrch::addPort(const PortConfig &port)
{
return true;
}

sai_status_t PortsOrch::removePort(sai_object_id_t port_id)
{
return SAI_STATUS_SUCCESS;
Expand Down
61 changes: 0 additions & 61 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2889,67 +2889,6 @@ void PortsOrch::updateDbPortOperStatus(const Port& port, sai_port_oper_status_t
m_portTable->set(port.m_alias, tuples);
}

bool PortsOrch::addPort(const PortConfig &port)
{
SWSS_LOG_ENTER();

if (!port.speed.is_set || !port.lanes.is_set)
{
/*
speed and lane list are mandatory attributes for the initial create_port call
This check is required because the incoming notifs may not be atomic
*/
return true;
}

vector<uint32_t> lanes(port.lanes.value.begin(), port.lanes.value.end());

sai_attribute_t attr;
vector<sai_attribute_t> attrs;

attr.id = SAI_PORT_ATTR_SPEED;
attr.value.u32 = port.speed.value;
attrs.push_back(attr);

attr.id = SAI_PORT_ATTR_HW_LANE_LIST;
attr.value.u32list.list = lanes.data();
attr.value.u32list.count = static_cast<uint32_t>(lanes.size());
attrs.push_back(attr);

if (port.autoneg.is_set)
{
attr.id = SAI_PORT_ATTR_AUTO_NEG_MODE;
attr.value.booldata = port.autoneg.value;
attrs.push_back(attr);
}

if (port.fec.is_set)
{
attr.id = SAI_PORT_ATTR_FEC_MODE;
attr.value.s32 = port.fec.value;
attrs.push_back(attr);
}

sai_object_id_t port_id;
sai_status_t status = sai_port_api->create_port(&port_id, gSwitchId, static_cast<uint32_t>(attrs.size()), attrs.data());
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to create port with the speed %u, rv:%d", port.speed.value, status);
task_process_status handle_status = handleSaiCreateStatus(SAI_API_PORT, status);
if (handle_status != task_success)
{
return parseHandleSaiStatusFailure(handle_status);
}
}

m_portListLaneMap[port.lanes.value] = port_id;
m_portCount++;

SWSS_LOG_NOTICE("Create port %" PRIx64 " with the speed %u", port_id, port.speed.value);

return true;
}

sai_status_t PortsOrch::removePort(sai_object_id_t port_id)
{
SWSS_LOG_ENTER();
Expand Down
1 change: 0 additions & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ class PortsOrch : public Orch, public Subject
bool setCollectionOnLagMember(Port &lagMember, bool enableCollection);
bool setDistributionOnLagMember(Port &lagMember, bool enableDistribution);

bool addPort(const PortConfig &port);
sai_status_t removePort(sai_object_id_t port_id);
bool initPort(const PortConfig &port);
void deInitPort(string alias, sai_object_id_t port_id);
Expand Down

0 comments on commit 8d76a4e

Please sign in to comment.