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 B898944077; Mon, 20 May 2024 12:43:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED51740DCD; Mon, 20 May 2024 12:43:20 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2076.outbound.protection.outlook.com [40.107.94.76]) by mails.dpdk.org (Postfix) with ESMTP id AA24040A75 for ; Mon, 20 May 2024 12:43:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hX+WyJVbxtp/c3nMQF4e/iCDb5F0w/PkfMmQuscm8mTw0zVk5OsRLcxX2lEP6js5Pr8W4+d38iDzu7iZhT4dp7BY5D3HW4Kr46DV2k6RpPzqxJk/f5mE5DnhtfkZWeu3nJ8GTUZ7HiecIp7YKwAcR+P8SCB/p0GhnpzwCst91VpWbP74moBZrudwqRSTz7ILtp58au4ClJSW7gUSsr9ebDlwVxCzl7hUUh7HGfE/cKdebCfZDscSuOgDoAEuhFpSbuJ10pK8M1XQ4nclcI36gLhX+pn8QWFtaQ+SL7UGg9kGhF9l1Ule81MJe2Lq4EMti4cEM5AwYhN5HP/TSpXP4Q== 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=tJ6+NbynVklZaFVcRx4nsOYl8SlFFyL7wW2mmC1bghw=; b=GQDfhp2NBnbt1/xZwRikKto/hrVl0t92v7BDdB02GRtMXyee99sTSld+x/4DRrlX7+BAQrghApkYFduDQiRHq1WA5PU5vxkVp7JqeqTb7PSFATKe0Riv5R2v4ejdefuRgylciZAovnqB5OABEE6f0d2Y9Y9dOXHwzGGgIlNI/5ON4KEyXasPSrZPPJdvfTtTDNMAgr6VFQXY+P15Q7557bBSYWXFvqksafUMeLuRKY8KqLzUZA14r3aEogK6UGiqgpR0LrJO4hghwYGj8c2OPRJQ0/RaYtd77eoyV93hSKsM3B9yjhbehPVXBaZbil1fKrdnGIf3FW+GAThGuvp2+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=tJ6+NbynVklZaFVcRx4nsOYl8SlFFyL7wW2mmC1bghw=; b=osfVXVE595+jkU61+VrmqdKNDFgNIk4cTuLQllpi/tjaLqaQE1YaL4WO+x1sAOnhnZDbSeWLcBV9wrUcC1aw25lFe9H5bAbvmCACPRKKtlyHlRjKUV7m+1TzhVV1DLKWuU/570OUO+kkwlcY/qx8kjfBie24C5EmeK8HL0JGY44= Received: from DM4PR12MB5055.namprd12.prod.outlook.com (2603:10b6:5:39a::20) by DS0PR12MB7607.namprd12.prod.outlook.com (2603:10b6:8:13f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Mon, 20 May 2024 10:43:17 +0000 Received: from DM4PR12MB5055.namprd12.prod.outlook.com ([fe80::acbd:ea93:4496:51a5]) by DM4PR12MB5055.namprd12.prod.outlook.com ([fe80::acbd:ea93:4496:51a5%7]) with mapi id 15.20.7587.035; Mon, 20 May 2024 10:43:17 +0000 From: "Sebastian, Selwin" To: "Ande, Venkat Kumar" , "dev@dpdk.org" Subject: RE: [PATCH v2 22/25] net/axgbe: add support for Rx adaptation Thread-Topic: [PATCH v2 22/25] net/axgbe: add support for Rx adaptation Thread-Index: AQHaoHxPV2JMFT9PXkCcKDruDALDKbGgBA+g Date: Mon, 20 May 2024 10:43:17 +0000 Message-ID: References: <20240412125013.10498-1-VenkatKumar.Ande@amd.com> <20240507124305.2318-1-venkatkumar.ande@amd.com> <20240507124305.2318-22-venkatkumar.ande@amd.com> In-Reply-To: <20240507124305.2318-22-venkatkumar.ande@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_ActionId=9b312ce2-05db-4084-81d3-d501a646df1f; MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_ContentBits=0; MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Enabled=true; MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Method=Standard; MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Name=AMD Internal Distribution Only; MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_SetDate=2024-05-20T10:43:13Z; MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR12MB5055:EE_|DS0PR12MB7607:EE_ x-ms-office365-filtering-correlation-id: 9ef00da4-fe7c-43ee-aa85-08dc78b9a8b8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|376005|366007|1800799015|38070700009; x-microsoft-antispam-message-info: =?us-ascii?Q?ZKhY4vnEc+7auKBr6CRGOLSo4WZBHOaKT+W9HUXFvMLOXOCLNHnCMRf4spnu?= =?us-ascii?Q?WeKqpSWQMKk6tX4U/W2BiA+GHpdOKKCokhpvpmUwMV3hJLr6YFLV6SejOh4N?= =?us-ascii?Q?brV5Q5YLCU2klZ2WCQIY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fOnUiPZUnPOP3?= =?us-ascii?Q?7SId2l+JQaUqnaBL9Ups5DzPt9sEOagbRo/YDNNSPaPlc6w77JbUmYZ5YmT8?= =?us-ascii?Q?XdIVzkYtBzwxUPo9zemEg9Vfi+R1lqIwGSoShVuIxuHVasEv8ToCCA9KqI+U?= =?us-ascii?Q?CB2VxsXdW/mm4CSD02/AeSUyQbKiX6eabXcmiE5ZYSJHkpy3JiY8EWq08yfC?= =?us-ascii?Q?eQouZ4p0801cfTvnrqhqdrATMwdqDeVAg3jgAI5LtomNjhQ/HgZTjkj5aEPl?= =?us-ascii?Q?290UK1pp6sH4crgFYd+jObwFj6yOwEhFWcHGFZuc5gskHJuPz+RKnc8JF6xh?= =?us-ascii?Q?NTa4BvUjl5KABO+aUpLKt9UVdVCQfZ6FUCTHMEyrrwKvUg=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5055.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(366007)(1800799015)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?BOlTx/KQiBEVggqF7cZeSA7CJfl8QSrm9PceBg2nMeK76v6AK+N/6OzeSFr5?= =?us-ascii?Q?bafnGijs2TxhyFYVolPfN33WwJ+6zggINlwh3venoBAWBoqAlXLPimXZ6l9d?= =?us-ascii?Q?sZSbIlI8w9jFU0ardPlJ7EXrNBeN1J3UdZ8GnDbG7i01dcXmN6lMtFG1nHuj?= =?us-ascii?Q?MnR6AWhDknSmpZjbkvjYJ19Pp+9v6dbWCQcRGKNakwYkkryi0m7kuRlZoRsH?= =?us-ascii?Q?iTXQD5fW28GEqR5Te8iMQpIGHnGB7/DEigU1NTUIDC9rtdMMcwy1xvaQukDL?= =?us-ascii?Q?7wtose3M/XPGjXs3PthUZ3MLEzQrvpybwEehRUPWq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Q+v5JAaqOE3y2tbmhHO+J7toQXg/PuhQmsizGjRrGqWQ3d?= =?us-ascii?Q?GYzxqWnrAFdBZuucjZpctta1nBXXfGRJVBosUetF1BIY6mNaq3ErlVnPvFZK?= =?us-ascii?Q?nB9riZnvMgVdeFDojZ86sG8sHUrELSm1ttgF3N2KRAZ2m0WYLnZD1L81S5/7?= =?us-ascii?Q?iOG1xnwf3duPKKnSO4kzuD6Apy3cAyKlfVxW90DQ9kqRW/fOqxuP6QB7BMdy?= =?us-ascii?Q?QLC238RO35h6VOvXxux+q1v+R1FhOUuN9veWl1io1BhAVsJ3IJ5qd1yk20+i?= =?us-ascii?Q?WIdt6ug2iNM5xGR+NCxiJC4LK1J3dHCxu728nZDSS8Fgz2j3KOM46L6iuPqc?= =?us-ascii?Q?fzIVPsjdFd8hlXwR6WuesRsaXdfzEKIYuqEvrYqP?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5055.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ef00da4-fe7c-43ee-aa85-08dc78b9a8b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 May 2024 10:43:17.4219 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VFjkCVcPrfKAT/BLlB7euuVYsQUS2ft+w33PIZxSv90q6qeO3n1SzcmDQ25GBE4ENhce6zuT96gnTDQISdTNnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7607 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 [AMD Official Use Only - AMD Internal Distribution Only] Acked-by: Selwin Sebastian -----Original Message----- From: Ande, Venkat Kumar Sent: Tuesday, May 7, 2024 6:13 PM To: dev@dpdk.org Cc: Sebastian, Selwin ; Ande, Venkat Kumar Subject: [PATCH v2 22/25] net/axgbe: add support for Rx adaptation The existing implementation for non-Autonegotiation 10G speed modes does no= t enable RX adaptation in the Driver and FW. The RX Equalization settings (= AFE settings alone) are manually configured and the existing link-up sequen= ce in the driver does not perform rx adaptation process as mentioned in the= Synopsys databook. There's a customer request for 10G backplane mode witho= ut 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 ens= ure seamless RX Adaptation for 10G-SFI (LONG DAC) and 10G-KR without AN (CL= 72 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 b= y 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_com= mon.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_eth= dev.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 =3D 0, + AXGBE_MB_SUBCMD_RX_ADAP, /* 10GbE SFP subcommands */ AXGBE_MB_SUBCMD_ACTIVE =3D 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); stati= c 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_po= rt *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++ >=3D MAX_RX_ADAPT_RETRIES) { + pdata->rx_adapt_retries =3D 0; + return; + } + + axgbe_phy_perform_ratechange(pdata, + mode =3D=3D 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 =3D 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 PH= Y) */ + reg =3D 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_DISABL= E); + + /* Check if coefficient update command is set */ + if ((reg & XGBE_PMA_CFF_UPDT_MASK) !=3D 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 =3D XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); + reg =3D 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 =3D true; + pdata->mode_set =3D 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 =3D 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) !=3D 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++ >=3D MAX_RX_ADAPT_RETRIES) { + pdata->rx_adapt_retries =3D 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 axg= be_port *pdata, wait =3D 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 =3D=3D AXGBE_MB_SUBCMD_RX_ADAP && + (cmd =3D=3D AXGBE_MB_CMD_SET_10G_KR || cmd =3D=3D AXGBE_MB_CMD_= SET_10G_SFI)) { + PMD_DRV_LOG(NOTICE, "Enabling RX adaptation\n"); + pdata->mode_set =3D 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 R= RC cmds */ @@ -1296,6 +1401,31 @@ static void axgbe_phy_power_off(struct ax= gbe_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 =3D pdata->phy_data; + unsigned int ver; + + /* Rx-Adaptation is not supported on older platforms(< 0x30H) */ + ver =3D 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 =3D=3D AXGBE_PHY_REDRV_MODEL_4223 || + phy_data->redrv_model =3D=3D AXGBE_PHY_REDRV_MODEL_4227)) + return false; + + /* 10G KR mode with AN does not support Rx-Adaptation */ + if (mode =3D=3D AXGBE_MODE_KR && + phy_data->port_mode !=3D AXGBE_PORT_MODE_BACKPLANE_NO_AUTONEG) + return false; + + pdata->en_rx_adap =3D 1; + return true; +} + static void axgbe_phy_sfi_mode(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data =3D pdata->phy_data; @@ -1304,8 +14= 34,13 @@ static void axgbe_phy_sfi_mode(struct axgbe_port *pdata) /* 10G/SFI */ if (phy_data->sfp_cable !=3D AXGBE_SFP_CABLE_PASSIVE) { + pdata->en_rx_adap =3D 0; axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SET_10G_SF= I, AXGBE_MB_SUBCMD_ACT= IVE); + } else if ((phy_data->sfp_cable =3D=3D AXGBE_SFP_CABLE_PASSIVE) && + (enable_rx_adap(pdata, AXGBE_MODE_SFI))) { + axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SET_10G_SF= I, + AXGBE_MB_SUBCMD_RX_ADAP); } else { if (phy_data->sfp_cable_len <=3D 1) axgbe_phy_perform_ratechange(pdata, AXGBE_MB_CMD_SE= T_10G_SFI, @@ -1330,6 +1465,10 @@ static void axgbe_phy_kr_mode(struct axgb= e_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 =3D 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 =3D false; return 0; + } } /* Link status is latched low, so read once to clear @@ -1728,7 +18= 70,29 @@ static int axgbe_phy_link_status(struct axgbe_port *pdata, int *an= _restart) */ reg =3D XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); reg =3D 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 don= e, + * 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 =3D false; + axgbe_phy_set_mode(pdata, phy_data->cur_mode); + } + + /* check again for the link and adaptation status */ + reg =3D 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 =3D=3D AUTONEG_ENABLE && -- 2.34.1