Skip to contentSkip to conversation

vdpa: conditionally fill max max queue pair for stats

PATCH In review Jason Wang 3 participants 6 messages Sep 7, 2022 – Dec 13, 2022 virtio core

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 vdpa: conditionally fill max max queue pair for stats

For the device without multiqueue feature, we will read 0 as max_virtqueue_pairs from the config. So if we fill VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the config we will confuse the user.

Fixing this by only filling the value when multiqueue is offered by the device so userspace can assume 1 when the attr is not provided.

Fixes 13b00b135665c("vdpa: Add support for querying vendor statistics")
Cc Eli Cohen <[email protected]>
---
 drivers/vdpa/vdpa.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +4 -5
index c06c02704461..bc328197263f 100644
@@ -894,7 +894,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg,
 {
 	struct virtio_net_config config = {};
 	u64 features;
-	u16 max_vqp;
 	u8 status;
 	int err;
 
@@ -905,15 +904,15 @@ static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg,
 	}
 	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
 
-	max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
-	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, max_vqp))
-		return -EMSGSIZE;
-
 	features = vdev->config->get_driver_features(vdev);
 	if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
 			      features, VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
+	err = vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	if (err)
+		return err;
+
 	if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
 		return -EMSGSIZE;
 
Signature · 6 lines
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#1 lore raw
Quoted 8 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:01
To: [email protected]; [email protected]; Eli Cohen <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] vdpa: conditionally fill max max queue pair for stats

For the device without multiqueue feature, we will read 0 as max_virtqueue_pairs from the config.

If this is the case for other vdpa vendor drivers, shouldn't we fix it there? After all, config->max_virtqueue_pairs should always show valid values.

Quoted 38 lines

So if we fill
VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the config
we will confuse the user.

Fixing this by only filling the value when multiqueue is offered by the device so userspace can assume 1 when the attr is not provided.

Fixes 13b00b135665c("vdpa: Add support for querying vendor statistics")
Cc Eli Cohen <[email protected]>
---
 drivers/vdpa/vdpa.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +0 -5
index c06c02704461..bc328197263f 100644
@@ -894,7 +894,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device
 *vdev, struct sk_buff *msg,
 {
 	struct virtio_net_config config = {};
 	u64 features;
-	u16 max_vqp;
 	u8 status;
 	int err;
@@ -905,15 +904,15 @@ static int vdpa_fill_stats_rec(struct vdpa_device
 *vdev, struct sk_buff *msg,
 	}
 	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
 
-	max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
-	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 max_vqp))
-		return -EMSGSIZE;
-

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct vdpa_device · line 918

Quoted 10 lines
drivers/vdpa/vdpa.c +4 -0
 	features = vdev->config->get_driver_features(vdev);
 	if (nla_put_u64_64bit(msg,
 VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
 			      features, VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
+	err = vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	if (err)
+		return err;
+

So that means that you can't read statistics when MQ is not supported. Is this worth sacrificing?

Quoted 5 lines
drivers/vdpa/vdpa.c +0 -1
 	if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
 		return -EMSGSIZE;
 
--

2.25.1

author
#2 lore raw
Quoted 11 lines · Eli Cohen
Quoted 9 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:01
To: [email protected]; [email protected]; Eli Cohen <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] vdpa: conditionally fill max max queue pair for stats

For the device without multiqueue feature, we will read 0 as max_virtqueue_pairs from the config.

If this is the case for other vdpa vendor drivers, shouldn't we fix it there? After all, config->max_virtqueue_pairs should always show valid values.

Not for the case when the device doesn't offer MQ. According to the spec, the max_virtqueue_pairs doesn't exist in this case.

Quoted 45 lines
Quoted 45 lines

So if we fill
VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the config
we will confuse the user.

Fixing this by only filling the value when multiqueue is offered by the device so userspace can assume 1 when the attr is not provided.

Fixes 13b00b135665c("vdpa: Add support for querying vendor statistics")
Cc Eli Cohen <[email protected]>
---
 drivers/vdpa/vdpa.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +0 -5
index c06c02704461..bc328197263f 100644
@@ -894,7 +894,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device
 *vdev, struct sk_buff *msg,
 {
      struct virtio_net_config config = {};
      u64 features;
-     u16 max_vqp;
      u8 status;
      int err;
@@ -905,15 +904,15 @@ static int vdpa_fill_stats_rec(struct vdpa_device
 *vdev, struct sk_buff *msg,
      }
      vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
 
-     max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
-     if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 max_vqp))
-             return -EMSGSIZE;
-
      features = vdev->config->get_driver_features(vdev);
      if (nla_put_u64_64bit(msg,
 VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
                            features, VDPA_ATTR_PAD))
              return -EMSGSIZE;
 
