Skip to contentSkip to conversation

vdpa: Add support for returning device configuration information

PATCH Si-Wei Liu 4 participants 19 messages Dec 13, 2021 – Dec 21, 2021 13 messages not in the archive virtio core

lore
Share & tools
lore

Si-Wei Liu

author
#2 lore raw
In reply to a message not in the archive
Quoted 85 lines · Eli Cohen

Add netlink attribute to store flags indicating current state of the device.
In addition, introduce a flag to indicate whether control virtqueue is used.

This indication can be retrieved by:

vdpa dev config show vdpa-a
vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 1
mtu 1500 ctrl_vq yes

----
V1 -> V2
Patch was changed to return only an indication of ctrl VQ

---
  drivers/vdpa/vdpa.c       | 17 +++++++++++++++++
  include/uapi/linux/vdpa.h |  8 ++++++++
  2 files changed, 25 insertions(+)
drivers/vdpa/vdpa.c +17 -0
index 7b7bef7673b4..130a8d4aeaed 100644
@@ -787,6 +787,19 @@ static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callba
  	return msg->len;
  }
 
+static int vdpa_dev_net_ctrl_vq_fill(struct vdpa_device *vdev,
+				     struct sk_buff *msg,
+				     struct virtio_net_config *config,
+				     u64 features)
+{
+	if (!(features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
+		return 0;
+
+	/* currently the only flag can be returned */
+	return nla_put_u64_64bit(msg, VDPA_ATTR_DEV_FLAGS,
+				 BIT_ULL(VDPA_DEV_ATTR_CVQ), VDPA_ATTR_PAD);
+}
+
  static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
  				       struct sk_buff *msg, u64 features,
  				       const struct virtio_net_config *config)
@@ -805,6 +818,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
  	struct virtio_net_config config = {};
  	u64 features;
  	u16 val_u16;
+	int err;
 
  	vdpa_get_config(vdev, 0, &config, sizeof(config));
 
@@ -821,6 +835,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
  		return -EMSGSIZE;
 
  	features = vdev->config->get_driver_features(vdev);
+	err = vdpa_dev_net_ctrl_vq_fill(vdev, msg, &config, features);
+	if (err)
+		return err;
 
  	return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
  }
include/uapi/linux/vdpa.h +7 -0
index a252f06f9dfd..23b854e3e5e2 100644
@@ -20,9 +20,16 @@ enum vdpa_command {
  	VDPA_CMD_DEV_CONFIG_GET,	/* can dump */
  };
 
