From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6DF2343FC9; Tue, 7 May 2024 14:46:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F31DF433C7; Tue, 7 May 2024 14:44:40 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2086.outbound.protection.outlook.com [40.107.92.86]) by mails.dpdk.org (Postfix) with ESMTP id E646D433D9 for ; Tue, 7 May 2024 14:44:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+B8NE4256E75gSX107aYEwXSIv4Jp5DMdpeCzaDn3/NH0X1/pB54wVxc23aVXOQ5MdHIzU1fA8ZDNf/REfYkrQuQq2wItO6nB/LNCBvtfZYO83dlHbBbdHgomhpSHt/lw9lBARi/1hErz+2TsWcnXzvEGtWZqSet+s3dcltWOv16N/gtrdzWvPe8Dwxn5BtGcygrCAg9haTycchp0gUcbhYheMJQFfj4GqADY1WJf7c8vpRM38OsZqI5iNcMvEIMDZ2E3KKZcKecEZ74l/N2tqmRFo91zRA2mvIhKsAjAU5tGxlsFGFE4w1nu2qOi6wf3WNdYc52gfwcClNoTlTTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sqqMen0GE9PckLPny4gOoGY0p3ivgyrPK3mNL0j8IEc=; b=SLDP+hhL9xi6KXY5uclVpK+T6lkFy9cFkbvELN/0xjAbaeJmpfOQllrry/BXirBD9MrNds3xd5mW256rVEDFp9qaUiiFnY+0KPOcMk44g+wMWTXmHC1/19Eww8YfcZE2OWYkJFqQCLgHg9VTHqHlwFH2fXfqfP4jf01ZCOKHXMPo/+fr1An2PE2LsZmw6hsd1JK69kJUhGIEgS4TQvwn48IHJrAVx156E5F/9wqiWhjbzIu0gQ+wZ4vZJSvd0H6t+Se+KAxKlShttzYJB63bVQrGYr7GtgpMjAwaShkphCtlCZAJEllPVUYy2GWnMJPVcu1h0bEhjlaA7LEF4kA//w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sqqMen0GE9PckLPny4gOoGY0p3ivgyrPK3mNL0j8IEc=; b=SuhMREzxN+BmaeqBdhJPCZC6zM9sVyU3jIrmq3YIhv0G+1bhozWR4bOyY2bbH7dsWa09nTmAMouSQpmg9BRemJaX41DBbK6gXIV8/pn7CkE9Ocdi3x3CA2yqGDpdXjaYHTux87OeR1zF3VfXddyzggq5KL/c4GowDfsTwv0baco= Received: from PR2P264CA0013.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::25) by PH7PR12MB7188.namprd12.prod.outlook.com (2603:10b6:510:204::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29; Tue, 7 May 2024 12:44:35 +0000 Received: from SN1PEPF00036F42.namprd05.prod.outlook.com (2603:10a6:101:0:cafe::1) by PR2P264CA0013.outlook.office365.com (2603:10a6:101::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41 via Frontend Transport; Tue, 7 May 2024 12:44:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00036F42.mail.protection.outlook.com (10.167.248.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Tue, 7 May 2024 12:44:33 +0000 Received: from cae-Lilac-RMB.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 7 May 2024 07:44:26 -0500 From: Venkat Kumar Ande To: CC: , Venkat Kumar Ande Subject: [PATCH v2 22/25] net/axgbe: add support for Rx adaptation Date: Tue, 7 May 2024 18:13:02 +0530 Message-ID: <20240507124305.2318-22-venkatkumar.ande@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507124305.2318-1-venkatkumar.ande@amd.com> References: <20240412125013.10498-1-VenkatKumar.Ande@amd.com> <20240507124305.2318-1-venkatkumar.ande@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F42:EE_|PH7PR12MB7188:EE_ X-MS-Office365-Filtering-Correlation-Id: ffd7d962-36d9-43a4-12a6-08dc6e937264 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iir8RGVoopHmK/xNS3mwuu0meRgEGk8ON04bBVHeh0zM6ZzyNcXzHTeO6+N3?= =?us-ascii?Q?DLbWKvPTUtTx7Aor5X5tR3zPWUX9Bb4ZZSo6bPpcqyRm/4tBTODAv0w5WShF?= =?us-ascii?Q?Hj7uF0q+5fzSa5k1GhEwWHTey5anOVvhF6GKwxQoJlnZNRsmtEHgj0WDEHuE?= =?us-ascii?Q?IUwdxjbndX7YVjXExemr1ioRnArk35RlhyJXwYJ8X8BwrbASJPgPSfL6APw8?= =?us-ascii?Q?rj3gNhi9tvH80hydGpYELPl8e5n2HJO3aqfDsWpqX2BZlp40T0CgjP2CwQrs?= =?us-ascii?Q?ONXdyuHOPCDIlVaLXlTTuuDCg3iM5ZIXLTO/HG5Fgd83gpjceuxzsriksWz/?= =?us-ascii?Q?7KrDWFv2xN9X8YA2gYNxjOzSAdOgJxdx3+JlyHAnhEijbaCba85kcyI/R5xv?= =?us-ascii?Q?Z8/rSK+69v5Br69+YS754NcdIxdMhQu+rbYvwrQe3nTvukxePLoDYDMgt5VJ?= =?us-ascii?Q?lHP3pg3oWG4QoMu2cZruWJC2v8bhBeY+28aystbSnoQxjKtHsozFGdk9xGhB?= =?us-ascii?Q?7VZDKsSg3m1B9Z86a+WJ96jWJgTRljtil89MfJSEBTPTDijqyNAv2DgUHgtj?= =?us-ascii?Q?sT+gjZRc4zG5RxHqGeEBiSLMKLXQcoRlSJ0XhlKtOaIIZiy3AFmnKNRJN0yE?= =?us-ascii?Q?wJD4X8Umr6CvZyIAfInYHe+eZaxnL4060AGA0p+xtQHyCFjSDW3Z2/4N/50n?= =?us-ascii?Q?3GxBbI4UxC3lREYGCEU+g7gZf2jR2nsXjs+POoDFyExn0T5Ms9r5FxcELtuA?= =?us-ascii?Q?FKcPVodqIdJqaMjGgfImCs7vUMruzPuhQUOEj+D2ABfTckN2kdR6huhjKSIT?= =?us-ascii?Q?ctxSXZ3Y/qPQ0wMFLTabcYlacSpvJUVFoQjxDjaf62qQ/Sxy8lBh7WKpa7sp?= =?us-ascii?Q?EGE1/rTDHdi9WXCPze6wUIp9G+bGxflyK0EqBVAdgrxAuPLeUqOAO0qpPb3B?= =?us-ascii?Q?EcZyroaQIHS6wTRE/qBR+XLmxs3o+GbxPAQNNp3N0hpD9jIgqvTYFDpr6mvV?= =?us-ascii?Q?Bk8Y+ag85MAoA7bYMCfvViCSCQsj30G2hrEie1FZXig8Gprk8R/pUQqLZO/w?= =?us-ascii?Q?Lfkb9ihzarkMnV/c7hKkLkNL3c0ug7KgW/r7ilSJd5b6kuriIRmRV23Rxdlx?= =?us-ascii?Q?4/4MVIX2aUKczKgTXxJT7LbR0E29jxeUnlSzYr62Yro+vtTg5oXqTiQvsPRu?= =?us-ascii?Q?mhBNj7NuHT9CWrQCI8qp1SalbWVgOxW7JVhR/UwQUITPuTJiLV8nphuJlYoq?= =?us-ascii?Q?zCKKCXVtrMeoMkbAHF91Bl3c0cH1IsjzMVzCve0GFIRTi22sADYJ6Y18C8uz?= =?us-ascii?Q?/F0sDahfUmoEMqllIoqSNaVcCDj1RDRGRJjdgSDBzCu1enMS+VY7wx2LctpR?= =?us-ascii?Q?/vyIHNl8xRkWQSxvmjMUb4bzLhV/?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(82310400017)(36860700004)(376005)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 12:44:33.7551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ffd7d962-36d9-43a4-12a6-08dc6e937264 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F42.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7188 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The existing implementation for non-Autonegotiation 10G speed modes does not enable RX adaptation in the Driver and FW. The RX Equalization settings (AFE settings alone) are manually configured and the existing link-up sequence in the driver does not perform rx adaptation process as mentioned in the Synopsys databook. There's a customer request for 10G backplane mode without Auto-negotiation and for the DAC cables of more significant length that follow the non-Autonegotiation mode. These modes require PHY to perform RX Adaptation. The proposed logic adds the necessary changes to Yellow Carp devices to ensure seamless RX Adaptation for 10G-SFI (LONG DAC) and 10G-KR without AN (CL72 not present). The RX adaptation core algorithm is executed by firmware, however, to achieve that a new mailbox sub-command is required to be sent by the driver. Signed-off-by: Venkat Kumar Ande --- drivers/net/axgbe/axgbe_common.h | 38 +++++++ drivers/net/axgbe/axgbe_ethdev.h | 5 + drivers/net/axgbe/axgbe_phy_impl.c | 170 ++++++++++++++++++++++++++++- 3 files changed, 210 insertions(+), 3 deletions(-) diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h index 1a43192630..0e1b2c1500 100644 --- a/drivers/net/axgbe/axgbe_common.h +++ b/drivers/net/axgbe/axgbe_common.h @@ -1274,6 +1274,22 @@ #define MDIO_PMA_RX_CTRL1 0x8051 #endif +#ifndef MDIO_PMA_RX_LSTS +#define MDIO_PMA_RX_LSTS 0x018020 +#endif + +#ifndef MDIO_PMA_RX_EQ_CTRL4 +#define MDIO_PMA_RX_EQ_CTRL4 0x0001805C +#endif + +#ifndef MDIO_PMA_MP_MISC_STS +#define MDIO_PMA_MP_MISC_STS 0x0078 +#endif + +#ifndef MDIO_PMA_PHY_RX_EQ_CEU +#define MDIO_PMA_PHY_RX_EQ_CEU 0x1800E +#endif + #ifndef MDIO_PCS_DIG_CTRL #define MDIO_PCS_DIG_CTRL 0x8000 #endif @@ -1415,6 +1431,28 @@ static inline uint32_t high32_value(uint64_t addr) #define XGBE_PMA_RX_RST_0_RESET_ON 0x10 #define XGBE_PMA_RX_RST_0_RESET_OFF 0x00 +#define XGBE_PMA_RX_SIG_DET_0_MASK BIT(4) +#define XGBE_PMA_RX_SIG_DET_0_ENABLE BIT(4) +#define XGBE_PMA_RX_SIG_DET_0_DISABLE 0x0000 + +#define XGBE_PMA_RX_VALID_0_MASK BIT(12) +#define XGBE_PMA_RX_VALID_0_ENABLE BIT(12) +#define XGBE_PMA_RX_VALID_0_DISABLE 0x0000 + +#define XGBE_PMA_RX_AD_REQ_MASK BIT(12) +#define XGBE_PMA_RX_AD_REQ_ENABLE BIT(12) +#define XGBE_PMA_RX_AD_REQ_DISABLE 0x0000 + +#define XGBE_PMA_RX_ADPT_ACK_MASK BIT(12) +#define XGBE_PMA_RX_ADPT_ACK BIT(12) + +#define XGBE_PMA_CFF_UPDTM1_VLD BIT(8) +#define XGBE_PMA_CFF_UPDT0_VLD BIT(9) +#define XGBE_PMA_CFF_UPDT1_VLD BIT(10) +#define XGBE_PMA_CFF_UPDT_MASK (XGBE_PMA_CFF_UPDTM1_VLD |\ + XGBE_PMA_CFF_UPDT0_VLD | \ + XGBE_PMA_CFF_UPDT1_VLD) + /*END*/ /* Bit setting and getting macros diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h index cb3df47a63..dd00ae8af5 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -244,6 +244,7 @@ enum axgbe_mb_cmd { enum axgbe_mb_subcmd { AXGBE_MB_SUBCMD_NONE = 0, + AXGBE_MB_SUBCMD_RX_ADAP, /* 10GbE SFP subcommands */ AXGBE_MB_SUBCMD_ACTIVE = 0, @@ -722,6 +723,10 @@ struct axgbe_port { struct rte_timecounter tx_tstamp; unsigned int tstamp_addend; + bool en_rx_adap; + int rx_adapt_retries; + bool rx_adapt_done; + bool mode_set; }; void axgbe_init_function_ptrs_dev(struct axgbe_hw_if *hw_if); diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c index 13b37e9b8b..a1c42b7dd4 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -247,6 +247,10 @@ struct axgbe_phy_data { }; static enum axgbe_an_mode axgbe_phy_an_mode(struct axgbe_port *pdata); +static void axgbe_phy_perform_ratechange(struct axgbe_port *pdata, + enum axgbe_mb_cmd cmd, enum axgbe_mb_subcmd sub_cmd); +static void axgbe_phy_rrc(struct axgbe_port *pdata); + static int axgbe_phy_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *i2c_op) @@ -1194,6 +1198,92 @@ static void axgbe_phy_set_redrv_mode(struct axgbe_port *pdata) axgbe_phy_put_comm_ownership(pdata); } +#define MAX_RX_ADAPT_RETRIES 1 +#define XGBE_PMA_RX_VAL_SIG_MASK (XGBE_PMA_RX_SIG_DET_0_MASK | \ + XGBE_PMA_RX_VALID_0_MASK) + +static void axgbe_set_rx_adap_mode(struct axgbe_port *pdata, + enum axgbe_mode mode) +{ + if (pdata->rx_adapt_retries++ >= MAX_RX_ADAPT_RETRIES) { + pdata->rx_adapt_retries = 0; + return; + } + + axgbe_phy_perform_ratechange(pdata, + mode == AXGBE_MODE_KR ? + AXGBE_MB_CMD_SET_10G_KR : + AXGBE_MB_CMD_SET_10G_SFI, + AXGBE_MB_SUBCMD_RX_ADAP); +} + +static void axgbe_rx_adaptation(struct axgbe_port *pdata) +{ + struct axgbe_phy_data *phy_data = pdata->phy_data; + unsigned int reg; + + /* step 2: force PCS to send RX_ADAPT Req to PHY */ + XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_EQ_CTRL4, + XGBE_PMA_RX_AD_REQ_MASK, XGBE_PMA_RX_AD_REQ_ENABLE); + + /* Step 3: Wait for RX_ADAPT ACK from the PHY */ + rte_delay_ms(200); + + /* Software polls for coefficient update command (given by local PHY) */ + reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_PHY_RX_EQ_CEU); + + /* Clear the RX_AD_REQ bit */ + XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_EQ_CTRL4, + XGBE_PMA_RX_AD_REQ_MASK, XGBE_PMA_RX_AD_REQ_DISABLE); + + /* Check if coefficient update command is set */ + if ((reg & XGBE_PMA_CFF_UPDT_MASK) != XGBE_PMA_CFF_UPDT_MASK) + goto set_mode; + + /* Step 4: Check for Block lock */ + + /* Link status is latched low, so read once to clear + * and then read again to get current state + */ + reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); + reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); + if (reg & MDIO_STAT1_LSTATUS) { + /* If the block lock is found, update the helpers + * and declare the link up + */ + PMD_DRV_LOG(NOTICE, "Rx adaptation - Block_lock done\n"); + pdata->rx_adapt_done = true; + pdata->mode_set = false; + return; + } + +set_mode: + axgbe_set_rx_adap_mode(pdata, phy_data->cur_mode); +} + +static void axgbe_phy_rx_adaptation(struct axgbe_port *pdata) +{ + unsigned int reg; + +rx_adapt_reinit: + reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_LSTS, + XGBE_PMA_RX_VAL_SIG_MASK); + + /* step 1: Check for RX_VALID && LF_SIGDET */ + if ((reg & XGBE_PMA_RX_VAL_SIG_MASK) != XGBE_PMA_RX_VAL_SIG_MASK) { + PMD_DRV_LOG(NOTICE, "RX_VALID or LF_SIGDET is unset, issue rrc\n"); + axgbe_phy_rrc(pdata); + if (pdata->rx_adapt_retries++ >= MAX_RX_ADAPT_RETRIES) { + pdata->rx_adapt_retries = 0; + return; + } + goto rx_adapt_reinit; + } + + /* perform rx adaptation */ + axgbe_rx_adaptation(pdata); +} + static void axgbe_phy_rx_reset(struct axgbe_port *pdata) { int reg; @@ -1258,12 +1348,27 @@ static void axgbe_phy_perform_ratechange(struct axgbe_port *pdata, wait = AXGBE_RATECHANGE_COUNT; while (wait--) { if (!XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) - goto reenable_pll; + goto do_rx_adaptation; rte_delay_us(1500); } PMD_DRV_LOG(NOTICE, "firmware mailbox command did not complete\n"); /* Reset on error */ axgbe_phy_rx_reset(pdata); + goto reenable_pll; + + +do_rx_adaptation: + if (pdata->en_rx_adap && sub_cmd == AXGBE_MB_SUBCMD_RX_ADAP && + (cmd == AXGBE_MB_CMD_SET_10G_KR || cmd == AXGBE_MB_CMD_SET_10G_SFI)) { + PMD_DRV_LOG(NOTICE, "Enabling RX adaptation\n"); + pdata->mode_set = true; + axgbe_phy_rx_adaptation(pdata); + /* return from here to avoid enabling PLL ctrl + * during adaptation phase + */ + return; + } + reenable_pll: /* Enable PLL re-initialization, not needed for PHY Power Off and RRC cmds */ @@ -1296,6 +1401,31 @@ static void axgbe_phy_power_off(struct axgbe_port *pdata) PMD_DRV_LOG(DEBUG, "phy powered off\n"); } +static bool enable_rx_adap(struct axgbe_port *pdata, enum axgbe_mode mode) +{ + struct axgbe_phy_data *phy_data = pdata->phy_data; + unsigned int ver; + + /* Rx-Adaptation is not supported on older platforms(< 0x30H) */ + ver = AXGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER); + if (ver < 0x30) + return false; + + /* Re-driver models 4223 && 4227 do not support Rx-Adaptation */ + if (phy_data->redrv && + (phy_data->redrv_model == AXGBE_PHY_REDRV_MODEL_4223 || + phy_data->redrv_model == AXGBE_PHY_REDRV_MODEL_4227)) + return false; + + /* 10G KR mode with AN does not support Rx-Adaptation */ + if (mode == AXGBE_MODE_KR && + phy_data->port_mode != AXGBE_PORT_MODE_BACKPLANE_NO_AUTONEG) + return false; + + pdata->en_rx_adap = 1; + return true; +} + static void axgbe_phy_sfi_mode(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; @@ -1304,8 +1434,13 @@ static void axgbe_phy_sfi_mode(struct axgbe_port *pdata) /* 10G/SFI */ if (phy_data->sfp_cable != AXGBE_SFP_CABLE_PASSIVE) { + pdata->en_rx_adap = 0; axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SET_10G_SFI, AXGBE_MB_SUBCMD_ACTIVE); + } else if ((phy_data->sfp_cable == AXGBE_SFP_CABLE_PASSIVE) && + (enable_rx_adap(pdata, AXGBE_MODE_SFI))) { + axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SET_10G_SFI, + AXGBE_MB_SUBCMD_RX_ADAP); } else { if (phy_data->sfp_cable_len <= 1) axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SET_10G_SFI, @@ -1330,6 +1465,10 @@ static void axgbe_phy_kr_mode(struct axgbe_port *pdata) axgbe_phy_set_redrv_mode(pdata); /* 10G/KR */ + if (enable_rx_adap(pdata, AXGBE_MODE_KR)) + axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SET_10G_KR, + AXGBE_MB_SUBCMD_RX_ADAP); + else axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SET_10G_KR, AXGBE_MB_SUBCMD_NONE); phy_data->cur_mode = AXGBE_MODE_KR; @@ -1719,8 +1858,11 @@ static int axgbe_phy_link_status(struct axgbe_port *pdata, int *an_restart) return 0; } - if (phy_data->sfp_mod_absent || phy_data->sfp_rx_los) + if (phy_data->sfp_mod_absent || phy_data->sfp_rx_los) { + if (pdata->en_rx_adap) + pdata->rx_adapt_done = false; return 0; + } } /* Link status is latched low, so read once to clear @@ -1728,7 +1870,29 @@ static int axgbe_phy_link_status(struct axgbe_port *pdata, int *an_restart) */ reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); - if (reg & MDIO_STAT1_LSTATUS) + + if (pdata->en_rx_adap) { + /* if the link is available and adaptation is done, + * declare link up + */ + if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done) + return 1; + /* If either link is not available or adaptation is not done, + * retrigger the adaptation logic. (if the mode is not set, + * then issue mailbox command first) + */ + if (pdata->mode_set) { + axgbe_phy_rx_adaptation(pdata); + } else { + pdata->rx_adapt_done = false; + axgbe_phy_set_mode(pdata, phy_data->cur_mode); + } + + /* check again for the link and adaptation status */ + reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); + if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done) + return 1; + } else if (reg & MDIO_STAT1_LSTATUS) return 1; if (pdata->phy.autoneg == AUTONEG_ENABLE && -- 2.34.1