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 D48B945AFE; Thu, 10 Oct 2024 09:46:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E319F4060C; Thu, 10 Oct 2024 09:46:24 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2091.outbound.protection.outlook.com [40.107.94.91]) by mails.dpdk.org (Postfix) with ESMTP id 763EC402CD for ; Thu, 10 Oct 2024 09:46:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YKX1U0wMxlCeeR52NW6nr8fmN9f1RUOTImEOH8PRkxIoRJG1dXjVGJp4vghWFG22KMLSFpeGkhgniC/7HR5RbZ/r7CahnekY6uDkCHvxlHajv1z3YsJZpRhsAOUdQmEHO+/hhV31Un70J+74yPgFTVl05IcOqv+VQbNSzZJ5xBk3JhWVzlvd1cRmHyd04fjPPMA3OCXGWl+zau5leCAA00i7AVDUn9d9cNHTAFRBUmbIiSQ6wH/JwS4uj1gusXXkKVv2ejWrq6U5X83reWMbyYBubZEF3NEwgTHqkDZxg/3S1EpGRdrY1S3gturByfD/3hpK0aX5Esb2UJKwOsisGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kqFwlobJbxnfzKcqAuwBpq9tM5hp1nu9DxfgTUrhtjQ=; b=H1EKvXzvyvfY3FZHZhPgAE1mgamEzvGTZFX0EvNAXNlRH5iZuHT9+mv6WHztpvNJIyrCnztRGG+IERPEDuHRgmZzShekW0STm35mUHkMPB3Brgzrz1071H4XP87TEHOScp7buPX4Pq8Z3Vi0GmXiLqx8rme3tqZoElI6O4wxUl3120GUOxhug2t9Ezg7xbHL3lICugIOqh6MKea48W8YWqGcCf9DXnmRFdiIg6Ix/jwfooq4Gzlix1PAcq4L4pd4Ulyvk6Rjmb3BnK2W+MXcbXAhvHWu3siZTf6zLVBOAhhiASoaJdvtKVQSNyjdFirY/LsHiYObT0pSOHMT1XGQnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kqFwlobJbxnfzKcqAuwBpq9tM5hp1nu9DxfgTUrhtjQ=; b=UbKN6IIfUhwRBbl7aK9NxWSLC6GVWrgeIUnx3r2+6w4GH/YlF0A8ljIr9Fyl2ysGJoHHYX+B48uOyc3cKoc5CVZ+WrnkzCmyXScbpNgGLxENO5NvB7zWD4GBzeJKTqAHYWkwcqdocERE7dlCV/DfiZii4mQnDf9yv33Au6gEVxo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by DS1PR13MB7099.namprd13.prod.outlook.com (2603:10b6:8:210::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 07:46:20 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%5]) with mapi id 15.20.8026.020; Thu, 10 Oct 2024 07:46:20 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He Subject: [PATCH 2/2] net/nfp: enhance the flower service framework Date: Thu, 10 Oct 2024 15:45:57 +0800 Message-Id: <20241010074557.3622716-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20241010074557.3622716-1-chaoyong.he@corigine.com> References: <20241010074557.3622716-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR01CA0033.apcprd01.prod.exchangelabs.com (2603:1096:4:192::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DS1PR13MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 449839d0-353e-43f5-d8a4-08dce8ffa15a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VCGjU2VXtVnIv4GrDtAlgEtIDfvnlQMt0RHCs41nbEkzdHHyVZ6rXFXhPnjz?= =?us-ascii?Q?sKxaBzEg2pzpSeq39zVzA7ZFSNxHQ+JTBuIdMWkSkoYBYYK78fF9GJhgxdCP?= =?us-ascii?Q?pok/aKUOqofmnBvFPW/VMOFr0X3JCt273jlUWL/s7zmoNdBqgRFrw7DX7ga0?= =?us-ascii?Q?7HXZloBMwg0GtNnVS5eTMK5PXsF5Lwan0zYxu1lFgckySIhbF5EMifSJAujs?= =?us-ascii?Q?FZZ0uHqJn2dDyipnfGirJz/tXVtUw07Vpc71Ijh1Q+EHPw9SfBKEuPEUrrVl?= =?us-ascii?Q?lp1WQe32fmsMYKtVIBjuqVctE0wBufYCM0f6Vs+D3USM30yoGv5gY3qtPr7H?= =?us-ascii?Q?2fBPRi/pW44zhOYuPIEV+S7TK+P4a1jhB1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?yR43PiWMPfQk4yqovKC5lIYa+CyIGaUthNqamk0prGkUyC+c+QvallJ4W18j?= =?us-ascii?Q?qfDqcP7MUqiWP0TajGLJ6EIby+AiZ8BR6ZArOsKV3PGErA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024)(52116014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?K3E+8N+r5kzLAoJlCe+8SJbHncttTqPEMVq7k6ub0AVQ/bWp2Iht0dH5KxG7?= =?us-ascii?Q?vYSDR4tyqlo1nNQXxPGFN1er9YASGrnYGL1q+mZew12Z9ZXBhStHuzCBjKhj?= =?us-ascii?Q?/RaLj2diSawqiCZ+RTcHtek9BOY4/cBk3e778tHAGboNYrJQw4haVbl06Fwu?= =?us-ascii?Q?z2coKfXygrEDBu39kluZsobdBcetruTUM3swDfW3U4u+wsJHWq0TQwyHPjGq?= =?us-ascii?Q?zfaMsU7MCu96ftDxlmWWRyEy7Zwk6nd2NCT7chKJ+khDPWoWRUHUeEsRUW1k?= =?us-ascii?Q?A4yHCvlis+yk+iPzYwAf2Tvhc9syrYQdNXJUymoCnfIxtdn/JCxBW0Ejz6vm?= =?us-ascii?Q?mhH4U6+ReI5JD6B0WiVOvK/v3WI0wYJqdwpy5K/TGDCTm68nKR9KKwErI4wC?= =?us-ascii?Q?S+YqWPqgbITj3rE77k7TEK75NY4ZEphqU+AHM14nAgYEZSxVopw5O22lKoqw?= =?us-ascii?Q?9Aw24YZ129vAS91U6rZ98RQueLiQ3JWBEP8c4Yb6OjycTZEx6x/DLHk+3s6/?= =?us-ascii?Q?DDSx+W1tOqutEoTLlsI/nHu/7sO7CoJa7nh0JQeu3snI+hIJbHBRXYT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iaDNK9vutaN3tvX/FPO+tV4WCCM2keDEVHz7O81jFKaH?= =?us-ascii?Q?rQImQfGfIw3KPbaiAgPucGHcoBudB0N5Mzdvw6R+PPiRmxN2jRpIXbBuftTi?= =?us-ascii?Q?YyntaRkBC02L9RcbI3djeYfcYMX+6WY1prKSmKAvFuD5HlLwyF7meCn73zYe?= =?us-ascii?Q?bA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 449839d0-353e-43f5-d8a4-08dce8ffa15a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 07:46:20.2763 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CvyfzA7NYRzRq9c/tgp9pzD5kKpj+NsoP6c8PDTy2fumx/Hy2N8IeBVvReAuxHXVkp56ARSWQSSfBb1TkgDVbn3UfI6jTMtIIK9Q4+DEjeA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS1PR13MB7099 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 From: Long Wu Some DPDK applications may not have the service core which can be used for the NFP flower service, so enhance the flower service framework by adding an alarm for this situation. Signed-off-by: Long Wu Reviewed-by: Chaoyong He --- drivers/net/nfp/flower/nfp_flower_service.c | 70 +++++++++++++++++++-- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_service.c b/drivers/net/nfp/flower/nfp_flower_service.c index 782f083b71..aac11dbb94 100644 --- a/drivers/net/nfp/flower/nfp_flower_service.c +++ b/drivers/net/nfp/flower/nfp_flower_service.c @@ -5,6 +5,7 @@ #include "nfp_flower_service.h" +#include #include #include "nfp_flower_ctrl.h" @@ -16,9 +17,13 @@ /* Driver limitation, PMD can enlarge it if need. */ #define MAX_FLOWER_SERVICE_SLOT 8 +#define FLOWER_ALARM_INTERVAL 3000 + struct nfp_flower_service { /** Flower service is enabled */ bool service_enabled; + /** Flower alarm is enabled */ + bool alarm_enabled; /** Flower service info */ struct nfp_service_info info; /** Store flower cards' information */ @@ -33,6 +38,52 @@ nfp_flower_service_handle_get(struct nfp_net_hw_priv *hw_priv) return hw_priv->pf_dev->process_share.fl_service; } +static void +nfp_flower_service_alarm_func(void *arg) +{ + int ret; + uint16_t slot; + struct nfp_net_hw_priv *hw_priv; + struct nfp_flower_service *service_handle; + + service_handle = arg; + if (!service_handle->alarm_enabled) + goto alarm_set; + + rte_spinlock_lock(&service_handle->spinlock); + for (slot = 0; slot < MAX_FLOWER_SERVICE_SLOT; slot++) { + hw_priv = service_handle->slots[slot]; + if (hw_priv == NULL) + continue; + + nfp_flower_ctrl_vnic_process(hw_priv); + } + rte_spinlock_unlock(&service_handle->spinlock); + +alarm_set: + ret = rte_eal_alarm_set(FLOWER_ALARM_INTERVAL, nfp_flower_service_alarm_func, arg); + if (ret < 0) + PMD_DRV_LOG(ERR, "Set flower service alarm failed."); +} + +static int +nfp_flower_service_alarm_enable(struct nfp_flower_service *service_handle) +{ + int ret; + + ret = rte_eal_alarm_set(FLOWER_ALARM_INTERVAL, nfp_flower_service_alarm_func, + (void *)service_handle); + if (ret < 0) { + PMD_DRV_LOG(ERR, "Flower service alarm initialization failed."); + return ret; + } + + rte_spinlock_init(&service_handle->spinlock); + service_handle->alarm_enabled = true; + + return 0; +} + static int nfp_flower_service_func(void *arg) { @@ -109,11 +160,15 @@ nfp_flower_service_start(struct nfp_net_hw_priv *hw_priv) } /* Enable flower service when driver initializes the first NIC */ - if (!service_handle->service_enabled) { + if (!service_handle->service_enabled && !service_handle->alarm_enabled) { ret = nfp_flower_service_enable(service_handle); if (ret != 0) { - PMD_DRV_LOG(ERR, "Could not enable flower service"); - return -ESRCH; + PMD_DRV_LOG(INFO, "Could not enable flower service."); + ret = nfp_flower_service_alarm_enable(service_handle); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Could not set flower service alarm."); + return ret; + } } } @@ -157,8 +212,13 @@ nfp_flower_service_stop(struct nfp_net_hw_priv *hw_priv) if (count > 1) return; - if (nfp_service_disable(&service_handle->info) != 0) - PMD_DRV_LOG(ERR, "Could not disable service"); + if (service_handle->service_enabled) { + if (nfp_service_disable(&service_handle->info) != 0) + PMD_DRV_LOG(ERR, "Could not disable service."); + } else if (service_handle->alarm_enabled) { + rte_eal_alarm_cancel(nfp_flower_service_alarm_func, + (void *)service_handle); + } } int -- 2.39.1