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 3BDF2A04FF; Wed, 23 Mar 2022 01:59:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1A7941104; Wed, 23 Mar 2022 01:59:52 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 5CAC841101 for ; Wed, 23 Mar 2022 01:59:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647997191; x=1679533191; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=C3ANdMaW2VxmYgiIJWQwHqTkzIBma2Bn9ZDN9OCF5D0=; b=fj5cbfE8xz9GciOd9S42SYwBG76QXSq4SnNxfgejsk9/bkD6g7295/Qg UwhiyM8CdIr8IBb4vc3HxKWgtX6lmkuP/dSk2Cj0Lm3XNRRYF2/PhFILD m/j0WvTeoFPRic8EVo56u9sI2nFUOr+pAwSV/96MiB3HvpGx8Yob6R9yo ybj8DeLqGUg3KsujvAlqVQntIfhn405lzpVKyHQ1D7MFf1a25asr5v5YE 5jhICrlmhh0ylqL3ivNfIoQWNFjNLUPV/OluU7ZFdSiiuFIznOH2bmGmc w7SDbAKXzGDjwlCSRaqhs6SITHq4BXEiaAbCo0WyDJyTpjwZlSrbt89Dq Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10294"; a="255554494" X-IronPort-AV: E=Sophos;i="5.90,203,1643702400"; d="scan'208";a="255554494" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2022 17:59:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,203,1643702400"; d="scan'208";a="500819055" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga003.jf.intel.com with ESMTP; 22 Mar 2022 17:59:48 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 22 Mar 2022 17:59:47 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Tue, 22 Mar 2022 17:59:47 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Tue, 22 Mar 2022 17:59:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DQnGHYPDMRCGNuu6A2mprvgsKugCzG8UrosX6qyyK9XXyGv/S0WLO+2aXsa/c80NZ78Q8g2Ar7WIFU/qK6CHm0pnyE0d93Ki1G1jsG6DMHOlkpFJ4fvQx4st489MpR3uQmxakKU5yQK1I7lBdlcN4VlUkMvP1qfwsfU2BbwNlVYY+7+CafJqsnT+6cB45lx6YnPUs3KhhJALmeofKI1AH7Zy2cY1xGHU4e7lf2TmYxNAHlMvkYqzYmZHAUXpcdPv/ZB47oy8a3K/lxsmxRHjsqoRRunvZi5zW0eHwRWspBMtJrnEql2/8JZRyWXAqKk5OV/qhHNsy8x09HY7qVEXhQ== 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=6bOS/41wi8bAZoWLXvtka83XRo3qw1veZSkGfuMeUhM=; b=MefhtdSfy/FVXe7mlys7apsVZU38wR70hQyhJFJR24WHsSbAkAuAmmAYW9535QxXT/BzKHVikK+Xj6xRUzGDYa3UZ8tjQ7HSfxXOr4ue1s2a5rooaWQb6/k4Amsdw+E21BpIDfKFdcdO+VBNGM6tKGmjAnFAKwstgQBLQbN9CXq6XDjhZhtqNIFw5bARqSKl0rqKFkBNDkf6D546UXINy3H9rPj441SMUTO0zfSxtssuo+jXee+eDoh6e/z4Yynd5+0DHE9vUXGYXNYPDx/jahGAjIMXqzISR7M+3oSiOAPMjbu7CRXgTTB6scaXiS2464SMZoFdGf/p68btXnmOQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BYAPR11MB3495.namprd11.prod.outlook.com (2603:10b6:a03:8a::14) by DM4PR11MB5551.namprd11.prod.outlook.com (2603:10b6:5:392::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.15; Wed, 23 Mar 2022 00:59:46 +0000 Received: from BYAPR11MB3495.namprd11.prod.outlook.com ([fe80::cc6f:9806:bca7:2297]) by BYAPR11MB3495.namprd11.prod.outlook.com ([fe80::cc6f:9806:bca7:2297%7]) with mapi id 15.20.5081.022; Wed, 23 Mar 2022 00:59:46 +0000 From: "Wang, Haiyue" To: "Daly, Jeff" , "dev@dpdk.org" CC: Stephen Douthit , "Daly, Jeff" Subject: RE: [PATCH v2] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs Thread-Topic: [PATCH v2] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs Thread-Index: AQHYPgDzcEL2UNYrKEudB/gfpDBf06zMJmgA Date: Wed, 23 Mar 2022 00:59:46 +0000 Message-ID: References: <20220307223337.27876-1-jeffd@silicom-usa.com> <20220322152406.9657-1-jeffd@silicom-usa.com> In-Reply-To: <20220322152406.9657-1-jeffd@silicom-usa.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.401.20 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 975808ce-782b-499d-56cb-08da0c686c86 x-ms-traffictypediagnostic: DM4PR11MB5551:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr 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: 7kz9k/J5mO9uCxCMPygELzMFQfc1Pf6/3T/2pYQty2RkzNiUWDyXmvbUGVlElXwM61GS3u51D79aAmsDVkPl7n0doio23FQyeSxiwwSTJX4raOEPLCTrSp/x6T/6NX83dde0qzCvJUtfKElQEiFftmcfbgkwWNjJgRhYQoVL4A5+smtYYxBonbboZoxY4amYkejd+1wX79uXrKJqGtZLzIkpJDp5Z8tXt4GXzFlSr2zIC13OWf+3KIqk+wiCggvHNDlE3m3V4vpH1JkNEEii533sG1HQv154QPuJKC4pg3GBdUbS1pNRc/tfE7QTEbGRjgqHZy1wlEd7K5zn0Rmhd3LgADfWVMgRB8m8rhohlQ8oR9ofqnha6GcqsEWR/DStYUKVY1Ksv5TTVcYvtY19gqg4RkvZXxejF9Kp5a2Dq9gykbeyymSkHwH9CqDXsT2U83jC4DN2BTLsgk+wCmq2dz6F0li+omJ/4tGaWuFgeRulblHHDFDoxZD1YMS1iTbW44njIs/hiNttH1oV42tm/bciduMGoE7wsjJgzrjeh0bgsNxt8yIqvNrs4e0nkeZVAVIKzA9p/VPHL4/77E4+R0jiGiY1b2qFHU4CgQi11zCwneXhMNV0Crt9wyEkNcxs6Ttlay0YJ0t7fPYLFpqTafacBwhm/3OWE11sH6Pw4njdi/zu5jKpo5NeTkOwrRX8SuF4HkgRZgPyQ9/TMvYhyQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3495.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(9686003)(53546011)(508600001)(7696005)(2906002)(71200400001)(6506007)(83380400001)(316002)(54906003)(110136005)(55016003)(186003)(86362001)(122000001)(26005)(66556008)(66446008)(64756008)(76116006)(66476007)(66946007)(38070700005)(4326008)(52536014)(38100700002)(5660300002)(33656002)(82960400001)(8676002)(8936002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?bvrTpZ8zuX79zVj0O9pSFSzXSNjKVM3EoHn+M9Vu0I5HTh7IDGeT8TUe1Bbb?= =?us-ascii?Q?NGKAhaZg8jc2Gi1xWfkcMYCQU8+M4NUL8yZ3XQ0rqxgoVLOKdh7/37vS0rT4?= =?us-ascii?Q?zv62sZhvQp0Admj63fKkRM3jggnb3GcEpG3d5VvIjfqXz3qTcL2qCeMZqEEZ?= =?us-ascii?Q?L/O57Wh9HxuuLPeP29D66h0nPdqWxRfH/HmwuA8kAQaWaHhvmkpbBXO9owQy?= =?us-ascii?Q?EqRaw2y4bRl65wM59mmEFd7kVbxx2tDUHOggDByQK/r3BM9eIOVbNjaD7gLa?= =?us-ascii?Q?0rtuqIvjyr1KVLAVFmsFy7mGvXUdLJ6FUf6k5UbidRuZ96ZtM6gBJIJYpO++?= =?us-ascii?Q?FtjXqSHV5PmLv80AlwwW++wDvoLtPrfHRXZJ4UufXACu/lplCY3wn+ewhxNG?= =?us-ascii?Q?y3U9RCd8rzRVuTdqrHhduaerWGwn/B9IjhTOWmxC+PIylkyTl1rE2r15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6/dgEbrhxADE4pBdbCQDVzskQR4sHo8vAArFDv?= =?us-ascii?Q?kO76ubEJQf25HQe6E5RFz5ShR9P78JeCO34smzJvezf9FcU/Vmu2xVIxgItj?= =?us-ascii?Q?TYRIsMHpTgFWpkfr8bBoz/LIeT+7ZvXM?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3495.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 975808ce-782b-499d-56cb-08da0c686c86 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2022 00:59:46.2128 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W5iN5pvXYnfbG0vyp9JYHuwJ5ZhW3Qb4gFb4LbOuoaMPMPIdo8DwGs43Qe13KGCVoST1qmiE9ZJedAhHKQhbTg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5551 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: jeffd@silicom-usa.com > Sent: Tuesday, March 22, 2022 23:24 > To: dev@dpdk.org > Cc: Stephen Douthit ; Daly, Jeff ; Wang, Haiyue > > Subject: [PATCH v2] net/ixgbe: Retry SFP ID read field to handle misbehav= ing SFPs >=20 > From: Stephen Douthit >=20 > 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. >=20 > Retry the ID read several times looking not just for NAK, but also for a > valid ID field. >=20 > Since the device isn't NAKing the trasanction the existing longer retry > code in ixgbe_read_i2c_byte_generic_int() doesn't apply here. >=20 > Signed-off-by: Stephen Douthit > Signed-off-by: Jeff Daly > --- > v2: > * Removed superfluous DEBUGOUT > * Renamed id_reads to retries > * Don't assume status =3D=3D 0 means IXGBE_SUCCESS >=20 > drivers/net/ixgbe/base/ixgbe_phy.c | 30 ++++++++++++++++++++++++++---- > 1 file changed, 26 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c b/drivers/net/ixgbe/base/= ixgbe_phy.c > index 8d4d9bbfef..657f404fe8 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 =3D 0; > u8 cable_spec =3D 0; > u16 enforce_sfp =3D 0; > + u8 retries; >=20 > DEBUGFUNC("ixgbe_identify_sfp_module_generic"); >=20 > @@ -1279,12 +1280,33 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgb= e_hw *hw) > /* LAN ID is needed for I2C access */ > hw->mac.ops.set_lan_id(hw); >=20 > - status =3D 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 targe= t > + * 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 =3D 0; retries < 5; retries++) { > + status =3D hw->phy.ops.read_i2c_eeprom(hw, > + IXGBE_SFF_IDENTIFIER, > + &identifier); >=20 > - if (status !=3D IXGBE_SUCCESS) > + DEBUGOUT("status %d, SFF identifier 0x%x\n", status, identifier); > + if (status =3D=3D IXGBE_SUCCESS && > + identifier =3D=3D IXGBE_SFF_IDENTIFIER_SFP) > + break; > + } > + > + if (status !=3D IXGBE_SUCCESS) { > goto err_read_i2c_eeprom; > + } >=20 Just one line, no need {} if (status !=3D IXGBE_SUCCESS) goto err_read_i2c_eeprom; > if (identifier !=3D IXGBE_SFF_IDENTIFIER_SFP) { > hw->phy.type =3D ixgbe_phy_sfp_unsupported; > -- > 2.25.1