[openib-general] [PATCH 2/5] multicast: allow retrieving an MCMemberRecord based on MGID

Sean Hefty sean.hefty at intel.com
Fri Jun 9 14:46:56 PDT 2006


Add an API to allow retrieving an MCMemberRecord from the local cache
based on an MGID.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
This allows an existing MCMemberRecord to be used as a template for
creating other multicast groups.

--- svn3/gen2/trunk/src/linux-kernel/infiniband/include/rdma/ib_multicast.h	2006-05-25 11:18:47.000000000 -0700
+++ svn/gen2/trunk/src/linux-kernel/infiniband/include/rdma/ib_multicast.h	2006-05-23 14:58:06.000000000 -0700
@@ -82,4 +82,16 @@ struct ib_multicast *ib_join_multicast(s
  */
 void ib_free_multicast(struct ib_multicast *multicast);
 
+/**
+ * ib_get_mcmember_rec - Looks up a multicast member record by its MGID and
+ *   returns it if found.
+ * @device: Device associated with the multicast group.
+ * @port_num: Port on the specified device to associate with the multicast
+ *   group.
+ * @mgid: MGID of multicast group.
+ * @rec: Location to copy SA multicast member record.
+ */
+int ib_get_mcmember_rec(struct ib_device *device, u8 port_num,
+			union ib_gid *mgid, struct ib_sa_mcmember_rec *rec);
+
 #endif /* IB_MULTICAST_H */
--- svn3/gen2/trunk/src/linux-kernel/infiniband/core/multicast.c	2006-06-08 21:53:21.000000000 -0700
+++ svn/gen2/trunk/src/linux-kernel/infiniband/core/multicast.c	2006-06-08 17:14:01.000000000 -0700
@@ -612,6 +612,29 @@ void ib_free_multicast(struct ib_multica
 }
 EXPORT_SYMBOL(ib_free_multicast);
 
+int ib_get_mcmember_rec(struct ib_device *device, u8 port_num,
+			union ib_gid *mgid, struct ib_sa_mcmember_rec *rec)
+{
+	struct mcast_device *dev;
+	struct mcast_port *port;
+	struct mcast_group *group;
+	unsigned long flags;
+
+	dev = ib_get_client_data(device, &mcast_client);
+	if (!dev)
+		return -ENODEV;
+
+	port = &dev->port[port_num - dev->start_port];
+	spin_lock_irqsave(&port->lock, flags);
+	group = mcast_find(port, mgid);
+	if (group)
+		*rec = group->rec;
+	spin_unlock_irqrestore(&port->lock, flags);
+
+	return group ? 0 : -EADDRNOTAVAIL;
+}
+EXPORT_SYMBOL(ib_get_mcmember_rec);
+
 static void mcast_groups_lost(struct mcast_port *port)
 {
 	struct mcast_group *group;





More information about the general mailing list