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 5788DA0C41; Fri, 3 Dec 2021 23:56:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C3754274C; Fri, 3 Dec 2021 23:56:07 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2127.outbound.protection.outlook.com [40.107.21.127]) by mails.dpdk.org (Postfix) with ESMTP id CDB4D410DC for ; Fri, 3 Dec 2021 23:56:00 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W7SR7FrPc2Kd4JWEzSoJSyfcma+CWzIOc9o4KgEUC60OBWBc1WtexMCqbwrCUnJ6zP8S0Gdh0f4JzW4OTGQytB+zUjdRWqw5/rJFrY4SHyZ9RU0yqgxTEzRmchs1URilJqNdutgCQW5rUc2ulL5t3FZT2kTcajjs/5lMW+kq1QSgcGf4okFcXhg6Wq4XKx6rthj60Y+sUviOny9zD5re4LKjcp2YDEFMjxsM9aL5WeiZKSESd/NKn5CHujQQsrKiu5ln6v5SqFZPXKmIE/xmRtZFCeRSmvIIT7deoeRcbHCPEXfraweP00IgN7Qf+fQJ3n5yZF+xqbZTyY7sNdn2ag== 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=+cygPwvzvwBIhArNeOm/AlwWOV4zV9Ta/anCCBEjUFY=; b=MlH+OHyhhgz2e7Pkou+Dcr8h7qjD1JmB7dX4s8/czlxcl5GKy2AZFyUzvlnSaQPLE4zZzMPgp5Pfmdj+2BdLdzh7+yQgboFRk0v+7C4z1Ycee1E3QeQqVCDEwrKpu6Pnp5mI7YFEDs3t5WpvZ3ALv/uOgCOj5M39GTVcNeUgq4TxURXZUXq3W2Wv3ZYrIZbMGpTL02UsJL6TMn5kVX7lwgpFW0lhgkh332KXdKh/lmETu7HCdm4HIfbMmOqMPpCczfCCSjsFhz0PLtI2sA8bbBk2i3HiJPokY7m0R9EiaIh/90fxpQt8v8vMvsQcJrnaiZsg0n3s+1kSbX6gaY8P/A== 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=+cygPwvzvwBIhArNeOm/AlwWOV4zV9Ta/anCCBEjUFY=; b=iNRCyRu+rEqbNaBR07LqThG2kMIXqj1xyy97go8jkNi+GkmaTq1ryqfg19Ioe5TASjwh1DOXKut3V8A6lrBNDFGFYE/pWvyaeiSdCt5fP63VNCMFJ6NplMZclewKt5n//ASs8T4NCEb4coAQDxy+LY133DPJMWvSEaVjZA23Cq8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silicom-usa.com; Received: from AM0PR04MB4083.eurprd04.prod.outlook.com (2603:10a6:208:64::29) by AM0PR04MB6404.eurprd04.prod.outlook.com (2603:10a6:208:178::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Fri, 3 Dec 2021 22:56:00 +0000 Received: from AM0PR04MB4083.eurprd04.prod.outlook.com ([fe80::f4db:d40d:a746:7bfc]) by AM0PR04MB4083.eurprd04.prod.outlook.com ([fe80::f4db:d40d:a746:7bfc%7]) with mapi id 15.20.4755.019; Fri, 3 Dec 2021 22:56:00 +0000 From: Stephen Douthit To: dev@dpdk.org Cc: wenw@silicom-usa.com, Stephen Douthit , Haiyue Wang Subject: [PATCH 6/7] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs Date: Fri, 3 Dec 2021 17:55:15 -0500 Message-Id: <20211203225516.571368-7-stephend@silicom-usa.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203225516.571368-1-stephend@silicom-usa.com> References: <20211203225516.571368-1-stephend@silicom-usa.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BL1PR13CA0431.namprd13.prod.outlook.com (2603:10b6:208:2c3::16) To AM0PR04MB4083.eurprd04.prod.outlook.com (2603:10a6:208:64::29) MIME-Version: 1.0 Received: from lappy.adi.eng (173.14.114.227) by BL1PR13CA0431.namprd13.prod.outlook.com (2603:10b6:208:2c3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.10 via Frontend Transport; Fri, 3 Dec 2021 22:55:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2cd8edc4-76be-4b4e-90ad-08d9b6b0130d X-MS-TrafficTypeDiagnostic: AM0PR04MB6404: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xj/NaJmJY/tNTIRIDK1S18amRqwI9kxD+TptApZFyJeExzo4oEq+ktUWBufuWvawtRUhPryE5u1LXwWp22ddCNXjyUiQ0nX+SQrp1a4D4SQbO7whHy5uv8ZgVRicbrH5GafjJV1n5cdGq4GVeRwguh2n25of62xNJWb8MmjDhrALOJvEgamGZaY3u8JwG9cDna45rpBVyg01oH2iG4V7dpaYCBwFz2cj5zK2rcoqbsaWQ5g1eMequd227KAZ/z9Nl95tRlMqTAOj/6YMc7AV43h8PhqN0H804kXZRyHgRgzvYZfg7QhZsHQ2iD5d3NXpFLlQfL1XUTJFX9JjZnKS7flRpnxSbglFZPlAG9LCUKLPYqi6E6iCAjvMxrMw358uIHKJmWjEKFCE0uTehme6FswPOQYhom6EqLQUrswGzRu4SJf+vrUdpAWKazfVP29QpnoY5dX2Udcttb8xQKlqVo2334+xpgPMK2QG0jY7kCYAKpRxg3iVzsPWrbN+x6zOQiHZUoTubYT/5nYT+dSwbYmqe80ia6v4F9VhnkwxGXsfwYYqgh115zJGQqxa3J3Pn6+nMFwoJWHPhjrLWenVxgTW1P8pTpR+4Ov01oey9XEUROoZn/X5yUmcRHpf4t/aH+u/CJAjevfO6V1kqX3x/dw0AWX/BbnX7vjmxmWoegEVEY3Qh1CO/Jz/2QIcVkK7PEtraqgehjJCbVE6dLAwPg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB4083.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(2906002)(508600001)(6916009)(8676002)(6486002)(26005)(956004)(83380400001)(316002)(1076003)(36756003)(5660300002)(86362001)(186003)(4326008)(66946007)(2616005)(38100700002)(38350700002)(6506007)(66556008)(52116002)(66476007)(6666004)(6512007)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KImqoMqEmH1NtYfHWMFR45b57s279NqtpL51nqDnxi6wH1F/KaMeIiz9CKIK?= =?us-ascii?Q?qwB2SKVCNOApzLLMBhpC991RViqJ4qBbXllIqfwK/TqelFWdbg7WcBFUh3Ad?= =?us-ascii?Q?IH15QU7pOIUKjMdyVAt18WgWdwcui61U2a5fZIZeUBd/s8qGF24fAo8NLU4T?= =?us-ascii?Q?3JAJykU0HWk/uO6bxnsYYbFeEeH3PKdWxPk6BAnR/IIdQHDq+dk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dcxdLe7QqwBU5K/ZU2/iVTOKqlp+auo3ag?= =?us-ascii?Q?rbZ6rhuymFcNvZ8EA3HCx3sLppLaFMxFqsh9+5izzvFKH48RafbUVmq8x+6s?= =?us-ascii?Q?yJ0Rors/59DHu2GBbGQTQpFCbrJOJZnAouYwiZ/ksa1BTMAlIT1FM1Jr1my0?= =?us-ascii?Q?vXx2BRqOqr37LRA/j9jsNXrO7BFZUVmRDBDQpq7Cx+eX1UH1hnWmuCuU5CLg?= =?us-ascii?Q?EZLLaBkYDq2WjisFAl3zIT2jbeYdqLC6TBNOCFCVnu5+vInADslzhvaMA+eS?= =?us-ascii?Q?NLyKuceKL41bkGtzSr/i4Z0GuK0Pcyasqa/rUNdjdyViFLg/8hXmcoSNiMUC?= =?us-ascii?Q?ELiWld8UZD8hGl3/vzf7vGqlqT9cGl0t2seR4iJc41zyz4FVSeY3coasNfUZ?= =?us-ascii?Q?73vT/A0xF2w4ZVp7A65ANTC97JNn3Wfcb0s108NT+bGBh6P2GB/AWe2WMmro?= =?us-ascii?Q?xa1TjWdtoqIPfiLsusrSVTegpCCMSCzEEriWrTjA3hUEpwXEVPjAiXGsUXOH?= =?us-ascii?Q?/+4BSQGf6bOrAbfbRXdZLcVZ4ZTjzqTC4+MMKpXWQ+KvFpOJuy2byGKWHPJR?= =?us-ascii?Q?e3/cKS0Lknff3btVSu6AYN1j9TE=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cd8edc4-76be-4b4e-90ad-08d9b6b0130d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4083.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 22:56:00.0930 (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: ZZn+hmB0bP5R/5fbwMcumCpOUylvKGaflcIAwAR/3qLnQD0wzrSMD9AbYpaSV88EN1slq7NsaLv/rBlHkv0MXup2QEMxDMiA3MwvVAaCoRA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6404 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 Some XGS-PON SFPs have been observed ACKing I2C reads and return 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 it's 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 trasaction the existing longer retry code in ixgbe_read_i2c_byte_generic_int() doesn't apply here. Signed-off-by: Stephen Douthit --- 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..429b2b4142 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 slave + * device) before things are truely 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.31.1