Skip to contentSkip to conversation

vdpa tool enhancements

PATCH Superseded Eli Cohen 4 participants 11 messages Mar 2, 2022 – Mar 9, 2022

Subsystems (3)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

v4 cover vdpa tool enhancements

Hi Stephen,

this is a resend of v3 which omitted you and netdev from the recepient list. I added a few "acked-by" and called it v4.

The following four patch series enhances vdpa to show negotiated features for a vdpa device, max features for a management device and allows to configure max number of virtqueue pairs.

v3->v4:
Resend the patches with added "Acked-by" to the right mailing list.

Eli Cohen (4):
vdpa: Remove unsupported command line option
vdpa: Allow for printing negotiated features of a device
vdpa: Support for configuring max VQ pairs for a device
vdpa: Support reading device features

 vdpa/include/uapi/linux/vdpa.h |   4 +
 vdpa/vdpa.c                    | 151 +++++++++++++++++++++++++++++++--
 2 files changed, 148 insertions(+), 7 deletions(-)
Signature · 1 line
2.35.1
author
#1 lore raw

PATCH v4 1/4 vdpa: Remove unsupported command line option

"-v[erbose]" option is not supported. Remove it.

---
 vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
vdpa/vdpa.c +1 -1
index f048e470c929..4ccb564872a0 100644
@@ -711,7 +711,7 @@ static void help(void)
 	fprintf(stderr,
 		"Usage: vdpa [ OPTIONS ] OBJECT { COMMAND | help }\n"
 		"where  OBJECT := { mgmtdev | dev }\n"
-		"       OPTIONS := { -V[ersion] | -n[o-nice-names] | -j[son] | -p[retty] | -v[erbose] }\n");
+		"       OPTIONS := { -V[ersion] | -n[o-nice-names] | -j[son] | -p[retty] }\n");
 }
 
 static int vdpa_cmd(struct vdpa *vdpa, int argc, char **argv)
Signature · 1 line
2.35.1
Reviewed-by on v4 1/4
#2 lore raw

RE: [PATCH v4 1/4] vdpa: Remove unsupported command line option

Quoted 30 lines

From: Eli Cohen <[email protected]>
Sent: Wednesday, March 2, 2022 12:25 PM

"-v[erbose]" option is not supported. Remove it.

---
 vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
vdpa/vdpa.c +1 -1
index f048e470c929..4ccb564872a0 100644
@@ -711,7 +711,7 @@ static void help(void)
 	fprintf(stderr,
 		"Usage: vdpa [ OPTIONS ] OBJECT { COMMAND | help }\n"
 		"where  OBJECT := { mgmtdev | dev }\n"
-		"       OPTIONS := { -V[ersion] | -n[o-nice-names] | -j[son] | -
 p[retty] | -v[erbose] }\n");
+		"       OPTIONS := { -V[ersion] | -n[o-nice-names] | -j[son] | -
 p[retty] }\n");
 }
Quoted 3 lines

static int vdpa_cmd(struct vdpa *vdpa, int argc, char **argv)
--
2.35.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#3 lore raw

PATCH v4 2/4 vdpa: Allow for printing negotiated features of a device

In reply to Eli Cohen

When reading the configuration of a vdpa device, check if the VDPA_ATTR_DEV_NEGOTIATED_FEATURES is available. If it is, parse the feature bits and print a string representation of each of the feature bits.

We keep the strings in two different arrays. One for net device related devices and one for generic feature bits.

In this patch we parse only net device specific features. Support for other devices can be added later. If the device queried is not a net device, we print its bit number only.

Examples:
1. Standard presentation

$ vdpa dev config show vdpa-a
vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 2 mtu 9000
  negotiated_features CSUM GUEST_CSUM MTU MAC HOST_TSO4 HOST_TSO6 STATUS \
CTRL_VQ MQ CTRL_MAC_ADDR VERSION_1 ACCESS_PLATFORM

2. json output

$ 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":2,"mtu":9000,"negotiated_features":["CSUM","GUEST_CSUM",\
"MTU","MAC","HOST_TSO4","HOST_TSO6","STATUS","CTRL_VQ","MQ","CTRL_MAC_ADDR",\
"VERSION_1","ACCESS_PLATFORM"]}}}

