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 E718CA00C2; Thu, 3 Nov 2022 11:10:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C21540694; Thu, 3 Nov 2022 11:10:54 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2066.outbound.protection.outlook.com [40.107.237.66]) by mails.dpdk.org (Postfix) with ESMTP id 3832D40693 for ; Thu, 3 Nov 2022 11:10:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AvFYvlrJq2HBk+ogSgcHqftqqajvShbN5PYfJVXA8Ve3b/mGWAZWeZrGM6Lzeb9zmqdSHdz/pUKBEE03gyzU7UZeDqGelZeNqQC0ciqwjk6IYc6QozcoRXL2LFi96d0Cyw1hRWZsgl1bejqw2VM9XAlHrJPXhgUVzHyN6tlIeHWx2URk+mOyQob+pEkR09B3MkbIA3podGOR9qNJpMIaW59FbWev+hr+F4YQD0V+I6XP0A4NPmubmmTFCxU8rbNGwm2XPsHH4rDZjlcQp3ximbvhHyfoFRWbWk6p/3UUfAqVtIflqwVjxZm4ITHFGzZ1hLDsMULekL4DfH/qLUmDNQ== 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=LUHJmsXxqzlgMISjfSfz7wlHNv8plKvVs7PZtBm7g3o=; b=lQ0L+Vkjl5bbRssu2+NC+4+YbjxpBAze8/1UKvSoWtqxmKIIpAW5R956mvVE9PbjiUN+G9uUmP0/V/0NSoEMCClXhV5kjWdOQzmGfP5C/mcr68lT5JmEHSzt0EMT9IPYru0YfwcxoGByd6orLT3/CqOp03xl+u6IdpkrbPSgq2SDvYRWXR3DJpWwc/VEPwZrHTRFu1QXY6v6lrCqIxWt0G7Hh2xnX7kA5jvdaHq0Z2kg/okZ3859bYz2EloNWUDU2Z4rO6bft5+spDxmu/FPu6Ha7UYHgZNzpxMOA/eSf6+kJ2Up8zeaBD6E6yNCyQTptho+tfZ27J2Trdvw1ZX3OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=LUHJmsXxqzlgMISjfSfz7wlHNv8plKvVs7PZtBm7g3o=; b=U/ZSjZsPAdqmJ4edTRmyT8aNu22lut51V2L+hhNcc7Ap+vc9c9A/BTGMTtMMS3E6ST9Bb5zVmbsQ3eCaRnB7MUDkrcw/lWZmLtxriPOgrEdf0ffcl8W5HhwPkfZyyCXhLRrOvkUC5mTcHlDs6jLa/eQ8adqByeJarH83+ZV3+POcUee8ccUex+ncJGt55t72RKdFn5iBDB0W8Df1HcmDol87LsioexwK5chKOGshjTMzJqol3neZYMsIEYA2zjbl1BhtIoaoUrBtfJdbS3bfKeuDJMPygyZBqwwuXuMgs99ZVJ2Yq1cKYw87Frgv6e6f7PEFE5TSJFup2iZ9/ghHUQ== Received: from MW4PR03CA0001.namprd03.prod.outlook.com (2603:10b6:303:8f::6) by CY8PR12MB8066.namprd12.prod.outlook.com (2603:10b6:930:70::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Thu, 3 Nov 2022 10:10:50 +0000 Received: from CO1NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::c3) by MW4PR03CA0001.outlook.office365.com (2603:10b6:303:8f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21 via Frontend Transport; Thu, 3 Nov 2022 10:10:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT061.mail.protection.outlook.com (10.13.175.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20 via Frontend Transport; Thu, 3 Nov 2022 10:10:50 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 3 Nov 2022 03:10:37 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 3 Nov 2022 03:10:35 -0700 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko CC: , Raslan Darawsheh Subject: [PATCH] net/mlx5: forbid direction attributes in transfer flow rules Date: Thu, 3 Nov 2022 10:10:05 +0000 Message-ID: <20221103101005.204800-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT061:EE_|CY8PR12MB8066:EE_ X-MS-Office365-Filtering-Correlation-Id: 403862ac-3ea4-4900-45c9-08dabd83af43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lac3QRpiytlywvF7EoAM6cEj5Obmp41ZMyqIaUlR27ybwgo239bX9BdJUdl59ZkMRI6kn+WVK2pVfyxsknOaMsZ4PyLPMXljXbjBHYofP/lGNHUjEmzZ/+46ZFM8fTmoH/yAPLKDQrTLRCpMRIFkm0I+hhCtl2Ulcw1FeAVt2g1ukNaQPye6PZMWVwh2CNgeP+cF/m3MMpGe36XZlmJXDID8ZeYQ1tLghvw9XPTDwtT3xYH9XYz2IeoljDJvbHSA0Wzb+GorUmBbLZdp1M5oxcpnKNGxaPpN+8wy4RyUph4kSsk3dx5XGXVNuF9zDuZow1dxcgOpW1tdvW+wjEFkN0cYQk7sFzdHCuef80NRKQ/vpcTL5v92ATZOZkXobz3gpdetjv90AAxsqkdgQNX99kuw5Yn0mW+8Qct8qJZrXQagEmYssR4gwRqDZTQiFM9Sz5qHfpfqpAAeu9Qgdn570toBQJp85ENLI70HCfN6K5gJNouvkZPwxziMQIvq8Q2H6dLp0YjwiL7bU0+FFvo7/cT4ArP1nqdCFM23zTZy/2O3yxHfJen8IWcHto0FQ9Xag7aOB09GrcnyzAaDBsf1XCS84i9joU0ePPljH3B3tsSauVKfGIvs49E415navAm7Rs9gDx9EVv81GuWTyg27z5oINEZumutCMkNTKbs8GotWFPdlEb0nj3PSss7+h7p8Vs2pDaQTxhPQXkksk5HZEVID4Ht3D7GZShvTi3HzcjHOdqEgYMNS/eqBv7JXdbcgqfpDfvsryWXLoBSr7F90iQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199015)(46966006)(36840700001)(40470700004)(36756003)(82310400005)(70206006)(41300700001)(47076005)(55016003)(7636003)(316002)(5660300002)(8936002)(40460700003)(40480700001)(110136005)(6636002)(54906003)(2906002)(30864003)(356005)(6286002)(426003)(26005)(2616005)(16526019)(336012)(70586007)(4326008)(1076003)(83380400001)(186003)(478600001)(36860700001)(82740400003)(86362001)(107886003)(7696005)(8676002)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2022 10:10:50.3571 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 403862ac-3ea4-4900-45c9-08dabd83af43 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8066 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 Since [1] flow API forbids usage of direction attributes in transfer flow rules. This patch adapts mlx5 PMD to this requirement. >From this patch, flow rule validation in mxl5 PMD will reject transfer flow rules with any of the direction attributes set (i.e. 'ingress' or 'egress'). As a result flow rule can only have one of 'ingress', 'egress' or 'transfer' attributes set. This patch also changes the following: - Control flow rules used in FDB are 'transfer' only. - Checks which assumed that 'transfer' can be used with 'ingress' and 'egress' are reduced to just checking for direction attributes, since all attributes are exclusive. - Flow rules for updating flow_tag are created for both ingress and transfer flow rules which have MARK action. - Moves mlx5_flow_validate_attributes() function from generic flow implementation to legacy Verbs flow engine implementation, since it was used only there. Function is renamed accordingly. Also removes checking if E-Switch uses DV in that function, since if legacy Verbs flow engine is used, then that is always not the case. [1] commit bd2a4d4b2e3a ("ethdev: forbid direction attribute in transfer flow rules") Signed-off-by: Dariusz Sosnowski Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 59 +++--------------------------- drivers/net/mlx5/mlx5_flow.h | 3 -- drivers/net/mlx5/mlx5_flow_dv.c | 42 ++++++++------------- drivers/net/mlx5/mlx5_flow_verbs.c | 50 ++++++++++++++++++++++++- 4 files changed, 71 insertions(+), 83 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 8e7d649d15..921e419d05 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2299,53 +2299,6 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev, return 0; } -/** - * Verify the @p attributes will be correctly understood by the NIC and store - * them in the @p flow if everything is correct. - * - * @param[in] dev - * Pointer to the Ethernet device structure. - * @param[in] attributes - * Pointer to flow attributes - * @param[out] error - * Pointer to error structure. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -int -mlx5_flow_validate_attributes(struct rte_eth_dev *dev, - const struct rte_flow_attr *attributes, - struct rte_flow_error *error) -{ - struct mlx5_priv *priv = dev->data->dev_private; - uint32_t priority_max = priv->sh->flow_max_priority - 1; - - if (attributes->group) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_GROUP, - NULL, "groups is not supported"); - if (attributes->priority != MLX5_FLOW_LOWEST_PRIO_INDICATOR && - attributes->priority >= priority_max) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, - NULL, "priority out of range"); - if (attributes->egress) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, - "egress is not supported"); - if (attributes->transfer && !priv->sh->config.dv_esw_en) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, - NULL, "transfer is not supported"); - if (!attributes->ingress) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, - NULL, - "ingress attribute is mandatory"); - return 0; -} - /** * Validate ICMP6 item. * @@ -6342,7 +6295,7 @@ flow_create_split_metadata(struct rte_eth_dev *dev, ret = -rte_errno; goto exit; } - } else if (attr->egress && !attr->transfer) { + } else if (attr->egress) { /* * All the actions on NIC Tx should have a metadata register * copy action to copy reg_a from WQE to reg_c[meta] @@ -7061,7 +7014,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, flow->drv_type < MLX5_FLOW_TYPE_MAX); memset(rss_desc, 0, offsetof(struct mlx5_flow_rss_desc, queue)); /* RSS Action only works on NIC RX domain */ - if (attr->ingress && !attr->transfer) + if (attr->ingress) rss = flow_get_rss_action(dev, p_actions_rx); if (rss) { if (flow_rss_workspace_adjust(wks, rss_desc, rss->queue_num)) @@ -7159,11 +7112,11 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, * we might create the extra rte_flow for each unique * MARK/FLAG action ID. * - * The table is updated for ingress Flows only, because + * The table is updated for ingress and transfer flows only, because * the egress Flows belong to the different device and * copy table should be updated in peer NIC Rx domain. */ - if (attr->ingress && + if ((attr->ingress || attr->transfer) && (external || attr->group != MLX5_FLOW_MREG_CP_TABLE_GROUP)) { ret = flow_mreg_update_copy_table(dev, flow, actions, error); if (ret) @@ -7235,7 +7188,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) const struct rte_flow_attr attr = { .group = 0, .priority = 0, - .ingress = 1, + .ingress = 0, .egress = 0, .transfer = 1, }; @@ -7279,7 +7232,7 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num) struct rte_flow_attr attr = { .group = 0, .priority = MLX5_FLOW_LOWEST_PRIO_INDICATOR, - .ingress = 1, + .ingress = 0, .egress = 0, .transfer = 1, }; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index da9b65d8fe..2398e44ea0 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2228,9 +2228,6 @@ int mlx5_flow_validate_action_rss(const struct rte_flow_action *action, int mlx5_flow_validate_action_default_miss(uint64_t action_flags, const struct rte_flow_attr *attr, struct rte_flow_error *error); -int mlx5_flow_validate_attributes(struct rte_eth_dev *dev, - const struct rte_flow_attr *attributes, - struct rte_flow_error *error); int mlx5_flow_item_acceptable(const struct rte_flow_item *item, const uint8_t *mask, const uint8_t *nic_mask, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1e52278191..2be62cbdcb 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3384,8 +3384,7 @@ flow_dv_validate_action_set_tag(struct rte_eth_dev *dev, ret = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG, conf->index, error); if (ret < 0) return ret; - if (!attr->transfer && attr->ingress && - (action_flags & terminal_action_flags)) + if (attr->ingress && (action_flags & terminal_action_flags)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "set_tag has no effect" @@ -5942,7 +5941,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, "action"); } } - if (attr->ingress && !attr->transfer) { + if (attr->ingress) { if (!(sub_action_flags & (MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS))) return rte_flow_error_set(error, EINVAL, @@ -5950,7 +5949,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, NULL, "Ingress must has a dest " "QUEUE for Sample"); - } else if (attr->egress && !attr->transfer) { + } else if (attr->egress) { return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, @@ -5995,8 +5994,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, NULL, "encap and decap " "combination aren't " "supported"); - if (!attr->transfer && attr->ingress && (sub_action_flags & - MLX5_FLOW_ACTION_ENCAP)) + if (attr->ingress && (sub_action_flags & MLX5_FLOW_ACTION_ENCAP)) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "encap is not supported" @@ -6820,23 +6818,16 @@ flow_dv_validate_attributes(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, NULL, "priority out of range"); - if (attributes->transfer) { - if (!priv->sh->config.dv_esw_en) - return rte_flow_error_set - (error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "E-Switch dr is not supported"); - if (attributes->egress) - return rte_flow_error_set - (error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, attributes, - "egress is not supported"); - } - if (!(attributes->egress ^ attributes->ingress)) + if (attributes->transfer && !priv->sh->config.dv_esw_en) return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "E-Switch dr is not supported"); + if (attributes->ingress + attributes->egress + attributes->transfer != 1) { + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR, NULL, "must specify exactly one of " - "ingress or egress"); + "ingress, egress or transfer"); + } return ret; } @@ -8153,11 +8144,11 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "tunnel set decap rule must terminate " "with JUMP"); - if (!attr->ingress) + if (attr->egress) return rte_flow_error_set (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "tunnel flows for ingress traffic only"); + "tunnel flows for ingress and transfer traffic only"); } if (action_flags & MLX5_FLOW_ACTION_TUNNEL_MATCH) { uint64_t bad_actions_mask = MLX5_FLOW_ACTION_JUMP | @@ -8262,7 +8253,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, "push VLAN action not supported " "for ingress"); } - if (!attr->transfer && attr->ingress) { + if (attr->ingress) { if (action_flags & MLX5_FLOW_ACTION_ENCAP) return rte_flow_error_set (error, ENOTSUP, @@ -8350,8 +8341,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, * hairpin default egress flow with TX_QUEUE item, other flows not * work due to metadata regC0 mismatch. */ - if ((!attr->transfer && attr->egress) && priv->representor && - !(item_flags & MLX5_FLOW_ITEM_SQ)) + if (attr->egress && priv->representor && !(item_flags & MLX5_FLOW_ITEM_SQ)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, NULL, @@ -13673,7 +13663,7 @@ flow_dv_translate_items_sws(struct rte_eth_dev *dev, !(wks.item_flags & MLX5_FLOW_ITEM_REPRESENTED_PORT) && !(wks.item_flags & MLX5_FLOW_ITEM_PORT_REPRESENTOR) && priv->sh->esw_mode && - !(attr->egress && !attr->transfer) && + !attr->egress && attr->group != MLX5_FLOW_MREG_CP_TABLE_GROUP) { if (flow_dv_translate_item_port_id_all(dev, match_mask, match_value, NULL, attr)) diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 81a33ddf09..8da2bd1f78 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -1207,6 +1207,54 @@ flow_verbs_translate_action_count(struct mlx5_flow *dev_flow, return 0; } +/** + * Validates @p attributes of the flow rule. + * + * This function is used if and only if legacy Verbs flow engine is used. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] attributes + * Pointer to flow attributes + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +flow_verbs_validate_attributes(struct rte_eth_dev *dev, + const struct rte_flow_attr *attributes, + struct rte_flow_error *error) +{ + struct mlx5_priv *priv = dev->data->dev_private; + uint32_t priority_max = priv->sh->flow_max_priority - 1; + + if (attributes->group) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_GROUP, + NULL, "groups is not supported"); + if (attributes->priority != MLX5_FLOW_LOWEST_PRIO_INDICATOR && + attributes->priority >= priority_max) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, + NULL, "priority out of range"); + if (attributes->egress) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, + "egress is not supported"); + if (attributes->transfer) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, + NULL, "transfer is not supported"); + if (!attributes->ingress) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, + NULL, + "ingress attribute is mandatory"); + return 0; +} + /** * Internal validation function. For validating both actions and items. * @@ -1249,7 +1297,7 @@ flow_verbs_validate(struct rte_eth_dev *dev, if (items == NULL) return -1; - ret = mlx5_flow_validate_attributes(dev, attr, error); + ret = flow_verbs_validate_attributes(dev, attr, error); if (ret < 0) return ret; is_root = ret; -- 2.25.1