Skip to content

Commit

Permalink
gve: DQO: Configure interrupts on device up
Browse files Browse the repository at this point in the history
When interrupts are first enabled, we also set the ratelimits, which
will be static for the entire usage of the device.

Signed-off-by: Bailey Forrest <[email protected]>
Reviewed-by: Willem de Bruijn <[email protected]>
Reviewed-by: Catherine Sullivan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
baileyforrest authored and davem330 committed Jun 24, 2021
1 parent 9c1a59a commit 0dcc144
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
19 changes: 19 additions & 0 deletions drivers/net/ethernet/google/gve/gve_dqo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#define GVE_ITR_CLEAR_PBA_BIT_DQO BIT(1)
#define GVE_ITR_NO_UPDATE_DQO (3 << 3)

#define GVE_ITR_INTERVAL_DQO_SHIFT 5
#define GVE_ITR_INTERVAL_DQO_MASK ((1 << 12) - 1)

#define GVE_TX_IRQ_RATELIMIT_US_DQO 50
#define GVE_RX_IRQ_RATELIMIT_US_DQO 20

Expand All @@ -38,6 +41,22 @@ gve_tx_put_doorbell_dqo(const struct gve_priv *priv,
iowrite32(val, &priv->db_bar2[index]);
}

/* Builds register value to write to DQO IRQ doorbell to enable with specified
* ratelimit.
*/
static inline u32 gve_set_itr_ratelimit_dqo(u32 ratelimit_us)
{
u32 result = GVE_ITR_ENABLE_BIT_DQO;

/* Interval has 2us granularity. */
ratelimit_us >>= 1;

ratelimit_us &= GVE_ITR_INTERVAL_DQO_MASK;
result |= (ratelimit_us << GVE_ITR_INTERVAL_DQO_SHIFT);

return result;
}

static inline void
gve_write_irq_doorbell_dqo(const struct gve_priv *priv,
const struct gve_notify_block *block, u32 val)
Expand Down
16 changes: 14 additions & 2 deletions drivers/net/ethernet/google/gve/gve_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,14 +1077,26 @@ static void gve_turnup(struct gve_priv *priv)
struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];

napi_enable(&block->napi);
iowrite32be(0, gve_irq_doorbell(priv, block));
if (gve_is_gqi(priv)) {
iowrite32be(0, gve_irq_doorbell(priv, block));
} else {
u32 val = gve_set_itr_ratelimit_dqo(GVE_TX_IRQ_RATELIMIT_US_DQO);

gve_write_irq_doorbell_dqo(priv, block, val);
}
}
for (idx = 0; idx < priv->rx_cfg.num_queues; idx++) {
int ntfy_idx = gve_rx_idx_to_ntfy(priv, idx);
struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];

napi_enable(&block->napi);
iowrite32be(0, gve_irq_doorbell(priv, block));
if (gve_is_gqi(priv)) {
iowrite32be(0, gve_irq_doorbell(priv, block));
} else {
u32 val = gve_set_itr_ratelimit_dqo(GVE_RX_IRQ_RATELIMIT_US_DQO);

gve_write_irq_doorbell_dqo(priv, block, val);
}
}

gve_set_napi_enabled(priv);
Expand Down

0 comments on commit 0dcc144

Please sign in to comment.