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 5AB4FA09EC; Wed, 19 Oct 2022 20:41:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D29A42C34; Wed, 19 Oct 2022 20:41:41 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2076.outbound.protection.outlook.com [40.107.243.76]) by mails.dpdk.org (Postfix) with ESMTP id 5D03842C2C for ; Wed, 19 Oct 2022 20:41:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dCZX5/X+Tg5kEaK2Sq2/pOq5k/aiIz5Yy5zntbdr1lOdL84ZeGZ+K9OmvRVqfoUsDmAza0iDuqmh206hqpGJKxMWxVKy2fvef/pODO+cP+bnJA0N86ae7H4OXLjbQ0qEwsGuwpotyuHrmRzHfdWjZWRp/a4Zb/TAq3DPf1QjnMnThKJsYwDTqlKQkN3AfAnEY6RA5CepoVW+kyxbyBVCpVF/x/C4htKdF58QpP1dfkeu32RaJkXqzkrZyIAypB8QM1UXpaazo/3EmCrj84DlFK6IpR60FtOeGOKGZXs8zcAUnNYVjPvGz32y5hMQQaYd7MlG2zKCaTtdnNqZY8N21w== 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=Sm3/kzVg2bPCn24vIWGCMeh63Q8dQ4RAEMSae8PZ2rg=; b=eoxzFIHrpDaWiLVAikC9xUyywtDOuf26UMAZ6MBhE6Aem/70JncrAbPxTocXkFRiUU1B2RaSnd4pQdpUtcT3b0QdIjByTKHQ/ziI/LgcIs79IuhHBU2wY/jAGwzp/yhIEUmPMYhonR9uRte6OLRveU1QXDFf1lZl9boOI09LzsYiUH5Hy9eQSw6bIxlOFzwOcU5V3o+68fDn4Te0QVYWXRbqvS+YbuwfstLCkGY2RFLHuC5SlabQnCOXDdNWA943NoNWNtKNzvX8EIe7i9qrELK36sHUwmDvR8n7lSeITH4sZ0tg8cfF3FLSWv9duyJmvvSyZtDu5AxAvcVLDNCjaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject 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=Sm3/kzVg2bPCn24vIWGCMeh63Q8dQ4RAEMSae8PZ2rg=; b=IipFS126kPVb0QbuaQpFSWLjMVplmnZHkp+zVyzbw2TdrkwAyBr9wwB0XuEJsDRaA5dqKMXC23osRcchL9zo3sNAGjBajy+J8al97nCIIabdmgYloe7JiVyKJtie9tWM5gIzeZnvFIhOvM+ysr9w+Qjm8AbeVUU3sSxHtsuaXUvcDEuZ0KoVk9WpIIPn7/GqAiE+BnLcvy7RtdMZ4/ZFyCfkyvOxnVgzkYZt/z7YHfGGB6Cr6m+41AUV61rDgo7kOu8ALUFqCyGaV+hUKy7zTXLeUWcfclH56sVKVpOZ4oTlywvcGFf5MmI/4DXLP2+U7MisQfToFIm3uTqYvEXOUQ== Received: from MW4P221CA0030.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::35) by MW4PR12MB7239.namprd12.prod.outlook.com (2603:10b6:303:228::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Wed, 19 Oct 2022 18:41:38 +0000 Received: from CO1NAM11FT112.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::38) by MW4P221CA0030.outlook.office365.com (2603:10b6:303:8b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 18:41:38 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT112.mail.protection.outlook.com (10.13.174.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 18:41:38 +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; Wed, 19 Oct 2022 11:41:21 -0700 Received: from nvidia.com (10.126.230.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; Wed, 19 Oct 2022 11:41:19 -0700 From: Michael Savisko To: CC: , , , , Matan Azrad , Ferruh Yigit Subject: [PATCH v2 4/4] net/mlx5: translation of rte flow send to kernel action Date: Wed, 19 Oct 2022 21:40:07 +0300 Message-ID: <20221019184007.1032874-5-michaelsav@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221019184007.1032874-1-michaelsav@nvidia.com> References: <20221019184007.1032874-1-michaelsav@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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: CO1NAM11FT112:EE_|MW4PR12MB7239:EE_ X-MS-Office365-Filtering-Correlation-Id: cafb5de9-0fe4-474c-4bf0-08dab2018eaf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WJMuLpwBDBXlZ2XTgUlvu8nXeLcGIwehTD3Ndw5u/Y8LzyETS4nGVSDBlFNjVjGQCKt7ym2QyRTKLWNIoTVJJ0IjfKfDNsRmZCQFdwpMBvdAAOz1PaqblcbfBpvfIhn6i0e6VEeQJXZ5anHCokwP/EqvE1sVzY6/4zB4RDuMkEItr4/xNf7oxfzbfzk8n5dnF9LAEKQ8jSjPLipbAVpKjCpxelMCzRcmGhTqcEMbmrqpI5tno4ya9eZCWj1Ks+qKH+U6hpImwCKEHJen6jnpHYBW3RPUOC5RTfFvbZk92uJR3laZ2EQtx+2Q0tzyHHP/sBmH7anD9y3mWnH1rnOmGd4OPXAhSCtID5IK72VGD8/RSDtTGjhiqUk1xOpaiY0Uu2gddXu7EtjZ/HAzhK+AL9nzOjJhTi+UmGfNbuZnnxOABNOOibynndNGkj7nOicVJ7/nSFPdt2fwoQiaZiN+BUKEicQRqt2EQ7aJC9+5ifSXgLV6btMDO3F/Rj2MObr0qTGcbvgPJOWMUzEb6gxwoZIDjbY88Zs9L6g5yUdt7kxi8tCzT87sK8RbuBn8FnCiohDxCYrxOdos8piNqTbWwVf49lXoipBLFQRZ1Y7bmaLDXD0qoKz6LPBqweNVBYJ3EWIwYfGwczUy6GM/LMteYEBCWWrwvzVO8+TnwFcDz/32WXCs7SYR2+GWVbdeRLbhD7h3Ybfx7yEPVSdx6TAs8PWmC4ngdpobl47DjeHMqG/QSsvoceZBGsB0FSZii8dvJpicW1odWC53sW2dy8RBug== 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)(376002)(346002)(136003)(39860400002)(396003)(451199015)(36840700001)(40470700004)(46966006)(41300700001)(26005)(40460700003)(186003)(82310400005)(6286002)(336012)(478600001)(2616005)(1076003)(16526019)(36756003)(6666004)(86362001)(2906002)(8936002)(5660300002)(4326008)(7696005)(82740400003)(36860700001)(6916009)(40480700001)(54906003)(316002)(47076005)(55016003)(8676002)(70586007)(83380400001)(7636003)(426003)(356005)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 18:41:38.3035 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cafb5de9-0fe4-474c-4bf0-08dab2018eaf 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: CO1NAM11FT112.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7239 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 Introduce mlx5_get_send_to_kernel_priority() function which returns value of priority which must be used to jump back to table 0 in order to send traffic to kernel. This function returns lowest priority. Add flow_dv_translate_action_send_to_kernel() function which will allocate rdma-core send_to_kernel action object. Called from flow_dv_translate(). Fail translation of RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL action in HW steering. Signed-off-by: Michael Savisko Acked-by: Matan Azrad --- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + drivers/net/mlx5/mlx5_flow.c | 32 ++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 57 ++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_hw.c | 3 ++ 6 files changed, 92 insertions(+), 3 deletions(-) diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index b450ef7e1a..5ed2b90843 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -198,3 +198,4 @@ set_ttl = vf = vxlan_decap = vxlan_encap = +send_to_kernel = diff --git a/doc/guides/nics/features/mlx5.ini b/doc/guides/nics/features/mlx5.ini index e5974063c8..9f158ef171 100644 --- a/doc/guides/nics/features/mlx5.ini +++ b/doc/guides/nics/features/mlx5.ini @@ -128,3 +128,4 @@ set_tp_src = Y set_ttl = Y vxlan_decap = Y vxlan_encap = Y +send_to_kernel = Y diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index e4744b0a67..de998a9720 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -10967,6 +10967,38 @@ mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, return res; } +/** + * Get the priority for sending traffic to kernel table. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * + * @return + * On success: the value of priority for sending traffic to kernel table + * On failure: -1 + */ +uint32_t +mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + uint32_t res; + + switch (priv->sh->flow_max_priority) { + case RTE_DIM(priority_map_5): + res = 15; + break; + case RTE_DIM(priority_map_3): + res = 7; + break; + default: + DRV_LOG(ERR, + "port %u maximum priority: %d expected 8/16", + dev->data->port_id, priv->sh->flow_max_priority); + res = (uint32_t)-1; + } + return res; +} + /** * Get the E-Switch Manager vport id. * diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 525db05969..8e97fa188a 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1753,6 +1753,7 @@ uint32_t mlx5_get_lowest_priority(struct rte_eth_dev *dev, uint16_t mlx5_get_matcher_priority(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, uint32_t subpriority, bool external); +uint32_t mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev); int mlx5_flow_get_reg_id(struct rte_eth_dev *dev, enum mlx5_feature_name feature, uint32_t id, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index bcd9926b81..4bdcb1815b 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -12192,6 +12192,51 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev, return 0; } +static void * +flow_dv_translate_action_send_to_kernel(struct rte_eth_dev *dev, + struct rte_flow_error *error) +{ + struct mlx5_flow_tbl_resource *tbl; + struct mlx5_dev_ctx_shared *sh; + uint32_t priority; + void *action; + int ret; + + sh = MLX5_SH(dev); + if (sh->send_to_kernel_action.action) + return sh->send_to_kernel_action.action; + priority = mlx5_get_send_to_kernel_priority(dev); + if (priority == (uint32_t)-1) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "required priority is not available"); + return NULL; + } + tbl = flow_dv_tbl_resource_get(dev, 0, 0, 0, false, NULL, 0, 0, 0, + error); + if (!tbl) { + rte_flow_error_set(error, ENODATA, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "cannot find destination root table"); + return NULL; + } + ret = mlx5_flow_os_create_flow_action_send_to_kernel(tbl->obj, + priority, &action); + if (ret) { + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "cannot create action"); + goto err; + } + MLX5_ASSERT(action); + sh->send_to_kernel_action.action = action; + sh->send_to_kernel_action.tbl = tbl; + return action; +err: + flow_dv_tbl_resource_release(sh, tbl); + return NULL; +} + /** * Convert Sample action to DV specification. * @@ -13697,9 +13742,15 @@ flow_dv_translate(struct rte_eth_dev *dev, action_flags |= MLX5_FLOW_ACTION_CT; break; case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL: - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "send to kernel action is not supported."); + dev_flow->dv.actions[actions_n] = + flow_dv_translate_action_send_to_kernel(dev, + error); + if (!dev_flow->dv.actions[actions_n]) + return -rte_errno; + actions_n++; + action_flags |= MLX5_FLOW_ACTION_SEND_TO_KERNEL; + dev_flow->handle->fate_action = + MLX5_FLOW_FATE_SEND_TO_KERNEL; break; case RTE_FLOW_ACTION_TYPE_END: actions_end = true; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 12498794a5..b168ff9e7e 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -707,6 +707,9 @@ flow_hw_actions_translate(struct rte_eth_dev *dev, reformat_pos = i++; refmt_type = MLX5DR_ACTION_REFORMAT_TYPE_TNL_L2_TO_L2; break; + case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL: + DRV_LOG(ERR, "send to kernel action is not supported in HW steering."); + goto err; case RTE_FLOW_ACTION_TYPE_END: actions_end = true; break; -- 2.27.0