From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C4ED458D8 for ; Fri, 26 Aug 2016 15:28:49 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 26 Aug 2016 06:28:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,580,1464678000"; d="scan'208";a="1020731258" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga001.jf.intel.com with ESMTP; 26 Aug 2016 06:28:47 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.24]) by IRSMSX104.ger.corp.intel.com ([163.33.3.159]) with mapi id 14.03.0248.002; Fri, 26 Aug 2016 14:28:47 +0100 From: "Pattan, Reshma" To: "Horton, Remy" CC: "dev@dpdk.org" , "thomas.monjalon@6wind.com" Thread-Topic: [dpdk-dev] [RFC PATCH v1] rte: add bit-rate metrics to xstats Thread-Index: AQHR/hf5vrpRZIUfp0q+4YmY6P7la6BbPhCA Date: Fri, 26 Aug 2016 13:28:46 +0000 Message-ID: <3AEA2BF9852C6F48A459DA490692831F01074743@IRSMSX109.ger.corp.intel.com> References: <1472050682-21420-1-git-send-email-remy.horton@intel.com> In-Reply-To: <1472050682-21420-1-git-send-email-remy.horton@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2ZjMDBhMTEtN2Y5Mi00YmFjLWIzYzQtNGMwMmQxOGM1ZDlkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkpxQjRoVGU0bUdmUDBHYjA3ZjdFREp1MVpZOTNnQnJqbnN3MGduRyt2UW89In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC PATCH v1] rte: add bit-rate metrics to xstats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Aug 2016 13:28:50 -0000 Hi, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton > Sent: Wednesday, August 24, 2016 3:58 PM > To: thomas.monjalon@6wind.com > Cc: dev@dpdk.org > Subject: [dpdk-dev] [RFC PATCH v1] rte: add bit-rate metrics to xstats >=20 > This patch adds peak and average data-rate metrics to the extended statis= tics. > The intervals used to generate the statistics are controlled by any appli= cation > wishing to make use of these metrics. >=20 > Signed-off-by: Remy Horton > --- > +int > +rte_eth_dev_stats_init(uint8_t port_id, uint32_t cnt_buckets) { > + struct rte_eth_dev *dev; > + struct rte_eth_dev_stats *stats; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > + dev =3D &rte_eth_devices[port_id]; > + stats =3D &dev->data->stats; > + > + memset(stats, 0, sizeof(struct rte_eth_dev_stats)); > + stats->list_ibuckets =3D rte_zmalloc( > + NULL, sizeof(uint64_t) * cnt_buckets, 0); We can have the sizeof(uint64_t) * cnt_buckets, calculated on top and use t= hat in both the rte_zmallocs, Instead of performing * operation twice. > + stats->list_obuckets =3D rte_zmalloc( > + NULL, sizeof(uint64_t) * cnt_buckets, 0); > + if (stats->list_ibuckets =3D=3D NULL || stats->list_obuckets =3D=3D NUL= L) > + return -ENOMEM; If either of them has valid pointer we should free that before returning. > + stats->cnt_buckets =3D cnt_buckets; > + return 0; > +} > + Thanks, Reshma