linux/drivers/infiniband/ulp/rtrs/rtrs-srv.c

// 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)

#include <linux/module.h>

#include "rtrs-srv.h"
#include "rtrs-log.h"
#include <rdma/ib_cm.h>
#include <rdma/ib_verbs.h>
#include "rtrs-srv-trace.h"

MODULE_DESCRIPTION();
MODULE_LICENSE();

/* Must be power of 2, see mask from mr->page_size in ib_sg_to_pages() */
#define DEFAULT_MAX_CHUNK_SIZE
#define DEFAULT_SESS_QUEUE_DEPTH
#define MAX_HDR_SIZE

static struct rtrs_rdma_dev_pd dev_pd;
const struct class rtrs_dev_class =;
static struct rtrs_srv_ib_ctx ib_ctx;

static int __read_mostly max_chunk_size =;
static int __read_mostly sess_queue_depth =;

static bool always_invalidate =;
module_param(always_invalidate, bool, 0444);
MODULE_PARM_DESC();

module_param_named(max_chunk_size, max_chunk_size, int, 0444);
MODULE_PARM_DESC();

module_param_named(sess_queue_depth, sess_queue_depth, int, 0444);
MODULE_PARM_DESC();

static cpumask_t cq_affinity_mask =;

static struct workqueue_struct *rtrs_wq;

static inline struct rtrs_srv_con *to_srv_con(struct rtrs_con *c)
{}

static bool rtrs_srv_change_state(struct rtrs_srv_path *srv_path,
				  enum rtrs_srv_state new_state)
{}

static void free_id(struct rtrs_srv_op *id)
{}

