From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id B2A47A0471 for ; Fri, 21 Jun 2019 00:09:50 +0200 (CEST) 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 Content-Transfer-Encoding: 8bit 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); } -- 2.20.1