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 9B25DA0C43; Wed, 20 Oct 2021 17:06:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26F1C41196; Wed, 20 Oct 2021 17:06:57 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2057.outbound.protection.outlook.com [40.107.220.57]) by mails.dpdk.org (Postfix) with ESMTP id 2E41140142 for ; Wed, 20 Oct 2021 17:06:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CvQpu8A+C8ZepxayBQVT/Z/HGsDb5qhLvVGyDyP2rHwhc4N52GULEjignzwn4zbfM1NIugjdnFygixxS2UIm1NwrRR4HaDtumdbJX4LMDtH+76nopl5yOjjyAYvDrC3Rm1viyLN02Xuf9pqofxkFB05o87P/0va7r1tNg0+HRoM8kKQF/t1r0n9xtcVPH2/7vzESvYH/js2r4b67fS3owRmIB819qLhHp5ASqn1IluStaK0BKLgeaW6n3G36dtZ/kd9rUqTzWm7qZxfeBWC7Fb3MeI/jh5QWISrm2lLylGCrqAfRnaQi1HV++ZRzOY2nFrxhYxyt2/7KmompSntKkw== 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=TCxeP1cZwEOa3eK6l5Hx9HC5Znta0jUzqYqVqgna1B4=; b=UExhnY9wkQkfaU6FK3V4GwcfDlVNebHTM0gO4gge2RAQeVCbXpbBi3bc9qYYcIdkK7/30dpfpkh0Ia7g3GtOR4CjLcLbu3QeQJloGCU3kV7WI6YV9R4ACbLt/T/TUMrE2rxqD6aSR4T/qIpGYsTrHuziifZU3jeU/ldWsICOdHWntetReTNcCSDtUM+yRoI7opWz9ydUnpCsPCygVaEvTqUO2imjXtmkgtgJ8blMaeJR6OL5OlWx27XdQPbZzL7isjX13/todosttcMcNIU8aSuydn8ABRTj1WqVqyn6RHcq7l9hcFPlEHQjwZ6d6wBcvUeT8mGXFOv2dkvHx/+JVQ== 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=TCxeP1cZwEOa3eK6l5Hx9HC5Znta0jUzqYqVqgna1B4=; b=kB+EYep55BloXAN3f3sxsEBkQfP49yYO6Cv+fZDmnOAhGN302b102J0/XYz51Kbrj5tf56coFcol8RYO3uuiI8D0EB+3Ji6k0+Kh6UV4jKJKG3l7jH+4k3ZOEjVQ3hGpGA0Jl0aktaLLFCTIKG8zUWCB/ZIgJjbUVdPfX+2RtiI/IREbB9o3hW3vJ9WTjWygxQUCa6k9L8FuIQjEWEPf8+/BinfMIB4kXD5P/vXNX2Y2m1jy6JayswkjZ7BqI6cMibxw52kMtKTAZuE0ZSrrgQLfL0FSgPbwpJNWxakXdGRjApiT/jJu8Q8jTjVTu+nde3vbL6pd1YDMRKU+QMzGNA== Received: from MW4PR04CA0046.namprd04.prod.outlook.com (2603:10b6:303:6a::21) by DM5PR1201MB0057.namprd12.prod.outlook.com (2603:10b6:4:5b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Wed, 20 Oct 2021 15:06:53 +0000 Received: from CO1NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::29) by MW4PR04CA0046.outlook.office365.com (2603:10b6:303:6a::21) 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:06:53 +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 CO1NAM11FT037.mail.protection.outlook.com (10.13.174.91) 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:06:53 +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:06:44 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Wed, 20 Oct 2021 18:06:18 +0300 Message-ID: <20211020150621.16517-2-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211020150621.16517-1-viacheslavo@nvidia.com> References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211020150621.16517-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00154230-6310-4cb9-0db9-08d993db4033 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0057: 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: 1si3vamLj94Z10M1UsZfRYAntOsm6FoD8bqOMRh3cbMZaAQyDgt+krxOvgyfsVeA7u9GYudRrFMNrmYMPFAVSZ8m2Ge6D6EtyV/1HLcFZ6J6wtWNsri4cx+emmU8+Q4IxxYpY8eVTdehyP9dFe/wC9ZyeyI9mJz4X5c3x/aEm0WETc0A26ixffixZcceUVQhr5hhdu1YA90NFoFgGQwlyf1vwJBcMowg2yyGThQ20LOJWDQXne0p2oBeIFAfoLxd2JxnRwRv4wYtcx0Lon/DsH8etlFjQdJi/IJwsUYnh8mgWDUIs9WIqjLvw4jMubw/u15Lkn/zt/JF6QqGxN+SYg1YNuhlBecczNBtkczIQcd9s8uV5vfP4u6a8aXNpOptpn4cj/XRCFto2/vqs6RsEOp+9U38gnlPy2uz/Oec/xjw480blLRptHVYocOSwJehkWs3BuJodjIKSv3bDHeavHYjjSor1RJi3WQXXIoKSAKi/6UtBypkdZmvZsdv3Tm4W/ptOJh+HGJYdLxvO0t+sqMUOCcBLIrDDJnPER9vTIKyY/OeJehJJlZEKkqjjm465O2fguspSU0E1pHQgO96U+uWRGGCZWwG67UAymdSNOf1whqnFG7xNMGvVLeAdGTgjGTu/xGgBuMar69ZXbw4iJwBQBZnp3qx2s05pMmwQfeKcUB+YAcJnSZF6fyOhW0YfaN+V22IQzG1bHMDcssHNA== 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)(36840700001)(46966006)(36860700001)(82310400003)(186003)(16526019)(426003)(6666004)(336012)(2616005)(6286002)(70586007)(36906005)(83380400001)(316002)(8936002)(7696005)(508600001)(86362001)(70206006)(6916009)(54906003)(55016002)(4326008)(47076005)(36756003)(8676002)(2906002)(1076003)(26005)(356005)(7636003)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2021 15:06:53.2974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00154230-6310-4cb9-0db9-08d993db4033 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: CO1NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0057 Subject: [dpdk-dev] [PATCH v7 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" 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