Skip to content

Commit b5cd55b

Browse files
committed
Merge tag 'mlx5-fixes-2020-07-28' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes-2020-07-28 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') ==================== Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents 2ff34c9 + 350a632 commit b5cd55b

File tree

8 files changed

+121
-52
lines changed

8 files changed

+121
-52
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ void mlx5e_rep_bond_unslave(struct mlx5_eswitch *esw,
183183

184184
static bool mlx5e_rep_is_lag_netdev(struct net_device *netdev)
185185
{
186-
struct mlx5e_priv *priv = netdev_priv(netdev);
187-
struct mlx5e_rep_priv *rpriv = priv->ppriv;
186+
struct mlx5e_rep_priv *rpriv;
187+
struct mlx5e_priv *priv;
188188

189189
/* A given netdev is not a representor or not a slave of LAG configuration */
190190
if (!mlx5e_eswitch_rep(netdev) || !bond_slave_get_rtnl(netdev))
191191
return false;
192192

193+
priv = netdev_priv(netdev);
194+
rpriv = priv->ppriv;
195+
193196
/* Egress acl forward to vport is supported only non-uplink representor */
194197
return rpriv->rep->vport != MLX5_VPORT_UPLINK;
195198
}

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,6 +3069,25 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
30693069
priv->tstamp.rx_filter = HWTSTAMP_FILTER_NONE;
30703070
}
30713071

3072+
static void mlx5e_modify_admin_state(struct mlx5_core_dev *mdev,
3073+
enum mlx5_port_status state)
3074+
{
3075+
struct mlx5_eswitch *esw = mdev->priv.eswitch;
3076+
int vport_admin_state;
3077+
3078+
mlx5_set_port_admin_status(mdev, state);
3079+
3080+
if (!MLX5_ESWITCH_MANAGER(mdev) || mlx5_eswitch_mode(esw) == MLX5_ESWITCH_OFFLOADS)
3081+
return;
3082+
3083+
if (state == MLX5_PORT_UP)
3084+
vport_admin_state = MLX5_VPORT_ADMIN_STATE_AUTO;
3085+
else
3086+
vport_admin_state = MLX5_VPORT_ADMIN_STATE_DOWN;
3087+
3088+
mlx5_eswitch_set_vport_state(esw, MLX5_VPORT_UPLINK, vport_admin_state);
3089+
}
3090+
30723091
int mlx5e_open_locked(struct net_device *netdev)
30733092
{
30743093
struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -3101,7 +3120,7 @@ int mlx5e_open(struct net_device *netdev)
31013120
mutex_lock(&priv->state_lock);
31023121
err = mlx5e_open_locked(netdev);
31033122
if (!err)
3104-
mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
3123+
mlx5e_modify_admin_state(priv->mdev, MLX5_PORT_UP);
31053124
mutex_unlock(&priv->state_lock);
31063125

31073126
return err;
@@ -3135,7 +3154,7 @@ int mlx5e_close(struct net_device *netdev)
31353154
return -ENODEV;
31363155

31373156
mutex_lock(&priv->state_lock);
3138-
mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_DOWN);
3157+
mlx5e_modify_admin_state(priv->mdev, MLX5_PORT_DOWN);
31393158
err = mlx5e_close_locked(netdev);
31403159
mutex_unlock(&priv->state_lock);
31413160

@@ -5182,7 +5201,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
51825201

51835202
/* Marking the link as currently not needed by the Driver */
51845203
if (!netif_running(netdev))
5185-
mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
5204+
mlx5e_modify_admin_state(mdev, MLX5_PORT_DOWN);
51865205

51875206
mlx5e_set_netdev_mtu_boundaries(priv);
51885207
mlx5e_set_dev_port_mtu(priv);
@@ -5390,6 +5409,8 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)
53905409
profile->cleanup_tx(priv);
53915410

53925411
out:
5412+
set_bit(MLX5E_STATE_DESTROYING, &priv->state);
5413+
cancel_work_sync(&priv->update_stats_work);
53935414
return err;
53945415
}
53955416

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
936936

937937
static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
938938
{
939+
mlx5e_ethtool_cleanup_steering(priv);
939940
rep_vport_rx_rule_destroy(priv);
940941
mlx5e_destroy_rep_root_ft(priv);
941942
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
@@ -1080,6 +1081,8 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
10801081

10811082
mlx5e_rep_tc_enable(priv);
10821083

1084+
mlx5_modify_vport_admin_state(mdev, MLX5_VPORT_STATE_OP_MOD_UPLINK,
1085+
0, 0, MLX5_VPORT_ADMIN_STATE_AUTO);
10831086
mlx5_lag_add(mdev, netdev);
10841087
priv->events_nb.notifier_call = uplink_rep_async_event;
10851088
mlx5_notifier_register(mdev, &priv->events_nb);

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int mode, int num_vfs)
16081608
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
16091609
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
16101610
}
1611-
1611+
esw_destroy_tsar(esw);
16121612
return err;
16131613
}
16141614

@@ -1653,8 +1653,6 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw, bool clear_vf)
16531653
else if (esw->mode == MLX5_ESWITCH_OFFLOADS)
16541654
esw_offloads_disable(esw);
16551655

1656-
esw_destroy_tsar(esw);
1657-
16581656
old_mode = esw->mode;
16591657
esw->mode = MLX5_ESWITCH_NONE;
16601658

@@ -1664,6 +1662,8 @@ void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw, bool clear_vf)
16641662
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
16651663
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
16661664
}
1665+
esw_destroy_tsar(esw);
1666+
16671667
if (clear_vf)
16681668
mlx5_eswitch_clear_vf_vports_info(esw);
16691669
}
@@ -1826,22 +1826,26 @@ int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
18261826
u16 vport, int link_state)
18271827
{
18281828
struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
1829+
int opmod = MLX5_VPORT_STATE_OP_MOD_ESW_VPORT;
1830+
int other_vport = 1;
18291831
int err = 0;
18301832

18311833
if (!ESW_ALLOWED(esw))
18321834
return -EPERM;
18331835
if (IS_ERR(evport))
18341836
return PTR_ERR(evport);
18351837

1838+
if (vport == MLX5_VPORT_UPLINK) {
1839+
opmod = MLX5_VPORT_STATE_OP_MOD_UPLINK;
1840+
other_vport = 0;
1841+
vport = 0;
1842+
}
18361843
mutex_lock(&esw->state_lock);
18371844

1838-
err = mlx5_modify_vport_admin_state(esw->dev,
1839-
MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
1840-
vport, 1, link_state);
1845+
err = mlx5_modify_vport_admin_state(esw->dev, opmod, vport, other_vport, link_state);
18411846
if (err) {
1842-
mlx5_core_warn(esw->dev,
1843-
"Failed to set vport %d link state, err = %d",
1844-
vport, err);
1847+
mlx5_core_warn(esw->dev, "Failed to set vport %d link state, opmod = %d, err = %d",
1848+
vport, opmod, err);
18451849
goto unlock;
18461850
}
18471851

@@ -1883,8 +1887,6 @@ int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
18831887
struct mlx5_vport *evport = mlx5_eswitch_get_vport(esw, vport);
18841888
int err = 0;
18851889

1886-
if (!ESW_ALLOWED(esw))
1887-
return -EPERM;
18881890
if (IS_ERR(evport))
18891891
return PTR_ERR(evport);
18901892
if (vlan > 4095 || qos > 7)
@@ -1912,6 +1914,9 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
19121914
u8 set_flags = 0;
19131915
int err;
19141916

1917+
if (!ESW_ALLOWED(esw))
1918+
return -EPERM;
1919+
19151920
if (vlan || qos)
19161921
set_flags = SET_VLAN_STRIP | SET_VLAN_INSERT;
19171922

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) { r
680680
static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw, bool clear_vf) {}
681681
static inline bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1) { return true; }
682682
static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }
683+
static inline
684+
int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, u16 vport, int link_state) { return 0; }
683685
static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)
684686
{
685687
return ERR_PTR(-EOPNOTSUPP);

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ static struct mlx5_flow_table *find_closest_ft_recursive(struct fs_node *root,
797797
return ft;
798798
}
799799

800-
/* If reverse if false then return the first flow table in next priority of
800+
/* If reverse is false then return the first flow table in next priority of
801801
* prio in the tree, else return the last flow table in the previous priority
802802
* of prio in the tree.
803803
*/
@@ -829,34 +829,16 @@ static struct mlx5_flow_table *find_prev_chained_ft(struct fs_prio *prio)
829829
return find_closest_ft(prio, true);
830830
}
831831

832-
static struct fs_prio *find_fwd_ns_prio(struct mlx5_flow_root_namespace *root,
833-
struct mlx5_flow_namespace *ns)
834-
{
835-
struct mlx5_flow_namespace *root_ns = &root->ns;
836-
struct fs_prio *iter_prio;
837-
struct fs_prio *prio;
838-
839-
fs_get_obj(prio, ns->node.parent);
840-
list_for_each_entry(iter_prio, &root_ns->node.children, node.list) {
841-
if (iter_prio == prio &&
842-
!list_is_last(&prio->node.children, &iter_prio->node.list))
843-
return list_next_entry(iter_prio, node.list);
844-
}
845-
return NULL;
846-
}
847-
848832
static struct mlx5_flow_table *find_next_fwd_ft(struct mlx5_flow_table *ft,
849833
struct mlx5_flow_act *flow_act)
850834
{
851-
struct mlx5_flow_root_namespace *root = find_root(&ft->node);
852835
struct fs_prio *prio;
836+
bool next_ns;
853837

854-
if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS)
855-
prio = find_fwd_ns_prio(root, ft->ns);
856-
else
857-
fs_get_obj(prio, ft->node.parent);
838+
next_ns = flow_act->action & MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS;
839+
fs_get_obj(prio, next_ns ? ft->ns->node.parent : ft->node.parent);
858840

859-
return (prio) ? find_next_chained_ft(prio) : NULL;
841+
return find_next_chained_ft(prio);
860842
}
861843

862844
static int connect_fts_in_prio(struct mlx5_core_dev *dev,

drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,17 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp,
273273
if (rq->extts.index >= clock->ptp_info.n_pins)
274274
return -EINVAL;
275275

276+
pin = ptp_find_pin(clock->ptp, PTP_PF_EXTTS, rq->extts.index);
277+
if (pin < 0)
278+
return -EBUSY;
279+
276280
if (on) {
277-
pin = ptp_find_pin(clock->ptp, PTP_PF_EXTTS, rq->extts.index);
278-
if (pin < 0)
279-
return -EBUSY;
280281
pin_mode = MLX5_PIN_MODE_IN;
281282
pattern = !!(rq->extts.flags & PTP_FALLING_EDGE);
282283
field_select = MLX5_MTPPS_FS_PIN_MODE |
283284
MLX5_MTPPS_FS_PATTERN |
284285
MLX5_MTPPS_FS_ENABLE;
285286
} else {
286-
pin = rq->extts.index;
287287
field_select = MLX5_MTPPS_FS_ENABLE;
288288
}
289289

@@ -331,12 +331,12 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
331331
if (rq->perout.index >= clock->ptp_info.n_pins)
332332
return -EINVAL;
333333

334-
if (on) {
335-
pin = ptp_find_pin(clock->ptp, PTP_PF_PEROUT,
336-
rq->perout.index);
337-
if (pin < 0)
338-
return -EBUSY;
334+
pin = ptp_find_pin(clock->ptp, PTP_PF_PEROUT,
335+
rq->perout.index);
336+
if (pin < 0)
337+
return -EBUSY;
339338

339+
if (on) {
340340
pin_mode = MLX5_PIN_MODE_OUT;
341341
pattern = MLX5_OUT_PATTERN_PERIODIC;
342342
ts.tv_sec = rq->perout.period.sec;
@@ -362,7 +362,6 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
362362
MLX5_MTPPS_FS_ENABLE |
363363
MLX5_MTPPS_FS_TIME_STAMP;
364364
} else {
365-
pin = rq->perout.index;
366365
field_select = MLX5_MTPPS_FS_ENABLE;
367366
}
368367

@@ -409,10 +408,31 @@ static int mlx5_ptp_enable(struct ptp_clock_info *ptp,
409408
return 0;
410409
}
411410

411+
enum {
412+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN = BIT(0),
413+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT = BIT(1),
414+
};
415+
412416
static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
413417
enum ptp_pin_function func, unsigned int chan)
414418
{
415-
return (func == PTP_PF_PHYSYNC) ? -EOPNOTSUPP : 0;
419+
struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock,
420+
ptp_info);
421+
422+
switch (func) {
423+
case PTP_PF_NONE:
424+
return 0;
425+
case PTP_PF_EXTTS:
426+
return !(clock->pps_info.pin_caps[pin] &
427+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN);
428+
case PTP_PF_PEROUT:
429+
return !(clock->pps_info.pin_caps[pin] &
430+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT);
431+
default:
432+
return -EOPNOTSUPP;
433+
}
434+
435+
return -EOPNOTSUPP;
416436
}
417437

