]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
IPoIB: Allow setting policy to ignore multicast groups
authorOr Gerlitz <ogerlitz@voltaire.com>
Mon, 8 Oct 2007 08:13:00 +0000 (10:13 +0200)
committerRoland Dreier <rolandd@cisco.com>
Wed, 10 Oct 2007 20:02:30 +0000 (13:02 -0700)
The kernel IB stack allows (through the RDMA CM) userspace
applications to join and use multicast groups from the IPoIB MGID
range.  This allows multicast traffic to be handled directly from
userspace QPs, without going through the kernel stack, which gives
better performance for some applications.

However, to fully interoperate with IP multicast, such userspace
applications need to participate in IGMP reports and queries, or else
routers may not forward the multicast traffic to the system where the
application is running.  The simplest way to do this is to share the
kernel IGMP implementation by using the IP_ADD_MEMBERSHIP option to
join multicast groups that are being handled directly in userspace.

However, in such cases, the actual multicast traffic should not also
be handled by the IPoIB interface, because that would burn resources
handling multicast packets that will just be discarded in the kernel.

To handle this, this patch adds lookup on the database used for IB
multicast group reference counting when IPoIB is joining multicast
groups, and if a multicast group is already handled by user space,
then the IPoIB kernel driver ignores the group.  This is controlled by
a per-interface policy flag.  When the flag is set, IPoIB will not
join and attach its QP to a multicast group which already has an entry
in the database; when the flag is cleared, IPoIB will behave as before
this change.

For each IPoIB interface, the /sys/class/net/$intf/umcast attribute
controls the policy flag.  The default value is off/0.

Signed-off-by: Or Gerlitz <ogerlitz@voltaire.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/ulp/ipoib/ipoib.h
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/ipoib/ipoib_multicast.c
drivers/infiniband/ulp/ipoib/ipoib_vlan.c

index fc16bced8e5431a9058d8ae5662c0e18cb94ac8a..a198ce8371db3520d9deadb4c382be562cd5aa19 100644 (file)
@@ -86,6 +86,7 @@ enum {
        IPOIB_MCAST_STARTED       = 8,
        IPOIB_FLAG_NETIF_STOPPED  = 9,
        IPOIB_FLAG_ADMIN_CM       = 10,
+       IPOIB_FLAG_UMCAST         = 11,
 
        IPOIB_MAX_BACKOFF_SECONDS = 16,
 
@@ -384,6 +385,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_umcast_attr(struct net_device *dev);
 
 void ipoib_send(struct net_device *dev, struct sk_buff *skb,
                struct ipoib_ah *address, u32 qpn);
index 900335a36e459378882985430fb1df5ccc6641be..ff17fe3c765bd720b7601e6e6a9a1e5f8d4949ce 100644 (file)
@@ -1019,6 +1019,37 @@ static ssize_t show_pkey(struct device *dev,
 }
 static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
 
+static ssize_t show_umcast(struct device *dev,
+                          struct device_attribute *attr, char *buf)
+{
+       struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev));
+
+       return sprintf(buf, "%d\n", test_bit(IPOIB_FLAG_UMCAST, &priv->flags));
+}
+
+static ssize_t set_umcast(struct device *dev,
+                         struct device_attribute *attr,
+                         const char *buf, size_t count)
+{
+       struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev));
+       unsigned long umcast_val = simple_strtoul(buf, NULL, 0);
+
+       if (umcast_val > 0) {
+               set_bit(IPOIB_FLAG_UMCAST, &priv->flags);
+               ipoib_warn(priv, "ignoring multicast groups joined directly "
+                               "by userspace\n");
+       } else
+               clear_bit(IPOIB_FLAG_UMCAST, &priv->flags);
+
+       return count;
+}
+static DEVICE_ATTR(umcast, S_IWUSR | S_IRUGO, show_umcast, set_umcast);
+
+int ipoib_add_umcast_attr(struct net_device *dev)
+{
+       return device_create_file(&dev->dev, &dev_attr_umcast);
+}
+
 static ssize_t create_child(struct device *dev,
                            struct device_attribute *attr,
                            const char *buf, size_t count)
@@ -1136,6 +1167,8 @@ static struct net_device *ipoib_add_port(const char *format,
                goto sysfs_failed;
        if (ipoib_add_pkey_attr(priv->dev))
                goto sysfs_failed;
+       if (ipoib_add_umcast_attr(priv->dev))
+               goto sysfs_failed;
        if (device_create_file(&priv->dev->dev, &dev_attr_create_child))
                goto sysfs_failed;
        if (device_create_file(&priv->dev->dev, &dev_attr_delete_child))
index 94a57097e2b4b3ddad0cd662bf32772d17cfa8fa..62abfb6f35c1f9270ced7bb2920287c59904c6fa 100644 (file)
@@ -761,6 +761,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
        struct ipoib_mcast *mcast, *tmcast;
        LIST_HEAD(remove_list);
        unsigned long flags;
+       struct ib_sa_mcmember_rec rec;
 
        ipoib_dbg_mcast(priv, "restarting multicast task\n");
 
@@ -794,6 +795,14 @@ void ipoib_mcast_restart_task(struct work_struct *work)
                if (!mcast || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
                        struct ipoib_mcast *nmcast;
 
+                       /* ignore group which is directly joined by userspace */
+                       if (test_bit(IPOIB_FLAG_UMCAST, &priv->flags) &&
+                           !ib_sa_get_mcmember_rec(priv->ca, priv->port, &mgid, &rec)) {
+                               ipoib_dbg_mcast(priv, "ignoring multicast entry for mgid "
+                                               IPOIB_GID_FMT "\n", IPOIB_GID_ARG(mgid));
+                               continue;
+                       }
+
                        /* Not found or send-only group, let's add a new entry */
                        ipoib_dbg_mcast(priv, "adding multicast entry for mgid "
                                        IPOIB_GID_FMT "\n", IPOIB_GID_ARG(mgid));
index 6762988439d1f6fcd96b82aad8a25f51e7bf5a86..293f5b892e3f5f20d33ababa2a50f1688254f891 100644 (file)
@@ -119,6 +119,8 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
                goto sysfs_failed;
        if (ipoib_add_pkey_attr(priv->dev))
                goto sysfs_failed;
+       if (ipoib_add_umcast_attr(priv->dev))
+               goto sysfs_failed;
 
        if (device_create_file(&priv->dev->dev, &dev_attr_parent))
                goto sysfs_failed;