From patchwork Wed Feb 15 16:18:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Gu X-Patchwork-Id: 57617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp283973wrn; Wed, 15 Feb 2023 08:23:08 -0800 (PST) X-Google-Smtp-Source: AK7set8B9ty2Jx3ZDEZLmxSEPlfVEXBar5234nyvwXjdtcaFXCPvruc46Gycqx3Rf2H4BMPF08uZ X-Received: by 2002:a05:6402:516b:b0:4ac:bd93:e453 with SMTP id d11-20020a056402516b00b004acbd93e453mr2710625ede.22.1676478188102; Wed, 15 Feb 2023 08:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676478188; cv=none; d=google.com; s=arc-20160816; b=JAAoFXtPW6OKk37sw8L8TPfsZRvq4gSjQ5JbpwJ49p5K7bpHsGwc4Vif8Fq6UJFbhE ojbx+uIiQhVvqfLLQFO/2+OxagHoKRwmA6JVxOv/80Rh+4uGpxXmlcmGWBWkCsf7PPyu i/Bg7rxg+Pwx9sHOiOBDZ3mT1j/nz09F9BiKHzZcgpC1+SmGxL+PTtNbPbHQQqLuMnN4 M09V1j8RFYcM7PkRvBlfMpwXFG3whUEBkUwN08g7po2uAWhKP0BTQ5IKhF10PIyjL3KI fV+srK5UjAO6q5A0va8F5m9adrUeSIxs+LDvDB21mPZw1LsB4oF5nqN+FAYbKIr8skoJ 3whA== 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=jKxxqr4ChVk6NmGXSYxCvZYpLMf7WwhXQjJUwH/T3Nw=; b=XFbOWwCE/hKL+0EZELg4C/np8cGptlA+48QGUojXvqjOEGmEh0h0clbokEB2u6TCiC extHnSnmndblmk+e7H49oOcCFLHcuj+VlzPsDZ6grFHf7UrnO26VmpS5J+k8vpBxmZhV Bztaampo6DRY+a7SzCjzotlIWaBfMmgABeekJFKZ7yMXI9he68DXkq5wAfoOMvbHzzbQ 1Tmwz7kuaf8b/g7jucVpWuthnbKz9ol4fl9uBHpZCl9dBGH/Gec8z8u1g/hU1SG8GZWp tDOUgKXTIsPAlIR+qQrxDGz6W8GaM4QKWX9ooCC5HtzSxG2ONn9KTFMFIZBUllzDcdEJ qn2g== 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 j11-20020aa7c0cb000000b004acd971cf09si6464edp.503.2023.02.15.08.22.42; Wed, 15 Feb 2023 08:23:08 -0800 (PST) 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 S229679AbjBOQTW (ORCPT + 99 others); Wed, 15 Feb 2023 11:19:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230044AbjBOQSx (ORCPT ); Wed, 15 Feb 2023 11:18:53 -0500 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5B643B0E8; Wed, 15 Feb 2023 08:18:50 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R931e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Vbl3P-7_1676477924; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0Vbl3P-7_1676477924) by smtp.aliyun-inc.com; Thu, 16 Feb 2023 00:18:45 +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 v3 6/9] net/smc: Introudce interfaces for DMB attach and detach Date: Thu, 16 Feb 2023 00:18:22 +0800 Message-Id: <1676477905-88043-7-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1676477905-88043-1-git-send-email-guwen@linux.alibaba.com> References: <1676477905-88043-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,SPF_HELO_NONE,SPF_PASS,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?1757914793003484580?= X-GMAIL-MSGID: =?utf-8?q?1757914793003484580?= 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 DMB 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 256d600..0790e64 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 e085c48..e2670e3 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 aabea35..fc16dc2 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -39,6 +39,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);