-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: hns3: add support for registering devlink for VF
Add devlink register support for HNS3 ethernet VF driver. Signed-off-by: Yufeng Mo <moyufeng@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Yufeng Mo
authored and
David S. Miller
committed
Jul 26, 2021
1 parent
b741269
commit cd62429
Showing
5 changed files
with
81 additions
and
1 deletion.
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
54 changes: 54 additions & 0 deletions
54
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.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,54 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
/* Copyright (c) 2021 Hisilicon Limited. */ | ||
|
||
#include <net/devlink.h> | ||
|
||
#include "hclgevf_devlink.h" | ||
|
||
static const struct devlink_ops hclgevf_devlink_ops = { | ||
}; | ||
|
||
int hclgevf_devlink_init(struct hclgevf_dev *hdev) | ||
{ | ||
struct pci_dev *pdev = hdev->pdev; | ||
struct hclgevf_devlink_priv *priv; | ||
struct devlink *devlink; | ||
int ret; | ||
|
||
devlink = devlink_alloc(&hclgevf_devlink_ops, | ||
sizeof(struct hclgevf_devlink_priv)); | ||
if (!devlink) | ||
return -ENOMEM; | ||
|
||
priv = devlink_priv(devlink); | ||
priv->hdev = hdev; | ||
|
||
ret = devlink_register(devlink, &pdev->dev); | ||
if (ret) { | ||
dev_err(&pdev->dev, "failed to register devlink, ret = %d\n", | ||
ret); | ||
goto out_reg_fail; | ||
} | ||
|
||
hdev->devlink = devlink; | ||
|
||
return 0; | ||
|
||
out_reg_fail: | ||
devlink_free(devlink); | ||
return ret; | ||
} | ||
|
||
void hclgevf_devlink_uninit(struct hclgevf_dev *hdev) | ||
{ | ||
struct devlink *devlink = hdev->devlink; | ||
|
||
if (!devlink) | ||
return; | ||
|
||
devlink_unregister(devlink); | ||
|
||
devlink_free(devlink); | ||
|
||
hdev->devlink = NULL; | ||
} |
15 changes: 15 additions & 0 deletions
15
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.h
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,15 @@ | ||
/* SPDX-License-Identifier: GPL-2.0+ */ | ||
/* Copyright (c) 2021 Hisilicon Limited. */ | ||
|
||
#ifndef __HCLGEVF_DEVLINK_H | ||
#define __HCLGEVF_DEVLINK_H | ||
|
||
#include "hclgevf_main.h" | ||
|
||
struct hclgevf_devlink_priv { | ||
struct hclgevf_dev *hdev; | ||
}; | ||
|
||
int hclgevf_devlink_init(struct hclgevf_dev *hdev); | ||
void hclgevf_devlink_uninit(struct hclgevf_dev *hdev); | ||
#endif |
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