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 CBA57A034F; Mon, 6 Dec 2021 23:20:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1C9184120A; Mon, 6 Dec 2021 23:19:53 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130125.outbound.protection.outlook.com [40.107.13.125]) by mails.dpdk.org (Postfix) with ESMTP id 8053141169; Mon, 6 Dec 2021 23:19:50 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxz07tJ/RENyGrw4imK46q/dmtr5ikGCUhA3KNxudLbxPgY6mhya76eqqJu/aZ9L1QPc72B3P8iLUW7srP/pxzQh31oZoR8gee9nvSf7wOyAii0JH0qPM26IipFhLXkoyvoTdcpgmXa0kblXXan0A6/7QY8r17e98e0q/OzUZukc8jIIsHXFl2+fRHWamaAzYg0gutpySIkTGkxU4Lwz4vFSju6K10+i6wK3Wl8UqwVT9VfoXGCRJEho4K+SM+ZRi9y+a9M7pGPPvfHNwiU2mOyXoNoGXoNbVLGDyZJilYZm6+fM9Tf/cTWRb9xrUO6ebJXauriPnbxeEP5LqCbwhQ== 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=U1ToY7tooyrlQKzotnHseoh8V/mRmx0gxOiB9eHyvhc=; b=jqKdxOWyNaSQiiRiUiQ9bMSbjTDPF9pOoYEnph+iFUfmEqU9Lgc6v+SSvr3ypOq+sp8fKyqF8xg2UQISWy7W40TVTkfZuG4e3GSb3NzVl4dbYPA/DkCPpIANNNh5sqmDoxQSLN62l97poLc6QOFR8qUFsLX5iRauaKC7hAkVumyLOsNBnrpiS6ej0FAYVo/0T3freDanRJ97PW3e33Glr+toYLUjdwCKNX/fI6K9bhGwTVbH8JnaoaOO4FENG2kdanPDa0d7w4nFXYxwCm4gnmDAFYSzGb+LfLvOMeWJ608eDlj+daV54WVu7Kac7MF9Dy0+5OpE9Hge/ajnxyqqqQ== 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=U1ToY7tooyrlQKzotnHseoh8V/mRmx0gxOiB9eHyvhc=; b=KqtKhaI1Dvyl6hLu2Euz2CfpbWB7b3q93wXcn09ai9Wcqo/zxC8GWC9tjYgVdxW63NekKDeSVZuPF/TCedZnicYoeRWUtsVdNOgMvFI6RyxIeyPST8JUnuV/PLUaWvF3Be8KqoJYM733tHSLw28Xy/OXak/vtJwbFUyKFrsvAGk= 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:49 +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:49 +0000 From: Stephen Douthit To: Haiyue Wang , Xiao Wang , Wenzhuo Lu Cc: dev@dpdk.org, wenw@silicom-usa.com, Stephen Douthit , stable@dpdk.org Subject: [PATCH v2 2/7] net/ixgbe: Add ixgbe_check_sfp_cage() for testing state of PRSNT# signal Date: Mon, 6 Dec 2021 17:19:16 -0500 Message-Id: <20211206221922.644187-3-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:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bbebfd3-278f-4f15-f3f3-08d9b9068475 X-MS-TrafficTypeDiagnostic: AM0PR04MB6724: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: fQG0hPMTI0CQmAOFp52lQw+8sD37dFZjOEznASy3H3kbWBVzdIctTUfzv9wj0pRlTQrwZnEPYItXlkJVvpGnInBEiafM2YyYv24C2B7rbU4K76JQ0ZTat7eGX9kXzadPB6qIWgJMBKEHxsjonNFSmNcNOUoPPc5RVCFgtTqVzyEa8k2i5ndMeARb28d56Zj/7wHVImCd80g/Z0RW8I6av1XsltU6n10+s0HpnPsBnJyvAocViOb5aeD1FDoF8QujMitCpZXD+S2EB2PD317Dksv70UhSxuOT6PODF8zqBIsoQlKj1WBk/Xffhm3EsKtpkf38YaTYO8w61t/e00nOTqPAmrifEDKvBpvrrdSZMmHhZAfKhJG2ZjuWTDekJc+1nLnSUmH0lc9CMnu4dDGxj8N/lorPXnT1MIicRrL+zkbM1QGVUoaw0Wg9qUx5q/kGGzAXfeJZJNQJAiKOVfiEYIem4wy7nXugs/wR0iGQkxkUKX5tArwXwKbPxUsFKmFc2Eu9EEenPoYNx+J+O/U6ls7+DS/p2f0WH7gU2LxTPRXSm/wAbVUnxyqbnBzLPsBFbJBvGLkQRXGrtR27NkpFdKM0W5Mw2kKZ1MfekuNy7Zi4nGc76azZJ3nNM14NrcWTjPeMsgvKoeJtUbhQPzBS5F3W9q0JmSdETForQVLkoPZyFpOq3WvPLBkhrqpJw1yuHwDHsXev5xb/Ks1PGby14Q== 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?Oe7Ecy0B+28pUIFdiITC9+WrSx40+YDaV6KzLXRCPBfRsSJ0v3DrfhTU7lvY?= =?us-ascii?Q?JnordX5ttojrrGV/xEfwvTdh7TAZ0hP3tOqV6d9UEdgSs1zVCSesa1ycpCI3?= =?us-ascii?Q?QLhnQAioCQvgtTcnuBQ+esV0ykyPDBqcPLKeiOSfdVelbTltMbZeDs7jVVyC?= =?us-ascii?Q?7NCC1Pe7Ez1LVMdr9C12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q?pukuKIrmFEGcArNb1+OXaJzdIVK9D9j1E+7lU2XRhFwIzGJA6D1TS3nQraaH?= =?us-ascii?Q?QnRE/Myb2uP20YuYLxuqlDKidjq9wD+kz/exugm4q4gPLr/rGX8WMBrMMsvy?= =?us-ascii?Q?WDYJZFU1C+PIKrsBofQynoAWIApgznh3+ORa985CR5sjDsfmFN4eNBd1wCZ9?= =?us-ascii?Q?cgnqCDHHjDoXG+VmW6aGrAbvF9Mfku6T0rtPeAwT0jKA9QdWy5fwNMLLKJ7p?= =?us-ascii?Q?VlhrLI3+IDXy0ktoOxz/NJC80tBQt+J2sXNu7V3rTvjz92nPX+EJUcOinJbG?= =?us-ascii?Q?rUWVv/EV/DNNFrbdbWNiiJXfenL66057leewMbR8E3gINlEOnUunWOOGxyDj?= =?us-ascii?Q?syXmvL1Q3S6E3kKluEqp2OiVTnXT3f7ZlDosqm6JdHhw8irlqztNLw1ayuc5?= =?us-ascii?Q?DMqr/Rad+6S4RDGKSQ6n4/03QxXBCXlFZVrFOWzI4Rk4E8uWWp2mUbWL0wSV?= =?us-ascii?Q?Kt7VV3phqt8cBD8D4RJHFUQ1FUVGsmyZprAEPklEM9EnvSbKV+UATz2Zt+i/?= =?us-ascii?Q?Rp0lB2JDTk1iDrtse0F7OzEqqmXtCQkIP62oxkR07zgoqxuT1+rTtOLkhFkz?= =?us-ascii?Q?OH+aEg=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bbebfd3-278f-4f15-f3f3-08d9b9068475 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:49.4609 (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: Yd64HONSVoqcuXkQ7FEXqiNAiDUYGk66eS1uuAGjyfe7sTkll3OR4y7HG4nm/OpHazKlYt85R9fUIrjcsCDd2KVL4xNVBjIlR5/OGaijnA0= 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 Refactor the SFP check code from ixgbe_check_mac_link_generic into its own function. Note that the SFP present status was inverted for the X550EM family of devices, where SDP0 represents the active low PRSNT# signal from the cage. Call the new function in ixgbe_identify_module_generic() to short circuit the I2C polling and greatly speed things up for devices we know are absent. Fixes: dd3a93cf5a2 ("net/ixgbe/base: bypass checking link for crosstalk") Cc: stable@dpdk.org Signed-off-by: Stephen Douthit --- drivers/net/ixgbe/base/ixgbe_common.c | 60 +++++++++++++++++++-------- drivers/net/ixgbe/base/ixgbe_common.h | 8 ++++ drivers/net/ixgbe/base/ixgbe_phy.c | 8 ++++ 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/drivers/net/ixgbe/base/ixgbe_common.c b/drivers/net/ixgbe/base/ixgbe_common.c index aa843bd5c4..2764cf7cf1 100644 --- a/drivers/net/ixgbe/base/ixgbe_common.c +++ b/drivers/net/ixgbe/base/ixgbe_common.c @@ -4124,6 +4124,45 @@ static bool ixgbe_need_crosstalk_fix(struct ixgbe_hw *hw) return true; } +/** + * ixgbe_check_sfp_cage - Find present status of SFP module + * @hw: pointer to hardware structure + * + * Find if a SFP module is present and if this device supports SFPs + **/ +enum ixgbe_sfp_cage_status ixgbe_check_sfp_cage(struct ixgbe_hw *hw) +{ + enum ixgbe_sfp_cage_status status; + + /* If we're not a fiber/fiber_qsfp, no cage to check */ + switch (hw->mac.ops.get_media_type(hw)) { + case ixgbe_media_type_fiber: + case ixgbe_media_type_fiber_qsfp: + break; + default: + return IXGBE_SFP_CAGE_NOCAGE; + } + + switch (hw->mac.type) { + case ixgbe_mac_82599EB: + status = !!(IXGBE_READ_REG(hw, IXGBE_ESDP) & + IXGBE_ESDP_SDP2); + break; + case ixgbe_mac_X550EM_x: + case ixgbe_mac_X550EM_a: + /* SDP0 is the active low signal PRSNT#, so invert this */ + status = !(IXGBE_READ_REG(hw, IXGBE_ESDP) & + IXGBE_ESDP_SDP0); + break; + default: + /* Don't know how to check this device type yet */ + status = IXGBE_SFP_CAGE_UNKNOWN; + break; + } + + return status; +} + /** * ixgbe_check_mac_link_generic - Determine link and speed status * @hw: pointer to hardware structure @@ -4145,25 +4184,10 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, * the SFP+ cage is full. */ if (ixgbe_need_crosstalk_fix(hw)) { - u32 sfp_cage_full; - - switch (hw->mac.type) { - case ixgbe_mac_82599EB: - sfp_cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & - IXGBE_ESDP_SDP2; - break; - case ixgbe_mac_X550EM_x: - case ixgbe_mac_X550EM_a: - sfp_cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & - IXGBE_ESDP_SDP0; - break; - default: - /* sanity check - No SFP+ devices here */ - sfp_cage_full = false; - break; - } + enum ixgbe_sfp_cage_status sfp_cage_status; - if (!sfp_cage_full) { + sfp_cage_status = ixgbe_check_sfp_cage(hw); + if (sfp_cage_status != IXGBE_SFP_CAGE_FULL) { *link_up = false; *speed = IXGBE_LINK_SPEED_UNKNOWN; return IXGBE_SUCCESS; diff --git a/drivers/net/ixgbe/base/ixgbe_common.h b/drivers/net/ixgbe/base/ixgbe_common.h index 5bdb484407..30db9a08c4 100644 --- a/drivers/net/ixgbe/base/ixgbe_common.h +++ b/drivers/net/ixgbe/base/ixgbe_common.h @@ -112,6 +112,14 @@ s32 ixgbe_set_vlvf_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind, s32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw); s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan, bool vlvf_bypass); +enum ixgbe_sfp_cage_status { + IXGBE_SFP_CAGE_EMPTY = 0, + IXGBE_SFP_CAGE_FULL, + IXGBE_SFP_CAGE_UNKNOWN = -1, + IXGBE_SFP_CAGE_NOCAGE = -2, +}; +enum ixgbe_sfp_cage_status ixgbe_check_sfp_cage(struct ixgbe_hw *hw); + s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, bool *link_up, bool link_up_wait_to_complete); diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c b/drivers/net/ixgbe/base/ixgbe_phy.c index 8d4d9bbfef..d8d51d2c3f 100644 --- a/drivers/net/ixgbe/base/ixgbe_phy.c +++ b/drivers/net/ixgbe/base/ixgbe_phy.c @@ -1228,9 +1228,17 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw) { s32 status = IXGBE_ERR_SFP_NOT_PRESENT; + enum ixgbe_sfp_cage_status sfp_cage_status; DEBUGFUNC("ixgbe_identify_module_generic"); + sfp_cage_status = ixgbe_check_sfp_cage(hw); + if (sfp_cage_status == IXGBE_SFP_CAGE_EMPTY || + sfp_cage_status == IXGBE_SFP_CAGE_NOCAGE) { + hw->phy.sfp_type = ixgbe_sfp_type_not_present; + return status; + } + switch (hw->mac.ops.get_media_type(hw)) { case ixgbe_media_type_fiber: status = ixgbe_identify_sfp_module_generic(hw); -- 2.31.1