diff mbox series

[iproute2] vdpa: Add virtqueue pairs set capacity

Message ID 1648113553-10547-1-git-send-email-08005325@163.com (mailing list archive)
State New, archived
Delegated to: David Ahern
Headers show
Series [iproute2] vdpa: Add virtqueue pairs set capacity | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

08005325@163.com March 24, 2022, 9:19 a.m. UTC
From: Michael Qiu <qiudayu@archeros.com>

vdpa framework not only support query the max virtqueue pair, but
also for the set action.

This patch enable this capacity, and it is very useful for VMs
 who needs multiqueue support.

Signed-off-by: Michael Qiu <qiudayu@archeros.com>
---
 vdpa/vdpa.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Comments

Parav Pandit April 6, 2022, 3:45 a.m. UTC | #1
> From: 08005325@163.com <08005325@163.com>
> Sent: Thursday, March 24, 2022 5:19 AM
> 
> From: Michael Qiu <qiudayu@archeros.com>
>
Sorry for the late response.
Please see short comments below.
 
> vdpa framework not only support query the max virtqueue pair, but also for
> the set action.
> 
> This patch enable this capacity, and it is very useful for VMs  who needs
> multiqueue support.
>
A simpler rewrite as below.
This patch enables user to set max vq pairs for the net vdpa device during device addition time.
An example,

$ vdpa dev add ..  please give exact command that other users can copy.

 
> Signed-off-by: Michael Qiu <qiudayu@archeros.com>
> ---
>  vdpa/vdpa.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
> index f048e47..434d68e 100644
> --- a/vdpa/vdpa.c
> +++ b/vdpa/vdpa.c
> @@ -23,6 +23,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_VDEV_QUEUE_PAIRS      BIT(6)
> 
>  struct vdpa_opts {
>         uint64_t present; /* flags of present items */ @@ -32,6 +33,7 @@
> struct vdpa_opts {
>         unsigned int device_id;
>         char mac[ETH_ALEN];
>         uint16_t mtu;
> +       uint16_t max_vq_pairs;
>  };
> 
>  struct vdpa {
> @@ -219,6 +221,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_VDEV_QUEUE_PAIRS)
> +               mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
> + opts->max_vq_pairs);
>  }
> 
>  static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv, @@ -
> 287,6 +291,15 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc,
> char **argv,
> 
>                         NEXT_ARG_FWD();
>                         o_found |= VDPA_OPT_VDEV_MTU;
> +               } else if ((strcmp(*argv, "max_vq_pairs") == 0) &&

Currently on query side this is printed as "max_vqp".
Please keep the same name on argument too to keep symmetry in get and set.

> +                          (o_all & VDPA_OPT_VDEV_QUEUE_PAIRS)) {
> +                       NEXT_ARG_FWD();
> +                       err = vdpa_argv_u16(vdpa, argc, argv, &opts->max_vq_pairs);
> +                       if (err)
> +                               return err;
> +
> +                       NEXT_ARG_FWD();
> +                       o_found |= VDPA_OPT_VDEV_QUEUE_PAIRS;
>                 } else {
>                         fprintf(stderr, "Unknown option \"%s\"\n", *argv);
>                         return -EINVAL;
> @@ -467,7 +480,7 @@ static int cmd_mgmtdev(struct vdpa *vdpa, int argc,
> char **argv)  static void cmd_dev_help(void)  {
>         fprintf(stderr, "Usage: vdpa dev show [ DEV ]\n");
> -       fprintf(stderr, "       vdpa dev add name NAME mgmtdev
> MANAGEMENTDEV [ mac MACADDR ] [ mtu MTU ]\n");
> +       fprintf(stderr, "       vdpa dev add name NAME mgmtdev
> MANAGEMENTDEV [ mac MACADDR ] [ mtu MTU ] [ max_vq_pairs N ]\n");
>         fprintf(stderr, "       vdpa dev del DEV\n");
>         fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");  }
> @@ -557,7 +570,7 @@ 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_VDEV_QUEUE_PAIRS);
>         if (err)
>                 return err;
> 
> --
> 1.8.3.1

Please also extend the man page for this addition with example in man/man8/vdpa-dev.8.
Stephen Hemminger April 6, 2022, 3:33 p.m. UTC | #2
On Thu, 24 Mar 2022 05:19:13 -0400
08005325@163.com wrote:

> From: Michael Qiu <qiudayu@archeros.com>
> 
> vdpa framework not only support query the max virtqueue pair, but
> also for the set action.
> 
> This patch enable this capacity, and it is very useful for VMs
>  who needs multiqueue support.
> 
> Signed-off-by: Michael Qiu <qiudayu@archeros.com>

You need to add show logic to pr_out_dev_net_config
diff mbox series

Patch

diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
index f048e47..434d68e 100644
--- a/vdpa/vdpa.c
+++ b/vdpa/vdpa.c
@@ -23,6 +23,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_VDEV_QUEUE_PAIRS	BIT(6)
 
 struct vdpa_opts {
 	uint64_t present; /* flags of present items */
@@ -32,6 +33,7 @@  struct vdpa_opts {
 	unsigned int device_id;
 	char mac[ETH_ALEN];
 	uint16_t mtu;
+	uint16_t max_vq_pairs;
 };
 
 struct vdpa {
@@ -219,6 +221,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_VDEV_QUEUE_PAIRS)
+		mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, opts->max_vq_pairs);
 }
 
 static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
@@ -287,6 +291,15 @@  static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
 
 			NEXT_ARG_FWD();
 			o_found |= VDPA_OPT_VDEV_MTU;
+		} else if ((strcmp(*argv, "max_vq_pairs") == 0) &&
+			   (o_all & VDPA_OPT_VDEV_QUEUE_PAIRS)) {
+			NEXT_ARG_FWD();
+			err = vdpa_argv_u16(vdpa, argc, argv, &opts->max_vq_pairs);
+			if (err)
+				return err;
+
+			NEXT_ARG_FWD();
+			o_found |= VDPA_OPT_VDEV_QUEUE_PAIRS;
 		} else {
 			fprintf(stderr, "Unknown option \"%s\"\n", *argv);
 			return -EINVAL;
@@ -467,7 +480,7 @@  static int cmd_mgmtdev(struct vdpa *vdpa, int argc, char **argv)
 static void cmd_dev_help(void)
 {
 	fprintf(stderr, "Usage: vdpa dev show [ DEV ]\n");
-	fprintf(stderr, "       vdpa dev add name NAME mgmtdev MANAGEMENTDEV [ mac MACADDR ] [ mtu MTU ]\n");
+	fprintf(stderr, "       vdpa dev add name NAME mgmtdev MANAGEMENTDEV [ mac MACADDR ] [ mtu MTU ] [ max_vq_pairs N ]\n");
 	fprintf(stderr, "       vdpa dev del DEV\n");
 	fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");
 }
@@ -557,7 +570,7 @@  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_VDEV_QUEUE_PAIRS);
 	if (err)
 		return err;