Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp409351lqg; Fri, 1 Mar 2024 08:44:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWtFa8SGIOjWitEty0eRXAuC8xwhiHNvV5UCj99nZWDobu/9M1QvZwVkLuZlkXH9OlRz20ajDXaBQRhrARfdB9zkpAUJhTSuRUWddK+gw== X-Google-Smtp-Source: AGHT+IHzinjYTw2v4ROozQTctW53zfFja9rMTYF6v4z/KtHSB2STTJFKJNsWivgJKS0BakfTQzjk X-Received: by 2002:a17:906:3811:b0:a40:bff7:6e73 with SMTP id v17-20020a170906381100b00a40bff76e73mr1533203ejc.36.1709311443285; Fri, 01 Mar 2024 08:44:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709311443; cv=pass; d=google.com; s=arc-20160816; b=Zwdn7QlFxxN/dP7Bs64pzk26I4KEluxNTG9sidbTXyLfCZiMs1Qeo2HXcBXW9itgv2 JcPppxeMUBx7xOfxRLOQSB5zMIl8nwKrt0qvzAUfMjKommG0BO+xa0LrWu7fJ4Lho1WZ RwNSrG23iIGc1f/yonF4KtrW7iDE40gjl9aBTbsELXML8JnLxXr4/GwM27yQzfZMgEZt CYPg2+Z3Wt67XsA82gf7kAQE2wD1TMjNukJ09QUhwAEeHjq7tMeV4iczbv7kQ0eo3+NQ Ll8Ibl0tljigmQDXN/jXqf7ceAlTHZmEMp1KXw+Qe1CmG75QBJ2LQNK1Ugf3VRLXiRJk kFdA== 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=TRdqimspnMZVPKymX1p9GQpRQzRORSRvhQalJQ51PVE=; fh=icnuzcdbhXgwjK0pgvJXK7xplE+Och0jvyZv2PxZJ18=; b=cXUmczlmKAoqDtmuO++0Zo08jDcOTBr4a7An1qVhXyeh9JRsPF8ne4pqDeZqD9wAXT soNYM8MoabpRfb4bEHi1opqWfx2LINHhzMkGRKP5a7timCMEZxp2CWd4465bnj53bmh6 L8KN5fJ9uIkuBNVRIHzehftTLCNahsRuwnl9uA5ZaFzeT/rryDyKpbJa2uVOrO/hIMVC rKyzcgs5dCjeLX9AX92wb5chorWH/wRT5t+S5qk2QepjhrZPi3IKJOH3PlEd6BECpCNM PTrFCmoK5UtEy0loFOrXMVBOqsGCxxr39jtKG2JuP/mm3zrNdWG6EffM4Mb/sCMldWc2 KKcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E7Z9HLo6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-88732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id vr6-20020a170906bfe600b00a43248e2b96si1617019ejb.1016.2024.03.01.08.44.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 08:44:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E7Z9HLo6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-88732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3C9A71F266A7 for ; Fri, 1 Mar 2024 16:44:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67EE63D540; Fri, 1 Mar 2024 16:38:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E7Z9HLo6" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 37DB63D0A4 for ; Fri, 1 Mar 2024 16:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709311130; cv=none; b=h9vX00oVxbt56ykJkaXKWg+Op+Foj3yAwFxkkU4wuEVXXiCtJo39Reo5VO0CyIBAmwdLyRJwPNxEPj7FVDMpWtCxGmmEN3dE4Nc5BlzHV7w4Rqrv7Gf7gfKVyvXVMIjTZKPWF9nHLaYNKrK7tgXSyV4qg7rDMKRYGirZC2A6zT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709311130; c=relaxed/simple; bh=1yskpCVzWiHGiofGxGLw9LLF25f7okHA+AFw/Vlb7/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b/fy0zsgllvu7b+4o/5Pe6LTzjvEF0h5Es3YcmnOXVTQH0/5dPU1pB2aGFZLjeJNYyXE/cyamVHOkBMPheKP6bdoukdaYJ9LRQ19ydMbUB9E387/JpJk0rxrzOthAq4GHK75ygDN+v4cIFlU8JA13bkqwVXzxSZn1wBaBBtf5Rg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=E7Z9HLo6; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709311127; 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=TRdqimspnMZVPKymX1p9GQpRQzRORSRvhQalJQ51PVE=; b=E7Z9HLo6gYuAFkNpBRAdRu5i1vj2dCTyOEdOVxn78e4T7PCc4ZAC8VKUWLNELjl0tz93DE SdkIwoL1FeIg57VfZRUihgfRSeTJcDoJM3C+4IgkM7WDwZe0fcNe7su4F5PGl3Cir9Som+ nHQHSkwYFhU4Qkiw9H7HPFkhtGOX/uk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-5FNzdSJ-OaWa41wo-lVhCA-1; Fri, 01 Mar 2024 11:38:44 -0500 X-MC-Unique: 5FNzdSJ-OaWa41wo-lVhCA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0D741C0513E; Fri, 1 Mar 2024 16:38:27 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD696492BE2; Fri, 1 Mar 2024 16:38:26 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 09/21] rxrpc: Add a kvec[] to the rxrpc_txbuf struct Date: Fri, 1 Mar 2024 16:37:41 +0000 Message-ID: <20240301163807.385573-10-dhowells@redhat.com> In-Reply-To: <20240301163807.385573-1-dhowells@redhat.com> References: <20240301163807.385573-1-dhowells@redhat.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 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Add a kvec[] to the rxrpc_txbuf struct to point to the contributory buffers for a packet. Start with just a single element for now, but this will be expanded later. Make the ACK sending function use it, which means that rxrpc_fill_out_ack() doesn't need to return the size of the sack table, padding and trailer. Make the data sending code use it, both in where sendmsg() packages code up into txbufs and where those txbufs are transmitted. Signed-off-by: David Howells cc: Marc Dionne cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: linux-afs@lists.infradead.org cc: netdev@vger.kernel.org --- net/rxrpc/ar-internal.h | 2 ++ net/rxrpc/output.c | 33 ++++++++++++--------------------- net/rxrpc/sendmsg.c | 8 +++++--- net/rxrpc/txbuf.c | 3 +++ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index c9a2882627aa..c6731f43a2d5 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -805,6 +805,8 @@ struct rxrpc_txbuf { #define RXRPC_TXBUF_RESENT 0x100 /* Set if has been resent */ __be16 cksum; /* Checksum to go in header */ u8 /*enum rxrpc_propose_ack_trace*/ ack_why; /* If ack, why */ + u8 nr_kvec; + struct kvec kvec[1]; struct { /* The packet for encrypting and DMA'ing. We align it such * that data[] aligns correctly for any crypto blocksize. diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c index e2c9e645fcfb..f2b10c3e4cc2 100644 --- a/net/rxrpc/output.c +++ b/net/rxrpc/output.c @@ -77,10 +77,10 @@ static void rxrpc_set_keepalive(struct rxrpc_call *call) /* * Fill out an ACK packet. */ -static size_t rxrpc_fill_out_ack(struct rxrpc_connection *conn, - struct rxrpc_call *call, - struct rxrpc_txbuf *txb, - u16 *_rwind) +static void rxrpc_fill_out_ack(struct rxrpc_connection *conn, + struct rxrpc_call *call, + struct rxrpc_txbuf *txb, + u16 *_rwind) { struct rxrpc_acktrailer trailer; unsigned int qsize, sack, wrap, to; @@ -134,7 +134,9 @@ static size_t rxrpc_fill_out_ack(struct rxrpc_connection *conn, *ackp++ = 0; *ackp++ = 0; memcpy(ackp, &trailer, sizeof(trailer)); - return txb->ack.nAcks + 3 + sizeof(trailer); + txb->kvec[0].iov_len = sizeof(txb->wire) + + sizeof(txb->ack) + txb->ack.nAcks + 3 + sizeof(trailer); + txb->len = txb->kvec[0].iov_len; } /* @@ -187,8 +189,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb) { struct rxrpc_connection *conn; struct msghdr msg; - struct kvec iov[1]; - size_t len, n; int ret, rtt_slot = -1; u16 rwind; @@ -207,13 +207,7 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb) txb->flags |= RXRPC_REQUEST_ACK; txb->wire.flags = txb->flags & RXRPC_TXBUF_WIRE_FLAGS; - n = rxrpc_fill_out_ack(conn, call, txb, &rwind); - if (n == 0) - return 0; - - iov[0].iov_base = &txb->wire; - iov[0].iov_len = sizeof(txb->wire) + sizeof(txb->ack) + n; - len = iov[0].iov_len; + rxrpc_fill_out_ack(conn, call, txb, &rwind); txb->serial = rxrpc_get_next_serial(conn); txb->wire.serial = htonl(txb->serial); @@ -230,9 +224,9 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb) /* Grab the highest received seq as late as possible */ txb->ack.previousPacket = htonl(call->rx_highest_seq); - iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len); + iov_iter_kvec(&msg.msg_iter, WRITE, txb->kvec, txb->nr_kvec, txb->len); rxrpc_local_dont_fragment(conn->local, false); - ret = do_udp_sendmsg(conn->local->socket, &msg, len); + ret = do_udp_sendmsg(conn->local->socket, &msg, txb->len); call->peer->last_tx_at = ktime_get_seconds(); if (ret < 0) { trace_rxrpc_tx_fail(call->debug_id, txb->serial, ret, @@ -327,7 +321,6 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb) enum rxrpc_req_ack_trace why; enum rxrpc_tx_point frag; struct msghdr msg; - struct kvec iov[1]; size_t len; int ret, rtt_slot = -1; @@ -342,10 +335,8 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb) txb->seq == 1) txb->wire.userStatus = RXRPC_USERSTATUS_SERVICE_UPGRADE; - iov[0].iov_base = &txb->wire; - iov[0].iov_len = sizeof(txb->wire) + txb->len; - len = iov[0].iov_len; - iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len); + len = txb->kvec[0].iov_len; + iov_iter_kvec(&msg.msg_iter, WRITE, txb->kvec, txb->nr_kvec, len); msg.msg_name = &call->peer->srx.transport; msg.msg_namelen = call->peer->srx.transport_len; diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 25c7c1d4f4c6..1e81046ea8a6 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -362,7 +362,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, if (!txb) goto maybe_error; - txb->offset = offset; + txb->offset = offset + sizeof(struct rxrpc_wire_header); txb->space -= offset; txb->space = min_t(size_t, chunk, txb->space); } @@ -374,8 +374,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, size_t copy = min_t(size_t, txb->space, msg_data_left(msg)); _debug("add %zu", copy); - if (!copy_from_iter_full(txb->data + txb->offset, copy, - &msg->msg_iter)) + if (!copy_from_iter_full(txb->kvec[0].iov_base + txb->offset, + copy, &msg->msg_iter)) goto efault; _debug("added"); txb->space -= copy; @@ -404,6 +404,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, if (ret < 0) goto out; + txb->kvec[0].iov_len += txb->len; + txb->len = txb->kvec[0].iov_len; rxrpc_queue_packet(rx, call, txb, notify_end_tx); txb = NULL; } diff --git a/net/rxrpc/txbuf.c b/net/rxrpc/txbuf.c index 7273615afe94..91e96cda6dc7 100644 --- a/net/rxrpc/txbuf.c +++ b/net/rxrpc/txbuf.c @@ -36,6 +36,9 @@ struct rxrpc_txbuf *rxrpc_alloc_txbuf(struct rxrpc_call *call, u8 packet_type, txb->seq = call->tx_prepared + 1; txb->serial = 0; txb->cksum = 0; + txb->nr_kvec = 1; + txb->kvec[0].iov_base = &txb->wire; + txb->kvec[0].iov_len = sizeof(txb->wire); txb->wire.epoch = htonl(call->conn->proto.epoch); txb->wire.cid = htonl(call->cid); txb->wire.callNumber = htonl(call->call_id);