[ofa-general] [PATCH 4/4] ipoib: add broadcast_scope attribute to child devices

Rolf Manderscheid rvm at obsidianresearch.com
Mon Dec 10 12:42:12 PST 2007


This patch just makes child devices slightly more consistent with parent devices
with respect to configuring the scope.  It allows the administrator to correct
the scope after the child has already been created.  The scope argument to
create_child is still needed to support a parent device with default scope
and a child device within the same partition.

Signed-off-by: Rolf Manderscheid <rvm at obsidianresearch.com>

---

diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index a1834d8..78d5b2d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -390,6 +390,7 @@ static inline void ipoib_put_ah(struct ipoib_ah *ah)
 
 int ipoib_open(struct net_device *dev);
 int ipoib_add_pkey_attr(struct net_device *dev);
+int ipoib_add_broadcast_scope_attr(struct net_device *dev);
 int ipoib_add_umcast_attr(struct net_device *dev);
 
 void ipoib_send(struct net_device *dev, struct sk_buff *skb,
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 07cce7f..f72266b 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1101,6 +1101,11 @@ static ssize_t set_bcast_scope(struct device *dev,
 }
 static DEVICE_ATTR(broadcast_scope, S_IWUSR | S_IRUGO, show_bcast_scope, set_bcast_scope);
 
+int ipoib_add_broadcast_scope_attr(struct net_device *dev)
+{
+	return device_create_file(&dev->dev, &dev_attr_broadcast_scope);
+}
+
 static ssize_t create_child(struct device *dev,
 			    struct device_attribute *attr,
 			    const char *buf, size_t count)
@@ -1159,6 +1164,11 @@ int ipoib_pkey_scope_in_use(struct net_device *dev, unsigned short pkey, unsigne
 	struct ipoib_dev_priv *ppriv, *priv;
 
 	ppriv = netdev_priv(dev);
+	if (ppriv->parent) {
+	    dev = ppriv->parent;
+	    ppriv = netdev_priv(dev);
+	}
+
 	/*
 	 * We check the parent device and then all of the child interfaces to make sure
 	 * the Pkey and scope don't match.
@@ -1251,7 +1261,7 @@ static struct net_device *ipoib_add_port(const char *format,
 		goto sysfs_failed;
 	if (device_create_file(&priv->dev->dev, &dev_attr_delete_child))
 		goto sysfs_failed;
-	if (device_create_file(&priv->dev->dev, &dev_attr_broadcast_scope))
+	if (ipoib_add_broadcast_scope_attr(priv->dev))
 		goto sysfs_failed;
 
 	return priv->dev;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 280556f..317a79d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -116,6 +116,8 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey,
 
 	if (device_create_file(&priv->dev->dev, &dev_attr_parent))
 		goto sysfs_failed;
+	if (ipoib_add_broadcast_scope_attr(priv->dev))
+		goto sysfs_failed;
 
 	list_add_tail(&priv->list, &ppriv->child_intfs);
 



More information about the general mailing list