Mellanox, mlx5 fixes 2019-01-25
Hi Dave,
This series introduces some fixes to mlx5 driver.
For more information please see tag log below.
Please pull and let me know if there is any problem.
For -stable v4.13
('net/mlx5e: Allow MAC invalidation while spoofchk is ON')
For -stable v4.18
('Revert "net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager"')
Thanks,
Saeed.
---
The following changes since commit 49a57857aeea06ca831043acbb0fa5e0f50602fd:
Linux 5.0-rc3 (2019-01-21 13:14:44 +1300)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2019-01-25
for you to fetch changes up to 6ce966fd2671899a48037abe7bf1df80a5adf029:
net/mlx5e: Unblock setting vid 0 for VFs through the uplink rep (2019-01-25 12:00:29 -0800)
----------------------------------------------------------------
mlx5-fixes-2019-01-25
----------------------------------------------------------------
Aya Levin (1):
net/mlx5e: Allow MAC invalidation while spoofchk is ON
Bodong Wang (1):
Revert "net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager"
Moni Shoua (1):
net/mlx5: Take lock with IRQs disabled to avoid deadlock
Or Gerlitz (2):
net/mlx5e: Move to use common phys port names for vport representors net/mlx5e: Unblock setting vid 0 for VFs through the uplink rep
Shay Agroskin (1):
net/mlx5e: Fix wrong private flag usage causing checksum disable
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 25 ++++++++++++++++++++-- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 22 +++++++------------ drivers/net/ethernet/mellanox/mlx5/core/lag.c | 21 ++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/qp.c | 5 +++-- 6 files changed, 58 insertions(+), 19 deletions(-)
PATCH 1/6 Revert "net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager"
From: Bodong Wang <[email protected]>
This reverts commit 5f5991f36dce1e69dd8bd7495763eec2e28f08e7.
With the original commit, eswitch instance will not be initialized for a function which is vport group manager but not eswitch manager such as host PF on SmartNIC (BlueField) card. This will result in a kernel crash when such a vport group manager is trying to access vports in its group. E.g, PF vport manager (not eswitch manager) tries to configure the MAC of its VF vport, a kernel trace will happen similar as bellow:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 ... RIP: 0010:mlx5_eswitch_get_vport_config+0xc/0x180 [mlx5_core] ...
--- 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
@@ -1728,7 +1728,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)int vport_num;int err; -if (!MLX5_ESWITCH_MANAGER (dev)) +if (!MLX5_VPORT_MANAGER (dev))return 0 ; esw_info(dev,
@@ -1797,7 +1797,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)void mlx5_eswitch_cleanup (struct mlx5_eswitch *esw) { -if (!esw || !MLX5_ESWITCH_MANAGER (esw->dev)) +if (!esw || !MLX5_VPORT_MANAGER (esw->dev))return ;esw_info (esw->dev,"cleanup\n" );
Signature · 1 line
2.20.1
PATCH 2/6 net/mlx5e: Fix wrong private flag usage causing checksum disable
In reply to Saeed MahameedFrom: Shay Agroskin <[email protected]>
MLX5E_PFLAG_* definitions were changed from bitmask to enumerated values. However, in mlx5e_open_rq(), the proper API (MLX5E_GET_PFLAG macro) was not used to read the flag value of MLX5E_PFLAG_RX_NO_CSUM_COMPLETE. Fixed it.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -1
@@ -950,7 +950,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,if (params->rx_dim_enabled)__set_bit (MLX5E_RQ_STATE_AM , &c->rq.state); -if (params->pflags &MLX5E_PFLAG_RX_NO_CSUM_COMPLETE ) +if (MLX5E_GET_PFLAG (params,MLX5E_PFLAG_RX_NO_CSUM_COMPLETE ))__set_bit (MLX5E_RQ_STATE_NO_CSUM_COMPLETE , &c->rq.state);return 0 ;
Signature · 1 line
2.20.1
PATCH 3/6 net/mlx5: Take lock with IRQs disabled to avoid deadlock
In reply to Saeed MahameedFrom: Moni Shoua <[email protected]>
The lock in qp_table might be taken from process context or from interrupt context. This may lead to a deadlock unless it is taken with IRQs disabled.
Discovered by lockdep
================================
WARNING: inconsistent lock state
4.20.0-rc6
--------------------------------
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W}
python/12572 [HC1[1]:SC0[0]:HE0:SE1] takes:00000000052a4df4 (&(&table->lock)->rlock#2){?.+.}, /0x50 [mlx5_core] {HARDIRQ-ON-W} state was registered at:
_raw_spin_lock+0x33/0x70 mlx5_get_rsc+0x1a/0x50 [mlx5_core] mlx5_ib_eqe_pf_action+0x493/0x1be0 [mlx5_ib] process_one_work+0x90c/0x1820 worker_thread+0x87/0xbb0 kthread+0x320/0x3e0 ret_from_fork+0x24/0x30 irq event stamp: 103928 hardirqs last enabled at (103927): [] nk+0x1a/0x1c hardirqs last disabled at (103928): [] unk+0x1a/0x1c softirqs last enabled at (103924): [] tcp_sendmsg+0x31/0x40 softirqs last disabled at (103922): [] 80
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----lock(&(&table->lock)->rlock#2);
lock(&(&table->lock)->rlock#2);
*** DEADLOCK ***
--- drivers/net/ethernet/mellanox/mlx5/core/qp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/qp.c +3 -2
@@ -44,14 +44,15 @@ static struct mlx5_core_rsc_common * mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn) {struct mlx5_core_rsc_common *common; +unsigned long flags; -spin_lock (&table->lock); +spin_lock_irqsave (&table->lock, flags); common =radix_tree_lookup (&table->tree, rsn);if (common)atomic_inc (&common->refcount); -spin_unlock (&table->lock); +spin_unlock_irqrestore (&table->lock, flags);return common; }
Signature · 1 line
2.20.1
PATCH 4/6 net/mlx5e: Allow MAC invalidation while spoofchk is ON
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Prior to this patch the driver prohibited spoof checking on invalid MAC. Now the user can set this configuration if it wishes to.
This is required since libvirt might invalidate the VF Mac by setting it to zero, while spoofcheck is ON.
--- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +6 -12
@@ -1134,13 +1134,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,int err =0 ;u8 *smac_v; -if (vport->info.spoofchk && !is_valid_ether_addr (vport->info.mac)) { -mlx5_core_warn (esw->dev, -"vport[%d] configure ingress rules failed, illegal mac with spoofchk\n" , - vport->vport); -return -EPERM ; - } -esw_vport_cleanup_ingress_rules (esw, vport);if (!vport->info.vlan && !vport->info.qos && !vport->info.spoofchk) {
@@ -1827,13 +1820,10 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,mutex_lock (&esw->state_lock); evport = &esw->vports[vport]; -if (evport->info.spoofchk && !is_valid_ether_addr (mac)) { +if (evport->info.spoofchk && !is_valid_ether_addr (mac))mlx5_core_warn (esw->dev, -"MAC invalidation is not allowed when spoofchk is on, vport(%d)\n" , +"Set invalid MAC while spoofchk is on, vport(%d)\n" , vport); - err = -EPERM ; - goto unlock; - } err =mlx5_modify_nic_vport_mac_address (esw->dev, vport, mac);if (err) {
@@ -1979,6 +1969,10 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, evport = &esw->vports[vport]; pschk = evport->info.spoofchk; evport->info.spoofchk = spoofchk; +if (pschk && !is_valid_ether_addr (evport->info.mac)) +mlx5_core_warn (esw->dev, +"Spoofchk in set while MAC is invalid, vport(%d)\n" , + evport->vport);if (evport->enabled && esw->mode ==SRIOV_LEGACY ) err =esw_vport_ingress_config (esw, evport);if (err)
Signature · 1 line
2.20.1
PATCH 5/6 net/mlx5e: Move to use common phys port names for vport representors
In reply to Saeed MahameedFrom: Or Gerlitz <[email protected]>
With VF LAG commit 491c37e49b48 "net/mlx5e: In case of LAG, one switch parent id is used for all representors", both uplinks and all the VFs (on both of them) get the same switchdev id.
This cause the provisioning system method to identify the rep of a given VF from the parent PF PCI device using switchev id and physical port name to break, since VFm of PF0 will have the (id, name) as VFm of PF1.
To fix that, we align to use the framework agreed upstream and set by nfp commit 168c478e107e "nfp: wire get_phys_port_name on representors":
$ cat /sys/class/net/eth4_*/phys_port_name p0 pf0vf0 pf0vf1
Now, the names will be different, e.g. pf0vf0 vs. pf1vf0.
--- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 12 +++++++++-- drivers/net/ethernet/mellanox/mlx5/core/lag.c | 21 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +10 -2
@@ -1126,9 +1126,17 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,struct mlx5e_priv *priv =netdev_priv (dev);struct mlx5e_rep_priv *rpriv = priv->ppriv;struct mlx5_eswitch_rep *rep = rpriv->rep; -int ret; +int ret, pf_num; + + ret =mlx5_lag_get_pf_num (priv->mdev, &pf_num); +if (ret) +return ret; + +if (rep->vport ==FDB_UPLINK_VPORT ) + ret =snprintf (buf, len,"p%d" , pf_num); +else + ret =snprintf (buf, len,"pf%dvf%d" , pf_num, rep->vport -1 ); - ret =snprintf (buf, len,"%d" , rep->vport -1 );if (ret >= len)return -EOPNOTSUPP ;
drivers/net/ethernet/mellanox/mlx5/core/lag.c +21 -0
@@ -616,6 +616,27 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev) } } +int mlx5_lag_get_pf_num (struct mlx5_core_dev *dev,int *pf_num) +{ +struct mlx5_lag *ldev; +int n; + + ldev =mlx5_lag_dev_get (dev); +if (!ldev) { +mlx5_core_warn (dev,"no lag device, can't get pf num\n" ); +return -EINVAL ; + } + +for (n =0 ; n <MLX5_MAX_PORTS ; n++) +if (ldev->pf[n].dev == dev) { + *pf_num = n; +return 0 ; + } + +mlx5_core_warn (dev,"wasn't able to locate pf in the lag device\n" ); +return -EINVAL ; +} +/* Must be called with intf_mutex held */ void mlx5_lag_remove (struct mlx5_core_dev *dev) {
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +2 -0
@@ -187,6 +187,8 @@ static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev)MLX5_CAP_GEN (dev, lag_master); } +int mlx5_lag_get_pf_num (struct mlx5_core_dev *dev,int *pf_num); +void mlx5_reload_interface (struct mlx5_core_dev *mdev,int protocol);void mlx5_lag_update (struct mlx5_core_dev *dev);
Signature · 1 line
2.20.1
PATCH 6/6 net/mlx5e: Unblock setting vid 0 for VFs through the uplink rep
In reply to Saeed MahameedFrom: Or Gerlitz <[email protected]>
It turns out that libvirt uses 0-vid as a default if no vlan was set for the guest (which is the case for switchdev mode) and errs if we disallow that:
error: Failed to start domain vm75
error: Cannot set interface MAC/vlanid to 6a:66:2d:48:92:c2/0 \
for ifname enp59s0f0 vf 0: Operation not supported
So allow this in order not to break existing systems.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +13 -0
@@ -1293,6 +1293,18 @@ static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr)return 0 ; } +static int mlx5e_uplink_rep_set_vf_vlan (struct net_device *dev,int vf,u16 vlan,u8 qos, +__be16 vlan_proto) +{ +netdev_warn_once (dev,"legacy vf vlan setting isn't supported in switchdev mode\n" ); + +if (vlan !=0 ) +return -EOPNOTSUPP ; + +/* allow setting 0-vid for compatibility with libvirt */ +return 0 ; +} +static const struct switchdev_ops mlx5e_rep_switchdev_ops = { .switchdev_port_attr_get = mlx5e_attr_get, };
@@ -1327,6 +1339,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = { .ndo_set_vf_rate = mlx5e_set_vf_rate, .ndo_get_vf_config = mlx5e_get_vf_config, .ndo_get_vf_stats = mlx5e_get_vf_stats, + .ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan, };bool mlx5e_eswitch_rep (struct net_device *netdev)
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Saeed Mahameed <[email protected]>
Date: Fri, 25 Jan 2019 12:01:34 -0800
Quoted 4 lines
This series introduces some fixes to mlx5 driver.
For more information please see tag log below.Please pull and let me know if there is any problem.
Pulled.
Quoted 5 lines
For -stable v4.13
('net/mlx5e: Allow MAC invalidation while spoofchk is ON')For -stable v4.18
('Revert "net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager"')
Queued up.