aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavdeep Parhar <np@FreeBSD.org>2022-03-25 07:34:54 +0000
committerNavdeep Parhar <np@FreeBSD.org>2022-03-25 07:39:00 +0000
commit231f2112403229a1382be3f5f6ed50bffe3497e8 (patch)
tree23f93c885c462fc11d4d9128480d851fa368eb2b
parent9d9ba2b79b3196935431879efd9094eb9bfedd95 (diff)
downloadsrc-231f2112403229a1382be3f5f6ed50bffe3497e8.tar.gz
src-231f2112403229a1382be3f5f6ed50bffe3497e8.zip
cxgbe(4): Handle FORCE_FEC in pcaps correctly.
The firmware doesn't report FORCE_FEC in pcaps if the transceiver plugged in at that time does not support a speed that may use FEC. It is incorrect for the driver to assume that the FORCE_FEC value it read during attach (in init_link_config) is permanent. Instead, it should check pcaps just before issuing the L1CFG command. MFC after: 1 week Sponsored by: Chelsio Communications
-rw-r--r--sys/dev/cxgbe/common/t4_hw.c15
-rw-r--r--sys/dev/cxgbe/t4_main.c14
2 files changed, 15 insertions, 14 deletions
diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c
index c32dab915ee6..0176eb3e2b0d 100644
--- a/sys/dev/cxgbe/common/t4_hw.c
+++ b/sys/dev/cxgbe/common/t4_hw.c
@@ -3908,13 +3908,16 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
speed = fwcap_top_speed(lc->pcaps);
fec = 0;
-#ifdef INVARIANTS
- if (lc->force_fec != 0)
- MPASS(lc->pcaps & FW_PORT_CAP32_FORCE_FEC);
-#endif
if (fec_supported(speed)) {
+ int force_fec;
+
+ if (lc->pcaps & FW_PORT_CAP32_FORCE_FEC)
+ force_fec = lc->force_fec;
+ else
+ force_fec = 0;
+
if (lc->requested_fec == FEC_AUTO) {
- if (lc->force_fec > 0) {
+ if (force_fec > 0) {
/*
* Must use FORCE_FEC even though requested FEC
* is AUTO. Set all the FEC bits valid for the
@@ -3960,7 +3963,7 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
* User has explicitly requested some FEC(s). Set
* FORCE_FEC unless prohibited from using it.
*/
- if (lc->force_fec != 0)
+ if (force_fec != 0)
fec |= FW_PORT_CAP32_FORCE_FEC;
fec |= fec_to_fwcap(lc->requested_fec &
M_FW_PORT_CAP32_FEC);
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index f367ebc60c14..56ceae56a700 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -5789,7 +5789,6 @@ init_link_config(struct port_info *pi)
struct link_config *lc = &pi->link_cfg;
PORT_LOCK_ASSERT_OWNED(pi);
- MPASS(lc->pcaps != 0);
lc->requested_caps = 0;
lc->requested_speed = 0;
@@ -5815,13 +5814,12 @@ init_link_config(struct port_info *pi)
if (lc->requested_fec == 0)
lc->requested_fec = FEC_AUTO;
}
- lc->force_fec = 0;
- if (lc->pcaps & FW_PORT_CAP32_FORCE_FEC) {
- if (t4_force_fec < 0)
- lc->force_fec = -1;
- else if (t4_force_fec > 0)
- lc->force_fec = 1;
- }
+ if (t4_force_fec < 0)
+ lc->force_fec = -1;
+ else if (t4_force_fec > 0)
+ lc->force_fec = 1;
+ else
+ lc->force_fec = 0;
}
/*