Skip to content

Commit fce2903

Browse files
danielj-mellanoxPaolo Abeni
authored andcommitted
virtio_net: Store RSS setting in virtnet_info
Stop storing RSS setting in the control buffer. This is prep work for removing RTNL lock protection of the control buffer. Signed-off-by: Daniel Jurgens <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Reviewed-by: Heng Qi <[email protected]> Tested-by: Heng Qi <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent d8dcf5b commit fce2903

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

drivers/net/virtio_net.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ struct control_buf {
373373
u8 allmulti;
374374
__virtio16 vid;
375375
__virtio64 offloads;
376-
struct virtio_net_ctrl_rss rss;
377376
struct virtio_net_ctrl_coal_tx coal_tx;
378377
struct virtio_net_ctrl_coal_rx coal_rx;
379378
struct virtio_net_ctrl_coal_vq coal_vq;
@@ -416,6 +415,7 @@ struct virtnet_info {
416415
u16 rss_indir_table_size;
417416
u32 rss_hash_types_supported;
418417
u32 rss_hash_types_saved;
418+
struct virtio_net_ctrl_rss rss;
419419

420420
/* Has control virtqueue */
421421
bool has_cvq;
@@ -3243,17 +3243,17 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi)
32433243
sg_init_table(sgs, 4);
32443244

32453245
sg_buf_size = offsetof(struct virtio_net_ctrl_rss, indirection_table);
3246-
sg_set_buf(&sgs[0], &vi->ctrl->rss, sg_buf_size);
3246+
sg_set_buf(&sgs[0], &vi->rss, sg_buf_size);
32473247

3248-
sg_buf_size = sizeof(uint16_t) * (vi->ctrl->rss.indirection_table_mask + 1);
3249-
sg_set_buf(&sgs[1], vi->ctrl->rss.indirection_table, sg_buf_size);
3248+
sg_buf_size = sizeof(uint16_t) * (vi->rss.indirection_table_mask + 1);
3249+
sg_set_buf(&sgs[1], vi->rss.indirection_table, sg_buf_size);
32503250

32513251
sg_buf_size = offsetof(struct virtio_net_ctrl_rss, key)
32523252
- offsetof(struct virtio_net_ctrl_rss, max_tx_vq);
3253-
sg_set_buf(&sgs[2], &vi->ctrl->rss.max_tx_vq, sg_buf_size);
3253+
sg_set_buf(&sgs[2], &vi->rss.max_tx_vq, sg_buf_size);
32543254

32553255
sg_buf_size = vi->rss_key_size;
3256-
sg_set_buf(&sgs[3], vi->ctrl->rss.key, sg_buf_size);
3256+
sg_set_buf(&sgs[3], vi->rss.key, sg_buf_size);
32573257

32583258
if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ,
32593259
vi->has_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG
@@ -3269,21 +3269,21 @@ static void virtnet_init_default_rss(struct virtnet_info *vi)
32693269
u32 indir_val = 0;
32703270
int i = 0;
32713271

3272-
vi->ctrl->rss.hash_types = vi->rss_hash_types_supported;
3272+
vi->rss.hash_types = vi->rss_hash_types_supported;
32733273
vi->rss_hash_types_saved = vi->rss_hash_types_supported;
3274-
vi->ctrl->rss.indirection_table_mask = vi->rss_indir_table_size
3274+
vi->rss.indirection_table_mask = vi->rss_indir_table_size
32753275
? vi->rss_indir_table_size - 1 : 0;
3276-
vi->ctrl->rss.unclassified_queue = 0;
3276+
vi->rss.unclassified_queue = 0;
32773277

32783278
for (; i < vi->rss_indir_table_size; ++i) {
32793279
indir_val = ethtool_rxfh_indir_default(i, vi->curr_queue_pairs);
3280-
vi->ctrl->rss.indirection_table[i] = indir_val;
3280+
vi->rss.indirection_table[i] = indir_val;
32813281
}
32823282

3283-
vi->ctrl->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0;
3284-
vi->ctrl->rss.hash_key_length = vi->rss_key_size;
3283+
vi->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0;
3284+
vi->rss.hash_key_length = vi->rss_key_size;
32853285

3286-
netdev_rss_key_fill(vi->ctrl->rss.key, vi->rss_key_size);
3286+
netdev_rss_key_fill(vi->rss.key, vi->rss_key_size);
32873287
}
32883288

32893289
static void virtnet_get_hashflow(const struct virtnet_info *vi, struct ethtool_rxnfc *info)
@@ -3394,7 +3394,7 @@ static bool virtnet_set_hashflow(struct virtnet_info *vi, struct ethtool_rxnfc *
33943394

33953395
if (new_hashtypes != vi->rss_hash_types_saved) {
33963396
vi->rss_hash_types_saved = new_hashtypes;
3397-
vi->ctrl->rss.hash_types = vi->rss_hash_types_saved;
3397+
vi->rss.hash_types = vi->rss_hash_types_saved;
33983398
if (vi->dev->features & NETIF_F_RXHASH)
33993399
return virtnet_commit_rss_command(vi);
34003400
}
@@ -4574,11 +4574,11 @@ static int virtnet_get_rxfh(struct net_device *dev,
45744574

45754575
if (rxfh->indir) {
45764576
for (i = 0; i < vi->rss_indir_table_size; ++i)
4577-
rxfh->indir[i] = vi->ctrl->rss.indirection_table[i];
4577+
rxfh->indir[i] = vi->rss.indirection_table[i];
45784578
}
45794579

45804580
if (rxfh->key)
4581-
memcpy(rxfh->key, vi->ctrl->rss.key, vi->rss_key_size);
4581+
memcpy(rxfh->key, vi->rss.key, vi->rss_key_size);
45824582

45834583
rxfh->hfunc = ETH_RSS_HASH_TOP;
45844584

@@ -4602,7 +4602,7 @@ static int virtnet_set_rxfh(struct net_device *dev,
46024602
return -EOPNOTSUPP;
46034603

46044604
for (i = 0; i < vi->rss_indir_table_size; ++i)
4605-
vi->ctrl->rss.indirection_table[i] = rxfh->indir[i];
4605+
vi->rss.indirection_table[i] = rxfh->indir[i];
46064606
update = true;
46074607
}
46084608

@@ -4614,7 +4614,7 @@ static int virtnet_set_rxfh(struct net_device *dev,
46144614
if (!vi->has_rss && !vi->has_rss_hash_report)
46154615
return -EOPNOTSUPP;
46164616

4617-
memcpy(vi->ctrl->rss.key, rxfh->key, vi->rss_key_size);
4617+
memcpy(vi->rss.key, rxfh->key, vi->rss_key_size);
46184618
update = true;
46194619
}
46204620

@@ -5028,9 +5028,9 @@ static int virtnet_set_features(struct net_device *dev,
50285028

50295029
if ((dev->features ^ features) & NETIF_F_RXHASH) {
50305030
if (features & NETIF_F_RXHASH)
5031-
vi->ctrl->rss.hash_types = vi->rss_hash_types_saved;
5031+
vi->rss.hash_types = vi->rss_hash_types_saved;
50325032
else
5033-
vi->ctrl->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE;
5033+
vi->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE;
50345034

50355035
if (!virtnet_commit_rss_command(vi))
50365036
return -EINVAL;

0 commit comments

Comments
 (0)