[openib-general] [PATCH] ib_mad.c: Fix bug in completion handler when status != success

Hal Rosenstock
Mon Oct 25 19:01:07 PDT 2004


ib_mad.c: Fix bug in completion handler when status != success

ib_mad_completion_handler switches on wc.opcode, even if wc.status is
not SUCCESS.  This isn't correct, since according to the IB spec,
wc.opcode may not be valid if the completion has an unsuccessful
status.

Index: ib_mad.c
===================================================================
--- ib_mad.c    (revision 1069)
+++ ib_mad.c    (working copy)
@@ -1165,27 +1165,24 @@
        ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
        
        while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) {
-               printk(KERN_DEBUG PFX "Completion opcode 0x%x WRID 0x%Lx\n",
-                      wc.opcode, (unsigned long long) wc.wr_id);
-               switch (wc.opcode) {
-               case IB_WC_SEND:
-                       if (wc.status != IB_WC_SUCCESS)
-                               printk(KERN_ERR PFX "Send completion error %d\n",
-                                      wc.status);
-                       ib_mad_send_done_handler(port_priv, &wc);
-                       break;
-               case IB_WC_RECV:
-                       if (wc.status != IB_WC_SUCCESS)
-                               printk(KERN_ERR PFX "Recv completion error %d\n",
-                                      wc.status);
-                       ib_mad_recv_done_handler(port_priv, &wc);
-                       break;
-               default:
-                       printk(KERN_ERR PFX "Wrong Opcode 0x%x on completion\n",
-                              wc.opcode);
-                       if (wc.status) {
-                               printk(KERN_ERR PFX "Completion error %d\n",
-                                      wc.status);
+               if (wc.status != IB_WC_SUCCESS) {
+                       printk(KERN_ERR PFX "Completion error %d WRID 0x%Lx\n",
+                                       wc.status, (unsigned long long)
wc.wr_id);
+               } else {
+                       printk(KERN_DEBUG PFX "Completion opcode 0x%x WRID 0x%Lx\n",
+                              wc.opcode, (unsigned long long) wc.wr_id);
+
+                       switch (wc.opcode) {
+                       case IB_WC_SEND:
+                               ib_mad_send_done_handler(port_priv, &wc);
+                               break;
+                       case IB_WC_RECV:
+                               ib_mad_recv_done_handler(port_priv, &wc);
+                               break;
+                       default:
+                               printk(KERN_ERR PFX "Wrong Opcode 0x%x on completion\n",
+                                      wc.opcode);
+                               break;
                        }
                }
        }





More information about the openib-general mailing list