[openib-general] [PATCH] ib_mad: Fix return posted receive MAD routine

Hal Rosenstock halr at voltaire.com
Tue Oct 5 12:03:12 PDT 2004


ib_mad: Fix return posted receive MAD routine

Index: ib_mad.c
===================================================================
--- ib_mad.c	(revision 924)
+++ ib_mad.c	(working copy)
@@ -1327,15 +1327,35 @@
 {
 	int i;
 	unsigned long flags;
+	struct ib_mad_private_header *mad_priv_hdr;
+	struct ib_mad_recv_buf *rbuf;
+	struct ib_mad_private *recv;
 
 	for (i = 0; i < IB_MAD_QPS_CORE; i++) {
 		spin_lock_irqsave(&port_priv->recv_list_lock, flags);
 		while (!list_empty(&port_priv->recv_posted_mad_list[i])) {
 
-			/* PCI mapping !!! */
+			rbuf = list_entry(&port_priv->recv_posted_mad_list[i],
+					   struct ib_mad_recv_buf, list);
+			rbuf = (struct ib_mad_recv_buf *)rbuf->list.next;
+			mad_priv_hdr = container_of(rbuf,
+						    struct ib_mad_private_header,
+						    recv_buf);
+			recv = container_of(mad_priv_hdr,
+					    struct ib_mad_private, header);
 
-			list_del(&port_priv->recv_posted_mad_list[i]);
+			/* Remove for posted receive MAD list */
+			list_del(&recv->header.recv_buf.list);
+ 
+			/* Undo PCI mapping */
+			pci_unmap_single(port_priv->device->dma_device,
+					 pci_unmap_addr(&recv->header, mapping),
+					 sizeof(struct ib_mad_private) -
+					 sizeof(struct ib_mad_private_header),
+					 PCI_DMA_FROMDEVICE);
 
+			kmem_cache_free(ib_mad_cache, recv);
+
 		}
 
 		INIT_LIST_HEAD(&port_priv->recv_posted_mad_list[i]);
@@ -1352,14 +1372,7 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&port_priv->send_list_lock, flags);
-	while (!list_empty(&port_priv->send_posted_mad_list)) {
-
-		list_del(&port_priv->send_posted_mad_list);
-
-		/* Call completion handler with flushed status !!! */
-
-	}
-
+	/* Just clear port send posted MAD list */
 	INIT_LIST_HEAD(&port_priv->send_posted_mad_list);
 	port_priv->send_posted_mad_count = 0;
 	spin_unlock_irqrestore(&port_priv->send_list_lock, flags);






More information about the general mailing list