All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinpu Wang <jinpu.wang@cloud.ionos.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Jack Wang <jinpuwang@gmail.com>,
	linux-block@vger.kernel.org, linux-rdma@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@infradead.org>,
	Sagi Grimberg <sagi@grimberg.me>,
	Bart Van Assche <bvanassche@acm.org>,
	Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Danil Kipnis <danil.kipnis@cloud.ionos.com>,
	Roman Penyaev <rpenyaev@suse.de>,
	Pankaj Gupta <pankaj.gupta@cloud.ionos.com>
Subject: Re: [PATCH v9 02/25] RDMA/rtrs: public interface header to establish RDMA connections
Date: Tue, 3 Mar 2020 15:23:09 +0100	[thread overview]
Message-ID: <CAMGffEkBy4uB-GL_5zqqG3uOnJgbP0X5TwfqmcKNJ0Lx8_B5Fw@mail.gmail.com> (raw)
In-Reply-To: <20200303141638.GN121803@unreal>

On Tue, Mar 3, 2020 at 3:16 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Tue, Mar 03, 2020 at 03:05:27PM +0100, Jinpu Wang wrote:
> > On Tue, Mar 3, 2020 at 10:40 AM Leon Romanovsky <leon@kernel.org> wrote:
> > >
> > > On Fri, Feb 21, 2020 at 11:46:58AM +0100, Jack Wang wrote:
> > > > From: Jack Wang <jinpu.wang@cloud.ionos.com>
> > > >
> > > > Introduce public header which provides set of API functions to
> > > > establish RDMA connections from client to server machine using
> > > > RTRS protocol, which manages RDMA connections for each session,
> > > > does multipathing and load balancing.
> > > >
> > > > Main functions for client (active) side:
> > > >
> > > >  rtrs_clt_open() - Creates set of RDMA connections incapsulated
> > > >                     in IBTRS session and returns pointer on RTRS
> > > >                   session object.
> > > >  rtrs_clt_close() - Closes RDMA connections associated with RTRS
> > > >                      session.
> > > >  rtrs_clt_request() - Requests zero-copy RDMA transfer to/from
> > > >                        server.
> > > >
> > > > Main functions for server (passive) side:
> > > >
> > > >  rtrs_srv_open() - Starts listening for RTRS clients on specified
> > > >                     port and invokes RTRS callbacks for incoming
> > > >                   RDMA requests or link events.
> > > >  rtrs_srv_close() - Closes RTRS server context.
> > > >
> > > > 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.h | 310 +++++++++++++++++++++++++++++
> > > >  1 file changed, 310 insertions(+)
> > > >  create mode 100644 drivers/infiniband/ulp/rtrs/rtrs.h
> > > >
> > > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs.h b/drivers/infiniband/ulp/rtrs/rtrs.h
> > > > new file mode 100644
> > > > index 000000000000..5e1c8a654e92
> > > > --- /dev/null
> > > > +++ b/drivers/infiniband/ulp/rtrs/rtrs.h
> > > > @@ -0,0 +1,310 @@
> > > > +/* 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.
> > > > + */
> > > > +#ifndef RTRS_H
> > > > +#define RTRS_H
> > > > +
> > > > +#include <linux/socket.h>
> > > > +#include <linux/scatterlist.h>
> > > > +
> > > > +struct rtrs_permit;
> > > > +struct rtrs_clt;
> > > > +struct rtrs_srv_ctx;
> > > > +struct rtrs_srv;
> > > > +struct rtrs_srv_op;
> > > > +
> > > > +/*
> > > > + * RDMA transport (RTRS) client API
> > > > + */
> > > > +
> > > > +/**
> > > > + * enum rtrs_clt_link_ev - Events about connectivity state of a client
> > > > + * @RTRS_CLT_LINK_EV_RECONNECTED     Client was reconnected.
> > > > + * @RTRS_CLT_LINK_EV_DISCONNECTED    Client was disconnected.
> > > > + */
> > > > +enum rtrs_clt_link_ev {
> > > > +     RTRS_CLT_LINK_EV_RECONNECTED,
> > > > +     RTRS_CLT_LINK_EV_DISCONNECTED,
> > > > +};
> > > > +
> > > > +/**
> > > > + * Source and destination address of a path to be established
> > > > + */
> > > > +struct rtrs_addr {
> > > > +     struct sockaddr_storage *src;
> > > > +     struct sockaddr_storage *dst;
> > > > +};
> > > > +
> > > > +typedef void (link_clt_ev_fn)(void *priv, enum rtrs_clt_link_ev ev);
> > > > +/**
> > > > + * rtrs_clt_open() - Open a session to an RTRS server
> > > > + * @priv: User supplied private data.
> > > > + * @link_ev: Event notification callback function for connection state changes
> > > > + *   @priv: User supplied data that was passed to rtrs_clt_open()
> > > > + *   @ev: Occurred event
> > > > + * @sessname: name of the session
> > > > + * @paths: Paths to be established defined by their src and dst addresses
> > > > + * @path_cnt: Number of elements in the @paths array
> > > > + * @port: port to be used by the RTRS session
> > > > + * @pdu_sz: Size of extra payload which can be accessed after permit allocation.
> > > > + * @max_inflight_msg: Max. number of parallel inflight messages for the session
> > > > + * @max_segments: Max. number of segments per IO request
> > > > + * @reconnect_delay_sec: time between reconnect tries
> > > > + * @max_reconnect_attempts: Number of times to reconnect on error before giving
> > > > + *                       up, 0 for * disabled, -1 for forever
> > > > + *
> > > > + * Starts session establishment with the rtrs_server. The function can block
> > > > + * up to ~2000ms before it returns.
> > > > + *
> > > > + * Return a valid pointer on success otherwise PTR_ERR.
> > > > + */
> > > > +struct rtrs_clt *rtrs_clt_open(void *priv, link_clt_ev_fn *link_ev,
> > > > +                              const char *sessname,
> > > > +                              const struct rtrs_addr *paths,
> > > > +                              size_t path_cnt, u16 port,
> > > > +                              size_t pdu_sz, u8 reconnect_delay_sec,
> > > > +                              u16 max_segments,
> > > > +                              s16 max_reconnect_attempts);
> > > > +
> > > > +/**
> > > > + * rtrs_clt_close() - Close a session
> > > > + * @sess: Session handle. Session is freed upon return.
> > > > + */
> > > > +void rtrs_clt_close(struct rtrs_clt *sess);
> > > > +
> > > > +/**
> > > > + * rtrs_permit_to_pdu() - converts rtrs_permit to opaque pdu pointer
> > > > + * @permit: RTRS permit pointer, it associates the memory allocation for future
> > > > + *          RDMA operation.
> > > > + */
> > > > +void *rtrs_permit_to_pdu(struct rtrs_permit *permit);
> > > > +
> > > > +enum {
> > > > +     RTRS_PERMIT_NOWAIT = 0,
> > > > +     RTRS_PERMIT_WAIT   = 1,
> > > > +};
> > > > +
> > > > +/**
> > > > + * enum rtrs_clt_con_type() type of ib connection to use with a given
> > > > + * rtrs_permit
> > > > + * @USR_CON - use connection reserved vor "service" messages
> > > > + * @IO_CON - use a connection reserved for IO
> > > > + */
> > > > +enum rtrs_clt_con_type {
> > > > +     RTRS_USR_CON,
> > > > +     RTRS_IO_CON
> > > > +};
> > > > +
> > > > +/**
> > > > + * rtrs_clt_get_permit() - allocates permit for future RDMA operation
> > > > + * @sess:    Current session
> > > > + * @con_type:        Type of connection to use with the permit
> > > > + * @wait:    Wait type
> > > > + *
> > > > + * Description:
> > > > + *    Allocates permit for the following RDMA operation.  Permit is used
> > > > + *    to preallocate all resources and to propagate memory pressure
> > > > + *    up earlier.
> > > > + *
> > > > + * Context:
> > > > + *    Can sleep if @wait == RTRS_TAG_WAIT
> > > > + */
> > > > +struct rtrs_permit *rtrs_clt_get_permit(struct rtrs_clt *sess,
> > > > +                                 enum rtrs_clt_con_type con_type,
> > > > +                                 int wait);
> > > > +
> > > > +/**
> > > > + * rtrs_clt_put_permit() - puts allocated permit
> > > > + * @sess:    Current session
> > > > + * @permit:  Permit to be freed
> > > > + *
> > > > + * Context:
> > > > + *    Does not matter
> > > > + */
> > > > +void rtrs_clt_put_permit(struct rtrs_clt *sess, struct rtrs_permit *permit);
> > > > +
> > > > +typedef void (rtrs_conf_fn)(void *priv, int errno);
> > > > +/**
> > > > + * rtrs_clt_request() - Request data transfer to/from server via RDMA.
> > > > + *
> > > > + * @dir:     READ/WRITE
> > > > + * @conf:    callback function to be called as confirmation
> > > > + * @sess:    Session
> > > > + * @permit:  Preallocated permit
> > > > + * @priv:    User provided data, passed back with corresponding
> > > > + *           @(conf) confirmation.
> > > > + * @vec:     Message that is sent to server together with the request.
> > > > + *           Sum of len of all @vec elements limited to <= IO_MSG_SIZE.
> > > > + *           Since the msg is copied internally it can be allocated on stack.
> > > > + * @nr:              Number of elements in @vec.
> > > > + * @len:     length of data sent to/from server
> > > > + * @sg:              Pages to be sent/received to/from server.
> > > > + * @sg_cnt:  Number of elements in the @sg
> > > > + *
> > > > + * Return:
> > > > + * 0:                Success
> > > > + * <0:               Error
> > > > + *
> > > > + * On dir=READ rtrs client will request a data transfer from Server to client.
> > > > + * The data that the server will respond with will be stored in @sg when
> > > > + * the user receives an %RTRS_CLT_RDMA_EV_RDMA_REQUEST_WRITE_COMPL event.
> > > > + * On dir=WRITE rtrs client will rdma write data in sg to server side.
> > > > + */
> > > > +int rtrs_clt_request(int dir, rtrs_conf_fn *conf, struct rtrs_clt *sess,
> > > > +                   struct rtrs_permit *permit, void *priv,
> > > > +                   const struct kvec *vec, size_t nr, size_t len,
> > > > +                   struct scatterlist *sg, unsigned int sg_cnt);
> > > > +
> > > > +/**
> > > > + * rtrs_attrs - RTRS session attributes
> > > > + */
> > > > +struct rtrs_attrs {
> > > > +     u32     queue_depth;
> > > > +     u32     max_io_size;
> > > > +     u8      sessname[NAME_MAX];
> > > > +     struct kobject *sess_kobj;
> > > > +};
> > > > +
> > > > +/**
> > > > + * rtrs_clt_query() - queries RTRS session attributes
> > > > + *
> > > > + * Returns:
> > > > + *    0 on success
> > > > + *    -ECOMM         no connection to the server
> > > > + */
> > > > +int rtrs_clt_query(struct rtrs_clt *sess, struct rtrs_attrs *attr);
> > > > +
> > > > +/*
> > > > + * Here goes RTRS server API
> > > > + */
> > > > +
> > > > +/**
> > > > + * enum rtrs_srv_link_ev - Server link events
> > > > + * @RTRS_SRV_LINK_EV_CONNECTED:      Connection from client established
> > > > + * @RTRS_SRV_LINK_EV_DISCONNECTED:   Connection was disconnected, all
> > > > + *                                   connection RTRS resources were freed.
> > > > + */
> > > > +enum rtrs_srv_link_ev {
> > > > +     RTRS_SRV_LINK_EV_CONNECTED,
> > > > +     RTRS_SRV_LINK_EV_DISCONNECTED,
> > > > +};
> > > > +
> > > > +/**
> > > > + * rdma_ev_fn():     Event notification for RDMA operations
> > > > + *                   If the callback returns a value != 0, an error message
> > > > + *                   for the data transfer will be sent to the client.
> > > > +
> > > > + *   @sess:          Session
> > > > + *   @priv:          Private data set by rtrs_srv_set_sess_priv()
> > > > + *   @id:            internal RTRS operation id
> > > > + *   @dir:           READ/WRITE
> > > > + *   @data:          Pointer to (bidirectional) rdma memory area:
> > > > + *                   - in case of %RTRS_SRV_RDMA_EV_RECV contains
> > > > + *                   data sent by the client
> > > > + *                   - in case of %RTRS_SRV_RDMA_EV_WRITE_REQ points to the
> > > > + *                   memory area where the response is to be written to
> > > > + *   @datalen:       Size of the memory area in @data
> > > > + *   @usr:           The extra user message sent by the client (%vec)
> > > > + *   @usrlen:        Size of the user message
> > > > + */
> > > > +typedef int (rdma_ev_fn)(struct rtrs_srv *sess, void *priv,
> > > > +                      struct rtrs_srv_op *id, int dir,
> > > > +                      void *data, size_t datalen, const void *usr,
> > > > +                      size_t usrlen);
> > > > +
> > > > +/**
> > > > + * link_ev_fn():     Events about connectivity state changes
> > > > + *                   If the callback returns != 0 and the event
> > > > + *                   %RTRS_SRV_LINK_EV_CONNECTED the corresponding session
> > > > + *                   will be destroyed.
> > > > + *   @sess:          Session
> > > > + *   @ev:            event
> > > > + *   @priv:          Private data from user if previously set with
> > > > + *                   rtrs_srv_set_sess_priv()
> > > > + */
> > > > +typedef int (link_ev_fn)(struct rtrs_srv *sess, enum rtrs_srv_link_ev ev,
> > > > +                      void *priv);
> > >
> > > I don't think that it is good idea to add typedefs to hide function
> > > callbacks definitions.
> > >
> > > Thanks
> > Hi Leon,
> >
> > What's the preferred way to do it, could you point me an example?
>
> Create struct that holds all needed parameters, pass it directly and
> don't hide the function signature.

