From patchwork Wed May 24 14:49:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13254098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 931E6C7EE23 for ; Wed, 24 May 2023 14:49:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DC02900004; Wed, 24 May 2023 10:49:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1654C900002; Wed, 24 May 2023 10:49:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F20EB900004; Wed, 24 May 2023 10:49:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E3853900002 for ; Wed, 24 May 2023 10:49:38 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 680AD409F6 for ; Wed, 24 May 2023 14:49:38 +0000 (UTC) X-FDA: 80825432436.07.A95D0B0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 7A99DC0014 for ; Wed, 24 May 2023 14:49:35 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UiOM2Gqt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684939775; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=97CTgaKk+HjxMsHB1NZqYRmtg/935y1khOuMG78saNk=; b=k1/AdlhNX0lFCIFY2AmjbvwLRRvwSeeMqe4bjHv9E7f19YHTn1g4zciRio6l7Fpd/+nNI0 TVwck8d3lSpBakvZs94WvX8HNVt2X8mavYdTlP2Ae6HHUYw2laLo9kE03hlnfjXvN16Scg 4TzuPjEMA0He0QZHjvxIGeiZzRzt4nI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UiOM2Gqt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684939775; a=rsa-sha256; cv=none; b=2P/jKyJVGuz6NM8C/zkZf1HJDlP6uP9+hTUjJOhJ+hJ9d4YtxLtk9lr+rNZTEaPxAHjpmT w11regMBH9uq6nBbf8r9bmbmFdIAhn0cJZ6I4TGcXKIYsN+LKtrjL5g0Gc7jLEaWrwMQrT cymSsXM04m4qYLTYrcRRqtgHDNHAhF0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684939774; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=97CTgaKk+HjxMsHB1NZqYRmtg/935y1khOuMG78saNk=; b=UiOM2Gqt70+tvRsoicjN18XTKp7IUOk0QVTyBVWfDZF2NRIsDo2ws06ufQpYKgoeLXslUS nV1xHJgjiambG7qKiEi7qYGIxiUtdG8c//WCpn6+PqUJE4mQ2HIBouHAocnx6Mns34+nW6 zYfBO/2ev2kULwErDuaC731fMHB1myY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-Tcx3RMC7MxyDhN2LK1DGPQ-1; Wed, 24 May 2023 10:49:31 -0400 X-MC-Unique: Tcx3RMC7MxyDhN2LK1DGPQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91F1229ABA03; Wed, 24 May 2023 14:49:30 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A11011121314; Wed, 24 May 2023 14:49:28 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ayush Sawal Subject: [PATCH net-next 1/4] chelsio: Support MSG_SPLICE_PAGES Date: Wed, 24 May 2023 15:49:20 +0100 Message-Id: <20230524144923.3623536-2-dhowells@redhat.com> In-Reply-To: <20230524144923.3623536-1-dhowells@redhat.com> References: <20230524144923.3623536-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: 7A99DC0014 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: t6x9qy8fydq9styupwy4it4nc33zrojh X-HE-Tag: 1684939775-457792 X-HE-Meta: U2FsdGVkX1+c53VU7JuXfd9G0IDNQoxtX9Llc4rnXxnJTrIEUYtNyXMK+GhonNcS/XhtnJKXW4m491YThjQd9Qwog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mbNtKuwOKBcxKKJ7qMlDAWUnLi6m2EI3QgqR4kQLBFsYCBqXmN+Q5UszB+exkbH4lPAp8rZcYYC803E8hfknoszzF6TqoZBxoShmadXjfA+unu/EGMsI/mdtRN5/0PmGaf3r4SPdwK0VJVsXnJpLDl3t22EU8FVtPMOimaLWq9oA6lZth7k5BhsTjYMd9MWWqWD5vC46BLUteZ2+Dp0ACXl9HsXaLqHULe5XjhE1DCRB8Jra+Y3dNDbeJlEGRd7iQAzflbkFEb01JnmPJMjkTEewDBRZDecj30hwQiniohCiaGoCgGDpN9eg/8nVRp0mPwjVDDr+PRrePrdbepSCR8r3TjXgV9+Qep4vxNjcIUQ7vhPGQu7bobzeo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Make Chelsio's TLS offload sendmsg() support MSG_SPLICE_PAGES, splicing in pages from the source iterator if possible and copying the data in otherwise. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Ayush Sawal cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- .../ethernet/chelsio/inline_crypto/chtls/chtls_io.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c index ae6b17b96bf1..1d08386ac916 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c @@ -1092,7 +1092,17 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) if (copy > size) copy = size; - if (skb_tailroom(skb) > 0) { + if (msg->msg_flags & MSG_SPLICE_PAGES) { + err = skb_splice_from_iter(skb, &msg->msg_iter, copy, + sk->sk_allocation); + if (err < 0) { + if (err == -EMSGSIZE) + goto new_buf; + goto do_fault; + } + copy = err; + sk_wmem_queued_add(sk, copy); + } else if (skb_tailroom(skb) > 0) { copy = min(copy, skb_tailroom(skb)); if (is_tls_tx(csk)) copy = min_t(int, copy, csk->tlshws.txleft);