import iproute-5.15.0-2.el8

This commit is contained in:
CentOS Sources 2022-01-28 04:20:22 +00:00 committed by Stepan Oksanichenko
parent 87d433e44e
commit e0cd438f2e
5 changed files with 782 additions and 1 deletions

View File

@ -0,0 +1,141 @@
From 548e39858ecf9291494555466e6e931935b4a0ee Mon Sep 17 00:00:00 2001
Message-Id: <548e39858ecf9291494555466e6e931935b4a0ee.1643220552.git.aclaudi@redhat.com>
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 26 Jan 2022 10:37:45 +0100
Subject: [PATCH] vdpa: align uapi headers
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2036880
Upstream Status: iproute2.git commit fa58de9b0c73
commit 34672eae6ec8e885f76ae30af10f849720012dd6
Author: Stephen Hemminger <stephen@networkplumber.org>
Date: Thu Nov 18 09:56:57 2021 -0800
vdpa: align uapi headers
Update vdpa headers based on 5.16.0-rc1 and remove redundant
copy.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/uapi/linux/vdpa.h | 40 ----------------------------
vdpa/include/uapi/linux/vdpa.h | 7 +++++
vdpa/include/uapi/linux/virtio_ids.h | 26 ++++++++++++++++++
3 files changed, 33 insertions(+), 40 deletions(-)
delete mode 100644 include/uapi/linux/vdpa.h
diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h
deleted file mode 100644
index 37ae26b6..00000000
--- a/include/uapi/linux/vdpa.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
-/*
- * vdpa device management interface
- * Copyright (c) 2020 Mellanox Technologies Ltd. All rights reserved.
- */
-
-#ifndef _LINUX_VDPA_H_
-#define _LINUX_VDPA_H_
-
-#define VDPA_GENL_NAME "vdpa"
-#define VDPA_GENL_VERSION 0x1
-
-enum vdpa_command {
- VDPA_CMD_UNSPEC,
- VDPA_CMD_MGMTDEV_NEW,
- VDPA_CMD_MGMTDEV_GET, /* can dump */
- VDPA_CMD_DEV_NEW,
- VDPA_CMD_DEV_DEL,
- VDPA_CMD_DEV_GET, /* can dump */
-};
-
-enum vdpa_attr {
- VDPA_ATTR_UNSPEC,
-
- /* bus name (optional) + dev name together make the parent device handle */
- VDPA_ATTR_MGMTDEV_BUS_NAME, /* string */
- VDPA_ATTR_MGMTDEV_DEV_NAME, /* string */
- VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES, /* u64 */
-
- VDPA_ATTR_DEV_NAME, /* string */
- VDPA_ATTR_DEV_ID, /* u32 */
- VDPA_ATTR_DEV_VENDOR_ID, /* u32 */
- VDPA_ATTR_DEV_MAX_VQS, /* u32 */
- VDPA_ATTR_DEV_MAX_VQ_SIZE, /* u16 */
-
- /* new attributes must be added above here */
- VDPA_ATTR_MAX,
-};
-
-#endif
diff --git a/vdpa/include/uapi/linux/vdpa.h b/vdpa/include/uapi/linux/vdpa.h
index 37ae26b6..b7eab069 100644
--- a/vdpa/include/uapi/linux/vdpa.h
+++ b/vdpa/include/uapi/linux/vdpa.h
@@ -17,6 +17,7 @@ enum vdpa_command {
VDPA_CMD_DEV_NEW,
VDPA_CMD_DEV_DEL,
VDPA_CMD_DEV_GET, /* can dump */
+ VDPA_CMD_DEV_CONFIG_GET, /* can dump */
};
enum vdpa_attr {
@@ -32,6 +33,12 @@ enum vdpa_attr {
VDPA_ATTR_DEV_VENDOR_ID, /* u32 */
VDPA_ATTR_DEV_MAX_VQS, /* u32 */
VDPA_ATTR_DEV_MAX_VQ_SIZE, /* u16 */
+ VDPA_ATTR_DEV_MIN_VQ_SIZE, /* u16 */
+
+ VDPA_ATTR_DEV_NET_CFG_MACADDR, /* binary */
+ VDPA_ATTR_DEV_NET_STATUS, /* u8 */
+ VDPA_ATTR_DEV_NET_CFG_MAX_VQP, /* u16 */
+ VDPA_ATTR_DEV_NET_CFG_MTU, /* u16 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,
diff --git a/vdpa/include/uapi/linux/virtio_ids.h b/vdpa/include/uapi/linux/virtio_ids.h
index bc1c0621..80d76b75 100644
--- a/vdpa/include/uapi/linux/virtio_ids.h
+++ b/vdpa/include/uapi/linux/virtio_ids.h
@@ -51,8 +51,34 @@
#define VIRTIO_ID_PSTORE 22 /* virtio pstore device */
#define VIRTIO_ID_IOMMU 23 /* virtio IOMMU */
#define VIRTIO_ID_MEM 24 /* virtio mem */
+#define VIRTIO_ID_SOUND 25 /* virtio sound */
#define VIRTIO_ID_FS 26 /* virtio filesystem */
#define VIRTIO_ID_PMEM 27 /* virtio pmem */
+#define VIRTIO_ID_RPMB 28 /* virtio rpmb */
#define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
+#define VIRTIO_ID_VIDEO_ENCODER 30 /* virtio video encoder */
+#define VIRTIO_ID_VIDEO_DECODER 31 /* virtio video decoder */
+#define VIRTIO_ID_SCMI 32 /* virtio SCMI */
+#define VIRTIO_ID_NITRO_SEC_MOD 33 /* virtio nitro secure module*/
+#define VIRTIO_ID_I2C_ADAPTER 34 /* virtio i2c adapter */
+#define VIRTIO_ID_WATCHDOG 35 /* virtio watchdog */
+#define VIRTIO_ID_CAN 36 /* virtio can */
+#define VIRTIO_ID_DMABUF 37 /* virtio dmabuf */
+#define VIRTIO_ID_PARAM_SERV 38 /* virtio parameter server */
+#define VIRTIO_ID_AUDIO_POLICY 39 /* virtio audio policy */
+#define VIRTIO_ID_BT 40 /* virtio bluetooth */
+#define VIRTIO_ID_GPIO 41 /* virtio gpio */
+
+/*
+ * Virtio Transitional IDs
+ */
+
+#define VIRTIO_TRANS_ID_NET 1000 /* transitional virtio net */
+#define VIRTIO_TRANS_ID_BLOCK 1001 /* transitional virtio block */
+#define VIRTIO_TRANS_ID_BALLOON 1002 /* transitional virtio balloon */
+#define VIRTIO_TRANS_ID_CONSOLE 1003 /* transitional virtio console */
+#define VIRTIO_TRANS_ID_SCSI 1004 /* transitional virtio SCSI */
+#define VIRTIO_TRANS_ID_RNG 1005 /* transitional virtio rng */
+#define VIRTIO_TRANS_ID_9P 1009 /* transitional virtio 9p console */
#endif /* _LINUX_VIRTIO_IDS_H */
--
2.34.1

View File

@ -0,0 +1,239 @@
From e3610d3ea2c8d88c3dd61d845a682f74a1af1d1f Mon Sep 17 00:00:00 2001
Message-Id: <e3610d3ea2c8d88c3dd61d845a682f74a1af1d1f.1643220552.git.aclaudi@redhat.com>
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 26 Jan 2022 10:39:38 +0100
Subject: [PATCH] vdpa: Enable user to query vdpa device config layout
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2036880
Upstream Status: iproute2.git commit a311f0c4
commit a311f0c43a67be939dfafda563453a3f9bf30e42
Author: Parav Pandit <parav@nvidia.com>
Date: Fri Dec 17 10:08:25 2021 +0200
vdpa: Enable user to query vdpa device config layout
Query the device configuration layout whenever kernel supports it.
An example of configuration layout of vdpa device of type network:
$ vdpa dev add name bar mgmtdev vdpasim_net
$ vdpa dev config show
bar: mac 00:35:09:19:48:05 link up link_announce false mtu 1500
$ vdpa dev config show -jp
{
"config": {
"bar": {
"mac": "00:35:09:19:48:05",
"link ": "up",
"link_announce ": false,
"mtu": 1500,
}
}
}
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
man/man8/vdpa-dev.8 | 21 +++++++++
vdpa/vdpa.c | 110 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 131 insertions(+)
diff --git a/man/man8/vdpa-dev.8 b/man/man8/vdpa-dev.8
index 36433519..5d3a3f26 100644
--- a/man/man8/vdpa-dev.8
+++ b/man/man8/vdpa-dev.8
@@ -36,6 +36,10 @@ vdpa-dev \- vdpa device configuration
.B vdpa dev del
.I DEV
+.ti -8
+.B vdpa dev config show
+.RI "[ " DEV " ]"
+
.SH "DESCRIPTION"
.SS vdpa dev show - display vdpa device attributes
@@ -65,6 +69,18 @@ Name of the management device to use for device addition.
.I "DEV"
- specifies the vdpa device to delete.
+.SS vdpa dev config show - Show configuration of specific device or all devices.
+
+.PP
+.I "DEV"
+- specifies the vdpa device to show its configuration.
+If this argument is omitted all devices configuration is listed.
+
+.in +4
+Format is:
+.in +2
+VDPA_DEVICE_NAME
+
.SH "EXAMPLES"
.PP
vdpa dev show
@@ -86,6 +102,11 @@ vdpa dev del foo
.RS 4
Delete the vdpa device named foo which was previously created.
.RE
+.PP
+vdpa dev config show foo
+.RS 4
+Shows the vdpa device configuration of device named foo.
+.RE
.SH SEE ALSO
.BR vdpa (8),
diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
index 7fdb36b9..ba704254 100644
--- a/vdpa/vdpa.c
+++ b/vdpa/vdpa.c
@@ -6,9 +6,11 @@
#include <linux/genetlink.h>
#include <linux/vdpa.h>
#include <linux/virtio_ids.h>
+#include <linux/virtio_net.h>
#include <linux/netlink.h>
#include <libmnl/libmnl.h>
#include "mnl_utils.h"
+#include <rt_names.h>
#include "version.h"
#include "json_print.h"
@@ -413,6 +415,7 @@ static void cmd_dev_help(void)
fprintf(stderr, "Usage: vdpa dev show [ DEV ]\n");
fprintf(stderr, " vdpa dev add name NAME mgmtdev MANAGEMENTDEV\n");
fprintf(stderr, " vdpa dev del DEV\n");
+ fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");
}
static const char *device_type_name(uint32_t type)
@@ -520,6 +523,111 @@ static int cmd_dev_del(struct vdpa *vdpa, int argc, char **argv)
return mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, NULL, NULL);
}
+static void pr_out_dev_net_config(struct nlattr **tb)
+{
+ SPRINT_BUF(macaddr);
+ uint16_t val_u16;
+
+ if (tb[VDPA_ATTR_DEV_NET_CFG_MACADDR]) {
+ const unsigned char *data;
+ uint16_t len;
+
+ len = mnl_attr_get_payload_len(tb[VDPA_ATTR_DEV_NET_CFG_MACADDR]);
+ data = mnl_attr_get_payload(tb[VDPA_ATTR_DEV_NET_CFG_MACADDR]);
+
+ print_string(PRINT_ANY, "mac", "mac %s ",
+ ll_addr_n2a(data, len, 0, macaddr, sizeof(macaddr)));
+ }
+ if (tb[VDPA_ATTR_DEV_NET_STATUS]) {
+ val_u16 = mnl_attr_get_u16(tb[VDPA_ATTR_DEV_NET_STATUS]);
+ print_string(PRINT_ANY, "link ", "link %s ",
+ (val_u16 & VIRTIO_NET_S_LINK_UP) ? "up" : "down");
+ print_bool(PRINT_ANY, "link_announce ", "link_announce %s ",
+ (val_u16 & VIRTIO_NET_S_ANNOUNCE) ? true : false);
+ }
+ if (tb[VDPA_ATTR_DEV_NET_CFG_MAX_VQP]) {
+ val_u16 = mnl_attr_get_u16(tb[VDPA_ATTR_DEV_NET_CFG_MAX_VQP]);
+ print_uint(PRINT_ANY, "max_vq_pairs", "max_vq_pairs %d ",
+ val_u16);
+ }
+ if (tb[VDPA_ATTR_DEV_NET_CFG_MTU]) {
+ val_u16 = mnl_attr_get_u16(tb[VDPA_ATTR_DEV_NET_CFG_MTU]);
+ print_uint(PRINT_ANY, "mtu", "mtu %d ", val_u16);
+ }
+}
+
+static void pr_out_dev_config(struct vdpa *vdpa, struct nlattr **tb)
+{
+ uint32_t device_id = mnl_attr_get_u32(tb[VDPA_ATTR_DEV_ID]);
+
+ pr_out_vdev_handle_start(vdpa, tb);
+ switch (device_id) {
+ case VIRTIO_ID_NET:
+ pr_out_dev_net_config(tb);
+ break;
+ default:
+ break;
+ }
+ pr_out_vdev_handle_end(vdpa);
+}
+
+static int cmd_dev_config_show_cb(const struct nlmsghdr *nlh, void *data)
+{
+ struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+ struct nlattr *tb[VDPA_ATTR_MAX + 1] = {};
+ struct vdpa *vdpa = data;
+
+ mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+ if (!tb[VDPA_ATTR_DEV_NAME] || !tb[VDPA_ATTR_DEV_ID])
+ return MNL_CB_ERROR;
+ pr_out_dev_config(vdpa, tb);
+ return MNL_CB_OK;
+}
+
+static int cmd_dev_config_show(struct vdpa *vdpa, int argc, char **argv)
+{
+ uint16_t flags = NLM_F_REQUEST | NLM_F_ACK;
+ struct nlmsghdr *nlh;
+ int err;
+
+ if (argc <= 0)
+ flags |= NLM_F_DUMP;
+
+ nlh = mnlu_gen_socket_cmd_prepare(&vdpa->nlg, VDPA_CMD_DEV_CONFIG_GET,
+ flags);
+ if (argc > 0) {
+ err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
+ VDPA_OPT_VDEV_HANDLE);
+ if (err)
+ return err;
+ }
+
+ pr_out_section_start(vdpa, "config");
+ err = mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, cmd_dev_config_show_cb, vdpa);
+ pr_out_section_end(vdpa);
+ return err;
+}
+
+static void cmd_dev_config_help(void)
+{
+ fprintf(stderr, "Usage: vdpa dev config show [ DEV ]\n");
+}
+
+static int cmd_dev_config(struct vdpa *vdpa, int argc, char **argv)
+{
+ if (!argc)
+ return cmd_dev_config_show(vdpa, argc - 1, argv + 1);
+
+ if (matches(*argv, "help") == 0) {
+ cmd_dev_config_help();
+ return 0;
+ } else if (matches(*argv, "show") == 0) {
+ return cmd_dev_config_show(vdpa, argc - 1, argv + 1);
+ }
+ fprintf(stderr, "Command \"%s\" not found\n", *argv);
+ return -ENOENT;
+}
+
static int cmd_dev(struct vdpa *vdpa, int argc, char **argv)
{
if (!argc)
@@ -535,6 +643,8 @@ static int cmd_dev(struct vdpa *vdpa, int argc, char **argv)
return cmd_dev_add(vdpa, argc - 1, argv + 1);
} else if (matches(*argv, "del") == 0) {
return cmd_dev_del(vdpa, argc - 1, argv + 1);
+ } else if (matches(*argv, "config") == 0) {
+ return cmd_dev_config(vdpa, argc - 1, argv + 1);
}
fprintf(stderr, "Command \"%s\" not found\n", *argv);
return -ENOENT;
--
2.34.1

View File

@ -0,0 +1,233 @@
From 33a786460c3ef992e5a8d7a1be7ef5aac8860ba9 Mon Sep 17 00:00:00 2001
Message-Id: <33a786460c3ef992e5a8d7a1be7ef5aac8860ba9.1643220552.git.aclaudi@redhat.com>
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1643220552.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 26 Jan 2022 10:39:38 +0100
Subject: [PATCH] vdpa: Enable user to set mac address of vdpa device
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2036880
Upstream Status: iproute2.git commit 384938f9
commit 384938f9b00f2d203603e0919f23ae6857a14d96
Author: Parav Pandit <parav@nvidia.com>
Date: Fri Dec 17 10:08:26 2021 +0200
vdpa: Enable user to set mac address of vdpa device
vdpa: Enable user to set mtu of the vdpa device
Implement mtu setting for vdpa device.
$ vdpa mgmtdev show
vdpasim_net:
supported_classes net
Add the device with specified mac address:
$ vdpa dev add name bar mgmtdev vdpasim_net mac 00:11:22:33:44:55
View the config after setting:
$ vdpa dev config show
bar: mac 00:11:22:33:44:55 link up link_announce false mtu 1500
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
man/man8/vdpa-dev.8 | 11 ++++++++++
vdpa/vdpa.c | 52 ++++++++++++++++++++++++++++++++++++---------
2 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/man/man8/vdpa-dev.8 b/man/man8/vdpa-dev.8
index 5d3a3f26..5c5ac469 100644
--- a/man/man8/vdpa-dev.8
+++ b/man/man8/vdpa-dev.8
@@ -31,6 +31,7 @@ vdpa-dev \- vdpa device configuration
.I NAME
.B mgmtdev
.I MGMTDEV
+.RI "[ mac " MACADDR " ]"
.ti -8
.B vdpa dev del
@@ -63,6 +64,11 @@ Name of the new vdpa device to add.
.BI mgmtdev " MGMTDEV"
Name of the management device to use for device addition.
+.PP
+.BI mac " MACADDR"
+- specifies the mac address for the new vdpa device.
+This is applicable only for the network type of vdpa device. This is optional.
+
.SS vdpa dev del - Delete the vdpa device.
.PP
@@ -98,6 +104,11 @@ vdpa dev add name foo mgmtdev vdpa_sim_net
Add the vdpa device named foo on the management device vdpa_sim_net.
.RE
.PP
+vdpa dev add name foo mgmtdev vdpa_sim_net mac 00:11:22:33:44:55
+.RS 4
+Add the vdpa device named foo on the management device vdpa_sim_net with mac address of 00:11:22:33:44:55.
+.RE
+.PP
vdpa dev del foo
.RS 4
Delete the vdpa device named foo which was previously created.
diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c
index ba704254..63d464d1 100644
--- a/vdpa/vdpa.c
+++ b/vdpa/vdpa.c
@@ -4,6 +4,7 @@
#include <getopt.h>
#include <errno.h>
#include <linux/genetlink.h>
+#include <linux/if_ether.h>
#include <linux/vdpa.h>
#include <linux/virtio_ids.h>
#include <linux/virtio_net.h>
@@ -20,6 +21,7 @@
#define VDPA_OPT_VDEV_MGMTDEV_HANDLE BIT(1)
#define VDPA_OPT_VDEV_NAME BIT(2)
#define VDPA_OPT_VDEV_HANDLE BIT(3)
+#define VDPA_OPT_VDEV_MAC BIT(4)
struct vdpa_opts {
uint64_t present; /* flags of present items */
@@ -27,6 +29,7 @@ struct vdpa_opts {
char *mdev_name;
const char *vdev_name;
unsigned int device_id;
+ char mac[ETH_ALEN];
};
struct vdpa {
@@ -136,6 +139,21 @@ static int vdpa_argv_str(struct vdpa *vdpa, int argc, char **argv,
return 0;
}
+static int vdpa_argv_mac(struct vdpa *vdpa, int argc, char **argv, char *mac)
+{
+ int alen;
+
+ if (argc <= 0 || *argv == NULL) {
+ fprintf(stderr, "String parameter expected\n");
+ return -EINVAL;
+ }
+
+ alen = ll_addr_a2n(mac, ETH_ALEN, *argv);
+ if (alen < 0)
+ return -EINVAL;
+ return 0;
+}
+
struct vdpa_args_metadata {
uint64_t o_flag;
const char *err_msg;
@@ -183,13 +201,16 @@ static void vdpa_opts_put(struct nlmsghdr *nlh, struct vdpa *vdpa)
if ((opts->present & VDPA_OPT_VDEV_NAME) ||
(opts->present & VDPA_OPT_VDEV_HANDLE))
mnl_attr_put_strz(nlh, VDPA_ATTR_DEV_NAME, opts->vdev_name);
+ if (opts->present & VDPA_OPT_VDEV_MAC)
+ mnl_attr_put(nlh, VDPA_ATTR_DEV_NET_CFG_MACADDR,
+ sizeof(opts->mac), opts->mac);
}
static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
- uint64_t o_required)
+ uint64_t o_required, uint64_t o_optional)
{
+ uint64_t o_all = o_required | o_optional;
struct vdpa_opts *opts = &vdpa->opts;
- uint64_t o_all = o_required;
uint64_t o_found = 0;
int err;
@@ -233,6 +254,15 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
NEXT_ARG_FWD();
o_found |= VDPA_OPT_VDEV_MGMTDEV_HANDLE;
+ } else if ((strcmp(*argv, "mac") == 0) &&
+ (o_all & VDPA_OPT_VDEV_MAC)) {
+ NEXT_ARG_FWD();
+ err = vdpa_argv_mac(vdpa, argc, argv, opts->mac);
+ if (err)
+ return err;
+
+ NEXT_ARG_FWD();
+ o_found |= VDPA_OPT_VDEV_MAC;
} else {
fprintf(stderr, "Unknown option \"%s\"\n", *argv);
return -EINVAL;
@@ -246,11 +276,11 @@ static int vdpa_argv_parse(struct vdpa *vdpa, int argc, char **argv,
static int vdpa_argv_parse_put(struct nlmsghdr *nlh, struct vdpa *vdpa,
int argc, char **argv,
- uint64_t o_required)
+ uint64_t o_required, uint64_t o_optional)
{
int err;
- err = vdpa_argv_parse(vdpa, argc, argv, o_required);
+ err = vdpa_argv_parse(vdpa, argc, argv, o_required, o_optional);
if (err)
return err;
vdpa_opts_put(nlh, vdpa);
@@ -386,7 +416,7 @@ static int cmd_mgmtdev_show(struct vdpa *vdpa, int argc, char **argv)
flags);
if (argc > 0) {
err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
- VDPA_OPT_MGMTDEV_HANDLE);
+ VDPA_OPT_MGMTDEV_HANDLE, 0);
if (err)
return err;
}
@@ -413,7 +443,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\n");
+ fprintf(stderr, " vdpa dev add name NAME mgmtdev MANAGEMENTDEV [ mac MACADDR ]\n");
fprintf(stderr, " vdpa dev del DEV\n");
fprintf(stderr, "Usage: vdpa dev config COMMAND [ OPTIONS ]\n");
}
@@ -483,7 +513,7 @@ static int cmd_dev_show(struct vdpa *vdpa, int argc, char **argv)
nlh = mnlu_gen_socket_cmd_prepare(&vdpa->nlg, VDPA_CMD_DEV_GET, flags);
if (argc > 0) {
err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
- VDPA_OPT_VDEV_HANDLE);
+ VDPA_OPT_VDEV_HANDLE, 0);
if (err)
return err;
}
@@ -502,7 +532,8 @@ static int cmd_dev_add(struct vdpa *vdpa, int argc, char **argv)
nlh = mnlu_gen_socket_cmd_prepare(&vdpa->nlg, VDPA_CMD_DEV_NEW,
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_MGMTDEV_HANDLE | VDPA_OPT_VDEV_NAME,
+ VDPA_OPT_VDEV_MAC);
if (err)
return err;
@@ -516,7 +547,8 @@ static int cmd_dev_del(struct vdpa *vdpa, int argc, char **argv)
nlh = mnlu_gen_socket_cmd_prepare(&vdpa->nlg, VDPA_CMD_DEV_DEL,
NLM_F_REQUEST | NLM_F_ACK);
- err = vdpa_argv_parse_put(nlh, vdpa, argc, argv, VDPA_OPT_VDEV_HANDLE);
+ err = vdpa_argv_parse_put(nlh, vdpa, argc, argv, VDPA_OPT_VDEV_HANDLE,
+ 0);
if (err)
return err;
@@ -597,7 +629,7 @@ static int cmd_dev_config_show(struct vdpa *vdpa, int argc, char **argv)
flags);
if (argc > 0) {
err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
- VDPA_OPT_VDEV_HANDLE);
+ VDPA_OPT_VDEV_HANDLE, 0);
if (err)
return err;
}
--
2.34.1

