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 BABCEA0503; Thu, 19 May 2022 20:03:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1286942B86; Thu, 19 May 2022 20:03:22 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2122.outbound.protection.outlook.com [40.107.22.122]) by mails.dpdk.org (Postfix) with ESMTP id 7F20442B75 for ; Thu, 19 May 2022 20:03:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eAQlOUNf4K/hFO2WWHCRNKuaIL8fUhfaeME97zPfkqh5NvAXxRy1Vx//Nn7ugZUts8s9gS6BwTjFNQVui0ATOA3nJk9PCQs11hWu8S0LQ7FwhQhLNf+AQyq4h9B+PdKOnPwVASj6WVRD4RpEwoireYw7r7WL3Uonk3tEu+M0rFumFUAoFi4ExzWQECY4EB8x7pVy7keZqejhh0OQMbsXUmDGNP1GjmHQl1DRkKsZ5q44PKwr693o2myYzgHuGquSLFh+f1B3NbT1uEGJeQo9ppqh/FGbdOI9EJCPQG8zsKjLqY+XqSiunI0B6l37JVahEBVRXGEueRulwcVTAuahlw== 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=m9TGb76kH2WUIu/Qo3gwN3E5yuPLZwqjpi7WaOgckMBq+9MnKwY1qckvqgP1mtW5LnW9I+VR5KWFHuPYmJBQsVetgm3LyaZNhqEpErQLSuz69dXLJB3zlzMvYR8lU/ZpgUICElhfYJAWfAmDz5091lMCI3TwvIJpFQocPbbGG84CFyOUvk0pJxEjyTMHnBxS8pWRRR/YB9kwOA66l++YqS8orPKszxJqVx9SNcB+mhNKXIzRLyo2cxY8NkpLJz/yBCyJ9FjyOLH76Eg8W+Vhn3kiuzrw8IOWlu+10UyJPdX9WC0JyTzgGvEmZ9GvytwHIVboZY5MCGQvu+LGJ0kAUw== 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=ZLgdtpwDPlVQpburrx1YHaKUN2LdBYcfVGIvo45FKR87yj5bu+sZrqtrGSdHs3BfEm2AqrEUFraEAHmNTkGzH9KDD2ANcOxTjqYw70wGpmlCB3+xrLB6Qa48O4TyiU4+QijiJDrvvNQ9iurTqoDWzx544+lKxzVuOEmK0GjUkK4= 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 AM9PR04MB9001.eurprd04.prod.outlook.com (2603:10a6:20b:408::24) 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 18:03:19 +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 18:03:17 +0000 From: Jeff Daly To: dev@dpdk.org, Qiming Yang , Wenjun Wu Cc: Stephen Douthit Subject: [PATCH 2/3] ixgbe: move periodic link service work into separate function Date: Thu, 19 May 2022 14:02:47 -0400 Message-Id: <20220519180248.23831-3-jeffd@silicom-usa.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220519180248.23831-1-jeffd@silicom-usa.com> References: <20220519180248.23831-1-jeffd@silicom-usa.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MN2PR03CA0006.namprd03.prod.outlook.com (2603:10b6:208:23a::11) 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: 7b89f61a-5e34-47ff-bc40-08da39c1d9f0 X-MS-TrafficTypeDiagnostic: AM9PR04MB9001: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: Nh3r3wNhuBvtzavCSe/Z5j43KtzK4FeA1fSDVaBicSkHaFAnHEDNVnn0mjdFkvx8lraKSINuh1Z15cUqx3j1O080ACU57V2IGdyfgM9NjxlieoPYnqbRozSmU+Hxm9wWkVLsP7hzHUsCMA+/ueW7v974aa0q2LP9SP6r1gIhfg8pWsqb1s/+0cMs0EqTZJQN63QgszlS+aUTIKoeahRWDJYJtdkuaERmp8rdYkCP55d8vndvtrj0k2TAZFM14YUFnTWnkLBqqgjTDxM5dNERsJuIJAKDPSPoJpIsBfKeCwf0OdaqszVRjP/r83gCysbfv3VFqQkCkw6x09JA0sLcVJSZK0OH5ztee2CYw2Qx3fJj65xJ/AqCR2wg2vN+PlLCjyRC6zWAeldGoGPUERRecnnH5fD7emK6eOBmE23IY1ULf3SbkUHte0IVChTzzb8YXT0jnD7pBkVWVkoncVKbI6btN7X9NDdwTFi5P0cNG2msc9mDOGaF49AnBoswbxSWeYq+WNK9C9hSxJQFxEF6KHz6tMZqSm2mbVZjg5rTQcEtLD91Gic3tYAEniLNt/s078zAOSFFgDVRSUiHHSzKLmxTP1STP1PUHv4cH0oAI/1XL00FGYZoEEFs5jEUX6+jwNfrmcRlSdEZe8xWwpArauLM7urN+D/uayc8++WsmudlYe2zy+aHx+Meah8P12QUovQF3z+IU/0SwqTwGHgEeA== 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)(83380400001)(2906002)(52116002)(6666004)(1076003)(107886003)(186003)(26005)(6512007)(6506007)(2616005)(110136005)(316002)(8936002)(36756003)(66556008)(4326008)(66946007)(66476007)(8676002)(86362001)(5660300002)(508600001)(38100700002)(6486002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?C6dYNH0WsoRxzEMp+GVz4j4T+AQ24psECmX3v8C9zumrgCuBMm5ZRzWuYldL?= =?us-ascii?Q?lLWhmf1DiIgLhxQN46qVPQwTyKVJ6q82ByCiPl2E6lMtb/I3oQhixp8GLfPe?= =?us-ascii?Q?YkltgK7iIu1XX1nwhChS1fYFesob005Dkq93xl07SNPERXnFXr8AoRMkqil/?= =?us-ascii?Q?aqmlg6HL8k5nvUM0sgzfLrYWRi2U5ou/qvXnZSWJ572ZbYicCqV7Tw0fOK+p?= =?us-ascii?Q?VS64FOmXD5HmBFfhlkX7UHf6Zp6hI1TcCd42naocNXJa35MZ6YX4gA7aEUxC?= =?us-ascii?Q?C5YN2fug2UAlqJOcWQDKM5z+pozrw81pff2Y58IWOLB1fPtjQCZTMffiPhca?= =?us-ascii?Q?mkRmu5qax/LVzaBcXtW4JN1arXm0h3eaTdhCIqL6nYL0xYHS7/gG4AIkkCgH?= =?us-ascii?Q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rHe1y3M9gIXL3K41n3w?= =?us-ascii?Q?A6xWjGz5+dkdJa5H4ejmoLKZffvqT2DxsidiqftNiL/AZrBpACc6Kxg/6IJZ?= =?us-ascii?Q?xaXqrIi4RUvvcQWSe89E4EetilzTJT2h7U/fw5oLMXaqRIoJ71CyVuzt6/cX?= =?us-ascii?Q?IKryVzMRFvrnOK2jpB+Y+n+KD0zAHYqo+wPKKSaTCa6h7CqYAty9gmR2hnBh?= =?us-ascii?Q?MJFN8LDYyY6o9v0Blj7AO2xRbQx77dxSg0XsbuI5kZFvCxmiw/PfajlZtgQK?= =?us-ascii?Q?6Y4B87rqFRZdpAT1VF8YX0TgzBqEjBO1nqX337lYtVMhPlmkzz2e1Tg0jln/?= =?us-ascii?Q?WEpEzJhe1R8RwG2BlOc9Y+ARYuKdCNprmUfiAG5F/055SmW/sR4ta6cpSouu?= =?us-ascii?Q?p4U+7MX3r7vn8frEgaEmZ8Q47dRSr2GyS0PMpTXlaPFoyS3agv4Nz412pV8M?= =?us-ascii?Q?1sIjbrSjEg=3D=3D?= X-OriginatorOrg: silicom-usa.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b89f61a-5e34-47ff-bc40-08da39c1d9f0 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3517.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2022 18:03:17.6281 (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: ABgsoXJUJ9YWTGvVNu9+OGP3eE+qXrEFYQud0AJ4L/3zrTZ6u+CCshgp9eLOb58Vc9zpuITMI2ok4wYH8fRQ2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB9001 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 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