Skip to content

Commit f9462c4

Browse files
authored
[Dynamic buffer] [Mellanox] Calculate the peer response time according to the speed (sonic-net#1930)
- What I did Peer response time was deduced from a fixed value for all the ports speed. According to IEEE802.3 31B.3.7 at different operating speeds, the peer response time is also different, to have a more accurate headroom allocation, the way to calculate the peer response time shall be changed accordingly. See HLD update PR sonic-net/SONiC#870 for more info - Why I did it To have the peer response time more accurate, calculate according to the definition in IEEE802.3 31B.3.7 - How I verified it Run buffer regression tests on various Mellanox platforms at various port speeds, cable lengths, with or w/o gearbox.
1 parent 8b5a401 commit f9462c4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

cfgmgr/buffer_headroom_mellanox.lua

+24-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ local state_db = "6"
3535

3636
local ret = {}
3737

38+
-- pause quanta should be taken for each operating speed is defined in IEEE 802.3 31B.3.7
39+
-- the key of table pause_quanta_per_speed is operating speed at Mb/s
40+
-- the value of table pause_quanta_per_speed is the number of pause_quanta
41+
local pause_quanta_per_speed = {}
42+
pause_quanta_per_speed[400000] = 905
43+
pause_quanta_per_speed[200000] = 453
44+
pause_quanta_per_speed[100000] = 394
45+
pause_quanta_per_speed[50000] = 147
46+
pause_quanta_per_speed[40000] = 118
47+
pause_quanta_per_speed[25000] = 80
48+
pause_quanta_per_speed[10000] = 67
49+
pause_quanta_per_speed[1000] = 2
50+
pause_quanta_per_speed[100] = 1
51+
52+
-- Get pause_quanta from the pause_quanta_per_speed table
53+
local pause_quanta = pause_quanta_per_speed[port_speed]
54+
3855
if gearbox_delay == nil then
3956
gearbox_delay = 0
4057
end
@@ -55,7 +72,8 @@ for i = 1, #asic_table_content, 2 do
5572
if asic_table_content[i] == "mac_phy_delay" then
5673
mac_phy_delay = tonumber(asic_table_content[i+1]) * 1024
5774
end
58-
if asic_table_content[i] == "peer_response_time" then
75+
-- If failed to get pause_quanta from the table, then use the default peer_response_time stored in state_db
76+
if asic_table_content[i] == "peer_response_time" and pause_quanta == nil then
5977
peer_response_time = tonumber(asic_table_content[i+1]) * 1024
6078
end
6179
end
@@ -124,6 +142,11 @@ else
124142
bytes_on_gearbox = port_speed * gearbox_delay / (8 * 1024)
125143
end
126144

145+
-- If successfully get pause_quanta from the table, then calculate peer_response_time from it
146+
if pause_quanta ~= nil then
147+
peer_response_time = (pause_quanta) * 512 / 8
148+
end
149+
127150
bytes_on_cable = 2 * cable_length * port_speed * 1000000000 / speed_of_light / (8 * 1024)
128151
propagation_delay = port_mtu + bytes_on_cable + 2 * bytes_on_gearbox + mac_phy_delay + peer_response_time
129152

0 commit comments

Comments
 (0)