diff mbox series

[net-next,V2,01/14] net/mlx5e: en_tc, Extend peer flows to a list

Message ID 20230602191301.47004-2-saeed@kernel.org (mailing list archive)
State Accepted
Commit 953bb24ddc118a5a3021a90a8cab8eae946238e7
Delegated to: Netdev Maintainers
Headers show
Series [net-next,V2,01/14] net/mlx5e: en_tc, Extend peer flows to a list | expand

Checks

Context Check Description
netdev/series_format success Pull request is its own cover letter
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Saeed Mahameed June 2, 2023, 7:12 p.m. UTC
From: Mark Bloch <mbloch@nvidia.com>

Currently, mlx5e_flow is holding a pointer to a peer_flow, in case one
was created. e.g. There is an assumption that mlx5e_flow can have only
one peer.
In order to support more than one peer, refactor mlx5e_flow to hold a
list of peer flows.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/en/tc_priv.h  |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 43 ++++++++++++-------
 2 files changed, 28 insertions(+), 17 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 5, 2023, 11 p.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by Saeed Mahameed <saeedm@nvidia.com>:

On Fri,  2 Jun 2023 12:12:48 -0700 you wrote:
> From: Mark Bloch <mbloch@nvidia.com>
> 
> Currently, mlx5e_flow is holding a pointer to a peer_flow, in case one
> was created. e.g. There is an assumption that mlx5e_flow can have only
> one peer.
> In order to support more than one peer, refactor mlx5e_flow to hold a
> list of peer flows.
> 
> [...]

