From patchwork Sun Apr 23 12:17:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Gu X-Patchwork-Id: 86709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2172721vqo; Sun, 23 Apr 2023 05:32:58 -0700 (PDT) X-Google-Smtp-Source: AKy350b51NWtjWT6Nj3jPUIVeVMlm/98UzbTP5exDbgeoLd+E+Xj88Dz7OWJRuuhgKrWBpMIGKlh X-Received: by 2002:a17:902:eac4:b0:19e:874e:7275 with SMTP id p4-20020a170902eac400b0019e874e7275mr11425082pld.23.1682253178719; Sun, 23 Apr 2023 05:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682253178; cv=none; d=google.com; s=arc-20160816; b=BBUmM6M6ePUHwC2ZztOfFWoeoxkfPFP5GVMrjgK6i2x+1JSuJGqXqBzQzdAOOyC1RS CejgVGzNGEDB8HJmpX8opScLQ4Tg/APhLUITwpOCJpdtcbyYlBVNw1WWhk9B3oQR7t9A EhKROkaRF/YVRlyIxpPFZDpZyCp9rbLQpYDRbX9euUun7QJCLdqUJrvBCfZV1MrAPJXR yYLzYN3biBJ4SvOuJDmW4WO17lJmb+1cVJNvEoXf1beXGeegCpwgeHRpFBImQhUGx/fq /HR7v0ltX89xrwRB/Nr630OAr7ymMSytmqUOQEb25pEvGYkwwunskhH6/Ok6GGnit9Tw N3hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=4YIB9Lhv/hhcQjHZHBGPM1DGmQS1NKXtZjdLXy3tDq0=; b=utF61GV+kwEU5Bk9Ug/UZTvRMtPm8Nic4tnDYGOfNS/B5xKFbf1K/GeouzkETFQyHA 91m6eWE9ZrNLQjBtb+zZFZK478O01vVxZweVPHalApJGhPB/O+Mgz81qJU3eM66sAybD 4jIn2u00tsVz39H3M5FnH9+c/OSuL+mVsRiCZQ+UG0hNkLnQX3csx8Vf65xs0Qb7lSJE mgzDBwATUnPm3vLclpG3OSbNu2cZry5+V8KkAGa+hU4JN9UWoTMBfNT0IBz0WnnOHsEI /kWSWRpLu1o7Z9eaUYag7U22EEzs0fHOE0dvtpINlAnJYLAJ4Iqop0gFkvZrlwpBlZJF 41CQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u7-20020a17090a6a8700b002475bc0a189si8964827pjj.113.2023.04.23.05.32.44; Sun, 23 Apr 2023 05:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbjDWMTM (ORCPT + 99 others); Sun, 23 Apr 2023 08:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjDWMSg (ORCPT ); Sun, 23 Apr 2023 08:18:36 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A3852D7F; Sun, 23 Apr 2023 05:18:09 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VgjzSS8_1682252284; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VgjzSS8_1682252284) by smtp.aliyun-inc.com; Sun, 23 Apr 2023 20:18:05 +0800 From: Wen Gu To: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next v5 6/9] net/smc: Introudce interfaces for DMB attach and detach Date: Sun, 23 Apr 2023 20:17:48 +0800 Message-Id: <1682252271-2544-7-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682252271-2544-1-git-send-email-guwen@linux.alibaba.com> References: <1682252271-2544-1-git-send-email-guwen@linux.alibaba.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763970308770691398?= X-GMAIL-MSGID: =?utf-8?q?1763970308770691398?= This patch extends smcd_ops, adding two more semantic for SMC-D DMB: - attach_dmb: Attach an already registered DMB to a specific buf_desc, so that we can refer to the DMB through this buf_desc. - detach_dmb: Reverse operation of attach_dmb. detach the DMB from the buf_desc. This interface extension is to prepare for the avoidance of memory copy from sndbuf to RMB with SMC-D device whose DMBs has ISM_DMB_MAPPABLE attribute. Signed-off-by: Wen Gu --- include/net/smc.h | 2 ++ net/smc/smc_ism.c | 31 +++++++++++++++++++++++++++++++ net/smc/smc_ism.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/include/net/smc.h b/include/net/smc.h index e39ac41..0132522 100644 --- a/include/net/smc.h +++ b/include/net/smc.h @@ -67,6 +67,8 @@ struct smcd_ops { int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb, void *client_priv); int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb); + int (*attach_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb); + int (*detach_dmb)(struct smcd_dev *dev, u64 token); int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id); int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id); int (*set_vlan_required)(struct smcd_dev *dev); diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 1d97e77..925af13 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -243,6 +243,37 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len, return rc; } +int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token, + struct smc_buf_desc *dmb_desc) +{ + struct smcd_dmb dmb; + int rc = 0; + + memset(&dmb, 0, sizeof(dmb)); + dmb.dmb_tok = token; + + if (!dev->ops->attach_dmb) + return -EINVAL; + + rc = dev->ops->attach_dmb(dev, &dmb); + if (!rc) { + dmb_desc->sba_idx = dmb.sba_idx; + dmb_desc->token = dmb.dmb_tok; + dmb_desc->cpu_addr = dmb.cpu_addr; + dmb_desc->dma_addr = dmb.dma_addr; + dmb_desc->len = dmb.dmb_len; + } + return rc; +} + +int smc_ism_detach_dmb(struct smcd_dev *dev, u64 token) +{ + if (!dev->ops->detach_dmb) + return -EINVAL; + + return dev->ops->detach_dmb(dev, token); +} + static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd, struct sk_buff *skb, struct netlink_callback *cb) diff --git a/net/smc/smc_ism.h b/net/smc/smc_ism.h index 0b1913a..31eb010 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -41,6 +41,8 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int buf_size, struct smc_buf_desc *dmb_desc); int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc); bool smc_ism_dmb_mappable(struct smcd_dev *smcd); +int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token, struct smc_buf_desc *dmb_desc); +int smc_ism_detach_dmb(struct smcd_dev *dev, u64 token); int smc_ism_signal_shutdown(struct smc_link_group *lgr); void smc_ism_get_system_eid(u8 **eid); u16 smc_ism_get_chid(struct smcd_dev *dev);