From nobody Wed Nov 15 23:09:14 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 4SVzPl4wlBz50s51; Wed, 15 Nov 2023 23:09:15 +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 4SVzPl0X88z3NF8; Wed, 15 Nov 2023 23:09:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089755; 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=6D3q5uycpKtNszebeQ0GQ5qJt5wupyJHXHlh9O2Fk/I=; b=j/lQRFl3UMOGCAjiLqAEkbmvaBe1f6fHFf9foPMkqfgV+c+sxkykXCv94kK7JY4dqDmeFf auYqHAq70Uj/inbMesfv5Ep1hNKX5N7IkInVMhTkxM+roX3jophd7PHJ6ydV/N28g9sVfg Kd/E9PMMmj7uuUBXJLikkSDiwY+CkEpaAv/rMoRkcZJAi7TBzWNpiEpAU7zSRTG3n+GhGi HmpghrWyKftFQhwK3EgX1d9xD5QytjHuddashr1e3SC8BUvcIJxBvXzd5x9nP7HmqY2Gho sNVwDGskSTtEIT8RsYSNzXE5E0TpRd6E4F4SeVz5y1tlYS/QSnMVQzZRHHm9PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700089755; 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=6D3q5uycpKtNszebeQ0GQ5qJt5wupyJHXHlh9O2Fk/I=; b=yvevbaUoiTaBKEclcAtGv3hYuwXdZwZQAvSjsUViHG0gnSqy4s3TtItc8HO6H5N3yxO+d9 aXv4N/HwMpRZaZYM4KWg+stW9axIVwzcjDt9lWogZtUt/mji9pzEWyR9iSwcsrqCgcCJtk 2PYwvVCbCrOlzofqjE/xpM7IjmoT6a8LQlRdRqoo5FaKyJ016HoHy3+6+5qQTyQ+lmCbzV mLIJEiCtUJoNlcUezL9dbJ/DIRZFzYE1VGez//MM10XqDGVhLCMWwt0GDEZHYFwiwaWTBS ArGAuXKtImQotZkSSq8gG8DY4Q8I3JbUfI58mutkZ39XBlNb3x62zmLWysWzfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700089755; a=rsa-sha256; cv=none; b=DBC2aZ4FydVIeWwJdmBbXXEJRgm/bTr+3YVAMdi+cc7B5tUhFNcd3HC/yTE4BK8VDVmf8S 9uAuK955D9iB1H1UmZ9fN9VPY+WqHDdrD43iS5wybS33tmn6laPTIA9S6XNfVDSRUkTkUd VJMlgAasfZROGMivCx++mSYvsmP4u+83CQgHItDz9Gr7LTWNiAbuCHYl1kPSUsp5SoxhND u9bDts1AEyeowpcBYmfzfnfYv1bgnBjNXwsGyGwz1SunWZH1AsAqYAwIl2cPp6I8LGGUdW +TLlAnyM6lHh5Kb+plfX0LUd7faF6KtsbX9Q+/fFifgRZ/dTLaEnNz4xcCrDzA== 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 4SVzPk6klrzbqh; Wed, 15 Nov 2023 23:09:14 +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 3AFN9EQ6065009; Wed, 15 Nov 2023 23:09:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AFN9Ess065006; Wed, 15 Nov 2023 23:09:14 GMT (envelope-from git) Date: Wed, 15 Nov 2023 23:09:14 GMT Message-Id: <202311152309.3AFN9Ess065006@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: ad744541311b - main - mlx5: add ability to attach flow counter to steering rule 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: ad744541311bfddd74ea3c5d49d52a4c366b9762 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ad744541311bfddd74ea3c5d49d52a4c366b9762 commit ad744541311bfddd74ea3c5d49d52a4c366b9762 Author: Mark Bloch AuthorDate: 2023-02-22 05:44:56 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-15 23:08:17 +0000 mlx5: add ability to attach flow counter to steering rule Expose a way to attach a counter 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 | 19 +++++++++++++++++-- sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/sys/dev/mlx5/fs.h b/sys/dev/mlx5/fs.h index 65d38b9ee67a..8aaa0e201f4a 100644 --- a/sys/dev/mlx5/fs.h +++ b/sys/dev/mlx5/fs.h @@ -94,6 +94,7 @@ enum mlx5_flow_act_actions { MLX5_FLOW_ACT_ACTIONS_FLOW_TAG = 1 << 0, MLX5_FLOW_ACT_ACTIONS_MODIFY_HDR = 1 << 1, MLX5_FLOW_ACT_ACTIONS_PACKET_REFORMAT = 1 << 2, + MLX5_FLOW_ACT_ACTIONS_COUNT = 1 << 3, }; enum MLX5_FLOW_ACT_FLAGS { @@ -106,6 +107,7 @@ struct mlx5_flow_act { u32 flow_tag; struct mlx5_modify_hdr *modify_hdr; struct mlx5_pkt_reformat *pkt_reformat; + struct mlx5_fc *counter; }; #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 8032d1a632e5..0f827f0e69d3 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c @@ -182,6 +182,7 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, int modify_mask = 0; int atomic_mod_cap; u32 prm_action = 0; + int count_list = 0; if (sw_action != MLX5_FLOW_RULE_FWD_ACTION_DEST) dest_size = 0; @@ -195,8 +196,13 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, if (sw_action & MLX5_FLOW_RULE_FWD_ACTION_DEST) prm_action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; + if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_COUNT) { + prm_action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + count_list = 1; + } + inlen = MLX5_ST_SZ_BYTES(set_fte_in) + - dest_size * MLX5_ST_SZ_BYTES(dest_format_struct); + (dest_size + count_list) * MLX5_ST_SZ_BYTES(dest_format_struct); if (!dev) return -EINVAL; @@ -248,8 +254,10 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, match_value); memcpy(in_match_value, match_val, MLX5_ST_SZ_BYTES(fte_match_param)); + + in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination); + if (dest_size) { - in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination); list_for_each_entry(dst, dests, base.list) { unsigned int id; @@ -265,6 +273,13 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, } } + if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_COUNT) { + MLX5_SET(dest_format_struct, in_dests, destination_id, + mlx5_fc_id(flow_act->counter)); + in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); + MLX5_SET(flow_context, in_flow_context, flow_counter_list_size, 1); + } + MLX5_SET(flow_context, in_flow_context, action, prm_action); err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); if (!err) diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c index 91543d3878ef..5966a73c58d1 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c @@ -1788,6 +1788,9 @@ static bool check_conflicting_actions(const struct mlx5_flow_act *act1, if (action1 & MLX5_FLOW_ACT_ACTIONS_PACKET_REFORMAT) return true; + if (action1 & MLX5_FLOW_ACT_ACTIONS_COUNT) + return true; + return false; }