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 6987AA0093; Mon, 7 Mar 2022 23:33:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 086AA41238; Mon, 7 Mar 2022 23:33:57 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2107.outbound.protection.outlook.com [40.107.21.107]) by mails.dpdk.org (Postfix) with ESMTP id C0D2A4122E for ; Mon, 7 Mar 2022 23:33:53 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YcZJPnm4Lo4Mrt9lIg4UiRVufAIyY9mF1+GEAIRNuzj8FmlO0ft0DIdN3qMU/lSP8H2CuB9mVGaIkTWg1YOYr5Wk9FsGW7gC1hqzWzopPHXWINKXspwhJ7zXAXcKetgN6bqUjElDl+uY5H/OYWf2V7HLJfUsO+Ohi21x/HX87BJJmwp7WlxjF5ksypGIEwRanGDXX+kp7kBN49sLNZ8QghbeFaL12G8hHLKQu2FeDJscdtjr+y4VMAQSMqSOTa2YHWvXSdj9fxnnXE0X7NjzHlcVOwwawZIXecpPVAcxDsdFAh+pOOMALsb3cM/j11yd+8+tRtvGD5PPl75xhzdtYQ== 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=P2j9asUeugT1I5g6qXvriswhWcLFP95jVPq8T8ru6D8=; b=GoLHxP7Ra8DSZSHUoxBFxWvxnjqkNIybLWTW/pxepaKRJIuTK3KJrwn8xOvoebVHNvPsnx6KvCkUDDyxL4fy8YZYQO5HTl0NfPXgozF+z2S3Nt7A4tTc4Wlo4mqywXAat2upCz1z7Tb6kpj83FXKZ5wgLUT0uCtk9Uweu4uussbRm45ceqFyhn7B7W8923NTuc4fD7HnIwLSzzD4DHBr7X57eoWT2LHgH20h9vDKWiN57Zoi8EgBIYKdM9j+AcZo0F24/yjy+Z04dXv2LviC/MmKuvm8Os5QLqExXgDBTk7gQNe4D+Bs+AWzWAGereTKm1d1MAh3t17G7uFA/23GIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silicom-usa.com; dmarc=pass action=none header.from=silicom-usa.com; dkim=pass header.d=silicom-usa.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=SILICOMLTD.onmicrosoft.com; s=selector2-SILICOMLTD-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P2j9asUeugT1I5g6qXvriswhWcLFP95jVPq8T8ru6D8=; b=Tn1GeDVnqW7jUDq/wBZf/gVW2TTCeZ7S6nJdstpLf0q4Q+47gMtprWFwcV8fjytyvy8GCAigvwX+SgNm3TtwwRcBg52FMBoI3ZzMTp7p12u+wny06EZ5+K4u1V+r/FnWSwhrlAXeSVwMV+qZliC0U6ZF6asRb4+l1CiJSa+4jYg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silicom-usa.com; Received: from VI1PR0402MB3517.eurprd04.prod.outlook.com (2603:10a6:803:b::16) by AM0PR04MB6819.eurprd04.prod.outlook.com (2603:10a6:208:17f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.16; Mon, 7 Mar 2022 22:33:52 +0000 Received: from VI1PR0402MB3517.eurprd04.prod.outlook.com ([fe80::a0f5:7a14:c41a:7d62]) by VI1PR0402MB3517.eurprd04.prod.outlook.com ([fe80::a0f5:7a14:c41a:7d62%3]) with mapi id 15.20.5038.027; Mon, 7 Mar 2022 22:33:52 +0000 From: jeffd@silicom-usa.com To: dev@dpdk.org Cc: Stephen Douthit , Jeff Daly , Haiyue Wang Subject: [PATCH] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs Date: Mon, 7 Mar 2022 17:33:37 -0500 Message-Id: <20220307223337.27876-1-jeffd@silicom-usa.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BN6PR14CA0023.namprd14.prod.outlook.com (2603:10b6:404:79::33) To VI1PR0402MB3517.eurprd04.prod.outlook.com (2603:10a6:803:b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1115d7a7-05d7-4710-5aa6-08da008a8e3c X-MS-TrafficTypeDiagnostic: AM0PR04MB6819:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OUVmjWb+DYHW/Axtzy9uIWytYgyt1pi6Vhaff0Kfq9whJhaXHpkbLpU8/AUCGrnr81NqwDqSxm2n5dpl/WAB9sDP5a/Z1BV/Ek4XSpE4rDaFSQLRtlXcnaLU9dnggmaJ7ij0TBaAYdOSXnyFbBxdciLiq+Gn0EUTfKZsJjCYTBZsLGDKjmpkz+Awvtv5B0ABKNDBbE0Yob7FI3Bpf5cM0b5FHaL97IUCvDhBmb+BhHiS0h5sEBk1Xg34l2a2aDGhGynB5AJ3UhyP96PmwPK2zL5jWhQYo1Qn1Dodnlrm3JXVDIMViOrG18yiILNGD0M1GOpN/6nDsPEUmvUbLc5H98KXskDGUp4Qdqre7x4ZY0gmpnu2f5VTIpX3hT7N9uKSXKl8VDAEzUNjf3JZSSIwVqIuHoCfYW4MU9OtLpBWfpyr6sYNfeO/RqY3+nSCR0SeUZsfWnh6F1TJ7ay8yODmGy3cobFIJJR7E/9PuFF377FUQclZRHIFFfONkkwk7FpGDgSpCbocE3BX3Uz4nUkauoRbNLIH6yJPaRCgH4VqZ7GOzKXJe6us53fLd18EY6hJ33dC/gqj0YE5rJ9hilfksgvd7VDMAQMKh41WGK+VMW0I9DUMUXJSaxdAAf8jJW7if1brCi4qFGvqSvTYnkTiy8s+ZCY28UIlvWT0v+6aMkq/kqy3oCCpBE8mk7ASZw9ynwjLIIgtbLLdJt4gGhW/5A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3517.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(86362001)(8936002)(6512007)(6506007)(6486002)(6666004)(9686003)(5660300002)(6916009)(316002)(36756003)(52116002)(2906002)(38350700002)(1076003)(4326008)(186003)(8676002)(2616005)(83380400001)(508600001)(54906003)(66556008)(66476007)(66946007)(26005)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?PhGJJmKbAlIiZVOoM+JLsyfXleBvLQ2rJbIwcj3GwnsmYfB+B+e4ybHSn+tf?= =?us-ascii?Q?IU+8zzLoSYoqh1LuXEzfxLYopr7KeT/0c3XJQn+lO0DJyxmlVwVzOiJC6c0C?= =?us-ascii?Q?aXnAGHBsaSFUaGXY6HF5Ibj5wAHVJQcWP7HKpkDpkESSTBJQ0rg3fnadPqV7?= =?us-ascii?Q?0NtC9LE7d0Yii8mWn13PBJWsWrHmNEPDX5XpsDQi6hWIiormHXGzbNEo4nWf?= =?us-ascii?Q?3Ew6JxcR7M9BTPqIRN/ES8yFsh3ivhJTs9/qw+qhoy5PuR7W3BqN1MCIQt4q?= =?us-ascii?Q?Lz4GBMOxX8b9e3a5AGEXqBb0PUeE72A54A9XkfMiFV9NZdu7ofDsYVrkstAJ?= =?us-ascii?Q?StC05JsW/aoeFPhRSAnc7zszM9sl1HS3jlZeXCusZKpHIuLx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Lql1YhxFYKmsiLqbe3Qxd32qqF4Ni5X5vt4Ow?= =?us-ascii?Q?IrAB+e85MSfD87ZpQKiOVnFxacBVeriJ2+4caYPeq8SV10Y96yP81int3Qxf?= =?us-ascii?Q?WxHnRTkRplxEL1k/sjcVRmSHIRAGx6azNnNfVlJ9M6pJ1amQwpBOG9V83U5U?= =?us-ascii?Q?YzulmTyUIwG5YaWE/pbCP0p4XAO8d90qCslOe1qCEZb5L3GcVYOYtN5WefkQ?= =?us-ascii?Q?6ZafOiH/GeKt+CWVMWDDENSXTRweGFjEE24ejQ/3V3WTjQvh2igA/R3ZwzAq?= =?us-ascii?Q?5YXYsXSWZvYmZGuUJA/Mb3yyhDIzajKo3Uqfpm4GwEMgwx+Cuda+LZkSKvqq?= =?us-ascii?Q?Eg=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1115d7a7-05d7-4710-5aa6-08da008a8e3c X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3517.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2022 22:33:52.3621 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: c9e326d8-ce47-4930-8612-cc99d3c87ad1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uYiQUEulhiijFUybl51stQd9KECjT2xeBPHT0JsmkVbKd5AVmASWh8UeRckOQl8Y90NCM+0ZNKM8MUsoAeMAAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6819 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 From: Stephen Douthit Some XGS-PON SFPs have been observed ACKing I2C reads and returning uninitialized garbage while their uC boots. This can lead to the SFP ID code marking an otherwise working SFP module as unsupported if a bogus ID value is read while its internal PHY/microcontroller is still booting. Retry the ID read several times looking not just for NAK, but also for a valid ID field. Since the device isn't NAKing the trasanction the existing longer retry code in ixgbe_read_i2c_byte_generic_int() doesn't apply here. Signed-off-by: Stephen Douthit Signed-off-by: Jeff Daly --- drivers/net/ixgbe/base/ixgbe_phy.c | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c b/drivers/net/ixgbe/base/ixgbe_phy.c index d8d51d2c3f..27bce066a1 100644 --- a/drivers/net/ixgbe/base/ixgbe_phy.c +++ b/drivers/net/ixgbe/base/ixgbe_phy.c @@ -1275,6 +1275,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) u8 cable_tech = 0; u8 cable_spec = 0; u16 enforce_sfp = 0; + u8 id_reads; DEBUGFUNC("ixgbe_identify_sfp_module_generic"); @@ -1287,12 +1288,34 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) /* LAN ID is needed for I2C access */ hw->mac.ops.set_lan_id(hw); - status = hw->phy.ops.read_i2c_eeprom(hw, - IXGBE_SFF_IDENTIFIER, - &identifier); + /* Need to check this a couple of times for a sane value. + * + * SFPs that have a uC slaved to the I2C bus (vs. a dumb EEPROM) can be + * poorly designed such that they will ACK I2C reads and return + * whatever bogus data is in the SRAM (or whatever is backing the target + * device) before things are truly initialized. + * + * In a perfect world devices would NAK I2C requests until they were + * sane, but here we are. + * + * Give such devices a couple tries to get their act together before + * marking the device as unsupported. + */ + for (id_reads = 0; id_reads < 5; id_reads++) { + status = hw->phy.ops.read_i2c_eeprom(hw, + IXGBE_SFF_IDENTIFIER, + &identifier); - if (status != IXGBE_SUCCESS) + DEBUGOUT("status %d, id %d\n", status, identifier); + if (!status && + identifier == IXGBE_SFF_IDENTIFIER_SFP) + break; + } + + if (status != IXGBE_SUCCESS) { + DEBUGOUT("Failed SFF ID read (%d attempts)\n", id_reads); goto err_read_i2c_eeprom; + } if (identifier != IXGBE_SFF_IDENTIFIER_SFP) { hw->phy.type = ixgbe_phy_sfp_unsupported; -- 2.25.1