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 C160D45BB4; Wed, 23 Oct 2024 19:01:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2027542EE5; Wed, 23 Oct 2024 19:00:53 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 1DA8542EC8 for ; Wed, 23 Oct 2024 19:00:48 +0200 (CEST) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2047.outbound.protection.outlook.com [104.47.11.47]) by mx-outbound42-14.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Oct 2024 17:00:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dbX4etitwAXv4S52wOeS7AXEQ21wtNlr+yMbvKWQDpFgCxyB7NfehoZBR3K/KW5NXd3VVatIZIWHkUECtPALsdX7QsfgJ3orvhjQwl6sFnmCeQ+zMs2WTvqcTlVIGTUowFYNqW0EJt/HiUFgzd/TlCdwlpl3ZVb/L/k5ZP3Px6IqAoGA+DeLGKtC+Xhobca3XvdmWyCeCLE0gPVdsq2L9lRaz45YE4LaZHKias5Dt0nCKYRFQwiBlD/ZKlTFw6L84jrre4E6uzu2TqPfkdm4nq9/gwzmxArIoIr7p3udlLKnBP+UdUnyL7YXjaHOhNGOA99sE8z1gCDycLFjqwkd6w== 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=2Z0TKx9BCIc56PcqQyuHWH0layhoKQUWUFeXa+RfD3I=; b=jt3nLj6CBja5okPmHxI5QDkzztFo3vTeGA4c+YInFSzOmCxUQnblFBOCbjOX9rv99lksW00/xFid7CWcY5ayzPXAXbcLkvXkn8aTdV0v4AQGeHoUoE6lPGt6CNorZ9jLMTDTbCsQn9RB4BiXLKmUKxDeYCu8+zkZ6Bkz4SrK0uJ7OjWVJtHpDs+ZvKCRrssEGLz7DwIGR9nVMQSLzrdbGP0WYzTyQtIxO+vO+BKC4W1aV+BoAXetaJKUosbvke2cdPg+8VGiHFLhXsh8WWhc+xUAmZ6gChuAbV/TR+vz0Gm9P7eYiteCY3aEdoJUczmgxuZFycWoxZTwhq3ThZEaMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2Z0TKx9BCIc56PcqQyuHWH0layhoKQUWUFeXa+RfD3I=; b=iICZKCNYqe9wNdSzU51rRk+ddNmdOjXV1MJ0WmVKcGY+1FZJ+2o3Yp7Xd9o5XH9gVDWml6FlIqZKMYhHGS18cbaDqNk1u5dzef6fi1KzaXc0ZGgRC0DPfGnJHrw3+60uY34giqFZKrXLqwdvjeAZdKsrF8vMtmqkvKSAmbzvyAg= Received: from DU7PR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::6) by AS8P190MB1960.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:52d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Wed, 23 Oct 2024 17:00:43 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::9c) by DU7PR01CA0006.outlook.office365.com (2603:10a6:10:50f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.31 via Frontend Transport; Wed, 23 Oct 2024 17:00:43 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DB5PEPF00014B9E.mail.protection.outlook.com (10.167.8.171) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Wed, 23 Oct 2024 17:00:43 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com Subject: [PATCH v3 04/73] net/ntnic: add internal flow create/destroy API Date: Wed, 23 Oct 2024 18:59:12 +0200 Message-ID: <20241023170032.314155-5-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241023170032.314155-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241023170032.314155-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B9E:EE_|AS8P190MB1960:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: a5d1df68-4a6a-4f38-282c-08dcf3843b51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5FMQz5ItFzXrE5py/hkM7xyawr700Mba5SfCz1b4+gvYLqDzbPZ4KsJYX8vk?= =?us-ascii?Q?nw7pkubt72zgjFczVjLC0jt7EFCEkuYW98i1dCKU2MhVYlQ0rwbEys/wen85?= =?us-ascii?Q?bz6toDteUgrp3DEkdmFGsnIS612RWaU2qqH1hwZ/Brz5tftvSIm44vgqXoKA?= =?us-ascii?Q?gzoatMVXSR2IYxS8pOE3U3P+Se0fHvGMUliL1r1YKXEffGpoRmXtZVC+eGQT?= =?us-ascii?Q?x0g3xbZPXcui1n1jBuRPoQADBdVXvgozlYmhBKqFZMmbhWo8DCygnBefcniP?= =?us-ascii?Q?0StVvAosYAT490ZvhuTGhhU8Teii+ygA0O0j7bEszAkj0IWeaHrt9bjjIiiK?= =?us-ascii?Q?btyrHYqDSoSlH49AoSb23c9J+NjBFmd3v95jJBZC3lrGCi9D9+ZG9v6hoQXN?= =?us-ascii?Q?HYyC9EQLctRFrUTIXdYXbl+A3rKKLBO3DcJNgC7O+5+8Fexih6CY2OsflVSX?= =?us-ascii?Q?FJK4YyXu++5wBJZKrqC3XUitMhYh7JGt8xNlDiu0PtmuQrGtARvJlnSR0bdv?= =?us-ascii?Q?ZgUdnd/4MOfm/U6wTN5pFJMohOntp6xny3H/1F11+CSiVLgN2nVIgMGHz+Dz?= =?us-ascii?Q?MqXdov4+OhzRye8X7RTOokNmevrNGWolCfVDQXcLccrxrLdQOVYM/uFrqBOl?= =?us-ascii?Q?jVn9l5Yp35ScSD/xnOmn0JHdmKSel8nyrGW6NH5/kzIzcRJR3nSFx5LkTPPj?= =?us-ascii?Q?Tt3rtuShi8eyDEi4Q2cO1POyfeI73rdePTnywyBjObNeMy6M/wjP79z0AxvT?= =?us-ascii?Q?MpdRqoWX6TWDfv34L3U/TycR2uxDQ7cUsOgngAF6ieEqdl15ZcpPixyAGFBc?= =?us-ascii?Q?GAGjU9ULqViKNSVsiDytbK9P7mp7anQquJJLYHztIRSLQoyn/bZuFZZsYojc?= =?us-ascii?Q?VR0OnwgU4b+p3G8+TdWDY8kuCl8zbQbPQHQUyX6NoAmt+eiU0+3ILN2zpNmW?= =?us-ascii?Q?/OkWF/c+ltG5Jo8mLr5YcovPrrV4CbQ6ZzxTwZ8KBRKTZ+R+2jxpvA04eduB?= =?us-ascii?Q?yR/Mt/xhZuO9GAvY5OwNqa+6/D+jg72dp2i8g+i7IJT9jk0GF0/FvcNkYVn2?= =?us-ascii?Q?okwnNuF25rpN2mKe2bmnT2wPg28exW/edycJaEZ5tHRhnNb4KPobS+m/jjXF?= =?us-ascii?Q?GE5/0ZE55Comf2/QvARQnbHlYQS8Dw8mzQNcw0fb6Rw5Pvpr6N+Y6yrWFld8?= =?us-ascii?Q?fyx1O6h4oFSU4t+JzX6PxFfvD+P2MokaWyPMCGGagkdyK95O3mJpdYGBYb0A?= =?us-ascii?Q?9JKDZ4GH1XIWZpSM/vpzP3V76nZPYaFun5P337zVpv0Rg6Fk4S65xmYzqkQb?= =?us-ascii?Q?z3sfikAnn9klIVrXOH46EK94OJq34WjpU522gGd1F+go6SJnSvmPDr7BEK+G?= =?us-ascii?Q?4eM4WpsyU+cqso8EDn6eyFM9zauALCMjuXMDvvS85L3KwnD5PA=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 3C6dQs8ebOR2QU9u9ykalv+z+YNmDcT5hvwHyS0qQZHlwGEPDBQMFkOcM4Cr5bFaCO/L9kBb1+XPcGGL5ognEnZxTtMjGWzbmQ/4vlbGzqIih6o5xRYHLCrdCtV1pBFYJVpPfYcP0UlfaBkxcu7T/+loc0vRTpFwh+z99EV+oHV554AMiQ8+qh6Jqx62SJYZs9tBofgKwzKvuAJxy6lJ4l4SQZfaT4kDka8laU3xvbKaPSPI2VkC8fs1s+JoDcAFVALZP96VYLnVpntUGMTkvQ1VlG2w8OHCtQJIE0TP1YdUwmN44Un/JIUEIJBeAez4vTafOx9bJ/LF/fsSJZQwSepFGbwsJ6bQf88D0e4LUODhKTTM1pcaUk3S87bbKTV0egkJ6gehdr36IdmazIgPtT5pFmsOmVyREBEOwsx0hJZ05a5Nw/MvKK9gNiVB3RhIivL1KtOTJLXr3xhZeSGRU3WpTeJw/F9lM3fy8hSk6pbuWzLILS7bD04RcZQU6JJLlm6rE4vqrdb5V46K+ipP8wr0Y2878qqy9BFsDunzOS3/9CVxY/kwFpN7DyrHRt3cjXDnB/eBA8ATs0Pops29kp2uh9E13J7Xv6hqz/fEnuCeYABLsgWJsFK0jeEoOOdCLHVthybt3dBTGTUSy7MwR5pWOJAZepCwgQcCP7JwiRI= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:00:43.2892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5d1df68-4a6a-4f38-282c-08dcf3843b51 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B9E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1960 X-BESS-ID: 1729702847-310766-12812-42086-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.47 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmZmFkZAVgZQ0MLE1DLZIjHNON nMxDg1LSnN3CglKcnQ2MIoySzNJDFVqTYWAKpeF85BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259925 [from cloudscan19-22.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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 NT-specific flow filter API for creating/destroying a flow Signed-off-by: Serhii Iliushyk --- v2 * Change cast to void with __rte_unused --- drivers/net/ntnic/nthw/flow_api/flow_api.c | 39 +++++++++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 66 ++++++++++++++++++- drivers/net/ntnic/ntnic_mod_reg.h | 14 ++++ 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index f49aca79c1..d779dc481f 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -117,6 +117,40 @@ static struct flow_nic_dev *get_nic_dev_from_adapter_no(uint8_t adapter_no) return ndev; } +/* + * Flow API + */ + +static struct flow_handle *flow_create(struct flow_eth_dev *dev __rte_unused, + const struct rte_flow_attr *attr __rte_unused, + uint16_t forced_vlan_vid __rte_unused, + uint16_t caller_id __rte_unused, + const struct rte_flow_item item[] __rte_unused, + const struct rte_flow_action action[] __rte_unused, + struct rte_flow_error *error __rte_unused) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return NULL; + } + + return NULL; +} + +static int flow_destroy(struct flow_eth_dev *dev __rte_unused, + struct flow_handle *flow __rte_unused, struct rte_flow_error *error __rte_unused) +{ + const struct profile_inline_ops *profile_inline_ops = get_profile_inline_ops(); + + if (profile_inline_ops == NULL) { + NT_LOG(ERR, FILTER, "%s: profile_inline module uninitialized", __func__); + return -1; + } + + return -1; +} /* * Device Management API @@ -604,6 +638,11 @@ static const struct flow_filter_ops ops = { * Device Management API */ .flow_get_eth_dev = flow_get_eth_dev, + /* + * NT Flow API + */ + .flow_create = flow_create, + .flow_destroy = flow_destroy, }; void init_flow_filter(void) diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 74cf360da0..b9d723c9dd 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -110,6 +110,13 @@ static inline uint16_t get_caller_id(uint16_t port) return MAX_VDPA_PORTS + port + 1; } +static int is_flow_handle_typecast(struct rte_flow *flow) +{ + const void *first_element = &nt_flows[0]; + const void *last_element = &nt_flows[MAX_RTE_FLOWS - 1]; + return (void *)flow < first_element || (void *)flow > last_element; +} + static int convert_flow(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], @@ -173,9 +180,17 @@ static int convert_flow(struct rte_eth_dev *eth_dev, } static int -eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow, - struct rte_flow_error *error) +eth_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *flow, struct rte_flow_error *error) { + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + static struct rte_flow_error flow_error = { .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" }; int res = 0; @@ -185,6 +200,20 @@ eth_flow_destroy(struct rte_eth_dev *eth_dev __rte_unused, struct rte_flow *flow if (!flow) return 0; + if (is_flow_handle_typecast(flow)) { + res = flow_filter_ops->flow_destroy(internals->flw_dev, (void *)flow, &flow_error); + convert_error(error, &flow_error); + + } else { + res = flow_filter_ops->flow_destroy(internals->flw_dev, flow->flw_hdl, + &flow_error); + convert_error(error, &flow_error); + + rte_spinlock_lock(&flow_lock); + flow->used = 0; + rte_spinlock_unlock(&flow_lock); + } + return res; } @@ -194,6 +223,13 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_action actions[], struct rte_flow_error *error) { + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized"); + return NULL; + } + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; struct fpga_info_s *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info; @@ -213,8 +249,12 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, attribute.caller_id = get_caller_id(eth_dev->data->port_id); if (fpga_info->profile == FPGA_INFO_PROFILE_INLINE && attribute.attr.group > 0) { + void *flw_hdl = flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr, + attribute.forced_vlan_vid, attribute.caller_id, + match.rte_flow_item, action.flow_actions, + &flow_error); convert_error(error, &flow_error); - return (struct rte_flow *)NULL; + return (struct rte_flow *)flw_hdl; } struct rte_flow *flow = NULL; @@ -236,6 +276,26 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev *eth_dev, rte_spinlock_unlock(&flow_lock); + if (flow) { + flow->flw_hdl = flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr, + attribute.forced_vlan_vid, attribute.caller_id, + match.rte_flow_item, action.flow_actions, + &flow_error); + convert_error(error, &flow_error); + + if (!flow->flw_hdl) { + rte_spinlock_lock(&flow_lock); + flow->used = 0; + flow = NULL; + rte_spinlock_unlock(&flow_lock); + + } else { + rte_spinlock_lock(&flow_lock); + flow->caller_id = attribute.caller_id; + rte_spinlock_unlock(&flow_lock); + } + } + return flow; } diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 457dc58794..ec8c1612d1 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -242,6 +242,20 @@ struct flow_filter_ops { int *rss_target_id, enum flow_eth_dev_profile flow_profile, uint32_t exception_path); + /* + * NT Flow API + */ + struct flow_handle *(*flow_create)(struct flow_eth_dev *dev, + const struct rte_flow_attr *attr, + uint16_t forced_vlan_vid, + uint16_t caller_id, + const struct rte_flow_item item[], + const struct rte_flow_action action[], + struct rte_flow_error *error); + + int (*flow_destroy)(struct flow_eth_dev *dev, + struct flow_handle *flow, + struct rte_flow_error *error); }; void register_dev_flow_ops(const struct rte_flow_ops *ops); -- 2.45.0