diff mbox series

[v6,09/25] rtrs: server: private header with server structs and functions

Message ID 20191230102942.18395-10-jinpuwang@gmail.com (mailing list archive)
State New, archived
Headers show
Series RTRS (former IBTRS) rdma transport library and RNBD (former IBNBD) rdma network block device | expand

Commit Message

Jinpu Wang Dec. 30, 2019, 10:29 a.m. UTC
From: Jack Wang <jinpu.wang@cloud.ionos.com>

This header describes main structs and functions used by rtrs-server
module, mainly for accepting rtrs sessions, creating/destroying
sysfs entries, accounting statistics on server side.

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-srv.h | 141 +++++++++++++++++++++++++
 1 file changed, 141 insertions(+)
 create mode 100644 drivers/infiniband/ulp/rtrs/rtrs-srv.h

Comments

Bart Van Assche Jan. 2, 2020, 9:24 p.m. UTC | #1
On 12/30/19 2:29 AM, Jack Wang wrote:
> +struct rtrs_stats_wc_comp {
> +	atomic64_t	calls;
> +	atomic64_t	total_wc_cnt;
> +};

Please document the meaning of the members of this data structure.

> +struct rtrs_srv_stats_rdma_stats {
> +	struct {
> +		atomic64_t	cnt;
> +		atomic64_t	size_total;
> +	} dir[2];
> +};

Please document the meaning of the members of this data structure and 
also which index (0, 1) corresponds to which direction (read, write).

> +struct rtrs_srv_op {
> +	struct rtrs_srv_con		*con;
> +	u32				msg_id;
> +	u8				dir;
> +	struct rtrs_msg_rdma_read	*rd_msg;
> +	struct ib_rdma_wr		*tx_wr;
> +	struct ib_sge			*tx_sg;
> +};

Please document the role of this data structure.

> +struct rtrs_srv_mr {
> +	struct ib_mr	*mr;
> +	struct sg_table	sgt;
> +	struct ib_cqe	inv_cqe; /* only for always_invalidate=true */
> +	u32		msg_id; /* only for always_invalidate=true */
> +	u32		msg_off; /* only for always_invalidate=true */
> +	struct rtrs_iu	*iu; /* send buffer for new rkey msg */
> +};

Please document the role of this data structure.

> +extern struct class *rtrs_dev_class;

Please make sure that the static 'rtrs_dev_class' variable in rtrs-clt.c 
and in this header file have different names.

Thanks,

