components/open-fabrics/libsif/patches/004-Bug23743649.patch
author sreynata <sreyas.natarajan@oracle.com>
Tue, 26 Jul 2016 11:56:10 -0700
branchs11u3-sru
changeset 6479 5730eca693a9
permissions -rw-r--r--
23188922 libsif to support TSL policy 23743649 Userland changes for sqs-flush errors

# This patch is fix for the Bug-22995977
# It is developed By solaris PSIF team. We plan to have a common upstream repo
# and submit these changes to it, but do not yet have a target date of doing it
diff -r 7ecef74fde26 src/sndrcv.c
--- a/src/sndrcv.c	Wed Jul 20 03:09:52 2016 -0700
+++ b/src/sndrcv.c	Wed Jul 20 04:48:09 2016 -0700
@@ -68,6 +68,9 @@
 #define CB_KICK_MASK  (CB_KICK_ALIGN - 1)
 
 #define SQS_ACTIVE (get_psif_sq_hw__sq_next(qp->sq.hw) != 0xFFFFFFFF)
+
+bool reliable_qp(enum ibv_qp_type type);
+
 #ifdef _ILP32
 int sif_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, struct ibv_send_wr **bad_wr)
 {
@@ -96,6 +99,13 @@
     struct sif_qp *qp = to_sqp(ibqp);
     struct sif_sq *sq = &qp->sq;
 
+#ifdef HAVE_VERBS_REGISTER_DRIVER
+     struct ibv_qp *ibv_qp = &qp->verbs_qp.qp;
+#else
+     struct ibv_qp *ibv_qp = &qp->ibv_qp;
+#endif
+
+
     if (!qp->sq.m.sz)  /* no user space mappings, go via kernel */
         return ibv_cmd_post_send(ibqp, wr, bad_wr);
 
@@ -128,16 +138,43 @@
 	    }
 	    pthread_mutex_unlock(&sq->lock);
     }
+    if (reliable_qp(ibv_qp->qp_type)
+	&& ibv_qp->state == IBV_QPS_ERR) {
+	    ret = 0;
+	    goto flush_sq_wa4074;
+    }
 
     return 0;
 
  err_post_send:
     pthread_mutex_unlock(&sq->lock);
     *bad_wr = wr;
+
+flush_sq_wa4074:
+    /* WA #4074, issue SQ flush if QP in ERROR. */
+#if SIF_UVERBS_ABI_VERSION > SIF_UVERBS_VERSION(3,3)
+    if (reliable_qp(ibv_qp->qp_type)
+       && ibv_qp->state == IBV_QPS_ERR) {
+
+       struct sif_context *uc = to_sctx(ibqp->context);
+       struct ibv_qp_attr attr;
+       memset(&attr, 0, sizeof(attr));
+
+       if (flush_qp(ibv_qp, &attr, FLUSH_SQ))
+           sif_log(uc, SIF_INFO, "failed to flush SQ, QP %d",
+               ibv_qp->qp_num);
+    }
+#endif
+
     return ret;
 }
 #undef SQS_ACTIVE
 
+bool reliable_qp(enum ibv_qp_type type)
+{
+    return (type == IBV_QPT_RC);
+}
+
 /* Return bypass mode offset or 0 if invalid for post_sends (see below)
  * (PSIF will take care of rejecting the post)
  */
@@ -225,9 +262,12 @@
                 "next_seq %x length %d", rq->entries, rq->extent,
                 rq->index, rq->m.base, rq->sw->next_seq, rq->sw->length);
     }
-    /* Notify hw of new entries */
+
+    /* Enforce ordering of new rq entries and tail */
     wmb();
     set_psif_rq_sw__tail_indx(&rq->sw->d, rq->sw->next_seq);
+    /* Enforce visibility of rq tail on hw */
+    wmb();
 
     sif_log(uc, SIF_RCV, "Exit: success");
  err_post_recv:
diff -r 7ecef74fde26 src/uverbs.c
--- a/src/uverbs.c	Wed Jul 20 03:09:52 2016 -0700
+++ b/src/uverbs.c	Wed Jul 20 04:48:09 2016 -0700
@@ -388,7 +388,7 @@
 #if defined(__SVR4) && defined(__sun)
         cq->m.sz = page_align(cq->m.sz);
         off64_t offset = mmap_set_cmd(SIF_MAP_CQ, cq->index);
-        cq->m.base = mmap64(NULL, cq->m.sz, PROT_READ, MAP_SHARED, fd, offset);
+	cq->m.base = mmap64(NULL, cq->m.sz, PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset);
 #else
         off_t offset = mmap_set_cmd(SIF_MAP_CQ, cq->index);
         cq->m.base = mmap(NULL, cq->m.sz, PROT_READ, MAP_SHARED, fd, offset);