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 64463A0503; Thu, 19 May 2022 21:25:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A66642B6C; Thu, 19 May 2022 21:25:39 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2121.outbound.protection.outlook.com [40.107.20.121]) by mails.dpdk.org (Postfix) with ESMTP id 9D92240DF7 for ; Thu, 19 May 2022 21:25:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=djMCmuYbkGYfgcvuUxJU6hd12YzlNgZ/044dRLiJaBTYUR13Xd/LT1dOaO6u62WdeF7j21QU7jvbx0i07osot/0L1Qgd8yhGOg33KVj+4xpdaTB25UmrfBcuvTwNsnWhoL5OobCa2+EZ/QTOMINWpgMBrDEA+ICh0jia6Cv0kpeTAdwnCqsfyJ/wpQKsnnxJAx+F9h+J8fwaGMOozAnFZ3iJ2onWa9KcuA3w7ILesELdwQXArdRTtfktjDdeYjBMYWeoKtsRcvM03q6AvxE+a9uIbOsoMT8B4gTPFllWr0+ZvvjCXNonC+UPhEZfIuPtw1dsXEKNdFvcufxRH05YuA== 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=O8VZnZsHaGRBjYJ4Uhj45f9cEFWOD2IWXCHQEYhN/BA=; b=Qp3DzvxJr086yVsikp7NIShsK48LSh/aennL3pUN+/RgVdVCEBMkddjLSeQ4v1/09EtFCeKAURSMZ+QhsXIOam2HBoZ0GhxlRV0pkzleuSesAu/o3XijG2tH7XUe/QjaXliEEtM/HnKnZyjZY9o3VFh6UGTLXevbYN3i/RQLiMaGGG9m2Qrts0EzrHMxK0kpz9aJiilX/8vb8rgAzIyMqeJA7OMgB96yLEEjTva8pqp7zFatE3zy+F26E0BK53dE3hgvlkXUptGJlEP5FvODQ3P8S90d/PXpcMmTz9txNKr3or/+l+z2eijzzmjZx0B+92B/HcLNu0hI4xzIf/dLFg== 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=O8VZnZsHaGRBjYJ4Uhj45f9cEFWOD2IWXCHQEYhN/BA=; b=B8VFnaYIe7WTNPb55pK82u9JMr1FwU+jKtSbdm59PfeHU/oiHGmF4jbuzB6CXM9ynhUqw7yU3MH1i3wS3UgaAxnIRkRc/Er0KMqvqGkG1Z/e0fx+hm7l+MHCLKLcGXpAZyx3FdBJKX/iGjBOcKVUWio1LfgPhabNCjLGW8OLE/8= 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:35 +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:35 +0000 From: Jeff Daly To: dev@dpdk.org Cc: Stephen Douthit , Qiming Yang , Wenjun Wu Subject: [PATCH 1/3] ixgbe: make link update thread periodic Date: Thu, 19 May 2022 15:25:13 -0400 Message-Id: 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: a51a7ce0-41c5-4cae-007e-08da39cd5955 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: oKm1n0fmZkPhqcW10Guw/mrDvzgclCg10ZWm2/OOOerl1OAQYxIhIG0irOhBhPuqqBJE/QX+UZi3quwVUNCR4fynKpQklU2KnEPEJT+ChXON4S5ysdD8Y54+lOZ9u23bZZWcfUTO+/q9pgUsM3XniOKzDeCR+rIsUtAS/Jt+fXoyJhmOdzFSrs2a6IfvzabpIdVxZjJgWpNgOQtBumFWpRIx87ScCNJJq/+sP0H/5VMz4mommxJVDXbPmFEZcU5NKArjQf9ct4sbtzABjwk+OcK+ibn4BYDQc8xQ0KvIDINbSVoyvTRhDj2DSpLyLoVWdmLZ3nU/76mbq5VY3lk07vWLfZXr2Wn2IcRQ7as8f4iMsYskxT0JP9+t9hMPT5lNFcXA5H3dD/R9KT81OBnreiOVITdQhETu0AIIMIxudlBMMBQv5OjyzF9dmUFMGbb67Li3j9w/PH6Uh25IccLSH6XszhNjT0Ezn8FbtcF9jbPNc6zq6m+b9+I9umjzgCTcXFtZhpvZPVGwkSjPAnxBBk2YLQAlMKUYP6y5w6gL23OhQAM3tPERSKm43QNRAgAn5pjhuTK3FwkkvGAdOnKIqAE86vLxznvo8l/Nl2CP2B2X+0j61TC5AOd97Oe9zXKbScWLxUuXnmyjJVYcgBmkrvwWAp8WVmbyLBefW6r/k3E17UnPHBKC9kQ8w5DpsGIQLdt5Ob7ZEl+SuabQG2o5/A== 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)(15650500001)(2906002)(6506007)(30864003)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6cjvlT7lgcyvoeCsYoc+IJ5C/sEnRfCl7S+KPu7c4OAgkQ1gM/tqrdsgGfJ8?= =?us-ascii?Q?qNtK8yfR6YOAOJ1cHpPcQqpC75GqesoW4tBBa2jHzxcDwAfXMWNUtzQyRf26?= =?us-ascii?Q?TQTMT5CuP6cdCs9nZEfOMqmhAegtN2WxQs9ofxe4a246K5dDS2bnllPxzloU?= =?us-ascii?Q?+JI7UL+bG3mqehj4jtkQBQ9m6brMyK0vuS8V79pToVt1Yzm4S/sFrvJ6Q3et?= =?us-ascii?Q?FrFgmochj9zruB29ll0T5fZ7DyZzEe49Z7Yzu7TcRTwgATZzjrBWusBpaGL+?= =?us-ascii?Q?y+8dNSvETrSsdNVImbvs/GSoyjE7XAi5P5WMKFqkTQaxx24SaCbGWM5xnnqC?= =?us-ascii?Q?C2bRs35THRnQUQeKKLqL/UrxScWgp7SoTqAkD7RvgODvyZolcNOAftEfQBqQ?= =?us-ascii?Q?TJOaks34k9czKTQhRMEszFWXb3pqg7VmCFIpTDd/aaEbFDeEI+Pr/S/a5+Mz?= =?us-ascii?Q?R9N2cKj0w+Z1PNggVlQAVT25Vg2qnGrRKK8pKbnlckpZZ+s5b85IibRIBuoj?= =?us-ascii?Q?+ccALe3MJraM+B0op/EgdzzAcj6JNQJ8iPzL6me5u4TfaOhHYVIZTrp2HDbD?= =?us-ascii?Q?MMsAma1KhuGISPBKW1aJ5GrYkwYfQsCcR3RwRnoeGs6Q2UbjtJO53Nc2/v8W?= =?us-ascii?Q?XUHAFInXEiEUNu3Tp42k4GY6DU7IUBZH2IX8lTOPm9MkfyJnw/gZEfWy2ow+?= =?us-ascii?Q?pYsQplKWRQV7DOABFdL7TA/MgELPwLC3frx62W0CNrrUt8xM1jUka2OB6SiO?= =?us-ascii?Q?zu+4xz7DKIRJpisjDb+Yh4W3wtCEInvyD8dRaMIPUuAppvMaDFUe2tZoefDX?= =?us-ascii?Q?dfyUgjRkAcjZyF4IrQgWMVs9NAII3S76YOEyopIUXZ6GgYDTVSlPwcvDmJXe?= =?us-ascii?Q?IVHPAg2NS2xzBRvlK4JR0blJc+nFb8ViC0kJYoOhCqvAxhEadwQMGyZObLTL?= =?us-ascii?Q?oTtLDkqPeamJnUY7bRxOVqQz2qkORO5dAEYcCjhwsZftf5LhwvKrzWNekTTZ?= =?us-ascii?Q?vcp1UMDDHirzrO7QRhF8KnxqZ+Tnq978OYauJ5zZ0rlTor/sTCNjMh94rmDn?= =?us-ascii?Q?lzw6mWvkk+yeuxJ+q2pSbs2uaKZf4zitYG7DQ9hsYJ/WkTtemAdiOOPRrvUO?= =?us-ascii?Q?hxvavK4e1vJ3Kxv4IsXgUKaVmuT0BhN7jzuNvor2Hn6x2TKcDBqU9wbxiHIL?= =?us-ascii?Q?I0kCqPCq7+3qHf8Y8BZOoQ90cIxxkQ8F5NwqZpucjvaWyD5KuAQBf1h2my/L?= =?us-ascii?Q?TzNznemBGGdjfyOhVbEcNtDSOx4wUwh1mwsbzC2KR9i0Q6LZ/C5pRjlXT0bf?= =?us-ascii?Q?iBL/vHCi4FmVU41qfI4Ai1goRppC0/55500FgVxxbltNWJCupgNxyMKmp/zS?= =?us-ascii?Q?+rspMjuCJZiFj5lzkz47+8i0dLVV9AylOkNxg3R3TwYll+I3vhIMOfOErRSb?= =?us-ascii?Q?2UKpdrMjefSGS9DCUSRupW6jwJ9RtzUVyj0S5iPUVjMMQ8dn/8ksHRIT9LP/?= =?us-ascii?Q?iOYKmTosSmkvUn8sRAN8Z886ckJ9wxTnTpfO89Us/78PO68v+go9GWgaHA++?= =?us-ascii?Q?xc6yN3OIs4WbIYbZyVGks3ZeW2MBtI1MsQjHK82WPsTjkmKdiZ5dnxLB8GPd?= =?us-ascii?Q?McyN0l9boEGC/ggjb+qAxBl/8QEiwXigZdPQtRZ7qcHkzV8xmitnERQ6Qtz+?= =?us-ascii?Q?JgyEKG9a6TuUhAkwqIGrCAbXqpEK8v80J/qwIi/ZkNeved52Sxd1lcNPVLzp?= =?us-ascii?Q?Gx4bFf5T2w=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: a51a7ce0-41c5-4cae-007e-08da39cd5955 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:35.8511 (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: VHvP4drjPwpH0s9Va0lE/v4PX3QTLEfTJwi1phs7LDcVsdnHRaZ8p2lubITNJFqcinAw867tOM6shsONHHVc8g== 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 Rather than run-to-completion, allow the link update thread to be periodic. This will set the stage for properly handling hot-plugging. Signed-off-by: Jeff Daly Suggested-by: Stephen Douthit --- drivers/net/ixgbe/base/ixgbe_common.c | 4 +- drivers/net/ixgbe/ixgbe_ethdev.c | 180 ++++++++++---------------- 2 files changed, 71 insertions(+), 113 deletions(-) diff --git a/drivers/net/ixgbe/base/ixgbe_common.c b/drivers/net/ixgbe/base/ixgbe_common.c index aa843bd5c4a5..712062306491 100644 --- a/drivers/net/ixgbe/base/ixgbe_common.c +++ b/drivers/net/ixgbe/base/ixgbe_common.c @@ -4154,8 +4154,8 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, break; case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: - sfp_cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & - IXGBE_ESDP_SDP0; + sfp_cage_full = !(IXGBE_READ_REG(hw, IXGBE_ESDP) & + IXGBE_ESDP_SDP0); break; default: /* sanity check - No SFP+ devices here */ diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2da3f67bbc78..81b15ad28212 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -230,8 +230,6 @@ static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev); static void ixgbe_dev_interrupt_handler(void *param); static void ixgbe_dev_interrupt_delayed_handler(void *param); static void *ixgbe_dev_setup_link_thread_handler(void *param); -static int ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, - uint32_t timeout_ms); static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, @@ -1039,7 +1037,6 @@ ixgbe_swfw_lock_reset(struct ixgbe_hw *hw) static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { - struct ixgbe_adapter *ad = eth_dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = pci_dev->intr_handle; struct ixgbe_hw *hw = @@ -1094,7 +1091,6 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) return 0; } - rte_atomic32_clear(&ad->link_thread_running); rte_eth_copy_pci_info(eth_dev, pci_dev); eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; @@ -1547,7 +1543,6 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) { int diag; uint32_t tc, tcs; - struct ixgbe_adapter *ad = eth_dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = pci_dev->intr_handle; struct ixgbe_hw *hw = @@ -1590,7 +1585,6 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) return 0; } - rte_atomic32_clear(&ad->link_thread_running); ixgbevf_parse_devargs(eth_dev->data->dev_private, pci_dev->device.devargs); @@ -2558,8 +2552,11 @@ ixgbe_flow_ctrl_enable(struct rte_eth_dev *dev, struct ixgbe_hw *hw) static int ixgbe_dev_start(struct rte_eth_dev *dev) { + struct ixgbe_adapter *ad = dev->data->dev_private; 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); struct ixgbe_vf_info *vfinfo = *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private); struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); @@ -2580,9 +2577,6 @@ ixgbe_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - /* Stop the link setup handler before resetting the HW. */ - ixgbe_dev_wait_setup_link_complete(dev, 0); - /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); @@ -2700,8 +2694,16 @@ ixgbe_dev_start(struct rte_eth_dev *dev) if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) { err = hw->mac.ops.setup_sfp(hw); - if (err) + intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; + err = rte_ctrl_thread_create(&ad->link_thread_tid, + "ixgbe-service-tid", + NULL, + ixgbe_dev_setup_link_thread_handler, + dev); + if (err) { + PMD_DRV_LOG(ERR, "service_thread err"); goto error; + } } if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) { @@ -2825,12 +2827,6 @@ ixgbe_dev_start(struct rte_eth_dev *dev) if (err) goto error; - /* - * Update link status right before return, because it may - * start link configuration process in a separate thread. - */ - ixgbe_dev_link_update(dev, 0); - /* setup the macsec setting register */ if (macsec_setting->offload_en) ixgbe_dev_macsec_register_enable(dev, macsec_setting); @@ -2860,13 +2856,21 @@ ixgbe_dev_stop(struct rte_eth_dev *dev) int vf; struct ixgbe_tm_conf *tm_conf = IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private); + void *res; + s32 err; if (hw->adapter_stopped) return 0; PMD_INIT_FUNC_TRACE(); - ixgbe_dev_wait_setup_link_complete(dev, 0); + /* Cancel the service thread */ + err = pthread_cancel(adapter->link_thread_tid); + if (err) + PMD_DRV_LOG(ERR, "failed to cancel service thread %d", err); + err = pthread_join(adapter->link_thread_tid, &res); + if (err) + PMD_DRV_LOG(ERR, "failed to join service thread %d", err); /* disable interrupts */ ixgbe_disable_intr(hw); @@ -2945,7 +2949,6 @@ ixgbe_dev_set_link_up(struct rte_eth_dev *dev) } else { /* Turn on the laser */ ixgbe_enable_tx_laser(hw); - ixgbe_dev_link_update(dev, 0); } return 0; @@ -2976,7 +2979,6 @@ ixgbe_dev_set_link_down(struct rte_eth_dev *dev) } else { /* Turn off the laser */ ixgbe_disable_tx_laser(hw); - ixgbe_dev_link_update(dev, 0); } return 0; @@ -4129,54 +4131,58 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed, return ret_val; } -/* - * If @timeout_ms was 0, it means that it will not return until link complete. - * It returns 1 on complete, return 0 on timeout. - */ -static int -ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms) -{ -#define WARNING_TIMEOUT 9000 /* 9s in total */ - struct ixgbe_adapter *ad = dev->data->dev_private; - uint32_t timeout = timeout_ms ? timeout_ms : WARNING_TIMEOUT; - - while (rte_atomic32_read(&ad->link_thread_running)) { - msec_delay(1); - timeout--; - - if (timeout_ms) { - if (!timeout) - return 0; - } else if (!timeout) { - /* It will not return until link complete */ - timeout = WARNING_TIMEOUT; - PMD_DRV_LOG(ERR, "IXGBE link thread not complete too long time!"); - } - } - - return 1; -} - static void * ixgbe_dev_setup_link_thread_handler(void *param) { struct rte_eth_dev *dev = (struct rte_eth_dev *)param; - struct ixgbe_adapter *ad = dev->data->dev_private; 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; - bool autoneg = false; + u32 speed, start, ticks, service_ms; + s32 err; + bool link_up, autoneg = false; pthread_detach(pthread_self()); - speed = hw->phy.autoneg_advertised; - if (!speed) - ixgbe_get_link_capabilities(hw, &speed, &autoneg); - ixgbe_setup_link(hw, speed, true); + while (1) { + service_ms = 100; + if (intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) { + speed = hw->phy.autoneg_advertised; + + if (!speed) + ixgbe_get_link_capabilities(hw, &speed, &autoneg); + + err = ixgbe_setup_link(hw, speed, true); + + if (err == IXGBE_SUCCESS) + err = ixgbe_check_link(hw, &speed, &link_up, 0); + + /* 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; + } + + 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); + } + } + + /* Call msec_delay in a loop with several smaller sleeps to + * provide periodic thread cancellation points + */ + start = rte_get_timer_cycles(); + ticks = (uint64_t)service_ms * rte_get_timer_hz() / 1E3; + while ((rte_get_timer_cycles() - start) < ticks) + msec_delay(100); + } - intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; - rte_atomic32_clear(&ad->link_thread_running); return NULL; } @@ -4219,11 +4225,8 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, int wait_to_complete, int vf) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct ixgbe_adapter *ad = dev->data->dev_private; struct rte_eth_link link; ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; - struct ixgbe_interrupt *intr = - IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); bool link_up; int diag; int wait = 1; @@ -4238,9 +4241,6 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, hw->mac.get_link_status = true; - if (intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) - return rte_eth_linkstatus_set(dev, &link); - /* check if it needs to wait to complete, if lsc interrupt is enabled */ if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0) wait = 0; @@ -4255,7 +4255,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, else diag = ixgbe_check_link(hw, &link_speed, &link_up, wait); - if (diag != 0) { + if (diag != 0 || !link_up) { link.link_speed = RTE_ETH_SPEED_NUM_100M; link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; return rte_eth_linkstatus_set(dev, &link); @@ -4267,32 +4267,6 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, link_up = 0; } - if (link_up == 0) { - if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { - ixgbe_dev_wait_setup_link_complete(dev, 0); - if (rte_atomic32_test_and_set(&ad->link_thread_running)) { - /* To avoid race condition between threads, set - * the IXGBE_FLAG_NEED_LINK_CONFIG flag only - * when there is no link thread running. - */ - intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; - if (rte_ctrl_thread_create(&ad->link_thread_tid, - "ixgbe-link-handler", - NULL, - ixgbe_dev_setup_link_thread_handler, - dev) < 0) { - PMD_DRV_LOG(ERR, - "Create link thread failed!"); - rte_atomic32_clear(&ad->link_thread_running); - } - } else { - PMD_DRV_LOG(ERR, - "Other link thread is running now!"); - } - } - return rte_eth_linkstatus_set(dev, &link); - } - link.link_status = RTE_ETH_LINK_UP; link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; @@ -4566,6 +4540,8 @@ ixgbe_dev_link_status_print(struct rte_eth_dev *dev) static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev) { + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = pci_dev->intr_handle; struct ixgbe_interrupt *intr = IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); int64_t timeout; @@ -4605,16 +4581,14 @@ ixgbe_dev_interrupt_action(struct rte_eth_dev *dev) if (rte_eal_alarm_set(timeout * 1000, ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0) PMD_DRV_LOG(ERR, "Error setting alarm"); - else { - /* remember original mask */ - intr->mask_original = intr->mask; + else /* only disable lsc interrupt */ intr->mask &= ~IXGBE_EIMS_LSC; - } } PMD_DRV_LOG(DEBUG, "enable intr immediately"); ixgbe_enable_intr(dev); + rte_intr_ack(intr_handle); return 0; } @@ -4637,8 +4611,6 @@ static void ixgbe_dev_interrupt_delayed_handler(void *param) { struct rte_eth_dev *dev = (struct rte_eth_dev *)param; - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); - struct rte_intr_handle *intr_handle = pci_dev->intr_handle; struct ixgbe_interrupt *intr = IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); struct ixgbe_hw *hw = @@ -4668,13 +4640,10 @@ ixgbe_dev_interrupt_delayed_handler(void *param) intr->flags &= ~IXGBE_FLAG_MACSEC; } - /* restore original mask */ - intr->mask = intr->mask_original; - intr->mask_original = 0; + if (dev->data->dev_conf.intr_conf.lsc != 0) + intr->mask |= IXGBE_EICR_LSC; - PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr); ixgbe_enable_intr(dev); - rte_intr_ack(intr_handle); } /** @@ -5316,9 +5285,6 @@ ixgbevf_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - /* Stop the link setup handler before resetting the HW. */ - ixgbe_dev_wait_setup_link_complete(dev, 0); - err = hw->mac.ops.reset_hw(hw); /** @@ -5398,12 +5364,6 @@ ixgbevf_dev_start(struct rte_eth_dev *dev) /* Re-enable interrupt for VF */ ixgbevf_intr_enable(dev); - /* - * Update link status right before return, because it may - * start link configuration process in a separate thread. - */ - ixgbevf_dev_link_update(dev, 0); - hw->adapter_stopped = false; return 0; @@ -5422,8 +5382,6 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - ixgbe_dev_wait_setup_link_complete(dev, 0); - ixgbevf_intr_disable(dev); dev->data->dev_started = 0; -- 2.25.1