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 A5A2EA034F; Mon, 6 Dec 2021 23:20:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC7CC426EC; Mon, 6 Dec 2021 23:19:54 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130128.outbound.protection.outlook.com [40.107.13.128]) by mails.dpdk.org (Postfix) with ESMTP id 94B36411DD; Mon, 6 Dec 2021 23:19:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VM1RiO+Rkk6p+g6gdOR+ek54scJetUHO3Whu5Gsm/1PcxXUTLVuze4GERxpBDHwfQvZAbpEUcuXx5/qdxiEcEIqUTpkhZQfuK2HabiLnIGMLKDSXgqmAaihwPmZADzGmwJqthf0ctxA0AvYztakVFh1CCPsLoFMUqvyXXLoTUkkIXMy00uXoQOjX8p+uYVq/Bcsd/B1Q3RpAP8g0DsSzbttXF61FJj+CTNrnQZb/1g8hN8Ofgq9r7xvYm+Ttox/YXW24QpEqAlMzqSVEA29GFjg7t8gZ39xfowXsYU4Bgpy9E0vLOnRF/VW79XfNosMwDVWWWqBfGtUCVsz3j62d3Q== 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=kbGwrfkhiXYs+8DaWVgwsi/F4ize67M8nbNxe8cu5tk=; b=CPkvoOKJ3KUo5D9Eh6IRJ3cVk7XfC0Uj5nwE1Fw0HNrHGyeMQdFOP2XlGXr6EL3TmFBTaPTFxSc9AcVDRnKcBN/eaJ7DGUFU0TqxOHbBCAat9F+pRfhIFE8UnY6L3lprO8WNO3RnT1Vt8o3Ccv0Rqc71faHA3t0xK6DGPYf5IozpcJDDGP7zcNkxphBx5wlCluJqvP1OQX3Kx8ZoSBFfOIvFMgMHjwaWzHmTXlQwN7Y5Eds+2n2rfKEUm4IitlJZKyAJJ4MhK1IVzuhmmBRayj/P5ewOfNmJvn1rvBBnu1hYDj5PYnG66eZs9lyjQ5ciuxOsGfIdBSQhJxSJ7V6hyg== 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=kbGwrfkhiXYs+8DaWVgwsi/F4ize67M8nbNxe8cu5tk=; b=V3/ZMM/4iLVlu3KZUXJt9S2y7gTkHD1Ny/wZhSSZlQt8KvJfndfE5yX4v/EK/8VQIBGAsy/cFslr165tm735WzCSP3KBRZq5WwsVJUYuQvbkHULZXyDpALtXootw032McWjiFxYPzU04TpVBwXjADVuycfvcaNPYjRmBZ+7al4Q= 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 AM0PR04MB6724.eurprd04.prod.outlook.com (2603:10a6:208:17a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Mon, 6 Dec 2021 22:19:51 +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:51 +0000 From: Stephen Douthit To: Haiyue Wang , Wenzhuo Lu , Changchun Ouyang , Helin Zhang Cc: dev@dpdk.org, wenw@silicom-usa.com, Stephen Douthit , stable@dpdk.org Subject: [PATCH v2 3/7] net/ixgbe: Check that SFF-8472 soft rate select is supported before write Date: Mon, 6 Dec 2021 17:19:17 -0500 Message-Id: <20211206221922.644187-4-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:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1678f712-2ffb-4a4e-96e1-08d9b906854d X-MS-TrafficTypeDiagnostic: AM0PR04MB6724:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tFNo25RD16Ir8ybievP9ryajtaZmD06WgQgw5MwEivSUpaa5DEbhoV5Pfa+ppe8JQ7I/NGIwAiaZOQ+yFjKvIlTQIi1w0Cz4+hc86h7Gl9oFUlwH1NuPj6hOQtbaeTxQS7yvv7J6cd5j0tp2TS6g8E0ASO4eI0mOTALq3odCFs+xjVqpWkls1p+bI8L7rj1L1X/h7YAawzk/CPXVUSWH7pJHg/vMRX+168iTCS7z8NFnlVs6Qmc6w+hjlWC7iytiwwYO6PFsVTrwapXoIeYYl2TMMMAAMgcOHXep+U1TKA6g/WBsT3gtMhYUPySiiIRM3h/2wAOinairEWXYKKI6ZSL86aDTxByJRa0i5XsmrmcSoB/ZXnbNqtLLzF0jvM0tWIfG8FHcork4ALh32LRouuLWt7c3Wf+Sy2cZs5+AJs0cbPdWzCteYjtyQRf5CJxloMxeG/xQbn3LvYL3h1s4GFJWuw3kQYgVIqSjFctcox+cNMR/sgigJRM6dMX5KKQeJYaGdEVPXDRVpNMH5WeZAoE6W0RIq90jN9BuZz2+IZlgdigu0VGqnS2aEfVMCBQb+A5HzA8dqK7UjyxGq80XLpX+7731GwkXC81+cWqwYQqOOzXs98iOtsLMCviKEifIix98QkR6LxYXXpo4hZm7PgiRDW+d0JHuMNW/0yYHKxG0XoetJirh2L6IsoXp9hfL/BsDiB+SwsaheaY626+UmQ== 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)(4326008)(5660300002)(2906002)(83380400001)(508600001)(38100700002)(38350700002)(956004)(6512007)(6486002)(316002)(36756003)(110136005)(8936002)(26005)(1076003)(52116002)(2616005)(186003)(66476007)(6666004)(6506007)(66556008)(66946007)(8676002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cxxZqpInaXTRv54C0YDltghoBz+IcsjRaMrpcK192uGXD9sPT9GCwDAvs37s?= =?us-ascii?Q?9ZrH0T9zEPeNHE6nop6Dc9F9KMQu31vhhJfmDfkldKuQeT3loxIQyO7/c/Hs?= =?us-ascii?Q?CUGfbvuCme8qEeU3CO/Czf4SrIpUxfF0po20P6hzmqvIng8v4kfEGGXh10tF?= =?us-ascii?Q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q3LYnGbWFtJFJDFM?= =?us-ascii?Q?AtyFhulvjv+QgCjPIw5CVPtrjK+Oj8Shh5dfoOCiiuObGE6fZN7xubEGzBVR?= =?us-ascii?Q?l5D21yXhbiegdO1pgv1tg8/NUc2sLfjehvB8ND6RBCrhbv2sMeVvsCngdGyi?= =?us-ascii?Q?CvycWW1z648WgAUfKS2T/n+L4f8Kacqd/kHAoPIDTjthk9DF8Y9Fj0bbLPkn?= =?us-ascii?Q?0UeqLaNasuDyI+511oZsgd6u8oLkBv4EvCigQMYxxdbGDAzi+S76fzNyi/1y?= =?us-ascii?Q?lyKTUTmUd25xzRDCSKdCSUHmN7HnYgvil9N2XvDlF5+mij6olW/bdpQ3bcWz?= =?us-ascii?Q?fQmiJ/QgBK8D7GLGD8K6ghnrwEVDzgXZ+rSD22QH8kaS2OGgfeos/WdXYluj?= =?us-ascii?Q?RGt3kagNoXRdIsJEAVl2pNtJjSOIsH2uF4aLlmLPPewPsk5/7aXfHwg3kKM9?= =?us-ascii?Q?nZ38oxndW/p+QahQbtcVj09/mezlP0zuaFHEF4tyxf7KQdIcc3kPxpPNMa7J?= =?us-ascii?Q?hXuiv4NPJ3kYSRl94Kjk7+KrIV6mNAFxz6DZa4KK72KI1bqLJ2pb9TFhAMy1?= =?us-ascii?Q?ltG7uAReFhz4OA6TTlCdC+bl0E06RRx8cs/Io1op4KLTB4tNSTi6/YDnCZpf?= =?us-ascii?Q?epJEZg=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1678f712-2ffb-4a4e-96e1-08d9b906854d 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:51.2559 (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: EUt8C0KxFW8dEO+s1D0++cMoZDwmvXUQcMfAmVpMU/QQXKv8VVtphB2JIn22C14J9UBlxzaqEON4u0CHNkZkg6xu3zeVcXiVaPXqEgPrbbE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6724 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 Make sure an SFP is really a SFF-8472 device that supports the optional soft rate select feature before just blindly poking those I2C registers. Skip all I2C traffic if we know there's no SFP. Fixes: f3430431aba ("ixgbe/base: add SFP+ dual-speed support") Cc: stable@dpdk.org Signed-off-by: Stephen Douthit --- drivers/net/ixgbe/base/ixgbe_common.c | 46 +++++++++++++++++++++++++++ drivers/net/ixgbe/base/ixgbe_phy.h | 3 ++ 2 files changed, 49 insertions(+) diff --git a/drivers/net/ixgbe/base/ixgbe_common.c b/drivers/net/ixgbe/base/ixgbe_common.c index 2764cf7cf1..3be1cc7fa2 100644 --- a/drivers/net/ixgbe/base/ixgbe_common.c +++ b/drivers/net/ixgbe/base/ixgbe_common.c @@ -5371,6 +5371,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, void ixgbe_set_soft_rate_select_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed) { + enum ixgbe_sfp_cage_status sfp_cage_status; s32 status; u8 rs, eeprom_data; @@ -5387,6 +5388,51 @@ void ixgbe_set_soft_rate_select_speed(struct ixgbe_hw *hw, return; } + /* Can't set rate on missing devices, skip all I2C access */ + sfp_cage_status = ixgbe_check_sfp_cage(hw); + if (sfp_cage_status == IXGBE_SFP_CAGE_EMPTY || + sfp_cage_status == IXGBE_SFP_CAGE_NOCAGE) { + DEBUGOUT("No SFP\n"); + return; + } + + /* This only applies to SFF-8472 devices, so check that this device has + * a non-zero SFF8472 compliance code @ device 0xA0 byte 94 + */ + status = hw->phy.ops.read_i2c_eeprom(hw, + IXGBE_SFF_SFF_8472_COMP, + &eeprom_data); + if (status || !eeprom_data) { + DEBUGOUT("Not a SFF-8472 device\n"); + goto out; + } + + /* (read|write)_i2c_byte() don't support the address change mechanism + * outlined in section 8.9 "Addressing Modes" of SFF_8472, so if that + * is a requirement give up + */ + status = hw->phy.ops.read_i2c_eeprom(hw, + IXGBE_SFF_SFF_8472_SWAP, + &eeprom_data); + if (status || (eeprom_data & IXGBE_SFF_ADDRESSING_MODE)) { + DEBUGOUT("Address change not supported\n"); + goto out; + } + /* Digital diagnostic monitoring must be supported for rate select */ + if (!(eeprom_data & IXGBE_SFF_DDM_IMPLEMENTED)) { + DEBUGOUT("DDM not implemented\n"); + goto out; + } + + /* Finally check if the optional rate select feature is implemented */ + status = hw->phy.ops.read_i2c_eeprom(hw, + IXGBE_SFF_SFF_8472_EOPT, + &eeprom_data); + if (status || !(eeprom_data & IXGBE_SFF_HAVE_RS)) { + DEBUGOUT("Rate select not supported"); + goto out; + } + /* Set RS0 */ status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB, IXGBE_I2C_EEPROM_DEV_ADDR2, diff --git a/drivers/net/ixgbe/base/ixgbe_phy.h b/drivers/net/ixgbe/base/ixgbe_phy.h index ceefbb3e68..cd57ce040f 100644 --- a/drivers/net/ixgbe/base/ixgbe_phy.h +++ b/drivers/net/ixgbe/base/ixgbe_phy.h @@ -21,6 +21,7 @@ #define IXGBE_SFF_CABLE_TECHNOLOGY 0x8 #define IXGBE_SFF_CABLE_SPEC_COMP 0x3C #define IXGBE_SFF_SFF_8472_SWAP 0x5C +#define IXGBE_SFF_SFF_8472_EOPT 0x5D #define IXGBE_SFF_SFF_8472_COMP 0x5E #define IXGBE_SFF_SFF_8472_OSCB 0x6E #define IXGBE_SFF_SFF_8472_ESCB 0x76 @@ -48,6 +49,8 @@ #define IXGBE_SFF_SOFT_RS_SELECT_10G 0x8 #define IXGBE_SFF_SOFT_RS_SELECT_1G 0x0 #define IXGBE_SFF_ADDRESSING_MODE 0x4 +#define IXGBE_SFF_DDM_IMPLEMENTED 0x40 +#define IXGBE_SFF_HAVE_RS 0x2 #define IXGBE_SFF_QSFP_DA_ACTIVE_CABLE 0x1 #define IXGBE_SFF_QSFP_DA_PASSIVE_CABLE 0x8 #define IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE 0x23 -- 2.31.1