Skip to content

Commit fcbe392

Browse files
committed
Revert "Merge branch '202411' of https://github.com/sonic-net/sonic-swss into 202412"
This reverts commit bbce4b4, reversing changes made to 9e97862.
1 parent 9e9442d commit fcbe392

5 files changed

Lines changed: 136 additions & 4 deletions

File tree

orchagent/flexcounterorch.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ void FlexCounterOrch::doTask(Consumer &consumer)
138138

139139
if (op == SET_COMMAND)
140140
{
141+
string bulk_chunk_size;
142+
string bulk_chunk_size_per_counter;
141143

142144
for (auto valuePair:data)
143145
{
@@ -156,6 +158,14 @@ void FlexCounterOrch::doTask(Consumer &consumer)
156158
}
157159
}
158160
}
161+
else if (field == BULK_CHUNK_SIZE_FIELD)
162+
{
163+
bulk_chunk_size = value;
164+
}
165+
else if (field == BULK_CHUNK_SIZE_PER_PREFIX_FIELD)
166+
{
167+
bulk_chunk_size_per_counter = value;
168+
}
159169
else if(field == FLEX_COUNTER_STATUS_FIELD)
160170
{
161171
// Currently, the counters are disabled for polling by default
@@ -277,6 +287,19 @@ void FlexCounterOrch::doTask(Consumer &consumer)
277287
SWSS_LOG_NOTICE("Unsupported field %s", field.c_str());
278288
}
279289
}
290+
291+
if (!bulk_chunk_size.empty() || !bulk_chunk_size_per_counter.empty())
292+
{
293+
m_groupsWithBulkChunkSize.insert(key);
294+
setFlexCounterGroupBulkChunkSize(flexCounterGroupMap[key],
295+
bulk_chunk_size.empty() ? "NULL" : bulk_chunk_size,
296+
bulk_chunk_size_per_counter.empty() ? "NULL" : bulk_chunk_size_per_counter);
297+
}
298+
else if (m_groupsWithBulkChunkSize.find(key) != m_groupsWithBulkChunkSize.end())
299+
{
300+
setFlexCounterGroupBulkChunkSize(flexCounterGroupMap[key], "NULL", "NULL");
301+
m_groupsWithBulkChunkSize.erase(key);
302+
}
280303
}
281304

282305
consumer.m_toSync.erase(it++);

orchagent/pfc_detect_mellanox.lua

100644100755
Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ local timestamp_struct = redis.call('TIME')
1818
local timestamp_current = timestamp_struct[1] + timestamp_struct[2] / 1000000
1919
local timestamp_string = tostring(timestamp_current)
2020
redis.call('HSET', 'TIMESTAMP', 'pfcwd_poll_timestamp_last', timestamp_string)
21-
local effective_poll_time = poll_time
22-
local effective_poll_time_lasttime = redis.call('HGET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last')
21+
local global_effective_poll_time = poll_time
22+
local global_effective_poll_time_lasttime = redis.call('HGET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last')
2323
if timestamp_last ~= false then
24-
effective_poll_time = (timestamp_current - tonumber(timestamp_last)) * 1000000
25-
redis.call('HSET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last', effective_poll_time)
24+
global_effective_poll_time = (timestamp_current - tonumber(timestamp_last)) * 1000000
25+
redis.call('HSET', 'TIMESTAMP', 'effective_pfcwd_poll_time_last', global_effective_poll_time)
2626
end
2727

28+
local effective_poll_time
29+
local effective_poll_time_lasttime
30+
local port_timestamp_last_cache = {}
31+
32+
local debug_storm_global = redis.call('HGET', 'DEBUG_STORM', 'enabled') == 'true'
33+
local debug_storm_threshold = tonumber(redis.call('HGET', 'DEBUG_STORM', 'threshold'))
34+
2835
-- Iterate through each queue
2936
local n = table.getn(KEYS)
3037
for i = n, 1, -1 do
@@ -56,12 +63,37 @@ for i = n, 1, -1 do
5663
local pfc_rx_pkt_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PKTS'
5764
local pfc_duration_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PAUSE_DURATION_US'
5865

