Skip to contentSkip to conversation

ifcvf/vDPA: support query device config space through netlink

PATCH Superseded Zhu Lingshan 6 participants 26 messages Jul 22, 2022 – Aug 11, 2022

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover ifcvf/vDPA: support query device config space through netlink

This series allows userspace to query device config space of vDPA devices and the management devices through netlink,
to get multi-queue, feature bits and etc.

This series has introduced a new netlink attr VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, this should be used to query features of vDPA devices than the management device.

Please help review.

Thanks!
Zhu Lingshan

Changes from V3:
(1)drop the fixes tags(Parva)
(2)better commit log for patch 1/6(Michael)
(3)assign num_queues to max_supported_vqs than max_vq_pairs(Jason) (4)initialize virtio pci capabilities in the probe() function.

Changes from V2:
Add fixes tags(Parva)

Changes from V1:
(1) Use __virito16_to_cpu(true, xxx) for the le16 casting(Jason)
(2) Add a comment in ifcvf_get_config_size(), to explain
why we should return the minimum value of
sizeof(struct virtio_net_config) and the onboard
cap size(Jason)
(3) Introduced a new attr VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES
(4) Show the changes of iproute2 output before and after 5/6 patch(Jason)
(5) Fix cast warning in vdpa_fill_stats_rec()

Zhu Lingshan (6):
vDPA/ifcvf: get_config_size should return a value no greater than dev
implementation
vDPA/ifcvf: support userspace to query features and MQ of a management
device
vDPA: allow userspace to query features of a vDPA device
vDPA: !FEATURES_OK should not block querying device config space
vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ

    == 0

vDPA: fix 'cast to restricted le16' warnings in vdpa.c

 drivers/vdpa/ifcvf/ifcvf_base.c |  13 ++-
 drivers/vdpa/ifcvf/ifcvf_base.h |   2 +
 drivers/vdpa/ifcvf/ifcvf_main.c | 142 +++++++++++++++++---------------
 drivers/vdpa/vdpa.c             |  32 ++++---
 include/uapi/linux/vdpa.h       |   1 +
 5 files changed, 105 insertions(+), 85 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v4 1/6 vDPA/ifcvf: get_config_size should return a value no greater than dev implementation

Drivers must not access a BAR outside the capability length, and for a virtio device, ifcvf driver should not report any non-standard capability contents to the upper layers.

Function ifcvf_get_config_size() is introduced here to return a safe value of the device config capability size.

---
 drivers/vdpa/ifcvf/ifcvf_base.c | 13 +++++++++++--
 drivers/vdpa/ifcvf/ifcvf_base.h |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/vdpa/ifcvf/ifcvf_base.c +11 -2
index 48c4dadb0c7c..85611be5ccb4 100644
@@ -128,6 +128,7 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev)
 			break;
 		case VIRTIO_PCI_CAP_DEVICE_CFG:
 			hw->dev_cfg = get_cap_addr(hw, &cap);
+			hw->cap_dev_config_size = le32_to_cpu(cap.length);
 			IFCVF_DBG(pdev, "hw->dev_cfg = %p\n", hw->dev_cfg);
 			break;
 		}
