Jason Wang
2022-Jan-07 05:46 UTC
[PATCH v7 08/14] vdpa: Add support for returning device configuration information
? 2022/1/5 ??7:46, Eli Cohen ??:> Add netlink attribute to store the negotiated features. This can be used > by userspace to get the current state of the vdpa instance. > > Examples: > > $ vdpa dev config show vdpa-a > vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 16 mtu 1500 > negotiated_features CSUM GUEST_CSUM MTU MAC HOST_TSO4 HOST_TSO6 STATUS \ > CTRL_VQ MQ CTRL_MAC_ADDR VERSION_1 ACCESS_PLATFORM > > $ vdpa -j dev config show vdpa-a > {"config":{"vdpa-a":{"mac":"00:00:00:00:88:88","link ":"up","link_announce":false, \ > "max_vq_pairs":16,"mtu":1500,"negotiated_features":["CSUM","GUEST_CSUM","MTU","MAC", \ > "HOST_TSO4","HOST_TSO6","STATUS","CTRL_VQ","MQ","CTRL_MAC_ADDR","VERSION_1", \ > "ACCESS_PLATFORM"]}}} > > $ vdpa -jp dev config show vdpa-a > { > "config": { > "vdpa-a": { > "mac": "00:00:00:00:88:88", > "link ": "up", > "link_announce ": false, > "max_vq_pairs": 16, > "mtu": 1500, > "negotiated_features": [ > "CSUM","GUEST_CSUM","MTU","MAC","HOST_TSO4","HOST_TSO6","STATUS","CTRL_VQ","MQ", \ > "CTRL_MAC_ADDR","VERSION_1","ACCESS_PLATFORM" > ] > } > } > } > > Signed-off-by: Eli Cohen <elic at nvidia.com>Acked-by: Jason Wang <jasowang at redhat.com>> --- > drivers/vdpa/vdpa.c | 3 +++ > include/uapi/linux/vdpa.h | 4 ++++ > 2 files changed, 7 insertions(+) > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c > index 96d31b80fdce..60cf821175fa 100644 > --- a/drivers/vdpa/vdpa.c > +++ b/drivers/vdpa/vdpa.c > @@ -846,6 +846,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); > + if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features, > + VDPA_ATTR_PAD)) > + return -EMSGSIZE; > > return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config); > } > diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h > index a252f06f9dfd..db3738ef3beb 100644 > --- a/include/uapi/linux/vdpa.h > +++ b/include/uapi/linux/vdpa.h > @@ -23,6 +23,9 @@ enum vdpa_command { > 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 */ > @@ -40,6 +43,7 @@ enum vdpa_attr { > VDPA_ATTR_DEV_NET_CFG_MAX_VQP, /* u16 */ > VDPA_ATTR_DEV_NET_CFG_MTU, /* u16 */ > > + VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */ > /* new attributes must be added above here */ > VDPA_ATTR_MAX, > };