[ofa-general] [PATCH 16 of 17] ipoib: modify CQ through ethtool

Eli Cohen eli at mellanox.co.il
Tue Sep 11 08:55:07 PDT 2007


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-11 21:15:29.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/ulp/ipoib/ipoib.h	2007-09-11 21:15:30.000000000 +0300
@@ -283,6 +283,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;
+};
+
 struct ipoib_lro {
 	struct hlist_node node;
 	struct hlist_node flush_node;
@@ -388,6 +395,8 @@ struct ipoib_dev_priv {
 	struct hlist_head    lro_free;
 	struct hlist_head    lro_flush;
 	int		     lro_sz; /* must be 2^x */
+
+        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-11 21:15:29.000000000 +0300
+++ ofa_1_3_dev_kernel/drivers/infiniband/ulp/ipoib/ipoib_etool.c	2007-09-11 21:15:30.000000000 +0300
@@ -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