Re: [PATCH 1/2] vdpa: Allow to configure max data virtqueues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 11/30/2021 1:48 AM, Eli Cohen wrote:
Allow to configure the max virtqueues for a device.

Signed-off-by: Eli Cohen <elic@xxxxxxxxxx>
---
  drivers/vdpa/vdpa.c  | 16 +++++++++++++++-
  include/linux/vdpa.h |  1 +
  2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 7332a74a4b00..e185ec2ee851 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -480,7 +480,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))
It seems VDPA_ATTR_DEV_MAX_VQS (u32) is what you want (# of data virtqueues instead of # of data virtqueue pairs)? Not sure what's possible use of VDPA_ATTR_DEV_NET_CFG_MAX_VQP, was it to dump/display the config space max_virtqueue_pairs value (u16, 1-32768) for virtio-net? Why there's such quasi-duplicate attribute introduced in the first place?

Not even sure VDPA_ATTR_DEV_MAX_VQS by definition should include other virtqueues as well: such as control virtqueue or event virtqueue. Hence the name will be more applicable to vdpa devices of other virtio type than just virtio-net. Otherwise I would think this attribute is slightly misnamed (max_data_vqs might be a proper name).

static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
  {
@@ -506,6 +507,19 @@ 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]);
  		config.mask |= (1 << VDPA_ATTR_DEV_NET_CFG_MTU);
  	}
+	if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MAX_VQP]) {
+		config.max_virtqueues = nla_get_u16(nl_attrs[VDPA_ATTR_DEV_NET_CFG_MAX_VQP]);
+		if (config.max_virtqueues < 2) {
+			NL_SET_ERR_MSG_MOD(info->extack, "At least two virtqueues are required");
+			return -EINVAL;
+		}
+		if ((config.max_virtqueues - 1) & config.max_virtqueues) {
+			NL_SET_ERR_MSG_MOD(info->extack,
+					   "Must provide power of two number of virtqueues");
Why there's such limitation for the number of vDPA virtqueues? I thought the software virtio doesn't have this limitation (power of two).

-Siwei

+			return -EINVAL;
+		}
+		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
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index c3011ccda430..2f0b09c6d1ae 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -101,6 +101,7 @@ struct vdpa_dev_set_config {
  		u16 mtu;
  	} net;
  	u64 mask;
+	u16 max_virtqueues;
  };
/**

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux