Content-Type: multipart/mixed; boundary="===============8232987476683606647==" MIME-Version: 1.0 From: Jiang, Dave Subject: [Accel-config] Re: [PATCH v1 09/11] accel-config: Add wq locked state support Date: Sat, 05 Dec 2020 00:06:23 +0000 Message-ID: <72c595a04bed496886142e5efaf65bfe@intel.com> In-Reply-To: 20201202193057.299615-10-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============8232987476683606647== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: ramesh.thomas(a)intel.com > Sent: Wednesday, December 2, 2020 12:31 PM > To: accel-config(a)lists.01.org > Cc: Thomas, Ramesh ; Luck, Tony > ; Jiang, Dave > Subject: [PATCH v1 09/11] accel-config: Add wq locked state support > = > From: Ramesh Thomas Reviewed-by: Dave Jiang > = > 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 > --- > 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 =3D accfg_wq_get_state(wq); > - if (wq_state =3D=3D ACCFG_WQ_ENABLED) { > + if (wq_state =3D=3D ACCFG_WQ_ENABLED || wq_state > =3D=3D 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 !=3D ACCFG_WQ_ENABLED) { > + } else if (wq && wq_state !=3D ACCFG_WQ_ENABLED && > + wq_state !=3D ACCFG_WQ_LOCKED) { > rc =3D 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 =3D accfg_wq_get_state(wq); > = > - if (wq_state =3D=3D ACCFG_WQ_ENABLED) { > + if (wq_state =3D=3D ACCFG_WQ_ENABLED || wq_state =3D=3D > 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 =3D=3D ACCFG_WQ_QUIESCING) { > diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c > index ce789e6..7853a7e 100644 > --- a/accfg/lib/libaccfg.c > +++ b/accfg/lib/libaccfg.c > @@ -1940,7 +1940,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; > } > = > @@ -1986,6 +1986,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") =3D=3D 0) > return ACCFG_WQ_QUIESCING; > + else if (strcmp(read_state, "locked") =3D=3D 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 =3D 0, > - ACCFG_WQ_ENABLED =3D 1, > - ACCFG_WQ_QUIESCING =3D 2, > + ACCFG_WQ_DISABLED, > + ACCFG_WQ_ENABLED, > + ACCFG_WQ_QUIESCING, > + ACCFG_WQ_LOCKED, > ACCFG_WQ_UNKNOWN =3D -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 =3D accfg_wq_get_state(wq); > - if (wstate =3D=3D 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 =3D=3D ACCFG_WQ_ENABLED || wstate =3D=3D > 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 =3D 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 =3D 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) =3D=3D ACCFG_WQ_ENABLED) > + wq_state =3D accfg_wq_get_state(wq); > + if (wq_state =3D=3D ACCFG_WQ_ENABLED || wq_state =3D=3D > 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 =3D accfg_wq_get_state(wq); > /* Don't display idle wqs */ > - if (wq_state !=3D ACCFG_WQ_ENABLED && !(flags & UTIL_JSON_IDLE)) > + if (wq_state !=3D ACCFG_WQ_ENABLED && wq_state !=3D > ACCFG_WQ_LOCKED && > + !(flags & UTIL_JSON_IDLE)) > goto err; > = > jobj =3D 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 =3D json_object_new_string("quiescing"); > break; > + case ACCFG_WQ_LOCKED: > + jobj =3D json_object_new_string("locked"); > + break; > case ACCFG_WQ_UNKNOWN: > default: > jobj =3D json_object_new_string("unknown"); > -- > 2.26.2 --===============8232987476683606647==--