From patchwork Thu Jun 20 22:09:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55144 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 330EC1D4AF; Fri, 21 Jun 2019 00:09:37 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 066331D481 for ; Fri, 21 Jun 2019 00:09:33 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id y72so2285168pgd.8 for ; Thu, 20 Jun 2019 15:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y/ZXdhwUbaEMPMe2JVJMstAKCzj9cCnJEbZRHQabYo4=; b=wH47CbI8mtSK342WcHejbZq4JADWbPE1xQRkuLy9Jy35NvCCPirrjcmUV7PYGKF7l8 W2EtxmqxDG1XNUpzrBtx/3F7ZAR0dKJIYZ41EIXI85ouxUgGkHVQq7SJWkXUO5XdKK9D 9V0vlJIEThXpVGcvzsLyKDlEL13bLRB/mTb65Tj3olRANPhZNP5b8vNkcTScadTXaczD omYeu3HPz/Nc6pTBMk1Hzq8w4tTNZpzPBriogQO4MkfIwtAsy0K3JUf0sqk8tvyDc9/6 dcglXCwIPMSDH+NFsPQA+K6zIdW/kTfNlJW5A4fSx1ne6o28qkOvTyBKogr9rMc1ePct ASUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y/ZXdhwUbaEMPMe2JVJMstAKCzj9cCnJEbZRHQabYo4=; b=Upx4ubW1E11EBBHYpGUfFvBcKoJ633gQMmLfTMVxNlLp4Fz8H+GC6nSUc4FIJHiFpw BtxoF/s2sneLDtOQWiiA1ZTEqi6gkjc1THqIrniYm9O5JQJ69mh4aNqRRCKOK/ILGXuG HHqO+35M23NLwMyconO6ESCkCuK2shytEfjzSdnrRk08aiUHlmbqK17zj0WFe38X90DN //TZlZ8psVjBKBvo3NDYY/vSimC7dJDpQxpDgfTMFEc+ssdDa5ssg4qaEX51wi6hBsGO Ck4BVDdCcZySrL7+JeRC/13w5DIMw2sLhzVOgaWPLcYH/QdRxaFmeIiZNAztbxlvak4+ R08g== X-Gm-Message-State: APjAAAXaplEvFya/0U0yDtseg/b1IpueP62TcRNIFks2LnaKbyGE2V2X Nd5qfvTty5xSu3Bf3jKJ8DWVVj8D1eI= X-Google-Smtp-Source: APXvYqxHTW4XzRtBlVEbCU7SoguHAzoRXsuQCJPrU3FRFKPXnbdeQfaWBYNpYZNPgRRYI7nJ/BXJWw== X-Received: by 2002:a65:620a:: with SMTP id d10mr14751665pgv.42.1561068571836; Thu, 20 Jun 2019 15:09:31 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id y12sm422226pfn.187.2019.06.20.15.09.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 15:09:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: stable@dpdk.org, Mohsin Mazhar Shaikh , Stephen Hemminger Date: Thu, 20 Jun 2019 15:09:23 -0700 Message-Id: <20190620220924.32079-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620220924.32079-1-stephen@networkplumber.org> References: <20190620220924.32079-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/2] net/netvsc: set id in xstats_get 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" From: Mohsin Mazhar Shaikh The xstats_get was not setting id correctly for each entry. Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") Signed-off-by: Mohsin Mazhar Shaikh Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 9e7cf2df5472..d37db7c6a232 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -577,9 +577,11 @@ hn_dev_xstats_get(struct rte_eth_dev *dev, continue; stats = (const char *)&txq->stats; - for (t = 0; t < RTE_DIM(hn_stat_strings); t++) - xstats[count++].value = *(const uint64_t *) + for (t = 0; t < RTE_DIM(hn_stat_strings); t++, count++) { + xstats[count].id = count; + xstats[count].value = *(const uint64_t *) (stats + hn_stat_strings[t].offset); + } } for (i = 0; i < dev->data->nb_rx_queues; i++) { @@ -589,9 +591,11 @@ hn_dev_xstats_get(struct rte_eth_dev *dev, continue; stats = (const char *)&rxq->stats; - for (t = 0; t < RTE_DIM(hn_stat_strings); t++) - xstats[count++].value = *(const uint64_t *) + for (t = 0; t < RTE_DIM(hn_stat_strings); t++, count++) { + xstats[count].id = count; + xstats[count].value = *(const uint64_t *) (stats + hn_stat_strings[t].offset); + } } ret = hn_vf_xstats_get(dev, xstats + count, n - count); From patchwork Thu Jun 20 22:09:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55145 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4663E1D4B9; Fri, 21 Jun 2019 00:09:39 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 61CC51D4A4 for ; Fri, 21 Jun 2019 00:09:34 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id r1so2427271pfq.12 for ; Thu, 20 Jun 2019 15:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=31KiY49ADPgIgutfL4dOVmEFHnvBXuq6MNhrX3o5lc0=; b=qM/FOJlgkwIlv3Vr4F7KRXyJO5kxAcllYQjqMnlvGSlZJ6eUOPY1sRyNySbXPx+BSe MUvvyMOJ3NL3rJspmm3EYqLgXY+FNg2r8nYZSuduA1Kxx2txtuYbAiKtA6T2gh9pJEZW 88SyStmok3NoqDmTsahHvy/Z1OhrjXamDkxuZSQ5fUTfyGz55/6n0BMoKXhdVkePDDdV eHSt6x9xADCi5ndtLfzBj6U3NHAM9YkWoiQ1xwcqAq62NZyUinZHWBQWFJborMYoWBJw RIulzL2pHQ5I1s34Fb/DQezh+AoiH2e9WRDttsd7KyzfK45UyPiUlwswOyc++KSTYiLj TSAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=31KiY49ADPgIgutfL4dOVmEFHnvBXuq6MNhrX3o5lc0=; b=eQKQk/3/E8tFUvsx0DlNbU2Ht2AYbG/X48zgm/mBiAA9GGIZ0AMi/SjQzJrGqyF9tI WP3VfyJGL1EaHB00pOimPvHqSvychtC/eLy4KX8vxFusRFuuO/zvRto5e0MOjsrpI0sN MFHp98yCsaXChDkXCBHxjAprnoUfDSOP96DwB8QCANRJKLAckvwCc4Epld5fQyL03t64 jDC7tDbj1hCEFGF3NbWZj/lUR50LBaKyFZBAjER0I9boek9SBWpc0X2nHdZxgXHNi/7J VSoMFSmN7R8SrzrX2o10Iw5y9KA9O5wF3pjR461rj7huY8WpG3568OCnQb9dAsBDlkJu IOag== X-Gm-Message-State: APjAAAU5CWuIFRUu/+bcyjmsXVdIEZaomy41VYgVzk51JeM1r/cHDngW bjRSFczT0eoYXZtq2AvjBWN7rZ5aytk= X-Google-Smtp-Source: APXvYqyMG9Mi3OEyFk7dzuTk2ICXYkj/PX8CmJyu5ity5ie5eLAqkd22fv62hW2UKE+/MV1c1LoJZQ== X-Received: by 2002:a63:231a:: with SMTP id j26mr14473025pgj.389.1561068573307; Thu, 20 Jun 2019 15:09:33 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id y12sm422226pfn.187.2019.06.20.15.09.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 15:09:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: stable@dpdk.org, Stephen Hemminger Date: Thu, 20 Jun 2019 15:09:24 -0700 Message-Id: <20190620220924.32079-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620220924.32079-1-stephen@networkplumber.org> References: <20190620220924.32079-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/2] net/netvsc: fix xstats for VF device 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" The id values for VF stats were not being offset correctly. And getting xstats for VF device only worked if VF device supported it; it did not support the generic stats. Fixes: dc7680e8597c ("net/netvsc: support integrated VF") Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 2 +- drivers/net/netvsc/hn_var.h | 2 +- drivers/net/netvsc/hn_vf.c | 26 ++++++++++++++++++-------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index d37db7c6a232..2b1b2ba3b845 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -598,7 +598,7 @@ hn_dev_xstats_get(struct rte_eth_dev *dev, } } - ret = hn_vf_xstats_get(dev, xstats + count, n - count); + ret = hn_vf_xstats_get(dev, xstats, count, n); if (ret < 0) return ret; diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index bf94d90a7635..be657af0982a 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -237,5 +237,5 @@ int hn_vf_xstats_get_names(struct rte_eth_dev *dev, unsigned int size); int hn_vf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - unsigned int n); + unsigned int offset, unsigned int n); void hn_vf_xstats_reset(struct rte_eth_dev *dev); diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index 27ac87e7e975..3a833d447ac1 100644 --- a/drivers/net/netvsc/hn_vf.c +++ b/drivers/net/netvsc/hn_vf.c @@ -506,17 +506,19 @@ int hn_vf_xstats_get_names(struct rte_eth_dev *dev, struct hn_data *hv = dev->data->dev_private; struct rte_eth_dev *vf_dev; int i, count = 0; - char tmp[RTE_ETH_XSTATS_NAME_SIZE]; rte_spinlock_lock(&hv->vf_lock); vf_dev = hn_get_vf_dev(hv); - if (vf_dev && vf_dev->dev_ops->xstats_get_names) - count = vf_dev->dev_ops->xstats_get_names(vf_dev, names, n); + if (vf_dev) + count = rte_eth_xstats_get_names(vf_dev->data->port_id, + names, n); rte_spinlock_unlock(&hv->vf_lock); /* add vf_ prefix to xstat names */ if (names) { for (i = 0; i < count; i++) { + char tmp[RTE_ETH_XSTATS_NAME_SIZE]; + snprintf(tmp, sizeof(tmp), "vf_%s", names[i].name); strlcpy(names[i].name, tmp, sizeof(names[i].name)); } @@ -527,18 +529,26 @@ int hn_vf_xstats_get_names(struct rte_eth_dev *dev, int hn_vf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + unsigned int offset, unsigned int n) { struct hn_data *hv = dev->data->dev_private; struct rte_eth_dev *vf_dev; - int count = 0; + int i, count = 0; rte_spinlock_lock(&hv->vf_lock); vf_dev = hn_get_vf_dev(hv); - if (vf_dev && vf_dev->dev_ops->xstats_get) - count = vf_dev->dev_ops->xstats_get(vf_dev, xstats, n); + if (vf_dev) + count = rte_eth_xstats_get(vf_dev->data->port_id, + xstats + offset, n - offset); rte_spinlock_unlock(&hv->vf_lock); + /* Offset id's for VF stats */ + if (count > 0) { + for (i = 0; i < count; i++) + xstats[i + offset].id += offset; + } + return count; } @@ -549,7 +559,7 @@ void hn_vf_xstats_reset(struct rte_eth_dev *dev) rte_spinlock_lock(&hv->vf_lock); vf_dev = hn_get_vf_dev(hv); - if (vf_dev && vf_dev->dev_ops->xstats_reset) - vf_dev->dev_ops->xstats_reset(vf_dev); + if (vf_dev) + rte_eth_xstats_reset(vf_dev->data->port_id); rte_spinlock_unlock(&hv->vf_lock); }