gve: DQO: Configure interrupts on device up
authorBailey Forrest <bcf@google.com>
Thu, 24 Jun 2021 18:06:30 +0000 (11:06 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 24 Jun 2021 19:47:38 +0000 (12:47 -0700)
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 <bcf@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Catherine Sullivan <csully@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/google/gve/gve_dqo.h
drivers/net/ethernet/google/gve/gve_main.c

index 9877a33..3b30022 100644 (file)
@@ -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
 
@@ -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)
index cddf19c..1bf4468 100644 (file)
@@ -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);