Received: by 2002:a05:7208:70d5:b0:7f:5597:fa5c with SMTP id q21csp2215411rba; Sun, 24 Mar 2024 06:59:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJAPB7Utz5ZYg9JL1NR5f0h8IcWS4lL18tiZkNuuhhm+ttgG1zY89ZSsYUCWuntEgcsJKNYSNsFNjI1xVAhoSaiKqVhRLGZ/BcRv88Uw== X-Google-Smtp-Source: AGHT+IG65m4zD1Cieigs3/AuGc7FmL4esSfCyFBEMMDCpNTi7xmY/AQ6ikGOEi1BKd1wzDCKNVf0 X-Received: by 2002:a05:6870:2116:b0:229:fce0:cf2a with SMTP id f22-20020a056870211600b00229fce0cf2amr4759743oae.49.1711288740618; Sun, 24 Mar 2024 06:59:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711288740; cv=pass; d=google.com; s=arc-20160816; b=0Dn0K6EpSedZ5ELmM/c5rh3iAihm8QywpUjLZoAMlc+N4V0q0mzDjz9Ftl6yySP8Fn OXIxz7AxDEnv38jQziMrtdWaRl3QRB/f+6+/7NfGIZcx5ssSXJXweE496vUa1Ue/QP7k R7V+1x3euk24R87AlQ04msqE+Ytv4XfvECo+jukpAJhdF1Ssh71Y3lmBxd+2GAIvxO+p SE5ZNJA0C++mHgK/nfLdpBUnKrdcsXYm8GUo+youPLHoDM73n1cBKVMTu5pt3YUgkeqf kGMf9N7ohn91cEwLu72u9WTbZzQt93E0f8yAE+iZCGbPLHqr6PZ517xw9tOUSl+88sX6 bmwg== 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=cXxkfew4pLmEZxVFDkURa/WPZ9twZw4K1banM7Wm1Jc=; fh=dZ+5j4HvJgOzvN8nB02tgPlkwHWSh0WzjxQ9fqEQCrY=; b=ORuupj2f4xucYv+0cEUvbRAlLCOoqIjKj2oTUfvD+gJQAXdvlifltMNejYvPNphdZz vtBxV0cMH+AG+ssWDck5Rlig6HaKLzcZgA6+Y6VOupCrLO1GP1xsGfkoTrzmYvboCecX xtbPn9RlUXXjh5v4TAocWTxZs17J10jDAFyDyTl+sdwypeUsJd1To2hOBKFWl3EGooWO b2rDGfvylM65FhmA0KYL9oE1kKBskQagn1tkrOs54wMQty6BzL4PLD9iJ+qJ4r+wwvCM zYtZ/59lkicK/ez4zQOlpSLYsH8Qw8zoLOQUMPHm1eJKUgOX/sJo8Aavu1tq47zMdinh aG+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=CQrXjDIK; 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-112697-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112697-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 sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i30-20020a63585e000000b005dbdc9098c6si5854904pgm.445.2024.03.24.06.59.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 06:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112697-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=CQrXjDIK; 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-112697-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112697-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 467A2281761 for ; Sun, 24 Mar 2024 13:59:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4443237157; Sun, 24 Mar 2024 13:55:56 +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="CQrXjDIK" Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (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 DC3142562F; Sun, 24 Mar 2024 13:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.110 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711288555; cv=none; b=EJZ8bWBQH99JO9OxjN7pSz9zl3XfWq+GNMdfOR/BLfzLqlC11VdCjJAn4St64m+6UmjSMvOVo8z8uGYvki87ye1ilY0JayPq2y+D1+iayq9ZtvLNZLB9954JS8fn135Z/F37vF6zqKZbzYg+iCXyEHRLhML7UPcEVHYvwKgXM+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711288555; c=relaxed/simple; bh=PUGkVStuetsMke/VaEeAh7P6q9BaVMTgmXwXUKLgTNk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PmdoPbWrTEp78BAwjGDuv8ZLllYtRE4FtOjTRWK5sJkHWZcwaCeUKB/01YCw95XtuFpMNGQHtgmH3S7s5xPHekVAO7BgmB9cpo6pVxEatjHD/hwCRiwzjJTw+The/O+Z3azHF+qw8hCSJ1EIASibSRsTz+YssK+nnfualkfzfts= 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=CQrXjDIK; arc=none smtp.client-ip=115.124.30.110 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=1711288544; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=cXxkfew4pLmEZxVFDkURa/WPZ9twZw4K1banM7Wm1Jc=; b=CQrXjDIKfrRqQDC5s1Ujtm+E3R1y5DCcGHgM9uzI7iEhNiKSH3c+++l3vfm6q7HhiAXwbjFhsx1nrhReKuaDXcJLtvQRty3p3pAaQyrta8oP9k5SSGk5RSzQEYSMD2uvplCPxgtdWw8yaGhMgOiqCc0bKK1SOZtb3ZyM3ehXbg4= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0W37-8xY_1711288542; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0W37-8xY_1711288542) by smtp.aliyun-inc.com; Sun, 24 Mar 2024 21:55:44 +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: [RFC PATCH net-next v5 08/11] net/smc: add operations to merge sndbuf with peer DMB Date: Sun, 24 Mar 2024 21:55:19 +0800 Message-Id: <20240324135522.108564-9-guwen@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240324135522.108564-1-guwen@linux.alibaba.com> References: <20240324135522.108564-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 38469ff53346..182748927681 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 e6f57e5e1ef9..6763133dd8d0 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