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 5852BA0503; Thu, 19 May 2022 19:43:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 324BD42B7D; Thu, 19 May 2022 19:43:43 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2122.outbound.protection.outlook.com [40.107.21.122]) by mails.dpdk.org (Postfix) with ESMTP id D4AA340156 for ; Thu, 19 May 2022 19:43:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awMCLZEPUMX9IgbtKgGFFcaewcHdu77fjKnVNznwqC/W1hEnCdhlQfBEB3we54KNzKtwGDmXQXVz/5hINw721wGcDqBFUVS3uj7cfAPYM/S+F8xcdnRZBgWwc1e0Hv8yghugKrcAymDttyU2qIWueIV3SbejZByYVYHyggpFTHs4dknbIsDq/oOLE0/rCjK/wPgybD+Z3ct9B8GQAFU0GT+ClHm0DQ3DViMEuEgiw+8iw9rdWUSdvp70vSKYkA5amLQFrwocjdLZ07/uDSrbn2Ps70+C0HA+pZK8L5vZ21xYHwT8yYHS/NThJ4ppgZzvEJw3bGBrBH6I1bTYvZzPrw== 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=IdKNL7RhswcGl7wXhpzh4tqwE1W/R4g6L3oi8DpE610=; b=Q0GKgLzmzxt/7XKFQ7dzs9z/y3DBvV2L1K9XJJQJTw6bH/d2AeI/hFun2TUJnxCKt6BtHH43S3hPSZIvXSMAA0QuMzLWfSjLZpdZqHaKPTrXjjT1p8GWm63AMnxGOzyPEpmoJQs4zC1+0rBN9nnRsQMClXwK/w1CesRl3y+vfrPg1KmEGSCoTPGojBrh4mn9a03wtRa4VINVnRDQJ8wzt7c4fvV8QW6eeRgJIA+a0lE+mFipWV/ewYS5RAzd8lCLahSSj7hRujbALXR+p4sb8BYjrbQFmevU++JZOz5JqGKV9KqcNFhdjJv2Qcg3PIodTs0PF9P0mnyVdhlC9G9vbw== 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=IdKNL7RhswcGl7wXhpzh4tqwE1W/R4g6L3oi8DpE610=; b=NeYvbTheubZsks0D0d9kyos2DJADBUldKvvxpDBzWvGivvpvIRnqY8Xw1DLZti6usKR4pD+VSk95E3wekJP7tOGsZ8ApzNh3s1Qca2uPolqKsUrworwQlHdcce4ltJDznvyaxZNyW+Cb27+A4dHPJDT4R+FEvvFK1IBWLDzYLgU= 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 PAXPR04MB8160.eurprd04.prod.outlook.com (2603:10a6:102:1cb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.16; Thu, 19 May 2022 17:43:39 +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 17:43:39 +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 13:43:24 -0400 Message-Id: <20220519174325.23308-3-jeffd@silicom-usa.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220519174325.23308-1-jeffd@silicom-usa.com> References: <20220519174325.23308-1-jeffd@silicom-usa.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BL1PR13CA0026.namprd13.prod.outlook.com (2603:10b6:208:256::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: 5ec62fbb-f869-4451-9b7e-08da39bf1b81 X-MS-TrafficTypeDiagnostic: PAXPR04MB8160: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: 8wipVUaiBxmZ21zMH3HqMBhJJii2dIlQN6zdkzEqaFT1GzST1njrCs1tbb3DoRhwElrNt+QgoFWR4gDFIgPrVtsOyTBh9L7mjLj66od64/1ewpKiQXMFpkj6FEXXZs0CCiBNrba4D40ohGv2LOKG1u0dpRekPNRvGeqsM0T8up/MSIurxfeBKzjBq2v52QuC7tE+2NybCC/JEayQ29eGEhp+ZHrCmMD0WWAZrzV3GTwZBnlaf5xrsIeDpDZHbmCLD3jhT2dqeVUhCmgSS9zVkU5TUXi5nMuhKE6MvFN84fc2Cc1i3svju8h3gI7TpmEwr5KseX+hxKVg/jSIMTgaRl/8Ro019PG3FVN+w9CQ5543Wj/nFNiMHDodEsXBLO2zj/PzLFZriLpnDoZ1fC3ZFLnciZddSDDNfDG4UnqAZVElMM4Hhf4oWmYHJ3GpykPb9N4y8Vq8KTJXGuZzfbCW3wU+/NRQiw1XREbyGIeLzWBV9Z4+iw2+h+lVnTsFid8AWbkz0W3Ehua0gICUK1086Hxx8MQGQ1h4h788981HPUdpgN47iKd28yZM8Hlpam5c6y8uaCHOeQa8J+7YcdTHun+sGMg5+6lbuuXzpAWKGMd+sfBetOeg2gVXCXTMzEkpHjn0tGhjg9t74VwxXOEe22OKEvk9xYFuBvAWwjAcw5SK7S1Oq9WfqVlYN5ksv+xBmpCdtjyAhooIyaoJeVJ1wA== 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)(6506007)(2616005)(6512007)(26005)(36756003)(83380400001)(8676002)(66476007)(66556008)(4326008)(38350700002)(6666004)(66946007)(52116002)(1076003)(186003)(86362001)(508600001)(2906002)(38100700002)(5660300002)(8936002)(3450700001)(316002)(6486002)(6916009)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Dl8aun6zxd5NQFlNHXI1BN49ET+VZm7za4ZgqIYIYftTx6Yzrnj3tyDmBAey?= =?us-ascii?Q?1afqK2ZN/6ceEt3G+cbhw+17up5hOCNVLd3bAWw36qxpNQAp8Fd8dCeuRKQO?= =?us-ascii?Q?Mib9zga2QUr1t6KljiQVc2LlelIjWw54HzjGmSsVKBEXbwOINaW9i4K8wVkT?= =?us-ascii?Q?IOBgjgq/q84uP5eLjP5vZXglvS/u2kj6XT6TEkKs9ndpHNi1AN9X7mA0bwMV?= =?us-ascii?Q?luL9gcSzZowCemhjXxRUlChRt0Th7HCPYw/hldsMUvODEAGE7ZuoOAsLAi1A?= =?us-ascii?Q?ZPmmfCqDFOW3PK+yFlF+EawhNwJhc/O10ii6qiX6n7UrqBqc++zOJl4CJJlm?= =?us-ascii?Q?7p1PhimJHrVKDMAEYx79y33Lfj/AH7ri49JzFb2bojU2YbNja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f9HMhUlFQpAeR1tLZ4e9pc/5WIcR2tYkvhIn2jJT4eaql?= =?us-ascii?Q?JxOOvfJJmUtf7FWpuTZjIm0jd9oCfy7+3hfMysYJGfKmGDQRAQD9nU89otLL?= =?us-ascii?Q?XJ1N1yzS00BFLlXGmuQ2Ui1tH3PEF495fq1OnYl+bh3qcZMAZEwajMjFt4Am?= =?us-ascii?Q?cD5zMhWLQvMRg9rIRKIr2NYFWDapfWW5wd7QU6f/z7oaRDFLpzvXGh/MTiKo?= =?us-ascii?Q?IsR3gijW3jIgnG0Jxi4kr36WG0DIJfjrjqPTC7rhf0LQHWsWr7u2hj4EoxXt?= =?us-ascii?Q?XGMsLUVyOlALJVrFfhEc1Ki7JkdClk5Z9+th/ydf0kUTWDpUWV5SzL8WpKio?= =?us-ascii?Q?UnTT+8hQY3OY/7Tf/EECCf2OHMFbC5yPOAMI2BPOpO9sGxac2IazxABoxlRi?= =?us-ascii?Q?tWPpT4A5Mg6anAIkA5bjXl1uYhHRmoeOYT87ST7/SifXf2/drewG5rK9E6Ui?= =?us-ascii?Q?Pn2d1xFEiw=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ec62fbb-f869-4451-9b7e-08da39bf1b81 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3517.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2022 17:43:39.0455 (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: ub1LLT+fTABpdCPym2X6C4Rm6HcUIXBdpY1cEWA1R0eMLwtT5waFpC1hFF2c5ciZMBrqAqrsSe57Thwnj/Q/fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8160 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: , Reply-To: Jeff Daly 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 Inspired-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