Message ID | 20230621092350.3130866-5-msp@baylibre.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4233772vqr; Wed, 21 Jun 2023 02:31:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Xznb+gNwoaWNVhEIXmuapLh/V4AYpRtxeX9cyJMOKqh6DZgj2LldmcUZnugzkJCg7Q2iE X-Received: by 2002:a05:6808:5d3:b0:397:f2bb:b26e with SMTP id d19-20020a05680805d300b00397f2bbb26emr6576617oij.34.1687339902614; Wed, 21 Jun 2023 02:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687339902; cv=none; d=google.com; s=arc-20160816; b=gWh2O/jk93UXovcXxpoSR8CbwmB6lvHTSfZ87GGdgdc0YU3YuHTrR2r3RST58mF9bC AT4h2PQaT8eV+3dLWGuYMZd34VxHzvy5lZpW4XQB5EjpvLxtwlRi7OPV1Cs/cRq+Iigu rYUh7S9PykyVDBcWQVb9e20v3nQPETytPb+QD6euDp1ugFKpTrSep2XMs0S6usfIPAI1 sNKLdDKZj/9cQbkjmDs9K6c2lBR+XMMvVYKC/gMA3zVKYBoicU4lXRAjip21mehKSDvf mdGEAMXD31q9Enet1vrT5YYOYljVXySaGBSCNMDG4JzOCNxtshwlw2qa/gvbI21oPBUs ZVSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hZrlIC4UOKpv9upRfhGvF2jtmIJyO/l6blnJN/Kvfh8=; b=XEMfC27OSiYP+LSekk0Cqy3/Z9eCJFARrJzTjWHsEkNs3of5hjEPUN1vN9ELGTMARK 14dLeQ2A/k5LDWLLmoTHfZD0HTD2++tHhOFrG/A4qRkzfe+G/D8w4Ktti2B4H5nf/44w iHlckta9JREFEZdWn8t7SZ4xwU1KodS+XXXO2JPL0XSwUt8lFEaCjpFl66JQuMuNMj/t hw2TZEMMDL7Y6uOL9P0/PyoP5gYO1s7X5Zi29J/+7opcw2FS30IM2ffEJ/OfM7IUCXej BrCddnnTWRzFsk5zleyOlQfePeBQVVmQ6pezcY7thq2hBmVUHhuO3dQ7OE8rBR+abboT 6j3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=5AJVy31q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a63b211000000b005538bf65e5bsi37950pge.435.2023.06.21.02.31.28; Wed, 21 Jun 2023 02:31:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=5AJVy31q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbjFUJYm (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Wed, 21 Jun 2023 05:24:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbjFUJYU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 21 Jun 2023 05:24:20 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A90A61FC6 for <linux-kernel@vger.kernel.org>; Wed, 21 Jun 2023 02:24:01 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31121494630so6561177f8f.3 for <linux-kernel@vger.kernel.org>; Wed, 21 Jun 2023 02:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339440; x=1689931440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hZrlIC4UOKpv9upRfhGvF2jtmIJyO/l6blnJN/Kvfh8=; b=5AJVy31qidMPxttaXsZUnYinlqnN0ERHOCEPlFbpjhFQL0d2YW5FREmg5TuJvUv2zo ecphYqOVzQxJJgvfgN5yoHmX9CrOqcIEYtbUk3uS39swqBrpXxvulFYG5DWRE5729iQZ 3FzNnptBBB/Pk+4DuPLO5YoRsA8Durq9oiW1ETBphaiHhSQ06U2920rL8Lk+SYNOSCzb AUTywM8/yoxyC+wVvrnqoTdv4ldgiiBHmq8zCFWlx+JKvX9lqF+PwhGXTi0lUBtu10PI DXcGyfuzb2tCDlD4yt5Kj29fe+zHBBHvF2aZ45gUwPyHO7hdKqdH1SdhtO1aX8u7wBVT bvHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339440; x=1689931440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hZrlIC4UOKpv9upRfhGvF2jtmIJyO/l6blnJN/Kvfh8=; b=erNG7kvL6P0i/pqI8Zd8QWNppN/ZDJpbYojffb/a89fpaOrKaRzMHJmHVri4i3W91Z OiGzXqruWa9PaUaMD4zkI19no++fHILrnBBaRuP0MHVIyeiMe8anPmW1s1T97vEpI5yK x/T2nJsYd7x7BKuGgxYUVGNaHPhy1SrKTHZeER1lSj3zKNVb8DyzRdl8O72eIOUg1NMV cE8CDLglytHB+oucMZNnIHOknB8Ql03RIzTNeGZNTkR9uYeYynjqlIUFHpDdFJ6riVWc KYtAcyAz6vWqhqDOxz4AeJmQpJBIVtqV9KShjnhyTrp4izkHNuHbnuYRSwXfB3NJLhp9 W9Cg== X-Gm-Message-State: AC+VfDzjxGBjI/tWasgt2r2f6/YOYyIS80Vu+b/a9HdpOwz+2tf44rju mERPkPeP89yvcnOaQpwCzbIvyA== X-Received: by 2002:adf:fd82:0:b0:30f:ce87:9db3 with SMTP id d2-20020adffd82000000b0030fce879db3mr13025821wrr.23.1687339440208; Wed, 21 Jun 2023 02:24:00 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:b762:4f68:e1ed:5041]) by smtp.gmail.com with ESMTPSA id i11-20020adffdcb000000b002fda1b12a0bsm4022115wrs.2.2023.06.21.02.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:23:59 -0700 (PDT) From: Markus Schneider-Pargmann <msp@baylibre.com> To: Marc Kleine-Budde <mkl@pengutronix.de>, Chandrasekar Ramakrishnan <rcsekar@samsung.com>, Wolfgang Grandegger <wg@grandegger.com> Cc: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>, Simon Horman <simon.horman@corigine.com>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Julien Panis <jpanis@baylibre.com>, Markus Schneider-Pargmann <msp@baylibre.com> Subject: [PATCH v4 04/12] can: m_can: Add rx coalescing ethtool support Date: Wed, 21 Jun 2023 11:23:42 +0200 Message-Id: <20230621092350.3130866-5-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230621092350.3130866-1-msp@baylibre.com> References: <20230621092350.3130866-1-msp@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769304125868187324?= X-GMAIL-MSGID: =?utf-8?q?1769304125868187324?= |
Series |
can: m_can: Optimizations for m_can/tcan part 2
|
|
Commit Message
Markus Schneider-Pargmann
June 21, 2023, 9:23 a.m. UTC
Add the possibility to set coalescing parameters with ethtool. rx-frames-irq and rx-usecs-irq can only be set and unset together as the implemented mechanism would not work otherwise. rx-frames-irq can't be greater than the RX FIFO size. Also all values can only be changed if the chip is not active. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> --- drivers/net/can/m_can/m_can.c | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
Comments
On Wed, Jun 21, 2023 at 11:23:42AM +0200, Markus Schneider-Pargmann wrote: ... > +static int m_can_set_coalesce(struct net_device *dev, > + struct ethtool_coalesce *ec, > + struct kernel_ethtool_coalesce *kec, > + struct netlink_ext_ack *ext_ack) > +{ > + struct m_can_classdev *cdev = netdev_priv(dev); > + > + if (cdev->can.state != CAN_STATE_STOPPED) { > + netdev_err(dev, "Device is in use, please shut it down first\n"); > + return -EBUSY; > + } > + > + if (ec->rx_max_coalesced_frames_irq > cdev->mcfg[MRAM_RXF0].num) { > + netdev_err(dev, "rx-frames-irq %u greater than the RX FIFO %u\n", > + ec->rx_max_coalesced_frames_irq, > + cdev->mcfg[MRAM_RXF0].num); > + return -EINVAL; > + } > + if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { Hi Markus, For a W=1 build GCC 12.3.0 suggests, rather forcefully, that it would like some more parentheses here. drivers/net/can/m_can/m_can.c: In function 'm_can_set_coalesce': drivers/net/can/m_can/m_can.c:1978:45: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses] 1978 | if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ drivers/net/can/m_can/m_can.c:1978:50: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses] 1978 | if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n"); > + return -EINVAL; > + } > + > + cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; > + cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; > + > + return 0; > +} ...
Hi Markus, kernel test robot noticed the following build warnings: [auto build test WARNING on ac9a78681b921877518763ba0e89202254349d1b] url: https://github.com/intel-lab-lkp/linux/commits/Markus-Schneider-Pargmann/can-m_can-Write-transmit-header-and-data-in-one-transaction/20230621-173848 base: ac9a78681b921877518763ba0e89202254349d1b patch link: https://lore.kernel.org/r/20230621092350.3130866-5-msp%40baylibre.com patch subject: [PATCH v4 04/12] can: m_can: Add rx coalescing ethtool support config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230622/202306220129.pZuUUlrk-lkp@intel.com/config) compiler: sparc64-linux-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230622/202306220129.pZuUUlrk-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202306220129.pZuUUlrk-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/net/can/m_can/m_can.c: In function 'm_can_tx_handler': drivers/net/can/m_can/m_can.c:1697:27: warning: unused variable 'fifo_header' [-Wunused-variable] 1697 | struct id_and_dlc fifo_header; | ^~~~~~~~~~~ drivers/net/can/m_can/m_can.c: In function 'm_can_set_coalesce': >> drivers/net/can/m_can/m_can.c:1978:45: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses] 1978 | if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ drivers/net/can/m_can/m_can.c:1978:50: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses] 1978 | if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +1978 drivers/net/can/m_can/m_can.c 1959 1960 static int m_can_set_coalesce(struct net_device *dev, 1961 struct ethtool_coalesce *ec, 1962 struct kernel_ethtool_coalesce *kec, 1963 struct netlink_ext_ack *ext_ack) 1964 { 1965 struct m_can_classdev *cdev = netdev_priv(dev); 1966 1967 if (cdev->can.state != CAN_STATE_STOPPED) { 1968 netdev_err(dev, "Device is in use, please shut it down first\n"); 1969 return -EBUSY; 1970 } 1971 1972 if (ec->rx_max_coalesced_frames_irq > cdev->mcfg[MRAM_RXF0].num) { 1973 netdev_err(dev, "rx-frames-irq %u greater than the RX FIFO %u\n", 1974 ec->rx_max_coalesced_frames_irq, 1975 cdev->mcfg[MRAM_RXF0].num); 1976 return -EINVAL; 1977 } > 1978 if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { 1979 netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n"); 1980 return -EINVAL; 1981 } 1982 1983 cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; 1984 cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; 1985 1986 return 0; 1987 } 1988
Hi Simon, On Wed, Jun 21, 2023 at 04:22:12PM +0200, Simon Horman wrote: > On Wed, Jun 21, 2023 at 11:23:42AM +0200, Markus Schneider-Pargmann wrote: > > ... > > > +static int m_can_set_coalesce(struct net_device *dev, > > + struct ethtool_coalesce *ec, > > + struct kernel_ethtool_coalesce *kec, > > + struct netlink_ext_ack *ext_ack) > > +{ > > + struct m_can_classdev *cdev = netdev_priv(dev); > > + > > + if (cdev->can.state != CAN_STATE_STOPPED) { > > + netdev_err(dev, "Device is in use, please shut it down first\n"); > > + return -EBUSY; > > + } > > + > > + if (ec->rx_max_coalesced_frames_irq > cdev->mcfg[MRAM_RXF0].num) { > > + netdev_err(dev, "rx-frames-irq %u greater than the RX FIFO %u\n", > > + ec->rx_max_coalesced_frames_irq, > > + cdev->mcfg[MRAM_RXF0].num); > > + return -EINVAL; > > + } > > + if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { > > Hi Markus, > > For a W=1 build GCC 12.3.0 suggests, rather forcefully, that it would like > some more parentheses here. > > drivers/net/can/m_can/m_can.c: In function 'm_can_set_coalesce': > drivers/net/can/m_can/m_can.c:1978:45: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses] > 1978 | if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ > drivers/net/can/m_can/m_can.c:1978:50: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses] > 1978 | if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thanks, yes I just changed it because checkpatch doesn't like it the other way. I am going to change it back. Also I am wondering why clang doesn't complain at this point. Best, Markus > > > + netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n"); > > + return -EINVAL; > > + } > > + > > + cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; > > + cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; > > + > > + return 0; > > +} > > ...
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 781f287e7ce4..5238a5967971 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1944,8 +1944,54 @@ static const struct net_device_ops m_can_netdev_ops = { .ndo_change_mtu = can_change_mtu, }; +static int m_can_get_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec, + struct kernel_ethtool_coalesce *kec, + struct netlink_ext_ack *ext_ack) +{ + struct m_can_classdev *cdev = netdev_priv(dev); + + ec->rx_max_coalesced_frames_irq = cdev->rx_max_coalesced_frames_irq; + ec->rx_coalesce_usecs_irq = cdev->rx_coalesce_usecs_irq; + + return 0; +} + +static int m_can_set_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec, + struct kernel_ethtool_coalesce *kec, + struct netlink_ext_ack *ext_ack) +{ + struct m_can_classdev *cdev = netdev_priv(dev); + + if (cdev->can.state != CAN_STATE_STOPPED) { + netdev_err(dev, "Device is in use, please shut it down first\n"); + return -EBUSY; + } + + if (ec->rx_max_coalesced_frames_irq > cdev->mcfg[MRAM_RXF0].num) { + netdev_err(dev, "rx-frames-irq %u greater than the RX FIFO %u\n", + ec->rx_max_coalesced_frames_irq, + cdev->mcfg[MRAM_RXF0].num); + return -EINVAL; + } + if (ec->rx_max_coalesced_frames_irq == 0 != ec->rx_coalesce_usecs_irq == 0) { + netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n"); + return -EINVAL; + } + + cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; + cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; + + return 0; +} + static const struct ethtool_ops m_can_ethtool_ops = { + .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | + ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ, .get_ts_info = ethtool_op_get_ts_info, + .get_coalesce = m_can_get_coalesce, + .set_coalesce = m_can_set_coalesce, }; static int register_m_can_dev(struct net_device *dev)