bnxt_en: Add ethtool reset method
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Thu, 26 Oct 2017 15:51:26 +0000 (11:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Oct 2017 15:02:45 +0000 (00:02 +0900)
This is a firmware internal reset after driver is unloaded.

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_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h

index fe93625e0539e0226323b6d15ac1b91b38d0a498..fc32df7f979f71ff9777c86e59314f4754f903cb 100644 (file)
@@ -1337,7 +1337,6 @@ static int bnxt_firmware_reset(struct net_device *dev,
 
        bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_RESET, -1, -1);
 
-       /* TODO: Support ASAP ChiMP self-reset (e.g. upon PF driver unload) */
        /* TODO: Address self-reset of APE/KONG/BONO/TANG or ungraceful reset */
        /*       (e.g. when firmware isn't already running) */
        switch (dir_type) {
@@ -1363,6 +1362,10 @@ static int bnxt_firmware_reset(struct net_device *dev,
        case BNX_DIR_TYPE_BONO_PATCH:
                req.embedded_proc_type = FW_RESET_REQ_EMBEDDED_PROC_TYPE_ROCE;
                break;
+       case BNXT_FW_RESET_CHIP:
+               req.embedded_proc_type = FW_RESET_REQ_EMBEDDED_PROC_TYPE_CHIP;
+               req.selfrst_status = FW_RESET_REQ_SELFRST_STATUS_SELFRSTASAP;
+               break;
        default:
                return -EINVAL;
        }
@@ -2485,6 +2488,37 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
        }
 }
 
+static int bnxt_reset(struct net_device *dev, u32 *flags)
+{
+       struct bnxt *bp = netdev_priv(dev);
+       int rc = 0;
+
+       if (!BNXT_PF(bp)) {
+               netdev_err(dev, "Reset is not supported from a VF\n");
+               return -EOPNOTSUPP;
+       }
+
+       if (pci_vfs_assigned(bp->pdev)) {
+               netdev_err(dev,
+                          "Reset not allowed when VFs are assigned to VMs\n");
+               return -EBUSY;
+       }
+
+       if (*flags == ETH_RESET_ALL) {
+               /* This feature is not supported in older firmware versions */
+               if (bp->hwrm_spec_code < 0x10803)
+                       return -EOPNOTSUPP;
+
+               rc = bnxt_firmware_reset(dev, BNXT_FW_RESET_CHIP);
+               if (!rc)
+                       netdev_info(dev, "Reset request successful. Reload driver to complete reset\n");
+       } else {
+               rc = -EINVAL;
+       }
+
+       return rc;
+}
+
 void bnxt_ethtool_init(struct bnxt *bp)
 {
        struct hwrm_selftest_qlist_output *resp = bp->hwrm_cmd_resp_addr;
@@ -2597,4 +2631,5 @@ const struct ethtool_ops bnxt_ethtool_ops = {
        .nway_reset             = bnxt_nway_reset,
        .set_phys_id            = bnxt_set_phys_id,
        .self_test              = bnxt_self_test,
+       .reset                  = bnxt_reset,
 };
index f1bc90b6fb5bdbec7fbc7896fa32c46b71d104e9..ff601b42fcc8e8ad1e6b032eb2e6ac3f6aaf8118 100644 (file)
@@ -34,6 +34,8 @@ struct bnxt_led_cfg {
 #define BNXT_LED_DFLT_ENABLES(x)                       \
        cpu_to_le32(BNXT_LED_DFLT_ENA << (BNXT_LED_DFLT_ENA_SHIFT * (x)))
 
+#define BNXT_FW_RESET_CHIP     0xffff
+
 extern const struct ethtool_ops bnxt_ethtool_ops;
 
 u32 _bnxt_fw_to_ethtool_adv_spds(u16, u8);