git: 438b8352856a - stable/13 - cxgbe(4): Do not request an FEC that is invalid for the requested speed.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Mon, 28 Feb 2022 06:55:48 UTC
The branch stable/13 has been updated by np:

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

commit 438b8352856ad3bd5ef410f60a4dca47ec17cf7b
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2022-01-05 18:45:06 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2022-02-28 06:48:49 +0000

    cxgbe(4): Do not request an FEC that is invalid for the requested speed.
    
    This eliminates error messages like this from the driver when running at
    50Gbps with 100G cables:
    [3726] cc0: l1cfg failed: 71
    [4407] cc0: l1cfg failed: 71
    
    Note that link comes up anyway with or without this change.
    
    Reported by:    Suhas Lokesha @ Chelsio
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit f3c2987f2f5c91f0801fa8bbf9e1bc09d91aeb46)
---
 sys/dev/cxgbe/common/t4_hw.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c
index d65d69075e88..c60594596959 100644
--- a/sys/dev/cxgbe/common/t4_hw.c
+++ b/sys/dev/cxgbe/common/t4_hw.c
@@ -3924,6 +3924,9 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
 				if (speed & FW_PORT_CAP32_SPEED_100G) {
 					fec |= FW_PORT_CAP32_FEC_RS;
 					fec |= FW_PORT_CAP32_FEC_NO_FEC;
+				} else if (speed & FW_PORT_CAP32_SPEED_50G) {
+					fec |= FW_PORT_CAP32_FEC_BASER_RS;
+					fec |= FW_PORT_CAP32_FEC_NO_FEC;
 				} else {
 					fec |= FW_PORT_CAP32_FEC_RS;
 					fec |= FW_PORT_CAP32_FEC_BASER_RS;
@@ -3937,6 +3940,19 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
 				 * because we aren't setting FORCE_FEC here.
 				 */
 				fec |= fec_to_fwcap(lc->fec_hint);
+				MPASS(powerof2(fec));
+
+				/*
+				 * Override the hint if the FEC is not valid for
+				 * the potential top speed.  Request the best
+				 * FEC at that speed instead.
+				 */
+				if (speed & FW_PORT_CAP32_SPEED_100G &&
+				    fec == FW_PORT_CAP32_FEC_BASER_RS)
+					fec = FW_PORT_CAP32_FEC_RS;
+				else if (speed & FW_PORT_CAP32_SPEED_50G &&
+				    fec == FW_PORT_CAP32_FEC_RS)
+					fec = FW_PORT_CAP32_FEC_BASER_RS;
 			}
 		} else {
 			/*