Content-Type: multipart/mixed; boundary="===============5836051496941985162==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 4/4] accel-config: Add support for new driver portals Date: Thu, 11 Mar 2021 13:03:23 -0500 Message-ID: <20210311180323.307205-5-ramesh.thomas@intel.com> In-Reply-To: 20210311180323.307205-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============5836051496941985162== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas 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 --- 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[] =3D { + [ACCFG_WQT_KERNEL] =3D "idxd-kernel-portal", + [ACCFG_WQT_USER] =3D "idxd-user-portal", + [ACCFG_WQT_MDEV] =3D "idxd-mdev-portal", + NULL +}; = char *accfg_bus_types[] =3D { "dsa", @@ -641,6 +654,8 @@ static int wq_parse_type(struct accfg_wq *wq, char *wq_= type) wq->type =3D ACCFG_WQT_KERNEL; else if (strcmp(ptype, "user") =3D=3D 0) wq->type =3D ACCFG_WQT_USER; + else if (strcmp(ptype, "mdev") =3D=3D 0) + wq->type =3D ACCFG_WQT_MDEV; else wq->type =3D ACCFG_WQT_NONE; = @@ -1535,14 +1550,16 @@ static int accfg_device_control(struct accfg_device= *device, = if (flag =3D=3D ACCFG_DEVICE_ENABLE) { rc =3D 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 =3D=3D ACCFG_DEVICE_DISABLE) { int clients; = rc =3D 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, en= um accfg_control_flag flag, = if (flag =3D=3D ACCFG_WQ_ENABLE) { rc =3D 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 =3D=3D ACCFG_WQ_DISABLE) { int clients; = rc =3D 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 =3D 0, ACCFG_WQT_KERNEL, - ACCFG_WQT_USER + ACCFG_WQT_USER, + ACCFG_WQT_MDEV, }; = enum accfg_control_flag { -- = 2.26.2 --===============5836051496941985162==--