Skip to content

Commit b1e9a31

Browse files
Parvez Shaikhfacebook-github-bot
authored andcommitted
add SAI_SWITCH_ATTR_PORT_PTP_MODE
Summary: introducing SAI_SWITCH_ATTR_PORT_PTP_MODE in FBOSS Reviewed By: jasmeetbagga Differential Revision: D75498187 Privacy Context Container: L1125642 fbshipit-source-id: a236a620acdd425fbd716173eae442573016b569
1 parent 4a7f7ef commit b1e9a31

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

fboss/agent/hw/sai/api/SwitchApi.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,13 @@ struct SaiSwitchTraits {
572572
SAI_SWITCH_ATTR_ARS_PROFILE,
573573
SaiObjectIdT,
574574
SaiObjectIdDefault>;
575+
#endif
576+
#if SAI_API_VERSION >= SAI_VERSION(1, 16, 0)
577+
using PtpMode = SaiAttribute<
578+
EnumType,
579+
SAI_SWITCH_ATTR_PORT_PTP_MODE,
580+
sai_int32_t,
581+
SaiIntDefault<sai_int32_t>>;
575582
#endif
576583
struct AttributeReachabilityGroupList {
577584
std::optional<sai_attr_id_t> operator()();
@@ -826,6 +833,9 @@ struct SaiSwitchTraits {
826833
std::optional<Attributes::VoqLatencyMaxLevel2Ns>,
827834
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0)
828835
std::optional<Attributes::ArsProfile>,
836+
#endif
837+
#if SAI_API_VERSION >= SAI_VERSION(1, 16, 0)
838+
std::optional<Attributes::PtpMode>,
829839
#endif
830840
std::optional<Attributes::ReachabilityGroupList>,
831841
std::optional<Attributes::DelayDropCongThreshold>,
@@ -992,6 +1002,9 @@ SAI_ATTRIBUTE_NAME(Switch, VoqLatencyMaxLevel2Ns)
9921002
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0)
9931003
SAI_ATTRIBUTE_NAME(Switch, ArsProfile)
9941004
#endif
1005+
#if SAI_API_VERSION >= SAI_VERSION(1, 16, 0)
1006+
SAI_ATTRIBUTE_NAME(Switch, PtpMode)
1007+
#endif
9951008
SAI_ATTRIBUTE_NAME(Switch, ReachabilityGroupList)
9961009
SAI_ATTRIBUTE_NAME(Switch, FabricLinkLayerFlowControlThreshold)
9971010
SAI_ATTRIBUTE_NAME(Switch, SramFreePercentXoffTh)

fboss/agent/hw/sai/switch/SaiSwitchManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "fboss/agent/hw/sai/switch/SaiAclTableGroupManager.h"
1919
#include "fboss/agent/hw/sai/switch/SaiBufferManager.h"
2020
#include "fboss/agent/hw/sai/switch/SaiManagerTable.h"
21+
#include "fboss/agent/hw/sai/switch/SaiPortUtils.h"
2122
#include "fboss/agent/hw/sai/switch/SaiUdfManager.h"
2223
#include "fboss/agent/hw/switch_asics/HwAsic.h"
2324
#include "fboss/agent/hw/switch_asics/Jericho3Asic.h"
@@ -784,6 +785,10 @@ sai_object_id_t SaiSwitchManager::getDefaultVlanAdapterKey() const {
784785

785786
void SaiSwitchManager::setPtpTcEnabled(bool ptpEnable) {
786787
isPtpTcEnabled_ = ptpEnable;
788+
#if SAI_API_VERSION >= SAI_VERSION(1, 16, 0)
789+
auto ptpMode = utility::getSaiPortPtpMode(ptpEnable);
790+
switch_->setOptionalAttribute(SaiSwitchTraits::Attributes::PtpMode{ptpMode});
791+
#endif
787792
}
788793

789794
std::optional<bool> SaiSwitchManager::getPtpTcEnabled() {

fboss/agent/hw/sai/tracer/SwitchApiTracer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ std::map<int32_t, std::pair<std::string, std::size_t>> _SwitchMap{
9595
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0)
9696
SAI_ATTR_MAP(Switch, ArsProfile),
9797
#endif
98+
#if SAI_API_VERSION >= SAI_VERSION(1, 16, 0)
99+
SAI_ATTR_MAP(Switch, PtpMode),
100+
#endif
101+
98102
};
99103

100104
void handleExtensionAttributes() {

fboss/agent/platforms/sai/SaiPlatform.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,9 @@ SaiSwitchTraits::CreateAttributes SaiPlatform::getSwitchAttributes(
877877
voqLatencyMaxLevel2Ns, // Level2 VoQ latency bin max
878878
#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0)
879879
std::nullopt, // ARS profile
880+
#endif
881+
#if SAI_API_VERSION >= SAI_VERSION(1, 16, 0)
882+
std::nullopt, // PTP mode
880883
#endif
881884
std::nullopt, // ReachabilityGroupList
882885
delayDropCongThreshold, // Delay Drop Cong Threshold

0 commit comments

Comments
 (0)