From patchwork Wed Feb 7 09:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 197829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2118555dyb; Wed, 7 Feb 2024 01:52:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IG84ufHzTCBXcNao0orvw97OCwjqf3x1OLmbBu6DhR5wUKny6idEN3hvwqjxGJqUKGma6qn X-Received: by 2002:a17:906:af85:b0:a38:22d:7cce with SMTP id mj5-20020a170906af8500b00a38022d7ccemr5927964ejb.22.1707299544640; Wed, 07 Feb 2024 01:52:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707299544; cv=pass; d=google.com; s=arc-20160816; b=HTVSYbcj6HwAz7FY+BSNg0YIfwY5Zg1c1dRYMC3njrRfp4HRYRjQX98qI2yE7thnd8 MwR0dwm/hwcHVDxfD3avwrVN+56toC9CgYzE9Bqz2Iowl8fWHJQw/wZAyWEc9EyZKEj9 R2o2X/Fqvi2eGsURVypQvrfGvuGBL6Drt2ORn4mC+LtfaVShlGliAjUS+yOWNIjdwK9/ oS4vWdkVEPlXth5zeJf6p0bpdulQYNB10OeSemamrQGkjZL62VPpnXPi1na4Tdu1F7Kz h3pMHEypvcxTWDJWPY4AOxtousUL8Hhl9EoONYgMatdn+Lhek0ySFLQwknZ1ir23lWhI nJBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Z6gvVLaAJJ5SpKKyjtFK2dGPARZlV56P68Im7wENaso=; fh=MEr78bVjZ6a+SIOlgQ/7uWBteNP+RzW57aWkYSyD1qU=; b=oNI2Kph7pTmfg6RMx5R8O0vW/fAlbztu15xnMm/ZqTB5UeXTHnFmUiAIPnFMFcwJmZ C2ZxBOfrOt56mRsiO5jqRoDQZTwXDd3CYNwV2jm84L4iOSu/0NDwh7WtnB9UBCrXrmZD FMBbooeQkqQ0MvnLbeXLJSDVVYxrJwSsiXQ6fE+Vvar0xvtMxP8rMMpULv6S6+RtRBRY Sn1qdtmayyXizo8Sjz+m1OTOtrgbtUQxhkBbVpNGfU+wBpocc0v43vNGGPb6YWlTtN8k DZV47UDQkR4Uc0n963lew2wGv6XbqFg4w7BTpD9/wVfrTw1c922DCJG6D2lcgVAnRr3v gd6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ElNcL92z; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-56217-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56217-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVLzis+LiqEoZyjslvTiCc3jfa0jgCvVoy4tZw/wZ68y/k2i5hL65yF8h/dGQYyPjRe3KaCQqLtMYywuuSCE7KYdQLCtw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lf6-20020a170907174600b00a3737c479ebsi678867ejc.459.2024.02.07.01.52.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 01:52:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56217-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ElNcL92z; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-56217-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56217-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 55CD51F23349 for ; Wed, 7 Feb 2024 09:36:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA4B63C48C; Wed, 7 Feb 2024 09:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="ElNcL92z" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6589128DCA for ; Wed, 7 Feb 2024 09:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707298367; cv=none; b=hr2f4/kee3+zKyEfTLSBN+D7195CYY8q33FsxCJXNlFfKlM5RcuAerl9OX3SzrBUvuOf8r9aJr39hVuQUdRQY21au8qKPbfc5vvPmdEy/30bw1G1TPAROmOTyYBJcN8BvDSxIeJh8chDSkrVqLNPjffqin9koCkbg1opRml0k4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707298367; c=relaxed/simple; bh=seS2mYXKgOsaStLXlO6Hn49jlysXxgYFKeFnkw5vJfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QtKjLcE1xELcGMGXZloM3ydn6BmCwzmt4wDLMv8RH9nRXDtmaNKtpeRLgFrb2IjBL+f6HC/WlUCHUQo43FNbtxSPzYZclsDwSFO0sDDWZ5cKrJ/k/Ta0yzfG7opMIgRILj9TEJIhqukztg3H0wI8bfx0cGxyvwk6KNbtSmjVROg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=ElNcL92z; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a3864258438so85013166b.0 for ; Wed, 07 Feb 2024 01:32:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1707298363; x=1707903163; darn=vger.kernel.org; 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=Z6gvVLaAJJ5SpKKyjtFK2dGPARZlV56P68Im7wENaso=; b=ElNcL92zZytcCLqFP1+TVlCj8Yovx4+m24BMXj1d58bgaxq0Qc0OezZ045zKoSb07g OnvXQoL1ENdLa4OVtGc2bwtpqYqnJ6mqDWAaJimF/e9xvmTmbFhDbC+SDCcaHX7vClT2 V2bbHR8XU0M4faxIbli7xslXLz9dU2WbdhjzUZxb/mgrEc138v1x8PS1AnUoOJW3z6TV hbLruAJ7Fpw0yeEhWe0R/KC9QCCSvu/7Qu6hl2eJlgeEcN92JHYaazweJfp7/3cWlzfQ 3qGTb7TOKYLKyVHKwAZBgx0UJ9xwnlKm3yy1M1zShowbQfCl88MuFnvBlzKxHMhrUhCS hSUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707298363; x=1707903163; 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=Z6gvVLaAJJ5SpKKyjtFK2dGPARZlV56P68Im7wENaso=; b=SKT9cX9h0WIKmaITKgqlO7jmNGFBwsw258HwewfifX+5l7T9m7YjdoxdxY9C5gv+4e qU3VRKRzyInyALLRGohWYVehOG+77rNqA2lozxQTVf/NLPRq9+j8XzBfIcEfm16h5zEu w5NHV1/VK3l/ZN4BATVtrWuP8GVVaieiG4EwEBtAo1wWhRKiqanKbTbBmRTwx3YU6u9p 6A9nftVREvGTPFCbiXfOppiaTgl7YZ+y7gVhHbG6w38PtfGBBk4sLLlctteTxpGvxngI IKbok/zYdTuOy8CXzIYdTZu1v8FHV2vugyXkT8GSD0LQxU+aY0c0kS4qYGstGRon+H86 Y6hg== X-Gm-Message-State: AOJu0YzkAWLYek82R00yuYQR0m8tzqsovvydixzGimP0XtrNprw/3shJ lQX3YwKr9Q5VBJjWHfPaQQ+uxrVV90NWXuI59Sv+KeZ1UXlDDZYYUTgXoePzktE= X-Received: by 2002:a17:906:44:b0:a38:3e90:e1ed with SMTP id 4-20020a170906004400b00a383e90e1edmr3509955ejg.7.1707298363662; Wed, 07 Feb 2024 01:32:43 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU7xANWpOEcVoy0cWd1FA3d7ebTG317SnEhRB7lk6E7hkiAm5/6uwcW/39kazc+PLqt/PycVuIndwdXlbvHklivYovFU0XLCRZolNboHaIrA+inwYWFahk3rhFF814b/f/FfsQcecFwhKMQqNpTvs0ElMJRwYC18K3nh+0NwRJOLby27hHiIHAwIKn3jTppClv9Kt8buQhwqyu+N7NhRIjKk46jsnlv5eDDrkh5H3a7F6oKNqpcSzUPwu3Zt6qx28AKc1kW7nd8tdwL0hBxPNbY/5TQOvvQqf5tBjHDTwrr7U+OoXS/Up3rNS2evgdY/iSLZtAIM6NYSg92Yr13AZvtyQ4f+t2JgzH6gIe33oitODQbP1vqNvONyuk9pI8N/8H51lk156oIVFqEaK9vdivsuKZWL02jVWzYuG6qWUCFC5V/tkQH2k5FCDBR Received: from blmsp.fritz.box ([2001:4091:a246:821e:6f3b:6b50:4762:8343]) by smtp.gmail.com with ESMTPSA id qo9-20020a170907874900b00a388e24f533sm122336ejc.148.2024.02.07.01.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 01:32:43 -0800 (PST) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tony Lindgren , Judith Mendez Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Julien Panis , Markus Schneider-Pargmann Subject: [PATCH 07/14] can: m_can: Add tx coalescing ethtool support Date: Wed, 7 Feb 2024 10:32:13 +0100 Message-ID: <20240207093220.2681425-8-msp@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207093220.2681425-1-msp@baylibre.com> References: <20240207093220.2681425-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790233327743628182 X-GMAIL-MSGID: 1790233327743628182 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. Polling is excluded from TX irq coalescing. Signed-off-by: Markus Schneider-Pargmann --- 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 6dad1f569f82..b31df3e3ceeb 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1986,6 +1986,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; } @@ -2012,16 +2014,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,