Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp771297lqp; Sat, 13 Apr 2024 21:07:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaq4324sG1gBB2DSu1b0Ejq/ma2pgNsQ6/0c03YRj4rZ7bb2mAyF/eGlr8njR4BsaWI0T4WWMoD8pFz3DnzGCOK2s+Blo/nsUBFr/sNw== X-Google-Smtp-Source: AGHT+IEAdZONpfPiosB2hj4mL7ik6GO5TDTnkPQJstdDPzpc9TeH6CRxRzQ/DFOMsZCvODhLxn2a X-Received: by 2002:a17:90a:5794:b0:2a0:86b6:2e9 with SMTP id g20-20020a17090a579400b002a086b602e9mr6041168pji.12.1713067629142; Sat, 13 Apr 2024 21:07:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713067629; cv=pass; d=google.com; s=arc-20160816; b=IA3KRICf1z0PzKvjTG+h96i0/JX9shOFR/RecKz/zm+mZOuyZvNlt1rZBsto+ZhUo9 mRb9tPswx4WCJIDXGTmdSVKmIVMPucZqzrmhqYy3TgrMZsHkYWyre4YiOBC2KgChS7hV CgU2bW6KHo97HAYfh/BbOmu5tysPevgsHcvsStHB/VjSQqIyVVb+uFhN6qjcW1jMxstj QLpMX2npxiotevqD/6c08IqGAMARRzopU6ZvfQG3MLX6QxOZGdZqj/+17xyOttPRo6c5 EWr4XCjLjJnRRlwUeu0OXJTO9OHUuUtr2b8R8PxBoFb9Kqx223Sp+VDpyF2UbaqTNuyr c67Q== 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=TRMkEBmhvkR4yW3s8bf6OAtkd66aTfemcZ+2Tsdt1r4=; fh=dZ+5j4HvJgOzvN8nB02tgPlkwHWSh0WzjxQ9fqEQCrY=; b=B+425LPsFkNMJbgkI6ClSzt3+hu76Dxa0t7jZHB8cfQqewxdYxPlZxZqV7tJLNlMiC U3QQlvqKrKy6Rj+Tfv+2Q3licHaD6Ar2326nTFerjS5ld8fVI+yXCJofqUJG1jHXEPkM 14Zv0PZhocDWwPKeoGLSuna2aYFWDtuI2fsPNUyHEEHkaTLNQ9DJcWaeIbKTRhfX7mUJ 9H79IS5uAK/AeNdzE7xvqaLyXiGsi8R+lQjDQvA8ZtvXVnv+14R054e6nj/l1HRYh6qO DOiUZ+yi5BtuUYJR1GM6fbH92yxkQp7RQMoQBUf7PYh3AA8rGITJ/oGYevac6hv9uCzA MpfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=qPTs0jpu; 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-143966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143966-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 sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z2-20020a17090a014200b002a528b60fe4si7793104pje.75.2024.04.13.21.07.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 21:07:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=qPTs0jpu; 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-143966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143966-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F2251B20E16 for ; Sun, 14 Apr 2024 04:06:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F357B43AA2; Sun, 14 Apr 2024 04:03:35 +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="qPTs0jpu" Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 C5FB72A1D4; Sun, 14 Apr 2024 04:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713067415; cv=none; b=A9p5GgNFEalHqHQw7SYr2V5qZFVDREym+iMFr19v/MZmHdS1JAZnmzWgT4V8DwJDcGvtxv+2KO8BInfIpgt616U+IyRJWaBrWr5tn8MEfIj29KdCgeD6xVYd9VdFxS+WQSJIrX00jQmszt8X8/NmCG3KjG/GMZvsqwRTDfYwAFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713067415; c=relaxed/simple; bh=ml8XBd4t/EjacVpGSk9tropHTdaruhEtaMNNWhn9OjQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G+Ibq7ErFem+i/Z0HhpnXPBCYjSZaied85gr9oy6+aFE0NaPxqpAQ4sIE+mAcZIQRZEkO8fNmS0G0QAy9G9Tc+Wdn56dQV8WPqLL3LWa8UlQoAy/B8h6wkMzYh9a23faUJnS/PMDlUIxY5rY40FwO8LoXEyRqfOWz2pZt7xdngE= 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=qPTs0jpu; arc=none smtp.client-ip=115.124.30.100 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=1713067404; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=TRMkEBmhvkR4yW3s8bf6OAtkd66aTfemcZ+2Tsdt1r4=; b=qPTs0jpuHvTUCDPEnojm+g1hwNT+CRIcFcTSB0lTbgza43fmT/21jEcPkqc7ECQSsfdurpBJah5eybpQBjK9KIwtYiYveLz/HohD9gFV2xYM5Rnnb9KYbKKib8tH1MERW5QQYs2EmP5HAPtWQocTwg42K+PDAY/DFQxr3kifAJg= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0W4RqRI2_1713067402; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0W4RqRI2_1713067402) by smtp.aliyun-inc.com; Sun, 14 Apr 2024 12:03:24 +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 v6 08/11] net/smc: add operations to merge sndbuf with peer DMB Date: Sun, 14 Apr 2024 12:03:01 +0800 Message-Id: <20240414040304.54255-9-guwen@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240414040304.54255-1-guwen@linux.alibaba.com> References: <20240414040304.54255-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 33b753115e43..db84e4e35080 100644 --- a/include/net/smc.h +++ b/include/net/smc.h @@ -74,6 +74,9 @@ struct smcd_ops { int (*reset_vlan_required)(struct smcd_dev *dev); int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid, u32 trigger_irq, u32 event_code, u64 info); + 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); }; struct smcd_dev { diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 6bed0a61b746..84f98e18c7db 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -250,6 +250,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