git: cb85a1815fbe - stable/13 - cxgbei: Adjust the calculation for the maximum ISO payload.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 25 Aug 2022 17:31:32 UTC
The branch stable/13 has been updated by jhb:

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

commit cb85a1815fbe3cc9d67d51ad3fefa536b2e3c163
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-26 20:38:20 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-08-25 16:30:09 +0000

    cxgbei: Adjust the calculation for the maximum ISO payload.
    
    Round down the maximim ISO payload by the current MSS.  Otherwise the
    round up by MSS when calculating the 16-bit maximum payload len passed
    along in the FLOWC work request can overflow.
    
    Discussed with: np
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 8020c05683f266c5513cfe8ad3e58e7e06f85ffa)
---
 sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
index 7d58e11b7835..735d1fe19996 100644
--- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
+++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
@@ -1103,7 +1103,7 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd)
 	struct tcpcb *tp;
 	struct toepcb *toep;
 	cap_rights_t rights;
-	u_int max_rx_pdu_len, max_tx_pdu_len;
+	u_int max_iso_payload, max_rx_pdu_len, max_tx_pdu_len;
 	int error, max_iso_pdus;
 
 	MPASS(icc->icc_signature == CXGBEI_CONN_SIGNATURE);
@@ -1195,7 +1195,9 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd)
 
 	if (icc->sc->tt.iso && chip_id(icc->sc) >= CHELSIO_T5 &&
 	    !is_memfree(icc->sc)) {
-		max_iso_pdus = CXGBEI_MAX_ISO_PAYLOAD / max_tx_pdu_len;
+		max_iso_payload = rounddown(CXGBEI_MAX_ISO_PAYLOAD,
+		    tp->t_maxseg);
+		max_iso_pdus = max_iso_payload / max_tx_pdu_len;
 		ic->ic_hw_isomax = max_iso_pdus *
 		    ic->ic_max_send_data_segment_length;
 	} else