@@ -233,15 +234,23 @@ int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features)
 u32 ifcvf_get_config_size(struct ifcvf_hw *hw)
 {
 	struct ifcvf_adapter *adapter;
+	u32 net_config_size = sizeof(struct virtio_net_config);
+	u32 blk_config_size = sizeof(struct virtio_blk_config);
+	u32 cap_size = hw->cap_dev_config_size;
 	u32 config_size;
 
 	adapter = vf_to_adapter(hw);
+	/* If the onboard device config space size is greater than
+	 * the size of struct virtio_net/blk_config, only the spec
+	 * implementing contents size is returned, this is very
+	 * unlikely, defensive programming.
+	 */
 	switch (hw->dev_type) {
 	case VIRTIO_ID_NET:
-		config_size = sizeof(struct virtio_net_config);
+		config_size = min(cap_size, net_config_size);
 		break;
 	case VIRTIO_ID_BLOCK:
-		config_size = sizeof(struct virtio_blk_config);
+		config_size = min(cap_size, blk_config_size);
 		break;
 	default:
 		config_size = 0;
drivers/vdpa/ifcvf/ifcvf_base.h +2 -0
index 115b61f4924b..f5563f665cc6 100644
@@ -87,6 +87,8 @@ struct ifcvf_hw {
 	int config_irq;
 	int vqs_reused_irq;
 	u16 nr_vring;
+	/* VIRTIO_PCI_CAP_DEVICE_CFG size */
+	u32 cap_dev_config_size;
 };
 
 struct ifcvf_adapter {
Signature · 1 line
2.31.1
#2 lore raw

PATCH v4 2/6 vDPA/ifcvf: support userspace to query features and MQ of a management device

In reply to Zhu Lingshan

Adapting to current netlink interfaces, this commit allows userspace to query feature bits and MQ capability of a management device.

Currently both the vDPA device and the management device are the VF itself, thus this ifcvf should initialize the virtio capabilities in probe() before setting up the struct vdpa_mgmt_dev.

---
 drivers/vdpa/ifcvf/ifcvf_main.c | 142 +++++++++++++++++---------------
 1 file changed, 76 insertions(+), 66 deletions(-)
drivers/vdpa/ifcvf/ifcvf_main.c +76 -66
index 0a5670729412..3fd0267873f8 100644
@@ -752,59 +752,36 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 {
 	struct ifcvf_vdpa_mgmt_dev *ifcvf_mgmt_dev;
 	struct ifcvf_adapter *adapter;
+	struct vdpa_device *vdpa_dev;
 	struct pci_dev *pdev;
 	struct ifcvf_hw *vf;
-	struct device *dev;
-	int ret, i;
+	int ret;
 
 	ifcvf_mgmt_dev = container_of(mdev, struct ifcvf_vdpa_mgmt_dev, mdev);
-	if (ifcvf_mgmt_dev->adapter)
+	if (!ifcvf_mgmt_dev->adapter)
 		return -EOPNOTSUPP;
 
-	pdev = ifcvf_mgmt_dev->pdev;
-	dev = &pdev->dev;
-	adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
-				    dev, &ifc_vdpa_ops, 1, 1, name, false);
-	if (IS_ERR(adapter)) {
-		IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
-		return PTR_ERR(adapter);
-	}
-
-	ifcvf_mgmt_dev->adapter = adapter;
-
+	adapter = ifcvf_mgmt_dev->adapter;
 	vf = &adapter->vf;
-	vf->dev_type = get_dev_type(pdev);
-	vf->base = pcim_iomap_table(pdev);
+	pdev = adapter->pdev;
+	vdpa_dev = &adapter->vdpa;
 
-	adapter->pdev = pdev;
-	adapter->vdpa.dma_dev = &pdev->dev;
-
-	ret = ifcvf_init_hw(vf, pdev);
-	if (ret) {
-		IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
-		goto err;
-	}
-
-	for (i = 0; i < vf->nr_vring; i++)
-		vf->vring[i].irq = -EINVAL;
-
-	vf->hw_features = ifcvf_get_hw_features(vf);
-	vf->config_size = ifcvf_get_config_size(vf);
+	if (name)
+		ret = dev_set_name(&vdpa_dev->dev, "%s", name);
+	else
+		ret = dev_set_name(&vdpa_dev->dev, "vdpa%u", vdpa_dev->index);
 
-	adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev;
 	ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring);
 	if (ret) {
+		put_device(&adapter->vdpa.dev);
 		IFCVF_ERR(pdev, "Failed to register to vDPA bus");
-		goto err;
+		return ret;
 	}
 
 	return 0;
-
-err:
-	put_device(&adapter->vdpa.dev);
-	return ret;
 }
 
+
 static void ifcvf_vdpa_dev_del(struct vdpa_mgmt_dev *mdev, struct vdpa_device *dev)
 {
 	struct ifcvf_vdpa_mgmt_dev *ifcvf_mgmt_dev;
@@ -823,61 +800,94 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	struct ifcvf_vdpa_mgmt_dev *ifcvf_mgmt_dev;
 	struct device *dev = &pdev->dev;
+	struct ifcvf_adapter *adapter;
+	struct ifcvf_hw *vf;
 	u32 dev_type;
-	int ret;
-
-	ifcvf_mgmt_dev = kzalloc(sizeof(struct ifcvf_vdpa_mgmt_dev), GFP_KERNEL);
-	if (!ifcvf_mgmt_dev) {
-		IFCVF_ERR(pdev, "Failed to alloc memory for the vDPA management device\n");
-		return -ENOMEM;
-	}
-
-	dev_type = get_dev_type(pdev);
-	switch (dev_type) {
-	case VIRTIO_ID_NET:
-		ifcvf_mgmt_dev->mdev.id_table = id_table_net;
-		break;
-	case VIRTIO_ID_BLOCK:
-		ifcvf_mgmt_dev->mdev.id_table = id_table_blk;
-		break;
-	default:
-		IFCVF_ERR(pdev, "VIRTIO ID %u not supported\n", dev_type);
-		ret = -EOPNOTSUPP;
-		goto err;
-	}
-
-	ifcvf_mgmt_dev->mdev.ops = &ifcvf_vdpa_mgmt_dev_ops;
-	ifcvf_mgmt_dev->mdev.device = dev;
-	ifcvf_mgmt_dev->pdev = pdev;
+	int ret, i;
 
 	ret = pcim_enable_device(pdev);
 	if (ret) {
 		IFCVF_ERR(pdev, "Failed to enable device\n");
-		goto err;
+		return ret;
 	}
-
 	ret = pcim_iomap_regions(pdev, BIT(0) | BIT(2) | BIT(4),
 				 IFCVF_DRIVER_NAME);
 	if (ret) {
 		IFCVF_ERR(pdev, "Failed to request MMIO region\n");
-		goto err;
+		return ret;
 	}
 
 	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
 	if (ret) {
 		IFCVF_ERR(pdev, "No usable DMA configuration\n");
-		goto err;
+		return ret;
 	}
 
 	ret = devm_add_action_or_reset(dev, ifcvf_free_irq_vectors, pdev);
 	if (ret) {
 		IFCVF_ERR(pdev,
 			  "Failed for adding devres for freeing irq vectors\n");
-		goto err;
+		return ret;
 	}
 
 	pci_set_master(pdev);
 
+	adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
+				    dev, &ifc_vdpa_ops, 1, 1, NULL, false);
+	if (IS_ERR(adapter)) {
+		IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
+		return PTR_ERR(adapter);
+	}
+
+	vf = &adapter->vf;
+	vf->dev_type = get_dev_type(pdev);
+	vf->base = pcim_iomap_table(pdev);
+
+	adapter->pdev = pdev;
+	adapter->vdpa.dma_dev = &pdev->dev;
+
+	ret = ifcvf_init_hw(vf, pdev);
+	if (ret) {
+		IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
+		return ret;
+	}
+
+	for (i = 0; i < vf->nr_vring; i++)
+		vf->vring[i].irq = -EINVAL;
+
+	vf->hw_features = ifcvf_get_hw_features(vf);
+	vf->config_size = ifcvf_get_config_size(vf);
+
+	ifcvf_mgmt_dev = kzalloc(sizeof(struct ifcvf_vdpa_mgmt_dev), GFP_KERNEL);
+	if (!ifcvf_mgmt_dev) {
+		IFCVF_ERR(pdev, "Failed to alloc memory for the vDPA management device\n");
+		return -ENOMEM;
+	}
+
+	ifcvf_mgmt_dev->mdev.ops = &ifcvf_vdpa_mgmt_dev_ops;
+	ifcvf_mgmt_dev->mdev.device = dev;
+	ifcvf_mgmt_dev->adapter = adapter;
+
+	dev_type = get_dev_type(pdev);
+	switch (dev_type) {
+	case VIRTIO_ID_NET:
+		ifcvf_mgmt_dev->mdev.id_table = id_table_net;
+		break;
+	case VIRTIO_ID_BLOCK:
+		ifcvf_mgmt_dev->mdev.id_table = id_table_blk;
+		break;
+	default:
+		IFCVF_ERR(pdev, "VIRTIO ID %u not supported\n", dev_type);
+		ret = -EOPNOTSUPP;
+		goto err;
+	}
+
+	ifcvf_mgmt_dev->mdev.max_supported_vqs = vf->nr_vring;
+	ifcvf_mgmt_dev->mdev.supported_features = vf->hw_features;
+
+	adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev;
+
+
 	ret = vdpa_mgmtdev_register(&ifcvf_mgmt_dev->mdev);
 	if (ret) {
 		IFCVF_ERR(pdev,
Signature · 1 line
2.31.1
#3 lore raw

PATCH v4 3/6 vDPA: allow userspace to query features of a vDPA device

In reply to Zhu Lingshan

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.

---
 drivers/vdpa/vdpa.c       | 13 +++++++++----
 include/uapi/linux/vdpa.h |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c +9 -4
index ebf2f363fbe7..9b0e39b2f022 100644
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
 static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg)
 {
 	struct virtio_net_config config = {};
-	u64 features;
+	u64 features_device, features_driver;
 	u16 val_u16;
 
 	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
@@ -832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
 	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
 		return -EMSGSIZE;
 
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg, VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, features_device,
 			      VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver, &config);
 }
 
 static int
include/uapi/linux/vdpa.h +1 -0
index 25c55cab3d7c..39f1c3d7c112 100644
@@ -47,6 +47,7 @@ enum vdpa_attr {
 	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
 	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
 	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 
 	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */
 	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */
Signature · 1 line
2.31.1
#4 lore raw

RE: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 59 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.

---
 drivers/vdpa/vdpa.c       | 13 +++++++++----
 include/uapi/linux/vdpa.h |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg) {

drivers/vdpa/vdpa.c +1 -1
 	struct virtio_net_config config = {};
-	u64 features;
+	u64 features_device, features_driver;
 	u16 val_u16;
 
 	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@ -

832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms

drivers/vdpa/vdpa.c +0 -2
 	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
 		return -EMSGSIZE;
 
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,

drivers/vdpa/vdpa.c +3 -1
+features_device,
 			      VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
+&config);
 }
 
 static int
include/uapi/linux/vdpa.h index renamed from include/uapi/linux/vdpa.h +0 -0

25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h enum vdpa_attr { · line 51

Quoted 5 lines
include/uapi/linux/vdpa.h +1 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
 	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
 	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
 	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

MST,
I nack this patch.
As mentioned in the previous versions, also it is missing the example output in the commit log. Please include example output.

Quoted 4 lines
include/uapi/linux/vdpa.h +0 -1
 	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */
 	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */
--

2.31.1

#5 lore raw

Re: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 52 lines · Parav Pandit
Quoted 52 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.

---
  drivers/vdpa/vdpa.c       | 13 +++++++++----
  include/uapi/linux/vdpa.h |  1 +
  2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg) {
struct virtio_net_config config = {};

drivers/vdpa/vdpa.c +1 -1
-	u64 features;
+	u64 features_device, features_driver;
  	u16 val_u16;
 
  	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@ -

832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
return -EMSGSIZE;

drivers/vdpa/vdpa.c +0 -2
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,

drivers/vdpa/vdpa.c +3 -1
+features_device,
  			      VDPA_ATTR_PAD))
  		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
+&config);
  }
Quoted 14 lines

include/uapi/linux/vdpa.h enum vdpa_attr { · line 51

Quoted 11 lines

static int

include/uapi/linux/vdpa.h index renamed from include/uapi/linux/vdpa.h +0 -0

25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h +1 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
  	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
  	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
  	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

I believe we have already discussed this before in the V3 thread. I have told you that reusing this attr will lead to a new race condition.

Pleas refer to the previous thread, and you did not answer my questions in that thread.

Thanks,
Zhu Lingshan

Quoted 10 lines

MST,
I nack this patch.
As mentioned in the previous versions, also it is missing the example output in the commit log. Please include example output.

Quoted 4 lines
include/uapi/linux/vdpa.h +0 -1
  	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */
  	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */
--

2.31.1

#6 lore raw

RE: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 75 lines

From: Zhu, Lingshan <[email protected]>
Sent: Saturday, July 23, 2022 7:24 AM

Quoted 5 lines · Parav Pandit
Quoted 5 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query

features

Quoted 47 lines
Quoted 47 lines

of vDPA devices through this new attr.

---
  drivers/vdpa/vdpa.c       | 13 +++++++++----
  include/uapi/linux/vdpa.h |  1 +
  2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg) {
struct virtio_net_config config = {};

drivers/vdpa/vdpa.c +1 -1
-	u64 features;
+	u64 features_device, features_driver;
  	u16 val_u16;
 
  	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@ -

832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
return -EMSGSIZE;

drivers/vdpa/vdpa.c +0 -2
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,

drivers/vdpa/vdpa.c +3 -1
+features_device,
  			      VDPA_ATTR_PAD))
  		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
+&config);
  }
Quoted 15 lines

include/uapi/linux/vdpa.h enum vdpa_attr { · line 51

Quoted 12 lines

static int

include/uapi/linux/vdpa.h +0 -0

index
25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h +1 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
  	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
  	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
  	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

Quoted 3 lines

I believe we have already discussed this before in the V3 thread. I have told you that reusing this attr will lead to a new race condition.

Returning attribute cannot lead to any race condition.

Quoted 16 lines

Pleas refer to the previous thread, and you did not answer my questions in that thread.

Thanks,
Zhu Lingshan

Quoted 4 lines

MST,
I nack this patch.
As mentioned in the previous versions, also it is missing the example

output in the commit log.

Quoted 6 lines

Please include example output.

Quoted 4 lines
include/uapi/linux/vdpa.h +0 -1
  	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */
  	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */
--

2.31.1

#7 lore raw

Re: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 74 lines · Parav Pandit
Quoted 74 lines

From: Zhu, Lingshan <[email protected]>
Sent: Saturday, July 23, 2022 7:24 AM

Quoted 5 lines · Parav Pandit
Quoted 5 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query

features

Quoted 62 lines
Quoted 54 lines

of vDPA devices through this new attr.

---
   drivers/vdpa/vdpa.c       | 13 +++++++++----
   include/uapi/linux/vdpa.h |  1 +
   2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *msg)  {
   	struct virtio_net_config config = {};
drivers/vdpa/vdpa.c +1 -1
-	u64 features;
+	u64 features_device, features_driver;
   	u16 val_u16;
 
   	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@ -

832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
return -EMSGSIZE;

drivers/vdpa/vdpa.c +0 -2
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,

drivers/vdpa/vdpa.c +3 -1
+features_device,
   			      VDPA_ATTR_PAD))
   		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
+&config);
   }
 
   static int
include/uapi/linux/vdpa.h +0 -0

index
25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h enum vdpa_attr { · line 51

Quoted 5 lines
include/uapi/linux/vdpa.h +1 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
   	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
   	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
   	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

Quoted 4 lines
Quoted 3 lines

I believe we have already discussed this before in the V3 thread. I have told you that reusing this attr will lead to a new race condition.

Returning attribute cannot lead to any race condition.

Please refer to our discussion in the V3 series, I have explained
if re-use this attr, it will be a multiple consumers and multiple produces model, it is a typical racing condition.

Quoted 17 lines
Quoted 17 lines

Pleas refer to the previous thread, and you did not answer my questions in that thread.

Thanks,
Zhu Lingshan

Quoted 3 lines

MST,
I nack this patch.
As mentioned in the previous versions, also it is missing the example

output in the commit log.

Quoted 6 lines

Please include example output.

Quoted 4 lines
include/uapi/linux/vdpa.h +0 -1
   	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */
   	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */
--

2.31.1

#8 lore raw

RE: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 81 lines

From: Zhu, Lingshan <[email protected]>
Sent: Tuesday, July 26, 2022 7:03 AM

Quoted 11 lines · Parav Pandit
Quoted 11 lines

From: Zhu, Lingshan <[email protected]>
Sent: Saturday, July 23, 2022 7:24 AM

Quoted 5 lines · Parav Pandit
Quoted 5 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can

query

Quoted 64 lines
Quoted 64 lines

features

Quoted 63 lines
Quoted 55 lines

of vDPA devices through this new attr.

---
   drivers/vdpa/vdpa.c       | 13 +++++++++----
   include/uapi/linux/vdpa.h |  1 +
   2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *msg)  {
   	struct virtio_net_config config = {};
drivers/vdpa/vdpa.c +1 -2
-	u64 features;
+	u64 features_device, features_driver;
   	u16 val_u16;
 
   	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@
-

832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
return -EMSGSIZE;

drivers/vdpa/vdpa.c +0 -2
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,

drivers/vdpa/vdpa.c +3 -1
+features_device,
   			      VDPA_ATTR_PAD))
   		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
