mlx5 fixes-2020-07-28
Subsystems (5)
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(-)
PATCH v2 1/11 net/mlx5: E-switch, Destroy TSAR when fail to enable the mode
From: Parav Pandit <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1 -1
@@ -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; }
Signature · 1 line
2.26.2
PATCH v2 2/11 net/mlx5: E-switch, Destroy TSAR after reload interface
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +2 -2
@@ -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); }
Signature · 1 line
2.26.2
PATCH v2 3/11 net/mlx5: Fix forward to next namespace
In reply to Saeed MahameedFrom: Maor Gottlieb <[email protected]>
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.
--- .../net/ethernet/mellanox/mlx5/core/fs_core.c | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +5 -23
@@ -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,
Signature · 1 line
2.26.2
PATCH v2 4/11 net/mlx5e: Fix error path of device attach
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -0
@@ -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; }
Signature · 1 line
2.26.2
PATCH v2 5/11 net/mlx5e: Fix missing cleanup of ethtool steering during rep rx cleanup
In reply to Saeed MahameedFrom: Maor Dickman <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -0
@@ -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);
Signature · 1 line
2.26.2
PATCH v2 6/11 net/mlx5: Fix a bug of using ptp channel index as pin index
In reply to Saeed MahameedFrom: Eran Ben Elisha <[email protected]>
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.
--- .../ethernet/mellanox/mlx5/core/lib/clock.c | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +10 -11
@@ -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 ;
Signature · 1 line
2.26.2
PATCH v2 7/11 net/mlx5: Verify Hardware supports requested ptp function on a given pin
In reply to Saeed MahameedFrom: Eran Ben Elisha <[email protected]>
Fix a bug where driver did not verify Hardware pin capabilities for PTP functions.
--- .../ethernet/mellanox/mlx5/core/lib/clock.c | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +22 -1
@@ -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 = {
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerRe: [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin
Quoted 11 lines · 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,drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +7
-1enum 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 :
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c static int mlx5_ptp_enable(struct ptp_clock_info *ptp, · line 435
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +10
-0+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
PATCH v2 8/11 net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev
In reply to Saeed MahameedFrom: Raed Salem <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c +5 -2
@@ -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 ; }
Signature · 1 line
2.26.2
PATCH v2 9/11 net/mlx5: Query PPS pin operational status before registering it
In reply to Saeed MahameedFrom: Eran Ben Elisha <[email protected]>
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.
--- .../ethernet/mellanox/mlx5/core/lib/clock.c | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +33 -1
@@ -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 ; }
Signature · 1 line
2.26.2
PATCH v2 10/11 net/mlx5e: Modify uplink state on interface up/down
In reply to Saeed MahameedFrom: Ron Diskin <[email protected]>
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".
--- .../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(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +22 -3
@@ -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);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -0
@@ -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);
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +10 -6
@@ -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; }
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
@@ -680,6 +680,8 @@ static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) { rstatic 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 );
include/linux/mlx5/mlx5_ifc.h +1 -0
@@ -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 {
Signature · 1 line
2.26.2
Re: [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down
Quoted 10 lines · Saeed Mahameed
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.
Quoted 2 lines
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?
Quoted 1 line
Fixes 63bfd399de55 ("net/mlx5e: Send PAOS command on interface up/down")
Re: [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down
Quoted 21 lines · Or Gerlitz
Quoted 10 lines · Saeed Mahameed
When setting the PF interface up/down, notify the firmware to update
uplink state viaMODIFY_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 toQuoted 8 lines
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".
Quoted 3 lines
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.
Quoted 5 lines
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.
Quoted 3 lines
Quoted 3 lines
Fixes 63bfd399de55 ("net/mlx5e: Send PAOS command on interfaceup/down")
PATCH v2 11/11 net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev
In reply to Saeed MahameedFrom: Alaa Hleihel <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +3 -2
@@ -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 ;
Signature · 1 line
2.26.2
Quoted 7 lines · 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.
From: Saeed Mahameed <[email protected]>
Date: Tue, 28 Jul 2020 12:59:24 -0700
Quoted 7 lines
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.
Quoted 16 lines
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')
Quoted 5 lines
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.