xprtrdma: Eliminate ri_max_send_sges
authorChuck Lever <chuck.lever@oracle.com>
Fri, 3 Jan 2020 16:56:27 +0000 (11:56 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 15 Jan 2020 15:54:32 +0000 (10:54 -0500)
Clean-up. The max_send_sge value also happens to be stored in
ep->rep_attr. Let's keep just a single copy.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/frwr_ops.c
net/sunrpc/xprtrdma/rpc_rdma.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h

index 523722b..859c301 100644 (file)
@@ -190,6 +190,16 @@ int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep)
 {
        struct ib_device_attr *attrs = &ia->ri_id->device->attrs;
        int max_qp_wr, depth, delta;
+       unsigned int max_sge;
+
+       max_sge = min_t(unsigned int, attrs->max_send_sge,
+                       RPCRDMA_MAX_SEND_SGES);
+       if (max_sge < RPCRDMA_MIN_SEND_SGES) {
+               pr_err("rpcrdma: HCA provides only %u send SGEs\n", max_sge);
+               return -ENOMEM;
+       }
+       ep->rep_attr.cap.max_send_sge = max_sge;
+       ep->rep_attr.cap.max_recv_sge = 1;
 
        ia->ri_mrtype = IB_MR_TYPE_MEM_REG;
        if (attrs->device_cap_flags & IB_DEVICE_SG_GAPS_REG)
index aec3beb..af91722 100644 (file)
@@ -145,7 +145,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
                        remaining -= min_t(unsigned int,
                                           PAGE_SIZE - offset, remaining);
                        offset = 0;
-                       if (++count > r_xprt->rx_ia.ri_max_send_sges)
+                       if (++count > r_xprt->rx_ep.rep_attr.cap.max_send_sge)
                                return false;
                }
        }
index fda3889..9456036 100644 (file)
@@ -470,21 +470,12 @@ int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
        struct rpcrdma_ia *ia = &r_xprt->rx_ia;
        struct rpcrdma_connect_private *pmsg = &ep->rep_cm_private;
        struct ib_cq *sendcq, *recvcq;
-       unsigned int max_sge;
        int rc;
 
        ep->rep_max_requests = xprt_rdma_slot_table_entries;
        ep->rep_inline_send = xprt_rdma_max_inline_write;
        ep->rep_inline_recv = xprt_rdma_max_inline_read;
 
-       max_sge = min_t(unsigned int, ia->ri_id->device->attrs.max_send_sge,
-                       RPCRDMA_MAX_SEND_SGES);
-       if (max_sge < RPCRDMA_MIN_SEND_SGES) {
-               pr_warn("rpcrdma: HCA provides only %d send SGEs\n", max_sge);
-               return -ENOMEM;
-       }
-       ia->ri_max_send_sges = max_sge;
-
        rc = frwr_open(ia, ep);
        if (rc)
                return rc;
@@ -492,8 +483,6 @@ int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
        ep->rep_attr.event_handler = rpcrdma_qp_event_handler;
        ep->rep_attr.qp_context = ep;
        ep->rep_attr.srq = NULL;
-       ep->rep_attr.cap.max_send_sge = max_sge;
-       ep->rep_attr.cap.max_recv_sge = 1;
        ep->rep_attr.cap.max_inline_data = 0;
        ep->rep_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
        ep->rep_attr.qp_type = IB_QPT_RC;
@@ -796,11 +785,11 @@ static void rpcrdma_sendctxs_destroy(struct rpcrdma_buffer *buf)
        kfree(buf->rb_sc_ctxs);
 }
 
-static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ia *ia)
+static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ep *ep)
 {
        struct rpcrdma_sendctx *sc;
 
-       sc = kzalloc(struct_size(sc, sc_sges, ia->ri_max_send_sges),
+       sc = kzalloc(struct_size(sc, sc_sges, ep->rep_attr.cap.max_send_sge),
                     GFP_KERNEL);
        if (!sc)
                return NULL;
@@ -828,7 +817,7 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
 
        buf->rb_sc_last = i - 1;
        for (i = 0; i <= buf->rb_sc_last; i++) {
-               sc = rpcrdma_sendctx_create(&r_xprt->rx_ia);
+               sc = rpcrdma_sendctx_create(&r_xprt->rx_ep);
                if (!sc)
                        return -ENOMEM;
 
index d796d68..7655a99 100644 (file)
@@ -73,7 +73,6 @@ struct rpcrdma_ia {
        int                     ri_async_rc;
        unsigned int            ri_max_segs;
        unsigned int            ri_max_frwr_depth;
-       unsigned int            ri_max_send_sges;
        bool                    ri_implicit_roundup;
        enum ib_mr_type         ri_mrtype;
        unsigned long           ri_flags;