Skip to content

Commit ff8ced4

Browse files
committed
Merge tag 'mlx5-fixes-2023-02-07' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2023-02-07 This series provides bug fixes to mlx5 driver. * tag 'mlx5-fixes-2023-02-07' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5: Serialize module cleanup with reload and remove net/mlx5: fw_tracer, Zero consumer index when reloading the tracer net/mlx5: fw_tracer, Clear load bit when freeing string DBs buffers net/mlx5: Expose SF firmware pages counter net/mlx5: Store page counters in a single array net/mlx5e: IPoIB, Show unknown speed instead of error net/mlx5e: Fix crash unsetting rx-vlan-filter in switchdev mode net/mlx5: Bridge, fix ageing of peer FDB entries net/mlx5: DR, Fix potential race in dr_rule_create_rule_nic net/mlx5e: Update rx ring hw mtu upon each rx-fcs flag change ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents b963d9d + 8f0d145 commit ff8ced4

File tree

13 files changed

+86
-126
lines changed

13 files changed

+86
-126
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ void mlx5_pages_debugfs_init(struct mlx5_core_dev *dev)
245245
pages = dev->priv.dbg.pages_debugfs;
246246

247247
debugfs_create_u32("fw_pages_total", 0400, pages, &dev->priv.fw_pages);
248-
debugfs_create_u32("fw_pages_vfs", 0400, pages, &dev->priv.vfs_pages);
249-
debugfs_create_u32("fw_pages_host_pf", 0400, pages, &dev->priv.host_pf_pages);
248+
debugfs_create_u32("fw_pages_vfs", 0400, pages, &dev->priv.page_counters[MLX5_VF]);
249+
debugfs_create_u32("fw_pages_sfs", 0400, pages, &dev->priv.page_counters[MLX5_SF]);
250+
debugfs_create_u32("fw_pages_host_pf", 0400, pages, &dev->priv.page_counters[MLX5_HOST_PF]);
250251
debugfs_create_u32("fw_pages_alloc_failed", 0400, pages, &dev->priv.fw_pages_alloc_failed);
251252
debugfs_create_u32("fw_pages_give_dropped", 0400, pages, &dev->priv.give_pages_dropped);
252253
debugfs_create_u32("fw_pages_reclaim_discard", 0400, pages,

drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static int mlx5_query_mtrc_caps(struct mlx5_fw_tracer *tracer)
6464
MLX5_GET(mtrc_cap, out, num_string_trace);
6565
tracer->str_db.num_string_db = MLX5_GET(mtrc_cap, out, num_string_db);
6666
tracer->owner = !!MLX5_GET(mtrc_cap, out, trace_owner);
67+
tracer->str_db.loaded = false;
6768

6869
for (i = 0; i < tracer->str_db.num_string_db; i++) {
6970
mtrc_cap_sp = MLX5_ADDR_OF(mtrc_cap, out, string_db_param[i]);
@@ -756,6 +757,7 @@ static int mlx5_fw_tracer_set_mtrc_conf(struct mlx5_fw_tracer *tracer)
756757
if (err)
757758
mlx5_core_warn(dev, "FWTracer: Failed to set tracer configurations %d\n", err);
758759

760+
tracer->buff.consumer_index = 0;
759761
return err;
760762
}
761763

@@ -820,7 +822,6 @@ static void mlx5_fw_tracer_ownership_change(struct work_struct *work)
820822
mlx5_core_dbg(tracer->dev, "FWTracer: ownership changed, current=(%d)\n", tracer->owner);
821823
if (tracer->owner) {
822824
tracer->owner = false;
823-
tracer->buff.consumer_index = 0;
824825
return;
825826
}
826827

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void mlx5_ec_cleanup(struct mlx5_core_dev *dev)
8787

8888
mlx5_host_pf_cleanup(dev);
8989

90-
err = mlx5_wait_for_pages(dev, &dev->priv.host_pf_pages);
90+
err = mlx5_wait_for_pages(dev, &dev->priv.page_counters[MLX5_HOST_PF]);
9191
if (err)
9292
mlx5_core_warn(dev, "Timeout reclaiming external host PF pages err(%d)\n", err);
9393
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,6 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb,
438438

439439
switch (event) {
440440
case SWITCHDEV_FDB_ADD_TO_BRIDGE:
441-
/* only handle the event on native eswtich of representor */
442-
if (!mlx5_esw_bridge_is_local(dev, rep, esw))
443-
break;
444-
445441
fdb_info = container_of(info,
446442
struct switchdev_notifier_fdb_info,
447443
info);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ void mlx5e_enable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc)
443443

444444
void mlx5e_disable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc)
445445
{
446-
if (fs->vlan->cvlan_filter_disabled)
446+
if (!fs->vlan || fs->vlan->cvlan_filter_disabled)
447447
return;
448448

449449
fs->vlan->cvlan_filter_disabled = true;

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

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param
591591
rq->ix = c->ix;
592592
rq->channel = c;
593593
rq->mdev = mdev;
594-
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
594+
rq->hw_mtu =
595+
MLX5E_SW2HW_MTU(params, params->sw_mtu) - ETH_FCS_LEN * !params->scatter_fcs_en;
595596
rq->xdpsq = &c->rq_xdpsq;
596597
rq->stats = &c->priv->channel_stats[c->ix]->rq;
597598
rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
@@ -1014,35 +1015,6 @@ int mlx5e_flush_rq(struct mlx5e_rq *rq, int curr_state)
10141015
return mlx5e_rq_to_ready(rq, curr_state);
10151016
}
10161017

