From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7771BA04FF; Tue, 22 Mar 2022 10:26:20 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2EA8427F2; Tue, 22 Mar 2022 10:26:15 +0100 (CET) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mails.dpdk.org (Postfix) with ESMTP id 422DA4067B for ; Thu, 17 Mar 2022 14:24:40 +0100 (CET) Received: by mail-wm1-f52.google.com with SMTP id p184-20020a1c29c1000000b0037f76d8b484so3143592wmp.5 for ; Thu, 17 Mar 2022 06:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uRMe2+f3xWGJHp/e71yR/M6/XPkgR0qMwtL2kVtM61o=; b=FyTajzMJ4Udq08yM9P+qhItlHR24V7lD4kUg5RW1puz+eQD/YkXWFSrp+dSFsyuKL4 fGfHbdBgJ8YNj58cWNpqsCpCt2uL0UHW+NORGM43Kx9slWF09dkiXuO15GrojQx4TSWQ HXCQo9QAbgKs6qL3klzGuofn3QAON6RURRgne/8pFW8JluFY7YTiSryUdYMx+5AxmeXM 0oUhDC4TJBn9Gzyb+8NvjsD/0IcuWSZadZEnQwY668JHQlIaHeXXYLQeZYDvZ8y708lp GM7678b27Rb86XI/SEtFmaVSeaiC+DQnNZFMfRvv2xMRfW4Csbpc7vxennvmIcO+B9fn yJug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uRMe2+f3xWGJHp/e71yR/M6/XPkgR0qMwtL2kVtM61o=; b=fhoCOND5oYsRZswnAAAanjemjW0v50kUqaS+2ZBhJoHJI/9bvoJsi0Eu/5pNkQI0y7 WUYwVLpVznzuf47VXlGhpQWLj5N5sGqXV3O8pNb0tLYXqtb9nCpMo5xxkQBPeud10olf XTHiAQzaQSKb/oLYgCvxoRady/g7W4idzMr+6XNRNV8WzD2KBSppjjWLY5xL9WQZL1lJ vlnxEYHQjcfAVqZvgIJaH+4pzMcEs3DgYjcUbqNfG/GYVQ1aNc/79CtbGWejmIPrTMiU kthKjl7taeCdoX8zkIvaClHRzQhtF7n6JAee2D3SsbwQNOfKUsTuLRnXYq8tIyQxvUeA 4mmA== X-Gm-Message-State: AOAM530A8VL/kGHEGeBM3JCEL/qoIrPd6AH/g+5siG1dcPI+EKmDhLIm WsVhFGwxoE/OEifufe5HlEfJplrSIFMiww== X-Google-Smtp-Source: ABdhPJzr9JhsEza4BE2UBfZBtmuJzndLjnk2iudBr757dyw6LfeuZSrjXhox78uvVm77hZEWJbFvVw== X-Received: by 2002:a05:600c:1909:b0:389:ee24:caf6 with SMTP id j9-20020a05600c190900b00389ee24caf6mr12020941wmq.158.1647523480013; Thu, 17 Mar 2022 06:24:40 -0700 (PDT) Received: from extreme.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id w7-20020a1cf607000000b00389a5390180sm4159330wmc.25.2022.03.17.06.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 06:24:39 -0700 (PDT) From: =?UTF-8?q?Geoffrey=20Le=20Gourri=C3=A9rec?= To: dev@dpdk.org Cc: Didier Pallard , Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH] net/mlx5: fix linux stats gathering function Date: Thu, 17 Mar 2022 14:23:48 +0100 Message-Id: <20220317132348.30240-1-geoffrey.le_gourrierec@6wind.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 22 Mar 2022 10:26:13 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch encompasses a few fixes carried by a previous patch that aimed to support bonding device stats counting. - If mlx5_os_read_dev_stat fails, it returns 1 instead of a negative value, causing mlx5_xstats_get to return an invalid number of counters. Since this error is not blocking, do not mess ret value with mlx5_os_read_dev_stat returned value. This allows avoiding the very annoying log: "n_xstats != n_xstats_names => skipping" - Invert the check for mlx5_os_read_dev_stat(), currently leading us to store the result if the function failed, and use a backup value if it succeeded, which is the opposite of what we actually want. Revert to the original (correct) test. - Add missing test on _mlx5_os_read_dev_counters() to prevent using trash stats values. Fixes: 7ed15acdcd69 ("net/mlx5: improve xstats of bonding port") Signed-off-by: Didier Pallard Signed-off-by: Geoffrey Le GourriƩrec --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 8fe73f1adb58..b5819cc656ff 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1386,15 +1386,16 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats) } } else { ret = _mlx5_os_read_dev_counters(dev, -1, stats); + if (ret) + return ret; } /* Read IB counters. */ for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) { if (!xstats_ctrl->info[i].dev) continue; - ret = mlx5_os_read_dev_stat(priv, xstats_ctrl->info[i].ctr_name, - &stats[i]); /* return last xstats counter if fail to read. */ - if (ret != 0) + if (mlx5_os_read_dev_stat(priv, xstats_ctrl->info[i].ctr_name, + &stats[i]) == 0) xstats_ctrl->xstats[i] = stats[i]; else stats[i] = xstats_ctrl->xstats[i]; -- 2.30.2