@@ -12,7 +12,7 @@ local lossypg_400g = 0
12
12
local result = {}
13
13
local profiles = {}
14
14
15
- local total_port = 0
15
+ local count_up_port = 0
16
16
17
17
local mgmt_pool_size = 256 * 1024
18
18
local egress_mirror_headroom = 10 * 1024
30
30
31
31
local function iterate_all_items (all_items )
32
32
table.sort (all_items )
33
+ local prev_port = " None"
33
34
local port
35
+ local is_up
34
36
local fvpairs
37
+ local status
38
+ local admin_down_ports = 0
35
39
for i = 1 , # all_items , 1 do
36
- -- Count the number of priorities or queues in each BUFFER_PG or BUFFER_QUEUE item
37
- -- For example, there are:
38
- -- 3 queues in 'BUFFER_QUEUE_TABLE:Ethernet0:0-2'
39
- -- 2 priorities in 'BUFFER_PG_TABLE:Ethernet0:3-4'
40
+ -- Check whether the port on which pg or tc hosts is admin down
40
41
port = string.match (all_items [i ], " Ethernet%d+" )
41
42
if port ~= nil then
42
- local range = string.match (all_items [i ], " Ethernet%d+:([^%s]+)$" )
43
- local profile = redis .call (' HGET' , all_items [i ], ' profile' )
44
- local index = find_profile (profile )
45
- if index == 0 then
46
- -- Indicate an error in case the referenced profile hasn't been inserted or has been removed
47
- -- It's possible when the orchagent is busy
48
- -- The buffermgrd will take care of it and retry later
49
- return 1
50
- end
51
- local size
52
- if string.len (range ) == 1 then
53
- size = 1
54
- else
55
- size = 1 + tonumber (string.sub (range , - 1 )) - tonumber (string.sub (range , 1 , 1 ))
43
+ if prev_port ~= port then
44
+ status = redis .call (' HGET' , ' PORT_TABLE:' .. port , ' admin_status' )
45
+ prev_port = port
46
+ if status == " down" then
47
+ is_up = false
48
+ else
49
+ is_up = true
50
+ end
56
51
end
57
- profiles [index ][2 ] = profiles [index ][2 ] + size
58
- local speed = redis .call (' HGET' , ' PORT_TABLE:' .. port , ' speed' )
59
- if speed == ' 400000' and profile == ' [BUFFER_PROFILE_TABLE:ingress_lossy_profile]' then
60
- lossypg_400g = lossypg_400g + size
52
+ if is_up == true then
53
+ local range = string.match (all_items [i ], " Ethernet%d+:([^%s]+)$" )
54
+ local profile = redis .call (' HGET' , all_items [i ], ' profile' )
55
+ local index = find_profile (profile )
56
+ local size
57
+ if string.len (range ) == 1 then
58
+ size = 1
59
+ else
60
+ size = 1 + tonumber (string.sub (range , - 1 )) - tonumber (string.sub (range , 1 , 1 ))
61
+ end
62
+ profiles [index ][2 ] = profiles [index ][2 ] + size
63
+ local speed = redis .call (' HGET' , ' PORT_TABLE:' .. port , ' speed' )
64
+ if speed == ' 400000' and profile == ' [BUFFER_PROFILE_TABLE:ingress_lossy_profile]' then
65
+ lossypg_400g = lossypg_400g + size
66
+ end
61
67
end
62
68
end
63
69
end
64
- return 0
65
70
end
66
71
67
72
-- Connect to CONFIG_DB
68
73
redis .call (' SELECT' , config_db )
69
74
70
75
local ports_table = redis .call (' KEYS' , ' PORT|*' )
71
76
72
- total_port = # ports_table
77
+ for i = 1 , # ports_table do
78
+ local status = redis .call (' HGET' , ports_table [i ], ' admin_status' )
79
+ if status == " up" then
80
+ count_up_port = count_up_port + 1
81
+ end
82
+ end
73
83
74
84
local egress_lossless_pool_size = redis .call (' HGET' , ' BUFFER_POOL|egress_lossless_pool' , ' size' )
75
85
104
114
local all_pgs = redis .call (' KEYS' , ' BUFFER_PG*' )
105
115
local all_tcs = redis .call (' KEYS' , ' BUFFER_QUEUE*' )
106
116
107
- local fail_count = 0
108
- fail_count = fail_count + iterate_all_items (all_pgs )
109
- fail_count = fail_count + iterate_all_items (all_tcs )
110
- if fail_count > 0 then
111
- return {}
112
- end
117
+ iterate_all_items (all_pgs )
118
+ iterate_all_items (all_tcs )
113
119
114
120
local statistics = {}
115
121
@@ -124,7 +130,7 @@ for i = 1, #profiles, 1 do
124
130
size = size + lossypg_reserved
125
131
end
126
132
if profiles [i ][1 ] == " BUFFER_PROFILE_TABLE:egress_lossy_profile" then
127
- profiles [i ][2 ] = total_port
133
+ profiles [i ][2 ] = count_up_port
128
134
end
129
135
if size ~= 0 then
130
136
if shp_enabled and shp_size == 0 then
@@ -146,7 +152,7 @@ local lossypg_extra_for_400g = (lossypg_reserved_400g - lossypg_reserved) * loss
146
152
accumulative_occupied_buffer = accumulative_occupied_buffer + lossypg_extra_for_400g
147
153
148
154
-- Accumulate sizes for egress mirror and management pool
149
- local accumulative_egress_mirror_overhead = total_port * egress_mirror_headroom
155
+ local accumulative_egress_mirror_overhead = count_up_port * egress_mirror_headroom
150
156
accumulative_occupied_buffer = accumulative_occupied_buffer + accumulative_egress_mirror_overhead + mgmt_pool_size
151
157
152
158
-- Fetch mmu_size
@@ -234,6 +240,5 @@ table.insert(result, "debug:egress_mirror:" .. accumulative_egress_mirror_overhe
234
240
table.insert (result , " debug:shp_enabled:" .. tostring (shp_enabled ))
235
241
table.insert (result , " debug:shp_size:" .. shp_size )
236
242
table.insert (result , " debug:accumulative xoff:" .. accumulative_xoff )
237
- table.insert (result , " debug:total port:" .. total_port )
238
243
239
244
return result
0 commit comments