git: 7b8dd078ea3c - main - libnvmf: Correctly set the controller and host PDA fields

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Sat, 02 Nov 2024 13:54:54 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=7b8dd078ea3c6b836f514f47587672fd062279c8

commit 7b8dd078ea3c6b836f514f47587672fd062279c8
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-11-02 13:54:20 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-02 13:54:20 +0000

    libnvmf: Correctly set the controller and host PDA fields
    
    The caller supplied PDU data alignment (PDA) field from
    nvmf_association_params is the caller's restriction on data alignment
    (so affects received PDUs), and the PDA value received from the other
    end is the remote end's restriction (so affects transmitted PDUs).
    
    I had these backwards so that if the remote end advertised a PDA it
    was used as the receive PDA instead of the transmit PDA.
    
    Sponsored by:   Chelsio Communications
---
 lib/libnvmf/nvmf_tcp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libnvmf/nvmf_tcp.c b/lib/libnvmf/nvmf_tcp.c
index 93948b9b5fd0..cc4c0b90b0fb 100644
--- a/lib/libnvmf/nvmf_tcp.c
+++ b/lib/libnvmf/nvmf_tcp.c
@@ -1024,8 +1024,8 @@ tcp_connect(struct nvmf_tcp_qpair *qp, struct nvmf_association *na, bool admin)
 		return (false);
 	}
 
-	qp->txpda = (params->tcp.pda + 1) * 4;
-	qp->rxpda = (ic_resp.cpda + 1) * 4;
+	qp->rxpda = (params->tcp.pda + 1) * 4;
+	qp->txpda = (ic_resp.cpda + 1) * 4;
 	qp->header_digests = ic_resp.dgst.bits.hdgst_enable != 0;
 	qp->data_digests = ic_resp.dgst.bits.ddgst_enable != 0;
 	qp->maxr2t = params->tcp.maxr2t;
@@ -1069,8 +1069,8 @@ tcp_accept(struct nvmf_tcp_qpair *qp, struct nvmf_association *na)
 		return (false);
 	}
 
-	qp->txpda = (params->tcp.pda + 1) * 4;
-	qp->rxpda = (ic_req.hpda + 1) * 4;
+	qp->rxpda = (params->tcp.pda + 1) * 4;
+	qp->txpda = (ic_req.hpda + 1) * 4;
 	qp->header_digests = ic_resp.dgst.bits.hdgst_enable != 0;
 	qp->data_digests = ic_resp.dgst.bits.ddgst_enable != 0;
 	qp->maxr2t = le32toh(ic_req.maxr2t);