]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
IB/hfi1: Calculate flow weight based on QP MTU for TID RDMA
authorKaike Wan <kaike.wan@intel.com>
Fri, 25 Oct 2019 19:58:36 +0000 (15:58 -0400)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 6 Nov 2019 17:15:36 +0000 (13:15 -0400)
For a TID RDMA WRITE request, a QP on the responder side could be put into
a queue when a hardware flow is not available. A RNR NAK will be returned
to the requester with a RNR timeout value based on the position of the QP
in the queue. The tid_rdma_flow_wt variable is used to calculate the
timeout value and is determined by using a MTU of 4096 at the module
loading time. This could reduce the timeout value by half from the desired
value, leading to excessive RNR retries.

This patch fixes the issue by calculating the flow weight with the real
MTU assigned to the QP.

Fixes: 07b923701e38 ("IB/hfi1: Add functions to receive TID RDMA WRITE request")
Link: https://lore.kernel.org/r/20191025195836.106825.77769.stgit@awfm-01.aw.intel.com
Cc: <stable@vger.kernel.org>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/hfi1/init.c
drivers/infiniband/hw/hfi1/tid_rdma.c
drivers/infiniband/hw/hfi1/tid_rdma.h

index 71cb9525c07498b0c7ac25f4bb3cef8f96006498..26b792bb102796a727d1256c662226c15a424039 100644 (file)
@@ -1489,7 +1489,6 @@ static int __init hfi1_mod_init(void)
                goto bail_dev;
        }
 
-       hfi1_compute_tid_rdma_flow_wt();
        /*
         * These must be called before the driver is registered with
         * the PCI subsystem.
index 73bc78ba288e64320ae5d19585be9303458e4bc9..e53f542b60af8a4da8201ae00286aa3765ecfdab 100644 (file)
@@ -107,8 +107,6 @@ static u32 mask_generation(u32 a)
  * C - Capcode
  */
 
-static u32 tid_rdma_flow_wt;
-
 static void tid_rdma_trigger_resume(struct work_struct *work);
 static void hfi1_kern_exp_rcv_free_flows(struct tid_rdma_request *req);
 static int hfi1_kern_exp_rcv_alloc_flows(struct tid_rdma_request *req,
@@ -3388,18 +3386,17 @@ u32 hfi1_build_tid_rdma_write_req(struct rvt_qp *qp, struct rvt_swqe *wqe,
        return sizeof(ohdr->u.tid_rdma.w_req) / sizeof(u32);
 }
 
-void hfi1_compute_tid_rdma_flow_wt(void)
+static u32 hfi1_compute_tid_rdma_flow_wt(struct rvt_qp *qp)
 {
        /*
         * Heuristic for computing the RNR timeout when waiting on the flow
         * queue. Rather than a computationaly expensive exact estimate of when
         * a flow will be available, we assume that if a QP is at position N in
         * the flow queue it has to wait approximately (N + 1) * (number of
-        * segments between two sync points), assuming PMTU of 4K. The rationale
-        * for this is that flows are released and recycled at each sync point.
+        * segments between two sync points). The rationale for this is that
+        * flows are released and recycled at each sync point.
         */
-       tid_rdma_flow_wt = MAX_TID_FLOW_PSN * enum_to_mtu(OPA_MTU_4096) /
-               TID_RDMA_MAX_SEGMENT_SIZE;
+       return (MAX_TID_FLOW_PSN * qp->pmtu) >> TID_RDMA_SEGMENT_SHIFT;
 }
 
 static u32 position_in_queue(struct hfi1_qp_priv *qpriv,
@@ -3522,7 +3519,7 @@ static void hfi1_tid_write_alloc_resources(struct rvt_qp *qp, bool intr_ctx)
                if (qpriv->flow_state.index >= RXE_NUM_TID_FLOWS) {
                        ret = hfi1_kern_setup_hw_flow(qpriv->rcd, qp);
                        if (ret) {
-                               to_seg = tid_rdma_flow_wt *
+                               to_seg = hfi1_compute_tid_rdma_flow_wt(qp) *
                                        position_in_queue(qpriv,
                                                          &rcd->flow_queue);
                                break;
index 1c536185261ee966e0f55bd6b310af73bd2736e5..6e82df2190b77d771d0ebdd2d4868af4420e1e47 100644 (file)
@@ -17,6 +17,7 @@
 #define TID_RDMA_MIN_SEGMENT_SIZE       BIT(18)   /* 256 KiB (for now) */
 #define TID_RDMA_MAX_SEGMENT_SIZE       BIT(18)   /* 256 KiB (for now) */
 #define TID_RDMA_MAX_PAGES              (BIT(18) >> PAGE_SHIFT)
+#define TID_RDMA_SEGMENT_SHIFT         18
 
 /*
  * Bit definitions for priv->s_flags.
@@ -274,8 +275,6 @@ u32 hfi1_build_tid_rdma_write_req(struct rvt_qp *qp, struct rvt_swqe *wqe,
                                  struct ib_other_headers *ohdr,
                                  u32 *bth1, u32 *bth2, u32 *len);
 
-void hfi1_compute_tid_rdma_flow_wt(void);
-
 void hfi1_rc_rcv_tid_rdma_write_req(struct hfi1_packet *packet);
 
 u32 hfi1_build_tid_rdma_write_resp(struct rvt_qp *qp, struct rvt_ack_entry *e,