From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-4.sys.kth.se (smtp-4.sys.kth.se [130.237.48.193]) by dpdk.org (Postfix) with ESMTP id 0D404378B for ; Tue, 13 Nov 2018 11:16:42 +0100 (CET) Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id AE2252779; Tue, 13 Nov 2018 11:16:42 +0100 (CET) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-4.sys.kth.se ([127.0.0.1]) by smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 36AG08mhxkL2; Tue, 13 Nov 2018 11:16:42 +0100 (CET) X-KTH-Auth: barbette [192.16.125.165] DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kth.se; s=default; t=1542104202; bh=5yKOEeptQsuRjU++/AQcYdsYGSg9BV7Jj9beuMKu1U0=; h=From:To:Cc:Subject:Date; b=cmSltnsrdsYrlywWBiU/y2XCoTHuzRJ0XkBDdmtLLYqVpCTEqH/yuzXHP4Kvw45o4 IHboSWTiHP1gq17sxTBAtBGj3MW+qWicqSuReyR+0QYUKxUIYe/Jk+Wl3pPW6MPfEk w6I+DuJ0NYZfCBrb105v6i8Zd4vcC2RuD3CXGsEQ= X-KTH-mail-from: barbette@kth.se Received: from nslrack05.ssvl.kth.se (nslrack05.ssvl.kth.se [192.16.125.165]) by smtp-4.sys.kth.se (Postfix) with ESMTPSA id CD1A52647; Tue, 13 Nov 2018 11:16:41 +0100 (CET) From: Tom Barbette To: dev@dpdk.org Cc: Shahaf Shuler , Yongseok Koh , Tom Barbette Date: Tue, 13 Nov 2018 11:16:39 +0100 Message-Id: <1542104199-55746-1-git-send-email-barbette@kth.se> X-Mailer: git-send-email 2.7.4 Subject: [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: Tue, 13 Nov 2018 10:16:43 -0000 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. Following a recent discussion on the ML, as there is no way to tell the user 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 device. As for xstats, I added a base counter to be able to "reset" imissed. 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(-) 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; }; /* 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[] = { static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init); +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 = fopen(path, "rb"); + if (file) { + int n = fscanf(file, "%" SCNu64, stat); + + fclose(file); + if (n != 1) + stat = 0; + } +} + /** * Read device counters table. * @@ -155,19 +173,7 @@ mlx5_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats) } for (i = 0; i != 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 = fopen(path, "rb"); - if (file) { - int n = fscanf(file, "%" SCNu64, &stats[i]); - - fclose(file); - if (n != 1) - stats[i] = 0; - } + mlx5_read_ib_stat(priv, i, &stats[i]); } else { stats[i] = (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 += txq->stats.oerrors; } + mlx5_read_ib_stat(priv, 17, &tmp.imissed); + tmp.imissed -= 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 = 0; i != n; ++i) xstats_ctrl->base[i] = counters[i]; + mlx5_read_ib_stat(priv, 17, &xstats_ctrl->imissed_base); } /** -- 2.7.4