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

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/intf.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx4/intf.c
Extension
.c
Size
9498 bytes
Lines
391
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ret) {
			mlx4_err(dev, "Fail to reset port map\n");
			return ret;
		}
		dev->flags &= ~MLX4_FLAG_BONDED;
	}

	mutex_lock(&intf_mutex);

	for (i = 0; i < ARRAY_SIZE(mlx4_adev_devices); i++) {
		struct mlx4_adev *madev = priv->adev[i];
		struct mlx4_adrv *madrv;
		enum mlx4_protocol protocol;

		if (!madev)
			continue;

		device_lock(&madev->adev.dev);
		if (!madev->adev.dev.driver) {
			device_unlock(&madev->adev.dev);
			continue;
		}

		madrv = container_of(madev->adev.dev.driver, struct mlx4_adrv,
				     adrv.driver);
		if (!(madrv->flags & MLX4_INTFF_BONDING)) {
			device_unlock(&madev->adev.dev);
			continue;
		}

		if (mlx4_is_mfunc(dev)) {
			mlx4_dbg(dev,
				 "SRIOV, disabled HA mode for intf proto %d\n",
				 madrv->protocol);
			device_unlock(&madev->adev.dev);
			continue;
		}

		protocol = madrv->protocol;
		device_unlock(&madev->adev.dev);

		del_adev(&madev->adev);
		priv->adev[i] = add_adev(dev, i);
		if (IS_ERR(priv->adev[i])) {
			mlx4_warn(dev, "Device[%d] (%s) failed to load\n", i,
				  mlx4_adev_devices[i].suffix);
			priv->adev[i] = NULL;
			continue;
		}

		mlx4_dbg(dev,
			 "Interface for protocol %d restarted with bonded mode %s\n",
			 protocol, enable ? "enabled" : "disabled");
	}

	mutex_unlock(&intf_mutex);

	return 0;
}

void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,
			 void *param)
{
	struct mlx4_priv *priv = mlx4_priv(dev);

	atomic_notifier_call_chain(&priv->event_nh, type, param);
}

int mlx4_register_event_notifier(struct mlx4_dev *dev,
				 struct notifier_block *nb)
{
	struct mlx4_priv *priv = mlx4_priv(dev);

	return atomic_notifier_chain_register(&priv->event_nh, nb);
}
EXPORT_SYMBOL(mlx4_register_event_notifier);

int mlx4_unregister_event_notifier(struct mlx4_dev *dev,
				   struct notifier_block *nb)
{
	struct mlx4_priv *priv = mlx4_priv(dev);

	return atomic_notifier_chain_unregister(&priv->event_nh, nb);
}
EXPORT_SYMBOL(mlx4_unregister_event_notifier);

static int add_drivers(struct mlx4_dev *dev)
{
	struct mlx4_priv *priv = mlx4_priv(dev);
	int i, ret = 0;

Annotation

Implementation Notes