Skip to contentSkip to conversation

vdpa: add the support to set mac address and MTU

PATCH In review Cindy Lu 2 participants 3 messages Jul 9, 2024

Subsystems (2)
lore
Share & tools
lore

Cindy Lu

author
#0 lore raw

PATCH v2 1/1 vdpa: add the support to set mac address and MTU

Add new function to support the MAC address and MTU from VDPA tool. The kernel now only supports setting the MAC address.

The usage is vdpa dev set name vdpa_name mac **:**:**:**:**

here is sample:

root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "82:4d:e9:5d:d7:e6",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}
root@L1# vdpa dev set name vdpa0 mac 00:11:22:33:44:55
root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "00:11:22:33:44:55",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}
---
 man/man8/vdpa-dev.8            | 20 ++++++++++++++++++++
 vdpa/include/uapi/linux/vdpa.h |  1 +
 vdpa/vdpa.c                    | 19 +++++++++++++++++++
 3 files changed, 40 insertions(+)
man/man8/vdpa-dev.8 +20 -0
index 43e5bf48..718f40b2 100644
@@ -50,6 +50,12 @@ vdpa-dev \- vdpa device configuration
 .B qidx
 .I QUEUE_INDEX
 
+.ti -8
+.B vdpa dev set
+.B name
+.I NAME
+.B mac
+.RI "[ " MACADDR " ]"
 
 .SH "DESCRIPTION"
 .SS vdpa dev show - display vdpa device attributes
@@ -120,6 +126,15 @@ VDPA_DEVICE_NAME
 .BI qidx " QUEUE_INDEX"
 - specifies the virtqueue index to query
 
+.SS vdpa dev set - set the configuration to the vdpa device.
+
+.BI name " NAME"
+-Name of the vdpa device to configure.
+
+.BI mac " MACADDR"
+- specifies the mac address for the vdpa device.
+This is applicable only for the network type of vdpa device.
+
 .SH "EXAMPLES"
 .PP
 vdpa dev show
@@ -171,6 +186,11 @@ vdpa dev vstats show vdpa0 qidx 1
 .RS 4
 Shows vendor specific statistics information for vdpa device vdpa0 and virtqueue index 1
 .RE
+.PP
+vdpa dev set name vdpa0 mac 00:11:22:33:44:55
+.RS 4
+Set a specific MAC address to vdpa device vdpa0
+.RE
 
 .SH SEE ALSO
 .BR vdpa (8),
vdpa/include/uapi/linux/vdpa.h +1 -0
index 8586bd17..bc23c731 100644
@@ -19,6 +19,7 @@ enum vdpa_command {
 	VDPA_CMD_DEV_GET,		/* can dump */
 	VDPA_CMD_DEV_CONFIG_GET,	/* can dump */
 	VDPA_CMD_DEV_VSTATS_GET,
+	VDPA_CMD_DEV_ATTR_SET,
 };
 
 enum vdpa_attr {
vdpa/vdpa.c +19 -0
index 6e4a9c11..4b444b6a 100644
@@ -758,6 +758,22 @@ static int cmd_dev_del(struct vdpa *vdpa,  int argc, char **argv)
 	return mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, NULL, NULL);
 }
 
+static int cmd_dev_set(struct vdpa *vdpa, int argc, char **argv)
+{
+	struct nlmsghdr *nlh;
+	int err;
+
+	nlh = mnlu_gen_socket_cmd_prepare(&vdpa->nlg, VDPA_CMD_DEV_ATTR_SET,
+					  NLM_F_REQUEST | NLM_F_ACK);
+	err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
+				  VDPA_OPT_VDEV_NAME,
+				  VDPA_OPT_VDEV_MAC|VDPA_OPT_VDEV_MTU);
+	if (err)
+		return err;
+
+	return mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, NULL, NULL);
+}
+
 static void pr_out_dev_net_config(struct vdpa *vdpa, struct nlattr **tb)
 {
 	SPRINT_BUF(macaddr);
@@ -1028,6 +1044,9 @@ static int cmd_dev(struct vdpa *vdpa, int argc, char **argv)
 	} else if (!strcmp(*argv, "vstats")) {
 		return cmd_dev_vstats(vdpa, argc - 1, argv + 1);
 	}
+	else if (!strcmp(*argv, "set")) {
+		return cmd_dev_set(vdpa, argc - 1, argv + 1);
+	}
 	fprintf(stderr, "Command \"%s\" not found\n", *argv);
 	return -ENOENT;
 }
Signature · 1 line
2.45.0
#1 lore raw
Quoted 6 lines

From: Cindy Lu <[email protected]>
Sent: Tuesday, July 9, 2024 8:53 AM
Subject: [PATH v2] vdpa: add the support to set mac address and MTU

Please fix PATH to PATCH.

Quoted 3 lines

Add new function to support the MAC address and MTU from VDPA tool. The kernel now only supports setting the MAC address.

