@@ -53,7 +53,8 @@ NStats = namedtuple("NStats", "rx_ok, rx_err, rx_drop, rx_ovr, tx_ok,\
53
53
tx_64, tx_65_127, tx_128_255, tx_256_511, tx_512_1023, tx_1024_1518, tx_1519_2047, tx_2048_4095, tx_4096_9216, tx_9217_16383,\
54
54
tx_uca, tx_mca, tx_bca, tx_all,\
55
55
rx_jbr, rx_frag, rx_usize, rx_ovrrun,\
56
- fec_corr, fec_uncorr, fec_symbol_err" )
56
+ fec_corr, fec_uncorr, fec_symbol_err,\
57
+ wred_grn_drp_pkt, wred_ylw_drp_pkt, wred_red_drp_pkt, wred_tot_drp_pkt" )
57
58
header_all = ['IFACE' , 'STATE' , 'RX_OK' , 'RX_BPS' , 'RX_PPS' , 'RX_UTIL' , 'RX_ERR' , 'RX_DRP' , 'RX_OVR' ,
58
59
'TX_OK' , 'TX_BPS' , 'TX_PPS' , 'TX_UTIL' , 'TX_ERR' , 'TX_DRP' , 'TX_OVR' ]
59
60
header_std = ['IFACE' , 'STATE' , 'RX_OK' , 'RX_BPS' , 'RX_UTIL' , 'RX_ERR' , 'RX_DRP' , 'RX_OVR' ,
@@ -70,7 +71,13 @@ RateStats = namedtuple("RateStats", ratestat_fields)
70
71
The order and count of statistics mentioned below needs to be in sync with the values in portstat script
71
72
So, any fields added/deleted in here should be reflected in portstat script also
72
73
"""
73
- BUCKET_NUM = 45
74
+ BUCKET_NUM = 49
75
+
76
+ wred_green_pkt_stat_capable = False
77
+ wred_yellow_pkt_stat_capable = False
78
+ wred_red_pkt_stat_capable = False
79
+ wred_total_pkt_stat_capable = False
80
+
74
81
counter_bucket_dict = {
75
82
0 :['SAI_PORT_STAT_IF_IN_UCAST_PKTS' , 'SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS' ],
76
83
1 :['SAI_PORT_STAT_IF_IN_ERRORS' ],
@@ -116,7 +123,11 @@ counter_bucket_dict = {
116
123
41 :['SAI_PORT_STAT_IP_IN_RECEIVES' ],
117
124
42 :['SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES' ],
118
125
43 :['SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES' ],
119
- 44 :['SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS' ]
126
+ 44 :['SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS' ],
127
+ 45 :['SAI_PORT_STAT_GREEN_WRED_DROPPED_PACKETS' ],
128
+ 46 :['SAI_PORT_STAT_YELLOW_WRED_DROPPED_PACKETS' ],
129
+ 47 :['SAI_PORT_STAT_RED_WRED_DROPPED_PACKETS' ],
130
+ 48 :['SAI_PORT_STAT_WRED_DROPPED_PACKETS' ]
120
131
}
121
132
122
133
STATUS_NA = 'N/A'
@@ -170,6 +181,32 @@ class Portstat(object):
170
181
"""
171
182
Get the counters from specific table.
172
183
"""
184
+
185
+ global BUCKET_NUM
186
+
187
+ global wred_green_pkt_stat_capable
188
+ global wred_yellow_pkt_stat_capable
189
+ global wred_red_pkt_stat_capable
190
+ global wred_total_pkt_stat_capable
191
+ wred_green_pkt_stat_capable = self .db .get (self .db .STATE_DB , "PORT_COUNTER_CAPABILITIES|WRED_ECN_PORT_WRED_GREEN_DROP_PKT_COUNTER" ,"isSupported" )
192
+ wred_yellow_pkt_stat_capable = self .db .get (self .db .STATE_DB , "PORT_COUNTER_CAPABILITIES|WRED_ECN_PORT_WRED_YELLOW_DROP_PKT_COUNTER" ,"isSupported" )
193
+ wred_red_pkt_stat_capable = self .db .get (self .db .STATE_DB , "PORT_COUNTER_CAPABILITIES|WRED_ECN_PORT_WRED_RED_DROP_PKT_COUNTER" ,"isSupported" )
194
+ wred_total_pkt_stat_capable = self .db .get (self .db .STATE_DB , "PORT_COUNTER_CAPABILITIES|WRED_ECN_PORT_WRED_TOTAL_DROP_PKT_COUNTER" ,"isSupported" )
195
+
196
+ # Remove the unsupported stats from the counter dict
197
+ if wred_green_pkt_stat_capable != "true" and ('SAI_PORT_STAT_GREEN_WRED_DROPPED_PACKETS' in counter_bucket_dict .keys ()):
198
+ del counter_bucket_dict ['SAI_PORT_STAT_GREEN_WRED_DROPPED_PACKETS' ]
199
+ BUCKET_NUM = (BUCKET_NUM - 1 )
200
+ if wred_yellow_pkt_stat_capable != "true" and ('SAI_PORT_STAT_YELLOW_WRED_DROPPED_PACKETS' in counter_bucket_dict .keys ()):
201
+ del counter_bucket_dict ['SAI_PORT_STAT_YELLOW_WRED_DROPPED_PACKETS' ]
202
+ BUCKET_NUM = (BUCKET_NUM - 1 )
203
+ if wred_red_pkt_stat_capable != "true" and ('SAI_PORT_STAT_RED_WRED_DROPPED_PACKETS' in counter_bucket_dict .keys ()):
204
+ del counter_bucket_dict ['SAI_PORT_STAT_RED_WRED_DROPPED_PACKETS' ]
205
+ BUCKET_NUM = (BUCKET_NUM - 1 )
206
+ if wred_total_pkt_stat_capable != "true" and ('SAI_PORT_STAT_WRED_DROPPED_PACKETS' in counter_bucket_dict .keys ()):
207
+ del counter_bucket_dict ['SAI_PORT_STAT_WRED_DROPPED_PACKETS' ]
208
+ BUCKET_NUM = (BUCKET_NUM - 1 )
209
+
173
210
fields = ["0" ]* BUCKET_NUM
174
211
175
212
_ , fvs = counter_table .get (PortCounter (), port )
@@ -399,9 +436,20 @@ class Portstat(object):
399
436
print ("Unicast Packets Transmitted.................... {}" .format (ns_diff (cntr .tx_uca , old_cntr .tx_uca )))
400
437
print ("Multicast Packets Transmitted.................. {}" .format (ns_diff (cntr .tx_mca , old_cntr .tx_mca )))
401
438
print ("Broadcast Packets Transmitted.................. {}" .format (ns_diff (cntr .tx_bca , old_cntr .tx_bca )))
402
-
403
439
print ("Time Since Counters Last Cleared............... " + str (cnstat_old_dict .get ('time' )))
404
440
441
+ if wred_green_pkt_stat_capable == "true" or wred_yellow_pkt_stat_capable == "true" or wred_red_pkt_stat_capable == "true" or wred_total_pkt_stat_capable == "true" :
442
+ print ("" )
443
+ if wred_green_pkt_stat_capable == "true" :
444
+ print ("WRED Green Dropped Packets..................... {}" .format (ns_diff (cntr .wred_grn_drp_pkt , old_cntr .wred_grn_drp_pkt )))
445
+ if wred_yellow_pkt_stat_capable == "true" :
446
+ print ("WRED Yellow Dropped Packets.................... {}" .format (ns_diff (cntr .wred_ylw_drp_pkt , old_cntr .wred_ylw_drp_pkt )))
447
+ if wred_red_pkt_stat_capable == "true" :
448
+ print ("WRED Red Dropped Packets....................... {}" .format (ns_diff (cntr .wred_red_drp_pkt , old_cntr .wred_red_drp_pkt )))
449
+ if wred_total_pkt_stat_capable == "true" :
450
+ print ("WRED Total Dropped Packets..................... {}" .format (ns_diff (cntr .wred_tot_drp_pkt , old_cntr .wred_tot_drp_pkt )))
451
+
452
+
405
453
406
454
def cnstat_diff_print (self , cnstat_new_dict , cnstat_old_dict ,
407
455
ratestat_dict , intf_list , use_json ,
0 commit comments