Skip to content

Commit

Permalink
virtio_net: Fix endian with virtio_net_ctrl_rss
Browse files Browse the repository at this point in the history
Mark the fields of struct virtio_net_ctrl_rss as little endian as
they are in struct virtio_net_rss_config, which it follows.

Fixes: c7114b1 ("drivers/net/virtio_net: Added basic RSS support.")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://patch.msgid.link/20250321-virtio-v2-2-33afb8f4640b@daynix.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Akihiko Odaki authored and Jakub Kicinski committed Mar 25, 2025
1 parent 976c269 commit 9784134
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ struct receive_queue {
*/
#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40
struct virtio_net_ctrl_rss {
u32 hash_types;
u16 indirection_table_mask;
u16 unclassified_queue;
u16 hash_cfg_reserved; /* for HASH_CONFIG (see virtio_net_hash_config for details) */
u16 max_tx_vq;
__le32 hash_types;
__le16 indirection_table_mask;
__le16 unclassified_queue;
__le16 hash_cfg_reserved; /* for HASH_CONFIG (see virtio_net_hash_config for details) */
__le16 max_tx_vq;
u8 hash_key_length;
u8 key[VIRTIO_NET_RSS_MAX_KEY_SIZE];

u16 *indirection_table;
__le16 *indirection_table;
};

/* Control VQ buffers: protected by the rtnl lock */
Expand Down Expand Up @@ -3638,9 +3638,9 @@ static void virtnet_rss_update_by_qpairs(struct virtnet_info *vi, u16 queue_pair

for (; i < vi->rss_indir_table_size; ++i) {
indir_val = ethtool_rxfh_indir_default(i, queue_pairs);
vi->rss.indirection_table[i] = indir_val;
vi->rss.indirection_table[i] = cpu_to_le16(indir_val);
}
vi->rss.max_tx_vq = queue_pairs;
vi->rss.max_tx_vq = cpu_to_le16(queue_pairs);
}

static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)
Expand Down Expand Up @@ -4159,10 +4159,10 @@ static bool virtnet_commit_rss_command(struct virtnet_info *vi)

static void virtnet_init_default_rss(struct virtnet_info *vi)
{
vi->rss.hash_types = vi->rss_hash_types_supported;
vi->rss.hash_types = cpu_to_le32(vi->rss_hash_types_supported);
vi->rss_hash_types_saved = vi->rss_hash_types_supported;
vi->rss.indirection_table_mask = vi->rss_indir_table_size
? vi->rss_indir_table_size - 1 : 0;
? cpu_to_le16(vi->rss_indir_table_size - 1) : 0;
vi->rss.unclassified_queue = 0;

virtnet_rss_update_by_qpairs(vi, vi->curr_queue_pairs);
Expand Down Expand Up @@ -4280,7 +4280,7 @@ static bool virtnet_set_hashflow(struct virtnet_info *vi, struct ethtool_rxnfc *

if (new_hashtypes != vi->rss_hash_types_saved) {
vi->rss_hash_types_saved = new_hashtypes;
vi->rss.hash_types = vi->rss_hash_types_saved;
vi->rss.hash_types = cpu_to_le32(vi->rss_hash_types_saved);
if (vi->dev->features & NETIF_F_RXHASH)
return virtnet_commit_rss_command(vi);
}
Expand Down Expand Up @@ -5460,7 +5460,7 @@ static int virtnet_get_rxfh(struct net_device *dev,

if (rxfh->indir) {
for (i = 0; i < vi->rss_indir_table_size; ++i)
rxfh->indir[i] = vi->rss.indirection_table[i];
rxfh->indir[i] = le16_to_cpu(vi->rss.indirection_table[i]);
}

if (rxfh->key)
Expand Down Expand Up @@ -5488,7 +5488,7 @@ static int virtnet_set_rxfh(struct net_device *dev,
return -EOPNOTSUPP;

for (i = 0; i < vi->rss_indir_table_size; ++i)
vi->rss.indirection_table[i] = rxfh->indir[i];
vi->rss.indirection_table[i] = cpu_to_le16(rxfh->indir[i]);
update = true;
}

Expand Down Expand Up @@ -6109,9 +6109,9 @@ static int virtnet_set_features(struct net_device *dev,

if ((dev->features ^ features) & NETIF_F_RXHASH) {
if (features & NETIF_F_RXHASH)
vi->rss.hash_types = vi->rss_hash_types_saved;
vi->rss.hash_types = cpu_to_le32(vi->rss_hash_types_saved);
else
vi->rss.hash_types = VIRTIO_NET_HASH_REPORT_NONE;
vi->rss.hash_types = cpu_to_le32(VIRTIO_NET_HASH_REPORT_NONE);

if (!virtnet_commit_rss_command(vi))
return -EINVAL;
Expand Down

0 comments on commit 9784134

Please sign in to comment.