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 220F0A0506; Wed, 23 Mar 2022 21:04:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B440540DF7; Wed, 23 Mar 2022 21:04:06 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2097.outbound.protection.outlook.com [40.107.20.97]) by mails.dpdk.org (Postfix) with ESMTP id 3BAA14068A for ; Wed, 23 Mar 2022 21:04:06 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VMUV2FWB3Ak7OkDvzDiv6YLLnpY7kG1MIlG+emBPtERDOcVzgmnFK7F6YIgw0/F+os+AQjeJwm6T6gFNzZcnn/MTXAQG/wwBZWJBENWJLaNojW3po56UvcehNdJwFvHGJFSD91p7y9dSbiLbIog8LaHhE6TGl3Gz62nHoIbrocdfC5kZNfqn9tqYbac2DDR+TfRMLwuABd0yobfKS80F22m7KH/83FbrD0AR6mVQOA9Lrbvry4jaxiglauC2eHGFtk+nGdV4fmXhJvrKKmVujDIeaZgxHDQh7eG/u5d8B43EyzEuCwR3JWpu3fyOeLLJgyFtFF61j5oM4HDstRy7ZA== 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=TRrbR+WnG/dq5T7zq1dBr5t4SIZ+/f3YjmkQIetDq3s=; b=ofIFuKoKUflKf0ttvccJNByGvKZm1SfAy37ayYsprkCAHpFtLAslukfe8rbYGozgPNTXbpY1YJleqVkvKV9/llDyKpjPKpUj68LjZ9SBDDo+WZqx3JFp44swYY57FOiM6PMPTpnqp1fC3idHcUfKfu6+RMd9leavphtVyl+NYqPDq0g7h4m3aLvycEBKOCFGYxKu2Bos77tf8YIlGiSLFygNRXXTtLBilM7kmynhrNQjfwE2ApIsYihRMsyqGQbliiv0QwxSOkmG5B+BA9EtGLws7ZoC5t8GSRAofjDJX/OCgqimGy8hke2UUMWS9bH6qWYLSZXzval7z9KVt3xHYQ== 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=TRrbR+WnG/dq5T7zq1dBr5t4SIZ+/f3YjmkQIetDq3s=; b=szXN5wC8Iyj4G5AFoSyejlOn9LJJtXCTjBuxYq40gkKfaSK9ykjFMHYyJLw9gM7yV7oIbF+f9hjXRJsOXrEPNHmQRIxvZjMyv++hgVhJeeYThiLVBuwA+cDus49Wj3c9Vc92Nc9YOvYzYbCG/L4YbH7X58f2lQCNnytXJ4jMxBM= 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 AS8PR04MB9045.eurprd04.prod.outlook.com (2603:10a6:20b:440::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Wed, 23 Mar 2022 20:04:04 +0000 Received: from VI1PR0402MB3517.eurprd04.prod.outlook.com ([fe80::f069:df76:7697:8a71]) by VI1PR0402MB3517.eurprd04.prod.outlook.com ([fe80::f069:df76:7697:8a71%6]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 20:04:04 +0000 From: jeffd@silicom-usa.com To: dev@dpdk.org Cc: Stephen Douthit , Jeff Daly , Haiyue Wang Subject: [PATCH v3] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs Date: Wed, 23 Mar 2022 16:03:46 -0400 Message-Id: <20220323200346.22318-1-jeffd@silicom-usa.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307223337.27876-1-jeffd@silicom-usa.com> References: <20220307223337.27876-1-jeffd@silicom-usa.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BN7PR02CA0007.namprd02.prod.outlook.com (2603:10b6:408:20::20) 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: 859c05d0-3b63-402b-f52b-08da0d084796 X-MS-TrafficTypeDiagnostic: AS8PR04MB9045: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: Hcim3QV37l+HWlRmSetlb8Ji8J4/DSBerbUN26/6kn4T5ZZEsLzf3H/xqPOrocqU0usYFLtXESn2gDU2I2nfmuN/K7yV94KXxgSO/c3iAhi/setNXBmfLN+dKZbH7gtnT2AaaOM370Bdv1ImX3SQjhyHFsqkoftTlCp++EVsc2S0Cl6EGyu8uucGGkqRatyZo38elsHo0S3dAsTfc7ybP5tPjigiXtoyFhVbu5AfTxs8e0xPhEtmuLX2UsAZsq7AdNBAJi6pwmmzH1/lQto1RalU0y/f5ixmPjmpnzF1QLgETNh/jpMFmdeojRv+w4mu4wzMl9HBhNu1iB5Wxq+BmT8oN9+xrVCnCLeklf6hNqAIBcSDBXYuCav900QE7vusgRewDrhMXiaenAOH9I2L6wH9bsF+OZnL12q36PzOkPp0sOaEE/6SjhuW/4UrUoNUTknSwiO2H44ompk+4aq6xxbQ95iCWJJwcGkAkhbuc5QloYSIOArE5NqshonYXZTsslEZCgnDZcZKjeRsm9XppLkO7KOhhz/QsAegkHikexHT1erJDJLXwRB2Z/COsrTdyeQh4Sp1HyOdkTuvLeR9k7Ss6NT1os3eRSvLM5fG5hELqB4kouvOL7bFK2Xscue6fUfS87qbuV2KysL6GuahPQV3h3gv1oprzy7BQFmOwWHedFfW24BtkxFskF0zRV+NmR6kOys+AZ7lMdTPTFPWkg== 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)(66946007)(36756003)(66556008)(316002)(83380400001)(66476007)(6916009)(54906003)(5660300002)(8676002)(26005)(52116002)(1076003)(2616005)(9686003)(6512007)(6506007)(6666004)(6486002)(8936002)(186003)(38350700002)(2906002)(38100700002)(508600001)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?kov2c/GtBGVxL5KusuEPFIKVI9EGPyubGCy/1O6poOtwM+t+YAaHo3FxBPMc?= =?us-ascii?Q?+AWC9g5wvPlQUInOkb2joyEVivT4/v39DkHszVYOTkOkfOnQ34FE5cWrPQrE?= =?us-ascii?Q?MDdcs/6TjyKBf/2iLcduK0ZweazbiyWSHDE9X86j88q/cypCcW+xJ9X+MyGP?= =?us-ascii?Q?lpEPPUPBIZIQgOWmxwUZgzMkHc8rr0Yhc+8tROJq8ZAZm0jd49pYS1PmFzWL?= =?us-ascii?Q?BbgRsDj+DsH7xnX1+O2a6/QT3mFQIxkMqAATEDIsqot9whtqT5kKpgYP6SJw?= =?us-ascii?Q?Ussc2G/tJnckNqS6exCP15TOu03AL3Yyrcs0CWW6GLrK7C9DHKVoTFySQ7bS?= =?us-ascii?Q?JJb0PaX4BjMujcVzzSv9ZYh9d0NgTZISmiWyI+RyvyX7DHSJpCwG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1Xrcr15h5qcXK/ByB56Zgm8JuP/Qyo1/NNGEVWDSIV3hf7RwcJ?= =?us-ascii?Q?1EDpOxaCBbbm8/Xn2paiSFYFcRVukLMDm8AmCF7gAk0fCrNJZHXlU3SUUuOd?= =?us-ascii?Q?pCLGaIkl/ha+lW7CfdTdEpHWy9PGdByMWlanuTlAmyl3amwdXXv2ImNHAKwI?= =?us-ascii?Q?Oq4DsuN1c4BMD7oOTZyH1huPJl07B+UWyYjhN+l+ACCFkSeF6/OUhTc5K84u?= =?us-ascii?Q?2s2XTT0MUp5uDEDgS9KFquw7ztfQVu4LRWN+jZ/9EU2Am4ffrvExgpeSiixh?= =?us-ascii?Q?K7Rf5hNP0IEfd/8TykAK+mjMo19uSQ5paKtG7pZSVor6lDuvMWnOl5FqUzYw?= =?us-ascii?Q?1rVPMIwcx9aCY0uzhnVFdKeyhBvyq5cYBGwrwf54jdsoWF5QsFJShMfq3iMh?= =?us-ascii?Q?Jhj8npSPEfviOsIsDpcRti6LlGAPq6YddL4hHVT+tlOg8lINjuV3q6aciDXp?= =?us-ascii?Q?Ima/DwOxZA=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 859c05d0-3b63-402b-f52b-08da0d084796 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3517.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 20:04:04.1290 (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: O/Wbb+tY+bG+Wdt9KNuOfxY/aMFxnWZkdpbaWTknmzJkdFXlutDGciJ0/6+zMGXBGdsobp6HomqI5oRzN+9ryQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9045 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 --- Notes: v2: * Removed superfluous DEBUGOUT * Renamed id_reads to retries * Don't assume status == 0 means IXGBE_SUCCESS v3: * Removed extra braces around single statement if drivers/net/ixgbe/base/ixgbe_phy.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c b/drivers/net/ixgbe/base/ixgbe_phy.c index 8d4d9bbfef..74c5db16fa 100644 --- a/drivers/net/ixgbe/base/ixgbe_phy.c +++ b/drivers/net/ixgbe/base/ixgbe_phy.c @@ -1267,6 +1267,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) u8 cable_tech = 0; u8 cable_spec = 0; u16 enforce_sfp = 0; + u8 retries; DEBUGFUNC("ixgbe_identify_sfp_module_generic"); @@ -1279,9 +1280,29 @@ 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 (retries = 0; retries < 5; retries++) { + status = hw->phy.ops.read_i2c_eeprom(hw, + IXGBE_SFF_IDENTIFIER, + &identifier); + + DEBUGOUT("status %d, SFF identifier 0x%x\n", status, identifier); + if (status == IXGBE_SUCCESS && + identifier == IXGBE_SFF_IDENTIFIER_SFP) + break; + } if (status != IXGBE_SUCCESS) goto err_read_i2c_eeprom; -- 2.25.1