Skip to contentSkip to conversation

Mellanox, mlx5 fixes 2020-02-18

GIT PULL New Saeed Mahameed 2 participants 9 messages Feb 19, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Hi Dave,

This series introduces some fixes to mlx5 driver.

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

For -stable v5.3
('net/mlx5: Fix sleep while atomic in mlx5_eswitch_get_vepa')

For -stable v5.4
('net/mlx5: DR, Fix matching on vport gvmi') ('net/mlx5e: Fix crash in recovery flow without devlink reporter')

For -stable v5.5
('net/mlx5e: Reset RQ doorbell counter before moving RQ state from RST to RDY') ('net/mlx5e: Don't clear the whole vf config when switching modes')

Thanks,
Saeed.

---
The following changes since commit 9facfdb5467382a21fc0bd4211ced26c06f28832:

netlabel_domainhash.c: Use built-in RCU list checking (2020-02-18 12:44:23 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2020-02-18

for you to fetch changes up to 13a7e459a41a56d788ab33d825c6205379bbb711:

net/mlx5: DR, Handle reformat capability over sw-steering tables (2020-02-18 19:01:20 -0800)

----------------------------------------------------------------
mlx5-fixes-2020-02-18

----------------------------------------------------------------
Aya Levin (2):
net/mlx5e: Reset RQ doorbell counter before moving RQ state from RST to RDY net/mlx5e: Fix crash in recovery flow without devlink reporter

Dmytro Linkin (1):
net/mlx5e: Don't clear the whole vf config when switching modes

Erez Shitrit (1):
net/mlx5: DR, Handle reformat capability over sw-steering tables

Hamdan Igbaria (1):
net/mlx5: DR, Fix matching on vport gvmi

Huy Nguyen (1):
net/mlx5: Fix sleep while atomic in mlx5_eswitch_get_vepa

Paul Blakey (1):
net/mlx5: Fix lowest FDB pool size

 .../net/ethernet/mellanox/mlx5/core/en/health.c    |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h  |  8 +++++
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  3 ++
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  | 20 +++++------
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c |  4 +--
 .../mellanox/mlx5/core/eswitch_offloads_chains.c   |  2 +-
 .../ethernet/mellanox/mlx5/core/steering/dr_ste.c  |  5 ++-
 .../ethernet/mellanox/mlx5/core/steering/fs_dr.c   |  9 +++--
 drivers/net/ethernet/mellanox/mlx5/core/wq.c       | 39 +++++++++++++++++-----
 drivers/net/ethernet/mellanox/mlx5/core/wq.h       |  2 ++
 include/linux/mlx5/mlx5_ifc.h                      |  5 ++-
 11 files changed, 70 insertions(+), 29 deletions(-)
#1 lore raw

PATCH 1/7 net/mlx5: Fix sleep while atomic in mlx5_eswitch_get_vepa

From: Huy Nguyen <[email protected]>

rtnl_bridge_getlink is protected by rcu lock, so mlx5_eswitch_get_vepa cannot take mutex lock. Two possible issues can happen:
1. User at the same time change vepa mode via RTM_SETLINK command.
2. User at the same time change the switchdev mode via devlink netlink interface.

Case 1 cannot happen because rtnl executes one message in order. Case 2 can happen but we do not expect user to change the switchdev mode when changing vepa. Even if a user does it, so he will read a value which is no longer valid.

Fixes 8da202b24913 ("net/mlx5: E-Switch, Add support for VEPA in legacy mode.")
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +3 -11
index 5acf60b1bbfe..564d42605892 100644
@@ -2452,25 +2452,17 @@ int mlx5_eswitch_set_vepa(struct mlx5_eswitch *esw, u8 setting)
 
 int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting)
 {
-	int err = 0;
-
 	if (!esw)
 		return -EOPNOTSUPP;
 
 	if (!ESW_ALLOWED(esw))
 		return -EPERM;
 
-	mutex_lock(&esw->state_lock);
-	if (esw->mode != MLX5_ESWITCH_LEGACY) {
-		err = -EOPNOTSUPP;
-		goto out;
-	}
+	if (esw->mode != MLX5_ESWITCH_LEGACY)
+		return -EOPNOTSUPP;
 
 	*setting = esw->fdb_table.legacy.vepa_uplink_rule ? 1 : 0;
-
-out:
-	mutex_unlock(&esw->state_lock);
-	return err;
+	return 0;
 }
 
 int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
Signature · 1 line
2.24.1
#2 lore raw

PATCH 2/7 net/mlx5e: Reset RQ doorbell counter before moving RQ state from RST to RDY

In reply to Saeed Mahameed

From: Aya Levin <[email protected]>

Initialize RQ doorbell counters to zero prior to moving an RQ from RST to RDY state. Per HW spec, when RQ is back to RDY state, the descriptor ID on the completion is reset. The doorbell record must comply.

Fixes 8276ea1353a4 ("net/mlx5e: Report and recover from CQE with error on RQ")
---
 .../net/ethernet/mellanox/mlx5/core/en/txrx.h |  8 ++++
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  3 ++
 drivers/net/ethernet/mellanox/mlx5/core/wq.c  | 39 ++++++++++++++-----
 drivers/net/ethernet/mellanox/mlx5/core/wq.h  |  2 +
 4 files changed, 43 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +8 -0
index 7c8796d9743f..a226277b0980 100644
@@ -179,6 +179,14 @@ mlx5e_tx_dma_unmap(struct device *pdev, struct mlx5e_sq_dma *dma)
 	}
 }
 
