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)
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);
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 */
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;
}
#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
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)