Skip to content

Commit

Permalink
[QoS] Support dynamic headroom calculation for Barefoot platforms
Browse files Browse the repository at this point in the history
Signed-off-by: Mariusz Stachura <mariusz.stachura@intel.com>
  • Loading branch information
MariuszStachura committed Aug 11, 2022
1 parent 2e40f50 commit 8381a27
Show file tree
Hide file tree
Showing 8 changed files with 608 additions and 77 deletions.
5 changes: 3 additions & 2 deletions tests/common/config_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True,
logger.info('reloading {}'.format(config_source))

if config_source == 'minigraph':
if start_dynamic_buffer and duthost.facts['asic_type'] == 'mellanox':
if start_dynamic_buffer and duthost.facts['asic_type'] in ['mellanox', 'barefoot']:
output = duthost.shell('redis-cli -n 4 hget "DEVICE_METADATA|localhost" buffer_model', module_ignore_errors=True)
is_buffer_model_dynamic = (output and output.get('stdout') == 'dynamic')
else:
Expand All @@ -99,7 +99,8 @@ def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True,
if start_bgp:
duthost.shell('config bgp startup all')
if is_buffer_model_dynamic:
duthost.shell('enable-dynamic-buffer.py')
duthost.copy(src="./common/helpers/enable-dynamic-buffer.py", dest="/tmp/enable-dynamic-buffer.py", mode="0755")
duthost.shell('/tmp/enable-dynamic-buffer.py')
duthost.shell('config save -y')

if config_source == 'config_db':
Expand Down
3 changes: 3 additions & 0 deletions tests/common/system_utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tests.common import config_reload
from tests.common.utilities import wait_until
from tests.common.helpers.assertions import pytest_assert
from tests.common.barefoot_data import is_barefoot_device
from tests.common.broadcom_data import is_broadcom_device
from tests.common.mellanox_data import is_mellanox_device
from tests.common.errors import RunAnsibleModuleFail
Expand Down Expand Up @@ -215,6 +216,8 @@ def _get_vendor_id(duthost):
vendor_id = "brcm"
elif is_mellanox_device(duthost):
vendor_id = "mlnx"
elif is_barefoot_device(duthost):
vendor_id = "bfn"
elif is_cisco_device(duthost):
vendor_id = "cisco"
else:
Expand Down
179 changes: 179 additions & 0 deletions tests/qos/files/barefoot/qos_param_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import math

class QosParamBarefoot(object):
def __init__(self, qos_params, asic_type, speed_cable_len, dutConfig, ingressLosslessProfile, ingressLossyProfile, egressLosslessProfile, egressLossyProfile, sharedHeadroomPoolSize):
asic_param_dic = {
'tf1': {
'cell_size': 80,
},
'tf2': {
'cell_size': 176,
}
}

self.asic_type = asic_type
self.cell_size = asic_param_dic[asic_type]['cell_size']
self.speed_cable_len = speed_cable_len
self.lossless_profile = "pg_lossless_{}_profile".format(speed_cable_len)
self.pools_info = {}
self.qos_parameters = {}
self.qos_params_bfn = qos_params
self.qos_params_bfn[self.speed_cable_len] = self.qos_params_bfn['profile']
self.ingressLosslessProfile = ingressLosslessProfile
self.ingressLossyProfile = ingressLossyProfile
self.egressLosslessProfile = egressLosslessProfile
self.egressLossyProfile = egressLossyProfile
if sharedHeadroomPoolSize and int(sharedHeadroomPoolSize) != 0:
self.sharedHeadroomPoolSize = sharedHeadroomPoolSize
else:
self.sharedHeadroomPoolSize = None
self.dutConfig = dutConfig

return

def run(self):
"""
Main method of the class
Returns the dictionary containing all the parameters required for the qos test
"""
self.collect_qos_configurations()
self.calculate_parameters()
return self.qos_params_bfn

