Skip to content
Open
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
29 changes: 27 additions & 2 deletions fboss/agent/hw/sai/switch/npu/SaiPortManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "fboss/agent/FbossError.h"
#include "fboss/agent/hw/HwPortFb303Stats.h"
#include "fboss/agent/hw/gen-cpp2/hardware_stats_constants.h"
#include "fboss/agent/hw/sai/api/SaiApiError.h"
#include "fboss/agent/hw/sai/store/SaiStore.h"
#include "fboss/agent/hw/sai/switch/ConcurrentIndices.h"
#include "fboss/agent/hw/sai/switch/SaiBridgeManager.h"
Expand Down Expand Up @@ -1341,6 +1342,30 @@ void SaiPortManager::programSerdes(
swPort->getZeroPreemphasis()) {
createSerdesWithZeroPreemphasis(portHandle, swPort->getPinConfigs());
}
// Adopt existing serdes on ITEM_ALREADY_EXISTS (XGS keeps it on recreate).
auto setSerdesObject =
[&](const SaiPortSerdesTraits::CreateAttributes& serdesCreateAttributes) {
try {
return store.setObject(serdesKey, serdesCreateAttributes);
} catch (const SaiApiError& e) {
if (e.getSaiStatus() != SAI_STATUS_ITEM_ALREADY_EXISTS) {
throw;
}
std::optional<SaiPortTraits::Attributes::SerdesId> serdesIdAttr{};
auto serdesId = SaiApiTable::getInstance()->portApi().getAttribute(
saiPort->adapterKey(), serdesIdAttr);
if (!serdesId.has_value() || serdesId.value() == SAI_NULL_OBJECT_ID) {
// Nothing to adopt; surface the original error.
throw;
}
XLOG(WARNING) << "Port serdes already exists for port "
<< swPort->getID()
<< "; adopting existing serdes object "
<< serdesId.value();
store.reloadObject(static_cast<PortSerdesSaiId>(serdesId.value()));
return store.setObject(serdesKey, serdesCreateAttributes);
}
};
if (platform_->getAsic()->getAsicType() ==
cfg::AsicType::ASIC_TYPE_TOMAHAWK5 ||
platform_->getAsic()->getAsicType() ==
Expand Down Expand Up @@ -1380,13 +1405,13 @@ void SaiPortManager::programSerdes(
txPost1.resize(numLanes, 0);
std::get<std::optional<SaiPortSerdesTraits::Attributes::TxFirPost1>>(
attributes) = txPost1;
portHandle->serdes = store.setObject(serdesKey, attributes);
portHandle->serdes = setSerdesObject(attributes);
} else {
XLOG(DBG2) << "No tx main setting for port " << swPort->getID();
}
}
// create if serdes doesn't exist or update existing serdes
portHandle->serdes = store.setObject(serdesKey, serdesAttributes);
portHandle->serdes = setSerdesObject(serdesAttributes);

// Set RX Reach if ASIC supports and platform mapping has a rxReach
// setting
Expand Down
Loading