iproute2: gnet_stats
Subsystems (2)
PATCH 1/1 iproute2: gnet_stats
Stephen,
Here is the patch for iproute2 covering all statistic users. I moved the dumping code to tc_util.c and introduced print_tcstats2_attr for new code while print_tcstats_attr handles both.
I'm not sure whether you got my previous patch so this one includes all changes.
include/linux/gen_stats.h +62 -0
@@ -0,0 +1,62 @@ +#ifndef __LINUX_GEN_STATS_H +#define __LINUX_GEN_STATS_H + +#include <linux/types.h> + +enum { +TCA_STATS_UNSPEC , +TCA_STATS_BASIC , +TCA_STATS_RATE_EST , +TCA_STATS_QUEUE , +TCA_STATS_APP , + __TCA_STATS_MAX, +}; +#define TCA_STATS_MAX (__TCA_STATS_MAX - 1) + +/** +* @bytes: number of seen bytes +* @packets: number of seen packets +*/ +struct gnet_stats_basic +{ +__u64 bytes; +__u32 packets; +}; + +/** +* @bps: current byte rate +* @pps: current packet rate +*/ +struct gnet_stats_rate_est +{ +__u32 bps; +__u32 pps; +}; + +/** +* @qlen: queue length +* @backlog: backlog size of queue +* @drops: number of dropped packets +* @requeues: number of requeues +*/ +struct gnet_stats_queue +{ +__u32 qlen; +__u32 backlog; +__u32 drops; +__u32 requeues; +__u32 overlimits; +}; + +/** +* @interval: sampling period +* @ewma_log: the log of measurement window weight +*/ +struct gnet_estimator +{ +signed char interval; +unsigned char ewma_log; +}; + + +#endif /* __LINUX_GEN_STATS_H */
include/linux/rtnetlink.h +2 -0
@@ -698,6 +698,8 @@TCA_XSTATS ,TCA_RATE ,TCA_FCNT , +TCA_STATS2 , +TCA_ACT_STATS , __TCA_MAX };
tc/m_action.c +3 -3
@@ -261,9 +261,9 @@if (0 > err)return err; -if (show_stats && tb[TCA_STATS ]) { -fprintf (f,"\t" ); -print_tcstats_attr (f, tb[TCA_STATS ]); +if (show_stats && tb[TCA_ACT_STATS ]) { +fprintf (f,"\tAction statistics:\n" ); +print_tcstats2_attr (f, tb[TCA_ACT_STATS ],"\t" ,NULL );fprintf (f,"\n" ); }
tc/tc_class.c +6 -4
@@ -216,12 +216,14 @@ }fprintf (fp,"\n" );if (show_stats) { -if (tb[TCA_STATS ]) { -print_tcstats_attr (fp, tb[TCA_STATS ]); +struct rtattr *xstats =NULL ; + +if (tb[TCA_STATS ] || tb[TCA_STATS2 ]) { +print_tcstats_attr (fp, tb," " , &xstats);fprintf (fp,"\n" ); } -if (q && tb[TCA_XSTATS ] && q->print_xstats) { - q->print_xstats (q, fp, tb[TCA_XSTATS ]); +if (q && (xstats || tb[TCA_XSTATS ]) && q->print_xstats) { + q->print_xstats (q, fp, xstats ? : tb[TCA_XSTATS ]);fprintf (fp,"\n" ); } }
tc/tc_filter.c +2 -2
@@ -254,8 +254,8 @@ }fprintf (fp,"\n" ); -if (show_stats && tb[TCA_STATS ]) { -print_tcstats_attr (fp, tb[TCA_STATS ]); +if (show_stats && (tb[TCA_STATS ] || tb[TCA_STATS2 ])) { +print_tcstats_attr (fp, tb," " ,NULL );fprintf (fp,"\n" ); }
tc/tc_qdisc.c +6 -37
58 lines not on this page · raw message
tc/tc_util.c +88 -0
91 lines not on this page · raw message
tc/tc_util.h +3 -1
@@ -4,6 +4,7 @@#define MAX_MSG 16384#include <linux/pkt_sched.h> #include <linux/pkt_cls.h> +#include <linux/gen_stats.h> #include "tc_core.h" struct qdisc_util
@@ -58,7 +59,8 @@extern char *sprint_usecs (__u32 usecs,char *buf);extern char *sprint_percent (__u32 percent,char *buf); -extern void print_tcstats_attr (FILE *fp,const struct rtattr *ts); +extern void print_tcstats_attr (FILE *fp,struct rtattr *tb[],char *prefix,struct rtattr **xstats); +extern void print_tcstats2_attr (FILE *fp,struct rtattr *rta,char *prefix,struct rtattr **xstats);extern int get_tc_classid (__u32 *h,const char *str);extern int print_tc_classid (char *buf,int len,__u32 h);