diff mbox series

[net,v2,4/6] virtio-net: fix per queue coalescing parameter setting

Message ID 967eec7b4eaad940222448043c1098559bc484da.1695627660.git.hengqi@linux.alibaba.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series virtio-net: Fix and update interrupt moderation | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1340 this patch: 1340
netdev/cc_maintainers fail 1 blamed authors not CCed: dtatulea@nvidia.com; 1 maintainers not CCed: dtatulea@nvidia.com
netdev/build_clang success Errors and warnings before: 1363 this patch: 1363
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1365 this patch: 1365
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Heng Qi Sept. 25, 2023, 7:53 a.m. UTC
When the user sets a non-zero coalescing parameter to 0 for a specific
virtqueue, it does not work as expected, so let's fix this.

Fixes: 394bd87764b6 ("virtio_net: support per queue interrupt coalesce command")
Reported-by: Xiaoming Zhao <zxm377917@alibaba-inc.com>
Cc: Gavin Li <gavinl@nvidia.com>
Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>
---
v1->v2:
    1. Remove useless comments.

 drivers/net/virtio_net.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

Comments

Jason Wang Oct. 8, 2023, 5:20 a.m. UTC | #1
On Mon, Sep 25, 2023 at 3:53 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>
> When the user sets a non-zero coalescing parameter to 0 for a specific
> virtqueue, it does not work as expected, so let's fix this.
>
> Fixes: 394bd87764b6 ("virtio_net: support per queue interrupt coalesce command")
> Reported-by: Xiaoming Zhao <zxm377917@alibaba-inc.com>
> Cc: Gavin Li <gavinl@nvidia.com>
> Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

> ---
> v1->v2:
>     1. Remove useless comments.
>
>  drivers/net/virtio_net.c | 36 ++++++++++++++++--------------------
>  1 file changed, 16 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 6120dd5343dd..12ec3ae19b60 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -3296,27 +3296,23 @@ static int virtnet_send_notf_coal_vq_cmds(struct virtnet_info *vi,
>  {
>         int err;
>
> -       if (ec->rx_coalesce_usecs || ec->rx_max_coalesced_frames) {
> -               err = virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue),
> -                                                   ec->rx_coalesce_usecs,
> -                                                   ec->rx_max_coalesced_frames);
> -               if (err)
> -                       return err;
> -               /* Save parameters */
> -               vi->rq[queue].intr_coal.max_usecs = ec->rx_coalesce_usecs;
> -               vi->rq[queue].intr_coal.max_packets = ec->rx_max_coalesced_frames;
> -       }
> +       err = virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue),
> +                                           ec->rx_coalesce_usecs,
> +                                           ec->rx_max_coalesced_frames);
> +       if (err)
> +               return err;
>
> -       if (ec->tx_coalesce_usecs || ec->tx_max_coalesced_frames) {
> -               err = virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue),
> -                                                   ec->tx_coalesce_usecs,
> -                                                   ec->tx_max_coalesced_frames);
> -               if (err)
> -                       return err;
> -               /* Save parameters */
> -               vi->sq[queue].intr_coal.max_usecs = ec->tx_coalesce_usecs;
> -               vi->sq[queue].intr_coal.max_packets = ec->tx_max_coalesced_frames;
> -       }
> +       vi->rq[queue].intr_coal.max_usecs = ec->rx_coalesce_usecs;
> +       vi->rq[queue].intr_coal.max_packets = ec->rx_max_coalesced_frames;
> +
> +       err = virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue),
> +                                           ec->tx_coalesce_usecs,
> +                                           ec->tx_max_coalesced_frames);
> +       if (err)
> +               return err;
> +
> +       vi->sq[queue].intr_coal.max_usecs = ec->tx_coalesce_usecs;
> +       vi->sq[queue].intr_coal.max_packets = ec->tx_max_coalesced_frames;
>
>         return 0;
>  }
> --
> 2.19.1.6.gb485710b
>
>
diff mbox series

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 6120dd5343dd..12ec3ae19b60 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -3296,27 +3296,23 @@  static int virtnet_send_notf_coal_vq_cmds(struct virtnet_info *vi,
 {
 	int err;
 
-	if (ec->rx_coalesce_usecs || ec->rx_max_coalesced_frames) {
-		err = virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue),
-						    ec->rx_coalesce_usecs,
-						    ec->rx_max_coalesced_frames);
-		if (err)
-			return err;
-		/* Save parameters */
-		vi->rq[queue].intr_coal.max_usecs = ec->rx_coalesce_usecs;
-		vi->rq[queue].intr_coal.max_packets = ec->rx_max_coalesced_frames;
-	}
+	err = virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue),
+					    ec->rx_coalesce_usecs,
+					    ec->rx_max_coalesced_frames);
+	if (err)
+		return err;
 
-	if (ec->tx_coalesce_usecs || ec->tx_max_coalesced_frames) {
-		err = virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue),
-						    ec->tx_coalesce_usecs,
-						    ec->tx_max_coalesced_frames);
-		if (err)
-			return err;
-		/* Save parameters */
-		vi->sq[queue].intr_coal.max_usecs = ec->tx_coalesce_usecs;
-		vi->sq[queue].intr_coal.max_packets = ec->tx_max_coalesced_frames;
-	}
+	vi->rq[queue].intr_coal.max_usecs = ec->rx_coalesce_usecs;
+	vi->rq[queue].intr_coal.max_packets = ec->rx_max_coalesced_frames;
+
+	err = virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue),
+					    ec->tx_coalesce_usecs,
+					    ec->tx_max_coalesced_frames);
+	if (err)
+		return err;
+
+	vi->sq[queue].intr_coal.max_usecs = ec->tx_coalesce_usecs;
+	vi->sq[queue].intr_coal.max_packets = ec->tx_max_coalesced_frames;
 
 	return 0;
 }