OSDN Git Service

bnxt_en: Define macros for the various health register states.
authorMichael Chan <michael.chan@broadcom.com>
Mon, 25 Jan 2021 07:08:08 +0000 (02:08 -0500)
committerJakub Kicinski <kuba@kernel.org>
Tue, 26 Jan 2021 03:20:03 +0000 (19:20 -0800)
Define macros to check for the various states in the lower 16 bits of
the health register.  Replace the C code that checks for these values
with the newly defined macros.

Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

index d680653..a1dd80a 100644 (file)
@@ -1534,9 +1534,19 @@ struct bnxt_fw_reporter_ctx {
 #define BNXT_FW_HEALTH_WIN_OFF(reg)    (BNXT_FW_HEALTH_WIN_BASE +      \
                                         ((reg) & BNXT_GRC_OFFSET_MASK))
 
+#define BNXT_FW_STATUS_HEALTH_MSK      0xffff
 #define BNXT_FW_STATUS_HEALTHY         0x8000
 #define BNXT_FW_STATUS_SHUTDOWN                0x100000
 
+#define BNXT_FW_IS_HEALTHY(sts)                (((sts) & BNXT_FW_STATUS_HEALTH_MSK) ==\
+                                        BNXT_FW_STATUS_HEALTHY)
+
+#define BNXT_FW_IS_BOOTING(sts)                (((sts) & BNXT_FW_STATUS_HEALTH_MSK) < \
+                                        BNXT_FW_STATUS_HEALTHY)
+
+#define BNXT_FW_IS_ERR(sts)            (((sts) & BNXT_FW_STATUS_HEALTH_MSK) > \
+                                        BNXT_FW_STATUS_HEALTHY)
+
 struct bnxt {
        void __iomem            *bar0;
        void __iomem            *bar1;
index 6b7b69e..90a31b4 100644 (file)
@@ -44,21 +44,20 @@ static int bnxt_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
                                     struct netlink_ext_ack *extack)
 {
        struct bnxt *bp = devlink_health_reporter_priv(reporter);
-       u32 val, health_status;
+       u32 val;
        int rc;
 
        if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
                return 0;
 
        val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
-       health_status = val & 0xffff;
 
-       if (health_status < BNXT_FW_STATUS_HEALTHY) {
+       if (BNXT_FW_IS_BOOTING(val)) {
                rc = devlink_fmsg_string_pair_put(fmsg, "Description",
                                                  "Not yet completed initialization");
                if (rc)
                        return rc;
-       } else if (health_status > BNXT_FW_STATUS_HEALTHY) {
+       } else if (BNXT_FW_IS_ERR(val)) {
                rc = devlink_fmsg_string_pair_put(fmsg, "Description",
                                                  "Encountered fatal error and cannot recover");
                if (rc)