Bart.
Jinpu Wang Jan. 8, 2020, 4:33 p.m. UTC | #2
On Thu, Jan 2, 2020 at 10:24 PM Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 12/30/19 2:29 AM, Jack Wang wrote:
> > +struct rtrs_stats_wc_comp {
> > +     atomic64_t      calls;
> > +     atomic64_t      total_wc_cnt;
> > +};
>
> Please document the meaning of the members of this data structure.
will do.
>
> > +struct rtrs_srv_stats_rdma_stats {
> > +     struct {
> > +             atomic64_t      cnt;
> > +             atomic64_t      size_total;
> > +     } dir[2];
> > +};
>
> Please document the meaning of the members of this data structure and
> also which index (0, 1) corresponds to which direction (read, write).
yes, will do.
>
> > +struct rtrs_srv_op {
> > +     struct rtrs_srv_con             *con;
> > +     u32                             msg_id;
> > +     u8                              dir;
> > +     struct rtrs_msg_rdma_read       *rd_msg;
> > +     struct ib_rdma_wr               *tx_wr;
> > +     struct ib_sge                   *tx_sg;
> > +};
>
> Please document the role of this data structure.
ok.
>
> > +struct rtrs_srv_mr {
> > +     struct ib_mr    *mr;
> > +     struct sg_table sgt;
> > +     struct ib_cqe   inv_cqe; /* only for always_invalidate=true */
> > +     u32             msg_id; /* only for always_invalidate=true */
> > +     u32             msg_off; /* only for always_invalidate=true */
> > +     struct rtrs_iu  *iu; /* send buffer for new rkey msg */
> > +};
>
> Please document the role of this data structure.
ok
>
> > +extern struct class *rtrs_dev_class;
>
> Please make sure that the static 'rtrs_dev_class' variable in rtrs-clt.c
> and in this header file have different names.
ok
>
> Thanks,
>
> Bart.
Thanks
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.h b/drivers/infiniband/ulp/rtrs/rtrs-srv.h
new file mode 100644
index 000000000000..6ab6e2d3f564
--- /dev/null
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h
@@ -0,0 +1,141 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * InfiniBand 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 1&1 IONOS SE. All rights reserved.
+ */
+
+#ifndef RTRS_SRV_H
+#define RTRS_SRV_H
+
+#include <linux/device.h>
+#include <linux/refcount.h>
+#include "rtrs-pri.h"
+
+/**
+ * enum rtrs_srv_state - Server states.
+ */
+enum rtrs_srv_state {
+	RTRS_SRV_CONNECTING,
+	RTRS_SRV_CONNECTED,
+	RTRS_SRV_CLOSING,
+	RTRS_SRV_CLOSED,
+};
+
+struct rtrs_stats_wc_comp {
+	atomic64_t	calls;
+	atomic64_t	total_wc_cnt;
+};
+
+struct rtrs_srv_stats_rdma_stats {
+	struct {
+		atomic64_t	cnt;
+		atomic64_t	size_total;
+	} dir[2];
+};
+
+struct rtrs_srv_stats {
+	struct rtrs_srv_stats_rdma_stats	rdma_stats;
+	struct rtrs_stats_wc_comp		wc_comp;
+};
+
+struct rtrs_srv_con {
+	struct rtrs_con	c;
+	atomic_t		wr_cnt;
+};
+
+struct rtrs_srv_op {
+	struct rtrs_srv_con		*con;
+	u32				msg_id;
+	u8				dir;
+	struct rtrs_msg_rdma_read	*rd_msg;
+	struct ib_rdma_wr		*tx_wr;
+	struct ib_sge			*tx_sg;
+};
+
+struct rtrs_srv_mr {
+	struct ib_mr	*mr;
+	struct sg_table	sgt;
+	struct ib_cqe	inv_cqe; /* only for always_invalidate=true */
+	u32		msg_id; /* only for always_invalidate=true */
+	u32		msg_off; /* only for always_invalidate=true */
+	struct rtrs_iu	*iu; /* send buffer for new rkey msg */
+};
+
+struct rtrs_srv_sess {
+	struct rtrs_sess	s;
+	struct rtrs_srv	*srv;
+	struct work_struct	close_work;
+	enum rtrs_srv_state	state;
+	spinlock_t		state_lock;
+	int			cur_cq_vector;
+	struct rtrs_srv_op	**ops_ids;
+	atomic_t		ids_inflight;
+	wait_queue_head_t	ids_waitq;
+	struct rtrs_srv_mr	*mrs;
+	unsigned int		mrs_num;
+	dma_addr_t		*dma_addr;
+	bool			established;
+	unsigned int		mem_bits;
+	struct kobject		kobj;
+	struct kobject		kobj_stats;
+	struct rtrs_srv_stats	stats;
+};
+
+struct rtrs_srv {
+	struct list_head	paths_list;
+	int			paths_up;
+	struct mutex		paths_ev_mutex;
+	size_t			paths_num;
+	struct mutex		paths_mutex;
+	uuid_t			paths_uuid;
+	refcount_t		refcount;
+	struct rtrs_srv_ctx	*ctx;
+	struct list_head	ctx_list;
+	void			*priv;
+	size_t			queue_depth;
+	struct page		**chunks;
+	struct device		dev;
+	unsigned int		dev_ref;
+	struct kobject		kobj_paths;
+};
+
+struct rtrs_srv_ctx {
+	rdma_ev_fn *rdma_ev;
+	link_ev_fn *link_ev;
+	struct rdma_cm_id *cm_id_ip;
+	struct rdma_cm_id *cm_id_ib;
+	struct mutex srv_mutex;
+	struct list_head srv_list;
+};
+
+extern struct class *rtrs_dev_class;
+
+void close_sess(struct rtrs_srv_sess *sess);
+
+/* rtrs-srv-stats.c */
+
+void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s, size_t size, int d);
+void rtrs_srv_update_wc_stats(struct rtrs_srv_stats *s);
+
+int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable);
+ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats,
+				    char *page, size_t len);
+int rtrs_srv_reset_wc_completion_stats(struct rtrs_srv_stats *stats,
+					bool enable);
+int rtrs_srv_stats_wc_completion_to_str(struct rtrs_srv_stats *stats, char *buf,
+					 size_t len);
+int rtrs_srv_reset_all_stats(struct rtrs_srv_stats *stats, bool enable);
+ssize_t rtrs_srv_reset_all_help(struct rtrs_srv_stats *stats,
+				 char *page, size_t len);
+
+/* rtrs-srv-sysfs.c */
+
+int rtrs_srv_create_sess_files(struct rtrs_srv_sess *sess);
+void rtrs_srv_destroy_sess_files(struct rtrs_srv_sess *sess);
+
+#endif /* RTRS_SRV_H */