From: Leon Romanovsky <leon@kernel.org>
To: Jack Wang <jinpuwang@gmail.com>
Cc: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org,
axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me,
bvanassche@acm.org, dledford@redhat.com, jgg@ziepe.ca,
danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com,
rpenyaev@suse.de
Subject: Re: [PATCH v7 04/25] RDMA/rtrs: core: lib functions shared between client and server modules
Date: Sun, 19 Jan 2020 16:48:37 +0200 [thread overview]
Message-ID: <20200119144837.GE51881@unreal> (raw)
In-Reply-To: <20200116125915.14815-5-jinpuwang@gmail.com>
On Thu, Jan 16, 2020 at 01:58:54PM +0100, Jack Wang wrote:
> From: Jack Wang <jinpu.wang@cloud.ionos.com>
>
> This is a set of library functions existing as a rtrs-core module,
> used by client and server modules.
>
> Mainly these functions wrap IB and RDMA calls and provide a bit higher
> abstraction for implementing of RTRS protocol on client or server
> sides.
>
> Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
> Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
> ---
> drivers/infiniband/ulp/rtrs/rtrs.c | 597 +++++++++++++++++++++++++++++
> 1 file changed, 597 insertions(+)
> create mode 100644 drivers/infiniband/ulp/rtrs/rtrs.c
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
> new file mode 100644
> index 000000000000..7b84d76e2a67
> --- /dev/null
> +++ b/drivers/infiniband/ulp/rtrs/rtrs.c
> @@ -0,0 +1,597 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * RDMA Transport Layer
> + *
> + * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
> + *
> + * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
> + *
> + * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
> + */
> +#undef pr_fmt
> +#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
> +
> +#include <linux/module.h>
> +#include <linux/inet.h>
> +
> +#include "rtrs-pri.h"
> +#include "rtrs-log.h"
> +
> +MODULE_DESCRIPTION("RDMA Transport Core");
> +MODULE_LICENSE("GPL");
> +
> +struct rtrs_iu *rtrs_iu_alloc(u32 queue_size, size_t size, gfp_t gfp_mask,
> + struct ib_device *dma_dev,
> + enum dma_data_direction dir,
> + void (*done)(struct ib_cq *cq, struct ib_wc *wc))
> +{
> + struct rtrs_iu *ius, *iu;
> + int i;
> +
> + WARN_ON(!queue_size);
> + ius = kcalloc(queue_size, sizeof(*ius), gfp_mask);
> + if (unlikely(!ius))
> + return NULL;
Let's do not add useless WARN_ON() and unlikely to every error path.
> + for (i = 0; i < queue_size; i++) {
> + iu = &ius[i];
> + iu->buf = kzalloc(size, gfp_mask);
> + if (unlikely(!iu->buf))
> + goto err;
> +
> + iu->dma_addr = ib_dma_map_single(dma_dev, iu->buf, size, dir);
> + if (unlikely(ib_dma_mapping_error(dma_dev, iu->dma_addr)))
> + goto err;
> +
> + iu->cqe.done = done;
> + iu->size = size;
> + iu->direction = dir;
> + }
> + return ius;
> +err:
> + rtrs_iu_free(ius, dir, dma_dev, i);
> + return NULL;
> +}
> +EXPORT_SYMBOL_GPL(rtrs_iu_alloc);
> +
> +void rtrs_iu_free(struct rtrs_iu *ius, enum dma_data_direction dir,
> + struct ib_device *ibdev, u32 queue_size)
> +{
> + struct rtrs_iu *iu;
> + int i;
> +
> + if (!ius)
> + return;
> +
> + for (i = 0; i < queue_size; i++) {
> + iu = &ius[i];
> + ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, dir);
> + kfree(iu->buf);
> + }
> + kfree(ius);
> +}
> +EXPORT_SYMBOL_GPL(rtrs_iu_free);
> +
> +int rtrs_iu_post_recv(struct rtrs_con *con, struct rtrs_iu *iu)
> +{
> + struct rtrs_sess *sess = con->sess;
> + struct ib_recv_wr wr;
> + struct ib_sge list;
> +
> + list.addr = iu->dma_addr;
> + list.length = iu->size;
> + list.lkey = sess->dev->ib_pd->local_dma_lkey;
> +
> + if (WARN_ON(list.length == 0)) {
> + rtrs_wrn(con->sess,
> + "Posting receive work request failed, sg list is empty\n");
Both WARN_ON and warning message?
Thanks
next prev parent reply other threads:[~2020-01-19 14:48 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 12:58 [PATCH v7 00/25] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Jack Wang
2020-01-16 12:58 ` [PATCH v7 01/25] sysfs: export sysfs_remove_file_self() Jack Wang
2020-01-16 12:58 ` [PATCH v7 02/25] RDMA/rtrs: public interface header to establish RDMA connections Jack Wang
2020-01-16 12:58 ` [PATCH v7 03/25] RDMA/rtrs: private headers with rtrs protocol structs and helpers Jack Wang
2020-01-16 12:58 ` [PATCH v7 04/25] RDMA/rtrs: core: lib functions shared between client and server modules Jack Wang
2020-01-19 14:48 ` Leon Romanovsky [this message]
2020-01-20 11:32 ` Jinpu Wang
2020-01-20 13:30 ` Leon Romanovsky
2020-01-20 14:08 ` Jinpu Wang
2020-01-16 12:58 ` [PATCH v7 05/25] RDMA/rtrs: client: private header with client structs and functions Jack Wang
2020-01-16 12:58 ` [PATCH v7 06/25] RDMA/rtrs: client: main functionality Jack Wang
2020-01-16 14:53 ` Leon Romanovsky
2020-01-16 15:43 ` Jinpu Wang
2020-01-16 15:53 ` Jason Gunthorpe
2020-01-16 16:48 ` Jinpu Wang
2020-01-16 15:58 ` Leon Romanovsky
2020-01-16 16:24 ` Jinpu Wang
2020-01-18 10:12 ` Leon Romanovsky
2020-01-20 11:24 ` Jinpu Wang
2020-01-16 12:58 ` [PATCH v7 07/25] RDMA/rtrs: client: statistics functions Jack Wang
2020-01-16 12:58 ` [PATCH v7 08/25] RDMA/rtrs: client: sysfs interface functions Jack Wang
2020-01-16 12:58 ` [PATCH v7 09/25] RDMA/rtrs: server: private header with server structs and functions Jack Wang
2020-01-16 12:59 ` [PATCH v7 10/25] RDMA/rtrs: server: main functionality Jack Wang
2020-01-16 12:59 ` [PATCH v7 11/25] RDMA/rtrs: server: statistics functions Jack Wang
2020-01-16 12:59 ` [PATCH v7 12/25] RDMA/rtrs: server: sysfs interface functions Jack Wang
2020-01-16 12:59 ` [PATCH v7 13/25] RDMA/rtrs: include client and server modules into kernel compilation Jack Wang
2020-01-16 12:59 ` [PATCH v7 14/25] RDMA/rtrs: a bit of documentation Jack Wang
2020-01-16 12:59 ` [PATCH v7 15/25] block/rnbd: private headers with rnbd protocol structs and helpers Jack Wang
2020-01-16 12:59 ` [PATCH v7 16/25] block/rnbd: client: private header with client structs and functions Jack Wang
2020-01-16 12:59 ` [PATCH v7 17/25] block/rnbd: client: main functionality Jack Wang
2020-01-20 13:48 ` Leon Romanovsky
2020-01-20 17:30 ` Jinpu Wang
2020-01-22 12:31 ` Leon Romanovsky
2020-01-22 12:52 ` Jinpu Wang
2020-01-22 11:22 ` Jinpu Wang
2020-01-22 12:25 ` Leon Romanovsky
2020-01-22 13:12 ` Jinpu Wang
2020-01-22 14:07 ` Leon Romanovsky
2020-01-22 14:18 ` Jinpu Wang
2020-01-16 12:59 ` [PATCH v7 18/25] block/rnbd: client: sysfs interface functions Jack Wang
2020-01-16 12:59 ` [PATCH v7 19/25] block/rnbd: server: private header with server structs and functions Jack Wang
2020-01-16 12:59 ` [PATCH v7 20/25] block/rnbd: server: main functionality Jack Wang
2020-01-16 12:59 ` [PATCH v7 21/25] block/rnbd: server: functionality for IO submission to file or block dev Jack Wang
2020-01-16 12:59 ` [PATCH v7 22/25] block/rnbd: server: sysfs interface functions Jack Wang
2020-01-16 12:59 ` [PATCH v7 23/25] block/rnbd: include client and server modules into kernel compilation Jack Wang
2020-01-16 14:40 ` Leon Romanovsky
2020-01-16 14:54 ` Jinpu Wang
2020-01-16 15:59 ` Leon Romanovsky
2020-01-16 16:53 ` Jinpu Wang
2020-01-16 12:59 ` [PATCH v7 24/25] block/rnbd: a bit of documentation Jack Wang
2020-01-16 12:59 ` [PATCH v7 25/25] MAINTAINERS: Add maintainers for RNBD/RTRS modules Jack Wang
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=20200119144837.GE51881@unreal \
--to=leon@kernel.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=danil.kipnis@cloud.ionos.com \
--cc=dledford@redhat.com \
--cc=hch@infradead.org \
--cc=jgg@ziepe.ca \
--cc=jinpu.wang@cloud.ionos.com \
--cc=jinpuwang@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=rpenyaev@suse.de \
--cc=sagi@grimberg.me \
/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).