+enum {
+	VDPA_DEV_ATTR_CVQ,
+};
+
  enum vdpa_attr {
  	VDPA_ATTR_UNSPEC,
 
+	/* Pad attribute for 64b alignment */
+	VDPA_ATTR_PAD = VDPA_ATTR_UNSPEC,
+
  	/* bus name (optional) + dev name together make the parent device handle */
  	VDPA_ATTR_MGMTDEV_BUS_NAME,		/* string */
  	VDPA_ATTR_MGMTDEV_DEV_NAME,		/* string */

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

Quoted 4 lines
include/uapi/linux/vdpa.h +1 -0
@@ -34,6 +41,7 @@ enum vdpa_attr {
  	VDPA_ATTR_DEV_MAX_VQS,			/* u32 */
  	VDPA_ATTR_DEV_MAX_VQ_SIZE,		/* u16 */
  	VDPA_ATTR_DEV_MIN_VQ_SIZE,		/* u16 */
+	VDPA_ATTR_DEV_FLAGS,			/* u64 */

Adding new attr here would break existing userspace that is compiled with the older value. Need to append to the end.

-Siwei

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

Quoted 3 lines
include/uapi/linux/vdpa.h +0 -0
  	VDPA_ATTR_DEV_NET_CFG_MACADDR,		/* binary */
  	VDPA_ATTR_DEV_NET_STATUS,		/* u8 */

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

author
#7 lore raw

Re: [PATCH v2 09/10] vdpa: Support reporting max device virtqueues

In reply to a message not in the archive
Quoted 48 lines · Eli Cohen

Add max_supported_vqs field to struct vdpa_mgmt_dev. Upstream drivers need to feel this value according to the device capabilities.

This value is reported back in a netlink message when showing a device.

Example:

$ vdpa dev show
vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \
	max_vqp 3 max_vq_size 256 max_supported_vqs 256
---
  drivers/vdpa/vdpa.c       | 2 ++
  include/linux/vdpa.h      | 1 +
  include/uapi/linux/vdpa.h | 1 +
  3 files changed, 4 insertions(+)
drivers/vdpa/vdpa.c +2 -0
index 130a8d4aeaed..b9dd693146be 100644
@@ -695,6 +695,8 @@ vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq
  		goto msg_err;
  	if (nla_put_u16(msg, VDPA_ATTR_DEV_MIN_VQ_SIZE, min_vq_size))
  		goto msg_err;
+	if (nla_put_u16(msg, VDPA_ATTR_DEV_MAX_DEV_VQS, vdev->mdev->max_supported_vqs))
+		goto msg_err;
 
  	genlmsg_end(msg, hdr);
  	return 0;
include/linux/vdpa.h +1 -0
index 9245dfbf1b08..72ea8ad7ba21 100644
@@ -444,6 +444,7 @@ struct vdpa_mgmt_dev {
  	const struct vdpa_mgmtdev_ops *ops;
  	const struct virtio_device_id *id_table;
  	u64 config_attr_mask;
+	u16 max_supported_vqs;
  	struct list_head list;
  };
 
include/uapi/linux/vdpa.h +0 -0
index 23b854e3e5e2..1b758d77e228 100644

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

Quoted 4 lines
include/uapi/linux/vdpa.h +1 -0
@@ -42,6 +42,7 @@ enum vdpa_attr {
  	VDPA_ATTR_DEV_MAX_VQ_SIZE,		/* u16 */
  	VDPA_ATTR_DEV_MIN_VQ_SIZE,		/* u16 */
  	VDPA_ATTR_DEV_FLAGS,			/* u64 */
+	VDPA_ATTR_DEV_MAX_DEV_VQS,		/* u16 */

Adding new attr here would break existing userspace that is compiled with the older value. Need to append to the end.

-Siwei

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

Quoted 3 lines
include/uapi/linux/vdpa.h +0 -0
  	VDPA_ATTR_DEV_NET_CFG_MACADDR,		/* binary */
  	VDPA_ATTR_DEV_NET_STATUS,		/* u8 */

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

author Reviewed-by
#14 lore raw

Re: [PATCH v2 05/10] vdpa/mlx5: Fix config_attr_mask assignment

In reply to a message not in the archive
Quoted 8 lines · Eli Cohen

Fix VDPA_ATTR_DEV_NET_CFG_MACADDR assignment to be explicit 64 bit assignment.

No issue was seen since the value is well below 64 bit max value. Nevertheless it needs to be fixed.

Fixes a007d940040c ("vdpa/mlx5: Support configuration of MAC")
Quoted 10 lines
---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -0
index 98aed4b36c3f..4a2149f70f1e 100644

drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5v_probe(struct auxiliary_device *adev, · line 2675

Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
@@ -2669,7 +2669,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
  	mgtdev->mgtdev.ops = &mdev_ops;
  	mgtdev->mgtdev.device = mdev->device;
  	mgtdev->mgtdev.id_table = id_table;
-	mgtdev->mgtdev.config_attr_mask = (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR);
+	mgtdev->mgtdev.config_attr_mask = BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR);
  	mgtdev->madev = madev;
 
  	err = vdpa_mgmtdev_register(&mgtdev->mgtdev);

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

author
#16 lore raw

Re: [PATCH v2 04/10] vdpa: Allow to configure max data virtqueues

In reply to a message not in the archive
Quoted 25 lines · Eli Cohen

Add netlink support to configure the max virtqueue pairs for a device. At least one pair is required. The maximum is dictated by the device.

---
  drivers/vdpa/vdpa.c  | 14 +++++++++++++-
  include/linux/vdpa.h |  1 +
  2 files changed, 14 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa.c +2 -1
index 5749cf0a1500..7b7bef7673b4 100644
@@ -555,7 +555,8 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
  }
 
  #define VDPA_DEV_NET_ATTRS_MASK ((1 << VDPA_ATTR_DEV_NET_CFG_MACADDR) | \
-				 (1 << VDPA_ATTR_DEV_NET_CFG_MTU))
+				 (1 << VDPA_ATTR_DEV_NET_CFG_MTU) | \
+				 (1 << VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
 
  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
  {
@@ -581,6 +582,17 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
  			nla_get_u16(nl_attrs[VDPA_ATTR_DEV_NET_CFG_MTU]);

drivers/vdpa/vdpa.c static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i · line 592

Quoted 10 lines
drivers/vdpa/vdpa.c +8 -0
  		config.mask |= (1 << VDPA_ATTR_DEV_NET_CFG_MTU);
  	}
+	if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MAX_VQP]) {
+		config.net.max_vq_pairs =
+			nla_get_u16(nl_attrs[VDPA_ATTR_DEV_NET_CFG_MAX_VQP]);
+		if (!config.net.max_vq_pairs) {
+			NL_SET_ERR_MSG_MOD(info->extack,
+					   "At least one pair of VQs is required");
+			err = -EINVAL;
+			goto err;

Should directly return -EINVAL, vdpa_dev_mutex is not taken.

Quoted 11 lines
drivers/vdpa/vdpa.c +3 -0
+		}
+		config.mask |= BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP);
+	}
 
  	/* Skip checking capability if user didn't prefer to configure any
  	 * device networking attributes. It is likely that user might have used
include/linux/vdpa.h +0 -0
index 9cc4291a79b3..9245dfbf1b08 100644

include/linux/vdpa.h struct vdpa_dev_set_config { · line 107

Quoted 7 lines
include/linux/vdpa.h +1 -0
@@ -101,6 +101,7 @@ struct vdpa_dev_set_config {
  	struct {
  		u8 mac[ETH_ALEN];
  		u16 mtu;
+		u16 max_vq_pairs;
  	} net;
  	u64 mask;
  };

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

author
#8 lore raw

Re: [PATCH v2 09/10] vdpa: Support reporting max device virtqueues

In reply to a message not in the archive
Quoted 23 lines · Eli Cohen

Add max_supported_vqs field to struct vdpa_mgmt_dev. Upstream drivers need to feel this value according to the device capabilities.

This value is reported back in a netlink message when showing a device.

Example:

$ vdpa dev show
vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \
	max_vqp 3 max_vq_size 256 max_supported_vqs 256
---
  drivers/vdpa/vdpa.c       | 2 ++
  include/linux/vdpa.h      | 1 +
  include/uapi/linux/vdpa.h | 1 +
  3 files changed, 4 insertions(+)
drivers/vdpa/vdpa.c +0 -0
index 130a8d4aeaed..b9dd693146be 100644

drivers/vdpa/vdpa.c vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq · line 699

Quoted 5 lines
drivers/vdpa/vdpa.c +2 -0
@@ -695,6 +695,8 @@ vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq
  		goto msg_err;
  	if (nla_put_u16(msg, VDPA_ATTR_DEV_MIN_VQ_SIZE, min_vq_size))
  		goto msg_err;
+	if (nla_put_u16(msg, VDPA_ATTR_DEV_MAX_DEV_VQS, vdev->mdev->max_supported_vqs))
+		goto msg_err;

What is the default value if vendor driver doesn't expose this value? And it doesn't seem this is something to stash on struct vdpa_mgmt_dev, only some vdpa vendor for network drive may need to expose it; if otherwise not exposed we can assume it's 32767 by the spec. A generic vdpa op (get_device_capability?) to query device capability might be better I guess (define a VDPA_CAPAB_NET_MAX_VQS subtype to get it).

-Siwei

Quoted 20 lines
drivers/vdpa/vdpa.c +0 -0
  	genlmsg_end(msg, hdr);
  	return 0;
include/linux/vdpa.h +1 -0
index 9245dfbf1b08..72ea8ad7ba21 100644
@@ -444,6 +444,7 @@ struct vdpa_mgmt_dev {
  	const struct vdpa_mgmtdev_ops *ops;
  	const struct virtio_device_id *id_table;
  	u64 config_attr_mask;
+	u16 max_supported_vqs;
  	struct list_head list;
  };
 
include/uapi/linux/vdpa.h +0 -0
index 23b854e3e5e2..1b758d77e228 100644

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

Quoted 7 lines
include/uapi/linux/vdpa.h +1 -0
@@ -42,6 +42,7 @@ enum vdpa_attr {
  	VDPA_ATTR_DEV_MAX_VQ_SIZE,		/* u16 */
  	VDPA_ATTR_DEV_MIN_VQ_SIZE,		/* u16 */
  	VDPA_ATTR_DEV_FLAGS,			/* u64 */
