[openib-general] [PATCH] Convert multicast functions to new API

Roland Dreier roland at topspin.com
Tue Aug 10 10:56:27 PDT 2004


This patch converts the multicast functions to the new API.

There's still more work to do to get rid of all uses of tTS_IB_GID (in
favor of union ib_gid).

 - Roland

Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(revision 576)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c	(working copy)
@@ -38,7 +38,7 @@
 		set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
 }
 
-int ipoib_mcast_attach(struct net_device *dev, u16 mlid, tTS_IB_GID mgid)
+int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
 {
 	struct ipoib_dev_priv *priv = dev->priv;
 	struct ib_qp_attribute *qp_attr;
@@ -68,7 +68,7 @@
 
 	/* attach QP to multicast group */
 	down(&priv->mcast_mutex);
-	ret = ib_multicast_attach(mlid, mgid, priv->qp);
+	ret = ib_attach_mcast(priv->qp, mgid, mlid);
 	up(&priv->mcast_mutex);
 	if (ret)
 		TS_REPORT_FATAL(MOD_IB_NET,
@@ -80,17 +80,17 @@
 	return ret;
 }
 
-int ipoib_mcast_detach(struct net_device *dev, u16 mlid, tTS_IB_GID mgid)
+int ipoib_mcast_detach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
 {
 	struct ipoib_dev_priv *priv = dev->priv;
 	int ret;
 
 	down(&priv->mcast_mutex);
-	ret = ib_multicast_detach(mlid, mgid, priv->qp);
+	ret = ib_detach_mcast(priv->qp, mgid, mlid);
 	up(&priv->mcast_mutex);
 	if (ret)
 		TS_REPORT_WARN(MOD_IB_NET,
-			       "%s: ib_multicast_detach failed (result = %d)",
+			       "%s: ib_detach_mcast failed (result = %d)",
 			       dev->name, ret);
 
 	return ret;
Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib_arp.c
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib_arp.c	(revision 607)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib_arp.c	(working copy)
@@ -46,7 +46,7 @@
 
 	uint8_t hash[IPOIB_ADDRESS_HASH_BYTES];
 
-	tTS_IB_GID gid;
+	union ib_gid gid;
 	u32        qpn;
 	u16        lid;
 	tTS_IB_SL  sl;
@@ -87,7 +87,7 @@
 
 /* =============================================================== */
 /*.._ipoib_sarp_hash -- hash GID/QPN to 6 bytes                    */
-static void _ipoib_sarp_hash(tTS_IB_GID gid, u32 qpn, uint8_t *hash)
+static void _ipoib_sarp_hash(union ib_gid *gid, u32 qpn, uint8_t *hash)
 {
 	/* We use the FNV hash (http://www.isthe.com/chongo/tech/comp/fnv/) */
 #define TS_FNV_64_PRIME 0x100000001b3ULL
@@ -99,11 +99,11 @@
 	/* make qpn big-endian so we know where digits are */
 	qpn = cpu_to_be32(qpn);
 
-	for (i = 0; i < sizeof(tTS_IB_GID) + 3; ++i) {
+	for (i = 0; i < sizeof (union ib_gid) + 3; ++i) {
 		h *= TS_FNV_64_PRIME;
 		h ^= (i < sizeof(tTS_IB_GID)
-		      ? gid[i]
-		      : ((uint8_t *)&qpn)[i - sizeof(tTS_IB_GID) + 1]);
+		      ? gid->raw[i]
+		      : ((uint8_t *)&qpn)[i - sizeof (union ib_gid) + 1]);
 	}
 
 	/* xor fold down to 6 bytes and make big-endian */
@@ -291,7 +291,7 @@
 /* =============================================================== */
 /*..ipoib_sarp_iter_read -- get data pointed to by ARP iterator    */
 void ipoib_sarp_iter_read(struct ipoib_sarp_iter *iter, uint8_t *hash,
-			  tTS_IB_GID gid, u32 *qpn,
+			  union ib_gid *gid, u32 *qpn,
 			  unsigned long *created, unsigned long *last_verify,
 			  unsigned int *queuelen, unsigned int *complete)
 {
@@ -300,7 +300,7 @@
 	entry = list_entry(iter->cur, struct ipoib_sarp, cache_list);
 
 	memcpy(hash, entry->hash, IPOIB_ADDRESS_HASH_BYTES);
-	memcpy(gid, entry->gid, sizeof(tTS_IB_GID));
+	*gid = entry->gid;
 	*qpn = entry->qpn;
 	*created = entry->created;
 	*last_verify = entry->last_verify;
@@ -310,7 +310,7 @@
 
 /* =============================================================== */
 /*..ipoib_sarp_add -- add ARP entry                                */
-struct ipoib_sarp *ipoib_sarp_add(struct net_device *dev, tTS_IB_GID gid,
+struct ipoib_sarp *ipoib_sarp_add(struct net_device *dev, union ib_gid *gid,
 				  u32 qpn)
 {
 	struct ipoib_dev_priv *priv = dev->priv;
@@ -323,7 +323,7 @@
 	entry = _ipoib_sarp_find(dev, hash);
 	if (entry) {
 		if (entry->qpn != qpn
-		    || memcmp(entry->gid, gid, sizeof(tTS_IB_GID))) {
+		    || memcmp(entry->gid.raw, gid->raw, sizeof (union ib_gid))) {
 			TS_REPORT_WARN(MOD_IB_NET,
 				       "%s: hash collision", dev->name);
 			ipoib_sarp_put(entry);	/* for _find() */
@@ -340,8 +340,7 @@
 	}
 
 	memcpy(entry->hash, hash, sizeof(entry->hash));
-	memcpy(entry->gid, gid, sizeof(tTS_IB_GID));
-
+	entry->gid = *gid;
 	entry->qpn = qpn;
 
 	entry->require_verify = 1;
@@ -356,7 +355,7 @@
 /* =============================================================== */
 /*..ipoib_sarp_local_add -- add ARP hash for local node            */
 struct ipoib_sarp *ipoib_sarp_local_add(struct net_device *dev,
-					tTS_IB_GID gid, u32 qpn)
+					union ib_gid *gid, u32 qpn)
 {
 	_ipoib_sarp_hash(gid, qpn, dev->dev_addr);
 	return ipoib_sarp_add(dev, gid, qpn);
@@ -478,8 +477,10 @@
 	tTS_IB_CLIENT_QUERY_TID tid;
 
 	ipoib_sarp_get(entry);
-	if (tsIbPathRecordRequest(priv->ca, priv->port, priv->local_gid,
-				  entry->gid, priv->pkey, 0, HZ, 3600 * HZ,	/* XXX cache jiffies */
+	if (tsIbPathRecordRequest(priv->ca, priv->port,
+				  priv->local_gid.raw,
+				  entry->gid.raw,
+				  priv->pkey, 0, HZ, 3600 * HZ,	/* XXX cache jiffies */
 				  _ipoib_sarp_path_record_completion,
 				  entry, &tid)) {
 		TS_REPORT_WARN(MOD_IB_NET,
@@ -626,8 +627,8 @@
 
 	/* rewrite IPoIB hw address to hashes */
 	if (be32_to_cpu(*(uint32_t *)payload->src_hw_addr) & 0xffffff) {
-		_ipoib_sarp_hash(payload->src_hw_addr + 4,
-				be32_to_cpu(*(uint32_t *)payload->src_hw_addr) & 0xffffff, hash);
+		_ipoib_sarp_hash((union ib_gid *) (payload->src_hw_addr + 4),
+				 be32_to_cpu(*(uint32_t *)payload->src_hw_addr) & 0xffffff, hash);
 
 		/* add shadow ARP entries if necessary */
 		if (ARPOP_REPLY == ntohs(arp->ar_op)) {
@@ -676,7 +677,8 @@
 
 		/* Small optimization, if we already found it once, don't search again */
 		if (!entry)
-			entry = ipoib_sarp_add(dev, payload->src_hw_addr + 4,
+			entry = ipoib_sarp_add(dev,
+					       (union ib_gid *) (payload->src_hw_addr + 4),
 					       be32_to_cpu(*(uint32_t *)
 							   payload->src_hw_addr) &
 							   0xffffff);
@@ -696,10 +698,11 @@
 	memcpy(header->h_source, hash, sizeof(header->h_source));
 
 	if (be32_to_cpu(*(uint32_t *)payload->dst_hw_addr) & 0xffffff) {
-		_ipoib_sarp_hash(payload->dst_hw_addr + 4,
+		_ipoib_sarp_hash((union ib_gid *) (payload->dst_hw_addr + 4),
 				be32_to_cpu(*(uint32_t *)payload->dst_hw_addr) & 0xffffff, hash);
 
-		entry = ipoib_sarp_add(dev, payload->dst_hw_addr + 4,
+		entry = ipoib_sarp_add(dev,
+				       (union ib_gid *) (payload->dst_hw_addr + 4),
 				       be32_to_cpu(*(uint32_t *)payload->dst_hw_addr) &
 				       0xffffff);
 		if (entry)
@@ -753,7 +756,7 @@
 
 	if (memcmp(broadcast_mac_addr, skb->data, ETH_ALEN) == 0) {
 		/* Broadcast gets handled differently */
-		ret = ipoib_mcast_lookup(dev, priv->bcast_gid, &dmcast);
+		ret = ipoib_mcast_lookup(dev, &priv->bcast_gid, &dmcast);
 
 		/* mcast is only valid if we get a return code of 0 or -EAGAIN */
 		switch (ret) {
@@ -826,7 +829,7 @@
 						ipoib_sarp_delete(dev,
 								  dentry->hash);
 						entry = ipoib_sarp_add(dev,
-								       dentry->gid,
+								       &dentry->gid,
 								       dentry->qpn);
 						if (NULL == entry) {
 							TS_TRACE(MOD_IB_NET,
@@ -918,8 +921,8 @@
 	} else {
 		*((uint32_t *)new_payload->src_hw_addr) =
 		    cpu_to_be32(entry->qpn);
-		memcpy(&new_payload->src_hw_addr[4], entry->gid,
-		       sizeof(tTS_IB_GID));
+		memcpy(&new_payload->src_hw_addr[4], entry->gid.raw,
+		       sizeof (union ib_gid));
 		ipoib_sarp_put(entry);	/* for _find() */
 	}
 
@@ -927,8 +930,8 @@
 		   ETH_ALEN) == 0) {
 		*((uint32_t *)new_payload->dst_hw_addr) =
 		    cpu_to_be32(IB_MULTICAST_QPN);
-		memcpy(&new_payload->dst_hw_addr[4], priv->bcast_gid,
-		       sizeof(tTS_IB_GID));
+		memcpy(&new_payload->dst_hw_addr[4], priv->bcast_gid.raw,
+		       sizeof (union ib_gid));
 	} else {
 		entry = _ipoib_sarp_find(dev, payload +
 					 IPOIB_ADDRESS_HASH_BYTES + 4);
@@ -937,8 +940,8 @@
 		else {
 			*((uint32_t *)new_payload->dst_hw_addr) =
 			    cpu_to_be32(entry->qpn);
-			memcpy(&new_payload->dst_hw_addr[4], entry->gid,
-			       sizeof(tTS_IB_GID));
+			memcpy(&new_payload->dst_hw_addr[4], entry->gid.raw,
+			       sizeof (union ib_gid));
 			ipoib_sarp_put(entry);	/* for _find() */
 		}
 	}
@@ -1009,8 +1012,7 @@
 			if (nentry) {
 				memcpy(nentry->hash, entry->hash,
 				       sizeof(nentry->hash));
-				memcpy(nentry->gid, entry->gid,
-				       sizeof(tTS_IB_GID));
+				nentry->gid = entry->gid;
 
 				nentry->require_verify = entry->require_verify;
 				nentry->qpn = entry->qpn;
@@ -1087,7 +1089,7 @@
 	if (!entry)
 		return -EINVAL;
 
-	memcpy(gid, entry->gid, sizeof(tTS_IB_GID));
+	memcpy(gid, entry->gid.raw, sizeof (union ib_gid));
 
 	ipoib_sarp_put(entry);	/* for _find() */
 
Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib_main.c
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib_main.c	(revision 576)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib_main.c	(working copy)
@@ -45,8 +45,6 @@
 DECLARE_MUTEX(ipoib_device_mutex);
 LIST_HEAD(ipoib_device_list);
 
-extern tTS_IB_GID broadcast_mgid;
-
 static const uint8_t broadcast_mac_addr[] = {
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff
 };
@@ -121,7 +119,7 @@
 
 	*ca = priv->ca;
 	*port = priv->port;
-	memcpy(gid, priv->local_gid, sizeof(tTS_IB_GID));
+	memcpy(gid, priv->local_gid.raw, sizeof (union ib_gid));
 	*pkey = priv->pkey;
 
 	return 0;
@@ -271,25 +269,24 @@
 		    && (skb->data[3] & 0x80) == 0x00) {
 			/* Multicast MAC addr */
 			struct ipoib_mcast *mcast = NULL;
-			tTS_IB_GID mgid;
+			union ib_gid mgid;
 			struct iphdr *iph =
 			    (struct iphdr *)(skb->data + ETH_HLEN);
 			u32 multiaddr = ntohl(iph->daddr);
 
-			memcpy(mgid, ipoib_broadcast_mgid,
-			       sizeof(tTS_IB_GID));
+			mgid = ipoib_broadcast_mgid;
 
 			/* Add in the P_Key */
-			mgid[4] = (priv->pkey >> 8) & 0xff;
-			mgid[5] = priv->pkey & 0xff;
+			mgid.raw[4] = (priv->pkey >> 8) & 0xff;
+			mgid.raw[5] = priv->pkey & 0xff;
 
 			/* Fixup the group mapping */
-			mgid[12] = (multiaddr >> 24) & 0x0f;
-			mgid[13] = (multiaddr >> 16) & 0xff;
-			mgid[14] = (multiaddr >> 8) & 0xff;
-			mgid[15] = multiaddr & 0xff;
+			mgid.raw[12] = (multiaddr >> 24) & 0x0f;
+			mgid.raw[13] = (multiaddr >> 16) & 0xff;
+			mgid.raw[14] = (multiaddr >> 8) & 0xff;
+			mgid.raw[15] = multiaddr & 0xff;
 
-			ret = ipoib_mcast_lookup(dev, mgid, &mcast);
+			ret = ipoib_mcast_lookup(dev, &mgid, &mcast);
 			switch (ret) {
 			case 0:
 				return ipoib_mcast_send(dev, mcast, skb);
@@ -302,7 +299,7 @@
 		    if (memcmp(broadcast_mac_addr, skb->data, ETH_ALEN) == 0) {
 			struct ipoib_mcast *mcast = NULL;
 
-			ret = ipoib_mcast_lookup(dev, priv->bcast_gid, &mcast);
+			ret = ipoib_mcast_lookup(dev, &priv->bcast_gid, &mcast);
 			switch (ret) {
 			case 0:
 				return ipoib_mcast_send(dev, mcast, skb);
Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib.h
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib.h	(revision 607)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib.h	(working copy)
@@ -130,11 +130,11 @@
 	u16 pkey;
 	tTS_KERNEL_THREAD pkey_thread;
 
-	tTS_IB_GID local_gid;
+	union ib_gid local_gid;
 	u16        local_lid;
 	u32        local_qpn;
 
-	tTS_IB_GID bcast_gid;
+	union ib_gid bcast_gid;
 
 	unsigned int admin_mtu;
 	unsigned int mcast_mtu;
@@ -161,7 +161,7 @@
 extern struct semaphore ipoib_device_mutex;
 extern struct list_head ipoib_device_list;
 
-extern tTS_IB_GID ipoib_broadcast_mgid;
+extern union ib_gid ipoib_broadcast_mgid;
 
 /* functions */
 
@@ -187,9 +187,9 @@
 
 void ipoib_sarp_get(struct ipoib_sarp *entry);
 void ipoib_sarp_put(struct ipoib_sarp *entry);
-struct ipoib_sarp *ipoib_sarp_add(struct net_device *dev, tTS_IB_GID gid,
+struct ipoib_sarp *ipoib_sarp_add(struct net_device *dev, union ib_gid *gid,
 				  u32 qpn);
-struct ipoib_sarp *ipoib_sarp_local_add(struct net_device *dev, tTS_IB_GID gid,
+struct ipoib_sarp *ipoib_sarp_local_add(struct net_device *dev, union ib_gid *gid,
 					u32 qpn);
 int ipoib_sarp_delete(struct net_device *dev, const uint8_t *hash);
 int ipoib_sarp_lookup(struct net_device *dev, uint8_t *hash,
@@ -207,7 +207,7 @@
 void ipoib_sarp_iter_free(struct ipoib_sarp_iter *iter);
 int ipoib_sarp_iter_next(struct ipoib_sarp_iter *iter);
 void ipoib_sarp_iter_read(struct ipoib_sarp_iter *iter, uint8_t *hash,
-			  tTS_IB_GID gid, u32 *qpn,
+			  union ib_gid *gid, u32 *qpn,
 			  unsigned long *created,
 			  unsigned long *last_verify,
 			  unsigned int *queuelen, unsigned int *complete);
@@ -217,7 +217,7 @@
 
 void ipoib_mcast_get(struct ipoib_mcast *mcast);
 void ipoib_mcast_put(struct ipoib_mcast *mcast);
-int ipoib_mcast_lookup(struct net_device *dev, tTS_IB_GID mgid,
+int ipoib_mcast_lookup(struct net_device *dev, union ib_gid *mgid,
 		       struct ipoib_mcast **mcast);
 int ipoib_mcast_queue_packet(struct ipoib_mcast *mcast, struct sk_buff *skb);
 int ipoib_mcast_send(struct net_device *dev, struct ipoib_mcast *mcast,
@@ -234,16 +234,16 @@
 void ipoib_mcast_iter_free(struct ipoib_mcast_iter *iter);
 int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);
 void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
-				  tTS_IB_GID gid,
+				  union ib_gid *gid,
 				  unsigned long *created,
 				  unsigned int *queuelen,
 				  unsigned int *complete,
 				  unsigned int *send_only);
 
 int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
-		       tTS_IB_GID mgid);
+		       union ib_gid *mgid);
 int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
-		       tTS_IB_GID mgid);
+		       union ib_gid *mgid);
 
 int ipoib_qp_create(struct net_device *dev);
 void ipoib_qp_destroy(struct net_device *dev);
@@ -271,9 +271,13 @@
 #define IPOIB_GID_FMT		"%02x%02x%02x%02x%02x%02x%02x%02x" \
 				"%02x%02x%02x%02x%02x%02x%02x%02x"
 
-#define IPOIB_GID_ARG(gid)	gid[ 0], gid[ 1], gid[ 2], gid[ 3], \
-				gid[ 4], gid[ 5], gid[ 6], gid[ 7], \
-				gid[ 8], gid[ 9], gid[10], gid[11], \
-				gid[12], gid[13], gid[14], gid[15]
+#define IPOIB_GID_ARG(gid)	(gid).raw[ 0], (gid).raw[ 1], \
+				(gid).raw[ 2], (gid).raw[ 3], \
+				(gid).raw[ 4], (gid).raw[ 5], \
+				(gid).raw[ 6], (gid).raw[ 7], \
+				(gid).raw[ 8], (gid).raw[ 9], \
+				(gid).raw[10], (gid).raw[11], \
+				(gid).raw[12], (gid).raw[13], \
+				(gid).raw[14], (gid).raw[15]
 
 #endif /* _IPOIB_H */
Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c	(revision 607)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib_ib.c	(working copy)
@@ -29,11 +29,6 @@
 
 #include <asm/io.h>
 
-tTS_IB_GID broadcast_mgid = {
-	0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
-};
-
 static int _ipoib_ib_receive(struct ipoib_dev_priv *priv,
 			     u64 work_request_id,
 			     dma_addr_t addr)
Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib_proc.c
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib_proc.c	(revision 576)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib_proc.c	(working copy)
@@ -94,14 +94,14 @@
 	struct ipoib_sarp_iter *iter = iter_ptr;
 	uint8_t hash[IPOIB_ADDRESS_HASH_BYTES];
 	char gid_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")];
-	tTS_IB_GID gid;
+	union ib_gid gid;
 	u32 qpn;
 	int i, n;
 	unsigned long created, last_verify;
 	unsigned int queuelen, complete;
 
 	if (iter) {
-		ipoib_sarp_iter_read(iter, hash, gid, &qpn, &created,
+		ipoib_sarp_iter_read(iter, hash, &gid, &qpn, &created,
 				     &last_verify, &queuelen, &complete);
 
 		for (i = 0; i < IPOIB_ADDRESS_HASH_BYTES; ++i) {
@@ -112,10 +112,10 @@
 				seq_printf(file, "  ");
 		}
 
-		for (n = 0, i = 0; i < sizeof(tTS_IB_GID) / 2; ++i) {
+		for (n = 0, i = 0; i < sizeof gid / 2; ++i) {
 			n += sprintf(gid_buf + n, "%x",
-				     be16_to_cpu(((uint16_t *)gid)[i]));
-			if (i < sizeof(tTS_IB_GID) / 2 - 1)
+				     be16_to_cpu(((u16 *)gid.raw)[i]));
+			if (i < sizeof gid / 2 - 1)
 				gid_buf[n++] = ':';
 		}
 	}
@@ -162,7 +162,7 @@
 
 /* =============================================================== */
 /*.._ipoib_ascii_to_gid -- read GID from string                     */
-static int _ipoib_ascii_to_gid(const char *src, tTS_IB_GID dst)
+static int _ipoib_ascii_to_gid(const char *src, union ib_gid *dst)
 {
 	static const char xdigits[] = "0123456789abcdef";
 	unsigned char *tp, *endp, *colonp;
@@ -170,8 +170,8 @@
 	int ch, saw_xdigit;
 	unsigned int val;
 
-	memset((tp = dst), 0, sizeof(tTS_IB_GID));
-	endp = tp + sizeof(tTS_IB_GID);
+	memset((tp = (char *) dst), 0, sizeof (union ib_gid));
+	endp = tp + sizeof (union ib_gid);
 	colonp = NULL;
 
 	/* Leading :: requires some special handling. */
@@ -250,7 +250,7 @@
 	struct ipoib_sarp *entry;
 	char kernel_buf[256];
 	char gid_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")];
-	tTS_IB_GID gid;
+	union ib_gid gid;
 	u32 qpn;
 
 	count = min(count, sizeof(kernel_buf));
@@ -263,13 +263,13 @@
 	if (sscanf(kernel_buf, "%39s %i", gid_buf, &qpn) != 2)
 		return -EINVAL;
 
-	if (!_ipoib_ascii_to_gid(gid_buf, gid))
+	if (!_ipoib_ascii_to_gid(gid_buf, &gid))
 		return -EINVAL;
 
 	if (qpn > 0xffffff)
 		return -EINVAL;
 
-	entry = ipoib_sarp_add(proc_arp_device, gid, qpn);
+	entry = ipoib_sarp_add(proc_arp_device, &gid, qpn);
 	if (entry)
 		ipoib_sarp_put(entry);
 
@@ -355,19 +355,19 @@
 {
 	struct ipoib_mcast_iter *iter = iter_ptr;
 	char gid_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")];
-	tTS_IB_GID mgid;
+	union ib_gid mgid;
 	int i, n;
 	unsigned long created;
 	unsigned int queuelen, complete, send_only;
 
 	if (iter) {
-		ipoib_mcast_iter_read(iter, mgid, &created, &queuelen,
+		ipoib_mcast_iter_read(iter, &mgid, &created, &queuelen,
 				      &complete, &send_only);
 
-		for (n = 0, i = 0; i < sizeof(tTS_IB_GID) / 2; ++i) {
+		for (n = 0, i = 0; i < sizeof mgid / 2; ++i) {
 			n += sprintf(gid_buf + n, "%x",
-				     be16_to_cpu(((uint16_t *)mgid)[i]));
-			if (i < sizeof(tTS_IB_GID) / 2 - 1)
+				     be16_to_cpu(((u16 *)mgid.raw)[i]));
+			if (i < sizeof mgid / 2 - 1)
 				gid_buf[n++] = ':';
 		}
 	}
Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib_multicast.c
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib_multicast.c	(revision 607)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib_multicast.c	(working copy)
@@ -46,7 +46,7 @@
 	struct ib_ah *address_handle;
 	tTS_IB_CLIENT_QUERY_TID tid;
 
-	tTS_IB_GID mgid;
+	union ib_gid mgid;
 
 	unsigned long flags;
 	unsigned char logcount;
@@ -61,9 +61,9 @@
 	struct rb_node *rb_node;
 };
 
-tTS_IB_GID ipoib_broadcast_mgid = {
-	0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
+union ib_gid ipoib_broadcast_mgid = {
+	.raw = { 0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
+		 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff }
 };
 
 /* =============================================================== */
@@ -135,7 +135,7 @@
 
 /* =============================================================== */
 /*..__ipoib_mcast_find - find multicast group            */
-struct ipoib_mcast *__ipoib_mcast_find(struct net_device *dev, tTS_IB_GID mgid)
+struct ipoib_mcast *__ipoib_mcast_find(struct net_device *dev, union ib_gid *mgid)
 {
 	struct ipoib_dev_priv *priv = dev->priv;
 	struct rb_node *n = priv->multicast_tree.rb_node;
@@ -146,7 +146,7 @@
 
 		mcast = rb_entry(n, struct ipoib_mcast, rb_node);
 
-		ret = memcmp(mgid, mcast->mgid, sizeof(tTS_IB_GID));
+		ret = memcmp(mgid->raw, mcast->mgid.raw, sizeof(union ib_gid));
 		if (ret < 0)
 			n = n->rb_left;
 		else if (ret > 0)
@@ -162,7 +162,7 @@
 
 /* =============================================================== */
 /*.._ipoib_mcast_find - find multicast group                       */
-struct ipoib_mcast *_ipoib_mcast_find(struct net_device *dev, tTS_IB_GID mgid)
+struct ipoib_mcast *_ipoib_mcast_find(struct net_device *dev, union ib_gid *mgid)
 {
 	struct ipoib_mcast *mcast;
 	struct ipoib_dev_priv *priv = dev->priv;
@@ -189,7 +189,7 @@
 		pn = *n;
 		tmcast = rb_entry(pn, struct ipoib_mcast, rb_node);
 
-		ret = memcmp(mcast->mgid, tmcast->mgid, sizeof(tTS_IB_GID));
+		ret = memcmp(mcast->mgid.raw, tmcast->mgid.raw, sizeof(union ib_gid));
 		if (ret < 0)
 			n = &pn->rb_left;
 		else if (ret > 0)
@@ -226,10 +226,10 @@
 	}
 
 	/* Set the cached Q_Key before we attach if it's the broadcast group */
-	if (memcmp(mcast->mgid, priv->bcast_gid, sizeof(tTS_IB_GID)) == 0)
+	if (!memcmp(mcast->mgid.raw, priv->bcast_gid.raw, sizeof(union ib_gid)))
 		priv->qkey = priv->broadcast->mcast_member.qkey;
 
-	ret = ipoib_mcast_attach(dev, mcast->mcast_member.mlid, mcast->mgid);
+	ret = ipoib_mcast_attach(dev, mcast->mcast_member.mlid, &mcast->mgid);
 	if (ret < 0) {
 		TS_REPORT_FATAL(MOD_IB_NET,
 				"%s: couldn't attach QP to multicast group "
@@ -256,7 +256,8 @@
 			}
 		};
 
-		memcpy(av.grh.dgid.raw, mcast->mcast_member.mgid, sizeof av.grh.dgid);
+		memcpy(av.grh.dgid.raw, mcast->mcast_member.mgid,
+		       sizeof (union ib_gid));
 
 		mcast->address_handle = ib_create_ah(priv->pd, &av);
 		if (IS_ERR(mcast->address_handle)) {
@@ -360,7 +361,7 @@
 
 	ipoib_mcast_get(mcast);
 	ret = tsIbMulticastGroupJoin(priv->ca,
-				     priv->port, mcast->mgid, priv->pkey,
+				     priv->port, mcast->mgid.raw, priv->pkey,
 /* ib_sm doesn't support send only yet
 				     TS_IB_MULTICAST_JOIN_SEND_ONLY_NON_MEMBER,
  */
@@ -427,7 +428,7 @@
 
 	status = tsIbMulticastGroupJoin(priv->ca,
 					priv->port,
-					mcast->mgid,
+					mcast->mgid.raw,
 					priv->pkey,
 					TS_IB_MULTICAST_JOIN_FULL_MEMBER,
 					HZ,
@@ -524,13 +525,11 @@
 			goto out;
 		}
 
-		memcpy(priv->bcast_gid, ipoib_broadcast_mgid,
-		       sizeof(tTS_IB_GID));
-		priv->bcast_gid[4] = (priv->pkey >> 8) & 0xff;
-		priv->bcast_gid[5] = priv->pkey & 0xff;
+		priv->bcast_gid = ipoib_broadcast_mgid;
+		priv->bcast_gid.raw[4] = (priv->pkey >> 8) & 0xff;
+		priv->bcast_gid.raw[5] = priv->pkey & 0xff;
 
-		memcpy(priv->broadcast->mgid, priv->bcast_gid,
-		       sizeof(tTS_IB_GID));
+		priv->broadcast->mgid = priv->bcast_gid;
 
 		spin_lock_irqsave(&priv->lock, flags);
 		__ipoib_mcast_add(dev, priv->broadcast);
@@ -580,7 +579,7 @@
 		priv->local_lid = port_lid.lid;
 	}
 
-	if (ib_gid_entry_get(priv->ca, priv->port, 0, priv->local_gid))
+	if (ib_gid_entry_get(priv->ca, priv->port, 0, priv->local_gid.raw))
 		TS_REPORT_WARN(MOD_IB_NET,
 			       "%s: ib_gid_entry_get() failed", dev->name);
 
@@ -589,7 +588,7 @@
 
 	dev->mtu = min(priv->mcast_mtu, priv->admin_mtu);
 
-	entry = ipoib_sarp_local_add(dev, priv->local_gid, priv->local_qpn);
+	entry = ipoib_sarp_local_add(dev, &priv->local_gid, priv->local_qpn);
 	if (entry)
 		ipoib_sarp_put(entry);
 
@@ -693,7 +692,7 @@
 		return 0;
 
 	/* Remove ourselves from the multicast group */
-	result = ipoib_mcast_detach(dev, mcast->mcast_member.mlid, mcast->mgid);
+	result = ipoib_mcast_detach(dev, mcast->mcast_member.mlid, &mcast->mgid);
 	if (result)
 		TS_REPORT_WARN(MOD_IB_NET,
 			       "%s: ipoib_mcast_detach failed (result = %d)",
@@ -737,7 +736,7 @@
 
 /* =============================================================== */
 /*.._ipoib_mcast_delete -- delete multicast group join             */
-static int _ipoib_mcast_delete(struct net_device *dev, tTS_IB_GID mgid)
+static int _ipoib_mcast_delete(struct net_device *dev, union ib_gid *mgid)
 {
 	struct ipoib_mcast *mcast;
 	struct ipoib_dev_priv *priv = dev->priv;
@@ -763,7 +762,7 @@
 /* =============================================================== */
 /*..ipoib_mcast_lookup -- return reference to multicast            */
 int ipoib_mcast_lookup(struct net_device *dev,
-				 tTS_IB_GID mgid,
+				 union ib_gid *mgid,
 				 struct ipoib_mcast **mmcast)
 {
 	struct ipoib_dev_priv *priv = dev->priv;
@@ -777,7 +776,7 @@
 		/* Let's create a new send only group now */
 		TS_TRACE(MOD_IB_NET, T_VERY_VERBOSE, TRACE_IB_NET_MULTICAST,
 			 "%s: setting up send only multicast group for "
-			 IPOIB_GID_FMT, dev->name, IPOIB_GID_ARG(mgid));
+			 IPOIB_GID_FMT, dev->name, IPOIB_GID_ARG(*mgid));
 
 		mcast = ipoib_mcast_alloc(dev);
 		if (!mcast) {
@@ -790,7 +789,7 @@
 
 		set_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags);
 
-		memcpy(mcast->mgid, mgid, sizeof(tTS_IB_GID));
+		mcast->mgid = *mgid;
 
 		__ipoib_mcast_add(dev, mcast);
 
@@ -863,7 +862,7 @@
 			nmcast->flags =
 			    mcast->flags & (1 << IPOIB_MCAST_FLAG_SENDONLY);
 
-			memcpy(nmcast->mgid, mcast->mgid, sizeof(tTS_IB_GID));
+			nmcast->mgid = mcast->mgid;
 
 			/* Add the new group in before the to-be-destroyed group */
 			list_add_tail(&nmcast->list, &mcast->list);
@@ -886,8 +885,7 @@
 	if (priv->broadcast) {
 		nmcast = ipoib_mcast_alloc(dev);
 		if (nmcast) {
-			memcpy(nmcast->mgid, priv->broadcast->mgid,
-			       sizeof(tTS_IB_GID));
+			nmcast->mgid = priv->broadcast->mgid;
 
 			rb_replace_node(&priv->broadcast->rb_node,
 					&nmcast->rb_node,
@@ -920,7 +918,7 @@
 
 	/* Delete broadcast since it will be recreated */
 	if (priv->broadcast) {
-		_ipoib_mcast_delete(dev, priv->broadcast->mgid);
+		_ipoib_mcast_delete(dev, &priv->broadcast->mgid);
 		priv->broadcast = NULL;
 	}
 }
@@ -968,21 +966,21 @@
 	/* Mark all of the entries that are found or don't exist */
 	for (im = in_dev->mc_list; im; im = im->next) {
 		u32 multiaddr = ntohl(im->multiaddr);
-		tTS_IB_GID mgid;
+		union ib_gid mgid;
 
-		memcpy(mgid, ipoib_broadcast_mgid, sizeof(tTS_IB_GID));
+		mgid = ipoib_broadcast_mgid;
 
 		/* Add in the P_Key */
-		mgid[4] = (priv->pkey >> 8) & 0xff;
-		mgid[5] = priv->pkey & 0xff;
+		mgid.raw[4] = (priv->pkey >> 8) & 0xff;
+		mgid.raw[5] = priv->pkey & 0xff;
 
 		/* Fixup the group mapping */
-		mgid[12] = (multiaddr >> 24) & 0x0f;
-		mgid[13] = (multiaddr >> 16) & 0xff;
-		mgid[14] = (multiaddr >> 8) & 0xff;
-		mgid[15] = multiaddr & 0xff;
+		mgid.raw[12] = (multiaddr >> 24) & 0x0f;
+		mgid.raw[13] = (multiaddr >> 16) & 0xff;
+		mgid.raw[14] = (multiaddr >> 8) & 0xff;
+		mgid.raw[15] = multiaddr & 0xff;
 
-		mcast = __ipoib_mcast_find(dev, mgid);
+		mcast = __ipoib_mcast_find(dev, &mgid);
 		if (!mcast
 		    || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
 			struct ipoib_mcast *nmcast;
@@ -1002,7 +1000,7 @@
 
 			set_bit(IPOIB_MCAST_FLAG_FOUND, &nmcast->flags);
 
-			memcpy(nmcast->mgid, mgid, sizeof(tTS_IB_GID));
+			nmcast->mgid = mgid;
 
 			if (mcast) {
 				/* Destroy the send only entry */
@@ -1125,7 +1123,7 @@
 /* =============================================================== */
 /*..ipoib_mcast_iter_read -- get data pointed to by multicast iterator */
 void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
-			   tTS_IB_GID mgid,
+			   union ib_gid *mgid,
 			   unsigned long *created,
 			   unsigned int *queuelen,
 			   unsigned int *complete,
@@ -1135,7 +1133,7 @@
 
 	mcast = rb_entry(iter->rb_node, struct ipoib_mcast, rb_node);
 
-	memcpy(mgid, mcast->mgid, sizeof(tTS_IB_GID));
+	*mgid = mcast->mgid;
 	*created = mcast->created;
 	*queuelen = skb_queue_len(&mcast->pkt_queue);
 	*complete = mcast->address_handle != NULL;
Index: src/linux-kernel/infiniband/include/ib_verbs.h
===================================================================
--- src/linux-kernel/infiniband/include/ib_verbs.h	(revision 613)
+++ src/linux-kernel/infiniband/include/ib_verbs.h	(working copy)
@@ -260,8 +260,12 @@
 	ib_fmr_destroy_func          fmr_destroy;
 	ib_fmr_map_func              fmr_map;
 	ib_fmr_unmap_func            fmr_unmap;
-	ib_multicast_attach_func     multicast_attach;
-	ib_multicast_detach_func     multicast_detach;
+	int                        (*attach_mcast)(struct ib_qp *qp,
+						   union ib_gid *gid,
+						   u16 lid);
+	int                        (*detach_mcast)(struct ib_qp *qp,
+						   union ib_gid *gid,
+						   u16 lid);
 	ib_mad_process_func          mad_process;
 
 	struct class_device          class_dev;
@@ -352,6 +356,9 @@
 
 int ib_dealloc_mw(struct ib_mw *mw);
 
+int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
+int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
+
 #endif /* __KERNEL __ */
 
 /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
Index: src/linux-kernel/infiniband/include/ts_ib_core_types.h
===================================================================
--- src/linux-kernel/infiniband/include/ts_ib_core_types.h	(revision 613)
+++ src/linux-kernel/infiniband/include/ts_ib_core_types.h	(working copy)
@@ -595,12 +595,6 @@
 			       u32           *rkey);
 typedef int (*ib_fmr_unmap_func)(struct ib_device *device,
 				 struct list_head *fmr_list);
-typedef int (*ib_multicast_attach_func)(struct ib_qp *qp,
-					u16        lid,
-					tTS_IB_GID gid);
-typedef int (*ib_multicast_detach_func)(struct ib_qp *qp,
-					u16        lid,
-					tTS_IB_GID gid);
 
 struct ib_mad;
 
Index: src/linux-kernel/infiniband/include/ts_ib_core.h
===================================================================
--- src/linux-kernel/infiniband/include/ts_ib_core.h	(revision 613)
+++ src/linux-kernel/infiniband/include/ts_ib_core.h	(working copy)
@@ -108,13 +108,6 @@
 			     u32                    *rkey);
 int ib_fmr_deregister(struct ib_fmr *fmr);
 
-int ib_multicast_attach(u16           multicast_lid,
-			tTS_IB_GID    multicast_gid,
-			struct ib_qp *qp);
-int ib_multicast_detach(u16           multicast_lid,
-			tTS_IB_GID    multicast_gid,
-			struct ib_qp *qp);
-
 int ib_async_event_handler_register(struct ib_async_event_record   *record,
 				    ib_async_event_handler_func     function,
 				    void                           *arg,
Index: src/linux-kernel/infiniband/core/core_mcast.c
===================================================================
--- src/linux-kernel/infiniband/core/core_mcast.c	(revision 576)
+++ src/linux-kernel/infiniband/core/core_mcast.c	(working copy)
@@ -31,25 +31,21 @@
 
 #include <linux/errno.h>
 
-int ib_multicast_attach(u16           multicast_lid,
-                        tTS_IB_GID    multicast_gid,
-                        struct ib_qp *qp)
+int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
-	IB_CHECK_MAGIC(qp, QP);
-
-	return qp->device->multicast_attach(qp, multicast_lid, multicast_gid);
+	return qp->device->attach_mcast ?
+		qp->device->attach_mcast(qp, gid, lid) :
+		-ENOSYS;
 }
-EXPORT_SYMBOL(ib_multicast_attach);
+EXPORT_SYMBOL(ib_attach_mcast);
 
-int ib_multicast_detach(u16           multicast_lid,
-                        tTS_IB_GID    multicast_gid,
-                        struct ib_qp *qp)
+int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
-	IB_CHECK_MAGIC(qp, QP);
-
-	return qp->device->multicast_detach(qp, multicast_lid, multicast_gid);
+	return qp->device->detach_mcast ?
+		qp->device->detach_mcast(qp, gid, lid) :
+		-ENOSYS;
 }
-EXPORT_SYMBOL(ib_multicast_detach);
+EXPORT_SYMBOL(ib_detach_mcast);
 
 /*
   Local Variables:
Index: src/linux-kernel/infiniband/hw/mthca/mthca_dev.h
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_dev.h	(revision 607)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_dev.h	(working copy)
@@ -340,8 +340,8 @@
 int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
 		  struct ib_ud_header *header);
 
-int mthca_multicast_attach(struct ib_qp *ibqp, u16 lid, u8 gid[16]);
-int mthca_multicast_detach(struct ib_qp *ibqp, u16 lid, u8 gid[16]);
+int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
+int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
 
 enum ib_mad_result mthca_process_mad(struct ib_device *ibdev,
                                      int               ignore_mkey,
Index: src/linux-kernel/infiniband/hw/mthca/mthca_provider.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_provider.c	(revision 612)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_provider.c	(working copy)
@@ -559,8 +559,8 @@
 	dev->ib_dev.req_notify_cq        = mthca_req_notify_cq;
 	dev->ib_dev.reg_phys_mr          = mthca_reg_phys_mr;
 	dev->ib_dev.dereg_mr             = mthca_dereg_mr;
-	dev->ib_dev.multicast_attach     = mthca_multicast_attach;
-	dev->ib_dev.multicast_detach     = mthca_multicast_detach;
+	dev->ib_dev.attach_mcast         = mthca_multicast_attach;
+	dev->ib_dev.detach_mcast         = mthca_multicast_detach;
 	dev->ib_dev.mad_process          = mthca_process_mad;
 
 	return ib_device_register(&dev->ib_dev);
Index: src/linux-kernel/infiniband/hw/mthca/mthca_mcg.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_mcg.c	(revision 576)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_mcg.c	(working copy)
@@ -122,7 +122,7 @@
 	return err;
 }
 
-int mthca_multicast_attach(struct ib_qp *ibqp, u16 lid, u8 gid[16])
+int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
 	void *mailbox;
@@ -142,13 +142,13 @@
 	if (down_interruptible(&dev->mcg_table.sem))
 		return -EINTR;
 
-	err = find_mgm(dev, gid, mgm, &hash, &prev, &index);
+	err = find_mgm(dev, gid->raw, mgm, &hash, &prev, &index);
 	if (err)
 		goto out;
 
 	if (index != -1) {
 		if (!memcmp(mgm->gid, zero_gid, 16))
-			memcpy(mgm->gid, gid, 16);
+			memcpy(mgm->gid, gid->raw, 16);
 	} else {
 		link = 1;
 
@@ -168,7 +168,7 @@
 			goto out;
 		}
 
-		memcpy(mgm->gid, gid, 16);
+		memcpy(mgm->gid, gid->raw, 16);
 		mgm->next_gid_index = 0;
 	}
 
@@ -220,7 +220,7 @@
 	return err;
 }
 
-int mthca_multicast_detach(struct ib_qp *ibqp, u16 lid, u8 gid[16])
+int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 {
 	struct mthca_dev *dev = to_mdev(ibqp->device);
 	void *mailbox;
@@ -239,17 +239,21 @@
 	if (down_interruptible(&dev->mcg_table.sem))
 		return -EINTR;
 
-	err = find_mgm(dev, gid, mgm, &hash, &prev, &index);
+	err = find_mgm(dev, gid->raw, mgm, &hash, &prev, &index);
 	if (err)
 		goto out;
 
 	if (index == -1) {	
 		mthca_err(dev, "MGID %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x "
 			  "not found\n",
-			  be16_to_cpu(((u16 *) gid)[0]), be16_to_cpu(((u16 *) gid)[1]),
-			  be16_to_cpu(((u16 *) gid)[2]), be16_to_cpu(((u16 *) gid)[3]),
-			  be16_to_cpu(((u16 *) gid)[4]), be16_to_cpu(((u16 *) gid)[5]),
-			  be16_to_cpu(((u16 *) gid)[6]), be16_to_cpu(((u16 *) gid)[7]));
+			  be16_to_cpu(((u16 *) gid->raw)[0]),
+			  be16_to_cpu(((u16 *) gid->raw)[1]),
+			  be16_to_cpu(((u16 *) gid->raw)[2]),
+			  be16_to_cpu(((u16 *) gid->raw)[3]),
+			  be16_to_cpu(((u16 *) gid->raw)[4]),
+			  be16_to_cpu(((u16 *) gid->raw)[5]),
+			  be16_to_cpu(((u16 *) gid->raw)[6]),
+			  be16_to_cpu(((u16 *) gid->raw)[7]));
 		err = -EINVAL;
 		goto out;
 	}



More information about the general mailing list