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 55338A0C41 for ; Fri, 3 Dec 2021 23:56:09 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 199EC4273B; Fri, 3 Dec 2021 23:56:05 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2111.outbound.protection.outlook.com [40.107.21.111]) by mails.dpdk.org (Postfix) with ESMTP id 605024067B; Fri, 3 Dec 2021 23:55:59 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QXElkBu0Buwv5KihT4/rp9gBQVv3S4P7GHCiuKLTaA3sRbaQHZqT0zxofdz0BxJvtiOrVDIsFCOMUFSMZCgVI7/aEfVMrFtytF4g+sGqI5tL37uFgqO1NuIsLa5cxmaNqLbRaUBC42qbE5OB/IZLCks2ldLCd/l0mpTo8qhcNwtjfxXGyFmXAAy7tr+m0c2Wu91HCCUc131cNBsQVX8ZWTUSE4kiUQgMraeF1365EgKo8/V51a4odY0iWZk8yUajwyQxk/Zl0W1Sya5PSgAc9fSBfrdT5pt5pMGU87P5lcSa3OROMzQtifBgb4wxCiaMANWN/1WjLXi8AFha5qAJlg== 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=FMGvAV4/YnM4/iP39zMNB/mMjmvKLOKquBwNsIHuKdDrzZ5tTa1ldAMdReIJgNWLOOoBE8VVIgHP+06Rd8syECWoO5baJXBqyrNuvgyoh7PcSu9DR6Bd2XMbc3NdZArd6/uYuHMKb6Fr0uxhKUofQlkIV7deXXMYzByQJ0v6vATJWdBU8k/N/bqYo10DcfJ8r/Zcbh7IWSCGiTBlaMWwN6ERJi0gfv+B35Wr14WcbnZ10VDHIQAfHwpDA+ataT5dZsobk3Ga3+2quDLQ4hVk3B3NitfPcRIAAj67BzS6CKW3+hnWjuzhCQpRbKhbl6bnH1JlJOwMT8yoIs2QWuJqpg== 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=yAUNR5PFtM8ZsE2D1VUFB70UGK9UCp1fPmZWw5AvHL0/6Yf6i7X89/FKuVM9Z3KcHrPG9hnrHTC3BLi9DCzwRp10XSU4dybgciD75nmBeHCStmecKsZveZzMtEzkm2FV+kFUEPNY2Sd3MXclbXAAQWcORL3A7Se5wnBM3f1Ggmk= 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:55:56 +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:55:56 +0000 From: Stephen Douthit To: dev@dpdk.org Cc: wenw@silicom-usa.com, Stephen Douthit , stable@dpdk.org, Haiyue Wang , Helin Zhang , Changchun Ouyang , Wenzhuo Lu Subject: [PATCH 3/7] net/ixgbe: Check that SFF-8472 soft rate select is supported before write Date: Fri, 3 Dec 2021 17:55:12 -0500 Message-Id: <20211203225516.571368-4-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:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3241785-1d6c-4dfb-d78f-08d9b6b010bf X-MS-TrafficTypeDiagnostic: AM0PR04MB6404: 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: g7Vl7fMRdN0ygG+4C7mxnouLViow/p6AYhv8P2uq9ATC5pGZl/ij2PCshFICbNzghap3Nx/1Q5phSntG1vVRGKStJFJCqML6IOMW62wzbWfxL2u2S62IBqfB/5IoMJl3m1h1ILAP6GIkMDXskNXjusFLSrwmWJmgtatBnBCXB6IqiNetU521sXgX/FlqvL2UlEIZ2F5LKcNmVAVish4Oo4aYEDl9goV1KQVEffMv76DBU1y3nFDU1aCZfKj5ORfDp0/F8ci+24wygp1IYHLd69S6xTeX49k1E2J/Jak5IkFhSHL6yVXpg75j9v1gtZrWywHGL/6UVHeDBJrCIKdKj+mxfbYgJIWoQGPBMv3Ph/ehJIWVrY/A53z/FtWqoVCDtwhamnWBxby/gcnqGxZCcQZaUHGYoTHGeSbt3XmL6xO37vNrUMlRljvKczRMD8167JU5CnDwInC0SoxdoOm+pZHp0tc7F1taTFI74oc4l7uhxaQqLdLktZGe2MeLr6VhrCTA36GKxOEokiq6ikkCrWj/9av1T1cZ1T4r8sicvx8O0TeTRv2sLkocrFYlfMpMhhJuCBop0yBiF7I63imDunF7rbdG3/HC/q3LnXKapwyTXDc21TvbFP7bP/6LM8mVOCTa9EwjOkJ+3Kkz2yv54DaHHonw9qlTCQpQXYAk4zV5agPkGIDM8FM1wq5hgIe4Yc4E1AcWW5C7dG+nVyYzQA== 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?1EwauOOgGi3mZQ+pPc5Jh20g1CREk2rCNtRho4tnYHfST5Uuf8dY3ZDUNhRA?= =?us-ascii?Q?ogjByOeJWcT2H8YN9LanGVPdvleGqgTyxFEONV2KrzZtDxxPH4P08B8EtxAs?= =?us-ascii?Q?AOWSD0liLIQgJxEIFyWTYcOSJjmQWr2VRpPA0VfIC7Y37xJOZMqXUfWn2DGf?= =?us-ascii?Q?XU+y9slVq8hhMkL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R?= =?us-ascii?Q?bhd7GaL9vHiWb1ZYjWqqPKcVDRJMyUMA30c3Tdt8NzHgqYeQGpaToH0W/eeN?= =?us-ascii?Q?e0P/XQUpvlB+DB4tFceETgRVqDIVYn0gcmpH7I3k3LSLMGFv+toJ+ghr2UMW?= =?us-ascii?Q?KSbqhp0pdJUvHGjQ+/tnNBAAb0IaVhjsUACJvBRNSkiS1eh6C7+/3hnVbpmr?= =?us-ascii?Q?ITANhqu6V5dYma8m6x03hQhSaeCyrv+or+2purSgmUyjmKgJvSPzRcZAz4g5?= =?us-ascii?Q?dSQRFUqczAEyXBucNSX03VTXJFWoOyzHDhBZKWmdKsVhbJdA0hbbkjwo/M8g?= =?us-ascii?Q?iTasy8PdTw52pn+Droy+olbBKea6t9Y1qTEL6HFeayJuOCVFs4PqYYc52aK2?= =?us-ascii?Q?JBahXTAFkCqQkoTnSdmuiPK9ntltlGn77BsNQMUhKERI+IKOTDw31h6xqhyl?= =?us-ascii?Q?O64EwpT+QmKKCjGwZTb4dAXQhZ073kub36XuqkEzx5RRPhI/eBaW1MqgxG8y?= =?us-ascii?Q?CJyHne+XxV7D3eSLyy1K27Ok6T23NU94GgXbWL2Ph3RekY8TKVtAcctFOzwb?= =?us-ascii?Q?+CINj7LQWKW7Ch5w2uFeP+a1YRHRJGb6I+GPe3apUSnP+WoUxHptYOvohhIb?= =?us-ascii?Q?dFWmz/1DuBeaYv+YbFoMKj5FnnA=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3241785-1d6c-4dfb-d78f-08d9b6b010bf 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:55:56.1892 (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: 7N7+W3352Ix+SbpM3jpoZROP1gYumJMfdYBFnhdBO6NexYdEoqOpdvxjTlTZDxOfYfuLPlXJ/zJp9OF9/JbIFJliH5fjciHLORXBQAPUcEE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6404 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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