Hi, Harry: Your idea looks very good.
Thanks --Zhiyong > -----Original Message----- > From: Van Haaren, Harry > Sent: Friday, September 9, 2016 4:41 PM > To: Yang, Zhiyong <zhiyong.yang at intel.com>; dev at dpdk.org > Cc: yuanhan.liu at linux.intel.com; thomas.monjalon at 6wind.com; > "mailto:pmatilai"@redhat.com; Yang, Zhiyong <zhiyong.yang at intel.com> > Subject: RE: [dpdk-dev] [PATCH v2] net/vhost: add pmd xstats > > Hi Zhiyong, > > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Zhiyong Yang > > To: dev at dpdk.org > > Subject: [dpdk-dev] [PATCH v2] net/vhost: add pmd xstats > > > > +struct vhost_xstats { > > + uint64_t stat[16]; > > +}; > > Perhaps we could create an enum to access the stat array? > > enum VHOST_STAT { > ... > VHOST_STAT_64_PKT, > ... > }; > > > + {"broadcast_packets", > > + offsetof(struct vhost_queue, xstats.stat[8])}, > > I think the "magic number" 8 here could be from the enum, and would be > more clear which statistic is being accessed. > > > + if (pkt_len == 64) { > > + xstats_update->stat[1]++; > > Similarly, incrementing the counters would be more representative if it > looked like > > xstats_update->stat[VHOST_STAT_64_PKT]++; /* or similar */ > > -Harry