19
19
TEMPLATES_DIR = os .path .join (os .path .dirname (os .path .realpath (__file__ )), "templates" )
20
20
EXPECT_PFC_WD_DETECT_RE = ".* detected PFC storm .*"
21
21
EXPECT_PFC_WD_RESTORE_RE = ".*storm restored.*"
22
- WD_ACTION_MSG_PFX = { "dontcare" : "Verify PFCWD detection when queue buffer is not empty and proper function of drop action" ,
23
- "drop" : "Verify proper function of drop action" ,
24
- "forward" : "Verify proper function of forward action"
22
+ WD_ACTION_MSG_PFX = { "dontcare" : "Verify PFCWD detection when queue buffer is not empty and proper function of pfcwd drop action" ,
23
+ "drop" : "Verify proper function of pfcwd drop action" ,
24
+ "forward" : "Verify proper function of pfcwd forward action"
25
25
}
26
26
MMU_ACTIONS = ['change' , 'noop' , 'restore' , 'noop' ]
27
27
DB_SEPARATORS = {'0' : ':' , '4' : '|' }
@@ -183,32 +183,35 @@ def get_mmu_params(dut, port):
183
183
184
184
class PfcPktCntrs (object ):
185
185
""" PFCwd counter retrieval and verifications """
186
- def __init__ (self , dut , action ):
186
+ def __init__ (self , dut , rx_action , tx_action ):
187
187
"""
188
188
Args:
189
189
dut(AnsibleHost) : dut instance
190
190
action(string): PFCwd action for traffic test
191
191
"""
192
192
self .dut = dut
193
- self .action = action if action != "dontcare" else "drop"
194
- if self .action != "forward" :
193
+ self .rx_action = rx_action
194
+ self .tx_action = tx_action
195
+ if self .tx_action != "forward" :
195
196
self .pkt_cntrs_tx = ['PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS' , 'PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST' ]
196
- self .pkt_cntrs_rx = ['PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS' , 'PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST' ]
197
197
self .err_msg_tx = [("Tx drop cnt check failed: Tx drop before: {} Tx drop after: {} "
198
198
"Expected (diff): {} Obtained: {}" ),
199
199
"Tx drop last cnt check failed: Expected: {} Obtained: {}"
200
200
]
201
- self .err_msg_rx = [("Rx drop cnt check failed: Rx drop before: {} Rx drop after: {} "
202
- "Expected (diff): {} Obtained: {}" ),
203
- "Rx drop last cnt check failed: Expected: {} Obtained: {}"
204
- ]
205
201
else :
206
202
self .pkt_cntrs_tx = ['PFC_WD_QUEUE_STATS_TX_PACKETS' , 'PFC_WD_QUEUE_STATS_TX_PACKETS_LAST' ]
207
- self .pkt_cntrs_rx = ['PFC_WD_QUEUE_STATS_RX_PACKETS' , 'PFC_WD_QUEUE_STATS_RX_PACKETS_LAST' ]
208
203
self .err_msg_tx = [("Tx forward cnt check failed: Tx forward before: {} Tx forward after: {} "
209
204
"Expected (diff): {} Obtained: {}" ),
210
205
"Tx forward last cnt check failed: Expected: {} Obtained: {}"
211
206
]
207
+ if self .rx_action != "forward" :
208
+ self .pkt_cntrs_rx = ['PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS' , 'PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST' ]
209
+ self .err_msg_rx = [("Rx drop cnt check failed: Rx drop before: {} Rx drop after: {} "
210
+ "Expected (diff): {} Obtained: {}" ),
211
+ "Rx drop last cnt check failed: Expected: {} Obtained: {}"
212
+ ]
213
+ else :
214
+ self .pkt_cntrs_rx = ['PFC_WD_QUEUE_STATS_RX_PACKETS' , 'PFC_WD_QUEUE_STATS_RX_PACKETS_LAST' ]
212
215
self .err_msg_rx = [("Rx forward cnt check failed: Rx forward before: {} Rx forward after: {} "
213
216
"Expected (diff): {} Obtained: {}" ),
214
217
"Rx forward last cnt check failed: Expected: {} Obtained: {}"
@@ -241,7 +244,7 @@ def verify_pkt_cnts(self, port_type, pkt_cnt):
241
244
port_type(string) : the type of port (eg. portchannel, vlan, interface)
242
245
pkt_cnt(int) : Number of test packets sent from the PTF
243
246
"""
244
- logger .info ("--- Checking Tx {} cntrs ---" .format (self .action ))
247
+ logger .info ("--- Checking Tx {} cntrs ---" .format (self .tx_action ))
245
248
tx_diff = self .cntr_val ["tx_end" ] - self .cntr_val ["tx_begin" ]
246
249
if (port_type in ['vlan' , 'interface' ] and tx_diff != pkt_cnt ) or tx_diff <= 0 :
247
250
err_msg = self .err_msg_tx [0 ].format (self .cntr_val ["tx_begin" ], self .cntr_val ["tx_end" ], pkt_cnt , tx_diff )
@@ -251,7 +254,7 @@ def verify_pkt_cnts(self, port_type, pkt_cnt):
251
254
err_msg = self .err_msg_tx [1 ].format (pkt_cnt , self .cntr_val ["tx_last" ])
252
255
pytest_assert (err_msg )
253
256
254
- logger .info ("--- Checking Rx {} cntrs ---" .format (self .action ))
257
+ logger .info ("--- Checking Rx {} cntrs ---" .format (self .rx_action ))
255
258
rx_diff = self .cntr_val ["rx_end" ] - self .cntr_val ["rx_begin" ]
256
259
if (port_type in ['vlan' , 'interface' ] and rx_diff != pkt_cnt ) or rx_diff <= 0 :
257
260
err_msg = self .err_msg_rx [0 ].format (self .cntr_val ["rx_begin" ], self .cntr_val ["rx_end" ], pkt_cnt , rx_diff )
@@ -574,16 +577,16 @@ def fill_buffer(self):
574
577
ptf_runner (self .ptf , "ptftests" , "pfc_wd.PfcWdTest" , "ptftests" , params = ptf_params ,
575
578
log_file = log_file )
576
579
577
- def verify_wd_func (self , action ):
580
+ def verify_wd_func (self , action , rx_action , tx_action ):
578
581
"""
579
582
PTF traffic send and verify
580
583
581
584
Args:
582
585
action(string) : PTF traffic test action
583
586
"""
584
- logger .info ("--- Verify PFCwd function for action {} ---" .format (action ))
585
- self .verify_tx_egress (action )
586
- self .verify_rx_ingress (action )
587
+ logger .info ("--- Verify PFCwd function for pfcwd action {}, Tx traffic action {}, Rx traffic action {} ---" .format (action , tx_action , rx_action ))
588
+ self .verify_tx_egress (tx_action )
589
+ self .verify_rx_ingress (rx_action )
587
590
self .verify_other_pfc_queue ()
588
591
self .verify_other_pfc_pg ()
589
592
@@ -636,7 +639,7 @@ def storm_detect_path(self, dut, port, action):
636
639
loganalyzer .analyze (marker )
637
640
self .stats .get_pkt_cnts (self .queue_oid , begin = True )
638
641
# test pfcwd functionality on a storm
639
- self .traffic_inst .verify_wd_func (action if action != "dontcare" else "drop" )
642
+ self .traffic_inst .verify_wd_func (action , self . rx_action , self . tx_action )
640
643
return loganalyzer
641
644
642
645
def storm_restore_path (self , dut , loganalyzer , port , action ):
@@ -687,6 +690,14 @@ def run_test(self, dut, port, action, mmu_action=None):
687
690
logger .info ("--- Verify PFCwd counters for port {} ---" .format (port ))
688
691
self .stats .verify_pkt_cnts (self .pfc_wd ['port_type' ], self .pfc_wd ['test_pkt_count' ])
689
692
693
+ def set_traffic_action (self , duthost , action ):
694
+ action = action if action != "dontcare" else "drop"
695
+ if duthost .facts ["asic_type" ] == "mellanox" :
696
+ self .rx_action = "forward"
697
+ else :
698
+ self .rx_action = action
699
+ self .tx_action = action
700
+
690
701
def test_pfcwd_actions (self , request , fake_storm , setup_pfc_test , fanout_graph_facts , ptfhost , duthosts , rand_one_dut_hostname , fanouthosts ):
691
702
"""
692
703
PFCwd functional test
@@ -713,6 +724,8 @@ def test_pfcwd_actions(self, request, fake_storm, setup_pfc_test, fanout_graph_f
713
724
self .peer_dev_list = dict ()
714
725
self .fake_storm = fake_storm
715
726
self .storm_hndle = None
727
+ self .rx_action = None
728
+ self .tx_action = None
716
729
717
730
for idx , port in enumerate (self .ports ):
718
731
logger .info ("" )
@@ -727,8 +740,9 @@ def test_pfcwd_actions(self, request, fake_storm, setup_pfc_test, fanout_graph_f
727
740
actions = ['dontcare' , 'drop' ]
728
741
for action in actions :
729
742
try :
730
- self .stats = PfcPktCntrs (self .dut , action )
731
- logger .info ("{} on port {}" .format (WD_ACTION_MSG_PFX [action ], port ))
743
+ self .set_traffic_action (duthost , action )
744
+ self .stats = PfcPktCntrs (self .dut , self .rx_action , self .tx_action )
745
+ logger .info ("{} on port {}: Tx traffic action {}, Rx traffic action {} " .format (WD_ACTION_MSG_PFX [action ], port , self .tx_action , self .rx_action ))
732
746
self .run_test (self .dut , port , action )
733
747
except Exception as e :
734
748
pytest .fail (str (e ))
@@ -784,7 +798,10 @@ def test_pfcwd_mmu_change(self, request, fake_storm, setup_pfc_test, fanout_grap
784
798
self .storm_hndle = None
785
799
logger .info ("---- Testing on port {} ----" .format (port ))
786
800
self .setup_test_params (port , setup_info ['vlan' ], init = True , mmu_params = True )
787
- self .stats = PfcPktCntrs (self .dut , "drop" )
801
+ self .rx_action = None
802
+ self .tx_action = None
803
+ self .set_traffic_action (duthost , "drop" )
804
+ self .stats = PfcPktCntrs (self .dut , self .rx_action , self .tx_action )
788
805
789
806
try :
790
807
for idx , mmu_action in enumerate (MMU_ACTIONS ):
@@ -848,6 +865,8 @@ def test_pfcwd_port_toggle(self, request, fake_storm, setup_pfc_test, fanout_gra
848
865
self .peer_dev_list = dict ()
849
866
self .fake_storm = fake_storm
850
867
self .storm_hndle = None
868
+ self .rx_action = None
869
+ self .tx_action = None
851
870
action = "dontcare"
852
871
853
872
for idx , port in enumerate (self .ports ):
@@ -860,9 +879,10 @@ def test_pfcwd_port_toggle(self, request, fake_storm, setup_pfc_test, fanout_gra
860
879
self .timers ['pfc_wd_wait_for_restore_time' ] = int (pfc_wd_restore_time_large / 1000 * 2 )
861
880
862
881
try :
882
+ self .set_traffic_action (duthost , action )
863
883
# Verify that PFC storm is detected and restored
864
- self .stats = PfcPktCntrs (self .dut , action )
865
- logger .info ("{} on port {}" .format (WD_ACTION_MSG_PFX [action ], port ))
884
+ self .stats = PfcPktCntrs (self .dut , self . rx_action , self . tx_action )
885
+ logger .info ("{} on port {}. Tx traffic action {}, Rx traffic action {} " .format (WD_ACTION_MSG_PFX [action ], port , self . tx_action , self . rx_action ))
866
886
self .run_test (self .dut , port , action )
867
887
868
888
# Toggle test port and verify that PFC storm is not detected
0 commit comments