|
51 | 51 | #include <linux/workqueue.h>
|
52 | 52 | #include <rdma/ib_verbs.h>
|
53 | 53 | #include <rdma/rdma_cm.h>
|
| 54 | +#include <rdma/rw.h> |
54 | 55 | #include <linux/sunrpc/svc_rdma.h>
|
55 | 56 | #include <linux/export.h>
|
56 | 57 | #include "xprt_rdma.h"
|
@@ -713,7 +714,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
|
713 | 714 | struct ib_qp_init_attr qp_attr;
|
714 | 715 | struct ib_device *dev;
|
715 | 716 | struct sockaddr *sap;
|
716 |
| - unsigned int i; |
| 717 | + unsigned int i, ctxts; |
717 | 718 | int ret = 0;
|
718 | 719 |
|
719 | 720 | listen_rdma = container_of(xprt, struct svcxprt_rdma, sc_xprt);
|
@@ -754,7 +755,14 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
|
754 | 755 | newxprt->sc_max_bc_requests = 2;
|
755 | 756 | }
|
756 | 757 | newxprt->sc_fc_credits = cpu_to_be32(newxprt->sc_max_requests);
|
757 |
| - newxprt->sc_sq_depth = newxprt->sc_rq_depth; |
| 758 | + ctxts = rdma_rw_mr_factor(dev, newxprt->sc_port_num, RPCSVC_MAXPAGES); |
| 759 | + ctxts *= newxprt->sc_max_requests; |
| 760 | + newxprt->sc_sq_depth = newxprt->sc_rq_depth + ctxts; |
| 761 | + if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) { |
| 762 | + pr_warn("svcrdma: reducing send depth to %d\n", |
| 763 | + dev->attrs.max_qp_wr); |
| 764 | + newxprt->sc_sq_depth = dev->attrs.max_qp_wr; |
| 765 | + } |
758 | 766 | atomic_set(&newxprt->sc_sq_avail, newxprt->sc_sq_depth);
|
759 | 767 |
|
760 | 768 | if (!svc_rdma_prealloc_ctxts(newxprt))
|
@@ -789,8 +797,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
|
789 | 797 | qp_attr.event_handler = qp_event_handler;
|
790 | 798 | qp_attr.qp_context = &newxprt->sc_xprt;
|
791 | 799 | qp_attr.port_num = newxprt->sc_port_num;
|
792 |
| - qp_attr.cap.max_rdma_ctxs = newxprt->sc_max_requests; |
793 |
| - qp_attr.cap.max_send_wr = newxprt->sc_sq_depth; |
| 800 | + qp_attr.cap.max_rdma_ctxs = ctxts; |
| 801 | + qp_attr.cap.max_send_wr = newxprt->sc_sq_depth - ctxts; |
794 | 802 | qp_attr.cap.max_recv_wr = newxprt->sc_rq_depth;
|
795 | 803 | qp_attr.cap.max_send_sge = newxprt->sc_max_sge;
|
796 | 804 | qp_attr.cap.max_recv_sge = newxprt->sc_max_sge;
|
@@ -858,6 +866,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
|
858 | 866 | dprintk(" remote address : %pIS:%u\n", sap, rpc_get_port(sap));
|
859 | 867 | dprintk(" max_sge : %d\n", newxprt->sc_max_sge);
|
860 | 868 | dprintk(" sq_depth : %d\n", newxprt->sc_sq_depth);
|
| 869 | + dprintk(" rdma_rw_ctxs : %d\n", ctxts); |
861 | 870 | dprintk(" max_requests : %d\n", newxprt->sc_max_requests);
|
862 | 871 | dprintk(" ord : %d\n", newxprt->sc_ord);
|
863 | 872 |
|
|
0 commit comments