Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp451998lqi; Thu, 7 Mar 2024 02:05:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUHVlGHnCJU5IEiQrGuDDUAtgulB3RWRIH2LpnO1NiWEs11o1JSIedbFO/9rlTFiBJRs9C9S9a6bkUJ/BdxDPPr6DpkD5UWOE6uoSsJcQ== X-Google-Smtp-Source: AGHT+IHfOW93O6MVTYbUdwaTYsyYYp19dQ2NlvyztF7V1Jfm8GxnrTHloGMW5vIoL/FcxnyheOo0 X-Received: by 2002:ae9:e918:0:b0:788:4657:b469 with SMTP id x24-20020ae9e918000000b007884657b469mr1449091qkf.72.1709805933853; Thu, 07 Mar 2024 02:05:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709805933; cv=pass; d=google.com; s=arc-20160816; b=DBKEOag15Lx/zDHa1rGm63VBimSsVpas5cxK//yr00iVbbPUQ9n8W8htaruUqsZ0GX +pc0DcExzjRuQTSYqapbY3X1EnENYJkP/6XyFz4xS5ZflM2jyQK+yUZmEuNovk1hbgRy wq8BHAOQ2l7aFtBvMbz4b7eeoR5fhXpDgKu+A/Nllhzv7unWFJJygwH82k7Yl7O4rDX+ Vrlzui5PQrgPjcLdSidZH65WFxDXslFkOW0Wx1OGBIbXCuO/ey9v9JJvBO1SCSiUV7Ug uRBhLSv2nMmdwRqWxt09AoISJ5M8Og8LeLvPeoJA+0pFfpANWaepQhqneJ0sPX2JUW4r iomQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QJG4XVpyDbqfH79yfrnsyf6IB4nYg+t5eEXV9gnRZiM=; fh=dZ+5j4HvJgOzvN8nB02tgPlkwHWSh0WzjxQ9fqEQCrY=; b=PSpOwb32hcgR4fYczAkuHMY0BvVkwkIXChsMSctn5/CqTcLUUGyk/HPfcNS9a/rLB0 vcP3BiNoYZMDuCAaY2Stejkz99mA92SfhIVQDje4hD+x+J1FoNcL8YwuW1obAHQ2fWXd w1t/+6AUtSkccyC6YfuJbfEqYxGxUFCpXUcTFlOOKg7mPGsBWHYM1f1TNE2VH16unDfR MYRBSaq3PN9chQ9Huh6NYq7DmRNOt3d9wVgI/QETek1OwHfs+ZKlEol/iRG5+U8pFSSr ehmEpDmT1cLGU9v0IjDJeQlO11JMUVT95XN8i2s4Ozw6Rix7pmGiYEplb3XRKMtSXZ42 79ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ueX+ADsU; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-95288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z6-20020ae9e606000000b0078842f73d43si2241116qkf.722.2024.03.07.02.05.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 02:05:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ueX+ADsU; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-95288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 877D61C20DEB for ; Thu, 7 Mar 2024 10:05:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9613612880A; Thu, 7 Mar 2024 10:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ueX+ADsU" Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CCC284FAF; Thu, 7 Mar 2024 10:01:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709805684; cv=none; b=Sk+7FknTLAeood4DV9exl44IMpqQ7Q2X6U9L2A5o1W3Ttbl2vvRmEx1sppvZzMNMfUdvELN//Cwlsp6f9id8Ui0ZyeOOuD9JJ5dO8hkhRxuBaurbP9jLhroAmQ6uDD3AXbCHuFrTeiNo37zBzjHkEeiedNJdTRVFNB4HhPfr12M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709805684; c=relaxed/simple; bh=5wlNMC5COMEC+nVBo7GQbYItjwO3yGW0ypj2q0PmPZo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aCyebIYkDgI43zdPOlqwVtlFddycuIwM5SI4999pXbbDcg4vyht/fkm9yTU8OKusz6LaZYFxXVkzBTrLal+rfrgnNsqlClXrkFRQJTxQT556l2UIq1AWA0C5L7FvWlFXTAWv6Q7TDBRDynxFdRvhoEwb62zwD40/2eMUk2qLRB0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=ueX+ADsU; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1709805680; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=QJG4XVpyDbqfH79yfrnsyf6IB4nYg+t5eEXV9gnRZiM=; b=ueX+ADsUfBNPMpqZ/wJJaSHcOU0qF7KMvGgYAcZILXyxBB2d/XD3TXiVqadPPqG8dZZY5OQIwhgGusRz2P+sekTXI7Ik6PVzGr02fTh2knDmm0YOaKP+Owij+Sk2owpbDYSwF70cm7ylXCUUUE6IXgktykp5wOzfMOYTCj5PmJA= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R401e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0W2-HiFU_1709805356; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0W2-HiFU_1709805356) by smtp.aliyun-inc.com; Thu, 07 Mar 2024 17:55:58 +0800 From: Wen Gu To: wintera@linux.ibm.com, twinkler@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, wenjia@linux.ibm.com, jaka@linux.ibm.com Cc: borntraeger@linux.ibm.com, svens@linux.ibm.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 08/11] net/smc: add operations to merge sndbuf with peer DMB Date: Thu, 7 Mar 2024 17:55:33 +0800 Message-Id: <20240307095536.29648-9-guwen@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240307095536.29648-1-guwen@linux.alibaba.com> References: <20240307095536.29648-1-guwen@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In some scenarios using Emulated-ISM device, sndbuf can share the same physical memory region with peer DMB to avoid data copy from one side to the other. In such case the sndbuf is only a descriptor that describes the shared memory and does not actually occupy memory, it's more like a ghost buffer. +----------+ +----------+ | socket A | | socket B | +----------+ +----------+ | | +--------+ +--------+ | sndbuf | | DMB | | desc | | desc | +--------+ +--------+ | | | +----v-----+ +--------------------------> memory | +----------+ So here introduces three new SMC-D device operations to check if this feature is supported by device, and to {attach|detach} ghost sndbuf to peer DMB. For now only loopback-ism supports this. Signed-off-by: Wen Gu --- include/net/smc.h | 3 +++ net/smc/smc_ism.c | 40 ++++++++++++++++++++++++++++++++++++++++ net/smc/smc_ism.h | 4 ++++ 3 files changed, 47 insertions(+) diff --git a/include/net/smc.h b/include/net/smc.h index 6273c3a8b24a..01387631d8a6 100644 --- a/include/net/smc.h +++ b/include/net/smc.h @@ -62,6 +62,9 @@ struct smcd_ops { int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb, void *client); int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb); + int (*support_dmb_nocopy)(struct smcd_dev *dev); + 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 c50910300a03..67ab9bce202a 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -246,6 +246,46 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len, return rc; } +bool smc_ism_support_dmb_nocopy(struct smcd_dev *smcd) +{ + /* for now only loopback-ism supports + * merging sndbuf with peer DMB to avoid + * data copies between them. + */ + return (smcd->ops->support_dmb_nocopy && + smcd->ops->support_dmb_nocopy(smcd)); +} + +int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token, + struct smc_buf_desc *dmb_desc) +{ + struct smcd_dmb dmb; + int rc = 0; + + if (!dev->ops->attach_dmb) + return -EINVAL; + + memset(&dmb, 0, sizeof(dmb)); + dmb.dmb_tok = token; + 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 2ea169c1301c..83cf99265160 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -48,6 +48,10 @@ int smc_ism_put_vlan(struct smcd_dev *dev, unsigned short vlan_id); 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_support_dmb_nocopy(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); -- 2.32.0.3.g01195cf9f