agent: Handle out of order send completions
(Issue pointed out by Sean)

Index: agent_priv.h
===================================================================
--- agent_priv.h        (revision 1183)
+++ agent_priv.h        (working copy)
@@ -46,7 +46,6 @@
        struct ib_mad_agent *lr_smp_agent;    /* LR SM class */
        struct ib_mad_agent *perf_mgmt_agent; /* PerfMgmt class */
        struct ib_mr *mr;
-       u64 wr_id;
 };
 
 #endif /* __IB_AGENT_PRIV_H__ */
Index: agent.c
===================================================================
--- agent.c     (revision 1192)
+++ agent.c     (working copy)
@@ -117,9 +117,9 @@
        /* PCI mapping */
        gather_list.addr = pci_map_single(mad_agent->device->dma_device,
                                          &mad->mad,
-                                         sizeof mad->mad,
+                                         sizeof(mad->mad),
                                          PCI_DMA_TODEVICE);
-       gather_list.length = sizeof mad->mad;
+       gather_list.length = sizeof(mad->mad);
        gather_list.lkey = (*port_priv->mr).lkey;
 
        send_wr.next = NULL;
@@ -172,7 +172,7 @@
                send_wr.wr.ud.remote_qkey = 0; /* for SMPs */
        }
        send_wr.wr.ud.mad_hdr = &mad->mad.mad.mad_hdr;
-       send_wr.wr_id = ++port_priv->wr_id;
+       send_wr.wr_id = (unsigned long)&agent_send_wr->send_list;
 
        pci_unmap_addr_set(agent_send_wr, mapping, gather_list.addr);
 
@@ -182,7 +182,7 @@
                spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
                pci_unmap_single(mad_agent->device->dma_device,
                                 pci_unmap_addr(agent_send_wr, mapping),
-                                sizeof mad->mad,
+                                sizeof(mad->mad),
                                 PCI_DMA_TODEVICE);
                ib_destroy_ah(agent_send_wr->ah);
                kfree(agent_send_wr);
@@ -247,31 +247,18 @@
                return;
        }
 
-       /* Completion corresponds to first entry on posted MAD send list */
        spin_lock_irqsave(&port_priv->send_list_lock, flags);
-       if (list_empty(&port_priv->send_posted_list)) {
-               spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
-               printk(KERN_ERR SPFX "Send completion WR ID 0x%Lx but send "
-                      "list is empty\n",
-                      (unsigned long long) mad_send_wc->wr_id);
-               return;
-       }
-
-       agent_send_wr = list_entry(&port_priv->send_posted_list,
-                                   struct ib_agent_send_wr,
-                                   send_list);
-       send_wr = agent_send_wr->send_list.next;
-       agent_send_wr = container_of(send_wr, struct ib_agent_send_wr,
+       send_wr = (struct list_head *)(unsigned long)mad_send_wc->wr_id;
+       agent_send_wr =  container_of(send_wr, struct ib_agent_send_wr,
                                     send_list);
-
-       /* Remove from posted send MAD list */
+       /* Remove completed send from posted send MAD list */
        list_del(&agent_send_wr->send_list);
        spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
 
        /* Unmap PCI */
        pci_unmap_single(mad_agent->device->dma_device,
                         pci_unmap_addr(agent_send_wr, mapping),
-                        sizeof agent_send_wr->mad->mad,
+                        sizeof(agent_send_wr->mad->mad),
                         PCI_DMA_TODEVICE);
 
        ib_destroy_ah(agent_send_wr->ah);
@@ -306,7 +293,6 @@
 
        memset(port_priv, 0, sizeof *port_priv);
        port_priv->port_num = port_num;
-       port_priv->wr_id = 0;
        spin_lock_init(&port_priv->send_list_lock);
        INIT_LIST_HEAD(&port_priv->send_posted_list);
 



_______________________________________________
openib-general mailing list
[EMAIL PROTECTED]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to