From patchwork Fri Dec 20 15:50:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11305871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FB6B14E3 for ; Fri, 20 Dec 2019 15:51:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E65C24679 for ; Fri, 20 Dec 2019 15:51:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B+Sekbs+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727522AbfLTPv1 (ORCPT ); Fri, 20 Dec 2019 10:51:27 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44208 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbfLTPv1 (ORCPT ); Fri, 20 Dec 2019 10:51:27 -0500 Received: by mail-wr1-f67.google.com with SMTP id q10so9863403wrm.11; Fri, 20 Dec 2019 07:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EjyNWEfqFLUEbXZlfz4wsxZZpUgMKbLoy6ckTMTVn+c=; b=B+Sekbs+f/azBPF6gfUXD/7CIIgo/hP7aWCDouvamLnfCBeDeUldtgW3HF1J39QhYK vK2QH8p/J4ySEdXhylVT+xNOid8Ggmt8B/5iQpEHdbCN6NzuJsX67QZXGjoAC2fYG2Qr OZ9HdcbWNNuVOFgaFrsehnji5kXg/9DfmLDBA94PHolS9PsYGyPAepff3jwqK5Jkcb6w p4ctKYPw1BGiZoFl5sXCu64LuMwtrZltKC46LTT9oP010bkLf/CedoHlfoJ7KBEqkK3v zNdsdF0tVIAtZF+NgwGBTVQ0eKwcLA+IjeIyj6oYSRtG+o/IDDIiLKtQjOD9FYi3dHPE yLvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EjyNWEfqFLUEbXZlfz4wsxZZpUgMKbLoy6ckTMTVn+c=; b=nEEVhP+odsRs2qn87C8NXlOIzUTaEOqtDPosnk01GyxfFbY9HQ2LeciF0/7658iGoJ ek7HNEFIkzEQ4wM1isiIyRCSs/mRfyyKrOSi1BFSv045+Rf819nEgQgwoZrnaRi+sEJe LXs6bCPFkssIfn6C4eGAygx20E5Af32dihQYlpJ1iXL2sAh4PJvzSiaCjugbjCcbYx/o ELnmJ4kQ+sGjPaHlrzdrq8U7lytNBGZKdjdFaPJyLQoBJ2nejyv/pA8wIJomaefxKnsT 9nbLptYYsNFLeppQp2d1D4rOrYzK3ZrTmuVcd0kkZZjdZXln3+gihEZJDjdNq6YSTipK BkEg== X-Gm-Message-State: APjAAAUQ1/hnlXvfTUNY/7xgI/bI0UBBV+CEuG+Gy6ZGniVvRWTi5we1 AfDXsP7pQ+WTTdXPSoFd/z1gXSzWH1k= X-Google-Smtp-Source: APXvYqx+JGwfV8jYqIQnFlPKRJLqfbAajZFaqp2zp24S6dhgNVzACsrYFNuGIShRn2c4JlaPSc1k/Q== X-Received: by 2002:adf:ea4e:: with SMTP id j14mr16481350wrn.101.1576857084102; Fri, 20 Dec 2019 07:51:24 -0800 (PST) Received: from jwang-Latitude-5491.fritz.box ([2001:16b8:4972:cc00:b9e0:6ef7:286d:4897]) by smtp.gmail.com with ESMTPSA id u14sm10372139wrm.51.2019.12.20.07.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 07:51:23 -0800 (PST) From: Jack Wang To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, rpenyaev@suse.de Subject: [PATCH v5 09/25] rtrs: server: private header with server structs and functions Date: Fri, 20 Dec 2019 16:50:53 +0100 Message-Id: <20191220155109.8959-10-jinpuwang@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191220155109.8959-1-jinpuwang@gmail.com> References: <20191220155109.8959-1-jinpuwang@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Jack Wang 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 Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 159 +++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 drivers/infiniband/ulp/rtrs/rtrs-srv.h diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.h b/drivers/infiniband/ulp/rtrs/rtrs-srv.h new file mode 100644 index 000000000000..5124140652e4 --- /dev/null +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * InfiniBand Transport Layer + * + * Copyright (c) 2014 - 2017 ProfitBricks GmbH. All rights reserved. + * Authors: Fabian Holler + * Jack Wang + * Kleber Souza + * Danil Kipnis + * Roman Penyaev + * Milind Dumbare + * + * Copyright (c) 2017 - 2018 ProfitBricks GmbH. All rights reserved. + * Authors: Danil Kipnis + * Roman Penyaev + * Swapnil Ingle + * + * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved. + * Authors: Roman Penyaev + * Jinpu Wang + * Danil Kipnis + */ +/* Copyright (c) 2019 1&1 IONOS SE. All rights reserved. + * Authors: Jack Wang + * Danil Kipnis + * Guoqing Jiang + * Lutz Pogrell + */ + +#ifndef RTRS_SRV_H +#define RTRS_SRV_H + +#include +#include +#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 */