virtio-net: consistently save parameters for per-queue
authorHeng Qi <hengqi@linux.alibaba.com>
Sun, 8 Oct 2023 06:27:41 +0000 (14:27 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Oct 2023 06:13:50 +0000 (07:13 +0100)
When using .set_coalesce interface to set all queue coalescing
parameters, we need to update both per-queue and global save values.

Fixes: 394bd87764b6 ("virtio_net: support per queue interrupt coalesce command")
Cc: Gavin Li <gavinl@nvidia.com>
Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c

index 1037febefc3771ecbbf1c71354e5b08ede0b8193..04b48ca9ab1fa6756d49834e2ae34de70a431e12 100644 (file)
@@ -3233,6 +3233,7 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi,
                                       struct ethtool_coalesce *ec)
 {
        struct scatterlist sgs_tx, sgs_rx;
+       int i;
 
        vi->ctrl->coal_tx.tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs);
        vi->ctrl->coal_tx.tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames);
@@ -3246,6 +3247,10 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi,
        /* Save parameters */
        vi->intr_coal_tx.max_usecs = ec->tx_coalesce_usecs;
        vi->intr_coal_tx.max_packets = ec->tx_max_coalesced_frames;
+       for (i = 0; i < vi->max_queue_pairs; i++) {
+               vi->sq[i].intr_coal.max_usecs = ec->tx_coalesce_usecs;
+               vi->sq[i].intr_coal.max_packets = ec->tx_max_coalesced_frames;
+       }
 
        vi->ctrl->coal_rx.rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs);
        vi->ctrl->coal_rx.rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames);
@@ -3259,6 +3264,10 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi,
        /* Save parameters */
        vi->intr_coal_rx.max_usecs = ec->rx_coalesce_usecs;
        vi->intr_coal_rx.max_packets = ec->rx_max_coalesced_frames;
+       for (i = 0; i < vi->max_queue_pairs; i++) {
+               vi->rq[i].intr_coal.max_usecs = ec->rx_coalesce_usecs;
+               vi->rq[i].intr_coal.max_packets = ec->rx_max_coalesced_frames;
+       }
 
        return 0;
 }