|
|
7570e2 |
From 23f80a84bf306e32fe02b78c2d02555c5d35ffb4 Mon Sep 17 00:00:00 2001
|
|
|
7570e2 |
Message-Id: <23f80a84bf306e32fe02b78c2d02555c5d35ffb4.1647984433.git.aclaudi@redhat.com>
|
|
|
7570e2 |
In-Reply-To: <cef782ca658d695c5ca2d174ba1f89cba6bd84e5.1647984433.git.aclaudi@redhat.com>
|
|
|
7570e2 |
References: <cef782ca658d695c5ca2d174ba1f89cba6bd84e5.1647984433.git.aclaudi@redhat.com>
|
|
|
7570e2 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
7570e2 |
Date: Mon, 21 Mar 2022 16:35:16 +0100
|
|
|
7570e2 |
Subject: [PATCH] vdpa: Support for configuring max VQ pairs for a device
|
|
|
7570e2 |
|
|
|
7570e2 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2059427
|
|
|
7570e2 |
Upstream Status: iproute2-next.git commit 16482fd4
|
|
|
7570e2 |
|
|
|
7570e2 |
commit 16482fd4df1132749575c49797c8d167c316d3f7
|
|
|
7570e2 |
Author: Eli Cohen <elic@nvidia.com>
|
|
|
7570e2 |
Date: Sun Mar 13 19:12:18 2022 +0200
|
|
|
7570e2 |
|
|
|
7570e2 |
vdpa: Support for configuring max VQ pairs for a device
|
|
|
7570e2 |
|
|
|
7570e2 |
Use VDPA_ATTR_DEV_MGMTDEV_MAX_VQS to specify max number of virtqueue
|
|
|
7570e2 |
pairs to configure for a vdpa device when adding a device.
|
|
|
7570e2 |
|
|
|
7570e2 |
Examples:
|
|
|
7570e2 |
1. Create a device with 3 virtqueue pairs:
|
|
|
7570e2 |
$ vdpa dev add name vdpa-a mgmtdev auxiliary/mlx5_core.sf.1 max_vqp 3
|
|
|
7570e2 |
|
|
|
7570e2 |
2. Read the configuration of a vdpa device
|
|
|
7570e2 |
$ vdpa dev config show vdpa-a
|
|
|
7570e2 |
vdpa-a: mac 00:00:00:00:88:88 link up link_announce false max_vq_pairs 3 \
|
|
|
7570e2 |
mtu 1500
|
|
|
7570e2 |
negotiated_features CSUM GUEST_CSUM MTU MAC HOST_TSO4 HOST_TSO6 STATUS \
|
|
|
7570e2 |
CTRL_VQ MQ CTRL_MAC_ADDR VERSION_1 ACCESS_PLATFORM
|
|
|
7570e2 |
|
|
|
7570e2 |
Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com>
|
|
|
7570e2 |
Acked-by: Jason Wang <jasowang@redhat.com>
|
|
|
7570e2 |
Signed-off-by: Eli Cohen <elic@nvidia.com>
|
|
|
7570e2 |
Signed-off-by: David Ahern <dsahern@kernel.org>
|
|
|
7570e2 |
---
|
|
|
7570e2 |
vdpa/vdpa.c | 25 ++++++++++++++++++++++++-
|
|
|
7570e2 |
1 file changed, 24 insertions(+), 1 deletion(-)
|
|
|
7570e2 |
|
|
|
7570e2 |
diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
|
|
|
7570e2 |
index 40078b1c..9985b6ca 100644
|
|
|
7570e2 |
--- a/vdpa/vdpa.c
|
|
|
7570e2 |
+++ b/vdpa/vdpa.c
|
|
|
7570e2 |
@@ -25,6 +25,7 @@
|
|
|
7570e2 |
#define VDPA_OPT_VDEV_HANDLE BIT(3)
|
|
|
7570e2 |
#define VDPA_OPT_VDEV_MAC BIT(4)
|
|
|
7570e2 |
#define VDPA_OPT_VDEV_MTU BIT(5)
|
|
|
7570e2 |
+#define VDPA_OPT_MAX_VQP BIT(6)
|
|
|
7570e2 |
|
|
|
7570e2 |
struct vdpa_opts {
|
|
|
7570e2 |
uint64_t present; /* flags of present items */
|
|
|
7570e2 |
@@ -34,6 +35,7 @@ struct vdpa_opts {
|
|
|
7570e2 |
unsigned int device_id;
|
|
|
7570e2 |
char mac[ETH_ALEN];
|
|
|
7570e2 |
uint16_t mtu;
|
|
|
7570e2 |
+ uint16_t max_vqp;
|
|
|
7570e2 |
};
|
|
|
7570e2 |
|
|
|
7570e2 |
struct vdpa {
|
|
|
7570e2 |
@@ -81,6 +83,7 @@ static const enum mnl_attr_data_type vdpa_policy[VDPA_ATTR_MAX + 1] = {
|
|
|
7570e2 |
[VDPA_ATTR_DEV_MAX_VQS] = MNL_TYPE_U32,
|
|
|
7570e2 |
[VDPA_ATTR_DEV_MAX_VQ_SIZE] = MNL_TYPE_U16,
|
|
|
7570e2 |
[VDPA_ATTR_DEV_NEGOTIATED_FEATURES] = MNL_TYPE_U64,
|
|
|
7570e2 |
+ [VDPA_ATTR_DEV_MGMTDEV_MAX_VQS] = MNL_TYPE_U32,
|
|
|
7570e2 |
};
|
|
|
7570e2 |
|
|
|
7570e2 |
static int attr_cb(const struct nlattr *attr, void *data)
|
|
|
7570e2 |
@@ -222,6 +225,8 @@ static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa *vdpa)
|
|
|
7570e2 |
sizeof(opts->mac), opts->mac);
|
|
|
7570e2 |
if (opts->present & VDPA_OPT_VDEV_MTU)
|
|
|
7570e2 |
mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MTU, opts->mtu);
|
|
|
7570e2 |
+ if (opts->present & VDPA_OPT_MAX_VQP)
|
|
|
7570e2 |
+ mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, opts->max_vqp);
|
|
|
7570e2 |
}
|
|
|
7570e2 |
|
|
|
7570e2 |
static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
|
|
|
7570e2 |
@@ -290,6 +295,14 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
|
|
|
7570e2 |
|
|
|
7570e2 |
NEXT_ARG_FWD();
|
|
|
7570e2 |
o_found |= VDPA_OPT_VDEV_MTU;
|
|
|
7570e2 |
+ } else if ((matches(*argv, "max_vqp") == 0) && (o_optional & VDPA_OPT_MAX_VQP)) {
|
|
|
7570e2 |
+ NEXT_ARG_FWD();
|
|
|
7570e2 |
+ err = vdpa_argv_u16(vdpa, argc, argv, &opts->max_vqp);
|
|
|
7570e2 |
+ if (err)
|
|
|
7570e2 |
+ return err;
|
|
|
7570e2 |
+
|
|
|
7570e2 |
+ NEXT_ARG_FWD();
|
|
|
7570e2 |
+ o_found |= VDPA_OPT_MAX_VQP;
|
|
|
7570e2 |
} else {
|
|
|
7570e2 |
fprintf(stderr, "Unknown option \"%s\"\n", *argv);
|
|
|
7570e2 |
return -EINVAL;
|
|
|
7570e2 |
@@ -499,6 +512,14 @@ static void pr_out_mgmtdev_show(struct vdpa *vdpa, const struct nlmsghdr *nlh,
|
|
|
7570e2 |
pr_out_array_end(vdpa);
|
|
|
7570e2 |
}
|
|
|
7570e2 |
|
|
|
7570e2 |
+ if (tb[VDPA_ATTR_DEV_MGMTDEV_MAX_VQS]) {
|
|
|
7570e2 |
+ uint32_t num_vqs;
|
|
|
7570e2 |
+
|
|
|
7570e2 |
+ print_nl();
|
|
|
7570e2 |
+ num_vqs = mnl_attr_get_u32(tb[VDPA_ATTR_DEV_MGMTDEV_MAX_VQS]);
|
|
|
7570e2 |
+ print_uint(PRINT_ANY, "max_supported_vqs", " max_supported_vqs %d", num_vqs);
|
|
|
7570e2 |
+ }
|
|
|
7570e2 |
+
|
|
|
7570e2 |
pr_out_handle_end(vdpa);
|
|
|
7570e2 |
}
|
|
|
7570e2 |
|
|
|
7570e2 |
@@ -559,6 +580,7 @@ static void cmd_dev_help(void)
|
|
|
7570e2 |
{
|
|
|
7570e2 |
fprintf(stderr, "Usage: vdpa dev show [ DEV ]\n");
|
|
|
7570e2 |
fprintf(stderr, " vdpa dev add name NAME mgmtdev MANAGEMENTDEV [ mac MACADDR ] [ mtu MTU ]\n");
|
|
|
7570e2 |
+ fprintf(stderr, " [ max_vqp MAX_VQ_PAIRS ]\n");
|
|
|
7570e2 |
fprintf(stderr, " vdpa dev del DEV\n");
|
|
|
7570e2 |
fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");
|
|
|
7570e2 |
}
|
|
|
7570e2 |
@@ -648,7 +670,8 @@ static int cmd_dev_add(struct vdpa *vdpa, int argc, char **argv)
|
|
|
7570e2 |
NLM_F_REQUEST | NLM_F_ACK);
|
|
|
7570e2 |
err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
|
|
|
7570e2 |
VDPA_OPT_VDEV_MGMTDEV_HANDLE | VDPA_OPT_VDEV_NAME,
|
|
|
7570e2 |
- VDPA_OPT_VDEV_MAC | VDPA_OPT_VDEV_MTU);
|
|
|
7570e2 |
+ VDPA_OPT_VDEV_MAC | VDPA_OPT_VDEV_MTU |
|
|
|
7570e2 |
+ VDPA_OPT_MAX_VQP);
|
|
|
7570e2 |
if (err)
|
|
|
7570e2 |
return err;
|
|
|
7570e2 |
|
|
|
7570e2 |
--
|
|
|
7570e2 |
2.35.1
|
|
|
7570e2 |
|