1017-
static int mlx5e_modify_rq_scatter_fcs(struct mlx5e_rq *rq, bool enable)
1018-
{
1019-
struct mlx5_core_dev *mdev = rq->mdev;
1020-
1021-
void *in;
1022-
void *rqc;
1023-
int inlen;
1024-
int err;
1025-
1026-
inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
1027-
in = kvzalloc(inlen, GFP_KERNEL);
1028-
if (!in)
1029-
return -ENOMEM;
1030-
1031-
rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
1032-
1033-
MLX5_SET(modify_rq_in, in, rq_state, MLX5_RQC_STATE_RDY);
1034-
MLX5_SET64(modify_rq_in, in, modify_bitmask,
1035-
MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_SCATTER_FCS);
1036-
MLX5_SET(rqc, rqc, scatter_fcs, enable);
1037-
MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RDY);
1038-
1039-
err = mlx5_core_modify_rq(mdev, rq->rqn, in);
1040-
1041-
kvfree(in);
1042-
1043-
return err;
1044-
}
1045-
10461018
static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
10471019
{
10481020
struct mlx5_core_dev *mdev = rq->mdev;
@@ -3314,20 +3286,6 @@ static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
33143286
mlx5e_destroy_tises(priv);
33153287
}
33163288

3317-
static int mlx5e_modify_channels_scatter_fcs(struct mlx5e_channels *chs, bool enable)
3318-
{
3319-
int err = 0;
3320-
int i;
3321-
3322-
for (i = 0; i < chs->num; i++) {
3323-
err = mlx5e_modify_rq_scatter_fcs(&chs->c[i]->rq, enable);
3324-
if (err)
3325-
return err;
3326-
}
3327-
3328-
return 0;
3329-
}
3330-
33313289
static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd)
33323290
{
33333291
int err;
@@ -3903,41 +3861,27 @@ static int mlx5e_set_rx_port_ts(struct mlx5_core_dev *mdev, bool enable)
39033861
return mlx5_set_ports_check(mdev, in, sizeof(in));
39043862
}
39053863

3864+
static int mlx5e_set_rx_port_ts_wrap(struct mlx5e_priv *priv, void *ctx)
3865+
{
3866+
struct mlx5_core_dev *mdev = priv->mdev;
3867+
bool enable = *(bool *)ctx;
3868+
3869+
return mlx5e_set_rx_port_ts(mdev, enable);
3870+
}
3871+
39063872
static int set_feature_rx_fcs(struct net_device *netdev, bool enable)
39073873
{
39083874
struct mlx5e_priv *priv = netdev_priv(netdev);
39093875
struct mlx5e_channels *chs = &priv->channels;
3910-
struct mlx5_core_dev *mdev = priv->mdev;
3876+
struct mlx5e_params new_params;
39113877
int err;
39123878

39133879
mutex_lock(&priv->state_lock);
39143880

3915-
if (enable) {
3916-
err = mlx5e_set_rx_port_ts(mdev, false);
3917-
if (err)
3918-
goto out;
3919-
3920-
chs->params.scatter_fcs_en = true;
3921-
err = mlx5e_modify_channels_scatter_fcs(chs, true);
3922-
if (err) {
3923-
chs->params.scatter_fcs_en = false;
3924-
mlx5e_set_rx_port_ts(mdev, true);
3925-
}
3926-
} else {
3927-
chs->params.scatter_fcs_en = false;
3928-
err = mlx5e_modify_channels_scatter_fcs(chs, false);
3929-
if (err) {
3930-
chs->params.scatter_fcs_en = true;
3931-
goto out;
3932-
}
3933-
err = mlx5e_set_rx_port_ts(mdev, true);
3934-
if (err) {
3935-
mlx5_core_warn(mdev, "Failed to set RX port timestamp %d\n", err);
3936-
err = 0;
3937-
}
3938-
}
3939-
3940-
out:
3881+
new_params = chs->params;
3882+
new_params.scatter_fcs_en = enable;
3883+
err = mlx5e_safe_switch_params(priv, &new_params, mlx5e_set_rx_port_ts_wrap,
3884+
&new_params.scatter_fcs_en, true);
39413885
mutex_unlock(&priv->state_lock);
39423886
return err;
39433887
}
@@ -4074,6 +4018,10 @@ static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev
40744018
if (netdev->features & NETIF_F_GRO_HW)
40754019
netdev_warn(netdev, "Disabling HW_GRO, not supported in switchdev mode\n");
40764020

