From nobody Mon Nov 15 20:22:31 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 876941893BE9; Mon, 15 Nov 2021 20:22:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HtLGH3RyCz3Mgx; Mon, 15 Nov 2021 20:22:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 56A2B1FF5D; Mon, 15 Nov 2021 20:22:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AFKMVkQ014528; Mon, 15 Nov 2021 20:22:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AFKMV4t014527; Mon, 15 Nov 2021 20:22:31 GMT (envelope-from git) Date: Mon, 15 Nov 2021 20:22:31 GMT Message-Id: <202111152022.1AFKMV4t014527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Navdeep Parhar Subject: git: a8eacf9329e2 - main - cxgbe(4): Change the way t4_shutdown_adapter brings the link(s) down. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a8eacf9329e2984f9c950fb5ef6447be4676007a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=a8eacf9329e2984f9c950fb5ef6447be4676007a commit a8eacf9329e2984f9c950fb5ef6447be4676007a Author: Navdeep Parhar AuthorDate: 2021-11-15 18:55:04 +0000 Commit: Navdeep Parhar CommitDate: 2021-11-15 20:17:26 +0000 cxgbe(4): Change the way t4_shutdown_adapter brings the link(s) down. Modify the GPIO pins only on the Base-T cards and even there drive all of them low instead of putting them in hi-z state. For the rest (this is the common case), directly power off the PLLs of the high speed serdes. This is the simplest method that does not involve or conflict with the firmware but still works with all T4-T6 cards regardless of what's plugged into the port. This fixes a problem where the peer wouldn't always see a link down if it is connected to the device using a -CR4 copper cable. MFC after: 3 weeks Sponsored by: Chelsio Communications --- sys/dev/cxgbe/adapter.h | 3 ++- sys/dev/cxgbe/common/t4_hw.c | 24 +++++++++++++----------- sys/dev/cxgbe/firmware/t4fw_interface.h | 8 ++++++++ sys/dev/cxgbe/t4_main.c | 5 +++++ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 4762b46f3799..a7139b3f7b0e 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -930,7 +930,8 @@ struct adapter { struct tls_tunables tlst; uint8_t doorbells; - int offload_map; /* ports with IFCAP_TOE enabled */ + int offload_map; /* port_id's with IFCAP_TOE enabled */ + int bt_map; /* tx_chan's with BASE-T */ int active_ulds; /* ULDs activated on this adapter */ int flags; int debug_flags; diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index e2b55dc71eba..26ffddaa98f4 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -3827,15 +3827,6 @@ static uint16_t fwcaps32_to_caps16(uint32_t caps32) return caps16; } -static bool -is_bt(struct port_info *pi) -{ - - return (pi->port_type == FW_PORT_TYPE_BT_SGMII || - pi->port_type == FW_PORT_TYPE_BT_XFI || - pi->port_type == FW_PORT_TYPE_BT_XAUI); -} - static int8_t fwcap_to_fec(uint32_t caps, bool unset_means_none) { int8_t fec = 0; @@ -3970,7 +3961,7 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port, } /* Force AN on for BT cards. */ - if (is_bt(adap->port[adap->chan_map[port]])) + if (isset(&adap->bt_map, port)) aneg = lc->pcaps & FW_PORT_CAP32_ANEG; rcap = aneg | speed | fc | fec; @@ -9414,9 +9405,11 @@ int t4_prep_adapter(struct adapter *adapter, u32 *buf) int t4_shutdown_adapter(struct adapter *adapter) { int port; + const bool bt = adapter->bt_map != 0; t4_intr_disable(adapter); - t4_write_reg(adapter, A_DBG_GPIO_EN, 0); + if (bt) + t4_write_reg(adapter, A_DBG_GPIO_EN, 0xffff0000); for_each_port(adapter, port) { u32 a_port_cfg = is_t4(adapter) ? PORT_REG(port, A_XGMAC_PORT_CFG) : @@ -9425,6 +9418,15 @@ int t4_shutdown_adapter(struct adapter *adapter) t4_write_reg(adapter, a_port_cfg, t4_read_reg(adapter, a_port_cfg) & ~V_SIGNAL_DET(1)); + if (!bt) { + u32 hss_cfg0 = is_t4(adapter) ? + PORT_REG(port, A_XGMAC_PORT_HSS_CFG0) : + T5_PORT_REG(port, A_MAC_PORT_HSS_CFG0); + t4_set_reg_field(adapter, hss_cfg0, F_HSSPDWNPLLB | + F_HSSPDWNPLLA | F_HSSPLLBYPB | F_HSSPLLBYPA, + F_HSSPDWNPLLB | F_HSSPDWNPLLA | F_HSSPLLBYPB | + F_HSSPLLBYPA); + } } t4_set_reg_field(adapter, A_SGE_CONTROL, F_GLOBALENABLE, 0); diff --git a/sys/dev/cxgbe/firmware/t4fw_interface.h b/sys/dev/cxgbe/firmware/t4fw_interface.h index 876fd61b4b21..93e5f2207411 100644 --- a/sys/dev/cxgbe/firmware/t4fw_interface.h +++ b/sys/dev/cxgbe/firmware/t4fw_interface.h @@ -7804,6 +7804,14 @@ enum fw_port_type { FW_PORT_TYPE_NONE = M_FW_PORT_CMD_PTYPE }; +static inline bool +is_bt(enum fw_port_type port_type) +{ + return (port_type == FW_PORT_TYPE_BT_SGMII || + port_type == FW_PORT_TYPE_BT_XFI || + port_type == FW_PORT_TYPE_BT_XAUI); +} + /* These are read from module's EEPROM and determined once the module is inserted. */ enum fw_port_module_type { diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 44a9a1343016..f30e8c14ecb4 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -1313,6 +1313,11 @@ t4_attach(device_t dev) goto done; } + if (is_bt(pi->port_type)) + setbit(&sc->bt_map, pi->tx_chan); + else + MPASS(!isset(&sc->bt_map, pi->tx_chan)); + snprintf(pi->lockname, sizeof(pi->lockname), "%sp%d", device_get_nameunit(dev), i); mtx_init(&pi->pi_lock, pi->lockname, 0, MTX_DEF);