26
26
sai_thrift_read_port_watermarks ,
27
27
sai_thrift_read_pg_counters ,
28
28
sai_thrift_read_buffer_pool_watermark ,
29
+ sai_thrift_read_headroom_pool_watermark ,
29
30
sai_thrift_port_tx_disable ,
30
31
sai_thrift_port_tx_enable )
31
32
from switch_sai_thrift .ttypes import (sai_thrift_attribute_value_t ,
@@ -876,6 +877,18 @@ def setUp(self):
876
877
print >> sys .stderr , ("pkts num: leak_out: %d, trig_pfc: %d, hdrm_full: %d, hdrm_partial: %d, pkt_size %d" % (self .pkts_num_leak_out , self .pkts_num_trig_pfc , self .pkts_num_hdrm_full , self .pkts_num_hdrm_partial , self .pkt_size ))
877
878
elif self .pkts_num_trig_pfc_shp :
878
879
print >> sys .stderr , ("pkts num: leak_out: {}, trig_pfc: {}, hdrm_full: {}, hdrm_partial: {}, pkt_size {}" .format (self .pkts_num_leak_out , self .pkts_num_trig_pfc_shp , self .pkts_num_hdrm_full , self .pkts_num_hdrm_partial , self .pkt_size ))
880
+
881
+ # used only for headroom pool watermark
882
+ if all (key in self .test_params for key in ['hdrm_pool_wm_multiplier' , 'buf_pool_roid' , 'cell_size' , 'max_headroom' ]):
883
+ self .cell_size = int (self .test_params ['cell_size' ])
884
+ self .wm_multiplier = self .test_params ['hdrm_pool_wm_multiplier' ]
885
+ print >> sys .stderr , "Wm multiplier: %d buf_pool_roid: %s" % (self .wm_multiplier , self .test_params ['buf_pool_roid' ])
886
+ self .buf_pool_roid = int (self .test_params ['buf_pool_roid' ], 0 )
887
+ print >> sys .stderr , "buf_pool_roid: 0x%lx" % (self .buf_pool_roid )
888
+ self .max_headroom = int (self .test_params ['max_headroom' ])
889
+ else :
890
+ self .wm_multiplier = None
891
+
879
892
sys .stderr .flush ()
880
893
881
894
self .dst_port_mac = self .dataplane .get_mac (0 , self .dst_port_id )
@@ -997,6 +1010,15 @@ def runTest(self):
997
1010
print >> sys .stderr , "PFC triggered"
998
1011
sys .stderr .flush ()
999
1012
1013
+ upper_bound = 2
1014
+ if self .wm_multiplier :
1015
+ hdrm_pool_wm = sai_thrift_read_headroom_pool_watermark (self .client , self .buf_pool_roid )
1016
+ print >> sys .stderr , "Actual headroom pool watermark value to start: %d" % hdrm_pool_wm
1017
+ assert (hdrm_pool_wm <= (upper_bound * self .cell_size * self .wm_multiplier ))
1018
+
1019
+ expected_wm = 0
1020
+ wm_pkt_num = 0
1021
+ upper_bound_wm = 0
1000
1022
# send packets to all pgs to fill the headroom pool
1001
1023
for i in range (0 , self .pgs_num ):
1002
1024
# Prepare TCP packet data
@@ -1021,6 +1043,18 @@ def runTest(self):
1021
1043
assert (recv_counters [INGRESS_DROP ] == recv_counters_bases [sidx_dscp_pg_tuples [i ][0 ]][INGRESS_DROP ])
1022
1044
assert (recv_counters [INGRESS_PORT_BUFFER_DROP ] == recv_counters_bases [sidx_dscp_pg_tuples [i ][0 ]][INGRESS_PORT_BUFFER_DROP ])
1023
1045
1046
+ if self .wm_multiplier :
1047
+ wm_pkt_num += (self .pkts_num_hdrm_full if i != self .pgs_num - 1 else self .pkts_num_hdrm_partial )
1048
+ hdrm_pool_wm = sai_thrift_read_headroom_pool_watermark (self .client , self .buf_pool_roid )
1049
+ expected_wm = wm_pkt_num * self .cell_size * self .wm_multiplier
1050
+ upper_bound_wm = expected_wm + (upper_bound * self .cell_size * self .wm_multiplier )
1051
+ if upper_bound_wm > self .max_headroom :
1052
+ upper_bound_wm = self .max_headroom
1053
+
1054
+ print >> sys .stderr , "pkts sent: %d, lower bound: %d, actual headroom pool watermark: %d, upper_bound: %d" % (wm_pkt_num , expected_wm , hdrm_pool_wm , upper_bound_wm )
1055
+ assert (expected_wm <= hdrm_pool_wm )
1056
+ assert (hdrm_pool_wm <= upper_bound_wm )
1057
+
1024
1058
print >> sys .stderr , "all but the last pg hdrms filled"
1025
1059
sys .stderr .flush ()
1026
1060
@@ -1041,6 +1075,16 @@ def runTest(self):
1041
1075
assert (xmit_counters [EGRESS_PORT_BUFFER_DROP ] == xmit_counters_base [EGRESS_PORT_BUFFER_DROP ])
1042
1076
1043
1077
print >> sys .stderr , "pg hdrm filled"
1078
+ if self .wm_multiplier :
1079
+ # assert hdrm pool wm still remains the same
1080
+ hdrm_pool_wm = sai_thrift_read_headroom_pool_watermark (self .client , self .buf_pool_roid )
1081
+ assert (expected_wm <= hdrm_pool_wm )
1082
+ assert (hdrm_pool_wm <= upper_bound_wm )
1083
+ # at this point headroom pool should be full. send few more packets to continue causing drops
1084
+ print >> sys .stderr , "overflow headroom pool"
1085
+ send_packet (self , self .src_port_ids [sidx_dscp_pg_tuples [i ][0 ]], pkt , 10 )
1086
+ hdrm_pool_wm = sai_thrift_read_headroom_pool_watermark (self .client , self .buf_pool_roid )
1087
+ assert (hdrm_pool_wm <= self .max_headroom )
1044
1088
sys .stderr .flush ()
1045
1089
1046
1090
finally :
0 commit comments