+static inline void mlx5e_rqwq_reset(struct mlx5e_rq *rq)
+{
+	if (rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
+		mlx5_wq_ll_reset(&rq->mpwqe.wq);
+	else
+		mlx5_wq_cyc_reset(&rq->wqe.wq);
+}
+
 /* SW parser related functions */
 
 struct mlx5e_swp_spec {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -0
index 454d3459bd8b..966983674663 100644
@@ -712,6 +712,9 @@ int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state, int next_state)
 	if (!in)
 		return -ENOMEM;
 
+	if (curr_state == MLX5_RQC_STATE_RST && next_state == MLX5_RQC_STATE_RDY)
+		mlx5e_rqwq_reset(rq);
+
 	rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
 
 	MLX5_SET(modify_rq_in, in, rq_state, curr_state);
drivers/net/ethernet/mellanox/mlx5/core/wq.c +30 -9
index 02f7e4a39578..01f075fac276 100644
@@ -94,6 +94,13 @@ void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides)
 	print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, wqe, len, false);
 }
 
+void mlx5_wq_cyc_reset(struct mlx5_wq_cyc *wq)
+{
+	wq->wqe_ctr = 0;
+	wq->cur_sz = 0;
+	mlx5_wq_cyc_update_db_record(wq);
+}
+
 int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 		      void *qpc, struct mlx5_wq_qp *wq,
 		      struct mlx5_wq_ctrl *wq_ctrl)
@@ -192,6 +199,19 @@ int mlx5_cqwq_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 	return err;
 }
 
+static void mlx5_wq_ll_init_list(struct mlx5_wq_ll *wq)
+{
+	struct mlx5_wqe_srq_next_seg *next_seg;
+	int i;
+
+	for (i = 0; i < wq->fbc.sz_m1; i++) {
+		next_seg = mlx5_wq_ll_get_wqe(wq, i);
+		next_seg->next_wqe_index = cpu_to_be16(i + 1);
+	}
+	next_seg = mlx5_wq_ll_get_wqe(wq, i);
+	wq->tail_next = &next_seg->next_wqe_index;
+}
+
 int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 		      void *wqc, struct mlx5_wq_ll *wq,
 		      struct mlx5_wq_ctrl *wq_ctrl)
@@ -199,9 +219,7 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 	u8 log_wq_stride = MLX5_GET(wq, wqc, log_wq_stride);
 	u8 log_wq_sz     = MLX5_GET(wq, wqc, log_wq_sz);
 	struct mlx5_frag_buf_ctrl *fbc = &wq->fbc;
