[openib-general] [PATCH] Gen2 OpenSM

Tom Duffy tduffy at sun.com
Thu Dec 23 14:20:11 PST 2004


On Thu, 2004-12-23 at 23:48 +0200, shaharf wrote: 
> I will send a proper patch on Sunday.

BTW, your mailer munged the whitespace.

> _________________________________
>  
> static int mad_is_solicit(struct ib_mad_hdr *madhdr)
> {
>         int method = madhdr->method;
> 
>         // filter only request methods according to IB spec V1.2 13.4.5 and C13-6

Please don't use C++ isms in the kernel code.

Anyways, here is the patch from the whitespace-fixed, comment-fixed
version:

Index: drivers/infiniband/core/user_mad.c
===================================================================
--- drivers/infiniband/core/user_mad.c	(revision 1377)
+++ drivers/infiniband/core/user_mad.c	(working copy)
@@ -222,6 +222,21 @@
 	return ret;
 }
 
+static int mad_is_solicit(struct ib_mad_hdr *madhdr)
+{
+	int method = madhdr->method;
+
+	/*
+	 * filter only request methods according to
+	 * IB spec V1.2 13.4.5 and C13-6
+	 */
+	return (method < IB_MGMT_METHOD_RESP &&
+		method != IB_MGMT_METHOD_SEND &&
+		method != IB_MGMT_METHOD_TRAP &&
+		method != IB_MGMT_METHOD_TRAP_REPRESS);
+}
+
+
 static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 			     size_t count, loff_t *pos)
 {
@@ -263,10 +278,12 @@
 		goto err_up;
 	}
 
-	((struct ib_mad_hdr *) packet->mad.data)->tid =
-		cpu_to_be64(((u64) agent->hi_tid) << 32 |
-			    (be64_to_cpu(((struct ib_mad_hdr *) packet->mad.data)->tid) &
-			     0xffffffff));
+	if (mad_is_solicit((struct ib_mad_hdr *)packet->mad.data)) {
+		((struct ib_mad_hdr *) packet->mad.data)->tid =
+			cpu_to_be64(((u64) agent->hi_tid) << 32 |
+				(be64_to_cpu(((struct ib_mad_hdr *)
+					packet->mad.data)->tid) & 0xffffffff));
+	}
 
 	memset(&ah_attr, 0, sizeof ah_attr);
 	ah_attr.dlid          = be16_to_cpu(packet->mad.lid);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20041223/0c181ac7/attachment.sig>


More information about the general mailing list