All of lore.kernel.org
 help / color / mirror / Atom feed
* [pull request][net V2 00/11] mlx5 fixes-2020-07-28
@ 2020-07-28 19:59 Saeed Mahameed
  2020-07-28 19:59 ` [net V2 01/11] net/mlx5: E-switch, Destroy TSAR when fail to enable the mode Saeed Mahameed
                   ` (12 more replies)
  0 siblings, 13 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski; +Cc: netdev, Saeed Mahameed

Hi Dave,

This series introduces some fixes to mlx5 driver.
v1->v2:
 - Drop the "Hold reference on mirred devices" patch, until Or's
   comments are addressed.
 - Imporve "Modify uplink state" patch commit message per Or's request.

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

For -Stable:

For -stable v4.9
 ('net/mlx5e: Fix error path of device attach')

For -stable v4.15
 ('net/mlx5: Verify Hardware supports requested ptp function on a given
pin')

For -stable v5.3
 ('net/mlx5e: Modify uplink state on interface up/down')

For -stable v5.4
 ('net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev')
 ('net/mlx5: E-switch, Destroy TSAR when fail to enable the mode')

For -stable v5.5
 ('net/mlx5: E-switch, Destroy TSAR after reload interface')

For -stable v5.7
 ('net/mlx5: Fix a bug of using ptp channel index as pin index')


Thanks,
Saeed.

---
The following changes since commit 181964e619b76ae2e71bcdc6001cf977bec4cf6e:

  fix a braino in cmsghdr_from_user_compat_to_kern() (2020-07-27 13:25:39 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2020-07-28

for you to fetch changes up to 350a63249d270b1f5bd05c7e2a24cd8de0f9db20:

  net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev (2020-07-28 12:55:53 -0700)

----------------------------------------------------------------
mlx5-fixes-2020-07-28

----------------------------------------------------------------
Alaa Hleihel (1):
      net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev

Aya Levin (1):
      net/mlx5e: Fix error path of device attach

Eran Ben Elisha (3):
      net/mlx5: Fix a bug of using ptp channel index as pin index
      net/mlx5: Verify Hardware supports requested ptp function on a given pin
      net/mlx5: Query PPS pin operational status before registering it

Maor Dickman (1):
      net/mlx5e: Fix missing cleanup of ethtool steering during rep rx cleanup

Maor Gottlieb (1):
      net/mlx5: Fix forward to next namespace

Parav Pandit (2):
      net/mlx5: E-switch, Destroy TSAR when fail to enable the mode
      net/mlx5: E-switch, Destroy TSAR after reload interface

Raed Salem (1):
      net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev

Ron Diskin (1):
      net/mlx5e: Modify uplink state on interface up/down

 .../net/ethernet/mellanox/mlx5/core/en/rep/bond.c  |  7 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  | 27 +++++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   |  3 +
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  | 27 +++++---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  |  2 +
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c  | 28 ++------
 .../net/ethernet/mellanox/mlx5/core/lib/clock.c    | 78 ++++++++++++++++++----
 include/linux/mlx5/mlx5_ifc.h                      |  1 +
 8 files changed, 121 insertions(+), 52 deletions(-)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [net V2 01/11] net/mlx5: E-switch, Destroy TSAR when fail to enable the mode
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 02/11] net/mlx5: E-switch, Destroy TSAR after reload interface Saeed Mahameed
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Parav Pandit, Roi Dayan, Saeed Mahameed

From: Parav Pandit <parav@mellanox.com>

When either esw_legacy_enable() or esw_offloads_enable() fails,
code missed to destroy the created TSAR.

Hence, add the missing call to destroy the TSAR.

Fixes: 610090ebce92 ("net/mlx5: E-switch, Initialize TSAR Qos hardware block before its user vports")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 1116ab9bea6c5..9701f0f8be50b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1608,7 +1608,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int mode, int num_vfs)
 		mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
 		mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
 	}
-
+	esw_destroy_tsar(esw);
 	return err;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 02/11] net/mlx5: E-switch, Destroy TSAR after reload interface
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
  2020-07-28 19:59 ` [net V2 01/11] net/mlx5: E-switch, Destroy TSAR when fail to enable the mode Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 03/11] net/mlx5: Fix forward to next namespace Saeed Mahameed
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Parav Pandit, Roi Dayan, Saeed Mahameed

From: Parav Pandit <parav@mellanox.com>

When eswitch offloads is enabled, TSAR is created before reloading
the interfaces.
However when eswitch offloads mode is disabled, TSAR is disabled before
reloading the interfaces.

To keep the eswitch enable/disable sequence as mirror, destroy TSAR
after reloading the interfaces.

Fixes: 1bd27b11c1df ("net/mlx5: Introduce E-switch QoS management")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 9701f0f8be50b..d9376627584e9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1653,8 +1653,6 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw, bool clear_vf)
 	else if (esw->mode == MLX5_ESWITCH_OFFLOADS)
 		esw_offloads_disable(esw);
 
-	esw_destroy_tsar(esw);
-
 	old_mode = esw->mode;
 	esw->mode = MLX5_ESWITCH_NONE;
 
@@ -1664,6 +1662,8 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw, bool clear_vf)
 		mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
 		mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
 	}
+	esw_destroy_tsar(esw);
+
 	if (clear_vf)
 		mlx5_eswitch_clear_vf_vports_info(esw);
 }
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 03/11] net/mlx5: Fix forward to next namespace
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
  2020-07-28 19:59 ` [net V2 01/11] net/mlx5: E-switch, Destroy TSAR when fail to enable the mode Saeed Mahameed
  2020-07-28 19:59 ` [net V2 02/11] net/mlx5: E-switch, Destroy TSAR after reload interface Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 04/11] net/mlx5e: Fix error path of device attach Saeed Mahameed
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Maor Gottlieb, Mark Bloch, Saeed Mahameed

From: Maor Gottlieb <maorg@mellanox.com>

The steering tree is as follow (nic RX as example):
		   ---------
                   |root_ns|
		   ---------
			|
      	--------------------------------
    	|		|	       |
   ---------- 	   ----------      ---------
   |p(prio)0|	   |   p1   |      |   pn  |
   ----------	   ----------	   ---------
        |		|
 ----------------  ---------------
 |ns(e.g bypass)|  |ns(e.g. lag) |
 ----------------  ---------------
  |     |    |
----  ----  ----
|p0|  |p1|  |pn|
----  ----  ----
 |
----
|FT|
----

find_next_chained_ft(prio) returns the first flow table in the next
priority. If prio is a parent of a flow table then it returns the first
flow table in the next priority in the same namespace, else if prio
is parent of namespace, then it should return the first flow table
in the next namespace. Currently if the user requests to forward to
next namespace, the code calls to find_next_chained_ft with the prio
of the next namespace and not the prio of the namesapce itself.

Fixes: 9254f8ed15b6 ("net/mlx5: Add support in forward to namespace")
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../net/ethernet/mellanox/mlx5/core/fs_core.c | 28 ++++---------------
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 13e2fb79c21ae..2569bb6228b65 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -797,7 +797,7 @@ static struct mlx5_flow_table *find_closest_ft_recursive(struct fs_node  *root,
 	return ft;
 }
 
-/* If reverse if false then return the first flow table in next priority of
+/* If reverse is false then return the first flow table in next priority of
  * prio in the tree, else return the last flow table in the previous priority
  * of prio in the tree.
  */
@@ -829,34 +829,16 @@ static struct mlx5_flow_table *find_prev_chained_ft(struct fs_prio *prio)
 	return find_closest_ft(prio, true);
 }
 
-static struct fs_prio *find_fwd_ns_prio(struct mlx5_flow_root_namespace *root,
-					struct mlx5_flow_namespace *ns)
-{
-	struct mlx5_flow_namespace *root_ns = &root->ns;
-	struct fs_prio *iter_prio;
-	struct fs_prio *prio;
-
-	fs_get_obj(prio, ns->node.parent);
-	list_for_each_entry(iter_prio, &root_ns->node.children, node.list) {
-		if (iter_prio == prio &&
-		    !list_is_last(&prio->node.children, &iter_prio->node.list))
-			return list_next_entry(iter_prio, node.list);
-	}
-	return NULL;
-}
-
 static struct mlx5_flow_table *find_next_fwd_ft(struct mlx5_flow_table *ft,
 						struct mlx5_flow_act *flow_act)
 {
-	struct mlx5_flow_root_namespace *root = find_root(&ft->node);
 	struct fs_prio *prio;
+	bool next_ns;
 
-	if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS)
-		prio = find_fwd_ns_prio(root, ft->ns);
-	else
-		fs_get_obj(prio, ft->node.parent);
+	next_ns = flow_act->action & MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS;
+	fs_get_obj(prio, next_ns ? ft->ns->node.parent : ft->node.parent);
 
-	return (prio) ? find_next_chained_ft(prio) : NULL;
+	return find_next_chained_ft(prio);
 }
 
 static int connect_fts_in_prio(struct mlx5_core_dev *dev,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 04/11] net/mlx5e: Fix error path of device attach
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (2 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 03/11] net/mlx5: Fix forward to next namespace Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 05/11] net/mlx5e: Fix missing cleanup of ethtool steering during rep rx cleanup Saeed Mahameed
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Aya Levin, Tariq Toukan, Saeed Mahameed

From: Aya Levin <ayal@mellanox.com>

On failure to attach the netdev, fix the rollback by re-setting the
device's state back to MLX5E_STATE_DESTROYING.

Failing to attach doesn't stop statistics polling via .ndo_get_stats64.
In this case, although the device is not attached, it falsely continues
to query the firmware for counters. Setting the device's state back to
MLX5E_STATE_DESTROYING prevents the firmware counters query.

Fixes: 26e59d8077a3 ("net/mlx5e: Implement mlx5e interface attach/detach callbacks")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 081f15074cac4..31f9ecae98df9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5390,6 +5390,8 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)
 	profile->cleanup_tx(priv);
 
 out:
+	set_bit(MLX5E_STATE_DESTROYING, &priv->state);
+	cancel_work_sync(&priv->update_stats_work);
 	return err;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 05/11] net/mlx5e: Fix missing cleanup of ethtool steering during rep rx cleanup
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (3 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 04/11] net/mlx5e: Fix error path of device attach Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 06/11] net/mlx5: Fix a bug of using ptp channel index as pin index Saeed Mahameed
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Maor Dickman, Roi Dayan, Vlad Buslov, Saeed Mahameed

From: Maor Dickman <maord@mellanox.com>

The cited commit add initialization of ethtool steering during
representor rx initializations without cleaning it up in representor
rx cleanup, this may cause for stale ethtool flows to remain after
moving back from switchdev mode to legacy mode.

Fixed by calling ethtool steering cleanup during rep rx cleanup.

Fixes: 6783e8b29f63 ("net/mlx5e: Init ethtool steering for representors")
Signed-off-by: Maor Dickman <maord@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 006807e04eda3..8c294ab43f908 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -936,6 +936,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
 
 static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
 {
+	mlx5e_ethtool_cleanup_steering(priv);
 	rep_vport_rx_rule_destroy(priv);
 	mlx5e_destroy_rep_root_ft(priv);
 	mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 06/11] net/mlx5: Fix a bug of using ptp channel index as pin index
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (4 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 05/11] net/mlx5e: Fix missing cleanup of ethtool steering during rep rx cleanup Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin Saeed Mahameed
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Eran Ben Elisha, Ariel Levkovich, Saeed Mahameed

From: Eran Ben Elisha <eranbe@mellanox.com>

On PTP mlx5_ptp_enable(on=0) flow, driver mistakenly used channel index
as pin index.

After ptp patch marked in fixes tag was introduced, driver can freely
call ptp_find_pin() as part of the .enable() callback.

Fix driver mlx5_ptp_enable(on=0) flow to always use ptp_find_pin(). With
that, Driver will use the correct pin index in mlx5_ptp_enable(on=0) flow.

In addition, when initializing the pins, always set channel to zero. As
all pins can be attached to all channels, let ptp_set_pinfunc() to move
them between the channels.

For stable branches, this fix to be applied only on kernels that includes
both patches in fixes tag. Otherwise, mlx5_ptp_enable(on=0) will be stuck
on pincfg_mux.

Fixes: 62582a7ee783 ("ptp: Avoid deadlocks in the programmable pin code.")
Fixes: ee7f12205abc ("net/mlx5e: Implement 1PPS support")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../ethernet/mellanox/mlx5/core/lib/clock.c   | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index ef0706d15a5b7..c6967e1a560b7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -273,17 +273,17 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp,
 	if (rq->extts.index >= clock->ptp_info.n_pins)
 		return -EINVAL;
 
+	pin = ptp_find_pin(clock->ptp, PTP_PF_EXTTS, rq->extts.index);
+	if (pin < 0)
+		return -EBUSY;
+
 	if (on) {
-		pin = ptp_find_pin(clock->ptp, PTP_PF_EXTTS, rq->extts.index);
-		if (pin < 0)
-			return -EBUSY;
 		pin_mode = MLX5_PIN_MODE_IN;
 		pattern = !!(rq->extts.flags & PTP_FALLING_EDGE);
 		field_select = MLX5_MTPPS_FS_PIN_MODE |
 			       MLX5_MTPPS_FS_PATTERN |
 			       MLX5_MTPPS_FS_ENABLE;
 	} else {
-		pin = rq->extts.index;
 		field_select = MLX5_MTPPS_FS_ENABLE;
 	}
 
@@ -331,12 +331,12 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
 	if (rq->perout.index >= clock->ptp_info.n_pins)
 		return -EINVAL;
 
-	if (on) {
-		pin = ptp_find_pin(clock->ptp, PTP_PF_PEROUT,
-				   rq->perout.index);
-		if (pin < 0)
-			return -EBUSY;
+	pin = ptp_find_pin(clock->ptp, PTP_PF_PEROUT,
+			   rq->perout.index);
+	if (pin < 0)
+		return -EBUSY;
 
+	if (on) {
 		pin_mode = MLX5_PIN_MODE_OUT;
 		pattern = MLX5_OUT_PATTERN_PERIODIC;
 		ts.tv_sec = rq->perout.period.sec;
@@ -362,7 +362,6 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
 			       MLX5_MTPPS_FS_ENABLE |
 			       MLX5_MTPPS_FS_TIME_STAMP;
 	} else {
-		pin = rq->perout.index;
 		field_select = MLX5_MTPPS_FS_ENABLE;
 	}
 
@@ -452,7 +451,7 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock)
 			 "mlx5_pps%d", i);
 		clock->ptp_info.pin_config[i].index = i;
 		clock->ptp_info.pin_config[i].func = PTP_PF_NONE;
-		clock->ptp_info.pin_config[i].chan = i;
+		clock->ptp_info.pin_config[i].chan = 0;
 	}
 
 	return 0;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (5 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 06/11] net/mlx5: Fix a bug of using ptp channel index as pin index Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 20:20   ` Jakub Kicinski
  2020-07-28 19:59 ` [net V2 08/11] net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev Saeed Mahameed
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Eran Ben Elisha, Ariel Levkovich, Saeed Mahameed

From: Eran Ben Elisha <eranbe@mellanox.com>

Fix a bug where driver did not verify Hardware pin capabilities for
PTP functions.

Fixes: ee7f12205abc ("net/mlx5e: Implement 1PPS support")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../ethernet/mellanox/mlx5/core/lib/clock.c   | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index c6967e1a560b7..284806e331bd8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -408,10 +408,31 @@ static int mlx5_ptp_enable(struct ptp_clock_info *ptp,
 	return 0;
 }
 
+enum {
+	MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN = BIT(0),
+	MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT = BIT(1),
+};
+
 static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
 			   enum ptp_pin_function func, unsigned int chan)
 {
-	return (func == PTP_PF_PHYSYNC) ? -EOPNOTSUPP : 0;
+	struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock,
+						ptp_info);
+
+	switch (func) {
+	case PTP_PF_NONE:
+		return 0;
+	case PTP_PF_EXTTS:
+		return !(clock->pps_info.pin_caps[pin] &
+			 MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN);
+	case PTP_PF_PEROUT:
+		return !(clock->pps_info.pin_caps[pin] &
+			 MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT);
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return -EOPNOTSUPP;
 }
 
 static const struct ptp_clock_info mlx5_ptp_clock_info = {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 08/11] net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (6 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 09/11] net/mlx5: Query PPS pin operational status before registering it Saeed Mahameed
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Raed Salem, Roi Dayan, Vu Pham, Saeed Mahameed

From: Raed Salem <raeds@mellanox.com>

mlx5e_rep_is_lag_netdev is used as first check as part of netdev events
handler for bond device of non-uplink representors, this handler can get
any netdevice under the same network namespace of mlx5e netdevice. Current
code treats the netdev as mlx5e netdev and only later on verifies this,
hence causes the following Kasan trace:
[15402.744990] ==================================================================
[15402.746942] BUG: KASAN: slab-out-of-bounds in mlx5e_rep_is_lag_netdev+0xcb/0xf0 [mlx5_core]
[15402.749009] Read of size 8 at addr ffff880391f3f6b0 by task ovs-vswitchd/5347

[15402.752065] CPU: 7 PID: 5347 Comm: ovs-vswitchd Kdump: loaded Tainted: G    B      O     --------- -t - 4.18.0-g3dcc204d291d-dirty #1
[15402.755349] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
[15402.757600] Call Trace:
[15402.758968]  dump_stack+0x71/0xab
[15402.760427]  print_address_description+0x6a/0x270
[15402.761969]  kasan_report+0x179/0x2d0
[15402.763445]  ? mlx5e_rep_is_lag_netdev+0xcb/0xf0 [mlx5_core]
[15402.765121]  mlx5e_rep_is_lag_netdev+0xcb/0xf0 [mlx5_core]
[15402.766782]  mlx5e_rep_esw_bond_netevent+0x129/0x620 [mlx5_core]

Fix by deferring the violating access to be post the netdev verify check.

Fixes: 7e51891a237f ("net/mlx5e: Use netdev events to set/del egress acl forward-to-vport rule")
Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Vu Pham <vuhuong@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c
index bdb71332cbf2d..3e44e4d820c51 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c
@@ -183,13 +183,16 @@ void mlx5e_rep_bond_unslave(struct mlx5_eswitch *esw,
 
 static bool mlx5e_rep_is_lag_netdev(struct net_device *netdev)
 {
-	struct mlx5e_priv *priv = netdev_priv(netdev);
-	struct mlx5e_rep_priv *rpriv = priv->ppriv;
+	struct mlx5e_rep_priv *rpriv;
+	struct mlx5e_priv *priv;
 
 	/* A given netdev is not a representor or not a slave of LAG configuration */
 	if (!mlx5e_eswitch_rep(netdev) || !bond_slave_get_rtnl(netdev))
 		return false;
 
+	priv = netdev_priv(netdev);
+	rpriv = priv->ppriv;
+
 	/* Egress acl forward to vport is supported only non-uplink representor */
 	return rpriv->rep->vport != MLX5_VPORT_UPLINK;
 }
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 09/11] net/mlx5: Query PPS pin operational status before registering it
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (7 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 08/11] net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 19:59 ` [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down Saeed Mahameed
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski; +Cc: netdev, Eran Ben Elisha, Saeed Mahameed

From: Eran Ben Elisha <eranbe@mellanox.com>

In a special configuration, a ConnectX6-Dx pin pps-out might be activated
when driver is loaded. Fix the driver to always read the operational pin
mode when registering it, and advertise it accordingly.

Fixes: ee7f12205abc ("net/mlx5e: Implement 1PPS support")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../ethernet/mellanox/mlx5/core/lib/clock.c   | 34 ++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index 284806e331bd8..2d55b7c22c034 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -452,6 +452,38 @@ static const struct ptp_clock_info mlx5_ptp_clock_info = {
 	.verify		= NULL,
 };
 
+static int mlx5_query_mtpps_pin_mode(struct mlx5_core_dev *mdev, u8 pin,
+				     u32 *mtpps, u32 mtpps_size)
+{
+	u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {};
+
+	MLX5_SET(mtpps_reg, in, pin, pin);
+
+	return mlx5_core_access_reg(mdev, in, sizeof(in), mtpps,
+				    mtpps_size, MLX5_REG_MTPPS, 0, 0);
+}
+
+static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
+{
+	struct mlx5_core_dev *mdev = clock->mdev;
+	u32 out[MLX5_ST_SZ_DW(mtpps_reg)] = {};
+	u8 mode;
+	int err;
+
+	err = mlx5_query_mtpps_pin_mode(mdev, pin, out, sizeof(out));
+	if (err || !MLX5_GET(mtpps_reg, out, enable))
+		return PTP_PF_NONE;
+
+	mode = MLX5_GET(mtpps_reg, out, pin_mode);
+
+	if (mode == MLX5_PIN_MODE_IN)
+		return PTP_PF_EXTTS;
+	else if (mode == MLX5_PIN_MODE_OUT)
+		return PTP_PF_PEROUT;
+
+	return PTP_PF_NONE;
+}
+
 static int mlx5_init_pin_config(struct mlx5_clock *clock)
 {
 	int i;
@@ -471,7 +503,7 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock)
 			 sizeof(clock->ptp_info.pin_config[i].name),
 			 "mlx5_pps%d", i);
 		clock->ptp_info.pin_config[i].index = i;