View File

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

View File

@ -1,7 +1,7 @@
Summary: Advanced IP routing and network device configuration tools
Name: iproute
Version: 5.15.0
Release: 1%{?dist}%{?buildid}
Release: 2%{?dist}%{?buildid}
Group: Applications/System
URL: https://kernel.org/pub/linux/utils/net/%{name}2/
Source0: https://kernel.org/pub/linux/utils/net/%{name}2/%{name}2-%{version}.tar.xz
@ -13,6 +13,10 @@ Patch3: 0004-configure-simplify-options-parsing.patch
Patch4: 0005-configure-support-param-value-style.patch
Patch5: 0006-configure-add-the-prefix-option.patch
Patch6: 0007-configure-add-the-libdir-option.patch
Patch7: 0008-vdpa-align-uapi-headers.patch
Patch8: 0009-vdpa-Enable-user-to-query-vdpa-device-config-layout.patch
Patch9: 0010-vdpa-Enable-user-to-set-mac-address-of-vdpa-device.patch
Patch10: 0011-vdpa-Enable-user-to-set-mtu-of-the-vdpa-device.patch
License: GPLv2+ and Public Domain
BuildRequires: bison
@ -131,6 +135,12 @@ cat %{SOURCE1} >>%{buildroot}%{_sysconfdir}/iproute2/rt_dsfield
%{_includedir}/iproute2/bpf_elf.h
%changelog
* Wed Jan 26 2022 Andrea Claudi <aclaudi@redhat.com> - 5.15.0-2.el8
- vdpa: Enable user to set mtu of the vdpa device (Andrea Claudi) [2036880]
- vdpa: Enable user to set mac address of vdpa device (Andrea Claudi) [2036880]
- vdpa: Enable user to query vdpa device config layout (Andrea Claudi) [2036880]
- vdpa: align uapi headers (Andrea Claudi) [2036880]
* Tue Nov 23 2021 Andrea Claudi <aclaudi@redhat.com> - 5.15.0-1.el8
- New version 5.15.0 (Andrea Claudi) [2016061]