From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-8.cisco.com (rcdn-iport-8.cisco.com [173.37.86.79]) by dpdk.org (Postfix) with ESMTP id 2C38E5592 for ; Fri, 29 Apr 2016 15:43:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=6856; q=dns/txt; s=iport; t=1461937421; x=1463147021; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=thZMAa5NKMyWpoFxWeYms6JtGYtx5OtJE7o0sjGxSxc=; b=QclqzVf87WbZ+NxgczrViGv2A+VRCJdVmfHNgl4e3tD4qWeObhdtLvRT FZ70Wb852AB/2AHeCgI+N47bgaWSMr7hUn/KZ9VrHZysFK2GY515qMEs4 l8ojwWAasSg04EdH6r7bpeo7vohfc3v1CTJUb5pOqaZennTz1yT2uelM1 w=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AMAgCSYyNX/5ldJa1dgziBUAa3XIIPA?= =?us-ascii?q?Q2BdoYPAoEqOBQBAQEBAQEBZSeEQQEBAQMBOkQHBAIBCBEEAQEfCQcyFAkIAgQ?= =?us-ascii?q?BEgiIGgjEIwEBAQEBAQEBAQEBAQEBAQEBAQEBARWGIYRMhBqFeQWNVoVMhHEBj?= =?us-ascii?q?g+PGI8vAR4BAUKCBRsWgTVsh0Q+fwEBAQ?= X-IronPort-AV: E=Sophos;i="5.24,551,1454976000"; d="scan'208";a="97376486" Received: from rcdn-core-2.cisco.com ([173.37.93.153]) by rcdn-iport-8.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Apr 2016 13:43:39 +0000 Received: from XCH-RCD-020.cisco.com (xch-rcd-020.cisco.com [173.37.102.30]) by rcdn-core-2.cisco.com (8.14.5/8.14.5) with ESMTP id u3TDhdFC006020 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Fri, 29 Apr 2016 13:43:39 GMT Received: from xch-rcd-016.cisco.com (173.37.102.26) by XCH-RCD-020.cisco.com (173.37.102.30) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Fri, 29 Apr 2016 08:43: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; Fri, 29 Apr 2016 08:43:38 -0500 From: "David Harton (dharton)" To: Remy Horton , "dev@dpdk.org" , "Helin Zhang" Thread-Topic: [dpdk-dev] [RFC PATCH v1 2/3] drivers/net/ixgbe: change xstats to use integers Thread-Index: AQHRlyVbfgzH57UR0kCZIYmeahgylZ+hBNNg Date: Fri, 29 Apr 2016 13:43:38 +0000 Message-ID: <34cbe07723f64e9f926666164d9d5319@XCH-RCD-016.cisco.com> References: <1460731462-21229-1-git-send-email-remy.horton@intel.com> <1460731462-21229-3-git-send-email-remy.horton@intel.com> In-Reply-To: <1460731462-21229-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.212.42] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC PATCH v1 2/3] drivers/net/ixgbe: change xstats to use integers 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, 29 Apr 2016 13:43:41 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton > Sent: Friday, April 15, 2016 10:44 AM > To: dev@dpdk.org; Helin Zhang > Subject: [dpdk-dev] [RFC PATCH v1 2/3] drivers/net/ixgbe: change xstats t= o > use integers >=20 > Signed-off-by: Remy Horton > --- > drivers/net/ixgbe/ixgbe_ethdev.c | 87 > +++++++++++++++++++++++++++++++++++----- > 1 file changed, 78 insertions(+), 9 deletions(-) >=20 > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > b/drivers/net/ixgbe/ixgbe_ethdev.c > index 3f1ebc1..4d31fe9 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, > @@ -2698,6 +2704,76 @@ ixgbe_xstats_calc_num(void) { > (IXGBE_NB_TXQ_PRIO_STATS * 8); > } >=20 > +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, offset; > + > + if (ptr_names !=3D NULL) { > + count =3D 0; > + offset =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++) { > + snprintf(ptr_names[count].name, > + sizeof(ptr_names[count].name), > + "%s", > + rte_ixgbe_stats_strings[i].name); > + count++; > + offset +=3D RTE_ETH_XSTATS_NAME_SIZE; > + } > + > + /* RX Priority Stats */ > + for (stat =3D 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) { > + for (i =3D 0; i < 8; i++) { 8 seems magical. Is there a constant somewhere that can be used? > + snprintf(ptr_names[count].name, > + sizeof(ptr_names[count].name), > + "rx_priority%u_%s", i, > + rte_ixgbe_rxq_strings[stat].name); > + count++; > + offset +=3D RTE_ETH_XSTATS_NAME_SIZE; > + } > + } > + > + /* TX Priority Stats */ > + for (stat =3D 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) { > + for (i =3D 0; i < 8; i++) { Same magic number. > + snprintf(ptr_names[count].name, > + sizeof(ptr_names[count].name), > + "tx_priority%u_%s", i, > + rte_ixgbe_txq_strings[stat].name); > + count++; > + offset +=3D RTE_ETH_XSTATS_NAME_SIZE; > + } > + } > + /* FIXME: Debugging check */ Just a reminder to cleanup. > + if (cnt_stats !=3D count) > + return -EIO; > + } > + return cnt_stats; > +} > + > +static int ixgbevf_dev_xstats_names(__rte_unused struct rte_eth_dev *dev= , > + struct rte_eth_xstats_name *ptr_names, __rte_unused unsigned limit) > +{ > + unsigned i; > + > + if (limit < IXGBEVF_NB_XSTATS) Think this check has to be removed since rte_eth_xstats_count() calls with= =20 limit =3D=3D 0. > + 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; > +} > + > static int > ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats > *xstats, > unsigned n) > @@ -2731,8 +2807,6 @@ 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); Forgot to add key/id. Also, same name comment as above. > xstats[count].value =3D *(uint64_t *)(((char *)hw_stats) + > rte_ixgbe_stats_strings[i].offset); > count++; > @@ -2741,9 +2815,6 @@ ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struc= t > rte_eth_xstats *xstats, > /* 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); Add key/id...terminate name. > xstats[count].value =3D *(uint64_t *)(((char *)hw_stats) + > rte_ixgbe_rxq_strings[stat].offset + > (sizeof(uint64_t) * i)); > @@ -2754,16 +2825,14 @@ ixgbe_dev_xstats_get(struct rte_eth_dev *dev, > struct rte_eth_xstats *xstats, > /* 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); Add key/id...terminate name. > xstats[count].value =3D *(uint64_t *)(((char *)hw_stats) + > rte_ixgbe_txq_strings[stat].offset + > (sizeof(uint64_t) * i)); > count++; > } > } > - > + for (i =3D 0; i < count; i++) > + xstats[i].key =3D i; Suggest doing this in the loops above to be consistent with pass-thru and likely saves some instructions. Regards, Dave > return count; > } >=20 > -- > 2.5.5