]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/core/mad.c
Merge branch 'for-linus' of git://git.infradead.org/ubi-2.6
[linux-2.6-omap-h63xx.git] / drivers / infiniband / core / mad.c
index 5ed141ebd1c86f1819819c3b15858c8d16907feb..6edfecf1be72c9d2c3b3d9559d44187cad3e16af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.
  *
@@ -31,7 +31,6 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  *
- * $Id: mad.c 5596 2006-03-03 01:00:07Z sean.hefty $
  */
 #include <linux/dma-mapping.h>
 #include <rdma/ib_cache.h>
@@ -642,7 +641,8 @@ static void snoop_recv(struct ib_mad_qp_info *qp_info,
        spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
 }
 
-static void build_smp_wc(u64 wr_id, u16 slid, u16 pkey_index, u8 port_num,
+static void build_smp_wc(struct ib_qp *qp,
+                        u64 wr_id, u16 slid, u16 pkey_index, u8 port_num,
                         struct ib_wc *wc)
 {
        memset(wc, 0, sizeof *wc);
@@ -652,7 +652,7 @@ static void build_smp_wc(u64 wr_id, u16 slid, u16 pkey_index, u8 port_num,
        wc->pkey_index = pkey_index;
        wc->byte_len = sizeof(struct ib_mad) + sizeof(struct ib_grh);
        wc->src_qp = IB_QP0;
-       wc->qp_num = IB_QP0;
+       wc->qp = qp;
        wc->slid = slid;
        wc->sl = 0;
        wc->dlid_path_bits = 0;
@@ -667,7 +667,7 @@ static void build_smp_wc(u64 wr_id, u16 slid, u16 pkey_index, u8 port_num,
 static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
                                  struct ib_mad_send_wr_private *mad_send_wr)
 {
-       int ret;
+       int ret = 0;
        struct ib_smp *smp = mad_send_wr->send_buf.mad;
        unsigned long flags;
        struct ib_mad_local_private *local;
@@ -687,14 +687,15 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
         */
        if ((ib_get_smp_direction(smp) ? smp->dr_dlid : smp->dr_slid) ==
             IB_LID_PERMISSIVE &&
-           !smi_handle_dr_smp_send(smp, device->node_type, port_num)) {
+            smi_handle_dr_smp_send(smp, device->node_type, port_num) ==
+            IB_SMI_DISCARD) {
                ret = -EINVAL;
                printk(KERN_ERR PFX "Invalid directed route\n");
                goto out;
        }
+
        /* Check to post send on QP or process locally */
-       ret = smi_check_local_smp(smp, device);
-       if (!ret)
+       if (smi_check_local_smp(smp, device) == IB_SMI_DISCARD)
                goto out;
 
        local = kmalloc(sizeof *local, GFP_ATOMIC);
@@ -713,7 +714,8 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
                goto out;
        }
 
-       build_smp_wc(send_wr->wr_id, be16_to_cpu(smp->dr_slid),
+       build_smp_wc(mad_agent_priv->agent.qp,
+                    send_wr->wr_id, be16_to_cpu(smp->dr_slid),
                     send_wr->wr.ud.pkey_index,
                     send_wr->wr.ud.port_num, &mad_wc);
 
@@ -1872,18 +1874,22 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 
        if (recv->mad.mad.mad_hdr.mgmt_class ==
            IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
-               if (!smi_handle_dr_smp_recv(&recv->mad.smp,
-                                           port_priv->device->node_type,
-                                           port_priv->port_num,
-                                           port_priv->device->phys_port_cnt))
+               if (smi_handle_dr_smp_recv(&recv->mad.smp,
+                                          port_priv->device->node_type,
+                                          port_priv->port_num,
+                                          port_priv->device->phys_port_cnt) ==
+                                          IB_SMI_DISCARD)
                        goto out;
-               if (!smi_check_forward_dr_smp(&recv->mad.smp))
+
+               if (smi_check_forward_dr_smp(&recv->mad.smp) == IB_SMI_LOCAL)
                        goto local;
-               if (!smi_handle_dr_smp_send(&recv->mad.smp,
-                                           port_priv->device->node_type,
-                                           port_priv->port_num))
+
+               if (smi_handle_dr_smp_send(&recv->mad.smp,
+                                          port_priv->device->node_type,
+                                          port_priv->port_num) == IB_SMI_DISCARD)
                        goto out;
-               if (!smi_check_local_smp(&recv->mad.smp, port_priv->device))
+
+               if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD)
                        goto out;
        }
 
@@ -2355,7 +2361,8 @@ static void local_completions(struct work_struct *work)
                         * Defined behavior is to complete response
                         * before request
                         */
-                       build_smp_wc((unsigned long) local->mad_send_wr,
+                       build_smp_wc(recv_mad_agent->agent.qp,
+                                    (unsigned long) local->mad_send_wr,
                                     be16_to_cpu(IB_LID_PERMISSIVE),
                                     0, recv_mad_agent->agent.port_num, &wc);