|
32 | 32 | sai_thrift_read_pg_shared_watermark, |
33 | 33 | sai_thrift_read_buffer_pool_watermark, |
34 | 34 | sai_thrift_read_headroom_pool_watermark, |
35 | | - sai_thrift_read_queue_occupancy) |
| 35 | + sai_thrift_read_queue_occupancy, |
| 36 | + sai_thrift_read_pg_occupancy) |
36 | 37 | from switch_sai_thrift.ttypes import (sai_thrift_attribute_value_t, |
37 | 38 | sai_thrift_attribute_t) |
38 | 39 | from switch_sai_thrift.sai_headers import (SAI_PORT_ATTR_QOS_SCHEDULER_PROFILE_ID) |
@@ -241,6 +242,37 @@ def fill_leakout_plus_one(test_case, src_port_id, dst_port_id, pkt, queue, asic_ |
241 | 242 | return False |
242 | 243 |
|
243 | 244 |
|
| 245 | +def overflow_egress(test_case, src_port_id, pkt, queue, asic_type): |
| 246 | + # Attempts to queue 1 packet while compensating for a varying packet |
| 247 | + # leakout and egress queues. Returns pkts_num_egr_mem: number of packets |
| 248 | + # short of filling egress memory and leakout. |
| 249 | + # Returns extra_bytes_occupied: |
| 250 | + # extra number of bytes occupied in source port |
| 251 | + pkts_num_egr_mem = 0 |
| 252 | + extra_bytes_occupied = 0 |
| 253 | + if asic_type not in ['cisco-8000']: |
| 254 | + return pkts_num_egr_mem, extra_bytes_occupied |
| 255 | + |
| 256 | + pg_cntrs_base = sai_thrift_read_pg_occupancy( |
| 257 | + test_case.src_client, port_list['src'][src_port_id]) |
| 258 | + max_cycles = 1000 |
| 259 | + for cycle_i in range(max_cycles): |
| 260 | + send_packet(test_case, src_port_id, pkt, 1000) |
| 261 | + pg_cntrs = sai_thrift_read_pg_occupancy( |
| 262 | + test_case.src_client, port_list['src'][src_port_id]) |
| 263 | + if pg_cntrs[queue] > pg_cntrs_base[queue]: |
| 264 | + print("get_pkts_num_egr_mem: Success, sent %d packets, " |
| 265 | + "SQ occupancy bytes rose from %d to %d" % ( |
| 266 | + (cycle_i + 1) * 1000, pg_cntrs_base[queue], |
| 267 | + pg_cntrs[queue]), file=sys.stderr) |
| 268 | + pkts_num_egr_mem = cycle_i * 1000 |
| 269 | + extra_bytes_occupied = pg_cntrs[queue] - pg_cntrs_base[queue] |
| 270 | + print("overflow_egress:pkts_num_egr_mem:{}, extra_bytes_occupied:{}".format( |
| 271 | + pkts_num_egr_mem, extra_bytes_occupied)) |
| 272 | + return pkts_num_egr_mem, extra_bytes_occupied |
| 273 | + raise RuntimeError("Couldn't overflow the egress memory after 1000 iterations.") |
| 274 | + |
| 275 | + |
244 | 276 | def get_peer_addresses(data): |
245 | 277 | def get_peer_addr(data, addr): |
246 | 278 | if isinstance(data, dict) and 'peer_addr' in data: |
@@ -3865,6 +3897,8 @@ def runTest(self): |
3865 | 3897 | self.test_params['pkts_num_trig_ingr_drp']) |
3866 | 3898 | iterations = int(self.test_params['iterations']) |
3867 | 3899 | margin = int(self.test_params['pkts_num_margin']) |
| 3900 | + cell_size = int(self.test_params.get('cell_size', 0)) |
| 3901 | + is_multi_asic = (self.src_client != self.dst_client) |
3868 | 3902 |
|
3869 | 3903 | pkt_dst_mac = router_mac if router_mac != '' else dst_port_mac |
3870 | 3904 | dst_port_id = get_rx_port( |
@@ -3896,14 +3930,21 @@ def runTest(self): |
3896 | 3930 |
|
3897 | 3931 | pg_dropped_cntrs_base = sai_thrift_read_pg_drop_counters( |
3898 | 3932 | self.src_client, port_list['src'][src_port_id]) |
| 3933 | + pkt_num = pkts_num_trig_pfc |
| 3934 | + |
| 3935 | + # Fill egress memory and leakout |
| 3936 | + if 'cisco-8000' in asic_type and is_multi_asic: |
| 3937 | + pkts_num_egr_mem, extra_bytes_occupied = overflow_egress( |
| 3938 | + self, src_port_id, pkt, pg, asic_type) |
| 3939 | + pkt_num -= extra_bytes_occupied // cell_size |
3899 | 3940 |
|
3900 | 3941 | # Send packets to trigger PFC |
3901 | 3942 | print("Iteration {}/{}, sending {} packets to trigger PFC".format( |
3902 | 3943 | test_i + 1, iterations, pkts_num_trig_pfc), file=sys.stderr) |
3903 | | - send_packet(self, src_port_id, pkt, pkts_num_trig_pfc) |
| 3944 | + send_packet(self, src_port_id, pkt, pkt_num) |
3904 | 3945 |
|
3905 | 3946 | # Account for leakout |
3906 | | - if 'cisco-8000' in asic_type: |
| 3947 | + if 'cisco-8000' in asic_type and not is_multi_asic: |
3907 | 3948 | queue_counters = sai_thrift_read_queue_occupancy( |
3908 | 3949 | self.dst_client, "dst", dst_port_id) |
3909 | 3950 | occ_pkts = queue_counters[queue] // (packet_length + 24) |
|
0 commit comments