def collect_qos_configurations(self):
"""
Collect qos configuration from the following fixtures
ingressLosslessProfile
egressLossyProfile
"""
xon = int(math.ceil(float(self.ingressLosslessProfile['xon']) / self.cell_size))
xoff = int(math.ceil(float(self.ingressLosslessProfile['xoff']) / self.cell_size))
size = int(math.ceil(float(self.ingressLosslessProfile['size']) / self.cell_size))

# For Shared Headroom Pool Size
headroom = xon + xoff
ingress_lossless_size = int(math.ceil(float(self.ingressLosslessProfile['static_th']) / self.cell_size)) - xon
hysteresis = headroom - (xon + xoff)

egress_lossy_size = int(math.ceil(float(self.egressLossyProfile['static_th']) / self.cell_size))

pkts_num_trig_pfc = ingress_lossless_size + xon + hysteresis
pkts_num_trig_ingr_drp = ingress_lossless_size + headroom

# For Shared Headroom Pool Size
pkts_num_trig_ingr_drp += xoff
pkts_num_dismiss_pfc = ingress_lossless_size + 1
pkts_num_trig_egr_drp = egress_lossy_size + 1

# For Shared Headroom Pool Size
testPortIds = self.dutConfig['testPortIds']
ingress_ports_num_shp = 8
pkts_num_trig_pfc_shp = []
ingress_ports_list_shp = []
occupancy_per_port = ingress_lossless_size
self.qos_parameters['dst_port_id'] = testPortIds[0]
for i in range(1, ingress_ports_num_shp):
# for the first PG
pkts_num_trig_pfc_shp.append(occupancy_per_port + xon + hysteresis)
# for the second PG
occupancy_per_port /= 2
pkts_num_trig_pfc_shp.append(occupancy_per_port + xon + hysteresis)
occupancy_per_port /= 2
ingress_ports_list_shp.append(testPortIds[i])
self.qos_parameters['pkts_num_trig_pfc_shp'] = pkts_num_trig_pfc_shp
self.qos_parameters['src_port_ids'] = ingress_ports_list_shp
self.qos_parameters['pkts_num_hdrm_full'] = xoff - 2
self.qos_parameters['pkts_num_hdrm_partial'] = xoff - 2

self.qos_parameters['pkts_num_trig_pfc'] = pkts_num_trig_pfc
self.qos_parameters['pkts_num_trig_ingr_drp'] = pkts_num_trig_ingr_drp
self.qos_parameters['pkts_num_dismiss_pfc'] = pkts_num_dismiss_pfc
self.qos_parameters['pkts_num_trig_egr_drp'] = pkts_num_trig_egr_drp
self.qos_parameters['pkts_num_hysteresis'] = hysteresis

def calculate_parameters(self):
"""
Generate qos test parameters based on the configuration
xon
xoff
wm_pg_headroom
wm_pg_shared_lossless
wm_q_shared_lossless
lossy_queue_1
wm_pg_shared_lossy
wm_q_shared_lossy
wm_buf_pool_lossless
wm_buf_pool_lossy
"""
pkts_num_trig_pfc = self.qos_parameters['pkts_num_trig_pfc']
pkts_num_trig_ingr_drp = self.qos_parameters['pkts_num_trig_ingr_drp']
pkts_num_dismiss_pfc = self.qos_parameters['pkts_num_dismiss_pfc']
pkts_num_trig_egr_drp = self.qos_parameters['pkts_num_trig_egr_drp']
pkts_num_hysteresis = self.qos_parameters['pkts_num_hysteresis']

# For Shared Headroom Pool Size
hdrm_pool_size = self.qos_params_bfn[self.speed_cable_len]['hdrm_pool_size']
hdrm_pool_size['pkts_num_trig_pfc_shp'] = self.qos_parameters['pkts_num_trig_pfc_shp']
hdrm_pool_size['pkts_num_hdrm_full'] = self.qos_parameters['pkts_num_hdrm_full']
hdrm_pool_size['pkts_num_hdrm_partial'] = self.qos_parameters['pkts_num_hdrm_partial']
hdrm_pool_size['dst_port_id'] = self.qos_parameters['dst_port_id']
hdrm_pool_size['src_port_ids'] = self.qos_parameters['src_port_ids']
hdrm_pool_size['pgs_num'] = 2 * len(self.qos_parameters['src_port_ids'])
hdrm_pool_size['cell_size'] = self.cell_size
hdrm_pool_size['margin'] = 3

