]> git.baikalelectronics.ru Git - kernel.git/commitdiff
qed: move out devlink logic into a new file
authorIgor Russkikh <irusskikh@marvell.com>
Sun, 23 Aug 2020 11:19:25 +0000 (14:19 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Aug 2020 01:01:32 +0000 (18:01 -0700)
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>
drivers/net/ethernet/qlogic/qed/Makefile
drivers/net/ethernet/qlogic/qed/qed_devlink.c [new file with mode: 0644]
drivers/net/ethernet/qlogic/qed/qed_devlink.h [new file with mode: 0644]
drivers/net/ethernet/qlogic/qed/qed_main.c

index f947b105cf1460fff79771a8fa876e72c7918e0e..8251755ec18c2018b8641801c2bb23e59bdd520f 100644 (file)
@@ -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          \
diff --git a/drivers/net/ethernet/qlogic/qed/qed_devlink.c b/drivers/net/ethernet/qlogic/qed/qed_devlink.c
new file mode 100644 (file)
index 0000000..eb69378
--- /dev/null
@@ -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);
+}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_devlink.h b/drivers/net/ethernet/qlogic/qed/qed_devlink.h
new file mode 100644 (file)
index 0000000..b94c40e
--- /dev/null
@@ -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
index 2558cb680db3159a8836dfe31016955cc3ba7c2a..8751355d9ef7f4084b3e8ca7b25e40151d6d35bb 100644 (file)
@@ -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)