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 85697A0A0F; Mon, 5 Jul 2021 17:58:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 925D941211; Mon, 5 Jul 2021 17:58:33 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2071.outbound.protection.outlook.com [40.107.101.71]) by mails.dpdk.org (Postfix) with ESMTP id 936994068C for ; Mon, 5 Jul 2021 17:58:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VMVYCCFklZjFJn9wqxARIRwAsOF1fqIoh4ntNorhGb35y7Y3lgNEh9mwjnRDUgobq9ebK5RcJeApJBEccEW9OEi3KULENeDxFtzlOaxIxKgTZQ6/+GTmfOmoud4ARoPemTRwTzVXSUoQu/yW1Fjk6IezBWK6C+hQVcwKhFteSvH4OIrNHmBoD5I2Lk4BI4VvleIf4UbBWNw4vGed28vrMWBbajNwozeL/oiJGUZ7g0GoVm5ESDsvuQawswC7PR65R8DRq8GoX7SXjTWuZGaMx/rxO/z5keI1WVI7y1vtwoly46g+Ks+u5XflX3zLKXA8jgomargw3b/4bmw2BaYzqg== 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=YHgk9nqreeLDFlDBRiH1b/30Nh7N9lSkJCOZxRdI/fY=; b=caan3ORwSMLHLG15kAB4NfjHkl9lQTGwwnKCzCT/yFqGNXXa/F0GGyLkeWLBc9Ac7WkYH7H12tdxqatDwDp6NqaIQxSQrQOFfTQ0DHFsKIUXhL+c+DuCxZYFBUKcBS88Lf25R3eBMdpkp5adV/TQ9MI8r5/BREGlBxxQEt1R6jM3TEN9Z5Z8r74OaJz2ICnH4Sd0e7/u2Z35fGygEsZ5PqwkhjKwsrmxDHepZecvPVIU7yjLakK0SLe75Wl6fyPQKu+y8R8BoBI5/67PV22NjnGxZKy64VosUluA9jUJL5JDLzUbWMRRyJW0oaswKtNR0b3dk4u4bUOgL+HeEjLp9w== 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=YHgk9nqreeLDFlDBRiH1b/30Nh7N9lSkJCOZxRdI/fY=; b=IwaVP8AIwdco6HNEa88OfPsogTSDuE4zATfsBfUqn2BVR7auiaE7oi1+K/676ZkxQZo5zQ3Jz4PxcsrtJ+w2AJGc6ydsrw2TigLhavU5jp1XUpKBJxHAlI61tyDS9jOMl8BnEPUYrSRZHuDy+JijbtKF6mydSFgrK5toMEX+hTLLp3AMoVO6cIsANIAKhuVVTSvOfvndig3LpXEiRc3edNv8dykPFeFUk5qx83VI1zh71sdF+A8rlTDnWtj+MZPqjRMPHq09QanhsmLl5N3ARoXKItskJswOmCrAdYp9slxItGX6f48k/e0r/A8B2nVz7lSCTlaO270uKm+eTNCxig== Received: from DM5PR15CA0027.namprd15.prod.outlook.com (2603:10b6:4:4b::13) by DM6PR12MB3353.namprd12.prod.outlook.com (2603:10b6:5:3d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.31; Mon, 5 Jul 2021 15:58:29 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:4:4b:cafe::61) by DM5PR15CA0027.outlook.office365.com (2603:10b6:4:4b::13) 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:29 +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 DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) 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:29 +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:27 +0000 From: Bing Zhao To: , CC: , , Date: Mon, 5 Jul 2021 18:57:55 +0300 Message-ID: <20210705155756.21443-6-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: 0f6c2bb3-d37f-4f5a-f9b9-08d93fcdbb7e X-MS-TrafficTypeDiagnostic: DM6PR12MB3353: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AAwvftQheZNfmpR9tEsfQaXVAQs2Ue3m/Wc4O/51YIe9Ijl/hb3F8dlIv2TMUnXIAwGbFeqsYUK2zuX/11q9a1q6W/0XlSe9eDvKxjzjmYftpRwvvQ8dqYJtnyAP+AQEaTW/N+Pe4jZZ7539tdpGTAiE1KpzThbehVf58TRzu/F4IMk2Zv3bnTuVAG6VCovCmGBezk76o5ntvs9ANi2smtQIt7lq1QQarQuUODZKIVqomI71WpxzHlGIM0n5ubbF/OM1+BDDtXH1uJ2+cHCHGGfGn/SuAHIgnaP248JkpxtetfSzrx71KZZO00P2oNwOuQrDAnzAcZiT2lbxHPWRZ9vfkqA/Gez52zrM/gc34qcT6GBV2ilMguz+oMDzOYHqdSi/UtfQD5bLUpsJmRfle6mrelBZM/GqCtM24gqwgNtVmjD9jymdxhnJGno0CZJXcTxEMb0d0Zw8f04tKC1FzJpl1GQkHgDK2VYY04mS8QgQjbWN4U4UPMNme4t8W8XhGsoU4sM00TDclbQQxLux8a4Ad67aoF0OfxjqJIniiXgKqc4c1+yhRe1qhgUJ4j3B3fwKpzlzUeBa+cLw4IxFEHbSVLt3hrvoYWIaGGeTEMMJM+bfukAKmmC9/oiLUst092SSOI5OCDkjBkKys4p21BnjC9WS3b4af6W24TXl0Ux+kPaDH4sfw44iyHngptFZcGDerc41ZPyrqGAgPyWq5g== 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)(376002)(396003)(346002)(39860400002)(136003)(46966006)(36840700001)(82740400003)(16526019)(8936002)(36756003)(186003)(107886003)(6286002)(6636002)(7696005)(478600001)(2616005)(6666004)(426003)(8676002)(36860700001)(5660300002)(336012)(26005)(70206006)(70586007)(83380400001)(1076003)(2906002)(54906003)(4326008)(36906005)(86362001)(55016002)(316002)(47076005)(7636003)(110136005)(356005)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2021 15:58:29.5112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f6c2bb3-d37f-4f5a-f9b9-08d93fcdbb7e 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: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3353 Subject: [dpdk-dev] [PATCH 5/6] net/mlx5: split policies handling of colors 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" If the fate action is either RSS or Queue of a meter policy, the action will only be created in the flow splitting stage. With queue as the fate action, only one sub-policy is needed. And RSS will have more than one sub-policies if there is an expansion. Since the RSS parameters are the same for both green and yellow colors except the queues, the expansion result will be unique. Even if only one color has the RSS action, the checking and possible expansion will be done then. For each sub-policy, the action rules need to be created separately on its own policy table. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow.c | 37 +++++++++++--------- drivers/net/mlx5/mlx5_flow_dv.c | 61 +++++++++++++++++---------------- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 61c72da2aa..89056ec45e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4604,7 +4604,7 @@ get_meter_sub_policy(struct rte_eth_dev *dev, uint32_t i; MLX5_ASSERT(wks); - /** + /* * This is a tmp dev_flow, * no need to register any matcher for it in translate. */ @@ -4612,18 +4612,19 @@ get_meter_sub_policy(struct rte_eth_dev *dev, for (i = 0; i < MLX5_MTR_RTE_COLORS; i++) { struct mlx5_flow dev_flow = {0}; struct mlx5_flow_handle dev_handle = { {0} }; + uint8_t fate = policy->act_cnt[i].fate_action; - if (policy->is_rss) { + if (fate == MLX5_FLOW_FATE_SHARED_RSS) { const void *rss_act = policy->act_cnt[i].rss->conf; struct rte_flow_action rss_actions[2] = { [0] = { .type = RTE_FLOW_ACTION_TYPE_RSS, - .conf = rss_act + .conf = rss_act, }, [1] = { .type = RTE_FLOW_ACTION_TYPE_END, - .conf = NULL + .conf = NULL, } }; @@ -4650,7 +4651,8 @@ get_meter_sub_policy(struct rte_eth_dev *dev, rss_desc_v[i].tunnel = !!(dev_flow.handle->layers & MLX5_FLOW_LAYER_TUNNEL); - } else { + rss_desc[i] = &rss_desc_v[i]; + } else if (fate == MLX5_FLOW_FATE_QUEUE) { /* This is queue action. */ rss_desc_v[i] = wks->rss_desc; rss_desc_v[i].key_len = 0; @@ -4658,24 +4660,24 @@ get_meter_sub_policy(struct rte_eth_dev *dev, rss_desc_v[i].queue = &policy->act_cnt[i].queue; rss_desc_v[i].queue_num = 1; + rss_desc[i] = &rss_desc_v[i]; + } else { + rss_desc[i] = NULL; } - rss_desc[i] = &rss_desc_v[i]; } sub_policy = flow_drv_meter_sub_policy_rss_prepare(dev, flow, policy, rss_desc); } else { enum mlx5_meter_domain mtr_domain = attr->transfer ? MLX5_MTR_DOMAIN_TRANSFER : - attr->egress ? MLX5_MTR_DOMAIN_EGRESS : - MLX5_MTR_DOMAIN_INGRESS; + (attr->egress ? MLX5_MTR_DOMAIN_EGRESS : + MLX5_MTR_DOMAIN_INGRESS); sub_policy = policy->sub_policys[mtr_domain][0]; } - if (!sub_policy) { + if (!sub_policy) rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "Failed to get meter sub-policy."); - goto exit; - } + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Failed to get meter sub-policy."); exit: return sub_policy; } @@ -4810,6 +4812,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev, struct mlx5_flow_meter_sub_policy *sub_policy; struct mlx5_flow_tbl_data_entry *tbl_data; + /* Either G or Y can still use default policy. */ if (!fm->def_policy) { sub_policy = get_meter_sub_policy(dev, flow, fm->policy_id, attr, @@ -4819,8 +4822,8 @@ flow_meter_split_prep(struct rte_eth_dev *dev, } else { enum mlx5_meter_domain mtr_domain = attr->transfer ? MLX5_MTR_DOMAIN_TRANSFER : - attr->egress ? MLX5_MTR_DOMAIN_EGRESS : - MLX5_MTR_DOMAIN_INGRESS; + (attr->egress ? MLX5_MTR_DOMAIN_EGRESS : + MLX5_MTR_DOMAIN_INGRESS); sub_policy = &priv->sh->mtrmng->def_policy[mtr_domain]->sub_policy; @@ -4836,8 +4839,8 @@ flow_meter_split_prep(struct rte_eth_dev *dev, actions_pre++; if (!tag_action) return rte_flow_error_set(error, ENOMEM, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "No tag action space."); + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "No tag action space."); if (!mtr_flow_id) { tag_action->type = RTE_FLOW_ACTION_TYPE_VOID; goto exit; diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c606fa9471..0f62537938 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -14550,7 +14550,7 @@ __flow_dv_destroy_sub_policy_rules(struct rte_eth_dev *dev, } if (sub_policy->color_matcher[i]) { tbl = container_of(sub_policy->color_matcher[i]->tbl, - typeof(*tbl), tbl); + typeof(*tbl), tbl); mlx5_cache_unregister(&tbl->matchers, &sub_policy->color_matcher[i]->entry); sub_policy->color_matcher[i] = NULL; @@ -14563,13 +14563,13 @@ __flow_dv_destroy_sub_policy_rules(struct rte_eth_dev *dev, } if (sub_policy->jump_tbl[i]) { flow_dv_tbl_resource_release(MLX5_SH(dev), - sub_policy->jump_tbl[i]); + sub_policy->jump_tbl[i]); sub_policy->jump_tbl[i] = NULL; } } if (sub_policy->tbl_rsc) { flow_dv_tbl_resource_release(MLX5_SH(dev), - sub_policy->tbl_rsc); + sub_policy->tbl_rsc); sub_policy->tbl_rsc = NULL; } } @@ -14586,7 +14586,7 @@ __flow_dv_destroy_sub_policy_rules(struct rte_eth_dev *dev, */ static void flow_dv_destroy_policy_rules(struct rte_eth_dev *dev, - struct mlx5_flow_meter_policy *mtr_policy) + struct mlx5_flow_meter_policy *mtr_policy) { uint32_t i, j; struct mlx5_flow_meter_sub_policy *sub_policy; @@ -14599,8 +14599,8 @@ flow_dv_destroy_policy_rules(struct rte_eth_dev *dev, for (j = 0; j < sub_policy_num; j++) { sub_policy = mtr_policy->sub_policys[i][j]; if (sub_policy) - __flow_dv_destroy_sub_policy_rules - (dev, sub_policy); + __flow_dv_destroy_sub_policy_rules(dev, + sub_policy); } } } @@ -15550,6 +15550,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, uint8_t egress, transfer; int i; + /* If RSS or Queue, no previous actions / rules is created. */ for (i = 0; i < RTE_COLORS; i++) { acts[i].actions_n = 0; if (i == RTE_COLOR_RED) { @@ -15994,36 +15995,35 @@ flow_dv_meter_sub_policy_rss_prepare(struct rte_eth_dev *dev, sub_policy_num = (mtr_policy->sub_policy_num >> (MLX5_MTR_SUB_POLICY_NUM_SHIFT * domain)) & MLX5_MTR_SUB_POLICY_NUM_MASK; - for (i = 0; i < sub_policy_num; - i++) { - for (j = 0; j < MLX5_MTR_RTE_COLORS; j++) { - if (rss_desc[j] && - hrxq_idx[j] != - mtr_policy->sub_policys[domain][i]->rix_hrxq[j]) + for (j = 0; j < sub_policy_num; j++) { + for (i = 0; i < MLX5_MTR_RTE_COLORS; i++) { + if (rss_desc[i] && + hrxq_idx[i] != + mtr_policy->sub_policys[domain][j]->rix_hrxq[i]) break; } - if (j >= MLX5_MTR_RTE_COLORS) { + if (i >= MLX5_MTR_RTE_COLORS) { /* * Found the sub policy table with - * the same queue per color + * the same queue per color. */ rte_spinlock_unlock(&mtr_policy->sl); - for (j = 0; j < MLX5_MTR_RTE_COLORS; j++) - mlx5_hrxq_release(dev, hrxq_idx[j]); - return mtr_policy->sub_policys[domain][i]; + for (i = 0; i < MLX5_MTR_RTE_COLORS; i++) + mlx5_hrxq_release(dev, hrxq_idx[i]); + return mtr_policy->sub_policys[domain][j]; } } /* Create sub policy. */ if (!mtr_policy->sub_policys[domain][0]->rix_hrxq[0]) { - /* Reuse the first dummy sub_policy*/ + /* Reuse the first dummy sub_policy. */ sub_policy = mtr_policy->sub_policys[domain][0]; sub_policy_idx = sub_policy->idx; } else { sub_policy = mlx5_ipool_zmalloc (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], - &sub_policy_idx); + &sub_policy_idx); if (!sub_policy || - sub_policy_idx > MLX5_MAX_SUB_POLICY_TBL_NUM) { + sub_policy_idx > MLX5_MAX_SUB_POLICY_TBL_NUM) { for (i = 0; i < MLX5_MTR_RTE_COLORS; i++) mlx5_hrxq_release(dev, hrxq_idx[i]); goto rss_sub_policy_error; @@ -16040,9 +16040,9 @@ flow_dv_meter_sub_policy_rss_prepare(struct rte_eth_dev *dev, * RSS action to Queue action. */ hrxq = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_HRXQ], - hrxq_idx[i]); + hrxq_idx[i]); if (!hrxq) { - DRV_LOG(ERR, "Failed to create policy hrxq"); + DRV_LOG(ERR, "Failed to get policy hrxq."); goto rss_sub_policy_error; } act_cnt = &mtr_policy->act_cnt[i]; @@ -16056,19 +16056,21 @@ flow_dv_meter_sub_policy_rss_prepare(struct rte_eth_dev *dev, } } if (__flow_dv_create_policy_acts_rules(dev, mtr_policy, - sub_policy, domain)) { + sub_policy, domain)) { DRV_LOG(ERR, "Failed to create policy " - "rules per domain."); + "rules for ingress domain."); goto rss_sub_policy_error; } if (sub_policy != mtr_policy->sub_policys[domain][0]) { i = (mtr_policy->sub_policy_num >> (MLX5_MTR_SUB_POLICY_NUM_SHIFT * domain)) & MLX5_MTR_SUB_POLICY_NUM_MASK; + if (i >= MLX5_MTR_RSS_MAX_SUB_POLICY) { + DRV_LOG(ERR, "No free sub-policy slot."); + goto rss_sub_policy_error; + } mtr_policy->sub_policys[domain][i] = sub_policy; i++; - if (i > MLX5_MTR_RSS_MAX_SUB_POLICY) - goto rss_sub_policy_error; mtr_policy->sub_policy_num &= ~(MLX5_MTR_SUB_POLICY_NUM_MASK << (MLX5_MTR_SUB_POLICY_NUM_SHIFT * domain)); mtr_policy->sub_policy_num |= @@ -16085,8 +16087,7 @@ flow_dv_meter_sub_policy_rss_prepare(struct rte_eth_dev *dev, (MLX5_MTR_SUB_POLICY_NUM_SHIFT * domain)) & MLX5_MTR_SUB_POLICY_NUM_MASK; mtr_policy->sub_policys[domain][i] = NULL; - mlx5_ipool_free - (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], + mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], sub_policy->idx); } } @@ -16108,7 +16109,7 @@ flow_dv_meter_sub_policy_rss_prepare(struct rte_eth_dev *dev, */ static void flow_dv_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev, - struct mlx5_flow_meter_policy *mtr_policy) + struct mlx5_flow_meter_policy *mtr_policy) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_flow_meter_sub_policy *sub_policy = NULL; @@ -16154,7 +16155,7 @@ flow_dv_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev, case MLX5_FLOW_FATE_QUEUE: sub_policy = mtr_policy->sub_policys[domain][0]; __flow_dv_destroy_sub_policy_rules(dev, - sub_policy); + sub_policy); break; default: /*Other actions without queue and do nothing*/ -- 2.27.0