All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v2 09/12] accel-config: Add wq locked state support
@ 2020-12-05  5:38 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2020-12-05  5:38 UTC (permalink / raw)
  To: accel-config

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

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add support to the "locked" wq state. Read and save state to be used in
wq state identification querries and listing of wq details. It is
treated same as enabled state.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/config.c          |  5 +++--
 accfg/enable.c          |  4 ++--
 accfg/lib/libaccfg.c    |  4 +++-
 accfg/libaccel_config.h |  7 ++++---
 test/libaccfg.c         | 12 ++++++++----
 util/json.c             |  6 +++++-
 6 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/accfg/config.c b/accfg/config.c
index d36f1d9..dadf679 100644
--- a/accfg/config.c
+++ b/accfg/config.c
@@ -474,7 +474,7 @@ static int configure_json_value(struct accfg_ctx *ctx,
 			if (!wq)
 				return -ENOENT;
 			wq_state = accfg_wq_get_state(wq);
-			if (wq_state == ACCFG_WQ_ENABLED) {
+			if (wq_state == ACCFG_WQ_ENABLED || wq_state == ACCFG_WQ_LOCKED) {
 				fprintf(stderr, "%s is active, will skip...\n", parsed_string);
 				return 0;
 			}
@@ -539,7 +539,8 @@ static int configure_json_value(struct accfg_ctx *ctx,
 					key);
 			return rc;
 		}
-	} else if (wq && wq_state != ACCFG_WQ_ENABLED) {
+	} else if (wq && wq_state != ACCFG_WQ_ENABLED &&
+			wq_state != ACCFG_WQ_LOCKED) {
 		rc = wq_json_set_val(wq, jobj, key);
 		if (rc < 0) {
 			fprintf(stderr, "wq set %s value failed\n",
diff --git a/accfg/enable.c b/accfg/enable.c
index f1d8813..8fbdbb0 100644
--- a/accfg/enable.c
+++ b/accfg/enable.c
@@ -201,9 +201,9 @@ static int action_enable_wq(struct accfg_wq *wq, const char *wq_name)
 {
 	enum accfg_wq_state wq_state = accfg_wq_get_state(wq);
 
-	if (wq_state == ACCFG_WQ_ENABLED) {
+	if (wq_state == ACCFG_WQ_ENABLED || wq_state == ACCFG_WQ_LOCKED) {
 		fprintf(stderr,
-			"%s is in enabled mode already, skipping...\n",
+			"%s is in enabled or locked mode, skipping...\n",
 			wq_name);
 		return -ENXIO;
 	} else if (wq_state == ACCFG_WQ_QUIESCING) {
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index 106e21e..b003644 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -1942,7 +1942,7 @@ static int accfg_wq_control(struct accfg_wq *wq, enum accfg_control_flag flag,
 
 	/* verify state */
 	if (!accfg_wq_state_expected(wq, flag)) {
-		err(ctx, "WQ not in expected state.");
+		err(ctx, "WQ not in expected state\n");
 		return -ENXIO;
 	}
 
@@ -1988,6 +1988,8 @@ ACCFG_EXPORT enum accfg_wq_state accfg_wq_get_state(struct accfg_wq *wq)
 		return ACCFG_WQ_ENABLED;
 	else if (strcmp(read_state, "quiescing") == 0)
 		return ACCFG_WQ_QUIESCING;
+	else if (strcmp(read_state, "locked") == 0)
+		return ACCFG_WQ_LOCKED;
 
 	return ACCFG_WQ_UNKNOWN;
 }
diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h
index 95678fb..7fa3c2b 100644
--- a/accfg/libaccel_config.h
+++ b/accfg/libaccel_config.h
@@ -48,9 +48,10 @@ enum accfg_wq_mode {
 };
 
 enum accfg_wq_state {
-	ACCFG_WQ_DISABLED = 0,
-	ACCFG_WQ_ENABLED = 1,
-	ACCFG_WQ_QUIESCING = 2,
+	ACCFG_WQ_DISABLED,
+	ACCFG_WQ_ENABLED,
+	ACCFG_WQ_QUIESCING,
+	ACCFG_WQ_LOCKED,
 	ACCFG_WQ_UNKNOWN = -1,
 };
 
diff --git a/test/libaccfg.c b/test/libaccfg.c
index b8f6522..d423d1d 100644
--- a/test/libaccfg.c
+++ b/test/libaccfg.c
@@ -334,8 +334,10 @@ static int config_wq(struct accfg_ctx *ctx, int dev_id, int wq_id,
 
 			/* check if wq is disabled before configuration */
 			wstate = accfg_wq_get_state(wq);
-			if (wstate == ACCFG_WQ_ENABLED) {
-				fprintf(stderr, "wq%d in %s is in enabled mode and can not be configured\n", wq_id, dev_name);
+			if (wstate == ACCFG_WQ_ENABLED || wstate == ACCFG_WQ_LOCKED) {
+				fprintf(stderr,
+					"wq%d in %s is in enabled or locked mode and cannot be configured\n",
+					wq_id, dev_name);
 				continue;
 			}
 
@@ -497,7 +499,7 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)
 
 			rc = accfg_wq_disable(wq, true);
 			if (rc < 0) {
-				fprintf(stderr, "wq under %s disabled failed\n", dev_name);
+				fprintf(stderr, "wq under %s disable failed\n", dev_name);
 				return rc;
 			}
 		}
@@ -886,6 +888,7 @@ static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int wq_id)
 {
 	struct accfg_device *device;
 	struct accfg_wq *wq;
+	enum accfg_wq_state wq_state;
 	int rc;
 
 	device = accfg_ctx_device_get_by_name(ctx, dev_name);
@@ -909,7 +912,8 @@ static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int wq_id)
 		return -EINVAL;
 	}
 
-	if (accfg_wq_get_state(wq) == ACCFG_WQ_ENABLED)
+	wq_state = accfg_wq_get_state(wq);
+	if (wq_state == ACCFG_WQ_ENABLED || wq_state == ACCFG_WQ_LOCKED)
 		return 0;
 
 	return accfg_wq_enable(wq);
diff --git a/util/json.c b/util/json.c
index 8ff89d0..f8ace0d 100644
--- a/util/json.c
+++ b/util/json.c
@@ -400,7 +400,8 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,
 
 	wq_state = accfg_wq_get_state(wq);
 	/* Don't display idle wqs */
-	if (wq_state != ACCFG_WQ_ENABLED && !(flags & UTIL_JSON_IDLE))
+	if (wq_state != ACCFG_WQ_ENABLED && wq_state != ACCFG_WQ_LOCKED &&
+			!(flags & UTIL_JSON_IDLE))
 		goto err;
 
 	jobj = json_object_new_string(accfg_wq_get_devname(wq));
@@ -477,6 +478,9 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,
 		case ACCFG_WQ_QUIESCING:
 			jobj = json_object_new_string("quiescing");
 			break;
+		case ACCFG_WQ_LOCKED:
+			jobj = json_object_new_string("locked");
+			break;
 		case ACCFG_WQ_UNKNOWN:
 		default:
 			jobj = json_object_new_string("unknown");
-- 
2.26.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-05  5:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-05  5:38 [Accel-config] [PATCH v2 09/12] accel-config: Add wq locked state support ramesh.thomas

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.