-
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 PF
Add devlink register support for HNS3 ethernet PF 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
6149ab6
commit b741269
Showing
6 changed files
with
82 additions
and
2 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
54 changes: 54 additions & 0 deletions
54
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_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 "hclge_devlink.h" | ||
|
||
static const struct devlink_ops hclge_devlink_ops = { | ||
}; | ||
|
||
int hclge_devlink_init(struct hclge_dev *hdev) | ||
{ | ||
struct pci_dev *pdev = hdev->pdev; | ||
struct hclge_devlink_priv *priv; | ||
struct devlink *devlink; | ||
int ret; | ||
|
||
devlink = devlink_alloc(&hclge_devlink_ops, | ||
sizeof(struct hclge_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 hclge_devlink_uninit(struct hclge_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/hns3pf/hclge_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 __HCLGE_DEVLINK_H | ||
#define __HCLGE_DEVLINK_H | ||
|
||
#include "hclge_main.h" | ||
|
||
struct hclge_devlink_priv { | ||
struct hclge_dev *hdev; | ||
}; | ||
|
||
int hclge_devlink_init(struct hclge_dev *hdev); | ||
void hclge_devlink_uninit(struct hclge_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