418438
static const struct ptp_clock_info mlx5_ptp_clock_info = {
@@ -432,6 +452,38 @@ static const struct ptp_clock_info mlx5_ptp_clock_info = {
432452
.verify = NULL,
433453
};
434454

455+
static int mlx5_query_mtpps_pin_mode(struct mlx5_core_dev *mdev, u8 pin,
456+
u32 *mtpps, u32 mtpps_size)
457+
{
458+
u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {};
459+
460+
MLX5_SET(mtpps_reg, in, pin, pin);
461+
462+
return mlx5_core_access_reg(mdev, in, sizeof(in), mtpps,
463+
mtpps_size, MLX5_REG_MTPPS, 0, 0);
464+
}
465+
466+
static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
467+
{
468+
struct mlx5_core_dev *mdev = clock->mdev;
469+
u32 out[MLX5_ST_SZ_DW(mtpps_reg)] = {};
470+
u8 mode;
471+
int err;
472+
473+
err = mlx5_query_mtpps_pin_mode(mdev, pin, out, sizeof(out));
474+
if (err || !MLX5_GET(mtpps_reg, out, enable))
475+
return PTP_PF_NONE;
476+
477+
mode = MLX5_GET(mtpps_reg, out, pin_mode);
478+
479+
if (mode == MLX5_PIN_MODE_IN)
480+
return PTP_PF_EXTTS;
481+
else if (mode == MLX5_PIN_MODE_OUT)
482+
return PTP_PF_PEROUT;
483+
484+
return PTP_PF_NONE;
485+
}
486+
435487
static int mlx5_init_pin_config(struct mlx5_clock *clock)
436488
{
437489
int i;
@@ -451,8 +503,8 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock)
451503
sizeof(clock->ptp_info.pin_config[i].name),
452504
"mlx5_pps%d", i);
453505
clock->ptp_info.pin_config[i].index = i;
454-
clock->ptp_info.pin_config[i].func = PTP_PF_NONE;
455-
clock->ptp_info.pin_config[i].chan = i;
506+
clock->ptp_info.pin_config[i].func = mlx5_get_pps_pin_mode(clock, i);
507+
clock->ptp_info.pin_config[i].chan = 0;
456508
}
457509

458510
return 0;

include/linux/mlx5/mlx5_ifc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4381,6 +4381,7 @@ struct mlx5_ifc_query_vport_state_out_bits {
43814381
enum {
43824382
MLX5_VPORT_STATE_OP_MOD_VNIC_VPORT = 0x0,
43834383
MLX5_VPORT_STATE_OP_MOD_ESW_VPORT = 0x1,
4384+
MLX5_VPORT_STATE_OP_MOD_UPLINK = 0x2,
43844385
};
43854386

43864387
struct mlx5_ifc_arm_monitor_counter_in_bits {

0 commit comments

Comments
 (0)