public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Alex Margolin <alexma-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC rdma-core 2/2] verbs: Introduce non-contiguous memory registration
Date: Thu, 11 Jan 2018 14:22:07 +0200	[thread overview]
Message-ID: <20180111122206.GB2800@yuvallap> (raw)
In-Reply-To: <1515088046-26605-2-git-send-email-alexma-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

> +The following code example demonstrates non-contiguous memory registration,
> +by combining two contiguous regions, along with the WR-based completion semantic:
> +.PP
> +.nf
> +mr1 = ibv_reg_mr(pd, addr1, len1, 0);
> +if (!mr1) {
> +        fprintf(stderr, "Failed to create MR #1\en");
> +        return 1;
> +}
> +
> +mr2 = ibv_reg_mr(pd, addr2, len2, 0);
> +if (!mr2) {
> +        fprintf(stderr, "Failed to create MR #2\en");
> +        return 1;
> +}

So, to register non-contiguous 512 random buffers i would have to create
512 MRs?

> +
> +mr3 = ibv_reg_mr(pd, NULL, 0, IBV_ACCESS_ZERO_BASED);
> +if (!mr3) {
> +        fprintf(stderr, "Failed to create result MR\en");
> +        return 1;
> +}
> +
> +struct ibv_sge composite[] =
> +{
> +        {
> +                .addr = addr1,
> +                .length = len1,
> +                .lkey = mr1->lkey
> +        },
> +        {
> +                .addr = addr2,
> +                .length = len2,
> +                .lkey = mr2->lkey
> +        }
> +};
> +
> +ret = ibv_mr_set_layout_sg(mr3, 0, 2, composite);
> +if (ret) {
> +        fprintf(stderr, "Non-contiguous registration failed\en");
> +        return 1;
> +}
> +
> +struct ibv_sge non_contig =
> +{
> +        .addr = 0,
> +        .length = len1 + len2,
> +        .lkey = mr3->lkey
> +};
> +
> +struct ibv_send_wr send_wr = {
> +        .opcode = IBV_WR_SEND,
> +        .num_sge = 1,
> +        .sg_list = non_contig,
> +        .flags = 0
> +};
> +
> +ret = ibv_post_send(qp, send_wr, &bad_wr);
> +if (ret) {
> +        fprintf(stderr, "Non-contiguous send failed\en");
> +        return 1;
> +}
--
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

  parent reply	other threads:[~2018-01-11 12:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04 17:47 [RFC rdma-core 1/2] Registering non-contiguous memory Alex Margolin
     [not found] ` <1515088046-26605-1-git-send-email-alexma-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-01-04 17:47   ` [RFC rdma-core 2/2] verbs: Introduce non-contiguous memory registration Alex Margolin
     [not found]     ` <1515088046-26605-2-git-send-email-alexma-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-01-11 12:22       ` Yuval Shaia [this message]
2018-01-11 16:44         ` Jason Gunthorpe
     [not found]           ` <20180111164455.GA1309-uk2M96/98Pc@public.gmane.org>
2018-01-22 15:59             ` Alex Margolin
     [not found]               ` <VI1PR05MB1278C4C4FF78B4B1A551252EB9EC0-79XLn2atqDMOK6E67s+DINqRiQSDpxhJvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-01-23 20:29                 ` Yuval Shaia
2018-01-25 12:43                   ` Alex Margolin
     [not found]                     ` <VI1PR05MB12787572593F02F05AA20DE1B9E10-79XLn2atqDMOK6E67s+DINqRiQSDpxhJvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-01-25 16:07                       ` Jason Gunthorpe
2018-01-28 20:37                       ` Yuval Shaia
2018-01-29 17:27                         ` Jason Gunthorpe
     [not found]                           ` <20180129172717.GW23852-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-01-30 11:35                             ` Marcel Apfelbaum
     [not found]                               ` <12d04e1b-6024-0763-f5c5-46ca8b0823a6-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-01-30 15:42                                 ` Jason Gunthorpe
     [not found]                                   ` <20180130154200.GD21679-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-01-31 12:27                                     ` Marcel Apfelbaum
     [not found]                                       ` <76b5a8cf-b3ed-c76d-6157-91fc5f6f2b35-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-01-31 18:38                                         ` Jason Gunthorpe
     [not found]                                           ` <20180131183810.GA23352-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-02-01 18:22                                             ` Marcel Apfelbaum
     [not found]                                               ` <dded9055-a329-9b9d-943a-7a60445e2ada-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-02-01 18:29                                                 ` Jason Gunthorpe
     [not found]                                                   ` <20180201182959.GN23352-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2018-02-01 18:45                                                     ` Marcel Apfelbaum
2018-01-25 13:10                   ` Alex Margolin

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=20180111122206.GB2800@yuvallap \
    --to=yuval.shaia-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=alexma-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=linux-rdma-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