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 1E80DA034F; Mon, 11 Oct 2021 20:16:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E927A41130; Mon, 11 Oct 2021 20:16:00 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2047.outbound.protection.outlook.com [40.107.236.47]) by mails.dpdk.org (Postfix) with ESMTP id 1B6C3410EF for ; Mon, 11 Oct 2021 20:15:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cmbVQeNxTEq6po0ZUXBCBl4rpU6hOut6fVODWyLIG4farGJJ7zbbI9AC20kRrTNAPNXibuW+29aAlYKzCvCTI9V/IhUrviuwF/H6ZkAkzKuLsv7qnlddQbmzaT9pctsMwQkbzk1b9mJEYIFb/wRmnjSqDkir+1qgzrl0YVwj2Fv7ez8wUxBX0fTxkVwsurrYo70F5z99JF2+oQW80+tSopLqtpcesWdbOmqrnlWjngS6LK8OEVI6o+AZAhRNU78xVDZ8gs0Ej3DcXRlEW46TJF3TBJ1wRQsTgQPvoQT6M5PtqU4EuEL2H0ZFIWOFBlb1bpGSK6OWhe+VnkoGzAEtyQ== 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=b5PRTp2mWqIigTzV0pMbZAsYeNTMAMvLf5wLrHzpGf8=; b=Svmvyhi4atP7l6D2SX2HQftvS+MckQ7faG9FJ/luguGcuHG0SbL2zq5AQkIy1xR5HQsBDMQlL8hoNr1KY6/ra1F/vTo9IaAV1Ptfhc93Mpef+fvVK9eMksfI2ki6Yo6Mx1n/R7HG34G5rInSTT4UICMKswNUNSsyRmg16xyFzJFvx6wBp/KaHtB2U8JlsVblL8nP9UgtXSKrDsAkxm9b8Tnt1G86roNJPi80Yu6PdCaZV/CCH3AIIpGs5g8gW+3WduXh/2yqGUVT89cOiDWyWJ/MNwih67yLqJDaM62D75XNf5PJ8YfXWOJyJ6RBk5IwP7O/vCv8uSkBs669FXYpew== 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=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=b5PRTp2mWqIigTzV0pMbZAsYeNTMAMvLf5wLrHzpGf8=; b=S7SCsjHesGgy6fCn2dxUHy1Gwz0w4bk2EU5FChC/9nnOWFWyMN4ETOacqZC8DcJvJFw7/veJvhIUhWgzMnzlH/jnzNgEUPxJ7rnRvxrroPAE8srhtSEdsPe6s+JJ1DIWFPRp3DrKcd2Vt5sWSaXJBD2eGZ1e4j5s1sGo6FP1OlQZ20u9YRK3alBlAF0b1MRjcRokHiRbP6NOV90KtyZVN4NbVpoOZLpH5PCtL1URiunXVLeHbOhgKTHbJBu01FX+jSxQBeWVu40wAIYDE5KGASc7yleGgVY1HRBGQNDO6XGIiF+ET5MF8gJw3n1yi+ya+YBsXyJ0ozrbd4+/ND0C0Q== Received: from MWHPR02CA0011.namprd02.prod.outlook.com (2603:10b6:300:4b::21) by MWHPR12MB1133.namprd12.prod.outlook.com (2603:10b6:300:d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Mon, 11 Oct 2021 18:15:57 +0000 Received: from CO1NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:300:4b:cafe::44) by MWHPR02CA0011.outlook.office365.com (2603:10b6:300:4b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Mon, 11 Oct 2021 18:15:57 +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 CO1NAM11FT052.mail.protection.outlook.com (10.13.174.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Mon, 11 Oct 2021 18:15:57 +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; Mon, 11 Oct 2021 18:15:55 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Mon, 11 Oct 2021 21:15:25 +0300 Message-ID: <20211011181528.517-3-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211011181528.517-1-viacheslavo@nvidia.com> References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211011181528.517-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: 3f1fd2c1-1534-4255-bf8a-08d98ce32c1d X-MS-TrafficTypeDiagnostic: MWHPR12MB1133: 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: c7XZrc/k6pLJhnX4dEt9HOaV19V59WvN/4ePlRuTNvj6PphNDXdlI/OND0xfFH06DldDBVyL22K0jJ2rkmvHOdqtpuxaTOYazW0UkamATBg7eVMrT1HwWGVQFneVzUoBStoi+SPx39eL4eAQy2CpJB3xgs/pQPKxdIzHbzLNnniDAI8km5WW6TW+ozmQiiSUAX3qrxh5AP7EurKs74ybePAQCh0cUGKM9JP8PwHwQROOpi0XyuaFY1W4XL0d/z1lSLporOvs7xp5QzWfYDXmlVkVZqHuqRSCGJJGTrZnLZ06udpCC1LSrgscHGv7T8mm9gvJ+4W7b63Bq8QGxtMiFrJMB+8R3r+fKrJJ/y3ytlZoIKnuPV/0Hr09A+8rFQP1sTua4Zr7yTz5EQUgyQZKfI3ohSwPm7EGowjr4LZ23nWf4tRb7sv1LEiY8wsCvB2nSSgKrEaohKophTw6iQUx2QmZC+fe8CKNt7zGefgFGhuROpSvCGO/CJ2We3gH1iMqe9Jh8sOTjymTjIOwYAl1sQPeL9CWnQaPe5MdUPq1VS16H2dh8CZVpLctcoi3nVaLL7XZFpm+e62R8YRSaGA+df8SIAOQlogI2kmSIm0kRQ0xB7TGr5MEJ3l9B4D1xEWnBPlQeaG8oEibZ4e1iViJ6WxYghuce1j+Q9/S9E3w3xamccO6bFBwOXBWwlCLFmWN5I/b/VgdICpLzmegl98/TA== 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)(54906003)(36860700001)(186003)(36756003)(7636003)(4326008)(83380400001)(8936002)(316002)(36906005)(508600001)(26005)(2616005)(1076003)(16526019)(6666004)(2906002)(356005)(336012)(6916009)(5660300002)(426003)(86362001)(6286002)(82310400003)(70206006)(47076005)(7696005)(70586007)(55016002)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2021 18:15:57.3628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f1fd2c1-1534-4255-bf8a-08d98ce32c1d 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: CO1NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1133 Subject: [dpdk-dev] [PATCH v3 2/5] 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 Reviewed-by: Viacheslav Ovsiienko --- lib/ethdev/rte_flow.c | 83 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 13 deletions(-) diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 8cb7a069c8..100983ca59 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -30,13 +30,67 @@ 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; +} + +static size_t +rte_flow_item_flex_conv(void *buf, const void *data) +{ + struct rte_flow_item_flex *dst = buf; + const struct rte_flow_item_flex *src = data; + if (buf) { + dst->pattern = rte_memcpy + ((void *)((uintptr_t)(dst + 1)), src->pattern, + src->length); + } + return src->length; +} + /** 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. */ @@ -100,6 +154,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)), MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)), MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), + MK_FLOW_ITEM_FN(FLEX, sizeof(struct rte_flow_item_flex), + rte_flow_item_flex_conv), }; /** Generate flow_action[] entry. */ @@ -107,8 +163,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 +592,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 +695,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