]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - drivers/net/ethernet/mellanox/mlx5/core/devlink.c
net/mlx5: Move all devlink related functions calls to devlink.c
[mirror_ubuntu-eoan-kernel.git] / drivers / net / ethernet / mellanox / mlx5 / core / devlink.c
1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2 /* Copyright (c) 2019 Mellanox Technologies */
3
4 #include <devlink.h>
5
6 #include "mlx5_core.h"
7 #include "eswitch.h"
8
9 static int mlx5_devlink_flash_update(struct devlink *devlink,
10 const char *file_name,
11 const char *component,
12 struct netlink_ext_ack *extack)
13 {
14 struct mlx5_core_dev *dev = devlink_priv(devlink);
15 const struct firmware *fw;
16 int err;
17
18 if (component)
19 return -EOPNOTSUPP;
20
21 err = request_firmware_direct(&fw, file_name, &dev->pdev->dev);
22 if (err)
23 return err;
24
25 return mlx5_firmware_flash(dev, fw, extack);
26 }
27
28 static const struct devlink_ops mlx5_devlink_ops = {
29 #ifdef CONFIG_MLX5_ESWITCH
30 .eswitch_mode_set = mlx5_devlink_eswitch_mode_set,
31 .eswitch_mode_get = mlx5_devlink_eswitch_mode_get,
32 .eswitch_inline_mode_set = mlx5_devlink_eswitch_inline_mode_set,
33 .eswitch_inline_mode_get = mlx5_devlink_eswitch_inline_mode_get,
34 .eswitch_encap_mode_set = mlx5_devlink_eswitch_encap_mode_set,
35 .eswitch_encap_mode_get = mlx5_devlink_eswitch_encap_mode_get,
36 #endif
37 .flash_update = mlx5_devlink_flash_update,
38 };
39
40 struct devlink *mlx5_devlink_alloc()
41 {
42 return devlink_alloc(&mlx5_devlink_ops, sizeof(struct mlx5_core_dev));
43 }
44
45 void mlx5_devlink_free(struct devlink *devlink)
46 {
47 devlink_free(devlink);
48 }
49
50 int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
51 {
52 return devlink_register(devlink, dev);
53 }
54
55 void mlx5_devlink_unregister(struct devlink *devlink)
56 {
57 devlink_unregister(devlink);
58 }