From nobody Wed Nov 15 23:09:06 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SVzPb2sRlz50ry3; Wed, 15 Nov 2023 23:09:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SVzPb1s5jz3N1y; Wed, 15 Nov 2023 23:09:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=i8OrzAgWXtWSuoejGfjBOVnT9YwJmjtO37M8vT5KzdA=; b=YFK3zvh+/P7InzbFG+WDGDzVcgj7xLcvuhFcnRkHfvVoAohrvG29Xi0BCGhnPJTFpWhr+s hjgrIf86I+UgAuG4Kbx2h1Ztjy91Yc4Ja5wpr6h7TZj0S881+VkBfe5gnfFWaVzOOQZALJ WqFpgTYtYSTuz9HEBvltvFeteeFmBmnr98RMNE3oyL+jfSjOkeMjN7kXz5/McIgvZDVaan isa9euMLYITtROQNx6hp3bOV67jVkiPVDL1U349aYjaSzKzpz8rb/qirfqgej3Pou7zBO6 wExuSEZ6hd+yACj3gWTy1hMU384qdRX16BcRV6HgSm0S6frs64hU1dsM+p/sxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=i8OrzAgWXtWSuoejGfjBOVnT9YwJmjtO37M8vT5KzdA=; b=gfK0omYfvRaSMfvPgT1bmcFgE1Ofk5QoJcPb6ewBu2ZvloLIykW/d7A9j20L9rrgdcg1RK Mb4DNzKAKCJ/u0RR/ZrU6Tv+apPgAI6S8ikSscfeowEbYGUvle2DmOcOFtGhDAWl1xCH9Q D0QcX4Tvfi0L4lARBB0JoJHhS+0QenwZAHzTaTGcKikmz8xZIvaHKJ6shTiy1xVWZxVfBj K/biLaFs1z0eCjv552pzFENCjEV8eSuOD/uYQnHoE3jEUZp4s9V1d0Bkhop0P/5jk/uMsG Ye/hKqMqC9ybxITuZHxlXMjMiDMIah974rS3Ln2Jl+ZhibTJ7681hgyoXtAcMw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700089747; a=rsa-sha256; cv=none; b=Y+aA5W5Yi/3K+PB15eDqrPX8KiVgSVhuY6Z5jIFgq8/MLzCm/A89IZ5/KwlOg5/3PvO20a SFEEFAYVxADoeYBd2GVDp6m0579erioeM/v1S9UowuOAFwYWyng3X1oue8SsHYuAPimcno z1Dp0UkN2XCDqTcAHP/pDiPv/ADZkqSwTtYJUHCxYHSYl1rqItjYYfVu/rjFR6eQP/tp+u mPoXy0QSoNAVTHOSn5Ev3Zg/nTxYuVQZdJHw7kiq2gWVaLlVajFIE4e70U+xKOGLILaWsV ZsyuXzuxaJ/VP0SIUIXOwEj0Ldj2EMSdXz2swuOMHzqwpeRo8GgykxBAtjcNnA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SVzPb0Y0Jzbqg; Wed, 15 Nov 2023 23:09:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AFN96M9064650; Wed, 15 Nov 2023 23:09:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AFN96fI064647; Wed, 15 Nov 2023 23:09:06 GMT (envelope-from git) Date: Wed, 15 Nov 2023 23:09:06 GMT Message-Id: <202311152309.3AFN96fI064647@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 847542c60c2b - main - mlx5: Add modify header support to flow rules List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 847542c60c2b3d922d636cc36ce51714032f9825 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=847542c60c2b3d922d636cc36ce51714032f9825 commit 847542c60c2b3d922d636cc36ce51714032f9825 Author: Mark Bloch AuthorDate: 2023-02-19 11:15:00 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-15 23:08:16 +0000 mlx5: Add modify header support to flow rules Allow attaching a modify header to a flow rule. Signed-off-by: Mark Bloch Sponsored by: NVidia networking MFC after: 1 week --- sys/dev/mlx5/fs.h | 2 ++ sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c | 9 ++++++++- sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 4 ++++ sys/dev/mlx5/mlx5_ifc.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/dev/mlx5/fs.h b/sys/dev/mlx5/fs.h index 7ed7a5380cf1..bb087718d12f 100644 --- a/sys/dev/mlx5/fs.h +++ b/sys/dev/mlx5/fs.h @@ -84,11 +84,13 @@ struct mlx5_flow_destination { enum mlx5_flow_act_actions { MLX5_FLOW_ACT_ACTIONS_FLOW_TAG = 1 << 0, + MLX5_FLOW_ACT_ACTIONS_MODIFY_HDR = 1 << 1, }; struct mlx5_flow_act { u32 actions; /* See enum mlx5_flow_act_actions */ u32 flow_tag; + struct mlx5_modify_hdr *modify_hdr; }; #define FT_NAME_STR_SZ 20 diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c index 5ac0c95c7bca..22bc945a4b62 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c @@ -179,10 +179,12 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, int opmod = 0; int modify_mask = 0; int atomic_mod_cap; + u32 prm_action = 0; if (action != MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) dest_size = 0; + prm_action = action; inlen = MLX5_ST_SZ_BYTES(set_fte_in) + dest_size * MLX5_ST_SZ_BYTES(dest_format_struct); @@ -221,7 +223,11 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, MLX5_SET(flow_context, in_flow_context, group_id, group_id); if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_FLOW_TAG) MLX5_SET(flow_context, in_flow_context, flow_tag, flow_act->flow_tag); - MLX5_SET(flow_context, in_flow_context, action, action); + if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_MODIFY_HDR) { + MLX5_SET(flow_context, in_flow_context, modify_header_id, + flow_act->modify_hdr->id); + prm_action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; + } MLX5_SET(flow_context, in_flow_context, destination_list_size, dest_size); in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, @@ -244,6 +250,7 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, } } + MLX5_SET(flow_context, in_flow_context, action, prm_action); err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); if (!err) *fte_status |= FS_FTE_STATUS_EXISTING; diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c index 8e203a9662bb..7c3eb1e86d6d 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c @@ -1760,6 +1760,10 @@ static bool check_conflicting_actions(const struct mlx5_flow_act *act1, act1->flow_tag != act2->flow_tag) return true; + /* Can even have complex actions in merged rules */ + if (action1 & MLX5_FLOW_ACT_ACTIONS_MODIFY_HDR) + return true; + return false; } diff --git a/sys/dev/mlx5/mlx5_ifc.h b/sys/dev/mlx5/mlx5_ifc.h index 340e3b2e2d03..9534ac3d1c94 100644 --- a/sys/dev/mlx5/mlx5_ifc.h +++ b/sys/dev/mlx5/mlx5_ifc.h @@ -2264,6 +2264,7 @@ enum { MLX5_FLOW_CONTEXT_ACTION_DROP = 0x2, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST = 0x4, MLX5_FLOW_CONTEXT_ACTION_COUNT = 0x8, + MLX5_FLOW_CONTEXT_ACTION_MOD_HDR = 0x40, }; struct mlx5_ifc_flow_context_bits {