OSDN Git Service

bnxt_en: Add missing devlink health reporters for VFs.
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Tue, 10 Dec 2019 07:49:13 +0000 (02:49 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Dec 2019 01:37:14 +0000 (17:37 -0800)
The VF driver also needs to create the health reporters since
VFs are also involved in firmware reset and recovery.  Modify
bnxt_dl_register() and bnxt_dl_unregister() so that they can
be called by the VFs to register/unregister devlink.  Only the PF
will register the devlink parameters.  With devlink registered,
we can now create the health reporters on the VFs.

Fixes: 6763c779c2d8 ("bnxt_en: Add new FW devlink_health_reporter")
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

index 819b7d7..a754903 100644 (file)
@@ -11417,12 +11417,11 @@ static void bnxt_remove_one(struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct bnxt *bp = netdev_priv(dev);
 
-       if (BNXT_PF(bp)) {
+       if (BNXT_PF(bp))
                bnxt_sriov_disable(bp);
-               bnxt_dl_fw_reporters_destroy(bp, true);
-               bnxt_dl_unregister(bp);
-       }
 
+       bnxt_dl_fw_reporters_destroy(bp, true);
+       bnxt_dl_unregister(bp);
        pci_disable_pcie_error_reporting(pdev);
        unregister_netdev(dev);
        bnxt_shutdown_tc(bp);
@@ -11899,10 +11898,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (rc)
                goto init_err_cleanup_tc;
 
-       if (BNXT_PF(bp)) {
-               bnxt_dl_register(bp);
-               bnxt_dl_fw_reporters_create(bp);
-       }
+       bnxt_dl_register(bp);
+       bnxt_dl_fw_reporters_create(bp);
 
        netdev_info(dev, "%s found at mem %lx, node addr %pM\n",
                    board_info[ent->driver_data].name,
index 136953a..3eedd44 100644 (file)
@@ -270,6 +270,8 @@ static const struct devlink_ops bnxt_dl_ops = {
        .flash_update     = bnxt_dl_flash_update,
 };
 
+static const struct devlink_ops bnxt_vf_dl_ops;
+
 enum bnxt_dl_param_id {
        BNXT_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
        BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK,
@@ -483,7 +485,10 @@ int bnxt_dl_register(struct bnxt *bp)
                return -ENOTSUPP;
        }
 
-       dl = devlink_alloc(&bnxt_dl_ops, sizeof(struct bnxt_dl));
+       if (BNXT_PF(bp))
+               dl = devlink_alloc(&bnxt_dl_ops, sizeof(struct bnxt_dl));
+       else
+               dl = devlink_alloc(&bnxt_vf_dl_ops, sizeof(struct bnxt_dl));
        if (!dl) {
                netdev_warn(bp->dev, "devlink_alloc failed");
                return -ENOMEM;
@@ -502,6 +507,9 @@ int bnxt_dl_register(struct bnxt *bp)
                goto err_dl_free;
        }
 
+       if (!BNXT_PF(bp))
+               return 0;
+
        rc = devlink_params_register(dl, bnxt_dl_params,
                                     ARRAY_SIZE(bnxt_dl_params));
        if (rc) {
@@ -551,11 +559,14 @@ void bnxt_dl_unregister(struct bnxt *bp)
        if (!dl)
                return;
 
-       devlink_port_params_unregister(&bp->dl_port, bnxt_dl_port_params,
-                                      ARRAY_SIZE(bnxt_dl_port_params));
-       devlink_port_unregister(&bp->dl_port);
-       devlink_params_unregister(dl, bnxt_dl_params,
-                                 ARRAY_SIZE(bnxt_dl_params));
+       if (BNXT_PF(bp)) {
+               devlink_port_params_unregister(&bp->dl_port,
+                                              bnxt_dl_port_params,
+                                              ARRAY_SIZE(bnxt_dl_port_params));
+               devlink_port_unregister(&bp->dl_port);
+               devlink_params_unregister(dl, bnxt_dl_params,
+                                         ARRAY_SIZE(bnxt_dl_params));
+       }
        devlink_unregister(dl);
        devlink_free(dl);
 }