lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240518124234.2671651-25-s-vadapalli@ti.com>
Date: Sat, 18 May 2024 18:12:30 +0530
From: Siddharth Vadapalli <s-vadapalli@...com>
To: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <pabeni@...hat.com>, <corbet@....net>, <rogerq@...nel.org>,
        <danishanwar@...com>, <vladimir.oltean@....com>
CC: <netdev@...r.kernel.org>, <linux-doc@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
        <vigneshr@...com>, <misael.lopez@...com>, <srk@...com>,
        <s-vadapalli@...com>
Subject: [RFC PATCH net-next 24/28] net: ethernet: ti: cpsw-proxy-client: export coalescing support

Export coalescing support via ethtool ops.

Signed-off-by: Siddharth Vadapalli <s-vadapalli@...com>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