On 12/22/2021 6:20 AM, Eli Cohen wrote:
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 management
devices.

Examples:

$ vdpa mgmtdev show
auxiliary/mlx5_core.sf.1:
   supported_classes net
   max_supported_vqs 257

$ vdpa -j mgmtdev show
{"mgmtdev":{"auxiliary/mlx5_core.sf.1":{"supported_classes":["net"],"max_supported_vqs":257}}}

$ vdpa -jp mgmtdev show
{
     "mgmtdev": {
         "auxiliary/mlx5_core.sf.1": {
             "supported_classes": [ "net" ],
             "max_supported_vqs": 257
         }
     }
}

Signed-off-by: Eli Cohen <[email protected]>
---
  drivers/vdpa/vdpa.c       | 3 +++
  include/linux/vdpa.h      | 1 +
  include/uapi/linux/vdpa.h | 1 +
  3 files changed, 5 insertions(+)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 462da4968270..ea22aa864dd5 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -514,6 +514,9 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev 
*mdev, struct sk_buff *m
                err = -EMSGSIZE;
                goto msg_err;
        }
+       if (nla_put_u32(msg, VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,
+                       mdev->max_supported_vqs))
+               goto msg_err;
genlmsg_end(msg, hdr);
        return 0;
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index 47e2b780e4bc..bd75af4feaf7 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -448,6 +448,7 @@ struct vdpa_mgmt_dev {
        const struct virtio_device_id *id_table;
        u64 config_attr_mask;
        struct list_head list;
+       u32 max_supported_vqs;
  };
int vdpa_mgmtdev_register(struct vdpa_mgmt_dev *mdev);
diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h
index db3738ef3beb..995257c6bf2a 100644
--- a/include/uapi/linux/vdpa.h
+++ b/include/uapi/linux/vdpa.h
@@ -44,6 +44,7 @@ enum vdpa_attr {
        VDPA_ATTR_DEV_NET_CFG_MTU,              /* u16 */
VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */
+       VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,          /* u16 */
s/u16/u32/

-Siwei

        /* new attributes must be added above here */
        VDPA_ATTR_MAX,
  };

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

Reply via email to