All of lore.kernel.org
 help / color / mirror / Atom feed
From: ramesh.thomas at intel.com
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH v1 1/4] accel-config: Add new wq functions in lib
Date: Wed, 28 Oct 2020 12:54:49 -0400	[thread overview]
Message-ID: <20201028165452.86013-2-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20201028165452.86013-1-ramesh.thomas@intel.com

[-- Attachment #1: Type: text/plain, Size: 5262 bytes --]

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

                 reply	other threads:[~2020-10-28 16:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201028165452.86013-2-ramesh.thomas@intel.com \
    --to=accel-config@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.