Skip to content

Commit

Permalink
Add an API to fill extension queue stats from SaiQueueManager
Browse files Browse the repository at this point in the history
Summary: Extension queue stats to be filled in HwPortStats for queue.

Reviewed By: jasmeetbagga

Differential Revision: D61809753

fbshipit-source-id: 774742dabdcbed89feb05c28c7c54a5b04171346
  • Loading branch information
Nivin Lawrence authored and facebook-github-bot committed Aug 30, 2024
1 parent 440502c commit 0667edc
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmake/AgentHwSaiSwitch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ if (SAI_TAJO_IMPL)
fboss/agent/hw/sai/switch/npu/tajo/SaiPortManager.cpp
fboss/agent/hw/sai/switch/npu/tajo/SaiAclTableManager.cpp
fboss/agent/hw/sai/switch/oss/SaiSwitchManager.cpp
fboss/agent/hw/sai/switch/oss/SaiQueueManager.cpp
)
elseif (SAI_BRCM_IMPL)
list(APPEND SAI_SWITCH_SRC
fboss/agent/hw/sai/switch/npu/bcm/SaiSwitch.cpp
fboss/agent/hw/sai/switch/npu/bcm/SaiTamManager.cpp
fboss/agent/hw/sai/switch/npu/bcm/SaiPortManager.cpp
fboss/agent/hw/sai/switch/npu/bcm/SaiQueueManager.cpp
fboss/agent/hw/sai/switch/oss/SaiSwitchManager.cpp
fboss/agent/hw/sai/switch/oss/SaiAclTableManager.cpp
)
Expand All @@ -72,6 +74,7 @@ else()
fboss/agent/hw/sai/switch/oss/SaiPortManager.cpp
fboss/agent/hw/sai/switch/oss/SaiAclTableManager.cpp
fboss/agent/hw/sai/switch/oss/SaiSwitchManager.cpp
fboss/agent/hw/sai/switch/oss/SaiQueueManager.cpp
)
endif()

Expand Down
6 changes: 5 additions & 1 deletion fboss/agent/hw/sai/switch/SaiQueueManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ void fillHwQueueStats(
hwPortStats.queueEcnMarkedPackets_()[queueId] = value;
break;
default:
throw FbossError("Got unexpected queue counter id: ", counterId);
// Raise exception if this is not handled by implementation
// specific extension stats
if (!fillQueueExtensionStats(queueId, counterId, value, hwPortStats)) {
throw FbossError("Got unexpected queue counter id: ", counterId);
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions fboss/agent/hw/sai/switch/SaiQueueManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ struct SaiQueueHandle {
using SaiQueueHandles =
folly::F14FastMap<SaiQueueConfig, std::unique_ptr<SaiQueueHandle>>;

bool fillQueueExtensionStats(
const uint8_t queueId,
const sai_stat_id_t& counterId,
const uint64_t& counterValue,
HwPortStats& hwPortStats);

class SaiQueueManager {
public:
SaiQueueManager(
Expand Down
44 changes: 44 additions & 0 deletions fboss/agent/hw/sai/switch/npu/bcm/SaiQueueManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#include "fboss/agent/hw/sai/switch/SaiQueueManager.h"

#if defined(BRCM_SAI_SDK_DNX) && defined(BRCM_SAI_SDK_GTE_11_0)
extern "C" {
#include <brcm_sai_extensions.h>
}
#endif

namespace facebook::fboss {

#if defined(BRCM_SAI_SDK_DNX) && defined(BRCM_SAI_SDK_GTE_11_0)
bool fillQueueExtensionStats(
const uint8_t queueId,
const sai_stat_id_t& counterId,
const uint64_t& counterValue,
HwPortStats& hwPortStats) {
bool counterHandled = true;
switch (counterId) {
case SAI_QUEUE_STAT_EGRESS_GVOQ_THRESHOLD_WM:
// There are a few limitations w.r.t. GVOQ watermarks
// 1. Granularity of this counter is 8K bytes as of now
// 2. Max VoQ watermark that can be reported per VoQ is 16M
// 3. Max GVOQ watermark that can be reported per EGQ is 256M
hwPortStats.egressGvoqWatermarkBytes_()[queueId] = counterValue;
break;
default:
throw FbossError("Got unexpected queue counter id: ", counterId);
}
return counterHandled;
}
#else
bool fillQueueExtensionStats(
const uint8_t /*queueId*/,
const sai_stat_id_t& /*counterId*/,
const uint64_t& /*counterValue*/,
HwPortStats& /*hwPortStats*/) {
// No extension stat ID for Queue
return false;
}
#endif

} // namespace facebook::fboss
16 changes: 16 additions & 0 deletions fboss/agent/hw/sai/switch/oss/SaiQueueManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#include "fboss/agent/hw/sai/switch/SaiQueueManager.h"

namespace facebook::fboss {

bool fillQueueExtensionStats(
const uint8_t /*queueId*/,
const sai_stat_id_t& /*counterId*/,
const uint64_t& /*counterValue*/,
HwPortStats& /*hwPortStats*/) {
// No extension stat ID for Queue
return false;
}

} // namespace facebook::fboss
4 changes: 4 additions & 0 deletions fboss/agent/hw/sai/switch/switch.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ _NPU_BRCM_SRCS = _NPU_COMMON_SRCS + [
"facebook/SaiBufferManager.cpp",
"facebook/SaiHostifManager.cpp",
"facebook/SaiSwitchManager.cpp",
"npu/bcm/SaiQueueManager.cpp",
"npu/bcm/SaiSwitch.cpp",
"npu/bcm/SaiSwitchManager.cpp",
"npu/bcm/SaiPortManager.cpp",
Expand All @@ -68,6 +69,7 @@ _NPU_TAJO_SRCS = _NPU_COMMON_SRCS + [
"npu/tajo/SaiTamManager.cpp",
"npu/tajo/SaiAclTableManager.cpp",
"npu/tajo/SaiSwitchManager.cpp",
"oss/SaiQueueManager.cpp",
]

_NPU_FAKE_SRCS = _NPU_COMMON_SRCS + [
Expand All @@ -78,6 +80,7 @@ _NPU_FAKE_SRCS = _NPU_COMMON_SRCS + [
"oss/SaiPortManager.cpp",
"oss/SaiAclTableManager.cpp",
"oss/SaiSwitchManager.cpp",
"oss/SaiQueueManager.cpp",
]

_PHY_COMMON_SRCS = _COMMON_SRCS + [
Expand All @@ -91,6 +94,7 @@ _PHY_COMMON_SRCS = _COMMON_SRCS + [
"oss/SaiPortManager.cpp",
"oss/SaiAclTableManager.cpp",
"oss/SaiSwitchManager.cpp",
"oss/SaiQueueManager.cpp",
]

_PHY_FAKE_SRCS = _PHY_COMMON_SRCS
Expand Down

0 comments on commit 0667edc

Please sign in to comment.