@@ -133,7 +133,7 @@ local function iterate_profile_list(all_items)
133
133
return 0
134
134
end
135
135
136
- local function fetch_buffer_pool_size_from_appldb ()
136
+ local function fetch_buffer_pool_size_from_appldb (shp_enabled )
137
137
local buffer_pools = {}
138
138
redis .call (' SELECT' , config_db )
139
139
local buffer_pool_keys = redis .call (' KEYS' , ' BUFFER_POOL|*' )
@@ -158,7 +158,18 @@ local function fetch_buffer_pool_size_from_appldb()
158
158
end
159
159
xoff = redis .call (' HGET' , ' BUFFER_POOL_TABLE:' .. buffer_pools [i ], ' xoff' )
160
160
if not xoff then
161
- table.insert (result , buffer_pools [i ] .. ' :' .. size )
161
+ if shp_enabled and size == " 0" and buffer_pools [i ] == " ingress_lossless_pool" then
162
+ -- During initialization, if SHP is enabled
163
+ -- 1. the buffer pool sizes, xoff have initialized to 0, which means the shared headroom pool is disabled
164
+ -- 2. but the buffer profiles already indicate the shared headroom pool is enabled
165
+ -- 3. later on the buffer pool sizes are updated with xoff being non-zero
166
+ -- In case the orchagent starts handling buffer configuration between 2 and 3,
167
+ -- It is inconsistent between buffer pools and profiles, which fails Mellanox SAI sanity check
168
+ -- To avoid it, it indicates the shared headroom pool is enabled by setting a very small buffer pool and shared headroom pool sizes
169
+ table.insert (result , buffer_pools [i ] .. ' :2048:1024' )
170
+ else
171
+ table.insert (result , buffer_pools [i ] .. ' :' .. size )
172
+ end
162
173
else
163
174
table.insert (result , buffer_pools [i ] .. ' :' .. size .. ' :' .. xoff )
164
175
end
@@ -295,7 +306,7 @@ local fail_count = 0
295
306
fail_count = fail_count + iterate_all_items (all_pgs , true )
296
307
fail_count = fail_count + iterate_all_items (all_tcs , false )
297
308
if fail_count > 0 then
298
- fetch_buffer_pool_size_from_appldb ()
309
+ fetch_buffer_pool_size_from_appldb (shp_enabled )
299
310
return result
300
311
end
301
312
@@ -305,7 +316,7 @@ local all_egress_profile_lists = redis.call('KEYS', 'BUFFER_PORT_EGRESS_PROFILE_
305
316
fail_count = fail_count + iterate_profile_list (all_ingress_profile_lists )
306
317
fail_count = fail_count + iterate_profile_list (all_egress_profile_lists )
307
318
if fail_count > 0 then
308
- fetch_buffer_pool_size_from_appldb ()
319
+ fetch_buffer_pool_size_from_appldb (shp_enabled )
309
320
return result
310
321
end
311
322
@@ -406,10 +417,12 @@ local pool_size
406
417
if shp_size then
407
418
accumulative_occupied_buffer = accumulative_occupied_buffer + shp_size
408
419
end
420
+
421
+ local available_buffer = mmu_size - accumulative_occupied_buffer
409
422
if ingress_pool_count == 1 then
410
- pool_size = mmu_size - accumulative_occupied_buffer
423
+ pool_size = available_buffer
411
424
else
412
- pool_size = ( mmu_size - accumulative_occupied_buffer ) / 2
425
+ pool_size = available_buffer / 2
413
426
end
414
427
415
428
if pool_size > ceiling_mmu_size then
@@ -418,12 +431,19 @@ end
418
431
419
432
local shp_deployed = false
420
433
for i = 1 , # pools_need_update , 1 do
434
+ local percentage = tonumber (redis .call (' HGET' , pools_need_update [i ], ' percentage' ))
435
+ local effective_pool_size
436
+ if percentage ~= nil and percentage >= 0 then
437
+ effective_pool_size = available_buffer * percentage / 100
438
+ else
439
+ effective_pool_size = pool_size
440
+ end
421
441
local pool_name = string.match (pools_need_update [i ], " BUFFER_POOL|([^%s]+)$" )
422
442
if shp_size ~= 0 and pool_name == " ingress_lossless_pool" then
423
- table.insert (result , pool_name .. " :" .. math.ceil (pool_size ) .. " :" .. math.ceil (shp_size ))
443
+ table.insert (result , pool_name .. " :" .. math.ceil (effective_pool_size ) .. " :" .. math.ceil (shp_size ))
424
444
shp_deployed = true
425
445
else
426
- table.insert (result , pool_name .. " :" .. math.ceil (pool_size ))
446
+ table.insert (result , pool_name .. " :" .. math.ceil (effective_pool_size ))
427
447
end
428
448
end
429
449
0 commit comments