Please include only mac address setting for now in the example and documentation.
In the future when kernel supports setting the mtu, please extend vdpa tool at that point to add the option.

Quoted 115 lines

The usage is vdpa dev set name vdpa_name mac **:**:**:**:**

here is sample:

root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "82:4d:e9:5d:d7:e6",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}
root@L1# vdpa dev set name vdpa0 mac 00:11:22:33:44:55
root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "00:11:22:33:44:55",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}
---
 man/man8/vdpa-dev.8            | 20 ++++++++++++++++++++
 vdpa/include/uapi/linux/vdpa.h |  1 +
 vdpa/vdpa.c                    | 19 +++++++++++++++++++
 3 files changed, 40 insertions(+)
man/man8/vdpa-dev.8 index renamed from man/man8/vdpa-dev.8 +0 -0

43e5bf48..718f40b2 100644

man/man8/vdpa-dev.8 +0 -0
@@ -50,6 +50,12 @@ vdpa-dev \- vdpa device configuration  .B qidx  .I

QUEUE_INDEX

+.ti -8
+.B vdpa dev set
+.B name
+.I NAME
+.B mac
+.RI "[ " MACADDR " ]"

.SH "DESCRIPTION"
.SS vdpa dev show - display vdpa device attributes @@ -120,6 +126,15 @@
VDPA_DEVICE_NAME .BI qidx " QUEUE_INDEX"
- specifies the virtqueue index to query

+.SS vdpa dev set - set the configuration to the vdpa device.

man/man8/vdpa-dev.8 +8 -0
+
+.BI name " NAME"
+-Name of the vdpa device to configure.
+
+.BI mac " MACADDR"
+- specifies the mac address for the vdpa device.
+This is applicable only for the network type of vdpa device.
+
 .SH "EXAMPLES"
 .PP
 vdpa dev show
@@ -171,6 +186,11 @@ vdpa dev vstats show vdpa0 qidx 1  .RS 4  Shows

vendor specific statistics information for vdpa device vdpa0 and virtqueue index 1 .RE
+.PP

man/man8/vdpa-dev.8 +2 -0
+vdpa dev set name vdpa0 mac 00:11:22:33:44:55 .RS 4 Set a specific MAC
+address to vdpa device vdpa0 .RE
 
 .SH SEE ALSO
 .BR vdpa (8),
vdpa/include/uapi/linux/vdpa.h +1 -0
index 8586bd17..bc23c731 100644
@@ -19,6 +19,7 @@ enum vdpa_command {
 	VDPA_CMD_DEV_GET,		/* can dump */
 	VDPA_CMD_DEV_CONFIG_GET,	/* can dump */
 	VDPA_CMD_DEV_VSTATS_GET,
+	VDPA_CMD_DEV_ATTR_SET,
 };
 
 enum vdpa_attr {
vdpa/vdpa.c +14 -0
index 6e4a9c11..4b444b6a 100644
@@ -758,6 +758,22 @@ static int cmd_dev_del(struct vdpa *vdpa,  int argc,
 char **argv)
 	return mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, NULL, NULL);  }
 
+static int cmd_dev_set(struct vdpa *vdpa, int argc, char **argv) {
+	struct nlmsghdr *nlh;
+	int err;
+
+	nlh = mnlu_gen_socket_cmd_prepare(&vdpa->nlg,
 VDPA_CMD_DEV_ATTR_SET,
+					  NLM_F_REQUEST | NLM_F_ACK);
+	err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
+				  VDPA_OPT_VDEV_NAME,
+
 VDPA_OPT_VDEV_MAC|VDPA_OPT_VDEV_MTU);
+	if (err)
+		return err;
+
+	return mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, NULL, NULL); }
+
 static void pr_out_dev_net_config(struct vdpa *vdpa, struct nlattr **tb)  {
 	SPRINT_BUF(macaddr);

vdpa/vdpa.c static int cmd_dev(struct vdpa *vdpa, int argc, char · line 1050

Quoted 7 lines
vdpa/vdpa.c +3 -0
@@ -1028,6 +1044,9 @@ static int cmd_dev(struct vdpa *vdpa, int argc, char
 **argv)
 	} else if (!strcmp(*argv, "vstats")) {
 		return cmd_dev_vstats(vdpa, argc - 1, argv + 1);
 	}
+	else if (!strcmp(*argv, "set")) {
+		return cmd_dev_set(vdpa, argc - 1, argv + 1);
+	}

Else if can be in the previous line.

Quoted 5 lines
vdpa/vdpa.c +0 -0
 	fprintf(stderr, "Command \"%s\" not found\n", *argv);
 	return -ENOENT;

}
--
2.45.0

author
#2 lore raw
Quoted 130 lines · Parav Pandit
Quoted 7 lines

From: Cindy Lu <[email protected]>
Sent: Tuesday, July 9, 2024 8:53 AM
Subject: [PATH v2] vdpa: add the support to set mac address and MTU

Please fix PATH to PATCH.

Quoted 3 lines

