Skip to content

Commit 02b2b97

Browse files
Add support for platform based on Clounix asic
What I did Add support for platform based on Clounix asic. How I did it Add support for platform based on Clounix asic. How to verify it Verified on physical DUT. Signed-off-by: Long Wu <[email protected]> Signed-off-by: Qinghua Song <[email protected]>
1 parent f9bf770 commit 02b2b97

File tree

6 files changed

+108
-2
lines changed

6 files changed

+108
-2
lines changed

orchagent/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dist_swss_DATA = \
2828
pfc_detect_vs.lua \
2929
pfc_restore.lua \
3030
pfc_restore_cisco-8000.lua \
31+
pfc_detect_clounix.lua \
3132
port_rates.lua \
3233
watermark_queue.lua \
3334
watermark_pg.lua \

orchagent/aclorch.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,9 +3341,10 @@ AclRange *AclRange::create(sai_acl_range_type_t type, int min, int max)
33413341
// work around to avoid syncd termination on SAI error due to max count of ranges reached
33423342
// can be removed when syncd start passing errors to the SAI callers
33433343
char *platform = getenv("platform");
3344-
if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING))
3344+
if (platform)
33453345
{
3346-
if (m_ranges.size() >= MLNX_MAX_RANGES_COUNT)
3346+
if ((strstr(platform, MLNX_PLATFORM_SUBSTRING) && m_ranges.size() >= MLNX_MAX_RANGES_COUNT) ||
3347+
(strstr(platform, CLX_PLATFORM_SUBSTRING) && m_ranges.size() >= CLNX_MAX_RANGES_COUNT))
33473348
{
33483349
SWSS_LOG_ERROR("Maximum numbers of ACL ranges reached");
33493350
return NULL;
@@ -3466,6 +3467,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
34663467
platform == MRVL_TL_PLATFORM_SUBSTRING ||
34673468
platform == NPS_PLATFORM_SUBSTRING ||
34683469
platform == XS_PLATFORM_SUBSTRING ||
3470+
platform == CLX_PLATFORM_SUBSTRING ||
34693471
platform == VS_PLATFORM_SUBSTRING)
34703472
{
34713473
m_mirrorTableCapabilities =
@@ -3520,6 +3522,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
35203522
platform == CISCO_8000_PLATFORM_SUBSTRING ||
35213523
platform == MRVL_PRST_PLATFORM_SUBSTRING ||
35223524
platform == XS_PLATFORM_SUBSTRING ||
3525+
platform == CLX_PLATFORM_SUBSTRING ||
35233526
(platform == BRCM_PLATFORM_SUBSTRING && sub_platform == BRCM_DNX_PLATFORM_SUBSTRING))
35243527
{
35253528
m_isCombinedMirrorV6Table = false;

orchagent/aclorch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
#define IP_TYPE_ARP_REPLY "ARP_REPLY"
108108

109109
#define MLNX_MAX_RANGES_COUNT 16
110+
#define CLNX_MAX_RANGES_COUNT 16
110111
#define INGRESS_TABLE_DROP "IngressTableDrop"
111112
#define EGRESS_TABLE_DROP "EgressTableDrop"
112113
#define RULE_OPER_ADD 0

orchagent/orch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const char state_db_key_delimiter = '|';
4646
#define NPS_PLATFORM_SUBSTRING "nephos"
4747
#define CISCO_8000_PLATFORM_SUBSTRING "cisco-8000"
4848
#define XS_PLATFORM_SUBSTRING "xsight"
49+
#define CLX_PLATFORM_SUBSTRING "clounix"
4950

5051
#define CONFIGDB_KEY_SEPARATOR "|"
5152
#define DEFAULT_KEY_SEPARATOR ":"

orchagent/orchdaemon.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ bool OrchDaemon::init()
645645
}
646646
else if ((platform == MRVL_TL_PLATFORM_SUBSTRING)
647647
|| (platform == MRVL_PRST_PLATFORM_SUBSTRING)
648+
|| (platform == CLX_PLATFORM_SUBSTRING)
648649
|| (platform == BFN_PLATFORM_SUBSTRING)
649650
|| (platform == NPS_PLATFORM_SUBSTRING))
650651
{
@@ -679,6 +680,7 @@ bool OrchDaemon::init()
679680

680681
if ((platform == MRVL_PRST_PLATFORM_SUBSTRING) ||
681682
(platform == MRVL_TL_PLATFORM_SUBSTRING) ||
683+
(platform == CLX_PLATFORM_SUBSTRING) ||
682684
(platform == NPS_PLATFORM_SUBSTRING))
683685
{
684686
m_orchList.push_back(new PfcWdSwOrch<PfcWdZeroBufferHandler, PfcWdLossyHandler>(

orchagent/pfc_detect_clounix.lua

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
-- KEYS - queue IDs
2+
-- ARGV[1] - counters db index
3+
-- ARGV[2] - counters table name
4+
-- ARGV[3] - poll time interval (milliseconds)
5+
-- return queue Ids that satisfy criteria
6+
7+
local counters_db = ARGV[1]
8+
local counters_table_name = ARGV[2]
9+
local poll_time = tonumber(ARGV[3]) * 1000
10+
11+
local rets = {}
12+
13+
redis.call('SELECT', counters_db)
14+
15+
-- Iterate through each queue
16+
local n = table.getn(KEYS)
17+
for i = n, 1, -1 do
18+
local counter_keys = redis.call('HKEYS', counters_table_name .. ':' .. KEYS[i])
19+
local counter_num = 0
20+
local old_counter_num = 0
21+
local is_deadlock = false
22+
local pfc_wd_status = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_STATUS')
23+
local pfc_wd_action = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_ACTION')
24+
local big_red_switch_mode = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'BIG_RED_SWITCH_MODE')
25+
if not big_red_switch_mode and (pfc_wd_status == 'operational' or pfc_wd_action == 'alert') then
26+
local detection_time = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_DETECTION_TIME')
27+
if detection_time then
28+
detection_time = tonumber(detection_time)
29+
local time_left = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_DETECTION_TIME_LEFT')
30+
if not time_left then
31+
time_left = detection_time
32+
else
33+
time_left = tonumber(time_left)
34+
end
35+
36+
local queue_index = redis.call('HGET', 'COUNTERS_QUEUE_INDEX_MAP', KEYS[i])
37+
local port_id = redis.call('HGET', 'COUNTERS_QUEUE_PORT_MAP', KEYS[i])
38+
local pfc_rx_pkt_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PKTS'
39+
local pfc_duration_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PAUSE_DURATION'
40+
41+
-- Get all counters
42+
local occupancy_bytes = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES')
43+
local packets = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS')
44+
local pfc_rx_packets = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key)
45+
local pfc_duration = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_duration_key)
46+
47+
if occupancy_bytes and packets and pfc_rx_packets and pfc_duration then
48+
occupancy_bytes = tonumber(occupancy_bytes)
49+
packets = tonumber(packets)
50+
pfc_rx_packets = tonumber(pfc_rx_packets)
51+
pfc_duration = tonumber(pfc_duration)
52+
53+
local packets_last = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS_last')
54+
local pfc_rx_packets_last = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key .. '_last')
55+
local pfc_duration_last = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_duration_key .. '_last')
56+
-- DEBUG CODE START. Uncomment to enable
57+
local debug_storm = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'DEBUG_STORM')
58+
-- DEBUG CODE END.
59+
60+
-- If this is not a first run, then we have last values available
61+
if packets_last and pfc_rx_packets_last and pfc_duration_last then
62+
packets_last = tonumber(packets_last)
63+
pfc_rx_packets_last = tonumber(pfc_rx_packets_last)
64+
pfc_duration_last = tonumber(pfc_duration_last)
65+
66+
-- Check actual condition of queue being in PFC storm
67+
if (occupancy_bytes > 0 and packets - packets_last == 0 and pfc_rx_packets - pfc_rx_packets_last > 0) or
68+
-- DEBUG CODE START. Uncomment to enable
69+
(debug_storm == "enabled") or
70+
-- DEBUG CODE END.
71+
(occupancy_bytes == 0 and packets - packets_last == 0 and (pfc_duration - pfc_duration_last) > poll_time * 0.8) then
72+
if time_left <= poll_time then
73+
redis.call('PUBLISH', 'PFC_WD_ACTION', '["' .. KEYS[i] .. '","storm"]')
74+
is_deadlock = true
75+
time_left = detection_time
76+
else
77+
time_left = time_left - poll_time
78+
end
79+
else
80+
if pfc_wd_action == 'alert' and pfc_wd_status ~= 'operational' then
81+
redis.call('PUBLISH', 'PFC_WD_ACTION', '["' .. KEYS[i] .. '","restore"]')
82+
end
83+
time_left = detection_time
84+
end
85+
end
86+
87+
-- Save values for next run
88+
redis.call('HSET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS_last', packets)
89+
redis.call('HSET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_DETECTION_TIME_LEFT', time_left)
90+
redis.call('HSET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key .. '_last', pfc_rx_packets)
91+
redis.call('HDEL', counters_table_name .. ':' .. port_id, pfc_duration_key .. '_last')
92+
redis.call('HSET', counters_table_name .. ':' .. port_id, pfc_duration_key .. '_last', pfc_duration)
93+
end
94+
end
95+
end
96+
end
97+
98+
return rets

0 commit comments

Comments
 (0)