Skip to contentSkip to conversation

accel-config: Add mdev support

PATCH Superseded ramesh.thomas at intel.com 1 participant 28 messages Dec 2, 2020 – Dec 5, 2020 Documentation

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

ramesh.thomas at intel.com

#0 lore raw

cover accel-config: Add mdev support

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Implements vfio mdev support for wqs. This implementation uses wqs internally and user does not need to attach wqs. Mdevs are stored and listed in the context of devices.

Initially 2 types of mdevs, 1dwq and 1swq are supported. 1swq uses shared wq type while 1dwq uses dedicaed wq.

Implements both library and command interfaces.

Added improvements in test case management and clears up stale state after test failures.

Added support for "locked" wq state.

Added unit tests and man pages.

Ramesh Thomas (11):
accel-config: Add mdev path to device context
accel-config: Create mdev structures and load mdevs into device
context
accel-config: Add lib functions to list mdevs and retrieve mdev
properties
accel-config: Add mdev json support
accel-config: Implement create and remove mdev library API
accel-config: Add mdev create and remove commands
accel-config: Improve management of test cases
accel-config: Unit tests for mdev support
accel-config: Add wq locked state support
accel-config: Add documentation for mdev commands
accel-config: Clear conditions blocking unit test after failure

 .../accfg/accel-config-config-wq.txt          |  15 +
 .../accfg/accel-config-create-mdev.txt        |  32 +-
 .../accfg/accel-config-remove-mdev.txt        |  26 +-
 accfg/config.c                                |   5 +-
 accfg/enable.c                                |   4 +-
 accfg/lib/libaccel-config.sym                 |  11 +
 accfg/lib/libaccfg.c                          | 228 +++++++++++++-
 accfg/lib/private.h                           |   9 +
 accfg/libaccel_config.h                       |  28 +-
 accfg/mdev.c                                  | 123 +++++++-
 test/libaccfg.c                               | 277 +++++++++++++++---
 util/json.c                                   |  44 ++-
 12 files changed, 738 insertions(+), 64 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/11 accel-config: Add mdev path to device context

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

/sys/class/mdev_bus/<bdf> is used often to access mdevs associated with the device. Generate and store in device so it need not be constructed everytime.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c | 17 +++++++++++++++++
 accfg/lib/private.h  |  1 +
 2 files changed, 18 insertions(+)
accfg/lib/libaccfg.c +17 -0
index cd9da42..9b5615a 100644
@@ -194,6 +194,7 @@ static void free_device(struct accfg_device *device, struct list_head *head)
 		list_del_from(head, &device->list);
 	free(device->device_path);
 	free(device->device_buf);
+	free(device->mdev_path);
 	free(device);
 }
 
@@ -413,6 +414,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
 	char *path;
 	int dfd;
 	int rc;
+	char *p;
 
 	path = calloc(1, strlen(ctl_base) + MAX_PARAM_LEN);
 	if (!path) {
@@ -470,6 +472,20 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
 		goto err_dev_path;
 	}
 
+	device->mdev_path = strdup(device->device_path);
+	if (!device->mdev_path) {
+		err(ctx, "strdup of device_path failed\n");
+		goto err_dev_path;
+	}
+
+	if (asprintf(&p, "%s/%s", MDEV_BUS,
+			basename(dirname(device->mdev_path))) < 0) {
+		err(ctx, "device mdev_path allocation failed\n");
+		goto err_dev_path;
+	}
+	free(device->mdev_path);
+	device->mdev_path = p;
+
 	device->device_buf = calloc(1, strlen(device->device_path) +
 			MAX_PARAM_LEN);
 	if (!device->device_buf) {
@@ -490,6 +506,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
 err_dev_path:
 err_read:
 	free(device->device_buf);
+	free(device->mdev_path);
 	free(device);
 err_device:
 	free(path);
accfg/lib/private.h +1 -0
index f38ff23..365d484 100644
@@ -30,6 +30,7 @@ struct accfg_device {
         struct list_node list;
 	int group_init;
         char *device_path;
+	char *mdev_path;
         char *device_buf;
 	char *device_type_str;
 	enum accfg_device_type type;
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 1/11
#2 lore raw

[Accel-config] Re: [PATCH v1 01/11] accel-config: Add mdev path to device context

Quoted 10 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 01/11] accel-config: Add mdev path to device context

Quoted 7 lines

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

/sys/class/mdev_bus/<bdf> is used often to access mdevs associated with the device. Generate and store in device so it need not be constructed everytime.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>

Does private.h have a spacing issue? The diff looks rather odd.

Quoted 71 lines
---
 accfg/lib/libaccfg.c | 17 +++++++++++++++++  accfg/lib/private.h  |  1 +
 2 files changed, 18 insertions(+)
accfg/lib/libaccfg.c index cd9da42..9b5615a renamed from accfg/lib/libaccfg.c +0 -0

100644

accfg/lib/libaccfg.c +1 -0
@@ -194,6 +194,7 @@ static void free_device(struct accfg_device *device,
 struct list_head *head)
 		list_del_from(head, &device->list);
 	free(device->device_path);
 	free(device->device_buf);
+	free(device->mdev_path);
 	free(device);
 }
@@ -413,6 +414,7 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr

accfg/lib/libaccfg.c +1 -0
 	char *path;
 	int dfd;
 	int rc;
+	char *p;
 
 	path = calloc(1, strlen(ctl_base) + MAX_PARAM_LEN);
 	if (!path) {
@@ -470,6 +472,20 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr

accfg/lib/libaccfg.c +14 -0
 		goto err_dev_path;
 	}
 
+	device->mdev_path = strdup(device->device_path);
+	if (!device->mdev_path) {
+		err(ctx, "strdup of device_path failed\n");
+		goto err_dev_path;
+	}
+
+	if (asprintf(&p, "%s/%s", MDEV_BUS,
+			basename(dirname(device->mdev_path))) < 0) {
+		err(ctx, "device mdev_path allocation failed\n");
+		goto err_dev_path;
+	}
+	free(device->mdev_path);
+	device->mdev_path = p;
+
 	device->device_buf = calloc(1, strlen(device->device_path) +
 			MAX_PARAM_LEN);
 	if (!device->device_buf) {
@@ -490,6 +506,7 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr
err_dev_path:
err_read:

accfg/lib/libaccfg.c +1 -0
 	free(device->device_buf);
+	free(device->mdev_path);
 	free(device);
 err_device:
 	free(path);
accfg/lib/private.h index f38ff23..365d484 renamed from accfg/lib/private.h +0 -0

100644

accfg/lib/private.h +1 -1
@@ -30,6 +30,7 @@ struct accfg_device {
         struct list_node list;
 	int group_init;
         char *device_path;
+	char *mdev_path;
         char *device_buf;
 	char *device_type_str;
 	enum accfg_device_type type;
--

2.26.2

#3 lore raw

[Accel-config] Re: [PATCH v1 01/11] accel-config: Add mdev path to device context

Quoted 16 lines · Dave Jiang
Quoted 16 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 01/11] accel-config: Add mdev path to device context

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

/sys/class/mdev_bus/<bdf> is used often to access mdevs associated with the device. Generate and store in device so it need not be constructed everytime.

Quoted 5 lines
Quoted 1 line
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>

Does private.h have a spacing issue? The diff looks rather odd.

Yes, it does. Maybe I will add a patch to clean it up.

Quoted 74 lines
Quoted 73 lines

---
 accfg/lib/libaccfg.c | 17 +++++++++++++++++  accfg/lib/private.h  |  1 +
 2 files changed, 18 insertions(+)
accfg/lib/libaccfg.c index cd9da42..9b5615a renamed from accfg/lib/libaccfg.c +0 -0

100644

accfg/lib/libaccfg.c +1 -0
@@ -194,6 +194,7 @@ static void free_device(struct accfg_device *device,
 struct list_head *head)
 list_del_from(head, &device->list);
 free(device->device_path);
 free(device->device_buf);
+free(device->mdev_path);
 free(device);
 }
@@ -413,6 +414,7 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr
char *path;
int dfd;
int rc;

accfg/lib/libaccfg.c +1 -0
+char *p;
 
 path = calloc(1, strlen(ctl_base) + MAX_PARAM_LEN);
 if (!path) {
@@ -470,6 +472,20 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr
goto err_dev_path;
}

