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 C533DA0032; Fri, 1 Oct 2021 21:35:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4BFB41206; Fri, 1 Oct 2021 21:34:52 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2050.outbound.protection.outlook.com [40.107.96.50]) by mails.dpdk.org (Postfix) with ESMTP id 1A45A411C9 for ; Fri, 1 Oct 2021 21:34:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eu0L+Z3IKq1f5mfdoNRoUT4htSga7TNEaX1taHN9wdQVHGLIwuSPyrCSFIvTKvfkiA1XvxxGGN7f0JdhyezdTcut91YNejhpY82EDDu1A72iUtBIySltsuUJkqj3X1T+4bFERlHY45bUqn19IouGryJO6PkoFudjKQkKIOe0mE6sHzIkHwVXHtsO+4QHqhg39TQtBO8NIM/LQORAMM1i5K1uyWlB7w+ST8lCz1z+Ewq+DZIzU0rMLJr/sUEV7loXx+3dG6LTedFUJH2xbSFzwpmMgKisbWC49zGduKyl5tJbuCOEO3UODQTS3ADtSvJswJMd2omXpOXh3jxzbOy3Sw== 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=FmZ65eVJrvGx3qYc2X8I97qIIGViaZV9d384pl0uaOM=; b=kE4lP8oB0ZyoF5KpJWkvcYQmWjXW8tX2m5ObmTX2sQEPOWb9tOo1GNH/RCcRi7LVlQ/9Z8euwLLIdZeFIXSmZBWNFS2nZEfCRVytN0X6i4mGRPMGueT/LArj7EaKlK71maOhbqBhC2qykF52yHOtCd1DbuFuAPE6To/on/AQw3z5UNuE/6W0nvrf7iNN9sQiez4soMSAJEuYVeM6dLMwL7gSGguRu1tw/4bUMYnpDV/xmEeZLeY9EMM7a6cnAIf46TRLzLG48ja5XkX4RFNrDZJgvY5FV54Pybnr4TS5Qt5Xz0obYwVQ6y0rUE6xQF1qtBY+wM6SOcP0wNdkN/VPWQ== 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=FmZ65eVJrvGx3qYc2X8I97qIIGViaZV9d384pl0uaOM=; b=sCcMZ2pcBjtz1zdkNDqvXrhmZlNCRESPoGbqRnZQd4GU9BjCbtzdfAc8cYjAb2L11FQ0LFiIARztp4yUfUdJ6MBoa5EM8bxKTFgpn0lURsJSX/HKJxRIJguMqXdiaVynopPF9WBHMAZ1ClY2vtOQW2cQeASptCUk2rB+TOGWBZbrMdHURipik2w7//l+txtdNVPnPNOmDV8rphLCW4vmjVIPVNjmVxOdQAraI1+W/wea3fipL5ZdDo8Il6heSTODpHXg90qogRiWR75aTEKJcRmwBsnfGOZXn81zh88/igR9fS6Oq9LbNfx4RAoib6vkuPM6Epf26UgAqCUNcgxAcw== Received: from BN6PR13CA0055.namprd13.prod.outlook.com (2603:10b6:404:11::17) by CH0PR12MB5028.namprd12.prod.outlook.com (2603:10b6:610:e3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Fri, 1 Oct 2021 19:34:49 +0000 Received: from BN8NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:404:11:cafe::9b) by BN6PR13CA0055.outlook.office365.com (2603:10b6:404:11::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.7 via Frontend Transport; Fri, 1 Oct 2021 19:34:49 +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 BN8NAM11FT066.mail.protection.outlook.com (10.13.177.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 19:34:48 +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; Fri, 1 Oct 2021 19:34:46 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Fri, 1 Oct 2021 22:34:04 +0300 Message-ID: <20211001193415.23288-4-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211001193415.23288-1-viacheslavo@nvidia.com> References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211001193415.23288-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: 96668ac0-f36e-4f8a-5137-08d985128811 X-MS-TrafficTypeDiagnostic: CH0PR12MB5028: 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: TGQvJnrK6oyW8WaFGTi3+xA+Kh2tR+dJJl4nTtlVaO7thctfZpLEIJkEmZZTbASFI2M+v7s3fUjmC5wSySxhzGiuauHFCYJaEyJNgqHyD+CAAa0ziM5mQUy7QAmaEVLy8TX4+Hu0eVhZiYB/fHN1klZU76Ahs6xgOYpFyNQWwwdYJf43kuyMBxsi8KzjrJUUqEAeHdJv1siZQkmthn/BLPh12WI7WmgCCj3trxHqi/TtYnvaeiAvpEKFjrIUQC3DAC3pslVhLk6Dj3DudqsLHhhDBQqNk2KrO5or8bh7E7si85HEXHj5fzWQAEkKFCzRGBN8qU4VOl2vfnYsTFi7X+5R25I9b8kY7sZgkmYJzRRVl07gw75dIqbghawlXI//pqGtqzheoOYeFPGkeyZBY+JnkH7g+WuD4ScReZza91EhCvSUC/oyWjbtyNED8+Ogq2mYc2G9yMHYaRBoxdvJlfeaUTJkj1EY9wnp3f/7WZ6HoRHoLki/EGWvWH/DUn5pb0PgxtirNAySBLiSLqaxPTAyZnJhvmsB7GVRYlZQc8o6fdsnWU+NfKkLyh/ns45uXEXlGNxb0wj1qPwPY92UFxRhZv/WnCm3+23Jeia+cIKeK2EmGbzjDF3T214UlZJsGccxsrqL/8gsml9sIDtXnvOAaLq9XndEOB05ov/zZ6I76Smp7IkpniNaUZu61d1/Lh6JHFTFXCI9/+FyjmidFQ== 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)(1076003)(8676002)(6916009)(36756003)(47076005)(54906003)(86362001)(6286002)(2616005)(4326008)(2906002)(508600001)(55016002)(16526019)(186003)(83380400001)(316002)(70586007)(7636003)(8936002)(70206006)(36860700001)(5660300002)(356005)(426003)(26005)(6666004)(82310400003)(336012)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2021 19:34:48.6800 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96668ac0-f36e-4f8a-5137-08d985128811 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: BN8NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5028 Subject: [dpdk-dev] [PATCH v2 03/14] 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