3. Pretty json

$ 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": 2,
            "mtu": 9000,
            "negotiated_features": [
"CSUM","GUEST_CSUM","MTU","MAC","HOST_TSO4","HOST_TSO6","STATUS","CTRL_VQ",\
"MQ","CTRL_MAC_ADDR","VERSION_1","ACCESS_PLATFORM" ]
        }
    }
}
---
 vdpa/include/uapi/linux/vdpa.h |   2 +
 vdpa/vdpa.c                    | 107 ++++++++++++++++++++++++++++++++-
 2 files changed, 107 insertions(+), 2 deletions(-)
vdpa/include/uapi/linux/vdpa.h +2 -0
index b7eab069988a..748c350450b2 100644
@@ -40,6 +40,8 @@ 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,
 };
vdpa/vdpa.c +105 -2

145 lines not on this page · raw message

Signature · 1 line
2.35.1
author
#4 lore raw

PATCH v4 3/4 vdpa: Support for configuring max VQ pairs for a device

In reply to Eli Cohen

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
---
 vdpa/include/uapi/linux/vdpa.h |  1 +
 vdpa/vdpa.c                    | 27 +++++++++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)
vdpa/include/uapi/linux/vdpa.h +1 -0
index 748c350450b2..a3ebf4d4d9b8 100644
@@ -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,
vdpa/vdpa.c +25 -2
index 5f1aa91a4b96..22064c755baa 100644
@@ -25,6 +25,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 */
@@ -34,6 +35,7 @@ struct vdpa_opts {
 	unsigned int device_id;
 	char mac[ETH_ALEN];
 	uint16_t mtu;
+	uint16_t max_vqp;
 };
 
 struct vdpa {
@@ -81,6 +83,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)
@@ -222,6 +225,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,
@@ -290,6 +295,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;
 		} else {
 			fprintf(stderr, "Unknown option \"%s\"\n", *argv);
 			return -EINVAL;
@@ -501,6 +514,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);
 }
 
@@ -560,7 +582,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_vqp MAX_VQ_PAIRS]\n");
 	fprintf(stderr, "       vdpa dev del DEV\n");
 	fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");
 }
@@ -650,7 +672,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;
 
Signature · 1 line
2.35.1
#5 lore raw

RE: [PATCH v4 3/4] vdpa: Support for configuring max VQ pairs for a device

vdpa/include/uapi/linux/vdpa.h enum vdpa_attr { · line 45

Quoted 11 lines

From: Eli Cohen <[email protected]>
Sent: Wednesday, March 2, 2022 12:25 PM

vdpa/include/uapi/linux/vdpa.h +1 -0
@@ -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 */
 

Its u32 here, but in the code below at places, it is mix of u16 and u32. Please make it consistent to be u32 or u16 to match to kernel at all places.

Quoted 16 lines
vdpa/include/uapi/linux/vdpa.h +0 -0
 	/* new attributes must be added above here */
 	VDPA_ATTR_MAX,
vdpa/vdpa.c +1 -0
index 5f1aa91a4b96..22064c755baa 100644
@@ -25,6 +25,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 */ @@ -34,6 +35,7 @@

struct vdpa_opts {

vdpa/vdpa.c struct vdpa_opts { · line 39

Quoted 5 lines
vdpa/vdpa.c +1 -0
 	unsigned int device_id;
 	char mac[ETH_ALEN];
 	uint16_t mtu;
+	uint16_t max_vqp;
 };

u16 here.

vdpa/vdpa.c static const enum mnl_attr_data_type · line 88

Quoted 8 lines

struct vdpa {

vdpa/vdpa.c +1 -0
@@ -81,6 +83,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,
 };

u32 here, but code is doing u16.

Quoted 9 lines
vdpa/vdpa.c +0 -0
 static int attr_cb(const struct nlattr *attr, void *data) @@ -222,6 +225,8 @@

static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa *vdpa)

vdpa/vdpa.c +0 -0
 			     sizeof(opts->mac), opts->mac);
 	if (opts->present & VDPA_OPT_VDEV_MTU)
 		mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MTU, opts-
Quoted 1 line

mtu);

