Skip to content

Commit a4c80c3

Browse files
authored
patch for issue #1971 - enable Rx Drop handling for cisco-8000 (#2041)
What I did Enables support for Rx traffic drop for a port/tc by applying the zero buffer profile Changed class hierarchy so that default getHwCounters() function is used (since the Rx counter support is enabled) Fixes a pfc-wd off by 1 detection in case of PFC-WD detection without traffic Why I did it enabling a missing functionality leveraging sonic code as our sdk now implements the missing counter fixes a bug How I verified it on a cisco-8000 router: detected pfc-wd detection and restore happens within the (detection/restore-time + 1 poll interval) duration and that the changeset passes MSFT tests Verified that when PFC-WD is detected, both Rx and Tx traffic for a port/tc is dropped and no forwarding happens Details if related this patch will need to be double committed to the 202012 branch along with #1942 , #1748 and #1962 Signed-off-by: Alpesh S Patel <[email protected]>
1 parent 71751d1 commit a4c80c3

File tree

3 files changed

+19
-37
lines changed

3 files changed

+19
-37
lines changed

orchagent/pfc_restore_cisco-8000.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ for i = n, 1, -1 do
4444
and (debug_storm ~= "enabled")
4545
-- DEBUG CODE END.
4646
then
47-
if time_left <= 0 then
47+
if time_left <= poll_time then
4848
redis.call('PUBLISH', 'PFC_WD_ACTION', '["' .. KEYS[i] .. '","restore"]')
4949
time_left = restoration_time
5050
else

orchagent/pfcactionhandler.cpp

+17-34
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void PfcWdActionHandler::updateWdCounters(const string& queueIdStr, const PfcWdQ
221221

222222
PfcWdSaiDlrInitHandler::PfcWdSaiDlrInitHandler(sai_object_id_t port, sai_object_id_t queue,
223223
uint8_t queueId, shared_ptr<Table> countersTable):
224-
PfcWdActionHandler(port, queue, queueId, countersTable)
224+
PfcWdZeroBufferHandler(port, queue, queueId, countersTable)
225225
{
226226
SWSS_LOG_ENTER();
227227

@@ -262,39 +262,6 @@ PfcWdSaiDlrInitHandler::~PfcWdSaiDlrInitHandler(void)
262262
}
263263
}
264264

265-
bool PfcWdSaiDlrInitHandler::getHwCounters(PfcWdHwStats& counters)
266-
{
267-
SWSS_LOG_ENTER();
268-
269-
static const vector<sai_stat_id_t> queueStatIds =
270-
{
271-
SAI_QUEUE_STAT_PACKETS,
272-
SAI_QUEUE_STAT_DROPPED_PACKETS,
273-
};
274-
275-
vector<uint64_t> queueStats;
276-
queueStats.resize(queueStatIds.size());
277-
278-
sai_status_t status = sai_queue_api->get_queue_stats(
279-
getQueue(),
280-
static_cast<uint32_t>(queueStatIds.size()),
281-
queueStatIds.data(),
282-
queueStats.data());
283-
284-
if (status != SAI_STATUS_SUCCESS)
285-
{
286-
SWSS_LOG_ERROR("Failed to fetch queue 0x%" PRIx64 " stats: %d", getQueue(), status);
287-
return false;
288-
}
289-
290-
counters.txPkt = queueStats[0];
291-
counters.txDropPkt = queueStats[1];
292-
counters.rxPkt = 0;
293-
counters.rxDropPkt = 0;
294-
295-
return true;
296-
}
297-
298265
PfcWdAclHandler::PfcWdAclHandler(sai_object_id_t port, sai_object_id_t queue,
299266
uint8_t queueId, shared_ptr<Table> countersTable):
300267
PfcWdLossyHandler(port, queue, queueId, countersTable)
@@ -472,6 +439,14 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue
472439
{
473440
SWSS_LOG_ENTER();
474441

442+
string platform = getenv("platform") ? getenv("platform") : "";
443+
if (platform == CISCO_8000_PLATFORM_SUBSTRING)
444+
{
445+
SWSS_LOG_DEBUG("Skipping in constructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64,
446+
platform.c_str(), port);
447+
return;
448+
}
449+
475450
uint8_t pfcMask = 0;
476451

477452
if (!gPortsOrch->getPortPfc(port, &pfcMask))
@@ -491,6 +466,14 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void)
491466
{
492467
SWSS_LOG_ENTER();
493468

469+
string platform = getenv("platform") ? getenv("platform") : "";
470+
if (platform == CISCO_8000_PLATFORM_SUBSTRING)
471+
{
472+
SWSS_LOG_DEBUG("Skipping in destructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64,
473+
platform.c_str(), getPort());
474+
return;
475+
}
476+
494477
uint8_t pfcMask = 0;
495478

496479
if (!gPortsOrch->getPortPfc(getPort(), &pfcMask))

orchagent/pfcactionhandler.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,12 @@ class PfcWdZeroBufferHandler: public PfcWdLossyHandler
165165

166166
// PFC queue that implements drop action by draining queue via SAI
167167
// attribute SAI_QUEUE_ATTR_PFC_DLR_INIT.
168-
class PfcWdSaiDlrInitHandler: public PfcWdActionHandler
168+
class PfcWdSaiDlrInitHandler: public PfcWdZeroBufferHandler
169169
{
170170
public:
171171
PfcWdSaiDlrInitHandler(sai_object_id_t port, sai_object_id_t queue,
172172
uint8_t queueId, shared_ptr<Table> countersTable);
173173
virtual ~PfcWdSaiDlrInitHandler(void);
174-
virtual bool getHwCounters(PfcWdHwStats& counters);
175174
};
176175

177176
#endif

0 commit comments

Comments
 (0)