git: f3c2987f2f5c - main - cxgbe(4): Do not request an FEC that is invalid for the requested speed.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Wed, 05 Jan 2022 19:23:49 UTC
The branch main has been updated by np:

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

commit f3c2987f2f5c91f0801fa8bbf9e1bc09d91aeb46
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2022-01-05 18:45:06 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2022-01-05 19:15:34 +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
    MFC after:      1 week
    Sponsored by:   Chelsio Communications
---
 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 {
 			/*