IB/hfi1, qib, rdmavt: Move two IB event functions into rdmavt
authorBrian Welty <brian.welty@intel.com>
Wed, 8 Feb 2017 13:27:01 +0000 (05:27 -0800)
committerDoug Ledford <dledford@redhat.com>
Sun, 19 Feb 2017 14:18:38 +0000 (09:18 -0500)
Add rvt_rc_error() and rvt_comm_est() as shared functions in
rdmavt, moved from hfi1/qib logic.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Brian Welty <brian.welty@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
14 files changed:
drivers/infiniband/hw/hfi1/qp.c
drivers/infiniband/hw/hfi1/qp.h
drivers/infiniband/hw/hfi1/rc.c
drivers/infiniband/hw/hfi1/ruc.c
drivers/infiniband/hw/hfi1/uc.c
drivers/infiniband/hw/hfi1/ud.c
drivers/infiniband/hw/hfi1/verbs.h
drivers/infiniband/hw/qib/qib_rc.c
drivers/infiniband/hw/qib/qib_ruc.c
drivers/infiniband/hw/qib/qib_uc.c
drivers/infiniband/hw/qib/qib_ud.c
drivers/infiniband/hw/qib/qib_verbs.h
drivers/infiniband/sw/rdmavt/qp.c
include/rdma/rdmavt_qp.h

index 48d59e7175c127e6df74975df653aff36214f439..8f66c58b3afb94d5e985c9a3382e0a8bc13ec6ee 100644 (file)
@@ -784,19 +784,6 @@ void qp_iter_print(struct seq_file *s, struct qp_iter *iter)
                   qp->pid);
 }
 
-void qp_comm_est(struct rvt_qp *qp)
-{
-       qp->r_flags |= RVT_R_COMM_EST;
-       if (qp->ibqp.event_handler) {
-               struct ib_event ev;
-
-               ev.device = qp->ibqp.device;
-               ev.element.qp = &qp->ibqp;
-               ev.event = IB_EVENT_COMM_EST;
-               qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
-       }
-}
-
 void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp,
                    gfp_t gfp)
 {
index 587d84d65bb8124656e0ad2b56686f6ac964978a..4012fc5e1d6ec8fb6c128e8387a7cf18f993eefa 100644 (file)
@@ -131,12 +131,6 @@ int qp_iter_next(struct qp_iter *iter);
  */
 void qp_iter_print(struct seq_file *s, struct qp_iter *iter);
 
-/**
- * qp_comm_est - handle trap with QP established
- * @qp: the QP
- */
-void qp_comm_est(struct rvt_qp *qp);
-
 void _hfi1_schedule_send(struct rvt_qp *qp);
 void hfi1_schedule_send(struct rvt_qp *qp);
 
index abea4b7c92f44b11ee95ad0cdb5b3537274223b4..bb527154512754841142f03d98b4a0903c63c17c 100644 (file)
@@ -1966,25 +1966,6 @@ send_ack:
        return 0;
 }
 
-void hfi1_rc_error(struct rvt_qp *qp, enum ib_wc_status err)
-{
-       unsigned long flags;
-       int lastwqe;
-
-       spin_lock_irqsave(&qp->s_lock, flags);
-       lastwqe = rvt_error_qp(qp, err);
-       spin_unlock_irqrestore(&qp->s_lock, flags);
-
-       if (lastwqe) {
-               struct ib_event ev;
-
-               ev.device = qp->ibqp.device;
-               ev.element.qp = &qp->ibqp;
-               ev.event = IB_EVENT_QP_LAST_WQE_REACHED;
-               qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
-       }
-}
-
 static inline void update_ack_queue(struct rvt_qp *qp, unsigned n)
 {
        unsigned next;
@@ -2185,7 +2166,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
        }
 
        if (qp->state == IB_QPS_RTR && !(qp->r_flags & RVT_R_COMM_EST))
-               qp_comm_est(qp);
+               rvt_comm_est(qp);
 
        /* OK, process the packet. */
        switch (opcode) {
@@ -2517,7 +2498,7 @@ rnr_nak:
        return;
 
 nack_op_err:
-       hfi1_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
        qp->r_nak_state = IB_NAK_REMOTE_OPERATIONAL_ERROR;
        qp->r_ack_psn = qp->r_psn;
        /* Queue NAK for later */
@@ -2527,7 +2508,7 @@ nack_op_err:
 nack_inv_unlck:
        spin_unlock_irqrestore(&qp->s_lock, flags);
 nack_inv:
-       hfi1_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
        qp->r_nak_state = IB_NAK_INVALID_REQUEST;
        qp->r_ack_psn = qp->r_psn;
        /* Queue NAK for later */
@@ -2537,7 +2518,7 @@ nack_inv:
 nack_acc_unlck:
        spin_unlock_irqrestore(&qp->s_lock, flags);
 nack_acc:
-       hfi1_rc_error(qp, IB_WC_LOC_PROT_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_PROT_ERR);
        qp->r_nak_state = IB_NAK_REMOTE_ACCESS_ERROR;
        qp->r_ack_psn = qp->r_psn;
 send_ack:
index 717ed4b159d3df57c499345f9460171329174c72..a1e2b6ab94faea1fe4c2d384aef46d235524d4fd 100644 (file)
@@ -637,7 +637,7 @@ acc_err:
        wc.status = IB_WC_LOC_PROT_ERR;
 err:
        /* responder goes to error state */
-       hfi1_rc_error(qp, wc.status);
+       rvt_rc_error(qp, wc.status);
 
 serr:
        spin_lock_irqsave(&sqp->s_lock, flags);
index 74b7b2be458c180db978b59af7adcdc00d1edac2..782a0bfeedb7544ba40cf803981120f80eef125b 100644 (file)
@@ -384,7 +384,7 @@ inv:
        }
 
        if (qp->state == IB_QPS_RTR && !(qp->r_flags & RVT_R_COMM_EST))
-               qp_comm_est(qp);
+               rvt_comm_est(qp);
 
        /* OK, process the packet. */
        switch (opcode) {
@@ -584,5 +584,5 @@ drop:
        return;
 
 op_err:
-       hfi1_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
 }
index 6d81d79720b09b8799602c500ff1d7f2953020fc..58cd30104ec237925f9b62da8e97a251b4a4120b 100644 (file)
@@ -167,7 +167,7 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
 
                ret = hfi1_rvt_get_rwqe(qp, 0);
                if (ret < 0) {
-                       hfi1_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+                       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
                        goto bail_unlock;
                }
                if (!ret) {
@@ -796,7 +796,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
 
                ret = hfi1_rvt_get_rwqe(qp, 0);
                if (ret < 0) {
-                       hfi1_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+                       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
                        return;
                }
                if (!ret) {
index e6b893010e6d4b1dc2b920f9df318f9aa67a5ae1..39b0074e9c4362c972253dae2abcb0b708c84067 100644 (file)
@@ -327,8 +327,6 @@ void hfi1_stop_rc_timers(struct rvt_qp *qp);
 
 void hfi1_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr);
 
-void hfi1_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
-
 void hfi1_ud_rcv(struct hfi1_packet *packet);
 
 int hfi1_lookup_pkey_idx(struct hfi1_ibport *ibp, u16 pkey);
index 696bcd0d087c9aea79a97f086c2a6c7a147b1778..5b0d01be7e50c02bd1e1476a9138852bb1bfd18c 100644 (file)
@@ -1765,25 +1765,6 @@ send_ack:
        return 0;
 }
 
-void qib_rc_error(struct rvt_qp *qp, enum ib_wc_status err)
-{
-       unsigned long flags;
-       int lastwqe;
-
-       spin_lock_irqsave(&qp->s_lock, flags);
-       lastwqe = rvt_error_qp(qp, err);
-       spin_unlock_irqrestore(&qp->s_lock, flags);
-
-       if (lastwqe) {
-               struct ib_event ev;
-
-               ev.device = qp->ibqp.device;
-               ev.element.qp = &qp->ibqp;
-               ev.event = IB_EVENT_QP_LAST_WQE_REACHED;
-               qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
-       }
-}
-
 static inline void qib_update_ack_queue(struct rvt_qp *qp, unsigned n)
 {
        unsigned next;
@@ -1895,17 +1876,8 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
                break;
        }
 
-       if (qp->state == IB_QPS_RTR && !(qp->r_flags & RVT_R_COMM_EST)) {
-               qp->r_flags |= RVT_R_COMM_EST;
-               if (qp->ibqp.event_handler) {
-                       struct ib_event ev;
-
-                       ev.device = qp->ibqp.device;
-                       ev.element.qp = &qp->ibqp;
-                       ev.event = IB_EVENT_COMM_EST;
-                       qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
-               }
-       }
+       if (qp->state == IB_QPS_RTR && !(qp->r_flags & RVT_R_COMM_EST))
+               rvt_comm_est(qp);
 
        /* OK, process the packet. */
        switch (opcode) {
@@ -2197,7 +2169,7 @@ rnr_nak:
        return;
 
 nack_op_err:
-       qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
        qp->r_nak_state = IB_NAK_REMOTE_OPERATIONAL_ERROR;
        qp->r_ack_psn = qp->r_psn;
        /* Queue NAK for later */
@@ -2211,7 +2183,7 @@ nack_op_err:
 nack_inv_unlck:
        spin_unlock_irqrestore(&qp->s_lock, flags);
 nack_inv:
-       qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
        qp->r_nak_state = IB_NAK_INVALID_REQUEST;
        qp->r_ack_psn = qp->r_psn;
        /* Queue NAK for later */
@@ -2225,7 +2197,7 @@ nack_inv:
 nack_acc_unlck:
        spin_unlock_irqrestore(&qp->s_lock, flags);
 nack_acc:
-       qib_rc_error(qp, IB_WC_LOC_PROT_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_PROT_ERR);
        qp->r_nak_state = IB_NAK_REMOTE_ACCESS_ERROR;
        qp->r_ack_psn = qp->r_psn;
 send_ack:
index e54a2feeeb107d27ce5235037932a2a3c34283a3..5e9f5e35699df1024b6c20f7bce757243cfa524a 100644 (file)
@@ -621,7 +621,7 @@ acc_err:
        wc.status = IB_WC_LOC_PROT_ERR;
 err:
        /* responder goes to error state */
-       qib_rc_error(qp, wc.status);
+       rvt_rc_error(qp, wc.status);
 
 serr:
        spin_lock_irqsave(&sqp->s_lock, flags);
index 5b2d483451ad8e6ea8faef52a1404586a095d766..b337b60fc40d6aa4079086ad1ff1f8710c22b472 100644 (file)
@@ -325,17 +325,8 @@ inv:
                goto inv;
        }
 
-       if (qp->state == IB_QPS_RTR && !(qp->r_flags & RVT_R_COMM_EST)) {
-               qp->r_flags |= RVT_R_COMM_EST;
-               if (qp->ibqp.event_handler) {
-                       struct ib_event ev;
-
-                       ev.device = qp->ibqp.device;
-                       ev.element.qp = &qp->ibqp;
-                       ev.event = IB_EVENT_COMM_EST;
-                       qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
-               }
-       }
+       if (qp->state == IB_QPS_RTR && !(qp->r_flags & RVT_R_COMM_EST))
+               rvt_comm_est(qp);
 
        /* OK, process the packet. */
        switch (opcode) {
@@ -527,7 +518,7 @@ drop:
        return;
 
 op_err:
-       qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
        return;
 
 }
index f45cad1198b058ddcf385a7ed78342dd8bc06d26..04befa2551cdf2bfddab22a74e3262b31d58d832 100644 (file)
@@ -152,7 +152,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
 
                ret = qib_get_rwqe(qp, 0);
                if (ret < 0) {
-                       qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+                       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
                        goto bail_unlock;
                }
                if (!ret) {
@@ -548,7 +548,7 @@ void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
 
                ret = qib_get_rwqe(qp, 0);
                if (ret < 0) {
-                       qib_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
+                       rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
                        return;
                }
                if (!ret) {
index 94fd30fdedac5a637c70506e5c5e080d3592018f..e399cb0fb4ee0bb41249c73a0c4af041eb2667ba 100644 (file)
@@ -326,8 +326,6 @@ void qib_rc_rnr_retry(unsigned long arg);
 
 void qib_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr);
 
-void qib_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
-
 int qib_post_ud_send(struct rvt_qp *qp, struct ib_send_wr *wr);
 
 void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
index 2a13ac660f2ba44dae639a2ac3cb5adfbc3bc418..444b06cada229f1ba21a1f4131576f6c70e5d920 100644 (file)
@@ -1868,3 +1868,41 @@ int rvt_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
        }
        return 0;
 }
+
+/**
+ * qp_comm_est - handle trap with QP established
+ * @qp: the QP
+ */
+void rvt_comm_est(struct rvt_qp *qp)
+{
+       qp->r_flags |= RVT_R_COMM_EST;
+       if (qp->ibqp.event_handler) {
+               struct ib_event ev;
+
+               ev.device = qp->ibqp.device;
+               ev.element.qp = &qp->ibqp;
+               ev.event = IB_EVENT_COMM_EST;
+               qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
+       }
+}
+EXPORT_SYMBOL(rvt_comm_est);
+
+void rvt_rc_error(struct rvt_qp *qp, enum ib_wc_status err)
+{
+       unsigned long flags;
+       int lastwqe;
+
+       spin_lock_irqsave(&qp->s_lock, flags);
+       lastwqe = rvt_error_qp(qp, err);
+       spin_unlock_irqrestore(&qp->s_lock, flags);
+
+       if (lastwqe) {
+               struct ib_event ev;
+
+               ev.device = qp->ibqp.device;
+               ev.element.qp = &qp->ibqp;
+               ev.event = IB_EVENT_QP_LAST_WQE_REACHED;
+               qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
+       }
+}
+EXPORT_SYMBOL(rvt_rc_error);
index f3dbd157ae5cf47249305729680ec9ceb97d03e0..eaaba1b6cc577360a34dbbed3cba47eedada7f86 100644 (file)
@@ -607,6 +607,8 @@ static inline u32 rvt_div_mtu(struct rvt_qp *qp, u32 len)
 extern const int  ib_rvt_state_ops[];
 
 struct rvt_dev_info;
+void rvt_comm_est(struct rvt_qp *qp);
 int rvt_error_qp(struct rvt_qp *qp, enum ib_wc_status err);
+void rvt_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
 
 #endif          /* DEF_RDMAVT_INCQP_H */