From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-2.cisco.com (alln-iport-2.cisco.com [173.37.142.89]) by dpdk.org (Postfix) with ESMTP id 1CDC16889 for ; Mon, 9 May 2016 16:10:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3853; q=dns/txt; s=iport; t=1462803018; x=1464012618; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=K0Dsd6DQe72dQE725H5cUtMrqlkRWIjStVKRWyHuK1U=; b=UDbR9jSjuDaWVzHRtV/QFg8hQecu5tW3C1pyY8pAcvoit/n6bif0fuVu PK2gFLAS2v/+16mKaF/blWqcIC7SGfELgX85PRRPdgC/r+FOlw5xB0SR8 r9L96GHnNSG5VUrPkoS1xaPDv4j7nIS12IXgUkW3j53rPWFmxq34GuILK c=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AYAgBfmTBX/4cNJK1dgziBUga2cIIPA?= =?us-ascii?q?Q2BdoYQAoEuOBQBAQEBAQEBZSeEQQEBAQQnE0sEAgEIEQQBAR8JBzIUCQgCBAE?= =?us-ascii?q?SCIgjvxMBAQEBAQEBAQEBAQEBAQEBAQEBAQEVhiCETIoYBY1eikQBjhSPHo86A?= =?us-ascii?q?R4BAUKCBRuBS26IB38BAQE?= X-IronPort-AV: E=Sophos;i="5.24,600,1454976000"; d="scan'208";a="269800799" Received: from alln-core-2.cisco.com ([173.36.13.135]) by alln-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 May 2016 14:08:09 +0000 Received: from XCH-RCD-019.cisco.com (xch-rcd-019.cisco.com [173.37.102.29]) by alln-core-2.cisco.com (8.14.5/8.14.5) with ESMTP id u49E89RR006552 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Mon, 9 May 2016 14:08:09 GMT Received: from xch-rcd-016.cisco.com (173.37.102.26) by XCH-RCD-019.cisco.com (173.37.102.29) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Mon, 9 May 2016 09:08:08 -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:08:08 -0500 From: "David Harton (dharton)" To: Remy Horton , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC PATCH v2 3/3] examples/ethtool: add xstats display command Thread-Index: AQHRp4gWZR1M0e7KdkOFEICTzxIPQp+wqP4w Date: Mon, 9 May 2016 14:08:08 +0000 Message-ID: <19cf0a3831e743cb8731c9041c8a67cd@XCH-RCD-016.cisco.com> References: <1462533074-1994-1-git-send-email-remy.horton@intel.com> <1462533074-1994-4-git-send-email-remy.horton@intel.com> In-Reply-To: <1462533074-1994-4-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 3/3] examples/ethtool: add xstats display command 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 3/3] examples/ethtool: add xstats > display command >=20 > Signed-off-by: Remy Horton > --- > examples/ethtool/ethtool-app/ethapp.c | 57 > +++++++++++++++++++++++++++++++++++ > 1 file changed, 57 insertions(+) >=20 > diff --git a/examples/ethtool/ethtool-app/ethapp.c > b/examples/ethtool/ethtool-app/ethapp.c > index 2ed4796..1dc0c35 100644 > --- a/examples/ethtool/ethtool-app/ethapp.c > +++ b/examples/ethtool/ethtool-app/ethapp.c > @@ -98,6 +98,8 @@ cmdline_parse_token_string_t pcmd_rxmode_token_cmd =3D > TOKEN_STRING_INITIALIZER(struct pcmd_int_params, cmd, "rxmode"); > cmdline_parse_token_string_t pcmd_portstats_token_cmd =3D > TOKEN_STRING_INITIALIZER(struct pcmd_int_params, cmd, "portstats"); > +cmdline_parse_token_string_t pcmd_xstats_token_cmd =3D > + TOKEN_STRING_INITIALIZER(struct pcmd_int_params, cmd, "xstats"); > cmdline_parse_token_num_t pcmd_int_token_port =3D > TOKEN_NUM_INITIALIZER(struct pcmd_int_params, port, UINT16); >=20 > @@ -552,6 +554,49 @@ static void pcmd_portstats_callback(__rte_unused voi= d > *ptr_params, > printf("Port %i: Error fetching statistics\n", params->port); > } >=20 > +static void pcmd_xstats_callback(__rte_unused void *ptr_params, > + __rte_unused struct cmdline *ctx, > + __rte_unused void *ptr_data) > +{ > + struct rte_eth_xstats xstats[256]; > + struct pcmd_int_params *params =3D ptr_params; > + int cnt_xstats, idx_xstat, idx_name; > + struct rte_eth_xstats_name *ptr_names; > + > + if (!rte_eth_dev_is_valid_port(params->port)) { > + printf("Error: Invalid port number %i\n", params->port); > + return; > + } > + > + cnt_xstats =3D rte_eth_xstats_count(params->port); > + if (cnt_xstats < 0) { > + printf("Port %i: %s\n", params->port, strerror(-cnt_xstats)); > + return; > + } > + printf("Number of xstats: %i\n", cnt_xstats); > + ptr_names =3D malloc(sizeof(struct rte_eth_xstats_name) * cnt_xstats); > + if (cnt_xstats !=3D rte_eth_xstats_names( > + params->port, ptr_names, cnt_xstats)) { > + printf("Error: Fetched and expected counts mismatch\n"); > + return; > + } > + > + cnt_xstats =3D rte_eth_xstats_get(params->port, xstats, 256); > + if (cnt_xstats < 0) { > + printf("Error: Unable to get xstats (%s)\n", > + strerror(-cnt_xstats)); > + return; > + } > + for (idx_xstat =3D 0; idx_xstat < cnt_xstats; idx_xstat++) > + for (idx_name =3D 0; idx_name < cnt_xstats; idx_name++) > + if (ptr_names[idx_name].id =3D=3D xstats[idx_xstat].id) { > + printf("%s: %lu\n", ptr_names[idx_name].name, > + xstats[idx_xstat].value); > + break; > + } > + free(ptr_names); > +} > + > static void pcmd_ringparam_callback(__rte_unused void *ptr_params, > __rte_unused struct cmdline *ctx, > void *ptr_data) > @@ -790,6 +835,17 @@ cmdline_parse_inst_t pcmd_portstats =3D { > NULL > }, > }; > +cmdline_parse_inst_t pcmd_xstats =3D { > + .f =3D pcmd_xstats_callback, > + .data =3D NULL, > + .help_str =3D "xstats \n" > + " Print port eth xstats", > + .tokens =3D { > + (void *)&pcmd_xstats_token_cmd, > + (void *)&pcmd_int_token_port, > + NULL > + }, > +}; > cmdline_parse_inst_t pcmd_ringparam =3D { > .f =3D pcmd_ringparam_callback, > .data =3D NULL, > @@ -858,6 +914,7 @@ cmdline_parse_ctx_t list_prompt_commands[] =3D { > (cmdline_parse_inst_t *)&pcmd_stop, > (cmdline_parse_inst_t *)&pcmd_validate, > (cmdline_parse_inst_t *)&pcmd_vlan, > + (cmdline_parse_inst_t *)&pcmd_xstats, > (cmdline_parse_inst_t *)&pcmd_quit, > NULL > }; > -- > 2.5.5 Acked-by: David Harton