From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0087.outbound.protection.outlook.com [104.47.32.87]) by dpdk.org (Postfix) with ESMTP id 1490C1CFC5 for ; Fri, 6 Apr 2018 14:37:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CcLSquEGvjZfS9wJTz+2Hic6TT11thV+JaW6BmtL3ro=; b=mqAD2nR9R+Z1fcujX7hTh6RVJ/oyZJ2DtDWpcMTQiuSQhTpEXXe2PGNLnu55aKHn9q8M0l6ymOo+lj18YKzXoAjh0xJoAxHZqkdyiutrYShvwSyQRSmZL+ry2VfheYie6KIeeXDDfJaG7z3kgJJ2hJTFq11PsdiA+2Vh3Il2LnE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ravi1.Kumar@amd.com; Received: from wallaby-smavila.amd.com (202.56.249.162) by CY4PR12MB1509.namprd12.prod.outlook.com (2603:10b6:910:8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.10; Fri, 6 Apr 2018 12:37:37 +0000 From: Ravi Kumar To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 6 Apr 2018 08:36:50 -0400 Message-Id: <1523018211-65765-17-git-send-email-Ravi1.kumar@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523018211-65765-1-git-send-email-Ravi1.kumar@amd.com> References: <1522910389-35530-1-git-send-email-Ravi1.kumar@amd.com> <1523018211-65765-1-git-send-email-Ravi1.kumar@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [202.56.249.162] X-ClientProxiedBy: MA1PR0101CA0013.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::23) To CY4PR12MB1509.namprd12.prod.outlook.com (2603:10b6:910:8::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4bb30189-73b0-4f20-d2f7-08d59bbb2ea3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR12MB1509; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 3:SlcXD/mMhtVYlBvk3iI3H8IeFIAdZapH4l42y5Va1Ieg0hnAyklDdjHl65gFfTwfOfxinJTZ1wNxdOIYl5Zw/Ijp/rOYMemvvCTu8HuQFBlIpKq+dHkPiAoWDsvxROvHHPOXxccL+cQ9XWwMYMvPJQ7H86fULToex8yOoNcLDEe8gGaxMjaN0jon5YLvhcwAvG9wPLZOo/6i3RKluj16wcIG/7VI3SRCnk+JY9TOQokITK0cGN1lsKSPeD8Hvmk0; 25:7uoAbaXYgHG9J1qaAHhyZr/DlH21qOgbAp3kuU9ZlXOf4mDVTykNGuczH6kx0T7KZKgbTDGIiJMmojq7ctl6xdq1k1AR3kOL8HZry8igFxCtUeK0ouZ7BxGDQ9mSucV436NHfmLtg61UgFy7X9dMcZ4tHrgV+YuCag/Pxbp8sFjWO0RQ4/YMb7UBykgZCGdKaRMyIpQ0bSrZyYzIkUC9GEVAaxmD+Ec3PAdG/6or6Q6dc07Ga8jvFBK7WL9MaLxCL2sWGzbzt1iefsIg7WZe7ZIC0gnI/zmdkGvUKh3v2zEaAp6hNqxC81r1GbCnIYvLLvNyVs9+2KbLkT0wYJDXvg==; 31:eTCgGOL/dMVsCMetRYZGraiXgU8ArRMHYrJ9YURJkI6NZhsN1niItPqOXZmggrCtA4wGWoOfJyL0+XCkQp4/FdtPXruSaQ7yck9G2FnZLvoX6UilE+Dtqp7wOkgHgnsWo38YrMJONJWEotBtjvHGDYrE8kLt7xoRbokKjuiy0So4NiraPrE0KrcLU18yyX56IcHQjChBd+o2Jlsu1x82MnezuMN3Ko0DkVXDqjGtlkQ= X-MS-TrafficTypeDiagnostic: CY4PR12MB1509: X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 20:vFYUufibut3gvL9tRtSP6jDFukSccOtujefWhG2ZbaZC0zPrAwG1J3ga4MpUJY53e3OCW3fvP7NVxCjlICskgYWl6M89Aznc7weleqCM9Io8EYP8pB0zSfZ8+IEymIMOSe/NdVTb7D+cSy0pCat6jvur08pGXv4blUzy4nLRJiBzajL6bC7jNPUVmpGJsX8Bwe/w8tLAKAhkIqWs6d6r8kituAtWJBZr0Fa2C4VLKnSF/bsHa/ntfxJg7e2Zwl4SmaEi/MVSJPvo46IRGcycsADepqqDlL3Ya1wQschoft3jxPtnmFeRA2OXisaGIDqaClHcKFEeg8k/FstAN6QdG7XVfcBBi73jo5CtkxVWqUTwb2kOBiviBxlmDr2ie51JutNG2a5UrZC8tNwx557tDF8dYQlS+ISPKIhLxbKBtwmEirmPRWuQ+nSBGM1T5bekoYJ4RL/mZfiSJFO3KMKg01bI8mheZCanRziw6y+cJZ70y+1aJ3rjK0kgi2xOWunb; 4:KWTE5VMu8Cl4piN76xuKaIcF/n05zPtbvAomOID8/pm2SIpYJySwVVG6Ak2jT0vgtkZqBE++I410VMPE2Of/YsIDY8jFCpP7Kazpv13hfXvVHSjDhGt6vGrHj47tPnP8C9KTsOQBe7ZGXOV1Fzf5eOPapDq9f+4D5JThHFzVF3WWGv3Y+Wgm6M41CRhmmkb/hZxJl/VjsSlmzWdPeXXfoi1Cj4nIAnZOenxiOT6asMnMp5fJdIAFvpILUpLplfHU2EuJ/9nyhJK4PVIH8NDPjvZvgBJPxkRmTr95zLH5EdNi54etEQhePOAuhANqrcQJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231221)(944501327)(52105095)(6055026)(6041310)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:CY4PR12MB1509; BCL:0; PCL:0; RULEID:; SRVR:CY4PR12MB1509; X-Forefront-PRVS: 0634F37BFF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(39860400002)(346002)(366004)(376002)(199004)(189003)(48376002)(72206003)(7696005)(105586002)(478600001)(6116002)(50466002)(3846002)(446003)(486006)(53936002)(11346002)(68736007)(2906002)(2616005)(51416003)(386003)(16526019)(186003)(26005)(76176011)(956004)(50226002)(16586007)(476003)(316002)(97736004)(305945005)(2351001)(2361001)(25786009)(7736002)(36756003)(59450400001)(5660300001)(52116002)(8676002)(6916009)(6666003)(47776003)(4326008)(6486002)(86362001)(53416004)(8936002)(66066001)(81166006)(81156014)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1509; H:wallaby-smavila.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR12MB1509; 23:GlXxpr9UgcLTmkMM0ArekiG22Dvp7OWKrV2R9y56h?= =?us-ascii?Q?GBZ3RIi02f8AKcUXKllG159kuniA6EveAe2C1+0aPYx/nU7RdDy1Y+TynkLw?= =?us-ascii?Q?0gGfk44LegUEB5rPN6WZkni3EqLS7UI7O2GSjhA+lP7BOQKpYmhJ0Z2A60cX?= =?us-ascii?Q?XIU/kgyrPBS7lbz280ytMj9/sz1T8OITeTZz1VAo9JVzw0Wt5uNlxVsVTWz4?= =?us-ascii?Q?4aCxkJSKD2IaJIjnmXyu1Gufy637PdwYchx3zIWVIlhDU5jFA0Fju058kRvb?= =?us-ascii?Q?k/VWhn95A+pKSZrxAalYHKXWfCdl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y5tUpem6XJi1/PaYpfm4t3/ZFATXhUrIQZZL3e29+gT1tvo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1509; 7:vBiLRntzCB3bzXG5IuUT/9i9rmV5uuopw9MSHslR+duiuqQcORXFb8+K4kZZf4eEIXX42qW7f/HV/xs7uq2ATvNulWuOGPK91/iVT7fz+aAibjkzSkeqdf9FepQbpT7MuQzCyBGIR/VP7SAoqffeEPBCwaiPxOUZgWDxYPEAPU/mIQ+KjCdw0PPpWDmPgsMxZ+cTRZChpOhstsABdfKV2NID3RMFU59Gr42XkhU2cJfcrwE8tFQpBCI205BTW7yt; 20:B21klsWrxDcgeMo3BMb0ElgoJainEZ/tNJYbcMCwOzLqxbUnM5vjXbnjZRw1k1yFPoGb9EDgfgAEQ+3zQsKP2CcLxtWakwXqFPyBxkBH3xOh92iG68t3tI7cKZmFwlrlacNAUUZJ48Q2a2zly6C5w1+NqPklr3k0AEIyVy7dK2NJavJOX3K75ZFg9RddKDO/6uRQXC0vLIqi1ql74gyNSnQaZGaRjuWgOhNhd5PfcAM75mfcvfyJiFNyY8EGGGEC X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2018 12:37:37.6783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bb30189-73b0-4f20-d2f7-08d59bbb2ea3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1509 Subject: [dpdk-dev] [PATCH v5 17/18] net/axgbe: add workaround for axgbe ethernet training bug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 12:37:41 -0000 Signed-off-by: Ravi Kumar --- drivers/net/axgbe/axgbe_common.h | 8 +++ drivers/net/axgbe/axgbe_ethdev.c | 2 + drivers/net/axgbe/axgbe_ethdev.h | 6 ++ drivers/net/axgbe/axgbe_mdio.c | 13 ++++- drivers/net/axgbe/axgbe_phy_impl.c | 117 +++++++++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+), 2 deletions(-) diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h index 64c7a7f..97a80f5 100644 --- a/drivers/net/axgbe/axgbe_common.h +++ b/drivers/net/axgbe/axgbe_common.h @@ -1247,6 +1247,10 @@ #define MDIO_VEND2_AN_STAT 0x8002 #endif +#ifndef MDIO_VEND2_PMA_CDR_CONTROL +#define MDIO_VEND2_PMA_CDR_CONTROL 0x8056 +#endif + #ifndef MDIO_CTRL1_SPEED1G #define MDIO_CTRL1_SPEED1G (MDIO_CTRL1_SPEED10G & ~BMCR_SPEED100) #endif @@ -1294,6 +1298,10 @@ #define AXGBE_AN_CL37_PCS_MODE_SGMII 0x04 #define AXGBE_AN_CL37_TX_CONFIG_MASK 0x08 +#define AXGBE_PMA_CDR_TRACK_EN_MASK 0x01 +#define AXGBE_PMA_CDR_TRACK_EN_OFF 0x00 +#define AXGBE_PMA_CDR_TRACK_EN_ON 0x01 + /*generic*/ #define __iomem diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 61a600c..096154c 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -50,6 +50,7 @@ static struct axgbe_version_data axgbe_v2a = { .tx_tstamp_workaround = 1, .ecc_support = 1, .i2c_support = 1, + .an_cdr_workaround = 1, }; static struct axgbe_version_data axgbe_v2b = { @@ -61,6 +62,7 @@ static struct axgbe_version_data axgbe_v2b = { .tx_tstamp_workaround = 1, .ecc_support = 1, .i2c_support = 1, + .an_cdr_workaround = 1, }; static const struct rte_eth_desc_lim rx_desc_lim = { diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h index 7bd2900..b1cd298 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -337,6 +337,10 @@ struct axgbe_phy_impl_if { /* Process results of auto-negotiation */ enum axgbe_mode (*an_outcome)(struct axgbe_port *); + /* Pre/Post auto-negotiation support */ + void (*an_pre)(struct axgbe_port *port); + void (*an_post)(struct axgbe_port *port); + /* Pre/Post KR training enablement support */ void (*kr_training_pre)(struct axgbe_port *); void (*kr_training_post)(struct axgbe_port *); @@ -431,6 +435,7 @@ struct axgbe_version_data { unsigned int tx_tstamp_workaround; unsigned int ecc_support; unsigned int i2c_support; + unsigned int an_cdr_workaround; }; /* @@ -450,6 +455,7 @@ struct axgbe_port { void *xprop_regs; /* AXGBE property registers */ void *xi2c_regs; /* AXGBE I2C CSRs */ + bool cdr_track_early; /* XPCS indirect addressing lock */ unsigned int xpcs_window_def_reg; unsigned int xpcs_window_sel_reg; diff --git a/drivers/net/axgbe/axgbe_mdio.c b/drivers/net/axgbe/axgbe_mdio.c index 2296de7..2721e5c 100644 --- a/drivers/net/axgbe/axgbe_mdio.c +++ b/drivers/net/axgbe/axgbe_mdio.c @@ -287,10 +287,14 @@ static void axgbe_an73_disable(struct axgbe_port *pdata) { axgbe_an73_set(pdata, false, false); axgbe_an73_disable_interrupts(pdata); + pdata->an_start = 0; } static void axgbe_an_restart(struct axgbe_port *pdata) { + if (pdata->phy_if.phy_impl.an_pre) + pdata->phy_if.phy_impl.an_pre(pdata); + switch (pdata->an_mode) { case AXGBE_AN_MODE_CL73: case AXGBE_AN_MODE_CL73_REDRV: @@ -307,6 +311,9 @@ static void axgbe_an_restart(struct axgbe_port *pdata) static void axgbe_an_disable(struct axgbe_port *pdata) { + if (pdata->phy_if.phy_impl.an_post) + pdata->phy_if.phy_impl.an_post(pdata); + switch (pdata->an_mode) { case AXGBE_AN_MODE_CL73: case AXGBE_AN_MODE_CL73_REDRV: @@ -482,9 +489,9 @@ static enum axgbe_an axgbe_an73_incompat_link(struct axgbe_port *pdata) return AXGBE_AN_NO_LINK; } - axgbe_an73_disable(pdata); + axgbe_an_disable(pdata); axgbe_switch_mode(pdata); - axgbe_an73_restart(pdata); + axgbe_an_restart(pdata); return AXGBE_AN_INCOMPAT_LINK; } @@ -553,6 +560,8 @@ static void axgbe_an73_state_machine(struct axgbe_port *pdata) pdata->kr_state = AXGBE_RX_BPA; pdata->kx_state = AXGBE_RX_BPA; pdata->an_start = 0; + if (pdata->phy_if.phy_impl.an_post) + pdata->phy_if.phy_impl.an_post(pdata); } if (cur_state != pdata->an_state) diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c index 19bd4be..dfa908d 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -31,6 +31,11 @@ /* Rate-change complete wait/retry count */ #define AXGBE_RATECHANGE_COUNT 500 +/* CDR delay values for KR support (in usec) */ +#define AXGBE_CDR_DELAY_INIT 10000 +#define AXGBE_CDR_DELAY_INC 10000 +#define AXGBE_CDR_DELAY_MAX 100000 + enum axgbe_port_mode { AXGBE_PORT_MODE_RSVD = 0, AXGBE_PORT_MODE_BACKPLANE, @@ -237,6 +242,10 @@ struct axgbe_phy_data { unsigned int redrv_addr; unsigned int redrv_lane; unsigned int redrv_model; + + /* KR AN support */ + unsigned int phy_cdr_notrack; + unsigned int phy_cdr_delay; }; static enum axgbe_an_mode axgbe_phy_an_mode(struct axgbe_port *pdata); @@ -1766,6 +1775,100 @@ static bool axgbe_phy_port_enabled(struct axgbe_port *pdata) return true; } +static void axgbe_phy_cdr_track(struct axgbe_port *pdata) +{ + struct axgbe_phy_data *phy_data = pdata->phy_data; + + if (!pdata->vdata->an_cdr_workaround) + return; + + if (!phy_data->phy_cdr_notrack) + return; + + rte_delay_us(phy_data->phy_cdr_delay + 400); + + XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, + AXGBE_PMA_CDR_TRACK_EN_MASK, + AXGBE_PMA_CDR_TRACK_EN_ON); + + phy_data->phy_cdr_notrack = 0; +} + +static void axgbe_phy_cdr_notrack(struct axgbe_port *pdata) +{ + struct axgbe_phy_data *phy_data = pdata->phy_data; + + if (!pdata->vdata->an_cdr_workaround) + return; + + if (phy_data->phy_cdr_notrack) + return; + + XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_CDR_CONTROL, + AXGBE_PMA_CDR_TRACK_EN_MASK, + AXGBE_PMA_CDR_TRACK_EN_OFF); + + axgbe_phy_rrc(pdata); + + phy_data->phy_cdr_notrack = 1; +} + +static void axgbe_phy_kr_training_post(struct axgbe_port *pdata) +{ + if (!pdata->cdr_track_early) + axgbe_phy_cdr_track(pdata); +} + +static void axgbe_phy_kr_training_pre(struct axgbe_port *pdata) +{ + if (pdata->cdr_track_early) + axgbe_phy_cdr_track(pdata); +} + +static void axgbe_phy_an_post(struct axgbe_port *pdata) +{ + struct axgbe_phy_data *phy_data = pdata->phy_data; + + switch (pdata->an_mode) { + case AXGBE_AN_MODE_CL73: + case AXGBE_AN_MODE_CL73_REDRV: + if (phy_data->cur_mode != AXGBE_MODE_KR) + break; + + axgbe_phy_cdr_track(pdata); + + switch (pdata->an_result) { + case AXGBE_AN_READY: + case AXGBE_AN_COMPLETE: + break; + default: + if (phy_data->phy_cdr_delay < AXGBE_CDR_DELAY_MAX) + phy_data->phy_cdr_delay += AXGBE_CDR_DELAY_INC; + break; + } + break; + default: + break; + } +} + +static void axgbe_phy_an_pre(struct axgbe_port *pdata) +{ + struct axgbe_phy_data *phy_data = pdata->phy_data; + + switch (pdata->an_mode) { + case AXGBE_AN_MODE_CL73: + case AXGBE_AN_MODE_CL73_REDRV: + if (phy_data->cur_mode != AXGBE_MODE_KR) + break; + + axgbe_phy_cdr_notrack(pdata); + break; + default: + break; + } +} + static void axgbe_phy_stop(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; @@ -1774,6 +1877,9 @@ static void axgbe_phy_stop(struct axgbe_port *pdata) axgbe_phy_sfp_reset(phy_data); axgbe_phy_sfp_mod_absent(pdata); + /* Reset CDR support */ + axgbe_phy_cdr_track(pdata); + /* Power off the PHY */ axgbe_phy_power_off(pdata); @@ -1794,6 +1900,9 @@ static int axgbe_phy_start(struct axgbe_port *pdata) /* Start in highest supported mode */ axgbe_phy_set_mode(pdata, phy_data->start_mode); + /* Reset CDR support */ + axgbe_phy_cdr_track(pdata); + /* After starting the I2C controller, we can check for an SFP */ switch (phy_data->port_mode) { case AXGBE_PORT_MODE_SFP: @@ -2051,6 +2160,8 @@ static int axgbe_phy_init(struct axgbe_port *pdata) return -EINVAL; } } + + phy_data->phy_cdr_delay = AXGBE_CDR_DELAY_INIT; return 0; } void axgbe_init_function_ptrs_phy_v2(struct axgbe_phy_if *phy_if) @@ -2071,4 +2182,10 @@ void axgbe_init_function_ptrs_phy_v2(struct axgbe_phy_if *phy_if) phy_impl->an_config = axgbe_phy_an_config; phy_impl->an_advertising = axgbe_phy_an_advertising; phy_impl->an_outcome = axgbe_phy_an_outcome; + + phy_impl->an_pre = axgbe_phy_an_pre; + phy_impl->an_post = axgbe_phy_an_post; + + phy_impl->kr_training_pre = axgbe_phy_kr_training_pre; + phy_impl->kr_training_post = axgbe_phy_kr_training_post; } -- 2.7.4