From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-1.cisco.com (rcdn-iport-1.cisco.com [173.37.86.72]) by dpdk.org (Postfix) with ESMTP id D5CEB2E7B for ; Mon, 9 May 2016 16:10:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=7715; q=dns/txt; s=iport; t=1462803017; x=1464012617; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=7nuU3+pxTHxDhF8d0HwX+u5uZutCbMLYQ1NtMIakkmo=; b=j9zhXHa+SxxkIU6dstVBdTnw+Xm8CgpbVMmneSYbLnSB7CetdQEkoShu qd588gtg6fI0p54M6GAX37zTjyQDJCjL9aCRjyaxyNdpYchCYS9UJXHiY xfodQKvM3FxYo054KdLQGOmNbkEoi0mgXS6DquNTbXisVDbWBO+0H33// U=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AYAgCsmDBX/5JdJa1dgziBUga2cIIPA?= =?us-ascii?q?Q2BdoYQAoEtOBQBAQEBAQEBZSeEQQEBAQQ6SwQCAQgRBAEBHwkHMhQJCAIEARI?= =?us-ascii?q?IiCO/EQEBAQEBAQEBAQEBAQEBAQEBAQEBARWGIIRMhByFfAWNXoVOhHYBjhSPH?= =?us-ascii?q?o86AR4BAUKCBRsWgTVuh0k+fwEBAQ?= X-IronPort-AV: E=Sophos;i="5.24,600,1454976000"; d="scan'208";a="106073010" Received: from rcdn-core-10.cisco.com ([173.37.93.146]) by rcdn-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2016 14:06:38 +0000 Received: from XCH-ALN-020.cisco.com (xch-aln-020.cisco.com [173.36.7.30]) by rcdn-core-10.cisco.com (8.14.5/8.14.5) with ESMTP id u49E6cua005560 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Mon, 9 May 2016 14:06:38 GMT Received: from xch-rcd-016.cisco.com (173.37.102.26) by XCH-ALN-020.cisco.com (173.36.7.30) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Mon, 9 May 2016 09:06:38 -0500 Received: from xch-rcd-016.cisco.com ([173.37.102.26]) by XCH-RCD-016.cisco.com ([173.37.102.26]) with mapi id 15.00.1104.009; Mon, 9 May 2016 09:06:38 -0500 From: "David Harton (dharton)" To: Remy Horton , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC PATCH v2 2/3] drivers/net/ixgbe: change xstats to use integer id Thread-Index: AQHRp4gQYNdOChlSKke0Sq+D1LS6W5+wpvJA Date: Mon, 9 May 2016 14:06:38 +0000 Message-ID: References: <1462533074-1994-1-git-send-email-remy.horton@intel.com> <1462533074-1994-3-git-send-email-remy.horton@intel.com> In-Reply-To: <1462533074-1994-3-git-send-email-remy.horton@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.82.169.253] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC PATCH v2 2/3] drivers/net/ixgbe: change xstats to use integer id 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: Mon, 09 May 2016 14:10:19 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton > Sent: Friday, May 06, 2016 7:11 AM > To: dev@dpdk.org > Subject: [dpdk-dev] [RFC PATCH v2 2/3] drivers/net/ixgbe: change xstats t= o > use integer id >=20 > Signed-off-by: Remy Horton > --- > drivers/net/ixgbe/ixgbe_ethdev.c | 98 ++++++++++++++++++++++++++++++++++= - > ----- > 1 file changed, 85 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 3f1ebc1..3ff8bae 100644 > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > @@ -179,6 +179,10 @@ static int ixgbevf_dev_xstats_get(struct rte_eth_dev > *dev, > struct rte_eth_xstats *xstats, unsigned n); > static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev); > static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev); > +static int ixgbe_dev_xstats_names(__rte_unused struct rte_eth_dev *dev, > + struct rte_eth_xstats_name *ptr_names, __rte_unused unsigned limit); > +static int ixgbevf_dev_xstats_names(__rte_unused struct rte_eth_dev *dev= , > + struct rte_eth_xstats_name *ptr_names, __rte_unused unsigned limit); > static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev= , > uint16_t queue_id, > uint8_t stat_idx, > @@ -466,6 +470,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops =3D= { > .xstats_get =3D ixgbe_dev_xstats_get, > .stats_reset =3D ixgbe_dev_stats_reset, > .xstats_reset =3D ixgbe_dev_xstats_reset, > + .xstats_names =3D ixgbe_dev_xstats_names, > .queue_stats_mapping_set =3D ixgbe_dev_queue_stats_mapping_set, > .dev_infos_get =3D ixgbe_dev_info_get, > .dev_supported_ptypes_get =3D ixgbe_dev_supported_ptypes_get, > @@ -555,6 +560,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = =3D > { > .xstats_get =3D ixgbevf_dev_xstats_get, > .stats_reset =3D ixgbevf_dev_stats_reset, > .xstats_reset =3D ixgbevf_dev_stats_reset, > + .xstats_names =3D ixgbevf_dev_xstats_names, > .dev_close =3D ixgbevf_dev_close, > .allmulticast_enable =3D ixgbevf_dev_allmulticast_enable, > .allmulticast_disable =3D ixgbevf_dev_allmulticast_disable, > @@ -685,6 +691,7 @@ static const struct rte_ixgbe_xstats_name_off > rte_ixgbe_rxq_strings[] =3D { >=20 > #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \ > sizeof(rte_ixgbe_rxq_strings[0])) > +#define IXGBE_NB_RXQ_PRIO_VALUES 8 >=20 > static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = =3D { > {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)}, > @@ -695,6 +702,7 @@ static const struct rte_ixgbe_xstats_name_off > rte_ixgbe_txq_strings[] =3D { >=20 > #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \ > sizeof(rte_ixgbe_txq_strings[0])) > +#define IXGBE_NB_TXQ_PRIO_VALUES 8 >=20 > static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[= ] > =3D { > {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)}, > @@ -2694,8 +2702,75 @@ ixgbe_dev_stats_reset(struct rte_eth_dev *dev) > /* This function calculates the number of xstats based on the current > config */ > static unsigned > ixgbe_xstats_calc_num(void) { > - return IXGBE_NB_HW_STATS + (IXGBE_NB_RXQ_PRIO_STATS * 8) + > - (IXGBE_NB_TXQ_PRIO_STATS * 8); > + return IXGBE_NB_HW_STATS + > + (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) + > + (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES); Nice cleanup. > +} > + > +static int ixgbe_dev_xstats_names(__rte_unused struct rte_eth_dev *dev, > + struct rte_eth_xstats_name *ptr_names, __rte_unused unsigned limit) > +{ > + const unsigned cnt_stats =3D ixgbe_xstats_calc_num(); > + unsigned stat, i, count; > + > + if (ptr_names !=3D NULL) { > + count =3D 0; > + > + /* Note: limit >=3D cnt_stats checked upstream > + * in rte_eth_xstats_names() > + */ > + > + /* Extended stats from ixgbe_hw_stats */ > + for (i =3D 0; i < IXGBE_NB_HW_STATS; i++) { > + ptr_names[count].id =3D count; > + snprintf(ptr_names[count].name, > + sizeof(ptr_names[count].name), > + "%s", > + rte_ixgbe_stats_strings[i].name); > + count++; > + } > + > + /* RX Priority Stats */ > + for (stat =3D 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) { > + for (i =3D 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) { > + ptr_names[count].id =3D count; > + snprintf(ptr_names[count].name, > + sizeof(ptr_names[count].name), > + "rx_priority%u_%s", i, > + rte_ixgbe_rxq_strings[stat].name); > + count++; > + } > + } > + > + /* TX Priority Stats */ > + for (stat =3D 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) { > + for (i =3D 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) { > + ptr_names[count].id =3D count; > + snprintf(ptr_names[count].name, > + sizeof(ptr_names[count].name), > + "tx_priority%u_%s", i, > + rte_ixgbe_txq_strings[stat].name); > + count++; > + } > + } > + } > + return cnt_stats; > +} > + > +static int ixgbevf_dev_xstats_names(__rte_unused struct rte_eth_dev *dev= , > + struct rte_eth_xstats_name *ptr_names, unsigned limit) > +{ > + unsigned i; > + > + if (limit < IXGBEVF_NB_XSTATS && ptr_names !=3D NULL) > + return -ENOMEM; > + > + if (ptr_names !=3D NULL) > + for (i =3D 0; i < IXGBEVF_NB_XSTATS; i++) > + snprintf(ptr_names[i].name, > + sizeof(ptr_names[i].name), > + "%s", rte_ixgbevf_stats_strings[i].name); > + return IXGBEVF_NB_XSTATS; > } >=20 > static int > @@ -2731,8 +2806,8 @@ ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struc= t > rte_eth_xstats *xstats, > /* Extended stats from ixgbe_hw_stats */ > count =3D 0; > for (i =3D 0; i < IXGBE_NB_HW_STATS; i++) { > - snprintf(xstats[count].name, sizeof(xstats[count].name), "%s", > - rte_ixgbe_stats_strings[i].name); > + xstats[count].id =3D count; > + xstats[count].name[0] =3D '\0'; > xstats[count].value =3D *(uint64_t *)(((char *)hw_stats) + > rte_ixgbe_stats_strings[i].offset); > count++; > @@ -2740,10 +2815,9 @@ ixgbe_dev_xstats_get(struct rte_eth_dev *dev, > struct rte_eth_xstats *xstats, >=20 > /* RX Priority Stats */ > for (stat =3D 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) { > - for (i =3D 0; i < 8; i++) { > - snprintf(xstats[count].name, sizeof(xstats[count].name), > - "rx_priority%u_%s", i, > - rte_ixgbe_rxq_strings[stat].name); > + for (i =3D 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) { > + xstats[count].id =3D count; > + xstats[count].name[0] =3D '\0'; > xstats[count].value =3D *(uint64_t *)(((char *)hw_stats) + > rte_ixgbe_rxq_strings[stat].offset + > (sizeof(uint64_t) * i)); > @@ -2753,17 +2827,15 @@ ixgbe_dev_xstats_get(struct rte_eth_dev *dev, > struct rte_eth_xstats *xstats, >=20 > /* TX Priority Stats */ > for (stat =3D 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) { > - for (i =3D 0; i < 8; i++) { > - snprintf(xstats[count].name, sizeof(xstats[count].name), > - "tx_priority%u_%s", i, > - rte_ixgbe_txq_strings[stat].name); > + for (i =3D 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) { > + xstats[count].id =3D count; > + xstats[count].name[0] =3D '\0'; > xstats[count].value =3D *(uint64_t *)(((char *)hw_stats) + > rte_ixgbe_txq_strings[stat].offset + > (sizeof(uint64_t) * i)); > count++; > } > } > - > return count; > } >=20 > -- > 2.5.5 Acked-by: David Harton