@@ -85,14 +85,24 @@ mlxsw_sp_setup_tc_qdisc_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port,
8585{
8686 struct red_stats * xstats_base = & mlxsw_sp_qdisc -> xstats_base ;
8787 struct mlxsw_sp_port_xstats * xstats ;
88+ struct rtnl_link_stats64 * stats ;
8889
8990 xstats = & mlxsw_sp_port -> periodic_hw_stats .xstats ;
91+ stats = & mlxsw_sp_port -> periodic_hw_stats .stats ;
92+
93+ mlxsw_sp_qdisc -> tx_packets = stats -> tx_packets ;
94+ mlxsw_sp_qdisc -> tx_bytes = stats -> tx_bytes ;
9095
9196 switch (mlxsw_sp_qdisc -> type ) {
9297 case MLXSW_SP_QDISC_RED :
9398 xstats_base -> prob_mark = xstats -> ecn ;
9499 xstats_base -> prob_drop = xstats -> wred_drop [tclass_num ];
95100 xstats_base -> pdrop = xstats -> tail_drop [tclass_num ];
101+
102+ mlxsw_sp_qdisc -> overlimits = xstats_base -> prob_drop +
103+ xstats_base -> prob_mark ;
104+ mlxsw_sp_qdisc -> drops = xstats_base -> prob_drop +
105+ xstats_base -> pdrop ;
96106 break ;
97107 default :
98108 break ;
@@ -193,6 +203,43 @@ mlxsw_sp_qdisc_get_red_xstats(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
193203 return 0 ;
194204}
195205
206+ static int
207+ mlxsw_sp_qdisc_get_red_stats (struct mlxsw_sp_port * mlxsw_sp_port , u32 handle ,
208+ struct mlxsw_sp_qdisc * mlxsw_sp_qdisc ,
209+ int tclass_num ,
210+ struct tc_red_qopt_offload_stats * res )
211+ {
212+ u64 tx_bytes , tx_packets , overlimits , drops ;
213+ struct mlxsw_sp_port_xstats * xstats ;
214+ struct rtnl_link_stats64 * stats ;
215+
216+ if (mlxsw_sp_qdisc -> handle != handle ||
217+ mlxsw_sp_qdisc -> type != MLXSW_SP_QDISC_RED )
218+ return - EOPNOTSUPP ;
219+
220+ xstats = & mlxsw_sp_port -> periodic_hw_stats .xstats ;
221+ stats = & mlxsw_sp_port -> periodic_hw_stats .stats ;
222+
223+ tx_bytes = stats -> tx_bytes - mlxsw_sp_qdisc -> tx_bytes ;
224+ tx_packets = stats -> tx_packets - mlxsw_sp_qdisc -> tx_packets ;
225+ overlimits = xstats -> wred_drop [tclass_num ] + xstats -> ecn -
226+ mlxsw_sp_qdisc -> overlimits ;
227+ drops = xstats -> wred_drop [tclass_num ] + xstats -> tail_drop [tclass_num ] -
228+ mlxsw_sp_qdisc -> drops ;
229+
230+ _bstats_update (res -> bstats , tx_bytes , tx_packets );
231+ res -> qstats -> overlimits += overlimits ;
232+ res -> qstats -> drops += drops ;
233+ res -> qstats -> backlog += mlxsw_sp_cells_bytes (mlxsw_sp_port -> mlxsw_sp ,
234+ xstats -> backlog [tclass_num ]);
235+
236+ mlxsw_sp_qdisc -> drops += drops ;
237+ mlxsw_sp_qdisc -> overlimits += overlimits ;
238+ mlxsw_sp_qdisc -> tx_bytes += tx_bytes ;
239+ mlxsw_sp_qdisc -> tx_packets += tx_packets ;
240+ return 0 ;
241+ }
242+
196243#define MLXSW_SP_PORT_DEFAULT_TCLASS 0
197244
198245int mlxsw_sp_setup_tc_red (struct mlxsw_sp_port * mlxsw_sp_port ,
@@ -219,6 +266,10 @@ int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
219266 return mlxsw_sp_qdisc_get_red_xstats (mlxsw_sp_port , p -> handle ,
220267 mlxsw_sp_qdisc , tclass_num ,
221268 p -> xstats );
269+ case TC_RED_STATS :
270+ return mlxsw_sp_qdisc_get_red_stats (mlxsw_sp_port , p -> handle ,
271+ mlxsw_sp_qdisc , tclass_num ,
272+ & p -> stats );
222273 default :
223274 return - EOPNOTSUPP ;
224275 }
0 commit comments