-		clock->ptp_info.pin_config[i].func = PTP_PF_NONE;
+		clock->ptp_info.pin_config[i].func = mlx5_get_pps_pin_mode(clock, i);
 		clock->ptp_info.pin_config[i].chan = 0;
 	}
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (8 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 09/11] net/mlx5: Query PPS pin operational status before registering it Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-29  6:17   ` Or Gerlitz
  2020-07-28 19:59 ` [net V2 11/11] net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev Saeed Mahameed
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Ron Diskin, Roi Dayan, Moshe Shemesh, Saeed Mahameed

From: Ron Diskin <rondi@mellanox.com>

When setting the PF interface up/down, notify the firmware to update
uplink state via MODIFY_VPORT_STATE, when E-Switch is enabled.

This behavior will prevent sending traffic out on uplink port when PF is
down, such as sending traffic from a VF interface which is still up.
Currently when calling mlx5e_open/close(), the driver only sends PAOS
command to notify the firmware to set the physical port state to
up/down, however, it is not sufficient. When VF is in "auto" state, it
follows the uplink state, which was not updated on mlx5e_open/close()
before this patch.

When switchdev mode is enabled and uplink representor is first enabled,
set the uplink port state value back to its FW default "AUTO".

Fixes: 63bfd399de55 ("net/mlx5e: Send PAOS command on interface up/down")
Signed-off-by: Ron Diskin <rondi@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 25 ++++++++++++++++---
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  |  2 ++
 .../net/ethernet/mellanox/mlx5/core/eswitch.c | 16 +++++++-----
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |  2 ++
 include/linux/mlx5/mlx5_ifc.h                 |  1 +
 5 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 31f9ecae98df9..07fdbea7ea13b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3069,6 +3069,25 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
 	priv->tstamp.rx_filter = HWTSTAMP_FILTER_NONE;
 }
 