4021+
features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
4022+
if (netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
4023+
netdev_warn(netdev, "Disabling HW_VLAN CTAG FILTERING, not supported in switchdev mode\n");
4024+
40774025
return features;
40784026
}
40794027

drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ void mlx5_esw_bridge_fdb_update_used(struct net_device *dev, u16 vport_num, u16
17151715
struct mlx5_esw_bridge *bridge;
17161716

17171717
port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
1718-
if (!port || port->flags & MLX5_ESW_BRIDGE_PORT_FLAG_PEER)
1718+
if (!port)
17191719
return;
17201720

17211721
bridge = port->bridge;

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,16 @@ static inline int mlx5_ptys_rate_enum_to_int(enum mlx5_ptys_rate rate)
189189
}
190190
}
191191

192-
static int mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper)
192+
static u32 mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper)
193193
{
194194
int rate, width;
195195

196196
rate = mlx5_ptys_rate_enum_to_int(ib_proto_oper);
197197
if (rate < 0)
198-
return -EINVAL;
198+
return SPEED_UNKNOWN;
199199
width = mlx5_ptys_width_enum_to_int(ib_link_width_oper);
200200
if (width < 0)
201-
return -EINVAL;
201+
return SPEED_UNKNOWN;
202202

203203
return rate * width;
204204
}
@@ -221,16 +221,13 @@ static int mlx5i_get_link_ksettings(struct net_device *netdev,
221221
ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising);
222222

223223
speed = mlx5i_get_speed_settings(ib_link_width_oper, ib_proto_oper);
224-
if (speed < 0)
225-
return -EINVAL;
224+
link_ksettings->base.speed = speed;
225+
link_ksettings->base.duplex = speed == SPEED_UNKNOWN ? DUPLEX_UNKNOWN : DUPLEX_FULL;
226226

227-
link_ksettings->base.duplex = DUPLEX_FULL;
228227
link_ksettings->base.port = PORT_OTHER;
229228

230229
link_ksettings->base.autoneg = AUTONEG_DISABLE;
231230

232-
link_ksettings->base.speed = speed;
233-
234231
return 0;
235232
}
236233

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,34 +2110,34 @@ static int __init mlx5_init(void)
21102110
mlx5_core_verify_params();
21112111
mlx5_register_debugfs();
21122112

2113-
err = pci_register_driver(&mlx5_core_driver);
2113+
err = mlx5e_init();
21142114
if (err)
21152115
goto err_debug;
21162116

21172117
err = mlx5_sf_driver_register();
21182118
if (err)
21192119
goto err_sf;
21202120

2121-
err = mlx5e_init();
2121+
err = pci_register_driver(&mlx5_core_driver);
21222122
if (err)
2123-
goto err_en;
2123+
goto err_pci;
21242124

21252125
return 0;
21262126

2127-
err_en:
2127+
err_pci:
21282128
mlx5_sf_driver_unregister();
21292129
err_sf:
2130-
pci_unregister_driver(&mlx5_core_driver);
2130+
mlx5e_cleanup();
21312131
err_debug:
21322132
mlx5_unregister_debugfs();
21332133
return err;
21342134
}
21352135

21362136
static void __exit mlx5_cleanup(void)
21372137
{
2138-
mlx5e_cleanup();
2139-
mlx5_sf_driver_unregister();
21402138
pci_unregister_driver(&mlx5_core_driver);
2139+
mlx5_sf_driver_unregister();
2140+
mlx5e_cleanup();
21412141
mlx5_unregister_debugfs();
21422142
}
21432143

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ static u32 get_function(u16 func_id, bool ec_function)
7474
return (u32)func_id | (ec_function << 16);
7575
}
7676

