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 E4233A0C41; Mon, 2 Aug 2021 16:30:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63B3641147; Mon, 2 Aug 2021 16:30:47 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) by mails.dpdk.org (Postfix) with ESMTP id 2E4A940140; Mon, 2 Aug 2021 16:30:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lzmZjR4a1H248sBoS0c5d1qxNhiqCq7BTMoYm+mR0uRP1p+igXvGD+cWlwxnrPUcePxKo+gcLouDKPXXvpHnKLAn3gfcvyetsAPTr2A9VVVF6F0sEpIx1xYuJJ+r9T00LOYce7oVds/K3RmACKlEc/iD1Us6Z6JDRJQGZ5uP9kYZe2pA1vJKF4mgZnV3Mai8lIjVg+yczDAODHShggMBXGiuLj6V8WerUZIkhTN115i3nqqzrNCllUZiOVtapDSXNg0EeQ1I2nonSJjiVQKMuNkVXL7Aegk3ksqwSoG90psHjIjyl4xEMjUXAwt5yjOhF03hDo7Ts0c/nNVJ0Kpzwg== 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=MtVerORJbXXdMpMPWvXrBt2KMMHCrwq+WtRuhIzOo+o=; b=MwCTmevTScGWfyQhS4y7kuCNvHoLn1ZhiHyDo9YiiodVoW2sFDKGcVkz5NimJ9mrIR2SxByL4bOaKWjzjunDouaPJOlZz+mgKXoFhhYNHlodZCh103D8kw5cFbXq5rbFGVUgCEmpruaunyULbzOq5qlhc5km6le7LHHXA/DFxCpTUN/PMfwsI9v+uJD+p/q1avsZNoGZvjrWLKqgtBAinZDxJykx/PqeWQlzf4y8WW0lUuuWe25+Kn4+ANVYraN/NrrZadWmR4ljMCFXnav8jykdZ8Kkv/OdaBuN4ip4JbbRGfhgr00Tyl78fU4LXGhwuCsfgUU60e6h/AiQ1jNThA== 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=quarantine 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=MtVerORJbXXdMpMPWvXrBt2KMMHCrwq+WtRuhIzOo+o=; b=P3il9gzdq5riqI2dqEhj/qxHQIpShzH6J+kFHRBYj6mexk8FVwSuSzNA8sjmGdXiLwHBl9/jJ8W3hInyeGP8dFOqeXCf0UDBUOCTPzRHZCThIe7GTbRnlgjaIr0ONeL7KXF1DqO1TMIfOCA+uXQlffVKeEBWgl42Y7EQ7uSm5Xi5NNJIXSk8u1+Fh8fHYakVYBWmsFD2O8pd1s9OpMWjDtHbO2OSuljwwfp9Cwi4llDUaMEFsdXKia/fbFV9o+RTxMr206Wz9QXC4GCrOsz2eQr82rPgjgv26dG3/XE6RIpuOHDq/lCeVdyI1EzqUy7ixRxP7DRc2m0Guql0C79Y1Q== Received: from DS7PR03CA0265.namprd03.prod.outlook.com (2603:10b6:5:3b3::30) by DM6PR12MB3417.namprd12.prod.outlook.com (2603:10b6:5:118::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Mon, 2 Aug 2021 14:30:44 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::6d) by DS7PR03CA0265.outlook.office365.com (2603:10b6:5:3b3::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 14:30:44 +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 DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 14:30:44 +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, 2 Aug 2021 14:30:42 +0000 From: Suanming Mou To: , CC: , , Date: Mon, 2 Aug 2021 17:30:24 +0300 Message-ID: <20210802143024.30484-1-suanmingm@nvidia.com> X-Mailer: git-send-email 2.18.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 734e10d2-eaf8-401c-070b-08d955c21cd6 X-MS-TrafficTypeDiagnostic: DM6PR12MB3417: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fSNgs840koqEi2yJTSbRy9L8TrfFKjtoU2ZdIZnH94M7HqVgRwBAoYRkLaXjJxLRy9S+wAiYN0nqflcqdEMCirp43EtovM+NO2yI4kN42/EEgVk1AVr2hL+KBmRA1jwMHWJ1u35BlTV1advr8cASayWijC/yDnthO46r7c3rK4Agkkp+B4suKpurzeekoJhJ65Gp83CLQszx7qDL5lK4qZTAU1bKvWXm2k68FKhZnmHe75vZ62oDH8c3hrpewQR6koFGFhSEE/ic8kniuQ3nblb19L8v6JSmLG8DIKtm9WEd6spR4wr8YRrXWomAm5yJ9EPrtrwKf/DTyYs6LxcgoMfxj9Mpj43xgqyYHffsi7vT1Y91gaNB7/fhuQhCIHgtJOAzf2AGstpoyC1O+V+HabnHqtd98mbJjvIcckvgktu14WGzIl6HPMFqp0HeZw97PH1atNHgzr6/XG+QL39A8z9slKRpBEvxW0ZVPTolTIICqCXGnGq7WhJzcHeA3+NyjqjmP+J6/tM1fQwiQDzBVTJinPQgvAxQLyRAzL2MGvwFBhAzFxoIRJR1KMnt7k+0V+4Pu29qi/xDLKuNQ7XirbbdJ5UJOADBroR50GcbrN7zXA5CQhadH0dhllWKwqOROmplkiNmsmXp9TF/FB2CJRGMND30lEIzUs38yAXO6E6DXOMW/Gx8+8q1y7RpbeLIe/4SlDTbMseC6JFPCiWHTw== 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)(136003)(346002)(39860400002)(396003)(376002)(36840700001)(46966006)(55016002)(8676002)(70206006)(82740400003)(8936002)(186003)(82310400003)(70586007)(7636003)(16526019)(316002)(26005)(4326008)(7696005)(110136005)(6636002)(450100002)(2616005)(426003)(54906003)(6286002)(36906005)(5660300002)(6666004)(36860700001)(36756003)(83380400001)(1076003)(86362001)(356005)(47076005)(336012)(478600001)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 14:30:44.4261 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 734e10d2-eaf8-401c-070b-08d955c21cd6 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: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3417 Subject: [dpdk-dev] [PATCH] net/mlx5: workaround not supported drop action on the root table 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" Currently, there are two types of drop action implementation in the PMD. One is the DR(Direct Rules) dummy placeholder drop action and another is the dedicated dummy queue drop action. When creates flow on the root table with DR drop action, the action will be converted to MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs attribute in rdma-core. In some inbox systems, MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs attribute may not be supported in the kernel driver. Create flow with drop action on the root table will be failed as it is not supported. In this case, the dummy queue drop action should be used instead of DR dummy placeholder drop action. This commit adds the DR drop action support detect on the root table. If MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP Verbs is not supported in the system, a dummy queue will be used as drop action. Fixes: da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs") Cc: stable@dpdk.org Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 27 ++++++++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 72 +++++++++++++++++++++++++++++++- 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 8f98cf1716..2e25de5489 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -786,6 +786,32 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) #endif } +/** + * DR flow drop action support detect. + * + * @param dev + * Pointer to rte_eth_dev structure. + * + */ +static void +mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused) +{ +#ifdef HAVE_MLX5DV_DR + struct mlx5_priv *priv = dev->data->dev_private; + + if (!priv->config.dv_flow_en || !priv->sh->dr_drop_action) + return; + /** + * DR supports drop action placeholder when it is supported; + * otherwise, use the queue drop action. + */ + if (mlx5_flow_discover_dr_action_support(dev)) + priv->root_drop_action = priv->drop_queue.hrxq->action; + else + priv->root_drop_action = priv->sh->dr_drop_action; +#endif +} + static void mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev) { @@ -1864,6 +1890,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } rte_spinlock_init(&priv->shared_act_sl); mlx5_flow_counter_mode_config(eth_dev); + mlx5_flow_drop_action_config(eth_dev); if (priv->config.dv_flow_en) eth_dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; return eth_dev; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index faafe3d3f1..34d66e93ad 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1411,6 +1411,7 @@ struct mlx5_priv { unsigned int (*reta_idx)[]; /* RETA index table. */ unsigned int reta_idx_n; /* RETA index size. */ struct mlx5_drop drop_queue; /* Flow drop queues. */ + void *root_drop_action; /* Pointer to root drop action. */ struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI]; /* RTE Flow rules. */ uint32_t ctrl_flows; /* Control flow rules. */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3724293d26..218b5b6994 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1571,6 +1571,7 @@ struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev, struct mlx5_flow_meter_policy *mtr_policy); int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev); +int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev); int mlx5_action_handle_flush(struct rte_eth_dev *dev); void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id); int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh); diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 059bd25efc..c56f64148e 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -13773,7 +13773,9 @@ flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, #ifdef HAVE_MLX5DV_DR /* DR supports drop action placeholder. */ MLX5_ASSERT(priv->sh->dr_drop_action); - dv->actions[n++] = priv->sh->dr_drop_action; + dv->actions[n++] = dv->group ? + priv->sh->dr_drop_action : + priv->root_drop_action; #else /* For DV we use the explicit drop queue. */ MLX5_ASSERT(priv->drop_queue.hrxq); @@ -17087,6 +17089,74 @@ flow_dv_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev, } rte_spinlock_unlock(&mtr_policy->sl); } +/** + * Check whether the DR drop action is supported on the root table or not. + * + * Create a simple flow with DR drop action on root table to validate + * if DR drop action on root table is supported or not. + * + * @param[in] dev + * Pointer to rte_eth_dev structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_dev_ctx_shared *sh = priv->sh; + struct mlx5_flow_dv_match_params mask = { + .size = sizeof(mask.buf), + }; + struct mlx5_flow_dv_match_params value = { + .size = sizeof(value.buf), + }; + struct mlx5dv_flow_matcher_attr dv_attr = { + .type = IBV_FLOW_ATTR_NORMAL, + .priority = 0, + .match_criteria_enable = 0, + .match_mask = (void *)&mask, + }; + struct mlx5_flow_tbl_resource *tbl = NULL; + void *matcher = NULL; + void *flow = NULL; + int ret = -1; + + tbl = flow_dv_tbl_resource_get(dev, 0, 0, 0, false, NULL, + 0, 0, 0, NULL); + if (!tbl) + goto err; + dv_attr.match_criteria_enable = flow_dv_matcher_enable(mask.buf); + __flow_dv_adjust_buf_size(&mask.size, dv_attr.match_criteria_enable); + ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, tbl->obj, + &matcher); + if (ret) + goto err; + __flow_dv_adjust_buf_size(&value.size, dv_attr.match_criteria_enable); + ret = mlx5_flow_os_create_flow(matcher, (void *)&value, 1, + &sh->dr_drop_action, &flow); +err: + /* + * If DR drop action is not supported on root table, flow create will + * be failed with EOPNOTSUPP or EPROTONOSUPPORT. + */ + if (!flow) { + if (matcher && + (errno == EPROTONOSUPPORT || errno == EOPNOTSUPP)) + DRV_LOG(INFO, "DR drop action is not supported in root table."); + else + DRV_LOG(ERR, "Unexpected error in DR drop action support detection"); + ret = -1; + } else { + claim_zero(mlx5_flow_os_destroy_flow(flow)); + } + if (matcher) + claim_zero(mlx5_flow_os_destroy_flow_matcher(matcher)); + if (tbl) + flow_dv_tbl_resource_release(MLX5_SH(dev), tbl); + return ret; +} /** * Validate the batch counter support in root table. -- 2.25.1