[MTHCA] bugfix: in support of IB_SEND_OPT_FENCE flag in post_send methods
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 1 Aug 2006 10:14:58 +0000 (10:14 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 1 Aug 2006 10:14:58 +0000 (10:14 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@436 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/kernel/mthca_doorbell.h
hw/mthca/kernel/mthca_qp.c
hw/mthca/user/mlnx_uvp_doorbell.h
hw/mthca/user/mlnx_uvp_qp.c

index e7a83f3..bd70b60 100644 (file)
 #define MTHCA_CQ_DOORBELL      0x20
 #define MTHCA_EQ_DOORBELL      0x28
 
+enum {
+       MTHCA_SEND_DOORBELL_FENCE = 1 << 5
+};
+
 #if BITS_PER_LONG == 64
 /*
  * Assume that we can just write a 64-bit doorbell atomically.  s390
index b9734df..6afc02a 100644 (file)
@@ -1504,7 +1504,7 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr,
        int i;
        int size;
        int size0 = 0;
-       u32 f0 = 0;
+       u32 f0 = unlikely(wr->send_opt & IB_SEND_OPT_FENCE) ? MTHCA_SEND_DOORBELL_FENCE : 0;
        int ind;
        u8 op0 = 0;
        enum ib_wr_opcode opcode;
@@ -1516,10 +1516,6 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr,
 
        ind = qp->sq.next_ind;
 
-       /* prepare fence bit for the doorbell */
-       if (wr->send_opt & IB_SEND_OPT_FENCE)
-               f0 = 1 << 5;
-
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
                if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
                        HCA_PRINT(TRACE_LEVEL_ERROR,HCA_DBG_QP,("SQ %06x full (%u head, %u tail,"
@@ -1859,7 +1855,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr,
        int i;
        int size;
        int size0 = 0;
-       u32 f0 = 0;
+       u32 f0 = unlikely(wr->send_opt & IB_SEND_OPT_FENCE) ? MTHCA_SEND_DOORBELL_FENCE : 0;
        int ind;
        u8 op0 = 0;
        enum ib_wr_opcode opcode;
@@ -1871,10 +1867,6 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr,
 
        ind = qp->sq.head & (qp->sq.max - 1);
 
-       /* prepare fence bit for the doorbell */
-       if (wr->send_opt & IB_SEND_OPT_FENCE)
-               f0 = 1 << 5;
-
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
                if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) {
                        nreq = 0;
@@ -1883,6 +1875,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr,
                        doorbell[1] = cl_hton32((qp->qpn << 8) | size0);
                        qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB;
                        size0 = 0;
+                       f0 = unlikely(wr->send_opt & IB_SEND_OPT_FENCE) ? MTHCA_SEND_DOORBELL_FENCE : 0;
 
                        /*
                         * Make sure that descriptors are written before
index d8741a7..7d19725 100644 (file)
 #ifndef DOORBELL_H
 #define DOORBELL_H
 
+enum {
+       MTHCA_SEND_DOORBELL_FENCE = 1 << 5
+};
+
 #if defined (_WIN64)
 
 
index 9f9f771..7d3be01 100644 (file)
@@ -147,7 +147,7 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
        int i;
        int size;
        int size0 = 0;
-       uint32_t f0 = 0;
+       uint32_t f0 = unlikely(wr->send_opt & IB_SEND_OPT_FENCE) ? MTHCA_SEND_DOORBELL_FENCE : 0;
        int ind;
        int op0 = 0;
        enum ib_wr_opcode opcode;
@@ -166,10 +166,6 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
                goto err_busy;
        }
 
-       /* prepare fence bit for the doorbell */
-       if (wr->send_opt & IB_SEND_OPT_FENCE)
-               f0 = 1 << 5;
-
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
 
                if (mthca_wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) {
@@ -536,7 +532,7 @@ int mthca_arbel_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
        int i;
        int size;
        int size0 = 0;
-       uint32_t f0 = 0;
+       uint32_t f0 = unlikely(wr->send_opt & IB_SEND_OPT_FENCE) ? MTHCA_SEND_DOORBELL_FENCE : 0;
        int ind;
        uint8_t op0 = 0;
        enum ib_wr_opcode opcode;
@@ -555,10 +551,6 @@ int mthca_arbel_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
                goto err_busy;
        }
 
-       /* prepare fence bit for the doorbell */
-       if (wr->send_opt & IB_SEND_OPT_FENCE)
-               f0 = 1 << 5;
-
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
                if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) {
                        nreq = 0;
@@ -568,6 +560,7 @@ int mthca_arbel_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
                        doorbell[1] = cl_hton32((ibqp->qp_num << 8) | size0);
                        qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB;
                        size0 = 0;
+                       f0 = unlikely(wr->send_opt & IB_SEND_OPT_FENCE) ? MTHCA_SEND_DOORBELL_FENCE : 0;
 
                        /*
                         * Make sure that descriptors are written before