From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0128BA0597; Wed, 8 Apr 2020 20:16:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BF3B11C1C7; Wed, 8 Apr 2020 20:16:22 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id EEC551C1C4 for ; Wed, 8 Apr 2020 20:16:20 +0200 (CEST) IronPort-SDR: nbaU8Atx30y1c+RdjbrI2b2YPqO6nl7AliLh42DScUmUvl/pImaxf5R18Cm5Awby1MVc86wWCb 6/IUMRtDJfmg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2020 11:16:12 -0700 IronPort-SDR: Rq4+U+ghgP/sFA9MnZzpfo/OHNwpm4GuxTEjxRQaLcJKqDMeSaodz6Oraql7f4Y1AZ0IA47w68 D1om2GeBwAnw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,359,1580803200"; d="scan'208";a="251640681" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 08 Apr 2020 11:16:12 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 11:16:12 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 11:16:12 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.104) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Apr 2020 11:16:11 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0mEATb4u6D5/9L8Ep/ISn497PKewvNg3Znlgn5tUIEIEZJcHU1QDX6qh7E7HRFCx9wA8CYfzzQ4pjS7kw/kO8M99yM7anyoAcRFv6WWMq1qr//emM8MFtnR2MgOat0uj1G8onwHAc7TuD0zwqd/Rfluxq2w7YMEXJDGMuX1lxQrA4EUjpQT+4yqsoBBZu4lfv6R+GOhOdcEXyzdnVYPuVBM6Bl4CLPvjgV5ZQWJGchrcYF6jv6HF3ItnE7wQ9h/wwEHX+Yb9MvV74j1r2GinoMbFSI04JrdQQjGPBuaxG1eRWE71Tr6xS5KxWWGHSTi1QR26jnjN1+QOXI+RZClTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b7euj4L1ghpNlqAk6fBpfrxq3AOVMisWidqu6zlA32A=; b=VLMYw5BZUy8afEPgnzRv+0smzCOSYhIaUF2nj3onfwOibnOSO5T6djGSgi3dBeumXnwgMehJPK0dvzdIQNCwD/933FLgQaEbH6mgqr0/9nDd1qn693txK/qR1qz5O2L1WWVTb9xJfXyGwebA/1OhyKGTSPCduh+fxmlKegTcOLnhK/oH5g6wLyOz24GoAZ/mrPkVn6F+Ip4w+XbRN+FoeErp1f9d1hJqlWu+iBZn91QE93SYUe4zXK/wFl9QuRhaA8Q8uKCGjWFD2+vVlXCFqe/VeqbC2XaCC2AjmFAbQ/2P2Nk31bCYcRkkeqRR8K3bYyPog82SY94p3JTFhvB9+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b7euj4L1ghpNlqAk6fBpfrxq3AOVMisWidqu6zlA32A=; b=xWjdYvbYcAYKY7WREs6UacyiIrDmOBh5Q6wy4E+tqCa+InKzgmy2e+cURp5ExK6oqi6G5FMgyKN4KrNC0wig47LN+GNVWvzrLZ5JNvYDrjpsNDW4uqzwDW0rrA0uM3qMgWiiGvVA8Konn+uGUEawWYrJhtEklNbEByRQnhdaaNE= Received: from DM6PR11MB4593.namprd11.prod.outlook.com (2603:10b6:5:2a3::8) by DM6PR11MB2604.namprd11.prod.outlook.com (2603:10b6:5:c8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.17; Wed, 8 Apr 2020 18:16:10 +0000 Received: from DM6PR11MB4593.namprd11.prod.outlook.com ([fe80::9d18:a682:243f:6d6d]) by DM6PR11MB4593.namprd11.prod.outlook.com ([fe80::9d18:a682:243f:6d6d%3]) with mapi id 15.20.2900.015; Wed, 8 Apr 2020 18:16:10 +0000 From: "Wiles, Keith" To: "Power, Ciara" CC: dev , "Laatz, Kevin" , "Pattan, Reshma" , "jerinjacobk@gmail.com" , "david.marchand@redhat.com" , "mb@smartsharesystems.com" , "thomas@monjalon.net" , "Richardson, Bruce" Thread-Topic: [PATCH v2 08/16] ethdev: add callback support for telemetry Thread-Index: AQHWDchtzhXcZG4CaEOW49aqBr46U6hvh/yA Date: Wed, 8 Apr 2020 18:16:10 +0000 Message-ID: <759402D2-5628-4E34-BF87-30068783661F@intel.com> References: <20200319171907.60891-1-ciara.power@intel.com> <20200408164956.47864-1-ciara.power@intel.com> <20200408164956.47864-9-ciara.power@intel.com> In-Reply-To: <20200408164956.47864-9-ciara.power@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=keith.wiles@intel.com; x-originating-ip: [47.24.6.94] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 15b5cfb5-bede-42e0-81e5-08d7dbe8ea09 x-ms-traffictypediagnostic: DM6PR11MB2604: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:57; x-forefront-prvs: 0367A50BB1 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4593.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(136003)(39850400004)(346002)(376002)(396003)(366004)(53546011)(6506007)(186003)(26005)(316002)(37006003)(36756003)(6636002)(478600001)(2616005)(6512007)(4326008)(8936002)(107886003)(8676002)(6862004)(81156014)(2906002)(6486002)(81166007)(54906003)(91956017)(76116006)(66946007)(66476007)(66556008)(66446008)(33656002)(86362001)(5660300002)(64756008)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gI3rqORKDzKVPXp1X6UnPcJFQ7ZTg055jQ1Gq3Wac94mZEUF9s4bvD2q2ADZZXNKG5xv0nHRwVjDeFwy2FH76zd9lAk+RKHg9XLvPa5VQMlAmYc9qblIrNqk7t0NisCHP3Ei2tboXNZ+yXZw4fd4ttdeXZDtoQWoNkBtbYZWdTRqgZPGcSztRD+Foj7UsEaXhofEHnFOswn5r8VRAGXpVynnvSUPt2vKzl1h3et8dyi/SozrG630ZuilibmriZnn4ZNTiqtYIQotqFaXRjm0QizBqe+HetTgthqHY2ECF1RfA5DsOOHOYrj42qNk2JenEcRdwlecLV6F92aptS6AbT5clNlQJPI2rGSwXfAgwpuP3Dowe9JVfatJvG0wIj2bVSipvNRUhlMuzzzlTGQs8zO5bfwSo2QcFuhUqHq+idvfUBBMVisyoecEPu2y/K+q x-ms-exchange-antispam-messagedata: HamiU0rU+TVw9NjI/9+sQr/7GOJWAKADYwJAanWxZMz9B4hP2g8DcPelOmVnSzOeSM0/ur7aMo75As+dtboREa8gMTaKUBTDypHIxwhPQA+Fv6L3bm6kd9OOAczcZjvaKGf3hpA/sOz+RRxto8y+7Q== Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 15b5cfb5-bede-42e0-81e5-08d7dbe8ea09 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2020 18:16:10.0526 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /ZVYCvxfwt5p13BNrYL/VRtvWsiwAG4K/ZSSQF9V0UKlwJmSotN/5Q4+lNAi2ksk58vbgUPLd43Un1e4A2G5sQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2604 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 08/16] ethdev: add callback support for telemetry X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > On Apr 8, 2020, at 11:49 AM, Power, Ciara wrote: >=20 > From: Bruce Richardson >=20 > The ethdev library now registers commands with telemetry, and > implements the callback functions. These commands allow the list of > ethdev ports and the stats and link status for a port to be queried. >=20 > Signed-off-by: Bruce Richardson > Signed-off-by: Ciara Power >=20 > --- > v2: > - Renamed stats to xstats for device specific stats. > - Added link status command for ethdev ports. > --- > lib/librte_ethdev/Makefile | 4 ++ > lib/librte_ethdev/meson.build | 4 ++ > lib/librte_ethdev/rte_ethdev.c | 106 +++++++++++++++++++++++++++++++++ > 3 files changed, 114 insertions(+) >=20 > diff --git a/lib/librte_ethdev/Makefile b/lib/librte_ethdev/Makefile > index b627e4e23b..4ba9cb8f47 100644 > --- a/lib/librte_ethdev/Makefile > +++ b/lib/librte_ethdev/Makefile > @@ -24,6 +24,10 @@ SRCS-y +=3D rte_tm.c > SRCS-y +=3D rte_mtr.c > SRCS-y +=3D ethdev_profile.c >=20 > +ifeq ($(CONFIG_RTE_LIBRTE_TELEMETRY),y) > +LDLIBS +=3D -lrte_telemetry > +endif > + > # > # Export include files > # > diff --git a/lib/librte_ethdev/meson.build b/lib/librte_ethdev/meson.buil= d > index 3537f22f59..072805cf18 100644 > --- a/lib/librte_ethdev/meson.build > +++ b/lib/librte_ethdev/meson.build > @@ -26,3 +26,7 @@ headers =3D files('rte_ethdev.h', > 'rte_tm_driver.h') >=20 > deps +=3D ['net', 'kvargs', 'meter'] > + > +if dpdk_conf.has('RTE_LIBRTE_TELEMETRY') > + deps +=3D ['telemetry'] > +endif > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 0854ef8832..f033d60152 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -38,6 +38,9 @@ > #include > #include > #include > +#ifdef RTE_LIBRTE_TELEMETRY > +#include > +#endif >=20 > #include "rte_ethdev.h" > #include "rte_ethdev_driver.h" > @@ -5189,9 +5192,112 @@ rte_eth_devargs_parse(const char *dargs, struct r= te_eth_devargs *eth_da) > return result; > } >=20 > +#ifdef RTE_LIBRTE_TELEMETRY > +static int > +handle_port_list(const char *cmd __rte_unused, > + const char *params __rte_unused, > + char *buffer, int buf_len) > +{ > + int port_id, used =3D 0; > + > + used =3D rte_tel_json_empty_array(buffer, buf_len, used); > + RTE_ETH_FOREACH_DEV(port_id) > + used =3D rte_tel_json_add_array_int(buffer, buf_len, used, > + port_id); > + return used; > +} > + > +static int > +handle_port_xstats(const char *cmd __rte_unused, > + const char *params, > + char *buffer, int buf_len) > +{ > + struct rte_eth_xstat *eth_xstats; > + struct rte_eth_xstat_name *xstat_names; > + int port_id, num_xstats; > + int i, ret; > + int used =3D 0; > + > + if (params =3D=3D NULL || strlen(params) =3D=3D 0 || !isdigit(*params)) > + return -1; > + > + port_id =3D atoi(params); > + if (!rte_eth_dev_is_valid_port(port_id)) > + return -1; > + > + num_xstats =3D rte_eth_xstats_get(port_id, NULL, 0); > + if (num_xstats < 0) > + return -1; > + > + /* use one malloc for both names and stats */ > + eth_xstats =3D malloc((sizeof(struct rte_eth_xstat) + > + sizeof(struct rte_eth_xstat_name)) * num_xstats); > + if (eth_xstats =3D=3D NULL) > + return -1; > + xstat_names =3D (void *)ð_xstats[num_xstats]; > + > + ret =3D rte_eth_xstats_get_names(port_id, xstat_names, num_xstats); > + if (ret < 0 || ret > num_xstats) { > + free(eth_xstats); > + return -1; > + } > + > + ret =3D rte_eth_xstats_get(port_id, eth_xstats, num_xstats); > + if (ret < 0 || ret > num_xstats) { > + free(eth_xstats); > + return -1; > + } > + > + used =3D rte_tel_json_empty_obj(buffer, buf_len, used); > + for (i =3D 0; i < num_xstats; i++) > + used =3D rte_tel_json_add_obj_u64(buffer, buf_len, used, > + xstat_names[i].name, eth_xstats[i].value); > + > + return used; > +} > + > +static int > +handle_port_link_status(const char *cmd __rte_unused, > + const char *params, > + char *buffer, int buf_len) > +{ > + int ret, port_id; > + struct rte_eth_link link; > + > + if (params =3D=3D NULL || strlen(params) =3D=3D 0 || !isdigit(*params)) > + return -1; > + > + port_id =3D atoi(params); > + if (!rte_eth_dev_is_valid_port(port_id)) > + return -1; > + > + ret =3D rte_eth_link_get(port_id, &link); > + if (ret < 0) > + return -1; > + > + if (link.link_status) > + ret =3D snprintf(buffer, buf_len, > + "{\"status\":\"%s\", \"speed\":%u, \"duplex\":" > + "\"%s\"}", link.link_status ? "UP" : "DOWN:", > + link.link_speed, > + (link.link_duplex =3D=3D ETH_LINK_FULL_DUPLEX) ? > + ("full-duplex") : ("half-duplex")); Adding link status nice. Please remove the spaces in the output string. > + else > + ret =3D snprintf(buffer, buf_len, "{\"status\":\"DOWN\"}"); > + > + return ret >=3D buf_len ? -1 : ret; > +} > +#endif > + > RTE_INIT(ethdev_init_log) > { > rte_eth_dev_logtype =3D rte_log_register("lib.ethdev"); > if (rte_eth_dev_logtype >=3D 0) > rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO); > +#ifdef RTE_LIBRTE_TELEMETRY > + rte_telemetry_register_cmd("/ethdev/list", handle_port_list); > + rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats); > + rte_telemetry_register_cmd("/ethdev/link_status", > + handle_port_link_status); > +#endif > } > --=20 > 2.17.1 >=20