From patchwork Fri Mar 24 10:45:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9642583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 96A986020B for ; Fri, 24 Mar 2017 10:47:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADC5027F07 for ; Fri, 24 Mar 2017 10:47:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A21F02823D; Fri, 24 Mar 2017 10:47:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0196427F07 for ; Fri, 24 Mar 2017 10:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935711AbdCXKrs (ORCPT ); Fri, 24 Mar 2017 06:47:48 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:36022 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935578AbdCXKrl (ORCPT ); Fri, 24 Mar 2017 06:47:41 -0400 Received: by mail-wr0-f181.google.com with SMTP id u108so6737001wrb.3 for ; Fri, 24 Mar 2017 03:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/O9Pj34g8UDhHQYj2URofVP5ywvtcw4bKJugpDnZDs0=; b=Ze4jIwU7aRal9sJAogfVmfl852quKZ2CbmbbaRnTwvvPZFOnJvMrgPCYwyrjabH/bR 6k11723ubmcYIEH0dlnrEPFsLd56Gk1idPjiXqXGGNo34qX7/sr4NuhSujGC0ckS2lMl K8EifPc+83LF3dzvRyuq7fo2WTk+GFZ1hPDa3HfbwmzGS4sg2SyAwf5mWYDx0E/69Wqm gn5OTNnZnj71aZRLkzK6IXhbkCNeK0MYWPdXQVlSxOD9XTdFWpLrx1sZOyIPu80U4rU6 Wd3x2uXrF8Uu5xyPv1mu13uIvi6iZubEJNXZ8hir7CR1X5nSR3L1GlyzR/tLJ4Xof5bP Z5aQ== 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=/O9Pj34g8UDhHQYj2URofVP5ywvtcw4bKJugpDnZDs0=; b=FIFn6mxnJpU7Wg8TdTmU+M168pjxm2UICnC3+52sLYhVhwNwikJaZUOe4Ry3tUq26I PiVPfI6kT61juIZ9joM2oRBp5RqPiOpb7reiq+ZMLUDvFAt80XomswOBUehG1QJ3MNil JM4CPq+ecaCJiuWF+mlFvNeNV+6a74Zmo+J5Dpc7vZYbS9o72mvN1vNF3gLOYqFdrthR qdS5zbGj9MNbLKOtcAPsCmJs6VbTD7EjjwGSHSVIM0/p4zNMcziMuUPfhv3FaK/IMIrG VKUrRclPU9DSbwWBzUZI65wJiTqt7JZO1ASa389OAjpYoDIfxQkZ8uhYKncLwepwLQ+K /bYA== X-Gm-Message-State: AFeK/H2IYXBmJs8ZSYCwbTS9RbqdyEFyXJCb2rMSarT233qerclfY7o/AKDbsDDZEZvucP96 X-Received: by 10.223.135.85 with SMTP id 21mr6967117wrz.93.1490352459018; Fri, 24 Mar 2017 03:47:39 -0700 (PDT) Received: from jinpu-GA-870A-USB3.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id s17sm2404458wrc.25.2017.03.24.03.47.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Mar 2017 03:47:38 -0700 (PDT) From: Jack Wang X-Google-Original-From: Jack Wang To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org Cc: dledford@redhat.com, axboe@kernel.dk, hch@lst.de, mail@fholler.de, Milind.dumbare@gmail.com, yun.wang@profitbricks.com, Jack Wang , Kleber Souza , Danil Kipnis , Roman Pen Subject: [PATCH 09/28] ibtrs_srv: add header file for exported interface Date: Fri, 24 Mar 2017 11:45:24 +0100 Message-Id: <1490352343-20075-10-git-send-email-jinpu.wangl@profitbricks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490352343-20075-1-git-send-email-jinpu.wangl@profitbricks.com> References: <1490352343-20075-1-git-send-email-jinpu.wangl@profitbricks.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jack Wang Signed-off-by: Jack Wang Signed-off-by: Kleber Souza Signed-off-by: Danil Kipnis Signed-off-by: Roman Pen --- include/rdma/ibtrs_srv.h | 206 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 include/rdma/ibtrs_srv.h diff --git a/include/rdma/ibtrs_srv.h b/include/rdma/ibtrs_srv.h new file mode 100644 index 0000000..dbd535f --- /dev/null +++ b/include/rdma/ibtrs_srv.h @@ -0,0 +1,206 @@ +/* + * InfiniBand Transport Layer + * + * Copyright (c) 2014 - 2017 ProfitBricks GmbH. All rights reserved. + * Authors: Fabian Holler < mail@fholler.de> + * Jack Wang + * Kleber Souza + * Danil Kipnis + * Roman Pen + * Milind Dumbare + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + */ + +#ifndef _IBTRS_SRV_H +#define _IBTRS_SRV_H + +#include + +struct ibtrs_session; +struct ibtrs_ops_id; + +enum ibtrs_srv_rdma_ev { + IBTRS_SRV_RDMA_EV_RECV, + IBTRS_SRV_RDMA_EV_WRITE_REQ, +}; + +/** + * enum ibtrs_srv_sess_ev - Session events + * @IBTRS_SRV_SESS_EV_CONNECTED: Connection from client established + * @IBTRS_SRV_SESS_EV_DISCONNECTING: Connection is currently disconnected, + * sending data through the connection may + * fail, but could still recv messages. + * @IBTRS_SRV_SESS_EV_DISCONNECTED: Connection was disconnected, all + * connection IBTRS resources were freed. + */ + +enum ibtrs_srv_sess_ev { + IBTRS_SRV_SESS_EV_CONNECTED, + IBTRS_SRV_SESS_EV_DISCONNECTING, + IBTRS_SRV_SESS_EV_DISCONNECTED, +}; + +/** + * &struct ibtrs_srv_ops - Callbacks for ibtrs_server + * @owner: module that uses ibtrs_server + * @rdma_ev: Event notification for RDMA operations + * If the callback returns a value != 0, an error message + * for the data transfer will be sent to the client. + + * @sess: Session + * @priv: Private data from user + * @id: internal IBTRS id + * @ev: Event + * @data: Data received by the client. The message of the user of + * ibtrs_client is allocated at the end of the buffer. + * Before the message the data of the ibtrs_client is + * located. + * If the event is %IBTRS_SRV_RDMA_EV_WRITE_REQ, the user + * can write his response into @data. When + * ibtrs_srv_resp_rdma() is called, this @data will be + * transferred to the client. + * @len: length of data in @data + + * @sess_ev: Events about connective state changes + * If the callback returns != 0 and the event + * %IBTRS_SRV_SESS_EV_CONNECTED the corresponding session + * was destroyed. + * @sess: Session + * @ev: event + * @priv: Private data from user if previously set with + * ibtrs_srv_set_sess_priv() + + * @recv: Event notification for infiniband message receival + * @sess: Session + * @priv: Private data from user if previously set with + * ibtrs_srv_set_sess_priv() + * @msg: Received message + * @len: length of @msg + */ + +typedef int (rdma_ev_fn)(struct ibtrs_session *sess, void *priv, + struct ibtrs_ops_id *id, enum ibtrs_srv_rdma_ev ev, + void *data, size_t len); +typedef int (sess_ev_fn)(struct ibtrs_session *sess, enum ibtrs_srv_sess_ev ev, + void *priv); +typedef void (recv_fn)(struct ibtrs_session *sess, void *priv, const void *msg, + size_t len); + +struct ibtrs_srv_ops { + struct module *owner; + + rdma_ev_fn *rdma_ev; + sess_ev_fn *sess_ev; + recv_fn *recv; +}; + +/** + * ibtrs_srv_register() - register a module with ibtrs_server + * @ops: callback functions + * + * Registers a module with the ibtrs_server. The user module passes the function + * pointers, that ibtrs_server can call to communicate with it. + * + * Return: + * 0: Success + * <0: Error + */ +int ibtrs_srv_register(const struct ibtrs_srv_ops *ops); + +/** + * ibtrs_srv_unregister - unregister a module with ibtrs_server + * @ops: the struct that was passed to ibtrs_srv_register() before + * + * Unregisters a module from the ibtrs_server. All open connections will be + * terminated. + */ +void ibtrs_srv_unregister(const struct ibtrs_srv_ops *ops); + +/** + * ibtrs_srv_resp_rdma() - Finish an RDMA request + * + * @id: Internal IBTRS operation identifier + * @errno: Response Code send to the other side for this operation. + * 0 = success, <=0 error + * Return: + * 0: Success + * <0: Error + * + * Finish a RDMA operation. A message is sent to the client and the + * corresponding memory areas will be released. + */ +int ibtrs_srv_resp_rdma(struct ibtrs_ops_id *id, int errno); + +/** + * ibtrs_srv_send() - Send data to the ibtrs_server with an infiniband message. + * @sess Session + * @vec: Data send to the server + * @nr: Length of @vec + * + * Return: + * 0: Success + * <0: Error + * -EINVAL: @len is too big + */ +int ibtrs_srv_send(struct ibtrs_session *sess, const struct kvec *vec, + size_t nr); + +/** + * ibtrs_srv_set_sess_priv() - Set private pointer in ibtrs_session. + * @sess Session + * @priv: The private pointer that is associated with the session. + */ +void ibtrs_srv_set_sess_priv(struct ibtrs_session *sess, void *priv); + +/** + * ibtrs_srv_get_sess_qdepth() - Get ibtrs_session qdepth. + * @sess Session + */ +int ibtrs_srv_get_sess_qdepth(struct ibtrs_session *sess); + +/** + * ibtrs_srv_get_sess_addr() - Get ibtrs_session address. + * @sess Session + */ +const char *ibtrs_srv_get_sess_addr(struct ibtrs_session *sess); + +/** + * ibtrs_srv_get_sess_hostname() - Get ibtrs_session peer hostname. + * @sess Session + */ +const char *ibtrs_srv_get_sess_hostname(struct ibtrs_session *sess); + +#endif