We will do it this way!

Thanks
>
> Thanks
>
> >
> > Thanks!

  reply	other threads:[~2020-03-03 14:23 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 10:46 [PATCH v9 00/25] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Jack Wang
2020-02-21 10:46 ` [PATCH v9 01/25] sysfs: export sysfs_remove_file_self() Jack Wang
2020-03-01  0:24   ` Bart Van Assche
2020-03-02 14:37     ` Jinpu Wang
2020-02-21 10:46 ` [PATCH v9 02/25] RDMA/rtrs: public interface header to establish RDMA connections Jack Wang
2020-03-01  0:31   ` Bart Van Assche
2020-03-02  8:39     ` Jinpu Wang
2020-03-03  9:40   ` Leon Romanovsky
2020-03-03 14:05     ` Jinpu Wang
2020-03-03 14:16       ` Leon Romanovsky
2020-03-03 14:23         ` Jinpu Wang [this message]
2020-02-21 10:46 ` [PATCH v9 03/25] RDMA/rtrs: private headers with rtrs protocol structs and helpers Jack Wang
2020-03-01  0:37   ` Bart Van Assche
2020-03-02  9:21     ` Jinpu Wang
2020-03-03  9:45   ` Leon Romanovsky
2020-03-03 13:52     ` Jinpu Wang
2020-03-03 14:05       ` Jason Gunthorpe
2020-03-03 16:13         ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 04/25] RDMA/rtrs: core: lib functions shared between client and server modules Jack Wang
2020-03-01  0:47   ` Bart Van Assche
2020-03-02  8:40     ` Jinpu Wang
2020-03-03  9:57   ` Leon Romanovsky
2020-03-04 11:21     ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 05/25] RDMA/rtrs: client: private header with client structs and functions Jack Wang
2020-03-01  0:51   ` Bart Van Assche
2020-03-02 13:49     ` Jinpu Wang
2020-03-02 16:13       ` Bart Van Assche
2020-03-02 16:18         ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 06/25] RDMA/rtrs: client: main functionality Jack Wang
2020-03-01  1:33   ` Bart Van Assche
2020-03-02 13:20     ` Danil Kipnis
2020-03-03 16:04       ` Bart Van Assche
2020-03-04 16:43         ` Jinpu Wang
2020-03-04 16:49           ` Jason Gunthorpe
2020-03-05 11:26             ` Jinpu Wang
2020-03-05 13:27               ` Jason Gunthorpe
2020-03-05 13:37                 ` Jinpu Wang
2020-03-05 13:54                   ` Jason Gunthorpe
2020-03-06 13:33                     ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 07/25] RDMA/rtrs: client: statistics functions Jack Wang
2020-03-03 11:28   ` Leon Romanovsky
2020-03-03 11:46     ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 08/25] RDMA/rtrs: client: sysfs interface functions Jack Wang
2020-02-21 10:47 ` [PATCH v9 09/25] RDMA/rtrs: server: private header with server structs and functions Jack Wang
2020-02-21 10:47 ` [PATCH v9 10/25] RDMA/rtrs: server: main functionality Jack Wang
2020-03-01  1:42   ` Bart Van Assche
2020-03-02 14:39     ` Jinpu Wang
2020-03-03 11:37   ` Leon Romanovsky
2020-03-03 16:41     ` Jinpu Wang
2020-03-03 16:59       ` Leon Romanovsky
2020-03-04 11:03         ` Jinpu Wang
2020-03-05  8:00           ` Leon Romanovsky
     [not found]             ` <CAHg0Huyc=pn1=WSKGLjm+c8AcchyQ8q7JS-0ToQyiBRgpGG=jA@mail.gmail.com>
