Skip to content

Commit

Permalink
Handle different speed change combinations
Browse files Browse the repository at this point in the history
Summary: https://docs.google.com/document/d/1c45Lfy6kq1BFAZONt3lZDXhCIV45ruQhe5G2CJtkLAE/edit?tab=t.0

Reviewed By: srikrishnagopu

Differential Revision:
D65735292

Privacy Context Container: L1125642

fbshipit-source-id: 8311f43600e34375e25757554faf7552a88d72c0
  • Loading branch information
Vasant Patil authored and facebook-github-bot committed Dec 5, 2024
1 parent 184ca54 commit 3887f8f
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions fboss/agent/hw/sai/switch/npu/tajo/SaiPortManager.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#include "fboss/agent/hw/sai/switch/SaiPortManager.h"
#include "fboss/agent/platforms/sai/SaiPlatform.h"

namespace facebook::fboss {
class SaiPlatform;

void SaiPortManager::addRemovedHandle(PortID /*portID*/) {}

Expand Down Expand Up @@ -53,8 +55,56 @@ bool SaiPortManager::checkPortSerdesAttributes(
void SaiPortManager::changePortByRecreate(
const std::shared_ptr<Port>& oldPort,
const std::shared_ptr<Port>& newPort) {
removePort(oldPort);
addPort(newPort);
// If YUBA, disable port before recreating
if (platform_->getAsic()->getAsicType() == cfg::AsicType::ASIC_TYPE_YUBA) {
SaiPortTraits::Attributes::AdminState adminDisable{false};
SaiPortHandle* portHandle = getPortHandle(oldPort->getID());
SaiApiTable::getInstance()->portApi().setAttribute(
portHandle->port->adapterKey(), adminDisable);
}

// If YUBA and new or old port has 100G, we will delete/remove both/all ports
// in the group and add/create back both/all ports in the group.
if ((platform_->getAsic()->getAsicType() == cfg::AsicType::ASIC_TYPE_YUBA) &&
(newPort->getProfileID() ==
cfg::PortProfileID::PROFILE_100G_4_NRZ_RS528_OPTICAL ||
oldPort->getProfileID() ==
cfg::PortProfileID::PROFILE_100G_4_NRZ_RS528_OPTICAL)) {
removePort(oldPort);
pendingNewPorts_[newPort->getID()] = newPort;
bool allPortsInGroupRemoved = true;
auto& platformPortEntry =
platform_->getPort(oldPort->getID())->getPlatformPortEntry();
auto controllingPort =
PortID(*platformPortEntry.mapping()->controllingPort());
auto ports = platform_->getAllPortsInGroup(controllingPort);
XLOG(DBG2) << "Port " << oldPort->getID() << "'s controlling port is "
<< controllingPort;
for (auto portId : ports) {
if (handles_.find(portId) != handles_.end()) {
XLOG(DBG2) << "Port " << portId
<< " in the same group but not removed yet";
allPortsInGroupRemoved = false;
}
}
if (allPortsInGroupRemoved) {
for (auto portId : ports) {
removeRemovedHandleIf(portId);
}
XLOG(DBG2)
<< "All old ports in the same group removed, add new ports back";

for (auto portId : ports) {
if (pendingNewPorts_.find(portId) != pendingNewPorts_.end()) {
addPort(pendingNewPorts_[portId]);
pendingNewPorts_.erase(portId);
}
}
}
} else {
removePort(oldPort);
addPort(newPort);
}
}

} // namespace facebook::fboss

0 comments on commit 3887f8f

Please sign in to comment.