mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 01:10:04 +00:00
qed: move out devlink logic into a new file
We are extending devlink infrastructure, thus move the existing stuff into a new file qed_devlink.c Signed-off-by: Igor Russkikh <irusskikh@marvell.com> Signed-off-by: Alexander Lobakin <alobakin@marvell.com> Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
9ab9017948
commit
52306dee54
4 changed files with 127 additions and 101 deletions
|
@ -9,6 +9,7 @@ qed-y := \
|
|||
qed_dcbx.o \
|
||||
qed_debug.o \
|
||||
qed_dev.o \
|
||||
qed_devlink.o \
|
||||
qed_hw.o \
|
||||
qed_init_fw_funcs.o \
|
||||
qed_init_ops.o \
|
||||
|
|
110
drivers/net/ethernet/qlogic/qed/qed_devlink.c
Normal file
110
drivers/net/ethernet/qlogic/qed/qed_devlink.c
Normal file
|
@ -0,0 +1,110 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/* Marvell/Qlogic FastLinQ NIC driver
|
||||
*
|
||||
* Copyright (C) 2020 Marvell International Ltd.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include "qed.h"
|
||||
#include "qed_devlink.h"
|
||||
|
||||
enum qed_devlink_param_id {
|
||||
QED_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
|
||||
QED_DEVLINK_PARAM_ID_IWARP_CMT,
|
||||
};
|
||||
|
||||
struct qed_devlink {
|
||||
struct qed_dev *cdev;
|
||||
};
|
||||
|
||||
static int qed_dl_param_get(struct devlink *dl, u32 id,
|
||||
struct devlink_param_gset_ctx *ctx)
|
||||
{
|
||||
struct qed_devlink *qed_dl;
|
||||
struct qed_dev *cdev;
|
||||
|
||||
qed_dl = devlink_priv(dl);
|
||||
cdev = qed_dl->cdev;
|
||||
ctx->val.vbool = cdev->iwarp_cmt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qed_dl_param_set(struct devlink *dl, u32 id,
|
||||
struct devlink_param_gset_ctx *ctx)
|
||||
{
|
||||
struct qed_devlink *qed_dl;
|
||||
struct qed_dev *cdev;
|
||||
|
||||
qed_dl = devlink_priv(dl);
|
||||
cdev = qed_dl->cdev;
|
||||
cdev->iwarp_cmt = ctx->val.vbool;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct devlink_param qed_devlink_params[] = {
|
||||
DEVLINK_PARAM_DRIVER(QED_DEVLINK_PARAM_ID_IWARP_CMT,
|
||||
"iwarp_cmt", DEVLINK_PARAM_TYPE_BOOL,
|
||||
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
|
||||
qed_dl_param_get, qed_dl_param_set, NULL),
|
||||
};
|
||||
|
||||
static const struct devlink_ops qed_dl_ops;
|
||||
|
||||
int qed_devlink_register(struct qed_dev *cdev)
|
||||
{
|
||||
union devlink_param_value value;
|
||||
struct qed_devlink *qed_dl;
|
||||
struct devlink *dl;
|
||||
int rc;
|
||||
|
||||
dl = devlink_alloc(&qed_dl_ops, sizeof(*qed_dl));
|
||||
if (!dl)
|
||||
return -ENOMEM;
|
||||
|
||||
qed_dl = devlink_priv(dl);
|
||||
|
||||
cdev->dl = dl;
|
||||
qed_dl->cdev = cdev;
|
||||
|
||||
rc = devlink_register(dl, &cdev->pdev->dev);
|
||||
if (rc)
|
||||
goto err_free;
|
||||
|
||||
rc = devlink_params_register(dl, qed_devlink_params,
|
||||
ARRAY_SIZE(qed_devlink_params));
|
||||
if (rc)
|
||||
goto err_unregister;
|
||||
|
||||
value.vbool = false;
|
||||
devlink_param_driverinit_value_set(dl,
|
||||
QED_DEVLINK_PARAM_ID_IWARP_CMT,
|
||||
value);
|
||||
|
||||
devlink_params_publish(dl);
|
||||
cdev->iwarp_cmt = false;
|
||||
|
||||
return 0;
|
||||
|
||||
err_unregister:
|
||||
devlink_unregister(dl);
|
||||
|
||||
err_free:
|
||||
cdev->dl = NULL;
|
||||
devlink_free(dl);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void qed_devlink_unregister(struct qed_dev *cdev)
|
||||
{
|
||||
if (!cdev->dl)
|
||||
return;
|
||||
|
||||
devlink_params_unregister(cdev->dl, qed_devlink_params,
|
||||
ARRAY_SIZE(qed_devlink_params));
|
||||
|
||||
devlink_unregister(cdev->dl);
|
||||
devlink_free(cdev->dl);
|
||||
}
|
15
drivers/net/ethernet/qlogic/qed/qed_devlink.h
Normal file
15
drivers/net/ethernet/qlogic/qed/qed_devlink.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/* Marvell/Qlogic FastLinQ NIC driver
|
||||
*
|
||||
* Copyright (C) 2020 Marvell International Ltd.
|
||||
*/
|
||||
#ifndef _QED_DEVLINK_H
|
||||
#define _QED_DEVLINK_H
|
||||
|
||||
#include <linux/qed/qed_if.h>
|
||||
#include <net/devlink.h>
|
||||
|
||||
int qed_devlink_register(struct qed_dev *cdev);
|
||||
void qed_devlink_unregister(struct qed_dev *cdev);
|
||||
|
||||
#endif
|
|
@ -39,6 +39,7 @@
|
|||
#include "qed_hw.h"
|
||||
#include "qed_selftest.h"
|
||||
#include "qed_debug.h"
|
||||
#include "qed_devlink.h"
|
||||
|
||||
#define QED_ROCE_QPS (8192)
|
||||
#define QED_ROCE_DPIS (8)
|
||||
|
@ -510,107 +511,6 @@ static int qed_set_power_state(struct qed_dev *cdev, pci_power_t state)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct qed_devlink {
|
||||
struct qed_dev *cdev;
|
||||
};
|
||||
|
||||
enum qed_devlink_param_id {
|
||||
QED_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
|
||||
QED_DEVLINK_PARAM_ID_IWARP_CMT,
|
||||
};
|
||||
|
||||
static int qed_dl_param_get(struct devlink *dl, u32 id,
|
||||
struct devlink_param_gset_ctx *ctx)
|
||||
{
|
||||
struct qed_devlink *qed_dl;
|
||||
struct qed_dev *cdev;
|
||||
|
||||
qed_dl = devlink_priv(dl);
|
||||
cdev = qed_dl->cdev;
|
||||
ctx->val.vbool = cdev->iwarp_cmt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qed_dl_param_set(struct devlink *dl, u32 id,
|
||||
struct devlink_param_gset_ctx *ctx)
|
||||
{
|
||||
struct qed_devlink *qed_dl;
|
||||
struct qed_dev *cdev;
|
||||
|
||||
qed_dl = devlink_priv(dl);
|
||||
cdev = qed_dl->cdev;
|
||||
cdev->iwarp_cmt = ctx->val.vbool;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct devlink_param qed_devlink_params[] = {
|
||||
DEVLINK_PARAM_DRIVER(QED_DEVLINK_PARAM_ID_IWARP_CMT,
|
||||
"iwarp_cmt", DEVLINK_PARAM_TYPE_BOOL,
|
||||
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
|
||||
qed_dl_param_get, qed_dl_param_set, NULL),
|
||||
};
|
||||
|
||||
static const struct devlink_ops qed_dl_ops;
|
||||
|
||||
static int qed_devlink_register(struct qed_dev *cdev)
|
||||
{
|
||||
union devlink_param_value value;
|
||||
struct qed_devlink *qed_dl;
|
||||
struct devlink *dl;
|
||||
int rc;
|
||||
|
||||
dl = devlink_alloc(&qed_dl_ops, sizeof(*qed_dl));
|
||||
if (!dl)
|
||||
return -ENOMEM;
|
||||
|
||||
qed_dl = devlink_priv(dl);
|
||||
|
||||
cdev->dl = dl;
|
||||
qed_dl->cdev = cdev;
|
||||
|
||||
rc = devlink_register(dl, &cdev->pdev->dev);
|
||||
if (rc)
|
||||
goto err_free;
|
||||
|
||||
rc = devlink_params_register(dl, qed_devlink_params,
|
||||
ARRAY_SIZE(qed_devlink_params));
|
||||
if (rc)
|
||||
goto err_unregister;
|
||||
|
||||
value.vbool = false;
|
||||
devlink_param_driverinit_value_set(dl,
|
||||
QED_DEVLINK_PARAM_ID_IWARP_CMT,
|
||||
value);
|
||||
|
||||
devlink_params_publish(dl);
|
||||
cdev->iwarp_cmt = false;
|
||||
|
||||
return 0;
|
||||
|
||||
err_unregister:
|
||||
devlink_unregister(dl);
|
||||
|
||||
err_free:
|
||||
cdev->dl = NULL;
|
||||
devlink_free(dl);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void qed_devlink_unregister(struct qed_dev *cdev)
|
||||
{
|
||||
if (!cdev->dl)
|
||||
return;
|
||||
|
||||
devlink_params_unregister(cdev->dl, qed_devlink_params,
|
||||
ARRAY_SIZE(qed_devlink_params));
|
||||
|
||||
devlink_unregister(cdev->dl);
|
||||
devlink_free(cdev->dl);
|
||||
}
|
||||
|
||||
/* probing */
|
||||
static struct qed_dev *qed_probe(struct pci_dev *pdev,
|
||||
struct qed_probe_params *params)
|
||||
|
|
Loading…
Reference in a new issue