vdpa/vdpa.c +2 -0
+	if (opts->present & VDPA_OPT_MAX_VQP)
+		mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MAX_VQP,
Quoted 3 lines

opts->max_vqp);
}

u16 here.

Quoted 64 lines

static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv, @@ -
290,6 +295,14 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,

vdpa/vdpa.c +1 -0
 			NEXT_ARG_FWD();
 			o_found |= VDPA_OPT_VDEV_MTU;
+		} else if ((matches(*argv, "max_vqp")  == 0) && (o_optional &

VDPA_OPT_MAX_VQP)) {

vdpa/vdpa.c +2 -0
+			NEXT_ARG_FWD();
+			err = vdpa_argv_u16(vdpa, argc, argv, &opts-
Quoted 1 line

max_vqp);

vdpa/vdpa.c +14 -0
+			if (err)
+				return err;
+
+			NEXT_ARG_FWD();
+			o_found |= VDPA_OPT_MAX_VQP;
 		} else {
 			fprintf(stderr, "Unknown option \"%s\"\n", *argv);
 			return -EINVAL;
@@ -501,6 +514,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);
+	}
+
vdpa/vdpa.c +1 -1
 	pr_out_handle_end(vdpa);
 }
@@ -560,7 +582,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_vqp MAX_VQ_PAIRS]\n");

vdpa/vdpa.c +1 -1
 	fprintf(stderr, "       vdpa dev del DEV\n");
 	fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");  }
@@ -650,7 +672,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/vdpa.c +1 -1
+				  VDPA_OPT_MAX_VQP);
 	if (err)
 		return err;
 
--

2.35.1

author
#6 lore raw

RE: [PATCH v4 3/4] vdpa: Support for configuring max VQ pairs for a device

Quoted 38 lines

-----Original Message-----
From: Parav Pandit <[email protected]>
Sent: Wednesday, March 9, 2022 10:59 AM
To: Eli Cohen <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; si- [email protected]
Subject: RE: [PATCH v4 3/4] vdpa: Support for configuring max VQ pairs for a device

vdpa/include/uapi/linux/vdpa.h enum vdpa_attr { · line 45

Quoted 10 lines

From: Eli Cohen <[email protected]>
Sent: Wednesday, March 2, 2022 12:25 PM

vdpa/include/uapi/linux/vdpa.h +1 -0
@@ -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 */
 

Its u32 here, but in the code below at places, it is mix of u16 and u32. Please make it consistent to be u32 or u16 to match to kernel at all places.

Quoted 12 lines
vdpa/include/uapi/linux/vdpa.h +0 -0
 	/* new attributes must be added above here */
 	VDPA_ATTR_MAX,
vdpa/vdpa.c index renamed from vdpa/vdpa.c +0 -0

5f1aa91a4b96..22064c755baa 100644

vdpa/vdpa.c +1 -0
@@ -25,6 +25,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)
 
Quoted 10 lines

vdpa/vdpa.c struct vdpa_opts { · line 39

Quoted 9 lines
vdpa/vdpa.c +0 -0
 struct vdpa_opts {
 	uint64_t present; /* flags of present items */ @@ -34,6 +35,7 @@

struct vdpa_opts {

vdpa/vdpa.c +1 -0
 	unsigned int device_id;
 	char mac[ETH_ALEN];
 	uint16_t mtu;
+	uint16_t max_vqp;
 };

u16 here.

It should be u32. I will fix and resend.

Quoted 93 lines

vdpa/vdpa.c static const enum mnl_attr_data_type · line 88

Quoted 9 lines

struct vdpa {

vdpa/vdpa.c +1 -0
@@ -81,6 +83,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,
 };

u32 here, but code is doing u16.

vdpa/vdpa.c static const enum mnl_attr_data_type

Quoted 3 lines
vdpa/vdpa.c +1 -0
 static int attr_cb(const struct nlattr *attr, void *data) @@ -222,6
+225,8 @@ static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa

*vdpa)

vdpa/vdpa.c static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa *vdpa)

Quoted 3 lines
vdpa/vdpa.c +0 -0
 			     sizeof(opts->mac), opts->mac);
 	if (opts->present & VDPA_OPT_VDEV_MTU)
 		mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MTU,

opts-

vdpa/vdpa.c

Quoted 3 lines
Quoted 1 line

