All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v2 4/4] accel-config: Add support for new device bind paths
@ 2021-03-11 23:16 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2021-03-11 23:16 UTC (permalink / raw)
  To: accel-config

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

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

Use the per wq-type device portals to construct driver bind paths if not
in compat mode. If in compat mode, use the bus type stored in driver
context.

Driver bind paths in compat mode -
/sys/bus/dsa/drivers/dsa/<bind|unbind>
/sys/bus/iax/drivers/iax/<bind|unbind>

Driver bind paths in new ABI:
/sys/bus/dsa/drivers/idxd/<bind|unbind> (devices)
/sys/bus/dsa/drivers/<device portal>/<bind|unbind> (wqs)

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c    | 25 +++++++++++++++++++++----
 accfg/libaccel_config.h |  3 ++-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index c1b27b3..477a074 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -29,6 +29,17 @@
 
 #define MDEV_POSTFIX "mdev_supported_types"
 #define IDXD_DRIVER_BIND_PATH "/sys/bus/dsa/drivers/idxd"
+#define IDXD_DRIVER(c, d) ((c)->compat ? \
+		(d)->bus_type_str : "idxd")
+#define IDXD_WQ_DEVICE_PORTAL(c, d, w) ((c)->compat ? \
+		(d)->bus_type_str : accfg_wq_device_portals[(w)->type])
+
+char *accfg_wq_device_portals[] = {
+	[ACCFG_WQT_KERNEL] = "idxd-kernel-portal",
+	[ACCFG_WQT_USER] = "idxd-user-portal",
+	[ACCFG_WQT_MDEV] = "idxd-mdev-portal",
+	NULL
+};
 
 char *accfg_bus_types[] = {
 	"dsa",
@@ -640,6 +651,8 @@ static int wq_parse_type(struct accfg_wq *wq, char *wq_type)
 		wq->type = ACCFG_WQT_KERNEL;
 	else if (strcmp(ptype, "user") == 0)
 		wq->type = ACCFG_WQT_USER;
+	else if (strcmp(ptype, "mdev") == 0)
+		wq->type = ACCFG_WQT_MDEV;
 	else
 		wq->type = ACCFG_WQT_NONE;
 
@@ -1534,14 +1547,16 @@ static int accfg_device_control(struct accfg_device *device,
 
 	if (flag == ACCFG_DEVICE_ENABLE) {
 		rc = asprintf(&path, "/sys/bus/%s/drivers/%s/bind",
-				device->device_type_str, device->device_type_str);
+				device->bus_type_str,
+				IDXD_DRIVER(ctx, device));
 		if (rc < 0)
 			return rc;
 	} else if (flag == ACCFG_DEVICE_DISABLE) {
 		int clients;
 
 		rc = asprintf(&path, "/sys/bus/%s/drivers/%s/unbind",
-				device->device_type_str, device->device_type_str);
+				device->bus_type_str,
+				IDXD_DRIVER(ctx, device));
 		if (rc < 0)
 			return rc;
 
@@ -1944,14 +1959,16 @@ static int accfg_wq_control(struct accfg_wq *wq, enum accfg_control_flag flag,
 
 	if (flag == ACCFG_WQ_ENABLE) {
 		rc = asprintf(&path, "/sys/bus/%s/drivers/%s/bind",
-				device->device_type_str, device->device_type_str);
+				device->bus_type_str,
+				IDXD_WQ_DEVICE_PORTAL(ctx, device, wq));
 		if (rc < 0)
 			return rc;
 	} else if (flag == ACCFG_WQ_DISABLE) {
 		int clients;
 
 		rc = asprintf(&path, "/sys/bus/%s/drivers/%s/unbind",
-				device->device_type_str, device->device_type_str);
+				device->bus_type_str,
+				IDXD_WQ_DEVICE_PORTAL(ctx, device, wq));
 		if (rc < 0)
 			return rc;
 
diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h
index 091c388..b7b64c4 100644
--- a/accfg/libaccel_config.h
+++ b/accfg/libaccel_config.h
@@ -58,7 +58,8 @@ enum accfg_wq_state {
 enum accfg_wq_type {
 	ACCFG_WQT_NONE = 0,
 	ACCFG_WQT_KERNEL,
-	ACCFG_WQT_USER
+	ACCFG_WQT_USER,
+	ACCFG_WQT_MDEV,
 };
 
 enum accfg_control_flag {
-- 
2.26.2

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

only message in thread, other threads:[~2021-03-11 23:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 23:16 [Accel-config] [PATCH v2 4/4] accel-config: Add support for new device bind paths 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.