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 E0315A0C43; Wed, 20 Oct 2021 17:15:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55BC841238; Wed, 20 Oct 2021 17:15:47 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2077.outbound.protection.outlook.com [40.107.93.77]) by mails.dpdk.org (Postfix) with ESMTP id 483F741238 for ; Wed, 20 Oct 2021 17:15:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hq5iIFvbbRUIuGPS+NjnHE9ukiJaRsjG305FrgImckhWt7C6G3g5wT51GAXla0LhXRoIBsO/5+L5YUzhh3aNAOYI8ae6rAlW8Pge6IRbztyT7faJt1liLyENildQeVNEhzj9XgvnJ0t4WP44207KO7jZmPr54G3HcrgVT2SuhLd+80lDjnrV6HyTq5I+E2St7tA48wqaGB/QvfxElo1jGWeaSVYPNrStV4G0H1TUH+nDxjFLWrBNet4Ib76pMJP1SkFWhV0+s3Yy37GZayA2SQKd5V8yYmm/XnzFoVrZTDSCsXe3lLCHToZmVUi77XnQX8B1XHI/R7dlbRWa4w3DRg== 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=9Z4DWEtY+ogYiBbnqXYqrF7RqMvDG43jmGeNfOVXZP4=; b=DkRPCbrai/6JJz//v7cSbZgRvQj8o+tjXY5Ny1QFZLArMP2/XcpycCkuvw/E3eBbmkfU7vP0fnBQSBXKy3OrPx+4QHRwnwYVZRmR9lI6OpOcL7A2d5WMAP55mUCxRBNdtTIxPz/Mqvli7BKTWoZ3s3Yoq/R+yuH0Xr/x5bJIUhcLRZhirXwb7Gg2yi3KgHf5qbNCHp7uBYAhmIjrhpQvpICyZ5aMqDFcG9t7L/+mtIWBN1DBOaj9O7EHFuflSaF0fi78jen74P6NHYbHBlMXTmRkSVuLA52WQNLKZqX/HwXYaBBr3MIagtmaL6eGmYFEu/X7u8gNyO6UXa3b+KoATQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Z4DWEtY+ogYiBbnqXYqrF7RqMvDG43jmGeNfOVXZP4=; b=Zu74gU8xximESJiPciA5n/aDaxTGFkFXMRqPfOLbD7tlnU9luwDe2M//yb9R0gNPauKr2bYJ3N01vifgNYoHN2k1Ne7OqTvq6T6wk8UPDd/uyTt4DFe1/fWJlcmRoVM8npiM1Znp1eiCY+IzG8tycQ6Wi0PopGqVPtf5j6kaOTWY9n31FlR5OAr5OpZqjZB7Uks78PUIXOq0SjvrE3/8CvTgRepPwSYDXfQcRwHgfZHHn8UBBihI6oWGOyoD7tOk7ARtEcfiCOx+Xp+0N7jUPn5f2cUCdbu7NCvbiIeJyO0DaHILUiMU10ZKlUg0CWXDPHYLeaIgc0eUO1wggXkHXA== Received: from BN0PR04CA0052.namprd04.prod.outlook.com (2603:10b6:408:e8::27) by PH0PR12MB5436.namprd12.prod.outlook.com (2603:10b6:510:eb::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Wed, 20 Oct 2021 15:15:44 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::fe) by BN0PR04CA0052.outlook.office365.com (2603:10b6:408:e8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Wed, 20 Oct 2021 15:15:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT013.mail.protection.outlook.com (10.13.176.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4628.16 via Frontend Transport; Wed, 20 Oct 2021 15:15:44 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 20 Oct 2021 15:15:26 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Wed, 20 Oct 2021 18:14:54 +0300 Message-ID: <20211020151457.17577-2-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211020151457.17577-1-viacheslavo@nvidia.com> References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211020151457.17577-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aa178f2d-18c3-492d-9b04-08d993dc7cf0 X-MS-TrafficTypeDiagnostic: PH0PR12MB5436: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:773; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C9tonkIAEtm1qwzFjQlp2ckC2EIHpovDixZu7VS3JGp6sghpdbns00ohXW4lyN+MP0oT2BjQ9UDHQR1fPw0EH2wrjgzPlo8OkS0c2N94Fnv63RRAjiPbUwI0WevbYg+i14Oy3LWEFK5NPNd5LRJAO0q3f4DrhPG6iSgG91Kt0aMhaM+KcF2KAyrXowCtT4CZXYz0TyFHxovh9d1uxy3TO7C2TQWmWgWC4dda1q+Ei/NIguR43Yv9uvcpINQpwaUlBV9bLBEyp3dlH7eCZYBNr/xV3qxe+U5qSlYJkWM7L6foiA7MaDNJsgeS2RyI9bq41Hbbjt8h7KAzOnnxkw6r/D9TW58W8HDt/o1J2NNQ2kfgiUtmeMWuvJH9pSFm8axikEgITfkVoBXmnvG0VFX0BZmady/vHOqEE8hRiwZqbPh0JxS8b4KBmp0/7hgkpXw4ki2Ldq+o2LdpJL7KqLyf8mohznerPmHMuvvZIyuEEzc8lq9t4naH/yDbUybhogqpp2kp0cs9+UUhdpQI7asIex5MiediHC0zvxcGw2u7vR95SFfnRAJ5cx+zURt+l1juQpRyIIVIupakMGuqewITYMK730+lC7ib3bIgQ/9KPlDuCiNQ5rywvxIsCK/T50pli6RoV0OyL5EWZ0GdhCyJAmWj036BsNFV+BERjTuA8aQO+P3S85zx214hXWSCuvD1C+GfS4jYjBVc0WKO2BR1OA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(6916009)(356005)(7636003)(26005)(83380400001)(8676002)(4326008)(82310400003)(70586007)(508600001)(336012)(6286002)(8936002)(2616005)(7696005)(47076005)(1076003)(54906003)(36906005)(316002)(5660300002)(70206006)(6666004)(16526019)(426003)(86362001)(36860700001)(2906002)(36756003)(55016002)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2021 15:15:44.4229 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa178f2d-18c3-492d-9b04-08d993dc7cf0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5436 Subject: [dpdk-dev] [PATCH v8 1/4] ethdev: support flow elements with variable length 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 Sender: "dev" From: Gregory Etelson Flow API provides RAW item type for packet patterns of variable length. The RAW item structure has fixed size members that describe the variable pattern length and methods to process it. There is the new Flow items with variable lengths coming - flex item. In order to handle this item (and potentially other new ones with variable pattern length) in flow copy and conversion routines the helper function is introduced. Signed-off-by: Gregory Etelson Reviewed-by: Viacheslav Ovsiienko Acked-by: Ori Kam --- lib/ethdev/rte_flow.c | 66 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 29f2b0e954..c8e12404a7 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -30,13 +30,52 @@ uint64_t rte_flow_dynf_metadata_mask; struct rte_flow_desc_data { const char *name; size_t size; + size_t (*desc_fn)(void *dst, const void *src); }; +/** + * + * @param buf + * Destination memory. + * @param data + * Source memory + * @param size + * Requested copy size + * @param desc + * rte_flow_desc_item - for flow item conversion. + * rte_flow_desc_action - for flow action conversion. + * @param type + * Offset into the desc param or negative value for private flow elements. + */ +static inline size_t +rte_flow_conv_copy(void *buf, const void *data, const size_t size, + const struct rte_flow_desc_data *desc, int type) +{ + /** + * Allow PMD private flow item + */ + size_t sz = type >= 0 ? desc[type].size : sizeof(void *); + if (buf == NULL || data == NULL) + return 0; + rte_memcpy(buf, data, (size > sz ? sz : size)); + if (desc[type].desc_fn) + sz += desc[type].desc_fn(size > 0 ? buf : NULL, data); + return sz; +} + /** Generate flow_item[] entry. */ #define MK_FLOW_ITEM(t, s) \ [RTE_FLOW_ITEM_TYPE_ ## t] = { \ .name = # t, \ - .size = s, \ + .size = s, \ + .desc_fn = NULL,\ + } + +#define MK_FLOW_ITEM_FN(t, s, fn) \ + [RTE_FLOW_ITEM_TYPE_ ## t] = {\ + .name = # t, \ + .size = s, \ + .desc_fn = fn, \ } /** Information about known flow pattern items. */ @@ -109,8 +148,17 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { [RTE_FLOW_ACTION_TYPE_ ## t] = { \ .name = # t, \ .size = s, \ + .desc_fn = NULL,\ + } + +#define MK_FLOW_ACTION_FN(t, fn) \ + [RTE_FLOW_ACTION_TYPE_ ## t] = { \ + .name = # t, \ + .size = 0, \ + .desc_fn = fn,\ } + /** Information about known flow actions. */ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(END, 0), @@ -531,12 +579,8 @@ rte_flow_conv_item_spec(void *buf, const size_t size, } break; default: - /** - * allow PMD private flow item - */ - off = (int)item->type >= 0 ? - rte_flow_desc_item[item->type].size : sizeof(void *); - rte_memcpy(buf, data, (size > off ? off : size)); + off = rte_flow_conv_copy(buf, data, size, + rte_flow_desc_item, item->type); break; } return off; @@ -638,12 +682,8 @@ rte_flow_conv_action_conf(void *buf, const size_t size, } break; default: - /** - * allow PMD private flow action - */ - off = (int)action->type >= 0 ? - rte_flow_desc_action[action->type].size : sizeof(void *); - rte_memcpy(buf, action->conf, (size > off ? off : size)); + off = rte_flow_conv_copy(buf, action->conf, size, + rte_flow_desc_action, action->type); break; } return off; -- 2.18.1