+&config);
   }
 
   static int
include/uapi/linux/vdpa.h +0 -0

index
25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h enum vdpa_attr { · line 51

Quoted 5 lines
include/uapi/linux/vdpa.h +1 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
   	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
   	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
   	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

I believe we have already discussed this before in the V3 thread. I have told you that reusing this attr will lead to a new race condition.

Returning attribute cannot lead to any race condition.

Please refer to our discussion in the V3 series, I have explained if re-use this attr, it will be a multiple consumers and multiple produces model, it is a typical racing condition.

I read the emails with subject = " Re: [PATCH V3 3/6] vDPA: allow userspace to query features of a vDPA device" I couldn’t find multiple consumers multiple producers working on same nla message.

#9 lore raw

Re: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 82 lines · Parav Pandit via Virtualization
Quoted 82 lines

From: Zhu, Lingshan <[email protected]>
Sent: Tuesday, July 26, 2022 7:03 AM

Quoted 10 lines · Parav Pandit
Quoted 10 lines

From: Zhu, Lingshan <[email protected]>
Sent: Saturday, July 23, 2022 7:24 AM

Quoted 5 lines · Parav Pandit
Quoted 5 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can

query

Quoted 67 lines
Quoted 67 lines

features

Quoted 48 lines
Quoted 48 lines

of vDPA devices through this new attr.

---
    drivers/vdpa/vdpa.c       | 13 +++++++++----
    include/uapi/linux/vdpa.h |  1 +
    2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *msg)  {
    	struct virtio_net_config config = {};
drivers/vdpa/vdpa.c +1 -2
-	u64 features;
+	u64 features_device, features_driver;
    	u16 val_u16;
 
    	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@
-

832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms

    	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
    		return -EMSGSIZE;
drivers/vdpa/vdpa.c +0 -2
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,

drivers/vdpa/vdpa.c +3 -1
+features_device,
    			      VDPA_ATTR_PAD))
    		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
+&config);
    }
Quoted 15 lines

include/uapi/linux/vdpa.h enum vdpa_attr { · line 51

Quoted 12 lines

static int

include/uapi/linux/vdpa.h +0 -0

index
25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h +1 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
    	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
    	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
    	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

I believe we have already discussed this before in the V3 thread. I have told you that reusing this attr will lead to a new race condition.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Returning attribute cannot lead to any race condition.

Please refer to our discussion in the V3 series, I have explained if re-use this attr, it will be a multiple consumers and multiple produces model, it is a typical racing condition.

I read the emails with subject = " Re: [PATCH V3 3/6] vDPA: allow userspace to query features of a vDPA device" I couldn’t find multiple consumers multiple producers working on same nla message.

what if two or more iproute2 instance or other userspace tools querying the features of the management device and the vDPA device simultaneously? In such a case, there are multiple consumers in the userspace, and the kernel functions(to fill management device features and vDPA device features) are the multiple producers. And there are no locks.

Quoted 4 lines

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

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

#10 lore raw

Re: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

In reply to Parav Pandit
Quoted 82 lines · Parav Pandit
Quoted 82 lines

From: Zhu, Lingshan <[email protected]>
Sent: Tuesday, July 26, 2022 7:03 AM

Quoted 10 lines · Parav Pandit
Quoted 10 lines

From: Zhu, Lingshan <[email protected]>
Sent: Saturday, July 23, 2022 7:24 AM

Quoted 5 lines · Parav Pandit
Quoted 5 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can

query

Quoted 67 lines
Quoted 67 lines

features

Quoted 48 lines
Quoted 48 lines

of vDPA devices through this new attr.

---
    drivers/vdpa/vdpa.c       | 13 +++++++++----
    include/uapi/linux/vdpa.h |  1 +
    2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *msg)  {
    	struct virtio_net_config config = {};
drivers/vdpa/vdpa.c +1 -2
-	u64 features;
+	u64 features_device, features_driver;
    	u16 val_u16;
 
    	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@
-

832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms

    	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
    		return -EMSGSIZE;
drivers/vdpa/vdpa.c +0 -2
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,

drivers/vdpa/vdpa.c +3 -1
+features_device,
    			      VDPA_ATTR_PAD))
    		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
+&config);
    }
Quoted 15 lines

include/uapi/linux/vdpa.h enum vdpa_attr { · line 51

Quoted 12 lines

static int

include/uapi/linux/vdpa.h +0 -0

index
25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h +1 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
    	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
    	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
    	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

I believe we have already discussed this before in the V3 thread. I have told you that reusing this attr will lead to a new race condition.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Returning attribute cannot lead to any race condition.

Please refer to our discussion in the V3 series, I have explained if re-use this attr, it will be a multiple consumers and multiple produces model, it is a typical racing condition.

I read the emails with subject = " Re: [PATCH V3 3/6] vDPA: allow userspace to query features of a vDPA device" I couldn’t find multiple consumers multiple producers working on same nla message.

If this attr is reused, then there can be multiple iproute2 instances or other applications querying feature bits of the management device and the vDPA device simultaneously, and both kernel side management feature bits filler function and vDPA device feature bits filler function can write the NLA message at the same time. That's the multiple consumers and producers, and no locks

#11 lore raw

RE: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 101 lines

From: Zhu, Lingshan <[email protected]>
Sent: Wednesday, July 27, 2022 2:02 AM

Quoted 24 lines · Parav Pandit
Quoted 24 lines

From: Zhu, Lingshan <[email protected]>
Sent: Tuesday, July 26, 2022 7:03 AM

Quoted 10 lines · Parav Pandit
Quoted 10 lines

From: Zhu, Lingshan <[email protected]>
Sent: Saturday, July 23, 2022 7:24 AM

Quoted 5 lines · Parav Pandit
Quoted 5 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can

query

Quoted 9 lines
Quoted 9 lines

features

Quoted 8 lines
Quoted 8 lines

of vDPA devices through this new attr.

---
    drivers/vdpa/vdpa.c       | 13 +++++++++----
    include/uapi/linux/vdpa.h |  1 +
    2 files changed, 10 insertions(+), 4 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/vdpa/vdpa.c static int

Quoted 5 lines
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

ebf2f363fbe7..9b0e39b2f022 100644

drivers/vdpa/vdpa.c +0 -0
@@ -815,7 +815,7 @@ static int

vdpa_dev_net_mq_config_fill(struct

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *msg)  {
    	struct virtio_net_config config = {};
drivers/vdpa/vdpa.c +1 -1
-	u64 features;
+	u64 features_device, features_driver;
    	u16 val_u16;
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
    	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));

