]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ionic: add a watchdog timer to monitor heartbeat
authorShannon Nelson <snelson@pensando.io>
Thu, 24 Oct 2019 00:48:58 +0000 (17:48 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 26 Oct 2019 03:52:36 +0000 (20:52 -0700)
Add a watchdog to periodically monitor the NIC heartbeat.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/pensando/ionic/ionic.h
drivers/net/ethernet/pensando/ionic/ionic_dev.c
drivers/net/ethernet/pensando/ionic/ionic_dev.h

index 7a7060677f151bcf3d567bec6de7467cf5932f4c..5b013250f8c3c6bea5a2b687dcdff472bf5ddfca 100644 (file)
@@ -46,6 +46,8 @@ struct ionic {
        DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX);
        struct work_struct nb_work;
        struct notifier_block nb;
+       struct timer_list watchdog_timer;
+       int watchdog_period;
 };
 
 struct ionic_admin_ctx {
index 544a9f799afc6c9563156c990fe5db063c88561c..5f9d2ec70446faad30843506b2a5cc11109a13e3 100644 (file)
 #include "ionic_dev.h"
 #include "ionic_lif.h"
 
+static void ionic_watchdog_cb(struct timer_list *t)
+{
+       struct ionic *ionic = from_timer(ionic, t, watchdog_timer);
+
+       mod_timer(&ionic->watchdog_timer,
+                 round_jiffies(jiffies + ionic->watchdog_period));
+
+       ionic_heartbeat_check(ionic);
+}
+
 void ionic_init_devinfo(struct ionic *ionic)
 {
        struct ionic_dev *idev = &ionic->idev;
@@ -72,6 +82,11 @@ int ionic_dev_setup(struct ionic *ionic)
                return -EFAULT;
        }
 
+       timer_setup(&ionic->watchdog_timer, ionic_watchdog_cb, 0);
+       ionic->watchdog_period = IONIC_WATCHDOG_SECS * HZ;
+       mod_timer(&ionic->watchdog_timer,
+                 round_jiffies(jiffies + ionic->watchdog_period));
+
        idev->db_pages = bar->vaddr;
        idev->phy_db_pages = bar->bus_addr;
 
@@ -80,7 +95,7 @@ int ionic_dev_setup(struct ionic *ionic)
 
 void ionic_dev_teardown(struct ionic *ionic)
 {
-       /* place holder */
+       del_timer_sync(&ionic->watchdog_timer);
 }
 
 /* Devcmd Interface */
@@ -93,7 +108,7 @@ int ionic_heartbeat_check(struct ionic *ionic)
 
        /* wait a little more than one second before testing again */
        hb_time = jiffies;
-       if (time_before(hb_time, (idev->last_hb_time + (HZ * 2))))
+       if (time_before(hb_time, (idev->last_hb_time + ionic->watchdog_period)))
                return 0;
 
        /* firmware is useful only if fw_status is non-zero */
index 1ffb3e4dec5da5b8d937138933d5743376fb678c..78691c1ba20ba3371b89390ff9e7c1d58e32383d 100644 (file)
@@ -16,6 +16,7 @@
 #define IONIC_MIN_TXRX_DESC            16
 #define IONIC_DEF_TXRX_DESC            4096
 #define IONIC_LIFS_MAX                 1024
+#define IONIC_WATCHDOG_SECS            5
 #define IONIC_ITR_COAL_USEC_DEFAULT    64
 
 #define IONIC_DEV_CMD_REG_VERSION      1