diff --git a/orchagent/Makefile.am b/orchagent/Makefile.am index 5e3cd741cc..c706806ad6 100644 --- a/orchagent/Makefile.am +++ b/orchagent/Makefile.am @@ -18,6 +18,7 @@ dist_swss_DATA = \ rif_rates.lua \ pfc_detect_innovium.lua \ pfc_detect_mellanox.lua \ + pfc_detect_clounix.lua \ pfc_detect_broadcom.lua \ pfc_detect_barefoot.lua \ pfc_detect_nephos.lua \ diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 7c176fc0e5..fd60674805 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2907,6 +2907,7 @@ AclRange *AclRange::create(sai_acl_range_type_t type, int min, int max) // work around to avoid syncd termination on SAI error due to max count of ranges reached // can be removed when syncd start passing errors to the SAI callers char *platform = getenv("platform"); + if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING)) { if (m_ranges.size() >= MLNX_MAX_RANGES_COUNT) @@ -2915,6 +2916,17 @@ AclRange *AclRange::create(sai_acl_range_type_t type, int min, int max) return NULL; } } + //add the platform of CLOUNIX + else if (platform && strstr(platform, CLX_PLATFORM_SUBSTRING)) + { + + if (m_ranges.size() >= CLNX_MAX_RANGES_COUNT) + { + SWSS_LOG_ERROR("Maximum numbers of ACL ranges reached"); + //SWSS_LOG_INFO(" CLX_MAX_RANGES_COUNT: %d", CLNX_MAX_RANGES_COUNT); + return NULL; + } + } attr.id = SAI_ACL_RANGE_ATTR_TYPE; attr.value.s32 = type; @@ -3024,6 +3036,7 @@ void AclOrch::init(vector& connectors, PortsOrch *portOrch, Mirr // purposes. string platform = getenv("platform") ? getenv("platform") : ""; string sub_platform = getenv("sub_platform") ? getenv("sub_platform") : ""; + if (platform == BRCM_PLATFORM_SUBSTRING || platform == CISCO_8000_PLATFORM_SUBSTRING || platform == MLNX_PLATFORM_SUBSTRING || @@ -3032,7 +3045,8 @@ void AclOrch::init(vector& connectors, PortsOrch *portOrch, Mirr platform == INVM_PLATFORM_SUBSTRING || platform == NPS_PLATFORM_SUBSTRING || platform == XS_PLATFORM_SUBSTRING || - platform == VS_PLATFORM_SUBSTRING) + platform == VS_PLATFORM_SUBSTRING || + platform == CLX_PLATFORM_SUBSTRING) { m_mirrorTableCapabilities = { @@ -3061,7 +3075,8 @@ void AclOrch::init(vector& connectors, PortsOrch *portOrch, Mirr platform == CISCO_8000_PLATFORM_SUBSTRING || platform == MRVL_PLATFORM_SUBSTRING || platform == XS_PLATFORM_SUBSTRING || - (platform == BRCM_PLATFORM_SUBSTRING && sub_platform == BRCM_DNX_PLATFORM_SUBSTRING)) + (platform == BRCM_PLATFORM_SUBSTRING && sub_platform == BRCM_DNX_PLATFORM_SUBSTRING) || + platform == CLX_PLATFORM_SUBSTRING) { m_isCombinedMirrorV6Table = false; } @@ -3722,6 +3737,7 @@ bool AclOrch::updateAclTablePorts(AclTable &newTable, AclTable &curTable) curTable.link(port_oid); curTable.bind(port_oid); } + return true; } @@ -4216,6 +4232,7 @@ bool AclOrch::isAclActionListMandatoryOnTableCreation(acl_stage_type_t stage) co { return false; } + return it->second.isActionListMandatoryOnTableCreation; } diff --git a/orchagent/aclorch.h b/orchagent/aclorch.h index 57277615e3..6f8fd0f6df 100644 --- a/orchagent/aclorch.h +++ b/orchagent/aclorch.h @@ -94,6 +94,7 @@ #define IP_TYPE_ARP_REPLY "ARP_REPLY" #define MLNX_MAX_RANGES_COUNT 16 +#define CLNX_MAX_RANGES_COUNT 16 #define INGRESS_TABLE_DROP "IngressTableDrop" #define EGRESS_TABLE_DROP "EgressTableDrop" #define RULE_OPER_ADD 0 diff --git a/orchagent/orch.h b/orchagent/orch.h index efee98a73c..7353cb1b3b 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -41,6 +41,7 @@ const char state_db_key_delimiter = '|'; #define MRVL_PLATFORM_SUBSTRING "marvell" #define CISCO_8000_PLATFORM_SUBSTRING "cisco-8000" #define XS_PLATFORM_SUBSTRING "xsight" +#define CLX_PLATFORM_SUBSTRING "clounix" #define CONFIGDB_KEY_SEPARATOR "|" #define DEFAULT_KEY_SEPARATOR ":" diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 2b7564fc07..2b176ea8b7 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -518,6 +518,7 @@ bool OrchDaemon::init() PFC_WD_POLL_MSECS)); } else if ((platform == INVM_PLATFORM_SUBSTRING) + || (platform == CLX_PLATFORM_SUBSTRING) || (platform == BFN_PLATFORM_SUBSTRING) || (platform == NPS_PLATFORM_SUBSTRING)) { @@ -550,7 +551,7 @@ bool OrchDaemon::init() static const vector queueAttrIds; - if ((platform == INVM_PLATFORM_SUBSTRING) || (platform == NPS_PLATFORM_SUBSTRING)) + if ((platform == INVM_PLATFORM_SUBSTRING) || (platform == NPS_PLATFORM_SUBSTRING) || (platform == CLX_PLATFORM_SUBSTRING)) { m_orchList.push_back(new PfcWdSwOrch( m_configDb, diff --git a/orchagent/pfc_detect_clounix.lua b/orchagent/pfc_detect_clounix.lua new file mode 100644 index 0000000000..72f1cbea94 --- /dev/null +++ b/orchagent/pfc_detect_clounix.lua @@ -0,0 +1,99 @@ +-- KEYS - queue IDs +-- ARGV[1] - counters db index +-- ARGV[2] - counters table name +-- ARGV[3] - poll time interval (milliseconds) +-- return queue Ids that satisfy criteria + +local counters_db = ARGV[1] +local counters_table_name = ARGV[2] +local poll_time = tonumber(ARGV[3]) * 1000 + +local rets = {} + +redis.call('SELECT', counters_db) + +-- Iterate through each queue +local n = table.getn(KEYS) +for i = n, 1, -1 do + local counter_keys = redis.call('HKEYS', counters_table_name .. ':' .. KEYS[i]) + local counter_num = 0 + local old_counter_num = 0 + local is_deadlock = false + local pfc_wd_status = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_STATUS') + local pfc_wd_action = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_ACTION') + local big_red_switch_mode = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'BIG_RED_SWITCH_MODE') + if not big_red_switch_mode and (pfc_wd_status == 'operational' or pfc_wd_action == 'alert') then + local detection_time = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_DETECTION_TIME') + if detection_time then + detection_time = tonumber(detection_time) + local time_left = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_DETECTION_TIME_LEFT') + if not time_left then + time_left = detection_time + else + time_left = tonumber(time_left) + end + + local queue_index = redis.call('HGET', 'COUNTERS_QUEUE_INDEX_MAP', KEYS[i]) + local port_id = redis.call('HGET', 'COUNTERS_QUEUE_PORT_MAP', KEYS[i]) + local pfc_rx_pkt_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PKTS' + local pfc_duration_key = 'SAI_PORT_STAT_PFC_' .. queue_index .. '_RX_PAUSE_DURATION' + + -- Get all counters + local occupancy_bytes = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES') + local packets = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS') + local pfc_rx_packets = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key) + local pfc_duration = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_duration_key) + + if occupancy_bytes and packets and pfc_rx_packets and pfc_duration then + occupancy_bytes = tonumber(occupancy_bytes) + packets = tonumber(packets) + pfc_rx_packets = tonumber(pfc_rx_packets) + pfc_duration = tonumber(pfc_duration) + + local packets_last = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS_last') + local pfc_rx_packets_last = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key .. '_last') + local pfc_duration_last = redis.call('HGET', counters_table_name .. ':' .. port_id, pfc_duration_key .. '_last') + -- DEBUG CODE START. Uncomment to enable + local debug_storm = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'DEBUG_STORM') + -- DEBUG CODE END. + + -- If this is not a first run, then we have last values available + if packets_last and pfc_rx_packets_last and pfc_duration_last then + packets_last = tonumber(packets_last) + pfc_rx_packets_last = tonumber(pfc_rx_packets_last) + pfc_duration_last = tonumber(pfc_duration_last) + + -- Check actual condition of queue being in PFC storm + if (occupancy_bytes > 0 and packets - packets_last == 0 and pfc_rx_packets - pfc_rx_packets_last > 0) or + -- DEBUG CODE START. Uncomment to enable + (debug_storm == "enabled") or + -- DEBUG CODE END. + (occupancy_bytes == 0 and packets - packets_last == 0 and (pfc_duration - pfc_duration_last) > poll_time * 0.8) then + if time_left <= poll_time then + redis.call('PUBLISH', 'PFC_WD_ACTION', '["' .. KEYS[i] .. '","storm"]') + is_deadlock = true + time_left = detection_time + else + time_left = time_left - poll_time + end + else + if pfc_wd_action == 'alert' and pfc_wd_status ~= 'operational' then + redis.call('PUBLISH', 'PFC_WD_ACTION', '["' .. KEYS[i] .. '","restore"]') + end + time_left = detection_time + end + end + + -- Save values for next run + redis.call('HSET', counters_table_name .. ':' .. KEYS[i], 'SAI_QUEUE_STAT_PACKETS_last', packets) + redis.call('HSET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_DETECTION_TIME_LEFT', time_left) + redis.call('HSET', counters_table_name .. ':' .. port_id, pfc_rx_pkt_key .. '_last', pfc_rx_packets) + redis.call('HDEL', counters_table_name .. ':' .. port_id, pfc_duration_key .. '_last') + redis.call('HSET', counters_table_name .. ':' .. port_id, pfc_duration_key .. '_last', pfc_duration) + end + end + end +end + +return rets +