Skip to contentSkip to conversation

accel-config: Add completion record size setup for accfg_device

PATCH Ramesh Thomas 1 participant 1 message Apr 13, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ramesh Thomas

author
#1 lore raw

You missed or misunderstood my earlier comment in this patch. I am adding it here and additional ones.

Quoted 20 lines · Li Zhang

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 add compl_size field in struct accfg_device for using by DSA and IAA test code.

Signed-off-by Li Zhang <li4.zhang(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Reviewed-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
  accfg/lib/libaccfg.c    | 8 ++++++++
  accfg/lib/private.h     | 1 +
  accfg/libaccel_config.h | 5 +++++
  3 files changed, 14 insertions(+)
accfg/lib/libaccfg.c +0 -0
index 8d883b1..4821c04 100644
@@ -540,6 +540,14 @@ static int device_parse_type(struct accfg_device *device)
  	for (b = accfg_basenames, i = 0; *b != NULL; b++, i++) {

accfg/lib/libaccfg.c static int device_parse_type(struct accfg_device *device) · line 550

Quoted 10 lines
accfg/lib/libaccfg.c +8 -0
  		if (!strcmp(device->device_type_str, *b)) {
  			device->type = i;
+
+			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;
+

You can create an array similar to accfg_basenames but not public and then assign the associated value for the type as follows

unsigned int accfg_device_compl_size[] = {
         [ACCFG_DEVICE_DSA]      = 32,
         [ACCFG_DEVICE_IAX]      = 64,
};

After the type is determined, it can be used to index into this array

device->compl_size = accfg_device_compl_size[device->type];

accfg/lib/private.h struct accfg_device { · line 49

Quoted 12 lines
accfg/lib/libaccfg.c +0 -0
  			return 0;
  		}
  	}
accfg/lib/private.h +1 -0
index f88044c..773aba2 100644
@@ -46,6 +46,7 @@ struct accfg_device {
  	int numa_node;
  	int ims_size;
  	int max_batch_size;
+	int compl_size;

The API is returning unsigned int so make this unsigned

Quoted 8 lines
accfg/lib/private.h +0 -0
  	int configurable;
  	int max_read_buffers;
  	unsigned int read_buffer_limit;
accfg/libaccel_config.h +0 -0
index 9e952a7..ef7c8ae 100644

accfg/libaccel_config.h enum accfg_device_state { · line 52

Quoted 8 lines
accfg/libaccel_config.h +5 -0
@@ -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,
+};
+

This enum is not required.

Quoted 3 lines
accfg/libaccel_config.h +0 -0
  enum accfg_wq_mode {
  	ACCFG_WQ_SHARED = 0,
  	ACCFG_WQ_DEDICATED,