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 42AB3A0C46 for ; Mon, 16 Aug 2021 03:52:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1014140395; Mon, 16 Aug 2021 03:52:47 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) by mails.dpdk.org (Postfix) with ESMTP id D9CC540395 for ; Mon, 16 Aug 2021 03:52:45 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SrWXcn05PgN/YpJs83Mz9nUuCgrtpmY8wbCGF1jmhAG0hwjKsMHo8SBATdub1b7njL2qcHVgdxu0BWAdZphbQrPtJHjDl6yZWbG77mVZmRP3nwULIVyfw3u9hmK2W5lYspb4kQSSHZi+c/aFOIiixURG5LUtR8LR8Dh2R0VvxJHxcOLDtcOIc+ElVhIYvXgk1QrYYkDOhWRG4CS2BSIC4PqL75SlG4F+nvQMayIOGAgwMpOA8tQtkno4xudX9E2YAbPY/W10f891mSVdd8YvLWcb7xXRKRM2EQjjWQ2wYVceoQ8fBGdGQzwqrOWZc3Y3hQa94ON3O1IrsgiSAXZ6JA== 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=PXEWVW6VlbtU4wiT7B0EOXbTmgFZpKetwGaqyosPvEg=; b=Dz8Iy6Ybatmu7dxQJFKe3qQweoVjV2NYuZuG0ozHH7MWjDxIPJYvjv3DY15lyXcqHXcUuCM82BV7gS2DNuOiwAPODxnCgrpRWarkBolVDZ3y80868gKQpVvPQpt9I5ADxCVw1sUD5U8PqhWoDQQW7t013wwwz8Zz/ubn9ehyGqvCVlpnzERtqafPSxrLU6nciJbpohl62oLCqxqK+U+30rFS8HSJ4LUockA7O/YU9n7l/3rZvPCOmaqtlo5T8iIyG8tbFF22I1b0IQar8OSW+SXlCPDwBGZ+IrAfpSv0XuVumHpPlCT7MVGOSO/PXsoB07lyKHIeAOpyhZVTDWxv1w== 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=PXEWVW6VlbtU4wiT7B0EOXbTmgFZpKetwGaqyosPvEg=; b=VFy/qQxI33CyCE+LK63rKNIY/meU8xOFddZCv21Ae1P2twydifYR8TB0CLNWzJ8w03CHmMaltsyRmvHAA+v4Tr8MqwWbFBJksFUdFwCYlyq2x/MiGwYUUF0wktmAJH5169hADtJNe+p8lzZ7j93g4Y7cvJXfyaYcOaToShvhPm1T7R5Gk13sbkZGhSJTraXoON1RmFDR+ECQVuf0hQW859g5LBVAKLdQHzW0Yts9NfDKdqzEOSlJU4Hb7LeQ+ftT5Yfh3YZ6RMMYVBvZN030McqMZSZR9Yoi8RqdoWSzbDJQPddpXupQQGV286ZibauNk727VtCA3YUtU07guAUHZw== Received: from DM6PR03CA0099.namprd03.prod.outlook.com (2603:10b6:5:333::32) by BN8PR12MB2866.namprd12.prod.outlook.com (2603:10b6:408:68::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.16; Mon, 16 Aug 2021 01:52:44 +0000 Received: from DM6NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:5:333:cafe::da) by DM6PR03CA0099.outlook.office365.com (2603:10b6:5:333::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.13 via Frontend Transport; Mon, 16 Aug 2021 01:52: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 DM6NAM11FT062.mail.protection.outlook.com (10.13.173.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4415.16 via Frontend Transport; Mon, 16 Aug 2021 01:52:43 +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, 16 Aug 2021 01:52:41 +0000 From: Suanming Mou To: , , CC: Date: Mon, 16 Aug 2021 04:52:24 +0300 Message-ID: <20210816015224.12275-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: 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: 47107ed1-e5f8-4727-5078-08d960588a1c X-MS-TrafficTypeDiagnostic: BN8PR12MB2866: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aoGqgeVDESzKHr9ulQLvbS73ASVUs6OY2R8ZKFR1fZR8k4/91lss9PmhqXRYNPZimslzpJ5Jz3rvrVnd4XjEauwf1jSix4ZrgnRHP3tN5PlEnFzQTyPLuTbCcL/hPebw8wzhXzaE7rGIvXD4Wbp+KXsv8bFEfdkcBKXhlwhQUTZpD0k1I0SNRInc/YnRuzMwSCHjm1wpAZ3jGzTvggMjQIFWz3o8UMRCcnQYxeBIodG2/vHFBe0wiWtp2fBNBqXqHE/TTAh9Wtc8juSwd9xrGaQtW7mt4zImBUYdQyBdjRpBXyRhQYAkuCMhgwlTowvTy0jVo6rN7XcRoS8vILGS0G5UFhCMVFQe7qESiRCHYkx1NKMTzW6bdf2QK1gFOmCheHAWWmkCM8TylHKStgAwwPGEXhuv66P3p47o77lSG8M7lEBA7g0hR5SGc/grf28r2qA6ZJLmk8+IRCl3Yq3Vl1YD+z03DiYh2Ut4YXO7FDEWUBXUV3iq+hE+mjp0NgIkunDU2kLDWBt63htIApVBUE5UBy6g+Uw+4GjE+VGSMy9hNkH36uxIzCNjVO3RY+BLEjls3u/20ocEYXiKT+Dz7L5PgPkByfyRbnOCj/REwPb40aF3hBe13dB/B1Saav22UQUIDFxCLZwWrcau26wdJlVz6U0DsO7KktBnK3l5BZl/3+wMeukAMzJQbLXw37+VVLeyLZFAX4R2a+JWfjO3Kg== 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)(346002)(39860400002)(136003)(396003)(46966006)(36840700001)(110136005)(82740400003)(4326008)(8676002)(47076005)(2906002)(83380400001)(36860700001)(70586007)(8936002)(7696005)(316002)(7636003)(426003)(356005)(336012)(186003)(16526019)(478600001)(70206006)(26005)(86362001)(82310400003)(36756003)(1076003)(55016002)(5660300002)(6286002)(6666004)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2021 01:52:43.8966 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47107ed1-e5f8-4727-5078-08d960588a1c 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: DM6NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB2866 Subject: [dpdk-stable] [PATCH 19.11] net/mlx5: workaround drop action with old kernel X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream commit 45633c460c223a67dd1a7cc084c3eceb5e17687c ] 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/mlx5.c | 28 +++++++++++++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 72 +++++++++++++++++++++++++++++++-- 4 files changed, 99 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 3208b2eda7..ee019d6db1 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2129,6 +2129,33 @@ mlx5_dev_check_sibling_config(struct mlx5_priv *priv, } return 0; } + +/** + * 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_verbs_drop_action = 1; + else + priv->root_verbs_drop_action = 0; +#endif +} + /** * Spawn an Ethernet device from Verbs information. * @@ -2844,6 +2871,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; } } + mlx5_flow_drop_action_config(eth_dev); return eth_dev; error: if (priv) { diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 70509959fe..b2dc9e291b 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -736,6 +736,7 @@ struct mlx5_priv { unsigned int counter_fallback:1; /* Use counter fallback management. */ unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ + unsigned int root_verbs_drop_action; /* Root uses verbs drop action. */ uint16_t domain_id; /* Switch domain identifier. */ uint16_t vport_id; /* Associated VF vport index (if any). */ uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 4300e62fad..caf6afd4d8 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -893,4 +893,5 @@ int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev, const struct rte_flow_attr *attr); int mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error); +int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev); #endif /* RTE_PMD_MLX5_FLOW_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index a021ac9d20..22649cd79b 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7920,12 +7920,14 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, if (dev_flow->transfer) { assert(priv->sh->dr_drop_action); dv->actions[n++] = priv->sh->dr_drop_action; - } else { #ifdef HAVE_MLX5DV_DR + } else if (dev_flow->group || + !priv->root_verbs_drop_action) { /* DR supports drop action placeholder. */ assert(priv->sh->dr_drop_action); dv->actions[n++] = priv->sh->dr_drop_action; -#else +#endif + } else { /* For DV we use the explicit drop queue. */ dv->hrxq = mlx5_hrxq_drop_new(dev); if (!dv->hrxq) { @@ -7937,7 +7939,6 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, goto error; } dv->actions[n++] = dv->hrxq->action; -#endif } } else if (dev_flow->actions & (MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)) { @@ -8373,6 +8374,71 @@ flow_dv_query(struct rte_eth_dev *dev, return ret; } +/** + * 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_ibv_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, NULL); + if (!tbl) + goto err; + matcher = mlx5_glue->dv_create_flow_matcher(sh->ctx, &dv_attr, + tbl->obj); + if (!matcher) + goto err; + flow = mlx5_glue->dv_create_flow(matcher, (void *)&value, 1, + &sh->dr_drop_action); +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_glue->dv_destroy_flow(flow)); + } + if (matcher) + claim_zero(mlx5_glue->dv_destroy_flow_matcher(matcher)); + if (tbl) + flow_dv_tbl_resource_release(dev, tbl); + return ret; +} + /** * Destroy the meter table set. * Lock free, (mutex should be acquired by caller). -- 2.25.1