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 5AF93A0C3F; Mon, 5 Jul 2021 17:58:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D478411F5; Mon, 5 Jul 2021 17:58:28 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by mails.dpdk.org (Postfix) with ESMTP id 5270D411EF for ; Mon, 5 Jul 2021 17:58:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TQtrGBDnI8CNb+ofSUUTWrSf8cZOcav1OEY0DyFD5/Kj1gbf1hYgd8kBLZnGhaY/HpuVyix/H+hh359OragSSNGqPhLTzUqgpvuKuuFcIME0gxeJalQXhIYIAfaLgS/so/ogCMVM0GZrq3Pgl1k3mjmPDUCEO+aBr+zqEI+oPpxiMf/zVLtIt6gX/hKbizUrfhgAN8dFNj9aGtxJ6G0h0lZLh82iMxFIHxJvAkCTaUoFBNz8zZ9ROCIuQl1p+ijyJhyF41T0WAy5NkqxJHOpATtnqjpvFijdhSgLyj1BcxLn8VXr2RDoyvSh+iFqej+lopkItUFPBptVeRtYjDsHhw== 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-SenderADCheck; bh=bIbiHVYOyZn7rinh/WRMvIvgJE+ODkGq/7V51h4uC4Y=; b=CabGtd6nGEG0zlgRosJQz+qbI2nuDVjGcaJ9FHAUUvub/eIzO1rPg0jo9xcVrlAffvh3Gk79ywJeGa90jcW3PDf2MTG9r8AdBy9saIcYDrTYB8dZ+vkaeeFJWNJ+mLSCtL5zpY6Jx3TCpex8oOcYLE0tGiImIAUt8lMsvMBQSd4wglbxk4yJxpjKqLOtTxBtYwkg/bck/JA0Bfn8+hPLgvcJPiYbmAjRVEfqfBR0J0hTV4s5Qm3gFkYT0zBB2MbLxVsKgCMW03g2C6hgLiuy/50dKCI2G2vCAXH7oaVURGq5ymzODJGtJK2d2MF7Hb6VcmCbPlcpYnDNZRrpdc3BOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none 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=bIbiHVYOyZn7rinh/WRMvIvgJE+ODkGq/7V51h4uC4Y=; b=ca6sSjGWRBZwjvEwlVZ2Vdz+Vano9DO4/mcBuce48UJ3ruz7IQcs4PdGZbVX8Ti5V4ByoyUE2P9JpFiLxg3jtZNT0b0WqyfQ7m/3A1Krn4UDdmYAMFi8ylrJTeZrQRvDVH6oQHI64u5qF+SvWJikM1hMVmZdmOQ+LiDcKCuVxpulNggIq+6J5e8GWlJ30yaztDgz5/G0mKciml5hbPO2frtuvMrHCe2DSWj9/62Dwe8Y1y0hFzOI9042OGII5e74T5JCjDVHDwk6uLg/9flAYr2yuKzOOCmXJbyuLzDLJbrksxoiRWlzdTIo6E2lAXTUlcg1DDdVRTV2JxxSyA0iIQ== Received: from DM3PR08CA0001.namprd08.prod.outlook.com (2603:10b6:0:52::11) by DM4PR12MB5263.namprd12.prod.outlook.com (2603:10b6:5:39b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22; Mon, 5 Jul 2021 15:58:24 +0000 Received: from DM6NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:0:52:cafe::5e) by DM3PR08CA0001.outlook.office365.com (2603:10b6:0:52::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Mon, 5 Jul 2021 15:58:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) 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.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 DM6NAM11FT055.mail.protection.outlook.com (10.13.173.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Mon, 5 Jul 2021 15:58:24 +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.2; Mon, 5 Jul 2021 15:58:22 +0000 From: Bing Zhao To: , CC: , , Date: Mon, 5 Jul 2021 18:57:52 +0300 Message-ID: <20210705155756.21443-3-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210705155756.21443-1-bingz@nvidia.com> References: <20210705155756.21443-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: bb69edbe-f5cd-484f-c801-08d93fcdb87a X-MS-TrafficTypeDiagnostic: DM4PR12MB5263: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zTeJxdXTq9e+zbfvsdyH8fhLkt+B6fOG/66vyoKu+8T20FI8IsEOKIpRtSBgxgVEibP9TIkbx1Z61x5/KYYTIhnsC9oun2ps1iMITqVUlkWoGuVI9s/re9OG+c6x2YQDzVneAw75ayU6kkSDNiih6JrPylgsocyLBY3Lwjbq20y6fhHgnOZSevVe95WoqJqZg7gerfOJEVz+mYxD1FuRBljm4h1wZOINmBuCNc5HEX1FNzxnseef6/zHVJ9uN3lywSj73fcwKtSWiH8DooCkr7XzWUYPAQ01+9RZpa2BTinlf6DAf3Sg+0As+aKAA4+tfkF4iwwEVuioR6Z3aCwKXPdI57cyJGo9sG1+TrlGz3AuvD3VuQ1a84wQhlbRp1tGEYjbO28CMIAQTpT3qXNU+pHLuVa1fuO/fGKZxTXpQAZ4TtrESMThM1OfHHuDcAWUd5oQmVgfjqDbiIkDE7WGQotSg5Sc27M9orHnJ6aVGMkn1h5b2JmXWXg55z93EF+4J9zMRFIn1SC0iUtDFnI/wsJ9YC2rpd/yjou6cMkhV4IPxqq4Wlu3vC4Lw+BoHSpkoIKMjN0eOziC+Kio/hikqqziv8D0rBZTmsND8+kjRWiliTxg9OTFcbfTfUKgeQw1EPBCb9AQQbx0qKo95NIKnNxUiQyl+kFcmS0kd524LNc3qG92LrzjBF0N71T5rpjP718DYgalxXLLub+/yICpzg== 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)(39860400002)(346002)(396003)(136003)(376002)(46966006)(36840700001)(478600001)(6286002)(2616005)(110136005)(1076003)(7696005)(16526019)(47076005)(336012)(6636002)(8676002)(36860700001)(82310400003)(186003)(107886003)(30864003)(54906003)(86362001)(36756003)(426003)(26005)(8936002)(4326008)(83380400001)(5660300002)(7636003)(356005)(82740400003)(36906005)(70586007)(55016002)(316002)(2906002)(70206006)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2021 15:58:24.3986 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb69edbe-f5cd-484f-c801-08d93fcdb87a 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: DM6NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5263 Subject: [dpdk-dev] [PATCH 2/6] net/mlx5: support yellow in meter policy validation 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" In the previous implementation, the policy for yellow color was not supported. The action validation for yellow was skipped. Since the yellow color policy needs to be supported, the validation should also be done for yellow color. In the meanwhile, due to the fact that color policies of one meter should be used for the same flow(s), the domains supported of both colors shall be the same. If both of the colors have RSS as the fate actions, except the queues, all other parameters of RSS should be the same. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5.h | 4 +- drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow_dv.c | 151 +++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_meter.c | 3 +- 4 files changed, 97 insertions(+), 65 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 1b2dc8f815..1d2e003900 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -608,8 +608,8 @@ struct mlx5_dev_shared_port { /*ASO flow meter structures*/ /* Modify this value if enum rte_mtr_color changes. */ #define RTE_MTR_DROPPED RTE_COLORS -/* Yellow is not supported. */ -#define MLX5_MTR_RTE_COLORS (RTE_COLOR_GREEN + 1) +/* Yellow is now supported. */ +#define MLX5_MTR_RTE_COLORS (RTE_COLOR_YELLOW + 1) /* table_id 22 bits in mlx5_flow_tbl_key so limit policy number. */ #define MLX5_MAX_SUB_POLICY_TBL_NUM 0x3FFFFF #define MLX5_INVALID_POLICY_ID UINT32_MAX diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 3b7c94d92f..61c72da2aa 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7093,8 +7093,8 @@ mlx5_flow_validate_mtr_acts(struct rte_eth_dev *dev, const struct mlx5_flow_driver_ops *fops; fops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV); - return fops->validate_mtr_acts(dev, actions, attr, - is_rss, domain_bitmap, is_def_policy, error); + return fops->validate_mtr_acts(dev, actions, attr, is_rss, + domain_bitmap, is_def_policy, error); } /** diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c6a06d9def..f53cf65e87 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -16430,6 +16430,19 @@ flow_dv_action_validate(struct rte_eth_dev *dev, } } +static inline int +flow_dv_mtr_policy_rss_compare(const struct rte_flow_action_rss *r1, + const struct rte_flow_action_rss *r2) +{ + if (!r1 || !r2) + return 0; + if (r1->func != r2->func || r1->level != r2->level || + r1->types != r2->types || r1->key_len != r2->key_len || + memcmp(r1->key, r2->key, r1->key_len)) + return 1; + return 0; +} + /** * Validate meter policy actions. * Dispatcher for action type specific validation. @@ -16459,42 +16472,46 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_dev_config *dev_conf = &priv->config; const struct rte_flow_action *act; - uint64_t action_flags = 0; + uint64_t action_flags[RTE_COLORS] = {0}; int actions_n; int i, ret; struct rte_flow_error flow_err; uint8_t domain_color[RTE_COLORS] = {0}; uint8_t def_domain = MLX5_MTR_ALL_DOMAIN_BIT; + bool def_green = false; + bool def_yellow = false; + const struct rte_flow_action_rss *rss_color[RTE_COLORS] = {NULL}; if (!priv->config.dv_esw_en) def_domain &= ~MLX5_MTR_DOMAIN_TRANSFER_BIT; *domain_bitmap = def_domain; - if (actions[RTE_COLOR_YELLOW] && - actions[RTE_COLOR_YELLOW]->type != RTE_FLOW_ACTION_TYPE_END) - return -rte_mtr_error_set(error, ENOTSUP, - RTE_MTR_ERROR_TYPE_METER_POLICY, - NULL, - "Yellow color does not support any action."); - if (actions[RTE_COLOR_YELLOW] && - actions[RTE_COLOR_YELLOW]->type != RTE_FLOW_ACTION_TYPE_DROP) + if (actions[RTE_COLOR_RED] && + actions[RTE_COLOR_RED]->type != RTE_FLOW_ACTION_TYPE_DROP) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "Red color only supports drop action."); /* * Check default policy actions: - * Green/Yellow: no action, Red: drop action + * Green / Yellow: no action, Red: drop action + * Either G or Y will trigger default policy actions to be created. */ - if ((!actions[RTE_COLOR_GREEN] || - actions[RTE_COLOR_GREEN]->type == RTE_FLOW_ACTION_TYPE_END)) { + if (!actions[RTE_COLOR_GREEN] || + actions[RTE_COLOR_GREEN]->type == RTE_FLOW_ACTION_TYPE_END) + def_green = true; + if (!actions[RTE_COLOR_YELLOW] || + actions[RTE_COLOR_YELLOW]->type == RTE_FLOW_ACTION_TYPE_END) + def_yellow = true; + if (def_green && def_yellow) { *is_def_policy = true; return 0; } - flow_err.message = NULL; + /* Set to empty string in case of NULL pointer access by user. */ + flow_err.message = ""; for (i = 0; i < RTE_COLORS; i++) { act = actions[i]; - for (action_flags = 0, actions_n = 0; - act && act->type != RTE_FLOW_ACTION_TYPE_END; - act++) { + for (action_flags[i] = 0, actions_n = 0; + act && act->type != RTE_FLOW_ACTION_TYPE_END; + act++) { if (actions_n == MLX5_DV_MAX_NUMBER_OF_ACTIONS) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, @@ -16508,7 +16525,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, NULL, "PORT action validate check" " fail for ESW disable"); ret = flow_dv_validate_action_port_id(dev, - action_flags, + action_flags[i], act, attr, &flow_err); if (ret) return -rte_mtr_error_set(error, @@ -16518,11 +16535,11 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, flow_err.message : "PORT action validate check fail"); ++actions_n; - action_flags |= MLX5_FLOW_ACTION_PORT_ID; + action_flags[i] |= MLX5_FLOW_ACTION_PORT_ID; break; case RTE_FLOW_ACTION_TYPE_MARK: ret = flow_dv_validate_action_mark(dev, act, - action_flags, + action_flags[i], attr, &flow_err); if (ret < 0) return -rte_mtr_error_set(error, @@ -16539,12 +16556,12 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, NULL, "Extend MARK action is " "not supported. Please try use " "default policy for meter."); - action_flags |= MLX5_FLOW_ACTION_MARK; + action_flags[i] |= MLX5_FLOW_ACTION_MARK; ++actions_n; break; case RTE_FLOW_ACTION_TYPE_SET_TAG: ret = flow_dv_validate_action_set_tag(dev, - act, action_flags, + act, action_flags[i], attr, &flow_err); if (ret) return -rte_mtr_error_set(error, @@ -16557,15 +16574,14 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, * Count all modify-header actions * as one action. */ - if (!(action_flags & - MLX5_FLOW_MODIFY_HDR_ACTIONS)) + if (!(action_flags[i] & + MLX5_FLOW_MODIFY_HDR_ACTIONS)) ++actions_n; - action_flags |= MLX5_FLOW_ACTION_SET_TAG; + action_flags[i] |= MLX5_FLOW_ACTION_SET_TAG; break; case RTE_FLOW_ACTION_TYPE_DROP: ret = mlx5_flow_validate_action_drop - (action_flags, - attr, &flow_err); + (action_flags[i], attr, &flow_err); if (ret < 0) return -rte_mtr_error_set(error, ENOTSUP, @@ -16573,7 +16589,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, NULL, flow_err.message ? flow_err.message : "Drop action validate check fail"); - action_flags |= MLX5_FLOW_ACTION_DROP; + action_flags[i] |= MLX5_FLOW_ACTION_DROP; ++actions_n; break; case RTE_FLOW_ACTION_TYPE_QUEUE: @@ -16582,9 +16598,9 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, * metadata feature is engaged. */ if (dev_conf->dv_flow_en && - (dev_conf->dv_xmeta_en != - MLX5_XMETA_MODE_LEGACY) && - mlx5_flow_ext_mreg_supported(dev)) + (dev_conf->dv_xmeta_en != + MLX5_XMETA_MODE_LEGACY) && + mlx5_flow_ext_mreg_supported(dev)) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, @@ -16592,7 +16608,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, "is not supported. Please try use " "default policy for meter."); ret = mlx5_flow_validate_action_queue(act, - action_flags, dev, + action_flags[i], dev, attr, &flow_err); if (ret < 0) return -rte_mtr_error_set(error, @@ -16601,14 +16617,14 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, NULL, flow_err.message ? flow_err.message : "Queue action validate check fail"); - action_flags |= MLX5_FLOW_ACTION_QUEUE; + action_flags[i] |= MLX5_FLOW_ACTION_QUEUE; ++actions_n; break; case RTE_FLOW_ACTION_TYPE_RSS: if (dev_conf->dv_flow_en && - (dev_conf->dv_xmeta_en != - MLX5_XMETA_MODE_LEGACY) && - mlx5_flow_ext_mreg_supported(dev)) + (dev_conf->dv_xmeta_en != + MLX5_XMETA_MODE_LEGACY) && + mlx5_flow_ext_mreg_supported(dev)) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, @@ -16624,13 +16640,14 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, NULL, flow_err.message ? flow_err.message : "RSS action validate check fail"); - action_flags |= MLX5_FLOW_ACTION_RSS; + action_flags[i] |= MLX5_FLOW_ACTION_RSS; ++actions_n; - *is_rss = true; + /* Either G or Y will set the RSS. */ + rss_color[i] = act->conf; break; case RTE_FLOW_ACTION_TYPE_JUMP: ret = flow_dv_validate_action_jump(dev, - NULL, act, action_flags, + NULL, act, action_flags[i], attr, true, &flow_err); if (ret) return -rte_mtr_error_set(error, @@ -16640,7 +16657,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, flow_err.message : "Jump action validate check fail"); ++actions_n; - action_flags |= MLX5_FLOW_ACTION_JUMP; + action_flags[i] |= MLX5_FLOW_ACTION_JUMP; break; default: return -rte_mtr_error_set(error, ENOTSUP, @@ -16649,17 +16666,14 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, "Doesn't support optional action"); } } - /* Yellow is not supported, just skip. */ - if (i == RTE_COLOR_YELLOW) - continue; - if (action_flags & MLX5_FLOW_ACTION_PORT_ID) + if (action_flags[i] & MLX5_FLOW_ACTION_PORT_ID) domain_color[i] = MLX5_MTR_DOMAIN_TRANSFER_BIT; - else if ((action_flags & - (MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_QUEUE)) || - (action_flags & MLX5_FLOW_ACTION_MARK)) + else if ((action_flags[i] & + (MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_QUEUE)) || + (action_flags[i] & MLX5_FLOW_ACTION_MARK)) /* * Only support MLX5_XMETA_MODE_LEGACY - * so MARK action only in ingress domain. + * so MARK action is only in ingress domain. */ domain_color[i] = MLX5_MTR_DOMAIN_INGRESS_BIT; else @@ -16669,8 +16683,8 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, * with other actions. Drop action is mutually-exclusive * with any other action, except for Count action. */ - if ((action_flags & MLX5_FLOW_ACTION_DROP) && - (action_flags & ~MLX5_FLOW_ACTION_DROP)) { + if ((action_flags[i] & MLX5_FLOW_ACTION_DROP) && + (action_flags[i] & ~MLX5_FLOW_ACTION_DROP)) { return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "Drop action is mutually-exclusive " @@ -16679,30 +16693,29 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, /* Eswitch has few restrictions on using items and actions */ if (domain_color[i] & MLX5_MTR_DOMAIN_TRANSFER_BIT) { if (!mlx5_flow_ext_mreg_supported(dev) && - action_flags & MLX5_FLOW_ACTION_MARK) + action_flags[i] & MLX5_FLOW_ACTION_MARK) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "unsupported action MARK"); - if (action_flags & MLX5_FLOW_ACTION_QUEUE) + if (action_flags[i] & MLX5_FLOW_ACTION_QUEUE) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "unsupported action QUEUE"); - if (action_flags & MLX5_FLOW_ACTION_RSS) + if (action_flags[i] & MLX5_FLOW_ACTION_RSS) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "unsupported action RSS"); - if (!(action_flags & MLX5_FLOW_FATE_ESWITCH_ACTIONS)) + if (!(action_flags[i] & MLX5_FLOW_FATE_ESWITCH_ACTIONS)) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "no fate action is found"); } else { - if (!(action_flags & MLX5_FLOW_FATE_ACTIONS) && - (domain_color[i] & - MLX5_MTR_DOMAIN_INGRESS_BIT)) { + if (!(action_flags[i] & MLX5_FLOW_FATE_ACTIONS) && + (domain_color[i] & MLX5_MTR_DOMAIN_INGRESS_BIT)) { if ((domain_color[i] & - MLX5_MTR_DOMAIN_EGRESS_BIT)) + MLX5_MTR_DOMAIN_EGRESS_BIT)) domain_color[i] = - MLX5_MTR_DOMAIN_EGRESS_BIT; + MLX5_MTR_DOMAIN_EGRESS_BIT; else return -rte_mtr_error_set(error, ENOTSUP, @@ -16710,9 +16723,27 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, NULL, "no fate action is found"); } } - if (domain_color[i] != def_domain) - *domain_bitmap = domain_color[i]; } + /* If both colors have RSS, the attributes should be the same. */ + if (flow_dv_mtr_policy_rss_compare(rss_color[RTE_COLOR_GREEN], + rss_color[RTE_COLOR_YELLOW])) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, "policy RSS attr conflict"); + if (rss_color[RTE_COLOR_GREEN] || rss_color[RTE_COLOR_YELLOW]) + *is_rss = true; + /* "domain_color[C]" is non-zero for each color, default is ALL. */ + if (!def_green && !def_yellow && + domain_color[RTE_COLOR_GREEN] != domain_color[RTE_COLOR_YELLOW]) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, "policy domains conflict"); + /* + * At least one color policy is listed in the actions, the domains + * to be supported should be the intersection. + */ + *domain_bitmap = domain_color[RTE_COLOR_GREEN] & + domain_color[RTE_COLOR_YELLOW]; return 0; } diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index d7ce5cd2f6..d313786eb3 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -660,7 +660,8 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, "policy ID exists. "); ret = mlx5_flow_validate_mtr_acts(dev, policy->actions, &attr, - &is_rss, &domain_bitmap, &is_def_policy, error); + &is_rss, &domain_bitmap, + &is_def_policy, error); if (ret) return ret; if (!domain_bitmap) -- 2.27.0