Skip to content

Commit 82376e2

Browse files
author
Herton R. Krzesinski
committed
Merge: CNB: rebase/update devlink for RHEL 9.2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1690 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2131117 Tested: selftests, basic devlink features on ice and mlx5 Depends: https://bugzilla.redhat.com/show_bug.cgi?id=2140704 Depends: https://bugzilla.redhat.com/show_bug.cgi?id=2112940 Update devlink up to v6.1. Signed-off-by: Petr Oros <poros@redhat.com> Approved-by: Ivan Vecera <ivecera@redhat.com> Approved-by: Marcelo Ricardo Leitner <mleitner@redhat.com> Approved-by: Kamal Heib <kheib@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 8117149 + e70b74b commit 82376e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2336
-1512
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
3+
=================
4+
Devlink Selftests
5+
=================
6+
7+
The ``devlink-selftests`` API allows executing selftests on the device.
8+
9+
Tests Mask
10+
==========
11+
The ``devlink-selftests`` command should be run with a mask indicating
12+
the tests to be executed.
13+
14+
Tests Description
15+
=================
16+
The following is a list of tests that drivers may execute.
17+
18+
.. list-table:: List of tests
19+
:widths: 5 90
20+
21+
* - Name
22+
- Description
23+
* - ``DEVLINK_SELFTEST_FLASH``
24+
- Devices may have the firmware on non-volatile memory on the board, e.g.
25+
flash. This particular test helps to run a flash selftest on the device.
26+
Implementation of the test is left to the driver/firmware.
27+
28+
example usage
29+
-------------
30+
31+
.. code:: shell
32+
33+
# Query selftests supported on the devlink device
34+
$ devlink dev selftests show DEV
35+
# Query selftests supported on all devlink devices
36+
$ devlink dev selftests show
37+
# Executes selftests on the device
38+
$ devlink dev selftests run DEV id flash

Documentation/networking/devlink/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ general.
3838
devlink-region
3939
devlink-resource
4040
devlink-reload
41+
devlink-selftests
4142
devlink-trap
4243
devlink-linecard
4344

drivers/net/ethernet/mellanox/mlx4/catas.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,13 @@ void mlx4_enter_error_state(struct mlx4_dev_persistent *persist)
204204

205205
static void mlx4_handle_error_state(struct mlx4_dev_persistent *persist)
206206
{
207+
struct mlx4_dev *dev = persist->dev;
208+
struct devlink *devlink;
207209
int err = 0;
208210

209211
mlx4_enter_error_state(persist);
212+
devlink = priv_to_devlink(mlx4_priv(dev));
213+
devl_lock(devlink);
210214
mutex_lock(&persist->interface_state_mutex);
211215
if (persist->interface_state & MLX4_INTERFACE_STATE_UP &&
212216
!(persist->interface_state & MLX4_INTERFACE_STATE_DELETION)) {
@@ -215,6 +219,7 @@ static void mlx4_handle_error_state(struct mlx4_dev_persistent *persist)
215219
err);
216220
}
217221
mutex_unlock(&persist->interface_state_mutex);
222+
devl_unlock(devlink);
218223
}
219224

220225
static void dump_err_buf(struct mlx4_dev *dev)

drivers/net/ethernet/mellanox/mlx4/crdump.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,21 @@ int mlx4_crdump_init(struct mlx4_dev *dev)
226226

227227
/* Create cr-space region */
228228
crdump->region_crspace =
229-
devlink_region_create(devlink,
230-
&region_cr_space_ops,
231-
MAX_NUM_OF_DUMPS_TO_STORE,
232-
pci_resource_len(pdev, 0));
229+
devl_region_create(devlink,
230+
&region_cr_space_ops,
231+
MAX_NUM_OF_DUMPS_TO_STORE,
232+
pci_resource_len(pdev, 0));
233233
if (IS_ERR(crdump->region_crspace))
234234
mlx4_warn(dev, "crdump: create devlink region %s err %ld\n",
235235
region_cr_space_str,
236236
PTR_ERR(crdump->region_crspace));
237237