Quoted 6 lines

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg, · line 915

Quoted 4 lines
drivers/vdpa/vdpa.c +4 -0
+     err = vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+     if (err)
+             return err;
+

So that means that you can't read statistics when MQ is not supported. Is this worth sacrificing?

vdpa_dev_net_mq_config_fill() will return 0 in the case of !MQ, so it should still work.

Thanks

Quoted 7 lines
Quoted 6 lines
      if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
              return -EMSGSIZE;

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reviewed-by
#3 lore raw
Quoted 16 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:53
To: Eli Cohen <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH] vdpa: conditionally fill max max queue pair for stats

Quoted 4 lines · Eli Cohen
Quoted 4 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:01
To: [email protected]; [email protected]; Eli Cohen

<[email protected]>;

Quoted 3 lines
Quoted 3 lines

[email protected]; [email protected]
Subject: [PATCH] vdpa: conditionally fill max max queue pair for stats

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

For the device without multiqueue feature, we will read 0 as max_virtqueue_pairs from the config.

If this is the case for other vdpa vendor drivers, shouldn't we fix it there?

After all,

Quoted 1 line

config->max_virtqueue_pairs should always show valid values.

Not for the case when the device doesn't offer MQ. According to the spec, the max_virtqueue_pairs doesn't exist in this case.

I see, thanks.

Quoted 53 lines
Quoted 10 lines
Quoted 10 lines

So if we fill
VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the config
we will confuse the user.

Fixing this by only filling the value when multiqueue is offered by the device so userspace can assume 1 when the attr is not provided.

Fixes 13b00b135665c("vdpa: Add support for querying vendor

statistics")

Quoted 19 lines
Quoted 19 lines
---
 drivers/vdpa/vdpa.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +0 -1
index c06c02704461..bc328197263f 100644
@@ -894,7 +894,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device
 *vdev, struct sk_buff *msg,
 {
      struct virtio_net_config config = {};
      u64 features;
-     u16 max_vqp;
      u8 status;
      int err;
Quoted 1 line

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct

Quoted 1 line
drivers/vdpa/vdpa.c +0 -0
@@ -905,15 +904,15 @@ static int vdpa_fill_stats_rec(struct

vdpa_device

Quoted 15 lines
Quoted 15 lines
drivers/vdpa/vdpa.c +0 -4
 *vdev, struct sk_buff *msg,
      }
      vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
 
-     max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
-     if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 max_vqp))
-             return -EMSGSIZE;
-
      features = vdev->config->get_driver_features(vdev);
      if (nla_put_u64_64bit(msg,
 VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
                            features, VDPA_ATTR_PAD))
              return -EMSGSIZE;
 
Quoted 6 lines

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg, · line 915

Quoted 4 lines
drivers/vdpa/vdpa.c +4 -0
+     err = vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+     if (err)
+             return err;
+

So that means that you can't read statistics when MQ is not supported. Is

Quoted 4 lines

this worth sacrificing?

vdpa_dev_net_mq_config_fill() will return 0 in the case of !MQ, so it should still work.

Right, missed that.

Quoted 11 lines

Thanks

Quoted 7 lines
Quoted 6 lines
      if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
              return -EMSGSIZE;

--
2.25.1

author
#4 lore raw
Quoted 81 lines · Eli Cohen
Quoted 17 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:53
To: Eli Cohen <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH] vdpa: conditionally fill max max queue pair for stats

Quoted 4 lines · Eli Cohen
Quoted 4 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:01
To: [email protected]; [email protected]; Eli Cohen

<[email protected]>;

Quoted 3 lines
Quoted 3 lines

[email protected]; [email protected]
Subject: [PATCH] vdpa: conditionally fill max max queue pair for stats

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

For the device without multiqueue feature, we will read 0 as max_virtqueue_pairs from the config.

If this is the case for other vdpa vendor drivers, shouldn't we fix it there?

After all,

Quoted 1 line

config->max_virtqueue_pairs should always show valid values.

Not for the case when the device doesn't offer MQ. According to the spec, the max_virtqueue_pairs doesn't exist in this case.

I see, thanks.

Quoted 53 lines
Quoted 10 lines
Quoted 10 lines

So if we fill
VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the config
we will confuse the user.

Fixing this by only filling the value when multiqueue is offered by the device so userspace can assume 1 when the attr is not provided.