77+
static u16 func_id_to_type(struct mlx5_core_dev *dev, u16 func_id, bool ec_function)
78+
{
79+
if (!func_id)
80+
return mlx5_core_is_ecpf(dev) && !ec_function ? MLX5_HOST_PF : MLX5_PF;
81+
82+
return func_id <= mlx5_core_max_vfs(dev) ? MLX5_VF : MLX5_SF;
83+
}
84+
7785
static struct rb_root *page_root_per_function(struct mlx5_core_dev *dev, u32 function)
7886
{
7987
struct rb_root *root;
@@ -332,6 +340,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
332340
u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};
333341
int inlen = MLX5_ST_SZ_BYTES(manage_pages_in);
334342
int notify_fail = event;
343+
u16 func_type;
335344
u64 addr;
336345
int err;
337346
u32 *in;
@@ -383,11 +392,9 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
383392
goto out_dropped;
384393
}
385394

395+
func_type = func_id_to_type(dev, func_id, ec_function);
396+
dev->priv.page_counters[func_type] += npages;
386397
dev->priv.fw_pages += npages;
387-
if (func_id)
388-
dev->priv.vfs_pages += npages;
389-
else if (mlx5_core_is_ecpf(dev) && !ec_function)
390-
dev->priv.host_pf_pages += npages;
391398

392399
mlx5_core_dbg(dev, "npages %d, ec_function %d, func_id 0x%x, err %d\n",
393400
npages, ec_function, func_id, err);
@@ -414,6 +421,7 @@ static void release_all_pages(struct mlx5_core_dev *dev, u16 func_id,
414421
struct rb_root *root;
415422
struct rb_node *p;
416423
int npages = 0;
424+
u16 func_type;
417425

418426
root = xa_load(&dev->priv.page_root_xa, function);
419427
if (WARN_ON_ONCE(!root))
@@ -428,11 +436,9 @@ static void release_all_pages(struct mlx5_core_dev *dev, u16 func_id,
428436
free_fwp(dev, fwp, fwp->free_count);
429437
}
430438

439+
func_type = func_id_to_type(dev, func_id, ec_function);
440+
dev->priv.page_counters[func_type] -= npages;
431441
dev->priv.fw_pages -= npages;
432-
if (func_id)
433-
dev->priv.vfs_pages -= npages;
434-
else if (mlx5_core_is_ecpf(dev) && !ec_function)
435-
dev->priv.host_pf_pages -= npages;
436442

437443
mlx5_core_dbg(dev, "npages %d, ec_function %d, func_id 0x%x\n",
438444
npages, ec_function, func_id);
@@ -498,6 +504,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
498504
int outlen = MLX5_ST_SZ_BYTES(manage_pages_out);
499505
u32 in[MLX5_ST_SZ_DW(manage_pages_in)] = {};
500506
int num_claimed;
507+
u16 func_type;
501508
u32 *out;
502509
int err;
503510
int i;
@@ -549,11 +556,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
549556
if (nclaimed)
550557
*nclaimed = num_claimed;
551558

559+
func_type = func_id_to_type(dev, func_id, ec_function);
560+
dev->priv.page_counters[func_type] -= num_claimed;
552561
dev->priv.fw_pages -= num_claimed;
553-
if (func_id)
554-
dev->priv.vfs_pages -= num_claimed;
555-
else if (mlx5_core_is_ecpf(dev) && !ec_function)
556-
dev->priv.host_pf_pages -= num_claimed;
557562

558563
out_free:
559564
kvfree(out);
@@ -706,12 +711,12 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev)
706711
WARN(dev->priv.fw_pages,
707712
"FW pages counter is %d after reclaiming all pages\n",
708713
dev->priv.fw_pages);
709-
WARN(dev->priv.vfs_pages,
714+
WARN(dev->priv.page_counters[MLX5_VF],
710715
"VFs FW pages counter is %d after reclaiming all pages\n",
711-
dev->priv.vfs_pages);
712-
WARN(dev->priv.host_pf_pages,
716+
dev->priv.page_counters[MLX5_VF]);
717+
WARN(dev->priv.page_counters[MLX5_HOST_PF],
713718
"External host PF FW pages counter is %d after reclaiming all pages\n",
714-
dev->priv.host_pf_pages);
719+
dev->priv.page_counters[MLX5_HOST_PF]);
715720

716721
return 0;
717722
}

0 commit comments

Comments
 (0)