On Mon, Sep 23, 2019 at 7:44 PM Bart Van Assche <bvanassche@xxxxxxx> wrote: > > +/** > > + * enum ibtrs_clt_link_ev - Events about connectivity state of a client > > + * @IBTRS_CLT_LINK_EV_RECONNECTED Client was reconnected. > > + * @IBTRS_CLT_LINK_EV_DISCONNECTED Client was disconnected. > > + */ > > +enum ibtrs_clt_link_ev { > > + IBTRS_CLT_LINK_EV_RECONNECTED, > > + IBTRS_CLT_LINK_EV_DISCONNECTED, > > +}; > > + > > +/** > > + * Source and destination address of a path to be established > > + */ > > +struct ibtrs_addr { > > + struct sockaddr_storage *src; > > + struct sockaddr_storage *dst; > > +}; > > Is it really useful to define a structure to hold two pointers or can > these two pointers also be passed as separate arguments? We always need both src and dst throughout ibnbd and ibtrs code and indeed one reason to introduce this struct is that "f(struct ibtrs_addr *addr, ...);" is shorter than "f(struct sockaddr_storage *src, struct sockaddr_storage *dst, ...);". But it also makes it easier to extend the address information describing one ibtrs path in the future. > > +/** > > + * ibtrs_clt_open() - Open a session to a IBTRS client > > + * @priv: User supplied private data. > > + * @link_ev: Event notification for connection state changes > > + * @priv: user supplied data that was passed to > > + * ibtrs_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 elemnts in the @paths array > > + * @port: port to be used by the IBTRS session > > + * @pdu_sz: Size of extra payload which can be accessed after tag 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 ibtrs_server. The function can block > > + * up to ~2000ms until it returns. > > + * > > + * Return a valid pointer on success otherwise PTR_ERR. > > + */ > > +struct ibtrs_clt *ibtrs_clt_open(void *priv, link_clt_ev_fn *link_ev, > > + const char *sessname, > > + const struct ibtrs_addr *paths, > > + size_t path_cnt, short port, > > + size_t pdu_sz, u8 reconnect_delay_sec, > > + u16 max_segments, > > + s16 max_reconnect_attempts); > > Having detailed kernel-doc headers for describing API functions is great > but I'm not sure a .h file is the best location for such documentation. > Many kernel developers keep kernel-doc headers in .c files because that > makes it more likely that the documentation and the implementation stay > in sync. What is better: to move it or to only copy it to the corresponding C file? > > > + > > +/** > > + * ibtrs_clt_close() - Close a session > > + * @sess: Session handler, is freed on return > ^^^^^^^ > handle? > > This sentence suggests that the handle is freed on return. I guess that > you meant that the session is freed upon return? Right, will fix the wording. > > > +/** > > + * ibtrs_clt_get_tag() - allocates tag for future RDMA operation > > + * @sess: Current session > > + * @con_type: Type of connection to use with the tag > > + * @wait: Wait type > > + * > > + * Description: > > + * Allocates tag for the following RDMA operation. Tag is used > > + * to preallocate all resources and to propagate memory pressure > > + * up earlier. > > + * > > + * Context: > > + * Can sleep if @wait == IBTRS_TAG_WAIT > > + */ > > +struct ibtrs_tag *ibtrs_clt_get_tag(struct ibtrs_clt *sess, > > + enum ibtrs_clt_con_type con_type, > > + int wait); > > Since struct ibtrs_tag has another role than what is called a tag in the > block layer I think a better description is needed of what struct > ibtrs_tag actually represents. I think it would be better to rename it to ibtrs_permit in order to avoid confusion with block layer tags. Will extend the description also. > > +/* > > + * Here goes IBTRS server API > > + */ > > Most software either uses the client API or the server API but not both > at the same time. Has it been considered to use separate header files > for the client and server APIs? I don't have any really good reason to put API of server and client into a single file. Except may be that the reader can see API calls corresponding the full sequence of request -> indication -> response -> confirmation in one place.