Add new function to support the MAC address and MTU from VDPA tool. The kernel now only supports setting the MAC address.

Please include only mac address setting for now in the example and documentation.
In the future when kernel supports setting the mtu, please extend vdpa tool at that point to add the option.

Quoted 115 lines

The usage is vdpa dev set name vdpa_name mac **:**:**:**:**

here is sample:

root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "82:4d:e9:5d:d7:e6",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}
root@L1# vdpa dev set name vdpa0 mac 00:11:22:33:44:55
root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "00:11:22:33:44:55",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}
---
 man/man8/vdpa-dev.8            | 20 ++++++++++++++++++++
 vdpa/include/uapi/linux/vdpa.h |  1 +
 vdpa/vdpa.c                    | 19 +++++++++++++++++++
 3 files changed, 40 insertions(+)
man/man8/vdpa-dev.8 index renamed from man/man8/vdpa-dev.8 +0 -0

43e5bf48..718f40b2 100644

man/man8/vdpa-dev.8 +0 -0
@@ -50,6 +50,12 @@ vdpa-dev \- vdpa device configuration  .B qidx  .I

QUEUE_INDEX

+.ti -8
+.B vdpa dev set
+.B name
+.I NAME
+.B mac
+.RI "[ " MACADDR " ]"

.SH "DESCRIPTION"
.SS vdpa dev show - display vdpa device attributes @@ -120,6 +126,15 @@
VDPA_DEVICE_NAME .BI qidx " QUEUE_INDEX"
- specifies the virtqueue index to query

+.SS vdpa dev set - set the configuration to the vdpa device.

man/man8/vdpa-dev.8 +8 -0
+
+.BI name " NAME"
+-Name of the vdpa device to configure.
+
+.BI mac " MACADDR"
+- specifies the mac address for the vdpa device.
+This is applicable only for the network type of vdpa device.
+
 .SH "EXAMPLES"
 .PP
 vdpa dev show
@@ -171,6 +186,11 @@ vdpa dev vstats show vdpa0 qidx 1  .RS 4  Shows

vendor specific statistics information for vdpa device vdpa0 and virtqueue index 1 .RE
+.PP

man/man8/vdpa-dev.8 +2 -0
+vdpa dev set name vdpa0 mac 00:11:22:33:44:55 .RS 4 Set a specific MAC
+address to vdpa device vdpa0 .RE
 
 .SH SEE ALSO
 .BR vdpa (8),
vdpa/include/uapi/linux/vdpa.h +1 -0
index 8586bd17..bc23c731 100644
@@ -19,6 +19,7 @@ enum vdpa_command {
      VDPA_CMD_DEV_GET,               /* can dump */
      VDPA_CMD_DEV_CONFIG_GET,        /* can dump */
      VDPA_CMD_DEV_VSTATS_GET,
+     VDPA_CMD_DEV_ATTR_SET,
 };
 
 enum vdpa_attr {
vdpa/vdpa.c +14 -0
index 6e4a9c11..4b444b6a 100644
@@ -758,6 +758,22 @@ static int cmd_dev_del(struct vdpa *vdpa,  int argc,
 char **argv)
      return mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, NULL, NULL);  }
 
+static int cmd_dev_set(struct vdpa *vdpa, int argc, char **argv) {
+     struct nlmsghdr *nlh;
+     int err;
+
+     nlh = mnlu_gen_socket_cmd_prepare(&vdpa->nlg,
 VDPA_CMD_DEV_ATTR_SET,
+                                       NLM_F_REQUEST | NLM_F_ACK);
+     err = vdpa_argv_parse_put(nlh, vdpa, argc, argv,
+                               VDPA_OPT_VDEV_NAME,
+
 VDPA_OPT_VDEV_MAC|VDPA_OPT_VDEV_MTU);
+     if (err)
+             return err;
+
+     return mnlu_gen_socket_sndrcv(&vdpa->nlg, nlh, NULL, NULL); }
+
 static void pr_out_dev_net_config(struct vdpa *vdpa, struct nlattr **tb)  {
      SPRINT_BUF(macaddr);
@@ -1028,6 +1044,9 @@ static int cmd_dev(struct vdpa *vdpa, int argc, char
Quoted 9 lines

vdpa/vdpa.c static int cmd_dev(struct vdpa *vdpa, int argc, char **argv) · line 1049

Quoted 7 lines
vdpa/vdpa.c +3 -0
 **argv)
      } else if (!strcmp(*argv, "vstats")) {
              return cmd_dev_vstats(vdpa, argc - 1, argv + 1);
      }
+     else if (!strcmp(*argv, "set")) {
+             return cmd_dev_set(vdpa, argc - 1, argv + 1);
+     }

Else if can be in the previous line.

Thanks will fix this
Thanks
Cindy

Quoted 6 lines
Quoted 5 lines
vdpa/vdpa.c +0 -0
      fprintf(stderr, "Command \"%s\" not found\n", *argv);
      return -ENOENT;

}
--
2.45.0