Here is the summary with links:
  - [net-next,V2,01/14] net/mlx5e: en_tc, Extend peer flows to a list
    https://git.kernel.org/netdev/net-next/c/953bb24ddc11
  - [net-next,V2,02/14] net/mlx5e: tc, Refactor peer add/del flow
    https://git.kernel.org/netdev/net-next/c/b1661efa4dbb
  - [net-next,V2,03/14] net/mlx5e: rep, store send to vport rules per peer
    https://git.kernel.org/netdev/net-next/c/ed7a8fe71836
  - [net-next,V2,04/14] net/mlx5e: en_tc, re-factor query route port
    https://git.kernel.org/netdev/net-next/c/0af3613ddc91
  - [net-next,V2,05/14] net/mlx5e: Handle offloads flows per peer
    https://git.kernel.org/netdev/net-next/c/9be6c21fdcf8
  - [net-next,V2,06/14] net/mlx5: E-switch, enlarge peer miss group table
    https://git.kernel.org/netdev/net-next/c/18e31d422675
  - [net-next,V2,07/14] net/mlx5: E-switch, refactor FDB miss rule add/remove
    https://git.kernel.org/netdev/net-next/c/9bee385a6e39
  - [net-next,V2,08/14] net/mlx5: E-switch, Handle multiple master egress rules
    https://git.kernel.org/netdev/net-next/c/5e0202eb49ed
  - [net-next,V2,09/14] net/mlx5: E-switch, generalize shared FDB creation
    https://git.kernel.org/netdev/net-next/c/014e4d48eaa3
  - [net-next,V2,10/14] net/mlx5: DR, handle more than one peer domain
    https://git.kernel.org/netdev/net-next/c/6d5b7321d8af
  - [net-next,V2,11/14] net/mlx5: Devcom, Rename paired to ready
    https://git.kernel.org/netdev/net-next/c/e67f928a5204
  - [net-next,V2,12/14] net/mlx5: E-switch, mark devcom as not ready when all eswitches are unpaired
    https://git.kernel.org/netdev/net-next/c/8611df722030
  - [net-next,V2,13/14] net/mlx5: Devcom, introduce devcom_for_each_peer_entry
    https://git.kernel.org/netdev/net-next/c/90ca127c62e9
  - [net-next,V2,14/14] net/mlx5: Devcom, extend mlx5_devcom_send_event to work with more than two devices
    https://git.kernel.org/netdev/net-next/c/e2a82bf8a428

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h
index ba2b1f24ff14..8a500a966f06 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h
@@ -94,13 +94,13 @@  struct mlx5e_tc_flow {
 	 * destinations.
 	 */
 	struct encap_flow_item encaps[MLX5_MAX_FLOW_FWD_VPORTS];
-	struct mlx5e_tc_flow *peer_flow;
 	struct mlx5e_hairpin_entry *hpe; /* attached hairpin instance */
 	struct list_head hairpin; /* flows sharing the same hairpin */
 	struct list_head peer;    /* flows with peer flow */
 	struct list_head unready; /* flows not ready to be offloaded (e.g
 				   * due to missing route)
 				   */
+	struct list_head peer_flows; /* flows on peer */
 	struct net_device *orig_dev; /* netdev adding flow first */
 	int tmp_entry_index;
 	struct list_head tmp_list; /* temporary flow list used by neigh update */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index fd9f928e25c7..9c9c7024772f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1989,6 +1989,8 @@  void mlx5e_put_flow_list(struct mlx5e_priv *priv, struct list_head *flow_list)
 static void __mlx5e_tc_del_fdb_peer_flow(struct mlx5e_tc_flow *flow)
 {
 	struct mlx5_eswitch *esw = flow->priv->mdev->priv.eswitch;
+	struct mlx5e_tc_flow *peer_flow;
+	struct mlx5e_tc_flow *tmp;
 
 	if (!flow_flag_test(flow, ESWITCH) ||
 	    !flow_flag_test(flow, DUP))
@@ -2000,12 +2002,13 @@  static void __mlx5e_tc_del_fdb_peer_flow(struct mlx5e_tc_flow *flow)
 
 	flow_flag_clear(flow, DUP);
 
-	if (refcount_dec_and_test(&flow->peer_flow->refcnt)) {
-		mlx5e_tc_del_fdb_flow(flow->peer_flow->priv, flow->peer_flow);
-		kfree(flow->peer_flow);
+	list_for_each_entry_safe(peer_flow, tmp, &flow->peer_flows, peer_flows) {
+		if (refcount_dec_and_test(&peer_flow->refcnt)) {
+			mlx5e_tc_del_fdb_flow(peer_flow->priv, peer_flow);
+			list_del(&peer_flow->peer_flows);
+			kfree(peer_flow);
+		}
 	}
-
-	flow->peer_flow = NULL;
 }
 
 static void mlx5e_tc_del_fdb_peer_flow(struct mlx5e_tc_flow *flow)
@@ -4295,6 +4298,7 @@  mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,
 	INIT_LIST_HEAD(&flow->hairpin);
 	INIT_LIST_HEAD(&flow->l3_to_l2_reformat);
 	INIT_LIST_HEAD(&flow->attrs);
+	INIT_LIST_HEAD(&flow->peer_flows);
 	refcount_set(&flow->refcnt, 1);
 	init_completion(&flow->init_done);
 	init_completion(&flow->del_hw_done);
@@ -4443,7 +4447,7 @@  static int mlx5e_tc_add_fdb_peer_flow(struct flow_cls_offload *f,
 		goto out;
 	}
 
-	flow->peer_flow = peer_flow;
+	list_add_tail(&peer_flow->peer_flows, &flow->peer_flows);
 	flow_flag_set(flow, DUP);
 	mutex_lock(&esw->offloads.peer_mutex);
 	list_add_tail(&flow->peer, &esw->offloads.peer_flows);
@@ -4741,19 +4745,26 @@  int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
 	if (!peer_esw)
 		goto out;
 
-	if (flow_flag_test(flow, DUP) &&
-	    flow_flag_test(flow->peer_flow, OFFLOADED)) {
-		u64 bytes2;
-		u64 packets2;
-		u64 lastuse2;
+	if (flow_flag_test(flow, DUP)) {
+		struct mlx5e_tc_flow *peer_flow;
 
-		if (flow_flag_test(flow, USE_ACT_STATS)) {
-			f->use_act_stats = true;
-		} else {
-			counter = mlx5e_tc_get_counter(flow->peer_flow);
+		list_for_each_entry(peer_flow, &flow->peer_flows, peer_flows) {
+			u64 packets2;
+			u64 lastuse2;
+			u64 bytes2;
+
+			if (!flow_flag_test(peer_flow, OFFLOADED))
+				continue;
+			if (flow_flag_test(flow, USE_ACT_STATS)) {
+				f->use_act_stats = true;
+				break;
+			}
+
+			counter = mlx5e_tc_get_counter(peer_flow);
 			if (!counter)
 				goto no_peer_counter;
-			mlx5_fc_query_cached(counter, &bytes2, &packets2, &lastuse2);
+			mlx5_fc_query_cached(counter, &bytes2, &packets2,
+					     &lastuse2);
 
 			bytes += bytes2;
 			packets += packets2;