mtu);

vdpa/vdpa.c +2 -0
+	if (opts->present & VDPA_OPT_MAX_VQP)
+		mnl_attr_put_u16(nlh,

VDPA_ATTR_DEV_NET_CFG_MAX_VQP,

Quoted 3 lines

opts->max_vqp);
}

u16 here.

Quoted 45 lines

static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
@@ -
290,6 +295,14 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,

vdpa/vdpa.c +1 -0
 			NEXT_ARG_FWD();
 			o_found |= VDPA_OPT_VDEV_MTU;
+		} else if ((matches(*argv, "max_vqp")  == 0) && (o_optional &

VDPA_OPT_MAX_VQP)) {

vdpa/vdpa.c +2 -0
+			NEXT_ARG_FWD();
+			err = vdpa_argv_u16(vdpa, argc, argv, &opts-
Quoted 1 line

max_vqp);

vdpa/vdpa.c +14 -0
+			if (err)
+				return err;
+
+			NEXT_ARG_FWD();
+			o_found |= VDPA_OPT_MAX_VQP;
 		} else {
 			fprintf(stderr, "Unknown option \"%s\"\n", *argv);
 			return -EINVAL;
@@ -501,6 +514,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);
+	}
+
vdpa/vdpa.c +1 -1
 	pr_out_handle_end(vdpa);
 }
@@ -560,7 +582,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
Quoted 1 line

MANAGEMENTDEV [ mac MACADDR ] [ mtu MTU ] [max_vqp

MAX_VQ_PAIRS]\n");

Quoted 18 lines
vdpa/vdpa.c +1 -1
 	fprintf(stderr, "       vdpa dev del DEV\n");
 	fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");  }
@@ -650,7 +672,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/vdpa.c +1 -1
+				  VDPA_OPT_MAX_VQP);
 	if (err)
 		return err;
 
--

2.35.1

author
#7 lore raw

RE: [PATCH v4 3/4] vdpa: Support for configuring max VQ pairs for a device

Quoted 61 lines

-----Original Message-----
From: Eli Cohen
Sent: Wednesday, March 9, 2022 11:04 AM
To: Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; si- [email protected]
Subject: RE: [PATCH v4 3/4] vdpa: Support for configuring max VQ pairs for a device

Quoted 36 lines

-----Original Message-----
From: Parav Pandit <[email protected]>
Sent: Wednesday, March 9, 2022 10:59 AM
To: Eli Cohen <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; si- [email protected]
Subject: RE: [PATCH v4 3/4] vdpa: Support for configuring max VQ pairs for a device

vdpa/include/uapi/linux/vdpa.h enum vdpa_attr { · line 45

Quoted 10 lines

From: Eli Cohen <[email protected]>
Sent: Wednesday, March 2, 2022 12:25 PM

vdpa/include/uapi/linux/vdpa.h +1 -0
@@ -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 */
 

Its u32 here, but in the code below at places, it is mix of u16 and u32. Please make it consistent to be u32 or u16 to match to kernel at all places.

Quoted 12 lines
vdpa/include/uapi/linux/vdpa.h +0 -0
 	/* new attributes must be added above here */
 	VDPA_ATTR_MAX,
vdpa/vdpa.c index renamed from vdpa/vdpa.c +0 -0

5f1aa91a4b96..22064c755baa 100644

vdpa/vdpa.c +1 -0
@@ -25,6 +25,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)
 
Quoted 10 lines

vdpa/vdpa.c struct vdpa_opts { · line 39

Quoted 9 lines
vdpa/vdpa.c +0 -0
 struct vdpa_opts {
 	uint64_t present; /* flags of present items */ @@ -34,6 +35,7 @@

struct vdpa_opts {

vdpa/vdpa.c +1 -0
 	unsigned int device_id;
 	char mac[ETH_ALEN];
 	uint16_t mtu;
+	uint16_t max_vqp;
 };

u16 here.

Quoted 1 line

It should be u32. I will fix and resend.

Sorry, I meant u16.

Quoted 95 lines
Quoted 69 lines

vdpa/vdpa.c static const enum mnl_attr_data_type · line 88

Quoted 10 lines

struct vdpa {

vdpa/vdpa.c +1 -0
@@ -81,6 +83,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,
 };

u32 here, but code is doing u16.

vdpa/vdpa.c static const enum mnl_attr_data_type

Quoted 4 lines
vdpa/vdpa.c +2 -0
 static int attr_cb(const struct nlattr *attr, void *data) @@ -222,6
+225,8 @@ static void vdpa_opts_put(struct nlmsghdr *nlh, struct
+vdpa

*vdpa)

vdpa/vdpa.c static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa *vdpa)

Quoted 3 lines
vdpa/vdpa.c +0 -0
 			     sizeof(opts->mac), opts->mac);
 	if (opts->present & VDPA_OPT_VDEV_MTU)
 		mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MTU,