@@
-
832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms

    	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU,

val_u16))

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
    		return -EMSGSIZE;
drivers/vdpa/vdpa.c +0 -2
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,

drivers/vdpa/vdpa.c +2 -0
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,

drivers/vdpa/vdpa.c +5 -0
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg,

VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,
+features_device,

    			      VDPA_ATTR_PAD))
    		return -EMSGSIZE;
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/vdpa/vdpa.c

Quoted 1 line
drivers/vdpa/vdpa.c +0 -1
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features,

&config);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/vdpa/vdpa.c

Quoted 1 line
drivers/vdpa/vdpa.c +1 -0
+	return vdpa_dev_net_mq_config_fill(vdev, msg,

features_driver,

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

include/uapi/linux/vdpa.h enum vdpa_attr { · line 48

Quoted 12 lines
+&config);
    }

    static int
(quoted diff) +0 -0

b/include/uapi/linux/vdpa.h index
25c55cab3d7c..39f1c3d7c112 100644

include/uapi/linux/vdpa.h +0 -0
@@ -47,6 +47,7 @@ enum vdpa_attr {
    	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
    	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/*

u32 */

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/uapi/linux/vdpa.h enum vdpa_attr { · line 50

Quoted 2 lines
include/uapi/linux/vdpa.h +1 -0
    	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/*

u64 */

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

I have answered in previous emails.
I disagree with the change.
Please reuse VDPA_ATTR_DEV_SUPPORTED_FEATURES.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

I believe we have already discussed this before in the V3 thread. I have told you that reusing this attr will lead to a new race condition.

Returning attribute cannot lead to any race condition.

Please refer to our discussion in the V3 series, I have explained if re-use this attr, it will be a multiple consumers and multiple produces model, it is a typical racing condition.

I read the emails with subject = " Re: [PATCH V3 3/6] vDPA: allow userspace

to query features of a vDPA device"

Quoted 1 line

I couldn’t find multiple consumers multiple producers working on same nla

Quoted 8 lines

message.
If this attr is reused, then there can be multiple iproute2 instances or other applications querying feature bits of the management device and the vDPA device simultaneously, and both kernel side management feature bits filler

function and vDPA device feature bits filler function can write the NLA message at the same time. That's the multiple consumers and producers, and no locks

No. Each filling up happens in each process context. There is no race here.

#12 lore raw

Re: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

In reply to Zhu Lingshan
Quoted 5 lines · Zhu Lingshan

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.

I think at least some discussion and documentation of this attribute versus VDPA_ATTR_DEV_SUPPORTED_FEATURES is called for.

Otherwise how do people know which one to use?

We can't send everyone to go read the lkml thread.

Quoted 53 lines
---
 drivers/vdpa/vdpa.c       | 13 +++++++++----
 include/uapi/linux/vdpa.h |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c +9 -4
index ebf2f363fbe7..9b0e39b2f022 100644
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
 static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg)
 {
 	struct virtio_net_config config = {};
-	u64 features;
+	u64 features_device, features_driver;
 	u16 val_u16;
 
 	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
@@ -832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
 	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
 		return -EMSGSIZE;
 
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg, VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, features_device,
 			      VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver, &config);
 }
 
 static int
include/uapi/linux/vdpa.h +1 -0
index 25c55cab3d7c..39f1c3d7c112 100644
@@ -47,6 +47,7 @@ enum vdpa_attr {
 	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
 	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
 	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 
 	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */
 	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */
Signature · 1 line
2.31.1
#13 lore raw

RE: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

Quoted 12 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, August 9, 2022 3:24 PM

Quoted 2 lines · Zhu Lingshan

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query

features of

Quoted 3 lines

vDPA devices through this new attr.

Quoted 6 lines

I think at least some discussion and documentation of this attribute versus VDPA_ATTR_DEV_SUPPORTED_FEATURES is called for.

Otherwise how do people know which one to use?

We can't send everyone to go read the lkml thread.

There is no race here. Commit log is missing example anyway.
I explained multiple times that this patch and/or its previous version cannot proceed in same state.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#14 lore raw

Re: [PATCH V4 3/6] vDPA: allow userspace to query features of a vDPA device

In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Zhu Lingshan

This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.

Quoted 7 lines

I think at least some discussion and documentation of this attribute versus VDPA_ATTR_DEV_SUPPORTED_FEATURES is called for.

Otherwise how do people know which one to use?

We can't send everyone to go read the lkml thread.

I will add comments in both this vdpa_dev_net_config_fill() and the header file.

Thanks,
Zhu Lingshan

Quoted 54 lines
Quoted 54 lines
---
  drivers/vdpa/vdpa.c       | 13 +++++++++----
  include/uapi/linux/vdpa.h |  1 +
  2 files changed, 10 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c +9 -4
index ebf2f363fbe7..9b0e39b2f022 100644
@@ -815,7 +815,7 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
  static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg)
  {
  	struct virtio_net_config config = {};
-	u64 features;
+	u64 features_device, features_driver;
  	u16 val_u16;
 
  	vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
@@ -832,12 +832,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
  	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
  		return -EMSGSIZE;
 
-	features = vdev->config->get_driver_features(vdev);
-	if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features,
+	features_driver = vdev->config->get_driver_features(vdev);
+	if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver,
+			      VDPA_ATTR_PAD))
+		return -EMSGSIZE;
+
+	features_device = vdev->config->get_device_features(vdev);
+	if (nla_put_u64_64bit(msg, VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, features_device,
  			      VDPA_ATTR_PAD))
  		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver, &config);
  }
 
  static int
