Skip to contentSkip to conversation

vdpa tool to query and set config layout

PATCH In review Parav Pandit 3 participants 12 messages Dec 17, 2021 – Dec 20, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover vdpa tool to query and set config layout

This series implements querying and setting of the mac address and mtu device config fields of the vdpa device of type net.

An example of query and set as below.

$ vdpa dev add name bar mgmtdev vdpasim_net mac 00:11:22:33:44:55 mtu 9000
$ vdpa dev config show
bar: mac 00:11:22:33:44:55 link up link_announce false mtu 9000
$ vdpa dev config show -jp
{
    "config": {
        "bar": {
            "mac": "00:11:22:33:44:55",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500,
        }
    }
}

patch summary:
patch-1 updates the kernel headers
patch-2 implements the query command
patch-3 implements setting the mac address of vdpa dev config space patch-4 implements setting the mtu of vdpa dev config space

changelog:
v1->v2:
- addressed comments from David
- added man page
- using get_u16
- using strcmp() instead of matches() for arguments

Parav Pandit (4):
vdpa: Update kernel headers
vdpa: Enable user to query vdpa device config layout
vdpa: Enable user to set mac address of vdpa device
vdpa: Enable user to set mtu of the vdpa device

 include/uapi/linux/virtio_net.h |  81 ++++++++++++++
 man/man8/vdpa-dev.8             |  42 ++++++++
 vdpa/include/uapi/linux/vdpa.h  |   7 ++
 vdpa/vdpa.c                     | 184 ++++++++++++++++++++++++++++++--
 4 files changed, 305 insertions(+), 9 deletions(-)
 create mode 100644 include/uapi/linux/virtio_net.h
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/4 vdpa: Update kernel headers

Update kernel headers to commit:
ad69dd0bf26b ("vdpa: Introduce query of device config layout")

---
 include/uapi/linux/virtio_net.h | 81 +++++++++++++++++++++++++++++++++
 vdpa/include/uapi/linux/vdpa.h  |  7 +++
 2 files changed, 88 insertions(+)
 create mode 100644 include/uapi/linux/virtio_net.h
include/uapi/linux/virtio_net.h new file +81 -0
new file mode 100644
index 00000000..d52965cf
@@ -0,0 +1,81 @@
+#ifndef _LINUX_VIRTIO_NET_H
+#define _LINUX_VIRTIO_NET_H
+/* This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE. */
+
+/* The feature bitmap for virtio net */
+#define VIRTIO_NET_F_CSUM	0	/* Host handles pkts w/ partial csum */
+#define VIRTIO_NET_F_GUEST_CSUM	1	/* Guest handles pkts w/ partial csum */
+#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */
+#define VIRTIO_NET_F_MTU	3	/* Initial MTU advice */
+#define VIRTIO_NET_F_MAC	5	/* Host has given MAC address. */
+#define VIRTIO_NET_F_GUEST_TSO4	7	/* Guest can handle TSOv4 in. */
+#define VIRTIO_NET_F_GUEST_TSO6	8	/* Guest can handle TSOv6 in. */
+#define VIRTIO_NET_F_GUEST_ECN	9	/* Guest can handle TSO[6] w/ ECN in. */
+#define VIRTIO_NET_F_GUEST_UFO	10	/* Guest can handle UFO in. */
+#define VIRTIO_NET_F_HOST_TSO4	11	/* Host can handle TSOv4 in. */
+#define VIRTIO_NET_F_HOST_TSO6	12	/* Host can handle TSOv6 in. */
+#define VIRTIO_NET_F_HOST_ECN	13	/* Host can handle TSO[6] w/ ECN in. */
+#define VIRTIO_NET_F_HOST_UFO	14	/* Host can handle UFO in. */
+#define VIRTIO_NET_F_MRG_RXBUF	15	/* Host can merge receive buffers. */
+#define VIRTIO_NET_F_STATUS	16	/* virtio_net_config.status available */
+#define VIRTIO_NET_F_CTRL_VQ	17	/* Control channel available */
+#define VIRTIO_NET_F_CTRL_RX	18	/* Control channel RX mode support */
+#define VIRTIO_NET_F_CTRL_VLAN	19	/* Control channel VLAN filtering */
+#define VIRTIO_NET_F_CTRL_RX_EXTRA 20	/* Extra RX mode control support */
+#define VIRTIO_NET_F_GUEST_ANNOUNCE 21	/* Guest can announce device on the
+					 * network */
+#define VIRTIO_NET_F_MQ	22	/* Device supports Receive Flow
+					 * Steering */
+#define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
+
+#define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
+#define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
+#define VIRTIO_NET_F_RSC_EXT	  61	/* extended coalescing info */
+#define VIRTIO_NET_F_STANDBY	  62	/* Act as standby for another device
+					 * with the same MAC.
+					 */
+#define VIRTIO_NET_F_SPEED_DUPLEX 63	/* Device set linkspeed and duplex */
+
+#ifndef VIRTIO_NET_NO_LEGACY
+#define VIRTIO_NET_F_GSO	6	/* Host handles pkts w/ any GSO type */
+#endif /* VIRTIO_NET_NO_LEGACY */
+
+#define VIRTIO_NET_S_LINK_UP	1	/* Link is up */
+#define VIRTIO_NET_S_ANNOUNCE	2	/* Announcement is needed */
+
+/* supported/enabled hash types */
+#define VIRTIO_NET_RSS_HASH_TYPE_IPv4          (1 << 0)
+#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4         (1 << 1)
+#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4         (1 << 2)
+#define VIRTIO_NET_RSS_HASH_TYPE_IPv6          (1 << 3)
+#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6         (1 << 4)
+#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6         (1 << 5)
+#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX         (1 << 6)
+#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX        (1 << 7)
+#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX        (1 << 8)
+
+#endif /* _LINUX_VIRTIO_NET_H */
vdpa/include/uapi/linux/vdpa.h +7 -0
index 37ae26b6..b7eab069 100644
@@ -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,
Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/4 vdpa: Enable user to query vdpa device config layout

In reply to Parav Pandit

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,
        }
    }
}

---
changelog:
v1->v2:
- added man page

---
 man/man8/vdpa-dev.8 |  21 +++++++++
 vdpa/vdpa.c         | 110 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 131 insertions(+)
man/man8/vdpa-dev.8 +21 -0
index 36433519..5d3a3f26 100644
@@ -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),
vdpa/vdpa.c +110 -0

137 lines not on this page · raw message

Signature · 1 line
2.26.2
#3 lore raw

PATCH v2 3/4 vdpa: Enable user to set mac address of vdpa device

In reply to Parav Pandit

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

---
changelog:
v1->v2:
- use strcmp() instead of matches()
- added man page

---
 man/man8/vdpa-dev.8 | 11 ++++++++++
 vdpa/vdpa.c         | 52 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 53 insertions(+), 10 deletions(-)
man/man8/vdpa-dev.8 +11 -0
index 5d3a3f26..5c5ac469 100644
@@ -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.
vdpa/vdpa.c +42 -10

138 lines not on this page · raw message

Signature · 1 line
2.26.2
#4 lore raw

PATCH v2 4/4 vdpa: Enable user to set mtu of the vdpa device

In reply to Parav Pandit

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

---
changelog:
v1->v2:
- use get_u16
- use strcmp() instead of matches()
- added man page

---
 man/man8/vdpa-dev.8 | 10 ++++++++++
 vdpa/vdpa.c         | 28 ++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)
man/man8/vdpa-dev.8 +10 -0
index 5c5ac469..aa21ae3a 100644
@@ -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.
vdpa/vdpa.c +26 -2
index 63d464d1..f048e470 100644
@@ -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;
 
Signature · 1 line
2.26.2
#5 lore raw

Re: [iproute2-next v2 4/4] vdpa: Enable user to set mtu of the vdpa device

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

Quoted 6 lines · Parav Pandit
vdpa/vdpa.c +2 -0
@@ -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);

Why limit the MTU to a u16? Eric for example is working on "Big TCP" where IPv6 can work with Jumbograms where mtu can be > 64k.

https://datatracker.ietf.org/doc/html/rfc2675

#6 lore raw

Re: [iproute2-next v2 4/4] vdpa: Enable user to set mtu of the vdpa device

Quoted 11 lines · David Ahern

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

Quoted 6 lines · Parav Pandit
vdpa/vdpa.c +2 -0
@@ -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);

Why limit the MTU to a u16? Eric for example is working on "Big TCP" where IPv6 can work with Jumbograms where mtu can be > 64k.

Quoted 1 line

https://datatracker.ietf.org/doc/html/rfc2675

Well it's 16 bit at the virtio level, though we can extend that of course. Making it match for now removes need for validation.

Signature · 1 line
MST
#7 lore raw

RE: [iproute2-next v2 4/4] vdpa: Enable user to set mtu of the vdpa device

Quoted 16 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Sunday, December 19, 2021 3:37 AM

Quoted 2 lines · David Ahern

Review static void vdpa_opts_put(struct nlmsghdr *nlh,

Quoted 1 line · Parav Pandit
(quoted diff) +0 -0
@@ -204,6 +217,8 @@ static void vdpa_opts_put(struct nlmsghdr *nlh,

struct vdpa *vdpa)

Quoted 5 lines

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

Quoted 5 lines
vdpa/vdpa.c +2 -0
 	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);

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

Why limit the MTU to a u16? Eric for example is working on "Big TCP" where IPv6 can work with Jumbograms where mtu can be > 64k.

https://datatracker.ietf.org/doc/html/rfc2675

Well it's 16 bit at the virtio level, though we can extend that of course. Making it match for now removes need for validation.
--

As Michael mentioned virtio specification limits the mtu to 64k-1. Hence 16-bit.
First we need to update the virtio spec to support > 64K mtu.
However, when/if (I don't know when) that happens, we need to make this also u32.
So may be we can make it u32 now, but still restrict the mtu value to 64k-1 in kernel, until the spec is updated.

Let me know, if you think that's future proofing is better, I first need to update the kernel to take nla u32.

Quoted 1 line

MST

#8 lore raw

Re: [iproute2-next v2 4/4] vdpa: Enable user to set mtu of the vdpa device

Quoted 24 lines · Parav Pandit
Quoted 16 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Sunday, December 19, 2021 3:37 AM

Quoted 2 lines · David Ahern

Review static void vdpa_opts_put(struct nlmsghdr *nlh,

Quoted 1 line · Parav Pandit
(quoted diff) +0 -0
@@ -204,6 +217,8 @@ static void vdpa_opts_put(struct nlmsghdr *nlh,

struct vdpa *vdpa)

Quoted 5 lines

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

Quoted 5 lines
vdpa/vdpa.c +2 -0
 	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);

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

Why limit the MTU to a u16? Eric for example is working on "Big TCP" where IPv6 can work with Jumbograms where mtu can be > 64k.

https://datatracker.ietf.org/doc/html/rfc2675

Well it's 16 bit at the virtio level, though we can extend that of course. Making it match for now removes need for validation.
--

Quoted 8 lines

As Michael mentioned virtio specification limits the mtu to 64k-1. Hence 16-bit.
First we need to update the virtio spec to support > 64K mtu.
However, when/if (I don't know when) that happens, we need to make this also u32.
So may be we can make it u32 now, but still restrict the mtu value to 64k-1 in kernel, until the spec is updated.

Let me know, if you think that's future proofing is better, I first need to update the kernel to take nla u32.

Quoted 1 line

MST

After consideration, this future proofing seems like a good thing to have.

Signature · 1 line
MST
#9 lore raw

RE: [iproute2-next v2 4/4] vdpa: Enable user to set mtu of the vdpa device

Quoted 38 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Monday, December 20, 2021 5:33 PM

Quoted 7 lines · Parav Pandit
Quoted 7 lines

From: Michael S. Tsirkin <[email protected]>
Sent: Sunday, December 19, 2021 3:37 AM

Quoted 1 line · David Ahern

On 12/17/21 1:08 AM, Parav Pandit wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Review static void vdpa_opts_put(struct nlmsghdr · line 217

Quoted 2 lines
(quoted diff) +0 -0
@@ -204,6 +217,8 @@ static void vdpa_opts_put(struct nlmsghdr
 *nlh,

struct vdpa *vdpa)

Quoted 5 lines

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

Quoted 5 lines
vdpa/vdpa.c +2 -0
 	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,

Quoted 11 lines
Quoted 10 lines

opts->mtu);

Quoted 5 lines

Why limit the MTU to a u16? Eric for example is working on "Big TCP" where IPv6 can work with Jumbograms where mtu can be > 64k.

https://datatracker.ietf.org/doc/html/rfc2675

Well it's 16 bit at the virtio level, though we can extend that of course. Making it match for now removes need for validation. --

As Michael mentioned virtio specification limits the mtu to 64k-1. Hence 16-

bit.

Quoted 2 lines

First we need to update the virtio spec to support > 64K mtu. However, when/if (I don't know when) that happens, we need to make this

also u32.

Quoted 1 line

So may be we can make it u32 now, but still restrict the mtu value to 64k-1 in

Quoted 8 lines

kernel, until the spec is updated.

Quoted 2 lines

Let me know, if you think that's future proofing is better, I first need to

update the kernel to take nla u32.

Quoted 2 lines
Quoted 2 lines

MST

After consideration, this future proofing seems like a good thing to have.

Ok. I will first get kernel change merged, after which will send v3 for iproute2.

#10 lore raw

Re: [iproute2-next v2 4/4] vdpa: Enable user to set mtu of the vdpa device

Quoted 2 lines · Parav Pandit
Quoted 1 line

After consideration, this future proofing seems like a good thing to have.

Ok. I will first get kernel change merged, after which will send v3 for iproute2.

this set has been committed; not sure what happened to the notification from patchworks bot.

#11 lore raw

Re: [iproute2-next v2 4/4] vdpa: Enable user to set mtu of the vdpa device

Quoted 6 lines · David Ahern
Quoted 2 lines · Parav Pandit
Quoted 1 line

After consideration, this future proofing seems like a good thing to have.

Ok. I will first get kernel change merged, after which will send v3 for iproute2.

this set has been committed; not sure what happened to the notification from patchworks bot.

OK in that case it's too late, so maybe let's worry about supporting extensions later when we actually need them, in particular when linux better supports mtu > 64k.

Signature · 1 line
MST