git: 231f21124032 - main - cxgbe(4): Handle FORCE_FEC in pcaps correctly.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Mar 2022 07:47:47 UTC
The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=231f2112403229a1382be3f5f6ed50bffe3497e8 commit 231f2112403229a1382be3f5f6ed50bffe3497e8 Author: Navdeep Parhar <np@FreeBSD.org> AuthorDate: 2022-03-25 07:34:54 +0000 Commit: Navdeep Parhar <np@FreeBSD.org> CommitDate: 2022-03-25 07:39:00 +0000 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 --- sys/dev/cxgbe/common/t4_hw.c | 15 +++++++++------ sys/dev/cxgbe/t4_main.c | 14 ++++++-------- 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; } /*