Skip to content

Commit 3da15ad

Browse files
committed
Merge tag 'mlx5-fixes-2019-01-25' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== Mellanox, mlx5 fixes 2019-01-25 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"') ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents b0cf029 + 6ce966f commit 3da15ad

File tree

6 files changed

+58
-19
lines changed

6 files changed

+58
-19
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
950950
if (params->rx_dim_enabled)
951951
__set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
952952

953-
if (params->pflags & MLX5E_PFLAG_RX_NO_CSUM_COMPLETE)
953+
if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE))
954954
__set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state);
955955

956956
return 0;

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,17 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,
11261126
struct mlx5e_priv *priv = netdev_priv(dev);
11271127
struct mlx5e_rep_priv *rpriv = priv->ppriv;
11281128
struct mlx5_eswitch_rep *rep = rpriv->rep;
1129-
int ret;
1129+
int ret, pf_num;
1130+
1131+
ret = mlx5_lag_get_pf_num(priv->mdev, &pf_num);
1132+
if (ret)
1133+
return ret;
1134+
1135+
if (rep->vport == FDB_UPLINK_VPORT)
1136+
ret = snprintf(buf, len, "p%d", pf_num);
1137+
else
1138+
ret = snprintf(buf, len, "pf%dvf%d", pf_num, rep->vport - 1);
11301139

1131-
ret = snprintf(buf, len, "%d", rep->vport - 1);
11321140
if (ret >= len)
11331141
return -EOPNOTSUPP;
11341142

@@ -1285,6 +1293,18 @@ static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr)
12851293
return 0;
12861294
}
12871295

1296+
static int mlx5e_uplink_rep_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos,
1297+
__be16 vlan_proto)
1298+
{
1299+
netdev_warn_once(dev, "legacy vf vlan setting isn't supported in switchdev mode\n");
1300+
1301+
if (vlan != 0)
1302+
return -EOPNOTSUPP;
1303+
1304+
/* allow setting 0-vid for compatibility with libvirt */
1305+
return 0;
1306+
}
1307+
12881308
static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
12891309
.switchdev_port_attr_get = mlx5e_attr_get,
12901310
};
@@ -1319,6 +1339,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
13191339
.ndo_set_vf_rate = mlx5e_set_vf_rate,
13201340
.ndo_get_vf_config = mlx5e_get_vf_config,
13211341
.ndo_get_vf_stats = mlx5e_get_vf_stats,
1342+
.ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan,
13221343
};
13231344

13241345
bool mlx5e_eswitch_rep(struct net_device *netdev)

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,13 +1134,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
11341134
int err = 0;
11351135
u8 *smac_v;
11361136

1137-
if (vport->info.spoofchk && !is_valid_ether_addr(vport->info.mac)) {
1138-
mlx5_core_warn(esw->dev,
1139-
"vport[%d] configure ingress rules failed, illegal mac with spoofchk\n",
1140-
vport->vport);
1141-
return -EPERM;
1142-
}
1143-
11441137
esw_vport_cleanup_ingress_rules(esw, vport);
11451138

11461139
if (!vport->info.vlan && !vport->info.qos && !vport->info.spoofchk) {
@@ -1728,7 +1721,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
17281721
int vport_num;
17291722
int err;
17301723

1731-
if (!MLX5_ESWITCH_MANAGER(dev))
1724+
if (!MLX5_VPORT_MANAGER(dev))
17321725
return 0;
17331726

17341727
esw_info(dev,
@@ -1797,7 +1790,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
17971790

17981791
void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
17991792
{
1800-
if (!esw || !MLX5_ESWITCH_MANAGER(esw->dev))
1793+
if (!esw || !MLX5_VPORT_MANAGER(esw->dev))
18011794
return;
18021795

18031796
esw_info(esw->dev, "cleanup\n");
@@ -1827,13 +1820,10 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
18271820
mutex_lock(&esw->state_lock);
18281821
evport = &esw->vports[vport];
18291822

1830-
if (evport->info.spoofchk && !is_valid_ether_addr(mac)) {
1823+
if (evport->info.spoofchk && !is_valid_ether_addr(mac))
18311824
mlx5_core_warn(esw->dev,
1832-
"MAC invalidation is not allowed when spoofchk is on, vport(%d)\n",
1825+
"Set invalid MAC while spoofchk is on, vport(%d)\n",
18331826
vport);
1834-
err = -EPERM;
1835-
goto unlock;
1836-
}
18371827

18381828
err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac);
18391829
if (err) {
@@ -1979,6 +1969,10 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw,
19791969
evport = &esw->vports[vport];
19801970
pschk = evport->info.spoofchk;
19811971
evport->info.spoofchk = spoofchk;
1972+
if (pschk && !is_valid_ether_addr(evport->info.mac))
1973+
mlx5_core_warn(esw->dev,
1974+
"Spoofchk in set while MAC is invalid, vport(%d)\n",
1975+
evport->vport);
19821976
if (evport->enabled && esw->mode == SRIOV_LEGACY)
19831977
err = esw_vport_ingress_config(esw, evport);
19841978
if (err)

drivers/net/ethernet/mellanox/mlx5/core/lag.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,27 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)
616616
}
617617
}
618618

619+
int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num)
620+
{
621+
struct mlx5_lag *ldev;
622+
int n;
623+
624+
ldev = mlx5_lag_dev_get(dev);
625+
if (!ldev) {
626+
mlx5_core_warn(dev, "no lag device, can't get pf num\n");
627+
return -EINVAL;
628+
}
629+
630+
for (n = 0; n < MLX5_MAX_PORTS; n++)
631+
if (ldev->pf[n].dev == dev) {
632+
*pf_num = n;
633+
return 0;
634+
}
635+
636+
mlx5_core_warn(dev, "wasn't able to locate pf in the lag device\n");
637+
return -EINVAL;
638+
}
639+
619640
/* Must be called with intf_mutex held */
620641
void mlx5_lag_remove(struct mlx5_core_dev *dev)
621642
{

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev)
187187
MLX5_CAP_GEN(dev, lag_master);
188188
}
189189

190+
int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num);
191+
190192
void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol);
191193
void mlx5_lag_update(struct mlx5_core_dev *dev);
192194

drivers/net/ethernet/mellanox/mlx5/core/qp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ static struct mlx5_core_rsc_common *
4444
mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn)
4545
{
4646
struct mlx5_core_rsc_common *common;
47+
unsigned long flags;
4748

48-
spin_lock(&table->lock);
49+
spin_lock_irqsave(&table->lock, flags);
4950

5051
common = radix_tree_lookup(&table->tree, rsn);
5152
if (common)
5253
atomic_inc(&common->refcount);
5354

54-
spin_unlock(&table->lock);
55+
spin_unlock_irqrestore(&table->lock, flags);
5556

5657
return common;
5758
}

0 commit comments

Comments
 (0)