include/uapi/linux/vdpa.h +1 -0
index 25c55cab3d7c..39f1c3d7c112 100644
@@ -47,6 +47,7 @@ enum vdpa_attr {
  	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
  	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */
  	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
+	VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES,	/* u64 */
 
  	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */
  	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */
Signature · 1 line
2.31.1
#15 lore raw

PATCH v4 4/6 vDPA: !FEATURES_OK should not block querying device config space

In reply to Zhu Lingshan

Users may want to query the config space of a vDPA device, to choose a appropriate one for a certain guest. This means the users need to read the config space before FEATURES_OK, and the existence of config space contents does not depend on FEATURES_OK.

The spec says:
The device MUST allow reading of any device-specific configuration field before FEATURES_OK is set by the driver. This includes fields which are conditional on feature bits, as long as those feature bits are offered by the device.

---
 drivers/vdpa/vdpa.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/vdpa/vdpa.c +0 -8
index 9b0e39b2f022..d76b22b2f7ae 100644
@@ -851,17 +851,9 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,
 {
 	u32 device_id;
 	void *hdr;
-	u8 status;
 	int err;
 
 	down_read(&vdev->cf_lock);
-	status = vdev->config->get_status(vdev);
-	if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) {
-		NL_SET_ERR_MSG_MOD(extack, "Features negotiation not completed");
-		err = -EAGAIN;
-		goto out;
-	}
-
 	hdr = genlmsg_put(msg, portid, seq, &vdpa_nl_family, flags,
 			  VDPA_CMD_DEV_CONFIG_GET);
 	if (!hdr) {
Signature · 1 line
2.31.1
#16 lore raw

PATCH v4 5/6 vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

In reply to Zhu Lingshan

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

---
 drivers/vdpa/vdpa.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c +4 -3
index d76b22b2f7ae..846dd37f3549 100644
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
 	u16 val_u16;
 
 	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-		return 0;
+		val_u16 = 1;
+	else
+		val_u16 = __virtio16_to_cpu(true, config->max_virtqueue_pairs);
 
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
 	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
 }
 
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
 			      VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver, &config);
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_device, &config);
 }
 
 static int
Signature · 1 line
2.31.1
#17 lore raw

RE: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

Quoted 19 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

No. We do not want to diverge returning values of config space for fields which are not present as discussed in previous versions. Please drop this patch.
Nack on this patch.

Quoted 38 lines
---
 drivers/vdpa/vdpa.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

d76b22b2f7ae..846dd37f3549 100644

drivers/vdpa/vdpa.c +3 -2
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct
 vdpa_device *vdev,
 	u16 val_u16;
 
 	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-		return 0;
+		val_u16 = 1;
+	else
+		val_u16 = __virtio16_to_cpu(true, config-
 >max_virtqueue_pairs);
 
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
 	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,

val_u16); }

drivers/vdpa/vdpa.c +0 -0
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *ms

drivers/vdpa/vdpa.c +0 -1
 			      VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,

&config);

drivers/vdpa/vdpa.c +2 -1
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_device,
+&config);
 }
 
 static int
--

2.31.1

#18 lore raw

Re: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

Quoted 18 lines · Parav Pandit
Quoted 18 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

Quoted 8 lines
Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

No. We do not want to diverge returning values of config space for fields which are not present as discussed in previous versions. Please drop this patch.
Nack on this patch.

I believe MST has replied to you in the V3 thread, did you miss that?

Quoted 38 lines
Quoted 38 lines
---
  drivers/vdpa/vdpa.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

d76b22b2f7ae..846dd37f3549 100644

drivers/vdpa/vdpa.c +3 -2
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct
 vdpa_device *vdev,
  	u16 val_u16;
 
  	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-		return 0;
+		val_u16 = 1;
+	else
+		val_u16 = __virtio16_to_cpu(true, config-
 > max_virtqueue_pairs);
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
  	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 val_u16);  }
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *ms
VDPA_ATTR_PAD))
return -EMSGSIZE;

drivers/vdpa/vdpa.c +0 -1
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,

&config);

drivers/vdpa/vdpa.c +2 -1
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_device,
+&config);
  }
 
  static int
--

2.31.1

#19 lore raw

Re: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

In reply to Parav Pandit
Quoted 19 lines · Parav Pandit
Quoted 19 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

Quoted 8 lines
Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

No. We do not want to diverge returning values of config space for fields which are not present as discussed in previous versions. Please drop this patch.
Nack on this patch.

Wrt this patch as far as I'm concerned you guys are bikeshedding.

Parav generally don't send nacks please they are not helpful.

Zhu Lingshan please always address comments in some way. E.g. refer to them in the commit log explaining the motivation and the alternatives. I know you don't agree with Parav but ghosting isn't nice.

I still feel what we should have done is
not return a value, as long as we do return it we might as well return something reasonable, not 0.

And I like it that this fixes sparse warning actually:
max_virtqueue_pairs it tagged as __virtio, not __le.

However, I am worried there is another bug here:
this is checking driver features. But really max vqs should not depend on that, it depends on device features, no?

Quoted 35 lines
Quoted 35 lines
---
 drivers/vdpa/vdpa.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

d76b22b2f7ae..846dd37f3549 100644

drivers/vdpa/vdpa.c +3 -2
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct
 vdpa_device *vdev,
 	u16 val_u16;
 
 	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-		return 0;
+		val_u16 = 1;
+	else
+		val_u16 = __virtio16_to_cpu(true, config-
 >max_virtqueue_pairs);
 
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
 	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,

val_u16); }

drivers/vdpa/vdpa.c +0 -0
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *ms

drivers/vdpa/vdpa.c +0 -1
 			      VDPA_ATTR_PAD))
 		return -EMSGSIZE;
 
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,

&config);

drivers/vdpa/vdpa.c +2 -0
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_device,
+&config);
 }
Quoted 3 lines
Quoted 3 lines

static int
--
2.31.1

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

#20 lore raw

RE: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

Quoted 8 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, August 9, 2022 3:36 PM

Quoted 5 lines
Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

Quoted 8 lines
Quoted 1 line

No. We do not want to diverge returning values of config space for fields

which are not present as discussed in previous versions.

Quoted 2 lines

Please drop this patch.
Nack on this patch.

Wrt this patch as far as I'm concerned you guys are bikeshedding.

Parav generally don't send nacks please they are not helpful.

Ok. I explained the technical reasoning that we don't diverge in fields. All are linked to the respective feature bits uniformly. This I explained repeatedly in almost v1 to v3.
And reporting 1 is mis-leading, because it says _MQ is not negotiated, how come this device tells its config space has max_qp = 1.

But if you want to proceed to diverge kernel on feature bits go ahead. It requires inspection feature but feature. I just don't see how this can be well maintained.

Commit log doesn't even describe the weird use case that says "as user space, I do not want to read device feature bits and just want to read config space to decide...". Odd..

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

#21 lore raw

Re: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

In reply to Michael S. Tsirkin
Quoted 31 lines · Michael S. Tsirkin
Quoted 18 lines · Parav Pandit
Quoted 18 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

Quoted 8 lines
Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