66+
-- Get port specific timestamp
67+
local port_timestamp_current = tonumber(redis.call('HGET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp'))
68+
if port_timestamp_current ~= nil then
69+
local port_timestamp_lasttime = port_timestamp_last_cache[port_id]
70+
if port_timestamp_lasttime == nil then
71+
port_timestamp_lasttime = tonumber(redis.call('HGET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp_last'))
72+
port_timestamp_last_cache[port_id] = port_timestamp_lasttime
73+
redis.call('HSET', counters_table_name .. ':' .. port_id, 'PFC_WD_time_stamp_last', port_timestamp_current)
74+
end
75+
76+
if port_timestamp_lasttime ~= nil then
77+
effective_poll_time = (port_timestamp_current - port_timestamp_lasttime) / 1000
78+
else
79+
effective_poll_time = global_effective_poll_time
80+
end
81+
effective_poll_time_lasttime = false
82+
else
83+
effective_poll_time = global_effective_poll_time
84+
effective_poll_time_lasttime = global_effective_poll_time_lasttime
85+
end
86+
5987
-- Get all counters
6088
local occupancy_bytes = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES')
6189
local packets = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS')
6290
local pfc_rx_packets = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key)
6391
local pfc_duration = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_duration_key)
6492

93+
if debug_storm_global then
94+
redis.call('PUBLISH', 'PFC_WD_DEBUG', 'Port ID ' .. port_id .. ' Queue index ' .. queue_index .. ' occupancy ' .. occupancy_bytes .. ' packets ' .. packets .. ' pfc rx ' .. pfc_rx_packets .. ' pfc duration ' .. pfc_duration .. ' effective poll time ' .. tostring(effective_poll_time) .. '(global ' .. tostring(global_effective_poll_time) .. ')')
95+
end
96+
6597
if occupancy_bytes and packets and pfc_rx_packets and pfc_duration then
6698
occupancy_bytes = tonumber(occupancy_bytes)
6799
packets = tonumber(packets)
@@ -82,6 +114,10 @@ for i = n, 1, -1 do
82114
pfc_duration_last = tonumber(pfc_duration_last)
83115
local storm_condition = (pfc_duration - pfc_duration_last) > (effective_poll_time * 0.99)
84116

117+
if debug_storm_threshold ~= nil and (pfc_duration - pfc_duration_last) > (effective_poll_time * debug_storm_threshold / 100) then
118+
redis.call('PUBLISH', 'PFC_WD_DEBUG', 'Port ID ' .. port_id .. ' Queue index ' .. queue_index .. ' occupancy ' .. occupancy_bytes .. ' packets ' .. packets .. ' pfc rx ' .. pfc_rx_packets .. ' pfc duration ' .. pfc_duration .. ' effective poll time ' .. tostring(effective_poll_time) .. ', triggered by threshold ' .. debug_storm_threshold .. '%')
119+
end
120+
85121
-- Check actual condition of queue being in PFC storm
86122
if (occupancy_bytes > 0 and packets - packets_last == 0 and storm_condition) or
87123
-- DEBUG CODE START. Uncomment to enable

orchagent/saihelper.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,8 @@ static inline void initSaiRedisCounterEmptyParameter(sai_redis_flex_counter_grou
851851
initSaiRedisCounterEmptyParameter(flex_counter_group_param.stats_mode);
852852
initSaiRedisCounterEmptyParameter(flex_counter_group_param.plugin_name);
853853
initSaiRedisCounterEmptyParameter(flex_counter_group_param.plugins);
854+
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size);
855+
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size_per_prefix);
854856
}
855857

856858
static inline void initSaiRedisCounterParameterFromString(sai_s8_list_t &sai_s8_list, const std::string &str)
@@ -935,6 +937,8 @@ void setFlexCounterGroupParameter(const string &group,
935937
attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP;
936938
attr.value.ptr = &flex_counter_group_param;
937939

940+
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size);
941+
initSaiRedisCounterEmptyParameter(flex_counter_group_param.bulk_chunk_size_per_prefix);
938942
initSaiRedisCounterParameterFromString(flex_counter_group_param.counter_group_name, group);
939943
initSaiRedisCounterParameterFromString(flex_counter_group_param.poll_interval, poll_interval);
940944
initSaiRedisCounterParameterFromString(flex_counter_group_param.operation, operation);
@@ -1014,6 +1018,25 @@ void setFlexCounterGroupStatsMode(const std::string &group,
10141018
notifySyncdCounterOperation(is_gearbox, attr);
10151019
}
10161020

1021+
void setFlexCounterGroupBulkChunkSize(const std::string &group,
1022+
const std::string &bulk_chunk_size,
1023+
const std::string &bulk_chunk_size_per_prefix,
1024+
bool is_gearbox)
1025+
{
1026+
sai_attribute_t attr;
1027+
sai_redis_flex_counter_group_parameter_t flex_counter_group_param;
1028+
1029+
attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP;
1030+
attr.value.ptr = &flex_counter_group_param;
1031+
1032+
initSaiRedisCounterEmptyParameter(flex_counter_group_param);
1033+
initSaiRedisCounterParameterFromString(flex_counter_group_param.counter_group_name, group);
1034+
initSaiRedisCounterParameterFromString(flex_counter_group_param.bulk_chunk_size, bulk_chunk_size);
1035+
initSaiRedisCounterParameterFromString(flex_counter_group_param.bulk_chunk_size_per_prefix, bulk_chunk_size_per_prefix);
1036+
1037+
notifySyncdCounterOperation(is_gearbox, attr);
1038+
}
1039+
10171040
void delFlexCounterGroup(const std::string &group,
10181041
bool is_gearbox)
10191042
{

orchagent/saihelper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ void setFlexCounterGroupStatsMode(const std::string &group,
3939
const std::string &stats_mode,
4040
bool is_gearbox=false);
4141

42+
void setFlexCounterGroupBulkChunkSize(const std::string &group,
43+
const std::string &bulk_size,
44+
const std::string &bulk_chunk_size_per_prefix,
45+
bool is_gearbox=false);
46+
4247
void delFlexCounterGroup(const std::string &group,
4348
bool is_gearbox=false);
4449

tests/mock_tests/flexcounter_ut.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ namespace flexcounter_test
131131
}
132132
else
133133
{
134+
if (flexCounterGroupParam->bulk_chunk_size.list != nullptr || flexCounterGroupParam->bulk_chunk_size_per_prefix.list != nullptr)
135+
{
136+
return SAI_STATUS_SUCCESS;
137+
}
134138
mockFlexCounterGroupTable->del(key);
135139
}
136140

@@ -923,6 +927,47 @@ namespace flexcounter_test
923927
consumer->addToSync(entries);
924928
entries.clear();
925929
static_cast<Orch *>(gBufferOrch)->doTask();
930+
931+
if (!gTraditionalFlexCounter)
932+
{
933+
// Verify bulk chunk size fields which can be verified in any combination of parameters.
934+
// We verify it here just for convenience.
935+
consumer = dynamic_cast<Consumer *>(flexCounterOrch->getExecutor(CFG_FLEX_COUNTER_TABLE_NAME));
936+
937+
entries.push_back({"PORT", "SET", {
938+
{"FLEX_COUNTER_STATUS", "enable"},
939+
{"BULK_CHUNK_SIZE", "64"}
940+
}});
941+
consumer->addToSync(entries);
942+
entries.clear();
943+
static_cast<Orch *>(flexCounterOrch)->doTask();
944+
ASSERT_TRUE(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT") != flexCounterOrch->m_groupsWithBulkChunkSize.end());
945+
946+
entries.push_back({"PORT", "SET", {
947+
{"FLEX_COUNTER_STATUS", "enable"}
948+
}});
949+
consumer->addToSync(entries);
950+
entries.clear();
951+
static_cast<Orch *>(flexCounterOrch)->doTask();
952+
ASSERT_EQ(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT"), flexCounterOrch->m_groupsWithBulkChunkSize.end());
953+
954+
entries.push_back({"PORT", "SET", {
955+
{"FLEX_COUNTER_STATUS", "enable"},
956+
{"BULK_CHUNK_SIZE_PER_PREFIX", "SAI_PORT_STAT_IF_OUT_QLEN:0;SAI_PORT_STAT_IF_IN_FEC:32"}
957+
}});
958+
consumer->addToSync(entries);
959+
entries.clear();
960+
static_cast<Orch *>(flexCounterOrch)->doTask();
961+
ASSERT_TRUE(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT") != flexCounterOrch->m_groupsWithBulkChunkSize.end());
962+
963+
entries.push_back({"PORT", "SET", {
964+
{"FLEX_COUNTER_STATUS", "enable"}
965+
}});
966+
consumer->addToSync(entries);
967+
entries.clear();
968+
static_cast<Orch *>(flexCounterOrch)->doTask();
969+
ASSERT_EQ(flexCounterOrch->m_groupsWithBulkChunkSize.find("PORT"), flexCounterOrch->m_groupsWithBulkChunkSize.end());
970+
}
926971
}
927972

928973
// Remove buffer pools

0 commit comments

Comments
 (0)