Content-Type: multipart/mixed; boundary="===============4278974416814122276==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 5/6] accel-config: Add new API to support 256 bits op_cap Date: Fri, 07 May 2021 15:31:25 -0400 Message-ID: <20210507193126.841998-6-ramesh.thomas@intel.com> In-Reply-To: 20210507193126.841998-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============4278974416814122276== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas Adds new API to get 256 bits op_cap field. It will return a structure containing for 64 bit values as returned by the sysfs interface Signed-off-by: Ramesh Thomas --- accfg/lib/libaccel-config.sym | 5 +++++ accfg/lib/libaccfg.c | 29 +++++++++++++++++++++++++++++ accfg/libaccel_config.h | 6 ++++++ 3 files changed, 40 insertions(+) diff --git a/accfg/lib/libaccel-config.sym b/accfg/lib/libaccel-config.sym index bffb8d8..aecc98b 100644 --- a/accfg/lib/libaccel-config.sym +++ b/accfg/lib/libaccel-config.sym @@ -144,3 +144,8 @@ LIBACCFG_8 { global: accfg_wq_get_user_dev_path; } LIBACCFG_7; + +LIBACCFG_9 { +global: + accfg_device_get_op_cap; +} LIBACCFG_8; diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c index 1d39bd6..12a97f5 100644 --- a/accfg/lib/libaccfg.c +++ b/accfg/lib/libaccfg.c @@ -1250,6 +1250,35 @@ ACCFG_EXPORT uint64_t accfg_device_get_max_transfer_= size( return device->max_transfer_size; } = +ACCFG_EXPORT int accfg_device_get_op_cap(struct accfg_device *device, + struct accfg_op_cap *op_cap) +{ + char *oc; + int dfd; + int rc; + struct accfg_ctx *ctx; + + if (!device) + return -EINVAL; + + ctx =3D accfg_device_get_ctx(device); + dfd =3D open(device->device_path, O_PATH); + if (dfd < 0) + return -errno; + oc =3D accfg_get_param_str(ctx, dfd, "op_cap"); + close(dfd); + rc =3D sscanf(oc, "%" SCNx64 " %" SCNx64 " %" SCNx64 " %" SCNx64, + &op_cap->bits[0], &op_cap->bits[1], + &op_cap->bits[2], &op_cap->bits[3]); + + free(oc); + + if (rc !=3D 4) + return errno ? -errno : -EIO; + + return 0; +} + ACCFG_EXPORT uint64_t accfg_device_get_gen_cap(struct accfg_device *device) { return device->gencap; diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h index 3354028..5b37790 100644 --- a/accfg/libaccel_config.h +++ b/accfg/libaccel_config.h @@ -79,6 +79,10 @@ struct accfg_error { uint64_t val[4]; }; = +struct accfg_op_cap { + uint64_t bits[4]; +}; + /* parameters read from sysfs of accfg driver */ struct dev_parameters { unsigned int token_limit; @@ -168,6 +172,8 @@ int accfg_device_get_numa_node(struct accfg_device *dev= ice); unsigned int accfg_device_get_ims_size(struct accfg_device *device); unsigned int accfg_device_get_max_batch_size(struct accfg_device *device); uint64_t accfg_device_get_max_transfer_size(struct accfg_device *device); +int accfg_device_get_op_cap(struct accfg_device *device, + struct accfg_op_cap *op_cap); uint64_t accfg_device_get_gen_cap(struct accfg_device *device); unsigned int accfg_device_get_configurable(struct accfg_device *device); bool accfg_device_get_pasid_enabled(struct accfg_device *device); -- = 2.26.3 --===============4278974416814122276==--