static void rtrs_srv_free_ops_ids(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_rdma_done(struct ib_cq *cq, struct ib_wc *wc);

static struct ib_cqe io_comp_cqe =;

static inline void rtrs_srv_inflight_ref_release(struct percpu_ref *ref)
{}

static int rtrs_srv_alloc_ops_ids(struct rtrs_srv_path *srv_path)
{}

static inline void rtrs_srv_get_ops_ids(struct rtrs_srv_path *srv_path)
{}

static inline void rtrs_srv_put_ops_ids(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_reg_mr_done(struct ib_cq *cq, struct ib_wc *wc)
{}

static struct ib_cqe local_reg_cqe =;

static int rdma_write_sg(struct rtrs_srv_op *id)
{}

/**
 * send_io_resp_imm() - respond to client with empty IMM on failed READ/WRITE
 *                      requests or on successful WRITE request.
 * @con:	the connection to send back result
 * @id:		the id associated with the IO
 * @errno:	the error number of the IO.
 *
 * Return 0 on success, errno otherwise.
 */
static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id,
			    int errno)
{}

void close_path(struct rtrs_srv_path *srv_path)
{}

static inline const char *rtrs_srv_state_str(enum rtrs_srv_state state)
{}

/**
 * rtrs_srv_resp_rdma() - Finish an RDMA request
 *
 * @id:		Internal RTRS operation identifier
 * @status:	Response Code sent to the other side for this operation.
 *		0 = success, <=0 error
 * Context: any
 *
 * Finish a RDMA operation. A message is sent to the client and the
 * corresponding memory areas will be released.
 */
bool rtrs_srv_resp_rdma(struct rtrs_srv_op *id, int status)
{}
EXPORT_SYMBOL();

/**
 * rtrs_srv_set_sess_priv() - Set private pointer in rtrs_srv.
 * @srv:	Session pointer
 * @priv:	The private pointer that is associated with the session.
 */
void rtrs_srv_set_sess_priv(struct rtrs_srv_sess *srv, void *priv)
{}
EXPORT_SYMBOL();

static void unmap_cont_bufs(struct rtrs_srv_path *srv_path)
{}

static int map_cont_bufs(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_hb_err_handler(struct rtrs_con *c)
{}

static void rtrs_srv_init_hb(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_start_hb(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_stop_hb(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_info_rsp_done(struct ib_cq *cq, struct ib_wc *wc)
{}

static int rtrs_srv_path_up(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_path_down(struct rtrs_srv_path *srv_path)
{}

static bool exist_pathname(struct rtrs_srv_ctx *ctx,
			   const char *pathname, const uuid_t *path_uuid)
{}

static int post_recv_path(struct rtrs_srv_path *srv_path);
static int rtrs_rdma_do_reject(struct rdma_cm_id *cm_id, int errno);

static int process_info_req(struct rtrs_srv_con *con,
			    struct rtrs_msg_info_req *msg)
{}

static void rtrs_srv_info_req_done(struct ib_cq *cq, struct ib_wc *wc)
{}

static int post_recv_info_req(struct rtrs_srv_con *con)
{}

static int post_recv_io(struct rtrs_srv_con *con, size_t q_size)
{}

static int post_recv_path(struct rtrs_srv_path *srv_path)
{}

static void process_read(struct rtrs_srv_con *con,
			 struct rtrs_msg_rdma_read *msg,
			 u32 buf_id, u32 off)
{}

static void process_write(struct rtrs_srv_con *con,
			  struct rtrs_msg_rdma_write *req,
			  u32 buf_id, u32 off)
{}

static void process_io_req(struct rtrs_srv_con *con, void *msg,
			   u32 id, u32 off)
{}

static void rtrs_srv_inv_rkey_done(struct ib_cq *cq, struct ib_wc *wc)
{}

static int rtrs_srv_inv_rkey(struct rtrs_srv_con *con,
			      struct rtrs_srv_mr *mr)
{}

static void rtrs_rdma_process_wr_wait_list(struct rtrs_srv_con *con)
{}

static void rtrs_srv_rdma_done(struct ib_cq *cq, struct ib_wc *wc)
{}

/**
 * rtrs_srv_get_path_name() - Get rtrs_srv peer hostname.
 * @srv:	Session
 * @pathname:	Pathname buffer
 * @len:	Length of sessname buffer
 */
int rtrs_srv_get_path_name(struct rtrs_srv_sess *srv, char *pathname,
			   size_t len)
{}
EXPORT_SYMBOL();

/**
 * rtrs_srv_get_queue_depth() - Get rtrs_srv qdepth.
 * @srv:	Session
 */
int rtrs_srv_get_queue_depth(struct rtrs_srv_sess *srv)
{}
EXPORT_SYMBOL();

static int find_next_bit_ring(struct rtrs_srv_path *srv_path)
{}

static int rtrs_srv_get_next_cq_vector(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_dev_release(struct device *dev)
{}

static void free_srv(struct rtrs_srv_sess *srv)
{}

static struct rtrs_srv_sess *get_or_create_srv(struct rtrs_srv_ctx *ctx,
					  const uuid_t *paths_uuid,
					  bool first_conn)
{}

static void put_srv(struct rtrs_srv_sess *srv)
{}

static void __add_path_to_srv(struct rtrs_srv_sess *srv,
			      struct rtrs_srv_path *srv_path)
{}

static void del_path_from_srv(struct rtrs_srv_path *srv_path)
{}

/* return true if addresses are the same, error other wise */
static int sockaddr_cmp(const struct sockaddr *a, const struct sockaddr *b)
{}

static bool __is_path_w_addr_exists(struct rtrs_srv_sess *srv,
				    struct rdma_addr *addr)
{}

static void free_path(struct rtrs_srv_path *srv_path)
{}

static void rtrs_srv_close_work(struct work_struct *work)
{}

static int rtrs_rdma_do_accept(struct rtrs_srv_path *srv_path,
			       struct rdma_cm_id *cm_id)
{}

static int rtrs_rdma_do_reject(struct rdma_cm_id *cm_id, int errno)
{}

static struct rtrs_srv_path *
__find_path(struct rtrs_srv_sess *srv, const uuid_t *sess_uuid)
{}

static int create_con(struct rtrs_srv_path *srv_path,
		      struct rdma_cm_id *cm_id,
		      unsigned int cid)
{}

static struct rtrs_srv_path *__alloc_path(struct rtrs_srv_sess *srv,
					   struct rdma_cm_id *cm_id,
					   unsigned int con_num,
					   unsigned int recon_cnt,
					   const uuid_t *uuid)
{}

static int rtrs_rdma_connect(struct rdma_cm_id *cm_id,
			      const struct rtrs_msg_conn_req *msg,
			      size_t len)
{}

static int rtrs_srv_rdma_cm_handler(struct rdma_cm_id *cm_id,
				     struct rdma_cm_event *ev)
{}

static struct rdma_cm_id *rtrs_srv_cm_init(struct rtrs_srv_ctx *ctx,
					    struct sockaddr *addr,
					    enum rdma_ucm_port_space ps)
{}

static int rtrs_srv_rdma_init(struct rtrs_srv_ctx *ctx, u16 port)
{}

static struct rtrs_srv_ctx *alloc_srv_ctx(struct rtrs_srv_ops *ops)
{}

static void free_srv_ctx(struct rtrs_srv_ctx *ctx)
{}

static int rtrs_srv_add_one(struct ib_device *device)
{}

static void rtrs_srv_remove_one(struct ib_device *device, void *client_data)
{}

static struct ib_client rtrs_srv_client =;

/**
 * rtrs_srv_open() - open RTRS server context
 * @ops:		callback functions
 * @port:               port to listen on
 *
 * Creates server context with specified callbacks.
 *
 * Return a valid pointer on success otherwise PTR_ERR.
 */
struct rtrs_srv_ctx *rtrs_srv_open(struct rtrs_srv_ops *ops, u16 port)
{}
EXPORT_SYMBOL();

static void close_paths(struct rtrs_srv_sess *srv)
{}

static void close_ctx(struct rtrs_srv_ctx *ctx)
{}

/**
 * rtrs_srv_close() - close RTRS server context
 * @ctx: pointer to server context
 *
 * Closes RTRS server context with all client sessions.
 */
void rtrs_srv_close(struct rtrs_srv_ctx *ctx)
{}
EXPORT_SYMBOL();

static int check_module_params(void)
{}

static int __init rtrs_server_init(void)
{}

static void __exit rtrs_server_exit(void)
{}

module_init();
module_exit(rtrs_server_exit);