Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1493869lqo; Sat, 18 May 2024 05:50:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6LAHdankdjT7+qlbI7dumJtppEdMpAPTgYpX/SPGFJZbSjNvl8JccY5eaKl6dCy3DiVVS4m2RJSNB3j1Qhmg7jqkvqQ3R0sJDiOMJwA== X-Google-Smtp-Source: AGHT+IG1YXAn7thj0bVZd2OuX+D551oXoILVwOZMkKSi1TWbGakjHMqb9AOvtuBxLV9o/I03w2IU X-Received: by 2002:a05:6512:48c5:b0:51d:682d:c2ab with SMTP id 2adb3069b0e04-5220fc7eee3mr15377647e87.32.1716036607474; Sat, 18 May 2024 05:50:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716036607; cv=pass; d=google.com; s=arc-20160816; b=lohb5HRD5B4BmwX/tGRVN/Qmek38Xl1prTjKjrTg/6DvwQSq3nbvqnfNRLXnVLdiQR LCPeB4IEpovDi5xEreV6i0mG4gKqARcCvOZP9zzVbpdhIufxoe6wsZUc1V/UHkjsoSDT UTBQAP9YtqiAD6t5u6/lDdyl2akgwvBHS1Q2gtcbtZ1AkRc3cPfMSDENPbSL1yMPkRwn MmoIqDm2Yk3SnQf6Wld33FctcEc0G283MBhFDFQnsvcbngcnXm6xoNskw6io3K/FN39b jcyUt86qBsanh6EJFCjnU5fsAES4zhpJzeIqfxDiS7vMt70zLD2hYB20cLFHNz16I75D 1Kdw== 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=QVXXevX2p35Tc0MKEUXQO7615FHZ3IeMDwxKByj5l54=; fh=o09Pg6xF7oDS6d546SEMTPTO411plfH6YfIeKl0U52o=; b=c2fJNytQV3pIWSoms/FfmwwNaFh7QnYBmUomGRTB71BeWk1BPj8bq9ruLRhgb4Ot6+ 3GY7ZgevQm5MOTZTTzDTR71+Vfd2M2DvlWL3KONTQHF8koMUfwgOA+YIwZTgc4P/MSga ioqQLfah9cc1lD9rHLsVxoXY51tQEg7L5DJXKW2pF+3+cYmt+3AL6Hk8gXwMDpbchslJ NUKYphiMPv0rw69AAl3JkUlJxJTIfJJLE6YzBFLQXctqB/olWRSn4aslC8P9rJRv87hI WOU1AHf74mU9x6oat4GKtRXOB2bZeCzy1piEUxazzv8aD/YbPyEsBobornMvwvYrnSj1 GJyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="jMB/r8r2"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-182871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c328884si10880118a12.409.2024.05.18.05.50.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 05:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182871-linux.lists.archive=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=@ti.com header.s=ti-com-17Q1 header.b="jMB/r8r2"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-182871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com 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 07BD01F21FDE for ; Sat, 18 May 2024 12:50:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E0A57A141; Sat, 18 May 2024 12:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="jMB/r8r2" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12B0C78C70; Sat, 18 May 2024 12:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716036286; cv=none; b=U81eGauAy7tyaOrT7WtPorWYYkPMs17h4fZidPo2QtnvZg1dli1qFwNzTIT4oWXbIIHQQAsy7zg7UNLoJ9+3SZcM4uDFT0Zq90FsAbCC1i64+jlVj9dG/AXeE2hVU/pBBR5M/jL+exAYzSQdmZRKHKo1rEj2PL3G5ADgS3O9Z+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716036286; c=relaxed/simple; bh=i5Rd3pPxPnww42sxf22pzP0ZZOno9q5S9lWTpp/rxM4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A1OSDdEpg2pEOgJCzZpD6vtraF1QsZIzL81tPsa7h1WMlDnwbr8glj0kpMRebjVBbDUAr3DX2wWcNOYzNj6rWOFuBh6B9ufZdOYmeSys0u0dOsf6mnr/+8ikKa5Y8It2lUx/VBLhedrv8riU4QqLtZO8+m99+hlwvkEW+qci0l8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=jMB/r8r2; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44ICiTgX002883; Sat, 18 May 2024 07:44:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1716036269; bh=QVXXevX2p35Tc0MKEUXQO7615FHZ3IeMDwxKByj5l54=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=jMB/r8r2dtWaVBFxKclXHnSN+aMzyXYmIohPK275YdeF5dMkBqKxpTQ+93MTFqr5w SYJ6wUJyvtNr/53azwxvkvOEaBHhEtwpqhNMLWcrgFWN7aRC0q2FMd6YmfQo/CNFPG 6nOzjQnKwwlEVunXsNfMBFyyquDlihffub5KiDSI= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44ICiTQH130389 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 18 May 2024 07:44:29 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sat, 18 May 2024 07:44:29 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Sat, 18 May 2024 07:44:29 -0500 Received: from uda0492258.dhcp.ti.com (uda0492258.dhcp.ti.com [172.24.227.9]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44ICgY9e041511; Sat, 18 May 2024 07:44:25 -0500 From: Siddharth Vadapalli To: , , , , , , , CC: , , , , , , , Subject: [RFC PATCH net-next 24/28] net: ethernet: ti: cpsw-proxy-client: export coalescing support Date: Sat, 18 May 2024 18:12:30 +0530 Message-ID: <20240518124234.2671651-25-s-vadapalli@ti.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240518124234.2671651-1-s-vadapalli@ti.com> References: <20240518124234.2671651-1-s-vadapalli@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Export coalescing support via ethtool ops. Signed-off-by: Siddharth Vadapalli --- drivers/net/ethernet/ti/cpsw-proxy-client.c | 86 +++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/drivers/net/ethernet/ti/cpsw-proxy-client.c b/drivers/net/ethernet/ti/cpsw-proxy-client.c index 408c9f78c059..b42be0d389b8 100644 --- a/drivers/net/ethernet/ti/cpsw-proxy-client.c +++ b/drivers/net/ethernet/ti/cpsw-proxy-client.c @@ -1253,8 +1253,94 @@ static u32 vport_get_link(struct net_device *ndev) return link_up; } +static int vport_get_coal(struct net_device *ndev, struct ethtool_coalesce *coal, + struct kernel_ethtool_coalesce *kernel_coal, + struct netlink_ext_ack *extack) +{ + struct virtual_port *vport = vport_ndev_to_vport(ndev); + + coal->tx_coalesce_usecs = vport->tx_chans[0].tx_pace_timeout / 1000; + coal->rx_coalesce_usecs = vport->rx_chans[0].rx_pace_timeout / 1000; + return 0; +} + +static int vport_set_coal(struct net_device *ndev, struct ethtool_coalesce *coal, + struct kernel_ethtool_coalesce *kernel_coal, + struct netlink_ext_ack *extack) +{ + struct virtual_port *vport = vport_ndev_to_vport(ndev); + struct cpsw_proxy_priv *proxy_priv = vport->proxy_priv; + struct device *dev = proxy_priv->dev; + u32 i; + + if (coal->tx_coalesce_usecs && coal->tx_coalesce_usecs < 20) { + dev_err(dev, "TX coalesce must be at least 20 usecs. Defaulting to 20 usecs\n"); + coal->tx_coalesce_usecs = 20; + } + + if (coal->rx_coalesce_usecs && coal->rx_coalesce_usecs < 20) { + dev_err(dev, "RX coalesce must be at least 20 usecs. Defaulting to 20 usecs\n"); + coal->rx_coalesce_usecs = 20; + } + + /* Since it is possible to set pacing values per TX and RX queue, if per queue value is + * not specified, apply it to all available TX and RX queues. + */ + + for (i = 0; i < vport->num_tx_chan; i++) + vport->tx_chans[i].tx_pace_timeout = coal->tx_coalesce_usecs * 1000; + + for (i = 0; i < vport->num_rx_chan; i++) + vport->rx_chans[i].rx_pace_timeout = coal->rx_coalesce_usecs * 1000; + + return 0; +} + +static int vport_get_per_q_coal(struct net_device *ndev, u32 q, + struct ethtool_coalesce *coal) +{ + struct virtual_port *vport = vport_ndev_to_vport(ndev); + + if (q >= vport->num_tx_chan || q >= vport->num_rx_chan) + return -EINVAL; + + coal->tx_coalesce_usecs = vport->tx_chans[q].tx_pace_timeout / 1000; + coal->rx_coalesce_usecs = vport->rx_chans[q].rx_pace_timeout / 1000; + + return 0; +} + +static int vport_set_per_q_coal(struct net_device *ndev, u32 q, + struct ethtool_coalesce *coal) +{ struct virtual_port *vport = vport_ndev_to_vport(ndev); + struct device *dev = vport->proxy_priv->dev; + + if (q >= vport->num_tx_chan || q >= vport->num_rx_chan) + return -EINVAL; + + if (coal->tx_coalesce_usecs && coal->tx_coalesce_usecs < 20) { + dev_err(dev, "TX coalesce must be at least 20 usecs. Defaulting to 20 usecs\n"); + coal->tx_coalesce_usecs = 20; + } + + if (coal->rx_coalesce_usecs && coal->rx_coalesce_usecs < 20) { + dev_err(dev, "RX coalesce must be at least 20 usecs. Defaulting to 20 usecs\n"); + coal->rx_coalesce_usecs = 20; + } + + vport->tx_chans[q].tx_pace_timeout = coal->tx_coalesce_usecs * 1000; + vport->rx_chans[q].rx_pace_timeout = coal->rx_coalesce_usecs * 1000; + + return 0; +} + const struct ethtool_ops cpsw_proxy_client_ethtool_ops = { .get_link = vport_get_link, + .supported_coalesce_params = ETHTOOL_COALESCE_USECS, + .get_coalesce = vport_get_coal, + .set_coalesce = vport_set_coal, + .get_per_queue_coalesce = vport_get_per_q_coal, + .set_per_queue_coalesce = vport_set_per_q_coal, }; static int register_mac(struct virtual_port *vport) -- 2.40.1