Skip to contentSkip to conversation

mlx5 updates 2022-02-16

GIT PULL Applied Saeed Mahameed 2 participants 17 messages Feb 17, 2022

Subsystems (4)
lore
Share & tools
lore
#3 lore raw

PATCH 2/15 net/mlx5e: Add support for using xdp->data_meta

In reply to Saeed Mahameed

From: Alex Liu <[email protected]>

Add support for using xdp->data_meta for cross-program communication

Pass "true" to the last argument of xdp_prepare_buff().

After SKB is built, call skb_metadata_set() if metadata was pushed.

---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +12 -5
index 91fdf957cd7c..3fe4f06f3e71 100644
@@ -1489,7 +1489,7 @@ static inline void mlx5e_complete_rx_cqe(struct mlx5e_rq *rq,
 static inline
 struct sk_buff *mlx5e_build_linear_skb(struct mlx5e_rq *rq, void *va,
 				       u32 frag_size, u16 headroom,
-				       u32 cqe_bcnt)
+				       u32 cqe_bcnt, u32 metasize)
 {
 	struct sk_buff *skb = build_skb(va, frag_size);
 
@@ -1501,6 +1501,9 @@ struct sk_buff *mlx5e_build_linear_skb(struct mlx5e_rq *rq, void *va,
 	skb_reserve(skb, headroom);
 	skb_put(skb, cqe_bcnt);
 
+	if (metasize)
+		skb_metadata_set(skb, metasize);
+
 	return skb;
 }
 
@@ -1508,7 +1511,7 @@ static void mlx5e_fill_xdp_buff(struct mlx5e_rq *rq, void *va, u16 headroom,
 				u32 len, struct xdp_buff *xdp)
 {
 	xdp_init_buff(xdp, rq->buff.frame0_sz, &rq->xdp_rxq);
-	xdp_prepare_buff(xdp, va, headroom, len, false);
+	xdp_prepare_buff(xdp, va, headroom, len, true);
 }
 
 static struct sk_buff *
@@ -1521,6 +1524,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
 	struct sk_buff *skb;
 	void *va, *data;
 	u32 frag_size;
+	u32 metasize;
 
 	va             = page_address(di->page) + wi->offset;
 	data           = va + rx_headroom;
@@ -1537,7 +1541,8 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
 
 	rx_headroom = xdp.data - xdp.data_hard_start;
 	frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt);
-	skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt);
+	metasize = xdp.data - xdp.data_meta;
+	skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt, metasize);
 	if (unlikely(!skb))
 		return NULL;
 
@@ -1836,6 +1841,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
 	struct sk_buff *skb;
 	void *va, *data;
 	u32 frag_size;
+	u32 metasize;
 
 	/* Check packet size. Note LRO doesn't use linear SKB */
 	if (unlikely(cqe_bcnt > rq->hw_mtu)) {
@@ -1861,7 +1867,8 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
 
 	rx_headroom = xdp.data - xdp.data_hard_start;
 	frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt32);
-	skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt32);
+	metasize = xdp.data - xdp.data_meta;
+	skb = mlx5e_build_linear_skb(rq, va, frag_size, rx_headroom, cqe_bcnt32, metasize);
 	if (unlikely(!skb))
 		return NULL;
 
@@ -1892,7 +1899,7 @@ mlx5e_skb_from_cqe_shampo(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
 		dma_sync_single_range_for_cpu(rq->pdev, head->addr, 0, frag_size, DMA_FROM_DEVICE);
 		prefetchw(hdr);
 		prefetch(data);
-		skb = mlx5e_build_linear_skb(rq, hdr, frag_size, rx_headroom, head_size);
+		skb = mlx5e_build_linear_skb(rq, hdr, frag_size, rx_headroom, head_size, 0);
 
 		if (unlikely(!skb))
 			return NULL;
Signature · 1 line
2.34.1
#0 lore raw

From: Saeed Mahameed <[email protected]>

Hi Dave, Hi Jakub,

This series provides general misc updates to mlx5 driver. For more information please see tag log below.

Please pull and let me know if there is any problem.

Thanks,
Saeed.

The following changes since commit 22b67d17194fa47ac06b27475e63bb9f7f65b307:

net: rtnetlink: rtnl_stats_get(): Emit an extack for unset filter_mask (2022-02-16 20:56:21 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2022-02-16

for you to fetch changes up to b070e70381ee343dc10d2b1f0f3a6b1f940f0ae5:

net/mlx5e: TC, Allow sample action with CT (2022-02-16 23:55:17 -0800)

----------------------------------------------------------------
mlx5-updates-2022-02-16

Misc updates for mlx5:
1) Alex Liu Adds support for using xdp->data_meta

2) Aya Levin Adds PTP counters and port time stamp mode for representors and switchdev mode.

3) Tariq Toukan, Striding RQ simple improvements.

4) Roi Dayan (7): Create multiple attr instances per flow

Some TC actions use post actions for their implementation. For example CT and sample actions.

Create a new flow attr instance after each multi table action and create a post action rule for it as a generic parsing step. Now multi table actions like CT, sample don't require to do it.

When flow has multiple attr instances, the first flow attr is being offloaded normally and linked to the next attr (post action rule) by setting an id on reg_c for matching.
Post action rule (rule created from second attr instance) match the id on reg_c and does rest of the actions.

Example rule with actions CT,goto will be created with 2 attr instances as following: attr1(CT)->attr2(goto)

----------------------------------------------------------------
Alex Liu (1):

      net/mlx5e: Add support for using xdp->data_meta

Aya Levin (2):
net/mlx5e: E-Switch, Add PTP counters for uplink representor net/mlx5e: E-Switch, Add support for tx_port_ts in switchdev mode

Colin Ian King (1):

      net/mlx5e: Fix spelling mistake "supoported" -> "supported"

Paul Blakey (1):
net/mlx5e: TC, Move flow hashtable to be per rep

Roi Dayan (7):
net/mlx5e: Pass actions param to actions_match_supported() net/mlx5e: Add post act offload/unoffload API net/mlx5e: Create new flow attr for multi table actions net/mlx5e: Use multi table support for CT and sample actions net/mlx5e: TC, Clean redundant counter flag from tc action parsers net/mlx5e: TC, Make post_act parse CT and sample actions net/mlx5e: TC, Allow sample action with CT

Tariq Toukan (3):
net/mlx5e: Generalize packet merge error message
net/mlx5e: Default to Striding RQ when not conflicting with CQE compression net/mlx5e: RX, Restrict bulk size for small Striding RQs

 drivers/net/ethernet/mellanox/mlx5/core/en.h       |   1 +
 .../net/ethernet/mellanox/mlx5/core/en/params.c    |  11 +-
 .../net/ethernet/mellanox/mlx5/core/en/params.h    |   1 +
 .../net/ethernet/mellanox/mlx5/core/en/rep/tc.c    |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/en/rss.c   |   4 +-
 .../ethernet/mellanox/mlx5/core/en/tc/act/accept.c |   3 +-
 .../ethernet/mellanox/mlx5/core/en/tc/act/act.c    |  73 ++++
 .../ethernet/mellanox/mlx5/core/en/tc/act/act.h    |  25 ++
 .../net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c |  20 +-
 .../ethernet/mellanox/mlx5/core/en/tc/act/drop.c   |   3 +-
 .../ethernet/mellanox/mlx5/core/en/tc/act/goto.c   |   3 +-
 .../ethernet/mellanox/mlx5/core/en/tc/act/mirred.c |   3 +-
 .../mellanox/mlx5/core/en/tc/act/mirred_nic.c      |   3 +-
 .../mlx5/core/en/tc/act/redirect_ingress.c         |   3 +-
 .../ethernet/mellanox/mlx5/core/en/tc/act/sample.c |  29 +-
 .../ethernet/mellanox/mlx5/core/en/tc/act/sample.h |  14 +
 .../ethernet/mellanox/mlx5/core/en/tc/act/trap.c   |   3 +-
 .../ethernet/mellanox/mlx5/core/en/tc/post_act.c   |  69 ++--
 .../ethernet/mellanox/mlx5/core/en/tc/post_act.h   |   8 +
 .../net/ethernet/mellanox/mlx5/core/en/tc/sample.c |  71 +---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c |  47 +--
 .../net/ethernet/mellanox/mlx5/core/en/tc_priv.h   |   7 +
 .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c  |  48 ++-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |   1 +
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   |  31 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.h   |   6 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c    |  20 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.h |   1 +
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c    | 432 +++++++++++++++++----
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.h    |  12 +-
 31 files changed, 714 insertions(+), 244 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.h
#1 lore raw

PATCH 1/15 net/mlx5e: Fix spelling mistake "supoported" -> "supported"

From: Colin Ian King <[email protected]>

There is a spelling mistake in a NL_SET_ERR_MSG_MOD error message. Fix it.

Fixes 3b49a7edec1d ("net/mlx5e: TC, Reject rules with multiple CT actions")
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c +1 -1
index 85f0cb88127f..9fb1a9a8bc02 100644
@@ -21,7 +21,7 @@ tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,
 	}
 
 	if (parse_state->ct && !clear_action) {
-		NL_SET_ERR_MSG_MOD(extack, "Multiple CT actions are not supoported");
+		NL_SET_ERR_MSG_MOD(extack, "Multiple CT actions are not supported");
 		return false;
 	}
 
Signature · 1 line
2.34.1
#4 lore raw

PATCH 3/15 net/mlx5e: Generalize packet merge error message

In reply to Saeed Mahameed

From: Tariq Toukan <[email protected]>

Update the old error message for LRO state modify with the new general name.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/rss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rss.c +2 -2
index c1cdd8c2e37a..7f93426b88b3 100644
@@ -442,7 +442,7 @@ int mlx5e_rss_packet_merge_set_param(struct mlx5e_rss *rss,
 			goto inner_tir;
 		err = mlx5e_tir_modify(tir, builder);
 		if (err) {
-			mlx5e_rss_warn(rss->mdev, "Failed to update LRO state of indirect TIR %#x for traffic type %d: err = %d\n",
+			mlx5e_rss_warn(rss->mdev, "Failed to update packet merge state of indirect TIR %#x for traffic type %d: err = %d\n",
 				       mlx5e_tir_get_tirn(tir), tt, err);
 			if (!final_err)
 				final_err = err;
@@ -457,7 +457,7 @@ int mlx5e_rss_packet_merge_set_param(struct mlx5e_rss *rss,
 			continue;
 		err = mlx5e_tir_modify(tir, builder);
 		if (err) {
-			mlx5e_rss_warn(rss->mdev, "Failed to update LRO state of inner indirect TIR %#x for traffic type %d: err = %d\n",
+			mlx5e_rss_warn(rss->mdev, "Failed to update packet merge state of inner indirect TIR %#x for traffic type %d: err = %d\n",
 				       mlx5e_tir_get_tirn(tir), tt, err);
 			if (!final_err)
 				final_err = err;
Signature · 1 line
2.34.1
#5 lore raw

PATCH 4/15 net/mlx5e: Default to Striding RQ when not conflicting with CQE compression

In reply to Saeed Mahameed

From: Tariq Toukan <[email protected]>

CQE compression is turned on by default on slow pci systems to help reduce the load on pci.
In this case, Striding RQ was turned off as CQEs of packets that span several strides were not compressed, significantly reducing the compression effectiveness.
This issue does not exist when using the newer mini_cqe format "stride_index". Hence, allow defaulting to Striding RQ in this case.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/params.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +3 -2
index d41936d65483..2d9707c024b0 100644
@@ -359,12 +359,13 @@ void mlx5e_build_rq_params(struct mlx5_core_dev *mdev,
 {
 	/* Prefer Striding RQ, unless any of the following holds:
 	 * - Striding RQ configuration is not possible/supported.
-	 * - Slow PCI heuristic.
+	 * - CQE compression is ON, and stride_index mini_cqe layout is not supported.
 	 * - Legacy RQ would use linear SKB while Striding RQ would use non-linear.
 	 *
 	 * No XSK params: checking the availability of striding RQ in general.
 	 */
-	if (!slow_pci_heuristic(mdev) &&
+	if ((!MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS) ||
+	     MLX5_CAP_GEN(mdev, mini_cqe_resp_stride_index)) &&
 	    mlx5e_striding_rq_possible(mdev, params) &&
 	    (mlx5e_rx_mpwqe_is_linear_skb(mdev, params, NULL) ||
 	     !mlx5e_rx_is_linear_skb(params, NULL)))
Signature · 1 line
2.34.1
#6 lore raw

PATCH 5/15 net/mlx5e: RX, Restrict bulk size for small Striding RQs

In reply to Saeed Mahameed

From: Tariq Toukan <[email protected]>

In RQs of type multi-packet WQE (Striding RQ), each WQE is relatively large (typically 256KB) but their number is relatively small (8 in default).

Re-mapping the descriptors' buffers before re-posting them is done via UMR (User-Mode Memory Registration) operations.

On the one hand, posting UMR WQEs in bulks reduces communication overhead with the HW and better utilizes its processing units.
On the other hand, delaying the WQE repost operations for a small RQ (say, of 4 WQEs) might drastically hit its performance, causing packet drops due to no receive buffer, for high or bursty incoming packets rate.

Here we restrict the bulk size for too small RQs. Effectively, with the current constants, RQ of size 4 (minimum allowed) would have no bulking, while larger RQs will continue working with bulks of 2.

---
 drivers/net/ethernet/mellanox/mlx5/core/en.h        | 1 +
 drivers/net/ethernet/mellanox/mlx5/core/en/params.c | 6 ++++++
 drivers/net/ethernet/mellanox/mlx5/core/en/params.h | 1 +
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c   | 1 +
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c     | 3 +--
 5 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
index e29ac77e9bec..2704c7537481 100644
@@ -714,6 +714,7 @@ struct mlx5e_rq {
 			u8                     umr_in_progress;
 			u8                     umr_last_bulk;
 			u8                     umr_completed;
+			u8                     min_wqe_bulk;
 			struct mlx5e_shampo_hd *shampo;
 		} mpwqe;
 	};
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +6 -0
index 2d9707c024b0..0bd8698f7226 100644
@@ -178,6 +178,12 @@ u8 mlx5e_mpwqe_get_log_num_strides(struct mlx5_core_dev *mdev,
 		mlx5e_mpwqe_get_log_stride_size(mdev, params, xsk);
 }
 
+u8 mlx5e_mpwqe_get_min_wqe_bulk(unsigned int wq_sz)
+{
+#define UMR_WQE_BULK (2)
+	return min_t(unsigned int, UMR_WQE_BULK, wq_sz / 2 - 1);
+}
+
 u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
 			  struct mlx5e_params *params,
 			  struct mlx5e_xsk_param *xsk)
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +1 -0
index 433e6967692d..47a368112e31 100644
@@ -129,6 +129,7 @@ u8 mlx5e_mpwqe_get_log_stride_size(struct mlx5_core_dev *mdev,
 u8 mlx5e_mpwqe_get_log_num_strides(struct mlx5_core_dev *mdev,
 				   struct mlx5e_params *params,
 				   struct mlx5e_xsk_param *xsk);
+u8 mlx5e_mpwqe_get_min_wqe_bulk(unsigned int wq_sz);
 u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
 			  struct mlx5e_params *params,
 			  struct mlx5e_xsk_param *xsk);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -0
index b157c7aac4ca..b2ed2f6d4a92 100644
@@ -595,6 +595,7 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
 		rq->mpwqe.log_stride_sz = mlx5e_mpwqe_get_log_stride_size(mdev, params, xsk);
 		rq->mpwqe.num_strides =
 			BIT(mlx5e_mpwqe_get_log_num_strides(mdev, params, xsk));
+		rq->mpwqe.min_wqe_bulk = mlx5e_mpwqe_get_min_wqe_bulk(wq_sz);
 
 		rq->buff.frame0_sz = (1 << rq->mpwqe.log_stride_sz);
 
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -2
index 3fe4f06f3e71..4cb7c7135b6a 100644
@@ -960,8 +960,7 @@ INDIRECT_CALLABLE_SCOPE bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq)
 	if (unlikely(rq->mpwqe.umr_in_progress > rq->mpwqe.umr_last_bulk))
 		rq->stats->congst_umr++;
 
-#define UMR_WQE_BULK (2)
-	if (likely(missing < UMR_WQE_BULK))
+	if (likely(missing < rq->mpwqe.min_wqe_bulk))
 		return false;
 
 	if (rq->page_pool)
Signature · 1 line
2.34.1
#9 lore raw

PATCH 8/15 net/mlx5e: TC, Move flow hashtable to be per rep

In reply to Saeed Mahameed

From: Paul Blakey <[email protected]>

To allow shared tc block offload between two or more reps of the same eswitch, move the tc flow hashtable to be per rep, instead of per eswitch.

---
 .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |  4 +-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  | 12 ++++-
 .../net/ethernet/mellanox/mlx5/core/en_rep.h  |  6 +--
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 44 ++++++++++---------
 .../net/ethernet/mellanox/mlx5/core/en_tc.h   |  9 +++-
 5 files changed, 43 insertions(+), 32 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +2 -2
index 0991345c4ae5..86fa0bdbee36 100644
@@ -263,14 +263,14 @@ int mlx5e_rep_tc_init(struct mlx5e_rep_priv *rpriv)
 	INIT_LIST_HEAD(&uplink_priv->unready_flows);
 
 	/* init shared tc flow table */
-	err = mlx5e_tc_esw_init(&uplink_priv->tc_ht);
+	err = mlx5e_tc_esw_init(uplink_priv);
 	return err;
 }
 
 void mlx5e_rep_tc_cleanup(struct mlx5e_rep_priv *rpriv)
 {
 	/* delete shared tc flow table */
-	mlx5e_tc_esw_cleanup(&rpriv->uplink_priv.tc_ht);
+	mlx5e_tc_esw_cleanup(&rpriv->uplink_priv);
 	mutex_destroy(&rpriv->uplink_priv.unready_flows_lock);
 }
 
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +10 -2
index 6070b8a13818..6b7e7ea6ded2 100644
@@ -942,15 +942,21 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
 		return err;
 	}
 
+	err = mlx5e_tc_ht_init(&rpriv->tc_ht);
+	if (err)
+		goto err_ht_init;
+
 	if (rpriv->rep->vport == MLX5_VPORT_UPLINK) {
 		err = mlx5e_init_uplink_rep_tx(rpriv);
 		if (err)
-			goto destroy_tises;
+			goto err_init_tx;
 	}
 
 	return 0;
 
-destroy_tises:
+err_init_tx:
+	mlx5e_tc_ht_cleanup(&rpriv->tc_ht);
+err_ht_init:
 	mlx5e_destroy_tises(priv);
 	return err;
 }
@@ -970,6 +976,8 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
 
 	if (rpriv->rep->vport == MLX5_VPORT_UPLINK)
 		mlx5e_cleanup_uplink_rep_tx(rpriv);
+
+	mlx5e_tc_ht_cleanup(&rpriv->tc_ht);
 }
 
 static void mlx5e_rep_enable(struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +1 -5
index b01dacb6f527..0b619c7846d0 100644
@@ -64,11 +64,6 @@ struct mlx5e_tc_tun_encap;
 struct mlx5e_post_act;
 
 struct mlx5_rep_uplink_priv {
-	/* Filters DB - instantiated by the uplink representor and shared by
-	 * the uplink's VFs
-	 */
-	struct rhashtable  tc_ht;
-
 	/* indirect block callbacks are invoked on bind/unbind events
 	 * on registered higher level devices (e.g. tunnel devices)
 	 *
@@ -113,6 +108,7 @@ struct mlx5e_rep_priv {
 	struct list_head       vport_sqs_list;
 	struct mlx5_rep_uplink_priv uplink_priv; /* valid for uplink rep */
 	struct rtnl_link_stats64 prev_vf_vport_stats;
+	struct rhashtable tc_ht;
 };
 
 static inline
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +23 -21

85 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +7 -2
index c6221728b767..533c897bd517 100644
@@ -167,8 +167,11 @@ enum {
 
 #define MLX5_TC_FLAG(flag) BIT(MLX5E_TC_FLAG_##flag##_BIT)
 
-int mlx5e_tc_esw_init(struct rhashtable *tc_ht);
-void mlx5e_tc_esw_cleanup(struct rhashtable *tc_ht);
+int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv);
+void mlx5e_tc_esw_cleanup(struct mlx5_rep_uplink_priv *uplink_priv);
+
+int mlx5e_tc_ht_init(struct rhashtable *tc_ht);
+void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht);
 
 int mlx5e_configure_flower(struct net_device *dev, struct mlx5e_priv *priv,
 			   struct flow_cls_offload *f, unsigned long flags);
@@ -304,6 +307,8 @@ int mlx5e_set_fwd_to_int_port_actions(struct mlx5e_priv *priv,
 #else /* CONFIG_MLX5_CLS_ACT */
 static inline int  mlx5e_tc_nic_init(struct mlx5e_priv *priv) { return 0; }
 static inline void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) {}
+static inline int mlx5e_tc_ht_init(struct rhashtable *tc_ht) { return 0; }
+static inline void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht) {}
 static inline int
 mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv)
 { return -EOPNOTSUPP; }
Signature · 1 line
2.34.1
#10 lore raw

PATCH 9/15 net/mlx5e: Pass actions param to actions_match_supported()

In reply to Saeed Mahameed

From: Roi Dayan <[email protected]>

Currently the mlx5_flow object contains a single mlx5_attr instance. However, multi table actions (e.g. CT) instantiate multiple attr instances.

Currently action_match_supported() reads the actions flag from the flow's attribute instance. Modify the function to receive the action flags as a parameter which is set by the calling function and pass the aggregated actions to actions_match_supported().

---
 .../net/ethernet/mellanox/mlx5/core/en/tc/act/act.h    |  1 +
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c        | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +1 -0
index bfbc91c116a5..fc7c06688b51 100644
@@ -16,6 +16,7 @@ struct mlx5e_tc_act_parse_state {
 	unsigned int num_actions;
 	struct mlx5e_tc_flow *flow;
 	struct netlink_ext_ack *extack;
+	u32 actions;
 	bool ct;
 	bool encap;
 	bool decap;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +7 -3
index 342ab0688f13..a709b2e9f3f2 100644
@@ -3257,11 +3257,11 @@ actions_match_supported_fdb(struct mlx5e_priv *priv,
 static bool
 actions_match_supported(struct mlx5e_priv *priv,
 			struct flow_action *flow_action,
+			u32 actions,
 			struct mlx5e_tc_flow_parse_attr *parse_attr,
 			struct mlx5e_tc_flow *flow,
 			struct netlink_ext_ack *extack)
 {
-	u32 actions = flow->attr->action;
 	bool ct_flow, ct_clear;
 
 	ct_clear = flow->attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR;
@@ -3344,6 +3344,8 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
 		err = tc_act->parse_action(parse_state, act, priv, attr);
 		if (err)
 			return err;
+
+		parse_state->actions |= attr->action;
 	}
 
 	flow_action_for_each(i, act, flow_action) {
@@ -3445,7 +3447,8 @@ parse_tc_nic_actions(struct mlx5e_priv *priv,
 	if (err)
 		return err;
 
-	if (!actions_match_supported(priv, flow_action, parse_attr, flow, extack))
+	if (!actions_match_supported(priv, flow_action, parse_state->actions,
+				     parse_attr, flow, extack))
 		return -EOPNOTSUPP;
 
 	return 0;
@@ -3574,7 +3577,8 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv,
 	if (err)
 		return err;
 
-	if (!actions_match_supported(priv, flow_action, parse_attr, flow, extack))
+	if (!actions_match_supported(priv, flow_action, parse_state->actions,
+				     parse_attr, flow, extack))
 		return -EOPNOTSUPP;
 
 	return 0;
Signature · 1 line
2.34.1
#7 lore raw

PATCH 6/15 net/mlx5e: E-Switch, Add PTP counters for uplink representor

In reply to Saeed Mahameed

From: Aya Levin <[email protected]>

There is a configuration where the uplink interface is the synchronizer. Add PTP counters for this interface for monitoring.

---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   | 1 +
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -0
index a3f257623af4..4459e5585075 100644
@@ -1094,6 +1094,7 @@ static mlx5e_stats_grp_t mlx5e_ul_rep_stats_grps[] = {
 	&MLX5E_STATS_GRP(ipsec_sw),
 	&MLX5E_STATS_GRP(ipsec_hw),
 #endif
+	&MLX5E_STATS_GRP(ptp),
 };
 
 static unsigned int mlx5e_ul_rep_stats_grps_num(struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +1 -1
index 26e326fe503c..3e5d8c788026 100644
@@ -2348,7 +2348,7 @@ MLX5E_DEFINE_STATS_GRP(channels, 0);
 MLX5E_DEFINE_STATS_GRP(per_port_buff_congest, 0);
 MLX5E_DEFINE_STATS_GRP(eth_ext, 0);
 static MLX5E_DEFINE_STATS_GRP(tls, 0);
-static MLX5E_DEFINE_STATS_GRP(ptp, 0);
+MLX5E_DEFINE_STATS_GRP(ptp, 0);
 static MLX5E_DEFINE_STATS_GRP(qos, 0);
 
 /* The stats groups order is opposite to the update_stats() order calls */
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +1 -0
index 2c1ed5b81be6..14eaf923e7b3 100644
@@ -459,5 +459,6 @@ extern MLX5E_DECLARE_STATS_GRP(channels);
 extern MLX5E_DECLARE_STATS_GRP(per_port_buff_congest);
 extern MLX5E_DECLARE_STATS_GRP(ipsec_hw);
 extern MLX5E_DECLARE_STATS_GRP(ipsec_sw);
+extern MLX5E_DECLARE_STATS_GRP(ptp);
 
 #endif /* __MLX5_EN_STATS_H__ */
Signature · 1 line
2.34.1
#8 lore raw

PATCH 7/15 net/mlx5e: E-Switch, Add support for tx_port_ts in switchdev mode

In reply to Saeed Mahameed

From: Aya Levin <[email protected]>

When turning on tx_port_ts (private flag) a PTP-SQ is created. Consider this queue when adding rules matching SQs to VPORTs. Otherwise the traffic on this queue won't reach the wire.

---
 .../net/ethernet/mellanox/mlx5/core/en_rep.c   | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +15 -3
index 4459e5585075..6070b8a13818 100644
@@ -55,6 +55,7 @@
 #include "diag/en_rep_tracepoint.h"
 #include "en_accel/ipsec.h"
 #include "en/tc/int_port.h"
+#include "en/ptp.h"
 
 #define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \
 	max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
@@ -401,13 +402,18 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
 	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
 	struct mlx5e_rep_priv *rpriv = priv->ppriv;
 	struct mlx5_eswitch_rep *rep = rpriv->rep;
+	int n, tc, nch, num_sqs = 0;
 	struct mlx5e_channel *c;
-	int n, tc, num_sqs = 0;
 	int err = -ENOMEM;
+	bool ptp_sq;
 	u32 *sqs;
 
-	sqs = kcalloc(priv->channels.num * mlx5e_get_dcb_num_tc(&priv->channels.params),
-		      sizeof(*sqs), GFP_KERNEL);
+	ptp_sq = !!(priv->channels.ptp &&
+		    MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_TX_PORT_TS));
+	nch = priv->channels.num + ptp_sq;
+
+	sqs = kcalloc(nch * mlx5e_get_dcb_num_tc(&priv->channels.params), sizeof(*sqs),
+		      GFP_KERNEL);
 	if (!sqs)
 		goto out;
 
@@ -416,6 +422,12 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
 		for (tc = 0; tc < c->num_tc; tc++)
 			sqs[num_sqs++] = c->sq[tc].sqn;
 	}
+	if (ptp_sq) {
+		struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
+
+		for (tc = 0; tc < ptp_ch->num_tc; tc++)
+			sqs[num_sqs++] = ptp_ch->ptpsq[tc].txqsq.sqn;
+	}
 
 	err = mlx5e_sqs2vport_start(esw, rep, sqs, num_sqs);
 	kfree(sqs);
Signature · 1 line
2.34.1
#11 lore raw

PATCH 10/15 net/mlx5e: Add post act offload/unoffload API

In reply to Saeed Mahameed

From: Roi Dayan <[email protected]>

Introduce mlx5e_tc_post_act_offload() and mlx5e_tc_post_act_unoffload() to be able to unoffload and reoffload existing post action rules handles. For example in neigh update events, the driver removes and readds rules in hardware.

---
 .../mellanox/mlx5/core/en/tc/post_act.c       | 67 +++++++++++++------
 .../mellanox/mlx5/core/en/tc/post_act.h       |  8 +++
 2 files changed, 54 insertions(+), 21 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c +46 -21
index 9e0e229cf164..ce7ba1951e25 100644
@@ -75,21 +75,47 @@ mlx5e_tc_post_act_destroy(struct mlx5e_post_act *post_act)
 	kfree(post_act);
 }
 
+int
+mlx5e_tc_post_act_offload(struct mlx5e_post_act *post_act,
+			  struct mlx5e_post_act_handle *handle)
+{
+	struct mlx5_flow_spec *spec;
+	int err;
+
+	spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
+	if (!spec)
+		return -ENOMEM;
+
+	/* Post action rule matches on fte_id and executes original rule's tc rule action */
+	mlx5e_tc_match_to_reg_match(spec, FTEID_TO_REG, handle->id, MLX5_POST_ACTION_MASK);
+
+	handle->rule = mlx5_tc_rule_insert(post_act->priv, spec, handle->attr);
+	if (IS_ERR(handle->rule)) {
+		err = PTR_ERR(handle->rule);
+		netdev_warn(post_act->priv->netdev, "Failed to add post action rule");
+		goto err_rule;
+	}
+
+	kvfree(spec);
+	return 0;
+
+err_rule:
+	kvfree(spec);
+	return err;
+}
+
 struct mlx5e_post_act_handle *
 mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *attr)
 {
 	u32 attr_sz = ns_to_attr_sz(post_act->ns_type);
-	struct mlx5e_post_act_handle *handle = NULL;
-	struct mlx5_flow_attr *post_attr = NULL;
-	struct mlx5_flow_spec *spec = NULL;
+	struct mlx5e_post_act_handle *handle;
+	struct mlx5_flow_attr *post_attr;
 	int err;
 
 	handle = kzalloc(sizeof(*handle), GFP_KERNEL);
-	spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
 	post_attr = mlx5_alloc_flow_attr(post_act->ns_type);
-	if (!handle || !spec || !post_attr) {
+	if (!handle || !post_attr) {
 		kfree(post_attr);
-		kvfree(spec);
 		kfree(handle);
 		return ERR_PTR(-ENOMEM);
 	}
@@ -113,36 +139,35 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *at
 	if (err)
 		goto err_xarray;
 
-	/* Post action rule matches on fte_id and executes original rule's
-	 * tc rule action
-	 */
-	mlx5e_tc_match_to_reg_match(spec, FTEID_TO_REG,
-				    handle->id, MLX5_POST_ACTION_MASK);
-
-	handle->rule = mlx5_tc_rule_insert(post_act->priv, spec, post_attr);
-	if (IS_ERR(handle->rule)) {
-		err = PTR_ERR(handle->rule);
-		netdev_warn(post_act->priv->netdev, "Failed to add post action rule");
-		goto err_rule;
-	}
 	handle->attr = post_attr;
+	err = mlx5e_tc_post_act_offload(post_act, handle);
+	if (err)
+		goto err_rule;
+
 
-	kvfree(spec);
 	return handle;
 
 err_rule:
 	xa_erase(&post_act->ids, handle->id);
 err_xarray:
 	kfree(post_attr);
-	kvfree(spec);
 	kfree(handle);
 	return ERR_PTR(err);
 }
 
 void
-mlx5e_tc_post_act_del(struct mlx5e_post_act *post_act, struct mlx5e_post_act_handle *handle)
+mlx5e_tc_post_act_unoffload(struct mlx5e_post_act *post_act,
+			    struct mlx5e_post_act_handle *handle)
 {
 	mlx5_tc_rule_delete(post_act->priv, handle->rule, handle->attr);
+	handle->rule = NULL;
+}
+
+void
+mlx5e_tc_post_act_del(struct mlx5e_post_act *post_act, struct mlx5e_post_act_handle *handle)
+{
+	if (!IS_ERR_OR_NULL(handle->rule))
+		mlx5e_tc_post_act_unoffload(post_act, handle);
 	xa_erase(&post_act->ids, handle->id);
 	kfree(handle->attr);
 	kfree(handle);
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.h +8 -0
index b530ec1981a5..f476774c0b75 100644
@@ -24,6 +24,14 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *at
 void
 mlx5e_tc_post_act_del(struct mlx5e_post_act *post_act, struct mlx5e_post_act_handle *handle);
 
+int
+mlx5e_tc_post_act_offload(struct mlx5e_post_act *post_act,
+			  struct mlx5e_post_act_handle *handle);
+
+void
+mlx5e_tc_post_act_unoffload(struct mlx5e_post_act *post_act,
+			    struct mlx5e_post_act_handle *handle);
+
 struct mlx5_flow_table *
 mlx5e_tc_post_act_get_ft(struct mlx5e_post_act *post_act);
 
Signature · 1 line
2.34.1
#15 lore raw

PATCH 14/15 net/mlx5e: TC, Make post_act parse CT and sample actions

In reply to Saeed Mahameed

From: Roi Dayan <[email protected]>

Before this commit post_act can be used for normal rules and didn't handle special cases like CT and sample. With this commit post_act rule can also handle the special cases when needed.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c +3 -2
index 32abc91adf23..dea137dd744b 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
 // Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
+#include "en/tc_priv.h"
 #include "en_tc.h"
 #include "post_act.h"
 #include "mlx5_core.h"
@@ -89,7 +90,7 @@ mlx5e_tc_post_act_offload(struct mlx5e_post_act *post_act,
 	/* Post action rule matches on fte_id and executes original rule's tc rule action */
 	mlx5e_tc_match_to_reg_match(spec, FTEID_TO_REG, handle->id, MLX5_POST_ACTION_MASK);
 
-	handle->rule = mlx5_tc_rule_insert(post_act->priv, spec, handle->attr);
+	handle->rule = mlx5e_tc_rule_offload(post_act->priv, spec, handle->attr);
 	if (IS_ERR(handle->rule)) {
 		err = PTR_ERR(handle->rule);
 		netdev_warn(post_act->priv->netdev, "Failed to add post action rule");
@@ -152,7 +153,7 @@ void
 mlx5e_tc_post_act_unoffload(struct mlx5e_post_act *post_act,
 			    struct mlx5e_post_act_handle *handle)
 {
-	mlx5_tc_rule_delete(post_act->priv, handle->rule, handle->attr);
+	mlx5e_tc_rule_unoffload(post_act->priv, handle->rule, handle->attr);
 	handle->rule = NULL;
 }
 
Signature · 1 line
2.34.1
#13 lore raw

PATCH 12/15 net/mlx5e: Use multi table support for CT and sample actions

In reply to Saeed Mahameed

From: Roi Dayan <[email protected]>

CT and sample actions use post actions for their implementation. Flag those actions as multi table actions so the post act infrastructure will handle the post actions allocation.

---
 .../mellanox/mlx5/core/en/tc/act/ct.c         | 12 +++
 .../mellanox/mlx5/core/en/tc/act/sample.c     | 21 ++++++
 .../mellanox/mlx5/core/en/tc/act/sample.h     | 14 ++++
 .../mellanox/mlx5/core/en/tc/post_act.c       |  3 +-
 .../mellanox/mlx5/core/en/tc/sample.c         | 74 +++++--------------
 .../ethernet/mellanox/mlx5/core/en/tc_ct.c    | 50 ++++---------
 6 files changed, 80 insertions(+), 94 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.h
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c +12 -0
index 9fb1a9a8bc02..1492d3e49c59 100644
@@ -56,8 +56,20 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,
 	return 0;
 }
 
+static bool
+tc_act_is_multi_table_act_ct(struct mlx5e_priv *priv,
+			     const struct flow_action_entry *act,
+			     struct mlx5_flow_attr *attr)
+{
+	if (act->ct.action & TCA_CT_ACT_CLEAR)
+		return false;
+
+	return true;
+}
+
 struct mlx5e_tc_act mlx5e_tc_act_ct = {
 	.can_offload = tc_act_can_offload_ct,
 	.parse_action = tc_act_parse_ct,
+	.is_multi_table_act = tc_act_is_multi_table_act_ct,
 };
 
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c +21 -0
index 539fea13ce9f..f39538e3d027 100644
@@ -4,6 +4,7 @@
 #include <net/psample.h>
 #include "act.h"
 #include "en/tc_priv.h"
+#include "en/tc/act/sample.h"
 
 static bool
 tc_act_can_offload_sample(struct mlx5e_tc_act_parse_state *parse_state,
@@ -42,7 +43,27 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,
 	return 0;
 }
 
+bool
+mlx5e_tc_act_sample_is_multi_table(struct mlx5_core_dev *mdev,
+				   struct mlx5_flow_attr *attr)
+{
+	if (MLX5_CAP_GEN(mdev, reg_c_preserve) ||
+	    attr->action & MLX5_FLOW_CONTEXT_ACTION_DECAP)
+		return true;
+
+	return false;
+}
+
+static bool
+tc_act_is_multi_table_act_sample(struct mlx5e_priv *priv,
+				 const struct flow_action_entry *act,
+				 struct mlx5_flow_attr *attr)
+{
+	return mlx5e_tc_act_sample_is_multi_table(priv->mdev, attr);
+}
+
 struct mlx5e_tc_act mlx5e_tc_act_sample = {
 	.can_offload = tc_act_can_offload_sample,
 	.parse_action = tc_act_parse_sample,
+	.is_multi_table_act = tc_act_is_multi_table_act_sample,
 };
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.h new file +14 -0
new file mode 100644
index 000000000000..3efb3a15c5d2
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
+/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
+
+#ifndef __MLX5_EN_TC_ACT_SAMPLE_H__
+#define __MLX5_EN_TC_ACT_SAMPLE_H__
+
+#include <net/flow_offload.h>
+#include "en/tc_priv.h"
+
+bool
+mlx5e_tc_act_sample_is_multi_table(struct mlx5_core_dev *mdev,
+				   struct mlx5_flow_attr *attr);
+
+#endif /* __MLX5_EN_TC_ACT_SAMPLE_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c +1 -2
index 27854ac844a0..32abc91adf23 100644
@@ -126,8 +126,7 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *at
 	post_attr->ft = post_act->ft;
 	post_attr->inner_match_level = MLX5_MATCH_NONE;
 	post_attr->outer_match_level = MLX5_MATCH_NONE;
-	post_attr->action &= ~(MLX5_FLOW_CONTEXT_ACTION_DECAP);
-	post_attr->flags &= ~MLX5_ATTR_FLAG_SAMPLE;
+	post_attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_DECAP;
 
 	handle->ns_type = post_act->ns_type;
 	/* Splits were handled before post action */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +18 -56

185 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +14 -36

144 lines not on this page · raw message

Signature · 1 line
2.34.1
#16 lore raw

PATCH 15/15 net/mlx5e: TC, Allow sample action with CT

In reply to Saeed Mahameed

From: Roi Dayan <[email protected]>

Allow sample+CT actions but still block sample+CT NAT as it is not supported.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c    | 6 ------
 .../net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c    | 8 +++++---
 2 files changed, 5 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c +0 -6
index 1492d3e49c59..7368f95f2310 100644
@@ -14,12 +14,6 @@ tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,
 	bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR;
 	struct netlink_ext_ack *extack = parse_state->extack;
 
-	if (flow_flag_test(parse_state->flow, SAMPLE)) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "Sample action with connection tracking is not supported");
-		return false;
-	}
-
 	if (parse_state->ct && !clear_action) {
 		NL_SET_ERR_MSG_MOD(extack, "Multiple CT actions are not supported");
 		return false;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c +5 -3
index f39538e3d027..2c0196431302 100644
@@ -13,10 +13,12 @@ tc_act_can_offload_sample(struct mlx5e_tc_act_parse_state *parse_state,
 			  struct mlx5_flow_attr *attr)
 {
 	struct netlink_ext_ack *extack = parse_state->extack;
+	bool ct_nat;
 
-	if (flow_flag_test(parse_state->flow, CT)) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "Sample action with connection tracking is not supported");
+	ct_nat = attr->ct_attr.ct_action & TCA_CT_ACT_NAT;
+
+	if (flow_flag_test(parse_state->flow, CT) && ct_nat) {
+		NL_SET_ERR_MSG_MOD(extack, "Sample action with CT NAT is not supported");
 		return false;
 	}
 
Signature · 1 line
2.34.1
#12 lore raw

PATCH 11/15 net/mlx5e: Create new flow attr for multi table actions

In reply to Saeed Mahameed

From: Roi Dayan <[email protected]>

Some TC actions use post actions for their implementation. For example CT and sample actions.

Create a new flow attr after each multi table action and create a post action rule for it.

First flow attr being offloaded normally and linked to the next attr (post action rule) with setting an id on reg_c.
Post action rules match the id on reg_c and continue to the next one.

The flow counter is allocated on the last rule.

---
 .../mellanox/mlx5/core/en/tc/act/act.c        |  73 ++++
 .../mellanox/mlx5/core/en/tc/act/act.h        |  24 ++
 .../mellanox/mlx5/core/en/tc/post_act.c       |   6 -
 .../mellanox/mlx5/core/en/tc/sample.c         |   3 +
 .../ethernet/mellanox/mlx5/core/en/tc_ct.c    |   3 +
 .../ethernet/mellanox/mlx5/core/en/tc_priv.h  |   7 +
 .../mellanox/mlx5/core/en/tc_tun_encap.c      |  48 ++-
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 383 +++++++++++++++---
 .../net/ethernet/mellanox/mlx5/core/en_tc.h   |   3 +-
 9 files changed, 483 insertions(+), 67 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +73 -0
index e600924e30ea..cb8f7593a00c 100644
@@ -2,6 +2,7 @@
 // Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
 #include "act.h"
+#include "en/tc/post_act.h"
 #include "en/tc_priv.h"
 #include "mlx5_core.h"
 
@@ -101,3 +102,75 @@ mlx5e_tc_act_init_parse_state(struct mlx5e_tc_act_parse_state *parse_state,
 	parse_state->num_actions = flow_action->num_entries;
 	parse_state->extack = extack;
 }
+
+void
+mlx5e_tc_act_reorder_flow_actions(struct flow_action *flow_action,
+				  struct mlx5e_tc_flow_action *flow_action_reorder)
+{
+	struct flow_action_entry *act;
+	int i, j = 0;
+
+	flow_action_for_each(i, act, flow_action) {
+		/* Add CT action to be first. */
+		if (act->id == FLOW_ACTION_CT)
+			flow_action_reorder->entries[j++] = act;
+	}
+
+	flow_action_for_each(i, act, flow_action) {
+		if (act->id == FLOW_ACTION_CT)
+			continue;
+		flow_action_reorder->entries[j++] = act;
+	}
+}
+
+int
+mlx5e_tc_act_post_parse(struct mlx5e_tc_act_parse_state *parse_state,
+			struct flow_action *flow_action,
+			struct mlx5_flow_attr *attr,
+			enum mlx5_flow_namespace_type ns_type)
+{
+	struct flow_action_entry *act;
+	struct mlx5e_tc_act *tc_act;
+	struct mlx5e_priv *priv;
+	int err = 0, i;
+
+	priv = parse_state->flow->priv;
+
+	flow_action_for_each(i, act, flow_action) {
+		tc_act = mlx5e_tc_act_get(act->id, ns_type);
+		if (!tc_act || !tc_act->post_parse ||
+		    !tc_act->can_offload(parse_state, act, i, attr))
+			continue;
+
+		err = tc_act->post_parse(parse_state, priv, attr);
+		if (err)
+			goto out;
+	}
+
+out:
+	return err;
+}
+
+int
+mlx5e_tc_act_set_next_post_act(struct mlx5e_tc_flow *flow,
+			       struct mlx5_flow_attr *attr,
+			       struct mlx5_flow_attr *next_attr)
+{
+	struct mlx5_core_dev *mdev = flow->priv->mdev;
+	struct mlx5e_tc_mod_hdr_acts *mod_acts;
+	int err;
+
+	mod_acts = &attr->parse_attr->mod_hdr_acts;
+
+	/* Set handle on current post act rule to next post act rule. */
+	err = mlx5e_tc_post_act_set_handle(mdev, next_attr->post_act_handle, mod_acts);
+	if (err) {
+		mlx5_core_warn(mdev, "Failed setting post action handle");
+		return err;
+	}
+
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
+			MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
+
+	return 0;
+}
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +24 -0
index fc7c06688b51..519fa1056d9f 100644
@@ -42,6 +42,15 @@ struct mlx5e_tc_act {
 	int (*post_parse)(struct mlx5e_tc_act_parse_state *parse_state,
 			  struct mlx5e_priv *priv,
 			  struct mlx5_flow_attr *attr);
+
+	bool (*is_multi_table_act)(struct mlx5e_priv *priv,
+				   const struct flow_action_entry *act,
+				   struct mlx5_flow_attr *attr);
+};
+
+struct mlx5e_tc_flow_action {
+	unsigned int num_entries;
+	struct flow_action_entry **entries;
 };
 
 extern struct mlx5e_tc_act mlx5e_tc_act_drop;
@@ -74,4 +83,19 @@ mlx5e_tc_act_init_parse_state(struct mlx5e_tc_act_parse_state *parse_state,
 			      struct flow_action *flow_action,
 			      struct netlink_ext_ack *extack);
 
+void
+mlx5e_tc_act_reorder_flow_actions(struct flow_action *flow_action,
+				  struct mlx5e_tc_flow_action *flow_action_reorder);
+
+int
+mlx5e_tc_act_post_parse(struct mlx5e_tc_act_parse_state *parse_state,
+			struct flow_action *flow_action,
+			struct mlx5_flow_attr *attr,
+			enum mlx5_flow_namespace_type ns_type);
+
+int
+mlx5e_tc_act_set_next_post_act(struct mlx5e_tc_flow *flow,
+			       struct mlx5_flow_attr *attr,
+			       struct mlx5_flow_attr *next_attr);
+
 #endif /* __MLX5_EN_TC_ACT_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c +0 -6
index ce7ba1951e25..27854ac844a0 100644
@@ -140,15 +140,9 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *at
 		goto err_xarray;
 
 	handle->attr = post_attr;
-	err = mlx5e_tc_post_act_offload(post_act, handle);
-	if (err)
-		goto err_rule;
-
 
 	return handle;
 
-err_rule:
-	xa_erase(&post_act->ids, handle->id);
 err_xarray:
 	kfree(post_attr);
 	kfree(handle);
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +3 -0
index 32230e677029..90b86c4aaf51 100644
@@ -533,6 +533,9 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
 			err = PTR_ERR(post_act_handle);
 			goto err_post_act;
 		}
+		err = mlx5e_tc_post_act_offload(tc_psample->post_act, post_act_handle);
+		if (err)
+			goto err_post_rule;
 		sample_flow->post_act_handle = post_act_handle;
 	} else {
 		err = add_post_rule(esw, sample_flow, spec, attr, &default_tbl_id);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +3 -0
index 0f4d3b9dd979..228ebb19fcab 100644
@@ -1823,6 +1823,9 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
 		ct_dbg("Failed to allocate post action handle");
 		goto err_post_act_handle;
 	}
+	err = mlx5e_tc_post_act_offload(ct_priv->post_act, handle);
+	if (err)
+		goto err_alloc_pre;
 	ct_flow->post_act_handle = handle;
 
 	/* Base flow attributes of both rules on original rule attribute */
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +7 -0
index 9ffba584b982..f76624699a8d 100644
@@ -109,6 +109,7 @@ struct mlx5e_tc_flow {
 	struct completion init_done;
 	struct completion del_hw_done;
 	struct mlx5_flow_attr *attr;
+	struct list_head attrs;
 };
 
 struct mlx5_flow_handle *
@@ -129,6 +130,12 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,
 			   struct mlx5_flow_spec *spec,
 			   struct mlx5_flow_attr *attr);
 
+struct mlx5_flow_attr *
+mlx5e_tc_get_encap_attr(struct mlx5e_tc_flow *flow);
+
+void mlx5e_tc_unoffload_flow_post_acts(struct mlx5e_tc_flow *flow);
+int mlx5e_tc_offload_flow_post_acts(struct mlx5e_tc_flow *flow);
+
 bool mlx5e_is_eswitch_flow(struct mlx5e_tc_flow *flow);
 bool mlx5e_is_ft_flow(struct mlx5e_tc_flow *flow);
 bool mlx5e_is_offloaded_flow(struct mlx5e_tc_flow *flow);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +37 -11

107 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +334 -49

455 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +2 -1
index 533c897bd517..a80b00946f1b 100644
@@ -53,7 +53,6 @@
 			    ESW_FLOW_ATTR_SZ :\
 			    NIC_FLOW_ATTR_SZ)
 
-
 int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags);
 
 struct mlx5e_tc_update_priv {
@@ -84,6 +83,8 @@ struct mlx5_flow_attr {
 	u8 tun_ip_version;
 	int tunnel_id; /* mapped tunnel id */
 	u32 flags;
+	struct list_head list;
+	struct mlx5e_post_act_handle *post_act_handle;
 	union {
 		struct mlx5_esw_flow_attr esw_attr[0];
 		struct mlx5_nic_flow_attr nic_attr[0];
Signature · 1 line
2.34.1
#14 lore raw

PATCH 13/15 net/mlx5e: TC, Clean redundant counter flag from tc action parsers

In reply to Saeed Mahameed

From: Roi Dayan <[email protected]>

When tc actions being parsed only the last flow attr created needs the counter flag and the previous flags being reset.
Clean the flag from the tc action parsers.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c     | 3 +--
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c       | 3 +--
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c       | 3 +--
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c     | 3 +--
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred_nic.c | 3 +--
 .../ethernet/mellanox/mlx5/core/en/tc/act/redirect_ingress.c   | 3 +--
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c       | 3 +--
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c                | 1 -
 8 files changed, 7 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c +1 -2
index 2b53738938a9..21aab96357b5 100644
@@ -19,8 +19,7 @@ tc_act_parse_accept(struct mlx5e_tc_act_parse_state *parse_state,
 		    struct mlx5e_priv *priv,
 		    struct mlx5_flow_attr *attr)
 {
-	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
-			MLX5_FLOW_CONTEXT_ACTION_COUNT;
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 	attr->flags |= MLX5_ATTR_FLAG_ACCEPT;
 
 	return 0;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c +1 -2
index 3d5f23636a02..dd025a95c439 100644
@@ -19,8 +19,7 @@ tc_act_parse_drop(struct mlx5e_tc_act_parse_state *parse_state,
 		  struct mlx5e_priv *priv,
 		  struct mlx5_flow_attr *attr)
 {
-	attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP |
-			MLX5_FLOW_CONTEXT_ACTION_COUNT;
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
 
 	return 0;
 }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c +1 -2
index fb1be822ad25..4726bcb46eec 100644
@@ -76,8 +76,7 @@ tc_act_parse_goto(struct mlx5e_tc_act_parse_state *parse_state,
 		  struct mlx5e_priv *priv,
 		  struct mlx5_flow_attr *attr)
 {
-	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
-			MLX5_FLOW_CONTEXT_ACTION_COUNT;
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 	attr->dest_chain = act->chain_index;
 
 	return 0;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c +1 -2
index 99fb98b3e71b..d08abec93704 100644
@@ -296,8 +296,7 @@ tc_act_parse_mirred(struct mlx5e_tc_act_parse_state *parse_state,
 	if (err)
 		return err;
 
-	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
-			MLX5_FLOW_CONTEXT_ACTION_COUNT;
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 
 	return 0;
 }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred_nic.c +1 -2
index 16681cf6e93e..90b4c1b34776 100644
@@ -40,8 +40,7 @@ tc_act_parse_mirred_nic(struct mlx5e_tc_act_parse_state *parse_state,
 {
 	attr->parse_attr->mirred_ifindex[0] = act->dev->ifindex;
 	flow_flag_set(parse_state->flow, HAIRPIN);
-	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
-			MLX5_FLOW_CONTEXT_ACTION_COUNT;
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 
 	return 0;
 }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/redirect_ingress.c +1 -2
index 9dd244147385..ad09a8a5f36e 100644
@@ -58,8 +58,7 @@ tc_act_parse_redirect_ingress(struct mlx5e_tc_act_parse_state *parse_state,
 	struct net_device *out_dev = act->dev;
 	int err;
 
-	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
-			MLX5_FLOW_CONTEXT_ACTION_COUNT;
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 
 	err = mlx5e_set_fwd_to_int_port_actions(priv, attr, out_dev->ifindex,
 						MLX5E_TC_INT_PORT_INGRESS,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c +1 -2
index 9ea293fdc434..a7d9eab19e4a 100644
@@ -26,8 +26,7 @@ tc_act_parse_trap(struct mlx5e_tc_act_parse_state *parse_state,
 		  struct mlx5e_priv *priv,
 		  struct mlx5_flow_attr *attr)
 {
-	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
-			MLX5_FLOW_CONTEXT_ACTION_COUNT;
+	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 	attr->flags |= MLX5_ATTR_FLAG_SLOW_PATH;
 
 	return 0;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -1
index b9d6a2e8b240..76a015dfc5fc 100644
@@ -3536,7 +3536,6 @@ alloc_flow_post_acts(struct mlx5e_tc_flow *flow, struct netlink_ext_ack *extack)
 			/* Set counter action on last post act rule. */
 			attr->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT;
 		} else {
-			attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_COUNT;
 			err = mlx5e_tc_act_set_next_post_act(flow, attr, next_attr);
 			if (err)
 				goto out_free;
Signature · 1 line
2.34.1
#2 lore raw

Re: [net-next 01/15] net/mlx5e: Fix spelling mistake "supoported" -> "supported"

In reply to Saeed Mahameed
This series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:

Quoted 11 lines · On Wed, 16 Feb 2022 23:56:18 -0800 you wrote:

From: Colin Ian King <[email protected]>

There is a spelling mistake in a NL_SET_ERR_MSG_MOD error message. Fix it.

Fixes 3b49a7edec1d ("net/mlx5e: TC, Reject rules with multiple CT actions")

[...]

Here is the summary with links:
- [net-next,01/15] net/mlx5e: Fix spelling mistake "supoported" -> "supported"

    https://git.kernel.org/netdev/net-next/c/9625bf39bd41
  - [net-next,02/15] net/mlx5e: Add support for using xdp->data_meta
    https://git.kernel.org/netdev/net-next/c/c1e80bf4ad3e
  - [net-next,03/15] net/mlx5e: Generalize packet merge error message
    https://git.kernel.org/netdev/net-next/c/b98d2d722f81
  - [net-next,04/15] net/mlx5e: Default to Striding RQ when not conflicting with CQE compression
    https://git.kernel.org/netdev/net-next/c/1d5024f88dad
  - [net-next,05/15] net/mlx5e: RX, Restrict bulk size for small Striding RQs
    https://git.kernel.org/netdev/net-next/c/4b5fba4a3ac7
  - [net-next,06/15] net/mlx5e: E-Switch, Add PTP counters for uplink representor
    https://git.kernel.org/netdev/net-next/c/7c5f940d264e
  - [net-next,07/15] net/mlx5e: E-Switch, Add support for tx_port_ts in switchdev mode
    https://git.kernel.org/netdev/net-next/c/bfbdd77ac52f
  - [net-next,08/15] net/mlx5e: TC, Move flow hashtable to be per rep
    https://git.kernel.org/netdev/net-next/c/d1a3138f7913
  - [net-next,09/15] net/mlx5e: Pass actions param to actions_match_supported()
    https://git.kernel.org/netdev/net-next/c/0610f8dc0309
  - [net-next,10/15] net/mlx5e: Add post act offload/unoffload API
    https://git.kernel.org/netdev/net-next/c/314e1105831b
  - [net-next,11/15] net/mlx5e: Create new flow attr for multi table actions
    https://git.kernel.org/netdev/net-next/c/8300f225268b
  - [net-next,12/15] net/mlx5e: Use multi table support for CT and sample actions
    https://git.kernel.org/netdev/net-next/c/a81283263bb0
  - [net-next,13/15] net/mlx5e: TC, Clean redundant counter flag from tc action parsers
    https://git.kernel.org/netdev/net-next/c/2a829fe25d28
  - [net-next,14/15] net/mlx5e: TC, Make post_act parse CT and sample actions
    https://git.kernel.org/netdev/net-next/c/7843bd604081
  - [net-next,15/15] net/mlx5e: TC, Allow sample action with CT
    https://git.kernel.org/netdev/net-next/c/b070e70381ee

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html