accfg/lib/libaccfg.c +14 -0
+device->mdev_path = strdup(device->device_path);
+if (!device->mdev_path) {
+err(ctx, "strdup of device_path failed\n");
+goto err_dev_path;
+}
+
+if (asprintf(&p, "%s/%s", MDEV_BUS,
+basename(dirname(device->mdev_path))) < 0) {
+err(ctx, "device mdev_path allocation failed\n");
+goto err_dev_path;
+}
+free(device->mdev_path);
+device->mdev_path = p;
+
 device->device_buf = calloc(1, strlen(device->device_path) +
 MAX_PARAM_LEN);
 if (!device->device_buf) {
@@ -490,6 +506,7 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr
err_dev_path:
err_read:
free(device->device_buf);

accfg/lib/libaccfg.c +1 -0
+free(device->mdev_path);
 free(device);
 err_device:
 free(path);
accfg/lib/private.h index f38ff23..365d484 renamed from accfg/lib/private.h +0 -0

100644

accfg/lib/private.h +1 -1
@@ -30,6 +30,7 @@ struct accfg_device {
         struct list_node list;
 int group_init;
         char *device_path;
+char *mdev_path;
         char *device_buf;
 char *device_type_str;
 enum accfg_device_type type;
--

2.26.2

#4 lore raw

PATCH 2/11 accel-config: Create mdev structures and load mdevs into device context

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Lays the foundation for the mdev implementation

- Create private and exported structures for mdev types and mdev list
- Create routines to scan and classify mdevs in sysfs
- Store mdev details in device contexts during init

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c    | 81 +++++++++++++++++++++++++++++++++++++++++
 accfg/lib/private.h     |  8 ++++
 accfg/libaccel_config.h |  7 ++++
 3 files changed, 96 insertions(+)
accfg/lib/libaccfg.c +81 -0
index 9b5615a..0dd1f0c 100644
@@ -43,6 +43,12 @@ ACCFG_EXPORT char *accfg_basenames[] = {
 	NULL
 };
 
+ACCFG_EXPORT char *accfg_mdev_basenames[] = {
+	[ACCFG_MDEV_TYPE_1_DWQ]      = "1dwq",
+	[ACCFG_MDEV_TYPE_1_SWQ]      = "1swq",
+	NULL
+};
+
 enum {
 	ACCFG_CMD_STATUS_MAX = 0x45,
 };
@@ -407,6 +413,77 @@ static int device_parse_type(struct accfg_device *device)
 	return 0;
 }
 
+static int mdev_str_to_type(char *mdev_type_str)
+{
+	char **b;
+	char *s;
+	int l, i;
+
+	s = strchr(mdev_type_str, '-');
+	if (!s)
+		s = mdev_type_str;
+	else
+		s++;
+	l = (int) (strchrnul(s, '-') - s);
+
+	for (b = accfg_mdev_basenames, i = 0; *b != NULL; b++, i++)
+		if (!strncmp(*b, s, l))
+			return i;
+
+	return ACCFG_MDEV_TYPE_UNKNOWN;
+}
+
+static int add_device_mdevs(struct accfg_ctx *ctx, struct accfg_device *dev)
+{
+	struct accfg_device_mdev *dev_mdev;
+	uuid_t uu;
+	struct dirent **d;
+	char *f, *mdev_type_str;
+	char p[PATH_MAX];
+	char mdev_path[PATH_MAX];
+	int n, n1, rc = 0;
+
+	n1 = n = scandir(dev->mdev_path, &d, NULL, alphasort);
+	if (n < 0) {
+		err(ctx, "scandir failed\n");
+		return -ENOENT;
+	}
+
+	while (n--) {
+		f = &d[n]->d_name[0];
+		if (*f == '.' || uuid_parse(f, uu))
+			continue;
+		sprintf(p, "%s/%s/mdev_type", dev->mdev_path, f);
+		if (!realpath(p, mdev_path))
+			continue;
+		dev_mdev = calloc(1,
+			sizeof(struct accfg_device_mdev));
+		if (!dev_mdev) {
+			err(ctx, "allocation failed\n");
+			rc = -ENOMEM;
+			goto exit_add_mdev;
+		}
+		uuid_copy(dev_mdev->uuid, uu);
+		mdev_type_str = strrchr(mdev_path, '/') + 1;
+		dev_mdev->device = dev;
+		dev_mdev->type = mdev_str_to_type(mdev_type_str);
+		if (dev_mdev->type == ACCFG_MDEV_TYPE_UNKNOWN) {
+			err(ctx, "mdev type error\n");
+			free(dev_mdev);
+			rc = -EINVAL;
+			goto exit_add_mdev;
+		}
+		list_add_tail(&dev->mdev_list, &dev_mdev->list);
+	}
+
+exit_add_mdev:
+	while (n1--)
+		free(d[n1]);
+	free(d);
+
+	return rc;
+}
+
 static void *add_device(void *parent, int id, const char *ctl_base, char *dev_prefix)
 {
 	struct accfg_ctx *ctx = parent;
@@ -439,6 +516,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
 	list_head_init(&device->groups);
 	list_head_init(&device->wqs);
 	list_head_init(&device->engines);
+	list_head_init(&device->mdev_list);
 
 	device->ctx = ctx;
 	device->id = id;
@@ -501,6 +579,9 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
 	list_add_tail(&ctx->devices, &device->list);
 	free(path);
 
+	if (add_device_mdevs(ctx, device))
+		goto err_dev_path;
+
 	return device;
 
 err_dev_path:
accfg/lib/private.h +8 -0
index 365d484..305d73e 100644
@@ -35,6 +35,7 @@ struct accfg_device {
 	char *device_type_str;
 	enum accfg_device_type type;
         size_t buf_len;
+	struct list_head mdev_list;
 
 	/* Device Attributes */
 	struct accfg_error errors;
@@ -56,6 +57,13 @@ struct accfg_device {
 	char *pasid_enabled;
 };
 
+struct accfg_device_mdev {
+	struct accfg_device *device;
+	uuid_t uuid;
+	enum accfg_mdev_type type;
+	struct list_node list;
+};
+
 struct accfg_group {
         struct accfg_device *device;
         int id;
accfg/libaccel_config.h +7 -0
index f85670c..e89bd40 100644
@@ -67,6 +67,12 @@ enum accfg_control_flag {
 	ACCFG_WQ_DISABLE,
 };
 
+enum accfg_mdev_type {
+	ACCFG_MDEV_TYPE_1_DWQ,
+	ACCFG_MDEV_TYPE_1_SWQ,
+	ACCFG_MDEV_TYPE_UNKNOWN,
+};
+
 /* no need to save device error */
 struct accfg_error {
         uint64_t val[4];
@@ -78,6 +84,7 @@ struct dev_parameters {
 };
 
 extern char *accfg_basenames[];
+extern char *accfg_mdev_basenames[];
 
 struct group_parameters {
 	unsigned int tokens_reserved;
Signature · 1 line
2.26.2
#5 lore raw

[Accel-config] Re: [PATCH v1 02/11] accel-config: Create mdev structures and load mdevs into device context

Quoted 45 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 02/11] accel-config: Create mdev structures and load mdevs into device context

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Lays the foundation for the mdev implementation

- Create private and exported structures for mdev types and mdev list
- Create routines to scan and classify mdevs in sysfs
- Store mdev details in device contexts during init

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c    | 81
+++++++++++++++++++++++++++++++++++++++++
 accfg/lib/private.h     |  8 ++++
 accfg/libaccel_config.h |  7 ++++
 3 files changed, 96 insertions(+)
accfg/lib/libaccfg.c index 9b5615a..0dd1f0c renamed from accfg/lib/libaccfg.c +0 -0

100644

accfg/lib/libaccfg.c +6 -0
@@ -43,6 +43,12 @@ ACCFG_EXPORT char *accfg_basenames[] = {
 	NULL
 };
 
+ACCFG_EXPORT char *accfg_mdev_basenames[] = {
+	[ACCFG_MDEV_TYPE_1_DWQ]      = "1dwq",
+	[ACCFG_MDEV_TYPE_1_SWQ]      = "1swq",
+	NULL
+};
+
 enum {
 	ACCFG_CMD_STATUS_MAX = 0x45,
 };

accfg/lib/libaccfg.c static int device_parse_type(struct accfg_device · line 417

Quoted 5 lines
accfg/lib/libaccfg.c +1 -0
@@ -407,6 +413,77 @@ static int device_parse_type(struct accfg_device
 *device)
 	return 0;
 }
 
+static int mdev_str_to_type(char *mdev_type_str) {

Please start the { on a new line for all functions

Quoted 123 lines
accfg/lib/libaccfg.c +69 -0
+	char **b;
+	char *s;
+	int l, i;
+
+	s = strchr(mdev_type_str, '-');
+	if (!s)
+		s = mdev_type_str;
+	else
+		s++;
+	l = (int) (strchrnul(s, '-') - s);
+
+	for (b = accfg_mdev_basenames, i = 0; *b != NULL; b++, i++)
+		if (!strncmp(*b, s, l))
+			return i;
+
+	return ACCFG_MDEV_TYPE_UNKNOWN;
+}
+
+static int add_device_mdevs(struct accfg_ctx *ctx, struct accfg_device
+*dev) {
+	struct accfg_device_mdev *dev_mdev;
+	uuid_t uu;
+	struct dirent **d;
+	char *f, *mdev_type_str;
+	char p[PATH_MAX];
+	char mdev_path[PATH_MAX];
+	int n, n1, rc = 0;
+
+	n1 = n = scandir(dev->mdev_path, &d, NULL, alphasort);
+	if (n < 0) {
+		err(ctx, "scandir failed\n");
+		return -ENOENT;
+	}
+
+	while (n--) {
+		f = &d[n]->d_name[0];
+		if (*f == '.' || uuid_parse(f, uu))
+			continue;
+		sprintf(p, "%s/%s/mdev_type", dev->mdev_path, f);
+		if (!realpath(p, mdev_path))
+			continue;
+		dev_mdev = calloc(1,
+			sizeof(struct accfg_device_mdev));
+		if (!dev_mdev) {
+			err(ctx, "allocation failed\n");
+			rc = -ENOMEM;
+			goto exit_add_mdev;
+		}
+		uuid_copy(dev_mdev->uuid, uu);
+		mdev_type_str = strrchr(mdev_path, '/') + 1;
+		dev_mdev->device = dev;
+		dev_mdev->type = mdev_str_to_type(mdev_type_str);
+		if (dev_mdev->type == ACCFG_MDEV_TYPE_UNKNOWN) {
+			err(ctx, "mdev type error\n");
+			free(dev_mdev);
+			rc = -EINVAL;
+			goto exit_add_mdev;
+		}
+		list_add_tail(&dev->mdev_list, &dev_mdev->list);
+	}
+
+exit_add_mdev:
+	while (n1--)
+		free(d[n1]);
+	free(d);
+
+	return rc;
+}
+
 static void *add_device(void *parent, int id, const char *ctl_base, char
 *dev_prefix)  {
 	struct accfg_ctx *ctx = parent;
@@ -439,6 +516,7 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr

accfg/lib/libaccfg.c +1 -0
 	list_head_init(&device->groups);
 	list_head_init(&device->wqs);
 	list_head_init(&device->engines);
+	list_head_init(&device->mdev_list);
 
 	device->ctx = ctx;
 	device->id = id;
@@ -501,6 +579,9 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr

accfg/lib/libaccfg.c +3 -0
 	list_add_tail(&ctx->devices, &device->list);
 	free(path);
 
+	if (add_device_mdevs(ctx, device))
+		goto err_dev_path;
+
 	return device;
 
 err_dev_path:
accfg/lib/private.h index 365d484..305d73e renamed from accfg/lib/private.h +0 -0

100644

accfg/lib/private.h +8 -0
@@ -35,6 +35,7 @@ struct accfg_device {
 	char *device_type_str;
 	enum accfg_device_type type;
         size_t buf_len;
+	struct list_head mdev_list;
 
 	/* Device Attributes */
 	struct accfg_error errors;
@@ -56,6 +57,13 @@ struct accfg_device {
 	char *pasid_enabled;
 };
 
+struct accfg_device_mdev {
+	struct accfg_device *device;
+	uuid_t uuid;
+	enum accfg_mdev_type type;
+	struct list_node list;
+};
+
 struct accfg_group {
         struct accfg_device *device;
         int id;
accfg/libaccel_config.h index renamed from accfg/libaccel_config.h +0 -0

f85670c..e89bd40 100644

accfg/libaccel_config.h enum accfg_control_flag { · line 73

Quoted 7 lines
accfg/libaccel_config.h +4 -0
@@ -67,6 +67,12 @@ enum accfg_control_flag {
 	ACCFG_WQ_DISABLE,
 };
 
+enum accfg_mdev_type {
+	ACCFG_MDEV_TYPE_1_DWQ,
+	ACCFG_MDEV_TYPE_1_SWQ,
+	ACCFG_MDEV_TYPE_UNKNOWN,

Should we assign the UNKNOWN to a -1 value?

Quoted 14 lines
accfg/libaccel_config.h +3 -1
+};
+
 /* no need to save device error */
 struct accfg_error {
         uint64_t val[4];
@@ -78,6 +84,7 @@ struct dev_parameters {  };
 
 extern char *accfg_basenames[];
+extern char *accfg_mdev_basenames[];
 
 struct group_parameters {
 	unsigned int tokens_reserved;
--

2.26.2

#6 lore raw

[Accel-config] Re: [PATCH v1 02/11] accel-config: Create mdev structures and load mdevs into device context

Quoted 49 lines · Dave Jiang
Quoted 49 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 02/11] accel-config: Create mdev structures and load mdevs into device context

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Lays the foundation for the mdev implementation

- Create private and exported structures for mdev types and mdev list
- Create routines to scan and classify mdevs in sysfs
- Store mdev details in device contexts during init

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c    | 81
+++++++++++++++++++++++++++++++++++++++++
 accfg/lib/private.h     |  8 ++++
 accfg/libaccel_config.h |  7 ++++
 3 files changed, 96 insertions(+)
accfg/lib/libaccfg.c index 9b5615a..0dd1f0c renamed from accfg/lib/libaccfg.c +0 -0

100644

accfg/lib/libaccfg.c +6 -0
@@ -43,6 +43,12 @@ ACCFG_EXPORT char *accfg_basenames[] = {
 	NULL
 };
 
+ACCFG_EXPORT char *accfg_mdev_basenames[] = {
+	[ACCFG_MDEV_TYPE_1_DWQ]      = "1dwq",
+	[ACCFG_MDEV_TYPE_1_SWQ]      = "1swq",
+	NULL
+};
+
 enum {
 	ACCFG_CMD_STATUS_MAX = 0x45,
 };
@@ -407,6 +413,77 @@ static int device_parse_type(struct accfg_device
 *device)
 	return 0;
 }
 
Quoted 3 lines

accfg/lib/libaccfg.c static int device_parse_type(struct accfg_device · line 417

Quoted 1 line
accfg/lib/libaccfg.c +1 -0
+static int mdev_str_to_type(char *mdev_type_str) {

Please start the { on a new line for all functions

I think it is your Outlook removing newlines. The code is ok

Quoted 151 lines
Quoted 124 lines
accfg/lib/libaccfg.c +69 -0
+	char **b;
+	char *s;
+	int l, i;
+
+	s = strchr(mdev_type_str, '-');
+	if (!s)
+		s = mdev_type_str;
+	else
+		s++;
+	l = (int) (strchrnul(s, '-') - s);
+
+	for (b = accfg_mdev_basenames, i = 0; *b != NULL; b++, i++)
+		if (!strncmp(*b, s, l))
+			return i;
+
+	return ACCFG_MDEV_TYPE_UNKNOWN;
+}
+
+static int add_device_mdevs(struct accfg_ctx *ctx, struct accfg_device
+*dev) {
+	struct accfg_device_mdev *dev_mdev;
+	uuid_t uu;
+	struct dirent **d;
+	char *f, *mdev_type_str;
+	char p[PATH_MAX];
+	char mdev_path[PATH_MAX];
+	int n, n1, rc = 0;
+
+	n1 = n = scandir(dev->mdev_path, &d, NULL, alphasort);
+	if (n < 0) {
+		err(ctx, "scandir failed\n");
+		return -ENOENT;
+	}
+
+	while (n--) {
+		f = &d[n]->d_name[0];
+		if (*f == '.' || uuid_parse(f, uu))
+			continue;
+		sprintf(p, "%s/%s/mdev_type", dev->mdev_path, f);
+		if (!realpath(p, mdev_path))
+			continue;
+		dev_mdev = calloc(1,
+			sizeof(struct accfg_device_mdev));
+		if (!dev_mdev) {
+			err(ctx, "allocation failed\n");
+			rc = -ENOMEM;
+			goto exit_add_mdev;
+		}
+		uuid_copy(dev_mdev->uuid, uu);
+		mdev_type_str = strrchr(mdev_path, '/') + 1;
+		dev_mdev->device = dev;
+		dev_mdev->type = mdev_str_to_type(mdev_type_str);
+		if (dev_mdev->type == ACCFG_MDEV_TYPE_UNKNOWN) {
+			err(ctx, "mdev type error\n");
+			free(dev_mdev);
+			rc = -EINVAL;
+			goto exit_add_mdev;
+		}
+		list_add_tail(&dev->mdev_list, &dev_mdev->list);
+	}
+
+exit_add_mdev:
+	while (n1--)
+		free(d[n1]);
+	free(d);
+
+	return rc;
+}
+
 static void *add_device(void *parent, int id, const char *ctl_base, char
 *dev_prefix)  {
 	struct accfg_ctx *ctx = parent;
@@ -439,6 +516,7 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr

accfg/lib/libaccfg.c +1 -0
 	list_head_init(&device->groups);
 	list_head_init(&device->wqs);
 	list_head_init(&device->engines);
+	list_head_init(&device->mdev_list);
 
 	device->ctx = ctx;
 	device->id = id;
@@ -501,6 +579,9 @@ static void *add_device(void *parent, int id, const

char *ctl_base, char *dev_pr

accfg/lib/libaccfg.c +3 -0
 	list_add_tail(&ctx->devices, &device->list);
 	free(path);
 
+	if (add_device_mdevs(ctx, device))
+		goto err_dev_path;
+
 	return device;
 
 err_dev_path:
accfg/lib/private.h index 365d484..305d73e renamed from accfg/lib/private.h +0 -0

100644

accfg/lib/private.h +8 -0
@@ -35,6 +35,7 @@ struct accfg_device {
 	char *device_type_str;
 	enum accfg_device_type type;
         size_t buf_len;
+	struct list_head mdev_list;
 
 	/* Device Attributes */
 	struct accfg_error errors;
@@ -56,6 +57,13 @@ struct accfg_device {
 	char *pasid_enabled;
 };
 
+struct accfg_device_mdev {
+	struct accfg_device *device;
+	uuid_t uuid;
+	enum accfg_mdev_type type;
+	struct list_node list;
+};
+
 struct accfg_group {
         struct accfg_device *device;
         int id;
accfg/libaccel_config.h index renamed from accfg/libaccel_config.h +0 -0

f85670c..e89bd40 100644

accfg/libaccel_config.h enum accfg_control_flag { · line 73

Quoted 7 lines
accfg/libaccel_config.h +4 -0
@@ -67,6 +67,12 @@ enum accfg_control_flag {
 	ACCFG_WQ_DISABLE,
 };
 
+enum accfg_mdev_type {
+	ACCFG_MDEV_TYPE_1_DWQ,
+	ACCFG_MDEV_TYPE_1_SWQ,
+	ACCFG_MDEV_TYPE_UNKNOWN,

Should we assign the UNKNOWN to a -1 value?

Quoted 13 lines
accfg/libaccel_config.h +3 -1
+};
+
 /* no need to save device error */
 struct accfg_error {
         uint64_t val[4];
@@ -78,6 +84,7 @@ struct dev_parameters {  };
 
 extern char *accfg_basenames[];
+extern char *accfg_mdev_basenames[];
 
 struct group_parameters {
 	unsigned int tokens_reserved;
--
Quoted 1 line

2.26.2

_______________________________________________
Accel-config mailing list -- accel-config(a)lists.01.org To unsubscribe send an email to accel-config-leave(a)lists.01.org

#7 lore raw

[Accel-config] Re: [PATCH v1 02/11] accel-config: Create mdev structures and load mdevs into device context

Quoted 63 lines

-----Original Message-----
From: Thomas, Ramesh <ramesh.thomas(a)intel.com>
Sent: Friday, December 4, 2020 4:53 PM
To: Jiang, Dave <dave.jiang(a)intel.com>; accel-config(a)lists.01.org
Cc: Luck, Tony <tony.luck(a)intel.com>
Subject: RE: [PATCH v1 02/11] accel-config: Create mdev structures and load mdevs into device context

Quoted 51 lines · Dave Jiang
Quoted 51 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 02/11] accel-config: Create mdev structures and load mdevs into device context

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Lays the foundation for the mdev implementation

- Create private and exported structures for mdev types and mdev list
- Create routines to scan and classify mdevs in sysfs
- Store mdev details in device contexts during init

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c    | 81
+++++++++++++++++++++++++++++++++++++++++
 accfg/lib/private.h     |  8 ++++
 accfg/libaccel_config.h |  7 ++++
 3 files changed, 96 insertions(+)
accfg/lib/libaccfg.c index renamed from accfg/lib/libaccfg.c +0 -0

9b5615a..0dd1f0c
100644

accfg/lib/libaccfg.c +6 -0
@@ -43,6 +43,12 @@ ACCFG_EXPORT char *accfg_basenames[] = {  NULL
 };
 
+ACCFG_EXPORT char *accfg_mdev_basenames[] = {
+[ACCFG_MDEV_TYPE_1_DWQ]      = "1dwq",
+[ACCFG_MDEV_TYPE_1_SWQ]      = "1swq",
+NULL
+};
+
 enum {
 ACCFG_CMD_STATUS_MAX = 0x45,
 };
@@ -407,6 +413,77 @@ static int device_parse_type(struct

accfg_device
*device)
return 0;
}

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+static int mdev_str_to_type(char *mdev_type_str) {

Please start the { on a new line for all functions

I think it is your Outlook removing newlines. The code is ok

Grrrr ok. I'll do the review in Mutt. I had Thunderbird working but it stopped with an update :(

Quoted 129 lines
Quoted 28 lines
Quoted 28 lines
accfg/lib/libaccfg.c +26 -0
+char **b;
+char *s;
+int l, i;
+
+s = strchr(mdev_type_str, '-');
+if (!s)
+s = mdev_type_str;
+else
+s++;
+l = (int) (strchrnul(s, '-') - s);
+
+for (b = accfg_mdev_basenames, i = 0; *b != NULL; b++, i++) if
+(!strncmp(*b, s, l)) return i;
+
+return ACCFG_MDEV_TYPE_UNKNOWN;
+}
+
+static int add_device_mdevs(struct accfg_ctx *ctx, struct
+accfg_device
+*dev) {
+struct accfg_device_mdev *dev_mdev; uuid_t uu; struct dirent **d;
+char *f, *mdev_type_str; char p[PATH_MAX]; char
+mdev_path[PATH_MAX]; int n, n1, rc = 0;
+
+n1 = n = scandir(dev->mdev_path, &d, NULL, alphasort); if (n < 0) {
+err(ctx, "scandir failed\n"); return -ENOENT; }
Quoted 8 lines

accfg/lib/libaccfg.c

Quoted 8 lines
accfg/lib/libaccfg.c +8 -0
+
+while (n--) {
+f = &d[n]->d_name[0];
+if (*f == '.' || uuid_parse(f, uu)) continue; sprintf(p,
+"%s/%s/mdev_type", dev->mdev_path, f); if (!realpath(p, mdev_path))
+continue; dev_mdev = calloc(1, sizeof(struct accfg_device_mdev));
+if (!dev_mdev) { err(ctx, "allocation failed\n"); rc = -ENOMEM;
+goto exit_add_mdev; } uuid_copy(dev_mdev->uuid, uu);

mdev_type_str

Quoted 3 lines

accfg/lib/libaccfg.c

Quoted 3 lines

+= strrchr(mdev_path, '/') + 1; dev_mdev->device = dev;

accfg/lib/libaccfg.c +2 -0
+dev_mdev->type = mdev_str_to_type(mdev_type_str); if
+(dev_mdev->type == ACCFG_MDEV_TYPE_UNKNOWN) { err(ctx,

"mdev type

Quoted 46 lines
Quoted 46 lines
accfg/lib/libaccfg.c +11 -0
+error\n"); free(dev_mdev); rc = -EINVAL; goto exit_add_mdev; }
+list_add_tail(&dev->mdev_list, &dev_mdev->list); }
+
+exit_add_mdev:
+while (n1--)
+free(d[n1]);
+free(d);
+
+return rc;
+}
+
 static void *add_device(void *parent, int id, const char *ctl_base,

char
*dev_prefix) {
struct accfg_ctx *ctx = parent;

accfg/lib/libaccfg.c +4 -0
@@ -439,6 +516,7 @@ static void *add_device(void *parent, int id,
 const char *ctl_base, char *dev_pr  list_head_init(&device->groups);
 list_head_init(&device->wqs);  list_head_init(&device->engines);
+list_head_init(&device->mdev_list);
 
 device->ctx = ctx;
 device->id = id;
@@ -501,6 +579,9 @@ static void *add_device(void *parent, int id,
 const char *ctl_base, char *dev_pr  list_add_tail(&ctx->devices,
 &device->list);  free(path);
 
+if (add_device_mdevs(ctx, device))
+goto err_dev_path;
+
 return device;
 
 err_dev_path:
accfg/lib/private.h index renamed from accfg/lib/private.h +0 -0

365d484..305d73e
100644

accfg/lib/private.h +1 -0
@@ -35,6 +35,7 @@ struct accfg_device {  char *device_type_str;
 enum accfg_device_type type;
         size_t buf_len;
+struct list_head mdev_list;
 
 /* Device Attributes */
 struct accfg_error errors;
@@ -56,6 +57,13 @@ struct accfg_device {  char *pasid_enabled;  };
 
Quoted 15 lines

accfg/libaccel_config.h enum accfg_control_flag { ACCFG_WQ_DISABLE,

Quoted 15 lines
accfg/lib/private.h +7 -0
+struct accfg_device_mdev {
+struct accfg_device *device;
+uuid_t uuid;
+enum accfg_mdev_type type;
+struct list_node list;
+};
+
 struct accfg_group {
         struct accfg_device *device;
         int id;
accfg/libaccel_config.h index renamed from accfg/libaccel_config.h +0 -0

f85670c..e89bd40 100644

accfg/libaccel_config.h +0 -0
@@ -67,6 +67,12 @@ enum accfg_control_flag {  ACCFG_WQ_DISABLE,

};

Quoted 25 lines

accfg/libaccel_config.h enum accfg_control_flag { · line 73

Quoted 5 lines
accfg/libaccel_config.h +4 -0
+enum accfg_mdev_type {
+ACCFG_MDEV_TYPE_1_DWQ,
+ACCFG_MDEV_TYPE_1_SWQ,
+ACCFG_MDEV_TYPE_UNKNOWN,

Should we assign the UNKNOWN to a -1 value?

Quoted 13 lines
accfg/libaccel_config.h +3 -1
+};
+
 /* no need to save device error */
 struct accfg_error {
         uint64_t val[4];
@@ -78,6 +84,7 @@ struct dev_parameters {  };
 
 extern char *accfg_basenames[];
+extern char *accfg_mdev_basenames[];
 
 struct group_parameters {
 unsigned int tokens_reserved;
--
Quoted 1 line

2.26.2

_______________________________________________
Accel-config mailing list -- accel-config(a)lists.01.org To unsubscribe send an email to accel-config-leave(a)lists.01.org

#8 lore raw

PATCH 3/11 accel-config: Add lib functions to list mdevs and retrieve mdev properties

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Create library functions for querrying mdev details
- Functions to retrieve first and next mdev in list
- Macro to iterate mdev list
- Functions to retrieve mdev uuid and type

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccel-config.sym |  9 +++++++++
 accfg/lib/libaccfg.c          | 22 ++++++++++++++++++++++
 accfg/libaccel_config.h       | 11 +++++++++++
 3 files changed, 42 insertions(+)
accfg/lib/libaccel-config.sym +9 -0
index 471e06a..a857152 100644
@@ -133,3 +133,12 @@ global:
 	accfg_wq_set_max_batch_size;
 	accfg_wq_set_max_transfer_size;
 } LIBACCFG_6;
+
+LIBACCFG_8 {
+global:
+	accfg_device_first_mdev;
+	accfg_device_next_mdev;
+	accfg_mdev_get_uuid;
+	accfg_mdev_get_type;
+	accfg_mdev_basenames;
+} LIBACCFG_7;
accfg/lib/libaccfg.c +22 -0
index 0dd1f0c..6a4648a 100644
@@ -956,6 +956,28 @@ static void engines_init(struct accfg_device *device)
 			add_engine);
 }
 
+ACCFG_EXPORT struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device *device)
+{
+	return list_top(&device->mdev_list, struct accfg_device_mdev, list);
+}
+
+ACCFG_EXPORT struct accfg_device_mdev *accfg_device_next_mdev(struct accfg_device_mdev *mdev)
+{
+	struct accfg_device *device = mdev->device;
+
+	return list_next(&device->mdev_list, mdev, list);
+}
+
+ACCFG_EXPORT void accfg_mdev_get_uuid(struct accfg_device_mdev *mdev, uuid_t uuid)
+{
+	uuid_copy(uuid, mdev->uuid);
+}
+
+ACCFG_EXPORT enum accfg_mdev_type accfg_mdev_get_type(struct accfg_device_mdev *mdev)
+{
+	return mdev->type;
+}
+
 /**
  * accfg_device_get_first - retrieve first device in the system
  * @ctx: context established by accfg_new
accfg/libaccel_config.h +11 -0
index e89bd40..a55bfde 100644
@@ -184,6 +184,17 @@ int accfg_device_is_active(struct accfg_device *device);
 int accfg_device_get_cmd_status(struct accfg_device *device);
 const char * accfg_device_get_cmd_status_str(struct accfg_device *device);
 
+struct accfg_device_mdev;
+struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device *device);
+struct accfg_device_mdev *accfg_device_next_mdev(struct accfg_device_mdev *mdev);
+void accfg_mdev_get_uuid(struct accfg_device_mdev *mdev, uuid_t uuid);
+enum accfg_mdev_type accfg_mdev_get_type(struct accfg_device_mdev *mdev);
+
+#define accfg_device_mdev_foreach(device, mdev) \
+	for (mdev = accfg_device_first_mdev(device); \
+		mdev != NULL; \
+		mdev = accfg_device_next_mdev(mdev))
+
 /* libaccfg function for group */
 struct accfg_group;
 struct accfg_group *accfg_group_get_first(struct accfg_device *device);
Signature · 1 line
2.26.2
#9 lore raw

[Accel-config] Re: [PATCH v1 03/11] accel-config: Add lib functions to list mdevs and retrieve mdev properties

Quoted 47 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 03/11] accel-config: Add lib functions to list mdevs and retrieve mdev properties

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Create library functions for querrying mdev details
- Functions to retrieve first and next mdev in list
- Macro to iterate mdev list
- Functions to retrieve mdev uuid and type

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccel-config.sym |  9 +++++++++
 accfg/lib/libaccfg.c          | 22 ++++++++++++++++++++++
 accfg/libaccel_config.h       | 11 +++++++++++
 3 files changed, 42 insertions(+)
accfg/lib/libaccel-config.sym index renamed from accfg/lib/libaccel-config.sym +0 -0

471e06a..a857152 100644

accfg/lib/libaccel-config.sym +9 -0
@@ -133,3 +133,12 @@ global:
 	accfg_wq_set_max_batch_size;
 	accfg_wq_set_max_transfer_size;
 } LIBACCFG_6;
+
+LIBACCFG_8 {
+global:
+	accfg_device_first_mdev;
+	accfg_device_next_mdev;
+	accfg_mdev_get_uuid;
+	accfg_mdev_get_type;
+	accfg_mdev_basenames;
+} LIBACCFG_7;
accfg/lib/libaccfg.c index 0dd1f0c..6a4648a renamed from accfg/lib/libaccfg.c +0 -0

100644

accfg/lib/libaccfg.c static void engines_init(struct accfg_device *device) · line 961

Quoted 6 lines
accfg/lib/libaccfg.c +2 -0
@@ -956,6 +956,28 @@ static void engines_init(struct accfg_device *device)
 			add_engine);
 }
 
+ACCFG_EXPORT struct accfg_device_mdev
 *accfg_device_first_mdev(struct
+accfg_device *device) {

Can you line up the function like:
ACCFG_EXPORT struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device *device) {

This is for the entire series. Otherwise looks ok.

- Dave.

Quoted 48 lines
accfg/lib/libaccfg.c +9 -0
+	return list_top(&device->mdev_list, struct accfg_device_mdev, list);
 }
+
+ACCFG_EXPORT struct accfg_device_mdev
 *accfg_device_next_mdev(struct
+accfg_device_mdev *mdev) {
+	struct accfg_device *device = mdev->device;
+
+	return list_next(&device->mdev_list, mdev, list); }
+
+ACCFG_EXPORT void accfg_mdev_get_uuid(struct accfg_device_mdev

*mdev,

accfg/lib/libaccfg.c +9 -0
+uuid_t uuid) {
+	uuid_copy(uuid, mdev->uuid);
+}
+
+ACCFG_EXPORT enum accfg_mdev_type accfg_mdev_get_type(struct
+accfg_device_mdev *mdev) {
+	return mdev->type;
+}
+
 /**
  * accfg_device_get_first - retrieve first device in the system
  * @ctx: context established by accfg_new diff --git a/accfg/libaccel_config.h

b/accfg/libaccel_config.h index e89bd40..a55bfde 100644

accfg/libaccel_config.h +12 -1
@@ -184,6 +184,17 @@ int accfg_device_is_active(struct accfg_device
 *device);  int accfg_device_get_cmd_status(struct accfg_device *device);
 const char * accfg_device_get_cmd_status_str(struct accfg_device *device);
 
+struct accfg_device_mdev;
+struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device
+*device); struct accfg_device_mdev *accfg_device_next_mdev(struct
+accfg_device_mdev *mdev); void accfg_mdev_get_uuid(struct
+accfg_device_mdev *mdev, uuid_t uuid); enum accfg_mdev_type
+accfg_mdev_get_type(struct accfg_device_mdev *mdev);
+
+#define accfg_device_mdev_foreach(device, mdev) \
+	for (mdev = accfg_device_first_mdev(device); \
+		mdev != NULL; \
+		mdev = accfg_device_next_mdev(mdev))
+
 /* libaccfg function for group */
 struct accfg_group;
 struct accfg_group *accfg_group_get_first(struct accfg_device *device);
--

2.26.2

#10 lore raw

[Accel-config] Re: [PATCH v1 03/11] accel-config: Add lib functions to list mdevs and retrieve mdev properties

Quoted 58 lines · Dave Jiang
Quoted 47 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 03/11] accel-config: Add lib functions to list mdevs and retrieve mdev properties

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Create library functions for querrying mdev details
- Functions to retrieve first and next mdev in list
- Macro to iterate mdev list
- Functions to retrieve mdev uuid and type

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccel-config.sym |  9 +++++++++
 accfg/lib/libaccfg.c          | 22 ++++++++++++++++++++++
 accfg/libaccel_config.h       | 11 +++++++++++
 3 files changed, 42 insertions(+)
accfg/lib/libaccel-config.sym index renamed from accfg/lib/libaccel-config.sym +0 -0

471e06a..a857152 100644

accfg/lib/libaccel-config.sym +9 -0
@@ -133,3 +133,12 @@ global:
 accfg_wq_set_max_batch_size;
 accfg_wq_set_max_transfer_size;
 } LIBACCFG_6;
+
+LIBACCFG_8 {
+global:
+accfg_device_first_mdev;
+accfg_device_next_mdev;
+accfg_mdev_get_uuid;
+accfg_mdev_get_type;
+accfg_mdev_basenames;
+} LIBACCFG_7;
accfg/lib/libaccfg.c index 0dd1f0c..6a4648a renamed from accfg/lib/libaccfg.c +0 -0

100644

accfg/lib/libaccfg.c static void engines_init(struct accfg_device *device) · line 961

Quoted 6 lines
accfg/lib/libaccfg.c +2 -0
@@ -956,6 +956,28 @@ static void engines_init(struct accfg_device *device)
 add_engine);
 }
 
+ACCFG_EXPORT struct accfg_device_mdev
 *accfg_device_first_mdev(struct
+accfg_device *device) {

Can you line up the function like:
ACCFG_EXPORT struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device *device) {

Quoted 1 line

This is for the entire series. Otherwise looks ok.

Assuming this is also the issue with your Outlook removing newlines. In code it is aligned like you suggest.

Quoted 53 lines

- Dave.

Quoted 48 lines
accfg/lib/libaccfg.c +9 -0
+return list_top(&device->mdev_list, struct accfg_device_mdev, list);
 }
+
+ACCFG_EXPORT struct accfg_device_mdev
 *accfg_device_next_mdev(struct
+accfg_device_mdev *mdev) {
+struct accfg_device *device = mdev->device;
+
+return list_next(&device->mdev_list, mdev, list); }
+
+ACCFG_EXPORT void accfg_mdev_get_uuid(struct accfg_device_mdev

*mdev,

accfg/lib/libaccfg.c +9 -0
+uuid_t uuid) {
+uuid_copy(uuid, mdev->uuid);
+}
+
+ACCFG_EXPORT enum accfg_mdev_type accfg_mdev_get_type(struct
+accfg_device_mdev *mdev) {
+return mdev->type;
+}
+
 /**
  * accfg_device_get_first - retrieve first device in the system
  * @ctx: context established by accfg_new diff --git a/accfg/libaccel_config.h

b/accfg/libaccel_config.h index e89bd40..a55bfde 100644

accfg/libaccel_config.h +12 -1
@@ -184,6 +184,17 @@ int accfg_device_is_active(struct accfg_device
 *device);  int accfg_device_get_cmd_status(struct accfg_device *device);
 const char * accfg_device_get_cmd_status_str(struct accfg_device *device);
 
+struct accfg_device_mdev;
+struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device
+*device); struct accfg_device_mdev *accfg_device_next_mdev(struct
+accfg_device_mdev *mdev); void accfg_mdev_get_uuid(struct
+accfg_device_mdev *mdev, uuid_t uuid); enum accfg_mdev_type
+accfg_mdev_get_type(struct accfg_device_mdev *mdev);
+
+#define accfg_device_mdev_foreach(device, mdev) \
+for (mdev = accfg_device_first_mdev(device); \
+mdev != NULL; \
+mdev = accfg_device_next_mdev(mdev))
+
 /* libaccfg function for group */
 struct accfg_group;
 struct accfg_group *accfg_group_get_first(struct accfg_device *device);
--

2.26.2

#11 lore raw

[Accel-config] Re: [PATCH v1 03/11] accel-config: Add lib functions to list mdevs and retrieve mdev properties

Quoted 68 lines

-----Original Message-----
From: Thomas, Ramesh <ramesh.thomas(a)intel.com>
Sent: Friday, December 4, 2020 5:00 PM
To: Jiang, Dave <dave.jiang(a)intel.com>; accel-config(a)lists.01.org
Cc: Luck, Tony <tony.luck(a)intel.com>
Subject: RE: [PATCH v1 03/11] accel-config: Add lib functions to list mdevs and retrieve mdev properties

Quoted 51 lines · Dave Jiang
Quoted 51 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 03/11] accel-config: Add lib functions to list mdevs and retrieve mdev properties

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Create library functions for querrying mdev details
- Functions to retrieve first and next mdev in list
- Macro to iterate mdev list
- Functions to retrieve mdev uuid and type

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccel-config.sym |  9 +++++++++
 accfg/lib/libaccfg.c          | 22 ++++++++++++++++++++++
 accfg/libaccel_config.h       | 11 +++++++++++
 3 files changed, 42 insertions(+)
(quoted diff) +0 -0

b/accfg/lib/libaccel-config.sym index
471e06a..a857152 100644

accfg/lib/libaccel-config.sym +9 -0
@@ -133,3 +133,12 @@ global:
 accfg_wq_set_max_batch_size;
 accfg_wq_set_max_transfer_size;
 } LIBACCFG_6;
+
+LIBACCFG_8 {
+global:
+accfg_device_first_mdev;
+accfg_device_next_mdev;
+accfg_mdev_get_uuid;
+accfg_mdev_get_type;
+accfg_mdev_basenames;
+} LIBACCFG_7;
accfg/lib/libaccfg.c index renamed from accfg/lib/libaccfg.c +0 -0

0dd1f0c..6a4648a
100644

accfg/lib/libaccfg.c +0 -0
@@ -956,6 +956,28 @@ static void engines_init(struct accfg_device
 *device)  add_engine);  }
 
Quoted 6 lines

accfg/lib/libaccfg.c static void engines_init(struct accfg_device · line 960

Quoted 3 lines
accfg/lib/libaccfg.c +2 -0
+ACCFG_EXPORT struct accfg_device_mdev
 *accfg_device_first_mdev(struct
+accfg_device *device) {

Can you line up the function like:
ACCFG_EXPORT struct accfg_device_mdev

Quoted 7 lines

*accfg_device_first_mdev(struct

Quoted 3 lines

accfg_device *device) {

This is for the entire series. Otherwise looks ok.

Assuming this is also the issue with your Outlook removing newlines. In code it is aligned like you suggest.

Most likely. Disregard. You can add review tag.

Quoted 59 lines
Quoted 20 lines

- Dave.

Quoted 15 lines
accfg/lib/libaccfg.c +12 -0
+return list_top(&device->mdev_list, struct accfg_device_mdev,
+list);
 }
+
+ACCFG_EXPORT struct accfg_device_mdev
 *accfg_device_next_mdev(struct
+accfg_device_mdev *mdev) {
+struct accfg_device *device = mdev->device;
+
+return list_next(&device->mdev_list, mdev, list); }
+
+ACCFG_EXPORT void accfg_mdev_get_uuid(struct accfg_device_mdev
 *mdev,
+uuid_t uuid) {
+uuid_copy(uuid, mdev->uuid);
Quoted 8 lines

accfg/lib/libaccfg.c static void engines_init(struct accfg_device *device)

Quoted 8 lines
accfg/lib/libaccfg.c +5 -0
+}
+
+ACCFG_EXPORT enum accfg_mdev_type accfg_mdev_get_type(struct
+accfg_device_mdev *mdev) { return mdev->type; }
+
 /**
  * accfg_device_get_first - retrieve first device in the system
  * @ctx: context established by accfg_new diff --git

a/accfg/libaccel_config.h

Quoted 5 lines

accfg/libaccel_config.h int accfg_device_is_active(struct accfg_device · line 184

Quoted 5 lines

b/accfg/libaccel_config.h index e89bd40..a55bfde 100644

accfg/libaccel_config.h +0 -0
@@ -184,6 +184,17 @@ int accfg_device_is_active(struct accfg_device
 *device);  int accfg_device_get_cmd_status(struct accfg_device

*device);

Quoted 1 line
Quoted 1 line

const char * accfg_device_get_cmd_status_str(struct accfg_device

*device);

Quoted 3 lines

accfg/libaccel_config.h

Quoted 3 lines
accfg/libaccel_config.h +2 -0
+struct accfg_device_mdev;
+struct accfg_device_mdev *accfg_device_first_mdev(struct

accfg_device

Quoted 16 lines
Quoted 15 lines
accfg/libaccel_config.h +10 -1
+*device); struct accfg_device_mdev *accfg_device_next_mdev(struct
+accfg_device_mdev *mdev); void accfg_mdev_get_uuid(struct
+accfg_device_mdev *mdev, uuid_t uuid); enum accfg_mdev_type
+accfg_mdev_get_type(struct accfg_device_mdev *mdev);
+
+#define accfg_device_mdev_foreach(device, mdev) \
+for (mdev = accfg_device_first_mdev(device); \
+mdev != NULL; \
+mdev = accfg_device_next_mdev(mdev))
+
 /* libaccfg function for group */
 struct accfg_group;
 struct accfg_group *accfg_group_get_first(struct accfg_device *device);
--

2.26.2

#12 lore raw

PATCH 4/11 accel-config: Add mdev json support

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Load the mdevs stored in device contexts into json objects as array of mdev structures containing uuid and types

"list" command will list the mdevs structures under each device

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 util/json.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
util/json.c +38 -0
index 6f4b4d1..8ff89d0 100644
@@ -153,6 +153,12 @@ struct json_object *util_device_to_json(struct accfg_device *device,
 	unsigned long ulong_val;
 	unsigned long long ullong_val;
 	bool new_bool;
+	struct accfg_device_mdev *mdev;
+	struct json_object *json_uuid;
+	struct json_object *json_mtype;
+	char uuid_string[UUID_STR_LEN];
+	int mdev_found = 0;
+	struct json_object *json_mdev;
 
 	if (!jdevice)
 		return NULL;
@@ -339,6 +345,38 @@ struct json_object *util_device_to_json(struct accfg_device *device,
 		goto err;
 	json_object_object_add(jdevice, "clients", jobj);
 
+	jobj = json_object_new_array();
+	accfg_device_mdev_foreach(device, mdev) {
+		uuid_t uuid;
+		const char *mdev_type;
+
+		accfg_mdev_get_uuid(mdev, uuid);
+		uuid_unparse(uuid, uuid_string);
+		json_uuid = json_object_new_string(uuid_string);
+		if (!json_uuid)
+			break;
+		mdev_type = accfg_mdev_basenames[accfg_mdev_get_type(mdev)];
+		json_mtype = json_object_new_string(mdev_type);
+		if (!json_mtype) {
+			json_object_put(json_uuid);
+			break;
+		}
+		json_mdev = json_object_new_object();
+		if (!json_mdev) {
+			json_object_put(json_uuid);
+			json_object_put(json_mtype);
+			break;
+		}
+		json_object_object_add(json_mdev, "uuid", json_uuid);
+		json_object_object_add(json_mdev, "type", json_mtype);
+		json_object_array_add(jobj, json_mdev);
+		mdev_found++;
+	}
+	if (mdev_found)
+		json_object_object_add(jdevice, "mdevs", jobj);
+	else
+		json_object_put(jobj);
+
 	free(error);
 	return jdevice;
 err:
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 4/11
#13 lore raw

[Accel-config] Re: [PATCH v1 04/11] accel-config: Add mdev json support

Quoted 10 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 04/11] accel-config: Add mdev json support

Quoted 8 lines

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Load the mdevs stored in device contexts into json objects as array of mdev structures containing uuid and types

"list" command will list the mdevs structures under each device

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 65 lines
---
 util/json.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
util/json.c +6 -0
index 6f4b4d1..8ff89d0 100644
@@ -153,6 +153,12 @@ struct json_object *util_device_to_json(struct
 accfg_device *device,
 	unsigned long ulong_val;
 	unsigned long long ullong_val;
 	bool new_bool;
+	struct accfg_device_mdev *mdev;
+	struct json_object *json_uuid;
+	struct json_object *json_mtype;
+	char uuid_string[UUID_STR_LEN];
+	int mdev_found = 0;
+	struct json_object *json_mdev;
 
 	if (!jdevice)
util/json.c +32 -0
 		return NULL;
@@ -339,6 +345,38 @@ struct json_object *util_device_to_json(struct
 accfg_device *device,
 		goto err;
 	json_object_object_add(jdevice, "clients", jobj);
 
+	jobj = json_object_new_array();
+	accfg_device_mdev_foreach(device, mdev) {
+		uuid_t uuid;
+		const char *mdev_type;
+
+		accfg_mdev_get_uuid(mdev, uuid);
+		uuid_unparse(uuid, uuid_string);
+		json_uuid = json_object_new_string(uuid_string);
+		if (!json_uuid)
+			break;
+		mdev_type =
 accfg_mdev_basenames[accfg_mdev_get_type(mdev)];
+		json_mtype = json_object_new_string(mdev_type);
+		if (!json_mtype) {
+			json_object_put(json_uuid);
+			break;
+		}
+		json_mdev = json_object_new_object();
+		if (!json_mdev) {
+			json_object_put(json_uuid);
+			json_object_put(json_mtype);
+			break;
+		}
+		json_object_object_add(json_mdev, "uuid", json_uuid);
+		json_object_object_add(json_mdev, "type", json_mtype);
+		json_object_array_add(jobj, json_mdev);
+		mdev_found++;
+	}
+	if (mdev_found)
+		json_object_object_add(jdevice, "mdevs", jobj);
+	else
+		json_object_put(jobj);
+
 	free(error);

return jdevice;
err:
--
2.26.2

#14 lore raw

PATCH 5/11 accel-config: Implement create and remove mdev library API

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Adds accfg_create_mdev and accfg_remove_mdev library functions.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccel-config.sym |   2 +
 accfg/lib/libaccfg.c          | 104 ++++++++++++++++++++++++++++++++++
 accfg/libaccel_config.h       |   3 +
 3 files changed, 109 insertions(+)
accfg/lib/libaccel-config.sym +2 -0
index a857152..73c8417 100644
@@ -141,4 +141,6 @@ global:
 	accfg_mdev_get_uuid;
 	accfg_mdev_get_type;
 	accfg_mdev_basenames;
+	accfg_create_mdev;
+	accfg_remove_mdev;
 } LIBACCFG_7;
accfg/lib/libaccfg.c +104 -0

110 lines not on this page · raw message

accfg/libaccel_config.h +3 -0
index a55bfde..95678fb 100644
@@ -189,6 +189,9 @@ struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device *device);
 struct accfg_device_mdev *accfg_device_next_mdev(struct accfg_device_mdev *mdev);
 void accfg_mdev_get_uuid(struct accfg_device_mdev *mdev, uuid_t uuid);
 enum accfg_mdev_type accfg_mdev_get_type(struct accfg_device_mdev *mdev);
+int accfg_create_mdev(struct accfg_device *device, enum accfg_mdev_type type,
+		uuid_t uuid);
+int accfg_remove_mdev(struct accfg_device *device, uuid_t uuid);
 
 #define accfg_device_mdev_foreach(device, mdev) \
 	for (mdev = accfg_device_first_mdev(device); \
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 5/11
#15 lore raw

[Accel-config] Re: [PATCH v1 05/11] accel-config: Implement create and remove mdev library API

Quoted 11 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 05/11] accel-config: Implement create and remove mdev library API

Quoted 5 lines

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Adds accfg_create_mdev and accfg_remove_mdev library functions.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 155 lines
---
 accfg/lib/libaccel-config.sym |   2 +
 accfg/lib/libaccfg.c          | 104 ++++++++++++++++++++++++++++++++++
 accfg/libaccel_config.h       |   3 +
 3 files changed, 109 insertions(+)
accfg/lib/libaccel-config.sym +2 -0
index a857152..73c8417 100644
@@ -141,4 +141,6 @@ global:
 	accfg_mdev_get_uuid;
 	accfg_mdev_get_type;
 	accfg_mdev_basenames;
+	accfg_create_mdev;
+	accfg_remove_mdev;
 } LIBACCFG_7;
accfg/lib/libaccfg.c +0 -0
index 6a4648a..ce789e6 100644
@@ -978,6 +978,110 @@ ACCFG_EXPORT enum accfg_mdev_type

accfg_mdev_get_type(struct accfg_device_mdev *

accfg/lib/libaccfg.c +64 -0
 	return mdev->type;
 }
 
+static void accfg_gen_uuid(struct accfg_device *device, uuid_t uuid)
+{
+	struct accfg_device_mdev *entry, *next;
+
+	uuid_clear(uuid);
+	while (1) {
+		uuid_generate(uuid);
+		if (list_empty(&device->mdev_list))
+			return;
+		list_for_each_safe(&device->mdev_list, entry, next, list) {
+			if (uuid_compare(uuid, entry->uuid) != 0)
+				return;
+		}
+	}
+}
+
+ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device,
+		enum accfg_mdev_type type, uuid_t uuid)
+{
+	struct accfg_ctx *ctx = accfg_device_get_ctx(device);
+	struct accfg_device_mdev *mdev;
+	char uuid_str[UUID_STR_LEN];
+	char mdev_path[PATH_MAX];
+	int rc;
+
+	if (type >= ACCFG_MDEV_TYPE_UNKNOWN || type < 0)
+		return -EINVAL;
+
+	mdev = calloc(1, sizeof(struct accfg_device_mdev));
+	if (!mdev) {
+		err(ctx, "mdev allocation failed\n");
+		return -ENOMEM;
+	}
+	accfg_gen_uuid(device, mdev->uuid);
+	mdev->type = type;
+
+	uuid_unparse(mdev->uuid, uuid_str);
+	sprintf(mdev_path, "%s/%s/idxd-%s/create", device->mdev_path,
+			MDEV_POSTFIX, accfg_mdev_basenames[type]);
+	rc = sysfs_write_attr(ctx, mdev_path, uuid_str);
+	if (rc < 0) {
+		err(ctx, "create mdev failed %d\n", rc);
+		goto create_err;
+	}
+
+	list_add_tail(&device->mdev_list, &mdev->list);
+	uuid_copy(uuid, mdev->uuid);
+	return 0;
+
+create_err:
+	free(mdev);
+	return rc;
+}
+
+static int accfg_device_mdev_remove(struct accfg_device *device,
+		struct accfg_device_mdev *mdev)
+{
+	struct accfg_ctx *ctx = accfg_device_get_ctx(device);
+	char uuid_str[UUID_STR_LEN];
+	char mdev_path[PATH_MAX];
+	int rc;
+
+	uuid_unparse(mdev->uuid, uuid_str);
+	sprintf(mdev_path, "%s/%s/remove", device->mdev_path,

uuid_str);

accfg/lib/libaccfg.c +11 -0
+	rc = sysfs_write_attr(ctx, mdev_path, "1");
+	if (rc < 0)
+		return rc;
+
+	list_del(&mdev->list);
+	free(mdev);
+
+	return 0;
+}
+
+ACCFG_EXPORT int accfg_remove_mdev(struct accfg_device *device,

uuid_t uuid)

accfg/lib/libaccfg.c +29 -0
+{
+	struct accfg_ctx *ctx = accfg_device_get_ctx(device);
+	struct accfg_device_mdev *entry, *next;
+	int rc, all;
+
+	/* remove all mdevs if null uuid is passed */
+	all = uuid_is_null(uuid);
+	list_for_each_safe(&device->mdev_list, entry, next, list) {
+		if (all || !uuid_compare(entry->uuid, uuid)) {
+			rc = accfg_device_mdev_remove(device, entry);
+			if (rc < 0)
+				goto remove_err;
+			if (!all)
+				return 0;
+		}
+	}
+
+	if (!all) {
+		err(ctx, "mdev uuid not found\n");
+		return -EINVAL;
+	}
+
+	return 0;
+
+remove_err:
+	err(ctx, "remove mdev failed %d\n", rc);
+	return rc;
+}
+
 /**
  * accfg_device_get_first - retrieve first device in the system
  * @ctx: context established by accfg_new
accfg/libaccel_config.h +1 -0
index a55bfde..95678fb 100644
@@ -189,6 +189,9 @@ struct accfg_device_mdev
 *accfg_device_first_mdev(struct accfg_device *device);
 struct accfg_device_mdev *accfg_device_next_mdev(struct
 accfg_device_mdev *mdev);
 void accfg_mdev_get_uuid(struct accfg_device_mdev *mdev, uuid_t uuid);
 enum accfg_mdev_type accfg_mdev_get_type(struct accfg_device_mdev
 *mdev);
+int accfg_create_mdev(struct accfg_device *device, enum

accfg_mdev_type type,

accfg/libaccel_config.h +2 -1
+		uuid_t uuid);
+int accfg_remove_mdev(struct accfg_device *device, uuid_t uuid);
 
 #define accfg_device_mdev_foreach(device, mdev) \
 	for (mdev = accfg_device_first_mdev(device); \
--

2.26.2

#16 lore raw

PATCH 6/11 accel-config: Add mdev create and remove commands

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Implements following commands -
accel-config create-mdev <device-name> [<mdev-type>|<options>] accel-config remove-mdev <device-name> [<uuid>|<options>]

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/mdev.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 122 insertions(+), 1 deletion(-)
accfg/mdev.c +122 -1
index 56c5c68..652b734 100644
@@ -21,12 +21,133 @@
 #include <sys/stat.h>
 #include <accfg.h>
 
+static int opt_called;
+static struct accfg_device *device;
+
+static int opt_cb_create_mdev(const struct option *opt, const char *arg, int unset)
+{
+	char **m;
+
+	if (opt->short_name != 'l')
+		return -1;
+
+	printf("Available mdev types:\n");
+	for (m = accfg_mdev_basenames; *m; m++)
+		printf("\t%s\n", *m);
+
+	opt_called = true;
+
+	return 0;
+}
+
+static int opt_cb_remove_mdev(const struct option *opt, const char *arg, int unset)
+{
+	uuid_t uuid;
+	char uuid_str[UUID_STR_LEN];
+	struct accfg_device_mdev *mdev;
+	enum accfg_mdev_type type;
+
+	if (opt->short_name != 'l')
+		return -1;
+
+	printf("Available mdevs:\n");
+	accfg_device_mdev_foreach(device, mdev) {
+		accfg_mdev_get_uuid(mdev, uuid);
+		type = accfg_mdev_get_type(mdev);
+		uuid_unparse(uuid, uuid_str);
+		printf("\tuuid:%s, type:%s\n", uuid_str,
+				accfg_mdev_basenames[type]);
+	}
+	opt_called = true;
+
+	return 0;
+}
+
 int cmd_create_mdev(int argc, const char **argv, void *ctx)
 {
+	char **m;
+	int rc, t;
+	uuid_t uuid;
+	char uuid_str[UUID_STR_LEN];
+
+	const struct option options[] = {
+		OPT_CALLBACK_NOOPT('l', "list-mdev-types", NULL, NULL,
+				"will list available mdev types", opt_cb_create_mdev),
+		OPT_END(),
+	};
+
+	const char *const u[] = {
+		"accfg create-mdev <device name> [<mdev type>|<options>]",
+		NULL
+	};
+
+	if (argc < 3)
+		usage_with_options(u, options);
+
+	device = accfg_ctx_device_get_by_name(ctx, argv[1]);
+	if (!device) {
+		fprintf(stderr, "Enter a valid device to create mdev\n");
+		usage_with_options(u, options);
+	}
+
+	argc = parse_options(argc, argv, options, u, 0);
+	if (opt_called)
+		return 0;
+
+	for (m = accfg_mdev_basenames, t = 0; *m; m++, t++)
+		if (!strcmp(argv[1], *m))
+			break;
+	if (!*m) {
+		fprintf(stderr, "Invalid mdev type\n");
+		usage_with_options(u, options);
+	}
+
+	rc = accfg_create_mdev(device, t, uuid);
+	if (rc < 0)
+		return rc;
+
+	uuid_unparse(uuid, uuid_str);
+	printf("Created mdev wth uuid: %s\n", uuid_str);
+
 	return 0;
 }
 
 int cmd_remove_mdev(int argc, const char **argv, void *ctx)
 {
-	return 0;
+	int rc;
+	uuid_t uuid;
+
+	const struct option options[] = {
+		OPT_CALLBACK_NOOPT('l', "list-mdevs", NULL, NULL,
+				"will list available mdevs", opt_cb_remove_mdev),
+		OPT_END(),
+	};
+
+	const char *const u[] = {
+		"accfg remove-mdev <device name> [<uuid>|<options>]",
+		"Pass null uuid to remove all mdevs",
+		NULL
+	};
+
+	if (argc < 3)
+		usage_with_options(u, options);
+
+	device = accfg_ctx_device_get_by_name(ctx, argv[1]);
+	if (!device) {
+		fprintf(stderr, "Enter a valid device to remove mdev\n");
+		usage_with_options(u, options);
+	}
+
+	argc = parse_options(argc, argv, options, u, 0);
+	if (opt_called)
+		return 0;
+
+	if (uuid_parse(argv[1], uuid) < 0) {
+		fprintf(stderr, "Invalid uuid\n");
+		usage_with_options(u, options);
+	}
+
+	rc = accfg_remove_mdev(device, uuid);
+
+	return rc;
 }
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 6/11
#17 lore raw

[Accel-config] Re: [PATCH v1 06/11] accel-config: Add mdev create and remove commands

Quoted 11 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 06/11] accel-config: Add mdev create and remove commands

Quoted 1 line

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 157 lines

Implements following commands -
accel-config create-mdev <device-name> [<mdev-type>|<options>] accel-config remove-mdev <device-name> [<uuid>|<options>]

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/mdev.c | 123
++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 122 insertions(+), 1 deletion(-)
accfg/mdev.c +92 -1
index 56c5c68..652b734 100644
@@ -21,12 +21,133 @@
 #include <sys/stat.h>
 #include <accfg.h>
 
+static int opt_called;
+static struct accfg_device *device;
+
+static int opt_cb_create_mdev(const struct option *opt, const char *arg, int
 unset)
+{
+	char **m;
+
+	if (opt->short_name != 'l')
+		return -1;
+
+	printf("Available mdev types:\n");
+	for (m = accfg_mdev_basenames; *m; m++)
+		printf("\t%s\n", *m);
+
+	opt_called = true;
+
+	return 0;
+}
+
+static int opt_cb_remove_mdev(const struct option *opt, const char *arg,
 int unset)
+{
+	uuid_t uuid;
+	char uuid_str[UUID_STR_LEN];
+	struct accfg_device_mdev *mdev;
+	enum accfg_mdev_type type;
+
+	if (opt->short_name != 'l')
+		return -1;
+
+	printf("Available mdevs:\n");
+	accfg_device_mdev_foreach(device, mdev) {
+		accfg_mdev_get_uuid(mdev, uuid);
+		type = accfg_mdev_get_type(mdev);
+		uuid_unparse(uuid, uuid_str);
+		printf("\tuuid:%s, type:%s\n", uuid_str,
+				accfg_mdev_basenames[type]);
+	}
+	opt_called = true;
+
+	return 0;
+}
+
 int cmd_create_mdev(int argc, const char **argv, void *ctx)
 {
+	char **m;
+	int rc, t;
+	uuid_t uuid;
+	char uuid_str[UUID_STR_LEN];
+
+	const struct option options[] = {
+		OPT_CALLBACK_NOOPT('l', "list-mdev-types", NULL, NULL,
+				"will list available mdev types",
 opt_cb_create_mdev),
+		OPT_END(),
+	};
+
+	const char *const u[] = {
+		"accfg create-mdev <device name> [<mdev
 type>|<options>]",
+		NULL
+	};
+
+	if (argc < 3)
+		usage_with_options(u, options);
+
+	device = accfg_ctx_device_get_by_name(ctx, argv[1]);
+	if (!device) {
+		fprintf(stderr, "Enter a valid device to create mdev\n");
+		usage_with_options(u, options);
+	}
+
+	argc = parse_options(argc, argv, options, u, 0);
+	if (opt_called)
+		return 0;
+
+	for (m = accfg_mdev_basenames, t = 0; *m; m++, t++)
+		if (!strcmp(argv[1], *m))
+			break;
+	if (!*m) {
+		fprintf(stderr, "Invalid mdev type\n");
+		usage_with_options(u, options);
+	}
+
+	rc = accfg_create_mdev(device, t, uuid);
+	if (rc < 0)
+		return rc;
+
+	uuid_unparse(uuid, uuid_str);
+	printf("Created mdev wth uuid: %s\n", uuid_str);
+
 	return 0;
 }
 
 int cmd_remove_mdev(int argc, const char **argv, void *ctx)
 {
-	return 0;
+	int rc;
+	uuid_t uuid;
+
+	const struct option options[] = {
+		OPT_CALLBACK_NOOPT('l', "list-mdevs", NULL, NULL,
+				"will list available mdevs",

opt_cb_remove_mdev),

accfg/mdev.c +30 -1
+		OPT_END(),
+	};
+
+	const char *const u[] = {
+		"accfg remove-mdev <device name> [<uuid>|<options>]",
+		"Pass null uuid to remove all mdevs",
+		NULL
+	};
+
+	if (argc < 3)
+		usage_with_options(u, options);
+
+	device = accfg_ctx_device_get_by_name(ctx, argv[1]);
+	if (!device) {
+		fprintf(stderr, "Enter a valid device to remove mdev\n");
+		usage_with_options(u, options);
+	}
+
+	argc = parse_options(argc, argv, options, u, 0);
+	if (opt_called)
+		return 0;
+
+	if (uuid_parse(argv[1], uuid) < 0) {
+		fprintf(stderr, "Invalid uuid\n");
+		usage_with_options(u, options);
+	}
+
+	rc = accfg_remove_mdev(device, uuid);
+
+	return rc;
 }
--

2.26.2

#18 lore raw

PATCH 7/11 accel-config: Improve management of test cases

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Created structure to store test func and description. Array of this structure will be used to print test case description and results. This removes the need to name tests with serial numbers. Invidual tests can be enabled/disabled by setting a flag.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 66 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 26 deletions(-)
test/libaccfg.c +40 -26
index aef877a..2494a44 100644
@@ -766,7 +766,7 @@ static int wq_bounds_test(struct accfg_ctx *ctx, const char *dev_name)
 }
 
 /* test the set and get libaccfg functions for all components in dsa0 */
-static int do_test0(struct accfg_ctx *ctx)
+static int test_config(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
@@ -781,22 +781,18 @@ static int do_test0(struct accfg_ctx *ctx)
 
 	/* get configuration to see if match */
 	rc = check_config(ctx, "dsa0");
-	if (rc != 0) {
-		fprintf(stderr, "test 0: test the set and get libaccfg functions for components failed\n");
+	if (rc != 0)
 		return rc;
-	}
 
 	rc = device_test_reset(ctx, "dsa0");
 	if (rc != 0)
 		return rc;
 
-	fprintf(stderr, "test 0: test the set and get libaccfg functions for components passed successfully\n");
-
 	return 0;
 }
 
 /* set large wq to exceed max total size in dsa */
-static int do_test1(struct accfg_ctx *ctx)
+static int test_max_wq_size(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
@@ -805,21 +801,18 @@ static int do_test1(struct accfg_ctx *ctx)
 		return rc;
 
 	rc = set_exceed_config(ctx, "dsa1");
-	if (rc != 0) {
-		fprintf(stderr, "test 1: set large wq to exceed max total size in dsa failed\n");
+	if (rc != 0)
 		return rc;
-	}
 
 	rc = device_test_reset(ctx, "dsa1");
 	if (rc != 0)
 		return rc;
 
-	fprintf(stderr, "test 1: set large wq to exceed max total size in dsa passed successfully\n");
-		return 0;
+	return 0;
 }
 
 /* test the boundary conditions for wq max_batch_size and max_transfer_size */
-static int do_test2(struct accfg_ctx *ctx)
+static int test_wq_boundary_conditions(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
@@ -828,24 +821,39 @@ static int do_test2(struct accfg_ctx *ctx)
 		return rc;
 
 	rc = wq_bounds_test(ctx, "dsa0");
-	if (rc != 0) {
-		fprintf(stderr, "test 2: wq boundary conditions test failed\n");
+	if (rc != 0)
 		return rc;
-	}
 
 	rc = device_test_reset(ctx, "dsa0");
 	if (rc != 0)
 		return rc;
 
-	fprintf(stderr, "test 2: wq boundary conditions test passed successfully\n");
-		return 0;
+	return 0;
 }
 
 typedef int (*do_test_fn)(struct accfg_ctx *ctx);
-static do_test_fn do_test[] = {
-	do_test0,
-	do_test1,
-	do_test2,
+struct _test_case {
+	do_test_fn test_fn;
+	char *desc;
+	bool enabled;
+};
+
+static struct _test_case test_cases[] = {
+	{
+		.test_fn = test_config,
+		.desc = "set and get configurations",
+		.enabled = true,
+	},
+	{
+		.test_fn = test_max_wq_size,
+		.desc = "max wq size",
+		.enabled = true,
+	},
+	{
+		.test_fn = test_wq_boundary_conditions,
+		.desc = "wq boundary conditions",
+		.enabled = true,
+	},
 };
 
 static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod,
@@ -914,15 +922,21 @@ int test_libaccfg(int loglevel, struct accfg_test *test,
 		}
 	}
 
-	for (i = 0; i < ARRAY_SIZE(do_test); i++) {
-		err = do_test[i](ctx);
+	for (i = 0; i < ARRAY_SIZE(test_cases); i++) {
+		if (!test_cases[i].enabled) {
+			fprintf(stderr, "\naccfg-test%d *disabled*\n", i);
+			continue;
+		}
+		printf("\nRunning accfg-test%d: %s\n", i, test_cases[i].desc);
+		err = test_cases[i].test_fn(ctx);
 		if (err < 0) {
-			fprintf(stderr, "accfg-test%d failed: %d\n", i, err);
+			fprintf(stderr, "accfg-test%d *failed*: %d\n", i, err);
 			break;
 		}
+		printf("accfg-test%d passed!\n", i);
 	}
 
-	if (i >= ARRAY_SIZE(do_test))
+	if (i >= ARRAY_SIZE(test_cases))
 		result = EXIT_SUCCESS;
 
 	kmod_module_remove_module(mod, 0);
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 7/11
#19 lore raw

[Accel-config] Re: [PATCH v1 07/11] accel-config: Improve management of test cases

Quoted 11 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 07/11] accel-config: Improve management of test cases

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 160 lines

Created structure to store test func and description. Array of this structure will be used to print test case description and results. This removes the need to name tests with serial numbers. Invidual tests can be enabled/disabled by setting a flag.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 66 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 26 deletions(-)
test/libaccfg.c +3 -7
index aef877a..2494a44 100644
@@ -766,7 +766,7 @@ static int wq_bounds_test(struct accfg_ctx *ctx, const
 char *dev_name)
 }
 
 /* test the set and get libaccfg functions for all components in dsa0 */
-static int do_test0(struct accfg_ctx *ctx)
+static int test_config(struct accfg_ctx *ctx)
 {
 	int rc = 0;
@@ -781,22 +781,18 @@ static int do_test0(struct accfg_ctx *ctx)
 
 	/* get configuration to see if match */
 	rc = check_config(ctx, "dsa0");
-	if (rc != 0) {
-		fprintf(stderr, "test 0: test the set and get libaccfg functions
 for components failed\n");
+	if (rc != 0)
 		return rc;
-	}
 
 	rc = device_test_reset(ctx, "dsa0");
 	if (rc != 0)
 		return rc;
 
-	fprintf(stderr, "test 0: test the set and get libaccfg functions for
 components passed successfully\n");
-
 	return 0;
 }
 
 /* set large wq to exceed max total size in dsa */
-static int do_test1(struct accfg_ctx *ctx)
+static int test_max_wq_size(struct accfg_ctx *ctx)
 {
test/libaccfg.c +2 -5
 	int rc = 0;
@@ -805,21 +801,18 @@ static int do_test1(struct accfg_ctx *ctx)
 		return rc;
 
 	rc = set_exceed_config(ctx, "dsa1");
-	if (rc != 0) {
-		fprintf(stderr, "test 1: set large wq to exceed max total size in
 dsa failed\n");
+	if (rc != 0)
 		return rc;
-	}
 
 	rc = device_test_reset(ctx, "dsa1");
 	if (rc != 0)
 		return rc;
 
-	fprintf(stderr, "test 1: set large wq to exceed max total size in dsa
 passed successfully\n");
-		return 0;
+	return 0;
 }
 
 /* test the boundary conditions for wq max_batch_size and

max_transfer_size */

test/libaccfg.c +25 -10
-static int do_test2(struct accfg_ctx *ctx)
+static int test_wq_boundary_conditions(struct accfg_ctx *ctx)
 {
 	int rc = 0;
@@ -828,24 +821,39 @@ static int do_test2(struct accfg_ctx *ctx)
 		return rc;
 
 	rc = wq_bounds_test(ctx, "dsa0");
-	if (rc != 0) {
-		fprintf(stderr, "test 2: wq boundary conditions test
 failed\n");
+	if (rc != 0)
 		return rc;
-	}
 
 	rc = device_test_reset(ctx, "dsa0");
 	if (rc != 0)
 		return rc;
 
-	fprintf(stderr, "test 2: wq boundary conditions test passed
 successfully\n");
-		return 0;
+	return 0;
 }
 
 typedef int (*do_test_fn)(struct accfg_ctx *ctx);
-static do_test_fn do_test[] = {
-	do_test0,
-	do_test1,
-	do_test2,
+struct _test_case {
+	do_test_fn test_fn;
+	char *desc;
+	bool enabled;
+};
+
+static struct _test_case test_cases[] = {
+	{
+		.test_fn = test_config,
+		.desc = "set and get configurations",
+		.enabled = true,
+	},
+	{
+		.test_fn = test_max_wq_size,
+		.desc = "max wq size",
+		.enabled = true,
+	},
+	{
+		.test_fn = test_wq_boundary_conditions,
+		.desc = "wq boundary conditions",
+		.enabled = true,
+	},
 };

static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module
**mod,

test/libaccfg.c +10 -5
@@ -914,15 +922,21 @@ int test_libaccfg(int loglevel, struct accfg_test *test,
 		}
 	}
 
-	for (i = 0; i < ARRAY_SIZE(do_test); i++) {
-		err = do_test[i](ctx);
+	for (i = 0; i < ARRAY_SIZE(test_cases); i++) {
+		if (!test_cases[i].enabled) {
+			fprintf(stderr, "\naccfg-test%d *disabled*\n", i);
+			continue;
+		}
+		printf("\nRunning accfg-test%d: %s\n", i, test_cases[i].desc);
+		err = test_cases[i].test_fn(ctx);
 		if (err < 0) {
-			fprintf(stderr, "accfg-test%d failed: %d\n", i, err);
+			fprintf(stderr, "accfg-test%d *failed*: %d\n", i, err);
 			break;
 		}
+		printf("accfg-test%d passed!\n", i);
 	}
 
-	if (i >= ARRAY_SIZE(do_test))
+	if (i >= ARRAY_SIZE(test_cases))
 		result = EXIT_SUCCESS;
 
 	kmod_module_remove_module(mod, 0);
--

2.26.2

#20 lore raw

PATCH 8/11 accel-config: Unit tests for mdev support

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Tests for create/remove mdev 1swq amd 1dwq

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 157 insertions(+), 1 deletion(-)
test/libaccfg.c +157 -1
index 2494a44..b8f6522 100644
@@ -492,7 +492,6 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
 
 			if (wq_state == ACCFG_WQ_DISABLED ||
 					wq_state == ACCFG_WQ_QUIESCING) {
-				fprintf(stderr, "%s is disabled already\n", accfg_wq_get_devname(wq));
 				continue;
 			}
 
@@ -762,6 +761,15 @@ static int wq_bounds_test(struct accfg_ctx *ctx, const char *dev_name)
 		return rc;
 	}
 
+	/* reset to valid values for following tests */
+	wq00_param.max_batch_size = 1;
+	wq00_param.max_transfer_size = 1;
+	rc = config_wq(ctx, 0, 0, wq00_param, dev_name);
+	if (rc != 0) {
+		fprintf(stderr, "config wq wq0.0 failed\n");
+		return rc;
+	}
+
 	return 0;
 }
 
@@ -831,6 +839,144 @@ static int test_wq_boundary_conditions(struct accfg_ctx *ctx)
 	return 0;
 }
 
+static int mdev_test(struct accfg_ctx *ctx, const char *dev_name,
+		char *mdev_type_str, int num_mdevs)
+{
+	struct accfg_device *device;
+	enum accfg_mdev_type type;
+	int rc, i;
+	char **m;
+	uuid_t uuid;
+
+	device = accfg_ctx_device_get_by_name(ctx, dev_name);
+	if (!device) {
+		fprintf(stderr, "Device %s not found\n", dev_name);
+		return -EINVAL;
+	}
+
+	for (m = accfg_mdev_basenames, type = 0; *m; m++, type++)
+		if (!strcmp(*m, mdev_type_str))
+			break;
+
+	if (!*m) {
+		fprintf(stderr, "Invalid mdev type\n");
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num_mdevs; i++) {
+		rc = accfg_create_mdev(device, type, uuid);
+		if (rc) {
+			fprintf(stderr, "mdev creation failed\n");
+			return rc;
+		}
+	}
+
+	/* Remove all mdevs */
+	uuid_clear(uuid);
+	rc = accfg_remove_mdev(device, uuid);
+	if (rc) {
+		fprintf(stderr, "mdev removal failed\n");
+		return rc;
+	}
+
+	return rc;
+}
+
+static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int wq_id)
+{
+	struct accfg_device *device;
+	struct accfg_wq *wq;
+	int rc;
+
+	device = accfg_ctx_device_get_by_name(ctx, dev_name);
+	if (!device) {
+		fprintf(stderr, "Device %s not found\n", dev_name);
+		return -EINVAL;
+	}
+	if (!accfg_device_is_active(device)) {
+		rc = accfg_device_enable(device);
+		if (rc < 0) {
+			fprintf(stderr, "device enable of %s failed\n",
+					dev_name);
+			return rc;
+		}
+	}
+
+	wq = accfg_device_wq_get_by_id(device, wq_id);
+	if (!wq) {
+		fprintf(stderr, "wq with id %d not found for device %s\n",
+				wq_id, dev_name);
+		return -EINVAL;
+	}
+
+	if (accfg_wq_get_state(wq) == ACCFG_WQ_ENABLED)
+		return 0;
+
+	return accfg_wq_enable(wq);
+}
+
+/* test 1swq type mdev creation and removal */
+static int test_mdev_1swq(struct accfg_ctx *ctx)
+{
+	int rc = 0;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	rc = set_config(ctx, "dsa0");
+	if (rc != 0)
+		return rc;
+
+	rc = enable_wq(ctx, "dsa0", 2);
+	if (rc) {
+		fprintf(stderr, "enable wq wq0.2 failed");
+		return rc;
+	}
+
+	/* create and remove 5 1swq mdevs */
+	rc = mdev_test(ctx, "dsa0", "1swq", 5);
+	if (rc)
+		return rc;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
+/* test 1dwq type mdev creation and removal */
+static int test_mdev_1dwq(struct accfg_ctx *ctx)
+{
+	int rc = 0;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	rc = set_config(ctx, "dsa0");
+	if (rc != 0)
+		return rc;
+
+	rc = enable_wq(ctx, "dsa0", 3);
+	if (rc) {
+		fprintf(stderr, "enable wq wq0.3 failed");
+		return rc;
+	}
+
+	/* create and remove 1 1dwq mdev */
+	rc = mdev_test(ctx, "dsa0", "1dwq", 1);
+	if (rc)
+		return rc;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
 typedef int (*do_test_fn)(struct accfg_ctx *ctx);
 struct _test_case {
 	do_test_fn test_fn;
@@ -854,6 +1000,16 @@ static struct _test_case test_cases[] = {
 		.desc = "wq boundary conditions",
 		.enabled = true,
 	},
+	{
+		.test_fn = test_mdev_1swq,
+		.desc = "1swq type mdev creation and removal",
+		.enabled = true,
+	},
+	{
+		.test_fn = test_mdev_1dwq,
+		.desc = "1dwq type mdev creation and removal",
+		.enabled = true,
+	},
 };
 
 static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod,
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 8/11
#21 lore raw

[Accel-config] Re: [PATCH v1 08/11] accel-config: Unit tests for mdev support

Quoted 10 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 08/11] accel-config: Unit tests for mdev support

Quoted 5 lines

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Tests for create/remove mdev 1swq amd 1dwq

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 204 lines
---
 test/libaccfg.c | 158
+++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 157 insertions(+), 1 deletion(-)
test/libaccfg.c +0 -1
index 2494a44..b8f6522 100644
@@ -492,7 +492,6 @@ static int device_test_reset(struct accfg_ctx *ctx,
 const char *dev_name)
 
 			if (wq_state == ACCFG_WQ_DISABLED ||
 					wq_state ==
 ACCFG_WQ_QUIESCING) {
-				fprintf(stderr, "%s is disabled already\n",
 accfg_wq_get_devname(wq));
test/libaccfg.c +147 -0
 				continue;
 			}
@@ -762,6 +761,15 @@ static int wq_bounds_test(struct accfg_ctx *ctx,
 const char *dev_name)
 		return rc;
 	}
 
+	/* reset to valid values for following tests */
+	wq00_param.max_batch_size = 1;
+	wq00_param.max_transfer_size = 1;
+	rc = config_wq(ctx, 0, 0, wq00_param, dev_name);
+	if (rc != 0) {
+		fprintf(stderr, "config wq wq0.0 failed\n");
+		return rc;
+	}
+
 	return 0;
 }
@@ -831,6 +839,144 @@ static int test_wq_boundary_conditions(struct
 accfg_ctx *ctx)
 	return 0;
 }
 
+static int mdev_test(struct accfg_ctx *ctx, const char *dev_name,
+		char *mdev_type_str, int num_mdevs)
+{
+	struct accfg_device *device;
+	enum accfg_mdev_type type;
+	int rc, i;
+	char **m;
+	uuid_t uuid;
+
+	device = accfg_ctx_device_get_by_name(ctx, dev_name);
+	if (!device) {
+		fprintf(stderr, "Device %s not found\n", dev_name);
+		return -EINVAL;
+	}
+
+	for (m = accfg_mdev_basenames, type = 0; *m; m++, type++)
+		if (!strcmp(*m, mdev_type_str))
+			break;
+
+	if (!*m) {
+		fprintf(stderr, "Invalid mdev type\n");
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num_mdevs; i++) {
+		rc = accfg_create_mdev(device, type, uuid);
+		if (rc) {
+			fprintf(stderr, "mdev creation failed\n");
+			return rc;
+		}
+	}
+
+	/* Remove all mdevs */
+	uuid_clear(uuid);
+	rc = accfg_remove_mdev(device, uuid);
+	if (rc) {
+		fprintf(stderr, "mdev removal failed\n");
+		return rc;
+	}
+
+	return rc;
+}
+
+static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int
 wq_id)
+{
+	struct accfg_device *device;
+	struct accfg_wq *wq;
+	int rc;
+
+	device = accfg_ctx_device_get_by_name(ctx, dev_name);
+	if (!device) {
+		fprintf(stderr, "Device %s not found\n", dev_name);
+		return -EINVAL;
+	}
+	if (!accfg_device_is_active(device)) {
+		rc = accfg_device_enable(device);
+		if (rc < 0) {
+			fprintf(stderr, "device enable of %s failed\n",
+					dev_name);
+			return rc;
+		}
+	}
+
+	wq = accfg_device_wq_get_by_id(device, wq_id);
+	if (!wq) {
+		fprintf(stderr, "wq with id %d not found for device %s\n",
+				wq_id, dev_name);
+		return -EINVAL;
+	}
+
+	if (accfg_wq_get_state(wq) == ACCFG_WQ_ENABLED)
+		return 0;
+
+	return accfg_wq_enable(wq);
+}
+
+/* test 1swq type mdev creation and removal */
+static int test_mdev_1swq(struct accfg_ctx *ctx)
+{
+	int rc = 0;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	rc = set_config(ctx, "dsa0");
+	if (rc != 0)
+		return rc;
+
+	rc = enable_wq(ctx, "dsa0", 2);
+	if (rc) {
+		fprintf(stderr, "enable wq wq0.2 failed");
+		return rc;
+	}
+
+	/* create and remove 5 1swq mdevs */
+	rc = mdev_test(ctx, "dsa0", "1swq", 5);
+	if (rc)
+		return rc;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
+/* test 1dwq type mdev creation and removal */
+static int test_mdev_1dwq(struct accfg_ctx *ctx)
+{
+	int rc = 0;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	rc = set_config(ctx, "dsa0");
+	if (rc != 0)
+		return rc;
+
+	rc = enable_wq(ctx, "dsa0", 3);
+	if (rc) {
+		fprintf(stderr, "enable wq wq0.3 failed");
+		return rc;
+	}
+
+	/* create and remove 1 1dwq mdev */
+	rc = mdev_test(ctx, "dsa0", "1dwq", 1);
+	if (rc)
+		return rc;
+
+	rc = device_test_reset(ctx, "dsa0");
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
 typedef int (*do_test_fn)(struct accfg_ctx *ctx);

struct _test_case {

test/libaccfg.c +10 -0
 	do_test_fn test_fn;
@@ -854,6 +1000,16 @@ static struct _test_case test_cases[] = {
 		.desc = "wq boundary conditions",
 		.enabled = true,
 	},
+	{
+		.test_fn = test_mdev_1swq,
+		.desc = "1swq type mdev creation and removal",
+		.enabled = true,
+	},
+	{
+		.test_fn = test_mdev_1dwq,
+		.desc = "1dwq type mdev creation and removal",
+		.enabled = true,
+	},
 };
 
 static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module

**mod,
--
2.26.2

#22 lore raw

PATCH 9/11 accel-config: Add wq locked state support

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add support to the "locked" wq state. Read and save state to be used in wq state identification querries and listing of wq details. It is treated same as enabled state.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/config.c          |  5 +++--
 accfg/enable.c          |  4 ++--
 accfg/lib/libaccfg.c    |  4 +++-
 accfg/libaccel_config.h |  7 ++++---
 test/libaccfg.c         | 12 ++++++++----
 util/json.c             |  6 +++++-
 6 files changed, 25 insertions(+), 13 deletions(-)
accfg/config.c +3 -2
index d36f1d9..dadf679 100644
@@ -474,7 +474,7 @@ static int configure_json_value(struct accfg_ctx *ctx,
 			if (!wq)
 				return -ENOENT;
 			wq_state = accfg_wq_get_state(wq);
-			if (wq_state == ACCFG_WQ_ENABLED) {
+			if (wq_state == ACCFG_WQ_ENABLED || wq_state == ACCFG_WQ_LOCKED) {
 				fprintf(stderr, "%s is active, will skip...\n", parsed_string);
 				return 0;
 			}
@@ -539,7 +539,8 @@ static int configure_json_value(struct accfg_ctx *ctx,
 					key);
 			return rc;
 		}
-	} else if (wq && wq_state != ACCFG_WQ_ENABLED) {
+	} else if (wq && wq_state != ACCFG_WQ_ENABLED &&
+			wq_state != ACCFG_WQ_LOCKED) {
 		rc = wq_json_set_val(wq, jobj, key);
 		if (rc < 0) {
 			fprintf(stderr, "wq set %s value failed\n",
accfg/enable.c +2 -2
index f1d8813..8fbdbb0 100644
@@ -201,9 +201,9 @@ static int action_enable_wq(struct accfg_wq *wq, const char *wq_name)
 {
 	enum accfg_wq_state wq_state = accfg_wq_get_state(wq);
 
-	if (wq_state == ACCFG_WQ_ENABLED) {
+	if (wq_state == ACCFG_WQ_ENABLED || wq_state == ACCFG_WQ_LOCKED) {
 		fprintf(stderr,
-			"%s is in enabled mode already, skipping...\n",
+			"%s is in enabled or locked mode, skipping...\n",
 			wq_name);
 		return -ENXIO;
 	} else if (wq_state == ACCFG_WQ_QUIESCING) {
accfg/lib/libaccfg.c +3 -1
index ce789e6..7853a7e 100644
@@ -1940,7 +1940,7 @@ static int accfg_wq_control(struct accfg_wq *wq, enum accfg_control_flag flag,
 
 	/* verify state */
 	if (!accfg_wq_state_expected(wq, flag)) {
-		err(ctx, "WQ not in expected state.");
+		err(ctx, "WQ not in expected state\n");
 		return -ENXIO;
 	}
 
@@ -1986,6 +1986,8 @@ ACCFG_EXPORT enum accfg_wq_state accfg_wq_get_state(struct accfg_wq *wq)
 		return ACCFG_WQ_ENABLED;
 	else if (strcmp(read_state, "quiescing") == 0)
 		return ACCFG_WQ_QUIESCING;
+	else if (strcmp(read_state, "locked") == 0)
+		return ACCFG_WQ_LOCKED;
 
 	return ACCFG_WQ_UNKNOWN;
 }
accfg/libaccel_config.h +4 -3
index 95678fb..7fa3c2b 100644
@@ -48,9 +48,10 @@ enum accfg_wq_mode {
 };
 
 enum accfg_wq_state {
-	ACCFG_WQ_DISABLED = 0,
-	ACCFG_WQ_ENABLED = 1,
-	ACCFG_WQ_QUIESCING = 2,
+	ACCFG_WQ_DISABLED,
+	ACCFG_WQ_ENABLED,
+	ACCFG_WQ_QUIESCING,
+	ACCFG_WQ_LOCKED,
 	ACCFG_WQ_UNKNOWN = -1,
 };
 
test/libaccfg.c +8 -4
index b8f6522..d423d1d 100644
@@ -334,8 +334,10 @@ static int config_wq(struct accfg_ctx *ctx, int dev_id, int wq_id,
 
 			/* check if wq is disabled before configuration */
 			wstate = accfg_wq_get_state(wq);
-			if (wstate == ACCFG_WQ_ENABLED) {
-				fprintf(stderr, "wq%d in %s is in enabled mode and can not be configured\n", wq_id, dev_name);
+			if (wstate == ACCFG_WQ_ENABLED || wstate == ACCFG_WQ_LOCKED) {
+				fprintf(stderr,
+					"wq%d in %s is in enabled or locked mode and cannot be configured\n",
+					wq_id, dev_name);
 				continue;
 			}
 
@@ -497,7 +499,7 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
 
 			rc = accfg_wq_disable(wq, true);
 			if (rc < 0) {
-				fprintf(stderr, "wq under %s disabled failed\n", dev_name);
+				fprintf(stderr, "wq under %s disable failed\n", dev_name);
 				return rc;
 			}
 		}
@@ -886,6 +888,7 @@ static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int wq_id)
 {
 	struct accfg_device *device;
 	struct accfg_wq *wq;
+	enum accfg_wq_state wq_state;
 	int rc;
 
 	device = accfg_ctx_device_get_by_name(ctx, dev_name);
@@ -909,7 +912,8 @@ static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int wq_id)
 		return -EINVAL;
 	}
 
-	if (accfg_wq_get_state(wq) == ACCFG_WQ_ENABLED)
+	wq_state = accfg_wq_get_state(wq);
+	if (wq_state == ACCFG_WQ_ENABLED || wq_state == ACCFG_WQ_LOCKED)
 		return 0;
 
 	return accfg_wq_enable(wq);
util/json.c +5 -1
index 8ff89d0..f8ace0d 100644
@@ -400,7 +400,8 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,
 
 	wq_state = accfg_wq_get_state(wq);
 	/* Don't display idle wqs */
-	if (wq_state != ACCFG_WQ_ENABLED && !(flags & UTIL_JSON_IDLE))
+	if (wq_state != ACCFG_WQ_ENABLED && wq_state != ACCFG_WQ_LOCKED &&
+			!(flags & UTIL_JSON_IDLE))
 		goto err;
 
 	jobj = json_object_new_string(accfg_wq_get_devname(wq));
@@ -477,6 +478,9 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,
 		case ACCFG_WQ_QUIESCING:
 			jobj = json_object_new_string("quiescing");
 			break;
+		case ACCFG_WQ_LOCKED:
+			jobj = json_object_new_string("locked");
+			break;
 		case ACCFG_WQ_UNKNOWN:
 		default:
 			jobj = json_object_new_string("unknown");
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 9/11
#23 lore raw

[Accel-config] Re: [PATCH v1 09/11] accel-config: Add wq locked state support

Quoted 11 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 09/11] accel-config: Add wq locked state support

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 183 lines

Add support to the "locked" wq state. Read and save state to be used in wq state identification querries and listing of wq details. It is treated same as enabled state.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/config.c          |  5 +++--
 accfg/enable.c          |  4 ++--
 accfg/lib/libaccfg.c    |  4 +++-
 accfg/libaccel_config.h |  7 ++++---
 test/libaccfg.c         | 12 ++++++++----
 util/json.c             |  6 +++++-
 6 files changed, 25 insertions(+), 13 deletions(-)
accfg/config.c +1 -1
index d36f1d9..dadf679 100644
@@ -474,7 +474,7 @@ static int configure_json_value(struct accfg_ctx *ctx,
 			if (!wq)
 				return -ENOENT;
 			wq_state = accfg_wq_get_state(wq);
-			if (wq_state == ACCFG_WQ_ENABLED) {
+			if (wq_state == ACCFG_WQ_ENABLED || wq_state
 == ACCFG_WQ_LOCKED) {
 				fprintf(stderr, "%s is active, will skip...\n",
 parsed_string);
accfg/config.c +2 -1
 				return 0;
 			}
@@ -539,7 +539,8 @@ static int configure_json_value(struct accfg_ctx *ctx,
 					key);
 			return rc;
 		}
-	} else if (wq && wq_state != ACCFG_WQ_ENABLED) {
+	} else if (wq && wq_state != ACCFG_WQ_ENABLED &&
+			wq_state != ACCFG_WQ_LOCKED) {
 		rc = wq_json_set_val(wq, jobj, key);
 		if (rc < 0) {
 			fprintf(stderr, "wq set %s value failed\n",
accfg/enable.c +2 -2
index f1d8813..8fbdbb0 100644
@@ -201,9 +201,9 @@ static int action_enable_wq(struct accfg_wq *wq,
 const char *wq_name)
 {
 	enum accfg_wq_state wq_state = accfg_wq_get_state(wq);
 
-	if (wq_state == ACCFG_WQ_ENABLED) {
+	if (wq_state == ACCFG_WQ_ENABLED || wq_state ==
 ACCFG_WQ_LOCKED) {
 		fprintf(stderr,
-			"%s is in enabled mode already, skipping...\n",
+			"%s is in enabled or locked mode, skipping...\n",
 			wq_name);
accfg/enable.c +0 -0
 		return -ENXIO;
 	} else if (wq_state == ACCFG_WQ_QUIESCING) {
accfg/lib/libaccfg.c +3 -1
index ce789e6..7853a7e 100644
@@ -1940,7 +1940,7 @@ static int accfg_wq_control(struct accfg_wq *wq,
 enum accfg_control_flag flag,
 
 	/* verify state */
 	if (!accfg_wq_state_expected(wq, flag)) {
-		err(ctx, "WQ not in expected state.");
+		err(ctx, "WQ not in expected state\n");
 		return -ENXIO;
 	}
@@ -1986,6 +1986,8 @@ ACCFG_EXPORT enum accfg_wq_state
 accfg_wq_get_state(struct accfg_wq *wq)
 		return ACCFG_WQ_ENABLED;
 	else if (strcmp(read_state, "quiescing") == 0)
 		return ACCFG_WQ_QUIESCING;
+	else if (strcmp(read_state, "locked") == 0)
+		return ACCFG_WQ_LOCKED;
 
 	return ACCFG_WQ_UNKNOWN;

}

accfg/libaccel_config.h +4 -3
index 95678fb..7fa3c2b 100644
@@ -48,9 +48,10 @@ enum accfg_wq_mode {
 };
 
 enum accfg_wq_state {
-	ACCFG_WQ_DISABLED = 0,
-	ACCFG_WQ_ENABLED = 1,
-	ACCFG_WQ_QUIESCING = 2,
+	ACCFG_WQ_DISABLED,
+	ACCFG_WQ_ENABLED,
+	ACCFG_WQ_QUIESCING,
+	ACCFG_WQ_LOCKED,
 	ACCFG_WQ_UNKNOWN = -1,
 };
 
test/libaccfg.c +3 -2
index b8f6522..d423d1d 100644
@@ -334,8 +334,10 @@ static int config_wq(struct accfg_ctx *ctx, int dev_id,
 int wq_id,
 
 			/* check if wq is disabled before configuration */
 			wstate = accfg_wq_get_state(wq);
-			if (wstate == ACCFG_WQ_ENABLED) {
-				fprintf(stderr, "wq%d in %s is in enabled
 mode and can not be configured\n", wq_id, dev_name);
+			if (wstate == ACCFG_WQ_ENABLED || wstate ==
 ACCFG_WQ_LOCKED) {
+				fprintf(stderr,
+					"wq%d in %s is in enabled or locked

mode and cannot be configured\n",

test/libaccfg.c +2 -1
+					wq_id, dev_name);
 				continue;
 			}
@@ -497,7 +499,7 @@ static int device_test_reset(struct accfg_ctx *ctx,
 const char *dev_name)
 
 			rc = accfg_wq_disable(wq, true);
 			if (rc < 0) {
-				fprintf(stderr, "wq under %s disabled
 failed\n", dev_name);
+				fprintf(stderr, "wq under %s disable
 failed\n", dev_name);
test/libaccfg.c +1 -0
 				return rc;
 			}
 		}
@@ -886,6 +888,7 @@ static int enable_wq(struct accfg_ctx *ctx, const char
 *dev_name, int wq_id)
 {
 	struct accfg_device *device;
 	struct accfg_wq *wq;
+	enum accfg_wq_state wq_state;
 	int rc;
 
test/libaccfg.c +2 -1
 	device = accfg_ctx_device_get_by_name(ctx, dev_name);
@@ -909,7 +912,8 @@ static int enable_wq(struct accfg_ctx *ctx, const char
 *dev_name, int wq_id)
 		return -EINVAL;
 	}
 
-	if (accfg_wq_get_state(wq) == ACCFG_WQ_ENABLED)
+	wq_state = accfg_wq_get_state(wq);
+	if (wq_state == ACCFG_WQ_ENABLED || wq_state ==
 ACCFG_WQ_LOCKED)
 		return 0;
test/libaccfg.c +0 -0
 	return accfg_wq_enable(wq);
util/json.c +1 -1
index 8ff89d0..f8ace0d 100644
@@ -400,7 +400,8 @@ struct json_object *util_wq_to_json(struct accfg_wq
 *wq,
 
 	wq_state = accfg_wq_get_state(wq);
 	/* Don't display idle wqs */
-	if (wq_state != ACCFG_WQ_ENABLED && !(flags & UTIL_JSON_IDLE))
+	if (wq_state != ACCFG_WQ_ENABLED && wq_state !=

ACCFG_WQ_LOCKED &&

util/json.c +4 -0
+			!(flags & UTIL_JSON_IDLE))
 		goto err;
 
 	jobj = json_object_new_string(accfg_wq_get_devname(wq));
@@ -477,6 +478,9 @@ struct json_object *util_wq_to_json(struct accfg_wq
 *wq,
 		case ACCFG_WQ_QUIESCING:
 			jobj = json_object_new_string("quiescing");
 			break;
+		case ACCFG_WQ_LOCKED:
+			jobj = json_object_new_string("locked");
+			break;
 		case ACCFG_WQ_UNKNOWN:
 		default:

jobj = json_object_new_string("unknown");
--
2.26.2

#24 lore raw

PATCH 10/11 accel-config: Add documentation for mdev commands

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add manual pages for create-mdev and remove-mdev commands Also added missing pages for some config-wq options

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 .../accfg/accel-config-config-wq.txt          | 15 +++++++++
 .../accfg/accel-config-create-mdev.txt        | 32 +++++++++++++------
 .../accfg/accel-config-remove-mdev.txt        | 26 +++++++++++----
 3 files changed, 57 insertions(+), 16 deletions(-)
Documentation/accfg/accel-config-config-wq.txt +15 -0
index 58be829..3ede09c 100644
@@ -64,4 +64,19 @@ OPTIONS
 	configure the mode for the wq. The wq mode can be set as "dedicated" or
 	"shared".
 
+-c::
+--max-batch-size::
+	specify the max batch size used by a work queue. The value should be
+	between 1 and the device maximum batch size found in the
+	max_batch_size attribute under device. If the value is not a power
+	of 2, it will be rounded up to the next power of 2.
+
+-x::
+--max-transfer-size::
+	specify the max transfer size used by a work queue. The value should be
+	between 1 and the device maximum transfer size found in the
+	max_transfer_size attribute under device. If the value is not a power
+	of 2, it will be rounded up to the next power of 2.
+
+
 include::../copyright.txt[]
Documentation/accfg/accel-config-create-mdev.txt +23 -9
index 1994657..09aa06b 100644
@@ -5,21 +5,35 @@ accel-config-create-mdev(1)
 
 NAME
 ----
-accel-config-create-mdev - create mdev to a specified workqueue by generating a
-random uuid and writing to workqueue sysfs. The workqueue has to be enabled
-before running this command and it has to be configured as "mdev" type. If the
-workqueue type is shared, this command can be issued multiple times. If the
-workqueue is dedicated, only one uuid is allowed to be created. If this command
-is issued to a dedicated wq with uuid already existing, it will trigger
-operation not permitted error.
+accel-config-create-mdev - create mdev to enabled workqueues of devices.
+A uuid is generated which is associated with the mdev and will be stored in
+/sys/class/mdev_bus under the device pcie bdf id. Creation of mdevs require
+enabled workqueues. For mdevs of the shared type, at least one shared
+mode workqueue needs to be enabled. Each dedicated type mdev require one
+dedicated mode workqueue to be enabled. Creation of dedicated type mdevs
+would set the state of workqueue used as "locked". Creation of shared
+type mdevs do not alter the state of workqueues.
 
 SYNOPSIS
 --------
 [verse]
-'accel-config create-mdev' <device name>/<workqueue name>
+'accel-config create-mdev <device-name> [<mdev-type>|<options>]'
 
 EXAMPLE
 -------
-accel-config create-mdev dsa0/wq0.0
+accel-config create-mdev dsa0 1dwq
+
+accel-config create-mdev dsa0 -l
+----
+Available mdev types:
+	1dwq
+	1swq
+----
+
+OPTIONS
+--------
+-l::
+--list-mdev-types::
+	list the available mdev types
 
 include::../copyright.txt[]
Documentation/accfg/accel-config-remove-mdev.txt +19 -7
index f327a98..90cab5a 100644
@@ -5,22 +5,34 @@ accel-config-remove-mdev(1)
 
 NAME
 ----
-accel-config-remove-mdev - clear the uuid from a workqueue uuid list. If not uuid is
-specified, then entire uuid list in this workqueue will be removed.
+accel-config-remove-mdev - remove mdev of a device associated with
+the passed uuid. Passing a null uuid will remove all mdevs of the
+device.
 
 SYNOPSIS
 --------
 [verse]
-'accel-config remove-mdev' <device name>/<workqueue name> [<options>]
+'accel-config remove-mdev <device-name> [<uuid>|<options>]'
 
 EXAMPLE
 -------
-accel-config remove-mdev dsa0/wq0.0 --uuid=0f34f0ed-6f67-4086-a4b7-8e1ecf077dce
+accel-config remove-mdev dsa0 0f34f0ed-6f67-4086-a4b7-8e1ecf077dce
 
+accel-config remove-mdev dsa0 00000000-0000-0000-0000-000000000000
+
+accel-config remove-mdev dsa0 -l
+----
+Available mdevs:
+        uuid:edc13abf-cbf4-4de8-bf01-0dc864c54290, type:1dwq
+        uuid:7e776dce-a80b-4da8-9b13-d0483bff678f, type:1swq
+        uuid:45174189-1b18-4270-9f02-30cadbd4b1a4, type:1swq
+        uuid:3c53af36-be6f-405f-9ebf-d556e0735943, type:1swq
+        uuid:131a1337-4c32-48a0-97a7-0aac053f383c, type:1swq
+----
 OPTIONS
 -------
--u::
---uuid=::
-	remove this specific uuid from uuid list in the specified workqueue.
+-l::
+--list-mdevs::
+	list available mdevs of device
 
 include::../copyright.txt[]
Signature · 1 line
2.26.2
#25 lore raw

[Accel-config] Re: [PATCH v1 10/11] accel-config: Add documentation for mdev commands

Quoted 45 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 10/11] accel-config: Add documentation for mdev commands

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add manual pages for create-mdev and remove-mdev commands Also added missing pages for some config-wq options

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 .../accfg/accel-config-config-wq.txt          | 15 +++++++++
 .../accfg/accel-config-create-mdev.txt        | 32 +++++++++++++------
 .../accfg/accel-config-remove-mdev.txt        | 26 +++++++++++----
 3 files changed, 57 insertions(+), 16 deletions(-)
Documentation/accfg/accel-config-config-wq.txt +0 -0
index 58be829..3ede09c 100644
@@ -64,4 +64,19 @@ OPTIONS
 	configure the mode for the wq. The wq mode can be set as

"dedicated" or

Documentation/accfg/accel-config-config-wq.txt +3 -0
 	"shared".
 
+-c::
+--max-batch-size::
+	specify the max batch size used by a work queue. The value should

be

Documentation/accfg/accel-config-config-wq.txt +7 -0
+	between 1 and the device maximum batch size found in the
+	max_batch_size attribute under device. If the value is not a power
+	of 2, it will be rounded up to the next power of 2.
+
+-x::
+--max-transfer-size::
+	specify the max transfer size used by a work queue. The value should

be

Documentation/accfg/accel-config-config-wq.txt OPTIONS · line 81

Quoted 5 lines
Documentation/accfg/accel-config-config-wq.txt +5 -0
+	between 1 and the device maximum transfer size found in the
+	max_transfer_size attribute under device. If the value is not a power
+	of 2, it will be rounded up to the next power of 2.
+
+

Does this chunk need to go to a different patch?

Quoted 111 lines

include::../copyright.txt[]

Documentation/accfg/accel-config-create-mdev.txt +0 -1
index 1994657..09aa06b 100644
@@ -5,21 +5,35 @@ accel-config-create-mdev(1)
 
 NAME
 ----
-accel-config-create-mdev - create mdev to a specified workqueue by

generating a
-random uuid and writing to workqueue sysfs. The workqueue has to be enabled
-before running this command and it has to be configured as "mdev" type. If the
-workqueue type is shared, this command can be issued multiple times. If the
-workqueue is dedicated, only one uuid is allowed to be created. If this command

Documentation/accfg/accel-config-create-mdev.txt +3 -2
-is issued to a dedicated wq with uuid already existing, it will trigger
-operation not permitted error.
+accel-config-create-mdev - create mdev to enabled workqueues of devices.
+A uuid is generated which is associated with the mdev and will be stored in
+/sys/class/mdev_bus under the device pcie bdf id. Creation of mdevs

require

Documentation/accfg/accel-config-create-mdev.txt +2 -0
+enabled workqueues. For mdevs of the shared type, at least one shared
+mode workqueue needs to be enabled. Each dedicated type mdev require

one
+dedicated mode workqueue to be enabled. Creation of dedicated type mdevs

Documentation/accfg/accel-config-create-mdev.txt +17 -2
+would set the state of workqueue used as "locked". Creation of shared
+type mdevs do not alter the state of workqueues.
 
 SYNOPSIS
 --------
 [verse]
-'accel-config create-mdev' <device name>/<workqueue name>
+'accel-config create-mdev <device-name> [<mdev-type>|<options>]'
 
 EXAMPLE
 -------
-accel-config create-mdev dsa0/wq0.0
+accel-config create-mdev dsa0 1dwq
+
+accel-config create-mdev dsa0 -l
+----
+Available mdev types:
+	1dwq
+	1swq
+----
+
+OPTIONS
+--------
+-l::
+--list-mdev-types::
+	list the available mdev types
 
 include::../copyright.txt[]
Documentation/accfg/accel-config-remove-mdev.txt +0 -1
index f327a98..90cab5a 100644
@@ -5,22 +5,34 @@ accel-config-remove-mdev(1)
 
 NAME
 ----
-accel-config-remove-mdev - clear the uuid from a workqueue uuid list. If

not uuid is

Documentation/accfg/accel-config-remove-mdev.txt +3 -2
-specified, then entire uuid list in this workqueue will be removed.
+accel-config-remove-mdev - remove mdev of a device associated with
+the passed uuid. Passing a null uuid will remove all mdevs of the
+device.
 
 SYNOPSIS
 --------
 [verse]
-'accel-config remove-mdev' <device name>/<workqueue name>

[<options>]
+'accel-config remove-mdev <device-name> [<uuid>|<options>]'

EXAMPLE
-------
-accel-config remove-mdev dsa0/wq0.0 --uuid=0f34f0ed-6f67-4086-a4b7- 8e1ecf077dce

Documentation/accfg/accel-config-remove-mdev.txt +15 -4
+accel-config remove-mdev dsa0 0f34f0ed-6f67-4086-a4b7-8e1ecf077dce
 
+accel-config remove-mdev dsa0 00000000-0000-0000-0000-000000000000
+
+accel-config remove-mdev dsa0 -l
+----
+Available mdevs:
+        uuid:edc13abf-cbf4-4de8-bf01-0dc864c54290, type:1dwq
+        uuid:7e776dce-a80b-4da8-9b13-d0483bff678f, type:1swq
+        uuid:45174189-1b18-4270-9f02-30cadbd4b1a4, type:1swq
+        uuid:3c53af36-be6f-405f-9ebf-d556e0735943, type:1swq
+        uuid:131a1337-4c32-48a0-97a7-0aac053f383c, type:1swq
+----
 OPTIONS
 -------
--u::
---uuid=::
-	remove this specific uuid from uuid list in the specified workqueue.
+-l::
+--list-mdevs::
+	list available mdevs of device
 
 include::../copyright.txt[]
--

2.26.2

#26 lore raw

PATCH 11/11 accel-config: Clear conditions blocking unit test after failure

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Not disabling components and resetting driver blocks future tests. This change force closes mdevs, wqs, devices and resets the driver. Also at start loads driver if it was not.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 53 +++++++++++++++++++++++++++++++++++++------------
 1 file changed, 40 insertions(+), 13 deletions(-)
test/libaccfg.c +40 -13
index d423d1d..94d6156 100644
@@ -475,12 +475,14 @@ static int check_engine(struct accfg_ctx *ctx, int dev_id, int engine_id,
 	return 0;
 }
 
-static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
+static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name,
+		bool forced)
 {
 	int rc = 0;
 	struct accfg_device *device;
 	struct accfg_wq *wq;
 	enum accfg_wq_state wq_state;
+	uuid_t uuid;
 
 	device = accfg_ctx_device_get_by_name(ctx, dev_name);
 	if (!device)
@@ -488,6 +490,15 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
 
 	/* make sure device is disabled before configuration */
 	if (accfg_device_is_active(device)) {
+
+		/* Remove all mdevs */
+		uuid_clear(uuid);
+		rc = accfg_remove_mdev(device, uuid);
+		if (rc && !forced) {
+			fprintf(stderr, "mdev removal failed\n");
+			return rc;
+		}
+
 		/* make sure each wq is disabled */
 		accfg_wq_foreach(device, wq) {
 			wq_state = accfg_wq_get_state(wq);
@@ -498,14 +509,14 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
 			}
 
 			rc = accfg_wq_disable(wq, true);
-			if (rc < 0) {
+			if (rc < 0 && !forced) {
 				fprintf(stderr, "wq under %s disable failed\n", dev_name);
 				return rc;
 			}
 		}
 		rc = accfg_device_disable(device, true);
 		if (rc < 0) {
-			fprintf(stderr, "%s should be disabled before config but failed\n", dev_name);
+			fprintf(stderr, "%s disabling failed\n", dev_name);
 			return rc;
 		}
 	}
@@ -514,6 +525,17 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
 
 }
 
+static void test_cleanup(struct accfg_ctx *ctx)
+{
+	struct accfg_device *device;
+
+	accfg_device_foreach(ctx, device) {
+		const char *dev_name = accfg_device_get_devname(device);
+
+		device_test_reset(ctx, dev_name, true);
+	}
+}
+
 static int set_config(struct accfg_ctx *ctx, const char *dev_name)
 {
 	int rc = 0;
@@ -780,7 +802,7 @@ static int test_config(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
 
@@ -794,7 +816,7 @@ static int test_config(struct accfg_ctx *ctx)
 	if (rc != 0)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
 
@@ -806,7 +828,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa1");
+	rc = device_test_reset(ctx, "dsa1", false);
 	if (rc != 0)
 		return rc;
 
@@ -814,7 +836,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx)
 	if (rc != 0)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa1");
+	rc = device_test_reset(ctx, "dsa1", false);
 	if (rc != 0)
 		return rc;
 
@@ -826,7 +848,7 @@ static int test_wq_boundary_conditions(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
 
@@ -834,7 +856,7 @@ static int test_wq_boundary_conditions(struct accfg_ctx *ctx)
 	if (rc != 0)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
 
@@ -924,7 +946,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -943,7 +965,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -955,7 +977,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -974,7 +996,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -1037,6 +1059,9 @@ static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 	}
 
 	rc = kmod_module_get_initstate(*mod);
+	if (rc == -ENOENT)
+		rc = kmod_module_probe_insert_module(*mod, 0, NULL, NULL, NULL,
+				NULL);
 	return rc;
 }
 
@@ -1098,6 +1123,8 @@ int test_libaccfg(int loglevel, struct accfg_test *test,
 
 	if (i >= ARRAY_SIZE(test_cases))
 		result = EXIT_SUCCESS;
+	else
+		test_cleanup(ctx);
 
 	kmod_module_remove_module(mod, 0);
 	kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
Signature · 1 line
2.26.2
Reviewed-by Dave Jiang on v1 11/11
#27 lore raw

[Accel-config] Re: [PATCH v1 11/11] accel-config: Clear conditions blocking unit test after failure

Quoted 11 lines

-----Original Message-----
From: ramesh.thomas(a)intel.com <ramesh.thomas(a)intel.com>
Sent: Wednesday, December 2, 2020 12:31 PM
To: accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>; Luck, Tony <tony.luck(a)intel.com>; Jiang, Dave <dave.jiang(a)intel.com>
Subject: [PATCH v1 11/11] accel-config: Clear conditions blocking unit test after failure

Quoted 7 lines

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Not disabling components and resetting driver blocks future tests. This change force closes mdevs, wqs, devices and resets the driver. Also at start loads driver if it was not.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 199 lines
---
 test/libaccfg.c | 53 +++++++++++++++++++++++++++++++++++++-----------
(quoted diff) +0 -1
-
 1 file changed, 40 insertions(+), 13 deletions(-)
test/libaccfg.c +3 -1
index d423d1d..94d6156 100644
@@ -475,12 +475,14 @@ static int check_engine(struct accfg_ctx *ctx, int
 dev_id, int engine_id,
 	return 0;
 }
 
-static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
+static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name,
+		bool forced)
 {
 	int rc = 0;
 	struct accfg_device *device;
 	struct accfg_wq *wq;
 	enum accfg_wq_state wq_state;
+	uuid_t uuid;
 
 	device = accfg_ctx_device_get_by_name(ctx, dev_name);
test/libaccfg.c +9 -0
 	if (!device)
@@ -488,6 +490,15 @@ static int device_test_reset(struct accfg_ctx *ctx,
 const char *dev_name)
 
 	/* make sure device is disabled before configuration */
 	if (accfg_device_is_active(device)) {
+
+		/* Remove all mdevs */
+		uuid_clear(uuid);
+		rc = accfg_remove_mdev(device, uuid);
+		if (rc && !forced) {
+			fprintf(stderr, "mdev removal failed\n");
+			return rc;
+		}
+
 		/* make sure each wq is disabled */
 		accfg_wq_foreach(device, wq) {
test/libaccfg.c +2 -2
 			wq_state = accfg_wq_get_state(wq);
@@ -498,14 +509,14 @@ static int device_test_reset(struct accfg_ctx *ctx,
 const char *dev_name)
 			}
 
 			rc = accfg_wq_disable(wq, true);
-			if (rc < 0) {
+			if (rc < 0 && !forced) {
 				fprintf(stderr, "wq under %s disable
 failed\n", dev_name);
 				return rc;
 			}
 		}
 		rc = accfg_device_disable(device, true);
 		if (rc < 0) {
-			fprintf(stderr, "%s should be disabled before config
 but failed\n", dev_name);
+			fprintf(stderr, "%s disabling failed\n", dev_name);
test/libaccfg.c +11 -0
 			return rc;
 		}
 	}
@@ -514,6 +525,17 @@ static int device_test_reset(struct accfg_ctx *ctx,
 const char *dev_name)
 
 }
 
+static void test_cleanup(struct accfg_ctx *ctx)
+{
+	struct accfg_device *device;
+
+	accfg_device_foreach(ctx, device) {
+		const char *dev_name =
 accfg_device_get_devname(device);
+
+		device_test_reset(ctx, dev_name, true);
+	}
+}
+
 static int set_config(struct accfg_ctx *ctx, const char *dev_name)

{

test/libaccfg.c +13 -10
 	int rc = 0;
@@ -780,7 +802,7 @@ static int test_config(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
 
@@ -794,7 +816,7 @@ static int test_config(struct accfg_ctx *ctx)
 	if (rc != 0)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
 
@@ -806,7 +828,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa1");
+	rc = device_test_reset(ctx, "dsa1", false);
 	if (rc != 0)
 		return rc;
 
@@ -814,7 +836,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx)
 	if (rc != 0)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa1");
+	rc = device_test_reset(ctx, "dsa1", false);
 	if (rc != 0)
 		return rc;
 
@@ -826,7 +848,7 @@ static int test_wq_boundary_conditions(struct
 accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
@@ -834,7 +856,7 @@ static int test_wq_boundary_conditions(struct
 accfg_ctx *ctx)
 	if (rc != 0)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc != 0)
 		return rc;
@@ -924,7 +946,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -943,7 +965,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -955,7 +977,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -974,7 +996,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
-	rc = device_test_reset(ctx, "dsa0");
+	rc = device_test_reset(ctx, "dsa0", false);
 	if (rc)
 		return rc;
 
@@ -1037,6 +1059,9 @@ static int idxd_kmod_init(struct kmod_ctx **ctx,
 struct kmod_module **mod,
 	}
 
 	rc = kmod_module_get_initstate(*mod);
+	if (rc == -ENOENT)
+		rc = kmod_module_probe_insert_module(*mod, 0, NULL,
 NULL, NULL,
+				NULL);
 	return rc;

}

test/libaccfg.c +2 -0
@@ -1098,6 +1123,8 @@ int test_libaccfg(int loglevel, struct accfg_test *test,
 
 	if (i >= ARRAY_SIZE(test_cases))
 		result = EXIT_SUCCESS;
+	else
+		test_cleanup(ctx);
 
 	kmod_module_remove_module(mod, 0);
 	kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL,

NULL);
--
2.26.2