IB/rdmavt, IB/hfi1, IB/qib: Add inlines for mtu division
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Thu, 8 Dec 2016 03:34:37 +0000 (19:34 -0800)
committerDoug Ledford <dledford@redhat.com>
Sun, 11 Dec 2016 20:29:42 +0000 (15:29 -0500)
Add rvt_div_round_up_mtu() and rvt_div_mtu() routines to
do the computation based on the pmtu and the log_pmtu.

Change divides in qib, hfi1 to use the new inlines.

Reviewed-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/rc.c
drivers/infiniband/hw/qib/qib_rc.c
include/rdma/rdmavt_qp.h

index ddc02237e5f6d0686251383d98e1656172232a06..9db260fe782a8b3350620d6d619d044a08bd80d2 100644 (file)
@@ -2377,8 +2377,7 @@ send_last:
                         * Update the next expected PSN.  We add 1 later
                         * below, so only add the remainder here.
                         */
-                       if (len > pmtu)
-                               qp->r_psn += (len - 1) / pmtu;
+                       qp->r_psn += rvt_div_mtu(qp, len - 1);
                } else {
                        e->rdma_sge.mr = NULL;
                        e->rdma_sge.vaddr = NULL;
index e23ee6ce435a24f0ca11d9d738e2e4a789501d8a..031433cb7206e0e5b00b2222fde1a654af3511c9 100644 (file)
@@ -2079,8 +2079,7 @@ send_last:
                         * Update the next expected PSN.  We add 1 later
                         * below, so only add the remainder here.
                         */
-                       if (len > pmtu)
-                               qp->r_psn += (len - 1) / pmtu;
+                       qp->r_psn += rvt_div_mtu(qp, len - 1);
                } else {
                        e->rdma_sge.mr = NULL;
                        e->rdma_sge.vaddr = NULL;
index 04facda681e0e092564de0f0aad9fbc9791abf7f..f3dbd157ae5cf47249305729680ec9ceb97d03e0 100644 (file)
@@ -582,7 +582,29 @@ static inline void rvt_qp_swqe_complete(
        }
 }
 
-extern const int ib_rvt_state_ops[];
+/**
+ * @qp - the qp pair
+ * @len - the length
+ *
+ * Perform a shift based mtu round up divide
+ */
+static inline u32 rvt_div_round_up_mtu(struct rvt_qp *qp, u32 len)
+{
+       return (len + qp->pmtu - 1) >> qp->log_pmtu;
+}
+
+/**
+ * @qp - the qp pair
+ * @len - the length
+ *
+ * Perform a shift based mtu divide
+ */
+static inline u32 rvt_div_mtu(struct rvt_qp *qp, u32 len)
+{
+       return len >> qp->log_pmtu;
+}
+
+extern const int  ib_rvt_state_ops[];
 
 struct rvt_dev_info;
 int rvt_error_qp(struct rvt_qp *qp, enum ib_wc_status err);