drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c
Extension
.c
Size
3487 bytes
Lines
131
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source 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) {
			rtnl_unlock();
			return ret;
		}

		ret = hdev->nic_client->ops->reset_notify(h,
							  HNAE3_UNINIT_CLIENT);
		rtnl_unlock();
		return ret;
	default:
		return -EOPNOTSUPP;
	}
}

static int hclgevf_devlink_reload_up(struct devlink *devlink,
				     enum devlink_reload_action action,
				     enum devlink_reload_limit limit,
				     u32 *actions_performed,
				     struct netlink_ext_ack *extack)
{
	struct hclgevf_devlink_priv *priv = devlink_priv(devlink);
	struct hclgevf_dev *hdev = priv->hdev;
	struct hnae3_handle *h = &hdev->nic;
	int ret;

	*actions_performed = BIT(action);
	switch (action) {
	case DEVLINK_RELOAD_ACTION_DRIVER_REINIT:
		rtnl_lock();
		ret = hdev->nic_client->ops->reset_notify(h, HNAE3_INIT_CLIENT);
		if (ret) {
			rtnl_unlock();
			return ret;
		}

		ret = hdev->nic_client->ops->reset_notify(h, HNAE3_UP_CLIENT);
		rtnl_unlock();
		return ret;
	default:
		return -EOPNOTSUPP;
	}
}

static const struct devlink_ops hclgevf_devlink_ops = {
	.info_get = hclgevf_devlink_info_get,
	.reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT),
	.reload_down = hclgevf_devlink_reload_down,
	.reload_up = hclgevf_devlink_reload_up,
};

int hclgevf_devlink_init(struct hclgevf_dev *hdev)
{
	struct pci_dev *pdev = hdev->pdev;
	struct hclgevf_devlink_priv *priv;
	struct devlink *devlink;

	devlink =
		devlink_alloc(&hclgevf_devlink_ops,
			      sizeof(struct hclgevf_devlink_priv), &pdev->dev);
	if (!devlink)
		return -ENOMEM;

	priv = devlink_priv(devlink);
	priv->hdev = hdev;
	hdev->devlink = devlink;

	devlink_register(devlink);
	return 0;
}

void hclgevf_devlink_uninit(struct hclgevf_dev *hdev)
{
	struct devlink *devlink = hdev->devlink;

	devlink_unregister(devlink);

	devlink_free(devlink);
}

Annotation

Implementation Notes