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 D0CE1A0C45; Wed, 22 Sep 2021 20:05:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D36DD41218; Wed, 22 Sep 2021 20:05:05 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2066.outbound.protection.outlook.com [40.107.96.66]) by mails.dpdk.org (Postfix) with ESMTP id C6E50411A8 for ; Wed, 22 Sep 2021 20:05:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vn2/pmznRltzNY3N/JoHHOXE1BzAiePOodOrTJjmKcKN8Ey4Wvazre2q+wUBuGgj5Zqf+gxl/hxoC5niypw7AqMDfm9zJysH0db1dtxIMZnq0/F8E2LdfZvcJgk2ur/AunmpC/RgEvOkX082VJ5ajSI7myHTSCKS4ILqQnj/YKaE1mM9rLhYQTFRD+cBVNGLlmvKqJjojogLwnmnNHGnLJv4mcTENDuBtdjp0xQCKaCL5mjs6xqEfL2U+E5hzl0t6NQz3LzAUwof3xg10QADUiveCIBwXkGk4H/f46YH8tH9JG3Q2nnXW8EeWQ0MQALbOJXqcKTfHLKqcmT7rAo2tg== 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=FmZ65eVJrvGx3qYc2X8I97qIIGViaZV9d384pl0uaOM=; b=Lxtf2Vm7zW6CTJy60XOe1wENrPwu/QiJIXItXlVCovwzjkMc9THmR/62EUlkmjsbN0LlOcOv3Rlo1TC/Zh5n7Yaa2UuFQMwhDVIHNe3UbN4DV8lj0M9ZMNGrh0wfIPru/9go8nPGndEaus75SYe9Kf3fD6yG+tRIolKnH0psKUXZTdXK5SSAH4RRyP2WowVEOxRIlSaWu5ouUhFC/V4VlEB8mfuhQ8SnbCPonkoau9Dz3YjFwHToXZM9+9CZtpD4pqL2nlbDab29viBVix6VVxdWpB3+TQZKuB4AKvakmTTaK94Ce/oDUIonwln7LH5AO/v0ditz75RqMm0I4Mz+Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) 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=FmZ65eVJrvGx3qYc2X8I97qIIGViaZV9d384pl0uaOM=; b=XQxNi9PurNrNMm3uAQIi7DFsBgs0TbSZ7I1k2PskJtHHGK3SzL15izexQRgLtGYkOTBz+DcjrtEvIZhIAxEfthNsI+1E2ltIS+Cur+Li/3/80/chrOm6NSlfWxP/f6oVGqoXbWhxzRBzifg2i0NB6r8v8MleI+DAixE++LtF/bHNHA+9bxSVDv223ALnmP0DgDfdlqLQXW388qk/YGJS/hAYTPBcbrOlOjVPtNZse8HIVnDDYHxFdfdHKDW4YKR+bgQtUffqui6pTtNXlgpAitreXVhqrw1osvK4wRQ2GDz0LsJWi06u+qr7oKa6YKDi3S72N6mPoMudMM5Dx7IGRQ== Received: from DM5PR22CA0005.namprd22.prod.outlook.com (2603:10b6:3:101::15) by PH0PR12MB5451.namprd12.prod.outlook.com (2603:10b6:510:ee::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 22 Sep 2021 18:04:53 +0000 Received: from DM6NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:3:101:cafe::20) by DM5PR22CA0005.outlook.office365.com (2603:10b6:3:101::15) 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:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) 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.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by DM6NAM11FT030.mail.protection.outlook.com (10.13.172.146) 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:53 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 22 Sep 2021 18:04:52 +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:50 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Wed, 22 Sep 2021 21:04:18 +0300 Message-ID: <20210922180418.20663-4-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: d058a1cb-55cd-4d52-60cb-08d97df37a79 X-MS-TrafficTypeDiagnostic: PH0PR12MB5451: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kRXzKiLSnbI44kOuCVlSFAQGQaPpFgsfiZunmmIdKU0puvHI+WZpVWTSZ86o3TqSgK/tdwU1xfK7SlewM/B7i51Wrg4RARizChe2qj2J3jTtwYXX/2w6xmW2wBG7bDhmlVz01D+QUCcrFfia1QA6Eaofzhg1NBNIDmE4BiZMmv7KEZAbvDjcl5PhQtq2b3rqT4pSKbDMMdRxejk4r3JCREE61lNQLLoJnnH/G6TS12NrJjj3BlTmA6c1MXFbVq5awZxpLH1Z1uKVtqadw959/KW829GP+SZ5jY5o2Dy87Kej2+LXT/7X2rz/6uo5OFCaSNRtpf5nFSHCy6IlUkAv2Urp/r0Py0mmuCvHoTbXFCn5I/OPFIsgRLpOFio8TBbN/W/7fCbTaB0ipHvo7bv3q/v/cMBsmwrDtEz7aweaGthUGUJE0y+Fq0B3gH0K18uKj5TW2aa130p6X7HEBeQDwvKEQkM+mYWOK+d3/5lFwIj7klzobHJFBWel2TFeqZC33UPiHLfWfGkDLfLo7uZEZVg10ytrikW/trguolGpiys3kbqddNqbY7ObZjeECs6rN1gWfcrdHQD3Aenb5157xTet26TtJ+5hceNGj+weKJrquzlMS96NBYxouscziXWV6Iq2FcSV4RvmbIRuoqn1aJqnMK0HFyMmtF/gSwCJc5owun5wn6gVHpCBujKlIazYNwG7qEM7QmMhwYEpafMgAw== X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(83380400001)(508600001)(336012)(36860700001)(7696005)(2906002)(70586007)(47076005)(186003)(8936002)(426003)(6286002)(6666004)(8676002)(82310400003)(2616005)(36756003)(6916009)(356005)(16526019)(55016002)(7636003)(1076003)(316002)(86362001)(26005)(54906003)(70206006)(36906005)(4326008)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2021 18:04:53.3836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d058a1cb-55cd-4d52-60cb-08d97df37a79 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.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5451 Subject: [dpdk-dev] [PATCH 3/3] ethdev: implement RTE flex item API 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 flex item API was introduced in "ethdev: introduce configurable flexible item" patch. The API allows DPDK application to define parser for custom network header in port hardware and offload flows that will match the custom header elements. Signed-off-by: Gregory Etelson --- lib/ethdev/rte_flow.c | 73 ++++++++++++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 13 +++++++ lib/ethdev/version.map | 5 +++ 3 files changed, 91 insertions(+) diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index fe199eaeb3..74f74d6009 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -80,6 +80,19 @@ rte_flow_conv_copy(void *buf, const void *data, const size_t size, .desc_fn = fn, \ } +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; +} + /** Information about known flow pattern items. */ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(END, 0), @@ -141,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. */ @@ -1308,3 +1323,61 @@ rte_flow_tunnel_item_release(uint16_t port_id, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, rte_strerror(ENOTSUP)); } + +struct rte_flow_item_flex_handle * +rte_flow_flex_item_create(uint16_t port_id, + const struct rte_flow_item_flex_conf *conf, + struct rte_flow_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error); + struct rte_flow_item_flex_handle *handle; + + if (unlikely(!ops)) + return NULL; + if (unlikely(!ops->flex_item_create)) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, rte_strerror(ENOTSUP)); + return NULL; + } + handle = ops->flex_item_create(dev, conf, error); + if (handle == NULL) + flow_err(port_id, -rte_errno, error); + return handle; +} + +int +rte_flow_flex_item_release(uint16_t port_id, + const struct rte_flow_item_flex_handle *handle, + struct rte_flow_error *error) +{ + int ret; + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error); + + if (unlikely(!ops || !ops->flex_item_release)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, rte_strerror(ENOTSUP)); + ret = ops->flex_item_release(dev, handle, error); + return flow_err(port_id, ret, error); +} + +int +rte_flow_flex_item_update(uint16_t port_id, + const struct rte_flow_item_flex_handle *handle, + const struct rte_flow_item_flex_conf *conf, + struct rte_flow_error *error) +{ + int ret; + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error); + + if (unlikely(!ops || !ops->flex_item_update)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, rte_strerror(ENOTSUP)); + ret = ops->flex_item_update(dev, handle, conf, error); + return flow_err(port_id, ret, error); +} diff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h index 46f62c2ec2..aed2ac03ad 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -139,6 +139,19 @@ struct rte_flow_ops { struct rte_flow_item *pmd_items, uint32_t num_of_items, struct rte_flow_error *err); + struct rte_flow_item_flex_handle *(*flex_item_create) + (struct rte_eth_dev *dev, + const struct rte_flow_item_flex_conf *conf, + struct rte_flow_error *error); + int (*flex_item_release) + (struct rte_eth_dev *dev, + const struct rte_flow_item_flex_handle *handle, + struct rte_flow_error *error); + int (*flex_item_update) + (struct rte_eth_dev *dev, + const struct rte_flow_item_flex_handle *handle, + const struct rte_flow_item_flex_conf *conf, + struct rte_flow_error *error); }; /** diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 904bce6ea1..994c57f4b2 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -247,6 +247,11 @@ EXPERIMENTAL { rte_mtr_meter_policy_delete; rte_mtr_meter_policy_update; rte_mtr_meter_policy_validate; + + # added in 21.11 + rte_flow_flex_item_create; + rte_flow_flex_item_release; + rte_flow_flex_item_update; }; INTERNAL { -- 2.18.1