History

virtio_net: extract interrupt coalescing settings to a structure

Extract interrupt coalescing settings to a structure so that it could be reused in other data structures.

Gavin Li committed 3 years ago

Commit 308d7981 parent 999d0861 file · +19 −16Browse files

Unified · Split

drivers/net/virtio_net.c+19−16
@@ -126,6 +126,11 @@ static const struct virtnet_stat_desc virtnet_rq_stats_desc[] = { · 125 unmodified lines
126126 #define VIRTNET_SQ_STATS_LEN ARRAY_SIZE(virtnet_sq_stats_desc)
127127 #define VIRTNET_RQ_STATS_LEN ARRAY_SIZE(virtnet_rq_stats_desc)
128128
129+struct virtnet_interrupt_coalesce {
130+ u32 max_packets;
131+ u32 max_usecs;
132+};
133+
129134 /* Internal representation of a send virtqueue */
130135 struct send_queue {
131136 /* Virtqueue associated with this send _queue */
@@ -281,10 +286,8 @@ struct virtnet_info { · 149 unmodified lines
281286 u32 speed;
282287
283288 /* Interrupt coalescing settings */
284− u32 tx_usecs;
285− u32 rx_usecs;
286− u32 tx_max_packets;
287− u32 rx_max_packets;
289+ struct virtnet_interrupt_coalesce intr_coal_tx;
290+ struct virtnet_interrupt_coalesce intr_coal_rx;
288291
289292 unsigned long guest_offloads;
290293 unsigned long guest_offloads_capable;
@@ -3056,8 +3059,8 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, · 2765 unmodified lines
30563059 return -EINVAL;
30573060
30583061 /* Save parameters */
3059− vi->tx_usecs = ec->tx_coalesce_usecs;
3060− vi->tx_max_packets = ec->tx_max_coalesced_frames;
3062+ vi->intr_coal_tx.max_usecs = ec->tx_coalesce_usecs;
3063+ vi->intr_coal_tx.max_packets = ec->tx_max_coalesced_frames;
30613064
30623065 vi->ctrl->coal_rx.rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs);
30633066 vi->ctrl->coal_rx.rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames);
@@ -3069,8 +3072,8 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi, · 5 unmodified lines
30693072 return -EINVAL;
30703073
30713074 /* Save parameters */
3072− vi->rx_usecs = ec->rx_coalesce_usecs;
3073− vi->rx_max_packets = ec->rx_max_coalesced_frames;
3075+ vi->intr_coal_rx.max_usecs = ec->rx_coalesce_usecs;
3076+ vi->intr_coal_rx.max_packets = ec->rx_max_coalesced_frames;
30743077
30753078 return 0;
30763079 }
@@ -3132,10 +3135,10 @@ static int virtnet_get_coalesce(struct net_device *dev, · 55 unmodified lines
31323135 struct virtnet_info *vi = netdev_priv(dev);
31333136
31343137 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) {
3135− ec->rx_coalesce_usecs = vi->rx_usecs;
3136− ec->tx_coalesce_usecs = vi->tx_usecs;
3137− ec->tx_max_coalesced_frames = vi->tx_max_packets;
3138− ec->rx_max_coalesced_frames = vi->rx_max_packets;
3138+ ec->rx_coalesce_usecs = vi->intr_coal_rx.max_usecs;
3139+ ec->tx_coalesce_usecs = vi->intr_coal_tx.max_usecs;
3140+ ec->tx_max_coalesced_frames = vi->intr_coal_tx.max_packets;
3141+ ec->rx_max_coalesced_frames = vi->intr_coal_rx.max_packets;
31393142 } else {
31403143 ec->rx_max_coalesced_frames = 1;
31413144
@@ -4119,10 +4122,10 @@ static int virtnet_probe(struct virtio_device *vdev) · 977 unmodified lines
41194122 }
41204123
41214124 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) {
4122− vi->rx_usecs = 0;
4123− vi->tx_usecs = 0;
4124− vi->tx_max_packets = 0;
4125− vi->rx_max_packets = 0;
4125+ vi->intr_coal_rx.max_usecs = 0;
4126+ vi->intr_coal_tx.max_usecs = 0;
4127+ vi->intr_coal_tx.max_packets = 0;
4128+ vi->intr_coal_rx.max_packets = 0;
41264129 }
41274130
41284131 if (virtio_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t