netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: netdev@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
	Marc Dionne <marc.dionne@auristor.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	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	[thread overview]
Message-ID: <20240301163807.385573-10-dhowells@redhat.com> (raw)
In-Reply-To: <20240301163807.385573-1-dhowells@redhat.com>

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 <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
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);


  parent reply	other threads:[~2024-03-01 16:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 16:37 [PATCH net-next 00/21] rxrpc: Miscellaneous changes and make use of MSG_SPLICE_PAGES David Howells
2024-03-01 16:37 ` [PATCH net-next 01/21] rxrpc: Record the Tx serial in the rxrpc_txbuf and retransmit trace David Howells
2024-03-01 16:37 ` [PATCH net-next 02/21] rxrpc: Convert rxrpc_txbuf::flags into a mask and don't use atomics David Howells
2024-03-01 16:37 ` [PATCH net-next 03/21] rxrpc: Note cksum in txbuf David Howells
2024-03-01 16:37 ` [PATCH net-next 04/21] rxrpc: Fix the names of the fields in the ACK trailer struct David Howells
2024-03-01 16:37 ` [PATCH net-next 05/21] rxrpc: Strip barriers and atomics off of timer tracking David Howells
2024-03-01 16:37 ` [PATCH net-next 06/21] rxrpc: Remove atomic handling on some fields only used in I/O thread David Howells
2024-03-01 16:37 ` [PATCH net-next 07/21] rxrpc: Do lazy DF flag resetting David Howells
2024-03-01 16:37 ` [PATCH net-next 08/21] rxrpc: Merge together DF/non-DF branches of data Tx function David Howells
2024-03-01 16:37 ` David Howells [this message]
2024-03-01 16:37 ` [PATCH net-next 10/21] rxrpc: Split up the DATA packet transmission function David Howells
2024-03-01 16:37 ` [PATCH net-next 11/21] rxrpc: Don't pick values out of the wire header when setting up security David Howells
2024-03-01 16:37 ` [PATCH net-next 12/21] rxrpc: Move rxrpc_send_ACK() to output.c with rxrpc_send_ack_packet() David Howells
2024-03-01 16:37 ` [PATCH net-next 13/21] rxrpc: Use rxrpc_txbuf::kvec[0] instead of rxrpc_txbuf::wire David Howells
2024-03-03  5:26   ` Jakub Kicinski
2024-03-01 16:37 ` [PATCH net-next 14/21] rxrpc: Do zerocopy using MSG_SPLICE_PAGES and page frags David Howells
2024-03-01 16:37 ` [PATCH net-next 15/21] rxrpc: Parse received packets before dealing with timeouts David Howells
2024-03-01 16:37 ` [PATCH net-next 16/21] rxrpc: Don't permit resending after all Tx packets acked David Howells
2024-03-01 16:37 ` [PATCH net-next 17/21] rxrpc: Differentiate PING ACK transmission traces David Howells
2024-03-01 16:37 ` [PATCH net-next 18/21] rxrpc: Use ktimes for call timeout tracking and set the timer lazily David Howells
2024-03-03  5:27   ` Jakub Kicinski
2024-03-03 23:58   ` David Howells
2024-03-01 16:37 ` [PATCH net-next 19/21] rxrpc: Record probes after transmission and reduce number of time-gets David Howells
2024-03-01 16:37 ` [PATCH net-next 20/21] rxrpc: Clean up the resend algorithm David Howells
2024-03-01 16:37 ` [PATCH net-next 21/21] rxrpc: Extract useful fields from a received ACK to skb priv data David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240301163807.385573-10-dhowells@redhat.com \
    --to=dhowells@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).