forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add buffer pool watermark support (sonic-net#853)
* Write fields to FLEX_COUNTER_GROUP_TABLE at the construction of a BufferOrch object: "POLL_INTERVAL" "BUFFER_POLL_PLUGIN_LIST" "STATS_MODE" Signed-off-by: Wenda Ni <wenni@microsoft.com> * Update buffer pool name to oid mapping in COUNTERS_DB upon the set and del of its oid Signed-off-by: Wenda Ni <wenni@microsoft.com> * Push buffer pool watermark COUNTER_ID_LIST to FLEX_COUNTER_TABLE Signed-off-by: Wenda Ni <wenni@microsoft.com> * Implement user clear logic to buffer pool watermark Signed-off-by: Wenda Ni <wenni@microsoft.com> * Add periodic clear to buffer pool watermark Signed-off-by: Wenda Ni <wenni@microsoft.com> * Add lua script for watermark_bufferpool Signed-off-by: Wenda Ni <wenni@microsoft.com> * Fix syntax error in buffer pool watermark lua script Signed-off-by: Wenda Ni <wenni@microsoft.com> * Fix compile error in watermarkorch.cpp Signed-off-by: Wenda Ni <wenni@microsoft.com> * Fix from dut verification Signed-off-by: Wenda Ni <wenni@microsoft.com> * Add 6000 to read only polling mode Signed-off-by: Wenda Ni <wenni@microsoft.com> * Touch-up to existing codes Signed-off-by: Wenda Ni <wenni@microsoft.com> * Remove debugging symbols Signed-off-by: Wenda Ni <wenni@microsoft.com> * Address comments Signed-off-by: Wenda Ni <wenni@microsoft.com> * Address comments Signed-off-by: Wenda Ni <wenni@microsoft.com>
- Loading branch information
Showing
7 changed files
with
241 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
-- KEYS - buffer IDs | ||
-- ARGV[1] - counters db index | ||
-- ARGV[2] - counters table name | ||
-- ARGV[3] - poll time interval | ||
-- return nothing for now | ||
|
||
local counters_db = ARGV[1] | ||
local counters_table_name = 'COUNTERS' | ||
|
||
local user_table_name = 'USER_WATERMARKS' | ||
local persistent_table_name = 'PERSISTENT_WATERMARKS' | ||
local periodic_table_name = 'PERIODIC_WATERMARKS' | ||
|
||
local sai_buffer_pool_watermark_stat_name = 'SAI_BUFFER_POOL_STAT_WATERMARK_BYTES' | ||
|
||
local rets = {} | ||
|
||
redis.call('SELECT', counters_db) | ||
|
||
-- Iterate through each buffer pool oid | ||
local n = table.getn(KEYS) | ||
for i = n, 1, -1 do | ||
-- Get new watermark value from COUNTERS | ||
local wm = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name) | ||
if wm then | ||
wm = tonumber(wm) | ||
|
||
-- Get last value from *_WATERMARKS | ||
local user_wm_last = redis.call('HGET', user_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name) | ||
|
||
-- Set higher value to *_WATERMARKS | ||
if user_wm_last then | ||
user_wm_last = tonumber(user_wm_last) | ||
if wm > user_wm_last then | ||
redis.call('HSET', user_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name, wm) | ||
end | ||
else | ||
redis.call('HSET', user_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name, wm) | ||
end | ||
|
||
local persistent_wm_last = redis.call('HGET', persistent_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name) | ||
if persistent_wm_last then | ||
persistent_wm_last = tonumber(persistent_wm_last) | ||
if wm > persistent_wm_last then | ||
redis.call('HSET', persistent_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name, wm) | ||
end | ||
else | ||
redis.call('HSET', persistent_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name, wm) | ||
end | ||
|
||
local periodic_wm_last = redis.call('HGET', periodic_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name) | ||
if periodic_wm_last then | ||
periodic_wm_last = tonumber(periodic_wm_last) | ||
if wm > periodic_wm_last then | ||
redis.call('HSET', periodic_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name, wm) | ||
end | ||
else | ||
redis.call('HSET', periodic_table_name .. ':' .. KEYS[i], sai_buffer_pool_watermark_stat_name, wm) | ||
end | ||
end | ||
end | ||
|
||
return rets |
Oops, something went wrong.