[Accel-config] [PATCH v1 4/4] accel-config: Add support for new driver portals

ramesh.thomas at intel.com
Newsgroups dev.linux.lists.accel-config
Message-ID <[email protected]>
From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Use the new driver portals if not in compat mode. If in compat mode, use
the bus type stored in driver context for bus and driver portal. This
will work in all compat modes as follows
- iax and dsa in their own buses and have portal name same as bus
- iax and dsa in dsa bus
- only dsa device in dsa bus

This will also work if kernel is built with compat mode. If idxd portal
is present then the new ABI is used, otherwise behave same as compat
mode in which all devices are in dsa bus.

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

diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index 6e472d4..269e7e8 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -30,6 +30,19 @@
 #define MDEV_POSTFIX "mdev_supported_types"
 #define IDXD_DRIVER_PATH "/sys/bus/dsa/drivers/"
 #define IDXD_DRIVER_PORTAL "idxd"
+#define IDXD_DRIVER_PATH "/sys/bus/dsa/drivers/"
+#define IDXD_DRIVER_PORTAL "idxd"
+#define GET_IDXD_PORTAL(c, d) ((c)->compat ? \
+		(d)->bus_type_str : IDXD_DRIVER_PORTAL)
+#define GET_IDXD_WQ_PORTAL(c, d, w) ((c)->compat ? \
+		(d)->bus_type_str : accfg_wq_driver_portals[(w)->type])
+
+char *accfg_wq_driver_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",
@@ -641,6 +654,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;
 
@@ -1535,14 +1550,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,
+				GET_IDXD_PORTAL(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,
+				GET_IDXD_PORTAL(ctx, device));
 		if (rc < 0)
 			return rc;
 
@@ -1945,14 +1962,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,
+				GET_IDXD_WQ_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,
+				GET_IDXD_WQ_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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.