-	struct mlx5_wqe_srq_next_seg *next_seg;
 	int err;
-	int i;
 
 	err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);
 	if (err) {
@@ -220,13 +238,7 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 
 	mlx5_init_fbc(wq_ctrl->buf.frags, log_wq_stride, log_wq_sz, fbc);
 
-	for (i = 0; i < fbc->sz_m1; i++) {
-		next_seg = mlx5_wq_ll_get_wqe(wq, i);
-		next_seg->next_wqe_index = cpu_to_be16(i + 1);
-	}
-	next_seg = mlx5_wq_ll_get_wqe(wq, i);
-	wq->tail_next = &next_seg->next_wqe_index;
-
+	mlx5_wq_ll_init_list(wq);
 	wq_ctrl->mdev = mdev;
 
 	return 0;
@@ -237,6 +249,15 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 	return err;
 }
 
+void mlx5_wq_ll_reset(struct mlx5_wq_ll *wq)
+{
+	wq->head = 0;
+	wq->wqe_ctr = 0;
+	wq->cur_sz = 0;
+	mlx5_wq_ll_init_list(wq);
+	mlx5_wq_ll_update_db_record(wq);
+}
+
 void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl)
 {
 	mlx5_frag_buf_free(wq_ctrl->mdev, &wq_ctrl->buf);
drivers/net/ethernet/mellanox/mlx5/core/wq.h +2 -0
index d9a94bc223c0..4cadc336593f 100644
@@ -80,6 +80,7 @@ int mlx5_wq_cyc_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 		       void *wqc, struct mlx5_wq_cyc *wq,
 		       struct mlx5_wq_ctrl *wq_ctrl);
 void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides);
+void mlx5_wq_cyc_reset(struct mlx5_wq_cyc *wq);
 
 int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 		      void *qpc, struct mlx5_wq_qp *wq,
@@ -92,6 +93,7 @@ int mlx5_cqwq_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
 		      void *wqc, struct mlx5_wq_ll *wq,
 		      struct mlx5_wq_ctrl *wq_ctrl);
+void mlx5_wq_ll_reset(struct mlx5_wq_ll *wq);
 
 void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl);
 
Signature · 1 line
2.24.1
#3 lore raw

PATCH 3/7 net/mlx5e: Fix crash in recovery flow without devlink reporter

In reply to Saeed Mahameed

From: Aya Levin <[email protected]>

When health reporters are not supported, recovery function is invoked directly, not via devlink health reporters.

In this direct flow, the recover function input parameter was passed incorrectly and is causing a kernel oops. This patch is fixing the input parameter.

Following call trace is observed on rx error health reporting.

Internal error: Oops: 96000007 [#1] PREEMPT SMP
Process kworker/u16:4 (pid: 4584, stack limit = 0x00000000c9e45703)
Call trace:
mlx5e_rx_reporter_err_rq_cqe_recover+0x30/0x164 [mlx5_core]
mlx5e_health_report+0x60/0x6c [mlx5_core]
mlx5e_reporter_rq_cqe_err+0x6c/0x90 [mlx5_core]
mlx5e_rq_err_cqe_work+0x20/0x2c [mlx5_core]
process_one_work+0x168/0x3d0
worker_thread+0x58/0x3d0
kthread+0x108/0x134
Fixes c50de4af1d63 ("net/mlx5e: Generalize tx reporter's functionality")
---
 drivers/net/ethernet/mellanox/mlx5/core/en/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/health.c +1 -1
index 3a975641f902..20b907dc1e29 100644
@@ -200,7 +200,7 @@ int mlx5e_health_report(struct mlx5e_priv *priv,
 	netdev_err(priv->netdev, err_str);
 
 	if (!reporter)
-		return err_ctx->recover(&err_ctx->ctx);
+		return err_ctx->recover(err_ctx->ctx);
 
 	return devlink_health_report(reporter, err_str, err_ctx);
 }
Signature · 1 line
2.24.1
#4 lore raw

PATCH 4/7 net/mlx5: DR, Fix matching on vport gvmi

In reply to Saeed Mahameed

From: Hamdan Igbaria <[email protected]>

Set vport gvmi in the tag, only when source gvmi is set in the bit mask.

Fixes 26d688e3 ("net/mlx5: DR, Add Steering entry (STE) utilities")
---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c +4 -1
index c6c7d1defbd7..aade62a9ee5c 100644
@@ -2307,7 +2307,9 @@ static int dr_ste_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
 	struct mlx5dr_cmd_vport_cap *vport_cap;
 	struct mlx5dr_domain *dmn = sb->dmn;
 	struct mlx5dr_cmd_caps *caps;
+	u8 *bit_mask = sb->bit_mask;
 	u8 *tag = hw_ste->tag;
+	bool source_gvmi_set;
 
 	DR_STE_SET_TAG(src_gvmi_qp, tag, source_qp, misc, source_sqn);
 
@@ -2328,7 +2330,8 @@ static int dr_ste_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
 	if (!vport_cap)
 		return -EINVAL;
 
-	if (vport_cap->vport_gvmi)
+	source_gvmi_set = MLX5_GET(ste_src_gvmi_qp, bit_mask, source_gvmi);
+	if (vport_cap->vport_gvmi && source_gvmi_set)
 		MLX5_SET(ste_src_gvmi_qp, tag, source_gvmi, vport_cap->vport_gvmi);
 
 	misc->source_eswitch_owner_vhca_id = 0;
Signature · 1 line
2.24.1
#5 lore raw

PATCH 5/7 net/mlx5e: Don't clear the whole vf config when switching modes

In reply to Saeed Mahameed

From: Dmytro Linkin <[email protected]>

There is no need to reset all vf config (except link state) between legacy and switchdev modes changes.
Also, set link state to AUTO, when legacy enabled.

Fixes 3b83b6c2e024 ("net/mlx5e: Clear VF config when switching modes")
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c          | 6 +++++-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +5 -1
index 564d42605892..e49acd0c5da5 100644
@@ -459,12 +459,16 @@ static void esw_destroy_legacy_table(struct mlx5_eswitch *esw)
 
 static int esw_legacy_enable(struct mlx5_eswitch *esw)
 {
-	int ret;
+	struct mlx5_vport *vport;
+	int ret, i;
 
 	ret = esw_create_legacy_table(esw);
 	if (ret)
 		return ret;
 
+	mlx5_esw_for_each_vf_vport(esw, i, vport, esw->esw_funcs.num_vfs)
+		vport->info.link_state = MLX5_VPORT_ADMIN_STATE_AUTO;
+
 	ret = mlx5_eswitch_enable_pf_vf_vports(esw, MLX5_LEGACY_SRIOV_VPORT_EVENTS);
 	if (ret)
 		esw_destroy_legacy_table(esw);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -2
index 979f13bdc203..1a57b2bd74b8 100644
@@ -1172,7 +1172,7 @@ static int esw_offloads_start(struct mlx5_eswitch *esw,
 		return -EINVAL;
 	}
 
-	mlx5_eswitch_disable(esw, true);
+	mlx5_eswitch_disable(esw, false);
 	mlx5_eswitch_update_num_of_vfs(esw, esw->dev->priv.sriov.num_vfs);
 	err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_OFFLOADS);
 	if (err) {
@@ -2065,7 +2065,7 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw,
 {
 	int err, err1;
 
-	mlx5_eswitch_disable(esw, true);
+	mlx5_eswitch_disable(esw, false);
 	err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_LEGACY);
 	if (err) {
 		NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");
Signature · 1 line
2.24.1
#6 lore raw

PATCH 6/7 net/mlx5: Fix lowest FDB pool size

In reply to Saeed Mahameed

From: Paul Blakey <[email protected]>

The pool sizes represent the pool sizes in the fw. when we request a pool size from fw, it will return the next possible group. We track how many pools the fw has left and start requesting groups from the big to the small.
When we start request 4k group, which doesn't exists in fw, fw wants to allocate the next possible size, 64k, but will fail since its exhausted. The correct smallest pool size in fw is 128 and not 4k.

Fixes 39ac237ce009 ("net/mlx5: E-Switch, Refactor chains and priorities")
---
 .../net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c +1 -1
index c5a446e295aa..4276194b633f 100644
@@ -35,7 +35,7 @@
 static const unsigned int ESW_POOLS[] = { 4 * 1024 * 1024,
 					  1 * 1024 * 1024,
 					  64 * 1024,
-					  4 * 1024, };
+					  128 };
 
 struct mlx5_esw_chains_priv {
 	struct rhashtable chains_ht;
Signature · 1 line
2.24.1
#7 lore raw

PATCH 7/7 net/mlx5: DR, Handle reformat capability over sw-steering tables

In reply to Saeed Mahameed

From: Erez Shitrit <[email protected]>

On flow table creation, send the relevant flags according to what the FW currently supports.
When FW doesn't support reformat option over SW-steering managed table, the driver shouldn't pass this.

Fixes 988fd6b32d07 ("net/mlx5: DR, Pass table flags at creation to lower layer")
---
 drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c | 9 +++++++--
 include/linux/mlx5/mlx5_ifc.h                            | 5 ++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +7 -2
index 3abfc8125926..c2027192e21e 100644
@@ -66,15 +66,20 @@ static int mlx5_cmd_dr_create_flow_table(struct mlx5_flow_root_namespace *ns,
 					 struct mlx5_flow_table *next_ft)
 {
 	struct mlx5dr_table *tbl;
+	u32 flags;
 	int err;
 
 	if (mlx5_dr_is_fw_table(ft->flags))
 		return mlx5_fs_cmd_get_fw_cmds()->create_flow_table(ns, ft,
 								    log_size,
 								    next_ft);
+	flags = ft->flags;
+	/* turn off encap/decap if not supported for sw-str by fw */
+	if (!MLX5_CAP_FLOWTABLE(ns->dev, sw_owner_reformat_supported))
+		flags = ft->flags & ~(MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |
+				      MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
 
-	tbl = mlx5dr_table_create(ns->fs_dr_domain.dr_domain,
-				  ft->level, ft->flags);
+	tbl = mlx5dr_table_create(ns->fs_dr_domain.dr_domain, ft->level, flags);
 	if (!tbl) {
 		mlx5_core_err(ns->dev, "Failed creating dr flow_table\n");
 		return -EINVAL;
include/linux/mlx5/mlx5_ifc.h +4 -1
index ff8c9d527bb4..bfdf41537cf1 100644
@@ -688,7 +688,10 @@ struct mlx5_ifc_flow_table_nic_cap_bits {
 	u8         nic_rx_multi_path_tirs[0x1];
 	u8         nic_rx_multi_path_tirs_fts[0x1];
 	u8         allow_sniffer_and_nic_rx_shared_tir[0x1];
-	u8	   reserved_at_3[0x1d];
+	u8	   reserved_at_3[0x4];
+	u8	   sw_owner_reformat_supported[0x1];
+	u8	   reserved_at_8[0x18];
+
 	u8	   encap_general_header[0x1];
 	u8	   reserved_at_21[0xa];
 	u8	   log_max_packet_reformat_context[0x5];
Signature · 1 line
2.24.1
maintainer
#8 lore raw
In reply to Saeed Mahameed

From: Saeed Mahameed <[email protected]>
Date: Wed, 19 Feb 2020 03:06:20 +0000

Quoted 3 lines

This series introduces some fixes to mlx5 driver.

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

Pulled.

Quoted 10 lines

For -stable v5.3
('net/mlx5: Fix sleep while atomic in mlx5_eswitch_get_vepa')

For -stable v5.4
('net/mlx5: DR, Fix matching on vport gvmi') ('net/mlx5e: Fix crash in recovery flow without devlink reporter')

For -stable v5.5
('net/mlx5e: Reset RQ doorbell counter before moving RQ state from RST to RDY') ('net/mlx5e: Don't clear the whole vf config when switching modes')

Queued up.

Thank you.