From: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
To: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org,
swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 11/12] IB/core: add RW API support for signature MRs
Date: Tue, 19 Apr 2016 17:20:09 +0300 [thread overview]
Message-ID: <57163E99.8090301@grimberg.me> (raw)
In-Reply-To: <1461010463-6603-12-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
> +/**
> + * rdma_rw_ctx_signature init - initialize a RW context with signature offload
> + * @ctx: context to initialize
> + * @qp: queue pair to operate on
> + * @port_num: port num to which the connection is bound
> + * @sg: scatterlist to READ/WRITE from/to
> + * @sg_cnt: number of entries in @sg
> + * @prot_sg: scatterlist to READ/WRITE protection information from/to
> + * @prot_sg_cnt: number of entries in @prot_sg
> + * @sig_attrs: signature offloading algorithms
> + * @remote_addr:remote address to read/write (relative to @rkey)
> + * @rkey: remote key to operate on
> + * @dir: %DMA_TO_DEVICE for RDMA WRITE, %DMA_FROM_DEVICE for RDMA READ
> + *
> + * Returns the number of WQEs that will be needed on the workqueue if
> + * successful, or a negative error code.
> + */
> +int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
> + u8 port_num, struct scatterlist *sg, u32 sg_cnt,
> + struct scatterlist *prot_sg, u32 prot_sg_cnt,
> + struct ib_sig_attrs *sig_attrs,
> + u64 remote_addr, u32 rkey, enum dma_data_direction dir)
> +{
> + struct ib_device *dev = qp->pd->device;
> + u32 pages_per_mr = rdma_rw_fr_page_list_len(qp->pd->device);
> + struct ib_rdma_wr *rdma_wr;
> + struct ib_send_wr *prev_wr = NULL;
> + int count = 0, ret;
> +
> + if (sg_cnt > pages_per_mr || prot_sg_cnt > pages_per_mr) {
> + pr_err("SG count too large\n");
> + return -EINVAL;
> + }
> +
> + ret = ib_dma_map_sg(dev, sg, sg_cnt, dir);
> + if (!ret)
> + return -ENOMEM;
> + sg_cnt = ret;
> +
> + ret = ib_dma_map_sg(dev, prot_sg, prot_sg_cnt, dir);
> + if (!ret) {
> + ret = -ENOMEM;
> + goto out_unmap_sg;
> + }
> + prot_sg_cnt = ret;
> +
> + ctx->type = RDMA_RW_SIG_MR;
> + ctx->nr_ops = 1;
> + ctx->sig = kcalloc(1, sizeof(*ctx->sig), GFP_KERNEL);
> + if (!ctx->sig) {
> + ret = -ENOMEM;
> + goto out_unmap_prot_sg;
> + }
> +
> + ret = rdma_rw_init_one_mr(qp, port_num, &ctx->sig->data, sg, sg_cnt, 0);
> + if (ret < 0)
> + goto out_free_ctx;
> + count += ret;
> + prev_wr = &ctx->sig->data.reg_wr.wr;
> +
In isert if the we have a single sg entry, we use the local_dma_lkey
just so we can skip a registration (also for protection sg), perhaps
rdma_rw_init_one_mr can do this optimization too?
I'm planning to rework some of the signature API, but it would be
nice not to lose this optimization in the mean time...
Other than that, looks really good,
Reviewed-by: Sagi Grimbeg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-04-19 14:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 20:14 generic RDMA READ/WRITE API V7 Christoph Hellwig
[not found] ` <1461010463-6603-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2016-04-18 20:14 ` [PATCH 01/12] IB/mlx5: Expose correct max_sge_rd limit Christoph Hellwig
2016-04-18 20:14 ` [PATCH 07/12] IB/core: add a need_inval flag to struct ib_mr Christoph Hellwig
2016-04-18 20:14 ` [PATCH 02/12] IB/cma: pass the port number to ib_create_qp Christoph Hellwig
2016-04-18 20:14 ` [PATCH 03/12] IB/core: allow passing mapping an offset into the SG in ib_map_mr_sg Christoph Hellwig
2016-04-18 20:14 ` [PATCH 04/12] IB/core: add a helper to check for READ WITH INVALIDATE support Christoph Hellwig
2016-04-18 20:14 ` [PATCH 05/12] IB/core: refactor ib_create_qp Christoph Hellwig
2016-04-18 20:14 ` [PATCH 06/12] IB/core: add a simple MR pool Christoph Hellwig
2016-04-18 20:14 ` [PATCH 08/12] IB/core: generic RDMA READ/WRITE API Christoph Hellwig
2016-04-18 20:14 ` [PATCH 09/12] target: enhance and export target_alloc_sgl/target_free_sgl Christoph Hellwig
2016-04-19 14:11 ` Sagi Grimberg
2016-04-18 20:14 ` [PATCH 10/12] IB/srpt: convert to the generic RDMA READ/WRITE API Christoph Hellwig
2016-04-18 20:14 ` [PATCH 11/12] IB/core: add RW API support for signature MRs Christoph Hellwig
[not found] ` <1461010463-6603-12-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2016-04-19 14:20 ` Sagi Grimberg [this message]
2016-04-19 17:26 ` Jason Gunthorpe
[not found] ` <20160419172627.GC20844-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-04-19 18:29 ` Christoph Hellwig
[not found] ` <20160419182950.GC989-jcswGhMUV9g@public.gmane.org>
2016-04-19 18:46 ` Sagi Grimberg
[not found] ` <57163E99.8090301-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2016-04-19 18:27 ` Christoph Hellwig
2016-04-18 20:14 ` [PATCH 12/12] IB/isert: convert to the generic RDMA READ/WRITE API Christoph Hellwig
2016-04-19 14:23 ` Sagi Grimberg
-- strict thread matches above, loose matches on Subject: below --
2016-04-11 21:32 generic RDMA READ/WRITE API V6 Christoph Hellwig
2016-04-11 21:32 ` [PATCH 11/12] IB/core: add RW API support for signature MRs Christoph Hellwig
[not found] ` <1460410360-13104-12-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2016-04-22 21:53 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57163E99.8090301@grimberg.me \
--to=sagi-nqwnxtmzq1alnmji0ikvqw@public.gmane.org \
--cc=bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org \
--cc=target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).