xoff = {}
xoff['pkts_num_trig_pfc'] = pkts_num_trig_pfc
xoff['pkts_num_trig_ingr_drp'] = pkts_num_trig_ingr_drp
# One motivation of margin is to tolerance the deviation.
xoff['pkts_num_margin'] = 3
self.qos_params_bfn[self.speed_cable_len]['xoff_1'].update(xoff)
self.qos_params_bfn[self.speed_cable_len]['xoff_2'].update(xoff)

xon = {}
xon['pkts_num_trig_pfc'] = pkts_num_trig_pfc
xon['pkts_num_dismiss_pfc'] = pkts_num_dismiss_pfc + self.extra_margin
xon['pkts_num_hysteresis'] = pkts_num_hysteresis + 16
xon['pkts_num_margin'] = 3
self.qos_params_bfn['xon_1'].update(xon)
self.qos_params_bfn['xon_2'].update(xon)

wm_pg_headroom = self.qos_params_bfn[self.speed_cable_len]['wm_pg_headroom']
wm_pg_headroom['pkts_num_trig_pfc'] = pkts_num_trig_pfc
wm_pg_headroom['pkts_num_trig_ingr_drp'] = pkts_num_trig_ingr_drp
wm_pg_headroom['cell_size'] = self.cell_size
wm_pg_headroom['pkts_num_margin'] = 3

wm_pg_shared_lossless = self.qos_params_bfn['wm_pg_shared_lossless']
wm_pg_shared_lossless['pkts_num_trig_pfc'] = pkts_num_dismiss_pfc
wm_pg_shared_lossless['cell_size'] = self.cell_size
wm_pg_shared_lossless["pkts_num_margin"] = 3

wm_q_shared_lossless = self.qos_params_bfn[self.speed_cable_len]['wm_q_shared_lossless']
wm_q_shared_lossless['pkts_num_trig_ingr_drp'] = pkts_num_trig_ingr_drp
wm_q_shared_lossless['cell_size'] = self.cell_size

lossy_queue = self.qos_params_bfn['lossy_queue_1']
lossy_queue['pkts_num_trig_egr_drp'] = pkts_num_trig_egr_drp - 1
lossy_queue['cell_size'] = self.cell_size

wm_shared_lossy = {}
wm_shared_lossy['pkts_num_trig_egr_drp'] = pkts_num_trig_egr_drp
wm_shared_lossy['cell_size'] = self.cell_size
wm_shared_lossy["pkts_num_margin"] = 3
self.qos_params_bfn['wm_pg_shared_lossy'].update(wm_shared_lossy)
self.qos_params_bfn['wm_q_shared_lossy'].update(wm_shared_lossy)

wm_buf_pool_lossless = self.qos_params_bfn['wm_buf_pool_lossless']
wm_buf_pool_lossless['pkts_num_trig_pfc'] = pkts_num_trig_pfc
wm_buf_pool_lossless['pkts_num_trig_ingr_drp'] = pkts_num_trig_ingr_drp
wm_buf_pool_lossless['cell_size'] = self.cell_size

wm_buf_pool_lossy = self.qos_params_bfn['wm_buf_pool_lossy']
wm_buf_pool_lossy['pkts_num_trig_egr_drp'] = pkts_num_trig_egr_drp
wm_buf_pool_lossy['cell_size'] = self.cell_size

for i in range(4):
self.qos_params_bfn['ecn_{}'.format(i+1)]['cell_size'] = self.cell_size

