From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130080.outbound.protection.outlook.com [40.107.13.80]) by dpdk.org (Postfix) with ESMTP id 1C9C11B113 for ; Wed, 14 Nov 2018 16:17:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bz6bERl73HVenKhEv+vEL2hLlq+l1y8FEt2I6oJ+DY0=; b=P7UvTBod+npgj8c9vInaU8OzEIjXQnFL/VbbPnRV3UKFDyOBAx4GEF+sv+4rwUTSp+vpQXVKnGb0t990HoXIuzC2kJUguKMYkqZ9wc/BYj0gsNrxmA/YaWXSKmh7BV+3CbKdA/UrF1qA4TPEwQmkbUVjNI4+hL/ysjyMYsa3928= Received: from DB7PR05MB4426.eurprd05.prod.outlook.com (52.134.109.15) by DB7PR05MB4841.eurprd05.prod.outlook.com (20.176.235.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.27; Wed, 14 Nov 2018 15:17:09 +0000 Received: from DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::bc22:c2f5:208d:826f]) by DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::bc22:c2f5:208d:826f%2]) with mapi id 15.20.1294.044; Wed, 14 Nov 2018 15:17:09 +0000 From: Shahaf Shuler To: Tom Barbette , "dev@dpdk.org" CC: Yongseok Koh Thread-Topic: [PATCH] mlx5: Report imissed stat Thread-Index: AQHUezn7GdEWLcTKrk2jn2J1oCKc+6VPYTIA Date: Wed, 14 Nov 2018 15:17:09 +0000 Message-ID: References: <1542104199-55746-1-git-send-email-barbette@kth.se> In-Reply-To: <1542104199-55746-1-git-send-email-barbette@kth.se> 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=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR05MB4841; 6:ODXVtS54u9PiJSrp9qxNsu6z0biajBWPjCLSeWZjqFE1bqCPU87l7Wc8nAylgcxmKT7KfaF2eyeOzggeFw+qwYpqFR2Bbb/0HiTInLMLLA6V47rZKroy5Hj5REB9mcFVRyknTsWrQ8AVR8klTmJMFmYVGNoNOgLPUElKY8LQfEOc0mhLqJsvPFsYoH8LCWkOkvtMvke/qF5LFGIQlN864PkAzGBQBo8egbJm0tT1Lu4BdPPv7jWnvVf0FxIuCzy0jRalf/SwfsaGYC3IS72t8+JWLEmMFo+/l0FnOdsUPDuEAJ9YVjlWvpYPg1LCyPFhLqBpq7QfBKmTHnR+wUnCVlkFb3RcNqHmrfVLt7bdl366uPo1BK7PranGBPLa02CgwqgN19dgbSYuiGWmmkBpaO3A8G2jEDjAnGXma7AJIPXQFGm5D0OUKdL4u6J0CfmUGbKxOahBB0Yn9abF2aTenA==; 5:czajG6f1R4ijOERR7xo/9qFkQTiH8ApPdtbWBwqoxWPuGbl++T9XdNTFSiywleozYdlETRbiI8HWEvXK1TeWpdRi2t+Ng3m5D+qzOrFR6YlbxxcMGy3L2X/JRQjtHlTPPtrMlicyALig98tRmdhkIxTl1IP/v8sadyBZOdNVsrE=; 7:8E9oaClJBgWgU8IP54ek1ovsjM2CdppQxPxrNKD5eFJiC4KCzZISvJBVV/qcdkIqFN05ID0/hEbjjpT5CnbBy9D7wyYWgjBOO9pbmQ+YifRZqrlZk/DQfQNRQMg/tarct3/XQKEIeqETGobC512/wQ== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 173d7480-859b-4147-6ed4-08d64a443f11 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4841; x-ms-traffictypediagnostic: DB7PR05MB4841: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231410)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DB7PR05MB4841; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4841; x-forefront-prvs: 085634EFF4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(396003)(376002)(346002)(136003)(199004)(189003)(6116002)(256004)(476003)(3846002)(305945005)(7736002)(446003)(4326008)(11346002)(486006)(53936002)(316002)(14454004)(110136005)(99286004)(25786009)(102836004)(6506007)(2906002)(5660300001)(107886003)(478600001)(7696005)(71190400001)(26005)(186003)(71200400001)(229853002)(76176011)(74316002)(66066001)(86362001)(33656002)(81156014)(97736004)(8676002)(8936002)(81166006)(2501003)(6246003)(106356001)(2900100001)(55016002)(68736007)(551984002)(9686003)(105586002)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4841; H:DB7PR05MB4426.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 7XooPk+BP+p55jdMvJMhkutzj9IMnsHVnbq0rr7aHGIjbe+HH0CqP+3e0DheywXYDpFBG3ZeX1yYfgLFK0qByBUC7ix29IgfxZj/R945Fh8nfGPv67h0Y0q7gVhc2pmC4KLV2iYy/JuDfzAT6C79t1fFrxLIGAeqBYeY+d81Oy2jE/2fi3RP5BaJAWRvzISkHAmsAa9lxEVCrZin8p4Tq8TpYFK8h2tQ8n94magaPtwzF2luKbYLscD1aW5j10/WqUK7fB8JInSSoYDz9NRZEarvlueN8eINPSWDod6f/mARMmr+WDW065aft5m2ubPLzfSU+YPfFE0tj3mdc8AUd6esLwaO8R/KT/pnIWWJzDA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 173d7480-859b-4147-6ed4-08d64a443f11 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Nov 2018 15:17:09.5373 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4841 Subject: Re: [dpdk-dev] [PATCH] mlx5: Report imissed stat 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: , X-List-Received-Date: Wed, 14 Nov 2018 15:17:11 -0000 Hi Again Tom,=20 Tuesday, November 13, 2018 12:17 PM, Tom Barbette: > Subject: [PATCH] mlx5: Report imissed stat >=20 > The imissed counters (number of packets dropped because the queues were > full) were actually reported through xstats as "rx_out_of_buffer" > but was not reported through stats. >=20 > Following a recent discussion on the ML, as there is no way to tell the u= ser if a > counter is implemented or not, this should be considered a bug. Eg, user > looking at imissed will think the packets are lost before reaching the de= vice. >=20 > As for xstats, I added a base counter to be able to "reset" imissed. >=20 Yes, a bit of extra work is needed here.=20 the full definition of the missed is " uint64_t imissed; =20 /**< Total of RX packets dropped by the HW, =20 * because there are no available buffer (i.e. RX queues are full). */ =20 " It is not well defined (this is other topic), because it assumes the only r= eason to drop packets is because there is no avail buffer on the Rx queue. It is not entirely correct, for example if you have large latency on your s= ystem it is possible that packets would be dropped on the physical port, no= t because the application is slow and not replenish the buffers fast enough= , rather because the NIC is not processing them on the needed rate. I guess what application seek on imissed is the sum of two. It can be done = by summing up two counters: the out_of_buffer and the rx_discard_phy (which= exists on ethtool -S and need to be added to mlx5_counters_init a= rray).=20 Still, the output will be incorrect on the following cases: 1. from VF, since VF cannot read the phy port counters 2. in the presence of representors, as they all share the same phy port cou= nter.=20 I guess if we want to get such patch in, we need first to make the calculat= ion correct, and document the limitations.=20 =20 > Signed-off-by: Tom Barbette > --- > drivers/net/mlx5/mlx5.h | 2 ++ > drivers/net/mlx5/mlx5_stats.c | 36 +++++++++++++++++++++++------------- > 2 files changed, 25 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index > a3a34cf..61054a8 100644 > --- a/drivers/net/mlx5/mlx5.h > +++ b/drivers/net/mlx5/mlx5.h > @@ -77,6 +77,8 @@ struct mlx5_xstats_ctrl { > /* Index in the device counters table. */ > uint16_t dev_table_idx[MLX5_MAX_XSTATS]; > uint64_t base[MLX5_MAX_XSTATS]; > + /* Base for imissed counter. */ > + uint64_t imissed_base; > }; >=20 > /* Flow list . */ > diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.= c > index 91f3d47..1e75e85 100644 > --- a/drivers/net/mlx5/mlx5_stats.c > +++ b/drivers/net/mlx5/mlx5_stats.c > @@ -119,6 +119,24 @@ static const struct mlx5_counter_ctrl > mlx5_counters_init[] =3D { >=20 > static const unsigned int xstats_n =3D RTE_DIM(mlx5_counters_init); >=20 > +static inline void > +mlx5_read_ib_stat(struct priv *priv, unsigned int idx, uint64_t *stat) > +{ > + FILE *file; > + MKSTR(path, "%s/ports/1/hw_counters/%s", > + priv->ibdev_path, > + mlx5_counters_init[idx].ctr_name); > + > + file =3D fopen(path, "rb"); > + if (file) { > + int n =3D fscanf(file, "%" SCNu64, stat); > + > + fclose(file); > + if (n !=3D 1) > + stat =3D 0; > + } > +} > + > /** > * Read device counters table. > * > @@ -155,19 +173,7 @@ mlx5_read_dev_counters(struct rte_eth_dev *dev, > uint64_t *stats) > } > for (i =3D 0; i !=3D xstats_n; ++i) { > if (mlx5_counters_init[i].ib) { > - FILE *file; > - MKSTR(path, "%s/ports/1/hw_counters/%s", > - priv->ibdev_path, > - mlx5_counters_init[i].ctr_name); > - > - file =3D fopen(path, "rb"); > - if (file) { > - int n =3D fscanf(file, "%" SCNu64, &stats[i]); > - > - fclose(file); > - if (n !=3D 1) > - stats[i] =3D 0; > - } > + mlx5_read_ib_stat(priv, i, &stats[i]); > } else { > stats[i] =3D (uint64_t) > et_stats->data[xstats_ctrl- > >dev_table_idx[i]]; > @@ -281,6 +287,7 @@ mlx5_xstats_init(struct rte_eth_dev *dev) > if (ret) > DRV_LOG(ERR, "port %u cannot read device counters: %s", > dev->data->port_id, strerror(rte_errno)); > + mlx5_read_ib_stat(priv, 17, &xstats_ctrl->imissed_base); > free: > rte_free(strings); > } > @@ -389,6 +396,8 @@ mlx5_stats_get(struct rte_eth_dev *dev, struct > rte_eth_stats *stats) #endif > tmp.oerrors +=3D txq->stats.oerrors; > } > + mlx5_read_ib_stat(priv, 17, &tmp.imissed); > + tmp.imissed -=3D priv->xstats_ctrl.imissed_base; > #ifndef MLX5_PMD_SOFT_COUNTERS > /* FIXME: retrieve and add hardware counters. */ #endif @@ -461,6 > +470,7 @@ mlx5_xstats_reset(struct rte_eth_dev *dev) > } > for (i =3D 0; i !=3D n; ++i) > xstats_ctrl->base[i] =3D counters[i]; > + mlx5_read_ib_stat(priv, 17, &xstats_ctrl->imissed_base); > } >=20 > /** > -- > 2.7.4