From patchwork Thu Sep 12 12:25:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1161560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="N72w1I8q"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46TdKG50qNz9s4Y for ; Thu, 12 Sep 2019 22:25:53 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CAE29DB7; Thu, 12 Sep 2019 12:25:51 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 0917FDB6 for ; Thu, 12 Sep 2019 12:25:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2AEC089B for ; Thu, 12 Sep 2019 12:25:49 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190912122548euoutp020d5db8d8ac433db6fd6d7dc805b66e2c~DsH10WGD61015510155euoutp02J for ; Thu, 12 Sep 2019 12:25:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190912122548euoutp020d5db8d8ac433db6fd6d7dc805b66e2c~DsH10WGD61015510155euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1568291148; bh=ynHcY3tWyx4tUG6LgS8FT0rsxO5AJwVBIdbgOvugVmg=; h=From:To:Cc:Subject:Date:References:From; b=N72w1I8qo+B4f6hnbauTw3QXlr5WHvm2BepW+zZHRMnsbTpxuySdarK6Op9CXrV2k wgJnlOEfoXxgx9wBJOmVo9LUOjo/8aZlakZ3THBzYSm3aixwCjxj5ik32gsYsSQi+l pWAevok3VJshWBHQze5QGLxvAjvff+h2zgcqy4hI= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190912122547eucas1p1921afd678285e4d273f6f49a2dffeb6d~DsH1WH0NH0621206212eucas1p1p; Thu, 12 Sep 2019 12:25:47 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 28.4E.04469.B493A7D5; Thu, 12 Sep 2019 13:25:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190912122546eucas1p16c66054fbe6a67940c72bafc7e72ea48~DsH0oLzmi0623006230eucas1p1t; Thu, 12 Sep 2019 12:25:46 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190912122546eusmtrp1eb1ae26bf6c8cd2a6b6dc003c2f7258a~DsH0Z8r6P1741817418eusmtrp1c; Thu, 12 Sep 2019 12:25:46 +0000 (GMT) X-AuditID: cbfec7f2-569ff70000001175-65-5d7a394bf57a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9C.97.04166.A493A7D5; Thu, 12 Sep 2019 13:25:46 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190912122546eusmtip22f99229f5982681179855d6346bd4d06~DsHz4o6kB1110511105eusmtip24; Thu, 12 Sep 2019 12:25:45 +0000 (GMT) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Thu, 12 Sep 2019 15:25:41 +0300 Message-Id: <20190912122541.13762-1-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEIsWRmVeSWpSXmKPExsWy7djPc7rellWxBr2PRSy2r+his7j7vIHJ 4kr7T3aLjQ/PslqsPfSB3WLup+eMFjfn7mZ1YPfY3LOXyWPxnpdMHs9u/mf0eH6th8Xj/b6r bB59W1YxBrBFcdmkpOZklqUW6dslcGX8uDmLveC8ScWKexPYGhg71LoYOTkkBEwkTsxrZgGx hQRWMEocP+PWxcgFZH9hlLj9bTobhPOZUWLj6x/sMB2/Ny9mhOhYzihxZLs+RNEPRolZ8+6x gSTYBHQkTq0+AlYkIiAt8br3DStIEbPAd0aJdYeuge0TFvCXuDLnNSuIzSKgKvF6/UugZg4O XgFrifUTuCCWyUus3nCAGaRXQuA+m0TP0WNsEAkXiXVr50BdJCzx6vgWKFtG4vTkHhYIu17i fstLRojmDkaJ6Yf+MUEk7CW2vD7HDrKMWUBTYv0ufYiwo8S5lS/AbpAQ4JO48VYQJMwMZE7a Np0ZIswr0dEmBFGtIvH74HJmCFtK4ua7z1AXeEjcfXWNFaRcSCBW4uh/5gmMcrMQVi1gZFzF KJ5aWpybnlpsmJdarlecmFtcmpeul5yfu4kRmBJO/zv+aQfj10tJhxgFOBiVeHgtdKpihVgT y4orcw8xSnAwK4nw+rypjBXiTUmsrEotyo8vKs1JLT7EKM3B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X-CMS-MailID: 20190912122546eucas1p16c66054fbe6a67940c72bafc7e72ea48 X-Msg-Generator: CA X-RootMTR: 20190912122546eucas1p16c66054fbe6a67940c72bafc7e72ea48 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190912122546eucas1p16c66054fbe6a67940c72bafc7e72ea48 References: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets , Ilya Maximets , David Marchand Subject: [ovs-dev] [PATCH] netdev-dpdk: Reuse vhost function for dpdk ETH custom stats. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This is yet another refactoring for upcoming detailed drop stats. It allowes to use single function for all the software calculated statistics in netdev-dpdk for both vhost and ETH ports. UINT64_MAX used as a marker for non-supported statistics in a same way as it's done in bridge.c for common netdev stats. Cc: Sriram Vatala Signed-off-by: Ilya Maximets --- Sriram, you could rebase your patch on top of this and send both patches as a patch-set. So the changes will be logically splitted. If you're using 'git format-patch' + 'git send-email' it should preserve authorship correctly. If you'll need some additional changes in this patch, you could amend them along with mentioning yourself as co-author. lib/netdev-dpdk.c | 67 +++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index bc20d6843..652b57e3b 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -471,6 +471,8 @@ struct netdev_rxq_dpdk { static void netdev_dpdk_destruct(struct netdev *netdev); static void netdev_dpdk_vhost_destruct(struct netdev *netdev); +static int netdev_dpdk_get_sw_custom_stats(const struct netdev *, + struct netdev_custom_stats *); static void netdev_dpdk_clear_xstats(struct netdev_dpdk *dev); int netdev_dpdk_get_vid(const struct netdev_dpdk *dev); @@ -1171,7 +1173,7 @@ common_construct(struct netdev *netdev, dpdk_port_t port_no, dev->rte_xstats_ids = NULL; dev->rte_xstats_ids_size = 0; - dev->tx_retries = 0; + dev->tx_retries = (dev->type == DPDK_DEV_VHOST) ? 0 : UINT64_MAX; return 0; } @@ -2771,7 +2773,9 @@ netdev_dpdk_get_custom_stats(const struct netdev *netdev, uint32_t i; struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); - int rte_xstats_ret; + int rte_xstats_ret, sw_stats_size; + + netdev_dpdk_get_sw_custom_stats(netdev, custom_stats); ovs_mutex_lock(&dev->mutex); @@ -2786,12 +2790,13 @@ netdev_dpdk_get_custom_stats(const struct netdev *netdev, if (rte_xstats_ret > 0 && rte_xstats_ret <= dev->rte_xstats_ids_size) { - custom_stats->size = rte_xstats_ret; - custom_stats->counters = - (struct netdev_custom_counter *) xcalloc(rte_xstats_ret, - sizeof(struct netdev_custom_counter)); + sw_stats_size = custom_stats->size; + custom_stats->size += rte_xstats_ret; + custom_stats->counters = xrealloc(custom_stats->counters, + custom_stats->size * + sizeof *custom_stats->counters); - for (i = 0; i < rte_xstats_ret; i++) { + for (i = sw_stats_size; i < sw_stats_size + rte_xstats_ret; i++) { ovs_strlcpy(custom_stats->counters[i].name, netdev_dpdk_get_xstat_name(dev, dev->rte_xstats_ids[i]), @@ -2801,8 +2806,6 @@ netdev_dpdk_get_custom_stats(const struct netdev *netdev, } else { VLOG_WARN("Cannot get XSTATS values for port: "DPDK_PORT_ID_FMT, dev->port_id); - custom_stats->counters = NULL; - custom_stats->size = 0; /* Let's clear statistics cache, so it will be * reconfigured */ netdev_dpdk_clear_xstats(dev); @@ -2817,39 +2820,47 @@ netdev_dpdk_get_custom_stats(const struct netdev *netdev, } static int -netdev_dpdk_vhost_get_custom_stats(const struct netdev *netdev, - struct netdev_custom_stats *custom_stats) +netdev_dpdk_get_sw_custom_stats(const struct netdev *netdev, + struct netdev_custom_stats *custom_stats) { struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); - int i; + int i, n; -#define VHOST_CSTATS \ - VHOST_CSTAT(tx_retries) +#define SW_CSTATS \ + SW_CSTAT(tx_retries) -#define VHOST_CSTAT(NAME) + 1 - custom_stats->size = VHOST_CSTATS; -#undef VHOST_CSTAT +#define SW_CSTAT(NAME) + 1 + custom_stats->size = SW_CSTATS; +#undef SW_CSTAT custom_stats->counters = xcalloc(custom_stats->size, sizeof *custom_stats->counters); - i = 0; -#define VHOST_CSTAT(NAME) \ - ovs_strlcpy(custom_stats->counters[i++].name, #NAME, \ - NETDEV_CUSTOM_STATS_NAME_SIZE); - VHOST_CSTATS; -#undef VHOST_CSTAT ovs_mutex_lock(&dev->mutex); rte_spinlock_lock(&dev->stats_lock); i = 0; -#define VHOST_CSTAT(NAME) \ +#define SW_CSTAT(NAME) \ custom_stats->counters[i++].value = dev->NAME; - VHOST_CSTATS; -#undef VHOST_CSTAT + SW_CSTATS; +#undef SW_CSTAT rte_spinlock_unlock(&dev->stats_lock); ovs_mutex_unlock(&dev->mutex); + i = 0; + n = 0; +#define SW_CSTAT(NAME) \ + if (custom_stats->counters[i].value != UINT64_MAX) { \ + ovs_strlcpy(custom_stats->counters[n].name, #NAME, \ + NETDEV_CUSTOM_STATS_NAME_SIZE); \ + custom_stats->counters[n].value = custom_stats->counters[i].value; \ + n++; \ + } \ + i++; + SW_CSTATS; +#undef SW_CSTAT + + custom_stats->size = n; return 0; } @@ -4433,7 +4444,7 @@ static const struct netdev_class dpdk_vhost_class = { .send = netdev_dpdk_vhost_send, .get_carrier = netdev_dpdk_vhost_get_carrier, .get_stats = netdev_dpdk_vhost_get_stats, - .get_custom_stats = netdev_dpdk_vhost_get_custom_stats, + .get_custom_stats = netdev_dpdk_get_sw_custom_stats, .get_status = netdev_dpdk_vhost_user_get_status, .reconfigure = netdev_dpdk_vhost_reconfigure, .rxq_recv = netdev_dpdk_vhost_rxq_recv, @@ -4449,7 +4460,7 @@ static const struct netdev_class dpdk_vhost_client_class = { .send = netdev_dpdk_vhost_send, .get_carrier = netdev_dpdk_vhost_get_carrier, .get_stats = netdev_dpdk_vhost_get_stats, - .get_custom_stats = netdev_dpdk_vhost_get_custom_stats, + .get_custom_stats = netdev_dpdk_get_sw_custom_stats, .get_status = netdev_dpdk_vhost_user_get_status, .reconfigure = netdev_dpdk_vhost_client_reconfigure, .rxq_recv = netdev_dpdk_vhost_rxq_recv,