From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0065.outbound.protection.outlook.com [104.47.34.65]) by dpdk.org (Postfix) with ESMTP id A35B6AABD for ; Fri, 9 Mar 2018 09:43:28 +0100 (CET) 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=xWDk6I4qcvCdYzBed0EXXHQPKX2dQl8U+0UmuDPPAEI=; b=vny170Vfo6TVfsqDO4UYey1KZiI+QpX4fC8Iraqsn8KHM6GgwViUluk+pXYqB3mdbVrMClbIV5uMa51bQqyspLpFkGNh8hc7SfmI4tgyND7ltRlzAdJb0rVERfm98G5S1gLz89tRVZG+Zgiy3yrVCHLkrIqx93LJF4SmzN0ekXA= Received: from wallaby-smavila.amd.com (202.56.249.162) by MWHPR12MB1517.namprd12.prod.outlook.com (2603:10b6:301:b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.12; Fri, 9 Mar 2018 08:43:26 +0000 From: Ravi Kumar To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 9 Mar 2018 03:42:33 -0500 Message-Id: <1520584954-130575-17-git-send-email-Ravi1.kumar@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520584954-130575-1-git-send-email-Ravi1.kumar@amd.com> References: <1515145938-97474-1-git-send-email-Ravi1.kumar@amd.com> <1520584954-130575-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: BM1PR0101CA0057.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::19) To MWHPR12MB1517.namprd12.prod.outlook.com (2603:10b6:301:b::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9a01f316-0a77-4388-3d44-08d58599d3d0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR12MB1517; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1517; 3:io2KAxcUFEhepQw8WGKSwv/resxSz0vo8sg22G0laomycQ9amM6nfIy9VG7Kh4wcCjFRlJCyL9q1oh6H8WWiHX+FfE/LurgOs59grcSjM32Z8ZRAyJaJLImk95Rkz+JKxas2zbwl8+pX7I7NKX20g4zf+Zl42bnGxisA+d+Sg1vPeDQCf5Pxf+fDfRi3nzrXRCxbqNXujF9GVhw28HtXO4TFwPcqTMzkePxwB2rLgNWJjLGY5qHVYfUnSW/OVhCR; 25:h+IjF7A7y9a3bLZ2iNRkeUccCBZhqUNHuuGExO/DuDDyiX+C4jWESbvBQ0BSbHK5i4JqLd8Uu2Yuo0UYNiFMbW1Ygn2siyxo1hqK8OiAHl9ThBjYEMGQkeBDXUB8RXgv5D4Gx/d/o+xgQgNn3oRPkfKXttkkbTzsnZVvSKD10PX3jbmmFbMsXJ7rzywn/2JqpW4vkV9Xu+/nO/jEq5hJFoueQPtQMXwPsAMctnfj6eHUHBb6EUZLicGuE16/ONNATG0vr33ajUzkoIud3Revvyh+cbo1ws/PiH8yH8YPKCfIb6d6D+WP+C7YGAB/pjkZ+heb+EWUflumTcvVIAAxlA==; 31:rnYunhxsjFIMwt3GI4vsX5+YGG/lqda4SCWQBJHh8KabrsKUDTNuv1PeJdtSyzYVVLF2lIgUtVXVVvK+eMoANoZXWrc5LHZsbGKPuGGr0KPHGzNx39+Zrl7Zly224cW7LVFs3Jsdh4Dni7S2rR8aX6ZEeJ/m10+Jk2/xftjyGLVf/FZdR8z7CVdWvWs6kmQOeLuA4aIIMlXXuv4MsctqWszwLn9DldHQChvNJfdaTyY= X-MS-TrafficTypeDiagnostic: MWHPR12MB1517: X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1517; 20:6Ga6l00opNRBDg+nWQmpuE1tFCu6w/ofnHxWg1CfDEXqtgvHMT4JlEuXDjTLHIDjzPwYsWY0D7+Zx+FglA7mD3j1LWLm5N43kOS40HNWfcVTKuHKq026reEDl1ynAVcUW2gZO2+VJ+uV8nCJsU6vcXfualA/Fc5GgRNdhKgFWO2Fur2eKygi4/ocs+NgDuYZr6PogITME65RCIwjS8qdjL69fLfpvX1rpq7m7wbpdlo2gSSmG+uaRE1GjtB8DqCbM6QIqRYx1a9HcTgkjZdAtwmE/kN/o5+Mq+psWpBgW7qCEzR9b6e8HtlZMSNAfZ173j7JQ/+RTnOlA/3wgkEPoSzvpqpos/MR0ife9iCbU6yvcXgbHldYSdvHUFblzt9IcIOo/hbVuh5IdDck6P9zw4Nz2WBaKLuj8qqmKIWcescdDxZwo5DwGf01s+Pzndj7qizPTY36atCqFMTTM4L4Q3X8HC8oe3bFL8P1a4ACfBj1NOcBVMETW8OoIBjq/WRZ; 4:yat3FzKY+xmjVRvd2oDTIAZrlz5f0HH/6XMdkmZSXBSFzTLqRppdOTsfeYs0wzTeUgg3s0Km0GOGtrzUP+kozdijoPIBbkhm1m5L11GoxrOsuLq1R8dr9UCpUii8ocFjfX0HhJAcfMWr2p6OkRyhlb/4vI3Fvlro/X6P9bhRkYBt+B7FHv1kPLlheA97iDQb2PduUczgqyJinH7w+FDk1mukd8YMTPWS2u7toXH1IP4JXuDd3H0eFXQLTPNV4uZvsgUYyWzI+j81asqpGsaG97M9Cq7qC0p4wdsdBnj/giEMmw39XdkBKZ0mdC3uP/rB 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)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231220)(944501244)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:MWHPR12MB1517; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1517; X-Forefront-PRVS: 0606BBEB39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(396003)(39860400002)(366004)(376002)(199004)(189003)(305945005)(50226002)(386003)(6346003)(26005)(36756003)(97736004)(25786009)(7736002)(50466002)(8936002)(4326008)(16586007)(86362001)(81156014)(81166006)(6666003)(2950100002)(6916009)(16526019)(186003)(5660300001)(59450400001)(316002)(8676002)(76176011)(52116002)(51416003)(7696005)(53416004)(48376002)(478600001)(106356001)(6116002)(3846002)(68736007)(2351001)(2906002)(6486002)(66066001)(47776003)(105586002)(72206003)(53936002)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1517; H:wallaby-smavila.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ravi1.Kumar@amd.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1517; 23:agoP7HJY9MJT806po1heRLnULQ6no448x6MKhP7mu?= =?us-ascii?Q?ODPsf/3Ime21tkn7jWcz3o0Gj4yzkRZxK3aRZHU8fzLYhGsT7QjCcITFBE5q?= =?us-ascii?Q?wQdlsWpcc17wpZjlaQH6RvycxFvM+PnFKwvHlL7Z+t+09w3pltMbCtnp/y/C?= =?us-ascii?Q?KLosbn/EIJIyR+VZ3ZSxUDYE8VMuJ4CLNbn1KH4Ujyrhw9Ptzu1ncE/KSYJV?= =?us-ascii?Q?9ynFo+GmyxuLCD0PDGxTdi9mcQcEQ+bUz453c78v7im2MXV3SFKz1tlf7JHP?= =?us-ascii?Q?7uUNpLtvtStemdnOOoTfoCWFC0hMwrQUFAPMK/LVH4W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Fin5QfCWRah5l6gD35pz1z/DDRqHuYMhgs+2Pnc6P2MKK9/l+dqnpE9kR5q3Df+Av3dRYACyvxrH04TTRLJBTiW35BdjLSpL4H9v/TtQLJLwdOzxVDT4cLo3g SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1517; 20:cmNITUmP4wDXZNiulst0tlZ8TkpgRfBvf8yw+h5c4obgAzNbXiVaLGPz9JkC0XPqslHAFk1fOTb1Dn6LxPHTTDM5IKDrvG1hDYnmsT3LC5EM+elKDVxfsw5QLhWVYbNHYzk1efKU6AzVDbNXiBVJNJE0z3pCT1IzBNvRpS4acZQT+YQVpj7MRuSs4V4T6yOG0I3JUZlf8LnJ4O7LAP4Ejg0yuNNHfzNjRdiYU7fFTznv57Db+bW2sfbbrlXBFT6O X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2018 08:43:26.3079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a01f316-0a77-4388-3d44-08d58599d3d0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1517 Subject: [dpdk-dev] [PATCH v3 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, 09 Mar 2018 08:43:29 -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 189139b..e1f3b45 100644 --- a/drivers/net/axgbe/axgbe_common.h +++ b/drivers/net/axgbe/axgbe_common.h @@ -1369,6 +1369,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 @@ -1416,6 +1420,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 d4d437a..ca21152 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -172,6 +172,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 = { @@ -183,6 +184,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 91260ca..4d5e6e5 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -459,6 +459,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 *); @@ -553,6 +557,7 @@ struct axgbe_version_data { unsigned int tx_tstamp_workaround; unsigned int ecc_support; unsigned int i2c_support; + unsigned int an_cdr_workaround; }; /* @@ -572,6 +577,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 07f4087..5f629f5 100644 --- a/drivers/net/axgbe/axgbe_mdio.c +++ b/drivers/net/axgbe/axgbe_mdio.c @@ -409,10 +409,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: @@ -429,6 +433,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: @@ -604,9 +611,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; } @@ -675,6 +682,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 5f69651..d9c7dc4 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -153,6 +153,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, @@ -359,6 +364,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); @@ -1888,6 +1897,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; @@ -1896,6 +1999,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); @@ -1916,6 +2022,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: @@ -2173,6 +2282,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) @@ -2193,4 +2304,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