[openib-general] [PATCH] ib_mad: Implement ib_free_recv_mad routine

Hal Rosenstock halr at voltaire.com
Wed Sep 15 09:38:24 PDT 2004


ib_mad: Implement ib_free_recv_mad routine

Index: ib_mad_priv.h
===================================================================
--- ib_mad_priv.h	(revision 841)
+++ ib_mad_priv.h	(working copy)
@@ -82,6 +82,7 @@
 };
 
 struct ib_mad_private_header {
+	struct ib_mad_recv_wc recv_wc; /* must be first member (for now !!!)
*/
 	struct list_head mad_list;
 	struct ib_mad_buf buf;
 	struct ib_mad_recv_buf recv_buf;
Index: ib_mad.c
===================================================================
--- ib_mad.c	(revision 841)
+++ ib_mad.c	(working copy)
@@ -359,6 +359,16 @@
 }
 EXPORT_SYMBOL(ib_post_send_mad);
 
+/*
+ * ib_free_recv_mad - Returns data buffers used to receive a MAD to the
+ *   access layer.
+ */
+void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc)
+{
+	kfree(mad_recv_wc); /* RMPP !!! */
+}
+EXPORT_SYMBOL(ib_free_recv_mad);
+
 static inline u8 convert_mgmt_class(u8 mgmt_class)
 {
 	/* Alias IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE to 0 */
@@ -669,7 +679,6 @@
 static void ib_mad_recv_done_handler(struct ib_mad_port_private
*port_priv,
 				     struct ib_wc *wc)
 {
-	struct ib_mad_recv_wc recv_wc;
 	struct ib_mad_private *recv;
 	unsigned long flags;
 	u32 qp_num;
@@ -707,9 +716,9 @@
 			 PCI_DMA_FROMDEVICE);
 
 	/* Setup MAD receive work completion from "normal" work completion */
-	recv_wc.wc = wc;
-	recv_wc.mad_len = sizeof(struct ib_mad); /* Should this be based on
wc->byte_len ? Also, RMPP !!! */
-	recv_wc.recv_buf = &recv->header.recv_buf;
+	recv->header.recv_wc.wc = wc;
+	recv->header.recv_wc.mad_len = sizeof(struct ib_mad); /* Should this
be based on wc->byte_len ? Also, RMPP !!! */
+	recv->header.recv_wc.recv_buf = &recv->header.recv_buf;
 
 	/* Setup MAD receive buffer */
 	recv->header.recv_buf.list.next = NULL; /* Until RMPP implemented !!!
*/
@@ -742,7 +751,7 @@
 
 		/* Invoke receive callback */	
 		mad_agent->agent->recv_handler(mad_agent->agent,
-					       &recv_wc);
+					       &recv->header.recv_wc);
 	}
 	spin_unlock_irqrestore(&port_priv->reg_lock, flags);
 
@@ -933,9 +942,10 @@
 	/* 
 	 * Allocate memory for receive buffer.
 	 * This is for both MAD and private header
-	 * which serves as the receive tracking structure.
-	 * By prepending thisheader, there is one rather 
-	 * than two memory allocations.
+	 * which contains the receive tracking structure.
+	 * By prepending this header, there is one rather 
+	 * than multiple memory allocations.
+	 * Ths will need revisiting for RMPP !!!
 	 */
 	mad_priv = kmalloc(sizeof *mad_priv,
 		       	   (in_atomic() || irqs_disabled()) ?





More information about the general mailing list