+static void mlx5e_modify_admin_state(struct mlx5_core_dev *mdev,
+				     enum mlx5_port_status state)
+{
+	struct mlx5_eswitch *esw = mdev->priv.eswitch;
+	int vport_admin_state;
+
+	mlx5_set_port_admin_status(mdev, state);
+
+	if (!MLX5_ESWITCH_MANAGER(mdev) ||  mlx5_eswitch_mode(esw) == MLX5_ESWITCH_OFFLOADS)
+		return;
+
+	if (state == MLX5_PORT_UP)
+		vport_admin_state = MLX5_VPORT_ADMIN_STATE_AUTO;
+	else
+		vport_admin_state = MLX5_VPORT_ADMIN_STATE_DOWN;
+
+	mlx5_eswitch_set_vport_state(esw, MLX5_VPORT_UPLINK, vport_admin_state);
+}
+
 int mlx5e_open_locked(struct net_device *netdev)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -3101,7 +3120,7 @@ int mlx5e_open(struct net_device *netdev)
 	mutex_lock(&priv->state_lock);
 	err = mlx5e_open_locked(netdev);
 	if (!err)
-		mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
+		mlx5e_modify_admin_state(priv->mdev, MLX5_PORT_UP);
 	mutex_unlock(&priv->state_lock);
 
 	return err;
