Thread (1 message) 1 message, 1 author, 2021-12-21

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

From: Jason Wang <hidden>
Date: 2021-12-21 05:53:17

On Sun, Dec 19, 2021 at 10:03 PM Eli Cohen [off-list ref] wrote:
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.

Signed-off-by: Eli Cohen <redacted>
Acked-by: Jason Wang <redacted>
quoted hunk
---
V2 -> V3:
Fix error flow

 drivers/vdpa/vdpa.c  | 13 ++++++++++++-
 include/linux/vdpa.h |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 5749cf0a1500..83730713c7d0 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -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,16 @@ 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.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");
+                       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 9cc4291a79b3..9245dfbf1b08 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -101,6 +101,7 @@ struct vdpa_dev_set_config {
        struct {
                u8 mac[ETH_ALEN];
                u16 mtu;
+               u16 max_vq_pairs;
        } net;
        u64 mask;
 };
--
2.34.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help