-
Notifications
You must be signed in to change notification settings - Fork 54.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/mlx5: SF, Add auxiliary device driver
Add auxiliary device driver for mlx5 subfunction auxiliary device. A mlx5 subfunction is similar to PCI PF and VF. For a subfunction an auxiliary device is created. As a result, when mlx5 SF auxiliary device binds to the driver, its netdev and rdma device are created, they appear as $ ls -l /sys/bus/auxiliary/devices/ mlx5_core.sf.4 -> ../../../devices/pci0000:00/0000:00:03.0/0000:06:00.0/mlx5_core.sf.4 $ ls -l /sys/class/net/eth1/device /sys/class/net/eth1/device -> ../../../mlx5_core.sf.4 $ cat /sys/bus/auxiliary/devices/mlx5_core.sf.4/sfnum 88 $ devlink dev show pci/0000:06:00.0 auxiliary/mlx5_core.sf.4 $ devlink port show auxiliary/mlx5_core.sf.4/1 auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false $ rdma link show mlx5_0/1 link mlx5_0/1 state ACTIVE physical_state LINK_UP netdev p0sf88 $ rdma dev show 8: rocep6s0f1: node_type ca fw 16.29.0550 node_guid 248a:0703:00b3:d113 sys_image_guid 248a:0703:00b3:d112 13: mlx5_0: node_type ca fw 16.29.0550 node_guid 0000:00ff:fe00:8888 sys_image_guid 248a:0703:00b3:d112 In future, devlink device instance name will adapt to have sfnum annotation using either an alias or as devlink instance name described in RFC [1]. [1] https://lore.kernel.org/netdev/20200519092258.GF4655@nanopsycho/ Signed-off-by: Parav Pandit <parav@nvidia.com> Reviewed-by: Vu Pham <vuhuong@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
- Loading branch information
1 parent
90d010b
commit 1958fc2
Showing
10 changed files
with
187 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | ||
/* Copyright (c) 2020 Mellanox Technologies Ltd */ | ||
|
||
#include <linux/mlx5/driver.h> | ||
#include <linux/mlx5/device.h> | ||
#include "mlx5_core.h" | ||
#include "dev.h" | ||
#include "devlink.h" | ||
|
||
static int mlx5_sf_dev_probe(struct auxiliary_device *adev, const struct auxiliary_device_id *id) | ||
{ | ||
struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, adev); | ||
struct mlx5_core_dev *mdev; | ||
struct devlink *devlink; | ||
int err; | ||
|
||
devlink = mlx5_devlink_alloc(); | ||
if (!devlink) | ||
return -ENOMEM; | ||
|
||
mdev = devlink_priv(devlink); | ||
mdev->device = &adev->dev; | ||
mdev->pdev = sf_dev->parent_mdev->pdev; | ||
mdev->bar_addr = sf_dev->bar_base_addr; | ||
mdev->iseg_base = sf_dev->bar_base_addr; | ||
mdev->coredev_type = MLX5_COREDEV_SF; | ||
mdev->priv.parent_mdev = sf_dev->parent_mdev; | ||
mdev->priv.adev_idx = adev->id; | ||
sf_dev->mdev = mdev; | ||
|
||
err = mlx5_mdev_init(mdev, MLX5_DEFAULT_PROF); | ||
if (err) { | ||
mlx5_core_warn(mdev, "mlx5_mdev_init on err=%d\n", err); | ||
goto mdev_err; | ||
} | ||
|
||
mdev->iseg = ioremap(mdev->iseg_base, sizeof(*mdev->iseg)); | ||
if (!mdev->iseg) { | ||
mlx5_core_warn(mdev, "remap error\n"); | ||
goto remap_err; | ||
} | ||
|
||
err = mlx5_load_one(mdev, true); | ||
if (err) { | ||
mlx5_core_warn(mdev, "mlx5_load_one err=%d\n", err); | ||
goto load_one_err; | ||
} | ||
return 0; | ||
|
||
load_one_err: | ||
iounmap(mdev->iseg); | ||
remap_err: | ||
mlx5_mdev_uninit(mdev); | ||
mdev_err: | ||
mlx5_devlink_free(devlink); | ||
return err; | ||
} | ||
|
||
static void mlx5_sf_dev_remove(struct auxiliary_device *adev) | ||
{ | ||
struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, adev); | ||
struct devlink *devlink; | ||
|
||
devlink = priv_to_devlink(sf_dev->mdev); | ||
mlx5_unload_one(sf_dev->mdev, true); | ||
iounmap(sf_dev->mdev->iseg); | ||
mlx5_mdev_uninit(sf_dev->mdev); | ||
mlx5_devlink_free(devlink); | ||
} | ||
|
||
static void mlx5_sf_dev_shutdown(struct auxiliary_device *adev) | ||
{ | ||
struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, adev); | ||
|
||
mlx5_unload_one(sf_dev->mdev, false); | ||
} | ||
|
||
static const struct auxiliary_device_id mlx5_sf_dev_id_table[] = { | ||
{ .name = MLX5_ADEV_NAME "." MLX5_SF_DEV_ID_NAME, }, | ||
{ }, | ||
}; | ||
|
||
MODULE_DEVICE_TABLE(auxiliary, mlx5_sf_dev_id_table); | ||
|
||
static struct auxiliary_driver mlx5_sf_driver = { | ||
.name = MLX5_SF_DEV_ID_NAME, | ||
.probe = mlx5_sf_dev_probe, | ||
.remove = mlx5_sf_dev_remove, | ||
.shutdown = mlx5_sf_dev_shutdown, | ||
.id_table = mlx5_sf_dev_id_table, | ||
}; | ||
|
||
int mlx5_sf_driver_register(void) | ||
{ | ||
return auxiliary_driver_register(&mlx5_sf_driver); | ||
} | ||
|
||
void mlx5_sf_driver_unregister(void) | ||
{ | ||
auxiliary_driver_unregister(&mlx5_sf_driver); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters