From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B3116A046B for ; Thu, 27 Jun 2019 00:22:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CDBB72C28; Thu, 27 Jun 2019 00:21:50 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id A15C62BE5 for ; Thu, 27 Jun 2019 00:21:47 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id g4so106080plb.5 for ; Wed, 26 Jun 2019 15:21:47 -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=C2Tnk++tde2KjvyzAagIkGGuI7D/Kkk0+x5at3unx6o=; b=Z9FYPZCohxAISy6XOsMp+UOOhwDZNfKClN1/WsG3S6eReqEvllJc2WtRqFq0DnwTmJ szT8Z6EA3OHkG8qhUzfRQgr06NuH2xkarEZiVqCm6huc/HV8UCzkWQhdNbVCfMtwVG+D dcCxrEAkXoIkw6xGoUfYYTk1Gs8Y2tNFgRYhBlSk+4ho1VmvciKfe86zvduQm92EoALx wokHEf9/QG+WJ6Q3grTsr/uM80tw0NhioPGHI6kavAtxcP+YXti81oYdZoD0jKggVyVe 0fXc0XuQrGRv/jfmMFN+KRDuIZSFoB9wPDaPBZe566He6FEQqVUqPO4jXAHllQhPeb8a EPrg== 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=C2Tnk++tde2KjvyzAagIkGGuI7D/Kkk0+x5at3unx6o=; b=F1SCXL6np23/S7L4Ecar9NLG7mCPJwGM5CKLpioyjv5l7dkcOk96PhpfFubGEu6nKE Chq1kxJvUf6qwPSKpMkRGdn9v9THYyBGA7NQc1qrfzFr+zV3UxNq0i3cyeLOgrZKzfEU g41BMlgV7b9F1Hd1hkxMESctmiiTUApQdl+ApEnUdvQw9YFjpU17Fj9bFhWT7tiOgJhA r0yeJG66WvobhB6XArSEAUa/zBCKnzfc9/jBuaXX7VflElXc4MvwbztA6D44uSU2lVFw A2YpYzzAdhn52nAsaKvzRPZdJl/36Hx/+bSpux26ohDSxUd5CBrfJQ2A8WyJi8LCwuwz 2xiQ== X-Gm-Message-State: APjAAAUyJq0Gu3qkIp7CCmcvlC0HnKibB5n47r41/6X1NJAKP3Jsvr4X ibEyl+f4jyGGgkh/Fem6lFUwbA== X-Google-Smtp-Source: APXvYqwTU2PCBDgPY+6dtvGYhQhw5kBC//4sJ0jBGTHb414b2ItnjdhvsSdYmZ/AyvUH5NyHL2fOlA== X-Received: by 2002:a17:902:e211:: with SMTP id ce17mr443753plb.193.1561587706807; Wed, 26 Jun 2019 15:21:46 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d5sm266114pfn.25.2019.06.26.15.21.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 15:21:45 -0700 (PDT) From: Stephen Hemminger To: gaetan.rivet@6wind.com Cc: dev@dpdk.org, Stephen Hemminger Date: Wed, 26 Jun 2019 15:21:35 -0700 Message-Id: <20190626222135.11368-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626222135.11368-1-stephen@networkplumber.org> References: <20190626222135.11368-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/2] failsafe: implement xstats 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: Stephen Hemminger Add support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device. Signed-off-by: Stephen Hemminger --- drivers/net/failsafe/failsafe_ops.c | 144 ++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 96e05d4dc4b1..9ab32457983d 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -789,6 +789,147 @@ fs_stats_reset(struct rte_eth_dev *dev) fs_unlock(dev, 0); } +static int +fs_xstats_count(struct rte_eth_dev *dev) +{ + struct sub_device *sdev; + int r, count; + uint8_t i; + + count = rte_eth_basic_stats_count(dev); + + fs_lock(dev, 0); + FOREACH_SUBDEV(sdev, i, dev) { + if (sdev->state < DEV_ACTIVE) + continue; + + r = rte_eth_xstats_get_names(PORT_ID(sdev), NULL, 0); + if (r < 0) { + fs_unlock(dev, 0); + return r; + } + + count += r; + } + fs_unlock(dev, 0); + + return count; +} + +static int +fs_xstats_get_names(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit) +{ + struct sub_device *sdev; + unsigned int count; + uint8_t i; + char tmp[RTE_ETH_XSTATS_NAME_SIZE]; + int j,r; + + if (!xstats_names) + return fs_xstats_count(dev); + + r = rte_eth_basic_stats_get_names(dev, xstats_names); + if (r < 0) + return r; + + count = r; + + fs_lock(dev, 0); + FOREACH_SUBDEV(sdev, i, dev) { + struct rte_eth_xstat_name *sub_names = xstats_names + count; + + if (sdev->state < DEV_ACTIVE) + continue; + + if (count >= limit) + break; + + r = rte_eth_xstats_get_names(PORT_ID(sdev), sub_names, + count < limit ? limit - count: 0); + if (r < 0) { + fs_unlock(dev, 0); + return r; + } + + /* add sub_ prefix to names */ + for (j = 0; j < r; j++) { + snprintf(tmp, sizeof(tmp), "sub%u_%s", + i, sub_names[j].name); + memcpy(sub_names[j].name, tmp, + RTE_ETH_XSTATS_NAME_SIZE); + } + + count += r; + } + fs_unlock(dev, 0); + + return count; +} + +static int +fs_xstats_get(struct rte_eth_dev *dev, + struct rte_eth_xstat *xstats, + unsigned int n) +{ + unsigned int nstats, j, count, scount; + struct sub_device *sdev; + uint8_t i; + int ret; + + nstats = fs_xstats_count(dev); + if (n < nstats || xstats == NULL) + return nstats; + + ret = rte_eth_basic_stats_get(dev->data->port_id, xstats); + if (ret < 0) + return ret; + + count = ret; + for (j = 0; j < count; j++) + xstats[j].id = j; + + fs_lock(dev, 0); + FOREACH_SUBDEV(sdev, i, dev) { + if (sdev->state < DEV_ACTIVE) + continue; + + ret = rte_eth_xstats_get(PORT_ID(sdev), + xstats + count, + n > count ? n - count : 0); + if (ret < 0) { + fs_unlock(dev, 0); + return ret; + } + scount = ret; + + /* add offset to id's from sub-device */ + for (j = 0; j < scount; j++) + xstats[count + j].id += count; + + count += scount; + } + fs_unlock(dev, 0); + + return count; +} + +static void +fs_xstats_reset(struct rte_eth_dev *dev) +{ + struct sub_device *sdev; + uint8_t i; + + rte_eth_stats_reset(dev->data->port_id); + + fs_lock(dev, 0); + FOREACH_SUBDEV(sdev, i, dev) { + rte_eth_xstats_reset(PORT_ID(sdev)); + } + fs_unlock(dev, 0); +} + static void fs_dev_merge_desc_lim(struct rte_eth_desc_lim *to, const struct rte_eth_desc_lim *from) @@ -1233,6 +1374,9 @@ const struct eth_dev_ops failsafe_ops = { .link_update = fs_link_update, .stats_get = fs_stats_get, .stats_reset = fs_stats_reset, + .xstats_get = fs_xstats_get, + .xstats_get_names = fs_xstats_get_names, + .xstats_reset = fs_xstats_reset, .dev_infos_get = fs_dev_infos_get, .dev_supported_ptypes_get = fs_dev_supported_ptypes_get, .mtu_set = fs_mtu_set, -- 2.20.1