|
|
32391d |
From 6af0b1f5f1848689ee3c4cd00af224309185c644 Mon Sep 17 00:00:00 2001
|
|
|
32391d |
Message-Id: <6af0b1f5f1848689ee3c4cd00af224309185c644.1643220552.git.aclaudi@redhat.com>
|
|
|
32391d |
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
|
|
|
32391d |
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
|
|
|
32391d |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
32391d |
Date: Wed, 26 Jan 2022 10:39:38 +0100
|
|
|
32391d |
Subject: [PATCH] vdpa: Enable user to set mtu of the vdpa device
|
|
|
32391d |
|
|
|
32391d |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2036880
|
|
|
32391d |
Upstream Status: iproute2.git commit 167e33f3
|
|
|
32391d |
|
|
|
32391d |
commit 167e33f3be88c0fbe206df25145b850ddf3897a2
|
|
|
32391d |
Author: Parav Pandit <parav@nvidia.com>
|
|
|
32391d |
Date: Fri Dec 17 10:08:27 2021 +0200
|
|
|
32391d |
|
|
|
32391d |
vdpa: Enable user to set mtu of the vdpa device
|
|
|
32391d |
|
|
|
32391d |
Implement mtu setting for vdpa device.
|
|
|
32391d |
|
|
|
32391d |
$ vdpa mgmtdev show
|
|
|
32391d |
vdpasim_net:
|
|
|
32391d |
supported_classes net
|
|
|
32391d |
|
|
|
32391d |
Add the device with mac address and mtu:
|
|
|
32391d |
$ vdpa dev add name bar mgmtdev vdpasim_net mac 00:11:22:33:44:55 mtu 9000
|
|
|
32391d |
|
|
|
32391d |
In above command only mac address or only mtu can also be set.
|
|
|
32391d |
|
|
|
32391d |
View the config after setting:
|
|
|
32391d |
$ vdpa dev config show
|
|
|
32391d |
bar: mac 00:11:22:33:44:55 link up link_announce false mtu 9000
|
|
|
32391d |
|
|
|
32391d |
Signed-off-by: Parav Pandit <parav@nvidia.com>
|
|
|
32391d |
Signed-off-by: David Ahern <dsahern@kernel.org>
|
|
|
32391d |
---
|
|
|
32391d |
man/man8/vdpa-dev.8 | 10 ++++++++++
|
|
|
32391d |
vdpa/vdpa.c | 28 ++++++++++++++++++++++++++--
|
|
|
32391d |
2 files changed, 36 insertions(+), 2 deletions(-)
|
|
|
32391d |
|
|
|
32391d |
diff --git a/man/man8/vdpa-dev.8 b/man/man8/vdpa-dev.8
|
|
|
32391d |
index 5c5ac469..aa21ae3a 100644
|
|
|
32391d |
--- a/man/man8/vdpa-dev.8
|
|
|
32391d |
+++ b/man/man8/vdpa-dev.8
|
|
|
32391d |
@@ -32,6 +32,7 @@ vdpa-dev \- vdpa device configuration
|
|
|
32391d |
.B mgmtdev
|
|
|
32391d |
.I MGMTDEV
|
|
|
32391d |
.RI "[ mac " MACADDR " ]"
|
|
|
32391d |
+.RI "[ mtu " MTU " ]"
|
|
|
32391d |
|
|
|
32391d |
.ti -8
|
|
|
32391d |
.B vdpa dev del
|
|
|
32391d |
@@ -69,6 +70,10 @@ Name of the management device to use for device addition.
|
|
|
32391d |
- specifies the mac address for the new vdpa device.
|
|
|
32391d |
This is applicable only for the network type of vdpa device. This is optional.
|
|
|
32391d |
|
|
|
32391d |
+.BI mtu " MTU"
|
|
|
32391d |
+- specifies the mtu for the new vdpa device.
|
|
|
32391d |
+This is applicable only for the network type of vdpa device. This is optional.
|
|
|
32391d |
+
|
|
|
32391d |
.SS vdpa dev del - Delete the vdpa device.
|
|
|
32391d |
|
|
|
32391d |
.PP
|
|
|
32391d |
@@ -109,6 +114,11 @@ vdpa dev add name foo mgmtdev vdpa_sim_net mac 00:11:22:33:44:55
|
|
|
32391d |
Add the vdpa device named foo on the management device vdpa_sim_net with mac address of 00:11:22:33:44:55.
|
|
|
32391d |
.RE
|
|
|
32391d |
.PP
|
|
|
32391d |
+vdpa dev add name foo mgmtdev vdpa_sim_net mac 00:11:22:33:44:55 mtu 9000
|
|
|
32391d |
+.RS 4
|
|
|
32391d |
+Add the vdpa device named foo on the management device vdpa_sim_net with mac address of 00:11:22:33:44:55 and mtu of 9000 bytes.
|
|
|
32391d |
+.RE
|
|
|
32391d |
+.PP
|
|
|
32391d |
vdpa dev del foo
|
|
|
32391d |
.RS 4
|
|
|
32391d |
Delete the vdpa device named foo which was previously created.
|
|
|
32391d |
diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
|
|
|
32391d |
index 63d464d1..f048e470 100644
|
|
|
32391d |
--- a/vdpa/vdpa.c
|
|
|
32391d |
+++ b/vdpa/vdpa.c
|
|
|
32391d |
@@ -22,6 +22,7 @@
|
|
|
32391d |
#define VDPA_OPT_VDEV_NAME BIT(2)
|
|
|
32391d |
#define VDPA_OPT_VDEV_HANDLE BIT(3)
|
|
|
32391d |
#define VDPA_OPT_VDEV_MAC BIT(4)
|
|
|
32391d |
+#define VDPA_OPT_VDEV_MTU BIT(5)
|
|
|
32391d |
|
|
|
32391d |
struct vdpa_opts {
|
|
|
32391d |
uint64_t present; /* flags of present items */
|
|
|
32391d |
@@ -30,6 +31,7 @@ struct vdpa_opts {
|
|
|
32391d |
const char *vdev_name;
|
|
|
32391d |
unsigned int device_id;
|
|
|
32391d |
char mac[ETH_ALEN];
|
|
|
32391d |
+ uint16_t mtu;
|
|
|
32391d |
};
|
|
|
32391d |
|
|
|
32391d |
struct vdpa {
|
|
|
32391d |
@@ -154,6 +156,17 @@ static int vdpa_argv_mac(struct vdpa *vdpa, int argc, char **argv, char *mac)
|
|
|
32391d |
return 0;
|
|
|
32391d |
}
|
|
|
32391d |
|
|
|
32391d |
+static int vdpa_argv_u16(struct vdpa *vdpa, int argc, char **argv,
|
|
|
32391d |
+ uint16_t *result)
|
|
|
32391d |
+{
|
|
|
32391d |
+ if (argc <= 0 || *argv == NULL) {
|
|
|
32391d |
+ fprintf(stderr, "number expected\n");
|
|
|
32391d |
+ return -EINVAL;
|
|
|
32391d |
+ }
|
|
|
32391d |
+
|
|
|
32391d |
+ return get_u16(result, *argv, 10);
|
|
|
32391d |
+}
|
|
|
32391d |
+
|
|
|
32391d |
struct vdpa_args_metadata {
|
|
|
32391d |
uint64_t o_flag;
|
|
|
32391d |
const char *err_msg;
|
|
|
32391d |
@@ -204,6 +217,8 @@ static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa *vdpa)
|
|
|
32391d |
if (opts->present & VDPA_OPT_VDEV_MAC)
|
|
|
32391d |
mnl_attr_put(nlh, VDPA_ATTR_DEV_NET_CFG_MACADDR,
|
|
|
32391d |
sizeof(opts->mac), opts->mac);
|
|
|
32391d |
+ if (opts->present & VDPA_OPT_VDEV_MTU)
|
|
|
32391d |
+ mnl_attr_put_u16(nlh, VDPA_ATTR_DEV_NET_CFG_MTU, opts->mtu);
|
|
|
32391d |
}
|
|
|
32391d |
|
|
|
32391d |
static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
|
|
|
32391d |
@@ -263,6 +278,15 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
|
|
|
32391d |
|
|
|
32391d |
NEXT_ARG_FWD();
|
|
|
32391d |
o_found |= VDPA_OPT_VDEV_MAC;
|
|
|
32391d |
+ } else if ((strcmp(*argv, "mtu") == 0) &&
|
|
|
32391d |
+ (o_all & VDPA_OPT_VDEV_MTU)) {
|
|
|
32391d |
+ NEXT_ARG_FWD();
|
|
|
32391d |
+ err = vdpa_argv_u16(vdpa, argc, argv, &opts->mtu);
|
|
|
32391d |
+ if (err)
|
|
|
32391d |
+ return err;
|
|
|
32391d |
+
|
|
|
32391d |
+ NEXT_ARG_FWD();
|
|
|
32391d |
+ o_found |= VDPA_OPT_VDEV_MTU;
|
|
|
32391d |
} else {
|
|
|
32391d |
fprintf(stderr, "Unknown option \"%s\"\n", *argv);
|
|
|
32391d |
return -EINVAL;
|
|
|
32391d |
@@ -443,7 +467,7 @@ static int cmd_mgmtdev(struct vdpa *vdpa, int argc, char **argv)
|
|
|
32391d |
static void cmd_dev_help(void)
|
|
|
32391d |
{
|
|
|
32391d |
fprintf(stderr, "Usage: vdpa dev show [ DEV ]\n");
|
|
|
32391d |
- fprintf(stderr, " vdpa dev add name NAME mgmtdev MANAGEMENTDEV [ mac MACADDR ]\n");
|
|
|
32391d |
+ fprintf(stderr, " vdpa dev add name NAME mgmtdev MANAGEMENTDEV [ mac MACADDR ] [ mtu MTU ]\n");
|
|
|
32391d |
fprintf(stderr, " vdpa dev del DEV\n");
|
|
|
32391d |
fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");
|
|
|
32391d |
}
|
|
|
32391d |
@@ -533,7 +557,7 @@ static int cmd_dev_add(struct vdpa *vdpa, int argc, char **argv)
|
|
|
32391d |
NLM_F_REQUEST | NLM_F_ACK);
|
|
|
32391d |
err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
|
|
|
32391d |
VDPA_OPT_VDEV_MGMTDEV_HANDLE | VDPA_OPT_VDEV_NAME,
|
|
|
32391d |
- VDPA_OPT_VDEV_MAC);
|
|
|
32391d |
+ VDPA_OPT_VDEV_MAC | VDPA_OPT_VDEV_MTU);
|
|
|
32391d |
if (err)
|
|
|
32391d |
return err;
|
|
|
32391d |
|
|
|
32391d |
--
|
|
|
32391d |
2.34.1
|
|
|
32391d |
|