From nobody Sun Feb 8 17:37:51 2026 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 B7D4A1B5BB for ; Mon, 4 Mar 2024 08:43:56 +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=1709541838; cv=none; b=S7U4tdRycEND8eBqS8bwMNW8dfnGngkZSWk7xV4ktLITRbB1w0Jl+fLrNG/w7Yar72mlP05ThN590dfNDBhZ/2zXXH3SocXAVmzCPTCQOVkqHavpzlgeQgPCTulrAoVzeqiS4Y70vZKE3kqwGzbbPFVBtPDo16hw7tzVbVi9/7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709541838; c=relaxed/simple; bh=JSAb75K5u7gBHHU2jfoUTctUJDfxxq41wkWofdDPz0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bqym45/3MKUN590mKLtFSuus8XmhNJvST1RgGqFauRWa+HPZrG8rLtMVRjgw46tigi0nfGoOqOVbe02IaHR60g18+2oluFaSWSI6DEEGl25QtZDbdpp6AXe7skIVK05xbxcMFHDyv//ocB4C//AyCzMvrfkqgrXePVsSJ5PMx2s= 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=CFUHazvj; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CFUHazvj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709541835; 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=au5j5ZW3rj6O9c0BmuDpUr2RzwJwFV//kP+rZhiY3eA=; b=CFUHazvj4Sexe3RZONDWrOEi7tbqUYyIjQL8iHPkNaH6Ku88iqU8cerFq4a1RvG/sxLWIz tP9xaRND9zAUGqjbqb0KGojELrES1sR9QK6lsJovic6Rx+KxnlErxNmcVUMWXcaDnEsgUH h6zKwcgYpdQ1SKZ+lcdSJPZ9+BBu2pI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-5hm474SANgKBtLmFpJNzSg-1; Mon, 04 Mar 2024 03:43:52 -0500 X-MC-Unique: 5hm474SANgKBtLmFpJNzSg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 34F96106D061; Mon, 4 Mar 2024 08:43:52 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C8602026D06; Mon, 4 Mar 2024 08:43:49 +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 v2 13/21] rxrpc: Use rxrpc_txbuf::kvec[0] instead of rxrpc_txbuf::wire Date: Mon, 4 Mar 2024 08:43:10 +0000 Message-ID: <20240304084322.705539-14-dhowells@redhat.com> In-Reply-To: <20240304084322.705539-1-dhowells@redhat.com> References: <20240304084322.705539-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: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 Content-Type: text/plain; charset="utf-8" Use rxrpc_txbuf::kvec[0] instead of rxrpc_txbuf::wire to gain access to the Rx protocol header. In future, the wire header will be stored in a page frag, not in the rxrpc_txbuf struct making it possible to use MSG_SPLICE_PAGES when sending it. Similarly, access the ack header as being immediately after the wire header when filling out an ACK packet. 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 --- Notes: Changes =3D=3D=3D=3D=3D=3D=3D ver #2) - Remove unused variable. net/rxrpc/ar-internal.h | 5 +-- net/rxrpc/output.c | 79 ++++++++++++++++++++--------------------- net/rxrpc/txbuf.c | 27 +++++++------- 3 files changed, 56 insertions(+), 55 deletions(-) diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index a8795ef0d669..9ea4e7e9d9f7 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -804,6 +804,7 @@ struct rxrpc_txbuf { #define RXRPC_TXBUF_WIRE_FLAGS 0xff /* The wire protocol flags */ #define RXRPC_TXBUF_RESENT 0x100 /* Set if has been resent */ __be16 cksum; /* Checksum to go in header */ + unsigned short ack_rwind; /* ACK receive window */ u8 /*enum rxrpc_propose_ack_trace*/ ack_why; /* If ack, why */ u8 nr_kvec; struct kvec kvec[1]; @@ -812,11 +813,11 @@ struct rxrpc_txbuf { * that data[] aligns correctly for any crypto blocksize. */ u8 pad[64 - sizeof(struct rxrpc_wire_header)]; - struct rxrpc_wire_header wire; /* Network-ready header */ + struct rxrpc_wire_header _wire; /* Network-ready header */ union { u8 data[RXRPC_JUMBO_DATALEN]; /* Data packet */ struct { - struct rxrpc_ackpacket ack; + struct rxrpc_ackpacket _ack; DECLARE_FLEX_ARRAY(u8, acks); }; }; diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c index ec9ae9c6c492..5398aa24bb8e 100644 --- a/net/rxrpc/output.c +++ b/net/rxrpc/output.c @@ -77,11 +77,13 @@ static void rxrpc_set_keepalive(struct rxrpc_call *call) /* * Fill out an ACK packet. */ -static void rxrpc_fill_out_ack(struct rxrpc_connection *conn, - struct rxrpc_call *call, +static void rxrpc_fill_out_ack(struct rxrpc_call *call, struct rxrpc_txbuf *txb, - u16 *_rwind) + u8 ack_reason, + rxrpc_serial_t serial) { + struct rxrpc_wire_header *whdr =3D txb->kvec[0].iov_base; + struct rxrpc_ackpacket *ack =3D (struct rxrpc_ackpacket *)(whdr + 1); struct rxrpc_acktrailer trailer; unsigned int qsize, sack, wrap, to; rxrpc_seq_t window, wtop; @@ -97,15 +99,24 @@ static void rxrpc_fill_out_ack(struct rxrpc_connection = *conn, window =3D call->ackr_window; wtop =3D call->ackr_wtop; sack =3D call->ackr_sack_base % RXRPC_SACK_SIZE; - txb->ack.firstPacket =3D htonl(window); - txb->ack.nAcks =3D wtop - window; + + whdr->seq =3D 0; + whdr->type =3D RXRPC_PACKET_TYPE_ACK; + txb->flags |=3D RXRPC_SLOW_START_OK; + ack->bufferSpace =3D 0; + ack->maxSkew =3D 0; + ack->firstPacket =3D htonl(window); + ack->previousPacket =3D htonl(call->rx_highest_seq); + ack->serial =3D htonl(serial); + ack->reason =3D ack_reason; + ack->nAcks =3D wtop - window; =20 if (after(wtop, window)) { wrap =3D RXRPC_SACK_SIZE - sack; - to =3D min_t(unsigned int, txb->ack.nAcks, RXRPC_SACK_SIZE); + to =3D min_t(unsigned int, ack->nAcks, RXRPC_SACK_SIZE); =20 - if (sack + txb->ack.nAcks <=3D RXRPC_SACK_SIZE) { - memcpy(txb->acks, call->ackr_sack_table + sack, txb->ack.nAcks); + if (sack + ack->nAcks <=3D RXRPC_SACK_SIZE) { + memcpy(txb->acks, call->ackr_sack_table + sack, ack->nAcks); } else { memcpy(txb->acks, call->ackr_sack_table + sack, wrap); memcpy(txb->acks + wrap, call->ackr_sack_table, @@ -115,16 +126,16 @@ static void rxrpc_fill_out_ack(struct rxrpc_connectio= n *conn, ackp +=3D to; } else if (before(wtop, window)) { pr_warn("ack window backward %x %x", window, wtop); - } else if (txb->ack.reason =3D=3D RXRPC_ACK_DELAY) { - txb->ack.reason =3D RXRPC_ACK_IDLE; + } else if (ack->reason =3D=3D RXRPC_ACK_DELAY) { + ack->reason =3D RXRPC_ACK_IDLE; } =20 - mtu =3D conn->peer->if_mtu; - mtu -=3D conn->peer->hdrsize; + mtu =3D call->peer->if_mtu; + mtu -=3D call->peer->hdrsize; jmax =3D rxrpc_rx_jumbo_max; qsize =3D (window - 1) - call->rx_consumed; rsize =3D max_t(int, call->rx_winsize - qsize, 0); - *_rwind =3D rsize; + txb->ack_rwind =3D rsize; trailer.maxMTU =3D htonl(rxrpc_rx_mtu); trailer.ifMTU =3D htonl(mtu); trailer.rwind =3D htonl(rsize); @@ -134,8 +145,7 @@ static void rxrpc_fill_out_ack(struct rxrpc_connection = *conn, *ackp++ =3D 0; *ackp++ =3D 0; memcpy(ackp, &trailer, sizeof(trailer)); - txb->kvec[0].iov_len =3D sizeof(txb->wire) + - sizeof(txb->ack) + txb->ack.nAcks + 3 + sizeof(trailer); + txb->kvec[0].iov_len +=3D sizeof(*ack) + ack->nAcks + 3 + sizeof(trailer); txb->len =3D txb->kvec[0].iov_len; } =20 @@ -187,10 +197,11 @@ static void rxrpc_cancel_rtt_probe(struct rxrpc_call = *call, */ static int rxrpc_send_ack_packet(struct rxrpc_call *call, struct rxrpc_txb= uf *txb) { + struct rxrpc_wire_header *whdr =3D txb->kvec[0].iov_base; struct rxrpc_connection *conn; + struct rxrpc_ackpacket *ack =3D (struct rxrpc_ackpacket *)(whdr + 1); struct msghdr msg; int ret, rtt_slot =3D -1; - u16 rwind; =20 if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) return -ECONNRESET; @@ -203,27 +214,22 @@ static int rxrpc_send_ack_packet(struct rxrpc_call *c= all, struct rxrpc_txbuf *tx msg.msg_controllen =3D 0; msg.msg_flags =3D 0; =20 - if (txb->ack.reason =3D=3D RXRPC_ACK_PING) + if (ack->reason =3D=3D RXRPC_ACK_PING) txb->flags |=3D RXRPC_REQUEST_ACK; - txb->wire.flags =3D txb->flags & RXRPC_TXBUF_WIRE_FLAGS; - - rxrpc_fill_out_ack(conn, call, txb, &rwind); + whdr->flags =3D txb->flags & RXRPC_TXBUF_WIRE_FLAGS; =20 txb->serial =3D rxrpc_get_next_serial(conn); - txb->wire.serial =3D htonl(txb->serial); + whdr->serial =3D htonl(txb->serial); trace_rxrpc_tx_ack(call->debug_id, txb->serial, - ntohl(txb->ack.firstPacket), - ntohl(txb->ack.serial), txb->ack.reason, txb->ack.nAcks, - rwind); + ntohl(ack->firstPacket), + ntohl(ack->serial), ack->reason, ack->nAcks, + txb->ack_rwind); =20 - if (txb->ack.reason =3D=3D RXRPC_ACK_PING) + if (ack->reason =3D=3D RXRPC_ACK_PING) rtt_slot =3D rxrpc_begin_rtt_probe(call, txb->serial, rxrpc_rtt_tx_ping); =20 rxrpc_inc_stat(call->rxnet, stat_tx_ack_send); =20 - /* Grab the highest received seq as late as possible */ - txb->ack.previousPacket =3D htonl(call->rx_highest_seq); - iov_iter_kvec(&msg.msg_iter, WRITE, txb->kvec, txb->nr_kvec, txb->len); rxrpc_local_dont_fragment(conn->local, false); ret =3D do_udp_sendmsg(conn->local->socket, &msg, txb->len); @@ -232,7 +238,7 @@ static int rxrpc_send_ack_packet(struct rxrpc_call *cal= l, struct rxrpc_txbuf *tx trace_rxrpc_tx_fail(call->debug_id, txb->serial, ret, rxrpc_tx_point_call_ack); } else { - trace_rxrpc_tx_packet(call->debug_id, &txb->wire, + trace_rxrpc_tx_packet(call->debug_id, whdr, rxrpc_tx_point_call_ack); if (txb->flags & RXRPC_REQUEST_ACK) call->peer->rtt_last_req =3D ktime_get_real(); @@ -268,18 +274,9 @@ void rxrpc_send_ACK(struct rxrpc_call *call, u8 ack_re= ason, return; } =20 - txb->ack_why =3D why; - txb->wire.seq =3D 0; - txb->wire.type =3D RXRPC_PACKET_TYPE_ACK; - txb->flags |=3D RXRPC_SLOW_START_OK; - txb->ack.bufferSpace =3D 0; - txb->ack.maxSkew =3D 0; - txb->ack.firstPacket =3D 0; - txb->ack.previousPacket =3D 0; - txb->ack.serial =3D htonl(serial); - txb->ack.reason =3D ack_reason; - txb->ack.nAcks =3D 0; + rxrpc_fill_out_ack(call, txb, ack_reason, serial); =20 + txb->ack_why =3D why; trace_rxrpc_send_ack(call, why, ack_reason, serial); rxrpc_send_ack_packet(call, txb); rxrpc_put_txbuf(txb, rxrpc_txbuf_put_ack_tx); @@ -365,7 +362,7 @@ static void rxrpc_prepare_data_subpacket(struct rxrpc_c= all *call, struct rxrpc_t =20 if (test_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags) && txb->seq =3D=3D 1) - txb->wire.userStatus =3D RXRPC_USERSTATUS_SERVICE_UPGRADE; + whdr->userStatus =3D RXRPC_USERSTATUS_SERVICE_UPGRADE; =20 /* If our RTT cache needs working on, request an ACK. Also request * ACKs if a DATA packet appears to have been lost. diff --git a/net/rxrpc/txbuf.c b/net/rxrpc/txbuf.c index 91e96cda6dc7..2e8c5b15a84f 100644 --- a/net/rxrpc/txbuf.c +++ b/net/rxrpc/txbuf.c @@ -19,10 +19,13 @@ atomic_t rxrpc_nr_txbuf; struct rxrpc_txbuf *rxrpc_alloc_txbuf(struct rxrpc_call *call, u8 packet_t= ype, gfp_t gfp) { + struct rxrpc_wire_header *whdr; struct rxrpc_txbuf *txb; =20 txb =3D kmalloc(sizeof(*txb), gfp); if (txb) { + whdr =3D &txb->_wire; + INIT_LIST_HEAD(&txb->call_link); INIT_LIST_HEAD(&txb->tx_link); refcount_set(&txb->ref, 1); @@ -37,18 +40,18 @@ struct rxrpc_txbuf *rxrpc_alloc_txbuf(struct rxrpc_call= *call, u8 packet_type, txb->serial =3D 0; txb->cksum =3D 0; txb->nr_kvec =3D 1; - txb->kvec[0].iov_base =3D &txb->wire; - txb->kvec[0].iov_len =3D sizeof(txb->wire); - txb->wire.epoch =3D htonl(call->conn->proto.epoch); - txb->wire.cid =3D htonl(call->cid); - txb->wire.callNumber =3D htonl(call->call_id); - txb->wire.seq =3D htonl(txb->seq); - txb->wire.type =3D packet_type; - txb->wire.flags =3D 0; - txb->wire.userStatus =3D 0; - txb->wire.securityIndex =3D call->security_ix; - txb->wire._rsvd =3D 0; - txb->wire.serviceId =3D htons(call->dest_srx.srx_service); + txb->kvec[0].iov_base =3D whdr; + txb->kvec[0].iov_len =3D sizeof(*whdr); + whdr->epoch =3D htonl(call->conn->proto.epoch); + whdr->cid =3D htonl(call->cid); + whdr->callNumber =3D htonl(call->call_id); + whdr->seq =3D htonl(txb->seq); + whdr->type =3D packet_type; + whdr->flags =3D 0; + whdr->userStatus =3D 0; + whdr->securityIndex =3D call->security_ix; + whdr->_rsvd =3D 0; + whdr->serviceId =3D htons(call->dest_srx.srx_service); =20 trace_rxrpc_txbuf(txb->debug_id, txb->call_debug_id, txb->seq, 1,