Si-Wei Liu
2022-Jan-07 02:12 UTC
[PATCH v7 10/14] vdpa: Support reporting max device capabilities
On 1/5/2022 3:46 AM, Eli Cohen wrote:> Add max_supported_vqs and supported_features fields to struct > vdpa_mgmt_dev. Upstream drivers need to feel these values according to > the device capabilities. > > These values are reported back in a netlink message when showing management > devices. > > Examples: > > $ auxiliary/mlx5_core.sf.1:Missing the exact 'vdpa mgmtdev show ...' command, otherwise: Reviewed-by: Si-Wei Liu<si-wei.liu at oracle.com>> supported_classes net > max_supported_vqs 257 > dev_features CSUM GUEST_CSUM MTU HOST_TSO4 HOST_TSO6 STATUS CTRL_VQ MQ \ > CTRL_MAC_ADDR VERSION_1 ACCESS_PLATFORM > > $ vdpa -j mgmtdev show > {"mgmtdev":{"auxiliary/mlx5_core.sf.1":{"supported_classes":["net"], \ > "max_supported_vqs":257,"dev_features":["CSUM","GUEST_CSUM","MTU", \ > "HOST_TSO4","HOST_TSO6","STATUS","CTRL_VQ","MQ","CTRL_MAC_ADDR", \ > "VERSION_1","ACCESS_PLATFORM"]}}} > > $ vdpa -jp mgmtdev show > { > "mgmtdev": { > "auxiliary/mlx5_core.sf.1": { > "supported_classes": [ "net" ], > "max_supported_vqs": 257, > "dev_features": ["CSUM","GUEST_CSUM","MTU","HOST_TSO4", \ > "HOST_TSO6","STATUS","CTRL_VQ","MQ", \ > "CTRL_MAC_ADDR","VERSION_1","ACCESS_PLATFORM"] > } > } > } > > Signed-off-by: Eli Cohen <elic at nvidia.com> > --- > v6 -> v7: > 1. Fix comment > 2. Fix error flow > 3. Add device features > > drivers/vdpa/vdpa.c | 10 ++++++++++ > include/linux/vdpa.h | 2 ++ > include/uapi/linux/vdpa.h | 2 ++ > 3 files changed, 14 insertions(+) > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c > index 60cf821175fa..34fa251db8cc 100644 > --- a/drivers/vdpa/vdpa.c > +++ b/drivers/vdpa/vdpa.c > @@ -514,6 +514,16 @@ 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)) { > + err = -EMSGSIZE; > + goto msg_err; > + } > + if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_SUPPORTED_FEATURES, > + mdev->supported_features, VDPA_ATTR_PAD)) { > + err = -EMSGSIZE; > + goto msg_err; > + } > > genlmsg_end(msg, hdr); > return 0; > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h > index 6d4d7e4fe208..a6047fd6cf12 100644 > --- a/include/linux/vdpa.h > +++ b/include/linux/vdpa.h > @@ -460,6 +460,8 @@ struct vdpa_mgmt_dev { > const struct virtio_device_id *id_table; > u64 config_attr_mask; > struct list_head list; > + u64 supported_features; > + 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..1061d8d2d09d 100644 > --- a/include/uapi/linux/vdpa.h > +++ b/include/uapi/linux/vdpa.h > @@ -44,6 +44,8 @@ enum vdpa_attr { > VDPA_ATTR_DEV_NET_CFG_MTU, /* u16 */ > > VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */ > + VDPA_ATTR_DEV_MGMTDEV_MAX_VQS, /* u32 */ > + VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */ > /* new attributes must be added above here */ > VDPA_ATTR_MAX, > };