[openib-commits] r2660 - gen2/trunk/src/linux-kernel/infiniband/hw/mthca

roland at openib.org
Mon Jun 20 09:56:59 PDT 2005


Author: roland
Date: 2005-06-20 09:56:59 -0700 (Mon, 20 Jun 2005)
New Revision: 2660

Modified:
   gen2/trunk/src/linux-kernel/infiniband/hw/mthca/mthca_cmd.c
Log:
Use two mailboxes -- one in and one out -- for MAD_IFC command, so
that we get full 4K alignment for both mailbox addresses.

Signed-off-by: Roland Dreier <roland at topspin.com>


Modified: gen2/trunk/src/linux-kernel/infiniband/hw/mthca/mthca_cmd.c
===================================================================
--- gen2/trunk/src/linux-kernel/infiniband/hw/mthca/mthca_cmd.c 2005-06-20 16:54:59 UTC (rev 2659)
+++ gen2/trunk/src/linux-kernel/infiniband/hw/mthca/mthca_cmd.c 2005-06-20 16:56:59 UTC (rev 2660)
@@ -1585,8 +1585,8 @@
                  int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
                  void *in_mad, void *response_mad, u8 *status)
 {
-       struct mthca_mailbox *mailbox;
-       void *box;
+       struct mthca_mailbox *inmailbox, *outmailbox;
+       void *inbox;
        int err;
        u32 in_modifier = port;
        u8 op_modifier = 0;
@@ -1600,13 +1600,19 @@
 #define MAD_IFC_PKEY_OFFSET   0x10e
 #define MAD_IFC_GRH_OFFSET    0x140
 
-       mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
-       if (IS_ERR(mailbox))
-               return PTR_ERR(mailbox);
-       box = mailbox->buf;
+       inmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+       if (IS_ERR(inmailbox))
+               return PTR_ERR(inmailbox);
+       inbox = inmailbox->buf;
 
-       memcpy(box, in_mad, 256);
+       outmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+       if (IS_ERR(outmailbox)) {
+               mthca_free_mailbox(dev, inmailbox);
+               return PTR_ERR(outmailbox);
+       }
 
+       memcpy(inbox, in_mad, 256);
+
        /*
         * Key check traps can't be generated unless we have in_wc to
         * tell us where to send the trap.
@@ -1619,37 +1625,38 @@
        if (in_wc) {
                u8 val;
 
-               memset(box + 256, 0, 256);
+               memset(inbox + 256, 0, 256);
 
-               MTHCA_PUT(box, in_wc->qp_num,          MAD_IFC_MY_QPN_OFFSET);
-               MTHCA_PUT(box, in_wc->src_qp,          MAD_IFC_RQPN_OFFSET);
+               MTHCA_PUT(inbox, in_wc->qp_num,     MAD_IFC_MY_QPN_OFFSET);
+               MTHCA_PUT(inbox, in_wc->src_qp,     MAD_IFC_RQPN_OFFSET);
 
                val = in_wc->sl << 4;
-               MTHCA_PUT(box, val,               MAD_IFC_SL_OFFSET);
+               MTHCA_PUT(inbox, val,               MAD_IFC_SL_OFFSET);
 
                val = in_wc->dlid_path_bits |
                        (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
-               MTHCA_PUT(box, val,               MAD_IFC_GRH_OFFSET);
+               MTHCA_PUT(inbox, val,               MAD_IFC_GRH_OFFSET);
 
-               MTHCA_PUT(box, in_wc->slid,       MAD_IFC_RLID_OFFSET);
-               MTHCA_PUT(box, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
+               MTHCA_PUT(inbox, in_wc->slid,       MAD_IFC_RLID_OFFSET);
+               MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
 
                if (in_grh)
-                       memcpy((u8 *) box + MAD_IFC_GRH_OFFSET, in_grh, 40);
+                       memcpy(inbox + MAD_IFC_GRH_OFFSET, in_grh, 40);
 
                op_modifier |= 0x10;
 
                in_modifier |= in_wc->slid << 16;
        }
 
-       err = mthca_cmd_box(dev, mailbox->dma, mailbox->dma + 512,
+       err = mthca_cmd_box(dev, inmailbox->dma, outmailbox->dma,
                            in_modifier, op_modifier,
                            CMD_MAD_IFC, CMD_TIME_CLASS_C, status);
 
        if (!err && !*status)
-               memcpy(response_mad, box + 512, 256);
+               memcpy(response_mad, outmailbox->buf, 256);
 
-       mthca_free_mailbox(dev, mailbox);
+       mthca_free_mailbox(dev, inmailbox);
+       mthca_free_mailbox(dev, outmailbox);
        return err;
 }
 



More information about the openib-commits mailing list