@@ -3135,7 +3154,7 @@ int mlx5e_close(struct net_device *netdev)
 		return -ENODEV;
 
 	mutex_lock(&priv->state_lock);
-	mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_DOWN);
+	mlx5e_modify_admin_state(priv->mdev, MLX5_PORT_DOWN);
 	err = mlx5e_close_locked(netdev);
 	mutex_unlock(&priv->state_lock);
 
@@ -5182,7 +5201,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
 
 	/* Marking the link as currently not needed by the Driver */
 	if (!netif_running(netdev))
-		mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
+		mlx5e_modify_admin_state(mdev, MLX5_PORT_DOWN);
 
 	mlx5e_set_netdev_mtu_boundaries(priv);
 	mlx5e_set_dev_port_mtu(priv);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 8c294ab43f908..9519a61bd8ec5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -1081,6 +1081,8 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
 
 	mlx5e_rep_tc_enable(priv);
 
+	mlx5_modify_vport_admin_state(mdev, MLX5_VPORT_STATE_OP_MOD_UPLINK,
+				      0, 0, MLX5_VPORT_ADMIN_STATE_AUTO);
 	mlx5_lag_add(mdev, netdev);
 	priv->events_nb.notifier_call = uplink_rep_async_event;
 	mlx5_notifier_register(mdev, &priv->events_nb);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index d9376627584e9..71d01143c4556 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1826,6 +1826,8 @@ int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
 				 u16 vport, int link_state)
 {
 	struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
+	int opmod = MLX5_VPORT_STATE_OP_MOD_ESW_VPORT;
+	int other_vport = 1;
 	int err = 0;
 
 	if (!ESW_ALLOWED(esw))
@@ -1833,15 +1835,17 @@ int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
 	if (IS_ERR(evport))
 		return PTR_ERR(evport);
 
+	if (vport == MLX5_VPORT_UPLINK) {
+		opmod = MLX5_VPORT_STATE_OP_MOD_UPLINK;
+		other_vport = 0;
+		vport = 0;
+	}
 	mutex_lock(&esw->state_lock);
 
-	err = mlx5_modify_vport_admin_state(esw->dev,
-					    MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
-					    vport, 1, link_state);
+	err = mlx5_modify_vport_admin_state(esw->dev, opmod, vport, other_vport, link_state);
 	if (err) {
-		mlx5_core_warn(esw->dev,
-			       "Failed to set vport %d link state, err = %d",
-			       vport, err);
+		mlx5_core_warn(esw->dev, "Failed to set vport %d link state, opmod = %d, err = %d",
+			       vport, opmod, err);
 		goto unlock;
 	}
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index a5175e98c0b34..5785596f13f5b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -680,6 +680,8 @@ static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) { r
 static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw, bool clear_vf) {}
 static inline bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1) { return true; }
 static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }
+static inline
+int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, u16 vport, int link_state) { return 0; }
 static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)
 {
 	return ERR_PTR(-EOPNOTSUPP);
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 073b79eacc991..1340e02b14ef2 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -4381,6 +4381,7 @@ struct mlx5_ifc_query_vport_state_out_bits {
 enum {
 	MLX5_VPORT_STATE_OP_MOD_VNIC_VPORT  = 0x0,
 	MLX5_VPORT_STATE_OP_MOD_ESW_VPORT   = 0x1,
+	MLX5_VPORT_STATE_OP_MOD_UPLINK      = 0x2,
 };
 
 struct mlx5_ifc_arm_monitor_counter_in_bits {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [net V2 11/11] net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (9 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down Saeed Mahameed
@ 2020-07-28 19:59 ` Saeed Mahameed
  2020-07-28 20:22 ` [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Jakub Kicinski
  2020-07-28 23:59 ` David Miller
  12 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-28 19:59 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: netdev, Alaa Hleihel, Roi Dayan, Vlad Buslov, Saeed Mahameed

From: Alaa Hleihel <alaa@mellanox.com>

After the cited commit, function 'mlx5_eswitch_set_vport_vlan' started
to acquire esw->state_lock.
However, esw is not defined for VF devices, hence attempting to set vf
VLANID on a VF dev will cause a kernel panic.

Fix it by moving up the (redundant) esw validation from function
'__mlx5_eswitch_set_vport_vlan' since the rest of the callers now have
and use a valid esw.

For example with vf device eth4:
 # ip link set dev eth4 vf 0 vlan 0

Trace of the panic:
 [  411.409842] BUG: unable to handle page fault for address: 00000000000011b8
 [  411.449745] #PF: supervisor read access in kernel mode
 [  411.452348] #PF: error_code(0x0000) - not-present page
 [  411.454938] PGD 80000004189c9067 P4D 80000004189c9067 PUD 41899a067 PMD 0
 [  411.458382] Oops: 0000 [#1] SMP PTI
 [  411.460268] CPU: 4 PID: 5711 Comm: ip Not tainted 5.8.0-rc4_for_upstream_min_debug_2020_07_08_22_04 #1
 [  411.462447] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
 [  411.464158] RIP: 0010:__mutex_lock+0x4e/0x940
 [  411.464928] Code: fd 41 54 49 89 f4 41 52 53 89 d3 48 83 ec 70 44 8b 1d ee 03 b0 01 65 48 8b 04 25 28 00 00 00 48 89 45 c8 31 c0 45 85 db 75 0a <48> 3b 7f 60 0f 85 7e 05 00 00 49 8d 45 68 41 56 41 b8 01 00 00 00
 [  411.467678] RSP: 0018:ffff88841fcd74b0 EFLAGS: 00010246
 [  411.468562] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
 [  411.469715] RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000001158
 [  411.470812] RBP: ffff88841fcd7550 R08: ffffffffa00fa1ce R09: 0000000000000000
 [  411.471835] R10: ffff88841fcd7570 R11: 0000000000000000 R12: 0000000000000002
 [  411.472862] R13: 0000000000001158 R14: ffffffffa00fa1ce R15: 0000000000000000
 [  411.474004] FS:  00007faee7ca6b80(0000) GS:ffff88846fc00000(0000) knlGS:0000000000000000
 [  411.475237] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 [  411.476129] CR2: 00000000000011b8 CR3: 000000041909c006 CR4: 0000000000360ea0
 [  411.477260] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
 [  411.478340] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
 [  411.479332] Call Trace:
 [  411.479760]  ? __nla_validate_parse.part.6+0x57/0x8f0
 [  411.482825]  ? mlx5_eswitch_set_vport_vlan+0x3e/0xa0 [mlx5_core]
 [  411.483804]  mlx5_eswitch_set_vport_vlan+0x3e/0xa0 [mlx5_core]
 [  411.484733]  mlx5e_set_vf_vlan+0x41/0x50 [mlx5_core]
 [  411.485545]  do_setlink+0x613/0x1000
 [  411.486165]  __rtnl_newlink+0x53d/0x8c0
 [  411.486791]  ? mark_held_locks+0x49/0x70
 [  411.487429]  ? __lock_acquire+0x8fe/0x1eb0
 [  411.488085]  ? rcu_read_lock_sched_held+0x52/0x60
 [  411.488998]  ? kmem_cache_alloc_trace+0x16d/0x2d0
 [  411.489759]  rtnl_newlink+0x47/0x70
 [  411.490357]  rtnetlink_rcv_msg+0x24e/0x450
 [  411.490978]  ? netlink_deliver_tap+0x92/0x3d0
 [  411.491631]  ? validate_linkmsg+0x330/0x330
 [  411.492262]  netlink_rcv_skb+0x47/0x110
 [  411.492852]  netlink_unicast+0x1ac/0x270
 [  411.493551]  netlink_sendmsg+0x336/0x450
 [  411.494209]  sock_sendmsg+0x30/0x40
 [  411.494779]  ____sys_sendmsg+0x1dd/0x1f0
 [  411.495378]  ? copy_msghdr_from_user+0x5c/0x90
 [  411.496082]  ___sys_sendmsg+0x87/0xd0
 [  411.496683]  ? lock_acquire+0xb9/0x3a0
 [  411.497322]  ? lru_cache_add+0x5/0x170
 [  411.497944]  ? find_held_lock+0x2d/0x90
 [  411.498568]  ? handle_mm_fault+0xe46/0x18c0
 [  411.499205]  ? __sys_sendmsg+0x51/0x90
 [  411.499784]  __sys_sendmsg+0x51/0x90
 [  411.500341]  do_syscall_64+0x59/0x2e0
 [  411.500938]  ? asm_exc_page_fault+0x8/0x30
 [  411.501609]  ? rcu_read_lock_sched_held+0x52/0x60
 [  411.502350]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
 [  411.503093] RIP: 0033:0x7faee73b85a7
 [  411.503654] Code: Bad RIP value.

Fixes: 0e18134f4f9f ("net/mlx5e: Eswitch, use state_lock to synchronize vlan change")
Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 71d01143c4556..43005caff09e1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1887,8 +1887,6 @@ int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
 	struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
 	int err = 0;
 
-	if (!ESW_ALLOWED(esw))
-		return -EPERM;
 	if (IS_ERR(evport))
 		return PTR_ERR(evport);
 	if (vlan > 4095 || qos > 7)
@@ -1916,6 +1914,9 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
 	u8 set_flags = 0;
 	int err;
 
+	if (!ESW_ALLOWED(esw))
+		return -EPERM;
+
 	if (vlan || qos)
 		set_flags = SET_VLAN_STRIP | SET_VLAN_INSERT;
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin
  2020-07-28 19:59 ` [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin Saeed Mahameed
@ 2020-07-28 20:20   ` Jakub Kicinski
  0 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2020-07-28 20:20 UTC (permalink / raw)
  To: Saeed Mahameed; +Cc: David S. Miller, netdev, Eran Ben Elisha, Ariel Levkovich

On Tue, 28 Jul 2020 12:59:31 -0700 Saeed Mahameed wrote:
>  static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
>  			   enum ptp_pin_function func, unsigned int chan)
>  {
> -	return (func == PTP_PF_PHYSYNC) ? -EOPNOTSUPP : 0;
> +	struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock,
> +						ptp_info);
> +
> +	switch (func) {
> +	case PTP_PF_NONE:
> +		return 0;
> +	case PTP_PF_EXTTS:
> +		return !(clock->pps_info.pin_caps[pin] &
> +			 MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN);
> +	case PTP_PF_PEROUT:
> +		return !(clock->pps_info.pin_caps[pin] &
> +			 MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT);
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +
> +	return -EOPNOTSUPP;

nit: entirely unnecessary return statement

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [pull request][net V2 00/11] mlx5 fixes-2020-07-28
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (10 preceding siblings ...)
  2020-07-28 19:59 ` [net V2 11/11] net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev Saeed Mahameed
@ 2020-07-28 20:22 ` Jakub Kicinski
  2020-07-28 23:59 ` David Miller
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2020-07-28 20:22 UTC (permalink / raw)
  To: Saeed Mahameed; +Cc: David S. Miller, netdev

On Tue, 28 Jul 2020 12:59:24 -0700 Saeed Mahameed wrote:
> Hi Dave,
> 
> This series introduces some fixes to mlx5 driver.
> v1->v2:
>  - Drop the "Hold reference on mirred devices" patch, until Or's
>    comments are addressed.
>  - Imporve "Modify uplink state" patch commit message per Or's request.

Acked-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [pull request][net V2 00/11] mlx5 fixes-2020-07-28
  2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
                   ` (11 preceding siblings ...)
  2020-07-28 20:22 ` [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Jakub Kicinski
@ 2020-07-28 23:59 ` David Miller
  12 siblings, 0 replies; 17+ messages in thread
From: David Miller @ 2020-07-28 23:59 UTC (permalink / raw)
  To: saeedm; +Cc: kuba, netdev

From: Saeed Mahameed <saeedm@mellanox.com>
Date: Tue, 28 Jul 2020 12:59:24 -0700

> This series introduces some fixes to mlx5 driver.
> v1->v2:
>  - Drop the "Hold reference on mirred devices" patch, until Or's
>    comments are addressed.
>  - Imporve "Modify uplink state" patch commit message per Or's request.
> 
> Please pull and let me know if there is any problem.

Pulled.

> For -Stable:
> 
> For -stable v4.9
>  ('net/mlx5e: Fix error path of device attach')
> 
> For -stable v4.15
>  ('net/mlx5: Verify Hardware supports requested ptp function on a given
> pin')
> 
> For -stable v5.3
>  ('net/mlx5e: Modify uplink state on interface up/down')
> 
> For -stable v5.4
>  ('net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev')
>  ('net/mlx5: E-switch, Destroy TSAR when fail to enable the mode')
> 
> For -stable v5.5
>  ('net/mlx5: E-switch, Destroy TSAR after reload interface')
> 
> For -stable v5.7
>  ('net/mlx5: Fix a bug of using ptp channel index as pin index')

Queued up, thanks.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down
  2020-07-28 19:59 ` [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down Saeed Mahameed
@ 2020-07-29  6:17   ` Or Gerlitz
  2020-07-29  6:38     ` Saeed Mahameed
  0 siblings, 1 reply; 17+ messages in thread
From: Or Gerlitz @ 2020-07-29  6:17 UTC (permalink / raw)
  To: Saeed Mahameed
  Cc: David S. Miller, Jakub Kicinski, Linux Netdev List, Ron Diskin,
	Roi Dayan, Moshe Shemesh

On Tue, Jul 28, 2020 at 11:07 PM Saeed Mahameed <saeedm@mellanox.com> wrote:
> When setting the PF interface up/down, notify the firmware to update
> uplink state via MODIFY_VPORT_STATE, when E-Switch is enabled.
> This behavior will prevent sending traffic out on uplink port when PF is
> down, such as sending traffic from a VF interface which is still up.
> Currently when calling mlx5e_open/close(), the driver only sends PAOS
> command to notify the firmware to set the physical port state to
> up/down, however, it is not sufficient. When VF is in "auto" state, it
> follows the uplink state, which was not updated on mlx5e_open/close()
> before this patch.

> When switchdev mode is enabled and uplink representor is first enabled,
> set the uplink port state value back to its FW default "AUTO".

So this is not the legacy mode "auto" vf vport state but rather something else?

If this is the case what is the semantics of the firmware "auto" state and
how it related to the switchdev vport representors architecture/behaviour?


> Fixes: 63bfd399de55 ("net/mlx5e: Send PAOS command on interface up/down")

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down
  2020-07-29  6:17   ` Or Gerlitz
@ 2020-07-29  6:38     ` Saeed Mahameed
  0 siblings, 0 replies; 17+ messages in thread
From: Saeed Mahameed @ 2020-07-29  6:38 UTC (permalink / raw)
  To: gerlitz.or; +Cc: Moshe Shemesh, Roi Dayan, davem, kuba, Ron Diskin, netdev

On Wed, 2020-07-29 at 09:17 +0300, Or Gerlitz wrote:
> On Tue, Jul 28, 2020 at 11:07 PM Saeed Mahameed <saeedm@mellanox.com>
> wrote:
> > When setting the PF interface up/down, notify the firmware to
> > update
> > uplink state via MODIFY_VPORT_STATE, when E-Switch is enabled.
> > This behavior will prevent sending traffic out on uplink port when
> > PF is
> > down, such as sending traffic from a VF interface which is still
> > up.
> > Currently when calling mlx5e_open/close(), the driver only sends
> > PAOS
> > command to notify the firmware to set the physical port state to
> > up/down, however, it is not sufficient. When VF is in "auto" state,
> > it
> > follows the uplink state, which was not updated on
> > mlx5e_open/close()
> > before this patch.
> > When switchdev mode is enabled and uplink representor is first
> > enabled,
> > set the uplink port state value back to its FW default "AUTO".
> 
> So this is not the legacy mode "auto" vf vport state but rather
> something else?
> 

Or, this is the uplink esw port and not the PF's, auto means 
FW/HW manages the state according to the actual physical link state.

> If this is the case what is the semantics of the firmware "auto"
> state and
> how it related to the switchdev vport representors
> architecture/behaviour?
> 

No change in the current switchdev behavior, only for legacy and NONE
mode. 

> 
> > Fixes: 63bfd399de55 ("net/mlx5e: Send PAOS command on interface
> > up/down")

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-07-29  6:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
2020-07-28 19:59 ` [net V2 01/11] net/mlx5: E-switch, Destroy TSAR when fail to enable the mode Saeed Mahameed
2020-07-28 19:59 ` [net V2 02/11] net/mlx5: E-switch, Destroy TSAR after reload interface Saeed Mahameed
2020-07-28 19:59 ` [net V2 03/11] net/mlx5: Fix forward to next namespace Saeed Mahameed
2020-07-28 19:59 ` [net V2 04/11] net/mlx5e: Fix error path of device attach Saeed Mahameed
2020-07-28 19:59 ` [net V2 05/11] net/mlx5e: Fix missing cleanup of ethtool steering during rep rx cleanup Saeed Mahameed
2020-07-28 19:59 ` [net V2 06/11] net/mlx5: Fix a bug of using ptp channel index as pin index Saeed Mahameed
2020-07-28 19:59 ` [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin Saeed Mahameed
2020-07-28 20:20   ` Jakub Kicinski
2020-07-28 19:59 ` [net V2 08/11] net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev Saeed Mahameed
2020-07-28 19:59 ` [net V2 09/11] net/mlx5: Query PPS pin operational status before registering it Saeed Mahameed
2020-07-28 19:59 ` [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down Saeed Mahameed
2020-07-29  6:17   ` Or Gerlitz
2020-07-29  6:38     ` Saeed Mahameed
2020-07-28 19:59 ` [net V2 11/11] net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev Saeed Mahameed
2020-07-28 20:22 ` [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Jakub Kicinski
2020-07-28 23:59 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.