From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB712CD5BC9 for ; Mon, 25 May 2026 14:07:22 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3DAA4065A; Mon, 25 May 2026 16:07:02 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by mails.dpdk.org (Postfix) with ESMTP id D7DC8402AC for ; Mon, 25 May 2026 16:07:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1779718021; x=1811254021; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=9r4iT2I9DXxNtbki9p9jt+9sPnzsKI2VGJZ9azRcfHs=; b=ems8O/I0YPST7eijPnxVSYKLmHUgWQDkAd3XCUNvyvQHN3car5vsTJa2 m3krUgbiq9sfi9kbGszgWr+NqHO9TkgF2mX1b1FLnvAodSKIB2GbSu42Y M9iGWAeKlIPW+kZWnjyeCyNtYx+TA0GpoRIMSVm+xNrxT9j9jDpQ4tim8 PHIUUuFOUwgDY4lEv3fUJ+WIdxCSLGo/j7Iwovj8F9nlWEHSUG4gYQsHc uUv0irPgh6jg4UumeNeS3xn0a6HWIoz7nFwfNSMlrQpnjsBJIs4l1hm1r MbGyGd3z2fspats6wZ0jk04rW1OtIeBeGw1qqBR74jOboS5E0e6Zgw42R g==; X-CSE-ConnectionGUID: ETL9YXlTTxa26h4otmwluQ== X-CSE-MsgGUID: Ov4C094CSeKNiSxI94rGWA== X-IronPort-AV: E=McAfee;i="6800,10657,11797"; a="84392488" X-IronPort-AV: E=Sophos;i="6.24,167,1774335600"; d="scan'208";a="84392488" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2026 07:07:00 -0700 X-CSE-ConnectionGUID: 0JxEV0WpR9+kle/1/RQ/xA== X-CSE-MsgGUID: sa+Lj+XlRD6ngI5U575lpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,167,1774335600"; d="scan'208";a="246692313" Received: from silpixa00401119.ir.intel.com ([10.20.224.206]) by fmviesa005.fm.intel.com with ESMTP; 25 May 2026 07:06:57 -0700 From: Anatoly Burakov To: dev@dpdk.org, Bruce Richardson Subject: [PATCH v5 04/27] net/intel/common: add common flow attr validation Date: Mon, 25 May 2026 15:06:23 +0100 Message-ID: X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 There are a lot of commonalities between what kinds of flow attr each Intel driver supports. Add a helper function that will validate attr based on common requirements and (optional) parameter checks. Things we check for: - Rejecting NULL attr (obviously) - Default to ingress flows - Transfer, group, priority, and egress are not allowed unless requested Signed-off-by: Anatoly Burakov --- drivers/net/intel/common/flow_check.h | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/net/intel/common/flow_check.h b/drivers/net/intel/common/flow_check.h index 74fb28ae3d..0572028664 100644 --- a/drivers/net/intel/common/flow_check.h +++ b/drivers/net/intel/common/flow_check.h @@ -54,6 +54,7 @@ ci_flow_action_type_in_list(const enum rte_flow_action_type type, /* Forward declarations */ struct ci_flow_actions; struct ci_flow_actions_check_param; +struct ci_flow_attr_check_param; static inline const char * ci_flow_action_type_to_str(enum rte_flow_action_type type) @@ -271,6 +272,74 @@ ci_flow_check_actions(const struct rte_flow_action *actions, return parsed_actions->count == 0 ? -EINVAL : 0; } +/** + * Parameter structure for attr check. + */ +struct ci_flow_attr_check_param { + bool allow_priority; /**< True if priority attribute is allowed. */ + bool allow_transfer; /**< True if transfer attribute is allowed. */ + bool allow_group; /**< True if group attribute is allowed. */ + bool expect_egress; /**< True if egress attribute is expected. */ +}; + +/** + * Validate rte_flow_attr structure against specified constraints. + * + * @param attr Pointer to rte_flow_attr structure to validate. + * @param attr_param Pointer to ci_flow_attr_check_param structure specifying constraints. + * @param error Pointer to rte_flow_error structure for error reporting. + * + * @return 0 on success, negative errno on failure. + */ +static inline int +ci_flow_check_attr(const struct rte_flow_attr *attr, + const struct ci_flow_attr_check_param *attr_param, + struct rte_flow_error *error) +{ + if (attr == NULL) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR, attr, + "NULL attribute"); + } + + /* Direction must be either ingress or egress */ + if (attr->ingress == attr->egress) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR, attr, + "Either ingress or egress must be set"); + } + + /* Expect ingress by default */ + if (attr->egress && (attr_param == NULL || !attr_param->expect_egress)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, attr, + "Egress not supported"); + } + + /* May not be supported */ + if (attr->transfer && (attr_param == NULL || !attr_param->allow_transfer)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, attr, + "Transfer not supported"); + } + + /* May not be supported */ + if (attr->group && (attr_param == NULL || !attr_param->allow_group)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_GROUP, attr, + "Group not supported"); + } + + /* May not be supported */ + if (attr->priority && (attr_param == NULL || !attr_param->allow_priority)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, attr, + "Priority not supported"); + } + + return 0; +} + #ifdef __cplusplus } #endif -- 2.47.3