net/ionic: check for command completion more frequently
authorAndrew Boyer <aboyer@pensando.io>
Thu, 10 Dec 2020 02:57:32 +0000 (18:57 -0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:04 +0000 (16:03 +0100)
This reduces the startup time a bit.

Signed-off-by: Neel Patel <neel@pensando.io>
Signed-off-by: Andrew Boyer <aboyer@pensando.io>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/ionic/ionic_dev.h
drivers/net/ionic/ionic_main.c
drivers/net/ionic/ionic_osdep.h

index 532255a..dc64a6d 100644 (file)
@@ -20,7 +20,9 @@
 
 #define IONIC_LIFS_MAX                 1024
 
-#define IONIC_DEVCMD_TIMEOUT   30 /* devcmd_timeout */
+#define IONIC_DEVCMD_TIMEOUT           5       /* devcmd_timeout */
+#define IONIC_DEVCMD_CHECK_PERIOD_US   10      /* devcmd status chk period */
+
 #define        IONIC_ALIGN             4096
 
 struct ionic_adapter;
index 2ade213..f77bdda 100644 (file)
@@ -144,12 +144,12 @@ static int
 ionic_wait_ctx_for_completion(struct ionic_lif *lif, struct ionic_qcq *qcq,
                struct ionic_admin_ctx *ctx, unsigned long max_wait)
 {
-       unsigned long step_msec = 1;
-       unsigned int max_wait_msec = max_wait * 1000;
-       unsigned long elapsed_msec = 0;
+       unsigned long step_usec = IONIC_DEVCMD_CHECK_PERIOD_US;
+       unsigned long max_wait_usec = max_wait * 1000000L;
+       unsigned long elapsed_usec = 0;
        int budget = 8;
 
-       while (ctx->pending_work && elapsed_msec < max_wait_msec) {
+       while (ctx->pending_work && elapsed_usec < max_wait_usec) {
                /*
                 * Locking here as adminq is served inline (this could be called
                 * from multiple places)
@@ -160,8 +160,8 @@ ionic_wait_ctx_for_completion(struct ionic_lif *lif, struct ionic_qcq *qcq,
 
                rte_spinlock_unlock(&lif->adminq_service_lock);
 
-               msec_delay(step_msec);
-               elapsed_msec += step_msec;
+               rte_delay_us_block(step_usec);
+               elapsed_usec += step_usec;
        }
 
        return (!ctx->pending_work);
@@ -195,9 +195,9 @@ ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
 static int
 ionic_dev_cmd_wait(struct ionic_dev *idev, unsigned long max_wait)
 {
-       unsigned long step_msec = 100;
-       unsigned int max_wait_msec = max_wait * 1000;
-       unsigned long elapsed_msec = 0;
+       unsigned long step_usec = IONIC_DEVCMD_CHECK_PERIOD_US;
+       unsigned long max_wait_usec = max_wait * 1000000L;
+       unsigned long elapsed_usec = 0;
        int done;
 
        /* Wait for dev cmd to complete.. but no more than max_wait sec */
@@ -205,20 +205,20 @@ ionic_dev_cmd_wait(struct ionic_dev *idev, unsigned long max_wait)
        do {
                done = ionic_dev_cmd_done(idev);
                if (done) {
-                       IONIC_PRINT(DEBUG, "DEVCMD %d done took %ld msecs",
-                               idev->dev_cmd->cmd.cmd.opcode,
-                               elapsed_msec);
+                       IONIC_PRINT(DEBUG, "DEVCMD %d done took %ld usecs",
+                               ioread8(&idev->dev_cmd->cmd.cmd.opcode),
+                               elapsed_usec);
                        return 0;
                }
 
-               msec_delay(step_msec);
+               rte_delay_us_block(step_usec);
 
-               elapsed_msec += step_msec;
-       } while (elapsed_msec < max_wait_msec);
+               elapsed_usec += step_usec;
+       } while (elapsed_usec < max_wait_usec);
 
-       IONIC_PRINT(DEBUG, "DEVCMD %d timeout after %ld msecs",
-               idev->dev_cmd->cmd.cmd.opcode,
-               elapsed_msec);
+       IONIC_PRINT(ERR, "DEVCMD %d timeout after %ld usecs",
+               ioread8(&idev->dev_cmd->cmd.cmd.opcode),
+               elapsed_usec);
 
        return -ETIMEDOUT;
 }
index e04bb8f..a55d599 100644 (file)
 
 #include "ionic_logs.h"
 
-#define DELAY(x) rte_delay_us(x)
-#define usec_delay(x) DELAY(x)
-#define msec_delay(x) DELAY(1000 * (x))
-
 #define BIT(nr)            (1UL << (nr))
 #define BIT_ULL(nr)        (1ULL << (nr))
-#define BITS_TO_LONGS(nr)  div_round_up(nr, 8 * sizeof(long))
 
 #ifndef PAGE_SHIFT
 #define PAGE_SHIFT      12
@@ -44,11 +39,6 @@ typedef uint16_t __le16;
 typedef uint32_t __le32;
 typedef uint64_t __le64;
 
-static inline uint32_t div_round_up(uint32_t n, uint32_t d)
-{
-       return (n + d - 1) / d;
-}
-
 #define ioread8(reg)           rte_read8(reg)
 #define ioread32(reg)          rte_read32(reg)
 #define iowrite8(value, reg)   rte_write8(value, reg)