Skip to content

Commit

Permalink
net/virtio-user: add VIRTIO_NET_F_RSS to supported features
Browse files Browse the repository at this point in the history
This patch introduces new function to get rss device config
and adds code to forward the RSS control command to backend
through hw control queue if RSS feature is negotiated.
This patch will help to negotiate VIRTIO_NET_F_RSS feature
if vhost-vdpa backend supports RSS in HW.

Signed-off-by: Srujana Challa <schalla@marvell.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
SruChalla authored and ovsrobot committed Jan 24, 2024
1 parent 6be9a7e commit f9900d6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
31 changes: 30 additions & 1 deletion drivers/net/virtio/virtio_user/virtio_user_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ virtio_user_dev_init_max_queue_pairs(struct virtio_user_dev *dev, uint32_t user_
return 0;
}

int
virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst, size_t offset, int length)
{
int ret = 0;

if (!(dev->device_features & (1ULL << VIRTIO_NET_F_RSS)))
return -ENOTSUP;

if (!dev->ops->get_config)
return -ENOTSUP;

ret = dev->ops->get_config(dev, dst, offset, length);
if (ret)
PMD_DRV_LOG(ERR, "(%s) Failed to get rss config in device", dev->path);

return ret;
}

int
virtio_user_dev_set_mac(struct virtio_user_dev *dev)
{
Expand Down Expand Up @@ -682,7 +700,8 @@ virtio_user_free_vrings(struct virtio_user_dev *dev)
1ULL << VIRTIO_F_IN_ORDER | \
1ULL << VIRTIO_F_VERSION_1 | \
1ULL << VIRTIO_F_RING_PACKED | \
1ULL << VIRTIO_F_NOTIFICATION_DATA)
1ULL << VIRTIO_F_NOTIFICATION_DATA | \
1ULL << VIRTIO_NET_F_RSS)

int
virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
Expand Down Expand Up @@ -894,6 +913,11 @@ virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring *vri

queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
status = virtio_user_handle_mq(dev, queues);
} else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
struct virtio_net_ctrl_rss *rss;

rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring->desc[idx_data].addr;
status = virtio_user_handle_mq(dev, rss->max_tx_vq);
} else if (hdr->class == VIRTIO_NET_CTRL_RX ||
hdr->class == VIRTIO_NET_CTRL_MAC ||
hdr->class == VIRTIO_NET_CTRL_VLAN) {
Expand Down Expand Up @@ -955,6 +979,11 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
queues = *(uint16_t *)(uintptr_t)
vring->desc[idx_data].addr;
status = virtio_user_handle_mq(dev, queues);
} else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
struct virtio_net_ctrl_rss *rss;

rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring->desc[idx_data].addr;
status = virtio_user_handle_mq(dev, rss->max_tx_vq);
} else if (hdr->class == VIRTIO_NET_CTRL_RX ||
hdr->class == VIRTIO_NET_CTRL_MAC ||
hdr->class == VIRTIO_NET_CTRL_VLAN) {
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/virtio/virtio_user/virtio_user_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ int virtio_user_dev_update_status(struct virtio_user_dev *dev);
int virtio_user_dev_update_link_state(struct virtio_user_dev *dev);
int virtio_user_dev_set_mac(struct virtio_user_dev *dev);
int virtio_user_dev_get_mac(struct virtio_user_dev *dev);
int virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst, size_t offset,
int length);
void virtio_user_dev_delayed_disconnect_handler(void *param);
int virtio_user_dev_server_reconnect(struct virtio_user_dev *dev);
extern const char * const virtio_user_backend_strings[];
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/virtio/virtio_user_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,

if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))
*(uint16_t *)dst = dev->max_queue_pairs;

if (offset >= offsetof(struct virtio_net_config, rss_max_key_size))
virtio_user_dev_get_rss_config(dev, dst, offset, length);
}

static void
Expand Down

0 comments on commit f9900d6

Please sign in to comment.