[ofa-general] [PATCH 10/11]: IB/ipoib modify cq params

Eli Cohen eli at mellanox.co.il
Mon Sep 24 05:41:24 PDT 2007


Implement support for modifying IPOIB CQ moderation params

This can be used to tune at run time the paramters controlling
the event (interrupt) generation rate and thus reduce the overhead
incurred by hadling interrupts resulting in better throughput.

Signed-off-by: Eli Cohen <eli at mellanox.co.il>

---

Index: ofa_1_3_dev_kernel/drivers/infiniband/ulp/ipoib/ipoib.h
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/ulp/ipoib/ipoib.h	2007-09-24 13:07:43.000000000 +0200
+++ ofa_1_3_dev_kernel/drivers/infiniband/ulp/ipoib/ipoib.h	2007-09-24 13:12:21.000000000 +0200
@@ -270,6 +270,13 @@ struct ipoib_cm_dev_priv {
 	struct ib_recv_wr       rx_wr;
 };
 
+struct ipoib_ethtool_st {
+	u16     rx_coalesce_usecs;
+	u16     tx_coalesce_usecs;
+	u16     rx_max_coalesced_frames;
+	u16     tx_max_coalesced_frames;
+};
+
 /*
  * Device private locking: tx_lock protects members used in TX fast
  * path (and we use LLTX so upper layers don't do extra locking).
@@ -346,6 +353,7 @@ struct ipoib_dev_priv {
 	struct dentry *mcg_dentry;
 	struct dentry *path_dentry;
 #endif
+	struct ipoib_ethtool_st etool;
 };
 
 struct ipoib_ah {
Index: ofa_1_3_dev_kernel/drivers/infiniband/ulp/ipoib/ipoib_etool.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/ulp/ipoib/ipoib_etool.c	2007-09-24 13:07:43.000000000 +0200
+++ ofa_1_3_dev_kernel/drivers/infiniband/ulp/ipoib/ipoib_etool.c	2007-09-24 13:09:26.000000000 +0200
@@ -44,9 +44,49 @@ static void ipoib_get_drvinfo(struct net
 	strncpy(drvinfo->driver, "ipoib", sizeof(drvinfo->driver) - 1);
 }
 
+static int ipoib_get_coalesce(struct net_device *dev,
+			      struct ethtool_coalesce *coal)
+{
+	struct ipoib_dev_priv *priv = netdev_priv(dev);
+
+	coal->rx_coalesce_usecs = priv->etool.rx_coalesce_usecs;
+	coal->tx_coalesce_usecs = priv->etool.tx_coalesce_usecs;
+	coal->rx_max_coalesced_frames = priv->etool.rx_max_coalesced_frames;
+	coal->rx_max_coalesced_frames = priv->etool.tx_max_coalesced_frames;
+
+	return 0;
+}
+
+static int ipoib_set_coalesce(struct net_device *dev,
+                             struct ethtool_coalesce *coal)
+{
+	struct ipoib_dev_priv *priv = netdev_priv(dev);
+	int ret;
+
+	if (coal->rx_coalesce_usecs > 0xffff            ||
+	    coal->tx_coalesce_usecs > 0xffff            ||
+	    coal->rx_max_coalesced_frames > 0xffff      ||
+	    coal->tx_max_coalesced_frames > 0xffff)
+		return -EINVAL;
+
+	ret = ib_modify_cq(priv->cq, coal->rx_max_coalesced_frames,
+	coal->rx_coalesce_usecs);
+	if (ret)
+		return ret;
+
+	priv->etool.rx_coalesce_usecs = coal->rx_coalesce_usecs;
+	priv->etool.tx_coalesce_usecs = coal->tx_coalesce_usecs;
+	priv->etool.rx_max_coalesced_frames = coal->rx_max_coalesced_frames;
+	priv->etool.tx_max_coalesced_frames = coal->rx_max_coalesced_frames;
+
+	return 0;
+}
+
 static const struct ethtool_ops ipoib_ethtool_ops = {
 	.get_drvinfo            = ipoib_get_drvinfo,
 	.get_tso		= ethtool_op_get_tso,
+	.get_coalesce           = ipoib_get_coalesce,
+	.set_coalesce           = ipoib_set_coalesce,
 };
 
 void ipoib_set_ethtool_ops(struct net_device *dev)




More information about the general mailing list