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 D855DA0C45; Wed, 22 Sep 2021 20:05:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B88DA411F0; Wed, 22 Sep 2021 20:04:59 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2087.outbound.protection.outlook.com [40.107.92.87]) by mails.dpdk.org (Postfix) with ESMTP id C60DE411A8 for ; Wed, 22 Sep 2021 20:04:57 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=grLShmB7cTGIBD+5zPEDNVTKoc5i3vtX6X7RmD/w726la2BvVB0iEBbAcOuql7Ar+D7PmE8c1XmKtf6uExl4WWolJjNECVEsYp+bZ3ApAlZDOaEbUChwW7e53QNew023GV0cbqKAkvp+fYJjgImzLYPWjJuL+JOedrZWS3au4hyJON3oopcohR6aRbTd6CvXwy2T3xPFrsnlU+yp3C0KelZbsMDtRP9+W7nagJoNrMH4xLF0TuNhSz8zI2RHn2EIP0OpyHsgXA9NtUNNzh387OL6mJWSDZJM0RvAlBdJOIZzvXHjivd8QhkZEihLS5Ix7yQA661DYAHcWq5+7IOpCQ== 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; bh=+tSKHujJZ17nlCVv2IOpIob9cvqI1kK4PuYm1culmvI=; b=m3hiqN/dUNNN1enC2JaH4X1rfUp4t1Dhb4I7gycpmh05X04Ug7xPuEVaauDZ6KAft+RIznOQsdsGIzDAPvJWX34tLyiDYPNkbrZlTfGMfbb4XDnMM7ODst06Be4M9L1F6AVzrXIN3irrEQw4FqRtFTvwhQQlzfye5aAysyLxAaxsQOH172ztoDNqkt0NAo5q45ySd/7sw4bb8JjLeCcd/iG6pXMWFSGdSciIHLvmdusZs48IR6mRdnhdJkoOivWt1e6oZ+AbDyS3aprKCeKBX2aE1TnoZ42xxaLxJMrd96Oy+q54cZgceskd6OIkQmFblrJN/sSdYs2d+N69molgGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=+tSKHujJZ17nlCVv2IOpIob9cvqI1kK4PuYm1culmvI=; b=jAWw4/lLhSRb3yAbw43zkCmVbtbVGGshLPP+ji78OC0jwWowzOGZmVaJqlYuQpcjYdWsPd5JpfX/BphOg7+hbZjZtBLOJQ5yBn5ySNaTicTzh4Fl+2PNj38Q3ZwDlt4jZJKGUEfJg16hPHeFBj6umL05KEnNpm3XCfbXFyaQ/eU43o5s3einff+lcW6wolzvzkdM8zMwgAfJ/KQ9ytztvcPR4RzQq2eXItXFsLsstgWHwPJfXoavqirkgW/hYDhkAfglS1GQ0rBZx2UHB2Y3BQo9OIzHk495Kg/d983Sd2i5CPoVB+bkwbQfUw1SWGNtcSxsI+rVS8yhcvK/AD5sEg== Received: from BN6PR1701CA0012.namprd17.prod.outlook.com (2603:10b6:405:15::22) by MWHPR12MB1680.namprd12.prod.outlook.com (2603:10b6:301:10::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Wed, 22 Sep 2021 18:04:51 +0000 Received: from BN8NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:405:15:cafe::40) by BN6PR1701CA0012.outlook.office365.com (2603:10b6:405:15::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Wed, 22 Sep 2021 18:04:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 BN8NAM11FT042.mail.protection.outlook.com (10.13.177.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Wed, 22 Sep 2021 18:04:50 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 22 Sep 2021 18:04:49 +0000 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 22 Sep 2021 18:04:47 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Wed, 22 Sep 2021 21:04:17 +0300 Message-ID: <20210922180418.20663-3-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210922180418.20663-1-viacheslavo@nvidia.com> References: <20210922180418.20663-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b3c4f4b8-ffb5-4026-2e1a-08d97df378ce X-MS-TrafficTypeDiagnostic: MWHPR12MB1680: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1247; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O8duqjVOmNpcDmwOK1pV0Ac8TqU9YGhHsU3ypbGaU/piFXM+G8PxooWe1lwxNt7On2HRtsAZCSHVEBA/eNT4dAl/hD8pygeNqUgomuOv0TfrKkXvNV54c9MEhu534D4+dRVs+EJyqhydN/wfn3jhYtbYhflq43teiFhfTQea0FK48sxjGXwNeNc1MXhghQDvvc+8Ibm51sT2Q+twZu0gG1aUKwmbw1FEOq1znuutnpcXk3XYd0enRvz6qajnDaMHL+Y8GazFY4ii3SFnPk2pd9w92b8g2Jo4KcSM3/+MUDkes4YyFvc1B8obrFOqIIvQoI/B2JaI6q/cPRPjSG2tOBtfXGTtiUk6gS8Vgtx3+k/Ecxm6075CcR3mr8Y9Equ2KIpLSXbf18RYX6DT6uRmJCywRrwlfEjjTjSNgGKJeNQuGMn/5bG6iUxsvocJXU4NkpiEDLsQ9X+bf7yEmogfr5Wvx5c6rVUDxtc6YrPhlIok4eJMZlhUqM1AJebQZtbYAQEMyqO6q7KYGgP3JC6D5JFHLceAUY4718CeMKnb79dNVqhW4rGNuGOFYk/in/j5uU2TERyrU/rAF5e0zoeNQiv1ps7BCAlDZT+I/dv1tGiLjhUHtlap3FKnyM4cmG1I1kG37QAtk+vE8Eq7Bp+dVjXA3vZTRMNrRwOhy82NnSnLGXmLP3x4BKeGxLuX61vzteS9XRAhPhogUVUthy8pfg== 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)(316002)(26005)(54906003)(356005)(186003)(86362001)(36906005)(70586007)(4326008)(7696005)(508600001)(6916009)(2616005)(83380400001)(70206006)(7636003)(36860700001)(2906002)(82310400003)(426003)(47076005)(16526019)(55016002)(336012)(5660300002)(6666004)(36756003)(8676002)(8936002)(6286002)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2021 18:04:50.5209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3c4f4b8-ffb5-4026-2e1a-08d97df378ce 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: BN8NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1680 Subject: [dpdk-dev] [PATCH 2/3] 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 RTE 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. A new RTE flow item type with variable length pattern that does not fit the RAW item meta description could not use the RAW item. For example, the new flow item that references 64 bits PMD handler cannot be described by the RAW item. The patch allows RTE conv helper functions to process custom flow items with variable length pattern. Signed-off-by: Gregory Etelson --- lib/ethdev/rte_flow.c | 68 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 8cb7a069c8..fe199eaeb3 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -30,13 +30,54 @@ 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 + * see 5d1bff8fe2 + * "ethdev: allow negative values in flow rule types" + */ + 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. */ @@ -107,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), @@ -527,12 +577,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; @@ -634,12 +680,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