naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0018-vdpa-Support-for-configuring-max-VQ-pairs-for-a-devi.patch

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