qed: use devlink logic to report errors
authorIgor Russkikh <irusskikh@marvell.com>
Sun, 23 Aug 2020 11:19:30 +0000 (14:19 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Aug 2020 01:01:33 +0000 (18:01 -0700)
Use devlink_health_report to push error indications.
We implement this in qede via callback function to make it possible
to reuse the same for other drivers sitting on top of qed in future.

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>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_devlink.c
drivers/net/ethernet/qlogic/qed/qed_devlink.h
drivers/net/ethernet/qlogic/qed/qed_main.c
drivers/net/ethernet/qlogic/qede/qede.h
drivers/net/ethernet/qlogic/qede/qede_main.c
include/linux/qed/qed_if.h

index 8b2c72fa8c447e458e6b8b6408d2a98ee26cea23..4de786d4261b45c1884b450dc5964e54f32b1926 100644 (file)
@@ -14,6 +14,24 @@ enum qed_devlink_param_id {
        QED_DEVLINK_PARAM_ID_IWARP_CMT,
 };
 
+struct qed_fw_fatal_ctx {
+       enum qed_hw_err_type err_type;
+};
+
+int qed_report_fatal_error(struct devlink *devlink, enum qed_hw_err_type err_type)
+{
+       struct qed_devlink *qdl = devlink_priv(devlink);
+       struct qed_fw_fatal_ctx fw_fatal_ctx = {
+               .err_type = err_type,
+       };
+
+       if (qdl->fw_reporter)
+               devlink_health_report(qdl->fw_reporter,
+                                     "Fatal error occurred", &fw_fatal_ctx);
+
+       return 0;
+}
+
 static const struct devlink_health_reporter_ops qed_fw_fatal_reporter_ops = {
                .name = "fw_fatal",
 };
index c68ecf778826574ebcafe1b8d903494bd3b3d6d1..ccc7d1d1bfd4a961e5906fad6efcb2b7d7c55503 100644 (file)
@@ -15,4 +15,6 @@ void qed_devlink_unregister(struct devlink *devlink);
 void qed_fw_reporters_create(struct devlink *devlink);
 void qed_fw_reporters_destroy(struct devlink *devlink);
 
+int qed_report_fatal_error(struct devlink *dl, enum qed_hw_err_type err_type);
+
 #endif
index d1a559ccf5167b285db77b1a0231d473ce500d44..a64d594f9294aa16df038c5f35731ca4f643410a 100644 (file)
@@ -3007,6 +3007,7 @@ const struct qed_common_ops qed_common_ops_pass = {
        .update_msglvl = &qed_init_dp,
        .devlink_register = qed_devlink_register,
        .devlink_unregister = qed_devlink_unregister,
+       .report_fatal_error = qed_report_fatal_error,
        .dbg_all_data = &qed_dbg_all_data,
        .dbg_all_data_size = &qed_dbg_all_data_size,
        .chain_alloc = &qed_chain_alloc,
index 1f0e7505a9738af35ad9efe9a5eaacde4dcbada5..3efc5899f65630d133bd482b6d014d2454b95d53 100644 (file)
@@ -264,6 +264,7 @@ struct qede_dev {
 
        struct bpf_prog                 *xdp_prog;
 
+       enum qed_hw_err_type            last_err_type;
        unsigned long                   err_flags;
 #define QEDE_ERR_IS_HANDLED            31
 #define QEDE_ERR_ATTN_CLR_EN           0
index 4cd8412e5ed02beef28ed8c4bfca12cf60285adc..bafdf46a9b1f50bc165fbeda933fec218986add6 100644 (file)
@@ -2601,6 +2601,9 @@ static void qede_generic_hw_err_handler(struct qede_dev *edev)
                  "Generic sleepable HW error handling started - err_flags 0x%lx\n",
                  edev->err_flags);
 
+       if (edev->devlink)
+               edev->ops->common->report_fatal_error(edev->devlink, edev->last_err_type);
+
        /* Trigger a recovery process.
         * This is placed in the sleep requiring section just to make
         * sure it is the last one, and that all the other operations
@@ -2661,6 +2664,7 @@ static void qede_schedule_hw_err_handler(void *dev,
                return;
        }
 
+       edev->last_err_type = err_type;
        qede_set_hw_err_flags(edev, err_type);
        qede_atomic_hw_err_handler(edev);
        set_bit(QEDE_SP_HW_ERR, &edev->sp_flags);
index 30fe06fe06a000c884a060c133759a0937085c40..a75533de918676fafd9558d4d19a472b97f4db12 100644 (file)
@@ -906,6 +906,9 @@ struct qed_common_ops {
 
        int (*dbg_all_data_size) (struct qed_dev *cdev);
 
+       int (*report_fatal_error)(struct devlink *devlink,
+                                 enum qed_hw_err_type err_type);
+
 /**
  * @brief can_link_change - can the instance change the link or not
  *