On 4/8/2022 5:30 AM, Li Zhang wrote:
DSA and IAA test need to get completion record size for allocating
and dumping completion record. DSA completion record is 32 bytes
while IAA completion record is 64 bytes. So init compl_size field in
struct accfg_device for using by DSA and IAA test code, modify
DSA test code for using compl_size.
Signed-off-by: Li Zhang <li4.zhang(a)intel.com>
Reviewed-by: Dave Jiang <dave.jiang(a)intel.com>
---
accfg/lib/libaccel-config.sym | 1 +
accfg/lib/libaccfg.c | 23 ++++++++++++++++++
accfg/lib/private.h | 1 +
accfg/libaccel_config.h | 6 +++++
Need to split the accel-config changes from the test changes. The
accel-config changes can be 2 patches. One setup the accfg_device and
the second exports the API calls.
accel-config: Add completion record size setup for accfg_device
accel-config: Export API to retrieve completion record for the device
accel-config: test: .....
test/dsa.c | 45
++++++++++++++++++-----------------
test/dsa.h | 16 +++++++------
test/dsa_test.c | 4 ++--
7 files changed, 65 insertions(+), 31 deletions(-)
diff --git a/accfg/lib/libaccel-config.sym b/accfg/lib/libaccel-config.sym
index fde9251..b85b9b5 100644
--- a/accfg/lib/libaccel-config.sym
+++ b/accfg/lib/libaccel-config.sym
@@ -22,6 +22,7 @@ LIBACCFG_1 {
accfg_device_get_ims_size;
accfg_device_get_max_batch_size;
accfg_device_get_max_transfer_size;
+ accfg_device_get_compl_size;
This needs to be in a different symbol block. You
can't just add to the
existing one. Every release needs to rev the API symbol revision.
accfg_device_get_configurable;
accfg_device_get_pasid_enabled;
accfg_device_get_errors;
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index 8d883b1..7e789b4 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -547,6 +547,19 @@ static int device_parse_type(struct accfg_device *device)
return -ENODEV;
}
+/*set completion record size*/
+static int device_parse_compl_size(struct accfg_device *device)
device_set_completion_record_size().
> +{
> + if (device->type == ACCFG_DEVICE_DSA)
> + device->compl_size = ACCFG_DEVICE_COMPL_SIZE_DSA;
> + else if (device->type == ACCFG_DEVICE_IAX)
> + device->compl_size = ACCFG_DEVICE_COMPL_SIZE_IAX;
> + else
> + return -ENODEV;
> +
> + return 0;
> +}
> +
> static int mdev_str_to_type(char *mdev_type_str)
> {
> char **b;
> @@ -706,6 +719,10 @@ static void *add_device(void *parent, int id, const char
*ctl_base,
> if (rc < 0)
> goto err_dev_path;
>
> + rc = device_parse_compl_size(device);
> + if (rc < 0)
> + goto err_dev_path;
> +
> device->bus_type_str = bus_type;
>
> if (is_mdev_registered(device) && add_device_mdevs(ctx, device))
> @@ -1340,6 +1357,12 @@ ACCFG_EXPORT uint64_t accfg_device_get_max_transfer_size(
> return device->max_transfer_size;
> }
>
> +/* Helper function to retrieve completion record size */
> +ACCFG_EXPORT unsigned int accfg_device_get_compl_size(struct accfg_device *device)
> +{
> + return device->compl_size;
> +}
> +
> ACCFG_EXPORT int accfg_device_get_op_cap(struct accfg_device *device,
> struct accfg_op_cap *op_cap)
> {
> diff --git a/accfg/lib/private.h b/accfg/lib/private.h
> index f88044c..edbae10 100644
> --- a/accfg/lib/private.h
> +++ b/accfg/lib/private.h
> @@ -55,6 +55,7 @@ struct accfg_device {
> uint64_t opcap;
> uint64_t gencap;
> char *pasid_enabled;
> + unsigned int compl_size;
> };
>
> struct accfg_device_mdev {
> diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h
> index 9e952a7..5cb49ce 100644
> --- a/accfg/libaccel_config.h
> +++ b/accfg/libaccel_config.h
> @@ -45,6 +45,11 @@ enum accfg_device_state {
> ACCFG_DEVICE_UNKNOWN = -1,
> };
>
> +enum accfg_device_compl_size {
> + ACCFG_DEVICE_COMPL_SIZE_DSA = 32,
> + ACCFG_DEVICE_COMPL_SIZE_IAX = 64,
> +};
> +
> enum accfg_wq_mode {
> ACCFG_WQ_SHARED = 0,
> ACCFG_WQ_DEDICATED,
> @@ -183,6 +188,7 @@ int accfg_device_get_numa_node(struct accfg_device *device);
> unsigned int accfg_device_get_ims_size(struct accfg_device *device);
> unsigned int accfg_device_get_max_batch_size(struct accfg_device *device);
> uint64_t accfg_device_get_max_transfer_size(struct accfg_device *device);
> +unsigned int accfg_device_get_compl_size(struct accfg_device *device);
> int accfg_device_get_op_cap(struct accfg_device *device,
> struct accfg_op_cap *op_cap);
> uint64_t accfg_device_get_gen_cap(struct accfg_device *device);
> diff --git a/test/dsa.c b/test/dsa.c
> index ec3ceb1..f1ca2e9 100644
> --- a/test/dsa.c
> +++ b/test/dsa.c
> @@ -255,6 +255,7 @@ int acctest_alloc(struct acctest_context *ctx, int shared, int
dev_id, int wq_id
> ctx->max_batch_size = accfg_device_get_max_batch_size(dev);
> ctx->max_xfer_size = accfg_device_get_max_transfer_size(dev);
> ctx->max_xfer_bits = bsr(ctx->max_xfer_size);
> + ctx->compl_size = accfg_device_get_compl_size(dev);
>
> info("alloc wq %d shared %d size %d addr %p batch sz %#x xfer sz
%#x\n",
> ctx->wq_idx, ctx->dedicated, ctx->wq_size, ctx->wq_reg,
> @@ -274,7 +275,7 @@ int acctest_alloc_multiple_tasks(struct acctest_context *ctx, int
num_itr)
> if (!ctx->multi_task_node)
> return -ENOMEM;
>
> - ctx->multi_task_node->tsk = acctest_alloc_task();
> + ctx->multi_task_node->tsk = acctest_alloc_task(ctx);
> if (!ctx->multi_task_node->tsk)
> return -ENOMEM;
> ctx->multi_task_node->next = tmp_tsk_node;
> @@ -283,7 +284,7 @@ int acctest_alloc_multiple_tasks(struct acctest_context *ctx, int
num_itr)
> return ACCTEST_STATUS_OK;
> }
>
> -struct task *acctest_alloc_task(void)
> +struct task *acctest_alloc_task(struct acctest_context *ctx)
> {
> struct task *tsk;
>
> @@ -299,8 +300,7 @@ struct task *acctest_alloc_task(void)
> }
> memset(tsk->desc, 0, sizeof(struct hw_desc));
>
> - /* To be compatible with IAX, completion record need to be 64-byte aligned */
> - tsk->comp = aligned_alloc(64, sizeof(struct completion_record));
> + tsk->comp = aligned_alloc(ctx->compl_size, sizeof(struct
completion_record));
> if (!tsk->comp) {
> free_task(tsk);
> return NULL;
> @@ -815,7 +815,7 @@ int alloc_batch_task(struct acctest_context *ctx, unsigned int
task_num, int num
>
> btsk = ctx->multi_btask_node->btsk;
>
> - btsk->core_task = acctest_alloc_task();
> + btsk->core_task = acctest_alloc_task(ctx);
> if (!btsk->core_task)
> return -ENOMEM;
>
> @@ -912,6 +912,7 @@ static inline int umwait(unsigned long timeout, unsigned int
state)
> }
>
> static int acctest_wait_on_desc_timeout(struct completion_record *comp,
> + struct acctest_context *ctx,
> unsigned int msec_timeout)
> {
> unsigned int j = 0;
> @@ -945,7 +946,7 @@ static int acctest_wait_on_desc_timeout(struct completion_record
*comp,
> j = msec_timeout;
> }
>
> - dump_compl_rec(comp);
> + dump_compl_rec(comp, ctx->compl_size);
>
> return (j == msec_timeout) ? -EAGAIN : 0;
> }
> @@ -1088,7 +1089,7 @@ int dsa_wait_noop(struct acctest_context *ctx, struct task
*tsk)
> struct completion_record *comp = tsk->comp;
> int rc;
>
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("noop desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1127,7 +1128,7 @@ int dsa_noop_multi_task_nodes(struct acctest_context *ctx)
> return ret;
> }
>
> -int dsa_wait_batch(struct batch_task *btsk)
> +int dsa_wait_batch(struct batch_task *btsk, struct acctest_context *ctx)
> {
> int rc;
>
> @@ -1135,13 +1136,13 @@ int dsa_wait_batch(struct batch_task *btsk)
>
> info("wait batch\n");
>
> - rc = acctest_wait_on_desc_timeout(ctsk->comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(ctsk->comp, ctx, ms_timeout);
> if (rc < 0) {
> err("batch desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> }
>
> - dump_sub_compl_rec(btsk);
> + dump_sub_compl_rec(btsk, ctx->compl_size);
> return ACCTEST_STATUS_OK;
> }
>
> @@ -1150,7 +1151,7 @@ int dsa_wait_drain(struct acctest_context *ctx, struct task
*tsk)
> struct completion_record *comp = tsk->comp;
> int rc;
>
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("drain desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1197,7 +1198,7 @@ int dsa_wait_memcpy(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("memcpy desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1253,7 +1254,7 @@ int dsa_wait_memfill(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
>
> if (rc < 0) {
> err("memfill desc timeout\n");
> @@ -1310,7 +1311,7 @@ int dsa_wait_compare(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
>
> if (rc < 0) {
> err("compare desc timeout\n");
> @@ -1367,7 +1368,7 @@ int dsa_wait_compval(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
>
> if (rc < 0) {
> err("compval desc timeout\n");
> @@ -1424,7 +1425,7 @@ int dsa_wait_dualcast(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("dualcast desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1480,7 +1481,7 @@ int dsa_wait_cr_delta(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("memcpy desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1536,7 +1537,7 @@ int dsa_wait_ap_delta(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("memcpy desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1592,7 +1593,7 @@ int dsa_wait_crcgen(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("CRC desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1648,7 +1649,7 @@ int dsa_wait_crc_copy(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("CRC copy desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1704,7 +1705,7 @@ int dsa_wait_dif(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("DIF desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> @@ -1857,7 +1858,7 @@ int dsa_wait_cflush(struct acctest_context *ctx, struct task
*tsk)
> int rc;
>
> again:
> - rc = acctest_wait_on_desc_timeout(comp, ms_timeout);
> + rc = acctest_wait_on_desc_timeout(comp, ctx, ms_timeout);
> if (rc < 0) {
> err("cflush desc timeout\n");
> return ACCTEST_STATUS_TIMEOUT;
> diff --git a/test/dsa.h b/test/dsa.h
> index e6205c5..496abb2 100644
> --- a/test/dsa.h
> +++ b/test/dsa.h
> @@ -136,6 +136,7 @@ struct acctest_context {
> unsigned int max_batch_size;
> unsigned int max_xfer_size;
> unsigned int max_xfer_bits;
> + unsigned int compl_size;
>
> int fd;
> int wq_idx;
> @@ -230,26 +231,27 @@ static inline void dump_sub_desc(struct batch_task *btsk)
> }
>
> /* Dump DSA completion record to log */
> -static inline void dump_compl_rec(struct completion_record *compl)
> +static inline void dump_compl_rec(struct completion_record *compl, int compl_size)
> {
> - struct raw_completion_record *rcompl = (void *)compl;
> int i;
> + struct raw_completion_record *rcompl = (void *)compl;
> + int num_qword = compl_size / sizeof(uint64_t);
>
> dbg("completion record addr: %p\n", compl);
>
> /* To be compatible with IAX, completion record was allocated 64 bytes*/
> - for (i = 0; i < 8; i++)
> + for (i = 0; i < num_qword; i++)
> dbg("compl[%d]: 0x%016lx\n", i, rcompl->field[i]);
> }
>
> /* dump all sub completion records for a batch task */
> -static inline void dump_sub_compl_rec(struct batch_task *btsk)
> +static inline void dump_sub_compl_rec(struct batch_task *btsk, int compl_size)
> {
> int i;
>
> for (i = 0; i < btsk->task_num; i++) {
> dbg("sub_comp[%d]:\n", i);
> - dump_compl_rec(btsk->sub_tasks[i].comp);
> + dump_compl_rec(btsk->sub_tasks[i].comp, compl_size);
> }
> }
>
> @@ -274,7 +276,7 @@ int acctest_enqcmd(struct acctest_context *ctx, struct hw_desc
*hw);
> struct acctest_context *acctest_init(void);
> int acctest_alloc(struct acctest_context *ctx, int shared, int dev_id, int wq_id);
> int acctest_alloc_multiple_tasks(struct acctest_context *ctx, int num_itr);
> -struct task *acctest_alloc_task(void);
> +struct task *acctest_alloc_task(struct acctest_context *ctx);
> int init_memcpy(struct task *tsk, int tflags, int opcode, unsigned long
xfer_size);
> int init_memfill(struct task *tsk, int tflags, int opcode, unsigned long
xfer_size);
> int init_compare(struct task *tsk, int tflags, int opcode, unsigned long
xfer_size);
> @@ -395,7 +397,7 @@ void dsa_prep_batch_dif_insert(struct batch_task *btsk);
> void dsa_prep_batch_dif_strip(struct batch_task *btsk);
> void dsa_prep_batch_dif_update(struct batch_task *btsk);
> void dsa_prep_batch_cflush(struct batch_task *btsk);
> -int dsa_wait_batch(struct batch_task *btsk);
> +int dsa_wait_batch(struct batch_task *btsk, struct acctest_context *ctx);
>
> void acctest_free(struct acctest_context *ctx);
> void acctest_free_task(struct acctest_context *ctx);
> diff --git a/test/dsa_test.c b/test/dsa_test.c
> index e882f6c..0c84190 100644
> --- a/test/dsa_test.c
> +++ b/test/dsa_test.c
> @@ -154,7 +154,7 @@ static int test_batch(struct acctest_context *ctx, size_t
buf_size,
>
> btsk_node = ctx->multi_btask_node;
> while (btsk_node) {
> - rc = dsa_wait_batch(btsk_node->btsk);
> + rc = dsa_wait_batch(btsk_node->btsk, ctx);
> if (rc != ACCTEST_STATUS_OK) {
> err("batch failed stat %d\n", rc);
> return rc;
> @@ -185,7 +185,7 @@ static int test_batch(struct acctest_context *ctx, size_t
buf_size,
>
> btsk_node = ctx->multi_btask_node;
> while (btsk_node) {
> - rc = dsa_wait_batch(btsk_node->btsk);
> + rc = dsa_wait_batch(btsk_node->btsk, ctx);
> if (rc != ACCTEST_STATUS_OK) {
> err("batch failed stat %d\n", rc);
> return rc;