[Accel-config] [PATCH v1 5/6] accel-config: Add new API to support 256 bits op_cap

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

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 <ramesh.thomas(a)intel.com>
---
 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 = accfg_device_get_ctx(device);
+	dfd = open(device->device_path, O_PATH);
+	if (dfd < 0)
+		return -errno;
+	oc = accfg_get_param_str(ctx, dfd, "op_cap");
+	close(dfd);
+	rc = 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 != 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 *device);
 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
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.