[openib-general] [PATCH] user_mad: Add receive side RMPP support

Hal Rosenstock halr at voltaire.com
Thu Jun 30 09:46:08 PDT 2005


user_mad: Add receive side RMPP support

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

Index: user_mad.c
===================================================================
--- user_mad.c	(revision 2760)
+++ user_mad.c	(working copy)
@@ -176,7 +176,7 @@
 	if (mad_recv_wc->wc->status != IB_WC_SUCCESS)
 		goto out;
 
-	length = 256;	/* until RMPP is supported */
+	length = mad_recv_wc->mad_len; 
 	packet = kmalloc(sizeof *packet + length, GFP_KERNEL);
 	if (!packet)
 		goto out;
@@ -184,7 +184,8 @@
 	memset(packet, 0, sizeof *packet + length);
 	packet->length = length;
 
-	memcpy(packet->mad.data, mad_recv_wc->recv_buf.mad, length);
+	ib_coalesce_recv_mad(mad_recv_wc, packet->mad.data);
+
 	packet->mad.hdr.status    = 0;
 	packet->mad.hdr.qpn 	  = cpu_to_be32(mad_recv_wc->wc->src_qp);
 	packet->mad.hdr.lid 	  = cpu_to_be16(mad_recv_wc->wc->slid);
@@ -214,7 +215,7 @@
 	struct ib_umad_packet *packet;
 	ssize_t ret;
 
-	if (count < sizeof (struct ib_user_mad) + 256) /* until RMPP supported */ 
+	if (count < sizeof (struct ib_user_mad) + sizeof (struct ib_mad))
 		return -EINVAL;
 
 	spin_lock_irq(&file->recv_lock);
@@ -238,13 +239,14 @@
 	spin_unlock_irq(&file->recv_lock);
 
 	if (count < packet->length + sizeof (struct ib_user_mad))
-		ret = -EINVAL;
+		/* return length needed if too small */
+		ret = packet->length + sizeof (struct ib_user_mad);
 	else if (copy_to_user(buf, &packet->mad,
 			      packet->length + sizeof (struct ib_user_mad)))
 		ret = -EFAULT;
 	else
 		ret = packet->length + sizeof (struct ib_user_mad);
-	if (ret < 0) {
+	if (ret < 0 || count < packet->length + sizeof (struct ib_user_mad)) {
 		/* Requeue packet */
 		spin_lock_irq(&file->recv_lock);
 		list_add(&packet->list, &file->recv_list);






More information about the general mailing list