accel-config/dsa_test Add devices flow control for submission
Tony Zhu
PATCH 1/1 accel-config/dsa_test Add devices flow control for submission
Add -i to input dsa device id and -d to input wq id which allows the flow control for task submission.
--- test/dsa.c | 63 +++++++++++++++++++++++++++++++++++++++++++++---- test/dsa.h | 2 +- test/dsa_test.c | 15 +++++++++--- 3 files changed, 71 insertions(+), 9 deletions(-)
test/dsa.c +58 -5
@@ -146,6 +146,55 @@ static struct accfg_wq *dsa_get_wq(struct dsa_context *ctx,return NULL ; } +static struct accfg_wq *dsa_get_wq_byid (struct dsa_context *ctx, +int dev_id,int wq_id) +{ +struct accfg_device *device; +struct accfg_wq *wq; +int rc; + + accfg_device_foreach(ctx->ctx, device) { +enum accfg_device_state dstate; + +/* Make sure that the device is enabled */ + dstate =accfg_device_get_state (device); +if (dstate !=ACCFG_DEVICE_ENABLED ) +continue ; + +/* Match the device to the id requested */ +if (accfg_device_get_id (device) != dev_id && + dev_id !=-1 ) +continue ; + + accfg_wq_foreach(device, wq) { +enum accfg_wq_state wstate; +enum accfg_wq_type type; + +/* Get a workqueue that's enabled */ + wstate =accfg_wq_get_state (wq); +if (wstate !=ACCFG_WQ_ENABLED ) +continue ; + +/* The wq type should be user */ + type =accfg_wq_get_type (wq); +if (type !=ACCFG_WQT_USER ) +continue ; + +/* Make sure the wq id is correct */ +if (wq_id !=accfg_wq_get_id (wq)) +continue ; + + rc =dsa_setup_wq (ctx, wq); +if (rc <0 ) +return NULL ; + +return wq; + } + } + +return NULL ; +} +static uint32_t bsr (uint32_t val) {uint32_t msb;
@@ -154,7 +203,7 @@ static uint32_t bsr(uint32_t val)return msb -1 ; } -int dsa_alloc (struct dsa_context *ctx,int shared) +int dsa_alloc (struct dsa_context *ctx,int shared,int dev_id,int wq_id) {struct accfg_device *dev;
@@ -162,14 +211,18 @@ int dsa_alloc(struct dsa_context *ctx, int shared)if (ctx->wq_reg)return 0 ; - ctx->wq =dsa_get_wq (ctx,-1 , shared); +if (wq_id !=-1 ){ + ctx->wq =dsa_get_wq_byid (ctx, dev_id, wq_id); + }else { + ctx->wq =dsa_get_wq (ctx, dev_id, shared); + } +if (!ctx->wq) {err ("No usable wq found\n" );return -ENODEV ; } dev =accfg_wq_get_device (ctx->wq); - - ctx->dedicated = !shared; + ctx->dedicated =accfg_wq_get_mode (ctx->wq); ctx->wq_size =accfg_wq_get_size (ctx->wq); ctx->wq_idx =accfg_wq_get_id (ctx->wq); ctx->bof =accfg_wq_get_block_on_fault (ctx->wq);
@@ -182,7 +235,7 @@ int dsa_alloc(struct dsa_context *ctx, int shared) ctx->max_xfer_bits =bsr (ctx->max_xfer_size);info ("alloc wq %d shared %d size %d addr %p batch sz %#x xfer sz %#x\n" , - ctx->wq_idx, shared, ctx->wq_size, ctx->wq_reg, + ctx->wq_idx, ctx->dedicated, ctx->wq_size, ctx->wq_reg, ctx->max_batch_size, ctx->max_xfer_size);return 0 ;
test/dsa.h +1 -1
@@ -211,7 +211,7 @@ int memcmp_pattern(const void *src, const uint64_t pattern, size_t len);int dsa_enqcmd (struct dsa_context *ctx,struct dsa_hw_desc *hw);struct dsa_context *dsa_init (void ); -int dsa_alloc (struct dsa_context *ctx,int shared); +int dsa_alloc (struct dsa_context *ctx,int shared,int dev_id,int wq_id);int alloc_task (struct dsa_context *ctx);struct task *__alloc_task (void ); int init_task(struct task *tsk, int tflags, int opcode,
test/dsa_test.c +12 -3
@@ -23,6 +23,8 @@ static void usage(void)"-o <opcode> ; opcode, same value as in DSA spec\n" "-b <opcode> ; if batch opcode, opcode in the batch\n" "-c <batch_size> ; if batch opcode, number of descriptors for batch\n" +"-i ; device id\n" +"-d ; wq number\n" "-t <ms timeout> ; ms to wait for descs to complete\n" "-v ; verbose\n" "-h ; print this message\n");
@@ -105,13 +107,14 @@ int main(int argc, char *argv[])int rc =0 ;unsigned long buf_size =DSA_TEST_SIZE ;int wq_type =SHARED ; +int wq_id =-1 ;int opcode =DSA_OPCODE_MEMMOVE ;int bopcode =DSA_OPCODE_MEMMOVE ;int tflags =TEST_FLAGS_BOF ; -int opt; +int opt, dev_id=-1 ;unsigned int bsize =0 ; -while ((opt =getopt (argc, argv,"w:l:f:o:b:c:t:p:vh" )) !=-1 ) { +while ((opt =getopt (argc, argv,"w:l:f:o:b:c:i:d:t:p:vh" )) !=-1 ) {switch (opt) {case 'w' : wq_type =atoi (optarg);
@@ -131,6 +134,12 @@ int main(int argc, char *argv[])case 'c' : bsize =strtoul (optarg,NULL ,0 );break ; +case 'i' : + dev_id =atoi (optarg); +break ; +case 'd' : + wq_id =strtoul (optarg,NULL ,0 ); +break ;case 't' : ms_timeout =strtoul (optarg,NULL ,0 );break ;
@@ -150,7 +159,7 @@ int main(int argc, char *argv[])if (dsa ==NULL )return -ENOMEM ; - rc =dsa_alloc (dsa, wq_type); + rc =dsa_alloc (dsa, wq_type, dev_id, wq_id);if (rc <0 )return -ENOMEM ;
Signature · 1 line
2.27.0
Dave Jiang
Quoted 2 lines · Tony Zhu
Add -i to input dsa device id and -d to input wq id which allows the flow control for task submission.
Not sure what this has anything to do with flow control. Maybe it should read:
accel-config: dsa_test: Add device and wq id selection for test
Add -i parameter to select DSA device id and -d parameter to select WQ id. This allows direct selection of which device and wq to utilize.
Although I think the better way to do this is to allow a single input like:
-d dsa0/wq0.0
And you parse that string. That way it makes it consistent with the utility. You can probably borrow code from accel-config on how to parse that.
Quoted 173 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>--- test/dsa.c | 63 +++++++++++++++++++++++++++++++++++++++++++++---- test/dsa.h | 2 +- test/dsa_test.c | 15 +++++++++--- 3 files changed, 71 insertions(+), 9 deletions(-)test/dsa.c +58
-5@@ -146,6 +146,55 @@ static struct accfg_wq *dsa_get_wq(struct dsa_context *ctx,return NULL ; } +static struct accfg_wq *dsa_get_wq_byid (struct dsa_context *ctx, +int dev_id,int wq_id) +{ +struct accfg_device *device; +struct accfg_wq *wq; +int rc; + + accfg_device_foreach(ctx->ctx, device) { +enum accfg_device_state dstate; + +/* Make sure that the device is enabled */ + dstate =accfg_device_get_state (device); +if (dstate !=ACCFG_DEVICE_ENABLED ) +continue ; + +/* Match the device to the id requested */ +if (accfg_device_get_id (device) != dev_id && + dev_id !=-1 ) +continue ; + + accfg_wq_foreach(device, wq) { +enum accfg_wq_state wstate; +enum accfg_wq_type type; + +/* Get a workqueue that's enabled */ + wstate =accfg_wq_get_state (wq); +if (wstate !=ACCFG_WQ_ENABLED ) +continue ; + +/* The wq type should be user */ + type =accfg_wq_get_type (wq); +if (type !=ACCFG_WQT_USER ) +continue ; + +/* Make sure the wq id is correct */ +if (wq_id !=accfg_wq_get_id (wq)) +continue ; + + rc =dsa_setup_wq (ctx, wq); +if (rc <0 ) +return NULL ; + +return wq; + } + } + +return NULL ; +} +static uint32_t bsr (uint32_t val) {uint32_t msb;@@ -154,7 +203,7 @@ static uint32_t bsr(uint32_t val)return msb -1 ; } -int dsa_alloc (struct dsa_context *ctx,int shared) +int dsa_alloc (struct dsa_context *ctx,int shared,int dev_id,int wq_id) {struct accfg_device *dev;@@ -162,14 +211,18 @@ int dsa_alloc(struct dsa_context *ctx, int shared)if (ctx->wq_reg)return 0 ; - ctx->wq =dsa_get_wq (ctx,-1 , shared); +if (wq_id !=-1 ){ + ctx->wq =dsa_get_wq_byid (ctx, dev_id, wq_id); + }else { + ctx->wq =dsa_get_wq (ctx, dev_id, shared); + } +if (!ctx->wq) {err ("No usable wq found\n" );return -ENODEV ; } dev =accfg_wq_get_device (ctx->wq); - - ctx->dedicated = !shared; + ctx->dedicated =accfg_wq_get_mode (ctx->wq); ctx->wq_size =accfg_wq_get_size (ctx->wq); ctx->wq_idx =accfg_wq_get_id (ctx->wq); ctx->bof =accfg_wq_get_block_on_fault (ctx->wq);@@ -182,7 +235,7 @@ int dsa_alloc(struct dsa_context *ctx, int shared) ctx->max_xfer_bits =bsr (ctx->max_xfer_size);info ("alloc wq %d shared %d size %d addr %p batch sz %#x xfer sz %#x\n" , - ctx->wq_idx, shared, ctx->wq_size, ctx->wq_reg, + ctx->wq_idx, ctx->dedicated, ctx->wq_size, ctx->wq_reg, ctx->max_batch_size, ctx->max_xfer_size);return 0 ;test/dsa.h +1
-1@@ -211,7 +211,7 @@ int memcmp_pattern(const void *src, const uint64_t pattern, size_t len);int dsa_enqcmd (struct dsa_context *ctx,struct dsa_hw_desc *hw);struct dsa_context *dsa_init (void ); -int dsa_alloc (struct dsa_context *ctx,int shared); +int dsa_alloc (struct dsa_context *ctx,int shared,int dev_id,int wq_id);int alloc_task (struct dsa_context *ctx);struct task *__alloc_task (void ); int init_task(struct task *tsk, int tflags, int opcode,test/dsa_test.c +12
-3@@ -23,6 +23,8 @@ static void usage(void)"-o <opcode> ; opcode, same value as in DSA spec\n" "-b <opcode> ; if batch opcode, opcode in the batch\n" "-c <batch_size> ; if batch opcode, number of descriptors for batch\n" +"-i ; device id\n" +"-d ; wq number\n" "-t <ms timeout> ; ms to wait for descs to complete\n" "-v ; verbose\n" "-h ; print this message\n");@@ -105,13 +107,14 @@ int main(int argc, char *argv[])int rc =0 ;unsigned long buf_size =DSA_TEST_SIZE ;int wq_type =SHARED ; +int wq_id =-1 ;int opcode =DSA_OPCODE_MEMMOVE ;int bopcode =DSA_OPCODE_MEMMOVE ;int tflags =TEST_FLAGS_BOF ; -int opt; +int opt, dev_id=-1 ;unsigned int bsize =0 ; -while ((opt =getopt (argc, argv,"w:l:f:o:b:c:t:p:vh" )) !=-1 ) { +while ((opt =getopt (argc, argv,"w:l:f:o:b:c:i:d:t:p:vh" )) !=-1 ) {switch (opt) {case 'w' : wq_type =atoi (optarg);@@ -131,6 +134,12 @@ int main(int argc, char *argv[])case 'c' : bsize =strtoul (optarg,NULL ,0 );break ; +case 'i' : + dev_id =atoi (optarg); +break ; +case 'd' : + wq_id =strtoul (optarg,NULL ,0 ); +break ;case 't' : ms_timeout =strtoul (optarg,NULL ,0 );break ;@@ -150,7 +159,7 @@ int main(int argc, char *argv[])if (dsa ==NULL )return -ENOMEM ; - rc =dsa_alloc (dsa, wq_type); + rc =dsa_alloc (dsa, wq_type, dev_id, wq_id);if (rc <0 )return -ENOMEM ;
Zhu
It will require many script change designed by DPG if combine -i and -d as 1.
Tony(zhu, xinzhan)
Cube:SHZ1-3W-279
iNet:8821-5077
-----Original Message-----
From: Jiang, Dave <dave.jiang(a)intel.com>
Sent: Tuesday, August 31, 2021 12:36 AM
To: Zhu, Tony <tony.zhu(a)intel.com>; accel-config(a)lists.01.org
Cc: Thomas, Ramesh <ramesh.thomas(a)intel.com>
Subject: Re: [PATCH v1 1/1] accel-config/dsa_test Add devices flow control for submission
Quoted 2 lines · Tony Zhu
Add -i to input dsa device id and -d to input wq id which allows the flow control for task submission.
Not sure what this has anything to do with flow control. Maybe it should read:
accel-config: dsa_test: Add device and wq id selection for test
Add -i parameter to select DSA device id and -d parameter to select WQ id. This allows direct selection of which device and wq to utilize.
Although I think the better way to do this is to allow a single input like:
-d dsa0/wq0.0
And you parse that string. That way it makes it consistent with the utility. You can probably borrow code from accel-config on how to parse that.
Quoted 173 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>--- test/dsa.c | 63 +++++++++++++++++++++++++++++++++++++++++++++---- test/dsa.h | 2 +- test/dsa_test.c | 15 +++++++++--- 3 files changed, 71 insertions(+), 9 deletions(-)test/dsa.c +58
-5@@ -146,6 +146,55 @@ static struct accfg_wq *dsa_get_wq(struct dsa_context *ctx,return NULL ; } +static struct accfg_wq *dsa_get_wq_byid (struct dsa_context *ctx, +int dev_id,int wq_id) +{ +struct accfg_device *device; +struct accfg_wq *wq; +int rc; + + accfg_device_foreach(ctx->ctx, device) { +enum accfg_device_state dstate; + +/* Make sure that the device is enabled */ + dstate =accfg_device_get_state (device); +if (dstate !=ACCFG_DEVICE_ENABLED ) +continue ; + +/* Match the device to the id requested */ +if (accfg_device_get_id (device) != dev_id && + dev_id !=-1 ) +continue ; + + accfg_wq_foreach(device, wq) { +enum accfg_wq_state wstate; +enum accfg_wq_type type; + +/* Get a workqueue that's enabled */ + wstate =accfg_wq_get_state (wq); +if (wstate !=ACCFG_WQ_ENABLED ) +continue ; + +/* The wq type should be user */ + type =accfg_wq_get_type (wq); +if (type !=ACCFG_WQT_USER ) +continue ; + +/* Make sure the wq id is correct */ +if (wq_id !=accfg_wq_get_id (wq)) +continue ; + + rc =dsa_setup_wq (ctx, wq); +if (rc <0 ) +return NULL ; + +return wq; + } + } + +return NULL ; +} +static uint32_t bsr (uint32_t val) {uint32_t msb;@@ -154,7 +203,7 @@ static uint32_t bsr(uint32_t val)return msb -1 ; } -int dsa_alloc (struct dsa_context *ctx,int shared) +int dsa_alloc (struct dsa_context *ctx,int shared,int dev_id,int wq_id) {struct accfg_device *dev;@@ -162,14 +211,18 @@ int dsa_alloc(struct dsa_context *ctx, int shared)if (ctx->wq_reg)return 0 ; - ctx->wq =dsa_get_wq (ctx,-1 , shared); +if (wq_id !=-1 ){ + ctx->wq =dsa_get_wq_byid (ctx, dev_id, wq_id); + }else { + ctx->wq =dsa_get_wq (ctx, dev_id, shared); + } +if (!ctx->wq) {err ("No usable wq found\n" );return -ENODEV ; } dev =accfg_wq_get_device (ctx->wq); - - ctx->dedicated = !shared; + ctx->dedicated =accfg_wq_get_mode (ctx->wq); ctx->wq_size =accfg_wq_get_size (ctx->wq); ctx->wq_idx =accfg_wq_get_id (ctx->wq); ctx->bof =accfg_wq_get_block_on_fault (ctx->wq);@@ -182,7 +235,7 @@ int dsa_alloc(struct dsa_context *ctx, int shared) ctx->max_xfer_bits =bsr (ctx->max_xfer_size);info ("alloc wq %d shared %d size %d addr %p batch sz %#x xfer sz %#x\n" , - ctx->wq_idx, shared, ctx->wq_size, ctx->wq_reg, + ctx->wq_idx, ctx->dedicated, ctx->wq_size, ctx->wq_reg, ctx->max_batch_size, ctx->max_xfer_size);return 0 ;test/dsa.h +1
-1@@ -211,7 +211,7 @@ int memcmp_pattern(const void *src, const uint64_t pattern, size_t len);int dsa_enqcmd (struct dsa_context *ctx,struct dsa_hw_desc *hw);struct dsa_context *dsa_init (void ); -int dsa_alloc (struct dsa_context *ctx,int shared); +int dsa_alloc (struct dsa_context *ctx,int shared,int dev_id,int wq_id);int alloc_task (struct dsa_context *ctx);struct task *__alloc_task (void ); int init_task(struct task *tsk, int tflags, int opcode,test/dsa_test.c +12
-3@@ -23,6 +23,8 @@ static void usage(void)"-o <opcode> ; opcode, same value as in DSA spec\n" "-b <opcode> ; if batch opcode, opcode in the batch\n" "-c <batch_size> ; if batch opcode, number of descriptors for batch\n" +"-i ; device id\n" +"-d ; wq number\n" "-t <ms timeout> ; ms to wait for descs to complete\n" "-v ; verbose\n" "-h ; print this message\n");@@ -105,13 +107,14 @@ int main(int argc, char *argv[])int rc =0 ;unsigned long buf_size =DSA_TEST_SIZE ;int wq_type =SHARED ; +int wq_id =-1 ;int opcode =DSA_OPCODE_MEMMOVE ;int bopcode =DSA_OPCODE_MEMMOVE ;int tflags =TEST_FLAGS_BOF ; -int opt; +int opt, dev_id=-1 ;unsigned int bsize =0 ; -while ((opt =getopt (argc, argv,"w:l:f:o:b:c:t:p:vh" )) !=-1 ) { +while ((opt =getopt (argc, argv,"w:l:f:o:b:c:i:d:t:p:vh" )) !=-1 ) {switch (opt) {case 'w' : wq_type =atoi (optarg);@@ -131,6 +134,12 @@ int main(int argc, char *argv[])case 'c' : bsize =strtoul (optarg,NULL ,0 );break ; +case 'i' : + dev_id =atoi (optarg); +break ; +case 'd' : + wq_id =strtoul (optarg,NULL ,0 ); +break ;case 't' : ms_timeout =strtoul (optarg,NULL ,0 );break ;@@ -150,7 +159,7 @@ int main(int argc, char *argv[])if (dsa ==NULL )return -ENOMEM ; - rc =dsa_alloc (dsa, wq_type); + rc =dsa_alloc (dsa, wq_type, dev_id, wq_id);if (rc <0 )return -ENOMEM ;