From patchwork Fri Feb 21 10:47:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11396149 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 22C1514E3 for ; Fri, 21 Feb 2020 10:47:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02ABD24650 for ; Fri, 21 Feb 2020 10:47:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZBAB8K1s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728201AbgBUKrf (ORCPT ); Fri, 21 Feb 2020 05:47:35 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45857 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728147AbgBUKrf (ORCPT ); Fri, 21 Feb 2020 05:47:35 -0500 Received: by mail-ed1-f65.google.com with SMTP id v28so1748190edw.12; Fri, 21 Feb 2020 02:47:33 -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=J8fBNjSPDt0FwN6DkrYYEkcMXSlBqigTlbjCKjfNPuY=; b=ZBAB8K1s7vteyi8xNGIoNrdu/qynkkyzhkiWvzi9WBYW1BcUHu/8ODZwvOGAU7xg1J FsBQEvm3LxVzhtk//rGWRxgOmsrCv0RAhRhhE29SFY53AsQQewdUVJB39cAPsx7n8XPj 8D6ZAGVnTMqmjsXtiqyuNTjEzxChkZ7M8ka3vCWYqpKpFYW4S68jlyEfoW4XsS/vwF2+ QsUHWXsa5GVX1NX8NIPInVebSZhjvV6yDNjt4iUB/vqv2Pur9Luazy55Dp+non84yvsg yPzelp9ApvNyigzk+CjNUEELkTcEru8jKFALlea3Tji2dArBoay+GjUrR1xnG12OkoWp 8h+w== 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=J8fBNjSPDt0FwN6DkrYYEkcMXSlBqigTlbjCKjfNPuY=; b=BWq0/XHHhNLZlxx6uHrfz9ft02kxkqL48rHmpN5lXOZJBKSqcOVKORmEAFhssItuHM 90MWU//Q1o6IzMZX5n2SPQBnijlm/UV0kiunbjA7O65a+fP8z7dpvjB3wmlQ+YdVQ4FY QSsGNRpQBq99YGRyquB5CXV5EP56pQflbqQyRBB286m5agUXRYJYXDrecpmH0tzMnLAc h/n1xcEjw9aKpBFSTbd7olx0Zs+ngY0qFeW8Vu9arB6PiwWCKHKTf0FB0WxKEmttFAjN HZZOnftpX4lXkGQo1c6Cyzblo8/E7bfk6d9vduZiqop3utA3x497pI4jb9HNvqXChx1p Gfqw== X-Gm-Message-State: APjAAAXWI4KVh52ZJTJ992rBi5VsqhfkmmdUOrawjhCuUKhwjaMSJOuf BuKeB5Qs++YL8Gwb2X8UAQVoONEa X-Google-Smtp-Source: APXvYqykQIwrZHzDG4Z8CW8VMkFMRMp97lnXQ9DWL5Jkf+Ze9peU8jQwv0SShg3CueGr5CH/e4Iarw== X-Received: by 2002:aa7:c703:: with SMTP id i3mr32831169edq.295.1582282052922; Fri, 21 Feb 2020 02:47:32 -0800 (PST) Received: from jwang-Latitude-5491.pb.local ([2001:1438:4010:2558:d8ec:cf8e:d7de:fb22]) by smtp.gmail.com with ESMTPSA id 2sm270594edv.87.2020.02.21.02.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 02:47:32 -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, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, rpenyaev@suse.de, pankaj.gupta@cloud.ionos.com Subject: [PATCH v9 09/25] RDMA/rtrs: server: private header with server structs and functions Date: Fri, 21 Feb 2020 11:47:05 +0100 Message-Id: <20200221104721.350-10-jinpuwang@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200221104721.350-1-jinpuwang@gmail.com> References: <20200221104721.350-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 | 138 +++++++++++++++++++++++++ 1 file changed, 138 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..73cc19821e74 --- /dev/null +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h @@ -0,0 +1,138 @@ +/* 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_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, +}; + +/* stats for Read and write operation. + * see Documentation/ABI/testing/sysfs-class-rtrs-server for details + */ +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_srv_con { + struct rtrs_con c; + atomic_t wr_cnt; +}; + +/* IO context in rtrs_srv, each io has one */ +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; +}; + +/* + * server side memory region context, when always_invalidate=Y, we need + * queue_depth of memory regrion to invalidate each memory region. + */ +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); + +/* functions which are implemented in rtrs-srv-stats.c */ +void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s, size_t size, int d); + +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); + +/* functions which are implemented in 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 */