All of lore.kernel.org
 help / color / mirror / Atom feed
From: Si-Wei Liu <si-wei.liu@oracle.com>
To: Eli Cohen <elic@nvidia.com>,
	stephen@networkplumber.org, netdev@vger.kernel.org
Cc: jasowang@redhat.com, lulu@redhat.com
Subject: Re: [PATCH v1 3/4] vdpa: Support for configuring max VQ pairs for a device
Date: Fri, 11 Feb 2022 16:37:02 -0800	[thread overview]
Message-ID: <321ab6dd-e866-635d-b9b0-03abeb5eb7d6@oracle.com> (raw)
In-Reply-To: <20220210133115.115967-4-elic@nvidia.com>



On 2/10/2022 5:31 AM, Eli Cohen wrote:
> Use VDPA_ATTR_DEV_MGMTDEV_MAX_VQS to specify max number of virtqueue
> pairs to configure for a vdpa device when adding a device.
>
> Examples:
> 1. Create a device with 3 virtqueue pairs:
> $ vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1 max_vqp 3
>
> 2. Read the configuration of a vdpa device
> $ vdpa dev config show vdpa-a
>    vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 3 \
>            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@nvidia.com>
> ---
>   vdpa/include/uapi/linux/vdpa.h |  1 +
>   vdpa/vdpa.c                    | 25 ++++++++++++++++++++++++-
>   2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/vdpa/include/uapi/linux/vdpa.h b/vdpa/include/uapi/linux/vdpa.h
> index 748c350450b2..a3ebf4d4d9b8 100644
> --- a/vdpa/include/uapi/linux/vdpa.h
> +++ b/vdpa/include/uapi/linux/vdpa.h
> @@ -41,6 +41,7 @@ enum vdpa_attr {
>   	VDPA_ATTR_DEV_NET_CFG_MTU,		/* u16 */
>   
>   	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
> +	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,          /* u32 */
>   
>   	/* new attributes must be added above here */
>   	VDPA_ATTR_MAX,
> diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
> index 7deab710913d..99ee828630cc 100644
> --- a/vdpa/vdpa.c
> +++ b/vdpa/vdpa.c
> @@ -24,6 +24,7 @@
>   #define VDPA_OPT_VDEV_HANDLE		BIT(3)
>   #define VDPA_OPT_VDEV_MAC		BIT(4)
>   #define VDPA_OPT_VDEV_MTU		BIT(5)
> +#define VDPA_OPT_MAX_VQP		BIT(6)
>   
>   struct vdpa_opts {
>   	uint64_t present; /* flags of present items */
> @@ -33,6 +34,7 @@ struct vdpa_opts {
>   	unsigned int device_id;
>   	char mac[ETH_ALEN];
>   	uint16_t mtu;
> +	uint16_t max_vqp;
>   };
>   
>   struct vdpa {
> @@ -80,6 +82,7 @@ static const enum mnl_attr_data_type vdpa_policy[VDPA_ATTR_MAX + 1] = {
>   	[VDPA_ATTR_DEV_MAX_VQS] = MNL_TYPE_U32,
>   	[VDPA_ATTR_DEV_MAX_VQ_SIZE] = MNL_TYPE_U16,
>   	[VDPA_ATTR_DEV_NEGOTIATED_FEATURES] = MNL_TYPE_U64,
> +	[VDPA_ATTR_DEV_MGMTDEV_MAX_VQS] = MNL_TYPE_U32,
>   };
>   
>   static int attr_cb(const struct nlattr *attr, void *data)
> @@ -221,6 +224,8 @@ static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa *vdpa)
>   			     sizeof(opts->mac), opts->mac);
>   	if (opts->present & VDPA_OPT_VDEV_MTU)
>   		mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MTU, opts->mtu);
> +	if (opts->present & VDPA_OPT_MAX_VQP)
> +		mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, opts->max_vqp);
>   }
>   
>   static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
> @@ -289,6 +294,14 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
>   
>   			NEXT_ARG_FWD();
>   			o_found |= VDPA_OPT_VDEV_MTU;
> +		} else if ((matches(*argv, "max_vqp")  == 0) && (o_optional & VDPA_OPT_MAX_VQP)) {
> +			NEXT_ARG_FWD();
> +			err = vdpa_argv_u16(vdpa, argc, argv, &opts->max_vqp);
> +			if (err)
> +				return err;
> +
> +			NEXT_ARG_FWD();
> +			o_found |= VDPA_OPT_MAX_VQP;
It'd be nice to update cmd_dev_help() to include the max_vqp option as well.

Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com>

>   		} else {
>   			fprintf(stderr, "Unknown option \"%s\"\n", *argv);
>   			return -EINVAL;
> @@ -513,6 +526,15 @@ static void pr_out_mgmtdev_show(struct vdpa *vdpa, const struct nlmsghdr *nlh,
>   		pr_out_array_end(vdpa);
>   	}
>   
> +	if (tb[VDPA_ATTR_DEV_MGMTDEV_MAX_VQS]) {
> +		uint16_t num_vqs;
> +
> +		if (!vdpa->json_output)
> +			printf("\n");
> +		num_vqs = mnl_attr_get_u16(tb[VDPA_ATTR_DEV_MGMTDEV_MAX_VQS]);
> +		print_uint(PRINT_ANY, "max_supported_vqs", "  max_supported_vqs %d", num_vqs);
> +	}
> +
>   	pr_out_handle_end(vdpa);
>   }
>   
> @@ -662,7 +684,8 @@ static int cmd_dev_add(struct vdpa *vdpa, int argc, char **argv)
>   					  NLM_F_REQUEST | NLM_F_ACK);
>   	err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
>   				  VDPA_OPT_VDEV_MGMTDEV_HANDLE | VDPA_OPT_VDEV_NAME,
> -				  VDPA_OPT_VDEV_MAC | VDPA_OPT_VDEV_MTU);
> +				  VDPA_OPT_VDEV_MAC | VDPA_OPT_VDEV_MTU |
> +				  VDPA_OPT_MAX_VQP);
>   	if (err)
>   		return err;
>   


  reply	other threads:[~2022-02-12  0:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 13:31 [PATCH v1 0/4] vdpa tool enhancements Eli Cohen
2022-02-10 13:31 ` [PATCH v1 1/4] vdpa: Remove unsupported command line option Eli Cohen
2022-02-12  0:44   ` Si-Wei Liu
2022-02-15 14:49     ` Eli Cohen
2022-02-10 13:31 ` [PATCH v1 2/4] vdpa: Allow for printing negotiated features of a device Eli Cohen
2022-02-12  1:15   ` Si-Wei Liu
2022-02-15 15:16     ` Eli Cohen
2022-02-16 21:42       ` Si-Wei Liu
2022-02-10 13:31 ` [PATCH v1 3/4] vdpa: Support for configuring max VQ pairs for " Eli Cohen
2022-02-12  0:37   ` Si-Wei Liu [this message]
2022-02-15 14:45     ` Eli Cohen
2022-02-10 13:31 ` [PATCH v1 4/4] vdpa: Support reading device features Eli Cohen
2022-02-12  0:43   ` Si-Wei Liu
2022-02-15 14:46     ` Eli Cohen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=321ab6dd-e866-635d-b9b0-03abeb5eb7d6@oracle.com \
    --to=si-wei.liu@oracle.com \
    --cc=elic@nvidia.com \
    --cc=jasowang@redhat.com \
    --cc=lulu@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.