Commit e03f0dfb authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'devlink-instances-relationships'



Jiri Pirko says:

====================
expose devlink instances relationships

From: Jiri Pirko <jiri@nvidia.com>

Currently, the user can instantiate new SF using "devlink port add"
command. That creates an E-switch representor devlink port.

When user activates this SF, there is an auxiliary device created and
probed for it which leads to SF devlink instance creation.

There is 1:1 relationship between E-switch representor devlink port and
the SF auxiliary device devlink instance.

Also, for example in mlx5, one devlink instance is created for
PCI device and one is created for an auxiliary device that represents
the uplink port. The relation between these is invisible to the user.

Patches #1-#3 and #5 are small preparations.

Patch #4 adds netnsid attribute for nested devlink if that in a
different namespace.

Patch #5 is the main one in this set, introduces the relationship
tracking infrastructure later on used to track SFs, linecards and
devlink instance relationships with nested devlink instances.

Expose the relation to the user by introducing new netlink attribute
DEVLINK_PORT_FN_ATTR_DEVLINK which contains the devlink instance related
to devlink port function. This is done by patch #8.
Patch #9 implements this in mlx5 driver.

Patch #10 converts the linecard nested devlink handling to the newly
introduced rel infrastructure.

Patch #11 benefits from the rel infra and introduces possiblitily to
have relation between devlink instances.
Patch #12 implements this in mlx5 driver.

Examples:
$ devlink dev
pci/0000:08:00.0: nested_devlink auxiliary/mlx5_core.eth.0
pci/0000:08:00.1: nested_devlink auxiliary/mlx5_core.eth.1
auxiliary/mlx5_core.eth.1
auxiliary/mlx5_core.eth.0

$ devlink port add pci/0000:08:00.0 flavour pcisf pfnum 0 sfnum 106
pci/0000:08:00.0/32768: type eth netdev eth4 flavour pcisf controller 0 pfnum 0 sfnum 106 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state inactive opstate detached roce enable
$ devlink port function set pci/0000:08:00.0/32768 state active
$ devlink port show pci/0000:08:00.0/32768
pci/0000:08:00.0/32768: type eth netdev eth4 flavour pcisf controller 0 pfnum 0 sfnum 106 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state active opstate attached roce enable nested_devlink auxiliary/mlx5_core.sf.2

$ devlink port show pci/0000:08:00.0/32768
pci/0000:08:00.0/32768: type eth netdev eth4 flavour pcisf controller 0 pfnum 0 sfnum 106 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state active opstate attached roce enable nested_devlink auxiliary/mlx5_core.sf.2 nested_devlink_netns ns1
====================

Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1e73cfe8 6c75258c
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -138,7 +138,6 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
{
	struct mlx5_core_dev *dev = devlink_priv(devlink);
	struct pci_dev *pdev = dev->pdev;
	bool sf_dev_allocated;
	int ret = 0;

	if (mlx5_dev_is_lightweight(dev)) {
@@ -148,16 +147,6 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
		return 0;
	}

	sf_dev_allocated = mlx5_sf_dev_allocated(dev);
	if (sf_dev_allocated) {
		/* Reload results in deleting SF device which further results in
		 * unregistering devlink instance while holding devlink_mutext.
		 * Hence, do not support reload.
		 */
		NL_SET_ERR_MSG_MOD(extack, "reload is unsupported when SFs are allocated");
		return -EOPNOTSUPP;
	}

	if (mlx5_lag_is_active(dev)) {
		NL_SET_ERR_MSG_MOD(extack, "reload is unsupported in Lag mode");
		return -EOPNOTSUPP;
+8 −0
Original line number Diff line number Diff line
@@ -12,11 +12,19 @@ struct mlx5e_dev *mlx5e_create_devlink(struct device *dev,
{
	struct mlx5e_dev *mlx5e_dev;
	struct devlink *devlink;
	int err;

	devlink = devlink_alloc_ns(&mlx5e_devlink_ops, sizeof(*mlx5e_dev),
				   devlink_net(priv_to_devlink(mdev)), dev);
	if (!devlink)
		return ERR_PTR(-ENOMEM);

	err = devl_nested_devlink_set(priv_to_devlink(mdev), devlink);
	if (err) {
		devlink_free(devlink);
		return ERR_PTR(err);
	}

	devlink_register(devlink);
	return devlink_priv(devlink);
}
+1 −1
Original line number Diff line number Diff line
@@ -1405,9 +1405,9 @@ static int mlx5_load(struct mlx5_core_dev *dev)

static void mlx5_unload(struct mlx5_core_dev *dev)
{
	mlx5_eswitch_disable(dev->priv.eswitch);
	mlx5_devlink_traps_unregister(priv_to_devlink(dev));
	mlx5_sf_dev_table_destroy(dev);
	mlx5_eswitch_disable(dev->priv.eswitch);
	mlx5_sriov_detach(dev);
	mlx5_lag_remove_mdev(dev);
	mlx5_ec_cleanup(dev);
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,12 @@ struct mlx5_sf_dev {
	u16 fn_id;
};

struct mlx5_sf_peer_devlink_event_ctx {
	u16 fn_id;
	struct devlink *devlink;
	int err;
};

void mlx5_sf_dev_table_create(struct mlx5_core_dev *dev);
void mlx5_sf_dev_table_destroy(struct mlx5_core_dev *dev);

+26 −0
Original line number Diff line number Diff line
@@ -8,6 +8,20 @@
#include "dev.h"
#include "devlink.h"

static int mlx5_core_peer_devlink_set(struct mlx5_sf_dev *sf_dev, struct devlink *devlink)
{
	struct mlx5_sf_peer_devlink_event_ctx event_ctx = {
		.fn_id = sf_dev->fn_id,
		.devlink = devlink,
	};
	int ret;

	ret = mlx5_blocking_notifier_call_chain(sf_dev->parent_mdev,
						MLX5_DRIVER_EVENT_SF_PEER_DEVLINK,
						&event_ctx);
	return ret == NOTIFY_OK ? event_ctx.err : 0;
}

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);
@@ -54,9 +68,21 @@ static int mlx5_sf_dev_probe(struct auxiliary_device *adev, const struct auxilia
		mlx5_core_warn(mdev, "mlx5_init_one err=%d\n", err);
		goto init_one_err;
	}

	err = mlx5_core_peer_devlink_set(sf_dev, devlink);
	if (err) {
		mlx5_core_warn(mdev, "mlx5_core_peer_devlink_set err=%d\n", err);
		goto peer_devlink_set_err;
	}

	devlink_register(devlink);
	return 0;

peer_devlink_set_err:
	if (mlx5_dev_is_lightweight(sf_dev->mdev))
		mlx5_uninit_one_light(sf_dev->mdev);
	else
		mlx5_uninit_one(sf_dev->mdev);
init_one_err:
	iounmap(mdev->iseg);
remap_err:
Loading