All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v2 1/5] accel-config: Support new driver changes in kernel ver 5.10
@ 2020-12-08 21:16 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2020-12-08 21:16 UTC (permalink / raw)
  To: accel-config

[-- Attachment #1: Type: text/plain, Size: 1935 bytes --]

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

New driver ver 1.0 in kernl 5.10 has changed the format of
mdev type name. Add changes in library to read the new type names
while scanning for and creation of mdevs.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by: Dave Jiang <dave.jiang(a)intel.com>
---
 accfg/lib/libaccfg.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index b003644..eda6b45 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -416,18 +416,10 @@ static int device_parse_type(struct accfg_device *device)
 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);
+	int i;
 
 	for (b = accfg_mdev_basenames, i = 0; *b != NULL; b++, i++)
-		if (!strncmp(*b, s, l))
+		if (strstr(mdev_type_str, *b))
 			return i;
 
 	return ACCFG_MDEV_TYPE_UNKNOWN;
@@ -1002,6 +994,7 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device,
 	struct accfg_device_mdev *mdev;
 	char uuid_str[UUID_STR_LEN];
 	char mdev_path[PATH_MAX];
+	unsigned int version;
 	int rc;
 
 	if (type >= ACCFG_MDEV_TYPE_UNKNOWN || type < 0)
@@ -1016,8 +1009,10 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device,
 	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]);
+	version = device->version  >> 8;
+	sprintf(mdev_path, "%s/%s/idxd-%s-%s-v%d/create", device->mdev_path,
+			MDEV_POSTFIX, device->device_type_str,
+			accfg_mdev_basenames[type], version);
 	rc = sysfs_write_attr(ctx, mdev_path, uuid_str);
 	if (rc < 0) {
 		err(ctx, "create mdev failed %d\n", rc);
-- 
2.26.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-08 21:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 21:16 [Accel-config] [PATCH v2 1/5] accel-config: Support new driver changes in kernel ver 5.10 ramesh.thomas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.