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 2DD08A0503; Thu, 19 May 2022 21:38:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0ACF4114A; Thu, 19 May 2022 21:38:01 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00091.outbound.protection.outlook.com [40.107.0.91]) by mails.dpdk.org (Postfix) with ESMTP id 46E7840156 for ; Thu, 19 May 2022 21:38:00 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HoXdd9QH1+IGGzZsiLQLfYtyQDzR5oFYQ3Iff0yWuyPmWNI8WAk4Qwd3Sn07/0WDy+rJjMMOL1oFSVJksl69hA/IDzqiUnZtvwkHH6UMuShPEFWUmFhuhW5OyRNInS8oIevQ2P5VD3KlNbyRS9slN0H+7hOai6kHdZPAC3Az6UMyxP2yKT4qzvR+qlCii0GGxmIO3NwEhjw2U5I5Nv6p7GC1EcfMl3Wa2T51S8VnvQIdlQ2atmglsoW1rDhDrolaL4NbuF4H5pPN2G02rz48QytzB53amS6ovX2gU1aT97rUv5FPzijBtd6kpC0sE9+sx6x1sLAIA9bahNJZuNiBYQ== 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=G8ENWs5rBiguwa8fESqYeoeft8oaG37C+e+boL03Cuw=; b=hK870KU5Cre0xl1St0V6bBI9QijyhleMJeLeO1PPp9UK5vz3p1UHhguQ8+julz7NmXzmlIkp6Hxrx1VE+au3EzV2beQ8ItXL36YGwrHHI+G3taFG9qnqQlHVEjIfpX4rF2XkuTAOKBUB7pna7xcq6yM00TasKw6FF+JL+XoMXtcXoh+OqJ/zshSvBvgvXhPhFPHm2qSm8pRi51Wz8fXXhi7Sa42yuwLK4MblK+RS70Bnchibg0LsW5PBIUbbKbf9BubELitVJxGQGLxDElqR0hxtmG+I2SITYUNRTFqNykb1TYLBdn05x7YxfRBJZzh2R8B5Sde7kgYPqJNB0YA2aQ== 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=G8ENWs5rBiguwa8fESqYeoeft8oaG37C+e+boL03Cuw=; b=KwQNFKhzmzzLEOiJYkWTOnhSevwBuuKzbvmTHfuvbhbg0laRzNTwwskZoLwsqGZ6/QsHNzjY6NtSoZhw7sIgI54IkN1ZnlwuIs+7Vw/r7ZWu34ZgLSVRzsISrDXUl3l4SaXCmfiAPcAG3BPv1vqLXaZrhyvRFWR4O0p4YafJYxQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silicom-usa.com; Received: from VI1PR0402MB3517.eurprd04.prod.outlook.com (2603:10a6:803:b::16) by AS8PR04MB8530.eurprd04.prod.outlook.com (2603:10a6:20b:421::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.18; Thu, 19 May 2022 19:37:59 +0000 Received: from VI1PR0402MB3517.eurprd04.prod.outlook.com ([fe80::a8d9:7211:83e:46db]) by VI1PR0402MB3517.eurprd04.prod.outlook.com ([fe80::a8d9:7211:83e:46db%4]) with mapi id 15.20.5250.018; Thu, 19 May 2022 19:37:59 +0000 From: Jeff Daly To: dev@dpdk.org Cc: Stephen Douthit , Qiming Yang , Wenjun Wu Subject: [PATCH v2 2/3] ixgbe: move periodic link service work into separate function Date: Thu, 19 May 2022 15:37:37 -0400 Message-Id: <2c2f2e569754a9cf3d07950eb67b544bfb54eece.1652988826.git.jeffd@silicom-usa.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BL1PR13CA0105.namprd13.prod.outlook.com (2603:10b6:208:2b9::20) To VI1PR0402MB3517.eurprd04.prod.outlook.com (2603:10a6:803:b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1999c492-e2cd-4701-c7b8-08da39cf149a X-MS-TrafficTypeDiagnostic: AS8PR04MB8530:EE_ 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: E9Q4bxO9YtXN3gk1CadGgp5WJfQg09NY6s8yHRuVuEAiht5GeeYTu6KtgK6GvRu9wze4AhvL3tVDvNMz3I+SvuBSeK2OXGL6E01JG2wtVGwSP0pzDwdrkgoSxbRrPuea7ts8/m1JwEEUgZGmrS6SUxKOBlr7PeT0mPf3FXDYskOkUydqvOP7d38J6OGequvy3aELovE/MEun2J9UdNofiPDzGefw6P9owYRbZmUalwRlD4MrsshdXoU4kaDSrIywqMdkSQ+iGs/B/ZwDDbvz22SLbkjUq+SqccsDeRBVJzVEF5ZqziSo8pF5tCGgfgQOolTU2I1/M0TzN2LJX0R+8pQRvgOQY+7SCmktItZPUVwPsNdQqchGtxxaQ/DQXR/4LgMG+E2zTIK0nQtaiJvYknEBx/bF/nXg2q+ZD9Pc7lNhKzLqKz1RH9y2BzbGeaXgaDNyxv2WWl3I4jo/h2zFbAuQhmKf0Ijx8JpPcB6yFmgfdomLoQ90wCg59N8xicSAQkqXL7H6ONysM2U3/kSAKdU8FPPFDLOQtDdYGkPKJjIBC9pd6hOu5jX1Nf8SLex1k73Px1U0LfcmufI9kUMmPYhTCqOCYH6XOdbOKswsCEE83HTOU0nbgbjGk6dfeXRI2XyTnxrFNk9veoEUU8jNWn6SZx/8mlibKv0lRzsftvcDwcK/TSfu/woZBAVVgQCXS8uryKbDV0Q9QXrUWamp9w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0402MB3517.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2616005)(66556008)(6486002)(2906002)(8676002)(8936002)(83380400001)(6506007)(6666004)(52116002)(6512007)(38350700002)(508600001)(5660300002)(86362001)(66476007)(316002)(36756003)(186003)(66946007)(4326008)(54906003)(6916009)(26005)(38100700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?c8nlSKQYIpeybERA2zrk1H26wOvOmlCI0nNf4lwDxnJVSLLKVIokL62EJm2V?= =?us-ascii?Q?CAWBHLhwCBnxsPcB034hHO060EteNvizfT1SjzzAy5ccJdZ7AoJjgKAj9V7H?= =?us-ascii?Q?kf8fRNw/tdZAtZrlcz6zuiZNwGfKYb0EVXeWohTAxHUSWx8JSSi2GkdpyHD0?= =?us-ascii?Q?zwr1DAKr2MiVmUDXSbSBXFowdwJhIwvq8I0B5GAU9H/WwgAMkUW6Hy40lbYs?= =?us-ascii?Q?nAnG6pClLtPBEGRooAqVggTfRiEmmj905BEZ6lrdg0cpthGqfHd9ZUu1KtNl?= =?us-ascii?Q?DSFJ0PYtCA7FOXYbAGRGirs/F3+uVHYw1aR0WEe9JtEm3u/OF55IKfbFDK0c?= =?us-ascii?Q?TjqDksB3gHCDoBu5M6eMK8bb1W/8Jbxt+DyGH+aTQoyW7G8K6aaxvH5/ICcp?= =?us-ascii?Q?Sa9Zg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nd?= =?us-ascii?Q?v6sAjxWGpyss3pRaxxyk8k1kFD4Grnd17JTiyIKBdiBbT30algOA7cxIBV9f?= =?us-ascii?Q?GTPSoezGnxlFHrpgjyKJarlA85YaBGn3gow9DLhmq74yWlRcf+SYWpjdvWiO?= =?us-ascii?Q?yO+3iXHSB2bvBvFmtz/ErR1v6bGAFEq/cOow2BzAvopqCugcUlJHcKdtqvmD?= =?us-ascii?Q?upbsidx0HLOkJ29lH36Uz+a3DP63/UUmub1uBlNSNvucO+P7Du9p95FlmChj?= =?us-ascii?Q?haYVRl7fnBUEZE2g0fsMtOwOHFtL2nko7q/iqeub/eOaqzbb09gGzeWkJkSP?= =?us-ascii?Q?gANCiJiSe6ZNQ43mO9shwEhSckkp1hnFGOr6f69JkLSDJeVREeWe4AUJofXN?= =?us-ascii?Q?z4nW6iGrGhnwpQTj6TjQm5BQUEnbEK42J5fxZL9IfTUBNsk/Eu5FfTOPQ0v0?= =?us-ascii?Q?HsgAA6U8lg=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1999c492-e2cd-4701-c7b8-08da39cf149a X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3517.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2022 19:37:59.4610 (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: JoUgl8eK7H6+M0YTQdn3K9QI4NRAa/7s7eYGXCMbLLCAFJwnxF4tDGNkbbEQDHlGwQ8/lp7GraaVfjTTHhQmpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8530 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 The link update originally direct coded into the periodic service thread and is made separate in preparation for additional SFP handling code. Signed-off-by: Jeff Daly Suggested-by: Stephen Douthit --- drivers/net/ixgbe/ixgbe_ethdev.c | 99 ++++++++++++++++++++++---------- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 2 files changed, 71 insertions(+), 29 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 81b15ad28212..f1694ef76b14 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4131,48 +4131,89 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed, return ret_val; } -static void * -ixgbe_dev_setup_link_thread_handler(void *param) +static void +ixgbe_link_service(struct rte_eth_dev *dev) { - struct rte_eth_dev *dev = (struct rte_eth_dev *)param; struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ixgbe_interrupt *intr = IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); - u32 speed, start, ticks, service_ms; + bool link_up, autoneg = false, have_int = false; + u32 speed; s32 err; - bool link_up, autoneg = false; - pthread_detach(pthread_self()); + /* Test if we have a LSC interrupt for this platform, if not we need to + * manually check the link register since IXGBE_FLAG_NEED_LINK_CONFIG + * will never be set in the interrupt handler + */ +#ifndef RTE_EXEC_ENV_FREEBSD + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = pci_dev->intr_handle; + if (rte_intr_allow_others(intr_handle)) { + /* check if LSC interrupt is enabled */ + if (dev->data->dev_conf.intr_conf.lsc) + have_int = true; + } +#endif /* #ifdef RTE_EXEC_ENV_FREEBSD */ - while (1) { - service_ms = 100; - if (intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) { - speed = hw->phy.autoneg_advertised; + /* Skip if we still need to setup an SFP, or if no link config requested + */ + if ((intr->flags & IXGBE_FLAG_NEED_SFP_SETUP) || + (!(intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) && have_int)) + return; + + if (!have_int && !(intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG)) { + err = ixgbe_check_link(hw, &speed, &link_up, 0); + if (!err && !link_up) { + intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; + PMD_DRV_LOG(DEBUG, "Link down, no LSC, set NEED_LINK_CONFIG\n"); + } else { + return; + } + } + + speed = hw->phy.autoneg_advertised; + if (!speed) + ixgbe_get_link_capabilities(hw, &speed, &autoneg); - if (!speed) - ixgbe_get_link_capabilities(hw, &speed, &autoneg); + err = ixgbe_setup_link(hw, speed, true); + if (err) { + PMD_DRV_LOG(ERR, "ixgbe_setup_link failed %d\n", err); + return; + } - err = ixgbe_setup_link(hw, speed, true); + intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; +} - if (err == IXGBE_SUCCESS) - err = ixgbe_check_link(hw, &speed, &link_up, 0); +static void * +ixgbe_dev_setup_link_thread_handler(void *param) +{ + struct rte_eth_dev *dev = (struct rte_eth_dev *)param; + struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + u32 speed, start, ticks, service_ms; + s32 err; + bool link_up = false; - /* Run the service thread handler more frequently when link is - * down to reduce link up latency (every 200ms vs 1s) - * - * Use a number of smaller sleeps to decrease exit latency when - * ixgbe_dev_stop() wants this thread to join - */ - if (err == IXGBE_SUCCESS && link_up) { - service_ms = 2000; - intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; - } + pthread_detach(pthread_self()); - if (!ixgbe_dev_link_update(dev, 0)) { - ixgbe_dev_link_status_print(dev); - rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); - } + while (1) { + ixgbe_link_service(dev); + + if (!ixgbe_dev_link_update(dev, 0)) { + ixgbe_dev_link_status_print(dev); + rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); } + /* Run the service thread handler more frequently when link is + * down to reduce link up latency (every 200ms vs 1s) + * + * Use a number of smaller sleeps to decrease exit latency when + * ixgbe_dev_stop() wants this thread to join + */ + + err = ixgbe_check_link(hw, &speed, &link_up, 0); + if (err == IXGBE_SUCCESS && link_up) + service_ms = 2000; + else + service_ms = 100; /* Call msec_delay in a loop with several smaller sleeps to * provide periodic thread cancellation points diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 69e0e82a5b1a..4f17fabf4073 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -29,6 +29,7 @@ #define IXGBE_FLAG_PHY_INTERRUPT (uint32_t)(1 << 2) #define IXGBE_FLAG_MACSEC (uint32_t)(1 << 3) #define IXGBE_FLAG_NEED_LINK_CONFIG (uint32_t)(1 << 4) +#define IXGBE_FLAG_NEED_SFP_SETUP ((uint32_t)(1 << 5)) /* * Defines that were not part of ixgbe_type.h as they are not used by the -- 2.25.1