Commit 953b9400 authored by Coiby Xu's avatar Coiby Xu Committed by Greg Kroah-Hartman

staging: qlge: Initialize devlink health dump framework

Initialize devlink health dump framework for the qlge driver so the
coredump could be done via devlink.

struct qlge_adapter is now used as the private data structure of
struct devlink so it could exist independently of struct net_device
and devlink reload could be supported in the future. The private data
of PCIe driver now points to qlge_adapter.

Since devlink_alloc will zero out struct qlge_adapter, memset in
qlge_init_device is not necessary.
Signed-off-by: default avatarCoiby Xu <coiby.xu@gmail.com>
Link: https://lore.kernel.org/r/20210123104613.38359-3-coiby.xu@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f8c047be
......@@ -3,6 +3,7 @@
config QLGE
tristate "QLogic QLGE 10Gb Ethernet Driver Support"
depends on ETHERNET && PCI
select NET_DEVLINK
help
This driver supports QLogic ISP8XXX 10Gb Ethernet cards.
......
......@@ -5,4 +5,4 @@
obj-$(CONFIG_QLGE) += qlge.o
qlge-objs := qlge_main.o qlge_dbg.o qlge_mpi.o qlge_ethtool.o
qlge-objs := qlge_main.o qlge_dbg.o qlge_mpi.o qlge_ethtool.o qlge_devlink.o
......@@ -2060,6 +2060,18 @@ struct nic_operations {
int (*port_initialize)(struct qlge_adapter *qdev);
};
struct qlge_netdev_priv {
struct qlge_adapter *qdev;
struct net_device *ndev;
};
static inline
struct qlge_adapter *netdev_to_qdev(struct net_device *ndev)
{
struct qlge_netdev_priv *ndev_priv = netdev_priv(ndev);
return ndev_priv->qdev;
}
/*
* The main Adapter structure definition.
* This structure has all fields relevant to the hardware.
......@@ -2077,6 +2089,7 @@ struct qlge_adapter {
struct pci_dev *pdev;
struct net_device *ndev; /* Parent NET device */
struct devlink_health_reporter *reporter;
/* Hardware information */
u32 chip_rev_id;
u32 fw_rev_id;
......
// SPDX-License-Identifier: GPL-2.0-or-later
#include "qlge.h"
#include "qlge_devlink.h"
static int
qlge_reporter_coredump(struct devlink_health_reporter *reporter,
struct devlink_fmsg *fmsg, void *priv_ctx,
struct netlink_ext_ack *extack)
{
return 0;
}
static const struct devlink_health_reporter_ops qlge_reporter_ops = {
.name = "dummy",
.dump = qlge_reporter_coredump,
};
void qlge_health_create_reporters(struct qlge_adapter *priv)
{
struct devlink_health_reporter *reporter;
struct devlink *devlink;
devlink = priv_to_devlink(priv);
priv->reporter =
devlink_health_reporter_create(devlink, &qlge_reporter_ops,
0, priv);
if (IS_ERR(priv->reporter))
netdev_warn(priv->ndev,
"Failed to create reporter, err = %ld\n",
PTR_ERR(reporter));
}
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef QLGE_DEVLINK_H
#define QLGE_DEVLINK_H
#include <net/devlink.h>
void qlge_health_create_reporters(struct qlge_adapter *priv);
#endif /* QLGE_DEVLINK_H */
......@@ -366,7 +366,7 @@ static void
qlge_get_ethtool_stats(struct net_device *ndev,
struct ethtool_stats *stats, u64 *data)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
int index, length;
length = QLGE_STATS_LEN;
......@@ -383,7 +383,7 @@ qlge_get_ethtool_stats(struct net_device *ndev,
static int qlge_get_link_ksettings(struct net_device *ndev,
struct ethtool_link_ksettings *ecmd)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
u32 supported, advertising;
supported = SUPPORTED_10000baseT_Full;
......@@ -415,7 +415,7 @@ static int qlge_get_link_ksettings(struct net_device *ndev,
static void qlge_get_drvinfo(struct net_device *ndev,
struct ethtool_drvinfo *drvinfo)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
strlcpy(drvinfo->driver, qlge_driver_name, sizeof(drvinfo->driver));
strlcpy(drvinfo->version, qlge_driver_version,
......@@ -431,7 +431,7 @@ static void qlge_get_drvinfo(struct net_device *ndev,
static void qlge_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
unsigned short ssys_dev = qdev->pdev->subsystem_device;
/* WOL is only supported for mezz card. */
......@@ -444,7 +444,7 @@ static void qlge_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
static int qlge_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
unsigned short ssys_dev = qdev->pdev->subsystem_device;
/* WOL is only supported for mezz card. */
......@@ -466,7 +466,7 @@ static int qlge_set_phys_id(struct net_device *ndev,
enum ethtool_phys_id_state state)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
switch (state) {
case ETHTOOL_ID_ACTIVE:
......@@ -574,7 +574,7 @@ static int qlge_loopback_test(struct qlge_adapter *qdev, u64 *data)
static void qlge_self_test(struct net_device *ndev,
struct ethtool_test *eth_test, u64 *data)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
memset(data, 0, sizeof(u64) * QLGE_TEST_LEN);
......@@ -603,7 +603,7 @@ static void qlge_self_test(struct net_device *ndev,
static int qlge_get_regs_len(struct net_device *ndev)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
if (!test_bit(QL_FRC_COREDUMP, &qdev->flags))
return sizeof(struct qlge_mpi_coredump);
......@@ -614,7 +614,7 @@ static int qlge_get_regs_len(struct net_device *ndev)
static void qlge_get_regs(struct net_device *ndev,
struct ethtool_regs *regs, void *p)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
qlge_get_dump(qdev, p);
qdev->core_is_dumped = 0;
......@@ -624,9 +624,9 @@ static void qlge_get_regs(struct net_device *ndev,
regs->len = sizeof(struct qlge_reg_dump);
}
static int qlge_get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
static int qlge_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *c)
{
struct qlge_adapter *qdev = netdev_priv(dev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
c->rx_coalesce_usecs = qdev->rx_coalesce_usecs;
c->tx_coalesce_usecs = qdev->tx_coalesce_usecs;
......@@ -649,7 +649,7 @@ static int qlge_get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
static int qlge_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *c)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
/* Validate user parameters. */
if (c->rx_coalesce_usecs > qdev->rx_ring_size / 2)
......@@ -677,10 +677,10 @@ static int qlge_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *c
return qlge_update_ring_coalescing(qdev);
}
static void qlge_get_pauseparam(struct net_device *netdev,
static void qlge_get_pauseparam(struct net_device *ndev,
struct ethtool_pauseparam *pause)
{
struct qlge_adapter *qdev = netdev_priv(netdev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
qlge_mb_get_port_cfg(qdev);
if (qdev->link_config & CFG_PAUSE_STD) {
......@@ -689,10 +689,10 @@ static void qlge_get_pauseparam(struct net_device *netdev,
}
}
static int qlge_set_pauseparam(struct net_device *netdev,
static int qlge_set_pauseparam(struct net_device *ndev,
struct ethtool_pauseparam *pause)
{
struct qlge_adapter *qdev = netdev_priv(netdev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
if ((pause->rx_pause) && (pause->tx_pause))
qdev->link_config |= CFG_PAUSE_STD;
......@@ -706,14 +706,14 @@ static int qlge_set_pauseparam(struct net_device *netdev,
static u32 qlge_get_msglevel(struct net_device *ndev)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
return qdev->msg_enable;
}
static void qlge_set_msglevel(struct net_device *ndev, u32 value)
{
struct qlge_adapter *qdev = netdev_priv(ndev);
struct qlge_adapter *qdev = netdev_to_qdev(ndev);
qdev->msg_enable = value;
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment