From 031f64283bf2f34cc25640211b3e4e21e6d0aba4 Mon Sep 17 00:00:00 2001 From: Stephen Sun Date: Wed, 23 Jun 2021 11:11:45 +0000 Subject: [PATCH] Read and check the number of lanes regardless of the ASIC type Signed-off-by: Stephen Sun --- cfgmgr/buffer_check_headroom_mellanox.lua | 11 ++----- cfgmgr/buffer_pool_mellanox.lua | 40 ++++++++++------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/cfgmgr/buffer_check_headroom_mellanox.lua b/cfgmgr/buffer_check_headroom_mellanox.lua index 08f955fe4c..d700862448 100644 --- a/cfgmgr/buffer_check_headroom_mellanox.lua +++ b/cfgmgr/buffer_check_headroom_mellanox.lua @@ -40,13 +40,8 @@ redis.call('SELECT', config_db) local lanes --- On SPC3 switch, we need to know whether it's a 8-lane port because it has extra pipeline latency -local is_spc3 = false -local platform = redis.call('HGET', 'DEVICE_METADATA|localhost', 'platform') -if platform and string.sub(platform, 1, 16) == "x86_64-mlnx_msn4" then - is_spc3 = true - lanes = redis.call('HGET', 'PORT|' .. port, 'lanes') -end +-- We need to know whether it's a 8-lane port because it has extra pipeline latency +lanes = redis.call('HGET', 'PORT|' .. port, 'lanes') -- Fetch the threshold from STATE_DB redis.call('SELECT', state_db) @@ -58,7 +53,7 @@ end local asic_keys = redis.call('KEYS', 'ASIC_TABLE*') local pipeline_latency = tonumber(redis.call('HGET', asic_keys[1], 'pipeline_latency')) -if is_spc3 and is_port_with_8lanes(lanes) then +if is_port_with_8lanes(lanes) then -- The pipeline latency should be adjusted accordingly for ports with 2 buffer units pipeline_latency = pipeline_latency * 2 - 1 end diff --git a/cfgmgr/buffer_pool_mellanox.lua b/cfgmgr/buffer_pool_mellanox.lua index f43109c168..76316936bc 100644 --- a/cfgmgr/buffer_pool_mellanox.lua +++ b/cfgmgr/buffer_pool_mellanox.lua @@ -10,8 +10,6 @@ local port_count_8lanes = 0 -- Number of lossy PG on ports with 8 lanes local lossypg_8lanes = 0 -local is_spc3 = false - -- Private headrom local private_headroom = 10 * 1024 @@ -61,7 +59,7 @@ local function iterate_all_items(all_items, check_lossless) size = 1 + tonumber(string.sub(range, -1)) - tonumber(string.sub(range, 1, 1)) end profiles[profile_name] = profile_ref_count + size - if is_spc3 and port_set_8lanes[port] and profile_name == 'BUFFER_PROFILE_TABLE:ingress_lossy_profile' then + if port_set_8lanes[port] and profile_name == 'BUFFER_PROFILE_TABLE:ingress_lossy_profile' then lossypg_8lanes = lossypg_8lanes + size end if check_lossless and lossless_profiles[profile_name] then @@ -83,26 +81,22 @@ local ports_table = redis.call('KEYS', 'PORT|*') total_port = #ports_table -- Initialize the port_set_8lanes set -local platform = redis.call('HGET', 'DEVICE_METADATA|localhost', 'platform') -if platform and string.sub(platform, 1, 16) == "x86_64-mlnx_msn4" then - is_spc3 = true - local lanes - local number_of_lanes - local port - for i = 1, total_port, 1 do - -- Load lanes from PORT table - lanes = redis.call('HGET', ports_table[i], 'lanes') - if lanes then - local _ - _, number_of_lanes = string.gsub(lanes, ",", ",") - number_of_lanes = number_of_lanes + 1 - port = string.sub(ports_table[i], 6, -1) - if (number_of_lanes == 8) then - port_set_8lanes[port] = true - port_count_8lanes = port_count_8lanes + 1 - else - port_set_8lanes[port] = false - end +local lanes +local number_of_lanes +local port +for i = 1, total_port, 1 do + -- Load lanes from PORT table + lanes = redis.call('HGET', ports_table[i], 'lanes') + if lanes then + local _ + _, number_of_lanes = string.gsub(lanes, ",", ",") + number_of_lanes = number_of_lanes + 1 + port = string.sub(ports_table[i], 6, -1) + if (number_of_lanes == 8) then + port_set_8lanes[port] = true + port_count_8lanes = port_count_8lanes + 1 + else + port_set_8lanes[port] = false end end end