From patchwork Wed Aug 2 17:34:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 129831 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 90FEF42F83; Wed, 2 Aug 2023 11:15:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17945410DC; Wed, 2 Aug 2023 11:15:13 +0200 (CEST) Received: from mgamail.intel.com (unknown [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id EA3EC4021D; Wed, 2 Aug 2023 11:15:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690967711; x=1722503711; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BBTmqzX1Fkd7QOYoh4DMG3lqPDKSVj8Uro6YbOG0SzU=; b=Q0J/55USrrGNuUtHvfa+rndqPCLy6f55R/Ex8YgazvzvipICNR2D9vAS FRBszZt4ax97Tl2lzd9WVG/Y9MPtsWxZuYzto0Yy0f1RDgZZCIKRqX2gW fQg+fIK9Q5SsFzr3GlwN48edf90jkl+knvYr0cfZZctCf/vN9Cq/8pXN3 6WYme/+c54q6hK+0kVy6Ms5NW45EmetvJwNEAr2GfmmZyekQqCmozi/e7 hfq0Aj5vy/3kQxoAWZi6mWx2j0FhkAZZI3/1riPiceDM3VD77P/SjqEpC Ygw18v9dEPh67Oz6JDRshSLaEk0wT8uKX1iE2fyr09M/clZ0BOPX732sv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10789"; a="366991834" X-IronPort-AV: E=Sophos;i="6.01,248,1684825200"; d="scan'208";a="366991834" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2023 02:15:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10789"; a="819123882" X-IronPort-AV: E=Sophos;i="6.01,248,1684825200"; d="scan'208";a="819123882" Received: from dpdk-qzhan15-test02.sh.intel.com ([10.67.115.37]) by FMSMGA003.fm.intel.com with ESMTP; 02 Aug 2023 02:15:05 -0700 From: Qi Zhang To: thomas@monjalon.net, orika@nvidia.com, david.marchand@redhat.com, bruce.richardson@intel.com, jerinj@marvell.com, ferruh.yigit@amd.com Cc: cristian.dumiterscu@intel.com, techboard@dpdk.org, john.mcnamara@intel.com, helin.zhang@intel.com, dev@dpdk.org, Cristian Dumitrescu , Qi Zhang Subject: [PATCH] ethdev: introduce generic flow item and action Date: Wed, 2 Aug 2023 13:34:51 -0400 Message-Id: <20230802173451.3151646-1-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 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 From: Cristian Dumitrescu For network devices that are programmable through languages such as the P4 language, there are no pre-defined flow items and actions. The format of the protocol header and metadata fields that are used to specify the flow items that make up the flow pattern, as well as the flow actions, are all defined by the program, with an infinity of possible combinations, as opposed to being selected from a finite pre-defined list. It is virtually impossible to pre-define all the flow items and the flow actions that programs might ever use, as these are only limited by the set of HW resources and the program developer's imagination. To support the programmable network devices, we are introducing: * A generic flow item: The flow item is expressed as an array of bytes of a given length, whose meaning is defined by the program loaded by the network device. The device is still expected to accept the existing pre-defined flow items such as Ethernet, IPv4/IPv6 headers, etc, as long as the program currently loaded on the device is defining and using flow items with identical format, but the device is not limited to the current set of pre-defined RTE_FLOW flow items. * A generic flow action: The flow action exact processing is defined by the program loaded by the network device, with the user expected to know the set of program actions for the purpose of assigning actions to flows. The device is still expected to accept the existing pre-defined flow actions such as packet drop, packet redirection to output queues, packet modifications, etc, as long as the program currently loaded on the device is defining and using flow actions that perform identical processing, but the device is not limited to the current set of pre-defined RTE_FLOW flow actions. Signed-off-by: Cristian Dumitrescu Signed-off-by: Qi Zhang --- lib/ethdev/rte_flow.h | 82 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 3fe57140f9..f7889d7dd0 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -688,6 +688,15 @@ enum rte_flow_item_type { * @see struct rte_flow_item_ib_bth. */ RTE_FLOW_ITEM_TYPE_IB_BTH, + + /** + * Matches a custom protocol header or metadata field represented + * as a byte string of a given length, whose meaning is typically + * defined by the data plane program. + * + * @see struct rte_flow_item_generic. + */ + RTE_FLOW_ITEM_TYPE_GENERIC, }; /** @@ -2311,6 +2320,32 @@ static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_GENERIC + * + * Matches a custom protocol header or metadata field represented as a byte + * array of a given length, whose meaning is typically defined by the data + * plane program. + * + * The field length must be non-zero. The field value must be non-NULL, with the + * value bytes specified in network byte order. + */ +struct rte_flow_item_generic { + uint32_t length; /**< Field length. */ + const uint8_t *value; /**< Field value. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_GENERIC. */ +#ifndef __cplusplus +static const struct rte_flow_item_generic rte_flow_item_generic_mask = { + .length = 0xffffffff, + .value = NULL, +}; +#endif + /** * Action types. * @@ -2989,6 +3024,14 @@ enum rte_flow_action_type { * @see struct rte_flow_action_indirect_list */ RTE_FLOW_ACTION_TYPE_INDIRECT_LIST, + + /** + * Custom action whose processing is typically defined by the data plane + * program. + * + * @see struct rte_flow_action_generic. + */ + RTE_FLOW_ACTION_TYPE_GENERIC, }; /** @@ -4064,6 +4107,45 @@ struct rte_flow_indirect_update_flow_meter_mark { enum rte_color init_color; }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice. + * + * Generic action argument configuration parameters. + * + * The action argument field length must be non-zero. The action argument field + * value must be non-NULL, with the value bytes specified in network byte order. + * + * @see struct rte_flow_action_generic + */ +struct rte_flow_action_generic_argument { + /** Argument field length. */ + uint32_t length; + /** Argument field value. */ + const uint8_t *value; +}; + +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice. + * + * RTE_FLOW_ACTION_TYPE_GENERIC + * + * Generic action configuration parameters. + * + * Each action can have zero or more arguments. + * + * @see RTE_FLOW_ACTION_TYPE_GENERIC + */ +struct rte_flow_action_generic { + /** Action ID. */ + uint32_t action_id; + /** Number of action arguments. */ + uint32_t action_args_num; + /** Action arguments array. */ + const struct rte_flow_action_generic_argument *action_args; +}; + /* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;