Skip to content

Commit

Permalink
Read and check the number of lanes regardless of the ASIC type
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sun <stephens@nvidia.com>
  • Loading branch information
stephenxs committed Jun 23, 2021
1 parent 467b8cb commit 031f642
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
11 changes: 3 additions & 8 deletions cfgmgr/buffer_check_headroom_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
40 changes: 17 additions & 23 deletions cfgmgr/buffer_pool_mellanox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 031f642

Please sign in to comment.