No. We do not want to diverge returning values of config space for fields which are not present as discussed in previous versions. Please drop this patch.
Nack on this patch.

Wrt this patch as far as I'm concerned you guys are bikeshedding.

Parav generally don't send nacks please they are not helpful.

Quoted 7 lines

Zhu Lingshan please always address comments in some way. E.g. refer to them in the commit log explaining the motivation and the alternatives. I know you don't agree with Parav but ghosting isn't nice.

I still feel what we should have done is
not return a value, as long as we do return it we might as well return something reasonable, not 0.

Maybe I missed something but I don't get this, when VIRTIO_NET_F_MQ is not negotiated, the VDPA_ATTR_DEV_NET_CFG_MAX_VQP attribute is simply not there, but userspace (iproute) mistakenly puts a zero value there. This is a pattern every tool in iproute follows consistently by large. I don't get why kernel has to return something without seeing a very convincing use case?

Not to mention spec doesn't give us explicit definition for when the field in config space becomes valid and/or the default value at first sights as part of feature negotiation. If we want to stick to the model Lingshan proposed, maybe fix the spec first then get back on the details?

-Siwei

Quoted 45 lines

And I like it that this fixes sparse warning actually:
max_virtqueue_pairs it tagged as __virtio, not __le.

However, I am worried there is another bug here:
this is checking driver features. But really max vqs should not depend on that, it depends on device features, no?

Quoted 34 lines
Quoted 34 lines
---
  drivers/vdpa/vdpa.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

d76b22b2f7ae..846dd37f3549 100644

drivers/vdpa/vdpa.c +3 -2
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct
 vdpa_device *vdev,
  	u16 val_u16;
 
  	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-		return 0;
+		val_u16 = 1;
+	else
+		val_u16 = __virtio16_to_cpu(true, config-
 > max_virtqueue_pairs);
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
  	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 val_u16);  }
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *ms
VDPA_ATTR_PAD))
return -EMSGSIZE;

drivers/vdpa/vdpa.c +0 -1
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,

&config);

drivers/vdpa/vdpa.c +2 -0
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_device,
+&config);
  }
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

static int
--
2.31.1

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

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

#22 lore raw

Re: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

Quoted 49 lines · Si-Wei Liu
Quoted 31 lines · Michael S. Tsirkin
Quoted 18 lines · Parav Pandit
Quoted 18 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

Quoted 8 lines
Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

No. We do not want to diverge returning values of config space for fields which are not present as discussed in previous versions. Please drop this patch.
Nack on this patch.

Wrt this patch as far as I'm concerned you guys are bikeshedding.

Parav generally don't send nacks please they are not helpful.

Quoted 7 lines

Zhu Lingshan please always address comments in some way. E.g. refer to them in the commit log explaining the motivation and the alternatives. I know you don't agree with Parav but ghosting isn't nice.

I still feel what we should have done is
not return a value, as long as we do return it we might as well return something reasonable, not 0.

Maybe I missed something but I don't get this, when VIRTIO_NET_F_MQ is not negotiated, the VDPA_ATTR_DEV_NET_CFG_MAX_VQP attribute is simply not there, but userspace (iproute) mistakenly puts a zero value there. This is a pattern every tool in iproute follows consistently by large. I don't get why kernel has to return something without seeing a very convincing use case?

Quoted 4 lines

Not to mention spec doesn't give us explicit definition for when the field in config space becomes valid and/or the default value at first sights as part of feature negotiation. If we want to stick to the model Lingshan proposed, maybe fix the spec first then get back on the details?

So spec said

"
The following driver-read-only field, max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is set.
"

My understanding is that the field is always valid if the device offers the feature.

Btw, even if the spec is unclear, it would be very hard to "fix" it without introducing a new feature bit, it means we still need to deal with device without the new feature.

Thanks

Quoted 56 lines

-Siwei

Quoted 45 lines

And I like it that this fixes sparse warning actually:
max_virtqueue_pairs it tagged as __virtio, not __le.

However, I am worried there is another bug here:
this is checking driver features. But really max vqs should not depend on that, it depends on device features, no?

Quoted 34 lines
Quoted 34 lines
---
  drivers/vdpa/vdpa.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

d76b22b2f7ae..846dd37f3549 100644

drivers/vdpa/vdpa.c +3 -2
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct
 vdpa_device *vdev,
    u16 val_u16;
 
    if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-           return 0;
+           val_u16 = 1;
+   else
+           val_u16 = __virtio16_to_cpu(true, config-
 > max_virtqueue_pairs);
-   val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
    return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 val_u16);  }
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *ms

                          VDPA_ATTR_PAD))
            return -EMSGSIZE;

- return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
&config);
+ return vdpa_dev_net_mq_config_fill(vdev, msg, features_device,
+&config);
}

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

static int
--
2.31.1

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

Quoted 5 lines

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

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

#23 lore raw

Re: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

Quoted 54 lines · Jason Wang
Quoted 47 lines · Si-Wei Liu
Quoted 30 lines · Michael S. Tsirkin
Quoted 17 lines · Parav Pandit
Quoted 17 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

Quoted 8 lines
Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

No. We do not want to diverge returning values of config space for fields which are not present as discussed in previous versions. Please drop this patch.
Nack on this patch.

Wrt this patch as far as I'm concerned you guys are bikeshedding.

Parav generally don't send nacks please they are not helpful.

Quoted 7 lines

Zhu Lingshan please always address comments in some way. E.g. refer to them in the commit log explaining the motivation and the alternatives. I know you don't agree with Parav but ghosting isn't nice.

I still feel what we should have done is
not return a value, as long as we do return it we might as well return something reasonable, not 0.

Maybe I missed something but I don't get this, when VIRTIO_NET_F_MQ is not negotiated, the VDPA_ATTR_DEV_NET_CFG_MAX_VQP attribute is simply not there, but userspace (iproute) mistakenly puts a zero value there. This is a pattern every tool in iproute follows consistently by large. I don't get why kernel has to return something without seeing a very convincing use case?

Quoted 4 lines

Not to mention spec doesn't give us explicit definition for when the field in config space becomes valid and/or the default value at first sights as part of feature negotiation. If we want to stick to the model Lingshan proposed, maybe fix the spec first then get back on the details?

So spec said

Quoted 7 lines

"
The following driver-read-only field, max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is set.
"

My understanding is that the field is always valid if the device offers the feature.

The tricky part is to deal with VERSION_1 on transitional device that determines the endianness of field. I know we don't support !VERSION_1 vdpa provider for now, but the tool should be made independent of this assumption.

