vdpa: Provide interface to read driver features
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jason Wang
Acked-byQuoted 10 lines · Eli Cohen
Provide an interface to read the negotiated features. This is needed when building the netlink message in
vdpa_dev_net_config_fill().Also fix the implementation of
vdpa_dev_net_config_fill()to use the negotiated features instead of the device features.To make APIs clearer, make the following name changes to struct
vdpa_config_opsso they better describe their operations:
Quoted 7 lines
get_features->get_device_featuresset_features->set_driver_featuresFinally, add
get_driver_featuresto return the negotiated features and add implementation to all the upstream drivers.Signed-off-by Eli Cohen <[email protected]>
Quoted 395 lines
--- drivers/vdpa/alibaba/eni_vdpa.c | 16 ++++++++++++---- drivers/vdpa/ifcvf/ifcvf_main.c | 16 ++++++++++++---- drivers/vdpa/mlx5/net/mlx5_vnet.c | 16 ++++++++++++---- drivers/vdpa/vdpa.c | 2 +- drivers/vdpa/vdpa_sim/vdpa_sim.c | 21 +++++++++++++++------ drivers/vdpa/vdpa_user/vduse_dev.c | 16 ++++++++++++---- drivers/vdpa/virtio_pci/vp_vdpa.c | 16 ++++++++++++---- drivers/vhost/vdpa.c | 2 +- drivers/virtio/virtio_vdpa.c | 2 +- include/linux/vdpa.h | 14 +++++++++----- 10 files changed, 87 insertions(+), 34 deletions(-)drivers/vdpa/alibaba/eni_vdpa.c +12
-4@@ -58,7 +58,7 @@ static struct virtio_pci_legacy_device *vdpa_to_ldev(struct vdpa_device *vdpa)return &eni_vdpa->ldev; } -static u64 eni_vdpa_get_features (struct vdpa_device *vdpa) +static u64 eni_vdpa_get_device_features (struct vdpa_device *vdpa) {struct virtio_pci_legacy_device *ldev =vdpa_to_ldev (vdpa);u64 features =vp_legacy_get_features (ldev);@@ -69,7 +69,7 @@ static u64 eni_vdpa_get_features(struct vdpa_device *vdpa)return features; } -static int eni_vdpa_set_features (struct vdpa_device *vdpa,u64 features) +static int eni_vdpa_set_driver_features (struct vdpa_device *vdpa,u64 features) {struct virtio_pci_legacy_device *ldev =vdpa_to_ldev (vdpa);@@ -84,6 +84,13 @@ static int eni_vdpa_set_features(struct vdpa_device *vdpa, u64 features)return 0 ; } +static u64 eni_vdpa_get_driver_features (struct vdpa_device *vdpa) +{ +struct virtio_pci_legacy_device *ldev =vdpa_to_ldev (vdpa); + +return vp_legacy_get_driver_features (ldev); +} +static u8 eni_vdpa_get_status (struct vdpa_device *vdpa) {struct virtio_pci_legacy_device *ldev =vdpa_to_ldev (vdpa);@@ -401,8 +408,9 @@ static void eni_vdpa_set_config_cb(struct vdpa_device *vdpa, }static const struct vdpa_config_ops eni_vdpa_ops = { - .get_features = eni_vdpa_get_features, - .set_features = eni_vdpa_set_features, + .get_device_features = eni_vdpa_get_device_features, + .set_driver_features = eni_vdpa_set_driver_features, + .get_driver_features = eni_vdpa_get_driver_features, .get_status = eni_vdpa_get_status, .set_status = eni_vdpa_set_status, .reset = eni_vdpa_reset,drivers/vdpa/ifcvf/ifcvf_main.c +12
-4@@ -169,7 +169,7 @@ static struct ifcvf_hw *vdpa_to_vf(struct vdpa_device *vdpa_dev)return &adapter->vf; } -static u64 ifcvf_vdpa_get_features (struct vdpa_device *vdpa_dev) +static u64 ifcvf_vdpa_get_device_features (struct vdpa_device *vdpa_dev) {struct ifcvf_adapter *adapter =vdpa_to_adapter (vdpa_dev);struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev);@@ -187,7 +187,7 @@ static u64 ifcvf_vdpa_get_features(struct vdpa_device *vdpa_dev)return features; } -static int ifcvf_vdpa_set_features (struct vdpa_device *vdpa_dev,u64 features) +static int ifcvf_vdpa_set_driver_features (struct vdpa_device *vdpa_dev,u64 features) {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev);int ret;@@ -201,6 +201,13 @@ static int ifcvf_vdpa_set_features(struct vdpa_device *vdpa_dev, u64 features)return 0 ; } +static u64 ifcvf_vdpa_get_driver_features (struct vdpa_device *vdpa_dev) +{ +struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev); + +return vf->req_features; +} +static u8 ifcvf_vdpa_get_status (struct vdpa_device *vdpa_dev) {struct ifcvf_hw *vf =vdpa_to_vf (vdpa_dev);@@ -426,8 +433,9 @@ static struct vdpa_notification_area ifcvf_get_vq_notification(struct vdpa_devic* implemented set_map()/dma_map()/dma_unmap() */ static const struct vdpa_config_ops ifc_vdpa_ops = { - .get_features = ifcvf_vdpa_get_features, - .set_features = ifcvf_vdpa_set_features, + .get_device_features = ifcvf_vdpa_get_device_features, + .set_driver_features = ifcvf_vdpa_set_driver_features, + .get_driver_features = ifcvf_vdpa_get_driver_features, .get_status = ifcvf_vdpa_get_status, .set_status = ifcvf_vdpa_set_status, .reset = ifcvf_vdpa_reset,drivers/vdpa/mlx5/net/mlx5_vnet.c +12
-4@@ -1880,7 +1880,7 @@ static u64 mlx_to_vritio_features(u16 dev_features)return result; } -static u64 mlx5_vdpa_get_features (struct vdpa_device *vdev) +static u64 mlx5_vdpa_get_device_features (struct vdpa_device *vdev) {struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev);struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);@@ -1973,7 +1973,7 @@ static void update_cvq_info(struct mlx5_vdpa_dev *mvdev) } } -static int mlx5_vdpa_set_features (struct vdpa_device *vdev,u64 features) +static int mlx5_vdpa_set_driver_features (struct vdpa_device *vdev,u64 features) {struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev);struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);@@ -2340,6 +2340,13 @@ static int mlx5_get_vq_irq(struct vdpa_device *vdv, u16 idx)return -EOPNOTSUPP ; } +static u64 mlx5_vdpa_get_driver_features (struct vdpa_device *vdev) +{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev); + +return mvdev->actual_features; +} +static const struct vdpa_config_ops mlx5_vdpa_ops = { .set_vq_address = mlx5_vdpa_set_vq_address, .set_vq_num = mlx5_vdpa_set_vq_num,@@ -2352,8 +2359,9 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = { .get_vq_notification = mlx5_get_vq_notification, .get_vq_irq = mlx5_get_vq_irq, .get_vq_align = mlx5_vdpa_get_vq_align, - .get_features = mlx5_vdpa_get_features, - .set_features = mlx5_vdpa_set_features, + .get_device_features = mlx5_vdpa_get_device_features, + .set_driver_features = mlx5_vdpa_set_driver_features, + .get_driver_features = mlx5_vdpa_get_driver_features, .set_config_cb = mlx5_vdpa_set_config_cb, .get_vq_num_max = mlx5_vdpa_get_vq_num_max, .get_device_id = mlx5_vdpa_get_device_id,drivers/vdpa/vdpa.c +1
-1@@ -808,7 +808,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_features (vdev); + features = vdev->config->get_driver_features (vdev);return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); }drivers/vdpa/vdpa_sim/vdpa_sim.c +15
-6@@ -399,14 +399,14 @@ static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)return VDPASIM_QUEUE_ALIGN ; } -static u64 vdpasim_get_features (struct vdpa_device *vdpa) +static u64 vdpasim_get_device_features (struct vdpa_device *vdpa) {struct vdpasim *vdpasim =vdpa_to_sim (vdpa);return vdpasim->dev_attr.supported_features; } -static int vdpasim_set_features (struct vdpa_device *vdpa,u64 features) +static int vdpasim_set_driver_features (struct vdpa_device *vdpa,u64 features) {struct vdpasim *vdpasim =vdpa_to_sim (vdpa);@@ -419,6 +419,13 @@ static int vdpasim_set_features(struct vdpa_device *vdpa, u64 features)return 0 ; } +static u64 vdpasim_get_driver_features (struct vdpa_device *vdpa) +{ +struct vdpasim *vdpasim =vdpa_to_sim (vdpa); + +return vdpasim->features; +} +static void vdpasim_set_config_cb (struct vdpa_device *vdpa,struct vdpa_callback *cb) {@@ -613,8 +620,9 @@ static const struct vdpa_config_ops vdpasim_config_ops = { .set_vq_state = vdpasim_set_vq_state, .get_vq_state = vdpasim_get_vq_state, .get_vq_align = vdpasim_get_vq_align, - .get_features = vdpasim_get_features, - .set_features = vdpasim_set_features, + .get_device_features = vdpasim_get_device_features, + .set_driver_features = vdpasim_set_driver_features, + .get_driver_features = vdpasim_get_driver_features, .set_config_cb = vdpasim_set_config_cb, .get_vq_num_max = vdpasim_get_vq_num_max, .get_device_id = vdpasim_get_device_id,@@ -642,8 +650,9 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = { .set_vq_state = vdpasim_set_vq_state, .get_vq_state = vdpasim_get_vq_state, .get_vq_align = vdpasim_get_vq_align, - .get_features = vdpasim_get_features, - .set_features = vdpasim_set_features, + .get_device_features = vdpasim_get_device_features, + .set_driver_features = vdpasim_set_driver_features, + .get_driver_features = vdpasim_get_driver_features, .set_config_cb = vdpasim_set_config_cb, .get_vq_num_max = vdpasim_get_vq_num_max, .get_device_id = vdpasim_get_device_id,drivers/vdpa/vdpa_user/vduse_dev.c +12
-4@@ -573,14 +573,14 @@ static u32 vduse_vdpa_get_vq_align(struct vdpa_device *vdpa)return dev->vq_align; } -static u64 vduse_vdpa_get_features (struct vdpa_device *vdpa) +static u64 vduse_vdpa_get_device_features (struct vdpa_device *vdpa) {struct vduse_dev *dev =vdpa_to_vduse (vdpa);return dev->device_features; } -static int vduse_vdpa_set_features (struct vdpa_device *vdpa,u64 features) +static int vduse_vdpa_set_driver_features (struct vdpa_device *vdpa,u64 features) {struct vduse_dev *dev =vdpa_to_vduse (vdpa);@@ -588,6 +588,13 @@ static int vduse_vdpa_set_features(struct vdpa_device *vdpa, u64 features)return 0 ; } +static u64 vduse_vdpa_get_driver_features (struct vdpa_device *vdpa) +{ +struct vduse_dev *dev =vdpa_to_vduse (vdpa); + +return dev->driver_features; +} +static void vduse_vdpa_set_config_cb (struct vdpa_device *vdpa,struct vdpa_callback *cb) {@@ -721,8 +728,9 @@ static const struct vdpa_config_ops vduse_vdpa_config_ops = { .set_vq_state = vduse_vdpa_set_vq_state, .get_vq_state = vduse_vdpa_get_vq_state, .get_vq_align = vduse_vdpa_get_vq_align, - .get_features = vduse_vdpa_get_features, - .set_features = vduse_vdpa_set_features, + .get_device_features = vduse_vdpa_get_device_features, + .set_driver_features = vduse_vdpa_set_driver_features, + .get_driver_features = vduse_vdpa_get_driver_features, .set_config_cb = vduse_vdpa_set_config_cb, .get_vq_num_max = vduse_vdpa_get_vq_num_max, .get_device_id = vduse_vdpa_get_device_id,drivers/vdpa/virtio_pci/vp_vdpa.c +12
-4@@ -53,14 +53,14 @@ static struct virtio_pci_modern_device *vdpa_to_mdev(struct vdpa_device *vdpa)return &vp_vdpa->mdev; } -static u64 vp_vdpa_get_features (struct vdpa_device *vdpa) +static u64 vp_vdpa_get_device_features (struct vdpa_device *vdpa) {struct virtio_pci_modern_device *mdev =vdpa_to_mdev (vdpa);return vp_modern_get_features (mdev); } -static int vp_vdpa_set_features (struct vdpa_device *vdpa,u64 features) +static int vp_vdpa_set_driver_features (struct vdpa_device *vdpa,u64 features) {struct virtio_pci_modern_device *mdev =vdpa_to_mdev (vdpa);@@ -69,6 +69,13 @@ static int vp_vdpa_set_features(struct vdpa_device *vdpa, u64 features)return 0 ; } +static u64 vp_vdpa_get_driver_features (struct vdpa_device *vdpa) +{ +struct virtio_pci_modern_device *mdev =vdpa_to_mdev (vdpa); + +return vp_modern_get_driver_features (mdev); +} +static u8 vp_vdpa_get_status (struct vdpa_device *vdpa) {struct virtio_pci_modern_device *mdev =vdpa_to_mdev (vdpa);@@ -415,8 +422,9 @@ vp_vdpa_get_vq_notification(struct vdpa_device *vdpa, u16 qid) }static const struct vdpa_config_ops vp_vdpa_ops = { - .get_features = vp_vdpa_get_features, - .set_features = vp_vdpa_set_features, + .get_device_features = vp_vdpa_get_device_features, + .set_driver_features = vp_vdpa_set_driver_features, + .get_driver_features = vp_vdpa_get_driver_features, .get_status = vp_vdpa_get_status, .set_status = vp_vdpa_set_status, .reset = vp_vdpa_reset,drivers/vhost/vdpa.c +1
-1@@ -262,7 +262,7 @@ static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *featurep)const struct vdpa_config_ops *ops = vdpa->config;u64 features; - features = ops->get_features (vdpa); + features = ops->get_device_features (vdpa);if (copy_to_user (featurep, &features,sizeof (features)))return -EFAULT ;drivers/virtio/virtio_vdpa.c +1
-1@@ -308,7 +308,7 @@ static u64 virtio_vdpa_get_features(struct virtio_device *vdev)struct vdpa_device *vdpa =vd_get_vdpa (vdev);const struct vdpa_config_ops *ops = vdpa->config; -return ops->get_features (vdpa); +return ops->get_device_features (vdpa); }static int virtio_vdpa_finalize_features (struct virtio_device *vdev)include/linux/vdpa.h +9
-6@@ -171,14 +171,17 @@ struct vdpa_map_file {* for the device * @vdev: vdpa device * Returns virtqueue algin requirement -* @get_features: Get virtio features supported by the device +* @get_device_features: Get virtio features supported by the device * @vdev: vdpa device * Returns the virtio features support by the * device -* @set_features: Set virtio features supported by the driver +* @set_driver_features: Set virtio features supported by the driver * @vdev: vdpa device * @features: feature support by the driver * Returns integer: success (0) or error (< 0) +* @get_driver_features: Get the virtio driver features in action +* @vdev: vdpa device +* Returns the virtio features accepted * @set_config_cb: Set the config interrupt callback * @vdev: vdpa device * @cb: virtio-vdev interrupt callback structure @@ -278,8 +281,9 @@ struct vdpa_config_ops {/* Device ops */ u32 (*get_vq_align)(struct vdpa_device *vdev); -u64 (*get_features)(struct vdpa_device *vdev); -int (*set_features)(struct vdpa_device *vdev,u64 features); +u64 (*get_device_features)(struct vdpa_device *vdev); +int (*set_driver_features)(struct vdpa_device *vdev,u64 features); +u64 (*get_driver_features)(struct vdpa_device *vdev);void (*set_config_cb)(struct vdpa_device *vdev,struct vdpa_callback *cb);u16 (*get_vq_num_max)(struct vdpa_device *vdev);@@ -397,7 +401,7 @@ static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features)const struct vdpa_config_ops *ops = vdev->config; vdev->features_valid = true; -return ops->set_features (vdev, features); +return ops->set_driver_features (vdev, features); } void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset, --
Quoted 2 lines
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jason Wang
Acked-byRe: [PATCH v3 02/10] vdpa/mlx5: Distribute RX virtqueues in RQT object
Quoted 9 lines · Eli Cohen
Distribute the available rx virtqueues amongst the available RQT entries.
RQTs require to have a power of two entries. When creating or modifying the RQT, use the lowest number of power of two entries that is not less than the number of rx virtqueues. Distribute them in the available entries such that some virtqueus may be referenced twice.
Quoted 6 lines
This allows to configure any number of virtqueue pairs when multiqueue is used.
Reviewed-by Si-Wei Liu <[email protected]>Signed-off-by Eli Cohen <[email protected]>---
Quoted 68 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-)drivers/vdpa/mlx5/net/mlx5_vnet.c +7
-24@@ -1261,17 +1261,10 @@ static int create_rqt(struct mlx5_vdpa_net *ndev)MLX5_SET (rqtc, rqtc, list_q_type,MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q );MLX5_SET (rqtc, rqtc, rqt_max_size, max_rqt); list =MLX5_ADDR_OF (rqtc, rqtc, rq_num[0 ]); -for (i =0 , j =0 ; j < max_rqt; j++) { -if (!ndev->vqs[j].initialized) -continue ; - -if (!vq_is_tx (ndev->vqs[j].index)) { - list[i] =cpu_to_be32 (ndev->vqs[j].virtq_id); - i++; - } - } -MLX5_SET (rqtc, rqtc, rqt_actual_size, i); +for (i =0 , j =0 ; i < max_rqt; i++, j +=2 ) + list[i] =cpu_to_be32 (ndev->vqs[j % ndev->mvdev.max_vqs].virtq_id); +MLX5_SET (rqtc, rqtc, rqt_actual_size, max_rqt); err =mlx5_vdpa_create_rqt (&ndev->mvdev, in, inlen, &ndev->res.rqtn);kfree (in);if (err)@@ -1292,7 +1285,7 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num)int i, j;int err; - max_rqt =min_t (int, ndev->cur_num_vqs /2 , + max_rqt =min_t (int,roundup_pow_of_two (ndev->cur_num_vqs /2 ),1 <<MLX5_CAP_GEN (ndev->mvdev.mdev, log_max_rqt_size));if (max_rqt <1 )return -EOPNOTSUPP ;@@ -1308,16 +1301,10 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num)MLX5_SET (rqtc, rqtc, list_q_type,MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q ); list =MLX5_ADDR_OF (rqtc, rqtc, rq_num[0 ]); -for (i =0 , j =0 ; j < num; j++) { -if (!ndev->vqs[j].initialized) -continue ; +for (i =0 , j =0 ; i < max_rqt; i++, j +=2 ) + list[i] =cpu_to_be32 (ndev->vqs[j % num].virtq_id); -if (!vq_is_tx (ndev->vqs[j].index)) { - list[i] =cpu_to_be32 (ndev->vqs[j].virtq_id); - i++; - } - } -MLX5_SET (rqtc, rqtc, rqt_actual_size, i); +MLX5_SET (rqtc, rqtc, rqt_actual_size, max_rqt); err =mlx5_vdpa_modify_rqt (&ndev->mvdev, in, inlen, ndev->res.rqtn);kfree (in);if (err)@@ -1581,9 +1568,6 @@ static virtio_net_ctrl_ack handle_ctrl_mq(struct mlx5_vdpa_dev *mvdev, u8 cmd)break ; } -if (newqps & (newqps -1 )) -break ; -if (!change_num_qps (mvdev, newqps)) status =VIRTIO_NET_OK ; --
Quoted 2 lines
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 03/10] vdpa: Read device configuration only if FEATURES_OK
Quoted 17 lines · Eli Cohen
Avoid reading device configuration during feature negotiation. Read device status and verify that
VIRTIO_CONFIG_S_FEATURES_OKis set. Otherwise, return-EAGAIN.Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/vdpa.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/vdpa/vdpa.c +0
-0@@ -819,8 +819,15 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, {u32 device_id;
drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 830
Quoted 10 lines
drivers/vdpa/vdpa.c +7
-0void *hdr; +u8 status;int err; + status = vdev->config->get_status (vdev); +if (!(status &VIRTIO_CONFIG_S_FEATURES_OK )) { +NL_SET_ERR_MSG_MOD (extack,"Features negotiation not completed" ); +return -EAGAIN ; + } +
I wonder how we synchronize this with set_status(), set/get_config()?
Thanks
Quoted 6 lines
drivers/vdpa/vdpa.c +0
-1hdr =genlmsg_put (msg, portid, seq, &vdpa_nl_family, flags,VDPA_CMD_DEV_CONFIG_GET );if (!hdr) --2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 03/10] vdpa: Read device configuration only if FEATURES_OK
Quoted 34 lines · Eli Cohen
Quoted 22 lines · Jason Wang
Quoted 21 lines · Eli Cohen
Avoid reading device configuration during feature negotiation. Read device status and verify that
VIRTIO_CONFIG_S_FEATURES_OKis set. Otherwise, return-EAGAIN.Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/vdpa.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/vdpa/vdpa.c +1
-0@@ -819,8 +819,15 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, {u32 device_id;void *hdr; +u8 status;int err;Quoted 9 lines
drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 830
Quoted 6 lines
drivers/vdpa/vdpa.c +6
-0+ status = vdev->config->get_status (vdev); +if (!(status &VIRTIO_CONFIG_S_FEATURES_OK )) { +NL_SET_ERR_MSG_MOD (extack,"Features negotiation not completed" ); +return -EAGAIN ; + } +I wonder how we synchronize this with
set_status(), set/get_config()?
Quoted 1 line
Not sure why set/get_config() is related to this.
I think guest may trigger set_config() while we are at vdpa_dev_config_fill(), this will lead to inconsistent values.
Quoted 3 lines
How about each upstream driver will take care to have a lock that serializes
set_status()withget_driver_features()to guarantee that we always provide valid features?
Yes and it looks like we've already had a per device cf_mutex, how about simply use this?
Thanks
Quoted 11 lines
Quoted 10 lines
Thanks
Quoted 6 lines
drivers/vdpa/vdpa.c +0
-1hdr =genlmsg_put (msg, portid, seq, &vdpa_nl_family, flags,VDPA_CMD_DEV_CONFIG_GET );if (!hdr) --2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 03/10] vdpa: Read device configuration only if FEATURES_OKg
Quoted 52 lines · Eli Cohen
Quoted 40 lines · Jason Wang
Quoted 34 lines · Eli Cohen
Quoted 22 lines · Jason Wang
Quoted 21 lines · Eli Cohen
Avoid reading device configuration during feature negotiation. Read device status and verify that
VIRTIO_CONFIG_S_FEATURES_OKis set. Otherwise, return-EAGAIN.Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/vdpa.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/vdpa/vdpa.c +1
-0@@ -819,8 +819,15 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, {u32 device_id;void *hdr; +u8 status;int err;Quoted 9 lines
drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 830
Quoted 6 lines
drivers/vdpa/vdpa.c +6
-0+ status = vdev->config->get_status (vdev); +if (!(status &VIRTIO_CONFIG_S_FEATURES_OK )) { +NL_SET_ERR_MSG_MOD (extack,"Features negotiation not completed" ); +return -EAGAIN ; + } +I wonder how we synchronize this with
set_status(), set/get_config()?Quoted 1 line
Not sure why set/get_config() is related to this.
I think guest may trigger
set_config()while we are atvdpa_dev_config_fill(), this will lead to inconsistent values.Quoted 6 lines
Quoted 3 lines
How about each upstream driver will take care to have a lock that serializes
set_status()withget_driver_features()to guarantee that we always provide valid features?Yes and it looks like we've already had a per device
cf_mutex, how about simply use this?Maybe do it in one place. For example, for vhost, in
drivers/vhost/vdpa.c:
Quoted 8 lines
mutex_lock(&vdpa->cf_mutex);ops->set_status(vdpa, status);mutex_unlock(&vdpa->cf_mutex);same for
drivers/virtio/virtio_vdpa.cOVerall,
set_status,get_status,set_config,get_configshould be protected.
Yes, maybe we can introduce new helpers in vdpa.c.
Thanks
Quoted 8 lines
Quoted 8 lines
Thanks
Quoted 3 lines
Quoted 3 lines
Thanks
Quoted 10 lines
Quoted 9 lines
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
drivers/vdpa/vdpa.c +0
-1hdr =genlmsg_put (msg, portid, seq, &vdpa_nl_family, flags,VDPA_CMD_DEV_CONFIG_GET );if (!hdr) --2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jason Wang
Acked-byRe: [PATCH v3 04/10] vdpa: Allow to configure max data virtqueues
Quoted 5 lines · Eli Cohen
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 <[email protected]>
Quoted 53 lines
---
V2 -> V3:
Fix error flowdrivers/vdpa/vdpa.c | 13 ++++++++++++- include/linux/vdpa.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-)drivers/vdpa/vdpa.c +12
-1@@ -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 *inla_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 include/linux/vdpa.h +1
-1@@ -101,6 +101,7 @@ struct vdpa_dev_set_config {struct {u8 mac[ETH_ALEN ];u16 mtu; +u16 max_vq_pairs; } net;u64 mask; }; --
Quoted 2 lines
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 07/10] vdpa: Add support for returning device configuration information
Quoted 41 lines · 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.
Example:
$ 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 features c3182bc3182b CSUM GUEST_CSUM MTU MAC HOST_TSO4 HOST_TSO6 STATUS VERSION_1 \ ACCESS_PLATFORMSigned-off-by Eli Cohen <[email protected]>----
V2 -> V3
1. Move attribute definition to end of enum definition
2. Return the entire negotiated features bit mask--- drivers/vdpa/vdpa.c | 3 +++ include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 7 insertions(+)drivers/vdpa/vdpa.c +3
-0@@ -820,6 +820,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msreturn -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); }include/uapi/linux/vdpa.h +0
-0
include/uapi/linux/vdpa.h enum vdpa_command { · line 28
Quoted 6 lines
include/uapi/linux/vdpa.h +3
-0@@ -23,6 +23,9 @@ enum vdpa_command {enum vdpa_attr {VDPA_ATTR_UNSPEC , +/* Pad attribute for 64b alignment */ +VDPA_ATTR_PAD =VDPA_ATTR_UNSPEC , +
I may miss something, but will this lead to a change in the existing ABI?
Thanks
Quoted 12 lines
include/uapi/linux/vdpa.h +1
-1/* 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, }; --
Quoted 2 lines
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jason Wang
Acked-byRe: [PATCH v3 07/10] vdpa: Add support for returning device configuration information
Quoted 55 lines · Eli Cohen
Quoted 53 lines · Eli Cohen
Quoted 51 lines · Jason Wang
Quoted 41 lines · 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.
Example:
$ 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 features c3182bc3182b CSUM GUEST_CSUM MTU MAC HOST_TSO4 HOST_TSO6 STATUS VERSION_1 \ ACCESS_PLATFORMSigned-off-by Eli Cohen <[email protected]>----
V2 -> V3
1. Move attribute definition to end of enum definition
2. Return the entire negotiated features bit mask--- drivers/vdpa/vdpa.c | 3 +++ include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 7 insertions(+)drivers/vdpa/vdpa.c +3
-0@@ -820,6 +820,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msreturn -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); }include/uapi/linux/vdpa.h +0
-0include/uapi/linux/vdpa.h enum vdpa_command { · line 28
Quoted 6 lines
include/uapi/linux/vdpa.h +3
-0@@ -23,6 +23,9 @@ enum vdpa_command {enum vdpa_attr {VDPA_ATTR_UNSPEC , +/* Pad attribute for 64b alignment */ +VDPA_ATTR_PAD =VDPA_ATTR_UNSPEC , +I may miss something, but will this lead to a change in the existing ABI?
Quoted 6 lines
Quoted 2 lines
You're right.
I think it can be moved to the end of the enumActuall, it's OK. It does not change the other enum values and it can't be moved to the end because it will corrupt the enumeration of
VDPA_ATTR_MAX
Right.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Thanks
Quoted 7 lines
include/uapi/linux/vdpa.h +0
-0/* 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 */
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/vdpa.h +1
-1+VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ /* new attributes must be added above here */ VDPA_ATTR_MAX, }; --2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 09/10] vdpa/mlx5: Configure max supported virtqueues
Quoted 6 lines · Eli Cohen
Configure max supported virtqueues on the management device. This info can be retrieved using:
$ vdpa dev show vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \ max_vqp 3 max_vq_size 256 max_supported_vqs 256
I still think we should report 257 here to be aligned with the spec even if we know cvq is probably emulated.
Quoted 11 lines
Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 + 1 file changed, 1 insertion(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5v_probe(struct auxiliary_device *adev, · line 2692
Quoted 4 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0@@ -2689,6 +2689,7 @@ static int mlx5v_probe(struct auxiliary_device *adev, mgtdev->mgtdev.id_table = id_table; mgtdev->mgtdev.config_attr_mask =BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MACADDR ) |BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MAX_VQP ); + mgtdev->mgtdev.max_supported_vqs =MLX5_CAP_DEV_VDPA_EMULATION (mdev, max_num_virtio_queues);
Do we need to change other vdpa parent like the simulator and ifcvf?
Thanks
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5v_probe(struct auxiliary_device *adev, · line 2695
Quoted 3 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0mgtdev->madev = madev; err =vdpa_mgmtdev_register (&mgtdev->mgtdev);
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 09/10] vdpa/mlx5: Configure max supported virtqueues
Quoted 12 lines · Eli Cohen
Quoted 10 lines · Jason Wang
Quoted 6 lines · Eli Cohen
Configure max supported virtqueues on the management device. This info can be retrieved using:
$ vdpa dev show vdpa-a: type network mgmtdev auxiliary/mlx5_core.sf.1 vendor_id 5555 \ max_vqp 3 max_vq_size 256 max_supported_vqs 256
Quoted 4 lines
Quoted 2 lines
I still think we should report 257 here to be aligned with the spec even if we know cvq is probably emulated.
OK, you mean report 257 for
max_supported_vqs?
Yes.
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 + 1 file changed, 1 insertion(+)Quoted 13 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5v_probe(struct auxiliary_device *adev, · line 2692
Quoted 9 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0@@ -2689,6 +2689,7 @@ static int mlx5v_probe(struct auxiliary_device *adev, mgtdev->mgtdev.id_table = id_table; mgtdev->mgtdev.config_attr_mask =BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MACADDR ) |BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MAX_VQP ); + mgtdev->mgtdev.max_supported_vqs =MLX5_CAP_DEV_VDPA_EMULATION (mdev, max_num_virtio_queues);Do we need to change other vdpa parent like the simulator and ifcvf?
Quoted 2 lines
I can change for the simulator but not sure I know how to do it for ifcvf or other drivers.
Adding LingShan to answer this question.
And we don't need to care about eni and vp_vdpa now since they don't support mgmt devices yet.
Thanks
Quoted 8 lines
Quoted 7 lines
Thanks
Quoted 2 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0mgtdev->madev = madev; err =vdpa_mgmtdev_register (&mgtdev->mgtdev);
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 10/10] vdpa: Use BIT_ULL for bit operations
Quoted 6 lines · Eli Cohen
All masks in this file are 64 bits. Change BIT to
BIT_ULL.Other occurences use (1 << val) which yields a 32 bit value. Change them to use
BIT_ULLtoo.
It looks to me the patch was squashed with vendor specific stats extension unexpectedly.
Thanks
Quoted 270 lines
Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/vdpa.c | 154 ++++++++++++++++++++++++++++++++++++-- include/linux/vdpa.h | 10 +++ include/uapi/linux/vdpa.h | 7 ++ 3 files changed, 166 insertions(+), 5 deletions(-)drivers/vdpa/vdpa.c +149
-5@@ -554,9 +554,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)return msg->len; } -#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_MAX_VQP)) +#define VDPA_DEV_NET_ATTRS_MASK (BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR) | \ + BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) | \ + BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))static int vdpa_nl_cmd_dev_add_set_doit (struct sk_buff *skb,struct genl_info *info) {@@ -575,12 +575,12 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *iif (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MACADDR ]) { macaddr =nla_data (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MACADDR ]);memcpy (config.net.mac, macaddr,sizeof (config.net.mac)); - config.mask |= (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR ); + config.mask |=BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MACADDR ); }if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MTU ]) { config.net.mtu =nla_get_u16 (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MTU ]); - config.mask |= (1 <<VDPA_ATTR_DEV_NET_CFG_MTU ); + config.mask |=BIT_ULL (VDPA_ATTR_DEV_NET_CFG_MTU ); }if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MAX_VQP ]) { config.net.max_vq_pairs =@@ -879,6 +879,90 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,return err; } +static int vdpa_fill_stats_rec (struct vdpa_device *vdev,struct sk_buff *msg,u16 *index) +{ +struct vdpa_vq_stats stats; +u16 idx = *index; +int err; + + err = vdev->config->get_vq_stats (vdev, index, &stats); +if (err) +return err; + +if (nla_put_u16 (msg,VDPA_ATTR_DEV_QUEUE_INDEX , idx)) +return -EMSGSIZE ; + +if (nla_put_u16 (msg,VDPA_ATTR_DEV_QUEUE_CTRL , !!stats.ctrl_vq)) +return -EMSGSIZE ; + +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_VENDOR_RECEIVED_DESC , stats.received_desc, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_VENDOR_COMPLETED_DESC , stats.completed_desc, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + +return 0 ; +} + +static int vdpa_dev_net_stats_fill (struct vdpa_device *vdev,struct sk_buff *msg,u16 index) +{ +int err; + +if (!vdev->config->get_vq_stats) +return -EOPNOTSUPP ; + +if (index !=VDPA_INVAL_QUEUE_INDEX ) { + err =vdpa_fill_stats_rec (vdev, msg, &index); +if (err) +return err; + }else { + index =0 ; +do { + err =vdpa_fill_stats_rec (vdev, msg, &index); +if (err) +return err; + }while (index !=VDPA_INVAL_QUEUE_INDEX ); + } + +return 0 ; +} + +static int vdpa_dev_stats_fill (struct vdpa_device *vdev,struct sk_buff *msg,u32 portid, +u32 seq,int flags,u16 index) +{ +u32 device_id; +void *hdr; +int err; + + hdr =genlmsg_put (msg, portid, seq, &vdpa_nl_family, flags, +VDPA_CMD_DEV_VSTATS_GET ); +if (!hdr) +return -EMSGSIZE ; + +if (nla_put_string (msg,VDPA_ATTR_DEV_NAME ,dev_name (&vdev->dev))) { + err = -EMSGSIZE ; + goto undo_msg; + } + + device_id = vdev->config->get_device_id (vdev); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_ID , device_id)) { + err = -EMSGSIZE ; + goto undo_msg; + } + + err =vdpa_dev_net_stats_fill (vdev, msg, index); + +genlmsg_end (msg, hdr); + +return err; + +undo_msg: +genlmsg_cancel (msg, hdr); +return err; +} +static int vdpa_nl_cmd_dev_config_get_doit (struct sk_buff *skb,struct genl_info *info) {struct vdpa_device *vdev;@@ -960,6 +1044,59 @@ vdpa_nl_cmd_dev_config_get_dumpit(struct sk_buff *msg, struct netlink_callback *return msg->len; } +static int vdpa_nl_cmd_dev_stats_get_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct vdpa_device *vdev; +struct sk_buff *msg; +const char *devname; +struct device *dev; +u16 index =-1 ; +int err; + +if (!info->attrs[VDPA_ATTR_DEV_NAME ]) +return -EINVAL ; + +if (info->attrs[VDPA_ATTR_DEV_QUEUE_INDEX ]) + index =nla_get_u16 (info->attrs[VDPA_ATTR_DEV_QUEUE_INDEX ]); + + devname =nla_data (info->attrs[VDPA_ATTR_DEV_NAME ]); + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + +mutex_lock (&vdpa_dev_mutex); + dev =bus_find_device (&vdpa_bus,NULL , devname, vdpa_name_match); +if (!dev) { +NL_SET_ERR_MSG_MOD (info->extack,"device not found" ); + err = -ENODEV ; + goto dev_err; + } + vdev = container_of(dev, struct vdpa_device, dev); +if (!vdev->mdev) { +NL_SET_ERR_MSG_MOD (info->extack,"unmanaged vdpa device" ); + err = -EINVAL ; + goto mdev_err; + } + err =vdpa_dev_stats_fill (vdev, msg, info->snd_portid, info->snd_seq,0 , index); +if (!err) + err =genlmsg_reply (msg, info); + +put_device (dev); +mutex_unlock (&vdpa_dev_mutex); + +if (err) +nlmsg_free (msg); + +return err; + +mdev_err: +put_device (dev); +dev_err: +mutex_unlock (&vdpa_dev_mutex); +return err; +} +static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX +1 ] = { [VDPA_ATTR_MGMTDEV_BUS_NAME ] = { .type =NLA_NUL_STRING }, [VDPA_ATTR_MGMTDEV_DEV_NAME ] = { .type =NLA_STRING },@@ -967,6 +1104,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_NET_CFG_MACADDR ] =NLA_POLICY_ETH_ADDR , /* virtio spec 1.1 section 5.1.4.1 for valid MTU range */ [VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68), + [VDPA_ATTR_DEV_QUEUE_INDEX] = NLA_POLICY_RANGE(NLA_U16, 0, 32767), };static const struct genl_ops vdpa_nl_ops[] = {@@ -1000,6 +1138,12 @@ static const struct genl_ops vdpa_nl_ops[] = { .doit = vdpa_nl_cmd_dev_config_get_doit, .dumpit = vdpa_nl_cmd_dev_config_get_dumpit, }, + { + .cmd = VDPA_CMD_DEV_VSTATS_GET, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = vdpa_nl_cmd_dev_stats_get_doit, + .flags = GENL_ADMIN_PERM, + }, };static struct genl_family vdpa_nl_family__ro_after_init = {include/linux/vdpa.h +10
-0@@ -58,6 +58,12 @@ struct vdpa_vq_state { }; }; +struct vdpa_vq_stats { +u64 received_desc; +u64 completed_desc; +bool ctrl_vq; +}; +struct vdpa_mgmt_dev ;/** @@ -275,6 +281,8 @@ struct vdpa_config_ops { const struct vdpa_vq_state *state);int (*get_vq_state)(struct vdpa_device *vdev,u16 idx,struct vdpa_vq_state *state); +int (*get_vq_stats)(struct vdpa_device *vdev,u16 *idx, +struct vdpa_vq_stats *stats);struct vdpa_notification_area (*get_vq_notification)(struct vdpa_device *vdev,u16 idx);/* vq irq is not expected to be changed once DRIVER_OK is set */ @@ -451,4 +459,6 @@ struct vdpa_mgmt_dev {int vdpa_mgmtdev_register (struct vdpa_mgmt_dev *mdev);void vdpa_mgmtdev_unregister (struct vdpa_mgmt_dev *mdev); +#define VDPA_INVAL_QUEUE_INDEX 0xffff +#endif /* _LINUX_VDPA_H */ include/uapi/linux/vdpa.h +7
-1@@ -18,6 +18,7 @@ enum vdpa_command {VDPA_CMD_DEV_DEL ,VDPA_CMD_DEV_GET ,/* can dump */ VDPA_CMD_DEV_CONFIG_GET ,/* can dump */ + VDPA_CMD_DEV_VSTATS_GET, }; enum vdpa_attr {@@ -45,6 +46,12 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MAX_DEV_VQS ,/* u16 */ + +VDPA_ATTR_DEV_QUEUE_INDEX ,/* u16 */ +VDPA_ATTR_DEV_QUEUE_CTRL ,/* u16 */ +VDPA_ATTR_DEV_VENDOR_RECEIVED_DESC ,/* u64 */ +VDPA_ATTR_DEV_VENDOR_COMPLETED_DESC ,/* u64 */ +/* new attributes must be added above here */ VDPA_ATTR_MAX, }; --
Quoted 2 lines
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization