From patchwork Mon Mar 27 03:28:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Gu X-Patchwork-Id: 75194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1251151vqo; Sun, 26 Mar 2023 20:41:17 -0700 (PDT) X-Google-Smtp-Source: AK7set+9J9mRyBTmrkqa+JIOCYRTt1opM/TkS8X+KwhmFEnb8AkYUR1TvN+ZWuqkeQ2grNV0w7Lb X-Received: by 2002:a05:6a20:c2a7:b0:d6:ba0b:c82c with SMTP id bs39-20020a056a20c2a700b000d6ba0bc82cmr9469366pzb.38.1679888477321; Sun, 26 Mar 2023 20:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679888477; cv=none; d=google.com; s=arc-20160816; b=StNqMKjOCVgQ6PeT6HKdS3D/Wfu2bnuT0kabiYTzO6m7Eq+56n3GedEH7GR7e9Siiq mkijvXyCLKKhy83hOp49eUMTV6/Bc8Nm8uwytsVLj8CgUAMw2+W3vEuEkip5Xb3IaqQt HU2MsoIM8NhU1+IRYRoAorFRgbRvaYasbYK+pu74kthhwMc23M6K75Vv5+aeopJhNI+D 8qQgR9eglk3tS/FXe/ItJXwgO7L7wz5srG08oMzVj+A2hINDW3hepq6sxmlGEoCPyfZh bGddmQqPUtAqhp9UPheGoTjhy3GX1RvYuc6JK+cXfp/X2oq1g/i3znk6IUUqx/rrppaE JagQ== 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=VJpJzT4lesGSHibtxjD5QhDT1+2PdTpClrp9n0wfJdE=; b=M/34B8gyusZQv/bbjnrhZkKvCTaZ/Gfy5HvKnKR6yUAMNhDXcNXNQcI1v4YnAXQ3XJ Bis6QNHeXzxOmQny+8g0mPY9nlWdvK4cVUMF8YmjQ6AvKycRQ7MwkZczgwIKQXzKa+Fb uBjS3n1XirssY27OHwYeGG6ovvoP6alP3Jk9OF0Udo77flFjbf0jPO3+RiiQTfZ9/3VO D602SyYnR0GSeacHN2Ic/pDwVeHi/AU0PuWu5heB+DQRSVt8WmUI38A3yaMoQeBN3y4C 5teds6NfbGZTT48ZHplZdA1hOwMUbBQcpz9bDmMU8BZb3rOTqTIrDu7TxVCIiIilCbAB R71Q== 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 f19-20020a056a00239300b00625f79ca1b4si27592680pfc.240.2023.03.26.20.41.04; Sun, 26 Mar 2023 20:41:17 -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 S229619AbjC0D3I (ORCPT + 99 others); Sun, 26 Mar 2023 23:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232056AbjC0D2l (ORCPT ); Sun, 26 Mar 2023 23:28:41 -0400 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F815246; Sun, 26 Mar 2023 20:28:36 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VeevirB_1679887712; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VeevirB_1679887712) by smtp.aliyun-inc.com; Mon, 27 Mar 2023 11:28:33 +0800 From: Wen Gu To: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com, wintera@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 v4 6/9] net/smc: Introudce interfaces for DMB attach and detach Date: Mon, 27 Mar 2023 11:28:16 +0800 Message-Id: <1679887699-54797-7-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679887699-54797-1-git-send-email-guwen@linux.alibaba.com> References: <1679887699-54797-1-git-send-email-guwen@linux.alibaba.com> X-Spam-Status: No, score=-8.0 required=5.0 tests=ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=unavailable 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?1761490739889685368?= X-GMAIL-MSGID: =?utf-8?q?1761490739889685368?= 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 a21c867..012df1d 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -263,6 +263,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 0ddaa45..d0ab025 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -40,6 +40,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);