-
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.
octeontx2-af: Add devlink suppoort to af driver
Add devlink support to AF driver. Basic devlink support is added. Currently info_get is the only supported devlink ops. devlink ouptput looks like this # devlink dev pci/0002:01:00.0 # devlink dev info pci/0002:01:00.0: driver octeontx2-af # Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> Signed-off-by: Jerin Jacob <jerinj@marvell.com> Signed-off-by: George Cherian <george.cherian@marvell.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
George Cherian
authored and
Jakub Kicinski
committed
Dec 15, 2020
1 parent
0e12c02
commit fae06da
Showing
6 changed files
with
98 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
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
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,64 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Marvell OcteonTx2 RVU Devlink | ||
* | ||
* Copyright (C) 2020 Marvell. | ||
* | ||
*/ | ||
|
||
#include "rvu.h" | ||
|
||
#define DRV_NAME "octeontx2-af" | ||
|
||
static int rvu_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, | ||
struct netlink_ext_ack *extack) | ||
{ | ||
return devlink_info_driver_name_put(req, DRV_NAME); | ||
} | ||
|
||
static const struct devlink_ops rvu_devlink_ops = { | ||
.info_get = rvu_devlink_info_get, | ||
}; | ||
|
||
int rvu_register_dl(struct rvu *rvu) | ||
{ | ||
struct rvu_devlink *rvu_dl; | ||
struct devlink *dl; | ||
int err; | ||
|
||
rvu_dl = kzalloc(sizeof(*rvu_dl), GFP_KERNEL); | ||
if (!rvu_dl) | ||
return -ENOMEM; | ||
|
||
dl = devlink_alloc(&rvu_devlink_ops, sizeof(struct rvu_devlink)); | ||
if (!dl) { | ||
dev_warn(rvu->dev, "devlink_alloc failed\n"); | ||
kfree(rvu_dl); | ||
return -ENOMEM; | ||
} | ||
|
||
err = devlink_register(dl, rvu->dev); | ||
if (err) { | ||
dev_err(rvu->dev, "devlink register failed with error %d\n", err); | ||
devlink_free(dl); | ||
kfree(rvu_dl); | ||
return err; | ||
} | ||
|
||
rvu_dl->dl = dl; | ||
rvu_dl->rvu = rvu; | ||
rvu->rvu_dl = rvu_dl; | ||
return 0; | ||
} | ||
|
||
void rvu_unregister_dl(struct rvu *rvu) | ||
{ | ||
struct rvu_devlink *rvu_dl = rvu->rvu_dl; | ||
struct devlink *dl = rvu_dl->dl; | ||
|
||
if (!dl) | ||
return; | ||
|
||
devlink_unregister(dl); | ||
devlink_free(dl); | ||
kfree(rvu_dl); | ||
} |
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,20 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Marvell OcteonTx2 RVU Devlink | ||
* | ||
* Copyright (C) 2020 Marvell. | ||
* | ||
*/ | ||
|
||
#ifndef RVU_DEVLINK_H | ||
#define RVU_DEVLINK_H | ||
|
||
struct rvu_devlink { | ||
struct devlink *dl; | ||
struct rvu *rvu; | ||
}; | ||
|
||
/* Devlink APIs */ | ||
int rvu_register_dl(struct rvu *rvu); | ||
void rvu_unregister_dl(struct rvu *rvu); | ||
|
||
#endif /* RVU_DEVLINK_H */ |