Fixes 13b00b135665c("vdpa: Add support for querying vendor

statistics")

Quoted 19 lines
Quoted 19 lines
---
 drivers/vdpa/vdpa.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +0 -1
index c06c02704461..bc328197263f 100644
@@ -894,7 +894,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device
 *vdev, struct sk_buff *msg,
 {
      struct virtio_net_config config = {};
      u64 features;
-     u16 max_vqp;
      u8 status;
      int err;
Quoted 1 line

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct

Quoted 1 line
drivers/vdpa/vdpa.c +0 -0
@@ -905,15 +904,15 @@ static int vdpa_fill_stats_rec(struct

vdpa_device

Quoted 21 lines
Quoted 9 lines
drivers/vdpa/vdpa.c +0 -4
 *vdev, struct sk_buff *msg,
      }
      vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
 
-     max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
-     if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 max_vqp))
-             return -EMSGSIZE;
-

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg, · line 915

Quoted 10 lines
drivers/vdpa/vdpa.c +4 -0
      features = vdev->config->get_driver_features(vdev);
      if (nla_put_u64_64bit(msg,
 VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
                            features, VDPA_ATTR_PAD))
              return -EMSGSIZE;
 
+     err = vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+     if (err)
+             return err;
+

So that means that you can't read statistics when MQ is not supported. Is

Quoted 8 lines
Quoted 4 lines

this worth sacrificing?

vdpa_dev_net_mq_config_fill() will return 0 in the case of !MQ, so it should still work.

Right, missed that.

Michael, I don't see this is merged.

Any comments for this patch?

Thanks

Quoted 6 lines
Quoted 6 lines

Thanks

Quoted 1 line
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
      if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
              return -EMSGSIZE;

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#5 lore raw
Quoted 89 lines · Jason Wang
Quoted 88 lines · Eli Cohen
Quoted 17 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:53
To: Eli Cohen <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH] vdpa: conditionally fill max max queue pair for stats

Quoted 4 lines · Eli Cohen
Quoted 4 lines

From: Jason Wang <[email protected]>
Sent: Wednesday, 7 September 2022 9:01
To: [email protected]; [email protected]; Eli Cohen

<[email protected]>;

Quoted 3 lines
Quoted 3 lines

[email protected]; [email protected]
Subject: [PATCH] vdpa: conditionally fill max max queue pair for stats

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

For the device without multiqueue feature, we will read 0 as max_virtqueue_pairs from the config.

If this is the case for other vdpa vendor drivers, shouldn't we fix it there?

After all,

Quoted 1 line

config->max_virtqueue_pairs should always show valid values.

Not for the case when the device doesn't offer MQ. According to the spec, the max_virtqueue_pairs doesn't exist in this case.

I see, thanks.

Quoted 53 lines
Quoted 10 lines
Quoted 10 lines

So if we fill
VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the config
we will confuse the user.

Fixing this by only filling the value when multiqueue is offered by the device so userspace can assume 1 when the attr is not provided.

Fixes 13b00b135665c("vdpa: Add support for querying vendor

statistics")

Quoted 19 lines
Quoted 19 lines
---
 drivers/vdpa/vdpa.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +0 -1
index c06c02704461..bc328197263f 100644
@@ -894,7 +894,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device
 *vdev, struct sk_buff *msg,
 {
      struct virtio_net_config config = {};
      u64 features;
-     u16 max_vqp;
      u8 status;
      int err;
Quoted 1 line

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct

Quoted 1 line
drivers/vdpa/vdpa.c +0 -0
@@ -905,15 +904,15 @@ static int vdpa_fill_stats_rec(struct

vdpa_device

Quoted 15 lines
Quoted 15 lines
drivers/vdpa/vdpa.c +0 -4
 *vdev, struct sk_buff *msg,
      }
      vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
 
-     max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
-     if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 max_vqp))
-             return -EMSGSIZE;
-
      features = vdev->config->get_driver_features(vdev);
      if (nla_put_u64_64bit(msg,
 VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
                            features, VDPA_ATTR_PAD))
              return -EMSGSIZE;
 
Quoted 6 lines

drivers/vdpa/vdpa.c static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg, · line 915

Quoted 4 lines
drivers/vdpa/vdpa.c +4 -0
+     err = vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+     if (err)
+             return err;
+

So that means that you can't read statistics when MQ is not supported. Is

Quoted 4 lines

this worth sacrificing?

vdpa_dev_net_mq_config_fill() will return 0 in the case of !MQ, so it should still work.

Right, missed that.

Quoted 8 lines
Quoted 1 line

Michael, I don't see this is merged.

Any comments for this patch?

Thanks

Will be in the pull. Working on it now, it's pretty big.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Thanks

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
      if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
              return -EMSGSIZE;

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization