Content-Type: multipart/mixed; boundary="===============1242111592223856830==" MIME-Version: 1.0 From: Ramesh Thomas Subject: [Accel-config] [PATCH 1/6] accel-config: Add driver_name attribute to wq context Date: Mon, 31 Jan 2022 18:53:14 -0800 Message-ID: <20220201025319.16393-2-ramesh.thomas@intel.com> In-Reply-To: 20220201025319.16393-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============1242111592223856830== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add a driver_name memember to wq context structure and API to set it. It will be initialized with the value stored in sysfs. A NULL will be stored if driver_name attribute is not present. Signed-off-by: Ramesh Thomas --- accfg/lib/libaccel-config.sym | 7 +++++++ accfg/lib/libaccfg.c | 24 ++++++++++++++++++++++++ accfg/lib/private.h | 1 + accfg/libaccel_config.h | 3 +++ 4 files changed, 35 insertions(+) diff --git a/accfg/lib/libaccel-config.sym b/accfg/lib/libaccel-config.sym index 560883a..fde9251 100644 --- a/accfg/lib/libaccel-config.sym +++ b/accfg/lib/libaccel-config.sym @@ -179,3 +179,10 @@ global: accfg_group_set_read_buffers_allowed; accfg_group_set_use_read_buffer_limit; } LIBACCFG_11; + +LIBACCFG_13 { +global: + accfg_wq_set_str_driver_name; + accfg_wq_get_driver_name; + accfg_wq_driver_name_validate; +} LIBACCFG_12; diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c index 86ee517..5bd4623 100644 --- a/accfg/lib/libaccfg.c +++ b/accfg/lib/libaccfg.c @@ -827,6 +827,7 @@ static void *add_wq(void *parent, int id, const char *w= q_base, wq->cdev_minor =3D accfg_get_param_long(ctx, dfd, "cdev_minor"); wq_type =3D accfg_get_param_str(ctx, dfd, "type"); wq->name =3D accfg_get_param_str(ctx, dfd, "name"); + wq->driver_name =3D accfg_get_param_str(ctx, dfd, "driver_name"); wq->threshold =3D accfg_get_param_long(ctx, dfd, "threshold"); wq->max_batch_size =3D accfg_get_param_long(ctx, dfd, "max_batch_size"); wq->max_transfer_size =3D accfg_get_param_long(ctx, dfd, "max_transfer_s= ize"); @@ -2062,6 +2063,28 @@ ACCFG_EXPORT const char *accfg_wq_get_type_name(stru= ct accfg_wq *wq) return wq->name; } = +ACCFG_EXPORT const char *accfg_wq_get_driver_name(struct accfg_wq *wq) +{ + return wq->driver_name; +} + +ACCFG_EXPORT int accfg_wq_driver_name_validate(struct accfg_wq *wq, + const char *drv_name) +{ + int rc =3D 0; + char *path =3D NULL; + struct accfg_device *device =3D accfg_wq_get_device(wq); + + rc =3D get_driver_bind_path(device->bus_type_str, wq->driver_name, &path); + if (rc < 0) + return 0; + + rc =3D access(path, F_OK); + free(path); + + return !rc; +} + ACCFG_EXPORT uint64_t accfg_wq_get_size(struct accfg_wq *wq) { return wq->size; @@ -2454,6 +2477,7 @@ ACCFG_EXPORT int accfg_wq_set_str_##field( \ = accfg_wq_set_str_field(wq, val, mode) accfg_wq_set_str_field(wq, val, name) +accfg_wq_set_str_field(wq, val, driver_name) = static int wq_parse_type(struct accfg_wq *wq, char *wq_type); = diff --git a/accfg/lib/private.h b/accfg/lib/private.h index b09297e..f88044c 100644 --- a/accfg/lib/private.h +++ b/accfg/lib/private.h @@ -121,6 +121,7 @@ struct accfg_wq { unsigned int threshold; char *mode; char *name; + char *driver_name; enum accfg_wq_type type; char *state; unsigned int max_batch_size; diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h index 8bd6dda..1aad3f3 100644 --- a/accfg/libaccel_config.h +++ b/accfg/libaccel_config.h @@ -293,6 +293,8 @@ int accfg_wq_get_block_on_fault(struct accfg_wq *wq); enum accfg_wq_state accfg_wq_get_state(struct accfg_wq *wq); int accfg_wq_get_cdev_minor(struct accfg_wq *wq); const char *accfg_wq_get_type_name(struct accfg_wq *wq); +const char *accfg_wq_get_driver_name(struct accfg_wq *wq); +int accfg_wq_driver_name_validate(struct accfg_wq *wq, const char *drv_nam= e); enum accfg_wq_type accfg_wq_get_type(struct accfg_wq *wq); unsigned int accfg_wq_get_max_batch_size(struct accfg_wq *wq); uint64_t accfg_wq_get_max_transfer_size(struct accfg_wq *wq); @@ -313,6 +315,7 @@ int accfg_wq_set_str_mode(struct accfg_wq *wq, const ch= ar *val); int accfg_wq_set_mode(struct accfg_wq *wq, enum accfg_wq_mode mode); int accfg_wq_set_str_type(struct accfg_wq *wq, const char *val); int accfg_wq_set_str_name(struct accfg_wq *wq, const char *val); +int accfg_wq_set_str_driver_name(struct accfg_wq *wq, const char *val); int accfg_wq_enable(struct accfg_wq *wq); int accfg_wq_disable(struct accfg_wq *wq, bool force); int accfg_wq_priority_boundary(struct accfg_wq *wq); -- = 2.31.1 --===============1242111592223856830==--