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 2EC49A034F; Mon, 6 Dec 2021 23:20:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1664426E4; Mon, 6 Dec 2021 23:19:57 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2095.outbound.protection.outlook.com [40.107.20.95]) by mails.dpdk.org (Postfix) with ESMTP id 79DAD40040 for ; Mon, 6 Dec 2021 23:19:56 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bCod5+Tkm58syvnJ0VkfgQRdvj/3/TcCLk1QHGSGwntUcMbVSMzqNCgsDeKU/j3PkdiIPS4qa/Aw/4WB5f6jUtaL0M8ZTRJJhfRXWj238Jjn0ZLAohyya/Vu0CoBTaCJd6N4OZ4goJt9mshFrjJwKhEbm6MmM/PXl7DwpVUFoD+hShnjk1+wCzn9ynOrOoEHzb1NAVHSuyDs1n3R2VcUzWtri8O6ZlTG8XjTfuvWa66xJLHHzCcs/YFee0U/QAvGyrs54shmDADnkqsEKwNOAgc/+Ug/OGf6ogcRwBqrzxEwvEWfERg4byVgPU1/S280iFUdYsbWAV9l8c612yn0hQ== 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=TLWJ/N3uy81luT2AJZRD2PrZ4DdBQfcOmmb5f39fGyo=; b=Tlh+V8Z4AFy8R+sElGFsEC4ocQljeJAIcd0eMFX4MxdxlBf0LTBHFCvi7NH2OfFKTZKInwBVwKsOTDheIZaa3r4hGW727NJPV8IxuRkx3TvRoHbzJqbwP16j3HM8nVuKfCDO8U8IuZSEd1ROUIghYRicex1msw0+feoeDuti2Sy3XXeGB3PdOwjTT3ZbqrvbpyJiMFE5My44yaXd1RCahZPWdE9i+Gpyt+QRhEifm/LJNs0471C3CVKcFP5JQvhpthgT0kGSnqLJguQNI4msaZ1nz5s+dmb4GufsfOqmEYhk5OntpZjpSwt6My9feb2nYWEBdgKtYje07dshJQIEeQ== 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=TLWJ/N3uy81luT2AJZRD2PrZ4DdBQfcOmmb5f39fGyo=; b=yJK66eX0Le3sCqYAiLErrkO0lH8elqoQ/RWNV+u0F0pJD/bvIsLrddC2cY6r1tFh421QMue7b4nvZelAfmXah6bKFQxgKDcQMc+0S6nAs8C3a0y5Ab90iP3qD2ejmXC3bemGSw46oRCAnYZbQ3NUhZUYDDYx5NG9dI7RFgGUTRs= 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 AM0PR04MB6596.eurprd04.prod.outlook.com (2603:10a6:208:173::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Mon, 6 Dec 2021 22:19:55 +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.022; Mon, 6 Dec 2021 22:19:55 +0000 From: Stephen Douthit To: Haiyue Wang Cc: dev@dpdk.org, wenw@silicom-usa.com, Stephen Douthit Subject: [PATCH v2 6/7] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs Date: Mon, 6 Dec 2021 17:19:20 -0500 Message-Id: <20211206221922.644187-7-stephend@silicom-usa.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211206221922.644187-1-stephend@silicom-usa.com> References: <20211206221922.644187-1-stephend@silicom-usa.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MN2PR20CA0031.namprd20.prod.outlook.com (2603:10b6:208:e8::44) 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 MN2PR20CA0031.namprd20.prod.outlook.com (2603:10b6:208:e8::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.19 via Frontend Transport; Mon, 6 Dec 2021 22:19:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9954f17d-76d0-45a1-99e6-08d9b90687d1 X-MS-TrafficTypeDiagnostic: AM0PR04MB6596:EE_ 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: G3A/V9IJJQVERVlSYjuUVjaWxpuxUI67y+lxZrHV+9AoS055cWymRKMqPbF5ZXRDSN9DkKKq70O5zocXm1TX3f1w7N+Kd5W4X/ZFvZkb3Xjtk18QlfrBakXTY17VdQi/Js8wQwd242PCVMg5W8Ak0RpBFMKNOMHnndZU5NhsUX3o5dgy+WcxzU9eRm0qon12qb3bHf7hCn3maHP5kPXJ+hgAnWHgZ81Piw5NnnIyapaKEKTyITJ7UexOs7qm0d/94hdA1DhrPBnLROLNTvcq80GFcpaVnMlVUYvGy0uEUwYSYByl20PWxOl8zGrSEBUDHXUH67aHc2m+9xNnymQukOmJyq1hT5t0wOD3d3w5RAmtSNHhxDFDC1yS5zk+esCs399133xttdy9Z5+uJ1rDY8mm9uoV7eJ3npYwhqDv/HotONs8uIz1lcwfO0LHvsQFwq0UfZBz9Nf7iASKmTwZa5spbO6xckDgxxjU/tQdsgMC/7eu3LKUySsnqpDkz4EE8e1teNYB6dv4400qX1kwRSMdoKYgd6YQDQmTJTxEg4a1WiPbk0nPa7gAEkayqZmq0I1iB9UU9f6e+M+MkOhnwElzPCo4p6BuB3XBDzPqmjGpCQ4jBYwkeMXNhK1nNouw/m+46Knj83LoSMFTrryetxD8KUPJkvPkWNYe1oCLwlKqeHJHEy4oz4+6HxH6+CIfkBtcsWsZcTDBJbTav5ZVZw== 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)(8676002)(4326008)(66946007)(6506007)(8936002)(6666004)(2616005)(52116002)(66476007)(66556008)(86362001)(956004)(107886003)(6486002)(6512007)(2906002)(316002)(83380400001)(1076003)(36756003)(38100700002)(38350700002)(26005)(5660300002)(186003)(508600001)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?g+KOOvp9ssse8ONtBYiiq1Reqm2ruKPCv6cs4gJmfoCJDLnfbAdqlPqB/Npo?= =?us-ascii?Q?m5YluwH0DmIFMUh1SWBpyBoHuUMoIs7RVHpS36RyTLaIs9XyQ3DzCFAc14Sh?= =?us-ascii?Q?fe2SVuTHdPa8X+gLyl8q5h26dVDGhPXkD3RQwznb1O094AEbuNNHmE/vfF3r?= =?us-ascii?Q?zhEW+rP8sWKpJyuUrFnGVBkrWDzS3a14ratSqmOKlc5citd8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LZX0xNczX1/6TzvInwhAsUNacBjxafDJ4Imqf9+qzZsB?= =?us-ascii?Q?b2rppXVLNLoM5Z0jyZJ6tK24Hc0HaTYLj5dusGO9FNV5Z6gtbIjLdj+R6rKp?= =?us-ascii?Q?JsVJZo/VhPXnqO8yMb2o32jSBSC7f5GyiU6mSKzyQ18b7TernThfFY75kkQ4?= =?us-ascii?Q?z1acf6XJPflb29xDm4fohmb1r2GlaXJkABMNjesPZ5VJy3rxb6Vmx/cZ3xuW?= =?us-ascii?Q?wgfhVVfCiAyMU3bAlNFsbcp5FjIEyI2vjZ9g3oBXCbpF386cwAvQ6FP6eZvR?= =?us-ascii?Q?f/C7HzgryPCtdWGd80M8l7/gau/vv6b2CgaGHePcaQrkGWB+JjZ0/eeQDgJy?= =?us-ascii?Q?Bnv1p6yvMlfpM5IPn/CbOgP1YaDU8KEkcb4LO3oRvY3WwCv4my4BjJYuMGAO?= =?us-ascii?Q?7tGWCVV1gnHWSD6rcnQe3OV6/iKed6t+eMKJKrdlP5qkC5wmx2PEIMz7Y7gn?= =?us-ascii?Q?fKqU1IPzcPwpITLbM4UGmpL4GbDHeaSzMqiF2ICB2//4d0kp0OeEp69XGiiT?= =?us-ascii?Q?n2vCM5xYq3JB5Nk1b1ff0lgR5gN78cZhC/neRwVJj8XkeWRjnNuQyrUfY7X6?= =?us-ascii?Q?fQr22w=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9954f17d-76d0-45a1-99e6-08d9b90687d1 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4083.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2021 22:19:55.1167 (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: RabHp0hpllU6tZWr1hh1DvaemTwTeu5h0jeQrq64ULjwYzQcOcWzaGKE/ub7lUX80jf2Xu6ic6+rvgusWXZEOzwNBpnYlr4c1q+z85lRH30= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6596 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 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 --- 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.31.1