From patchwork Sun Apr 23 12:17:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Gu X-Patchwork-Id: 86708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2172223vqo; Sun, 23 Apr 2023 05:31:53 -0700 (PDT) X-Google-Smtp-Source: AKy350aPGiagFyPt6oW+vJyj3zB/7NIOfYUWpyR3ievEfHJaKSbIRsscFC3qIgtfrzy7v98WsBLy X-Received: by 2002:a17:90b:4d8a:b0:246:ac0b:9d45 with SMTP id oj10-20020a17090b4d8a00b00246ac0b9d45mr10447072pjb.18.1682253112743; Sun, 23 Apr 2023 05:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682253112; cv=none; d=google.com; s=arc-20160816; b=Hot0OeRB2l7/Ef8p5ZSh5cFWsT27TKfA3qYMU3yl2066CdSQ7fWVOwvEHLjlNSAgbD bgYZwZvsJpAV6nDjwvOqAFbyHz2lCpyLzhtIQohZaN3w9PTJMUCvvht6nWLf0L8ov4Oi e35bBPO+fYWtFJve2SgX1nJA0KKZC39VjYImt3oEXwaUzRC5oMVYv4WXT0WNqbN60C0h 8GOqoUfcf16voFCRmUsfo9shzd1YoHktMSIf7MrqJwSDFRP9HUlaGtG9HUASfQOUZxOs bReIA7bfXaKTY6jX0289IQymDgoccfqdG5cy8rz07BIZyDOFdXut6I+dX6BC36HjYeKB WFaA== 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=JwQlTodHIjFmazLlveTPIvjCBIO+GiN3uYOLRGgR6OU=; b=iT0VTlEKMGT5e2yzJbd1HkasYKTQx1zOYgFaLNDplGhgFY2igRj83rAevaa/Ny9f8U 2JMONjZmjL0K0vOuu+CQgqZEpr47vf/zrRMkczGDNaTpdeO1sLNUpXzgfTZai6BiHEOC C3WzrdKYBahE3DGYHVD8Bb8UPyDXANaDZPzKtyTlX9bVE8PpiuIdj0RXFapMizTDXgUo 2eI99KJOQLcqjAjhHdyiyLwNKXo1I3Ib5XmSzhHQdQvhR4OaHYo1pnkVN7hlXTbsQmAf nMQSgcmd6SG/8mfvJKBL+7mNcnYxsp3vHOy1alNGUntpAahf13320zGuWvsk1IaSZM9Y bBCA== 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 s8-20020a17090aad8800b0024489068406si11700119pjq.113.2023.04.23.05.31.38; Sun, 23 Apr 2023 05:31:52 -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 S230348AbjDWMS6 (ORCPT + 99 others); Sun, 23 Apr 2023 08:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbjDWMSW (ORCPT ); Sun, 23 Apr 2023 08:18:22 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909A91FCC; Sun, 23 Apr 2023 05:18:08 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Vgjz4Dz_1682252281; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0Vgjz4Dz_1682252281) by smtp.aliyun-inc.com; Sun, 23 Apr 2023 20:18:03 +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 5/9] net/smc: Introduce an interface for getting DMB attribute Date: Sun, 23 Apr 2023 20:17:47 +0800 Message-Id: <1682252271-2544-6-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?1763970239644228483?= X-GMAIL-MSGID: =?utf-8?q?1763970239644228483?= On s390, since all OSs run on a kind of machine level hypervisor which is a partitioning hypervisor without paging, the sndbufs and DMBs in such case are unable to be mapped to the same physical memory. However, in other scene, such as communication within the same OS instance (loopback) or between guests of a paging hypervisor (eg. KVM), the sndbufs and DMBs can be mapped to the same physical memory to avoid memory copy from sndbufs to DMBs. So this patch introduces an interface to smcd_ops for users to judge whether DMB-map is available. And for reuse, the interface is designed to return DMB attribute, not only mappability. Signed-off-by: Wen Gu --- include/net/smc.h | 5 +++++ net/smc/smc_ism.c | 8 ++++++++ net/smc/smc_ism.h | 1 + 3 files changed, 14 insertions(+) diff --git a/include/net/smc.h b/include/net/smc.h index 021ca42..e39ac41 100644 --- a/include/net/smc.h +++ b/include/net/smc.h @@ -55,6 +55,10 @@ struct smcd_seid { #define ISM_ERROR 0xFFFF +enum { + ISM_DMB_MAPPABLE = 0, +}; + struct smcd_dev; struct smcd_ops { @@ -77,6 +81,7 @@ struct smcd_ops { u64 (*get_local_gid)(struct smcd_dev *dev); u16 (*get_chid)(struct smcd_dev *dev); struct device* (*get_dev)(struct smcd_dev *dev); + int (*get_dev_dmb_attr)(struct smcd_dev *dev); }; struct smcd_dev { diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 8ad4c71..1d97e77 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -213,6 +213,14 @@ int smc_ism_unregister_dmb(struct smcd_dev *smcd, struct smc_buf_desc *dmb_desc) return rc; } +bool smc_ism_dmb_mappable(struct smcd_dev *smcd) +{ + if (smcd->ops->get_dev_dmb_attr && + (smcd->ops->get_dev_dmb_attr(smcd) & (1 << ISM_DMB_MAPPABLE))) + return true; + return false; +} + int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len, struct smc_buf_desc *dmb_desc) { diff --git a/net/smc/smc_ism.h b/net/smc/smc_ism.h index d18c50a..0b1913a 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -40,6 +40,7 @@ struct smc_ism_vlanid { /* VLAN id set on ISM device */ 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_signal_shutdown(struct smc_link_group *lgr); void smc_ism_get_system_eid(u8 **eid); u16 smc_ism_get_chid(struct smcd_dev *dev);