vdpa: Add support for querying vendor statistics
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]
Quoted 36 lines · Eli Cohen
Allows to read vendor statistics of vdpa device. The specific statistics data is received by the upstream driver in the form of an attribute name/attribute value pairs.
An example of statistics for
mlx5_vdpadevice are:
received_desc- number of descriptors received by the virtqueuecompleted_desc- number of descriptors completed by the virtqueueA descriptors using indirect buffers is still counted as 1. In addition, N chained descriptors are counted correctly N times as one would expect.
A new callback was added to
vdpa_config_opswhich provides the means for the vdpa driver to return statistics results.The interface allows for reading all the supported virtqueues, including the control virtqueue if it exists.
Examples:
1. Read statistics for the virtqueue at index 1$ vdpa dev vstats show vdpa-a qidx 1 vdpa-a: qtype tx qidx 1 received_desc 4583367 completed_desc 45833672. Read statistics for the virtqueue at index 32
$ vdpa dev vstats show vdpa-a qidx 32 vdpa-a: qtype cvq qidx 32 received_desc 0 completed_desc 03. Read statisitics for the virtqueue at index 0 with json output
$ vdpa -j dev vstats show vdpa-a qidx 0 {"vstats":{"vdpa-a":{ "qtype":"rx","qidx":0,"name":"received_desc","value":490205,"name":"completed_desc","value":489964}}}
Quoted 8 lines
4. Read statistics for the virtqueue at index 0 with preety json output
$ vdpa -jp dev vstats show vdpa-a qidx 0 { "vstats": { "vdpa-a": {"qtype": "rx", "qidx": 0,
I wonder if it's better not to use abbreviations in at least json outputs.
Quoted 4 lines
"name": "received_desc",
"value": 490205,
"name": "completed_desc",
"value": 489964Are those counters going back to zero during a vDPA reset?
Quoted 16 lines
} } }Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/vdpa.c | 128 ++++++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 10 +++ include/uapi/linux/vdpa.h | 7 +++ 3 files changed, 145 insertions(+)drivers/vdpa/vdpa.c +0
-0
drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 910
Quoted 2 lines
drivers/vdpa/vdpa.c +0
-0@@ -909,6 +909,73 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,return err; }
Note related to this patch, but I think it's better to split out netlink logic into a dedicated c file (e.g netlink.c in drivers/vdpa)
Quoted 8 lines
drivers/vdpa/vdpa.c +7
-0+static int vdpa_fill_stats_rec (struct vdpa_device *vdev,struct sk_buff *msg, +struct genl_info *info,u16 index) +{ +int err; + +if (nla_put_u16 (msg,VDPA_ATTR_DEV_QUEUE_INDEX , index)) +return -EMSGSIZE ;
drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 927
Quoted 10 lines
drivers/vdpa/vdpa.c +10
-0+ + err = vdev->config->get_vq_stats (vdev, index, msg, info->extack); +if (err) +return err; + +return 0 ; +} + +static int vdpa_dev_net_stats_fill (struct vdpa_device *vdev,struct sk_buff *msg, +struct genl_info *info,u16 index)
This function looks not specific to net, I guess other types of device can use this as well? (Especially consider we put device id in the skb)
Quoted 6 lines
drivers/vdpa/vdpa.c +6
-0+{ +int err; + +if (!vdev->config->get_vq_stats) +return -EOPNOTSUPP ; +
drivers/vdpa/vdpa.c vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, · line 943
Quoted 10 lines
drivers/vdpa/vdpa.c +10
-0+ err =vdpa_fill_stats_rec (vdev, msg, info, index); +if (err) +return err; + +return 0 ; +} + +static int vdpa_dev_stats_fill (struct vdpa_device *vdev,struct sk_buff *msg, +struct genl_info *info,u16 index) +{
Considering there will be standard virtio stats to be supported in the future, I'd like to name this as vdpa_dev_vendor_stats_fill().
Quoted 99 lines
drivers/vdpa/vdpa.c +88
-0+u32 device_id; +void *hdr; +int err; +u32 portid = info->snd_portid; +u32 seq = info->snd_seq; +u32 flags =0 ; + + 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, info, 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;@@ -990,6 +1057,60 @@ 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 ]) +return -EINVAL ; + + devname =nla_data (info->attrs[VDPA_ATTR_DEV_NAME ]); + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + index =nla_get_u16 (info->attrs[VDPA_ATTR_DEV_QUEUE_INDEX ]); +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, 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 },
drivers/vdpa/vdpa.c static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = { · line 1121
Quoted 4 lines
drivers/vdpa/vdpa.c +1
-0@@ -997,6 +1118,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),
Any reason for choosing 32767 here, spec allows up to 0-65535 as queue index.
Quoted 21 lines
drivers/vdpa/vdpa.c +6
-0};static const struct genl_ops vdpa_nl_ops[] = {@@ -1030,6 +1152,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 +0
-0
include/linux/vdpa.h struct vdpa_vq_state { · line 65
Quoted 8 lines
include/linux/vdpa.h +5
-0@@ -58,6 +58,12 @@ struct vdpa_vq_state { }; }; +struct vdpa_vq_stats { +u64 received_desc; +u64 completed_desc; +bool ctrl_vq; +};
This seems to be a vendor specific stats, any chance to move it to the mlx5 directory?
include/linux/vdpa.h struct vdpa_config_ops { · line 285
Quoted 10 lines
include/linux/vdpa.h +3
-0+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 sk_buff *msg, +struct netlink_ext_ack *extack);
I think it's better to rename this as get_vendor_vq_stats().
Thanks
Quoted 36 lines
include/linux/vdpa.h +2
-0struct 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 */ @@ -466,4 +474,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 {@@ -46,6 +47,12 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ VDPA_ATTR_DEV_SUPPORTED_FEATURES ,/* u64 */ + +VDPA_ATTR_DEV_QUEUE_INDEX ,/* u16 */ +VDPA_ATTR_DEV_QUEUE_TYPE ,/* string */ +VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ +VDPA_ATTR_DEV_VENDOR_ATTR_VALUE ,/* 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]
Re: [PATCH 2/2] vdpa/mlx5: Add support for reading descriptor statistics
Quoted 43 lines · Eli Cohen
Implement the
get_vq_statscalback ofvdpa_config_opsto return the statistics for a virtqueue.The statistics are provided as vendor specific statistics where the driver provides a pair of attribute name and attribute value.
Currently supported are received descriptors and completed descriptors.
Signed-off-by Eli Cohen <[email protected]>--- drivers/vdpa/mlx5/core/mlx5_vdpa.h | 2 + drivers/vdpa/mlx5/net/mlx5_vnet.c | 154 +++++++++++++++++++++++++++++ include/linux/mlx5/mlx5_ifc.h | 1 + include/linux/mlx5/mlx5_ifc_vdpa.h | 39 ++++++++ 4 files changed, 196 insertions(+)drivers/vdpa/mlx5/core/mlx5_vdpa.h +2
-0@@ -61,6 +61,8 @@ struct mlx5_control_vq {struct vringh_kiov riov;struct vringh_kiov wiov;unsigned short head; +unsigned int received_desc; +unsigned int completed_desc; };struct mlx5_vdpa_wq_ent {drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0@@ -119,6 +119,7 @@ struct mlx5_vdpa_virtqueue {struct mlx5_vdpa_umem umem2;struct mlx5_vdpa_umem umem3; +u32 counter_set_id;bool initialized;int index;u32 virtq_id;
drivers/vdpa/mlx5/net/mlx5_vnet.c struct mlx5_vdpa_net { · line 168
Quoted 5 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +2
-0@@ -163,6 +164,8 @@ struct mlx5_vdpa_net {u32 cur_num_vqs;struct notifier_block nb;struct vdpa_callback config_cb; +/* sync access to virtqueues statistics */ +struct mutex numq_lock;
Patch 1 already held vdpa_dev_mutex, any reason for another mutex here?
Quoted 144 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +65
-0};static void free_resources (struct mlx5_vdpa_net *ndev);@@ -821,6 +824,12 @@ static u16 get_features_12_3(u64 features) (!!(features &BIT_ULL (VIRTIO_NET_F_GUEST_CSUM )) <<6 ); } +static bool counters_supported (const struct mlx5_vdpa_dev *mvdev) +{ +return MLX5_CAP_GEN_64 (mvdev->mdev, general_obj_types) & +BIT_ULL (MLX5_OBJ_TYPE_VIRTIO_Q_COUNTERS ); +} +static int create_virtqueue (struct mlx5_vdpa_net *ndev,struct mlx5_vdpa_virtqueue *mvq) {int inlen =MLX5_ST_SZ_BYTES (create_virtio_net_q_in);@@ -875,6 +884,8 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueMLX5_SET (virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);MLX5_SET (virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);MLX5_SET (virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn); +if (counters_supported (&ndev->mvdev)) +MLX5_SET (virtio_q, vq_ctx, counter_set_id, mvq->counter_set_id); err =mlx5_cmd_exec (ndev->mvdev.mdev, in, inlen, out,sizeof (out));if (err)@@ -1138,6 +1149,47 @@ static int modify_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtquereturn err; } +static int counter_set_alloc (struct mlx5_vdpa_net *ndev,struct mlx5_vdpa_virtqueue *mvq) +{ +u32 in[MLX5_ST_SZ_DW (create_virtio_q_counters_in)] = {}; +u32 out[MLX5_ST_SZ_DW (create_virtio_q_counters_out)] = {}; +void *cmd_hdr; +int err; + +if (!counters_supported (&ndev->mvdev)) +return 0 ; + + cmd_hdr =MLX5_ADDR_OF (create_virtio_q_counters_in, in, hdr); + +MLX5_SET (general_obj_in_cmd_hdr, cmd_hdr, opcode,MLX5_CMD_OP_CREATE_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, cmd_hdr, obj_type,MLX5_OBJ_TYPE_VIRTIO_Q_COUNTERS ); +MLX5_SET (general_obj_in_cmd_hdr, cmd_hdr, uid, ndev->mvdev.res.uid); + + err =mlx5_cmd_exec (ndev->mvdev.mdev, in,sizeof (in), out,sizeof (out)); +if (err) +return err; + + mvq->counter_set_id =MLX5_GET (general_obj_out_cmd_hdr, out, obj_id); + +return 0 ; +} + +static void counter_set_dealloc (struct mlx5_vdpa_net *ndev,struct mlx5_vdpa_virtqueue *mvq) +{ +u32 in[MLX5_ST_SZ_DW (destroy_virtio_q_counters_in)] = {}; +u32 out[MLX5_ST_SZ_DW (destroy_virtio_q_counters_out)] = {}; + +if (!counters_supported (&ndev->mvdev)) +return ; + +MLX5_SET (destroy_virtio_q_counters_in, in, hdr.opcode,MLX5_CMD_OP_DESTROY_GENERAL_OBJECT ); +MLX5_SET (destroy_virtio_q_counters_in, in, hdr.obj_id, mvq->counter_set_id); +MLX5_SET (destroy_virtio_q_counters_in, in, hdr.uid, ndev->mvdev.res.uid); +MLX5_SET (destroy_virtio_q_counters_in, in, hdr.obj_type,MLX5_OBJ_TYPE_VIRTIO_Q_COUNTERS ); +if (mlx5_cmd_exec (ndev->mvdev.mdev, in,sizeof (in), out,sizeof (out))) +mlx5_vdpa_warn (&ndev->mvdev,"dealloc counter set 0x%x\n" , mvq->counter_set_id); +} +static int setup_vq (struct mlx5_vdpa_net *ndev,struct mlx5_vdpa_virtqueue *mvq) {u16 idx = mvq->index;@@ -1165,6 +1217,10 @@ static int setup_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)if (err) goto err_connect; + err =counter_set_alloc (ndev, mvq); +if (err) + goto err_counter; + err =create_virtqueue (ndev, mvq);if (err) goto err_connect;@@ -1182,6 +1238,8 @@ static int setup_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)return 0 ; err_connect: +counter_set_dealloc (ndev, mvq); +err_counter:qp_destroy (ndev, &mvq->vqqp); err_vqqp:qp_destroy (ndev, &mvq->fwqp);@@ -1226,6 +1284,7 @@ static void teardown_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *suspend_vq (ndev, mvq);destroy_virtqueue (ndev, mvq); +counter_set_dealloc (ndev, mvq);qp_destroy (ndev, &mvq->vqqp);qp_destroy (ndev, &mvq->fwqp);cq_destroy (ndev, mvq->index);@@ -1573,8 +1632,10 @@ static virtio_net_ctrl_ack handle_ctrl_mq(struct mlx5_vdpa_dev *mvdev, u8 cmd)break ; } +mutex_lock (&ndev->numq_lock);if (!change_num_qps (mvdev, newqps)) status =VIRTIO_NET_OK ; +mutex_unlock (&ndev->numq_lock);break ;default :@@ -1615,6 +1676,7 @@ static void mlx5_cvq_kick_handler(struct work_struct *work)if (read !=sizeof (ctrl))break ; + cvq->received_desc++;switch (ctrl.class) {case VIRTIO_NET_CTRL_MAC : status =handle_ctrl_mac (mvdev, ctrl.cmd);@@ -1637,6 +1699,7 @@ static void mlx5_cvq_kick_handler(struct work_struct *work)if (vringh_need_notify_iotlb (&cvq->vring))vringh_notify (&cvq->vring); + cvq->completed_desc++; } out:kfree (wqent);@@ -2310,6 +2373,7 @@ static void mlx5_vdpa_free(struct vdpa_device *vdev)mlx5_mpfs_del_mac (pfmdev, ndev->config.mac); }mlx5_vdpa_free_resources (&ndev->mvdev); +mutex_destroy (&ndev->numq_lock);mutex_destroy (&ndev->reslock);kfree (ndev->event_cbs);kfree (ndev->vqs);@@ -2351,6 +2415,93 @@ static u64 mlx5_vdpa_get_driver_features(struct vdpa_device *vdev)return mvdev->actual_features; } +static int counter_set_query (struct mlx5_vdpa_net *ndev,struct mlx5_vdpa_virtqueue *mvq, +u64 *received_desc,u64 *completed_desc) +{ +u32 in[MLX5_ST_SZ_DW (query_virtio_q_counters_in)] = {};
drivers/vdpa/mlx5/net/mlx5_vnet.c static u64 mlx5_vdpa_get_driver_features(struct vdpa_device *vdev) · line 2431
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +10
-0+u32 out[MLX5_ST_SZ_DW (query_virtio_q_counters_out)] = {}; +void *cmd_hdr; +void *ctx; +int err; + +if (!counters_supported (&ndev->mvdev)) +return -EOPNOTSUPP ; + +if (mvq->fw_state !=MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY ) +return -EAGAIN ;
Not related to this patch, but I found this is interesting. It looks to me the Q_OBJECT_STATE_RDY bring some troubles, I wonder if we can delay the register of vdpa device until fw is ready then we don't even need this check?
Quoted 121 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +76
-0+ + cmd_hdr =MLX5_ADDR_OF (query_virtio_q_counters_in, in, hdr); + +MLX5_SET (general_obj_in_cmd_hdr, cmd_hdr, opcode,MLX5_CMD_OP_QUERY_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, cmd_hdr, obj_type,MLX5_OBJ_TYPE_VIRTIO_Q_COUNTERS ); +MLX5_SET (general_obj_in_cmd_hdr, cmd_hdr, uid, ndev->mvdev.res.uid); +MLX5_SET (general_obj_in_cmd_hdr, cmd_hdr, obj_id, mvq->counter_set_id); + + err =mlx5_cmd_exec (ndev->mvdev.mdev, in,sizeof (in), out,sizeof (out)); +if (err) +return err; + + ctx =MLX5_ADDR_OF (query_virtio_q_counters_out, out, counters); + *received_desc =MLX5_GET64 (virtio_q_counters, ctx, received_desc); + *completed_desc =MLX5_GET64 (virtio_q_counters, ctx, completed_desc); +return 0 ; +} + +static int mlx5_vdpa_get_vq_stats (struct vdpa_device *vdev,u16 idx, +struct sk_buff *msg, +struct netlink_ext_ack *extack) +{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_vdpa_virtqueue *mvq; +struct mlx5_control_vq *cvq; +u64 received_desc; +u64 completed_desc; +int err =0 ; + +mutex_lock (&ndev->numq_lock); +if (!is_index_valid (mvdev, idx)) { +NL_SET_ERR_MSG_MOD (extack,"virtqueue index is not valid" ); + err = -EINVAL ; + goto out_err; + } + +if (idx ==ctrl_vq_idx (mvdev)) { + cvq = &mvdev->cvq; + received_desc = cvq->received_desc; + completed_desc = cvq->completed_desc; + goto out; + } + + mvq = &ndev->vqs[idx]; + err =counter_set_query (ndev, mvq, &received_desc, &completed_desc); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"failed to query hardware" ); + goto out_err; + } + +out: + err = -EMSGSIZE ; +if (nla_put_string (msg,VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,"received_desc" )) + goto out_err; + +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_VENDOR_ATTR_VALUE , received_desc, +VDPA_ATTR_PAD )) + goto out_err; + +if (nla_put_string (msg,VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,"completed_desc" )) + goto out_err; + +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_VENDOR_ATTR_VALUE , completed_desc, +VDPA_ATTR_PAD )) + goto out_err; + + err =0 ; +out_err: +mutex_unlock (&ndev->numq_lock); +return err; +} +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,@@ -2360,6 +2511,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = { .get_vq_ready = mlx5_vdpa_get_vq_ready, .set_vq_state = mlx5_vdpa_set_vq_state, .get_vq_state = mlx5_vdpa_get_vq_state, + .get_vq_stats = mlx5_vdpa_get_vq_stats, .get_vq_notification = mlx5_get_vq_notification, .get_vq_irq = mlx5_get_vq_irq, .get_vq_align = mlx5_vdpa_get_vq_align,@@ -2593,6 +2745,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,init_mvqs (ndev);mutex_init (&ndev->reslock); +mutex_init (&ndev->numq_lock); config = &ndev->config; err =query_mtu (mdev, &mtu);if (err)@@ -2666,6 +2819,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,if (!is_zero_ether_addr (config->mac))mlx5_mpfs_del_mac (pfmdev, config->mac); err_mtu: +mutex_destroy (&ndev->numq_lock);mutex_destroy (&ndev->reslock); err_alloc:put_device (&mvdev->vdev.dev);include/linux/mlx5/mlx5_ifc.h +1
-0@@ -94,6 +94,7 @@ enum {enum {MLX5_OBJ_TYPE_GENEVE_TLV_OPT =0x000b ,MLX5_OBJ_TYPE_VIRTIO_NET_Q =0x000d , +MLX5_OBJ_TYPE_VIRTIO_Q_COUNTERS =0x001c ,MLX5_OBJ_TYPE_MATCH_DEFINER =0x0018 ,MLX5_OBJ_TYPE_MKEY =0xff01 ,MLX5_OBJ_TYPE_QP =0xff02 ,include/linux/mlx5/mlx5_ifc_vdpa.h +1
-0@@ -165,4 +165,43 @@ struct mlx5_ifc_modify_virtio_net_q_out_bits {struct mlx5_ifc_general_obj_out_cmd_hdr_bits general_obj_out_cmd_hdr; }; +struct mlx5_ifc_virtio_q_counters_bits {
include/linux/mlx5/mlx5_ifc_vdpa.h struct mlx5_ifc_modify_virtio_net_q_out_bits { · line 178
Quoted 10 lines
include/linux/mlx5/mlx5_ifc_vdpa.h +10
-0+u8 modify_field_select[0x40 ]; +u8 reserved_at_40[0x40 ]; +u8 received_desc[0x40 ]; +u8 completed_desc[0x40 ]; +u8 error_cqes[0x20 ]; +u8 bad_desc_errors[0x20 ]; +u8 exceed_max_chain[0x20 ]; +u8 invalid_buffer[0x20 ]; +u8 reserved_at_180[0x280 ]; +};
I wonder if it's better to support all of those counters from the beginning?
Thanks
Quoted 30 lines
include/linux/mlx5/mlx5_ifc_vdpa.h +28
-1+ +struct mlx5_ifc_create_virtio_q_counters_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_virtio_q_counters_bits virtio_q_counters; +}; + +struct mlx5_ifc_create_virtio_q_counters_out_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_virtio_q_counters_bits virtio_q_counters; +}; + +struct mlx5_ifc_destroy_virtio_q_counters_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +}; + +struct mlx5_ifc_destroy_virtio_q_counters_out_bits { +struct mlx5_ifc_general_obj_out_cmd_hdr_bits hdr; +}; + +struct mlx5_ifc_query_virtio_q_counters_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +}; + +struct mlx5_ifc_query_virtio_q_counters_out_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_virtio_q_counters_bits counters; +}; +#endif /* __MLX5_IFC_VDPA_H_ */ --
Quoted 2 lines
2.34.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization