[Accel-config] [PATCH v1 3/4] accel-config: New attrs to config-wq command

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

Added max-transfer-size and max-batch-size attrs to config-wq
command.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/config_attr.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/accfg/config_attr.c b/accfg/config_attr.c
index 3d9669c..f7f43b1 100644
--- a/accfg/config_attr.c
+++ b/accfg/config_attr.c
@@ -35,6 +35,8 @@ static struct wq_parameters wq_param = {
 	.priority = INT_MAX,
 	.block_on_fault = INT_MAX,
 	.threshold = INT_MAX,
+	.max_batch_size = INT_MAX,
+	.max_transfer_size = INT_MAX,
 };
 
 static struct engine_parameters engine_param;
@@ -131,7 +133,8 @@ static int accel_config_parse_group_attribs(struct accfg_group *group,
 static int accel_config_parse_wq_attribs(struct accfg_device *device,
 		struct accfg_wq *wq, struct wq_parameters *wq_params)
 {
-	unsigned int max_groups, max_wq_size;
+	unsigned int max_groups, max_wq_size, max_batch_size;
+	unsigned long max_transfer_size;
 	int rc = 0;
 
 	if (wq_params->mode) {
@@ -145,6 +148,8 @@ static int accel_config_parse_wq_attribs(struct accfg_device *device,
 
 	max_groups = accfg_device_get_max_groups(device);
 	max_wq_size = accfg_device_get_max_work_queues_size(device);
+	max_batch_size = accfg_device_get_max_batch_size(device);
+	max_transfer_size = accfg_device_get_max_transfer_size(device);
 
 	if ((wq_params->wq_size > max_wq_size)
 		&& (wq_params->wq_size != INT_MAX)) {
@@ -167,6 +172,22 @@ static int accel_config_parse_wq_attribs(struct accfg_device *device,
 		return -EINVAL;
 	}
 
+	if ((wq_params->max_batch_size < 1
+		|| wq_params->max_batch_size > max_batch_size)
+		&& (wq_params->max_batch_size != INT_MAX)) {
+		fprintf(stderr,
+			"valid max-batch-size should be 1 to %d\n", max_batch_size);
+		return -EINVAL;
+	}
+
+	if ((wq_params->max_transfer_size < 1
+		|| wq_params->max_transfer_size > max_transfer_size)
+		&& (wq_params->max_transfer_size != INT_MAX)) {
+		fprintf(stderr,
+			"valid max-transfer-size should be 1 to %ld\n", max_transfer_size);
+		return -EINVAL;
+	}
+
 	if (wq_params->mode) {
 		rc = accfg_wq_set_str_mode(wq, wq_params->mode);
 		if (rc < 0)
@@ -216,6 +237,18 @@ static int accel_config_parse_wq_attribs(struct accfg_device *device,
 			return rc;
 	}
 
+	if (wq_params->max_batch_size != INT_MAX) {
+		rc = accfg_wq_set_max_batch_size(wq, wq_params->max_batch_size);
+		if (rc < 0)
+			return rc;
+	}
+
+	if (wq_params->max_transfer_size != INT_MAX) {
+		rc = accfg_wq_set_max_transfer_size(wq, wq_params->max_transfer_size);
+		if (rc < 0)
+			return rc;
+	}
+
 	return 0;
 }
 
@@ -400,6 +433,10 @@ int cmd_config_wq(int argc, const char **argv, void *ctx)
 			   "specify name by wq"),
 		OPT_STRING('m', "mode", &wq_param.mode, "mode",
 			   "specify mode by wq"),
+		OPT_UINTEGER('c', "max-batch-size", &wq_param.max_batch_size,
+			     "specify max-batch-size used by wq"),
+		OPT_U64('x', "max-transfer-size", &wq_param.max_transfer_size,
+			     "specify max-transfer-size used by wq"),
 		OPT_END(),
 	};
 
-- 
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.