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 E84A2A0503; Thu, 19 May 2022 21:25:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6D67042B7B; Thu, 19 May 2022 21:25:41 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2114.outbound.protection.outlook.com [40.107.20.114]) by mails.dpdk.org (Postfix) with ESMTP id A49D742B71 for ; Thu, 19 May 2022 21:25:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gn79VaK8Yxz4p+/yYj5f+jwWCD1fw5BTipCwrFBck+y+4jwhWYHCbpLh/BJeIKlu2T1vZUIT2tJ5yb9nH2tyNqPn7iRjNWyO0FXfXSRnQMz1KqIYoJLaxR3V9h9CroMppmh/ct7bPIyehtcQ20aFt/tssYmeeN+bQGV3ev5KzCl78RAuchE56E0vIaFhwow8dRETSXuQVHiXk71t/ngLD6SGHVVUXwVKQibQf6jo6MNp7Kn8YfPtJO7NIeftOTMkiLORXRU5H3hCEhZ81Lm52b8X+FF0e2Qm7qTHpmm8tB4729P/S0bDg96zYFlixZn8LHfJiH7NTGjTyXpTLsDO/A== 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=eh7/o3I2WfI3MLPZ9ydKLWx/nUqKb6AMfnGmwSrC6bg=; b=djUAWhi1GQHtl2xYDz5QU4TRaCGPF26TwvRjlrvLQmrc2Esvso9hup5ZgeCbjXNYWk5DI8UKDxHCCUkZSZ3pjdyCcgRgI5OpkEQox322gN+E8NUUtMMDBVpgTqEu8GRxR69NBNlmBiqkdduGanFi0ZTTN14Mp9+gDQmKC0+RwFlBoGqfyj7021dRixtsEVoDp+L0ihYaPzF/+mifjxDh+vCbjtMKsyDi2He63RZgNFu7Aw9RjCghncpVi518Czd3JdkKNFLyf1eSFZYsqzEZ1w4BCheZKTCTIvOkqNeJeDIGkfc7ErzDHJFhIZaMJhGVL+cZKtXGwkDw2tsVaobIRQ== 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=eh7/o3I2WfI3MLPZ9ydKLWx/nUqKb6AMfnGmwSrC6bg=; b=A0qZ+2xyKXXalC8Ho9oZtyta6/26FdMTc49o43amKBH2jLFz8s/dI/ri+VH3lneup2D0tZE1uksly+oHdfvMob1MnVEs5o0tzYr/xotNaWaTLoZKwNMkp3iAUkIBTEBmReh6gCN6NX7oL7cEo2BoqWHDx8W69plVfM4n8A0NrmM= 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 DU0PR04MB9562.eurprd04.prod.outlook.com (2603:10a6:10:321::10) 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:25:38 +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:25:38 +0000 From: Jeff Daly To: dev@dpdk.org Cc: Stephen Douthit , Qiming Yang , Wenjun Wu Subject: [PATCH 2/3] ixgbe: move periodic link service work into separate function Date: Thu, 19 May 2022 15:25:14 -0400 Message-Id: <04814d26e71e72f91464a1261f850a6a442c54ad.1652987887.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: MN2PR08CA0026.namprd08.prod.outlook.com (2603:10b6:208:239::31) 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: 2bbfcc83-9376-44ea-e588-08da39cd5b06 X-MS-TrafficTypeDiagnostic: DU0PR04MB9562: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: LujUErxW8e4L+A8KPOMgus3pTCk5L81roI3At3zk9bJxiZQDVaAeGTW6mFPAdoO0K3wlyV7HnqLWYAmHxwGq3Jq9df9eN7CNcPjAMjpzWy5nZWw4ifykQkXquQg2vYc2PyBbS0667AzT1g70CpZLoc5oDtQVQDCealX4zR/6jFhiGtJbev7x35xR5GSPcfCu3Olh72L3yfTVqjm2ktEE2n7uVfl15Wz7fbLe7RCPRJznGDvsH2YFaue0/hD7W9eanH/vmHXj79Iq3qZD95FRfc3IHN4YKnNbXdem5lICOAVWiNGnCw7+ehS7oEQJnNK0bXK9SV5FSCR6zdp11tfoX44r57PvNHM6o87YFKNqfO2daT+MBjGonP5RAeTDYumt4YvO1J1T/R63dD7Ar8UKgzvCZlANSCX2JRCF0z/nhmucGFumwWgUIj5scP1+ehxrCzOSv+JE0DFq73XN5ePZld0Ne9HMr/6lit8z9xtXFyE3kk1+vCc9jBetUyCpXOK4Wm4J9HHa1F8HqYWFrAA+YE8Wj6WYj4yHAC1CjkjIJUN0+bkDdUPt5QokB8stALeSsx2G0SCBs7HFleyX2B+CsIIy/vw/cKYLo84eOAualmYiJ4XFm+1boWQq81Cqt/yoi7QwBZz9ulE24dQUQCB2qIeNW7KMTTckfXsE5Ykw49cKi95gDbjLwW+EIK7BOzAqljTokUWWbRhjTfH4ytjymg== 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)(36756003)(66556008)(4326008)(66946007)(66476007)(8676002)(86362001)(54906003)(8936002)(6916009)(316002)(6486002)(38350700002)(38100700002)(5660300002)(508600001)(52116002)(6666004)(26005)(6512007)(186003)(83380400001)(2906002)(6506007)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/ryOXI34iC3rqPHJOFW35lkqP5mOxZx6g3kBZ+71vUn8kkcydmHPVEixOb+c?= =?us-ascii?Q?29tYul6jADupXAmeF32AzFeX+2LtRhQrP69OBhIdz9IgdH/k8CZVTUYES5R6?= =?us-ascii?Q?Hq2FK7qIWc4jC61I4VE54YU9qEvbL+DXiDX7w/toR0ux7Qyzj+kPcGeRXyRy?= =?us-ascii?Q?2Hhn2s/42xCWhdSvJuRxlDzhazFRs5GsHhm9ztTOSJqzL29zYot6S4GIQenz?= =?us-ascii?Q?TStVPWhU5XF+y2fuEOZ3nVbafsh/6rBG6gRKG1oa8SFkGuRxE6w+Mo1TT2NL?= =?us-ascii?Q?ibdyGxfIvJCivnNxEhwraP+sv/Tj+xz809CcyZnVP1AXv+lUThq2nyX6ZbG7?= =?us-ascii?Q?pOXsJ/86HKX1MWinQkjNWJjgz0uVze95Cy8NFK4/35acL5VxsjYTraWEAX+F?= =?us-ascii?Q?mMPw+UZsuVwMPK+T1hJHt6EWNYyUeoCU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Mva/vsvwxde95KtRCViBc/VHFuK1b7tHi2VUOn3G24y22lxT?= =?us-ascii?Q?57LrUG9ii5JrfHnugOEjZ6bgCYtDL67jTkfGHM8KJt2tHG6rRNPN7OeG12PF?= =?us-ascii?Q?alnVhF2uCAdnITGtveeG0dcI173koJ9X3s10EnEz2gYp5nvH5JHA30Kk7gan?= =?us-ascii?Q?gJD5xj0RqQW9+tnugKFTgXZxf5gp7inl45CV8IQF2mmh6zpzDflc95iVqsuQ?= =?us-ascii?Q?CGd0VlRoqIZdJfFvfoSdFDo/eLd4A465DwLvikzpCeHDJ+OAbnKfX0ice/yi?= =?us-ascii?Q?ECeaiYUquQMGjD9fKZUvJUxuXNoiG4VEYrZowwErjhxaPvuGr73ZM36lmfwZ?= =?us-ascii?Q?AkygN8qGnX4LRmsjWfRzmX+prqhxBbKAIUfUdVpy7XCg8s1QTPZU9OJqtcR3?= =?us-ascii?Q?Wy/48yKRZQ=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bbfcc83-9376-44ea-e588-08da39cd5b06 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:25:38.6010 (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: SgjpamUU7Zles0nvfZ3L2962EjbkcuRqImJYBhQ7pfvTNpEsipDbehHQ1lomgGJacn+0d2bN1h7FYNO/dvyc/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9562 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..f61706c9eae6 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