On 6/29/26 11:36 PM, Haiyang Zhang wrote:
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c 
> b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 7438ea6b3f26..9391e9564605 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -1591,6 +1591,9 @@ int mana_create_wq_obj(struct mana_port_context *apc,
>  
>       mana_gd_init_req_hdr(&req.hdr, MANA_CREATE_WQ_OBJ,
>                            sizeof(req), sizeof(resp));
> +
> +     req.hdr.req.msg_version = GDMA_MESSAGE_V3;
> +     req.hdr.resp.msg_version = GDMA_MESSAGE_V2;

Double checking the above is intentional; it feels strange to me that
request and reply use different versions. Possibly a comment for future
memory would make sense.

>       req.vport = vport;
>       req.wq_type = wq_type;
>       req.wq_gdma_region = wq_spec->gdma_region;
> @@ -1599,6 +1602,9 @@ int mana_create_wq_obj(struct mana_port_context *apc,
>       req.cq_size = cq_spec->queue_size;
>       req.cq_moderation_ctx_id = cq_spec->modr_ctx_id;
>       req.cq_parent_qid = cq_spec->attached_eq;
> +     req.req_cq_moderation = cq_spec->req_cq_moderation;
> +     req.cq_moderation_comp = cq_spec->cq_moderation_comp;
> +     req.cq_moderation_usec = cq_spec->cq_moderation_usec;
>  
>       err = mana_send_request(apc->ac, &req, sizeof(req), &resp,
>                               sizeof(resp));
> @@ -1856,6 +1862,7 @@ static void mana_poll_tx_cq(struct mana_cq *cq)
>       struct gdma_posted_wqe_info *wqe_info;
>       unsigned int pkt_transmitted = 0;
>       unsigned int wqe_unit_cnt = 0;
> +     unsigned int tx_bytes = 0;
>       struct mana_txq *txq = cq->txq;
>       struct mana_port_context *apc;
>       struct netdev_queue *net_txq;
> @@ -1937,6 +1944,8 @@ static void mana_poll_tx_cq(struct mana_cq *cq)
>  
>               mana_unmap_skb(skb, apc);
>  
> +             tx_bytes += skb->len;
> +
>               napi_consume_skb(skb, cq->budget);
>  
>               pkt_transmitted++;
> @@ -1967,6 +1976,10 @@ static void mana_poll_tx_cq(struct mana_cq *cq)
>       if (atomic_sub_return(pkt_transmitted, &txq->pending_sends) < 0)
>               WARN_ON_ONCE(1);
>  
> +     /* Feed DIM with the completion rate observed here, in NAPI context. */
> +     cq->tx_dim_pkts += pkt_transmitted;
> +     cq->tx_dim_bytes += tx_bytes;
> +
>       cq->work_done = pkt_transmitted;
>  }
>  
> @@ -2318,6 +2331,119 @@ static void mana_poll_rx_cq(struct mana_cq *cq)
>               xdp_do_flush();
>  }
>  
> +static void mana_rx_dim_work(struct work_struct *work)
> +{
> +     struct dim *dim = container_of(work, struct dim, work);
> +     struct dim_cq_moder cur_moder;
> +     struct mana_cq *cq;
> +
> +     cur_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
> +     cq = container_of(dim, struct mana_cq, dim);
> +
> +     cur_moder.usec = min_t(u16, cur_moder.usec, MANA_INTR_MODR_USEC_MAX);
> +     cur_moder.pkts = min_t(u16, cur_moder.pkts, MANA_INTR_MODR_COMP_MAX);
> +
> +     mana_gd_ring_dim(cq->gdma_cq, cur_moder.usec, true,
> +                      cur_moder.pkts, true);
> +
> +     dim->state = DIM_START_MEASURE;
> +}
> +
> +static void mana_tx_dim_work(struct work_struct *work)
> +{
> +     struct dim *dim = container_of(work, struct dim, work);
> +     struct dim_cq_moder cur_moder;
> +     struct mana_cq *cq;
> +
> +     cur_moder = net_dim_get_tx_moderation(dim->mode, dim->profile_ix);
> +     cq = container_of(dim, struct mana_cq, dim);
> +
> +     cur_moder.usec = min_t(u16, cur_moder.usec, MANA_INTR_MODR_USEC_MAX);
> +     cur_moder.pkts = min_t(u16, cur_moder.pkts, MANA_INTR_MODR_COMP_MAX);
> +
> +     mana_gd_ring_dim(cq->gdma_cq, cur_moder.usec, true,
> +                      cur_moder.pkts, true);
> +
> +     dim->state = DIM_START_MEASURE;
> +}
> +
> +/* The caller must update apc->rx/tx_dim_enabled before disabling and
> + * after enabling. And synchronize_net() before draining the DIM work,
> + * so that NAPI cannot observe a stale flag.
> + */
> +int mana_dim_change(struct mana_cq *cq, bool enable)

This always return 0, and the return value is not checked by the
callers; return type should likelly changed to void

/P


Reply via email to