From patchwork Wed Jun 21 09:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 110897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4231854vqr; Wed, 21 Jun 2023 02:27:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SSvY8i+LAj2SBCVoELUOqkUtXPNM10PBkf7AUxaF9DDjZrwoQTyyqw+JL2q/hq36bOLdC X-Received: by 2002:a05:6a00:24cb:b0:668:74e9:8f06 with SMTP id d11-20020a056a0024cb00b0066874e98f06mr6873804pfv.1.1687339666676; Wed, 21 Jun 2023 02:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687339666; cv=none; d=google.com; s=arc-20160816; b=BJ+4u+yTsHiPIXGtT3yfnRs+PquxTw9b4RzZnYb2loCJi4lSmKRq6wfCUAnLWfIsEK a5iVRp5HDyDLjbTb+CSr3ZFSAHeDDXZFF+hcwTkT0X/M6HbMP7pVZPTJrq5oHL3QD6UO scc4c8lL0VjpkukEqer308nqpLDJhi1ZunRIFmw3Rxe39vlnOHK44HM7tnMmsR4Ku84S u60yjIEetvPeEBHGqqfU/+PAS2C75F3vOG5tZPQyQLJihpBG0eENB1N7huFs6/UPmRjJ /+NyiKO7l8tzbImQpjmbJeH0RD5AnCl/deAspLW2IHivaQmJ2QJbruiiSwXoNUPIyJWQ 9z+Q== 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=S3yb9swE3xTiKnV49xmW7qQT7kAh84V+/Srm0DQQmxA=; b=h9ljXygCyPTNItEGYJ2TAKt1FLj/KtmFdxVlS+zGP/tCTWyWMIb5yFRPQ2hj1TEUkJ Q2C7WlYeEdSAAGuZu+8iVMFNUIqCa0rgunaE1B7dqB8XETSy0Qd/pmp7KWA6ukCcqgG8 53Sb84McIiYAlJXdf11/IZhNyHQzW/RkHYhR9CdSCWSe6qX1CbtoM51AiN+xIq+T4fWT E6rsSTfZ/eNWTB0qU0S78NFfcs3yT+tbp/X1n0ahDDXkj4XwfmmYzcyyfcN8UDCpAFQp UXXYg4+vZmWAbSlq/fZnv7Cy1R+iXLy1ZkPUY2AWoD/cDaQXzqUqufTzFIUHyBMEZQd6 rw3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b="x4YWo/dR"; 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 j70-20020a636e49000000b005418b187c59si1410044pgc.633.2023.06.21.02.27.33; Wed, 21 Jun 2023 02:27:46 -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="x4YWo/dR"; 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 S231681AbjFUJYs (ORCPT + 99 others); Wed, 21 Jun 2023 05:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231428AbjFUJYW (ORCPT ); Wed, 21 Jun 2023 05:24:22 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECE161FCD for ; Wed, 21 Jun 2023 02:24:02 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31129591288so3921767f8f.1 for ; Wed, 21 Jun 2023 02:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339441; x=1689931441; 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=S3yb9swE3xTiKnV49xmW7qQT7kAh84V+/Srm0DQQmxA=; b=x4YWo/dRgd3X1CXi35YBtv7s4YeY0ryc8LBoz5C1znXUZ4qpZmvgbeA75ObRCxYC5M h1XBldnohWKXdZpZtDM3VAU7/kkv5vP0Qho9j1LvleCyUJPglEcq/jPLE9n6DdjU9Qu+ Ng2VjFCleB6NhIxz0uE0YJoAKEExD/0cOZCkerXlzsEELo2fqCTDKUbxx8riLQMtYsb2 89SmXnAjPt81FEv8oatHcckOq2p6JhqAXtfUoUyaB1N5Tku4lKDoUEUHBRKbVWz0Ayt9 BTmqCDy2K13LALirN5MlP02JiisY3IzrSOwagkN2XIEQEovHLnOp2jl+4v4YWGt61wt0 zLpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339441; x=1689931441; 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=S3yb9swE3xTiKnV49xmW7qQT7kAh84V+/Srm0DQQmxA=; b=PX0W/pQG2SaickjBDxcTZvcMfvJPH6tuDnOCqSf7FSMORGlmBD8pcTtOA/dJhhsw68 P9aiMlVY4pnV4KdX6bCLKvPwcM46TKnZFrPySYLr3awAMWWhbuLiEQLS66gvHj5I8Nr9 5zQST+1YfY53yOBLQoGIBU174uUqM54ldkaWQV3A0836pVJ1muQsVP6uNoYhsXEg+aeR Jln/21wRUjactztxUl9FD5nVtgR+EKOBOdxPu9br/p/kGYP+y44jR6gAz7ZnSCkidVUr ByQgrtO/gSObQSGVIRK44iouFYdwNxSqfYA6obt7QnAj1APX6IZaiig/CpkYkyQOnAsG O2Wg== X-Gm-Message-State: AC+VfDzYqCuyACuAMP9tSOjaHdvQ8qg6RzVrUEufiKAHrOvt7abMiuCv Sgr/85UdSAbL9oaqeHr74IK7FQ== X-Received: by 2002:adf:ffce:0:b0:30f:b045:8b60 with SMTP id x14-20020adfffce000000b0030fb0458b60mr9833679wrs.69.1687339441432; Wed, 21 Jun 2023 02:24:01 -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.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:24:01 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Julien Panis , Markus Schneider-Pargmann Subject: [PATCH v4 05/12] can: m_can: Add tx coalescing ethtool support Date: Wed, 21 Jun 2023 11:23:43 +0200 Message-Id: <20230621092350.3130866-6-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769303878469374075?= X-GMAIL-MSGID: =?utf-8?q?1769303878469374075?= Add TX support to get/set functions for ethtool coalescing. tx-frames-irq and tx-usecs-irq can only be set/unset together. tx-frames-irq needs to be less than TXE and TXB. As rx and tx share the same timer, rx-usecs-irq and tx-usecs-irq can be enabled/disabled individually but they need to have the same value if enabled. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman --- drivers/net/can/m_can/m_can.c | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 5238a5967971..d1435d1466b2 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1953,6 +1953,8 @@ static int m_can_get_coalesce(struct net_device *dev, ec->rx_max_coalesced_frames_irq = cdev->rx_max_coalesced_frames_irq; ec->rx_coalesce_usecs_irq = cdev->rx_coalesce_usecs_irq; + ec->tx_max_coalesced_frames_irq = cdev->tx_max_coalesced_frames_irq; + ec->tx_coalesce_usecs_irq = cdev->tx_coalesce_usecs_irq; return 0; } @@ -1979,16 +1981,50 @@ static int m_can_set_coalesce(struct net_device *dev, netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n"); return -EINVAL; } + if (ec->tx_max_coalesced_frames_irq > cdev->mcfg[MRAM_TXE].num) { + netdev_err(dev, "tx-frames-irq %u greater than the TX event FIFO %u\n", + ec->tx_max_coalesced_frames_irq, + cdev->mcfg[MRAM_TXE].num); + return -EINVAL; + } + if (ec->tx_max_coalesced_frames_irq > cdev->mcfg[MRAM_TXB].num) { + netdev_err(dev, "tx-frames-irq %u greater than the TX FIFO %u\n", + ec->tx_max_coalesced_frames_irq, + cdev->mcfg[MRAM_TXB].num); + return -EINVAL; + } + if (ec->tx_max_coalesced_frames_irq == 0 != ec->tx_coalesce_usecs_irq == 0) { + netdev_err(dev, "tx-frames-irq and tx-usecs-irq can only be set together\n"); + return -EINVAL; + } + if (ec->rx_coalesce_usecs_irq != 0 && ec->tx_coalesce_usecs_irq != 0 && + ec->rx_coalesce_usecs_irq != ec->tx_coalesce_usecs_irq) { + netdev_err(dev, "rx-usecs-irq %u needs to be equal to tx-usecs-irq %u if both are enabled\n", + ec->rx_coalesce_usecs_irq, + ec->tx_coalesce_usecs_irq); + return -EINVAL; + } cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq; cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq; + cdev->tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq; + cdev->tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq; + + if (cdev->rx_coalesce_usecs_irq) + cdev->irq_timer_wait = + ns_to_ktime(cdev->rx_coalesce_usecs_irq * NSEC_PER_USEC); + else + cdev->irq_timer_wait = + ns_to_ktime(cdev->tx_coalesce_usecs_irq * NSEC_PER_USEC); 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, + ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | + ETHTOOL_COALESCE_TX_USECS_IRQ | + ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ, .get_ts_info = ethtool_op_get_ts_info, .get_coalesce = m_can_get_coalesce, .set_coalesce = m_can_set_coalesce,