+	VDPA_ATTR_DEV_MAX_DEV_VQS,		/* u16 */
 
  	VDPA_ATTR_DEV_NET_CFG_MACADDR,		/* binary */
  	VDPA_ATTR_DEV_NET_STATUS,		/* u8 */

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

#17 lore raw

Re: [PATCH v2 00/10] Allow for configuring max number of virtqueue pairs

In reply to a message not in the archive
Quoted 6 lines · Eli Cohen

Allow the user to configure the max number of virtqueue pairs for a vdpa instance. The user can then control the actual number of virtqueue pairs using ethtool.

Example, set number of VQPs to 2:

Quoted 8 lines
$ ethtool -L ens1 combined 2

A user can check the max supported virtqueues for a management device by runnig:

vdpa dev show

    vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \
            max_vqp 3 max_vq_size 256 max_supported_vqs 256

I think the maxsupported_vqs should be an odd number since it should contain control vq.

Quoted 5 lines

and refer to this value when adding a device.

To create a device with a max of 5 VQPs:
vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1 max_vqp 5

A question, consider the parent support both net and block, if user use

vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1

How do we know it's a net or block device? Or do you expect some block specific attributes to be added?

Thanks

Quoted 35 lines

V1 -> V2:
1. Do not return the index of the control VQ. Instead return an indication if Ctrl VQ was negotiated.
2. Do not returen conig information if FEATURES_OK is not set to avoid reporting out of sync information.
3. Minor fixes as described by the individual patches
4. Add patches to return the max virtqueues a device is capable of supporting.

Eli Cohen (10):
vdpa: Provide interface to read driver features
vdpa/mlx5: Distribute RX virtqueues in RQT object
vdpa: Read device configuration only if FEATURES_OK
vdpa: Allow to configure max data virtqueues
vdpa/mlx5: Fix config_attr_mask assignment
vdpa/mlx5: Support configuring max data virtqueue pairs
vdpa: Add support for returning device configuration information vdpa/mlx5: Restore cur_num_vqs in case of failure in change_num_qps()
vdpa: Support reporting max device virtqueues
vdpa/mlx5: Configure max supported virtqueues

 drivers/vdpa/alibaba/eni_vdpa.c    | 16 +++--
 drivers/vdpa/ifcvf/ifcvf_main.c    | 16 +++--
 drivers/vdpa/mlx5/net/mlx5_vnet.c  | 94 +++++++++++++++++-------------
 drivers/vdpa/vdpa.c                | 42 ++++++++++++-
 drivers/vdpa/vdpa_sim/vdpa_sim.c   | 21 +++++--
 drivers/vdpa/vdpa_user/vduse_dev.c | 16 +++--
 drivers/vdpa/virtio_pci/vp_vdpa.c  | 16 +++--
 drivers/vhost/vdpa.c               |  2 +-
 drivers/virtio/virtio_vdpa.c       |  2 +-
 include/linux/vdpa.h               | 16 +++--
 include/uapi/linux/vdpa.h          |  9 +++
 11 files changed, 178 insertions(+), 72 deletions(-)
Quoted 3 lines

--
2.33.1

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

Acked-by
#27 lore raw

Re: [PATCH v2 01/10] vdpa: Provide interface to read driver features

In reply to a message not in the archive
Quoted 16 lines · Eli Cohen

Provide an interface to read the negotiated features. This is needed when building the netlink message in vdpa_dev_net_config_fill().

Also fix the implementation of vdpa_dev_net_config_fill() to use the negotiated features instead of the device features.

To make APIs clearer, make the following name changes to struct vdpa_config_ops so they better describe their operations:

get_features -> get_device_features
set_features -> set_driver_features

Finally, add get_driver_features to return the negotiated features and add implementation to all the upstream drivers.

Quoted 7 lines

-----
v1 -> v2:
1. Fix to call vp_modern_get_driver_features() in
vp_vdpa_get_driver_features()
2. Improve calback function description
---

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

#29 lore raw

Re: [PATCH v2 03/10] vdpa: Read device configuration only if FEATURES_OK

In reply to a message not in the archive
Quoted 23 lines · Eli Cohen

Avoid reading device configuration during feature negotiation. Read device status and verify that VIRTIO_CONFIG_S_FEATURES_OK is set. Otherwise, return -EAGAIN.

---
 drivers/vdpa/vdpa.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/vdpa/vdpa.c +1 -0
index 42d71d60d5dc..5749cf0a1500 100644
@@ -819,8 +819,15 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,
 {
        u32 device_id;
        void *hdr;
+       u8 status;
        int err;

drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 833

Quoted 10 lines
drivers/vdpa/vdpa.c +6 -0
 
+       status = vdev->config->get_status(vdev);
+       if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) {
+               NL_SET_ERR_MSG_MOD(extack, "Features negotiation not completed");
+               return -EAGAIN;
+       }
+
        hdr = genlmsg_put(msg, portid, seq, &vdpa_nl_family, flags,
                          VDPA_CMD_DEV_CONFIG_GET);
        if (!hdr)

It looks to me we need to synchronize this with set_status() and cf_mutex (set_config).

Or simply return all the config space (the maximum set of features)

Thanks

Quoted 3 lines

--
2.33.1

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

#3 lore raw
In reply to a message not in the archive
Quoted 11 lines · Eli Cohen

Add netlink attribute to store flags indicating current state of the device.
In addition, introduce a flag to indicate whether control virtqueue is used.

This indication can be retrieved by:

vdpa dev config show vdpa-a
vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 1
mtu 1500 ctrl_vq yes

I think the cvq is kind of duplicated with the driver features?

Thanks

Quoted 83 lines

----
V1 -> V2
Patch was changed to return only an indication of ctrl VQ

---
 drivers/vdpa/vdpa.c       | 17 +++++++++++++++++
 include/uapi/linux/vdpa.h |  8 ++++++++
 2 files changed, 25 insertions(+)
drivers/vdpa/vdpa.c +17 -0
index 7b7bef7673b4..130a8d4aeaed 100644
@@ -787,6 +787,19 @@ static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callba
        return msg->len;
 }
 
+static int vdpa_dev_net_ctrl_vq_fill(struct vdpa_device *vdev,
+                                    struct sk_buff *msg,
+                                    struct virtio_net_config *config,
+                                    u64 features)
+{
+       if (!(features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
+               return 0;
+
+       /* currently the only flag can be returned */
+       return nla_put_u64_64bit(msg, VDPA_ATTR_DEV_FLAGS,
+                                BIT_ULL(VDPA_DEV_ATTR_CVQ), VDPA_ATTR_PAD);
+}
+
 static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
                                       struct sk_buff *msg, u64 features,
                                       const struct virtio_net_config *config)
@@ -805,6 +818,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
        struct virtio_net_config config = {};
        u64 features;
        u16 val_u16;
+       int err;
 
        vdpa_get_config(vdev, 0, &config, sizeof(config));
 
@@ -821,6 +835,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
                return -EMSGSIZE;
 
        features = vdev->config->get_driver_features(vdev);
+       err = vdpa_dev_net_ctrl_vq_fill(vdev, msg, &config, features);
+       if (err)
+               return err;
 
        return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
 }
include/uapi/linux/vdpa.h +8 -1
index a252f06f9dfd..23b854e3e5e2 100644
@@ -20,9 +20,16 @@ enum vdpa_command {
        VDPA_CMD_DEV_CONFIG_GET,        /* can dump */
 };
 
+enum {
+       VDPA_DEV_ATTR_CVQ,
+};
+
 enum vdpa_attr {
        VDPA_ATTR_UNSPEC,
 
+       /* Pad attribute for 64b alignment */
+       VDPA_ATTR_PAD = VDPA_ATTR_UNSPEC,
+
        /* bus name (optional) + dev name together make the parent device handle */
        VDPA_ATTR_MGMTDEV_BUS_NAME,             /* string */
        VDPA_ATTR_MGMTDEV_DEV_NAME,             /* string */
@@ -34,6 +41,7 @@ enum vdpa_attr {
        VDPA_ATTR_DEV_MAX_VQS,                  /* u32 */
        VDPA_ATTR_DEV_MAX_VQ_SIZE,              /* u16 */
        VDPA_ATTR_DEV_MIN_VQ_SIZE,              /* u16 */
+       VDPA_ATTR_DEV_FLAGS,                    /* u64 */
 
        VDPA_ATTR_DEV_NET_CFG_MACADDR,          /* binary */
        VDPA_ATTR_DEV_NET_STATUS,               /* u8 */
--
Quoted 2 lines

2.33.1

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

#18 lore raw

RE: [PATCH v2 00/10] Allow for configuring max number of virtqueue pairs

In reply to Jason Wang
Quoted 10 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, December 14, 2021 8:47 AM

A question, consider the parent support both net and block, if user use

vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1

How do we know it's a net or block device? Or do you expect some block specific attributes to be added?

User should pass the virtio device id of type net/blk etc when creating the device.
No such in-kernel driver exists so far, so when it is added netlink interface should be enhanced to accept the optional device id.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#19 lore raw

Re: [PATCH v2 00/10] Allow for configuring max number of virtqueue pairs

Quoted 5 lines · Parav Pandit
Quoted 5 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, December 14, 2021 8:47 AM

Quoted 8 lines
Quoted 6 lines

A question, consider the parent support both net and block, if user use

vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1

How do we know it's a net or block device? Or do you expect some block specific attributes to be added?

User should pass the virtio device id of type net/blk etc when creating the device.
No such in-kernel driver exists so far, so when it is added netlink interface should be enhanced to accept the optional device id.

So the plan is to reject the dev adding without specifying the device type? Looks fine to me.

Thanks

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

#20 lore raw

RE: [PATCH v2 00/10] Allow for configuring max number of virtqueue pairs

Quoted 18 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, December 14, 2021 11:47 AM

Quoted 12 lines · Parav Pandit
Quoted 12 lines

From: Jason Wang <[email protected]>
Sent: Tuesday, December 14, 2021 8:47 AM

A question, consider the parent support both net and block, if user use

vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1

How do we know it's a net or block device? Or do you expect some block specific attributes to be added?

Quoted 7 lines
Quoted 1 line

User should pass the virtio device id of type net/blk etc when creating the

device.

Quoted 1 line

No such in-kernel driver exists so far, so when it is added netlink interface

should be enhanced to accept the optional device id.

So the plan is to reject the dev adding without specifying the device type? Looks fine to me.

Yes, this enhancement will be only for those mgmt. device that supports multiple device types.
This ensures backward compatibility and also avoids the burden from user to not specify this for mgmt. device that support single type of device.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#31 lore raw

Re: [PATCH v2 03/10] vdpa: Read device configuration only if FEATURES_OK

In reply to a message not in the archive
Quoted 43 lines · Eli Cohen
Quoted 25 lines · Jason Wang
Quoted 24 lines · Eli Cohen

Avoid reading device configuration during feature negotiation. Read device status and verify that VIRTIO_CONFIG_S_FEATURES_OK is set. Otherwise, return -EAGAIN.

---
 drivers/vdpa/vdpa.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/vdpa/vdpa.c +1 -0
index 42d71d60d5dc..5749cf0a1500 100644
@@ -819,8 +819,15 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,
 {
        u32 device_id;
        void *hdr;
+       u8 status;
        int err;
 
Quoted 12 lines

drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 833

Quoted 9 lines
drivers/vdpa/vdpa.c +6 -0
+       status = vdev->config->get_status(vdev);
+       if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) {
+               NL_SET_ERR_MSG_MOD(extack, "Features negotiation not completed");
+               return -EAGAIN;
+       }
+
        hdr = genlmsg_put(msg, portid, seq, &vdpa_nl_family, flags,
                          VDPA_CMD_DEV_CONFIG_GET);
        if (!hdr)

It looks to me we need to synchronize this with set_status() and cf_mutex (set_config).

Makes sense.

Quoted 1 line
Quoted 6 lines
Quoted 1 line

Or simply return all the config space (the maximum set of features)

No sure I follow you on this. Are you suggesting to return in the netlink message all the fields of struct virtio_net_config as individual fields?

How is this related to the need to sync with cf_mutex?

I meant the reason for the synchronization is because some config fields depend on the feature negotiation. I wonder if it would be easier we just return all the possible config fields, then there's probably no need for the synchronization since we don't need to check the driver feature but the device features.

Thanks

Quoted 9 lines
Quoted 8 lines

Thanks

Quoted 3 lines

--
2.33.1

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

#22 lore raw

Re: [PATCH v2 00/10] Allow for configuring max number of virtqueue pairs

In reply to a message not in the archive
Quoted 18 lines · Eli Cohen
Quoted 16 lines · Jason Wang
Quoted 14 lines · Eli Cohen

Allow the user to configure the max number of virtqueue pairs for a vdpa instance. The user can then control the actual number of virtqueue pairs using ethtool.

Example, set number of VQPs to 2:

$ ethtool -L ens1 combined 2

A user can check the max supported virtqueues for a management device by runnig:

vdpa dev show

    vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \
            max_vqp 3 max_vq_size 256 max_supported_vqs 256
Quoted 8 lines
Quoted 2 lines

I think the maxsupported_vqs should be an odd number since it should contain control vq.

I was thinking we should report data virtqueues. If some upstream driver or device does not support CVQ, this should still be an even number.

Moreover, if we want to include the CVQ, we might want to indicate that explicitly.

Can we expose driver features in this case?

Thanks

Quoted 52 lines
Quoted 52 lines
Quoted 7 lines

and refer to this value when adding a device.

To create a device with a max of 5 VQPs:
vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1 max_vqp 5

A question, consider the parent support both net and block, if user use

vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1

How do we know it's a net or block device? Or do you expect some block specific attributes to be added?

Thanks

Quoted 35 lines

V1 -> V2:
1. Do not return the index of the control VQ. Instead return an indication if Ctrl VQ was negotiated.
2. Do not returen conig information if FEATURES_OK is not set to avoid reporting out of sync information.
3. Minor fixes as described by the individual patches
4. Add patches to return the max virtqueues a device is capable of supporting.

Eli Cohen (10):
vdpa: Provide interface to read driver features
vdpa/mlx5: Distribute RX virtqueues in RQT object
vdpa: Read device configuration only if FEATURES_OK
vdpa: Allow to configure max data virtqueues
vdpa/mlx5: Fix config_attr_mask assignment
vdpa/mlx5: Support configuring max data virtqueue pairs
vdpa: Add support for returning device configuration information vdpa/mlx5: Restore cur_num_vqs in case of failure in change_num_qps()
vdpa: Support reporting max device virtqueues
vdpa/mlx5: Configure max supported virtqueues

 drivers/vdpa/alibaba/eni_vdpa.c    | 16 +++--
 drivers/vdpa/ifcvf/ifcvf_main.c    | 16 +++--
 drivers/vdpa/mlx5/net/mlx5_vnet.c  | 94 +++++++++++++++++-------------
 drivers/vdpa/vdpa.c                | 42 ++++++++++++-
 drivers/vdpa/vdpa_sim/vdpa_sim.c   | 21 +++++--
 drivers/vdpa/vdpa_user/vduse_dev.c | 16 +++--
 drivers/vdpa/virtio_pci/vp_vdpa.c  | 16 +++--
 drivers/vhost/vdpa.c               |  2 +-
 drivers/virtio/virtio_vdpa.c       |  2 +-
 include/linux/vdpa.h               | 16 +++--
 include/uapi/linux/vdpa.h          |  9 +++
 11 files changed, 178 insertions(+), 72 deletions(-)
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

--
2.33.1

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

#5 lore raw
In reply to a message not in the archive
Quoted 15 lines · Eli Cohen
Quoted 13 lines · Jason Wang
Quoted 11 lines · Eli Cohen

Add netlink attribute to store flags indicating current state of the device.
In addition, introduce a flag to indicate whether control virtqueue is used.

This indication can be retrieved by:

vdpa dev config show vdpa-a
vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 1
mtu 1500 ctrl_vq yes

Quoted 8 lines
Quoted 1 line

I think the cvq is kind of duplicated with the driver features?

We don't pass to userspace the driver features. The availablity of CVQ is passed trough a new bit mask field that encodes (currently) just the availablity of CVQ.

Are you suggesting the return the entire set of negotiated features and let user space decode that?

Yes, I think that can simplify things and save a lot of effort.

Thanks

Quoted 84 lines
Quoted 84 lines

Thanks

Quoted 80 lines

----
V1 -> V2
Patch was changed to return only an indication of ctrl VQ

---
 drivers/vdpa/vdpa.c       | 17 +++++++++++++++++
 include/uapi/linux/vdpa.h |  8 ++++++++
 2 files changed, 25 insertions(+)
drivers/vdpa/vdpa.c +17 -0
index 7b7bef7673b4..130a8d4aeaed 100644
@@ -787,6 +787,19 @@ static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callba
        return msg->len;
 }
 
+static int vdpa_dev_net_ctrl_vq_fill(struct vdpa_device *vdev,
+                                    struct sk_buff *msg,
+                                    struct virtio_net_config *config,
+                                    u64 features)
+{
+       if (!(features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
+               return 0;
+
+       /* currently the only flag can be returned */
+       return nla_put_u64_64bit(msg, VDPA_ATTR_DEV_FLAGS,
+                                BIT_ULL(VDPA_DEV_ATTR_CVQ), VDPA_ATTR_PAD);
+}
+
 static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,
                                       struct sk_buff *msg, u64 features,
                                       const struct virtio_net_config *config)
@@ -805,6 +818,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
        struct virtio_net_config config = {};
        u64 features;
        u16 val_u16;
+       int err;
 
        vdpa_get_config(vdev, 0, &config, sizeof(config));
 
@@ -821,6 +835,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
                return -EMSGSIZE;
 
        features = vdev->config->get_driver_features(vdev);
+       err = vdpa_dev_net_ctrl_vq_fill(vdev, msg, &config, features);
+       if (err)
+               return err;
 
        return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config);
 }
include/uapi/linux/vdpa.h +8 -0
index a252f06f9dfd..23b854e3e5e2 100644
@@ -20,9 +20,16 @@ enum vdpa_command {
        VDPA_CMD_DEV_CONFIG_GET,        /* can dump */
 };
 
+enum {
+       VDPA_DEV_ATTR_CVQ,
+};
+
 enum vdpa_attr {
        VDPA_ATTR_UNSPEC,
 
+       /* Pad attribute for 64b alignment */
+       VDPA_ATTR_PAD = VDPA_ATTR_UNSPEC,
+
        /* bus name (optional) + dev name together make the parent device handle */
        VDPA_ATTR_MGMTDEV_BUS_NAME,             /* string */
        VDPA_ATTR_MGMTDEV_DEV_NAME,             /* string */
@@ -34,6 +41,7 @@ enum vdpa_attr {
        VDPA_ATTR_DEV_MAX_VQS,                  /* u32 */
        VDPA_ATTR_DEV_MAX_VQ_SIZE,              /* u16 */
        VDPA_ATTR_DEV_MIN_VQ_SIZE,              /* u16 */
+       VDPA_ATTR_DEV_FLAGS,                    /* u64 */
 
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
include/uapi/linux/vdpa.h +0 -1
        VDPA_ATTR_DEV_NET_CFG_MACADDR,          /* binary */
        VDPA_ATTR_DEV_NET_STATUS,               /* u8 */
--

2.33.1

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

#23 lore raw

Re: [PATCH v2 00/10] Allow for configuring max number of virtqueue pairs

In reply to Jason Wang

Hi Eli,
I don't know what's wrong, but I've only received replies through the [email protected] mailing list.

Even in the archive I can't find your original series.

Adding [email protected] to double check what's going wrong.

Thanks,
Stefano

Quoted 69 lines · Jason Wang
Quoted 6 lines · Eli Cohen

Allow the user to configure the max number of virtqueue pairs for a vdpa instance. The user can then control the actual number of virtqueue pairs using ethtool.

Example, set number of VQPs to 2:

Quoted 8 lines
$ ethtool -L ens1 combined 2

A user can check the max supported virtqueues for a management device by runnig:

vdpa dev show

    vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \
            max_vqp 3 max_vq_size 256 max_supported_vqs 256

I think the maxsupported_vqs should be an odd number since it should contain control vq.

Quoted 5 lines

and refer to this value when adding a device.

To create a device with a max of 5 VQPs:
vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1 max_vqp 5

A question, consider the parent support both net and block, if user use

vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1

How do we know it's a net or block device? Or do you expect some block specific attributes to be added?

Thanks

Quoted 35 lines

V1 -> V2:
1. Do not return the index of the control VQ. Instead return an indication if Ctrl VQ was negotiated.
2. Do not returen conig information if FEATURES_OK is not set to avoid reporting out of sync information.
3. Minor fixes as described by the individual patches
4. Add patches to return the max virtqueues a device is capable of supporting.

Eli Cohen (10):
vdpa: Provide interface to read driver features
vdpa/mlx5: Distribute RX virtqueues in RQT object
vdpa: Read device configuration only if FEATURES_OK
vdpa: Allow to configure max data virtqueues
vdpa/mlx5: Fix config_attr_mask assignment
vdpa/mlx5: Support configuring max data virtqueue pairs
vdpa: Add support for returning device configuration information vdpa/mlx5: Restore cur_num_vqs in case of failure in change_num_qps()
vdpa: Support reporting max device virtqueues
vdpa/mlx5: Configure max supported virtqueues

 drivers/vdpa/alibaba/eni_vdpa.c    | 16 +++--
 drivers/vdpa/ifcvf/ifcvf_main.c    | 16 +++--
 drivers/vdpa/mlx5/net/mlx5_vnet.c  | 94 +++++++++++++++++-------------
 drivers/vdpa/vdpa.c                | 42 ++++++++++++-
 drivers/vdpa/vdpa_sim/vdpa_sim.c   | 21 +++++--
 drivers/vdpa/vdpa_user/vduse_dev.c | 16 +++--
 drivers/vdpa/virtio_pci/vp_vdpa.c  | 16 +++--
 drivers/vhost/vdpa.c               |  2 +-
 drivers/virtio/virtio_vdpa.c       |  2 +-
 include/linux/vdpa.h               | 16 +++--
 include/uapi/linux/vdpa.h          |  9 +++
 11 files changed, 178 insertions(+), 72 deletions(-)
Quoted 9 lines
Quoted 3 lines

--
2.33.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

#25 lore raw

Re: [PATCH v2 00/10] Allow for configuring max number of virtqueue pairs

In reply to a message not in the archive
Quoted 5 lines · Eli Cohen
Quoted 4 lines · Stefano Garzarella

Hi Eli,
I don't know what's wrong, but I've only received replies through the [email protected] mailing list.

Quoted 7 lines
Quoted 4 lines

Even in the archive I can't find your original series.

Adding [email protected] to double check what's going wrong.

OK, let me know if you want me to send you the patches. I am going to send a new series and can put you on CC.

I'll look at the new series.

Thanks,
Stefano

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

author
#10 lore raw

Re: [PATCH v2 09/10] vdpa: Support reporting max device virtqueues

In reply to a message not in the archive
Quoted 37 lines · Eli Cohen
Quoted 20 lines · Si-Wei Liu
Quoted 18 lines · Eli Cohen

Add max_supported_vqs field to struct vdpa_mgmt_dev. Upstream drivers need to feel this value according to the device capabilities.

This value is reported back in a netlink message when showing a device.

Example:

$ vdpa dev show
vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \
	max_vqp 3 max_vq_size 256 max_supported_vqs 256
---
   drivers/vdpa/vdpa.c       | 2 ++
   include/linux/vdpa.h      | 1 +
   include/uapi/linux/vdpa.h | 1 +
   3 files changed, 4 insertions(+)
Quoted 11 lines

drivers/vdpa/vdpa.c vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq · line 699

Quoted 10 lines
drivers/vdpa/vdpa.c +2 -0
index 130a8d4aeaed..b9dd693146be 100644
@@ -695,6 +695,8 @@ vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq
   		goto msg_err;
   	if (nla_put_u16(msg, VDPA_ATTR_DEV_MIN_VQ_SIZE, min_vq_size))
   		goto msg_err;
+	if (nla_put_u16(msg, VDPA_ATTR_DEV_MAX_DEV_VQS, vdev->mdev->max_supported_vqs))
+		goto msg_err;

What is the default value if vendor driver doesn't expose this value?

I think each vendor should put a value here. If you don't, you can still add a vdpa device but you'll have to guess.
Alternatively, I can provide a patch that sets this value to 2 for all vendors.

Quoted 6 lines
Quoted 4 lines

And it
doesn't seem this is something to stash on struct vdpa_mgmt_dev, only some vdpa vendor for network drive may need to expose it; if otherwise not exposed we can assume it's 32767 by the spec.

I am not sure there's any device capable of so many VQs. In any case, I think use 2 as defauly is better since any device can support that.

OK, default to 2 is fine (for net).

Quoted 5 lines
Quoted 3 lines

A generic vdpa op
(get_device_capability?)

The point is that you need this info to create a vdpa device so I don't see how it can be a vdpa device operation.

I wonder if this info should belong to mgmtdev rather than vdpa dev? It should be visible before user ever attempts to create a vdpa device.

Quoted 5 lines
Quoted 3 lines

to query device capability might be better I guess (define a VDPA_CAPAB_NET_MAX_VQS subtype to get it).

Why limit this capablity only for net devices? Any kind of vdpa device may want to report this capability.

I thought what you report here is the max number for data queues the device can support, no? The control or event queue that is emulated in userspace isn't much interesting to users IMHO.

User needs to take the hint from this value to create vdpa net device and specify a proper max_vqp value. It's rather counter intuitive if what they see is not what they would use.

Thanks,
-Siwei

Quoted 18 lines
Quoted 18 lines

-Siwei

Quoted 16 lines
drivers/vdpa/vdpa.c +0 -0
   	genlmsg_end(msg, hdr);
   	return 0;
include/linux/vdpa.h +1 -0
index 9245dfbf1b08..72ea8ad7ba21 100644
@@ -444,6 +444,7 @@ struct vdpa_mgmt_dev {
   	const struct vdpa_mgmtdev_ops *ops;
   	const struct virtio_device_id *id_table;
   	u64 config_attr_mask;
+	u16 max_supported_vqs;
   	struct list_head list;
   };
include/uapi/linux/vdpa.h +0 -1
index 23b854e3e5e2..1b758d77e228 100644
--- a/include/uapi/linux/vdpa.h
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines

+++ b/include/uapi/linux/vdpa.h

include/uapi/linux/vdpa.h +1 -0
@@ -42,6 +42,7 @@ enum vdpa_attr {
   	VDPA_ATTR_DEV_MAX_VQ_SIZE,		/* u16 */
   	VDPA_ATTR_DEV_MIN_VQ_SIZE,		/* u16 */
   	VDPA_ATTR_DEV_FLAGS,			/* u64 */
+	VDPA_ATTR_DEV_MAX_DEV_VQS,		/* u16 */
   	VDPA_ATTR_DEV_NET_CFG_MACADDR,		/* binary */
   	VDPA_ATTR_DEV_NET_STATUS,		/* u8 */

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

author
#12 lore raw

Re: [PATCH v2 09/10] vdpa: Support reporting max device virtqueues

In reply to a message not in the archive
Quoted 66 lines · Eli Cohen
Quoted 44 lines · Si-Wei Liu
Quoted 36 lines · Eli Cohen
Quoted 19 lines · Si-Wei Liu
Quoted 18 lines · Eli Cohen

Add max_supported_vqs field to struct vdpa_mgmt_dev. Upstream drivers need to feel this value according to the device capabilities.

This value is reported back in a netlink message when showing a device.

Example:

$ vdpa dev show
vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \
	max_vqp 3 max_vq_size 256 max_supported_vqs 256
---
    drivers/vdpa/vdpa.c       | 2 ++
    include/linux/vdpa.h      | 1 +
    include/uapi/linux/vdpa.h | 1 +
    3 files changed, 4 insertions(+)
Quoted 11 lines

drivers/vdpa/vdpa.c vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq · line 699

Quoted 10 lines
drivers/vdpa/vdpa.c +2 -0
index 130a8d4aeaed..b9dd693146be 100644
@@ -695,6 +695,8 @@ vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq
    		goto msg_err;
    	if (nla_put_u16(msg, VDPA_ATTR_DEV_MIN_VQ_SIZE, min_vq_size))
    		goto msg_err;
+	if (nla_put_u16(msg, VDPA_ATTR_DEV_MAX_DEV_VQS, vdev->mdev->max_supported_vqs))
+		goto msg_err;

What is the default value if vendor driver doesn't expose this value?

I think each vendor should put a value here. If you don't, you can still add a vdpa device but you'll have to guess.
Alternatively, I can provide a patch that sets this value to 2 for all vendors.

Quoted 6 lines
Quoted 4 lines

And it
doesn't seem this is something to stash on struct vdpa_mgmt_dev, only some vdpa vendor for network drive may need to expose it; if otherwise not exposed we can assume it's 32767 by the spec.

I am not sure there's any device capable of so many VQs. In any case, I think use 2 as defauly is better since any device can support that.

Quoted 9 lines

OK, default to 2 is fine (for net).

Quoted 4 lines
Quoted 2 lines

A generic vdpa op
(get_device_capability?)

The point is that you need this info to create a vdpa device so I don't see how it can be a vdpa device operation.

I wonder if this info should belong to mgmtdev rather than vdpa dev? It should be visible before user ever attempts to create a vdpa device.

Every vendor lists its devices in the management bus. The you use vdpa tool to instantiate a management device so I think management device is the right place.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

to query device capability might be better I guess (define a VDPA_CAPAB_NET_MAX_VQS subtype to get it).

Why limit this capablity only for net devices? Any kind of vdpa device may want to report this capability.

I thought what you report here is the max number for data queues the device can support, no? The control or event queue that is emulated in userspace isn't much interesting to users IMHO.

Quoted 6 lines
Quoted 3 lines

User needs to take the hint from this value to create vdpa net device and specify a proper max_vqp value. It's rather counter intuitive if what they see is not what they would use.

I am not following you here.
We report the max the device is capable of. The user uses this to create a device and specify valid number of virtqueues.

I mean why don't you expose this value in "vdpa mgmtdev show" before user attempts to create a vdpa device to know the max number of queues the parent may support? How can a user infer this value without having to create a vdpa device?

Thanks,
-Siwei

Quoted 22 lines
Quoted 22 lines

Thanks,
-Siwei

Quoted 18 lines
Quoted 18 lines

-Siwei

Quoted 16 lines
drivers/vdpa/vdpa.c +0 -0
    	genlmsg_end(msg, hdr);
    	return 0;
include/linux/vdpa.h +1 -0
index 9245dfbf1b08..72ea8ad7ba21 100644
@@ -444,6 +444,7 @@ struct vdpa_mgmt_dev {
    	const struct vdpa_mgmtdev_ops *ops;
    	const struct virtio_device_id *id_table;
    	u64 config_attr_mask;
+	u16 max_supported_vqs;
    	struct list_head list;
    };
include/uapi/linux/vdpa.h +0 -1
index 23b854e3e5e2..1b758d77e228 100644
--- a/include/uapi/linux/vdpa.h
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines

+++ b/include/uapi/linux/vdpa.h

include/uapi/linux/vdpa.h +1 -0
@@ -42,6 +42,7 @@ enum vdpa_attr {
    	VDPA_ATTR_DEV_MAX_VQ_SIZE,		/* u16 */
    	VDPA_ATTR_DEV_MIN_VQ_SIZE,		/* u16 */
    	VDPA_ATTR_DEV_FLAGS,			/* u64 */
+	VDPA_ATTR_DEV_MAX_DEV_VQS,		/* u16 */
    	VDPA_ATTR_DEV_NET_CFG_MACADDR,		/* binary */
    	VDPA_ATTR_DEV_NET_STATUS,		/* u8 */

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