From patchwork Fri Mar 12 17:48:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 12135639 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF4B9C433E0 for ; Fri, 12 Mar 2021 17:49:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C63464F29 for ; Fri, 12 Mar 2021 17:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232702AbhCLRtS (ORCPT ); Fri, 12 Mar 2021 12:49:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232768AbhCLRsy (ORCPT ); Fri, 12 Mar 2021 12:48:54 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 873FFC061574 for ; Fri, 12 Mar 2021 09:48:54 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id a8so5751062plp.13 for ; Fri, 12 Mar 2021 09:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=KyKOMMokP6jDQFUvlq0MosyUyH2Iv3Nr4lzzu8bCs5Y=; b=abMv9NZzVJbScw+4oOStB86EPYuPh5hQKe9I6rfFbT0Pm9/o6jVz/aApChnqIZz9Dc AZCJP1QlvqGXYFyoDUZLRY9zwb4KRT1eUMyz5PteWZM+mSoLTzajDw3oHrSgrMd2DUKQ OPyZgdNuBE86AKRFUzpOREL5EuMxqIj0tVNSnBhr3Hdd/Uy5ZyDidovF7Pc90nLEY+B0 8dIUtgtcoSZlhAxQJdX42EzN7pnZb66A8/rfX/lqC55Id//9iYF+mR9S0Jc9MqTQJVN+ Qaf0ujp1dItg/4klG68NTmyS9eUxDIreZVjdYmhScvB5w3u0GYVZ3v2RTslYhiQTkHXR mf+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=KyKOMMokP6jDQFUvlq0MosyUyH2Iv3Nr4lzzu8bCs5Y=; b=PRR/Pj0hSwp5A6fmXGxCFesdS8U0EByub02vq64J+Hl50HBVd0S+JQ+ReAMMeM/JHk uDQU1tA3hHLdPQRjaoM2f1STfkN/NfVDCRLjTMrmDuXyWzu9nY8o2As/CBRigRT+KSSy 6Hd6Mwj3qjaGVXKD/O94W7E1t/pHe5X/OFRFSc9qH3Fm7METRtOgQ6T/+n9FVrBLijF/ z7UCAvUvhUU/qqMpSeJssBlHi+bCgcljDB9kF9l2axRrvsYIPzU9/+Ak0eduPWTVr9zG vpwICYTExpB34oqa5A7KMlPtfqdCfJr7E2JwaROlnVL4UyJdTrvro+5r1A+eNXeXJbJ7 5CHg== X-Gm-Message-State: AOAM532QWlFvGzICTf2fI9DqfbURjO+ubqCoqZpKbM6oBVEVU8uCdjSQ 4PN/4IvD/iNUjH2x4cIgO6M= X-Google-Smtp-Source: ABdhPJy2/ZasrmQP/DD36QHTmioW14pkaI4HzgoAfCT6qy4y/aZY1pTkSmqpoi2zBWhgw0i1OQlXvA== X-Received: by 2002:a17:902:ee06:b029:e4:ba18:3726 with SMTP id z6-20020a170902ee06b02900e4ba183726mr179592plb.17.1615571334073; Fri, 12 Mar 2021 09:48:54 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id e63sm5991432pfe.208.2021.03.12.09.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:48:53 -0800 (PST) Subject: [net-next PATCH 08/10] vmxnet3: Update driver to use ethtool_sprintf From: Alexander Duyck To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, simon.horman@netronome.com, yisen.zhuang@huawei.com, salil.mehta@huawei.com, intel-wired-lan@lists.osuosl.org, jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, drivers@pensando.io, snelson@pensando.io, netanel@amazon.com, akiyano@amazon.com, gtzalik@amazon.com, saeedb@amazon.com, GR-Linux-NIC-Dev@marvell.com, skalluru@marvell.com, rmody@marvell.com, kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, mst@redhat.com, jasowang@redhat.com, pv-drivers@vmware.com, doshir@vmware.com, alexanderduyck@fb.com, Kernel-team@fb.com Date: Fri, 12 Mar 2021 09:48:52 -0800 Message-ID: <161557133283.10304.4658224540485154078.stgit@localhost.localdomain> In-Reply-To: <161557111604.10304.1798900949114188676.stgit@localhost.localdomain> References: <161557111604.10304.1798900949114188676.stgit@localhost.localdomain> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Alexander Duyck So this patch actually does 3 things. First it removes a stray white space at the start of the variable declaration in vmxnet3_get_strings. Second it flips the logic for the string test so that we exit immediately if we are not looking for the stats strings. Doing this we can avoid unnecessary indentation and line wrapping. Then finally it updates the code to use ethtool_sprintf rather than a memcpy and pointer increment to write the ethtool strings. Signed-off-by: Alexander Duyck --- drivers/net/vmxnet3/vmxnet3_ethtool.c | 53 ++++++++++++--------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index 7ec8652f2c26..c0bd9cbc43b1 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -218,43 +218,28 @@ vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) static void vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) { - struct vmxnet3_adapter *adapter = netdev_priv(netdev); - if (stringset == ETH_SS_STATS) { - int i, j; - for (j = 0; j < adapter->num_tx_queues; j++) { - for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) { - memcpy(buf, vmxnet3_tq_dev_stats[i].desc, - ETH_GSTRING_LEN); - buf += ETH_GSTRING_LEN; - } - for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); - i++) { - memcpy(buf, vmxnet3_tq_driver_stats[i].desc, - ETH_GSTRING_LEN); - buf += ETH_GSTRING_LEN; - } - } + struct vmxnet3_adapter *adapter = netdev_priv(netdev); + int i, j; - for (j = 0; j < adapter->num_rx_queues; j++) { - for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) { - memcpy(buf, vmxnet3_rq_dev_stats[i].desc, - ETH_GSTRING_LEN); - buf += ETH_GSTRING_LEN; - } - for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); - i++) { - memcpy(buf, vmxnet3_rq_driver_stats[i].desc, - ETH_GSTRING_LEN); - buf += ETH_GSTRING_LEN; - } - } + if (stringset != ETH_SS_STATS) + return; - for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) { - memcpy(buf, vmxnet3_global_stats[i].desc, - ETH_GSTRING_LEN); - buf += ETH_GSTRING_LEN; - } + for (j = 0; j < adapter->num_tx_queues; j++) { + for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) + ethtool_sprintf(&buf, vmxnet3_tq_dev_stats[i].desc); + for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) + ethtool_sprintf(&buf, vmxnet3_tq_driver_stats[i].desc); + } + + for (j = 0; j < adapter->num_rx_queues; j++) { + for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) + ethtool_sprintf(&buf, vmxnet3_rq_dev_stats[i].desc); + for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) + ethtool_sprintf(&buf, vmxnet3_rq_driver_stats[i].desc); } + + for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) + ethtool_sprintf(&buf, vmxnet3_global_stats[i].desc); } netdev_features_t vmxnet3_fix_features(struct net_device *netdev,