238238
/* Create fw-health region */
239239
crdump->region_fw_health =
240-
devlink_region_create(devlink,
241-
&region_fw_health_ops,
242-
MAX_NUM_OF_DUMPS_TO_STORE,
243-
HEALTH_BUFFER_SIZE);
240+
devl_region_create(devlink,
241+
&region_fw_health_ops,
242+
MAX_NUM_OF_DUMPS_TO_STORE,
243+
HEALTH_BUFFER_SIZE);
244244
if (IS_ERR(crdump->region_fw_health))
245245
mlx4_warn(dev, "crdump: create devlink region %s err %ld\n",
246246
region_fw_health_str,
@@ -253,6 +253,6 @@ void mlx4_crdump_end(struct mlx4_dev *dev)
253253
{
254254
struct mlx4_fw_crdump *crdump = &dev->persist->crdump;
255255

256-
devlink_region_destroy(crdump->region_fw_health);
257-
devlink_region_destroy(crdump->region_crspace);
256+
devl_region_destroy(crdump->region_fw_health);
257+
devl_region_destroy(crdump->region_crspace);
258258
}

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
30333033
struct mlx4_port_info *info = &mlx4_priv(dev)->port[port];
30343034
int err;
30353035

3036-
err = devlink_port_register(devlink, &info->devlink_port, port);
3036+
err = devl_port_register(devlink, &info->devlink_port, port);
30373037
if (err)
30383038
return err;
30393039

@@ -3071,7 +3071,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
30713071
err = device_create_file(&dev->persist->pdev->dev, &info->port_attr);
30723072
if (err) {
30733073
mlx4_err(dev, "Failed to create file for port %d\n", port);
3074-
devlink_port_unregister(&info->devlink_port);
3074+
devl_port_unregister(&info->devlink_port);
30753075
info->port = -1;
30763076
return err;
30773077
}
@@ -3093,7 +3093,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
30933093
mlx4_err(dev, "Failed to create mtu file for port %d\n", port);
30943094
device_remove_file(&info->dev->persist->pdev->dev,
30953095
&info->port_attr);
3096-
devlink_port_unregister(&info->devlink_port);
3096+
devl_port_unregister(&info->devlink_port);
30973097
info->port = -1;
30983098
return err;
30993099
}
@@ -3109,7 +3109,7 @@ static void mlx4_cleanup_port_info(struct mlx4_port_info *info)
31093109
device_remove_file(&info->dev->persist->pdev->dev, &info->port_attr);
31103110
device_remove_file(&info->dev->persist->pdev->dev,
31113111
&info->port_mtu_attr);
3112-
devlink_port_unregister(&info->devlink_port);
3112+
devl_port_unregister(&info->devlink_port);
31133113

31143114
#ifdef CONFIG_RFS_ACCEL
31153115
free_irq_cpu_rmap(info->rmap);
@@ -3333,6 +3333,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
33333333
int total_vfs, int *nvfs, struct mlx4_priv *priv,
33343334
int reset_flow)
33353335
{
3336+
struct devlink *devlink = priv_to_devlink(priv);
33363337
struct mlx4_dev *dev;
33373338
unsigned sum = 0;
33383339
int err;
@@ -3341,6 +3342,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
33413342
struct mlx4_dev_cap *dev_cap = NULL;
33423343
int existing_vfs = 0;
33433344

3345+
devl_assert_locked(devlink);
33443346
dev = &priv->dev;
33453347

33463348
INIT_LIST_HEAD(&priv->ctx_list);
@@ -3999,6 +4001,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
39994001
devlink = devlink_alloc(&mlx4_devlink_ops, sizeof(*priv), &pdev->dev);
40004002
if (!devlink)
40014003
return -ENOMEM;
4004+
devl_lock(devlink);
40024005
priv = devlink_priv(devlink);
40034006

40044007
dev = &priv->dev;
@@ -4026,6 +4029,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
40264029

40274030
pci_save_state(pdev);
40284031
devlink_set_features(devlink, DEVLINK_F_RELOAD);
4032+
devl_unlock(devlink);
40294033
devlink_register(devlink);
40304034
return 0;
40314035

@@ -4035,6 +4039,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
40354039
err_devlink_unregister:
40364040
kfree(dev->persist);
40374041
err_devlink_free:
4042+
devl_unlock(devlink);
40384043
devlink_free(devlink);
40394044
return ret;
40404045
}
@@ -4056,8 +4061,11 @@ static void mlx4_unload_one(struct pci_dev *pdev)
40564061
struct mlx4_dev *dev = persist->dev;
40574062
struct mlx4_priv *priv = mlx4_priv(dev);
40584063
int pci_dev_data;
4064+
struct devlink *devlink;
40594065
int p, i;
40604066

4067+
devlink = priv_to_devlink(priv);
4068+
devl_assert_locked(devlink);
40614069
if (priv->removed)
40624070
return;
40634071

@@ -4137,6 +4145,7 @@ static void mlx4_remove_one(struct pci_dev *pdev)
41374145

41384146
devlink_unregister(devlink);
41394147

4148+
devl_lock(devlink);
41404149
if (mlx4_is_slave(dev))
41414150
persist->interface_state |= MLX4_INTERFACE_STATE_NOWAIT;
41424151

@@ -4172,6 +4181,7 @@ static void mlx4_remove_one(struct pci_dev *pdev)
41724181
devlink_params_unregister(devlink, mlx4_devlink_params,
41734182
ARRAY_SIZE(mlx4_devlink_params));
41744183
kfree(dev->persist);
4184+
devl_unlock(devlink);
41754185
devlink_free(devlink);
41764186
}
41774187

@@ -4292,15 +4302,20 @@ static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev,
42924302
pci_channel_state_t state)
42934303
{
42944304
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
4305+
struct mlx4_dev *dev = persist->dev;
4306+
struct devlink *devlink;
42954307

42964308
mlx4_err(persist->dev, "mlx4_pci_err_detected was called\n");
42974309
mlx4_enter_error_state(persist);
42984310

4311+
devlink = priv_to_devlink(mlx4_priv(dev));
4312+
devl_lock(devlink);
42994313
mutex_lock(&persist->interface_state_mutex);
43004314
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
43014315
mlx4_unload_one(pdev);
43024316

43034317
mutex_unlock(&persist->interface_state_mutex);
4318+
devl_unlock(devlink);
43044319
if (state == pci_channel_io_perm_failure)
43054320
return PCI_ERS_RESULT_DISCONNECT;
43064321

@@ -4333,13 +4348,16 @@ static void mlx4_pci_resume(struct pci_dev *pdev)
43334348
struct mlx4_dev *dev = persist->dev;
43344349
struct mlx4_priv *priv = mlx4_priv(dev);
43354350
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
4351+
struct devlink *devlink;
43364352
int total_vfs;
43374353
int err;
43384354

43394355
mlx4_err(dev, "%s was called\n", __func__);
43404356
total_vfs = dev->persist->num_vfs;
43414357
memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
43424358

4359+
devlink = priv_to_devlink(priv);
4360+
devl_lock(devlink);
43434361
mutex_lock(&persist->interface_state_mutex);
43444362
if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) {
43454363
err = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs, nvfs,
@@ -4358,19 +4376,23 @@ static void mlx4_pci_resume(struct pci_dev *pdev)
43584376
}
43594377
end:
43604378
mutex_unlock(&persist->interface_state_mutex);
4361-
4379+
devl_unlock(devlink);
43624380
}
43634381

43644382
static void mlx4_shutdown(struct pci_dev *pdev)
43654383
{
43664384
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
43674385
struct mlx4_dev *dev = persist->dev;
4386+
struct devlink *devlink;
43684387

43694388
mlx4_info(persist->dev, "mlx4_shutdown was called\n");
4389+
devlink = priv_to_devlink(mlx4_priv(dev));
4390+
devl_lock(devlink);
43704391
mutex_lock(&persist->interface_state_mutex);
43714392
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
43724393
mlx4_unload_one(pdev);
43734394
mutex_unlock(&persist->interface_state_mutex);
4395+
devl_unlock(devlink);
43744396
mlx4_pci_disable_device(dev);
43754397
}
43764398

@@ -4385,12 +4407,16 @@ static int __maybe_unused mlx4_suspend(struct device *dev_d)
43854407
struct pci_dev *pdev = to_pci_dev(dev_d);
43864408
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
43874409
struct mlx4_dev *dev = persist->dev;
4410+
struct devlink *devlink;
43884411

43894412
mlx4_err(dev, "suspend was called\n");
4413+
devlink = priv_to_devlink(mlx4_priv(dev));
4414+
devl_lock(devlink);
43904415
mutex_lock(&persist->interface_state_mutex);
43914416
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
43924417
mlx4_unload_one(pdev);
43934418
mutex_unlock(&persist->interface_state_mutex);
4419+
devl_unlock(devlink);
43944420

43954421
return 0;
43964422
}
@@ -4402,13 +4428,16 @@ static int __maybe_unused mlx4_resume(struct device *dev_d)
44024428
struct mlx4_dev *dev = persist->dev;
44034429
struct mlx4_priv *priv = mlx4_priv(dev);
44044430
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
4431+
struct devlink *devlink;
44054432
int total_vfs;
44064433
int ret = 0;
44074434

44084435
mlx4_err(dev, "resume was called\n");
44094436
total_vfs = dev->persist->num_vfs;
44104437
memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
44114438

4439+
devlink = priv_to_devlink(priv);
4440+
devl_lock(devlink);
44124441
mutex_lock(&persist->interface_state_mutex);
44134442
if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) {
44144443
ret = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs,
@@ -4422,6 +4451,7 @@ static int __maybe_unused mlx4_resume(struct device *dev_d)
44224451
}
44234452
}
44244453
mutex_unlock(&persist->interface_state_mutex);
4454+
devl_unlock(devlink);
44254455

44264456
return ret;
44274457
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,10 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
340340
struct auxiliary_driver *adrv;
341341
int ret = 0, i;
342342

343+
devl_assert_locked(priv_to_devlink(dev));
343344
mutex_lock(&mlx5_intf_mutex);
344345
priv->flags &= ~MLX5_PRIV_FLAGS_DETACH;
346+
priv->flags |= MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW;
345347
for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) {
346348
if (!priv->adev[i]) {
347349
bool is_supported = false;
@@ -389,6 +391,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
389391
break;
390392
}
391393
}
394+
priv->flags &= ~MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW;
392395
mutex_unlock(&mlx5_intf_mutex);
393396
return ret;
394397
}
@@ -401,7 +404,9 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)
401404
pm_message_t pm = {};
402405
int i;
403406

407+
devl_assert_locked(priv_to_devlink(dev));
404408
mutex_lock(&mlx5_intf_mutex);
409+
priv->flags |= MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW;
405410
for (i = ARRAY_SIZE(mlx5_adev_devices) - 1; i >= 0; i--) {
406411
if (!priv->adev[i])
407412
continue;
@@ -430,6 +435,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)
430435
del_adev(&priv->adev[i]->adev);
431436
priv->adev[i] = NULL;
432437
}
438+
priv->flags &= ~MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW;
433439
priv->flags |= MLX5_PRIV_FLAGS_DETACH;
434440
mutex_unlock(&mlx5_intf_mutex);
435441
}
@@ -438,6 +444,7 @@ int mlx5_register_device(struct mlx5_core_dev *dev)
438444
{
439445
int ret;
440446

447+
devl_assert_locked(priv_to_devlink(dev));
441448
mutex_lock(&mlx5_intf_mutex);
442449
dev->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV;
443450
ret = mlx5_rescan_drivers_locked(dev);
@@ -450,6 +457,7 @@ int mlx5_register_device(struct mlx5_core_dev *dev)
450457

451458
void mlx5_unregister_device(struct mlx5_core_dev *dev)
452459
{
460+
devl_assert_locked(priv_to_devlink(dev));
453461
mutex_lock(&mlx5_intf_mutex);
454462
dev->priv.flags = MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV;
455463
mlx5_rescan_drivers_locked(dev);
@@ -526,16 +534,22 @@ static void delete_drivers(struct mlx5_core_dev *dev)
526534
int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev)
527535
{
528536
struct mlx5_priv *priv = &dev->priv;
537+
int err = 0;
529538

530539
lockdep_assert_held(&mlx5_intf_mutex);
531540
if (priv->flags & MLX5_PRIV_FLAGS_DETACH)
532541
return 0;
533542

543+
priv->flags |= MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW;
534544
delete_drivers(dev);
535545
if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV)
536-
return 0;
546+
goto out;
547+
548+
err = add_drivers(dev);
537549

538-
return add_drivers(dev);
550+
out:
551+
priv->flags &= ~MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW;
552+
return err;
539553
}
540554

541555
bool mlx5_same_hw_devs(struct mlx5_core_dev *dev, struct mlx5_core_dev *peer_dev)

0 commit comments

Comments
 (0)