For the most of config fields there's no actual valid "default" value during feature negotiation until it can be determined after negotiation is done. I wonder what is the administrative value if presenting those random value to the end user? And there's even special feature like VIRTIO_BLK_F_CONFIG_WCE that only present valid feature value after negotiation. I'm afraid it may further confuse end user, or it would require them to read and understand all of details in spec, which apparently contradict to the goal of showing meaningful queue-pair value without requiring user to read the spec details.

-Siwei

Quoted 65 lines

Btw, even if the spec is unclear, it would be very hard to "fix" it without introducing a new feature bit, it means we still need to deal with device without the new feature.

Thanks

Quoted 58 lines

-Siwei

Quoted 44 lines

And I like it that this fixes sparse warning actually:
max_virtqueue_pairs it tagged as __virtio, not __le.

However, I am worried there is another bug here:
this is checking driver features. But really max vqs should not depend on that, it depends on device features, no?

Quoted 34 lines
Quoted 34 lines
---
   drivers/vdpa/vdpa.c | 7 ++++---
   1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

d76b22b2f7ae..846dd37f3549 100644

drivers/vdpa/vdpa.c +3 -2
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct
 vdpa_device *vdev,
     u16 val_u16;
 
     if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-           return 0;
+           val_u16 = 1;
+   else
+           val_u16 = __virtio16_to_cpu(true, config-
 > max_virtqueue_pairs);
-   val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
     return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 val_u16);  }
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *ms

                           VDPA_ATTR_PAD))
             return -EMSGSIZE;

- return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,
&config);
+ return vdpa_dev_net_mq_config_fill(vdev, msg, features_device,

+&config);
   }
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

static int
--
2.31.1

_______________________________________________
Virtualization mailing list
[email protected]
https://urldefense.com/v3/__https://lists.linuxfoundation.org/mailman/listinfo/virtualization__;!!ACWV5N9M2RV99hQ!NE42b1rl66ElGUzHr3b9xXGYCs2Vpb5dkhF0fPXnAyyFYzZZyzsY9NV_Qbf2AZCI3XxC13_nlWfSVN52yIM$

_______________________________________________
Virtualization mailing list
[email protected]
https://urldefense.com/v3/__https://lists.linuxfoundation.org/mailman/listinfo/virtualization__;!!ACWV5N9M2RV99hQ!NE42b1rl66ElGUzHr3b9xXGYCs2Vpb5dkhF0fPXnAyyFYzZZyzsY9NV_Qbf2AZCI3XxC13_nlWfSVN52yIM$

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

#24 lore raw

Re: [PATCH V4 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0

In reply to Michael S. Tsirkin
Quoted 27 lines · Michael S. Tsirkin
Quoted 18 lines · Parav Pandit
Quoted 18 lines

From: Zhu Lingshan <[email protected]>
Sent: Friday, July 22, 2022 7:53 AM

If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero.

Function vdpa_dev_net_config_fill() fills the attributions of the vDPA devices, so that it should call vdpa_dev_net_mq_config_fill() so the parameter in vdpa_dev_net_mq_config_fill() should be feature_device than feature_driver for the vDPA devices themselves

Before this change, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 0 mtu 1500

Quoted 8 lines
Quoted 5 lines

After applying this commit, when MQ = 0, iproute2 output:
$vdpa dev config show vdpa0
vdpa0: mac 00:e8:ca:11:be:05 link up link_announce false max_vq_pairs 1 mtu 1500

No. We do not want to diverge returning values of config space for fields which are not present as discussed in previous versions. Please drop this patch.
Nack on this patch.

Quoted 7 lines

Wrt this patch as far as I'm concerned you guys are bikeshedding.

Parav generally don't send nacks please they are not helpful.

Zhu Lingshan please always address comments in some way. E.g. refer to them in the commit log explaining the motivation and the alternatives. I know you don't agree with Parav but ghosting isn't nice.

I can work out a better commit message, currently I have an example on how to process MQ = 0. I will handle all conditional fields(MTC, MAC...) here. So I will explain them both in general and details for every field.

Thanks,
Zhu Lingshan

Quoted 5 lines

I still feel what we should have done is
not return a value, as long as we do return it we might as well return something reasonable, not 0.

Quoted 7 lines

And I like it that this fixes sparse warning actually:
max_virtqueue_pairs it tagged as __virtio, not __le.

However, I am worried there is another bug here:
this is checking driver features. But really max vqs should not depend on that, it depends on device features, no?

We have this fix in this patch below:

return vdpa_dev_net_mq_config_fill(vdev, msg, features_device, &config);

this checks device features.

Thanks,
Zhu Lingshan

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
---
  drivers/vdpa/vdpa.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c index renamed from drivers/vdpa/vdpa.c +0 -0

d76b22b2f7ae..846dd37f3549 100644

drivers/vdpa/vdpa.c +3 -2
@@ -806,9 +806,10 @@ static int vdpa_dev_net_mq_config_fill(struct
 vdpa_device *vdev,
  	u16 val_u16;
 
  	if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0)
-		return 0;
+		val_u16 = 1;
+	else
+		val_u16 = __virtio16_to_cpu(true, config-
 > max_virtqueue_pairs);
-	val_u16 = le16_to_cpu(config->max_virtqueue_pairs);
  	return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
 val_u16);  }
@@ -842,7 +843,7 @@ static int vdpa_dev_net_config_fill(struct

vdpa_device *vdev, struct sk_buff *ms
VDPA_ATTR_PAD))
return -EMSGSIZE;

drivers/vdpa/vdpa.c +0 -1
-	return vdpa_dev_net_mq_config_fill(vdev, msg, features_driver,

&config);

drivers/vdpa/vdpa.c +2 -1
+	return vdpa_dev_net_mq_config_fill(vdev, msg, features_device,
+&config);
  }
 
  static int
--

2.31.1

#25 lore raw

PATCH v4 6/6 vDPA: fix 'cast to restricted le16' warnings in vdpa.c

In reply to Zhu Lingshan

This commit fixes spars warnings: cast to restricted __le16 in function vdpa_dev_net_config_fill() and vdpa_fill_stats_rec()

---
 drivers/vdpa/vdpa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vdpa/vdpa.c +3 -3
index 846dd37f3549..ed49fe46a79e 100644
@@ -825,11 +825,11 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
 		    config.mac))
 		return -EMSGSIZE;
 
-	val_u16 = le16_to_cpu(config.status);
+	val_u16 = __virtio16_to_cpu(true, config.status);
 	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_STATUS, val_u16))
 		return -EMSGSIZE;
 
-	val_u16 = le16_to_cpu(config.mtu);
+	val_u16 = __virtio16_to_cpu(true, config.mtu);
 	if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
 		return -EMSGSIZE;
 
@@ -911,7 +911,7 @@ 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 = le16_to_cpu(config.max_virtqueue_pairs);
+	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;
 
Signature · 1 line
2.31.1