opts-

vdpa/vdpa.c

Quoted 3 lines
Quoted 1 line

mtu);

vdpa/vdpa.c +2 -0
+	if (opts->present & VDPA_OPT_MAX_VQP)
+		mnl_attr_put_u16(nlh,

VDPA_ATTR_DEV_NET_CFG_MAX_VQP,

Quoted 3 lines

opts->max_vqp);
}

u16 here.

Quoted 39 lines

static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char
**argv, @@ -
290,6 +295,14 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,

vdpa/vdpa.c +1 -0
 			NEXT_ARG_FWD();
 			o_found |= VDPA_OPT_VDEV_MTU;
+		} else if ((matches(*argv, "max_vqp")  == 0) && (o_optional &

VDPA_OPT_MAX_VQP)) {

vdpa/vdpa.c +2 -0
+			NEXT_ARG_FWD();
+			err = vdpa_argv_u16(vdpa, argc, argv, &opts-
Quoted 1 line

max_vqp);

vdpa/vdpa.c +14 -0
+			if (err)
+				return err;
+
+			NEXT_ARG_FWD();
+			o_found |= VDPA_OPT_MAX_VQP;
 		} else {
 			fprintf(stderr, "Unknown option \"%s\"\n", *argv);
 			return -EINVAL;
@@ -501,6 +514,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);
}

Quoted 15 lines
Quoted 7 lines
vdpa/vdpa.c +1 -1
@@ -560,7 +582,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_vqp

MAX_VQ_PAIRS]\n");

Quoted 7 lines
vdpa/vdpa.c +0 -0
 	fprintf(stderr, "       vdpa dev del DEV\n");
 	fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");

} @@ -650,7 +672,8 @@ static int cmd_dev_add(struct vdpa *vdpa, int argc, char **argv)

vdpa/vdpa.c +0 -0
 					  NLM_F_REQUEST | NLM_F_ACK);
 	err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
 				  VDPA_OPT_VDEV_MGMTDEV_HANDLE |

VDPA_OPT_VDEV_NAME,

Quoted 10 lines
Quoted 10 lines
vdpa/vdpa.c +0 -1
-				  VDPA_OPT_VDEV_MAC |

VDPA_OPT_VDEV_MTU);

vdpa/vdpa.c +1 -0
+				  VDPA_OPT_VDEV_MAC |

VDPA_OPT_VDEV_MTU |

vdpa/vdpa.c +1 -1
+				  VDPA_OPT_MAX_VQP);
 	if (err)
 		return err;
 
--

2.35.1

author
#8 lore raw

PATCH v4 4/4 vdpa: Support reading device features

In reply to Eli Cohen

When showing the available management devices, check if VDPA_ATTR_DEV_SUPPORTED_FEATURES feature is available and print the supported features for a management device.

Examples:

$ vdpa mgmtdev show
auxiliary/mlx5_core.sf.1:
  supported_classes net
  max_supported_vqs 257
  dev_features CSUM GUEST_CSUM MTU HOST_TSO4 HOST_TSO6 STATUS CTRL_VQ MQ \
               CTRL_MAC_ADDR VERSION_1 ACCESS_PLATFORM
$ vdpa -jp mgmtdev show
{
    "mgmtdev": {
        "auxiliary/mlx5_core.sf.1": {
            "supported_classes": [ "net" ],
            "max_supported_vqs": 257,
            "dev_features": [
"CSUM","GUEST_CSUM","MTU","HOST_TSO4","HOST_TSO6","STATUS","CTRL_VQ","MQ",\
"CTRL_MAC_ADDR","VERSION_1","ACCESS_PLATFORM" ]
        }
    }
}
---
 vdpa/include/uapi/linux/vdpa.h |  1 +
 vdpa/vdpa.c                    | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
vdpa/include/uapi/linux/vdpa.h +1 -0
index a3ebf4d4d9b8..96ccbf305d14 100644
@@ -42,6 +42,7 @@ enum vdpa_attr {
 
 	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */
 	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,          /* u32 */
+	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */
 
 	/* new attributes must be added above here */
 	VDPA_ATTR_MAX,
vdpa/vdpa.c +13 -2
index 22064c755baa..bdc366880ab9 100644
@@ -84,6 +84,7 @@ static const enum mnl_attr_data_type vdpa_policy[VDPA_ATTR_MAX + 1] = {
 	[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,
+	[VDPA_ATTR_DEV_SUPPORTED_FEATURES] = MNL_TYPE_U64,
 };
 
 static int attr_cb(const struct nlattr *attr, void *data)
@@ -494,14 +495,14 @@ static void print_features(struct vdpa *vdpa, uint64_t features, bool mgmtdevf,
 static void pr_out_mgmtdev_show(struct vdpa *vdpa, const struct nlmsghdr *nlh,
 				struct nlattr **tb)
 {
+	uint64_t classes = 0;
 	const char *class;
 	unsigned int i;
 
 	pr_out_handle_start(vdpa, tb);
 
 	if (tb[VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES]) {
-		uint64_t classes = mnl_attr_get_u64(tb[VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES]);
-
+		classes = mnl_attr_get_u64(tb[VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES]);
 		pr_out_array_start(vdpa, "supported_classes");
 
 		for (i = 1; i < 64; i++) {
@@ -523,6 +524,16 @@ static void pr_out_mgmtdev_show(struct vdpa *vdpa, const struct nlmsghdr *nlh,
 		print_uint(PRINT_ANY, "max_supported_vqs", "  max_supported_vqs %d", num_vqs);
 	}
 
+	if (tb[VDPA_ATTR_DEV_SUPPORTED_FEATURES]) {
+		uint64_t features;
+
+		features  = mnl_attr_get_u64(tb[VDPA_ATTR_DEV_SUPPORTED_FEATURES]);
+		if (classes & BIT(VIRTIO_ID_NET))
+			print_features(vdpa, features, true, VIRTIO_ID_NET);
+		else
+			print_features(vdpa, features, true, 0);
+	}
+
 	pr_out_handle_end(vdpa);
 }
 
Signature · 1 line
2.35.1
#9 lore raw
In reply to Eli Cohen
Quoted 11 lines · Eli Cohen

Hi Stephen,

this is a resend of v3 which omitted you and netdev from the recepient list. I added a few "acked-by" and called it v4.

The following four patch series enhances vdpa to show negotiated features for a vdpa device, max features for a management device and allows to configure max number of virtqueue pairs.

v3->v4:
Resend the patches with added "Acked-by" to the right mailing list.

Hello maintainers:

Any comment on the series? We want to have this for the next RHEL release.

Thanks

Quoted 11 lines

Eli Cohen (4):
vdpa: Remove unsupported command line option
vdpa: Allow for printing negotiated features of a device
vdpa: Support for configuring max VQ pairs for a device
vdpa: Support reading device features

  vdpa/include/uapi/linux/vdpa.h |   4 +
  vdpa/vdpa.c                    | 151 +++++++++++++++++++++++++++++++--
  2 files changed, 148 insertions(+), 7 deletions(-)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#10 lore raw
Quoted 11 lines · Jason Wang
Quoted 9 lines · Eli Cohen

Hi Stephen,

this is a resend of v3 which omitted you and netdev from the recepient list. I added a few "acked-by" and called it v4.

The following four patch series enhances vdpa to show negotiated features for a vdpa device, max features for a management device and allows to configure max number of virtqueue pairs.

Quoted 8 lines
Quoted 2 lines

v3->v4:
Resend the patches with added "Acked-by" to the right mailing list.

Hello maintainers:

Any comment on the series? We want to have this for the next RHEL release.

I was no cc'ed on the patches; you will need to re-send.