[Accel-config] [PATCH v1 1/4] accel-config: Add new wq functions in lib

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

Added new library functions:
accfg_wq_get_max_batch_size
accfg_wq_get_max_transfer_size
accfg_wq_set_max_batch_size
accfg_wq_set_max_transfer_size

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccel-config.sym |  8 ++++++
 accfg/lib/libaccfg.c          | 46 +++++++++++++++++++++++++++++++++++
 accfg/lib/private.h           |  2 ++
 accfg/libaccel_config.h       |  6 +++++
 4 files changed, 62 insertions(+)

diff --git a/accfg/lib/libaccel-config.sym b/accfg/lib/libaccel-config.sym
index 34bef4d..9768d42 100644
--- a/accfg/lib/libaccel-config.sym
+++ b/accfg/lib/libaccel-config.sym
@@ -130,3 +130,11 @@ global:
 	accfg_device_get_cmd_status;
 	accfg_device_get_cmd_status_str;
 } LIBACCFG_5;
+
+LIBACCFG_7 {
+global:
+	accfg_wq_get_max_batch_size;
+	accfg_wq_get_max_transfer_size;
+	accfg_wq_set_max_batch_size;
+	accfg_wq_set_max_transfer_size;
+} LIBACCFG_6;
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index 1a252e8..d55a246 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -633,6 +633,8 @@ static void *add_wq(void *parent, int id, const char *wq_base,
 	wq_type = accfg_get_param_str(ctx, dfd, "type");
 	wq->name = accfg_get_param_str(ctx, dfd, "name");
 	wq->threshold =  accfg_get_param_long(ctx, dfd, "threshold");
+	wq->max_batch_size =  accfg_get_param_long(ctx, dfd, "max_batch_size");
+	wq->max_transfer_size =  accfg_get_param_long(ctx, dfd, "max_transfer_size");
 
 	wq_parse_type(wq, wq_type);
 	free(wq_type);
@@ -1598,6 +1600,16 @@ ACCFG_EXPORT unsigned long accfg_wq_get_size(struct accfg_wq *wq)
 	return wq->size;
 }
 
+ACCFG_EXPORT unsigned int accfg_wq_get_max_batch_size(struct accfg_wq *wq)
+{
+	return wq->max_batch_size;
+}
+
+ACCFG_EXPORT unsigned long accfg_wq_get_max_transfer_size(struct accfg_wq *wq)
+{
+	return wq->max_transfer_size;
+}
+
 ACCFG_EXPORT int accfg_wq_get_clients(struct accfg_wq *wq)
 {
 	struct accfg_ctx *ctx = accfg_wq_get_ctx(wq);
@@ -1874,6 +1886,40 @@ accfg_wq_set_field(wq, val, priority)
 accfg_wq_set_field(wq, val, group_id)
 accfg_wq_set_field(wq, val, block_on_fault)
 accfg_wq_set_field(wq, val, threshold)
+accfg_wq_set_field(wq, val, max_batch_size)
+
+#define accfg_wq_set_long_field(wq, val, field) \
+ACCFG_EXPORT int accfg_wq_set_##field( \
+		struct accfg_wq *wq, unsigned long val) \
+{ \
+	struct accfg_ctx *ctx = accfg_wq_get_ctx(wq); \
+	char *path = wq->wq_buf; \
+	char buf[SYSFS_ATTR_SIZE]; \
+	int rc; \
+	rc = sprintf(wq->wq_buf, "%s/%s", wq->wq_path, #field); \
+	if (rc < 0) \
+		return -errno; \
+	if (sprintf(buf, "%ld", val) < 0) { \
+		err(ctx, "%s: sprintf to buf failed: %s\n", \
+				accfg_wq_get_devname(wq), \
+				strerror(errno)); \
+		return -errno; \
+	} \
+	if (!accfg_device_get_configurable(wq->device)) { \
+		err(ctx, "device is not configurable\n"); \
+		return -errno; \
+	} \
+	if (sysfs_write_attr(ctx, path, buf) < 0) { \
+		err(ctx, "%s: write failed: %s\n", \
+				accfg_wq_get_devname(wq), \
+				strerror(errno)); \
+		return -errno; \
+	} \
+	wq->field = val; \
+	return 0; \
+}
+
+accfg_wq_set_long_field(wq, val, max_transfer_size)
 
 #define accfg_wq_set_str_field(wq, val, field) \
 ACCFG_EXPORT int accfg_wq_set_str_##field( \
diff --git a/accfg/lib/private.h b/accfg/lib/private.h
index d444028..399c601 100644
--- a/accfg/lib/private.h
+++ b/accfg/lib/private.h
@@ -117,6 +117,8 @@ struct accfg_wq {
 	char *name;
 	enum accfg_wq_type type;
 	char *state;
+	unsigned int max_batch_size;
+	unsigned long max_transfer_size;
 };
 
 struct accfg_wq_uuid {
diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h
index 616bb1f..706b371 100644
--- a/accfg/libaccel_config.h
+++ b/accfg/libaccel_config.h
@@ -93,6 +93,8 @@ struct wq_parameters {
 	unsigned int threshold;
 	unsigned int priority;
 	int block_on_fault;
+	unsigned int max_batch_size;
+	unsigned long max_transfer_size;
 	const char *mode;
 	const char *type;
 	const char *name;
@@ -239,6 +241,8 @@ 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);
 enum accfg_wq_type accfg_wq_get_type(struct accfg_wq *wq);
+unsigned int accfg_wq_get_max_batch_size(struct accfg_wq *wq);
+unsigned long accfg_wq_get_max_transfer_size(struct accfg_wq *wq);
 int accfg_wq_get_threshold(struct accfg_wq *wq);
 int accfg_wq_get_clients(struct accfg_wq *wq);
 int accfg_wq_is_enabled(struct accfg_wq *wq);
@@ -247,6 +251,8 @@ int accfg_wq_set_priority(struct accfg_wq *wq, int val);
 int accfg_wq_set_group_id(struct accfg_wq *wq, int val);
 int accfg_wq_set_threshold(struct accfg_wq *wq, int val);
 int accfg_wq_set_block_on_fault(struct accfg_wq *wq, int val);
+int accfg_wq_set_max_batch_size(struct accfg_wq *wq, int val);
+int accfg_wq_set_max_transfer_size(struct accfg_wq *wq, unsigned long val);
 int accfg_wq_set_str_mode(struct accfg_wq *wq, const char* 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);
-- 
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.