2020-03-05 12:16               ` Leon Romanovsky
2020-03-05 12:28                 ` Jinpu Wang
2020-03-05 12:35                   ` Leon Romanovsky
2020-03-05 13:02                     ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 11/25] RDMA/rtrs: server: statistics functions Jack Wang
2020-02-21 10:47 ` [PATCH v9 12/25] RDMA/rtrs: server: sysfs interface functions Jack Wang
2020-02-21 10:47 ` [PATCH v9 13/25] RDMA/rtrs: include client and server modules into kernel compilation Jack Wang
2020-02-21 10:47 ` [PATCH v9 14/25] RDMA/rtrs: a bit of documentation Jack Wang
2020-02-21 10:47 ` [PATCH v9 15/25] block/rnbd: private headers with rnbd protocol structs and helpers Jack Wang
2020-03-01  2:12   ` Bart Van Assche
2020-03-02 16:37     ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 16/25] block/rnbd: client: private header with client structs and functions Jack Wang
2020-03-01  2:26   ` Bart Van Assche
2020-03-02 14:59     ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 17/25] block/rnbd: client: main functionality Jack Wang
2020-03-01  2:46   ` Bart Van Assche
2020-03-02 14:58     ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 18/25] block/rnbd: client: sysfs interface functions Jack Wang
2020-02-21 10:47 ` [PATCH v9 19/25] block/rnbd: server: private header with server structs and functions Jack Wang
2020-03-01  2:47   ` Bart Van Assche
2020-03-02 10:07     ` Danil Kipnis
2020-02-21 10:47 ` [PATCH v9 20/25] block/rnbd: server: main functionality Jack Wang
2020-03-01  2:58   ` Bart Van Assche
2020-03-02  9:58     ` Danil Kipnis
2020-03-03  5:57       ` Bart Van Assche
2020-02-21 10:47 ` [PATCH v9 21/25] block/rnbd: server: functionality for IO submission to file or block dev Jack Wang
2020-03-01  3:09   ` Bart Van Assche
2020-03-02 10:06     ` Danil Kipnis
2020-03-03 16:20       ` Jinpu Wang
2020-03-03 16:28         ` Bart Van Assche
2020-03-03 16:43           ` Jinpu Wang
2020-02-21 10:47 ` [PATCH v9 22/25] block/rnbd: server: sysfs interface functions Jack Wang
2020-02-21 10:47 ` [PATCH v9 23/25] block/rnbd: include client and server modules into kernel compilation Jack Wang
2020-02-21 10:47 ` [PATCH v9 24/25] block/rnbd: a bit of documentation Jack Wang
2020-02-21 10:47 ` [PATCH v9 25/25] MAINTAINERS: Add maintainers for RNBD/RTRS modules Jack Wang
2020-03-03  9:28 ` [PATCH v9 00/25] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Leon Romanovsky
2020-03-04 14:06   ` Jinpu 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=CAMGffEkBy4uB-GL_5zqqG3uOnJgbP0X5TwfqmcKNJ0Lx8_B5Fw@mail.gmail.com \
    --to=jinpu.wang@cloud.ionos.com \
    --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=jinpuwang@gmail.com \
    --cc=leon@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=pankaj.gupta@cloud.ionos.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.