self.qos_params_bfn['shared-headroom-pool'] = self.sharedHeadroomPoolSize
34 changes: 34 additions & 0 deletions tests/qos/files/dynamic_buffer_param.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,39 @@
"x86_64-nvidia_sn5600-r0": "800000",
"x86_64-nvidia_sn5600_simx-r0": "800000"
}
},
"barefoot": {
"default_cable_length": ["5m", "40m", "300m"],
"testparam_cable_length": ["15m", "40m"],
"headroom-override": {
"add": {
"xon": "18432",
"xoff": "18432",
"size": "36864",
"dynamic_th": "1"
},
"set": {
"xon": "18432",
"xoff": "36864",
"size": "55296"
}
},
"lossless_pg": {
"headroom-override": {
"xon": "18432",
"xoff": "16384",
"size": "34816"
},
"non-default-dynamic_th": {
"dynamic_th": "7"
}
},
"lossy_pg": {
"default": "4096"
},
"shared-headroom-pool": {
"size": "3153920",
"private_pg_headroom": "70400"
}
}
}
122 changes: 122 additions & 0 deletions tests/qos/files/qos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2364,3 +2364,125 @@ qos_params:
lossless_weight: 30
hdrm_pool_wm_multiplier: 1
cell_size: 384
tf2:
topo-any:
profile:
pkts_num_leak_out: 0
xoff_1:
dscp: 3
ecn: 1
pg: 3
xoff_2:
dscp: 4
ecn: 1
pg: 4
wm_pg_headroom:
dscp: 3
ecn: 1
pg: 3
pkts_num_leak_out: 0
wm_q_shared_lossless:
dscp: 3
ecn: 1
queue: 3
pkts_num_leak_out: 0
pkts_num_fill_min: 0
packet_size: 64
hdrm_pool_size:
dscps: [3, 4]
ecn: 1
pgs: [3, 4]
pkts_num_trig_pfc: 0
pkts_num_leak_out: 0
pkts_num_fill_min: 0
packet_size: 64
xon_1:
dscp: 3
ecn: 1
pg: 3
pkts_num_leak_out: 0
xon_2:
dscp: 4
ecn: 1
pg: 4
pkts_num_trig_pfc: 90752
pkts_num_dismiss_pfc: 13
pkts_num_leak_out: 0
wm_pg_shared_lossless:
dscp: 3
ecn: 1
pg: 3
pkts_num_fill_min: 10
pkts_num_trig_pfc: 90752
packet_size: 64
cell_size: 176
pkts_num_margin: 10
wm_pg_shared_lossy:
dscp: 8
ecn: 1
pg: 0
pkts_num_fill_min: 0
packet_size: 64
cell_size: 176
pkts_num_margin: 10
wm_q_shared_lossy:
dscp: 8
ecn: 1
queue: 0
pkts_num_fill_min: 7
cell_size: 176
wm_q_shared_lossless:
dscp: 3
ecn: 1
queue: 3
pkts_num_leak_out: 0
pkts_num_fill_min: 0
cell_size: 176
wm_buf_pool_lossless:
dscp: 3
ecn: 1
pg: 3
queue: 3
pkts_num_fill_ingr_min: 7
pkts_num_trig_pfc: 90752
pkts_num_trig_ingr_drp: 91048
pkts_num_fill_egr_min: 8
cell_size: 176
wm_buf_pool_lossy:
dscp: 8
ecn: 1
pg: 0
queue: 0
pkts_num_fill_ingr_min: 0
pkts_num_trig_egr_drp: 16283
pkts_num_fill_egr_min: 7
cell_size: 176
lossy_queue_1:
dscp: 8
ecn: 1
pg: 0
pkts_num_trig_egr_drp: 16690
pkts_num_margin: 10
wrr:
ecn: 1
q0_num_of_pkts: 140
q1_num_of_pkts: 140
q2_num_of_pkts: 140
q3_num_of_pkts: 150
q4_num_of_pkts: 150
q5_num_of_pkts: 140
q6_num_of_pkts: 140
limit: 80
wrr_chg:
ecn: 1
q0_num_of_pkts: 80
q1_num_of_pkts: 80
q2_num_of_pkts: 80
q3_num_of_pkts: 300
q4_num_of_pkts: 300
q5_num_of_pkts: 80
q6_num_of_pkts: 80
limit: 80
lossy_weight: 8
lossless_weight: 30

Loading

0 comments on commit 8381a27

Please sign in to comment.