Skip to contentSkip to conversation

From: Nic Chautru <[email protected]>

PATCH Superseded Nic Chautru 2 participants 43 messages Sep 22, 2022 – Sep 27, 2022 Arm/Amlogic Meson SoC support Page 2 of 2

v4 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#19 lore raw

RE: [PATCH v4 07/14] baseband/acc: add queue configuration for ACC200

In reply to Maxime Coquelin

Hi Maxime,
Will update this in the new version. Thanks.

Quoted 60 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Thursday, September 22, 2022 7:30 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 07/14] baseband/acc: add queue configuration for ACC200

Quoted 5 lines · Nic Chautru

Adding function to create and configure queues for the device.

---
  drivers/baseband/acc/rte_acc200_pmd.c | 373

+++++++++++++++++++++++++++++++++-

Quoted 11 lines
  1 file changed, 372 insertions(+), 1 deletion(-)
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
index 43415eb..355cf8e 100644
@@ -220,16 +220,383 @@
  			acc_conf->q_fft.aq_depth_log2);
  }
 

drivers/baseband/acc/rte_acc200_pmd.c line 232

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+/* Allocate 64MB memory used for all software rings */ static int
+acc200_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int
+socket_id) {
+	uint32_t phys_low, phys_high, value;
+	struct acc_device *d = dev->data->dev_private;
+	const struct acc200_registry_addr *reg_addr;
+
+	if (d->pf_device && !d->acc_conf.pf_mode_en) {
+		rte_bbdev_log(NOTICE,
+				"%s has PF mode disabled. This PF can't be

used.",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+				dev->data->name);
+		return -ENODEV;
+	}
+	if (!d->pf_device && d->acc_conf.pf_mode_en) {
+		rte_bbdev_log(NOTICE,
+				"%s has PF mode enabled. This VF can't be

used.",

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				dev->data->name);
+		return -ENODEV;
+	}
+
+	alloc_sw_rings_min_mem(dev, d, num_queues, socket_id);
+
+	/* If minimal memory space approach failed, then allocate
+	 * the 2 * 64MB block for the sw rings
+	 */
+	if (d->sw_rings == NULL)
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 255

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+		alloc_2x64mb_sw_rings_mem(dev, d, socket_id);
+
+	if (d->sw_rings == NULL) {
+		rte_bbdev_log(NOTICE,
+				"Failure allocating sw_rings memory");
+		return -ENODEV;

-ENOMEM;

OK

Quoted 41 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+	}
+
+	/* Configure ACC200 with the base address for DMA descriptor rings
+	 * Same descriptor rings used for UL and DL DMA Engines
+	 * Note : Assuming only VF0 bundle is used for PF mode
+	 */
+	phys_high = (uint32_t)(d->sw_rings_iova >> 32);
+	phys_low  = (uint32_t)(d->sw_rings_iova & ~(ACC_SIZE_64MBYTE-

1));

Quoted 31 lines
drivers/baseband/acc/rte_acc200_pmd.c +31 -0
+
+	/* Choose correct registry addresses for the device type */
+	if (d->pf_device)
+		reg_addr = &pf_reg_addr;
+	else
+		reg_addr = &vf_reg_addr;
+
+	/* Read the populated cfg from ACC200 registers */
+	fetch_acc200_config(dev);
+
+	/* Start Pmon */
+	for (value = 0; value <= 2; value++) {
+		acc_reg_write(d, reg_addr->pmon_ctrl_a, value);
+		acc_reg_write(d, reg_addr->pmon_ctrl_b, value);
+		acc_reg_write(d, reg_addr->pmon_ctrl_c, value);
+	}
+
+	/* Release AXI from PF */
+	if (d->pf_device)
+		acc_reg_write(d, HWPfDmaAxiControl, 1);
+
+	acc_reg_write(d, reg_addr->dma_ring_ul5g_hi, phys_high);
+	acc_reg_write(d, reg_addr->dma_ring_ul5g_lo, phys_low);
+	acc_reg_write(d, reg_addr->dma_ring_dl5g_hi, phys_high);
+	acc_reg_write(d, reg_addr->dma_ring_dl5g_lo, phys_low);
+	acc_reg_write(d, reg_addr->dma_ring_ul4g_hi, phys_high);
+	acc_reg_write(d, reg_addr->dma_ring_ul4g_lo, phys_low);
+	acc_reg_write(d, reg_addr->dma_ring_dl4g_hi, phys_high);
+	acc_reg_write(d, reg_addr->dma_ring_dl4g_lo, phys_low);
+	acc_reg_write(d, reg_addr->dma_ring_fft_hi, phys_high);
+	acc_reg_write(d, reg_addr->dma_ring_fft_lo, phys_low);
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 299

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	/*
+	 * Configure Ring Size to the max queue ring size
+	 * (used for wrapping purpose)
+	 */
+	value = log2_basic(d->sw_ring_size / 64);

What is the 64 value meaning? The size of a descriptor? If so, you should either use sizeof() or a defined value.

OK, adding defined value for the magic number.

Quoted 18 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+	acc_reg_write(d, reg_addr->ring_size, value);
+
+	/* Configure tail pointer for use when SDONE enabled */
+	if (d->tail_ptrs == NULL)
+		d->tail_ptrs = rte_zmalloc_socket(
+				dev->device->driver->name,
+				ACC200_NUM_QGRPS * ACC200_NUM_AQS

* sizeof(uint32_t),

drivers/baseband/acc/rte_acc200_pmd.c line 312

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+				RTE_CACHE_LINE_SIZE, socket_id);
+	if (d->tail_ptrs == NULL) {
+		rte_bbdev_log(ERR, "Failed to allocate tail ptr for %s:%u",
+				dev->device->driver->name,
+				dev->data->dev_id);
+		rte_free(d->sw_rings);

You need to se to NULL, or you'll have a use after free looking at how it is allocated.

Quoted 2 lines
		ret = -ENOMEM;
		goto free_sw_rings;

OK for the overall error path change. Thanks

Quoted 54 lines
Quoted 15 lines
drivers/baseband/acc/rte_acc200_pmd.c +15 -0
+		return -ENOMEM;
+	}
+	d->tail_ptr_iova = rte_malloc_virt2iova(d->tail_ptrs);
+
+	phys_high = (uint32_t)(d->tail_ptr_iova >> 32);
+	phys_low  = (uint32_t)(d->tail_ptr_iova);
+	acc_reg_write(d, reg_addr->tail_ptrs_ul5g_hi, phys_high);
+	acc_reg_write(d, reg_addr->tail_ptrs_ul5g_lo, phys_low);
+	acc_reg_write(d, reg_addr->tail_ptrs_dl5g_hi, phys_high);
+	acc_reg_write(d, reg_addr->tail_ptrs_dl5g_lo, phys_low);
+	acc_reg_write(d, reg_addr->tail_ptrs_ul4g_hi, phys_high);
+	acc_reg_write(d, reg_addr->tail_ptrs_ul4g_lo, phys_low);
+	acc_reg_write(d, reg_addr->tail_ptrs_dl4g_hi, phys_high);
+	acc_reg_write(d, reg_addr->tail_ptrs_dl4g_lo, phys_low);
+	acc_reg_write(d, reg_addr->tail_ptrs_fft_hi, phys_high);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+	acc_reg_write(d, reg_addr->tail_ptrs_fft_lo, phys_low);
+
+	if (d->harq_layout == NULL)
+		d->harq_layout = rte_zmalloc_socket("HARQ Layout",
+				ACC_HARQ_LAYOUT * sizeof(*d-
 harq_layout),
+				RTE_CACHE_LINE_SIZE, dev->data-
 socket_id);
+	if (d->harq_layout == NULL) {
+		rte_bbdev_log(ERR, "Failed to allocate harq_layout for

%s:%u",

drivers/baseband/acc/rte_acc200_pmd.c line 312

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+				dev->device->driver->name,
+				dev->data->dev_id);
+		rte_free(d->sw_rings);

Same comment as above, and you also miss to free tail_ptrs. Maybe it would be better to have an error path, see below:

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+		return -ENOMEM;
+	}
+
+	/* Mark as configured properly */
+	d->configured = true;
+
+	rte_bbdev_log_debug(
+			"ACC200 (%s) configured  sw_rings = %p,

sw_rings_iova = %#"

drivers/baseband/acc/rte_acc200_pmd.c line 349

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+			PRIx64, dev->data->name, d->sw_rings, d-
 sw_rings_iova);
+
+	return 0;

free_tail_ptrs:

	rte_free(d->tail_ptrs);
	d->tail_ptrs = NULL;
free_sw_rings:
	rte_free(d->sw_rings);
	d->sw_rings = NULL;

	return ret;
Quoted 11 lines

drivers/baseband/acc/rte_acc200_pmd.c line 357

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -1
+}
+
  /* Free memory used for software rings */
  static int
  acc200_dev_close(struct rte_bbdev *dev)
  {
-	RTE_SET_USED(dev);
+	struct acc_device *d = dev->data->dev_private;
+	if (d->sw_rings_base != NULL) {

Isn't d->sw_rings that is allocated in this patch?

No this is sw_rings_base on purpose. The sw_rings pointers may have been realigned, while the sw_rings_base keeps track of the original malloc.

Quoted 32 lines

Also, the NULL check is not necessary, rte_free() takes care of it.

Quoted 18 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+		rte_free(d->tail_ptrs);
+		rte_free(d->sw_rings_base);
+		rte_free(d->harq_layout);
+		d->sw_rings_base = NULL;
+		d->tail_ptrs = NULL;
+		d->harq_layout = NULL;
+	}
  	/* Ensure all in flight HW transactions are completed */
  	usleep(ACC_LONG_WAIT);
  	return 0;
  }
 
+/**
+ * Report a ACC200 queue index which is free
+ * Return 0 to 16k for a valid queue_idx or -1 when no queue is
+available
+ * Note : Only supporting VF0 Bundle for PF mode  */ static int
+acc200_find_free_queue_idx(struct rte_bbdev *dev,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		const struct rte_bbdev_queue_conf *conf) {
+	struct acc_device *d = dev->data->dev_private;
+	int op_2_acc[6] = {0, UL_4G, DL_4G, UL_5G, DL_5G, FFT};
+	int acc = op_2_acc[conf->op_type];
+	struct rte_acc_queue_topology *qtop = NULL;
+
+	qtopFromAcc(&qtop, acc, &(d->acc_conf));
+	if (qtop == NULL)
+		return -1;
+	/* Identify matching QGroup Index which are sorted in priority order

*/

Quoted 3 lines

drivers/baseband/acc/rte_acc200_pmd.c line 388

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	uint16_t group_idx = qtop->first_qgroup_index;

Don't mix declarations & code.

OK

Quoted 12 lines

drivers/baseband/acc/rte_acc200_pmd.c line 397

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+	group_idx += conf->priority;
+	if (group_idx >= ACC200_NUM_QGRPS ||
+			conf->priority >= qtop->num_qgroups) {
+		rte_bbdev_log(INFO, "Invalid Priority on %s, priority %u",
+				dev->data->name, conf->priority);
+		return -1;
+	}
+	/* Find a free AQ_idx  */
+	uint64_t aq_idx;

Don't mix declarations & code.

OK

Quoted 85 lines

drivers/baseband/acc/rte_acc200_pmd.c line 399

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+	for (aq_idx = 0; aq_idx < qtop->num_aqs_per_groups; aq_idx++) {
+		if (((d->q_assigned_bit_map[group_idx] >> aq_idx) & 0x1) ==

0) {

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+			/* Mark the Queue as assigned */
+			d->q_assigned_bit_map[group_idx] |= (1 << aq_idx);
+			/* Report the AQ Index */
+			return (group_idx << ACC200_GRP_ID_SHIFT) +

aq_idx;

Quoted 19 lines
drivers/baseband/acc/rte_acc200_pmd.c +19 -0
+		}
+	}
+	rte_bbdev_log(INFO, "Failed to find free queue on %s, priority %u",
+			dev->data->name, conf->priority);
+	return -1;
+}
+
+/* Setup ACC200 queue */
+static int
+acc200_queue_setup(struct rte_bbdev *dev, uint16_t queue_id,
+		const struct rte_bbdev_queue_conf *conf) {
+	struct acc_device *d = dev->data->dev_private;
+	struct acc_queue *q;
+	int16_t q_idx;
+
+	if (d == NULL) {
+		rte_bbdev_log(ERR, "Undefined device");
+		return -ENODEV;
+	}

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	/* Allocate the queue data structure. */
+	q = rte_zmalloc_socket(dev->device->driver->name, sizeof(*q),
+			RTE_CACHE_LINE_SIZE, conf->socket);
+	if (q == NULL) {
+		rte_bbdev_log(ERR, "Failed to allocate queue memory");
+		return -ENOMEM;
+	}
+
+	q->d = d;
+	q->ring_addr = RTE_PTR_ADD(d->sw_rings, (d->sw_ring_size *

queue_id));

drivers/baseband/acc/rte_acc200_pmd.c line 433

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	q->ring_addr_iova = d->sw_rings_iova + (d->sw_ring_size *

queue_id);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+
+	/* Prepare the Ring with default descriptor format */
+	union acc_dma_desc *desc = NULL;
+	unsigned int desc_idx, b_idx;
+	int fcw_len = (conf->op_type == RTE_BBDEV_OP_LDPC_ENC ?
+		ACC_FCW_LE_BLEN : (conf->op_type ==

RTE_BBDEV_OP_TURBO_DEC ?

drivers/baseband/acc/rte_acc200_pmd.c line 440

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		ACC_FCW_TD_BLEN : (conf->op_type ==

RTE_BBDEV_OP_LDPC_DEC ?

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+		ACC_FCW_LD_BLEN : ACC_FCW_FFT_BLEN)));
+
+	for (desc_idx = 0; desc_idx < d->sw_ring_max_depth; desc_idx++) {
+		desc = q->ring_addr + desc_idx;
+		desc->req.word0 = ACC_DMA_DESC_TYPE;
+		desc->req.word1 = 0; /**< Timestamp */
+		desc->req.word2 = 0;
+		desc->req.word3 = 0;
+		uint64_t fcw_offset = (desc_idx << 8) +

ACC_DESC_FCW_OFFSET;

drivers/baseband/acc/rte_acc200_pmd.c line 450

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +

fcw_offset;

drivers/baseband/acc/rte_acc200_pmd.c line 462

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		desc->req.data_ptrs[0].blen = fcw_len;
+		desc->req.data_ptrs[0].blkid = ACC_DMA_BLKID_FCW;
+		desc->req.data_ptrs[0].last = 0;
+		desc->req.data_ptrs[0].dma_ext = 0;
+		for (b_idx = 1; b_idx < ACC_DMA_MAX_NUM_POINTERS - 1;
+				b_idx++) {
+			desc->req.data_ptrs[b_idx].blkid =

ACC_DMA_BLKID_IN;

Quoted 15 lines
drivers/baseband/acc/rte_acc200_pmd.c +15 -0
+			desc->req.data_ptrs[b_idx].last = 1;
+			desc->req.data_ptrs[b_idx].dma_ext = 0;
+			b_idx++;
+			desc->req.data_ptrs[b_idx].blkid =
+					ACC_DMA_BLKID_OUT_ENC;
+			desc->req.data_ptrs[b_idx].last = 1;
+			desc->req.data_ptrs[b_idx].dma_ext = 0;
+		}
+		/* Preset some fields of LDPC FCW */
+		desc->req.fcw_ld.FCWversion = ACC_FCW_VER;
+		desc->req.fcw_ld.gain_i = 1;
+		desc->req.fcw_ld.gain_h = 1;
+	}
+
+	q->lb_in = rte_zmalloc_socket(dev->device->driver->name,
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 478

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+			RTE_CACHE_LINE_SIZE,
+			RTE_CACHE_LINE_SIZE, conf->socket);
+	if (q->lb_in == NULL) {
+		rte_bbdev_log(ERR, "Failed to allocate lb_in memory");
+		rte_free(q);

Please introduce a proper error path as I gave example for acc200_setup_queues().

Fair enough, thanks.

Quoted 121 lines
Quoted 18 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+		return -ENOMEM;
+	}
+	q->lb_in_addr_iova = rte_malloc_virt2iova(q->lb_in);
+	q->lb_out = rte_zmalloc_socket(dev->device->driver->name,
+			RTE_CACHE_LINE_SIZE,
+			RTE_CACHE_LINE_SIZE, conf->socket);
+	if (q->lb_out == NULL) {
+		rte_bbdev_log(ERR, "Failed to allocate lb_out memory");
+		rte_free(q->lb_in);
+		rte_free(q);
+		return -ENOMEM;
+	}
+	q->lb_out_addr_iova = rte_malloc_virt2iova(q->lb_out);
+	q->companion_ring_addr = rte_zmalloc_socket(dev->device->driver-

name,

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			d->sw_ring_max_depth * sizeof(*q-

companion_ring_addr),

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+			RTE_CACHE_LINE_SIZE, conf->socket);
+	if (q->companion_ring_addr == NULL) {
+		rte_bbdev_log(ERR, "Failed to allocate companion_ring

memory");

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+		rte_free(q->lb_in);
+		rte_free(q->lb_out);
+		rte_free(q);
+		return -ENOMEM;
+	}
+
+	/*
+	 * Software queue ring wraps synchronously with the HW when it

reaches

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	 * the boundary of the maximum allocated queue size, no matter

what the

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	 * sw queue size is. This wrapping is guarded by setting the

wrap_mask

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	 * to represent the maximum queue size as allocated at the time

when

Quoted 31 lines
drivers/baseband/acc/rte_acc200_pmd.c +31 -0
+	 * the device has been setup (in configure()).
+	 *
+	 * The queue depth is set to the queue size value (conf->queue_size).
+	 * This limits the occupancy of the queue at any point of time, so that
+	 * the queue does not get swamped with enqueue requests.
+	 */
+	q->sw_ring_depth = conf->queue_size;
+	q->sw_ring_wrap_mask = d->sw_ring_max_depth - 1;
+
+	q->op_type = conf->op_type;
+
+	q_idx = acc200_find_free_queue_idx(dev, conf);
+	if (q_idx == -1) {
+		rte_free(q->companion_ring_addr);
+		rte_free(q->lb_in);
+		rte_free(q->lb_out);
+		rte_free(q);
+		return -1;
+	}
+
+	q->qgrp_id = (q_idx >> ACC200_GRP_ID_SHIFT) & 0xF;
+	q->vf_id = (q_idx >> ACC200_VF_ID_SHIFT)  & 0x3F;
+	q->aq_id = q_idx & 0xF;
+	q->aq_depth = 0;
+	if (conf->op_type ==  RTE_BBDEV_OP_TURBO_DEC)
+		q->aq_depth = (1 << d->acc_conf.q_ul_4g.aq_depth_log2);
+	else if (conf->op_type ==  RTE_BBDEV_OP_TURBO_ENC)
+		q->aq_depth = (1 << d->acc_conf.q_dl_4g.aq_depth_log2);
+	else if (conf->op_type ==  RTE_BBDEV_OP_LDPC_DEC)
+		q->aq_depth = (1 << d->acc_conf.q_ul_5g.aq_depth_log2);
+	else if (conf->op_type ==  RTE_BBDEV_OP_LDPC_ENC)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		q->aq_depth = (1 << d->acc_conf.q_dl_5g.aq_depth_log2);
+	else if (conf->op_type ==  RTE_BBDEV_OP_FFT)
+		q->aq_depth = (1 << d->acc_conf.q_fft.aq_depth_log2);
+
+	q->mmio_reg_enqueue = RTE_PTR_ADD(d->mmio_base,
+			queue_offset(d->pf_device,
+					q->vf_id, q->qgrp_id, q->aq_id));
+
+	rte_bbdev_log_debug(
+			"Setup dev%u q%u: qgrp_id=%u, vf_id=%u,

aq_id=%u, aq_depth=%u, mmio_reg_enqueue=%p base %p\n",

Quoted 15 lines
drivers/baseband/acc/rte_acc200_pmd.c +15 -0
+			dev->data->dev_id, queue_id, q->qgrp_id, q->vf_id,
+			q->aq_id, q->aq_depth, q->mmio_reg_enqueue,
+			d->mmio_base);
+
+	dev->data->queues[queue_id].queue_private = q;
+	return 0;
+}
+
+
+static int
+acc_queue_stop(struct rte_bbdev *dev, uint16_t queue_id) {
+	struct acc_queue *q;
+	q = dev->data->queues[queue_id].queue_private;
+	rte_bbdev_log(INFO, "Queue Stop %d H/T/D %d %d %x OpType %d",
+			queue_id, q->sw_ring_head, q->sw_ring_tail,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			q->sw_ring_depth, q->op_type);
+	/* ignore all operations in flight and clear counters */
+	q->sw_ring_tail = q->sw_ring_head;
+	q->aq_enqueued = 0;
+	q->aq_dequeued = 0;
+	dev->data->queues[queue_id].queue_stats.enqueued_count = 0;
+	dev->data->queues[queue_id].queue_stats.dequeued_count = 0;
+	dev->data->queues[queue_id].queue_stats.enqueue_err_count = 0;
+	dev->data->queues[queue_id].queue_stats.dequeue_err_count = 0;
+	dev->data->queues[queue_id].queue_stats.enqueue_warn_count =

0;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	dev->data->queues[queue_id].queue_stats.dequeue_warn_count =

0;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+	return 0;
+}
+
+/* Release ACC200 queue */
+static int
+acc200_queue_release(struct rte_bbdev *dev, uint16_t q_id) {
+	struct acc_device *d = dev->data->dev_private;
+	struct acc_queue *q = dev->data->queues[q_id].queue_private;
+
+	if (q != NULL) {
+		/* Mark the Queue as un-assigned */
+		d->q_assigned_bit_map[q->qgrp_id] &= (0xFFFFFFFFFFFFFFFF

-

Quoted 2 lines

s/0xFFFFFFFFFFFFFFFF/~0ULL/

OK

Quoted 31 lines

drivers/baseband/acc/rte_acc200_pmd.c line 589

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+				(uint64_t) (1 << q->aq_id));

Or better:

d->q_assigned_bit_map[q->qgrp_id] &= ~(1 << q->aq_id);

Quoted 25 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+		rte_free(q->companion_ring_addr);
+		rte_free(q->lb_in);
+		rte_free(q->lb_out);
+		rte_free(q);
+		dev->data->queues[q_id].queue_private = NULL;
+	}
+
+	return 0;
+}
+
  /* Get ACC200 device info */
  static void
  acc200_dev_info_get(struct rte_bbdev *dev, @@ -279,8 +646,12 @@
  }
 
  static const struct rte_bbdev_ops acc200_bbdev_ops = {
+	.setup_queues = acc200_setup_queues,
  	.close = acc200_dev_close,
  	.info_get = acc200_dev_info_get,
+	.queue_setup = acc200_queue_setup,
+	.queue_release = acc200_queue_release,
+	.queue_stop = acc_queue_stop,
  };
 
  /* ACC200 PCI PF address map */
#21 lore raw

Re: [PATCH v4 08/14] baseband/acc: add LDPC processing functions

In reply to Nic Chautru

Hi Nicolas,

I'm finishing reviewing this patch from v4 as I was in the middle of the review when you posted v5. Will continue the other ones on v5.

Quoted 49 lines · Nic Chautru

Adding LDPC encode and decode processing functions.

---
  drivers/baseband/acc/acc_common.h     |   84 ++
  drivers/baseband/acc/rte_acc200_pmd.c | 1526 ++++++++++++++++++++++++++++++++-
  2 files changed, 1606 insertions(+), 4 deletions(-)
drivers/baseband/acc/acc_common.h +33 -0
index ae8de9e..b430b45 100644
@@ -1300,4 +1300,88 @@ static inline uint32_t hq_index(uint32_t offset)
  	return 0;
  }
 
+static inline void
+acc_enqueue_status(struct rte_bbdev_queue_data *q_data,
+		enum rte_bbdev_enqueue_status status)
+{
+	q_data->enqueue_status = status;
+	q_data->queue_stats.enqueue_status_count[status]++;
+
+	rte_acc_log(WARNING, "Enqueue Status: %s %#"PRIx64"",
+			rte_bbdev_enqueue_status_str(status),
+			q_data->queue_stats.enqueue_status_count[status]);
+}
+
+static inline void
+acc_enqueue_invalid(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data, RTE_BBDEV_ENQ_STATUS_INVALID_OP);
+}
+
+static inline void
+acc_enqueue_ring_full(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data, RTE_BBDEV_ENQ_STATUS_RING_FULL);
+}
+
+static inline void
+acc_enqueue_queue_full(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data, RTE_BBDEV_ENQ_STATUS_QUEUE_FULL);
+}
+
+/* Number of available descriptor in ring to enqueue */
+static inline uint32_t
+acc_ring_avail_enq(struct acc_queue *q)

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset) · line 1345

Quoted 10 lines
drivers/baseband/acc/acc_common.h +10 -0
+{
+	return (q->sw_ring_depth - 1 + q->sw_ring_tail - q->sw_ring_head) % q->sw_ring_depth;
+}
+
+/* Number of available descriptor in ring to dequeue */
+static inline uint32_t
+acc_ring_avail_deq(struct acc_queue *q)
+{
+	return (q->sw_ring_depth + q->sw_ring_head - q->sw_ring_tail) % q->sw_ring_depth;
+}

My understanding is that the ring size is a power of 2, it that correct?
If so, indead of doing a modulo operation, you could do a AND operation with the ring mask which is less costly.

Also, I reiterate my comment on previous revision, it looks unbalanced that enq and dec implementations are off-by-one.

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset) · line 1357

Quoted 12 lines
drivers/baseband/acc/acc_common.h +12 -0
+
+/* Check room in AQ for the enqueues batches into Qmgr */
+static inline int32_t
+acc_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t num_ops)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = q->aq_depth -
+			((q->aq_enqueued - q->aq_dequeued +
+			ACC_MAX_QUEUE_DEPTH) % ACC_MAX_QUEUE_DEPTH)
+			- (num_ops >> 7);
+	if (aq_avail <= 0)
+		acc_enqueue_queue_full(q_data);

Shouldn't we raise an error if aq_avail negative?

Also this function does not seem related to LDPC processing, since it is not used in that patch. It should belong to next patch.

Quoted 547 lines
drivers/baseband/acc/acc_common.h +29 -0
+	return aq_avail;
+}
+
+/* Calculates number of CBs in processed encoder TB based on 'r' and input
+ * length.
+ */
+static inline uint8_t
+get_num_cbs_in_tb_ldpc_enc(struct rte_bbdev_op_ldpc_enc *ldpc_enc)
+{
+	uint8_t c, r, crc24_bits = 0;
+	uint16_t k = (ldpc_enc->basegraph == 1 ? 22 : 10) * ldpc_enc->z_c
+		- ldpc_enc->n_filler;
+	uint8_t cbs_in_tb = 0;
+	int32_t length;
+
+	length = ldpc_enc->input.length;
+	r = ldpc_enc->tb_params.r;
+	c = ldpc_enc->tb_params.c;
+	crc24_bits = 0;
+	if (check_bit(ldpc_enc->op_flags, RTE_BBDEV_LDPC_CRC_24B_ATTACH))
+		crc24_bits = 24;
+	while (length > 0 && r < c) {
+		length -= (k - crc24_bits) >> 3;
+		r++;
+		cbs_in_tb++;
+	}
+	return cbs_in_tb;
+}
+
  #endif /* _ACC_COMMON_H_ */
drivers/baseband/acc/rte_acc200_pmd.c +472 -4
index 355cf8e..1c59559 100644
@@ -554,15 +554,50 @@
  	return 0;
  }
 
+static inline void
+acc200_print_op(struct rte_bbdev_dec_op *op, enum rte_bbdev_op_type op_type,
+		uint16_t index)
+{
+	if (op == NULL)
+		return;
+	if (op_type == RTE_BBDEV_OP_LDPC_DEC)
+		rte_bbdev_log(INFO,
+			"  Op 5GUL %d %d %d %d %d %d %d %d %d %d %d %d",
+			index,
+			op->ldpc_dec.basegraph, op->ldpc_dec.z_c,
+			op->ldpc_dec.n_cb, op->ldpc_dec.q_m,
+			op->ldpc_dec.n_filler, op->ldpc_dec.cb_params.e,
+			op->ldpc_dec.op_flags, op->ldpc_dec.rv_index,
+			op->ldpc_dec.iter_max, op->ldpc_dec.iter_count,
+			op->ldpc_dec.harq_combined_input.length
+			);
+	else if (op_type == RTE_BBDEV_OP_LDPC_ENC) {
+		struct rte_bbdev_enc_op *op_dl = (struct rte_bbdev_enc_op *) op;
+		rte_bbdev_log(INFO,
+			"  Op 5GDL %d %d %d %d %d %d %d %d %d",
+			index,
+			op_dl->ldpc_enc.basegraph, op_dl->ldpc_enc.z_c,
+			op_dl->ldpc_enc.n_cb, op_dl->ldpc_enc.q_m,
+			op_dl->ldpc_enc.n_filler, op_dl->ldpc_enc.cb_params.e,
+			op_dl->ldpc_enc.op_flags, op_dl->ldpc_enc.rv_index
+			);
+	}
+}
 
  static int
  acc_queue_stop(struct rte_bbdev *dev, uint16_t queue_id)
  {
  	struct acc_queue *q;
+	struct rte_bbdev_dec_op *op;
+	uint16_t i;
  	q = dev->data->queues[queue_id].queue_private;
  	rte_bbdev_log(INFO, "Queue Stop %d H/T/D %d %d %x OpType %d",
  			queue_id, q->sw_ring_head, q->sw_ring_tail,
  			q->sw_ring_depth, q->op_type);
+	for (i = 0; i < q->sw_ring_depth; ++i) {
+		op = (q->ring_addr + i)->req.op_addr;
+		acc200_print_op(op, q->op_type, i);
+	}
  	/* ignore all operations in flight and clear counters */
  	q->sw_ring_tail = q->sw_ring_head;
  	q->aq_enqueued = 0;
@@ -605,6 +640,43 @@
  	struct acc_device *d = dev->data->dev_private;
  	int i;
  	static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
+		{
+			.type   = RTE_BBDEV_OP_LDPC_ENC,
+			.cap.ldpc_enc = {
+				.capability_flags =
+					RTE_BBDEV_LDPC_RATE_MATCH |
+					RTE_BBDEV_LDPC_CRC_24B_ATTACH |
+					RTE_BBDEV_LDPC_INTERLEAVER_BYPASS,
+				.num_buffers_src =
+						RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+				.num_buffers_dst =
+						RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+			}
+		},
+		{
+			.type   = RTE_BBDEV_OP_LDPC_DEC,
+			.cap.ldpc_dec = {
+			.capability_flags =
+				RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK |
+				RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP |
+				RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK |
+				RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK |
+				RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE |
+				RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE |
+				RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE |
+				RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS |
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER |
+				RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION |
+				RTE_BBDEV_LDPC_LLR_COMPRESSION,
+			.llr_size = 8,
+			.llr_decimals = 1,
+			.num_buffers_src =
+					RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+			.num_buffers_hard_out =
+					RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+			.num_buffers_soft_out = 0,
+			}
+		},
  		RTE_BBDEV_END_OF_CAPABILITIES_LIST()
  	};
 
@@ -621,13 +693,15 @@
  	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;
  	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = 0;
  	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = d->acc_conf.q_ul_5g.num_aqs_per_groups *
+			d->acc_conf.q_ul_5g.num_qgroups;
+	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_aqs_per_groups *
+			d->acc_conf.q_dl_5g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
  	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 0;
  	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d->acc_conf.q_ul_5g.num_qgroups;
+	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0;
  	dev_info->max_num_queues = 0;
  	for (i = RTE_BBDEV_OP_NONE; i <= RTE_BBDEV_OP_FFT; i++)
@@ -670,6 +744,1446 @@
  	{.device_id = 0},
  };
 
+/* Fill in a frame control word for LDPC decoding. */
+static inline void
+acc200_fcw_ld_fill(struct rte_bbdev_dec_op *op, struct acc_fcw_ld *fcw,
+		union acc_harq_layout_data *harq_layout)
+{
+	uint16_t harq_out_length, harq_in_length, ncb_p, k0_p, parity_offset;
+	uint32_t harq_index;
+	uint32_t l;
+
+	fcw->qm = op->ldpc_dec.q_m;
+	fcw->nfiller = op->ldpc_dec.n_filler;
+	fcw->BG = (op->ldpc_dec.basegraph - 1);
+	fcw->Zc = op->ldpc_dec.z_c;
+	fcw->ncb = op->ldpc_dec.n_cb;
+	fcw->k0 = get_k0(fcw->ncb, fcw->Zc, op->ldpc_dec.basegraph,
+			op->ldpc_dec.rv_index);
+	if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
+		fcw->rm_e = op->ldpc_dec.cb_params.e;
+	else
+		fcw->rm_e = (op->ldpc_dec.tb_params.r <
+				op->ldpc_dec.tb_params.cab) ?
+						op->ldpc_dec.tb_params.ea :
+						op->ldpc_dec.tb_params.eb;
+
+	if (unlikely(check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE) &&
+			(op->ldpc_dec.harq_combined_input.length == 0))) {
+		rte_bbdev_log(WARNING, "Null HARQ input size provided");
+		/* Disable HARQ input in that case to carry forward */
+		op->ldpc_dec.op_flags ^= RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE;
+	}
+	if (unlikely(fcw->rm_e == 0)) {
+		rte_bbdev_log(WARNING, "Null E input provided");
+		fcw->rm_e = 2;
+	}
+
+	fcw->hcin_en = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE);
+	fcw->hcout_en = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
+	fcw->crc_select = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK);
+	fcw->bypass_dec = 0;
+	fcw->bypass_intlv = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS);
+	if (op->ldpc_dec.q_m == 1) {
+		fcw->bypass_intlv = 1;
+		fcw->qm = 2;
+	}
+	fcw->hcin_decomp_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+	fcw->hcout_comp_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+	fcw->llr_pack_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_LLR_COMPRESSION);
+	harq_index = hq_index(op->ldpc_dec.harq_combined_output.offset);
+
+	if (fcw->hcin_en > 0) {
+		harq_in_length = op->ldpc_dec.harq_combined_input.length;
+		if (fcw->hcin_decomp_mode > 0)
+			harq_in_length = harq_in_length * 8 / 6;
+		harq_in_length = RTE_MIN(harq_in_length, op->ldpc_dec.n_cb
+				- op->ldpc_dec.n_filler);
+		harq_in_length = RTE_ALIGN_CEIL(harq_in_length, 64);
+		fcw->hcin_size0 = harq_in_length;
+		fcw->hcin_offset = 0;
+		fcw->hcin_size1 = 0;
+	} else {
+		fcw->hcin_size0 = 0;
+		fcw->hcin_offset = 0;
+		fcw->hcin_size1 = 0;
+	}
+
+	fcw->itmax = op->ldpc_dec.iter_max;
+	fcw->itstop = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE);
+	fcw->cnu_algo = ACC_ALGO_MSA;
+	fcw->synd_precoder = fcw->itstop;
+	/*
+	 * These are all implicitly set
+	 * fcw->synd_post = 0;
+	 * fcw->so_en = 0;
+	 * fcw->so_bypass_rm = 0;
+	 * fcw->so_bypass_intlv = 0;
+	 * fcw->dec_convllr = 0;
+	 * fcw->hcout_convllr = 0;
+	 * fcw->hcout_size1 = 0;
+	 * fcw->so_it = 0;
+	 * fcw->hcout_offset = 0;
+	 * fcw->negstop_th = 0;
+	 * fcw->negstop_it = 0;
+	 * fcw->negstop_en = 0;
+	 * fcw->gain_i = 1;
+	 * fcw->gain_h = 1;
+	 */
+	if (fcw->hcout_en > 0) {
+		parity_offset = (op->ldpc_dec.basegraph == 1 ? 20 : 8)
+			* op->ldpc_dec.z_c - op->ldpc_dec.n_filler;
+		k0_p = (fcw->k0 > parity_offset) ?
+				fcw->k0 - op->ldpc_dec.n_filler : fcw->k0;
+		ncb_p = fcw->ncb - op->ldpc_dec.n_filler;
+		l = k0_p + fcw->rm_e;
+		harq_out_length = (uint16_t) fcw->hcin_size0;
+		harq_out_length = RTE_MIN(RTE_MAX(harq_out_length, l), ncb_p);
+		harq_out_length = RTE_ALIGN_CEIL(harq_out_length, 64);
+		fcw->hcout_size0 = harq_out_length;
+		fcw->hcout_size1 = 0;
+		fcw->hcout_offset = 0;
+		harq_layout[harq_index].offset = fcw->hcout_offset;
+		harq_layout[harq_index].size0 = fcw->hcout_size0;
+	} else {
+		fcw->hcout_size0 = 0;
+		fcw->hcout_size1 = 0;
+		fcw->hcout_offset = 0;
+	}
+
+	fcw->tb_crc_select = 0;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK))
+		fcw->tb_crc_select = 2;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK))
+		fcw->tb_crc_select = 1;
+}
+
+static inline int
+acc200_dma_desc_le_fill(struct rte_bbdev_enc_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *output, uint32_t *in_offset,
+		uint32_t *out_offset, uint32_t *out_length,
+		uint32_t *mbuf_total_left, uint32_t *seg_total_left)
+{
+	int next_triplet = 1; /* FCW already done */
+	uint16_t K, in_length_in_bits, in_length_in_bytes;
+	struct rte_bbdev_op_ldpc_enc *enc = &op->ldpc_enc;
+
+	acc_header_init(desc);
+	K = (enc->basegraph == 1 ? 22 : 10) * enc->z_c;
+	in_length_in_bits = K - enc->n_filler;
+	if ((enc->op_flags & RTE_BBDEV_LDPC_CRC_24A_ATTACH) ||
+			(enc->op_flags & RTE_BBDEV_LDPC_CRC_24B_ATTACH))
+		in_length_in_bits -= 24;
+	in_length_in_bytes = in_length_in_bits >> 3;
+
+	if (unlikely((*mbuf_total_left == 0) ||
+			(*mbuf_total_left < in_length_in_bytes))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included CB sizes: mbuf len %u, cb len %u",
+				*mbuf_total_left, in_length_in_bytes);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset,
+			in_length_in_bytes,
+			seg_total_left, next_triplet,
+			check_bit(op->ldpc_enc.op_flags,
+			RTE_BBDEV_LDPC_ENC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf data length in bbdev_op: %p",
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= in_length_in_bytes;
+
+	/* Set output length */
+	/* Integer round up division by 8 */
+	*out_length = (enc->cb_params.e + 7) >> 3;
+
+	next_triplet = acc_dma_fill_blk_type(desc, output, *out_offset,
+			*out_length, next_triplet, ACC_DMA_BLKID_OUT_ENC);
+	op->ldpc_enc.output.length += *out_length;
+	*out_offset += *out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->data_ptrs[next_triplet - 1].dma_ext = 0;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
+acc200_dma_desc_ld_fill(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf **input, struct rte_mbuf *h_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,
+		uint32_t *h_out_length, uint32_t *mbuf_total_left,
+		uint32_t *seg_total_left,
+		struct acc_fcw_ld *fcw)
+{
+	struct rte_bbdev_op_ldpc_dec *dec = &op->ldpc_dec;
+	int next_triplet = 1; /* FCW already done */
+	uint32_t input_length;
+	uint16_t output_length, crc24_overlap = 0;
+	uint16_t sys_cols, K, h_p_size, h_np_size;
+	bool h_comp = check_bit(dec->op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+
+	acc_header_init(desc);
+
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP))
+		crc24_overlap = 24;
+
+	/* Compute some LDPC BG lengths */
+	input_length = fcw->rm_e;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_LLR_COMPRESSION))
+		input_length = (input_length * 3 + 3) / 4;
+	sys_cols = (dec->basegraph == 1) ? 22 : 10;
+	K = sys_cols * dec->z_c;
+	output_length = K - dec->n_filler - crc24_overlap;
+
+	if (unlikely((*mbuf_total_left == 0) ||
+			(*mbuf_total_left < input_length))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included CB sizes: mbuf len %u, cb len %u",
+				*mbuf_total_left, input_length);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input,
+			in_offset, input_length,
+			seg_total_left, next_triplet,
+			check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEC_SCATTER_GATHER));
+
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf data length in bbdev_op: %p",
+				op);
+		return -1;
+	}
+
+	if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) {
+		if (op->ldpc_dec.harq_combined_input.data == 0) {
+			rte_bbdev_log(ERR, "HARQ input is not defined");
+			return -1;
+		}
+		h_p_size = fcw->hcin_size0 + fcw->hcin_size1;
+		if (h_comp)
+			h_p_size = (h_p_size * 3 + 3) / 4;
+		if (op->ldpc_dec.harq_combined_input.data == 0) {
+			rte_bbdev_log(ERR, "HARQ input is not defined");
+			return -1;
+		}
+		acc_dma_fill_blk_type(
+				desc,
+				op->ldpc_dec.harq_combined_input.data,
+				op->ldpc_dec.harq_combined_input.offset,
+				h_p_size,
+				next_triplet,
+				ACC_DMA_BLKID_IN_HARQ);
+		next_triplet++;
+	}
+
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= input_length;
+
+	next_triplet = acc_dma_fill_blk_type(desc, h_output,
+			*h_out_offset, output_length >> 3, next_triplet,
+			ACC_DMA_BLKID_OUT_HARD);
+
+	if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) {
+		if (op->ldpc_dec.harq_combined_output.data == 0) {
+			rte_bbdev_log(ERR, "HARQ output is not defined");
+			return -1;
+		}
+
+		/* Pruned size of the HARQ */
+		h_p_size = fcw->hcout_size0 + fcw->hcout_size1;
+		/* Non-Pruned size of the HARQ */
+		h_np_size = fcw->hcout_offset > 0 ?
+				fcw->hcout_offset + fcw->hcout_size1 :
+				h_p_size;
+		if (h_comp) {
+			h_np_size = (h_np_size * 3 + 3) / 4;
+			h_p_size = (h_p_size * 3 + 3) / 4;
+		}
+		dec->harq_combined_output.length = h_np_size;
+		acc_dma_fill_blk_type(
+				desc,
+				dec->harq_combined_output.data,
+				dec->harq_combined_output.offset,
+				h_p_size,
+				next_triplet,
+				ACC_DMA_BLKID_OUT_HARQ);
+
+		next_triplet++;
+	}
+
+	*h_out_length = output_length >> 3;
+	dec->hard_output.length += *h_out_length;
+	*h_out_offset += *h_out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline void
+acc200_dma_desc_ld_update(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf *input, struct rte_mbuf *h_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,
+		uint32_t *h_out_length,
+		union acc_harq_layout_data *harq_layout)
+{
+	int next_triplet = 1; /* FCW already done */
+	desc->data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(input, *in_offset);
+	next_triplet++;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) {
+		struct rte_bbdev_op_data hi = op->ldpc_dec.harq_combined_input;
+		desc->data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(hi.data, hi.offset);
+		next_triplet++;
+	}
+
+	desc->data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(h_output, *h_out_offset);
+	*h_out_length = desc->data_ptrs[next_triplet].blen;
+	next_triplet++;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) {
+		/* Adjust based on previous operation */
+		struct rte_bbdev_dec_op *prev_op = desc->op_addr;
+		op->ldpc_dec.harq_combined_output.length =
+				prev_op->ldpc_dec.harq_combined_output.length;
+		uint32_t harq_idx = hq_index(
+				op->ldpc_dec.harq_combined_output.offset);
+		uint32_t prev_harq_idx = hq_index(
+				prev_op->ldpc_dec.harq_combined_output.offset);
+		harq_layout[harq_idx].val = harq_layout[prev_harq_idx].val;
+		struct rte_bbdev_op_data ho =
+				op->ldpc_dec.harq_combined_output;
+		desc->data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(ho.data, ho.offset);
+		next_triplet++;
+	}
+
+	op->ldpc_dec.hard_output.length += *h_out_length;
+	desc->op_addr = op;
+}
+
+/* Enqueue one encode operations for ACC200 device in CB mode
+ * multiplexed on the same descriptor
+ */
+static inline int
+enqueue_ldpc_enc_n_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ops,
+		uint16_t total_enqueued_descs, int16_t num)
+{
+	union acc_dma_desc *desc = NULL;
+	uint32_t out_length;
+	struct rte_mbuf *output_head, *output;
+	int i, next_triplet;
+	uint16_t  in_length_in_bytes;
+	struct rte_bbdev_op_ldpc_enc *enc = &ops[0]->ldpc_enc;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(ops[0], &desc->req.fcw_le, num, 0);
+
+	/** This could be done at polling */
+	acc_header_init(&desc->req);
+	desc->req.numCBs = num;
+
+	in_length_in_bytes = ops[0]->ldpc_enc.input.data->data_len;
+	out_length = (enc->cb_params.e + 7) >> 3;
+	desc->req.m2dlen = 1 + num;
+	desc->req.d2mlen = num;
+	next_triplet = 1;
+
+	for (i = 0; i < num; i++) {
+		desc->req.data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(ops[i]->ldpc_enc.input.data, 0);
+		desc->req.data_ptrs[next_triplet].blen = in_length_in_bytes;
+		next_triplet++;
+		desc->req.data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(
+				ops[i]->ldpc_enc.output.data, 0);
+		desc->req.data_ptrs[next_triplet].blen = out_length;

drivers/baseband/acc/rte_acc200_pmd.c line 1150

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		next_triplet++;
+		ops[i]->ldpc_enc.output.length = out_length;
+		output_head = output = ops[i]->ldpc_enc.output.data;
+		mbuf_append(output_head, output, out_length);
+		output->data_len = out_length;
+	}
+
+	desc->req.op_addr = ops[0];
+	/* Keep track of pointers even when multiplexed in single descriptor */
+	struct acc_ptrs *context_ptrs = q->companion_ring_addr + desc_idx;

Don't mix declarations & code.

drivers/baseband/acc/rte_acc200_pmd.c line 1160

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num; i++)
+		context_ptrs->ptr[i].op_addr = ops[i];
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+	/* One CB (one op) was successfully prepared to enqueue */

my understanding is that it is num CB, not one.

Quoted 120 lines
drivers/baseband/acc/rte_acc200_pmd.c +120 -0
+	return num;
+}
+
+/* Enqueue one encode operations for ACC200 device for a partial TB
+ * all codes blocks have same configuration multiplexed on the same descriptor
+ */
+static inline void
+enqueue_ldpc_enc_part_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_descs, int16_t num_cbs, uint32_t e,
+		uint16_t in_len_B, uint32_t out_len_B, uint32_t *in_offset,
+		uint32_t *out_offset)
+{
+
+	union acc_dma_desc *desc = NULL;
+	struct rte_mbuf *output_head, *output;
+	int i, next_triplet;
+	struct rte_bbdev_op_ldpc_enc *enc = &op->ldpc_enc;
+
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(op, &desc->req.fcw_le, num_cbs, e);
+
+	/** This could be done at polling */
+	acc_header_init(&desc->req);
+	desc->req.numCBs = num_cbs;
+
+	desc->req.m2dlen = 1 + num_cbs;
+	desc->req.d2mlen = num_cbs;
+	next_triplet = 1;
+
+	for (i = 0; i < num_cbs; i++) {
+		desc->req.data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(enc->input.data,
+					*in_offset);
+		*in_offset += in_len_B;
+		desc->req.data_ptrs[next_triplet].blen = in_len_B;
+		next_triplet++;
+		desc->req.data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(
+						enc->output.data, *out_offset);
+		*out_offset += out_len_B;
+		desc->req.data_ptrs[next_triplet].blen = out_len_B;
+		next_triplet++;
+		enc->output.length += out_len_B;
+		output_head = output = enc->output.data;
+		mbuf_append(output_head, output, out_len_B);
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+}
+
+/* Enqueue one encode operations for ACC200 device in CB mode */
+static inline int
+enqueue_ldpc_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(op, &desc->req.fcw_le, 1, 0);
+
+	input = op->ldpc_enc.input.data;
+	output_head = output = op->ldpc_enc.output.data;
+	in_offset = op->ldpc_enc.input.offset;
+	out_offset = op->ldpc_enc.output.offset;
+	out_length = 0;
+	mbuf_total_left = op->ldpc_enc.input.length;
+	seg_total_left = rte_pktmbuf_data_len(op->ldpc_enc.input.data)
+			- in_offset;
+
+	ret = acc200_dma_desc_le_fill(op, &desc->req, &input, output,
+			&in_offset, &out_offset, &out_length, &mbuf_total_left,
+			&seg_total_left);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	mbuf_append(output_head, output, out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+/* Enqueue one encode operations for ACC200 device in TB mode.
+ * returns the number of descs used
+ */
+static inline int
+enqueue_ldpc_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
+		uint16_t enq_descs, uint8_t cbs_in_tb)
+{
+	uint8_t num_a, num_b;
+	uint16_t desc_idx;
+	uint8_t r = op->ldpc_enc.tb_params.r;
+	uint8_t cab =  op->ldpc_enc.tb_params.cab;
+	union acc_dma_desc *desc;
+	uint16_t init_enq_descs = enq_descs;
+	uint16_t input_len_B = ((op->ldpc_enc.basegraph == 1 ? 22 : 10) *
+			op->ldpc_enc.z_c) >> 3;
+	if (check_bit(op->ldpc_enc.op_flags, RTE_BBDEV_LDPC_CRC_24B_ATTACH))

drivers/baseband/acc/rte_acc200_pmd.c line 1290

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		input_len_B -= 3;
+
+	if (r < cab) {
+		num_a = cab - r;
+		num_b = cbs_in_tb - cab;
+	} else {
+		num_a = 0;
+		num_b = cbs_in_tb - r;
+	}
+	uint32_t in_offset = 0, out_offset = 0;

Don't mix declarations & code.

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+
+	while (num_a > 0) {
+		uint32_t e = op->ldpc_enc.tb_params.ea;
+		uint32_t out_len_B = (e + 7) >> 3;
+		uint8_t enq = RTE_MIN(num_a, ACC_MUX_5GDL_DESC);
+		num_a -= enq;
+		enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e, input_len_B,
+				out_len_B, &in_offset, &out_offset);
+		enq_descs++;
+	}
+	while (num_b > 0) {

drivers/baseband/acc/rte_acc200_pmd.c line 1311

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		uint32_t e = op->ldpc_enc.tb_params.eb;
+		uint32_t out_len_B = (e + 7) >> 3;
+		uint8_t enq = RTE_MIN(num_b, ACC_MUX_5GDL_DESC);
+		num_b -= enq;
+		enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e, input_len_B,
+				out_len_B, &in_offset, &out_offset);
+		enq_descs++;
+	}
+
+	uint16_t return_descs = enq_descs - init_enq_descs;

Don't mix declarations & code.

Quoted 15 lines
drivers/baseband/acc/rte_acc200_pmd.c +15 -0
+	/* Keep total number of CBs in first TB */
+	desc_idx = ((q->sw_ring_head + init_enq_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	desc->req.cbs_in_tb = return_descs; /** Actual number of descriptors */
+	desc->req.op_addr = op;
+
+	/* Set SDone on last CB descriptor for TB mode. */
+	desc_idx = ((q->sw_ring_head + enq_descs - 1)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+	desc->req.op_addr = op;
+	return return_descs;

drivers/baseband/acc/rte_acc200_pmd.c line 1336

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+}
+
+/** Enqueue one decode operations for ACC200 device in CB mode */
+static inline int
+enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
+		uint16_t total_enqueued_cbs, bool same_op)
+{
+	int ret, hq_len;
+	if (op->ldpc_dec.cb_params.e == 0)
+		return -EINVAL;

Don't mix declarations & code.

drivers/baseband/acc/rte_acc200_pmd.c line 1342

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	union acc_dma_desc *desc;
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	struct rte_mbuf *input, *h_output_head, *h_output;

Don't mix declarations & code.

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+	uint32_t in_offset, h_out_offset, mbuf_total_left, h_out_length = 0;
+	input = op->ldpc_dec.input.data;
+	h_output_head = h_output = op->ldpc_dec.hard_output.data;
+	in_offset = op->ldpc_dec.input.offset;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+	h_out_offset = op->ldpc_dec.hard_output.offset;
+	mbuf_total_left = op->ldpc_dec.input.length;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(input == NULL)) {
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif
+	union acc_harq_layout_data *harq_layout = q->d->harq_layout;
 

Don't mix declarations & code.

Quoted 191 lines
drivers/baseband/acc/rte_acc200_pmd.c +191 -0
+	if (same_op) {
+		union acc_dma_desc *prev_desc;
+		desc_idx = ((q->sw_ring_head + total_enqueued_cbs - 1)
+				& q->sw_ring_wrap_mask);
+		prev_desc = q->ring_addr + desc_idx;
+		uint8_t *prev_ptr = (uint8_t *) prev_desc;
+		uint8_t *new_ptr = (uint8_t *) desc;
+		/* Copy first 4 words and BDESCs */
+		rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
+		rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0,
+				prev_ptr + ACC_5GUL_OFFSET_0,
+				ACC_5GUL_SIZE_1);
+		desc->req.op_addr = prev_desc->req.op_addr;
+		/* Copy FCW */
+		rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
+				prev_ptr + ACC_DESC_FCW_OFFSET,
+				ACC_FCW_LD_BLEN);
+		acc200_dma_desc_ld_update(op, &desc->req, input, h_output,
+				&in_offset, &h_out_offset,
+				&h_out_length, harq_layout);
+	} else {
+		struct acc_fcw_ld *fcw;
+		uint32_t seg_total_left;
+		fcw = &desc->req.fcw_ld;
+		acc200_fcw_ld_fill(op, fcw, harq_layout);
+
+		/* Special handling when using mbuf or not */
+		if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))
+			seg_total_left = rte_pktmbuf_data_len(input)
+					- in_offset;
+		else
+			seg_total_left = fcw->rm_e;
+
+		ret = acc200_dma_desc_ld_fill(op, &desc->req, &input, h_output,
+				&in_offset, &h_out_offset,
+				&h_out_length, &mbuf_total_left,
+				&seg_total_left, fcw);
+		if (unlikely(ret < 0))
+			return ret;
+	}
+
+	/* Hard output */
+	mbuf_append(h_output_head, h_output, h_out_length);
+	if (op->ldpc_dec.harq_combined_output.length > 0) {
+		/* Push the HARQ output into host memory */
+		struct rte_mbuf *hq_output_head, *hq_output;
+		hq_output_head = op->ldpc_dec.harq_combined_output.data;
+		hq_output = op->ldpc_dec.harq_combined_output.data;
+		hq_len = op->ldpc_dec.harq_combined_output.length;
+		if (unlikely(!mbuf_append(hq_output_head, hq_output,
+				hq_len))) {
+			rte_bbdev_log(ERR, "HARQ output mbuf issue %d %d\n",
+					hq_output->buf_len,
+					hq_len);
+			return -1;
+		}
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
+			sizeof(desc->req.fcw_ld) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+
+/* Enqueue one decode operations for ACC200 device in TB mode */
+static inline int
+enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb)
+{
+	union acc_dma_desc *desc = NULL;
+	union acc_dma_desc *desc_first = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, h_out_offset,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output;
+	uint16_t current_enqueued_cbs = 0;
+	uint16_t sys_cols, trail_len = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	desc_first = desc;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	union acc_harq_layout_data *harq_layout = q->d->harq_layout;
+	acc200_fcw_ld_fill(op, &desc->req.fcw_ld, harq_layout);
+
+	input = op->ldpc_dec.input.data;
+	h_output_head = h_output = op->ldpc_dec.hard_output.data;
+	in_offset = op->ldpc_dec.input.offset;
+	h_out_offset = op->ldpc_dec.hard_output.offset;
+	h_out_length = 0;
+	mbuf_total_left = op->ldpc_dec.input.length;
+	c = op->ldpc_dec.tb_params.c;
+	r = op->ldpc_dec.tb_params.r;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) {
+		sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10;
+		trail_len = sys_cols * op->ldpc_dec.z_c -
+				op->ldpc_dec.n_filler - 24;
+	}
+
+	while (mbuf_total_left > 0 && r < c) {
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))
+			seg_total_left = rte_pktmbuf_data_len(input)
+					- in_offset;
+		else
+			seg_total_left = op->ldpc_dec.input.length;
+		/* Set up DMA descriptor */
+		desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+				& q->sw_ring_wrap_mask);
+		desc = q->ring_addr + desc_idx;
+		fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +
+				fcw_offset;
+		desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN;
+		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
+				ACC_FCW_LD_BLEN);
+		desc->req.fcw_ld.tb_trailer_size = (c - r - 1) * trail_len;
+
+		ret = acc200_dma_desc_ld_fill(op, &desc->req, &input,
+				h_output, &in_offset, &h_out_offset,
+				&h_out_length,
+				&mbuf_total_left, &seg_total_left,
+				&desc->req.fcw_ld);
+
+		if (unlikely(ret < 0))
+			return ret;
+
+		/* Hard output */
+		mbuf_append(h_output_head, h_output, h_out_length);
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_td,
+				sizeof(desc->req.fcw_td) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER)
+				&& (seg_total_left == 0)) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			h_output = h_output->next;
+			h_out_offset = 0;
+		}
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+	/* Set SDone on last CB descriptor for TB mode */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
+/** Enqueue encode operations for ACC200 device in CB mode. */
+static inline uint16_t
+acc200_enqueue_ldpc_enc_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i = 0;
+	union acc_dma_desc *desc;
+	int ret, desc_idx = 0;
+	int16_t enq, left = num;
+
+	while (left > 0) {
+		if (unlikely(avail < 1)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail--;
+		enq = RTE_MIN(left, ACC_MUX_5GDL_DESC);
+		enq = check_mux(&ops[i], enq);

drivers/baseband/acc/rte_acc200_pmd.c line 1557

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		if (enq > 1) {
+			ret = enqueue_ldpc_enc_n_op_cb(q, &ops[i],
+					desc_idx, enq);
+			if (ret < 0) {
+				acc_enqueue_invalid(q_data);
+				break;
+			}
+			i += enq;
+		} else {
+			ret = enqueue_ldpc_enc_one_op_cb(q, ops[i], desc_idx);

Looking at the code of enqueue_ldpc_enc_one_op_cb and enqueue_ldpc_enc_n_op_cb, there should not be much performance difference by only using enqueue_ldpc_enc_n_op_cb even for single enc.

It even looks like enqueue_ldpc_enc_one_op_cb is heavier, could you explain the difference?

It would make maintainance easier to have a single function.

Quoted 79 lines
drivers/baseband/acc/rte_acc200_pmd.c +79 -0
+			if (ret < 0) {
+				acc_enqueue_invalid(q_data);
+				break;
+			}
+			i++;
+		}
+		desc_idx++;
+		left = num - i;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + desc_idx - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, desc_idx, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}
+
+/* Enqueue LDPC encode operations for ACC200 device in TB mode. */
+static uint16_t
+acc200_enqueue_ldpc_enc_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_descs = 0;
+	uint8_t cbs_in_tb;
+	int descs_used;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_ldpc_enc(&ops[i]->ldpc_enc);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+
+		descs_used = enqueue_ldpc_enc_one_op_tb(q, ops[i],
+				enqueued_descs, cbs_in_tb);
+		if (descs_used < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_descs += descs_used;
+		avail -= descs_used;
+	}
+	if (unlikely(enqueued_descs == 0))
+		return 0; /* Nothing to enqueue */
+
+	acc_dma_enqueue(q, enqueued_descs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}
+
+/* Check room in AQ for the enqueues batches into Qmgr */
+static int32_t
+acc200_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t num_ops)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = q->aq_depth -
+			((q->aq_enqueued - q->aq_dequeued +
+			ACC_MAX_QUEUE_DEPTH) % ACC_MAX_QUEUE_DEPTH)
+			- (num_ops >> 7);
+	if (aq_avail <= 0)
+		acc_enqueue_queue_full(q_data);

drivers/baseband/acc/rte_acc200_pmd.c line 1646

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	return aq_avail;
+}
+
+/* Enqueue encode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = acc_ring_avail_enq(q);

Introducing new line here and after the return 0 would not hurt and improve readability.

This is a general comment for the series, which lacks consistency on this point.

Quoted 54 lines
drivers/baseband/acc/rte_acc200_pmd.c +54 -0
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->ldpc_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
+		return acc200_enqueue_ldpc_enc_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_ldpc_enc_cb(q_data, ops, num);
+}
+
+/* Enqueue decode operations for ACC200 device in TB mode */
+static uint16_t
+acc200_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_ldpc_dec(&ops[i]->ldpc_dec);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) ||
+				(cbs_in_tb == 0)))
+			break;
+		avail -= cbs_in_tb;
+
+		ret = enqueue_ldpc_dec_one_op_tb(q, ops[i],
+				enqueued_cbs, cbs_in_tb);
+		if (ret <= 0)
+			break;
+		enqueued_cbs += ret;
+	}
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+/* Enqueue decode operations for ACC200 device in CB mode */
+static uint16_t
+acc200_enqueue_ldpc_dec_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+	bool same_op = false;
+	for (i = 0; i < num; ++i) {

drivers/baseband/acc/rte_acc200_pmd.c line 1710

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		/* Check if there are available space for further processing */
+		if (unlikely(avail < 1)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= 1;
+#ifdef ACC200_DESC_OPTIMIZATION
+		if (i > 0)
+			same_op = cmp_ldpc_dec_op(&ops[i-1]);
+#endif

I think I made same comment on the series about ACC100 changes for v22.11.

Such optimizations under #ifdefs are not welcome, as either we need to multiply the number of build tests to cover all the code in CI, or we never compile test this code.

Can you ellaborate when you need it, and when you don't? Is it safe to have this optimization by default, if not why?

If not safe, then just remove it, if safe, make it the default.

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		rte_bbdev_log(INFO, "Op %d %d %d %d %d %d %d %d %d %d %d %d\n",
+			i, ops[i]->ldpc_dec.op_flags, ops[i]->ldpc_dec.rv_index,
+			ops[i]->ldpc_dec.iter_max, ops[i]->ldpc_dec.iter_count,
+			ops[i]->ldpc_dec.basegraph, ops[i]->ldpc_dec.z_c,
+			ops[i]->ldpc_dec.n_cb, ops[i]->ldpc_dec.q_m,
+			ops[i]->ldpc_dec.n_filler, ops[i]->ldpc_dec.cb_params.e,
+			same_op);
+		ret = enqueue_ldpc_dec_one_op_cb(q, ops[i], i, same_op);
+		if (ret < 0) {
+			acc_enqueue_invalid(q_data);

drivers/baseband/acc/rte_acc200_pmd.c line 1730

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			break;
+		}
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);

I think having helpers to fetch descriptors would make the code easier to read and also would ease maintainance.

Quoted 375 lines
drivers/baseband/acc/rte_acc200_pmd.c +375 -0
+
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+/* Enqueue decode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	int32_t aq_avail = acc200_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
+		return acc200_enqueue_ldpc_dec_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_ldpc_dec_cb(q_data, ops, num);
+}
+
+
+/* Dequeue one encode operations from ACC200 device in CB mode
+ */
+static inline int
+dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued,
+		uint16_t *dequeued_descs)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_enc_op *op;
+	int i;
+	int desc_idx = ((q->sw_ring_tail + *dequeued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+	rte_bbdev_log_debug("Resp. desc %p: %x", desc, rsp.val);
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	op->status |= ((rsp.input_err)
+			? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+	op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+	op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0; /*Reserved bits */
+	desc->rsp.add_info_1 = 0; /*Reserved bits */
+
+	ref_op[0] = op;
+	struct acc_ptrs *context_ptrs = q->companion_ring_addr + desc_idx;
+	for (i = 1 ; i < desc->req.numCBs; i++)
+		ref_op[i] = context_ptrs->ptr[i].op_addr;
+
+	/* One op was successfully dequeued */
+	(*dequeued_descs)++;
+	*dequeued_ops += desc->req.numCBs;
+	return desc->req.numCBs;
+}
+
+/* Dequeue one LDPC encode operations from ACC200 device in TB mode
+ * That operation may cover multiple descriptors
+ */
+static inline int
+dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued,
+		uint16_t *dequeued_descs)
+{
+	union acc_dma_desc *desc, *last_desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_enc_op *op;
+	uint8_t i = 0;
+	uint16_t current_dequeued_descs = 0, descs_in_tb;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + *dequeued_descs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	/* Get number of CBs in dequeued TB */
+	descs_in_tb = desc->req.cbs_in_tb;
+	/* Get last CB */
+	last_desc = q->ring_addr + ((q->sw_ring_tail
+			+ *dequeued_descs + descs_in_tb - 1)
+			& q->sw_ring_wrap_mask);
+	/* Check if last CB in TB is ready to dequeue (and thus
+	 * the whole TB) - checking sdone bit. If not return.
+	 */
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)last_desc,
+			__ATOMIC_RELAXED);
+	if (!(atom_desc.rsp.val & ACC_SDONE))
+		return -1;
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	while (i < descs_in_tb) {
+		desc = q->ring_addr + ((q->sw_ring_tail
+				+ *dequeued_descs)
+				& q->sw_ring_wrap_mask);
+		atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+				__ATOMIC_RELAXED);
+		rsp.val = atom_desc.rsp.val;
+		rte_bbdev_log_debug("Resp. desc %p: %x", desc,
+				rsp.val);
+
+		op->status |= ((rsp.input_err)
+				? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+		op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+		op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+
+		if (desc->req.last_desc_in_batch) {
+			(*aq_dequeued)++;
+			desc->req.last_desc_in_batch = 0;
+		}
+		desc->rsp.val = ACC_DMA_DESC_TYPE;
+		desc->rsp.add_info_0 = 0;
+		desc->rsp.add_info_1 = 0;
+		(*dequeued_descs)++;
+		current_dequeued_descs++;
+		i++;
+	}
+
+	*ref_op = op;
+	(*dequeued_ops)++;
+	return current_dequeued_descs;
+}
+
+/* Dequeue one decode operation from ACC200 device in CB mode */
+static inline int
+dequeue_dec_one_op_cb(struct rte_bbdev_queue_data *q_data,
+		struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_dec_op *op;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+	rte_bbdev_log_debug("Resp. desc %p: %x\n", desc, rsp.val);
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+	op->status |= ((rsp.input_err)
+			? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+	op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+	op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+	if (op->status != 0) {
+		/* These errors are not expected */
+		q_data->queue_stats.dequeue_err_count++;
+	}
+
+	/* CRC invalid if error exists */
+	if (!op->status)
+		op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR;
+	op->turbo_dec.iter_count = (uint8_t) rsp.iter_cnt;
+	/* Check if this is the last desc in batch (Atomic Queue) */
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0;
+	desc->rsp.add_info_1 = 0;
+	*ref_op = op;
+
+	/* One CB (op) was successfully dequeued */
+	return 1;
+}
+
+/* Dequeue one decode operations from ACC200 device in CB mode */
+static inline int
+dequeue_ldpc_dec_one_op_cb(struct rte_bbdev_queue_data *q_data,
+		struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_dec_op *op;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+	rte_bbdev_log_debug("Resp. desc %p: %x %x %x\n", desc,
+			rsp.val, desc->rsp.add_info_0,
+			desc->rsp.add_info_1);
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+	op->status |= rsp.input_err << RTE_BBDEV_DATA_ERROR;
+	op->status |= rsp.dma_err << RTE_BBDEV_DRV_ERROR;
+	op->status |= rsp.fcw_err << RTE_BBDEV_DRV_ERROR;
+	if (op->status != 0)
+		q_data->queue_stats.dequeue_err_count++;
+
+	op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR;
+	if (op->ldpc_dec.hard_output.length > 0 && !rsp.synd_ok)
+		op->status |= 1 << RTE_BBDEV_SYNDROME_ERROR;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)  ||
+			check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK)) {
+		if (desc->rsp.add_info_1 != 0)
+			op->status |= 1 << RTE_BBDEV_CRC_ERROR;
+	}
+
+	op->ldpc_dec.iter_count = (uint8_t) rsp.iter_cnt;
+
+	/* Check if this is the last desc in batch (Atomic Queue) */
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0;
+	desc->rsp.add_info_1 = 0;
+
+	*ref_op = op;
+
+	/* One CB (op) was successfully dequeued */
+	return 1;
+}
+
+/* Dequeue one decode operations from ACC200 device in TB mode. */
+static inline int
+dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
+{
+	union acc_dma_desc *desc, *last_desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_dec_op *op;
+	uint8_t cbs_in_tb = 1, cb_idx = 0;
+	uint32_t tb_crc_check = 0;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Get number of CBs in dequeued TB */
+	cbs_in_tb = desc->req.cbs_in_tb;
+	/* Get last CB */
+	last_desc = q->ring_addr + ((q->sw_ring_tail
+			+ dequeued_cbs + cbs_in_tb - 1)
+			& q->sw_ring_wrap_mask);
+	/* Check if last CB in TB is ready to dequeue (and thus
+	 * the whole TB) - checking sdone bit. If not return.
+	 */
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)last_desc,
+			__ATOMIC_RELAXED);
+	if (!(atom_desc.rsp.val & ACC_SDONE))
+		return -1;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	/* Read remaining CBs if exists */
+	while (cb_idx < cbs_in_tb) {
+		desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+				& q->sw_ring_wrap_mask);
+		atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+				__ATOMIC_RELAXED);
+		rsp.val = atom_desc.rsp.val;
+		rte_bbdev_log_debug("Resp. desc %p: %x %x %x", desc,
+				rsp.val, desc->rsp.add_info_0,
+				desc->rsp.add_info_1);
+
+		op->status |= ((rsp.input_err)
+				? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+		op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+		op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK))
+			tb_crc_check ^= desc->rsp.add_info_1;
+
+		/* CRC invalid if error exists */
+		if (!op->status)
+			op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR;
+		op->turbo_dec.iter_count = RTE_MAX((uint8_t) rsp.iter_cnt,
+				op->turbo_dec.iter_count);
+
+		/* Check if this is the last desc in batch (Atomic Queue) */
+		if (desc->req.last_desc_in_batch) {
+			(*aq_dequeued)++;
+			desc->req.last_desc_in_batch = 0;
+		}
+		desc->rsp.val = ACC_DMA_DESC_TYPE;
+		desc->rsp.add_info_0 = 0;
+		desc->rsp.add_info_1 = 0;
+		dequeued_cbs++;
+		cb_idx++;
+	}
+
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) {
+		rte_bbdev_log_debug("TB-CRC Check %x\n", tb_crc_check);
+		if (tb_crc_check > 0)
+			op->status |= 1 << RTE_BBDEV_CRC_ERROR;
+	}
+
+	*ref_op = op;
+
+	return cb_idx;
+}
+
+/* Dequeue LDPC encode operations from ACC200 device. */
+static uint16_t
+acc200_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i, dequeued_ops = 0, dequeued_descs = 0;
+	int ret;

drivers/baseband/acc/rte_acc200_pmd.c line 2115

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	struct rte_bbdev_enc_op *op;
+	if (avail == 0)
+		return 0;
+	op = (q->ring_addr + (q->sw_ring_tail &
+			q->sw_ring_wrap_mask))->req.op_addr;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == NULL || q == NULL || op == NULL))
+		return 0;
+#endif
+	int cbm = op->ldpc_enc.code_block_mode;

Don't mix declarations & code.

Quoted 32 lines
drivers/baseband/acc/rte_acc200_pmd.c +32 -0
+	for (i = 0; i < avail; i++) {
+		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
+			ret = dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		else
+			ret = dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		if (ret < 0)
+			break;
+		if (dequeued_ops >= num)
+			break;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_descs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += dequeued_ops;
+
+	return dequeued_ops;
+}
+
+/* Dequeue decode operations from ACC200 device. */
+static uint16_t
+acc200_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	uint16_t dequeue_num;
+	uint32_t avail = acc_ring_avail_deq(q);

drivers/baseband/acc/rte_acc200_pmd.c line 2158

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	uint32_t aq_dequeued = 0;
+	uint16_t i;
+	uint16_t dequeued_cbs = 0;
+	struct rte_bbdev_dec_op *op;
+	int ret;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == 0 && q == NULL))
+		return 0;
+#endif

If there is a chance ops or q not to be set, this check should always be
here. If not, then just remove them. The q == NULL will anyway be catched easily since it is dereferenced below.

Quoted 42 lines
drivers/baseband/acc/rte_acc200_pmd.c +32 -0
+
+	dequeue_num = RTE_MIN(avail, num);
+
+	for (i = 0; i < dequeue_num; ++i) {
+		op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask))->req.op_addr;
+		if (op->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
+			ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs,
+					&aq_dequeued);
+		else
+			ret = dequeue_ldpc_dec_one_op_cb(
+					q_data, q, &ops[i], dequeued_cbs,
+					&aq_dequeued);
+
+		if (ret <= 0)
+			break;
+		dequeued_cbs += ret;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_cbs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += i;
+
+	return i;
+}
+
  /* Initialization Function */
  static void
  acc200_bbdev_init(struct rte_bbdev *dev, struct rte_pci_driver *drv)
@@ -677,6 +2191,10 @@
  	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
 
  	dev->dev_ops = &acc200_bbdev_ops;
+	dev->enqueue_ldpc_enc_ops = acc200_enqueue_ldpc_enc;
+	dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec;
+	dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc;
+	dev->dequeue_ldpc_dec_ops = acc200_dequeue_ldpc_dec;
 
  	((struct acc_device *) dev->data->dev_private)->pf_device =
  			!strcmp(drv->driver.name,
#25 lore raw

Re: [PATCH v4 09/14] baseband/acc: add LTE processing functions

In reply to Nic Chautru
Quoted 526 lines · Nic Chautru

Add functions and capability for 4G FEC

---
  drivers/baseband/acc/rte_acc200_pmd.c | 894 +++++++++++++++++++++++++++++++++-
  1 file changed, 874 insertions(+), 20 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +453 -4
index 1c59559..35ea0fe 100644
@@ -641,6 +641,46 @@
  	int i;
  	static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
  		{
+			.type = RTE_BBDEV_OP_TURBO_DEC,
+			.cap.turbo_dec = {
+				.capability_flags =
+					RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |
+					RTE_BBDEV_TURBO_CRC_TYPE_24B |
+					RTE_BBDEV_TURBO_EQUALIZER |
+					RTE_BBDEV_TURBO_SOFT_OUT_SATURATE |
+					RTE_BBDEV_TURBO_HALF_ITERATION_EVEN |
+					RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH |
+					RTE_BBDEV_TURBO_SOFT_OUTPUT |
+					RTE_BBDEV_TURBO_EARLY_TERMINATION |
+					RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN |
+					RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT |
+					RTE_BBDEV_TURBO_MAP_DEC |
+					RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP |
+					RTE_BBDEV_TURBO_DEC_SCATTER_GATHER,
+				.max_llr_modulus = INT8_MAX,
+				.num_buffers_src =
+						RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
+				.num_buffers_hard_out =
+						RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
+				.num_buffers_soft_out =
+						RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
+			}
+		},
+		{
+			.type = RTE_BBDEV_OP_TURBO_ENC,
+			.cap.turbo_enc = {
+				.capability_flags =
+					RTE_BBDEV_TURBO_CRC_24B_ATTACH |
+					RTE_BBDEV_TURBO_RV_INDEX_BYPASS |
+					RTE_BBDEV_TURBO_RATE_MATCH |
+					RTE_BBDEV_TURBO_ENC_SCATTER_GATHER,
+				.num_buffers_src =
+						RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
+				.num_buffers_dst =
+						RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
+			}
+		},
+		{
  			.type   = RTE_BBDEV_OP_LDPC_ENC,
  			.cap.ldpc_enc = {
  				.capability_flags =
@@ -691,15 +731,17 @@
 
  	/* Exposed number of queues */
  	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = d->acc_conf.q_ul_4g.num_aqs_per_groups *
+			d->acc_conf.q_ul_4g.num_qgroups;
+	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = d->acc_conf.q_dl_4g.num_aqs_per_groups *
+			d->acc_conf.q_dl_4g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = d->acc_conf.q_ul_5g.num_aqs_per_groups *
  			d->acc_conf.q_ul_5g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_aqs_per_groups *
  			d->acc_conf.q_dl_5g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = d->acc_conf.q_ul_4g.num_qgroups;
+	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = d->acc_conf.q_dl_4g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d->acc_conf.q_ul_5g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0;
@@ -744,6 +786,70 @@
  	{.device_id = 0},
  };
 
+/* Fill in a frame control word for turbo decoding. */
+static inline void
+acc200_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct acc_fcw_td *fcw)
+{
+	fcw->fcw_ver = 1;
+	fcw->num_maps = ACC_FCW_TD_AUTOMAP;
+	fcw->bypass_sb_deint = !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE);
+	if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
+		/* FIXME for TB block */
+		fcw->k_pos = op->turbo_dec.tb_params.k_pos;
+		fcw->k_neg = op->turbo_dec.tb_params.k_neg;
+	} else {
+		fcw->k_pos = op->turbo_dec.cb_params.k;
+		fcw->k_neg = op->turbo_dec.cb_params.k;
+	}
+	fcw->c = 1;
+	fcw->c_neg = 1;
+	if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
+		fcw->soft_output_en = 1;
+		fcw->sw_soft_out_dis = 0;
+		fcw->sw_et_cont = check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH);
+		fcw->sw_soft_out_saturation = check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_SOFT_OUT_SATURATE);
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_EQUALIZER)) {
+			fcw->bypass_teq = 0;
+			fcw->ea = op->turbo_dec.cb_params.e;
+			fcw->eb = op->turbo_dec.cb_params.e;
+			if (op->turbo_dec.rv_index == 0)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_0;
+			else if (op->turbo_dec.rv_index == 1)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_1;
+			else if (op->turbo_dec.rv_index == 2)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_2;
+			else
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_3;
+		} else {
+			fcw->bypass_teq = 1;
+			fcw->eb = 64; /* avoid undefined value */
+		}
+	} else {
+		fcw->soft_output_en = 0;
+		fcw->sw_soft_out_dis = 1;
+		fcw->bypass_teq = 0;
+	}
+
+	fcw->code_block_mode = 1; /* FIXME */
+	fcw->turbo_crc_type = check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_CRC_TYPE_24B);
+
+	fcw->ext_td_cold_reg_en = 1;
+	fcw->raw_decoder_input_on = 0;
+	fcw->max_iter = RTE_MAX((uint8_t) op->turbo_dec.iter_max, 2);
+	fcw->min_iter = 2;
+	fcw->half_iter_on = !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_HALF_ITERATION_EVEN);
+
+	fcw->early_stop_en = check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_EARLY_TERMINATION) & !fcw->soft_output_en;
+	fcw->ext_scale = 0xF;
+}
+
  /* Fill in a frame control word for LDPC decoding. */
  static inline void
  acc200_fcw_ld_fill(struct rte_bbdev_dec_op *op, struct acc_fcw_ld *fcw,
@@ -870,6 +976,89 @@
  }
 
  static inline int
+acc200_dma_desc_te_fill(struct rte_bbdev_enc_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *output, uint32_t *in_offset,
+		uint32_t *out_offset, uint32_t *out_length,
+		uint32_t *mbuf_total_left, uint32_t *seg_total_left, uint8_t r)
+{
+	int next_triplet = 1; /* FCW already done */
+	uint32_t e, ea, eb, length;
+	uint16_t k, k_neg, k_pos;
+	uint8_t cab, c_neg;
+
+	desc->word0 = ACC_DMA_DESC_TYPE;
+	desc->word1 = 0; /**< Timestamp could be disabled */
+	desc->word2 = 0;
+	desc->word3 = 0;
+	desc->numCBs = 1;
+
+	if (op->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
+		ea = op->turbo_enc.tb_params.ea;
+		eb = op->turbo_enc.tb_params.eb;
+		cab = op->turbo_enc.tb_params.cab;
+		k_neg = op->turbo_enc.tb_params.k_neg;
+		k_pos = op->turbo_enc.tb_params.k_pos;
+		c_neg = op->turbo_enc.tb_params.c_neg;
+		e = (r < cab) ? ea : eb;
+		k = (r < c_neg) ? k_neg : k_pos;
+	} else {
+		e = op->turbo_enc.cb_params.e;
+		k = op->turbo_enc.cb_params.k;
+	}
+
+	if (check_bit(op->turbo_enc.op_flags, RTE_BBDEV_TURBO_CRC_24B_ATTACH))
+		length = (k - 24) >> 3;
+	else
+		length = k >> 3;
+
+	if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < length))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included CB sizes: mbuf len %u, cb len %u",
+				*mbuf_total_left, length);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset,
+			length, seg_total_left, next_triplet,
+			check_bit(op->turbo_enc.op_flags,
+			RTE_BBDEV_TURBO_ENC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf data length in bbdev_op: %p",
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= length;
+
+	/* Set output length */
+	if (check_bit(op->turbo_enc.op_flags, RTE_BBDEV_TURBO_RATE_MATCH))
+		/* Integer round up division by 8 */
+		*out_length = (e + 7) >> 3;
+	else
+		*out_length = (k >> 3) * 3 + 2;
+
+	next_triplet = acc_dma_fill_blk_type(desc, output, *out_offset,
+			*out_length, next_triplet, ACC_DMA_BLKID_OUT_ENC);
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf data length in bbdev_op: %p",
+				op);
+		return -1;
+	}
+	op->turbo_enc.output.length += *out_length;
+	*out_offset += *out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
  acc200_dma_desc_le_fill(struct rte_bbdev_enc_op *op,
  		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
  		struct rte_mbuf *output, uint32_t *in_offset,
@@ -929,6 +1118,122 @@
  }
 
  static inline int
+acc200_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *h_output, struct rte_mbuf *s_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,
+		uint32_t *s_out_offset, uint32_t *h_out_length,
+		uint32_t *s_out_length, uint32_t *mbuf_total_left,
+		uint32_t *seg_total_left, uint8_t r)
+{
+	int next_triplet = 1; /* FCW already done */
+	uint16_t k;
+	uint16_t crc24_overlap = 0;
+	uint32_t e, kw;
+
+	desc->word0 = ACC_DMA_DESC_TYPE;
+	desc->word1 = 0; /**< Timestamp could be disabled */
+	desc->word2 = 0;
+	desc->word3 = 0;
+	desc->numCBs = 1;
+
+	if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
+		k = (r < op->turbo_dec.tb_params.c_neg)
+			? op->turbo_dec.tb_params.k_neg
+			: op->turbo_dec.tb_params.k_pos;
+		e = (r < op->turbo_dec.tb_params.cab)
+			? op->turbo_dec.tb_params.ea
+			: op->turbo_dec.tb_params.eb;
+	} else {
+		k = op->turbo_dec.cb_params.k;
+		e = op->turbo_dec.cb_params.e;
+	}
+
+	if ((op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
+		&& !check_bit(op->turbo_dec.op_flags,
+		RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
+		crc24_overlap = 24;
+
+	/* Calculates circular buffer size.
+	 * According to 3gpp 36.212 section 5.1.4.2
+	 *   Kw = 3 * Kpi,
+	 * where:
+	 *   Kpi = nCol * nRow
+	 * where nCol is 32 and nRow can be calculated from:
+	 *   D =< nCol * nRow
+	 * where D is the size of each output from turbo encoder block (k + 4).
+	 */
+	kw = RTE_ALIGN_CEIL(k + 4, 32) * 3;
+
+	if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < kw))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included CB sizes: mbuf len %u, cb len %u",
+				*mbuf_total_left, kw);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset, kw,
+			seg_total_left, next_triplet,
+			check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf data length in bbdev_op: %p",
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= kw;
+	*h_out_length = ((k - crc24_overlap) >> 3);
+	next_triplet = acc_dma_fill_blk_type(
+			desc, h_output, *h_out_offset,
+			*h_out_length, next_triplet, ACC_DMA_BLKID_OUT_HARD);
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf data length in bbdev_op: %p",
+				op);
+		return -1;
+	}
+
+	op->turbo_dec.hard_output.length += *h_out_length;
+	*h_out_offset += *h_out_length;
+
+	/* Soft output */
+	if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
+		if (op->turbo_dec.soft_output.data == 0) {
+			rte_bbdev_log(ERR, "Soft output is not defined");
+			return -1;
+		}
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_EQUALIZER))
+			*s_out_length = e;
+		else
+			*s_out_length = (k * 3) + 12;
+
+		next_triplet = acc_dma_fill_blk_type(desc, s_output,
+				*s_out_offset, *s_out_length, next_triplet,
+				ACC_DMA_BLKID_OUT_SOFT);
+		if (unlikely(next_triplet < 0)) {
+			rte_bbdev_log(ERR,
+					"Mismatch between data to process and mbuf data length in bbdev_op: %p",
+					op);
+			return -1;
+		}
+
+		op->turbo_dec.soft_output.length += *s_out_length;
+		*s_out_offset += *s_out_length;
+	}
+
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
  acc200_dma_desc_ld_fill(struct rte_bbdev_dec_op *op,
  		struct acc_dma_req_desc *desc,
  		struct rte_mbuf **input, struct rte_mbuf *h_output,
@@ -1100,6 +1405,51 @@
  	desc->op_addr = op;
  }
 
+/* Enqueue one encode operations for ACC200 device in CB mode */
+static inline int
+enqueue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_te_fill(op, &desc->req.fcw_te);
+
+	input = op->turbo_enc.input.data;
+	output_head = output = op->turbo_enc.output.data;
+	in_offset = op->turbo_enc.input.offset;
+	out_offset = op->turbo_enc.output.offset;
+	out_length = 0;
+	mbuf_total_left = op->turbo_enc.input.length;
+	seg_total_left = rte_pktmbuf_data_len(op->turbo_enc.input.data)
+			- in_offset;
+
+	ret = acc200_dma_desc_te_fill(op, &desc->req, &input, output,
+			&in_offset, &out_offset, &out_length, &mbuf_total_left,
+			&seg_total_left, 0);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	mbuf_append(output_head, output, out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_te,
+			sizeof(desc->req.fcw_te) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
  /* Enqueue one encode operations for ACC200 device in CB mode
   * multiplexed on the same descriptor
   */
@@ -1262,6 +1612,84 @@
  	return 1;
  }
 
+
+/* Enqueue one encode operations for ACC200 device in TB mode. */
+static inline int
+enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+	uint16_t current_enqueued_cbs = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	acc_fcw_te_fill(op, &desc->req.fcw_te);
+
+	input = op->turbo_enc.input.data;
+	output_head = output = op->turbo_enc.output.data;
+	in_offset = op->turbo_enc.input.offset;
+	out_offset = op->turbo_enc.output.offset;
+	out_length = 0;
+	mbuf_total_left = op->turbo_enc.input.length;
+
+	c = op->turbo_enc.tb_params.c;
+	r = op->turbo_enc.tb_params.r;
+
+	while (mbuf_total_left > 0 && r < c) {
+		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+		/* Set up DMA descriptor */
+		desc = q->ring_addr + ((q->sw_ring_head + total_enqueued_cbs)
+				& q->sw_ring_wrap_mask);
+		desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset;
+		desc->req.data_ptrs[0].blen = ACC_FCW_TE_BLEN;
+
+		ret = acc200_dma_desc_te_fill(op, &desc->req, &input, output,
+				&in_offset, &out_offset, &out_length,
+				&mbuf_total_left, &seg_total_left, r);
+		if (unlikely(ret < 0))
+			return ret;
+		mbuf_append(output_head, output, out_length);
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_te,
+				sizeof(desc->req.fcw_te) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+		if (seg_total_left == 0) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			output = output->next;
+			out_offset = 0;
+		}
+
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+
+	/* Set SDone on last CB descriptor for TB mode. */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
  /* Enqueue one encode operations for ACC200 device in TB mode.
   * returns the number of descs used
   */
@@ -1328,6 +1756,69 @@
 
  /** Enqueue one decode operations for ACC200 device in CB mode */
  static inline int
+enqueue_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, h_out_offset, s_out_offset, s_out_length,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output,
+		*s_output_head, *s_output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc200_fcw_td_fill(op, &desc->req.fcw_td);
+
+	input = op->turbo_dec.input.data;
+	h_output_head = h_output = op->turbo_dec.hard_output.data;
+	s_output_head = s_output = op->turbo_dec.soft_output.data;
+	in_offset = op->turbo_dec.input.offset;
+	h_out_offset = op->turbo_dec.hard_output.offset;
+	s_out_offset = op->turbo_dec.soft_output.offset;

drivers/baseband/acc/rte_acc200_pmd.c line 1789

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	h_out_length = s_out_length = 0;
+	mbuf_total_left = op->turbo_dec.input.length;
+	seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(input == NULL)) {
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif

It makes sense to have this check present unconditionnally. Also, putting it here is useless since rte_pktmbuf_data_len() dereference it just before. So if NULL, it will crash before being checked.

Quoted 54 lines
drivers/baseband/acc/rte_acc200_pmd.c +43 -4
+
+	/* Set up DMA descriptor */
+	desc = q->ring_addr + ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+
+	ret = acc200_dma_desc_td_fill(op, &desc->req, &input, h_output,
+			s_output, &in_offset, &h_out_offset, &s_out_offset,
+			&h_out_length, &s_out_length, &mbuf_total_left,
+			&seg_total_left, 0);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	/* Hard output */
+	mbuf_append(h_output_head, h_output, h_out_length);
+
+	/* Soft output */
+	if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT))
+		mbuf_append(s_output_head, s_output, s_out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_td,
+			sizeof(desc->req.fcw_td));
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+/** Enqueue one decode operations for ACC200 device in CB mode */
+static inline int
  enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  		uint16_t total_enqueued_cbs, bool same_op)
  {
@@ -1525,10 +2016,147 @@
  	return current_enqueued_cbs;
  }
 
-/** Enqueue encode operations for ACC200 device in CB mode. */
-static inline uint16_t
-acc200_enqueue_ldpc_enc_cb(struct rte_bbdev_queue_data *q_data,
-		struct rte_bbdev_enc_op **ops, uint16_t num)
+/* Enqueue one decode operations for ACC200 device in TB mode */
+static inline int
+enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, h_out_offset, s_out_offset, s_out_length,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output,

drivers/baseband/acc/rte_acc200_pmd.c line 2039

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		*s_output_head, *s_output;
+	uint16_t current_enqueued_cbs = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	acc200_fcw_td_fill(op, &desc->req.fcw_td);
+
+	input = op->turbo_dec.input.data;

Here you may want to check if not NULL, at least for consistency with enqueue_dec_one_op_cb()

Quoted 56 lines
drivers/baseband/acc/rte_acc200_pmd.c +56 -0
+	h_output_head = h_output = op->turbo_dec.hard_output.data;
+	s_output_head = s_output = op->turbo_dec.soft_output.data;
+	in_offset = op->turbo_dec.input.offset;
+	h_out_offset = op->turbo_dec.hard_output.offset;
+	s_out_offset = op->turbo_dec.soft_output.offset;
+	h_out_length = s_out_length = 0;
+	mbuf_total_left = op->turbo_dec.input.length;
+	c = op->turbo_dec.tb_params.c;
+	r = op->turbo_dec.tb_params.r;
+
+	while (mbuf_total_left > 0 && r < c) {
+
+		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+
+		/* Set up DMA descriptor */
+		desc = q->ring_addr + ((q->sw_ring_head + total_enqueued_cbs)
+				& q->sw_ring_wrap_mask);
+		desc->req.data_ptrs[0].address = q->ring_addr_iova + fcw_offset;
+		desc->req.data_ptrs[0].blen = ACC_FCW_TD_BLEN;
+		ret = acc200_dma_desc_td_fill(op, &desc->req, &input,
+				h_output, s_output, &in_offset, &h_out_offset,
+				&s_out_offset, &h_out_length, &s_out_length,
+				&mbuf_total_left, &seg_total_left, r);
+
+		if (unlikely(ret < 0))
+			return ret;
+
+		/* Hard output */
+		mbuf_append(h_output_head, h_output, h_out_length);
+
+		/* Soft output */
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_SOFT_OUTPUT))
+			mbuf_append(s_output_head, s_output, s_out_length);
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_td,
+				sizeof(desc->req.fcw_td) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+		if (seg_total_left == 0) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			h_output = h_output->next;
+			h_out_offset = 0;
+
+			if (check_bit(op->turbo_dec.op_flags,
+					RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
+				s_output = s_output->next;
+				s_out_offset = 0;
+			}
+		}

drivers/baseband/acc/rte_acc200_pmd.c line 2105

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif

If it can happen, then it should alway be present.

Quoted 89 lines
drivers/baseband/acc/rte_acc200_pmd.c +82 -0
+	/* Set SDone on last CB descriptor for TB mode */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
+/* Enqueue encode operations for ACC200 device in CB mode. */
+static uint16_t
+acc200_enqueue_enc_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail - 1 < 0)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= 1;
+
+		ret = enqueue_enc_one_op_cb(q, ops[i], i);
+		if (ret < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+/** Enqueue encode operations for ACC200 device in CB mode. */
+static inline uint16_t
+acc200_enqueue_ldpc_enc_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
  {
  	struct acc_queue *q = q_data->queue_private;
  	int32_t avail = acc_ring_avail_enq(q);
@@ -1583,6 +2211,45 @@
  	return i;
  }
 
+/* Enqueue encode operations for ACC200 device in TB mode. */
+static uint16_t
+acc200_enqueue_enc_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_enc(&ops[i]->turbo_enc);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= cbs_in_tb;
+
+		ret = enqueue_enc_one_op_tb(q, ops[i], enqueued_cbs, cbs_in_tb);
+		if (ret <= 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_cbs += ret;
+	}
+	if (unlikely(enqueued_cbs == 0))

drivers/baseband/acc/rte_acc200_pmd.c line 2251

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		return 0; /* Nothing to enqueue */
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_enc_tb(), it should be shared.

Quoted 68 lines
drivers/baseband/acc/rte_acc200_pmd.c +42 -11
+
  /* Enqueue LDPC encode operations for ACC200 device in TB mode. */
  static uint16_t
  acc200_enqueue_ldpc_enc_tb(struct rte_bbdev_queue_data *q_data,
@@ -1623,18 +2290,18 @@
  	return i;
  }
 
-/* Check room in AQ for the enqueues batches into Qmgr */
-static int32_t
-acc200_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t num_ops)
+/* Enqueue encode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
  {
-	struct acc_queue *q = q_data->queue_private;
-	int32_t aq_avail = q->aq_depth -
-			((q->aq_enqueued - q->aq_dequeued +
-			ACC_MAX_QUEUE_DEPTH) % ACC_MAX_QUEUE_DEPTH)
-			- (num_ops >> 7);
-	if (aq_avail <= 0)
-		acc_enqueue_queue_full(q_data);
-	return aq_avail;
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
+		return acc200_enqueue_enc_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_enc_cb(q_data, ops, num);
  }
 
  /* Enqueue encode operations for ACC200 device. */
@@ -1652,6 +2319,47 @@
  		return acc200_enqueue_ldpc_enc_cb(q_data, ops, num);
  }
 
+
+/* Enqueue decode operations for ACC200 device in CB mode */
+static uint16_t
+acc200_enqueue_dec_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail - 1 < 0))
+			break;
+		avail -= 1;
+
+		ret = enqueue_dec_one_op_cb(q, ops[i], i);
+		if (ret < 0)
+			break;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;

drivers/baseband/acc/rte_acc200_pmd.c line 2361

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_dec_cb(), it should be shared.

Quoted 35 lines
drivers/baseband/acc/rte_acc200_pmd.c +28 -0
+
  /* Enqueue decode operations for ACC200 device in TB mode */
  static uint16_t
  acc200_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data,
@@ -1740,12 +2448,64 @@
  	return i;
  }
 
+
+/* Enqueue decode operations for ACC200 device in TB mode */
+static uint16_t
+acc200_enqueue_dec_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_dec(&ops[i]->turbo_dec);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= cbs_in_tb;
+
+		ret = enqueue_dec_one_op_tb(q, ops[i], enqueued_cbs, cbs_in_tb);
+		if (ret <= 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_cbs += ret;

drivers/baseband/acc/rte_acc200_pmd.c line 2487

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	}
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_dec_tb(), it should be shared.

drivers/baseband/acc/rte_acc200_pmd.c line 2501

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+/* Enqueue decode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
+		return acc200_enqueue_dec_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_dec_cb(q_data, ops, num);
+}

Ditto

Quoted 23 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -1
  /* Enqueue decode operations for ACC200 device. */
  static uint16_t
  acc200_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
  		struct rte_bbdev_dec_op **ops, uint16_t num)
  {
-	int32_t aq_avail = acc200_aq_avail(q_data, num);
+	int32_t aq_avail = acc_aq_avail(q_data, num);
  	if (unlikely((aq_avail <= 0) || (num == 0)))
  		return 0;
  	if (ops[0]->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
@@ -2093,6 +2853,51 @@
  	return cb_idx;
  }
 
+/* Dequeue encode operations from ACC200 device. */
+static uint16_t
+acc200_dequeue_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i, dequeued_ops = 0, dequeued_descs = 0;

drivers/baseband/acc/rte_acc200_pmd.c line 2874

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	int ret;
+	struct rte_bbdev_enc_op *op;
+	if (avail == 0)
+		return 0;
+	op = (q->ring_addr + (q->sw_ring_tail &
+			q->sw_ring_wrap_mask))->req.op_addr;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == NULL || q == NULL || op == NULL))
+		return 0;
+#endif

q is dereferenced before it is checked.

drivers/baseband/acc/rte_acc200_pmd.c line 2875

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	int cbm = op->turbo_enc.code_block_mode;

Dont mix declarations & code.

Quoted 80 lines
drivers/baseband/acc/rte_acc200_pmd.c +69 -0
+	for (i = 0; i < num; i++) {
+		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
+			ret = dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		else
+			ret = dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		if (ret < 0)
+			break;
+		if (dequeued_ops >= num)
+			break;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_descs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += dequeued_ops;
+
+	return dequeued_ops;
+}
+
  /* Dequeue LDPC encode operations from ACC200 device. */
  static uint16_t
  acc200_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
@@ -2140,6 +2945,51 @@
 
  /* Dequeue decode operations from ACC200 device. */
  static uint16_t
+acc200_dequeue_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	uint16_t dequeue_num;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i;
+	uint16_t dequeued_cbs = 0;
+	struct rte_bbdev_dec_op *op;
+	int ret;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == 0 && q == NULL))
+		return 0;
+#endif
+
+	dequeue_num = (avail < num) ? avail : num;
+
+	for (i = 0; i < dequeue_num; ++i) {
+		op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask))->req.op_addr;
+		if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
+			ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs,
+					&aq_dequeued);
+		else
+			ret = dequeue_dec_one_op_cb(q_data, q, &ops[i],
+					dequeued_cbs, &aq_dequeued);
+
+		if (ret <= 0)
+			break;
+		dequeued_cbs += ret;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_cbs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += i;
+
+	return i;
+}
+
+/* Dequeue decode operations from ACC200 device. */
+static uint16_t
  acc200_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
  		struct rte_bbdev_dec_op **ops, uint16_t num)
  {

drivers/baseband/acc/rte_acc200_pmd.c line 3050

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
@@ -2191,6 +3041,10 @@
  	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
 
  	dev->dev_ops = &acc200_bbdev_ops;
+	dev->enqueue_enc_ops = acc200_enqueue_enc;
+	dev->enqueue_dec_ops = acc200_enqueue_dec;
+	dev->dequeue_enc_ops = acc200_dequeue_enc;
+	dev->dequeue_dec_ops = acc200_dequeue_dec;
  	dev->enqueue_ldpc_enc_ops = acc200_enqueue_ldpc_enc;
  	dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec;
  	dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc;

Overall, there are functions that are stricly identical to ACC100, they should be shared and not duplicated.

If at some point they need to diverge, let's have device specific ones, but only when it becomes needed.

Maxime

#29 lore raw

Re: [PATCH v4 10/14] baseband/acc: add support for FFT operations

In reply to Nic Chautru
Quoted 136 lines · Nic Chautru

Add functions and capability for FFT processing

---
  drivers/baseband/acc/rte_acc200_pmd.c | 251 +++++++++++++++++++++++++++++++++-
  1 file changed, 249 insertions(+), 2 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +101 -2
index 35ea0fe..fa23b6e 100644
@@ -717,6 +717,21 @@
  			.num_buffers_soft_out = 0,
  			}
  		},
+		{
+			.type	= RTE_BBDEV_OP_FFT,
+			.cap.fft = {
+				.capability_flags =
+						RTE_BBDEV_FFT_WINDOWING |
+						RTE_BBDEV_FFT_CS_ADJUSTMENT |
+						RTE_BBDEV_FFT_DFT_BYPASS |
+						RTE_BBDEV_FFT_IDFT_BYPASS |
+						RTE_BBDEV_FFT_WINDOWING_BYPASS,
+				.num_buffers_src =
+						RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+				.num_buffers_dst =
+						RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+			}
+		},
  		RTE_BBDEV_END_OF_CAPABILITIES_LIST()
  	};
 
@@ -739,12 +754,13 @@
  			d->acc_conf.q_ul_5g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_aqs_per_groups *
  			d->acc_conf.q_dl_5g.num_qgroups;
-	dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_FFT] = d->acc_conf.q_fft.num_aqs_per_groups *
+			d->acc_conf.q_fft.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = d->acc_conf.q_ul_4g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = d->acc_conf.q_dl_4g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d->acc_conf.q_ul_5g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d->acc_conf.q_dl_5g.num_qgroups;
-	dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_FFT] = d->acc_conf.q_fft.num_qgroups;
  	dev_info->max_num_queues = 0;
  	for (i = RTE_BBDEV_OP_NONE; i <= RTE_BBDEV_OP_FFT; i++)
  		dev_info->max_num_queues += dev_info->num_queues[i];
@@ -3034,6 +3050,235 @@
  	return i;
  }
 
+/* Fill in a frame control word for FFT processing. */
+static inline void
+acc200_fcw_fft_fill(struct rte_bbdev_fft_op *op, struct acc_fcw_fft *fcw)
+{
+	fcw->in_frame_size = op->fft.input_sequence_size;
+	fcw->leading_pad_size = op->fft.input_leading_padding;
+	fcw->out_frame_size = op->fft.output_sequence_size;
+	fcw->leading_depad_size = op->fft.output_leading_depadding;
+	fcw->cs_window_sel = op->fft.window_index[0] +
+			(op->fft.window_index[1] << 8) +
+			(op->fft.window_index[2] << 16) +
+			(op->fft.window_index[3] << 24);
+	fcw->cs_window_sel2 = op->fft.window_index[4] +
+			(op->fft.window_index[5] << 8);
+	fcw->cs_enable_bmap = op->fft.cs_bitmap;
+	fcw->num_antennas = op->fft.num_antennas_log2;
+	fcw->idft_size = op->fft.idft_log2;
+	fcw->dft_size = op->fft.dft_log2;
+	fcw->cs_offset = op->fft.cs_time_adjustment;
+	fcw->idft_shift = op->fft.idft_shift;
+	fcw->dft_shift = op->fft.dft_shift;
+	fcw->cs_multiplier = op->fft.ncs_reciprocal;
+	if (check_bit(op->fft.op_flags,
+			RTE_BBDEV_FFT_IDFT_BYPASS)) {
+		if (check_bit(op->fft.op_flags,
+				RTE_BBDEV_FFT_WINDOWING_BYPASS))
+			fcw->bypass = 2;
+		else
+			fcw->bypass = 1;
+	} else if (check_bit(op->fft.op_flags,
+			RTE_BBDEV_FFT_DFT_BYPASS))
+		fcw->bypass = 3;
+	else
+		fcw->bypass = 0;
+}
+
+static inline int
+acc200_dma_desc_fft_fill(struct rte_bbdev_fft_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf *input, struct rte_mbuf *output,
+		uint32_t *in_offset, uint32_t *out_offset)
+{
+	/* FCW already done */
+	acc_header_init(desc);
+	desc->data_ptrs[1].address =
+			rte_pktmbuf_iova_offset(input, *in_offset);
+	desc->data_ptrs[1].blen = op->fft.input_sequence_size * 4;
+	desc->data_ptrs[1].blkid = ACC_DMA_BLKID_IN;
+	desc->data_ptrs[1].last = 1;
+	desc->data_ptrs[1].dma_ext = 0;
+	desc->data_ptrs[2].address =
+			rte_pktmbuf_iova_offset(output, *out_offset);
+	desc->data_ptrs[2].blen = op->fft.output_sequence_size * 4;
+	desc->data_ptrs[2].blkid = ACC_DMA_BLKID_OUT_HARD;
+	desc->data_ptrs[2].last = 1;
+	desc->data_ptrs[2].dma_ext = 0;
+	desc->m2dlen = 2;
+	desc->d2mlen = 1;
+	desc->ib_ant_offset = op->fft.input_sequence_size;
+	desc->num_ant = op->fft.num_antennas_log2 - 3;
+	int num_cs = 0, i;
+	for (i = 0; i < 12; i++)
+		if (check_bit(op->fft.cs_bitmap, 1 << i))
+			num_cs++;
+	desc->num_cs = num_cs;
+	desc->ob_cyc_offset = op->fft.output_sequence_size;
+	desc->ob_ant_offset = op->fft.output_sequence_size * num_cs;
+	desc->op_addr = op;
+	return 0;
+}
+
+
+/** Enqueue one FFT operation for ACC200 device*/
+static inline int
+enqueue_fft_one_op(struct acc_queue *q, struct rte_bbdev_fft_op *op,
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc;
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	struct rte_mbuf *input, *output;
+	uint32_t in_offset, out_offset;

drivers/baseband/acc/rte_acc200_pmd.c line 3145

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	input = op->fft.base_input.data;
+	output = op->fft.base_output.data;
+	in_offset = op->fft.base_input.offset;
+	out_offset = op->fft.base_output.offset;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(input == NULL)) {
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif

Same comment as on previous patch, if needed just have this check by default, otherwise drop it.

drivers/baseband/acc/rte_acc200_pmd.c line 3146

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	struct acc_fcw_fft *fcw;

Don't mix declarations & code.

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	fcw = &desc->req.fcw_fft;
+	acc200_fcw_fft_fill(op, fcw);
+	acc200_dma_desc_fft_fill(op, &desc->req, input, output,
+			&in_offset, &out_offset);
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_fft,
+			sizeof(desc->req.fcw_fft));
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+	return 1;

drivers/baseband/acc/rte_acc200_pmd.c line 3166

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+}
+
+/* Enqueue decode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_fft(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_fft_op **ops, uint16_t num)
+{
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;

Don't mix declarations & code.

Quoted 88 lines
drivers/baseband/acc/rte_acc200_pmd.c +88 -0
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail < 1))
+			break;
+		avail -= 1;
+		ret = enqueue_fft_one_op(q, ops[i], i);
+		if (ret < 0)
+			break;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+
+/* Dequeue one FFT operations from ACC200 device */
+static inline int
+dequeue_fft_one_op(struct rte_bbdev_queue_data *q_data,
+		struct acc_queue *q, struct rte_bbdev_fft_op **ref_op,
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_fft_op *op;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "Resp", &desc->rsp.val,
+			sizeof(desc->rsp.val));
+#endif
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+	op->status |= rsp.input_err << RTE_BBDEV_DATA_ERROR;
+	op->status |= rsp.dma_err << RTE_BBDEV_DRV_ERROR;
+	op->status |= rsp.fcw_err << RTE_BBDEV_DRV_ERROR;
+	if (op->status != 0)
+		q_data->queue_stats.dequeue_err_count++;
+
+	/* Check if this is the last desc in batch (Atomic Queue) */
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0;
+	*ref_op = op;
+	/* One CB (op) was successfully dequeued */
+	return 1;
+}
+
+
+/* Dequeue FFT operations from ACC200 device. */
+static uint16_t
+acc200_dequeue_fft(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_fft_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	uint16_t dequeue_num, i, dequeued_cbs = 0;

drivers/baseband/acc/rte_acc200_pmd.c line 3264

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	int ret;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == 0 && q == NULL))
+		return 0;
+#endif
+
+	dequeue_num = RTE_MIN(avail, num);

num can be reused, no need to dequeue_num

Quoted 29 lines
drivers/baseband/acc/rte_acc200_pmd.c +19 -0
+
+	for (i = 0; i < dequeue_num; ++i) {
+		ret = dequeue_fft_one_op(
+				q_data, q, &ops[i], dequeued_cbs,
+				&aq_dequeued);
+		if (ret <= 0)
+			break;
+		dequeued_cbs += ret;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_cbs;
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += i;
+	return i;
+}
+
  /* Initialization Function */
  static void
  acc200_bbdev_init(struct rte_bbdev *dev, struct rte_pci_driver *drv)
@@ -3049,6 +3294,8 @@
  	dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec;
  	dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc;
  	dev->dequeue_ldpc_dec_ops = acc200_dequeue_ldpc_dec;
+	dev->enqueue_fft_ops = acc200_enqueue_fft;
+	dev->dequeue_fft_ops = acc200_dequeue_fft;
 
  	((struct acc_device *) dev->data->dev_private)->pf_device =
  			!strcmp(drv->driver.name,
#32 lore raw

Re: [PATCH v4 11/14] baseband/acc: support interrupt

In reply to Nic Chautru
Quoted 148 lines · Nic Chautru

Adding support for capability and functions for MSI/MSI-X interrupt and underlying information ring.

---
  drivers/baseband/acc/rte_acc200_pmd.c | 346 +++++++++++++++++++++++++++++++++-
  1 file changed, 344 insertions(+), 2 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +132 -0
index fa23b6e..b8b621a 100644
@@ -220,6 +220,193 @@
  			acc_conf->q_fft.aq_depth_log2);
  }
 
+/* Checks PF Info Ring to find the interrupt cause and handles it accordingly */
+static inline void
+acc200_check_ir(struct acc_device *acc200_dev)
+{
+	volatile union acc_info_ring_data *ring_data;
+	uint16_t info_ring_head = acc200_dev->info_ring_head;
+	if (acc200_dev->info_ring == NULL)
+		return;
+
+	ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head &
+			ACC_INFO_RING_MASK);
+
+	while (ring_data->valid) {
+		if ((ring_data->int_nb < ACC200_PF_INT_DMA_DL_DESC_IRQ) || (
+				ring_data->int_nb >
+				ACC200_PF_INT_DMA_DL5G_DESC_IRQ)) {
+			rte_bbdev_log(WARNING, "InfoRing: ITR:%d Info:0x%x",
+				ring_data->int_nb, ring_data->detailed_info);
+			/* Initialize Info Ring entry and move forward */
+			ring_data->val = 0;
+		}
+		info_ring_head++;
+		ring_data = acc200_dev->info_ring +
+				(info_ring_head & ACC_INFO_RING_MASK);
+	}
+}
+
+/* Checks PF Info Ring to find the interrupt cause and handles it accordingly */
+static inline void
+acc200_pf_interrupt_handler(struct rte_bbdev *dev)
+{
+	struct acc_device *acc200_dev = dev->data->dev_private;
+	volatile union acc_info_ring_data *ring_data;
+	struct acc_deq_intr_details deq_intr_det;
+
+	ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head &
+			ACC_INFO_RING_MASK);
+
+	while (ring_data->valid) {
+
+		rte_bbdev_log_debug(
+				"ACC200 PF Interrupt received, Info Ring data: 0x%x -> %d",
+				ring_data->val, ring_data->int_nb);
+
+		switch (ring_data->int_nb) {
+		case ACC200_PF_INT_DMA_DL_DESC_IRQ:
+		case ACC200_PF_INT_DMA_UL_DESC_IRQ:
+		case ACC200_PF_INT_DMA_FFT_DESC_IRQ:
+		case ACC200_PF_INT_DMA_UL5G_DESC_IRQ:
+		case ACC200_PF_INT_DMA_DL5G_DESC_IRQ:
+			deq_intr_det.queue_id = get_queue_id_from_ring_info(
+					dev->data, *ring_data);
+			if (deq_intr_det.queue_id == UINT16_MAX) {
+				rte_bbdev_log(ERR,
+						"Couldn't find queue: aq_id: %u, qg_id: %u, vf_id: %u",
+						ring_data->aq_id,
+						ring_data->qg_id,
+						ring_data->vf_id);
+				return;
+			}
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_DEQUEUE, &deq_intr_det);
+			break;
+		default:
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_ERROR, NULL);
+			break;
+		}
+
+		/* Initialize Info Ring entry and move forward */
+		ring_data->val = 0;
+		++acc200_dev->info_ring_head;
+		ring_data = acc200_dev->info_ring +
+				(acc200_dev->info_ring_head & ACC_INFO_RING_MASK);
+	}
+}
+
+/* Checks VF Info Ring to find the interrupt cause and handles it accordingly */
+static inline void
+acc200_vf_interrupt_handler(struct rte_bbdev *dev)
+{
+	struct acc_device *acc200_dev = dev->data->dev_private;
+	volatile union acc_info_ring_data *ring_data;
+	struct acc_deq_intr_details deq_intr_det;
+
+	ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head & ACC_INFO_RING_MASK);
+
+	while (ring_data->valid) {
+
+		rte_bbdev_log_debug(
+				"ACC200 VF Interrupt received, Info Ring data: 0x%x\n",
+				ring_data->val);
+
+		switch (ring_data->int_nb) {
+		case ACC200_VF_INT_DMA_DL_DESC_IRQ:
+		case ACC200_VF_INT_DMA_UL_DESC_IRQ:
+		case ACC200_VF_INT_DMA_FFT_DESC_IRQ:
+		case ACC200_VF_INT_DMA_UL5G_DESC_IRQ:
+		case ACC200_VF_INT_DMA_DL5G_DESC_IRQ:
+			/* VFs are not aware of their vf_id - it's set to 0 in
+			 * queue structures.
+			 */
+			ring_data->vf_id = 0;
+			deq_intr_det.queue_id = get_queue_id_from_ring_info(
+					dev->data, *ring_data);
+			if (deq_intr_det.queue_id == UINT16_MAX) {
+				rte_bbdev_log(ERR,
+						"Couldn't find queue: aq_id: %u, qg_id: %u",
+						ring_data->aq_id,
+						ring_data->qg_id);
+				return;
+			}
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_DEQUEUE, &deq_intr_det);
+			break;
+		default:
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_ERROR, NULL);
+			break;
+		}
+
+		/* Initialize Info Ring entry and move forward */
+		ring_data->valid = 0;
+		++acc200_dev->info_ring_head;
+		ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head
+				& ACC_INFO_RING_MASK);
+	}
+}
+
+/* Interrupt handler triggered by ACC200 dev for handling specific interrupt */
+static void
+acc200_dev_interrupt_handler(void *cb_arg)

drivers/baseband/acc/rte_acc200_pmd.c line 364

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+{
+	struct rte_bbdev *dev = cb_arg;
+	struct acc_device *acc200_dev = dev->data->dev_private;
+
+	/* Read info ring */
+	if (acc200_dev->pf_device)
+		acc200_pf_interrupt_handler(dev);
+	else
+		acc200_vf_interrupt_handler(dev);
+}

Both handlers are quite identical, it should be possible to rework differently so that more code are shared between PF and VF cases.

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+/* Allocate and setup inforing */
+static int
+allocate_info_ring(struct rte_bbdev *dev)
+{
+	struct acc_device *d = dev->data->dev_private;
+	const struct acc200_registry_addr *reg_addr;
+	rte_iova_t info_ring_iova;
+	uint32_t phys_low, phys_high;
+

drivers/baseband/acc/rte_acc200_pmd.c line 384

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	if (d->info_ring != NULL)
+		return 0; /* Already configured */
+
+	/* Choose correct registry addresses for the device type */
+	if (d->pf_device)
+		reg_addr = &pf_reg_addr;
+	else
+		reg_addr = &vf_reg_addr;
+	/* Allocate InfoRing */
+	if (d->info_ring == NULL)

This check is useless since it is already done earlier.

Quoted 94 lines
drivers/baseband/acc/rte_acc200_pmd.c +73 -0
+		d->info_ring = rte_zmalloc_socket("Info Ring",
+				ACC_INFO_RING_NUM_ENTRIES *
+				sizeof(*d->info_ring), RTE_CACHE_LINE_SIZE,
+				dev->data->socket_id);
+	if (d->info_ring == NULL) {
+		rte_bbdev_log(ERR,
+				"Failed to allocate Info Ring for %s:%u",
+				dev->device->driver->name,
+				dev->data->dev_id);
+		return -ENOMEM;
+	}
+	info_ring_iova = rte_malloc_virt2iova(d->info_ring);
+
+	/* Setup Info Ring */
+	phys_high = (uint32_t)(info_ring_iova >> 32);
+	phys_low  = (uint32_t)(info_ring_iova);
+	acc_reg_write(d, reg_addr->info_ring_hi, phys_high);
+	acc_reg_write(d, reg_addr->info_ring_lo, phys_low);
+	acc_reg_write(d, reg_addr->info_ring_en, ACC200_REG_IRQ_EN_ALL);
+	d->info_ring_head = (acc_reg_read(d, reg_addr->info_ring_ptr) &
+			0xFFF) / sizeof(union acc_info_ring_data);
+	return 0;
+}
+
+
  /* Allocate 64MB memory used for all software rings */
  static int
  acc200_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
@@ -227,6 +414,7 @@
  	uint32_t phys_low, phys_high, value;
  	struct acc_device *d = dev->data->dev_private;
  	const struct acc200_registry_addr *reg_addr;
+	int ret;
 
  	if (d->pf_device && !d->acc_conf.pf_mode_en) {
  		rte_bbdev_log(NOTICE,
@@ -327,6 +515,14 @@
  	acc_reg_write(d, reg_addr->tail_ptrs_fft_hi, phys_high);
  	acc_reg_write(d, reg_addr->tail_ptrs_fft_lo, phys_low);
 
+	ret = allocate_info_ring(dev);
+	if (ret < 0) {
+		rte_bbdev_log(ERR, "Failed to allocate info_ring for %s:%u",
+				dev->device->driver->name,
+				dev->data->dev_id);
+		/* Continue */
+	}
+
  	if (d->harq_layout == NULL)
  		d->harq_layout = rte_zmalloc_socket("HARQ Layout",
  				ACC_HARQ_LAYOUT * sizeof(*d->harq_layout),
@@ -349,17 +545,121 @@
  	return 0;
  }
 
+static int
+acc200_intr_enable(struct rte_bbdev *dev)
+{
+	int ret;
+	struct acc_device *d = dev->data->dev_private;
+	/*
+	 * MSI/MSI-X are supported
+	 * Option controlled by vfio-intr through EAL parameter
+	 */
+	if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSI) {
+
+		ret = allocate_info_ring(dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't allocate info ring for device: %s",
+					dev->data->name);
+			return ret;
+		}
+		ret = rte_intr_enable(dev->intr_handle);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't enable interrupts for device: %s",
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+		ret = rte_intr_callback_register(dev->intr_handle,
+				acc200_dev_interrupt_handler, dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't register interrupt callback for device: %s",
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+
+		return 0;
+	} else if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX) {
+

drivers/baseband/acc/rte_acc200_pmd.c line 596

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		ret = allocate_info_ring(dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't allocate info ring for device: %s",
+					dev->data->name);
+			return ret;
+		}
+
+		int i, max_queues;
+		struct acc_device *acc200_dev = dev->data->dev_private;

Don't mix declarations & code.

Quoted 179 lines
drivers/baseband/acc/rte_acc200_pmd.c +98 -2
+		if (acc200_dev->pf_device)
+			max_queues = ACC200_MAX_PF_MSIX;
+		else
+			max_queues = ACC200_MAX_VF_MSIX;
+
+		if (rte_intr_efd_enable(dev->intr_handle, max_queues)) {
+			rte_bbdev_log(ERR, "Failed to create fds for %u queues",
+					dev->data->num_queues);
+			return -1;
+		}
+
+		for (i = 0; i < max_queues; ++i) {
+			if (rte_intr_efds_index_set(dev->intr_handle, i,
+					rte_intr_fd_get(dev->intr_handle)))
+				return -rte_errno;
+		}
+
+		if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+				dev->data->num_queues)) {
+			rte_bbdev_log(ERR, "Failed to allocate %u vectors",
+					dev->data->num_queues);
+			return -ENOMEM;
+		}
+
+		ret = rte_intr_enable(dev->intr_handle);
+
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't enable interrupts for device: %s",
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+		ret = rte_intr_callback_register(dev->intr_handle,
+				acc200_dev_interrupt_handler, dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't register interrupt callback for device: %s",
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+
+		return 0;
+	}
+
+	rte_bbdev_log(ERR, "ACC200 (%s) supports only VFIO MSI/MSI-X interrupts\n",
+			dev->data->name);
+	return -ENOTSUP;
+}
+
  /* Free memory used for software rings */
  static int
  acc200_dev_close(struct rte_bbdev *dev)
  {
  	struct acc_device *d = dev->data->dev_private;
+	acc200_check_ir(d);
  	if (d->sw_rings_base != NULL) {
  		rte_free(d->tail_ptrs);
+		rte_free(d->info_ring);
  		rte_free(d->sw_rings_base);
  		rte_free(d->harq_layout);
  		d->sw_rings_base = NULL;
  		d->tail_ptrs = NULL;
+		d->info_ring = NULL;
  		d->harq_layout = NULL;
  	}
  	/* Ensure all in flight HW transactions are completed */
@@ -652,6 +952,7 @@
  					RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH |
  					RTE_BBDEV_TURBO_SOFT_OUTPUT |
  					RTE_BBDEV_TURBO_EARLY_TERMINATION |
+					RTE_BBDEV_TURBO_DEC_INTERRUPTS |
  					RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN |
  					RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT |
  					RTE_BBDEV_TURBO_MAP_DEC |
@@ -673,6 +974,7 @@
  					RTE_BBDEV_TURBO_CRC_24B_ATTACH |
  					RTE_BBDEV_TURBO_RV_INDEX_BYPASS |
  					RTE_BBDEV_TURBO_RATE_MATCH |
+					RTE_BBDEV_TURBO_ENC_INTERRUPTS |
  					RTE_BBDEV_TURBO_ENC_SCATTER_GATHER,
  				.num_buffers_src =
  						RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
@@ -686,7 +988,8 @@
  				.capability_flags =
  					RTE_BBDEV_LDPC_RATE_MATCH |
  					RTE_BBDEV_LDPC_CRC_24B_ATTACH |
-					RTE_BBDEV_LDPC_INTERLEAVER_BYPASS,
+					RTE_BBDEV_LDPC_INTERLEAVER_BYPASS |
+					RTE_BBDEV_LDPC_ENC_INTERRUPTS,
  				.num_buffers_src =
  						RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
  				.num_buffers_dst =
@@ -707,7 +1010,8 @@
  				RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS |
  				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER |
  				RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION |
-				RTE_BBDEV_LDPC_LLR_COMPRESSION,
+				RTE_BBDEV_LDPC_LLR_COMPRESSION |
+				RTE_BBDEV_LDPC_DEC_INTERRUPTS,
  			.llr_size = 8,
  			.llr_decimals = 1,
  			.num_buffers_src =
@@ -775,15 +1079,46 @@
  	dev_info->min_alignment = 1;
  	dev_info->capabilities = bbdev_capabilities;
  	dev_info->harq_buffer_size = 0;
+
+	acc200_check_ir(d);
+}
+
+static int
+acc200_queue_intr_enable(struct rte_bbdev *dev, uint16_t queue_id)
+{
+	struct acc_queue *q = dev->data->queues[queue_id].queue_private;
+
+	if (rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSI &&
+			rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSIX)
+		return -ENOTSUP;
+
+	q->irq_enable = 1;
+	return 0;
+}
+
+static int
+acc200_queue_intr_disable(struct rte_bbdev *dev, uint16_t queue_id)
+{
+	struct acc_queue *q = dev->data->queues[queue_id].queue_private;
+
+	if (rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSI &&
+			rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VFIO_MSIX)
+		return -ENOTSUP;
+
+	q->irq_enable = 0;
+	return 0;
  }
 
  static const struct rte_bbdev_ops acc200_bbdev_ops = {
  	.setup_queues = acc200_setup_queues,
+	.intr_enable = acc200_intr_enable,
  	.close = acc200_dev_close,
  	.info_get = acc200_dev_info_get,
  	.queue_setup = acc200_queue_setup,
  	.queue_release = acc200_queue_release,
  	.queue_stop = acc_queue_stop,
+	.queue_intr_enable = acc200_queue_intr_enable,
+	.queue_intr_disable = acc200_queue_intr_disable
  };
 
  /* ACC200 PCI PF address map */
@@ -2694,6 +3029,7 @@
  	if (op->status != 0) {
  		/* These errors are not expected */
  		q_data->queue_stats.dequeue_err_count++;
+		acc200_check_ir(q->d);
  	}
 
  	/* CRC invalid if error exists */
@@ -2763,6 +3099,9 @@
 
  	op->ldpc_dec.iter_count = (uint8_t) rsp.iter_cnt;
 
+	if (op->status & (1 << RTE_BBDEV_DRV_ERROR))
+		acc200_check_ir(q->d);
+
  	/* Check if this is the last desc in batch (Atomic Queue) */
  	if (desc->req.last_desc_in_batch) {
  		(*aq_dequeued)++;
@@ -3232,6 +3571,9 @@
  	if (op->status != 0)
  		q_data->queue_stats.dequeue_err_count++;
 
+	if (op->status & (1 << RTE_BBDEV_DRV_ERROR))
+		acc200_check_ir(q->d);
+
  	/* Check if this is the last desc in batch (Atomic Queue) */
  	if (desc->req.last_desc_in_batch) {
  		(*aq_dequeued)++;
Reviewed-by on v4 12/14
#35 lore raw

Re: [PATCH v4 12/14] baseband/acc: add device status and vf2pf comms

In reply to Nic Chautru
Quoted 64 lines · Nic Chautru

Add support to expose the device status seen from the host through v2pf mailbox communication.

---
  drivers/baseband/acc/rte_acc200_pmd.c | 61 +++++++++++++++++++++++++----------
  1 file changed, 44 insertions(+), 17 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +31 -17
index b8b621a..3c2931b 100644
@@ -201,23 +201,47 @@
  	rte_bbdev_log_debug(
  			"%s Config LLR SIGN IN/OUT %s %s QG %u %u %u %u %u AQ %u %u %u %u %u Len %u %u %u %u %u\n",
  			(d->pf_device) ? "PF" : "VF",
-			(acc_conf->input_pos_llr_1_bit) ? "POS" : "NEG",
-			(acc_conf->output_pos_llr_1_bit) ? "POS" : "NEG",
-			acc_conf->q_ul_4g.num_qgroups,
-			acc_conf->q_dl_4g.num_qgroups,
-			acc_conf->q_ul_5g.num_qgroups,
-			acc_conf->q_dl_5g.num_qgroups,
-			acc_conf->q_fft.num_qgroups,
-			acc_conf->q_ul_4g.num_aqs_per_groups,
-			acc_conf->q_dl_4g.num_aqs_per_groups,
-			acc_conf->q_ul_5g.num_aqs_per_groups,
-			acc_conf->q_dl_5g.num_aqs_per_groups,
-			acc_conf->q_fft.num_aqs_per_groups,
-			acc_conf->q_ul_4g.aq_depth_log2,
-			acc_conf->q_dl_4g.aq_depth_log2,
-			acc_conf->q_ul_5g.aq_depth_log2,
-			acc_conf->q_dl_5g.aq_depth_log2,
-			acc_conf->q_fft.aq_depth_log2);
+			(acc200_conf->input_pos_llr_1_bit) ? "POS" : "NEG",
+			(acc200_conf->output_pos_llr_1_bit) ? "POS" : "NEG",
+			acc200_conf->q_ul_4g.num_qgroups,
+			acc200_conf->q_dl_4g.num_qgroups,
+			acc200_conf->q_ul_5g.num_qgroups,
+			acc200_conf->q_dl_5g.num_qgroups,
+			acc200_conf->q_fft.num_qgroups,
+			acc200_conf->q_ul_4g.num_aqs_per_groups,
+			acc200_conf->q_dl_4g.num_aqs_per_groups,
+			acc200_conf->q_ul_5g.num_aqs_per_groups,
+			acc200_conf->q_dl_5g.num_aqs_per_groups,
+			acc200_conf->q_fft.num_aqs_per_groups,
+			acc200_conf->q_ul_4g.aq_depth_log2,
+			acc200_conf->q_dl_4g.aq_depth_log2,
+			acc200_conf->q_ul_5g.aq_depth_log2,
+			acc200_conf->q_dl_5g.aq_depth_log2,
+			acc200_conf->q_fft.aq_depth_log2);
+}
+
+static inline void
+acc200_vf2pf(struct acc_device *d, unsigned int payload)
+{
+	acc_reg_write(d, HWVfHiVfToPfDbellVf, payload);
+}
+
+/* Request device status information */
+static inline uint32_t
+acc200_device_status(struct rte_bbdev *dev)
+{
+	struct acc_device *d = dev->data->dev_private;
+	uint32_t reg, time_out = 0;

drivers/baseband/acc/rte_acc200_pmd.c line 244

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	if (d->pf_device)
+		return RTE_BBDEV_DEV_NOT_SUPPORTED;
+	acc200_vf2pf(d, ACC_VF2PF_STATUS_REQUEST);
+	reg = acc_reg_read(d, HWVfHiPfToVfDbellVf);
+	while ((time_out < ACC200_STATUS_TO) && (reg == RTE_BBDEV_DEV_NOSTATUS)) {
+		usleep(ACC200_STATUS_WAIT); /*< Wait or VF->PF->VF Comms */
+		reg = acc_reg_read(d, HWVfHiPfToVfDbellVf);
+		time_out++;
+	}
+	return reg;

Please add new lines for clarity.

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
  }
 
  /* Checks PF Info Ring to find the interrupt cause and handles it accordingly */
@@ -537,6 +561,7 @@
 
  	/* Mark as configured properly */
  	d->configured = true;
+	acc200_vf2pf(d, ACC_VF2PF_USING_VF);
 
  	rte_bbdev_log_debug(
  			"ACC200 (%s) configured  sw_rings = %p, sw_rings_iova = %#"

drivers/baseband/acc/rte_acc200_pmd.c line 1079

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
@@ -1047,6 +1072,8 @@
 
  	/* Read and save the populated config from ACC200 registers */
  	fetch_acc200_config(dev);
+	/* Check the status of device */
+	dev_info->device_status = acc200_device_status(dev);
 
  	/* Exposed number of queues */
  	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;

With cosmetics fixed:

Thanks,
Maxime

#38 lore raw

Re: [PATCH v4 13/14] baseband/acc: add PF configure companion function

In reply to Nic Chautru
Quoted 215 lines · Nic Chautru

Add configure function notably to configure the device from the PF within DPDK and bbdev-test (without external dependency).

---
  app/test-bbdev/test_bbdev_perf.c      |  71 ++++++
  drivers/baseband/acc/meson.build      |   2 +-
  drivers/baseband/acc/rte_acc200_cfg.h |  48 ++++
  drivers/baseband/acc/rte_acc200_pmd.c | 453 ++++++++++++++++++++++++++++++++++
  drivers/baseband/acc/version.map      |   1 +
  5 files changed, 574 insertions(+), 1 deletion(-)

create mode 100644 drivers/baseband/acc/rte_acc200_cfg.h

app/test-bbdev/test_bbdev_perf.c +71 -0
index 41c78de..ec6ee2a 100644
@@ -62,6 +62,15 @@
  #define ACC100_QMGR_INVALID_IDX -1
  #define ACC100_QMGR_RR 1
  #define ACC100_QOS_GBR 0
+#include <rte_acc200_cfg.h>
+#define ACC200PF_DRIVER_NAME   ("intel_acc200_pf")
+#define ACC200VF_DRIVER_NAME   ("intel_acc200_vf")
+#define ACC200_QMGR_NUM_AQS 16
+#define ACC200_QMGR_NUM_QGS 2
+#define ACC200_QMGR_AQ_DEPTH 5
+#define ACC200_QMGR_INVALID_IDX -1
+#define ACC200_QMGR_RR 1
+#define ACC200_QOS_GBR 0
  #endif
 
  #define OPS_CACHE_SIZE 256U
@@ -761,6 +770,68 @@ typedef int (test_case_function)(struct active_device *ad,
  				"Failed to configure ACC100 PF for bbdev %s",
  				info->dev_name);
  	}
+	if ((get_init_device() == true) &&
+		(!strcmp(info->drv.driver_name, ACC200PF_DRIVER_NAME))) {
+		struct rte_acc_conf conf;
+		unsigned int i;
+
+		printf("Configure ACC200 FEC Driver %s with default values\n",
+				info->drv.driver_name);
+
+		/* clear default configuration before initialization */
+		memset(&conf, 0, sizeof(struct rte_acc_conf));
+
+		/* Always set in PF mode for built-in configuration */
+		conf.pf_mode_en = true;
+		for (i = 0; i < RTE_ACC_NUM_VFS; ++i) {
+			conf.arb_dl_4g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_dl_4g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_dl_4g[i].round_robin_weight = ACC200_QMGR_RR;
+			conf.arb_ul_4g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_ul_4g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_ul_4g[i].round_robin_weight = ACC200_QMGR_RR;
+			conf.arb_dl_5g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_dl_5g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_dl_5g[i].round_robin_weight = ACC200_QMGR_RR;
+			conf.arb_ul_5g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_ul_5g[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_ul_5g[i].round_robin_weight = ACC200_QMGR_RR;
+			conf.arb_fft[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_fft[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_fft[i].round_robin_weight = ACC200_QMGR_RR;
+		}
+
+		conf.input_pos_llr_1_bit = true;
+		conf.output_pos_llr_1_bit = true;
+		conf.num_vf_bundles = 1; /**< Number of VF bundles to setup */
+
+		conf.q_ul_4g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_ul_4g.first_qgroup_index = ACC200_QMGR_INVALID_IDX;
+		conf.q_ul_4g.num_aqs_per_groups = ACC200_QMGR_NUM_AQS;
+		conf.q_ul_4g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_dl_4g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_dl_4g.first_qgroup_index = ACC200_QMGR_INVALID_IDX;
+		conf.q_dl_4g.num_aqs_per_groups = ACC200_QMGR_NUM_AQS;
+		conf.q_dl_4g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_ul_5g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_ul_5g.first_qgroup_index = ACC200_QMGR_INVALID_IDX;
+		conf.q_ul_5g.num_aqs_per_groups = ACC200_QMGR_NUM_AQS;
+		conf.q_ul_5g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_dl_5g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_dl_5g.first_qgroup_index = ACC200_QMGR_INVALID_IDX;
+		conf.q_dl_5g.num_aqs_per_groups = ACC200_QMGR_NUM_AQS;
+		conf.q_dl_5g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_fft.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_fft.first_qgroup_index = ACC200_QMGR_INVALID_IDX;
+		conf.q_fft.num_aqs_per_groups = ACC200_QMGR_NUM_AQS;
+		conf.q_fft.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+
+		/* setup PF with configuration information */
+		ret = rte_acc200_configure(info->dev_name, &conf);
+		TEST_ASSERT_SUCCESS(ret,
+				"Failed to configure ACC200 PF for bbdev %s",
+				info->dev_name);
+	}
  #endif
  	/* Let's refresh this now this is configured */
  	rte_bbdev_info_get(dev_id, info);
drivers/baseband/acc/meson.build +1 -1
index 63912f0..7ae162a 100644
@@ -5,4 +5,4 @@ deps += ['bbdev', 'bus_vdev', 'ring', 'pci', 'bus_pci']
 
  sources = files('rte_acc100_pmd.c', 'rte_acc200_pmd.c')
 
-headers = files('rte_acc100_cfg.h')
+headers = files('rte_acc100_cfg.h', 'rte_acc200_cfg.h')
drivers/baseband/acc/rte_acc200_cfg.h new file +48 -0
new file mode 100644
index 0000000..8bd9b20
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#ifndef _RTE_ACC200_CFG_H_
+#define _RTE_ACC200_CFG_H_
+
+/**
+ * @file rte_acc200_cfg.h
+ *
+ * Functions for configuring ACC200 HW, exposed directly to applications.
+ * Configuration related to encoding/decoding is done through the
+ * librte_bbdev library.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "rte_acc_common_cfg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Configure a ACC200 device
+ *
+ * @param dev_name
+ *   The name of the device. This is the short form of PCI BDF, e.g. 00:01.0.
+ *   It can also be retrieved for a bbdev device from the dev_name field in the
+ *   rte_bbdev_info structure returned by rte_bbdev_info_get().
+ * @param conf
+ *   Configuration to apply to ACC200 HW.
+ *
+ * @return
+ *   Zero on success, negative value on failure.
+ */
+__rte_experimental
+int
+rte_acc200_configure(const char *dev_name, struct rte_acc_conf *conf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_ACC200_CFG_H_ */
drivers/baseband/acc/rte_acc200_pmd.c +34 -0
index 3c2931b..21d614d 100644
@@ -43,6 +43,27 @@
 
  enum {UL_4G = 0, UL_5G, DL_4G, DL_5G, FFT, NUM_ACC};
 
+/* Return the accelerator enum for a Queue Group Index */
+static inline int
+accFromQgid(int qg_idx, const struct rte_acc_conf *acc_conf)
+{
+	int accQg[ACC200_NUM_QGRPS];
+	int NumQGroupsPerFn[NUM_ACC];
+	int acc, qgIdx, qgIndex = 0;
+	for (qgIdx = 0; qgIdx < ACC200_NUM_QGRPS; qgIdx++)
+		accQg[qgIdx] = 0;
+	NumQGroupsPerFn[UL_4G] = acc_conf->q_ul_4g.num_qgroups;
+	NumQGroupsPerFn[UL_5G] = acc_conf->q_ul_5g.num_qgroups;
+	NumQGroupsPerFn[DL_4G] = acc_conf->q_dl_4g.num_qgroups;
+	NumQGroupsPerFn[DL_5G] = acc_conf->q_dl_5g.num_qgroups;
+	NumQGroupsPerFn[FFT] = acc_conf->q_fft.num_qgroups;
+	for (acc = UL_4G;  acc < NUM_ACC; acc++)
+		for (qgIdx = 0; qgIdx < NumQGroupsPerFn[acc]; qgIdx++)
+			accQg[qgIndex++] = acc;
+	acc = accQg[qg_idx];
+	return acc;
+}
+
  /* Return the queue topology for a Queue Group Index */
  static inline void
  qtopFromAcc(struct rte_acc_queue_topology **qtop, int acc_enum,
@@ -75,6 +96,30 @@
  	*qtop = p_qtop;
  }
 
+/* Return the AQ depth for a Queue Group Index */
+static inline int
+aqDepth(int qg_idx, struct rte_acc_conf *acc_conf)
+{
+	struct rte_acc_queue_topology *q_top = NULL;
+	int acc_enum = accFromQgid(qg_idx, acc_conf);
+	qtopFromAcc(&q_top, acc_enum, acc_conf);
+	if (unlikely(q_top == NULL))
+		return 0;
+	return q_top->aq_depth_log2;
+}
+
+/* Return the AQ depth for a Queue Group Index */

drivers/baseband/acc/rte_acc200_pmd.c line 121

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+static inline int
+aqNum(int qg_idx, struct rte_acc_conf *acc_conf)
+{
+	struct rte_acc_queue_topology *q_top = NULL;
+	int acc_enum = accFromQgid(qg_idx, acc_conf);
+	qtopFromAcc(&q_top, acc_enum, acc_conf);
+	if (unlikely(q_top == NULL))
+		return 0;
+	return q_top->num_aqs_per_groups;
+}

For the 3 functions above, please add new lines for clarity.

Quoted 166 lines
drivers/baseband/acc/rte_acc200_pmd.c +159 -0
+
  static void
  initQTop(struct rte_acc_conf *acc_conf)
  {
@@ -3740,3 +3785,411 @@ static int acc200_pci_probe(struct rte_pci_driver *pci_drv,
  RTE_PMD_REGISTER_PCI_TABLE(ACC200PF_DRIVER_NAME, pci_id_acc200_pf_map);
  RTE_PMD_REGISTER_PCI(ACC200VF_DRIVER_NAME, acc200_pci_vf_driver);
  RTE_PMD_REGISTER_PCI_TABLE(ACC200VF_DRIVER_NAME, pci_id_acc200_vf_map);
+
+/* Initial configuration of a ACC200 device prior to running configure() */
+int
+rte_acc200_configure(const char *dev_name, struct rte_acc_conf *conf)
+{
+	rte_bbdev_log(INFO, "rte_acc200_configure");
+	uint32_t value, address, status;
+	int qg_idx, template_idx, vf_idx, acc, i;
+	struct rte_bbdev *bbdev = rte_bbdev_get_named_dev(dev_name);
+
+	/* Compile time checks */
+	RTE_BUILD_BUG_ON(sizeof(struct acc_dma_req_desc) != 256);
+	RTE_BUILD_BUG_ON(sizeof(union acc_dma_desc) != 256);
+	RTE_BUILD_BUG_ON(sizeof(struct acc_fcw_td) != 24);
+	RTE_BUILD_BUG_ON(sizeof(struct acc_fcw_te) != 32);
+
+	if (bbdev == NULL) {
+		rte_bbdev_log(ERR,
+		"Invalid dev_name (%s), or device is not yet initialised",
+		dev_name);
+		return -ENODEV;
+	}
+	struct acc_device *d = bbdev->data->dev_private;
+
+	/* Store configuration */
+	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
+
+
+	/* Check we are already out of PG */
+	status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+	if (status > 0) {
+		if (status != ACC200_PG_MASK_0) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_0);
+			return -ENODEV;
+		}
+		/* Clock gate sections that will be un-PG */
+		acc_reg_write(d, HWPfHiClkGateHystReg, ACC200_CLK_DIS);
+		/* Un-PG required sections */
+		acc_reg_write(d, HWPfHiSectionPowerGatingReq,
+				ACC200_PG_MASK_1);
+		status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+		if (status != ACC200_PG_MASK_1) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_1);
+			return -ENODEV;
+		}
+		acc_reg_write(d, HWPfHiSectionPowerGatingReq,
+				ACC200_PG_MASK_2);
+		status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+		if (status != ACC200_PG_MASK_2) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_2);
+			return -ENODEV;
+		}
+		acc_reg_write(d, HWPfHiSectionPowerGatingReq,
+				ACC200_PG_MASK_3);
+		status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+		if (status != ACC200_PG_MASK_3) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_3);
+			return -ENODEV;
+		}
+		/* Enable clocks for all sections */
+		acc_reg_write(d, HWPfHiClkGateHystReg, ACC200_CLK_EN);
+	}
+
+	/* Explicitly releasing AXI as this may be stopped after PF FLR/BME */
+	address = HWPfDmaAxiControl;
+	value = 1;
+	acc_reg_write(d, address, value);
+
+	/* Set the fabric mode */
+	address = HWPfFabricM2iBufferReg;
+	value = ACC200_FABRIC_MODE;
+	acc_reg_write(d, address, value);
+
+	/* Set default descriptor signature */
+	address = HWPfDmaDescriptorSignatuture;
+	value = 0;
+	acc_reg_write(d, address, value);
+
+	/* Enable the Error Detection in DMA */
+	value = ACC200_CFG_DMA_ERROR;
+	address = HWPfDmaErrorDetectionEn;
+	acc_reg_write(d, address, value);
+
+	/* AXI Cache configuration */
+	value = ACC200_CFG_AXI_CACHE;
+	address = HWPfDmaAxcacheReg;
+	acc_reg_write(d, address, value);
+
+	/* Default DMA Configuration (Qmgr Enabled) */
+	address = HWPfDmaConfig0Reg;
+	value = 0;
+	acc_reg_write(d, address, value);
+	address = HWPfDmaQmanen;
+	value = 0;
+	acc_reg_write(d, address, value);
+
+	/* Default RLIM/ALEN configuration */
+	int rlim = 0;
+	int alen = 1;
+	int timestamp = 0;
+	address = HWPfDmaConfig1Reg;
+	value = (1 << 31) + (rlim << 8) + (timestamp << 6) + alen;
+	acc_reg_write(d, address, value);
+
+	/* Default FFT configuration */
+	address = HWPfFftConfig0;
+	value = ACC200_FFT_CFG_0;
+	acc_reg_write(d, address, value);
+
+	/* Configure DMA Qmanager addresses */
+	address = HWPfDmaQmgrAddrReg;
+	value = HWPfQmgrEgressQueuesTemplate;
+	acc_reg_write(d, address, value);
+
+	/* ===== Qmgr Configuration ===== */
+	/* Configuration of the AQueue Depth QMGR_GRP_0_DEPTH_LOG2 for UL */
+	int totalQgs = conf->q_ul_4g.num_qgroups +
+			conf->q_ul_5g.num_qgroups +
+			conf->q_dl_4g.num_qgroups +
+			conf->q_dl_5g.num_qgroups +
+			conf->q_fft.num_qgroups;
+	for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) {
+		address = HWPfQmgrDepthLog2Grp +
+				ACC_BYTES_IN_WORD * qg_idx;
+		value = aqDepth(qg_idx, conf);
+		acc_reg_write(d, address, value);
+		address = HWPfQmgrTholdGrp +
+				ACC_BYTES_IN_WORD * qg_idx;
+		value = (1 << 16) + (1 << (aqDepth(qg_idx, conf) - 1));
+		acc_reg_write(d, address, value);
+	}
+
+	/* Template Priority in incremental order */
+	for (template_idx = 0; template_idx < ACC_NUM_TMPL;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg0Indx + ACC_BYTES_IN_WORD * template_idx;
+		value = ACC_TMPL_PRI_0;
+		acc_reg_write(d, address, value);
+		address = HWPfQmgrGrpTmplateReg1Indx + ACC_BYTES_IN_WORD * template_idx;
+		value = ACC_TMPL_PRI_1;
+		acc_reg_write(d, address, value);
+		address = HWPfQmgrGrpTmplateReg2indx + ACC_BYTES_IN_WORD * template_idx;
+		value = ACC_TMPL_PRI_2;
+		acc_reg_write(d, address, value);
+		address = HWPfQmgrGrpTmplateReg3Indx + ACC_BYTES_IN_WORD * template_idx;
+		value = ACC_TMPL_PRI_3;
+		acc_reg_write(d, address, value);
+	}
+
+	address = HWPfQmgrGrpPriority;
+	value = ACC200_CFG_QMGR_HI_P;
+	acc_reg_write(d, address, value);
+
+	/* Template Configuration */

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv, · line 3955

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (template_idx = 0; template_idx < ACC_NUM_TMPL;
+			template_idx++) {
+		value = 0;
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* 4GUL */
+	int numQgs = conf->q_ul_4g.num_qgroups;
+	int numQqsAcc = 0;

Don't mix declarations & code, here and elsewhere in this function.

Quoted 250 lines
drivers/baseband/acc/rte_acc200_pmd.c +240 -0
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++)
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_UL_4G;
+			template_idx <= ACC200_SIG_UL_4G_LAST;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* 5GUL */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_ul_5g.num_qgroups;
+	value = 0;
+	int numEngines = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++)
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_UL_5G;
+			template_idx <= ACC200_SIG_UL_5G_LAST;
+			template_idx++) {
+		/* Check engine power-on status */
+		address = HwPfFecUl5gIbDebugReg + ACC_ENGINE_OFFSET * template_idx;
+		status = (acc_reg_read(d, address) >> 4) & 0x7;
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		if (status == 1) {
+			acc_reg_write(d, address, value);
+			numEngines++;
+		} else
+			acc_reg_write(d, address, 0);
+	}
+	printf("Number of 5GUL engines %d\n", numEngines);
+	/* 4GDL */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_dl_4g.num_qgroups;
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++)
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_DL_4G;
+			template_idx <= ACC200_SIG_DL_4G_LAST;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* 5GDL */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_dl_5g.num_qgroups;
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++)
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_DL_5G;
+			template_idx <= ACC200_SIG_DL_5G_LAST;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* FFT */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_fft.num_qgroups;
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc); qg_idx++)
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_FFT;
+			template_idx <= ACC200_SIG_FFT_LAST;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+
+	/* Queue Group Function mapping */
+	int qman_func_id[8] = {0, 2, 1, 3, 4, 0, 0, 0};
+	value = 0;
+	for (qg_idx = 0; qg_idx < ACC_NUM_QGRPS_PER_WORD; qg_idx++) {
+		acc = accFromQgid(qg_idx, conf);
+		value |= qman_func_id[acc] << (qg_idx * 4);
+	}
+	acc_reg_write(d, HWPfQmgrGrpFunction0, value);
+	value = 0;
+	for (qg_idx = 0; qg_idx < ACC_NUM_QGRPS_PER_WORD; qg_idx++) {
+		acc = accFromQgid(qg_idx + ACC_NUM_QGRPS_PER_WORD, conf);
+		value |= qman_func_id[acc] << (qg_idx * 4);
+	}
+	acc_reg_write(d, HWPfQmgrGrpFunction1, value);
+
+	/* Configuration of the Arbitration QGroup depth to 1 */
+	for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) {
+		address = HWPfQmgrArbQDepthGrp +
+				ACC_BYTES_IN_WORD * qg_idx;
+		value = 0;
+		acc_reg_write(d, address, value);
+	}
+
+	/* This pointer to ARAM (256kB) is shifted by 2 (4B per register) */
+	uint32_t aram_address = 0;
+	for (qg_idx = 0; qg_idx < totalQgs; qg_idx++) {
+		for (vf_idx = 0; vf_idx < conf->num_vf_bundles; vf_idx++) {
+			address = HWPfQmgrVfBaseAddr + vf_idx
+					* ACC_BYTES_IN_WORD + qg_idx
+					* ACC_BYTES_IN_WORD * 64;
+			value = aram_address;
+			acc_reg_write(d, address, value);
+			/* Offset ARAM Address for next memory bank
+			 * - increment of 4B
+			 */
+			aram_address += aqNum(qg_idx, conf) *
+					(1 << aqDepth(qg_idx, conf));
+		}
+	}
+
+	if (aram_address > ACC200_WORDS_IN_ARAM_SIZE) {
+		rte_bbdev_log(ERR, "ARAM Configuration not fitting %d %d\n",
+				aram_address, ACC200_WORDS_IN_ARAM_SIZE);
+		return -EINVAL;
+	}
+
+	/* Performance tuning */
+	acc_reg_write(d, HWPfFabricI2Mdma_weight, 0x0FFF);
+	acc_reg_write(d, HWPfDma4gdlIbThld, 0x1f10);
+
+	/* ==== HI Configuration ==== */
+
+	/* No Info Ring/MSI by default */
+	address = HWPfHiInfoRingIntWrEnRegPf;
+	value = 0;
+	acc_reg_write(d, address, value);
+	address = HWPfHiCfgMsiIntWrEnRegPf;
+	value = 0xFFFFFFFF;
+	acc_reg_write(d, address, value);
+	/* Prevent Block on Transmit Error */
+	address = HWPfHiBlockTransmitOnErrorEn;
+	value = 0;
+	acc_reg_write(d, address, value);
+	/* Prevents to drop MSI */
+	address = HWPfHiMsiDropEnableReg;
+	value = 0;
+	acc_reg_write(d, address, value);
+	/* Set the PF Mode register */
+	address = HWPfHiPfMode;
+	value = (conf->pf_mode_en) ? ACC_PF_VAL : 0;
+	acc_reg_write(d, address, value);
+
+	/* QoS overflow init */
+	value = 1;
+	address = HWPfQosmonAEvalOverflow0;
+	acc_reg_write(d, address, value);
+	address = HWPfQosmonBEvalOverflow0;
+	acc_reg_write(d, address, value);
+
+	/* Configure the FFT RAM LUT */
+	uint32_t fft_lut[ACC200_FFT_RAM_SIZE] = {
+	0x1FFFF, 0x1FFFF, 0x1FFFE, 0x1FFFA, 0x1FFF6, 0x1FFF1, 0x1FFEA, 0x1FFE2,
+	0x1FFD9, 0x1FFCE, 0x1FFC2, 0x1FFB5, 0x1FFA7, 0x1FF98, 0x1FF87, 0x1FF75,
+	0x1FF62, 0x1FF4E, 0x1FF38, 0x1FF21, 0x1FF09, 0x1FEF0, 0x1FED6, 0x1FEBA,
+	0x1FE9D, 0x1FE7F, 0x1FE5F, 0x1FE3F, 0x1FE1D, 0x1FDFA, 0x1FDD5, 0x1FDB0,
+	0x1FD89, 0x1FD61, 0x1FD38, 0x1FD0D, 0x1FCE1, 0x1FCB4, 0x1FC86, 0x1FC57,
+	0x1FC26, 0x1FBF4, 0x1FBC1, 0x1FB8D, 0x1FB58, 0x1FB21, 0x1FAE9, 0x1FAB0,
+	0x1FA75, 0x1FA3A, 0x1F9FD, 0x1F9BF, 0x1F980, 0x1F93F, 0x1F8FD, 0x1F8BA,
+	0x1F876, 0x1F831, 0x1F7EA, 0x1F7A3, 0x1F75A, 0x1F70F, 0x1F6C4, 0x1F677,
+	0x1F629, 0x1F5DA, 0x1F58A, 0x1F539, 0x1F4E6, 0x1F492, 0x1F43D, 0x1F3E7,
+	0x1F38F, 0x1F337, 0x1F2DD, 0x1F281, 0x1F225, 0x1F1C8, 0x1F169, 0x1F109,
+	0x1F0A8, 0x1F046, 0x1EFE2, 0x1EF7D, 0x1EF18, 0x1EEB0, 0x1EE48, 0x1EDDF,
+	0x1ED74, 0x1ED08, 0x1EC9B, 0x1EC2D, 0x1EBBE, 0x1EB4D, 0x1EADB, 0x1EA68,
+	0x1E9F4, 0x1E97F, 0x1E908, 0x1E891, 0x1E818, 0x1E79E, 0x1E722, 0x1E6A6,
+	0x1E629, 0x1E5AA, 0x1E52A, 0x1E4A9, 0x1E427, 0x1E3A3, 0x1E31F, 0x1E299,
+	0x1E212, 0x1E18A, 0x1E101, 0x1E076, 0x1DFEB, 0x1DF5E, 0x1dED0, 0x1DE41,
+	0x1DDB1, 0x1DD20, 0x1DC8D, 0x1DBFA, 0x1DB65, 0x1DACF, 0x1DA38, 0x1D9A0,
+	0x1D907, 0x1D86C, 0x1D7D1, 0x1D734, 0x1D696, 0x1D5F7, 0x1D557, 0x1D4B6,
+	0x1D413, 0x1D370, 0x1D2CB, 0x1D225, 0x1D17E, 0x1D0D6, 0x1D02D, 0x1CF83,
+	0x1CED8, 0x1CE2B, 0x1CD7E, 0x1CCCF, 0x1CC1F, 0x1CB6E, 0x1CABC, 0x1CA09,
+	0x1C955, 0x1C89F, 0x1C7E9, 0x1C731, 0x1C679, 0x1C5BF, 0x1C504, 0x1C448,
+	0x1C38B, 0x1C2CD, 0x1C20E, 0x1C14E, 0x1C08C, 0x1BFCA, 0x1BF06, 0x1BE42,
+	0x1BD7C, 0x1BCB5, 0x1BBED, 0x1BB25, 0x1BA5B, 0x1B990, 0x1B8C4, 0x1B7F6,
+	0x1B728, 0x1B659, 0x1B589, 0x1B4B7, 0x1B3E5, 0x1B311, 0x1B23D, 0x1B167,
+	0x1B091, 0x1AFB9, 0x1AEE0, 0x1AE07, 0x1AD2C, 0x1AC50, 0x1AB73, 0x1AA95,
+	0x1A9B6, 0x1A8D6, 0x1A7F6, 0x1A714, 0x1A631, 0x1A54D, 0x1A468, 0x1A382,
+	0x1A29A, 0x1A1B2, 0x1A0C9, 0x19FDF, 0x19EF4, 0x19E08, 0x19D1B, 0x19C2D,
+	0x19B3E, 0x19A4E, 0x1995D, 0x1986B, 0x19778, 0x19684, 0x1958F, 0x19499,
+	0x193A2, 0x192AA, 0x191B1, 0x190B8, 0x18FBD, 0x18EC1, 0x18DC4, 0x18CC7,
+	0x18BC8, 0x18AC8, 0x189C8, 0x188C6, 0x187C4, 0x186C1, 0x185BC, 0x184B7,
+	0x183B1, 0x182AA, 0x181A2, 0x18099, 0x17F8F, 0x17E84, 0x17D78, 0x17C6C,
+	0x17B5E, 0x17A4F, 0x17940, 0x17830, 0x1771E, 0x1760C, 0x174F9, 0x173E5,
+	0x172D1, 0x171BB, 0x170A4, 0x16F8D, 0x16E74, 0x16D5B, 0x16C41, 0x16B26,
+	0x16A0A, 0x168ED, 0x167CF, 0x166B1, 0x16592, 0x16471, 0x16350, 0x1622E,
+	0x1610B, 0x15FE8, 0x15EC3, 0x15D9E, 0x15C78, 0x15B51, 0x15A29, 0x15900,
+	0x157D7, 0x156AC, 0x15581, 0x15455, 0x15328, 0x151FB, 0x150CC, 0x14F9D,
+	0x14E6D, 0x14D3C, 0x14C0A, 0x14AD8, 0x149A4, 0x14870, 0x1473B, 0x14606,
+	0x144CF, 0x14398, 0x14260, 0x14127, 0x13FEE, 0x13EB3, 0x13D78, 0x13C3C,
+	0x13B00, 0x139C2, 0x13884, 0x13745, 0x13606, 0x134C5, 0x13384, 0x13242,
+	0x130FF, 0x12FBC, 0x12E78, 0x12D33, 0x12BEE, 0x12AA7, 0x12960, 0x12819,
+	0x126D0, 0x12587, 0x1243D, 0x122F3, 0x121A8, 0x1205C, 0x11F0F, 0x11DC2,
+	0x11C74, 0x11B25, 0x119D6, 0x11886, 0x11735, 0x115E3, 0x11491, 0x1133F,
+	0x111EB, 0x11097, 0x10F42, 0x10dED, 0x10C97, 0x10B40, 0x109E9, 0x10891,
+	0x10738, 0x105DF, 0x10485, 0x1032B, 0x101D0, 0x10074, 0x0FF18, 0x0FDBB,
+	0x0FC5D, 0x0FAFF, 0x0F9A0, 0x0F841, 0x0F6E1, 0x0F580, 0x0F41F, 0x0F2BD,
+	0x0F15B, 0x0EFF8, 0x0EE94, 0x0ED30, 0x0EBCC, 0x0EA67, 0x0E901, 0x0E79A,
+	0x0E633, 0x0E4CC, 0x0E364, 0x0E1FB, 0x0E092, 0x0DF29, 0x0DDBE, 0x0DC54,
+	0x0DAE9, 0x0D97D, 0x0D810, 0x0D6A4, 0x0D536, 0x0D3C8, 0x0D25A, 0x0D0EB,
+	0x0CF7C, 0x0CE0C, 0x0CC9C, 0x0CB2B, 0x0C9B9, 0x0C847, 0x0C6D5, 0x0C562,
+	0x0C3EF, 0x0C27B, 0x0C107, 0x0BF92, 0x0BE1D, 0x0BCA8, 0x0BB32, 0x0B9BB,
+	0x0B844, 0x0B6CD, 0x0B555, 0x0B3DD, 0x0B264, 0x0B0EB, 0x0AF71, 0x0ADF7,
+	0x0AC7D, 0x0AB02, 0x0A987, 0x0A80B, 0x0A68F, 0x0A513, 0x0A396, 0x0A219,
+	0x0A09B, 0x09F1D, 0x09D9E, 0x09C20, 0x09AA1, 0x09921, 0x097A1, 0x09621,
+	0x094A0, 0x0931F, 0x0919E, 0x0901C, 0x08E9A, 0x08D18, 0x08B95, 0x08A12,
+	0x0888F, 0x0870B, 0x08587, 0x08402, 0x0827E, 0x080F9, 0x07F73, 0x07DEE,
+	0x07C68, 0x07AE2, 0x0795B, 0x077D4, 0x0764D, 0x074C6, 0x0733E, 0x071B6,
+	0x0702E, 0x06EA6, 0x06D1D, 0x06B94, 0x06A0B, 0x06881, 0x066F7, 0x0656D,
+	0x063E3, 0x06258, 0x060CE, 0x05F43, 0x05DB7, 0x05C2C, 0x05AA0, 0x05914,
+	0x05788, 0x055FC, 0x0546F, 0x052E3, 0x05156, 0x04FC9, 0x04E3B, 0x04CAE,
+	0x04B20, 0x04992, 0x04804, 0x04676, 0x044E8, 0x04359, 0x041CB, 0x0403C,
+	0x03EAD, 0x03D1D, 0x03B8E, 0x039FF, 0x0386F, 0x036DF, 0x0354F, 0x033BF,
+	0x0322F, 0x0309F, 0x02F0F, 0x02D7E, 0x02BEE, 0x02A5D, 0x028CC, 0x0273B,
+	0x025AA, 0x02419, 0x02288, 0x020F7, 0x01F65, 0x01DD4, 0x01C43, 0x01AB1,
+	0x0191F, 0x0178E, 0x015FC, 0x0146A, 0x012D8, 0x01147, 0x00FB5, 0x00E23,
+	0x00C91, 0x00AFF, 0x0096D, 0x007DB, 0x00648, 0x004B6, 0x00324, 0x00192};
+
+	acc_reg_write(d, HWPfFftRamPageAccess, ACC200_FFT_RAM_EN + 64);
+	for (i = 0; i < ACC200_FFT_RAM_SIZE; i++)
+		acc_reg_write(d, HWPfFftRamOff + i * 4, fft_lut[i]);
+	acc_reg_write(d, HWPfFftRamPageAccess, ACC200_FFT_RAM_DIS);
+
+	/* Enabling AQueues through the Queue hierarchy*/
+	for (vf_idx = 0; vf_idx < ACC200_NUM_VFS; vf_idx++) {
+		for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) {
+			value = 0;
+			if (vf_idx < conf->num_vf_bundles &&
+					qg_idx < totalQgs)
+				value = (1 << aqNum(qg_idx, conf)) - 1;
+			address = HWPfQmgrAqEnableVf
+					+ vf_idx * ACC_BYTES_IN_WORD;
+			value += (qg_idx << 16);
+			acc_reg_write(d, address, value);
+		}
+	}
+
+	rte_bbdev_log_debug("PF Tip configuration complete for %s", dev_name);
+	return 0;
+}
drivers/baseband/acc/version.map +1 -0
index b4ff13e..27fbbe3 100644
@@ -6,4 +6,5 @@ EXPERIMENTAL {
  	global:
 
  	rte_acc10x_configure;
+	rte_acc200_configure;
  };
#42 lore raw
In reply to Nic Chautru

Hi Nicolas,

I'm done with v4 review.

Please post a v6, I don't plan to review v5 that was posted while I was in the middle of my review.

Thanks,
Maxime

Quoted 83 lines · Nic Chautru

v4: Rebase to split the first commit and change the order within
the series based on Maxime's feedback. No functional change.
v3: Merge ACC100 and ACC200 PMDs in the same directory
v2: Includes now code refactory to have common structures and code reused with the parallel ACC1XX serie PMD which can be shared moving forward.
v1: This is targeting 22.11 and includes the PMD for the
new integrated accelerator on Intel Xeon SPR-EEC.
There is a dependency on that parallel patch serie still in-flight which extends the bbdev api https://patches.dpdk.org/project/dpdk/list/?series=23894
and is required to apply that patch.

Nic Chautru (14):
baseband/acc100: remove unused registers baseband/acc100: refactor to segregate common code baseband/acc: rename directory from acc100 to acc baseband/acc: introduce PMD for ACC200 baseband/acc: add HW register definitions for ACC200 baseband/acc: add info get function for ACC200 baseband/acc: add queue configuration for ACC200 baseband/acc: add LDPC processing functions baseband/acc: add LTE processing functions baseband/acc: add support for FFT operations baseband/acc: support interrupt baseband/acc: add device status and vf2pf comms baseband/acc: add PF configure companion function baseband/acc: simplify meson dependency

  MAINTAINERS                               |    5 +-
  app/test-bbdev/meson.build                |    4 +-
  app/test-bbdev/test_bbdev_perf.c          |   81 +-
  doc/guides/bbdevs/acc200.rst              |  244 ++
  doc/guides/bbdevs/index.rst               |    1 +
  drivers/baseband/acc/acc100_pf_enum.h     |  147 +
  drivers/baseband/acc/acc100_pmd.h         |  177 +
  drivers/baseband/acc/acc100_vf_enum.h     |   73 +
  drivers/baseband/acc/acc101_pmd.h         |   40 +
  drivers/baseband/acc/acc200_pf_enum.h     |  108 +
  drivers/baseband/acc/acc200_pmd.h         |  196 ++
  drivers/baseband/acc/acc200_vf_enum.h     |   83 +
  drivers/baseband/acc/acc_common.h         | 1387 ++++++++
  drivers/baseband/acc/meson.build          |    8 +
  drivers/baseband/acc/rte_acc100_cfg.h     |   49 +
  drivers/baseband/acc/rte_acc100_pmd.c     | 4655 +++++++++++++++++++++++++
  drivers/baseband/acc/rte_acc200_cfg.h     |   48 +
  drivers/baseband/acc/rte_acc200_pmd.c     | 4195 +++++++++++++++++++++++
  drivers/baseband/acc/rte_acc_common_cfg.h |  101 +
  drivers/baseband/acc/version.map          |   10 +
  drivers/baseband/acc100/acc100_pf_enum.h  | 1086 ------
  drivers/baseband/acc100/acc100_pmd.h      |  624 ----
  drivers/baseband/acc100/acc100_vf_enum.h  |   73 -
  drivers/baseband/acc100/acc101_pmd.h      |   50 -
  drivers/baseband/acc100/meson.build       |    8 -
  drivers/baseband/acc100/rte_acc100_cfg.h  |  113 -
  drivers/baseband/acc100/rte_acc100_pmd.c  | 5288 -----------------------------
  drivers/baseband/acc100/version.map       |    9 -
  drivers/baseband/meson.build              |    2 +-
  29 files changed, 11605 insertions(+), 7260 deletions(-)

create mode 100644 doc/guides/bbdevs/acc200.rst create mode 100644 drivers/baseband/acc/acc100_pf_enum.h create mode 100644 drivers/baseband/acc/acc100_pmd.h create mode 100644 drivers/baseband/acc/acc100_vf_enum.h create mode 100644 drivers/baseband/acc/acc101_pmd.h create mode 100644 drivers/baseband/acc/acc200_pf_enum.h create mode 100644 drivers/baseband/acc/acc200_pmd.h create mode 100644 drivers/baseband/acc/acc200_vf_enum.h create mode 100644 drivers/baseband/acc/acc_common.h create mode 100644 drivers/baseband/acc/meson.build create mode 100644 drivers/baseband/acc/rte_acc100_cfg.h create mode 100644 drivers/baseband/acc/rte_acc100_pmd.c create mode 100644 drivers/baseband/acc/rte_acc200_cfg.h create mode 100644 drivers/baseband/acc/rte_acc200_pmd.c create mode 100644 drivers/baseband/acc/rte_acc_common_cfg.h create mode 100644 drivers/baseband/acc/version.map delete mode 100644 drivers/baseband/acc100/acc100_pf_enum.h delete mode 100644 drivers/baseband/acc100/acc100_pmd.h delete mode 100644 drivers/baseband/acc100/acc100_vf_enum.h delete mode 100644 drivers/baseband/acc100/acc101_pmd.h delete mode 100644 drivers/baseband/acc100/meson.build delete mode 100644 drivers/baseband/acc100/rte_acc100_cfg.h delete mode 100644 drivers/baseband/acc100/rte_acc100_pmd.c delete mode 100644 drivers/baseband/acc100/version.map

#22 lore raw

RE: [PATCH v4 08/14] baseband/acc: add LDPC processing functions

In reply to Maxime Coquelin

Hi Maxime,

Quoted 75 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 1:30 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 08/14] baseband/acc: add LDPC processing functions

Hi Nicolas,

I'm finishing reviewing this patch from v4 as I was in the middle of the review when you posted v5. Will continue the other ones on v5.

Quoted 6 lines · Nic Chautru

Adding LDPC encode and decode processing functions.

---
  drivers/baseband/acc/acc_common.h     |   84 ++
  drivers/baseband/acc/rte_acc200_pmd.c | 1526

++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
  2 files changed, 1606 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/baseband/acc/acc_common.h

Quoted 14 lines

index ae8de9e..b430b45 100644

drivers/baseband/acc/acc_common.h +7 -0
@@ -1300,4 +1300,88 @@ static inline uint32_t hq_index(uint32_t offset)
  	return 0;
  }
 
+static inline void
+acc_enqueue_status(struct rte_bbdev_queue_data *q_data,
+		enum rte_bbdev_enqueue_status status)
+{
+	q_data->enqueue_status = status;
+	q_data->queue_stats.enqueue_status_count[status]++;
+

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset) · line 1319

Quoted 10 lines
drivers/baseband/acc/acc_common.h +9 -0
+	rte_acc_log(WARNING, "Enqueue Status: %s %#"PRIx64"",
+			rte_bbdev_enqueue_status_str(status),
+			q_data-
 queue_stats.enqueue_status_count[status]);
+}
+
+static inline void
+acc_enqueue_invalid(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data,

RTE_BBDEV_ENQ_STATUS_INVALID_OP);

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 6 lines
drivers/baseband/acc/acc_common.h +6 -0
+}
+
+static inline void
+acc_enqueue_ring_full(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data,

RTE_BBDEV_ENQ_STATUS_RING_FULL);

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 6 lines
drivers/baseband/acc/acc_common.h +6 -0
+}
+
+static inline void
+acc_enqueue_queue_full(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data,

RTE_BBDEV_ENQ_STATUS_QUEUE_FULL);

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 7 lines
drivers/baseband/acc/acc_common.h +7 -0
+}
+
+/* Number of available descriptor in ring to enqueue */
+static inline uint32_t
+acc_ring_avail_enq(struct acc_queue *q)
+{
+	return (q->sw_ring_depth - 1 + q->sw_ring_tail - q->sw_ring_head) %

q->sw_ring_depth;

Quoted 13 lines
Quoted 9 lines
drivers/baseband/acc/acc_common.h +7 -0
+}
+
+/* Number of available descriptor in ring to dequeue */
+static inline uint32_t
+acc_ring_avail_deq(struct acc_queue *q)
+{
+	return (q->sw_ring_depth + q->sw_ring_head - q->sw_ring_tail) % q-

sw_ring_depth;
+}

My understanding is that the ring size is a power of 2, it that correct? If so, indead of doing a modulo operation, you could do a AND operation with the ring mask which is less costly.

OK

Quoted 4 lines

Also, I reiterate my comment on previous revision, it looks unbalanced that enq and dec implementations are off-by-one.

I did reply on the other revision. There are not off by one, but quasi-complementary.

Quoted 10 lines

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 9 lines
drivers/baseband/acc/acc_common.h +9 -0
+
+/* Check room in AQ for the enqueues batches into Qmgr */
+static inline int32_t
+acc_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t num_ops)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = q->aq_depth -
+			((q->aq_enqueued - q->aq_dequeued +
+			ACC_MAX_QUEUE_DEPTH) %

ACC_MAX_QUEUE_DEPTH)

Quoted 5 lines

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset) · line 1357

Quoted 3 lines
drivers/baseband/acc/acc_common.h +3 -0
+			- (num_ops >> 7);
+	if (aq_avail <= 0)
+		acc_enqueue_queue_full(q_data);

Shouldn't we raise an error if aq_avail negative?

The error is managed externally ( and will be PMD specific).

Quoted 3 lines

Also this function does not seem related to LDPC processing, since it is not used in that patch. It should belong to next patch.

Thanks, there was an issue this should have been called.

Quoted 601 lines

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 5 lines
drivers/baseband/acc/acc_common.h +4 -0
+	return aq_avail;
+}
+
+/* Calculates number of CBs in processed encoder TB based on 'r' and

input

Quoted 6 lines

+ * length.
+ */

drivers/baseband/acc/acc_common.h +4 -0
+static inline uint8_t
+get_num_cbs_in_tb_ldpc_enc(struct rte_bbdev_op_ldpc_enc *ldpc_enc)
+{
+	uint8_t c, r, crc24_bits = 0;

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 10 lines
drivers/baseband/acc/acc_common.h +10 -0
+	uint16_t k = (ldpc_enc->basegraph == 1 ? 22 : 10) * ldpc_enc->z_c
+		- ldpc_enc->n_filler;
+	uint8_t cbs_in_tb = 0;
+	int32_t length;
+
+	length = ldpc_enc->input.length;
+	r = ldpc_enc->tb_params.r;
+	c = ldpc_enc->tb_params.c;
+	crc24_bits = 0;
+	if (check_bit(ldpc_enc->op_flags,

RTE_BBDEV_LDPC_CRC_24B_ATTACH))

Review

Quoted 11 lines
drivers/baseband/acc/acc_common.h +9 -0
+		crc24_bits = 24;
+	while (length > 0 && r < c) {
+		length -= (k - crc24_bits) >> 3;
+		r++;
+		cbs_in_tb++;
+	}
+	return cbs_in_tb;
+}
+
  #endif /* _ACC_COMMON_H_ */
(quoted diff) +0 -0

b/drivers/baseband/acc/rte_acc200_pmd.c

drivers/baseband/acc/rte_acc200_pmd.c line 558

Quoted 9 lines

index 355cf8e..1c59559 100644

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
@@ -554,15 +554,50 @@
  	return 0;
  }
 
+static inline void
+acc200_print_op(struct rte_bbdev_dec_op *op, enum rte_bbdev_op_type

op_type,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		uint16_t index)
+{
+	if (op == NULL)
+		return;
+	if (op_type == RTE_BBDEV_OP_LDPC_DEC)
+		rte_bbdev_log(INFO,
+			"  Op 5GUL %d %d %d %d %d %d %d %d %d %d %d

%d",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			index,
+			op->ldpc_dec.basegraph, op->ldpc_dec.z_c,
+			op->ldpc_dec.n_cb, op->ldpc_dec.q_m,
+			op->ldpc_dec.n_filler, op->ldpc_dec.cb_params.e,
+			op->ldpc_dec.op_flags, op->ldpc_dec.rv_index,
+			op->ldpc_dec.iter_max, op->ldpc_dec.iter_count,
+			op->ldpc_dec.harq_combined_input.length
+			);
+	else if (op_type == RTE_BBDEV_OP_LDPC_ENC) {
+		struct rte_bbdev_enc_op *op_dl = (struct rte_bbdev_enc_op

*) op;

Quoted 30 lines
drivers/baseband/acc/rte_acc200_pmd.c +16 -0
+		rte_bbdev_log(INFO,
+			"  Op 5GDL %d %d %d %d %d %d %d %d %d",
+			index,
+			op_dl->ldpc_enc.basegraph, op_dl->ldpc_enc.z_c,
+			op_dl->ldpc_enc.n_cb, op_dl->ldpc_enc.q_m,
+			op_dl->ldpc_enc.n_filler, op_dl-
 ldpc_enc.cb_params.e,
+			op_dl->ldpc_enc.op_flags, op_dl->ldpc_enc.rv_index
+			);
+	}
+}
 
  static int
  acc_queue_stop(struct rte_bbdev *dev, uint16_t queue_id)
  {
  	struct acc_queue *q;
+	struct rte_bbdev_dec_op *op;
+	uint16_t i;
  	q = dev->data->queues[queue_id].queue_private;
  	rte_bbdev_log(INFO, "Queue Stop %d H/T/D %d %d %x OpType %d",
  			queue_id, q->sw_ring_head, q->sw_ring_tail,
  			q->sw_ring_depth, q->op_type);
+	for (i = 0; i < q->sw_ring_depth; ++i) {
+		op = (q->ring_addr + i)->req.op_addr;
+		acc200_print_op(op, q->op_type, i);
+	}
  	/* ignore all operations in flight and clear counters */
  	q->sw_ring_tail = q->sw_ring_head;
  	q->aq_enqueued = 0;

drivers/baseband/acc/rte_acc200_pmd.c line 648

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
@@ -605,6 +640,43 @@
  	struct acc_device *d = dev->data->dev_private;
  	int i;
  	static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
+		{
+			.type   = RTE_BBDEV_OP_LDPC_ENC,
+			.cap.ldpc_enc = {
+				.capability_flags =
+					RTE_BBDEV_LDPC_RATE_MATCH |
+
	RTE_BBDEV_LDPC_CRC_24B_ATTACH |

drivers/baseband/acc/rte_acc200_pmd.c line 649

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_LDPC_INTERLEAVER_BYPASS,

drivers/baseband/acc/rte_acc200_pmd.c line 651

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_src =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 653

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_dst =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+			}
+		},
+		{
+			.type   = RTE_BBDEV_OP_LDPC_DEC,
+			.cap.ldpc_dec = {
+			.capability_flags =
+				RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK |
+				RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP |
+				RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK |
+				RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK |
+

RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE |

drivers/baseband/acc/rte_acc200_pmd.c line 665

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE |

drivers/baseband/acc/rte_acc200_pmd.c line 666

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE |

drivers/baseband/acc/rte_acc200_pmd.c line 667

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+				RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS

|

drivers/baseband/acc/rte_acc200_pmd.c line 669

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER |
+

RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION |

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+				RTE_BBDEV_LDPC_LLR_COMPRESSION,
+			.llr_size = 8,
+			.llr_decimals = 1,
+			.num_buffers_src =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 676

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+			.num_buffers_hard_out =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

Quoted 31 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -2
+			.num_buffers_soft_out = 0,
+			}
+		},
  		RTE_BBDEV_END_OF_CAPABILITIES_LIST()
  	};
 
@@ -621,13 +693,15 @@
  	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;
  	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = 0;
  	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = d-

acc_conf.q_ul_5g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+			d->acc_conf.q_ul_5g.num_qgroups;
+	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d-

acc_conf.q_dl_5g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +2 -2
+			d->acc_conf.q_dl_5g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
  	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 0;
  	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d-

acc_conf.q_ul_5g.num_qgroups;

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d-

acc_conf.q_dl_5g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0; dev_info->max_num_queues = 0;
for (i = RTE_BBDEV_OP_NONE; i <= RTE_BBDEV_OP_FFT; i++)

drivers/baseband/acc/rte_acc200_pmd.c line 752

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
@@ -670,6 +744,1446 @@
  	{.device_id = 0},
  };
 
+/* Fill in a frame control word for LDPC decoding. */
+static inline void
+acc200_fcw_ld_fill(struct rte_bbdev_dec_op *op, struct acc_fcw_ld *fcw,
+		union acc_harq_layout_data *harq_layout)
+{
+	uint16_t harq_out_length, harq_in_length, ncb_p, k0_p,

parity_offset;

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+	uint32_t harq_index;
+	uint32_t l;
+
+	fcw->qm = op->ldpc_dec.q_m;
+	fcw->nfiller = op->ldpc_dec.n_filler;
+	fcw->BG = (op->ldpc_dec.basegraph - 1);
+	fcw->Zc = op->ldpc_dec.z_c;
+	fcw->ncb = op->ldpc_dec.n_cb;
+	fcw->k0 = get_k0(fcw->ncb, fcw->Zc, op->ldpc_dec.basegraph,
+			op->ldpc_dec.rv_index);
+	if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
+		fcw->rm_e = op->ldpc_dec.cb_params.e;
+	else
+		fcw->rm_e = (op->ldpc_dec.tb_params.r <

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				op->ldpc_dec.tb_params.cab) ?
+						op->ldpc_dec.tb_params.ea :
+						op->ldpc_dec.tb_params.eb;
+
+	if (unlikely(check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE) &&
+			(op->ldpc_dec.harq_combined_input.length == 0))) {
+		rte_bbdev_log(WARNING, "Null HARQ input size provided");
+		/* Disable HARQ input in that case to carry forward */
+		op->ldpc_dec.op_flags ^=

RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE;

Quoted 65 lines
drivers/baseband/acc/rte_acc200_pmd.c +32 -0
+	}
+	if (unlikely(fcw->rm_e == 0)) {
+		rte_bbdev_log(WARNING, "Null E input provided");
+		fcw->rm_e = 2;
+	}
+
+	fcw->hcin_en = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE);
+	fcw->hcout_en = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
+	fcw->crc_select = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK);
+	fcw->bypass_dec = 0;
+	fcw->bypass_intlv = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS);
+	if (op->ldpc_dec.q_m == 1) {
+		fcw->bypass_intlv = 1;
+		fcw->qm = 2;
+	}
+	fcw->hcin_decomp_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+	fcw->hcout_comp_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+	fcw->llr_pack_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_LLR_COMPRESSION);
+	harq_index = hq_index(op->ldpc_dec.harq_combined_output.offset);
+
+	if (fcw->hcin_en > 0) {
+		harq_in_length = op->ldpc_dec.harq_combined_input.length;
+		if (fcw->hcin_decomp_mode > 0)
+			harq_in_length = harq_in_length * 8 / 6;
+		harq_in_length = RTE_MIN(harq_in_length, op-

ldpc_dec.n_cb

drivers/baseband/acc/rte_acc200_pmd.c +32 -0
+				- op->ldpc_dec.n_filler);
+		harq_in_length = RTE_ALIGN_CEIL(harq_in_length, 64);
+		fcw->hcin_size0 = harq_in_length;
+		fcw->hcin_offset = 0;
+		fcw->hcin_size1 = 0;
+	} else {
+		fcw->hcin_size0 = 0;
+		fcw->hcin_offset = 0;
+		fcw->hcin_size1 = 0;
+	}
+
+	fcw->itmax = op->ldpc_dec.iter_max;
+	fcw->itstop = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE);
+	fcw->cnu_algo = ACC_ALGO_MSA;
+	fcw->synd_precoder = fcw->itstop;
+	/*
+	 * These are all implicitly set
+	 * fcw->synd_post = 0;
+	 * fcw->so_en = 0;
+	 * fcw->so_bypass_rm = 0;
+	 * fcw->so_bypass_intlv = 0;
+	 * fcw->dec_convllr = 0;
+	 * fcw->hcout_convllr = 0;
+	 * fcw->hcout_size1 = 0;
+	 * fcw->so_it = 0;
+	 * fcw->hcout_offset = 0;
+	 * fcw->negstop_th = 0;
+	 * fcw->negstop_it = 0;
+	 * fcw->negstop_en = 0;
+	 * fcw->gain_i = 1;
+	 * fcw->gain_h = 1;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	 */
+	if (fcw->hcout_en > 0) {
+		parity_offset = (op->ldpc_dec.basegraph == 1 ? 20 : 8)
+			* op->ldpc_dec.z_c - op->ldpc_dec.n_filler;
+		k0_p = (fcw->k0 > parity_offset) ?
+				fcw->k0 - op->ldpc_dec.n_filler : fcw->k0;
+		ncb_p = fcw->ncb - op->ldpc_dec.n_filler;
+		l = k0_p + fcw->rm_e;
+		harq_out_length = (uint16_t) fcw->hcin_size0;
+		harq_out_length = RTE_MIN(RTE_MAX(harq_out_length, l),

ncb_p);

Quoted 27 lines
drivers/baseband/acc/rte_acc200_pmd.c +27 -0
+		harq_out_length = RTE_ALIGN_CEIL(harq_out_length, 64);
+		fcw->hcout_size0 = harq_out_length;
+		fcw->hcout_size1 = 0;
+		fcw->hcout_offset = 0;
+		harq_layout[harq_index].offset = fcw->hcout_offset;
+		harq_layout[harq_index].size0 = fcw->hcout_size0;
+	} else {
+		fcw->hcout_size0 = 0;
+		fcw->hcout_size1 = 0;
+		fcw->hcout_offset = 0;
+	}
+
+	fcw->tb_crc_select = 0;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK))
+		fcw->tb_crc_select = 2;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK))
+		fcw->tb_crc_select = 1;
+}
+
+static inline int
+acc200_dma_desc_le_fill(struct rte_bbdev_enc_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *output, uint32_t *in_offset,
+		uint32_t *out_offset, uint32_t *out_length,
+		uint32_t *mbuf_total_left, uint32_t *seg_total_left)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+{
+	int next_triplet = 1; /* FCW already done */
+	uint16_t K, in_length_in_bits, in_length_in_bytes;
+	struct rte_bbdev_op_ldpc_enc *enc = &op->ldpc_enc;
+
+	acc_header_init(desc);
+	K = (enc->basegraph == 1 ? 22 : 10) * enc->z_c;
+	in_length_in_bits = K - enc->n_filler;
+	if ((enc->op_flags & RTE_BBDEV_LDPC_CRC_24A_ATTACH) ||
+			(enc->op_flags &

RTE_BBDEV_LDPC_CRC_24B_ATTACH))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		in_length_in_bits -= 24;
+	in_length_in_bytes = in_length_in_bits >> 3;
+
+	if (unlikely((*mbuf_total_left == 0) ||
+			(*mbuf_total_left < in_length_in_bytes))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and

included CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+				*mbuf_total_left, in_length_in_bytes);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset,
+			in_length_in_bytes,
+			seg_total_left, next_triplet,
+			check_bit(op->ldpc_enc.op_flags,
+			RTE_BBDEV_LDPC_ENC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and

mbuf data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= in_length_in_bytes;
+
+	/* Set output length */
+	/* Integer round up division by 8 */
+	*out_length = (enc->cb_params.e + 7) >> 3;
+
+	next_triplet = acc_dma_fill_blk_type(desc, output, *out_offset,
+			*out_length, next_triplet,

ACC_DMA_BLKID_OUT_ENC);

Quoted 37 lines
drivers/baseband/acc/rte_acc200_pmd.c +37 -0
+	op->ldpc_enc.output.length += *out_length;
+	*out_offset += *out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->data_ptrs[next_triplet - 1].dma_ext = 0;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
+acc200_dma_desc_ld_fill(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf **input, struct rte_mbuf *h_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,
+		uint32_t *h_out_length, uint32_t *mbuf_total_left,
+		uint32_t *seg_total_left,
+		struct acc_fcw_ld *fcw)
+{
+	struct rte_bbdev_op_ldpc_dec *dec = &op->ldpc_dec;
+	int next_triplet = 1; /* FCW already done */
+	uint32_t input_length;
+	uint16_t output_length, crc24_overlap = 0;
+	uint16_t sys_cols, K, h_p_size, h_np_size;
+	bool h_comp = check_bit(dec->op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+
+	acc_header_init(desc);
+
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP))
+		crc24_overlap = 24;
+
+	/* Compute some LDPC BG lengths */
+	input_length = fcw->rm_e;
+	if (check_bit(op->ldpc_dec.op_flags,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			RTE_BBDEV_LDPC_LLR_COMPRESSION))
+		input_length = (input_length * 3 + 3) / 4;
+	sys_cols = (dec->basegraph == 1) ? 22 : 10;
+	K = sys_cols * dec->z_c;
+	output_length = K - dec->n_filler - crc24_overlap;
+
+	if (unlikely((*mbuf_total_left == 0) ||
+			(*mbuf_total_left < input_length))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and

included CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+				*mbuf_total_left, input_length);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input,
+			in_offset, input_length,
+			seg_total_left, next_triplet,
+			check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEC_SCATTER_GATHER));
+
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and

mbuf data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c line 953

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+				op);
+		return -1;
+	}
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) {
Quoted 21 lines
drivers/baseband/acc/rte_acc200_pmd.c +21 -0
+		if (op->ldpc_dec.harq_combined_input.data == 0) {
+			rte_bbdev_log(ERR, "HARQ input is not defined");
+			return -1;
+		}
+		h_p_size = fcw->hcin_size0 + fcw->hcin_size1;
+		if (h_comp)
+			h_p_size = (h_p_size * 3 + 3) / 4;
+		if (op->ldpc_dec.harq_combined_input.data == 0) {
+			rte_bbdev_log(ERR, "HARQ input is not defined");
+			return -1;
+		}
+		acc_dma_fill_blk_type(
+				desc,
+				op->ldpc_dec.harq_combined_input.data,
+				op->ldpc_dec.harq_combined_input.offset,
+				h_p_size,
+				next_triplet,
+				ACC_DMA_BLKID_IN_HARQ);
+		next_triplet++;
+	}
+

drivers/baseband/acc/rte_acc200_pmd.c line 1021

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= input_length;
+
+	next_triplet = acc_dma_fill_blk_type(desc, h_output,
+			*h_out_offset, output_length >> 3, next_triplet,
+			ACC_DMA_BLKID_OUT_HARD);
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) {
Quoted 43 lines
drivers/baseband/acc/rte_acc200_pmd.c +43 -0
+		if (op->ldpc_dec.harq_combined_output.data == 0) {
+			rte_bbdev_log(ERR, "HARQ output is not defined");
+			return -1;
+		}
+
+		/* Pruned size of the HARQ */
+		h_p_size = fcw->hcout_size0 + fcw->hcout_size1;
+		/* Non-Pruned size of the HARQ */
+		h_np_size = fcw->hcout_offset > 0 ?
+				fcw->hcout_offset + fcw->hcout_size1 :
+				h_p_size;
+		if (h_comp) {
+			h_np_size = (h_np_size * 3 + 3) / 4;
+			h_p_size = (h_p_size * 3 + 3) / 4;
+		}
+		dec->harq_combined_output.length = h_np_size;
+		acc_dma_fill_blk_type(
+				desc,
+				dec->harq_combined_output.data,
+				dec->harq_combined_output.offset,
+				h_p_size,
+				next_triplet,
+				ACC_DMA_BLKID_OUT_HARQ);
+
+		next_triplet++;
+	}
+
+	*h_out_length = output_length >> 3;
+	dec->hard_output.length += *h_out_length;
+	*h_out_offset += *h_out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline void
+acc200_dma_desc_ld_update(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf *input, struct rte_mbuf *h_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,

drivers/baseband/acc/rte_acc200_pmd.c line 1075

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		uint32_t *h_out_length,
+		union acc_harq_layout_data *harq_layout)
+{
+	int next_triplet = 1; /* FCW already done */
+	desc->data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(input, *in_offset);
+	next_triplet++;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) {
Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		struct rte_bbdev_op_data hi = op-

ldpc_dec.harq_combined_input;

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+		desc->data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(hi.data, hi.offset);

drivers/baseband/acc/rte_acc200_pmd.c line 1098

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		next_triplet++;
+	}
+
+	desc->data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(h_output, *h_out_offset);
+	*h_out_length = desc->data_ptrs[next_triplet].blen;
+	next_triplet++;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) {
Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		/* Adjust based on previous operation */
+		struct rte_bbdev_dec_op *prev_op = desc->op_addr;
+		op->ldpc_dec.harq_combined_output.length =
+				prev_op-

ldpc_dec.harq_combined_output.length;

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+		uint32_t harq_idx = hq_index(
+				op-

ldpc_dec.harq_combined_output.offset);

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+		uint32_t prev_harq_idx = hq_index(
+				prev_op-

ldpc_dec.harq_combined_output.offset);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		harq_layout[harq_idx].val = harq_layout[prev_harq_idx].val;
+		struct rte_bbdev_op_data ho =
+				op->ldpc_dec.harq_combined_output;
+		desc->data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(ho.data,

ho.offset);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+		next_triplet++;
+	}
+
+	op->ldpc_dec.hard_output.length += *h_out_length;
+	desc->op_addr = op;
+}
+
+/* Enqueue one encode operations for ACC200 device in CB mode
+ * multiplexed on the same descriptor
+ */
+static inline int
+enqueue_ldpc_enc_n_op_cb(struct acc_queue *q, struct

rte_bbdev_enc_op **ops,

Quoted 33 lines
drivers/baseband/acc/rte_acc200_pmd.c +27 -0
+		uint16_t total_enqueued_descs, int16_t num)
+{
+	union acc_dma_desc *desc = NULL;
+	uint32_t out_length;
+	struct rte_mbuf *output_head, *output;
+	int i, next_triplet;
+	uint16_t  in_length_in_bytes;
+	struct rte_bbdev_op_ldpc_enc *enc = &ops[0]->ldpc_enc;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(ops[0], &desc->req.fcw_le, num, 0);
+
+	/** This could be done at polling */
+	acc_header_init(&desc->req);
+	desc->req.numCBs = num;
+
+	in_length_in_bytes = ops[0]->ldpc_enc.input.data->data_len;
+	out_length = (enc->cb_params.e + 7) >> 3;
+	desc->req.m2dlen = 1 + num;
+	desc->req.d2mlen = num;
+	next_triplet = 1;
+
+	for (i = 0; i < num; i++) {
+		desc->req.data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(ops[i]-

ldpc_enc.input.data, 0);

drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		desc->req.data_ptrs[next_triplet].blen = in_length_in_bytes;
+		next_triplet++;
+		desc->req.data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(
+				ops[i]->ldpc_enc.output.data, 0);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		desc->req.data_ptrs[next_triplet].blen = out_length;
+		next_triplet++;
+		ops[i]->ldpc_enc.output.length = out_length;
+		output_head = output = ops[i]->ldpc_enc.output.data;
+		mbuf_append(output_head, output, out_length);
+		output->data_len = out_length;
+	}
+
+	desc->req.op_addr = ops[0];
+	/* Keep track of pointers even when multiplexed in single descriptor

*/

Quoted 3 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	struct acc_ptrs *context_ptrs = q->companion_ring_addr + desc_idx;

Don't mix declarations & code.

OK

Quoted 13 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1160

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num; i++)
+		context_ptrs->ptr[i].op_addr = ops[i];
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+	/* One CB (one op) was successfully prepared to enqueue */

my understanding is that it is num CB, not one.

Thansk

Quoted 129 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	return num;
+}
+
+/* Enqueue one encode operations for ACC200 device for a partial TB
+ * all codes blocks have same configuration multiplexed on the same

descriptor

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines

+ */

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+static inline void
+enqueue_ldpc_enc_part_tb(struct acc_queue *q, struct

rte_bbdev_enc_op *op,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		uint16_t total_enqueued_descs, int16_t num_cbs, uint32_t

e,

Quoted 23 lines
drivers/baseband/acc/rte_acc200_pmd.c +23 -0
+		uint16_t in_len_B, uint32_t out_len_B, uint32_t *in_offset,
+		uint32_t *out_offset)
+{
+
+	union acc_dma_desc *desc = NULL;
+	struct rte_mbuf *output_head, *output;
+	int i, next_triplet;
+	struct rte_bbdev_op_ldpc_enc *enc = &op->ldpc_enc;
+
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(op, &desc->req.fcw_le, num_cbs, e);
+
+	/** This could be done at polling */
+	acc_header_init(&desc->req);
+	desc->req.numCBs = num_cbs;
+
+	desc->req.m2dlen = 1 + num_cbs;
+	desc->req.d2mlen = num_cbs;
+	next_triplet = 1;
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num_cbs; i++) {
+		desc->req.data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(enc->input.data,
+					*in_offset);
+		*in_offset += in_len_B;
+		desc->req.data_ptrs[next_triplet].blen = in_len_B;
+		next_triplet++;
+		desc->req.data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(
+						enc->output.data,

*out_offset);

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+		*out_offset += out_len_B;
+		desc->req.data_ptrs[next_triplet].blen = out_len_B;
+		next_triplet++;
+		enc->output.length += out_len_B;
+		output_head = output = enc->output.data;
+		mbuf_append(output_head, output, out_len_B);
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+}
+
+/* Enqueue one encode operations for ACC200 device in CB mode */
+static inline int
+enqueue_ldpc_enc_one_op_cb(struct acc_queue *q, struct

rte_bbdev_enc_op *op,

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(op, &desc->req.fcw_le, 1, 0);
+
+	input = op->ldpc_enc.input.data;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	output_head = output = op->ldpc_enc.output.data;
+	in_offset = op->ldpc_enc.input.offset;
+	out_offset = op->ldpc_enc.output.offset;
+	out_length = 0;
+	mbuf_total_left = op->ldpc_enc.input.length;
+	seg_total_left = rte_pktmbuf_data_len(op->ldpc_enc.input.data)
+			- in_offset;
+
+	ret = acc200_dma_desc_le_fill(op, &desc->req, &input, output,
+			&in_offset, &out_offset, &out_length,

&mbuf_total_left,

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+			&seg_total_left);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	mbuf_append(output_head, output, out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+#endif
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+/* Enqueue one encode operations for ACC200 device in TB mode.
+ * returns the number of descs used
+ */
+static inline int
+enqueue_ldpc_enc_one_op_tb(struct acc_queue *q, struct

rte_bbdev_enc_op *op,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+		uint16_t enq_descs, uint8_t cbs_in_tb)
+{
+	uint8_t num_a, num_b;
+	uint16_t desc_idx;
+	uint8_t r = op->ldpc_enc.tb_params.r;
+	uint8_t cab =  op->ldpc_enc.tb_params.cab;
+	union acc_dma_desc *desc;
+	uint16_t init_enq_descs = enq_descs;
+	uint16_t input_len_B = ((op->ldpc_enc.basegraph == 1 ? 22 : 10) *
+			op->ldpc_enc.z_c) >> 3;
+	if (check_bit(op->ldpc_enc.op_flags,

RTE_BBDEV_LDPC_CRC_24B_ATTACH))

Quoted 12 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1290

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		input_len_B -= 3;
+
+	if (r < cab) {
+		num_a = cab - r;
+		num_b = cbs_in_tb - cab;
+	} else {
+		num_a = 0;
+		num_b = cbs_in_tb - r;
+	}
+	uint32_t in_offset = 0, out_offset = 0;

Don't mix declarations & code.

OK

Quoted 19 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+	while (num_a > 0) {
+		uint32_t e = op->ldpc_enc.tb_params.ea;
+		uint32_t out_len_B = (e + 7) >> 3;
+		uint8_t enq = RTE_MIN(num_a, ACC_MUX_5GDL_DESC);
+		num_a -= enq;
+		enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e,

input_len_B,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+				out_len_B, &in_offset, &out_offset);
+		enq_descs++;
+	}
+	while (num_b > 0) {
+		uint32_t e = op->ldpc_enc.tb_params.eb;
+		uint32_t out_len_B = (e + 7) >> 3;
+		uint8_t enq = RTE_MIN(num_b, ACC_MUX_5GDL_DESC);
+		num_b -= enq;
+		enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e,

input_len_B,

Quoted 7 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1311

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+				out_len_B, &in_offset, &out_offset);
+		enq_descs++;
+	}
+
+	uint16_t return_descs = enq_descs - init_enq_descs;

Don't mix declarations & code.

OK

Quoted 23 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	/* Keep total number of CBs in first TB */
+	desc_idx = ((q->sw_ring_head + init_enq_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	desc->req.cbs_in_tb = return_descs; /** Actual number of

descriptors */

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	desc->req.op_addr = op;
+
+	/* Set SDone on last CB descriptor for TB mode. */
+	desc_idx = ((q->sw_ring_head + enq_descs - 1)
+			& q->sw_ring_wrap_mask);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	desc = q->ring_addr + desc_idx;
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+	desc->req.op_addr = op;
+	return return_descs;
+}
+
+/** Enqueue one decode operations for ACC200 device in CB mode */
+static inline int
+enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct

rte_bbdev_dec_op *op,

Quoted 7 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1336

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		uint16_t total_enqueued_cbs, bool same_op)
+{
+	int ret, hq_len;
+	if (op->ldpc_dec.cb_params.e == 0)
+		return -EINVAL;

Don't mix declarations & code.

OK

Quoted 9 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1342

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	union acc_dma_desc *desc;
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	struct rte_mbuf *input, *h_output_head, *h_output;

Don't mix declarations & code.

Quoted 15 lines
Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	uint32_t in_offset, h_out_offset, mbuf_total_left, h_out_length = 0;
+	input = op->ldpc_dec.input.data;
+	h_output_head = h_output = op->ldpc_dec.hard_output.data;

drivers/baseband/acc/rte_acc200_pmd.c line 1355

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	in_offset = op->ldpc_dec.input.offset;
+	h_out_offset = op->ldpc_dec.hard_output.offset;
+	mbuf_total_left = op->ldpc_dec.input.length;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(input == NULL)) {
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif
+	union acc_harq_layout_data *harq_layout = q->d->harq_layout;

Don't mix declarations & code.

OK

Quoted 209 lines
Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+	if (same_op) {
+		union acc_dma_desc *prev_desc;
+		desc_idx = ((q->sw_ring_head + total_enqueued_cbs - 1)
+				& q->sw_ring_wrap_mask);
+		prev_desc = q->ring_addr + desc_idx;
+		uint8_t *prev_ptr = (uint8_t *) prev_desc;
+		uint8_t *new_ptr = (uint8_t *) desc;
+		/* Copy first 4 words and BDESCs */

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
+		rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0,
+				prev_ptr + ACC_5GUL_OFFSET_0,
+				ACC_5GUL_SIZE_1);
+		desc->req.op_addr = prev_desc->req.op_addr;
+		/* Copy FCW */
+		rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
+				prev_ptr + ACC_DESC_FCW_OFFSET,
+				ACC_FCW_LD_BLEN);
+		acc200_dma_desc_ld_update(op, &desc->req, input,

h_output,

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+				&in_offset, &h_out_offset,
+				&h_out_length, harq_layout);
+	} else {
+		struct acc_fcw_ld *fcw;
+		uint32_t seg_total_left;
+		fcw = &desc->req.fcw_ld;
+		acc200_fcw_ld_fill(op, fcw, harq_layout);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+		/* Special handling when using mbuf or not */
+		if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))
+			seg_total_left = rte_pktmbuf_data_len(input)
+					- in_offset;
+		else
+			seg_total_left = fcw->rm_e;
+
+		ret = acc200_dma_desc_ld_fill(op, &desc->req, &input,

h_output,

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+				&in_offset, &h_out_offset,
+				&h_out_length, &mbuf_total_left,
+				&seg_total_left, fcw);
+		if (unlikely(ret < 0))
+			return ret;
+	}
+
+	/* Hard output */
+	mbuf_append(h_output_head, h_output, h_out_length);
+	if (op->ldpc_dec.harq_combined_output.length > 0) {
+		/* Push the HARQ output into host memory */
+		struct rte_mbuf *hq_output_head, *hq_output;
+		hq_output_head = op-

ldpc_dec.harq_combined_output.data;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		hq_output = op->ldpc_dec.harq_combined_output.data;
+		hq_len = op->ldpc_dec.harq_combined_output.length;
+		if (unlikely(!mbuf_append(hq_output_head, hq_output,
+				hq_len))) {
+			rte_bbdev_log(ERR, "HARQ output mbuf issue %d

%d\n",

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+					hq_output->buf_len,
+					hq_len);
+			return -1;
+		}
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
+			sizeof(desc->req.fcw_ld) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+#endif
+
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+
+/* Enqueue one decode operations for ACC200 device in TB mode */
+static inline int
+enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct

rte_bbdev_dec_op *op,

Quoted 118 lines
drivers/baseband/acc/rte_acc200_pmd.c +118 -0
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb)
+{
+	union acc_dma_desc *desc = NULL;
+	union acc_dma_desc *desc_first = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, h_out_offset,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output;
+	uint16_t current_enqueued_cbs = 0;
+	uint16_t sys_cols, trail_len = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	desc_first = desc;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	union acc_harq_layout_data *harq_layout = q->d->harq_layout;
+	acc200_fcw_ld_fill(op, &desc->req.fcw_ld, harq_layout);
+
+	input = op->ldpc_dec.input.data;
+	h_output_head = h_output = op->ldpc_dec.hard_output.data;
+	in_offset = op->ldpc_dec.input.offset;
+	h_out_offset = op->ldpc_dec.hard_output.offset;
+	h_out_length = 0;
+	mbuf_total_left = op->ldpc_dec.input.length;
+	c = op->ldpc_dec.tb_params.c;
+	r = op->ldpc_dec.tb_params.r;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) {
+		sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10;
+		trail_len = sys_cols * op->ldpc_dec.z_c -
+				op->ldpc_dec.n_filler - 24;
+	}
+
+	while (mbuf_total_left > 0 && r < c) {
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))
+			seg_total_left = rte_pktmbuf_data_len(input)
+					- in_offset;
+		else
+			seg_total_left = op->ldpc_dec.input.length;
+		/* Set up DMA descriptor */
+		desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+				& q->sw_ring_wrap_mask);
+		desc = q->ring_addr + desc_idx;
+		fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +
+				fcw_offset;
+		desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN;
+		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
+				ACC_FCW_LD_BLEN);
+		desc->req.fcw_ld.tb_trailer_size = (c - r - 1) * trail_len;
+
+		ret = acc200_dma_desc_ld_fill(op, &desc->req, &input,
+				h_output, &in_offset, &h_out_offset,
+				&h_out_length,
+				&mbuf_total_left, &seg_total_left,
+				&desc->req.fcw_ld);
+
+		if (unlikely(ret < 0))
+			return ret;
+
+		/* Hard output */
+		mbuf_append(h_output_head, h_output, h_out_length);
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_td,
+				sizeof(desc->req.fcw_td) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER)
+				&& (seg_total_left == 0)) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			h_output = h_output->next;
+			h_out_offset = 0;
+		}
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+	/* Set SDone on last CB descriptor for TB mode */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
+/** Enqueue encode operations for ACC200 device in CB mode. */
+static inline uint16_t
+acc200_enqueue_ldpc_enc_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i = 0;
+	union acc_dma_desc *desc;
+	int ret, desc_idx = 0;
+	int16_t enq, left = num;
+
+	while (left > 0) {
+		if (unlikely(avail < 1)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail--;
+		enq = RTE_MIN(left, ACC_MUX_5GDL_DESC);
+		enq = check_mux(&ops[i], enq);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		if (enq > 1) {
+			ret = enqueue_ldpc_enc_n_op_cb(q, &ops[i],
+					desc_idx, enq);
+			if (ret < 0) {
+				acc_enqueue_invalid(q_data);
+				break;
+			}
+			i += enq;
+		} else {
+			ret = enqueue_ldpc_enc_one_op_cb(q, ops[i],

desc_idx);

Quoted 8 lines

Looking at the code of enqueue_ldpc_enc_one_op_cb and enqueue_ldpc_enc_n_op_cb, there should not be much performance difference by only using enqueue_ldpc_enc_n_op_cb even for single enc.

It even looks like enqueue_ldpc_enc_one_op_cb is heavier, could you explain the difference?

It would make maintainance easier to have a single function.

That's a good point. Thanks.

Quoted 97 lines
Quoted 63 lines
drivers/baseband/acc/rte_acc200_pmd.c +41 -0
+			if (ret < 0) {
+				acc_enqueue_invalid(q_data);
+				break;
+			}
+			i++;
+		}
+		desc_idx++;
+		left = num - i;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + desc_idx - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, desc_idx, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}
+
+/* Enqueue LDPC encode operations for ACC200 device in TB mode. */
+static uint16_t
+acc200_enqueue_ldpc_enc_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_descs = 0;
+	uint8_t cbs_in_tb;
+	int descs_used;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_ldpc_enc(&ops[i]-

ldpc_enc);

drivers/baseband/acc/rte_acc200_pmd.c +20 -0
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+
+		descs_used = enqueue_ldpc_enc_one_op_tb(q, ops[i],
+				enqueued_descs, cbs_in_tb);
+		if (descs_used < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_descs += descs_used;
+		avail -= descs_used;
+	}
+	if (unlikely(enqueued_descs == 0))
+		return 0; /* Nothing to enqueue */
+
+	acc_dma_enqueue(q, enqueued_descs, &q_data->queue_stats);
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}
+
+/* Check room in AQ for the enqueues batches into Qmgr */
+static int32_t
+acc200_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t

num_ops)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = q->aq_depth -
+			((q->aq_enqueued - q->aq_dequeued +
+			ACC_MAX_QUEUE_DEPTH) %

ACC_MAX_QUEUE_DEPTH)

drivers/baseband/acc/rte_acc200_pmd.c line 1646

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+			- (num_ops >> 7);
+	if (aq_avail <= 0)
+		acc_enqueue_queue_full(q_data);
+	return aq_avail;
+}
+
+/* Enqueue encode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = acc_ring_avail_enq(q);

Introducing new line here and after the return 0 would not hurt and improve readability.

Quoted 2 lines

This is a general comment for the series, which lacks consistency on this point.

Well is there any general recommendation we could put on DPDK on that?
This is quite subjective really but happy to follow any guidelines if we can capture them. For small functions like these I am not sure it helps readability.

Quoted 71 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->ldpc_enc.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 52 lines
drivers/baseband/acc/rte_acc200_pmd.c +18 -0
+		return acc200_enqueue_ldpc_enc_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_ldpc_enc_cb(q_data, ops, num);
+}
+
+/* Enqueue decode operations for ACC200 device in TB mode */
+static uint16_t
+acc200_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_ldpc_dec(&ops[i]-

ldpc_dec);

drivers/baseband/acc/rte_acc200_pmd.c +33 -0
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) ||
+				(cbs_in_tb == 0)))
+			break;
+		avail -= cbs_in_tb;
+
+		ret = enqueue_ldpc_dec_one_op_tb(q, ops[i],
+				enqueued_cbs, cbs_in_tb);
+		if (ret <= 0)
+			break;
+		enqueued_cbs += ret;
+	}
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+/* Enqueue decode operations for ACC200 device in CB mode */
+static uint16_t
+acc200_enqueue_ldpc_dec_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+	bool same_op = false;
+	for (i = 0; i < num; ++i) {

drivers/baseband/acc/rte_acc200_pmd.c line 1710

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		/* Check if there are available space for further processing */
+		if (unlikely(avail < 1)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= 1;
+#ifdef ACC200_DESC_OPTIMIZATION
+		if (i > 0)
+			same_op = cmp_ldpc_dec_op(&ops[i-1]);
+#endif

I think I made same comment on the series about ACC100 changes for v22.11.

Quoted 8 lines

Such optimizations under #ifdefs are not welcome, as either we need to multiply the number of build tests to cover all the code in CI, or we never compile test this code.

Can you ellaborate when you need it, and when you don't? Is it safe to have this optimization by default, if not why?

If not safe, then just remove it, if safe, make it the default.

Agreed, will take out.

Quoted 20 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		rte_bbdev_log(INFO, "Op %d %d %d %d %d %d %d %d %d %d

%d %d\n",

Quoted 17 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			i, ops[i]->ldpc_dec.op_flags, ops[i]-

ldpc_dec.rv_index,

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			ops[i]->ldpc_dec.iter_max, ops[i]-

ldpc_dec.iter_count,

drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+			ops[i]->ldpc_dec.basegraph, ops[i]->ldpc_dec.z_c,
+			ops[i]->ldpc_dec.n_cb, ops[i]->ldpc_dec.q_m,
+			ops[i]->ldpc_dec.n_filler, ops[i]-

ldpc_dec.cb_params.e,

drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+			same_op);
+		ret = enqueue_ldpc_dec_one_op_cb(q, ops[i], i, same_op);
+		if (ret < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+	}
+
+	if (unlikely(i == 0))
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1730

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);

I think having helpers to fetch descriptors would make the code easier to read and also would ease maintainance.

This can be looked at post 22.11 I believe. But noted.

Quoted 438 lines
Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+/* Enqueue decode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	int32_t aq_avail = acc200_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->ldpc_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		return acc200_enqueue_ldpc_dec_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_ldpc_dec_cb(q_data, ops, num);
+}
+
+
+/* Dequeue one encode operations from ACC200 device in CB mode
+ */
+static inline int
+dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op

**ref_op,

Quoted 45 lines
drivers/baseband/acc/rte_acc200_pmd.c +45 -0
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued,
+		uint16_t *dequeued_descs)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_enc_op *op;
+	int i;
+	int desc_idx = ((q->sw_ring_tail + *dequeued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+	rte_bbdev_log_debug("Resp. desc %p: %x", desc, rsp.val);
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	op->status |= ((rsp.input_err)
+			? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+	op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+	op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0; /*Reserved bits */
+	desc->rsp.add_info_1 = 0; /*Reserved bits */
+
+	ref_op[0] = op;
+	struct acc_ptrs *context_ptrs = q->companion_ring_addr + desc_idx;
+	for (i = 1 ; i < desc->req.numCBs; i++)
+		ref_op[i] = context_ptrs->ptr[i].op_addr;
+
+	/* One op was successfully dequeued */

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	(*dequeued_descs)++;
+	*dequeued_ops += desc->req.numCBs;
+	return desc->req.numCBs;
+}
+
+/* Dequeue one LDPC encode operations from ACC200 device in TB mode
+ * That operation may cover multiple descriptors
+ */
+static inline int
+dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op

**ref_op,

Quoted 41 lines
drivers/baseband/acc/rte_acc200_pmd.c +41 -0
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued,
+		uint16_t *dequeued_descs)
+{
+	union acc_dma_desc *desc, *last_desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_enc_op *op;
+	uint8_t i = 0;
+	uint16_t current_dequeued_descs = 0, descs_in_tb;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + *dequeued_descs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	/* Get number of CBs in dequeued TB */
+	descs_in_tb = desc->req.cbs_in_tb;
+	/* Get last CB */
+	last_desc = q->ring_addr + ((q->sw_ring_tail
+			+ *dequeued_descs + descs_in_tb - 1)
+			& q->sw_ring_wrap_mask);
+	/* Check if last CB in TB is ready to dequeue (and thus
+	 * the whole TB) - checking sdone bit. If not return.
+	 */
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)last_desc,
+			__ATOMIC_RELAXED);
+	if (!(atom_desc.rsp.val & ACC_SDONE))
+		return -1;
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	while (i < descs_in_tb) {
+		desc = q->ring_addr + ((q->sw_ring_tail
+				+ *dequeued_descs)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				& q->sw_ring_wrap_mask);
+		atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+				__ATOMIC_RELAXED);
+		rsp.val = atom_desc.rsp.val;
+		rte_bbdev_log_debug("Resp. desc %p: %x", desc,
+				rsp.val);
+
+		op->status |= ((rsp.input_err)
+				? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+		op->status |= ((rsp.dma_err) ? (1 <<

RTE_BBDEV_DRV_ERROR) : 0);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		op->status |= ((rsp.fcw_err) ? (1 <<

RTE_BBDEV_DRV_ERROR) : 0);

Quoted 130 lines
drivers/baseband/acc/rte_acc200_pmd.c +130 -0
+
+		if (desc->req.last_desc_in_batch) {
+			(*aq_dequeued)++;
+			desc->req.last_desc_in_batch = 0;
+		}
+		desc->rsp.val = ACC_DMA_DESC_TYPE;
+		desc->rsp.add_info_0 = 0;
+		desc->rsp.add_info_1 = 0;
+		(*dequeued_descs)++;
+		current_dequeued_descs++;
+		i++;
+	}
+
+	*ref_op = op;
+	(*dequeued_ops)++;
+	return current_dequeued_descs;
+}
+
+/* Dequeue one decode operation from ACC200 device in CB mode */
+static inline int
+dequeue_dec_one_op_cb(struct rte_bbdev_queue_data *q_data,
+		struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_dec_op *op;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+	rte_bbdev_log_debug("Resp. desc %p: %x\n", desc, rsp.val);
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+	op->status |= ((rsp.input_err)
+			? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+	op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+	op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+	if (op->status != 0) {
+		/* These errors are not expected */
+		q_data->queue_stats.dequeue_err_count++;
+	}
+
+	/* CRC invalid if error exists */
+	if (!op->status)
+		op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR;
+	op->turbo_dec.iter_count = (uint8_t) rsp.iter_cnt;
+	/* Check if this is the last desc in batch (Atomic Queue) */
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0;
+	desc->rsp.add_info_1 = 0;
+	*ref_op = op;
+
+	/* One CB (op) was successfully dequeued */
+	return 1;
+}
+
+/* Dequeue one decode operations from ACC200 device in CB mode */
+static inline int
+dequeue_ldpc_dec_one_op_cb(struct rte_bbdev_queue_data *q_data,
+		struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_dec_op *op;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+	rte_bbdev_log_debug("Resp. desc %p: %x %x %x\n", desc,
+			rsp.val, desc->rsp.add_info_0,
+			desc->rsp.add_info_1);
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+	op->status |= rsp.input_err << RTE_BBDEV_DATA_ERROR;
+	op->status |= rsp.dma_err << RTE_BBDEV_DRV_ERROR;
+	op->status |= rsp.fcw_err << RTE_BBDEV_DRV_ERROR;
+	if (op->status != 0)
+		q_data->queue_stats.dequeue_err_count++;
+
+	op->status |= rsp.crc_status << RTE_BBDEV_CRC_ERROR;
+	if (op->ldpc_dec.hard_output.length > 0 && !rsp.synd_ok)
+		op->status |= 1 << RTE_BBDEV_SYNDROME_ERROR;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)  ||
+			check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK)) {
+		if (desc->rsp.add_info_1 != 0)
+			op->status |= 1 << RTE_BBDEV_CRC_ERROR;
+	}
+
+	op->ldpc_dec.iter_count = (uint8_t) rsp.iter_cnt;
+
+	/* Check if this is the last desc in batch (Atomic Queue) */
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0;
+	desc->rsp.add_info_1 = 0;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+	*ref_op = op;
+
+	/* One CB (op) was successfully dequeued */
+	return 1;
+}
+
+/* Dequeue one decode operations from ACC200 device in TB mode. */
+static inline int
+dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op

**ref_op,

Quoted 41 lines
drivers/baseband/acc/rte_acc200_pmd.c +41 -0
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
+{
+	union acc_dma_desc *desc, *last_desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_dec_op *op;
+	uint8_t cbs_in_tb = 1, cb_idx = 0;
+	uint32_t tb_crc_check = 0;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Get number of CBs in dequeued TB */
+	cbs_in_tb = desc->req.cbs_in_tb;
+	/* Get last CB */
+	last_desc = q->ring_addr + ((q->sw_ring_tail
+			+ dequeued_cbs + cbs_in_tb - 1)
+			& q->sw_ring_wrap_mask);
+	/* Check if last CB in TB is ready to dequeue (and thus
+	 * the whole TB) - checking sdone bit. If not return.
+	 */
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)last_desc,
+			__ATOMIC_RELAXED);
+	if (!(atom_desc.rsp.val & ACC_SDONE))
+		return -1;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	/* Read remaining CBs if exists */
+	while (cb_idx < cbs_in_tb) {
+		desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+				& q->sw_ring_wrap_mask);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+				__ATOMIC_RELAXED);
+		rsp.val = atom_desc.rsp.val;
+		rte_bbdev_log_debug("Resp. desc %p: %x %x %x", desc,
+				rsp.val, desc->rsp.add_info_0,
+				desc->rsp.add_info_1);
+
+		op->status |= ((rsp.input_err)
+				? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+		op->status |= ((rsp.dma_err) ? (1 <<

RTE_BBDEV_DRV_ERROR) : 0);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		op->status |= ((rsp.fcw_err) ? (1 <<

RTE_BBDEV_DRV_ERROR) : 0);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK))
+			tb_crc_check ^= desc->rsp.add_info_1;
+
+		/* CRC invalid if error exists */
+		if (!op->status)
+			op->status |= rsp.crc_status <<

RTE_BBDEV_CRC_ERROR;

Quoted 37 lines
drivers/baseband/acc/rte_acc200_pmd.c +37 -0
+		op->turbo_dec.iter_count = RTE_MAX((uint8_t) rsp.iter_cnt,
+				op->turbo_dec.iter_count);
+
+		/* Check if this is the last desc in batch (Atomic Queue) */
+		if (desc->req.last_desc_in_batch) {
+			(*aq_dequeued)++;
+			desc->req.last_desc_in_batch = 0;
+		}
+		desc->rsp.val = ACC_DMA_DESC_TYPE;
+		desc->rsp.add_info_0 = 0;
+		desc->rsp.add_info_1 = 0;
+		dequeued_cbs++;
+		cb_idx++;
+	}
+
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) {
+		rte_bbdev_log_debug("TB-CRC Check %x\n", tb_crc_check);
+		if (tb_crc_check > 0)
+			op->status |= 1 << RTE_BBDEV_CRC_ERROR;
+	}
+
+	*ref_op = op;
+
+	return cb_idx;
+}
+
+/* Dequeue LDPC encode operations from ACC200 device. */
+static uint16_t
+acc200_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i, dequeued_ops = 0, dequeued_descs = 0;
+	int ret;

drivers/baseband/acc/rte_acc200_pmd.c line 2115

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	struct rte_bbdev_enc_op *op;
+	if (avail == 0)
+		return 0;
+	op = (q->ring_addr + (q->sw_ring_tail &
+			q->sw_ring_wrap_mask))->req.op_addr;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == NULL || q == NULL || op == NULL))
+		return 0;
+#endif
+	int cbm = op->ldpc_enc.code_block_mode;

Don't mix declarations & code.

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	for (i = 0; i < avail; i++) {
+		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
+			ret = dequeue_enc_one_op_tb(q,

&ops[dequeued_ops],

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		else
+			ret = dequeue_enc_one_op_cb(q,

&ops[dequeued_ops],

Quoted 31 lines
drivers/baseband/acc/rte_acc200_pmd.c +31 -0
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		if (ret < 0)
+			break;
+		if (dequeued_ops >= num)
+			break;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_descs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += dequeued_ops;
+
+	return dequeued_ops;
+}
+
+/* Dequeue decode operations from ACC200 device. */
+static uint16_t
+acc200_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	uint16_t dequeue_num;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i;
+	uint16_t dequeued_cbs = 0;
+	struct rte_bbdev_dec_op *op;
+	int ret;
+
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2158

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == 0 && q == NULL))
+		return 0;
+#endif

If there is a chance ops or q not to be set, this check should always be here. If not, then just remove them. The q == NULL will anyway be catched easily since it is dereferenced below.

Can remove DEBUG code. I don’t see the harm given this would not be used for production but okay.

Quoted 37 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+	dequeue_num = RTE_MIN(avail, num);
+
+	for (i = 0; i < dequeue_num; ++i) {
+		op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask))->req.op_addr;
+		if (op->ldpc_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			ret = dequeue_dec_one_op_tb(q, &ops[i],

dequeued_cbs,

Quoted 26 lines
drivers/baseband/acc/rte_acc200_pmd.c +20 -0
+					&aq_dequeued);
+		else
+			ret = dequeue_ldpc_dec_one_op_cb(
+					q_data, q, &ops[i], dequeued_cbs,
+					&aq_dequeued);
+
+		if (ret <= 0)
+			break;
+		dequeued_cbs += ret;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_cbs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += i;
+
+	return i;
+}
+
  /* Initialization Function */
  static void
  acc200_bbdev_init(struct rte_bbdev *dev, struct rte_pci_driver *drv)
@@ -677,6 +2191,10 @@
  	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
 
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2200

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
  	dev->dev_ops = &acc200_bbdev_ops;
+	dev->enqueue_ldpc_enc_ops = acc200_enqueue_ldpc_enc;
+	dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec;
+	dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc;
+	dev->dequeue_ldpc_dec_ops = acc200_dequeue_ldpc_dec;
 
  	((struct acc_device *) dev->data->dev_private)->pf_device =
  			!strcmp(drv->driver.name,

Thanks

#26 lore raw

RE: [PATCH v4 09/14] baseband/acc: add LTE processing functions

In reply to Maxime Coquelin

Hi Maxime,

Quoted 597 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 2:00 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 09/14] baseband/acc: add LTE processing functions

Quoted 5 lines · Nic Chautru

Add functions and capability for 4G FEC

---
  drivers/baseband/acc/rte_acc200_pmd.c | 894

+++++++++++++++++++++++++++++++++-

Quoted 8 lines
  1 file changed, 874 insertions(+), 20 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
index 1c59559..35ea0fe 100644

drivers/baseband/acc/rte_acc200_pmd.c line 647

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
@@ -641,6 +641,46 @@
  	int i;
  	static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
  		{
+			.type = RTE_BBDEV_OP_TURBO_DEC,
+			.cap.turbo_dec = {
+				.capability_flags =
+

RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+					RTE_BBDEV_TURBO_CRC_TYPE_24B |
+					RTE_BBDEV_TURBO_EQUALIZER |
+

RTE_BBDEV_TURBO_SOFT_OUT_SATURATE |

drivers/baseband/acc/rte_acc200_pmd.c line 651

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_HALF_ITERATION_EVEN |

drivers/baseband/acc/rte_acc200_pmd.c line 652

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH |

drivers/baseband/acc/rte_acc200_pmd.c line 654

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+					RTE_BBDEV_TURBO_SOFT_OUTPUT |
+

RTE_BBDEV_TURBO_EARLY_TERMINATION |

drivers/baseband/acc/rte_acc200_pmd.c line 655

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+
	RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN |

drivers/baseband/acc/rte_acc200_pmd.c line 656

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT |

drivers/baseband/acc/rte_acc200_pmd.c line 658

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+					RTE_BBDEV_TURBO_MAP_DEC |
+
	RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP |

drivers/baseband/acc/rte_acc200_pmd.c line 659

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_DEC_SCATTER_GATHER,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+				.max_llr_modulus = INT8_MAX,
+				.num_buffers_src =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 664

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_hard_out =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 666

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_soft_out =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+			}
+		},
+		{
+			.type = RTE_BBDEV_OP_TURBO_ENC,
+			.cap.turbo_enc = {
+				.capability_flags =
+

RTE_BBDEV_TURBO_CRC_24B_ATTACH |

drivers/baseband/acc/rte_acc200_pmd.c line 674

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_RV_INDEX_BYPASS |

drivers/baseband/acc/rte_acc200_pmd.c line 676

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+					RTE_BBDEV_TURBO_RATE_MATCH |
+

RTE_BBDEV_TURBO_ENC_SCATTER_GATHER,

drivers/baseband/acc/rte_acc200_pmd.c line 678

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_src =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 680

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_dst =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

Quoted 32 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -2
+			}
+		},
+		{
  			.type   = RTE_BBDEV_OP_LDPC_ENC,
  			.cap.ldpc_enc = {
  				.capability_flags =
@@ -691,15 +731,17 @@
 
  	/* Exposed number of queues */
  	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = d-

acc_conf.q_ul_4g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+			d->acc_conf.q_ul_4g.num_qgroups;
+	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = d-

acc_conf.q_dl_4g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			d->acc_conf.q_dl_4g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = d-

acc_conf.q_ul_5g.num_aqs_per_groups *
d->acc_conf.q_ul_5g.num_qgroups;
dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d-
acc_conf.q_dl_5g.num_aqs_per_groups *
d->acc_conf.q_dl_5g.num_qgroups;
dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;

drivers/baseband/acc/rte_acc200_pmd.c +1 -2
-	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = d-

acc_conf.q_ul_4g.num_qgroups;

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] =
+d->acc_conf.q_dl_4g.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d-
Quoted 4 lines

acc_conf.q_ul_5g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d-
acc_conf.q_dl_5g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0; @@ -744,6

+786,70

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines

@@
{.device_id = 0},
};

drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+/* Fill in a frame control word for turbo decoding. */ static inline
+void acc200_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct
+acc_fcw_td *fcw) {
+	fcw->fcw_ver = 1;
+	fcw->num_maps = ACC_FCW_TD_AUTOMAP;
+	fcw->bypass_sb_deint = !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE);
+	if (op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK) {

drivers/baseband/acc/rte_acc200_pmd.c line 814

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		/* FIXME for TB block */
+		fcw->k_pos = op->turbo_dec.tb_params.k_pos;
+		fcw->k_neg = op->turbo_dec.tb_params.k_neg;
+	} else {
+		fcw->k_pos = op->turbo_dec.cb_params.k;
+		fcw->k_neg = op->turbo_dec.cb_params.k;
+	}
+	fcw->c = 1;
+	fcw->c_neg = 1;
+	if (check_bit(op->turbo_dec.op_flags,

RTE_BBDEV_TURBO_SOFT_OUTPUT)) {

drivers/baseband/acc/rte_acc200_pmd.c line 836

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		fcw->soft_output_en = 1;
+		fcw->sw_soft_out_dis = 0;
+		fcw->sw_et_cont = check_bit(op->turbo_dec.op_flags,
+
	RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH);
Quoted 50 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		fcw->sw_soft_out_saturation = check_bit(op-

turbo_dec.op_flags,

drivers/baseband/acc/rte_acc200_pmd.c +37 -0
+				RTE_BBDEV_TURBO_SOFT_OUT_SATURATE);
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_EQUALIZER)) {
+			fcw->bypass_teq = 0;
+			fcw->ea = op->turbo_dec.cb_params.e;
+			fcw->eb = op->turbo_dec.cb_params.e;
+			if (op->turbo_dec.rv_index == 0)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_0;
+			else if (op->turbo_dec.rv_index == 1)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_1;
+			else if (op->turbo_dec.rv_index == 2)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_2;
+			else
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_3;
+		} else {
+			fcw->bypass_teq = 1;
+			fcw->eb = 64; /* avoid undefined value */
+		}
+	} else {
+		fcw->soft_output_en = 0;
+		fcw->sw_soft_out_dis = 1;
+		fcw->bypass_teq = 0;
+	}
+
+	fcw->code_block_mode = 1; /* FIXME */
+	fcw->turbo_crc_type = check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_CRC_TYPE_24B);
+
+	fcw->ext_td_cold_reg_en = 1;
+	fcw->raw_decoder_input_on = 0;
+	fcw->max_iter = RTE_MAX((uint8_t) op->turbo_dec.iter_max, 2);
+	fcw->min_iter = 2;
+	fcw->half_iter_on = !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_HALF_ITERATION_EVEN);
+
+	fcw->early_stop_en = check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_EARLY_TERMINATION) & !fcw-

soft_output_en;

drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	fcw->ext_scale = 0xF;
+}
+
  /* Fill in a frame control word for LDPC decoding. */
  static inline void
  acc200_fcw_ld_fill(struct rte_bbdev_dec_op *op, struct acc_fcw_ld

*fcw, @@ -870,6 +976,89 @@
}

static inline int

drivers/baseband/acc/rte_acc200_pmd.c line 983

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+acc200_dma_desc_te_fill(struct rte_bbdev_enc_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *output, uint32_t *in_offset,
+		uint32_t *out_offset, uint32_t *out_length,
+		uint32_t *mbuf_total_left, uint32_t *seg_total_left, uint8_t r)

{

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+	int next_triplet = 1; /* FCW already done */
+	uint32_t e, ea, eb, length;
+	uint16_t k, k_neg, k_pos;
+	uint8_t cab, c_neg;
+
+	desc->word0 = ACC_DMA_DESC_TYPE;
+	desc->word1 = 0; /**< Timestamp could be disabled */
+	desc->word2 = 0;
+	desc->word3 = 0;
+	desc->numCBs = 1;
+
+	if (op->turbo_enc.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK) {

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		ea = op->turbo_enc.tb_params.ea;
+		eb = op->turbo_enc.tb_params.eb;
+		cab = op->turbo_enc.tb_params.cab;
+		k_neg = op->turbo_enc.tb_params.k_neg;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		k_pos = op->turbo_enc.tb_params.k_pos;
+		c_neg = op->turbo_enc.tb_params.c_neg;
+		e = (r < cab) ? ea : eb;
+		k = (r < c_neg) ? k_neg : k_pos;
+	} else {
+		e = op->turbo_enc.cb_params.e;
+		k = op->turbo_enc.cb_params.k;
+	}
+
+	if (check_bit(op->turbo_enc.op_flags,

RTE_BBDEV_TURBO_CRC_24B_ATTACH))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		length = (k - 24) >> 3;
+	else
+		length = k >> 3;
+
+	if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < length))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included

CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+				*mbuf_total_left, length);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset,
+			length, seg_total_left, next_triplet,
+			check_bit(op->turbo_enc.op_flags,
+			RTE_BBDEV_TURBO_ENC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= length;
+
+	/* Set output length */
+	if (check_bit(op->turbo_enc.op_flags,

RTE_BBDEV_TURBO_RATE_MATCH))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		/* Integer round up division by 8 */
+		*out_length = (e + 7) >> 3;
+	else
+		*out_length = (k >> 3) * 3 + 2;
+
+	next_triplet = acc_dma_fill_blk_type(desc, output, *out_offset,
+			*out_length, next_triplet,

ACC_DMA_BLKID_OUT_ENC);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+				op);
+		return -1;
+	}
+	op->turbo_enc.output.length += *out_length;
+	*out_offset += *out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
  acc200_dma_desc_le_fill(struct rte_bbdev_enc_op *op,
  		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
  		struct rte_mbuf *output, uint32_t *in_offset, @@ -929,6

+1118,122

Quoted 13 lines

@@
}

static inline int

drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+acc200_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *h_output, struct rte_mbuf *s_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,
+		uint32_t *s_out_offset, uint32_t *h_out_length,
+		uint32_t *s_out_length, uint32_t *mbuf_total_left,
+		uint32_t *seg_total_left, uint8_t r) {
+	int next_triplet = 1; /* FCW already done */
+	uint16_t k;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	uint16_t crc24_overlap = 0;
+	uint32_t e, kw;
+
+	desc->word0 = ACC_DMA_DESC_TYPE;
+	desc->word1 = 0; /**< Timestamp could be disabled */
+	desc->word2 = 0;
+	desc->word3 = 0;
+	desc->numCBs = 1;
+
+	if (op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK) {

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+		k = (r < op->turbo_dec.tb_params.c_neg)
+			? op->turbo_dec.tb_params.k_neg
+			: op->turbo_dec.tb_params.k_pos;
+		e = (r < op->turbo_dec.tb_params.cab)
+			? op->turbo_dec.tb_params.ea
+			: op->turbo_dec.tb_params.eb;
+	} else {
+		k = op->turbo_dec.cb_params.k;
+		e = op->turbo_dec.cb_params.e;
+	}
+
+	if ((op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+		&& !check_bit(op->turbo_dec.op_flags,
+		RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
+		crc24_overlap = 24;
+
+	/* Calculates circular buffer size.
+	 * According to 3gpp 36.212 section 5.1.4.2
+	 *   Kw = 3 * Kpi,
+	 * where:

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	 *   Kpi = nCol * nRow
+	 * where nCol is 32 and nRow can be calculated from:
+	 *   D =< nCol * nRow
+	 * where D is the size of each output from turbo encoder block (k + 4).
+	 */
+	kw = RTE_ALIGN_CEIL(k + 4, 32) * 3;
+
+	if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < kw))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included

CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+				*mbuf_total_left, kw);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset, kw,
+			seg_total_left, next_triplet,
+			check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= kw;
+	*h_out_length = ((k - crc24_overlap) >> 3);
+	next_triplet = acc_dma_fill_blk_type(
+			desc, h_output, *h_out_offset,
+			*h_out_length, next_triplet,

ACC_DMA_BLKID_OUT_HARD);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c line 1208

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+				op);
+		return -1;
+	}
+
+	op->turbo_dec.hard_output.length += *h_out_length;
+	*h_out_offset += *h_out_length;
+
+	/* Soft output */
+	if (check_bit(op->turbo_dec.op_flags,

RTE_BBDEV_TURBO_SOFT_OUTPUT)) {

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+		if (op->turbo_dec.soft_output.data == 0) {
+			rte_bbdev_log(ERR, "Soft output is not defined");
+			return -1;
+		}
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_EQUALIZER))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			*s_out_length = e;
+		else
+			*s_out_length = (k * 3) + 12;
+
+		next_triplet = acc_dma_fill_blk_type(desc, s_output,
+				*s_out_offset, *s_out_length, next_triplet,
+				ACC_DMA_BLKID_OUT_SOFT);
+		if (unlikely(next_triplet < 0)) {
+			rte_bbdev_log(ERR,
+					"Mismatch between data to process

and mbuf data length in bbdev_op: %p",

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+					op);
+			return -1;
+		}
+
+		op->turbo_dec.soft_output.length += *s_out_length;
+		*s_out_offset += *s_out_length;
+	}
+
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
  acc200_dma_desc_ld_fill(struct rte_bbdev_dec_op *op,
  		struct acc_dma_req_desc *desc,
  		struct rte_mbuf **input, struct rte_mbuf *h_output, @@ -

1100,6

Quoted 21 lines

+1405,51 @@
desc->op_addr = op;
}

drivers/baseband/acc/rte_acc200_pmd.c +17 -0
+/* Enqueue one encode operations for ACC200 device in CB mode */
+static inline int enqueue_enc_one_op_cb(struct acc_queue *q, struct
+rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_te_fill(op, &desc->req.fcw_te);
+
+	input = op->turbo_enc.input.data;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	output_head = output = op->turbo_enc.output.data;
+	in_offset = op->turbo_enc.input.offset;
+	out_offset = op->turbo_enc.output.offset;
+	out_length = 0;
+	mbuf_total_left = op->turbo_enc.input.length;
+	seg_total_left = rte_pktmbuf_data_len(op->turbo_enc.input.data)
+			- in_offset;
+
+	ret = acc200_dma_desc_te_fill(op, &desc->req, &input, output,
+			&in_offset, &out_offset, &out_length,

&mbuf_total_left,

Quoted 48 lines
drivers/baseband/acc/rte_acc200_pmd.c +41 -0
+			&seg_total_left, 0);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	mbuf_append(output_head, output, out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_te,
+			sizeof(desc->req.fcw_te) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
  /* Enqueue one encode operations for ACC200 device in CB mode
   * multiplexed on the same descriptor
   */
@@ -1262,6 +1612,84 @@
  	return 1;
  }
 
+
+/* Enqueue one encode operations for ACC200 device in TB mode. */
+static inline int enqueue_enc_one_op_tb(struct acc_queue *q, struct
+rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb) {
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+	uint16_t current_enqueued_cbs = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	acc_fcw_te_fill(op, &desc->req.fcw_te);
+
+	input = op->turbo_enc.input.data;
+	output_head = output = op->turbo_enc.output.data;
+	in_offset = op->turbo_enc.input.offset;
+	out_offset = op->turbo_enc.output.offset;

drivers/baseband/acc/rte_acc200_pmd.c line 1647

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	out_length = 0;
+	mbuf_total_left = op->turbo_enc.input.length;
+
+	c = op->turbo_enc.tb_params.c;
+	r = op->turbo_enc.tb_params.r;
+
+	while (mbuf_total_left > 0 && r < c) {
+		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+		/* Set up DMA descriptor */
+		desc = q->ring_addr + ((q->sw_ring_head +

total_enqueued_cbs)

drivers/baseband/acc/rte_acc200_pmd.c line 1649

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				& q->sw_ring_wrap_mask);
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +

fcw_offset;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		desc->req.data_ptrs[0].blen = ACC_FCW_TE_BLEN;
+
+		ret = acc200_dma_desc_te_fill(op, &desc->req, &input,

output,

Quoted 42 lines
drivers/baseband/acc/rte_acc200_pmd.c +38 -0
+				&in_offset, &out_offset, &out_length,
+				&mbuf_total_left, &seg_total_left, r);
+		if (unlikely(ret < 0))
+			return ret;
+		mbuf_append(output_head, output, out_length);
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_te,
+				sizeof(desc->req.fcw_te) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); #endif
+
+		if (seg_total_left == 0) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			output = output->next;
+			out_offset = 0;
+		}
+
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+
+	/* Set SDone on last CB descriptor for TB mode. */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
  /* Enqueue one encode operations for ACC200 device in TB mode.
   * returns the number of descs used
   */

drivers/baseband/acc/rte_acc200_pmd.c line 1759

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
@@ -1328,6 +1756,69 @@
 
  /** Enqueue one decode operations for ACC200 device in CB mode */
  static inline int
+enqueue_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op

*op,

Quoted 26 lines
drivers/baseband/acc/rte_acc200_pmd.c +26 -0
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, h_out_offset, s_out_offset, s_out_length,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output,
+		*s_output_head, *s_output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc200_fcw_td_fill(op, &desc->req.fcw_td);
+
+	input = op->turbo_dec.input.data;
+	h_output_head = h_output = op->turbo_dec.hard_output.data;
+	s_output_head = s_output = op->turbo_dec.soft_output.data;
+	in_offset = op->turbo_dec.input.offset;
+	h_out_offset = op->turbo_dec.hard_output.offset;
+	s_out_offset = op->turbo_dec.soft_output.offset;
+	h_out_length = s_out_length = 0;
+	mbuf_total_left = op->turbo_dec.input.length;
+	seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(input == NULL)) {
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1789

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif

It makes sense to have this check present unconditionnally.
Also, putting it here is useless since rte_pktmbuf_data_len() dereference it just before. So if NULL, it will crash before being checked.

We would not want to do comprehensive check on input parameter in production.
We had been expecting this kind of check to only happen in debug mode for user to troubleshoot their code more easily. I can take out for now but would be good to review further the usecase of debug build.

Quoted 60 lines
Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+
+	/* Set up DMA descriptor */
+	desc = q->ring_addr + ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+
+	ret = acc200_dma_desc_td_fill(op, &desc->req, &input, h_output,
+			s_output, &in_offset, &h_out_offset, &s_out_offset,
+			&h_out_length, &s_out_length, &mbuf_total_left,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			&seg_total_left, 0);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	/* Hard output */
+	mbuf_append(h_output_head, h_output, h_out_length);
+
+	/* Soft output */
+	if (check_bit(op->turbo_dec.op_flags,

RTE_BBDEV_TURBO_SOFT_OUTPUT))

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		mbuf_append(s_output_head, s_output, s_out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_td,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+			sizeof(desc->req.fcw_td));
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); #endif
+
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+/** Enqueue one decode operations for ACC200 device in CB mode */
+static inline int
  enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct

rte_bbdev_dec_op *op,

Quoted 25 lines
drivers/baseband/acc/rte_acc200_pmd.c +15 -3
  		uint16_t total_enqueued_cbs, bool same_op)
  {
@@ -1525,10 +2016,147 @@
  	return current_enqueued_cbs;
  }
 
-/** Enqueue encode operations for ACC200 device in CB mode. */
-static inline uint16_t -acc200_enqueue_ldpc_enc_cb(struct
 rte_bbdev_queue_data *q_data,
-		struct rte_bbdev_enc_op **ops, uint16_t num)
+/* Enqueue one decode operations for ACC200 device in TB mode */
+static inline int enqueue_dec_one_op_tb(struct acc_queue *q, struct
+rte_bbdev_dec_op *op,
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb) {
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, h_out_offset, s_out_offset, s_out_length,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output,
+		*s_output_head, *s_output;
+	uint16_t current_enqueued_cbs = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2039

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	desc = q->ring_addr + desc_idx;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	acc200_fcw_td_fill(op, &desc->req.fcw_td);
+
+	input = op->turbo_dec.input.data;

Here you may want to check if not NULL, at least for consistency with enqueue_dec_one_op_cb()

Noted above this is taken out.

Quoted 58 lines
Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+	h_output_head = h_output = op->turbo_dec.hard_output.data;
+	s_output_head = s_output = op->turbo_dec.soft_output.data;
+	in_offset = op->turbo_dec.input.offset;
+	h_out_offset = op->turbo_dec.hard_output.offset;
+	s_out_offset = op->turbo_dec.soft_output.offset;
+	h_out_length = s_out_length = 0;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	mbuf_total_left = op->turbo_dec.input.length;
+	c = op->turbo_dec.tb_params.c;
+	r = op->turbo_dec.tb_params.r;
+
+	while (mbuf_total_left > 0 && r < c) {
+
+		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+
+		/* Set up DMA descriptor */
+		desc = q->ring_addr + ((q->sw_ring_head +

total_enqueued_cbs)

drivers/baseband/acc/rte_acc200_pmd.c line 2057

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				& q->sw_ring_wrap_mask);
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +

fcw_offset;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		desc->req.data_ptrs[0].blen = ACC_FCW_TD_BLEN;
+		ret = acc200_dma_desc_td_fill(op, &desc->req, &input,
+				h_output, s_output, &in_offset,

&h_out_offset,

drivers/baseband/acc/rte_acc200_pmd.c line 2061

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+				&s_out_offset, &h_out_length,

&s_out_length,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+				&mbuf_total_left, &seg_total_left, r);
+
+		if (unlikely(ret < 0))
+			return ret;
+
+		/* Hard output */
+		mbuf_append(h_output_head, h_output, h_out_length);
+
+		/* Soft output */
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_SOFT_OUTPUT))
+			mbuf_append(s_output_head, s_output,

s_out_length);

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_td,
+				sizeof(desc->req.fcw_td) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); #endif

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+		if (seg_total_left == 0) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			h_output = h_output->next;
+			h_out_offset = 0;
+
+			if (check_bit(op->turbo_dec.op_flags,
+					RTE_BBDEV_TURBO_SOFT_OUTPUT))

{

Quoted 16 lines
Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+				s_output = s_output->next;
+				s_out_offset = 0;
+			}
+		}

drivers/baseband/acc/rte_acc200_pmd.c line 2105

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif

If it can happen, then it should alway be present.

Same comment as above, not meant for production code.

Quoted 92 lines
Quoted 68 lines
drivers/baseband/acc/rte_acc200_pmd.c +61 -0
+	/* Set SDone on last CB descriptor for TB mode */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
+/* Enqueue encode operations for ACC200 device in CB mode. */ static
+uint16_t acc200_enqueue_enc_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail - 1 < 0)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= 1;
+
+		ret = enqueue_enc_one_op_cb(q, ops[i], i);
+		if (ret < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+/** Enqueue encode operations for ACC200 device in CB mode. */ static
+inline uint16_t acc200_enqueue_ldpc_enc_cb(struct
+rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
  {
  	struct acc_queue *q = q_data->queue_private;
  	int32_t avail = acc_ring_avail_enq(q); @@ -1583,6 +2211,45 @@
  	return i;
  }
 
+/* Enqueue encode operations for ACC200 device in TB mode. */ static
+uint16_t acc200_enqueue_enc_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_enc(&ops[i]->turbo_enc);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= cbs_in_tb;
+
+		ret = enqueue_enc_one_op_tb(q, ops[i], enqueued_cbs,

cbs_in_tb);

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+		if (ret <= 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_cbs += ret;
+	}
+	if (unlikely(enqueued_cbs == 0))
+		return 0; /* Nothing to enqueue */
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2251

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_enc_tb(), it should be shared.

Actually these and/or the underlying functions have differences. (or will be different once ACC100 PMDs changed are applied).

Quoted 73 lines
Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -2
+
  /* Enqueue LDPC encode operations for ACC200 device in TB mode. */
  static uint16_t
  acc200_enqueue_ldpc_enc_tb(struct rte_bbdev_queue_data *q_data, @@
-1623,18 +2290,18 @@
  	return i;
  }
 
-/* Check room in AQ for the enqueues batches into Qmgr */ -static

int32_t -acc200_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t num_ops)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -4
+/* Enqueue encode operations for ACC200 device. */ static uint16_t
+acc200_enqueue_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
  {
-	struct acc_queue *q = q_data->queue_private;
-	int32_t aq_avail = q->aq_depth -
-			((q->aq_enqueued - q->aq_dequeued +
-			ACC_MAX_QUEUE_DEPTH) %

ACC_MAX_QUEUE_DEPTH)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -4
-			- (num_ops >> 7);
-	if (aq_avail <= 0)
-		acc_enqueue_queue_full(q_data);
-	return aq_avail;
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->turbo_enc.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 43 lines
drivers/baseband/acc/rte_acc200_pmd.c +37 -0
+		return acc200_enqueue_enc_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_enc_cb(q_data, ops, num);
  }
 
  /* Enqueue encode operations for ACC200 device. */ @@ -1652,6
+2319,47 @@
  		return acc200_enqueue_ldpc_enc_cb(q_data, ops, num);
  }
 
+
+/* Enqueue decode operations for ACC200 device in CB mode */ static
+uint16_t acc200_enqueue_dec_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail - 1 < 0))
+			break;
+		avail -= 1;
+
+		ret = enqueue_dec_one_op_cb(q, ops[i], i);
+		if (ret < 0)
+			break;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2251

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_dec_cb(), it should be shared.

Same comment as above

Quoted 89 lines
Quoted 19 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -1
+
  /* Enqueue decode operations for ACC200 device in TB mode */
  static uint16_t
  acc200_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data, @@
-1740,12 +2448,64 @@
  	return i;
  }
 
+
+/* Enqueue decode operations for ACC200 device in TB mode */ static
+uint16_t acc200_enqueue_dec_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_dec(&ops[i]->turbo_dec);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= cbs_in_tb;
+
+		ret = enqueue_dec_one_op_tb(q, ops[i], enqueued_cbs,

cbs_in_tb);

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		if (ret <= 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_cbs += ret;

drivers/baseband/acc/rte_acc200_pmd.c line 2251

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	}
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_dec_tb(), it should be shared.

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+/* Enqueue decode operations for ACC200 device. */ static uint16_t
+acc200_enqueue_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		return acc200_enqueue_dec_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_dec_cb(q_data, ops, num); }

Ditto

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines

/* Enqueue decode operations for ACC200 device. */ static uint16_t
acc200_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_dec_op **ops, uint16_t num)
{

drivers/baseband/acc/rte_acc200_pmd.c +1 -1
-	int32_t aq_avail = acc200_aq_avail(q_data, num);
+	int32_t aq_avail = acc_aq_avail(q_data, num);
  	if (unlikely((aq_avail <= 0) || (num == 0)))
  		return 0;
  	if (ops[0]->ldpc_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 15 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
@@ -2093,6 +2853,51 @@
  	return cb_idx;
  }
 
+/* Dequeue encode operations from ACC200 device. */ static uint16_t
+acc200_dequeue_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i, dequeued_ops = 0, dequeued_descs = 0;
+	int ret;
+	struct rte_bbdev_enc_op *op;
+	if (avail == 0)
+		return 0;
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2874

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+	op = (q->ring_addr + (q->sw_ring_tail &
+			q->sw_ring_wrap_mask))->req.op_addr;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == NULL || q == NULL || op == NULL))
+		return 0;
+#endif

q is dereferenced before it is checked.

Thanks. Taking out.

Quoted 4 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2875

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	int cbm = op->turbo_enc.code_block_mode;

Dont mix declarations & code.

OK

Quoted 97 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	for (i = 0; i < num; i++) {
+		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
+			ret = dequeue_enc_one_op_tb(q,

&ops[dequeued_ops],

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		else
+			ret = dequeue_enc_one_op_cb(q,

&ops[dequeued_ops],

Quoted 36 lines
drivers/baseband/acc/rte_acc200_pmd.c +29 -1
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		if (ret < 0)
+			break;
+		if (dequeued_ops >= num)
+			break;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_descs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += dequeued_ops;
+
+	return dequeued_ops;
+}
+
  /* Dequeue LDPC encode operations from ACC200 device. */
  static uint16_t
  acc200_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data, @@
-2140,6 +2945,51 @@
 
  /* Dequeue decode operations from ACC200 device. */
  static uint16_t
+acc200_dequeue_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	uint16_t dequeue_num;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i;
+	uint16_t dequeued_cbs = 0;
+	struct rte_bbdev_dec_op *op;
+	int ret;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	if (unlikely(ops == 0 && q == NULL))
+		return 0;
+#endif
+
+	dequeue_num = (avail < num) ? avail : num;
+
+	for (i = 0; i < dequeue_num; ++i) {
+		op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask))->req.op_addr;
+		if (op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			ret = dequeue_dec_one_op_tb(q, &ops[i],

dequeued_cbs,

Quoted 24 lines
drivers/baseband/acc/rte_acc200_pmd.c +20 -0
+					&aq_dequeued);
+		else
+			ret = dequeue_dec_one_op_cb(q_data, q, &ops[i],
+					dequeued_cbs, &aq_dequeued);
+
+		if (ret <= 0)
+			break;
+		dequeued_cbs += ret;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_cbs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += i;
+
+	return i;
+}
+
+/* Dequeue decode operations from ACC200 device. */ static uint16_t
  acc200_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
  		struct rte_bbdev_dec_op **ops, uint16_t num)
  {

drivers/baseband/acc/rte_acc200_pmd.c line 3050

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
@@ -2191,6 +3041,10 @@
  	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
 
  	dev->dev_ops = &acc200_bbdev_ops;
+	dev->enqueue_enc_ops = acc200_enqueue_enc;
+	dev->enqueue_dec_ops = acc200_enqueue_dec;
+	dev->dequeue_enc_ops = acc200_dequeue_enc;
+	dev->dequeue_dec_ops = acc200_dequeue_dec;
  	dev->enqueue_ldpc_enc_ops = acc200_enqueue_ldpc_enc;
  	dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec;
  	dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc;

Overall, there are functions that are stricly identical to ACC100, they should be shared and not duplicated.

Quoted 2 lines

If at some point they need to diverge, let's have device specific ones, but only when it becomes needed.

Actually the ones that are not in acc_common.h end up having differences notably due to SW mitigations/workaround specific to ACC100.

Quoted 2 lines

Maxime

#30 lore raw

RE: [PATCH v4 10/14] baseband/acc: add support for FFT operations

In reply to Maxime Coquelin

Hi Maxime,

Quoted 169 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 2:06 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 10/14] baseband/acc: add support for FFT operations

Quoted 5 lines · Nic Chautru

Add functions and capability for FFT processing

---
  drivers/baseband/acc/rte_acc200_pmd.c | 251

+++++++++++++++++++++++++++++++++-

Quoted 8 lines
  1 file changed, 249 insertions(+), 2 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
index 35ea0fe..fa23b6e 100644

drivers/baseband/acc/rte_acc200_pmd.c line 724

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
@@ -717,6 +717,21 @@
  			.num_buffers_soft_out = 0,
  			}
  		},
+		{
+			.type	= RTE_BBDEV_OP_FFT,
+			.cap.fft = {
+				.capability_flags =
+

RTE_BBDEV_FFT_WINDOWING |

drivers/baseband/acc/rte_acc200_pmd.c line 725

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_FFT_CS_ADJUSTMENT |

drivers/baseband/acc/rte_acc200_pmd.c line 726

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_FFT_DFT_BYPASS |

drivers/baseband/acc/rte_acc200_pmd.c line 727

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_FFT_IDFT_BYPASS |

drivers/baseband/acc/rte_acc200_pmd.c line 728

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_FFT_WINDOWING_BYPASS,

drivers/baseband/acc/rte_acc200_pmd.c line 730

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_src =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 732

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_dst =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

Quoted 22 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+			}
+		},
  		RTE_BBDEV_END_OF_CAPABILITIES_LIST()
  	};
 
@@ -739,12 +754,13 @@
  			d->acc_conf.q_ul_5g.num_qgroups;
  	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d-

acc_conf.q_dl_5g.num_aqs_per_groups *
d->acc_conf.q_dl_5g.num_qgroups;

drivers/baseband/acc/rte_acc200_pmd.c +1 -1
-	dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_FFT] = d-

acc_conf.q_fft.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			d->acc_conf.q_fft.num_qgroups;
  	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = d-

acc_conf.q_ul_4g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = d-
acc_conf.q_dl_4g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d-
acc_conf.q_ul_5g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d-
acc_conf.q_dl_5g.num_qgroups;

drivers/baseband/acc/rte_acc200_pmd.c line 766

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -1
-	dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_FFT] =
+d->acc_conf.q_fft.num_qgroups;
  	dev_info->max_num_queues = 0;
  	for (i = RTE_BBDEV_OP_NONE; i <= RTE_BBDEV_OP_FFT; i++)
  		dev_info->max_num_queues += dev_info->num_queues[i];

@@ -3034,6

Quoted 89 lines

+3050,235 @@
return i;
}

drivers/baseband/acc/rte_acc200_pmd.c +85 -0
+/* Fill in a frame control word for FFT processing. */ static inline
+void acc200_fcw_fft_fill(struct rte_bbdev_fft_op *op, struct
+acc_fcw_fft *fcw) {
+	fcw->in_frame_size = op->fft.input_sequence_size;
+	fcw->leading_pad_size = op->fft.input_leading_padding;
+	fcw->out_frame_size = op->fft.output_sequence_size;
+	fcw->leading_depad_size = op->fft.output_leading_depadding;
+	fcw->cs_window_sel = op->fft.window_index[0] +
+			(op->fft.window_index[1] << 8) +
+			(op->fft.window_index[2] << 16) +
+			(op->fft.window_index[3] << 24);
+	fcw->cs_window_sel2 = op->fft.window_index[4] +
+			(op->fft.window_index[5] << 8);
+	fcw->cs_enable_bmap = op->fft.cs_bitmap;
+	fcw->num_antennas = op->fft.num_antennas_log2;
+	fcw->idft_size = op->fft.idft_log2;
+	fcw->dft_size = op->fft.dft_log2;
+	fcw->cs_offset = op->fft.cs_time_adjustment;
+	fcw->idft_shift = op->fft.idft_shift;
+	fcw->dft_shift = op->fft.dft_shift;
+	fcw->cs_multiplier = op->fft.ncs_reciprocal;
+	if (check_bit(op->fft.op_flags,
+			RTE_BBDEV_FFT_IDFT_BYPASS)) {
+		if (check_bit(op->fft.op_flags,
+				RTE_BBDEV_FFT_WINDOWING_BYPASS))
+			fcw->bypass = 2;
+		else
+			fcw->bypass = 1;
+	} else if (check_bit(op->fft.op_flags,
+			RTE_BBDEV_FFT_DFT_BYPASS))
+		fcw->bypass = 3;
+	else
+		fcw->bypass = 0;
+}
+
+static inline int
+acc200_dma_desc_fft_fill(struct rte_bbdev_fft_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf *input, struct rte_mbuf *output,
+		uint32_t *in_offset, uint32_t *out_offset) {
+	/* FCW already done */
+	acc_header_init(desc);
+	desc->data_ptrs[1].address =
+			rte_pktmbuf_iova_offset(input, *in_offset);
+	desc->data_ptrs[1].blen = op->fft.input_sequence_size * 4;
+	desc->data_ptrs[1].blkid = ACC_DMA_BLKID_IN;
+	desc->data_ptrs[1].last = 1;
+	desc->data_ptrs[1].dma_ext = 0;
+	desc->data_ptrs[2].address =
+			rte_pktmbuf_iova_offset(output, *out_offset);
+	desc->data_ptrs[2].blen = op->fft.output_sequence_size * 4;
+	desc->data_ptrs[2].blkid = ACC_DMA_BLKID_OUT_HARD;
+	desc->data_ptrs[2].last = 1;
+	desc->data_ptrs[2].dma_ext = 0;
+	desc->m2dlen = 2;
+	desc->d2mlen = 1;
+	desc->ib_ant_offset = op->fft.input_sequence_size;
+	desc->num_ant = op->fft.num_antennas_log2 - 3;
+	int num_cs = 0, i;
+	for (i = 0; i < 12; i++)
+		if (check_bit(op->fft.cs_bitmap, 1 << i))
+			num_cs++;
+	desc->num_cs = num_cs;
+	desc->ob_cyc_offset = op->fft.output_sequence_size;
+	desc->ob_ant_offset = op->fft.output_sequence_size * num_cs;
+	desc->op_addr = op;
+	return 0;
+}
+
+
+/** Enqueue one FFT operation for ACC200 device*/ static inline int
+enqueue_fft_one_op(struct acc_queue *q, struct rte_bbdev_fft_op *op,
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc;
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	struct rte_mbuf *input, *output;
+	uint32_t in_offset, out_offset;
+	input = op->fft.base_input.data;
+	output = op->fft.base_output.data;
+	in_offset = op->fft.base_input.offset;
+	out_offset = op->fft.base_output.offset; #ifdef
+RTE_LIBRTE_BBDEV_DEBUG
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 3145

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	if (unlikely(input == NULL)) {
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif

Same comment as on previous patch, if needed just have this check by default, otherwise drop it.

OK

Quoted 4 lines

drivers/baseband/acc/rte_acc200_pmd.c line 3146

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	struct acc_fcw_fft *fcw;

Don't mix declarations & code.

OK

Quoted 12 lines
Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+	fcw = &desc->req.fcw_fft;
+	acc200_fcw_fft_fill(op, fcw);
+	acc200_dma_desc_fft_fill(op, &desc->req, input, output,
+			&in_offset, &out_offset);
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_fft,
+			sizeof(desc->req.fcw_fft));
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); #endif
+	return 1;
+}
+
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 3166

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+/* Enqueue decode operations for ACC200 device. */ static uint16_t
+acc200_enqueue_fft(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_fft_op **ops, uint16_t num) {
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;

Don't mix declarations & code.

OK

Quoted 89 lines
Quoted 89 lines
drivers/baseband/acc/rte_acc200_pmd.c +88 -0
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail < 1))
+			break;
+		avail -= 1;
+		ret = enqueue_fft_one_op(q, ops[i], i);
+		if (ret < 0)
+			break;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+
+/* Dequeue one FFT operations from ACC200 device */ static inline int
+dequeue_fft_one_op(struct rte_bbdev_queue_data *q_data,
+		struct acc_queue *q, struct rte_bbdev_fft_op **ref_op,
+		uint16_t dequeued_cbs, uint32_t *aq_dequeued) {
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_fft_op *op;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "Resp", &desc->rsp.val,
+			sizeof(desc->rsp.val));
+#endif
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+	op->status |= rsp.input_err << RTE_BBDEV_DATA_ERROR;
+	op->status |= rsp.dma_err << RTE_BBDEV_DRV_ERROR;
+	op->status |= rsp.fcw_err << RTE_BBDEV_DRV_ERROR;
+	if (op->status != 0)
+		q_data->queue_stats.dequeue_err_count++;
+
+	/* Check if this is the last desc in batch (Atomic Queue) */
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0;
+	*ref_op = op;
+	/* One CB (op) was successfully dequeued */
+	return 1;
+}
+
+
+/* Dequeue FFT operations from ACC200 device. */ static uint16_t
+acc200_dequeue_fft(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_fft_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	uint16_t dequeue_num, i, dequeued_cbs = 0;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	int ret;
+
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 3264

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == 0 && q == NULL))
+		return 0;
+#endif
+
+	dequeue_num = RTE_MIN(avail, num);

num can be reused, no need to dequeue_num

I would keep as is notably for consistency for other similar functions Thanks

Quoted 30 lines
Quoted 30 lines
drivers/baseband/acc/rte_acc200_pmd.c +19 -0
+
+	for (i = 0; i < dequeue_num; ++i) {
+		ret = dequeue_fft_one_op(
+				q_data, q, &ops[i], dequeued_cbs,
+				&aq_dequeued);
+		if (ret <= 0)
+			break;
+		dequeued_cbs += ret;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_cbs;
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += i;
+	return i;
+}
+
  /* Initialization Function */
  static void
  acc200_bbdev_init(struct rte_bbdev *dev, struct rte_pci_driver *drv)
@@ -3049,6 +3294,8 @@
  	dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec;
  	dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc;
  	dev->dequeue_ldpc_dec_ops = acc200_dequeue_ldpc_dec;
+	dev->enqueue_fft_ops = acc200_enqueue_fft;
+	dev->dequeue_fft_ops = acc200_dequeue_fft;
 
  	((struct acc_device *) dev->data->dev_private)->pf_device =
  			!strcmp(drv->driver.name,
#33 lore raw

RE: [PATCH v4 11/14] baseband/acc: support interrupt

In reply to Maxime Coquelin

Hi Maxime,

Quoted 181 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 2:17 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 11/14] baseband/acc: support interrupt

Quoted 6 lines · Nic Chautru

Adding support for capability and functions for MSI/MSI-X interrupt and underlying information ring.

---
  drivers/baseband/acc/rte_acc200_pmd.c | 346

+++++++++++++++++++++++++++++++++-

Quoted 10 lines
  1 file changed, 344 insertions(+), 2 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
index fa23b6e..b8b621a 100644
@@ -220,6 +220,193 @@
  			acc_conf->q_fft.aq_depth_log2);
  }

drivers/baseband/acc/rte_acc200_pmd.c line 231

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
 
+/* Checks PF Info Ring to find the interrupt cause and handles it
+accordingly */ static inline void acc200_check_ir(struct acc_device
+*acc200_dev) {
+	volatile union acc_info_ring_data *ring_data;
+	uint16_t info_ring_head = acc200_dev->info_ring_head;
+	if (acc200_dev->info_ring == NULL)
+		return;
+
+	ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head

&

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+			ACC_INFO_RING_MASK);
+
+	while (ring_data->valid) {
+		if ((ring_data->int_nb <

ACC200_PF_INT_DMA_DL_DESC_IRQ) || (

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+				ring_data->int_nb >
+				ACC200_PF_INT_DMA_DL5G_DESC_IRQ)) {
+			rte_bbdev_log(WARNING, "InfoRing: ITR:%d

Info:0x%x",

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+				ring_data->int_nb, ring_data-
 detailed_info);
+			/* Initialize Info Ring entry and move forward */
+			ring_data->val = 0;
+		}
+		info_ring_head++;
+		ring_data = acc200_dev->info_ring +
+				(info_ring_head & ACC_INFO_RING_MASK);
+	}

drivers/baseband/acc/rte_acc200_pmd.c line 347

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+}
+
+/* Checks PF Info Ring to find the interrupt cause and handles it
+accordingly */ static inline void acc200_pf_interrupt_handler(struct
+rte_bbdev *dev) {
+	struct acc_device *acc200_dev = dev->data->dev_private;
+	volatile union acc_info_ring_data *ring_data;
+	struct acc_deq_intr_details deq_intr_det;
+
+	ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head

&

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+			ACC_INFO_RING_MASK);
+
+	while (ring_data->valid) {
+
+		rte_bbdev_log_debug(
+				"ACC200 PF Interrupt received, Info Ring

data: 0x%x -> %d",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+				ring_data->val, ring_data->int_nb);
+
+		switch (ring_data->int_nb) {
+		case ACC200_PF_INT_DMA_DL_DESC_IRQ:
+		case ACC200_PF_INT_DMA_UL_DESC_IRQ:
+		case ACC200_PF_INT_DMA_FFT_DESC_IRQ:
+		case ACC200_PF_INT_DMA_UL5G_DESC_IRQ:
+		case ACC200_PF_INT_DMA_DL5G_DESC_IRQ:
+			deq_intr_det.queue_id =

get_queue_id_from_ring_info(

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+					dev->data, *ring_data);
+			if (deq_intr_det.queue_id == UINT16_MAX) {
+				rte_bbdev_log(ERR,
+						"Couldn't find queue: aq_id:

%u, qg_id: %u, vf_id: %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+						ring_data->aq_id,
+						ring_data->qg_id,
+						ring_data->vf_id);
+				return;
+			}
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_DEQUEUE,

&deq_intr_det);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+			break;
+		default:
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_ERROR, NULL);
+			break;
+		}
+
+		/* Initialize Info Ring entry and move forward */
+		ring_data->val = 0;
+		++acc200_dev->info_ring_head;
+		ring_data = acc200_dev->info_ring +
+				(acc200_dev->info_ring_head &

ACC_INFO_RING_MASK);

drivers/baseband/acc/rte_acc200_pmd.c line 347

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+	}
+}
+
+/* Checks VF Info Ring to find the interrupt cause and handles it
+accordingly */ static inline void acc200_vf_interrupt_handler(struct
+rte_bbdev *dev) {
+	struct acc_device *acc200_dev = dev->data->dev_private;
+	volatile union acc_info_ring_data *ring_data;
+	struct acc_deq_intr_details deq_intr_det;
+
+	ring_data = acc200_dev->info_ring + (acc200_dev->info_ring_head

&

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+ACC_INFO_RING_MASK);
+
+	while (ring_data->valid) {
+
+		rte_bbdev_log_debug(
+				"ACC200 VF Interrupt received, Info Ring

data: 0x%x\n",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+				ring_data->val);
+
+		switch (ring_data->int_nb) {
+		case ACC200_VF_INT_DMA_DL_DESC_IRQ:
+		case ACC200_VF_INT_DMA_UL_DESC_IRQ:
+		case ACC200_VF_INT_DMA_FFT_DESC_IRQ:
+		case ACC200_VF_INT_DMA_UL5G_DESC_IRQ:
+		case ACC200_VF_INT_DMA_DL5G_DESC_IRQ:
+			/* VFs are not aware of their vf_id - it's set to 0 in
+			 * queue structures.
+			 */
+			ring_data->vf_id = 0;
+			deq_intr_det.queue_id =

get_queue_id_from_ring_info(

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+					dev->data, *ring_data);
+			if (deq_intr_det.queue_id == UINT16_MAX) {
+				rte_bbdev_log(ERR,
+						"Couldn't find queue: aq_id:

%u, qg_id: %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+						ring_data->aq_id,
+						ring_data->qg_id);
+				return;
+			}
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_DEQUEUE,

&deq_intr_det);

Quoted 22 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+			break;
+		default:
+			rte_bbdev_pmd_callback_process(dev,
+					RTE_BBDEV_EVENT_ERROR, NULL);
+			break;
+		}
+
+		/* Initialize Info Ring entry and move forward */
+		ring_data->valid = 0;
+		++acc200_dev->info_ring_head;
+		ring_data = acc200_dev->info_ring + (acc200_dev-

info_ring_head

drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				& ACC_INFO_RING_MASK);
+	}
+}
+
+/* Interrupt handler triggered by ACC200 dev for handling specific
+interrupt */ static void acc200_dev_interrupt_handler(void *cb_arg) {
+	struct rte_bbdev *dev = cb_arg;
+	struct acc_device *acc200_dev = dev->data->dev_private;
+
+	/* Read info ring */
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 364

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	if (acc200_dev->pf_device)
+		acc200_pf_interrupt_handler(dev);
+	else
+		acc200_vf_interrupt_handler(dev);
+}

Both handlers are quite identical, it should be possible to rework differently so that more code are shared between PF and VF cases.

OK

Quoted 14 lines
Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+
+/* Allocate and setup inforing */
+static int
+allocate_info_ring(struct rte_bbdev *dev) {
+	struct acc_device *d = dev->data->dev_private;
+	const struct acc200_registry_addr *reg_addr;
+	rte_iova_t info_ring_iova;
+	uint32_t phys_low, phys_high;
+
+	if (d->info_ring != NULL)
+		return 0; /* Already configured */
+
+	/* Choose correct registry addresses for the device type */
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 384

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+	if (d->pf_device)
+		reg_addr = &pf_reg_addr;
+	else
+		reg_addr = &vf_reg_addr;
+	/* Allocate InfoRing */
+	if (d->info_ring == NULL)

This check is useless since it is already done earlier.

Thanks

Quoted 108 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		d->info_ring = rte_zmalloc_socket("Info Ring",
+				ACC_INFO_RING_NUM_ENTRIES *
+				sizeof(*d->info_ring),

RTE_CACHE_LINE_SIZE,

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+				dev->data->socket_id);
+	if (d->info_ring == NULL) {
+		rte_bbdev_log(ERR,
+				"Failed to allocate Info Ring for %s:%u",
+				dev->device->driver->name,
+				dev->data->dev_id);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		return -ENOMEM;
+	}
+	info_ring_iova = rte_malloc_virt2iova(d->info_ring);
+
+	/* Setup Info Ring */
+	phys_high = (uint32_t)(info_ring_iova >> 32);
+	phys_low  = (uint32_t)(info_ring_iova);
+	acc_reg_write(d, reg_addr->info_ring_hi, phys_high);
+	acc_reg_write(d, reg_addr->info_ring_lo, phys_low);
+	acc_reg_write(d, reg_addr->info_ring_en,

ACC200_REG_IRQ_EN_ALL);

Quoted 37 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+	d->info_ring_head = (acc_reg_read(d, reg_addr->info_ring_ptr) &
+			0xFFF) / sizeof(union acc_info_ring_data);
+	return 0;
+}
+
+
  /* Allocate 64MB memory used for all software rings */
  static int
  acc200_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int

socket_id) @@ -227,6 +414,7 @@
uint32_t phys_low, phys_high, value; struct acc_device *d = dev->data->dev_private; const struct acc200_registry_addr *reg_addr;

drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+	int ret;
 
  	if (d->pf_device && !d->acc_conf.pf_mode_en) {
  		rte_bbdev_log(NOTICE,
@@ -327,6 +515,14 @@
  	acc_reg_write(d, reg_addr->tail_ptrs_fft_hi, phys_high);
  	acc_reg_write(d, reg_addr->tail_ptrs_fft_lo, phys_low);
 
+	ret = allocate_info_ring(dev);
+	if (ret < 0) {
+		rte_bbdev_log(ERR, "Failed to allocate info_ring for %s:%u",
+				dev->device->driver->name,
+				dev->data->dev_id);
+		/* Continue */
+	}
+
  	if (d->harq_layout == NULL)
  		d->harq_layout = rte_zmalloc_socket("HARQ Layout",
  				ACC_HARQ_LAYOUT * sizeof(*d-

harq_layout), @@ -349,17 +545,121
@@
return 0;
}

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+static int
+acc200_intr_enable(struct rte_bbdev *dev) {
+	int ret;
+	struct acc_device *d = dev->data->dev_private;
+	/*
+	 * MSI/MSI-X are supported
+	 * Option controlled by vfio-intr through EAL parameter
+	 */
+	if (rte_intr_type_get(dev->intr_handle) ==

RTE_INTR_HANDLE_VFIO_MSI)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+{
+
+		ret = allocate_info_ring(dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't allocate info ring for

device: %s",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+					dev->data->name);
+			return ret;
+		}
+		ret = rte_intr_enable(dev->intr_handle);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't enable interrupts for

device: %s",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+		ret = rte_intr_callback_register(dev->intr_handle,
+				acc200_dev_interrupt_handler, dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't register interrupt callback

for device: %s",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+
+		return 0;
+	} else if (rte_intr_type_get(dev->intr_handle) ==
+RTE_INTR_HANDLE_VFIO_MSIX) {
+
+		ret = allocate_info_ring(dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't allocate info ring for

device: %s",

Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 596

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+					dev->data->name);
+			return ret;
+		}
+
+		int i, max_queues;
+		struct acc_device *acc200_dev = dev->data->dev_private;

Don't mix declarations & code.

OK

Quoted 203 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		if (acc200_dev->pf_device)
+			max_queues = ACC200_MAX_PF_MSIX;
+		else
+			max_queues = ACC200_MAX_VF_MSIX;
+
+		if (rte_intr_efd_enable(dev->intr_handle, max_queues)) {
+			rte_bbdev_log(ERR, "Failed to create fds for %u

queues",

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+					dev->data->num_queues);
+			return -1;
+		}
+
+		for (i = 0; i < max_queues; ++i) {
+			if (rte_intr_efds_index_set(dev->intr_handle, i,
+					rte_intr_fd_get(dev->intr_handle)))
+				return -rte_errno;
+		}
+
+		if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+				dev->data->num_queues)) {

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			rte_bbdev_log(ERR, "Failed to allocate %u vectors",
+					dev->data->num_queues);
+			return -ENOMEM;
+		}
+
+		ret = rte_intr_enable(dev->intr_handle);
+
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't enable interrupts for

device: %s",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+		ret = rte_intr_callback_register(dev->intr_handle,
+				acc200_dev_interrupt_handler, dev);
+		if (ret < 0) {
+			rte_bbdev_log(ERR,
+					"Couldn't register interrupt callback

for device: %s",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+					dev->data->name);
+			rte_free(d->info_ring);
+			return ret;
+		}
+
+		return 0;
+	}
+
+	rte_bbdev_log(ERR, "ACC200 (%s) supports only VFIO MSI/MSI-X

interrupts\n",

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+			dev->data->name);
+	return -ENOTSUP;
+}
+
  /* Free memory used for software rings */
  static int
  acc200_dev_close(struct rte_bbdev *dev)
  {
  	struct acc_device *d = dev->data->dev_private;
+	acc200_check_ir(d);
  	if (d->sw_rings_base != NULL) {
  		rte_free(d->tail_ptrs);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		rte_free(d->info_ring);
  		rte_free(d->sw_rings_base);
  		rte_free(d->harq_layout);
  		d->sw_rings_base = NULL;
  		d->tail_ptrs = NULL;
+		d->info_ring = NULL;
  		d->harq_layout = NULL;
  	}
  	/* Ensure all in flight HW transactions are completed */ @@ -652,6
+952,7 @@

RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH |

Quoted 1 line

RTE_BBDEV_TURBO_SOFT_OUTPUT

|

Quoted 1 line

RTE_BBDEV_TURBO_EARLY_TERMINATION |

Quoted 1 line

+

RTE_BBDEV_TURBO_DEC_INTERRUPTS |

Quoted 1 line
	RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN |
Quoted 1 line

RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT |

drivers/baseband/acc/rte_acc200_pmd.c line 974

Quoted 3 lines

RTE_BBDEV_TURBO_MAP_DEC |

drivers/baseband/acc/rte_acc200_pmd.c +0 -0
@@ -673,6 +974,7 @@
 

RTE_BBDEV_TURBO_CRC_24B_ATTACH |

Quoted 1 line

RTE_BBDEV_TURBO_RV_INDEX_BYPASS |

Quoted 2 lines

RTE_BBDEV_TURBO_RATE_MATCH |
+

RTE_BBDEV_TURBO_ENC_INTERRUPTS |

Quoted 1 line

RTE_BBDEV_TURBO_ENC_SCATTER_GATHER,

Quoted 2 lines

.num_buffers_src =

	RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, @@ -686,7 +988,8 @@
Quoted 3 lines

.capability_flags =
RTE_BBDEV_LDPC_RATE_MATCH |

	RTE_BBDEV_LDPC_CRC_24B_ATTACH |
Quoted 1 line

-

RTE_BBDEV_LDPC_INTERLEAVER_BYPASS,

Quoted 1 line

+

RTE_BBDEV_LDPC_INTERLEAVER_BYPASS |

Quoted 1 line

+

RTE_BBDEV_LDPC_ENC_INTERRUPTS,

Quoted 2 lines

.num_buffers_src =

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 1010

Quoted 3 lines

.num_buffers_dst =

drivers/baseband/acc/rte_acc200_pmd.c +0 -0
@@ -707,7 +1010,8 @@
  				RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS

|

drivers/baseband/acc/rte_acc200_pmd.c line 1012

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
  				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER |
 

RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION |

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -1
-				RTE_BBDEV_LDPC_LLR_COMPRESSION,
+				RTE_BBDEV_LDPC_LLR_COMPRESSION |
+				RTE_BBDEV_LDPC_DEC_INTERRUPTS,
  			.llr_size = 8,
  			.llr_decimals = 1,
  			.num_buffers_src =
@@ -775,15 +1079,46 @@
  	dev_info->min_alignment = 1;
  	dev_info->capabilities = bbdev_capabilities;

drivers/baseband/acc/rte_acc200_pmd.c line 1090

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
  	dev_info->harq_buffer_size = 0;
+
+	acc200_check_ir(d);
+}
+
+static int
+acc200_queue_intr_enable(struct rte_bbdev *dev, uint16_t queue_id) {
+	struct acc_queue *q = dev->data->queues[queue_id].queue_private;
+
+	if (rte_intr_type_get(dev->intr_handle) !=

RTE_INTR_HANDLE_VFIO_MSI &&

drivers/baseband/acc/rte_acc200_pmd.c line 1091

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			rte_intr_type_get(dev->intr_handle) !=

RTE_INTR_HANDLE_VFIO_MSIX)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+		return -ENOTSUP;
+
+	q->irq_enable = 1;
+	return 0;
+}
+
+static int
+acc200_queue_intr_disable(struct rte_bbdev *dev, uint16_t queue_id) {
+	struct acc_queue *q = dev->data->queues[queue_id].queue_private;
+
+	if (rte_intr_type_get(dev->intr_handle) !=

RTE_INTR_HANDLE_VFIO_MSI &&

drivers/baseband/acc/rte_acc200_pmd.c line 1103

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			rte_intr_type_get(dev->intr_handle) !=

RTE_INTR_HANDLE_VFIO_MSIX)

Quoted 47 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+		return -ENOTSUP;
+
+	q->irq_enable = 0;
+	return 0;
  }
 
  static const struct rte_bbdev_ops acc200_bbdev_ops = {
  	.setup_queues = acc200_setup_queues,
+	.intr_enable = acc200_intr_enable,
  	.close = acc200_dev_close,
  	.info_get = acc200_dev_info_get,
  	.queue_setup = acc200_queue_setup,
  	.queue_release = acc200_queue_release,
  	.queue_stop = acc_queue_stop,
+	.queue_intr_enable = acc200_queue_intr_enable,
+	.queue_intr_disable = acc200_queue_intr_disable
  };
 
  /* ACC200 PCI PF address map */
@@ -2694,6 +3029,7 @@
  	if (op->status != 0) {
  		/* These errors are not expected */
  		q_data->queue_stats.dequeue_err_count++;
+		acc200_check_ir(q->d);
  	}
 
  	/* CRC invalid if error exists */
@@ -2763,6 +3099,9 @@
 
  	op->ldpc_dec.iter_count = (uint8_t) rsp.iter_cnt;
 
+	if (op->status & (1 << RTE_BBDEV_DRV_ERROR))
+		acc200_check_ir(q->d);
+
  	/* Check if this is the last desc in batch (Atomic Queue) */
  	if (desc->req.last_desc_in_batch) {
  		(*aq_dequeued)++;
@@ -3232,6 +3571,9 @@
  	if (op->status != 0)
  		q_data->queue_stats.dequeue_err_count++;
 
+	if (op->status & (1 << RTE_BBDEV_DRV_ERROR))
+		acc200_check_ir(q->d);
+
  	/* Check if this is the last desc in batch (Atomic Queue) */
  	if (desc->req.last_desc_in_batch) {
  		(*aq_dequeued)++;
#36 lore raw

RE: [PATCH v4 12/14] baseband/acc: add device status and vf2pf comms

In reply to Maxime Coquelin

Hi Maxime,

Quoted 85 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 2:23 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 12/14] baseband/acc: add device status and vf2pf comms

Quoted 6 lines · Nic Chautru

Add support to expose the device status seen from the host through v2pf mailbox communication.

---
  drivers/baseband/acc/rte_acc200_pmd.c | 61

+++++++++++++++++++++++++----------

drivers/baseband/acc/rte_acc200_pmd.c line 202

Quoted 10 lines
  1 file changed, 44 insertions(+), 17 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
index b8b621a..3c2931b 100644
@@ -201,23 +201,47 @@
  	rte_bbdev_log_debug(
  			"%s Config LLR SIGN IN/OUT %s %s QG %u %u %u %u

%u AQ %u %u %u %u %u Len %u %u %u %u %u\n",

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +0 -9
  			(d->pf_device) ? "PF" : "VF",
-			(acc_conf->input_pos_llr_1_bit) ? "POS" : "NEG",
-			(acc_conf->output_pos_llr_1_bit) ? "POS" : "NEG",
-			acc_conf->q_ul_4g.num_qgroups,
-			acc_conf->q_dl_4g.num_qgroups,
-			acc_conf->q_ul_5g.num_qgroups,
-			acc_conf->q_dl_5g.num_qgroups,
-			acc_conf->q_fft.num_qgroups,
-			acc_conf->q_ul_4g.num_aqs_per_groups,
-			acc_conf->q_dl_4g.num_aqs_per_groups,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -8
-			acc_conf->q_ul_5g.num_aqs_per_groups,
-			acc_conf->q_dl_5g.num_aqs_per_groups,
-			acc_conf->q_fft.num_aqs_per_groups,
-			acc_conf->q_ul_4g.aq_depth_log2,
-			acc_conf->q_dl_4g.aq_depth_log2,
-			acc_conf->q_ul_5g.aq_depth_log2,
-			acc_conf->q_dl_5g.aq_depth_log2,
-			acc_conf->q_fft.aq_depth_log2);
+			(acc200_conf->input_pos_llr_1_bit) ? "POS" : "NEG",
+			(acc200_conf->output_pos_llr_1_bit) ? "POS" :

"NEG",

Quoted 20 lines
drivers/baseband/acc/rte_acc200_pmd.c +20 -0
+			acc200_conf->q_ul_4g.num_qgroups,
+			acc200_conf->q_dl_4g.num_qgroups,
+			acc200_conf->q_ul_5g.num_qgroups,
+			acc200_conf->q_dl_5g.num_qgroups,
+			acc200_conf->q_fft.num_qgroups,
+			acc200_conf->q_ul_4g.num_aqs_per_groups,
+			acc200_conf->q_dl_4g.num_aqs_per_groups,
+			acc200_conf->q_ul_5g.num_aqs_per_groups,
+			acc200_conf->q_dl_5g.num_aqs_per_groups,
+			acc200_conf->q_fft.num_aqs_per_groups,
+			acc200_conf->q_ul_4g.aq_depth_log2,
+			acc200_conf->q_dl_4g.aq_depth_log2,
+			acc200_conf->q_ul_5g.aq_depth_log2,
+			acc200_conf->q_dl_5g.aq_depth_log2,
+			acc200_conf->q_fft.aq_depth_log2);
+}
+
+static inline void
+acc200_vf2pf(struct acc_device *d, unsigned int payload) {
+	acc_reg_write(d, HWVfHiVfToPfDbellVf, payload); }

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+/* Request device status information */ static inline uint32_t
+acc200_device_status(struct rte_bbdev *dev) {
+	struct acc_device *d = dev->data->dev_private;
+	uint32_t reg, time_out = 0;
+	if (d->pf_device)
+		return RTE_BBDEV_DEV_NOT_SUPPORTED;
+	acc200_vf2pf(d, ACC_VF2PF_STATUS_REQUEST);
+	reg = acc_reg_read(d, HWVfHiPfToVfDbellVf);
+	while ((time_out < ACC200_STATUS_TO) && (reg ==

RTE_BBDEV_DEV_NOSTATUS)) {

Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 236

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		usleep(ACC200_STATUS_WAIT); /*< Wait or VF->PF->VF

Comms */

drivers/baseband/acc/rte_acc200_pmd.c line 244

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		reg = acc_reg_read(d, HWVfHiPfToVfDbellVf);
+		time_out++;
+	}
+	return reg;

Please add new lines for clarity.

OK
Thanks

Quoted 28 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
  }
 
  /* Checks PF Info Ring to find the interrupt cause and handles it

accordingly */ @@ -537,6 +561,7 @@

  	/* Mark as configured properly */
  	d->configured = true;
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	acc200_vf2pf(d, ACC_VF2PF_USING_VF);
 
  	rte_bbdev_log_debug(
  			"ACC200 (%s) configured  sw_rings = %p,

sw_rings_iova = %#"

drivers/baseband/acc/rte_acc200_pmd.c line 1079

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
@@ -1047,6 +1072,8 @@
 
  	/* Read and save the populated config from ACC200 registers */
  	fetch_acc200_config(dev);
+	/* Check the status of device */
+	dev_info->device_status = acc200_device_status(dev);
 
  	/* Exposed number of queues */
  	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;

With cosmetics fixed:

Thanks,
Maxime

#39 lore raw

RE: [PATCH v4 13/14] baseband/acc: add PF configure companion function

In reply to Maxime Coquelin

Hi Maxime,
Thanks will send an updated serie now. Much appreciated.

Quoted 265 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 2:26 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 13/14] baseband/acc: add PF configure companion function

Quoted 9 lines · Nic Chautru

Add configure function notably to configure the device from the PF within DPDK and bbdev-test (without external dependency).

---
  app/test-bbdev/test_bbdev_perf.c      |  71 ++++++
  drivers/baseband/acc/meson.build      |   2 +-
  drivers/baseband/acc/rte_acc200_cfg.h |  48 ++++
  drivers/baseband/acc/rte_acc200_pmd.c | 453

++++++++++++++++++++++++++++++++++

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct

Quoted 26 lines
  drivers/baseband/acc/version.map      |   1 +
  5 files changed, 574 insertions(+), 1 deletion(-)

create mode 100644 drivers/baseband/acc/rte_acc200_cfg.h

app/test-bbdev/test_bbdev_perf.c +9 -0
index 41c78de..ec6ee2a 100644
@@ -62,6 +62,15 @@
  #define ACC100_QMGR_INVALID_IDX -1
  #define ACC100_QMGR_RR 1
  #define ACC100_QOS_GBR 0
+#include <rte_acc200_cfg.h>
+#define ACC200PF_DRIVER_NAME   ("intel_acc200_pf")
+#define ACC200VF_DRIVER_NAME   ("intel_acc200_vf")
+#define ACC200_QMGR_NUM_AQS 16
+#define ACC200_QMGR_NUM_QGS 2
+#define ACC200_QMGR_AQ_DEPTH 5
+#define ACC200_QMGR_INVALID_IDX -1
+#define ACC200_QMGR_RR 1
+#define ACC200_QOS_GBR 0
  #endif
 
  #define OPS_CACHE_SIZE 256U
@@ -761,6 +770,68 @@ typedef int (test_case_function)(struct

active_device *ad,

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 770

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +0 -0
  				"Failed to configure ACC100 PF for bbdev

%s",

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 4 lines
app/test-bbdev/test_bbdev_perf.c +2 -0
  				info->dev_name);
  	}
+	if ((get_init_device() == true) &&
+		(!strcmp(info->drv.driver_name, ACC200PF_DRIVER_NAME)))

{

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 4 lines
app/test-bbdev/test_bbdev_perf.c +4 -0
+		struct rte_acc_conf conf;
+		unsigned int i;
+
+		printf("Configure ACC200 FEC Driver %s with default

values\n",

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 9 lines
app/test-bbdev/test_bbdev_perf.c +9 -0
+				info->drv.driver_name);
+
+		/* clear default configuration before initialization */
+		memset(&conf, 0, sizeof(struct rte_acc_conf));
+
+		/* Always set in PF mode for built-in configuration */
+		conf.pf_mode_en = true;
+		for (i = 0; i < RTE_ACC_NUM_VFS; ++i) {
+			conf.arb_dl_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 788

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 789

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_4g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 790

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 791

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 792

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_4g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 793

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 794

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 795

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_5g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 796

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 797

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 798

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_5g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+			conf.arb_fft[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_fft[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_fft[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 5 lines
app/test-bbdev/test_bbdev_perf.c +5 -0
+		}
+
+		conf.input_pos_llr_1_bit = true;
+		conf.output_pos_llr_1_bit = true;
+		conf.num_vf_bundles = 1; /**< Number of VF bundles to

setup */

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+
+		conf.q_ul_4g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_ul_4g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 810

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_ul_4g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_ul_4g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_dl_4g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_dl_4g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 814

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_dl_4g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_dl_4g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_ul_5g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_ul_5g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 818

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_ul_5g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_ul_5g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_dl_5g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_dl_5g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 822

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_dl_5g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_dl_5g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_fft.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_fft.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 826

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_fft.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 6 lines
app/test-bbdev/test_bbdev_perf.c +6 -0
+		conf.q_fft.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+
+		/* setup PF with configuration information */
+		ret = rte_acc200_configure(info->dev_name, &conf);
+		TEST_ASSERT_SUCCESS(ret,
+				"Failed to configure ACC200 PF for bbdev

%s",

Quoted 44 lines
app/test-bbdev/test_bbdev_perf.c +2 -0
+				info->dev_name);
+	}
  #endif
  	/* Let's refresh this now this is configured */
  	rte_bbdev_info_get(dev_id, info);
drivers/baseband/acc/meson.build +0 -0
index 63912f0..7ae162a 100644
@@ -5,4 +5,4 @@ deps += ['bbdev', 'bus_vdev', 'ring', 'pci',

'bus_pci']

sources = files('rte_acc100_pmd.c', 'rte_acc200_pmd.c')

drivers/baseband/acc/meson.build +1 -1
-headers = files('rte_acc100_cfg.h')
+headers = files('rte_acc100_cfg.h', 'rte_acc200_cfg.h')
drivers/baseband/acc/rte_acc200_cfg.h new file +20 -0
new file mode 100644
index 0000000..8bd9b20
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation  */
+
+#ifndef _RTE_ACC200_CFG_H_
+#define _RTE_ACC200_CFG_H_
+
+/**
+ * @file rte_acc200_cfg.h
+ *
+ * Functions for configuring ACC200 HW, exposed directly to applications.
+ * Configuration related to encoding/decoding is done through the
+ * librte_bbdev library.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice  */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "rte_acc_common_cfg.h"
+

drivers/baseband/acc/rte_acc200_cfg.h line 30

Quoted 10 lines
drivers/baseband/acc/rte_acc200_cfg.h new file +10 -0
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Configure a ACC200 device
+ *
+ * @param dev_name
+ *   The name of the device. This is the short form of PCI BDF, e.g. 00:01.0.
+ *   It can also be retrieved for a bbdev device from the dev_name field in

the

Quoted 67 lines
drivers/baseband/acc/rte_acc200_cfg.h new file +17 -0
+ *   rte_bbdev_info structure returned by rte_bbdev_info_get().
+ * @param conf
+ *   Configuration to apply to ACC200 HW.
+ *
+ * @return
+ *   Zero on success, negative value on failure.
+ */
+__rte_experimental
+int
+rte_acc200_configure(const char *dev_name, struct rte_acc_conf
+*conf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_ACC200_CFG_H_ */
drivers/baseband/acc/rte_acc200_pmd.c +34 -1
index 3c2931b..21d614d 100644
@@ -43,6 +43,27 @@
 
  enum {UL_4G = 0, UL_5G, DL_4G, DL_5G, FFT, NUM_ACC};
 
+/* Return the accelerator enum for a Queue Group Index */ static
+inline int accFromQgid(int qg_idx, const struct rte_acc_conf
+*acc_conf) {
+	int accQg[ACC200_NUM_QGRPS];
+	int NumQGroupsPerFn[NUM_ACC];
+	int acc, qgIdx, qgIndex = 0;
+	for (qgIdx = 0; qgIdx < ACC200_NUM_QGRPS; qgIdx++)
+		accQg[qgIdx] = 0;
+	NumQGroupsPerFn[UL_4G] = acc_conf->q_ul_4g.num_qgroups;
+	NumQGroupsPerFn[UL_5G] = acc_conf->q_ul_5g.num_qgroups;
+	NumQGroupsPerFn[DL_4G] = acc_conf->q_dl_4g.num_qgroups;
+	NumQGroupsPerFn[DL_5G] = acc_conf->q_dl_5g.num_qgroups;
+	NumQGroupsPerFn[FFT] = acc_conf->q_fft.num_qgroups;
+	for (acc = UL_4G;  acc < NUM_ACC; acc++)
+		for (qgIdx = 0; qgIdx < NumQGroupsPerFn[acc]; qgIdx++)
+			accQg[qgIndex++] = acc;
+	acc = accQg[qg_idx];
+	return acc;
+}
+
  /* Return the queue topology for a Queue Group Index */
  static inline void
  qtopFromAcc(struct rte_acc_queue_topology **qtop, int acc_enum, @@
-75,6 +96,30 @@
  	*qtop = p_qtop;
  }
 
+/* Return the AQ depth for a Queue Group Index */ static inline int
+aqDepth(int qg_idx, struct rte_acc_conf *acc_conf) {
+	struct rte_acc_queue_topology *q_top = NULL;
+	int acc_enum = accFromQgid(qg_idx, acc_conf);
+	qtopFromAcc(&q_top, acc_enum, acc_conf);
+	if (unlikely(q_top == NULL))
+		return 0;
+	return q_top->aq_depth_log2;
+}
+
+/* Return the AQ depth for a Queue Group Index */ static inline int
+aqNum(int qg_idx, struct rte_acc_conf *acc_conf) {
+	struct rte_acc_queue_topology *q_top = NULL;
+	int acc_enum = accFromQgid(qg_idx, acc_conf);
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 121

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	qtopFromAcc(&q_top, acc_enum, acc_conf);
+	if (unlikely(q_top == NULL))
+		return 0;
+	return q_top->num_aqs_per_groups;
+}

For the 3 functions above, please add new lines for clarity.

OK, guidelines would be good, as I am not fully convinced. But updating in new series.

Quoted 179 lines

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+
  static void
  initQTop(struct rte_acc_conf *acc_conf)
  {
@@ -3740,3 +3785,411 @@ static int acc200_pci_probe(struct

rte_pci_driver *pci_drv,

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct · line 3785

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
  RTE_PMD_REGISTER_PCI_TABLE(ACC200PF_DRIVER_NAME,

pci_id_acc200_pf_map);

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct · line 3786

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
  RTE_PMD_REGISTER_PCI(ACC200VF_DRIVER_NAME,

acc200_pci_vf_driver);

Quoted 111 lines
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
  RTE_PMD_REGISTER_PCI_TABLE(ACC200VF_DRIVER_NAME,

pci_id_acc200_vf_map);

drivers/baseband/acc/rte_acc200_pmd.c +109 -0
+
+/* Initial configuration of a ACC200 device prior to running
+configure() */ int rte_acc200_configure(const char *dev_name, struct
+rte_acc_conf *conf) {
+	rte_bbdev_log(INFO, "rte_acc200_configure");
+	uint32_t value, address, status;
+	int qg_idx, template_idx, vf_idx, acc, i;
+	struct rte_bbdev *bbdev = rte_bbdev_get_named_dev(dev_name);
+
+	/* Compile time checks */
+	RTE_BUILD_BUG_ON(sizeof(struct acc_dma_req_desc) != 256);
+	RTE_BUILD_BUG_ON(sizeof(union acc_dma_desc) != 256);
+	RTE_BUILD_BUG_ON(sizeof(struct acc_fcw_td) != 24);
+	RTE_BUILD_BUG_ON(sizeof(struct acc_fcw_te) != 32);
+
+	if (bbdev == NULL) {
+		rte_bbdev_log(ERR,
+		"Invalid dev_name (%s), or device is not yet initialised",
+		dev_name);
+		return -ENODEV;
+	}
+	struct acc_device *d = bbdev->data->dev_private;
+
+	/* Store configuration */
+	rte_memcpy(&d->acc_conf, conf, sizeof(d->acc_conf));
+
+
+	/* Check we are already out of PG */
+	status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+	if (status > 0) {
+		if (status != ACC200_PG_MASK_0) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_0);
+			return -ENODEV;
+		}
+		/* Clock gate sections that will be un-PG */
+		acc_reg_write(d, HWPfHiClkGateHystReg, ACC200_CLK_DIS);
+		/* Un-PG required sections */
+		acc_reg_write(d, HWPfHiSectionPowerGatingReq,
+				ACC200_PG_MASK_1);
+		status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+		if (status != ACC200_PG_MASK_1) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_1);
+			return -ENODEV;
+		}
+		acc_reg_write(d, HWPfHiSectionPowerGatingReq,
+				ACC200_PG_MASK_2);
+		status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+		if (status != ACC200_PG_MASK_2) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_2);
+			return -ENODEV;
+		}
+		acc_reg_write(d, HWPfHiSectionPowerGatingReq,
+				ACC200_PG_MASK_3);
+		status = acc_reg_read(d, HWPfHiSectionPowerGatingAck);
+		if (status != ACC200_PG_MASK_3) {
+			rte_bbdev_log(ERR, "Unexpected status %x %x",
+					status, ACC200_PG_MASK_3);
+			return -ENODEV;
+		}
+		/* Enable clocks for all sections */
+		acc_reg_write(d, HWPfHiClkGateHystReg, ACC200_CLK_EN);
+	}
+
+	/* Explicitly releasing AXI as this may be stopped after PF FLR/BME */
+	address = HWPfDmaAxiControl;
+	value = 1;
+	acc_reg_write(d, address, value);
+
+	/* Set the fabric mode */
+	address = HWPfFabricM2iBufferReg;
+	value = ACC200_FABRIC_MODE;
+	acc_reg_write(d, address, value);
+
+	/* Set default descriptor signature */
+	address = HWPfDmaDescriptorSignatuture;
+	value = 0;
+	acc_reg_write(d, address, value);
+
+	/* Enable the Error Detection in DMA */
+	value = ACC200_CFG_DMA_ERROR;
+	address = HWPfDmaErrorDetectionEn;
+	acc_reg_write(d, address, value);
+
+	/* AXI Cache configuration */
+	value = ACC200_CFG_AXI_CACHE;
+	address = HWPfDmaAxcacheReg;
+	acc_reg_write(d, address, value);
+
+	/* Default DMA Configuration (Qmgr Enabled) */
+	address = HWPfDmaConfig0Reg;
+	value = 0;
+	acc_reg_write(d, address, value);
+	address = HWPfDmaQmanen;
+	value = 0;
+	acc_reg_write(d, address, value);
+
+	/* Default RLIM/ALEN configuration */
+	int rlim = 0;
+	int alen = 1;
+	int timestamp = 0;
+	address = HWPfDmaConfig1Reg;
+	value = (1 << 31) + (rlim << 8) + (timestamp << 6) + alen;
+	acc_reg_write(d, address, value);
+
+	/* Default FFT configuration */
+	address = HWPfFftConfig0;

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	value = ACC200_FFT_CFG_0;
+	acc_reg_write(d, address, value);
+
+	/* Configure DMA Qmanager addresses */
+	address = HWPfDmaQmgrAddrReg;
+	value = HWPfQmgrEgressQueuesTemplate;
+	acc_reg_write(d, address, value);
+
+	/* ===== Qmgr Configuration ===== */
+	/* Configuration of the AQueue Depth QMGR_GRP_0_DEPTH_LOG2

for UL */

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	int totalQgs = conf->q_ul_4g.num_qgroups +
+			conf->q_ul_5g.num_qgroups +
+			conf->q_dl_4g.num_qgroups +
+			conf->q_dl_5g.num_qgroups +
+			conf->q_fft.num_qgroups;
+	for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) {
+		address = HWPfQmgrDepthLog2Grp +
+				ACC_BYTES_IN_WORD * qg_idx;
+		value = aqDepth(qg_idx, conf);
+		acc_reg_write(d, address, value);

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		address = HWPfQmgrTholdGrp +
+				ACC_BYTES_IN_WORD * qg_idx;
+		value = (1 << 16) + (1 << (aqDepth(qg_idx, conf) - 1));
+		acc_reg_write(d, address, value);
+	}
+
+	/* Template Priority in incremental order */
+	for (template_idx = 0; template_idx < ACC_NUM_TMPL;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg0Indx +

ACC_BYTES_IN_WORD * template_idx;

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		value = ACC_TMPL_PRI_0;
+		acc_reg_write(d, address, value);
+		address = HWPfQmgrGrpTmplateReg1Indx +

ACC_BYTES_IN_WORD * template_idx;

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		value = ACC_TMPL_PRI_1;
+		acc_reg_write(d, address, value);
+		address = HWPfQmgrGrpTmplateReg2indx +

ACC_BYTES_IN_WORD * template_idx;

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		value = ACC_TMPL_PRI_2;
+		acc_reg_write(d, address, value);
+		address = HWPfQmgrGrpTmplateReg3Indx +

ACC_BYTES_IN_WORD * template_idx;

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+		value = ACC_TMPL_PRI_3;
+		acc_reg_write(d, address, value);
+	}
+
+	address = HWPfQmgrGrpPriority;
+	value = ACC200_CFG_QMGR_HI_P;
+	acc_reg_write(d, address, value);
+
+	/* Template Configuration */
+	for (template_idx = 0; template_idx < ACC_NUM_TMPL;
+			template_idx++) {
+		value = 0;
+		address = HWPfQmgrGrpTmplateReg4Indx
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv, · line 3955

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* 4GUL */
+	int numQgs = conf->q_ul_4g.num_qgroups;
+	int numQqsAcc = 0;

Don't mix declarations & code, here and elsewhere in this function.

OK

Quoted 327 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc);

qg_idx++)

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_UL_4G;
+			template_idx <= ACC200_SIG_UL_4G_LAST;
+			template_idx++) {

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* 5GUL */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_ul_5g.num_qgroups;
+	value = 0;
+	int numEngines = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc);

qg_idx++)

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_UL_5G;
+			template_idx <= ACC200_SIG_UL_5G_LAST;
+			template_idx++) {
+		/* Check engine power-on status */
+		address = HwPfFecUl5gIbDebugReg + ACC_ENGINE_OFFSET

* template_idx;

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		status = (acc_reg_read(d, address) >> 4) & 0x7;
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		if (status == 1) {
+			acc_reg_write(d, address, value);

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			numEngines++;
+		} else
+			acc_reg_write(d, address, 0);
+	}
+	printf("Number of 5GUL engines %d\n", numEngines);
+	/* 4GDL */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_dl_4g.num_qgroups;
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc);

qg_idx++)

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_DL_4G;
+			template_idx <= ACC200_SIG_DL_4G_LAST;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* 5GDL */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_dl_5g.num_qgroups;
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc);

qg_idx++)

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_DL_5G;
+			template_idx <= ACC200_SIG_DL_5G_LAST;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+	/* FFT */
+	numQqsAcc += numQgs;
+	numQgs	= conf->q_fft.num_qgroups;
+	value = 0;
+	for (qg_idx = numQqsAcc; qg_idx < (numQgs + numQqsAcc);

qg_idx++)

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		value |= (1 << qg_idx);
+	for (template_idx = ACC200_SIG_FFT;
+			template_idx <= ACC200_SIG_FFT_LAST;
+			template_idx++) {
+		address = HWPfQmgrGrpTmplateReg4Indx
+				+ ACC_BYTES_IN_WORD * template_idx;
+		acc_reg_write(d, address, value);
+	}
+
+	/* Queue Group Function mapping */

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	int qman_func_id[8] = {0, 2, 1, 3, 4, 0, 0, 0};
+	value = 0;
+	for (qg_idx = 0; qg_idx < ACC_NUM_QGRPS_PER_WORD; qg_idx++) {
+		acc = accFromQgid(qg_idx, conf);
+		value |= qman_func_id[acc] << (qg_idx * 4);
+	}
+	acc_reg_write(d, HWPfQmgrGrpFunction0, value);
+	value = 0;
+	for (qg_idx = 0; qg_idx < ACC_NUM_QGRPS_PER_WORD; qg_idx++) {
+		acc = accFromQgid(qg_idx + ACC_NUM_QGRPS_PER_WORD,

conf);

Quoted 21 lines
drivers/baseband/acc/rte_acc200_pmd.c +21 -0
+		value |= qman_func_id[acc] << (qg_idx * 4);
+	}
+	acc_reg_write(d, HWPfQmgrGrpFunction1, value);
+
+	/* Configuration of the Arbitration QGroup depth to 1 */
+	for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) {
+		address = HWPfQmgrArbQDepthGrp +
+				ACC_BYTES_IN_WORD * qg_idx;
+		value = 0;
+		acc_reg_write(d, address, value);
+	}
+
+	/* This pointer to ARAM (256kB) is shifted by 2 (4B per register) */
+	uint32_t aram_address = 0;
+	for (qg_idx = 0; qg_idx < totalQgs; qg_idx++) {
+		for (vf_idx = 0; vf_idx < conf->num_vf_bundles; vf_idx++) {
+			address = HWPfQmgrVfBaseAddr + vf_idx
+					* ACC_BYTES_IN_WORD + qg_idx
+					* ACC_BYTES_IN_WORD * 64;
+			value = aram_address;
+			acc_reg_write(d, address, value);

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			/* Offset ARAM Address for next memory bank
+			 * - increment of 4B
+			 */
+			aram_address += aqNum(qg_idx, conf) *
+					(1 << aqDepth(qg_idx, conf));
+		}
+	}
+
+	if (aram_address > ACC200_WORDS_IN_ARAM_SIZE) {
+		rte_bbdev_log(ERR, "ARAM Configuration not fitting %d

%d\n",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+				aram_address,

ACC200_WORDS_IN_ARAM_SIZE);

Quoted 29 lines
drivers/baseband/acc/rte_acc200_pmd.c +29 -0
+		return -EINVAL;
+	}
+
+	/* Performance tuning */
+	acc_reg_write(d, HWPfFabricI2Mdma_weight, 0x0FFF);
+	acc_reg_write(d, HWPfDma4gdlIbThld, 0x1f10);
+
+	/* ==== HI Configuration ==== */
+
+	/* No Info Ring/MSI by default */
+	address = HWPfHiInfoRingIntWrEnRegPf;
+	value = 0;
+	acc_reg_write(d, address, value);
+	address = HWPfHiCfgMsiIntWrEnRegPf;
+	value = 0xFFFFFFFF;
+	acc_reg_write(d, address, value);
+	/* Prevent Block on Transmit Error */
+	address = HWPfHiBlockTransmitOnErrorEn;
+	value = 0;
+	acc_reg_write(d, address, value);
+	/* Prevents to drop MSI */
+	address = HWPfHiMsiDropEnableReg;
+	value = 0;
+	acc_reg_write(d, address, value);
+	/* Set the PF Mode register */
+	address = HWPfHiPfMode;
+	value = (conf->pf_mode_en) ? ACC_PF_VAL : 0;
+	acc_reg_write(d, address, value);
+

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	/* QoS overflow init */
+	value = 1;
+	address = HWPfQosmonAEvalOverflow0;
+	acc_reg_write(d, address, value);
+	address = HWPfQosmonBEvalOverflow0;
+	acc_reg_write(d, address, value);
+
+	/* Configure the FFT RAM LUT */
+	uint32_t fft_lut[ACC200_FFT_RAM_SIZE] = {
+	0x1FFFF, 0x1FFFF, 0x1FFFE, 0x1FFFA, 0x1FFF6, 0x1FFF1, 0x1FFEA,

0x1FFE2,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1FFD9, 0x1FFCE, 0x1FFC2, 0x1FFB5, 0x1FFA7, 0x1FF98, 0x1FF87,

0x1FF75,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1FF62, 0x1FF4E, 0x1FF38, 0x1FF21, 0x1FF09, 0x1FEF0, 0x1FED6,

0x1FEBA,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1FE9D, 0x1FE7F, 0x1FE5F, 0x1FE3F, 0x1FE1D, 0x1FDFA, 0x1FDD5,

0x1FDB0,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1FD89, 0x1FD61, 0x1FD38, 0x1FD0D, 0x1FCE1, 0x1FCB4, 0x1FC86,

0x1FC57,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1FC26, 0x1FBF4, 0x1FBC1, 0x1FB8D, 0x1FB58, 0x1FB21, 0x1FAE9,

0x1FAB0,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1FA75, 0x1FA3A, 0x1F9FD, 0x1F9BF, 0x1F980, 0x1F93F, 0x1F8FD,

0x1F8BA,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1F876, 0x1F831, 0x1F7EA, 0x1F7A3, 0x1F75A, 0x1F70F, 0x1F6C4,

0x1F677,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1F629, 0x1F5DA, 0x1F58A, 0x1F539, 0x1F4E6, 0x1F492, 0x1F43D,

0x1F3E7,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1F38F, 0x1F337, 0x1F2DD, 0x1F281, 0x1F225, 0x1F1C8, 0x1F169,

0x1F109,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1F0A8, 0x1F046, 0x1EFE2, 0x1EF7D, 0x1EF18, 0x1EEB0, 0x1EE48,

0x1EDDF,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1ED74, 0x1ED08, 0x1EC9B, 0x1EC2D, 0x1EBBE, 0x1EB4D,

0x1EADB, 0x1EA68,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1E9F4, 0x1E97F, 0x1E908, 0x1E891, 0x1E818, 0x1E79E, 0x1E722,

0x1E6A6,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1E629, 0x1E5AA, 0x1E52A, 0x1E4A9, 0x1E427, 0x1E3A3, 0x1E31F,

0x1E299,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1E212, 0x1E18A, 0x1E101, 0x1E076, 0x1DFEB, 0x1DF5E, 0x1dED0,

0x1DE41,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1DDB1, 0x1DD20, 0x1DC8D, 0x1DBFA, 0x1DB65, 0x1DACF,

0x1DA38, 0x1D9A0,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1D907, 0x1D86C, 0x1D7D1, 0x1D734, 0x1D696, 0x1D5F7,

0x1D557, 0x1D4B6,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1D413, 0x1D370, 0x1D2CB, 0x1D225, 0x1D17E, 0x1D0D6,

0x1D02D, 0x1CF83,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1CED8, 0x1CE2B, 0x1CD7E, 0x1CCCF, 0x1CC1F, 0x1CB6E,

0x1CABC, 0x1CA09,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1C955, 0x1C89F, 0x1C7E9, 0x1C731, 0x1C679, 0x1C5BF, 0x1C504,

0x1C448,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1C38B, 0x1C2CD, 0x1C20E, 0x1C14E, 0x1C08C, 0x1BFCA, 0x1BF06,

0x1BE42,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1BD7C, 0x1BCB5, 0x1BBED, 0x1BB25, 0x1BA5B, 0x1B990,

0x1B8C4, 0x1B7F6,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1B728, 0x1B659, 0x1B589, 0x1B4B7, 0x1B3E5, 0x1B311, 0x1B23D,

0x1B167,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1B091, 0x1AFB9, 0x1AEE0, 0x1AE07, 0x1AD2C, 0x1AC50, 0x1AB73,

0x1AA95,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1A9B6, 0x1A8D6, 0x1A7F6, 0x1A714, 0x1A631, 0x1A54D, 0x1A468,

0x1A382,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1A29A, 0x1A1B2, 0x1A0C9, 0x19FDF, 0x19EF4, 0x19E08, 0x19D1B,

0x19C2D,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x19B3E, 0x19A4E, 0x1995D, 0x1986B, 0x19778, 0x19684, 0x1958F,

0x19499,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x193A2, 0x192AA, 0x191B1, 0x190B8, 0x18FBD, 0x18EC1, 0x18DC4,

0x18CC7,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x18BC8, 0x18AC8, 0x189C8, 0x188C6, 0x187C4, 0x186C1, 0x185BC,

0x184B7,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x183B1, 0x182AA, 0x181A2, 0x18099, 0x17F8F, 0x17E84, 0x17D78,

0x17C6C,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x17B5E, 0x17A4F, 0x17940, 0x17830, 0x1771E, 0x1760C, 0x174F9,

0x173E5,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x172D1, 0x171BB, 0x170A4, 0x16F8D, 0x16E74, 0x16D5B, 0x16C41,

0x16B26,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x16A0A, 0x168ED, 0x167CF, 0x166B1, 0x16592, 0x16471, 0x16350,

0x1622E,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x1610B, 0x15FE8, 0x15EC3, 0x15D9E, 0x15C78, 0x15B51, 0x15A29,

0x15900,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x157D7, 0x156AC, 0x15581, 0x15455, 0x15328, 0x151FB, 0x150CC,

0x14F9D,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x14E6D, 0x14D3C, 0x14C0A, 0x14AD8, 0x149A4, 0x14870, 0x1473B,

0x14606,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x144CF, 0x14398, 0x14260, 0x14127, 0x13FEE, 0x13EB3, 0x13D78,

0x13C3C,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x13B00, 0x139C2, 0x13884, 0x13745, 0x13606, 0x134C5, 0x13384,

0x13242,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x130FF, 0x12FBC, 0x12E78, 0x12D33, 0x12BEE, 0x12AA7, 0x12960,

0x12819,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x126D0, 0x12587, 0x1243D, 0x122F3, 0x121A8, 0x1205C, 0x11F0F,

0x11DC2,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x11C74, 0x11B25, 0x119D6, 0x11886, 0x11735, 0x115E3, 0x11491,

0x1133F,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x111EB, 0x11097, 0x10F42, 0x10dED, 0x10C97, 0x10B40, 0x109E9,

0x10891,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x10738, 0x105DF, 0x10485, 0x1032B, 0x101D0, 0x10074, 0x0FF18,

0x0FDBB,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0FC5D, 0x0FAFF, 0x0F9A0, 0x0F841, 0x0F6E1, 0x0F580, 0x0F41F,

0x0F2BD,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0F15B, 0x0EFF8, 0x0EE94, 0x0ED30, 0x0EBCC, 0x0EA67, 0x0E901,

0x0E79A,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0E633, 0x0E4CC, 0x0E364, 0x0E1FB, 0x0E092, 0x0DF29, 0x0DDBE,

0x0DC54,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0DAE9, 0x0D97D, 0x0D810, 0x0D6A4, 0x0D536, 0x0D3C8,

0x0D25A, 0x0D0EB,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0CF7C, 0x0CE0C, 0x0CC9C, 0x0CB2B, 0x0C9B9, 0x0C847,

0x0C6D5, 0x0C562,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0C3EF, 0x0C27B, 0x0C107, 0x0BF92, 0x0BE1D, 0x0BCA8, 0x0BB32,

0x0B9BB,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0B844, 0x0B6CD, 0x0B555, 0x0B3DD, 0x0B264, 0x0B0EB,

0x0AF71, 0x0ADF7,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0AC7D, 0x0AB02, 0x0A987, 0x0A80B, 0x0A68F, 0x0A513, 0x0A396,

0x0A219,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0A09B, 0x09F1D, 0x09D9E, 0x09C20, 0x09AA1, 0x09921, 0x097A1,

0x09621,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x094A0, 0x0931F, 0x0919E, 0x0901C, 0x08E9A, 0x08D18, 0x08B95,

0x08A12,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0888F, 0x0870B, 0x08587, 0x08402, 0x0827E, 0x080F9, 0x07F73,

0x07DEE,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x07C68, 0x07AE2, 0x0795B, 0x077D4, 0x0764D, 0x074C6, 0x0733E,

0x071B6,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0702E, 0x06EA6, 0x06D1D, 0x06B94, 0x06A0B, 0x06881, 0x066F7,

0x0656D,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x063E3, 0x06258, 0x060CE, 0x05F43, 0x05DB7, 0x05C2C, 0x05AA0,

0x05914,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x05788, 0x055FC, 0x0546F, 0x052E3, 0x05156, 0x04FC9, 0x04E3B,

0x04CAE,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x04B20, 0x04992, 0x04804, 0x04676, 0x044E8, 0x04359, 0x041CB,

0x0403C,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x03EAD, 0x03D1D, 0x03B8E, 0x039FF, 0x0386F, 0x036DF, 0x0354F,

0x033BF,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0322F, 0x0309F, 0x02F0F, 0x02D7E, 0x02BEE, 0x02A5D, 0x028CC,

0x0273B,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x025AA, 0x02419, 0x02288, 0x020F7, 0x01F65, 0x01DD4, 0x01C43,

0x01AB1,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	0x0191F, 0x0178E, 0x015FC, 0x0146A, 0x012D8, 0x01147, 0x00FB5,

0x00E23,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+	0x00C91, 0x00AFF, 0x0096D, 0x007DB, 0x00648, 0x004B6, 0x00324,
+0x00192};
+
+	acc_reg_write(d, HWPfFftRamPageAccess, ACC200_FFT_RAM_EN +

64);

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+	for (i = 0; i < ACC200_FFT_RAM_SIZE; i++)
+		acc_reg_write(d, HWPfFftRamOff + i * 4, fft_lut[i]);
+	acc_reg_write(d, HWPfFftRamPageAccess, ACC200_FFT_RAM_DIS);
+
+	/* Enabling AQueues through the Queue hierarchy*/
+	for (vf_idx = 0; vf_idx < ACC200_NUM_VFS; vf_idx++) {
+		for (qg_idx = 0; qg_idx < ACC200_NUM_QGRPS; qg_idx++) {
+			value = 0;
+			if (vf_idx < conf->num_vf_bundles &&

drivers/baseband/acc/rte_acc200_pmd.c static int acc200_pci_probe(struct rte_pci_driver *pci_drv,

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+					qg_idx < totalQgs)
+				value = (1 << aqNum(qg_idx, conf)) - 1;
+			address = HWPfQmgrAqEnableVf
+					+ vf_idx * ACC_BYTES_IN_WORD;
+			value += (qg_idx << 16);
+			acc_reg_write(d, address, value);
+		}
+	}
+
+	rte_bbdev_log_debug("PF Tip configuration complete for %s",

dev_name);

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+	return 0;
+}
drivers/baseband/acc/version.map +1 -0
index b4ff13e..27fbbe3 100644
@@ -6,4 +6,5 @@ EXPERIMENTAL {
  	global:
 
  	rte_acc10x_configure;
+	rte_acc200_configure;
  };
#23 lore raw

Re: [PATCH v4 08/14] baseband/acc: add LDPC processing functions

In reply to Chautru, Nicolas
Quoted 1,864 lines · Nicolas

Hi Maxime,

Quoted 75 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 1:30 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 08/14] baseband/acc: add LDPC processing functions

Hi Nicolas,

I'm finishing reviewing this patch from v4 as I was in the middle of the review when you posted v5. Will continue the other ones on v5.

Quoted 6 lines · Nic Chautru

Adding LDPC encode and decode processing functions.

---
   drivers/baseband/acc/acc_common.h     |   84 ++
   drivers/baseband/acc/rte_acc200_pmd.c | 1526

++++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
   2 files changed, 1606 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/baseband/acc/acc_common.h

Quoted 14 lines

index ae8de9e..b430b45 100644

drivers/baseband/acc/acc_common.h +7 -0
@@ -1300,4 +1300,88 @@ static inline uint32_t hq_index(uint32_t offset)
   	return 0;
   }
 
+static inline void
+acc_enqueue_status(struct rte_bbdev_queue_data *q_data,
+		enum rte_bbdev_enqueue_status status)
+{
+	q_data->enqueue_status = status;
+	q_data->queue_stats.enqueue_status_count[status]++;
+

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset) · line 1319

Quoted 10 lines
drivers/baseband/acc/acc_common.h +9 -0
+	rte_acc_log(WARNING, "Enqueue Status: %s %#"PRIx64"",
+			rte_bbdev_enqueue_status_str(status),
+			q_data-
 queue_stats.enqueue_status_count[status]);
+}
+
+static inline void
+acc_enqueue_invalid(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data,

RTE_BBDEV_ENQ_STATUS_INVALID_OP);

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 6 lines
drivers/baseband/acc/acc_common.h +6 -0
+}
+
+static inline void
+acc_enqueue_ring_full(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data,

RTE_BBDEV_ENQ_STATUS_RING_FULL);

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 6 lines
drivers/baseband/acc/acc_common.h +6 -0
+}
+
+static inline void
+acc_enqueue_queue_full(struct rte_bbdev_queue_data *q_data)
+{
+	acc_enqueue_status(q_data,

RTE_BBDEV_ENQ_STATUS_QUEUE_FULL);

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 7 lines
drivers/baseband/acc/acc_common.h +7 -0
+}
+
+/* Number of available descriptor in ring to enqueue */
+static inline uint32_t
+acc_ring_avail_enq(struct acc_queue *q)
+{
+	return (q->sw_ring_depth - 1 + q->sw_ring_tail - q->sw_ring_head) %

q->sw_ring_depth;

Quoted 13 lines
Quoted 9 lines
drivers/baseband/acc/acc_common.h +7 -0
+}
+
+/* Number of available descriptor in ring to dequeue */
+static inline uint32_t
+acc_ring_avail_deq(struct acc_queue *q)
+{
+	return (q->sw_ring_depth + q->sw_ring_head - q->sw_ring_tail) % q-

sw_ring_depth;
+}

My understanding is that the ring size is a power of 2, it that correct? If so, indead of doing a modulo operation, you could do a AND operation with the ring mask which is less costly.

OK

Quoted 4 lines

Also, I reiterate my comment on previous revision, it looks unbalanced that enq and dec implementations are off-by-one.

I did reply on the other revision. There are not off by one, but quasi-complementary.

Quoted 10 lines

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 9 lines
drivers/baseband/acc/acc_common.h +9 -0
+
+/* Check room in AQ for the enqueues batches into Qmgr */
+static inline int32_t
+acc_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t num_ops)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = q->aq_depth -
+			((q->aq_enqueued - q->aq_dequeued +
+			ACC_MAX_QUEUE_DEPTH) %

ACC_MAX_QUEUE_DEPTH)

Quoted 5 lines

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset) · line 1357

Quoted 3 lines
drivers/baseband/acc/acc_common.h +3 -0
+			- (num_ops >> 7);
+	if (aq_avail <= 0)
+		acc_enqueue_queue_full(q_data);

Shouldn't we raise an error if aq_avail negative?

The error is managed externally ( and will be PMD specific).

Quoted 3 lines

Also this function does not seem related to LDPC processing, since it is not used in that patch. It should belong to next patch.

Thanks, there was an issue this should have been called.

Quoted 601 lines

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 5 lines
drivers/baseband/acc/acc_common.h +4 -0
+	return aq_avail;
+}
+
+/* Calculates number of CBs in processed encoder TB based on 'r' and

input

Quoted 6 lines

+ * length.
+ */

drivers/baseband/acc/acc_common.h +4 -0
+static inline uint8_t
+get_num_cbs_in_tb_ldpc_enc(struct rte_bbdev_op_ldpc_enc *ldpc_enc)
+{
+	uint8_t c, r, crc24_bits = 0;

drivers/baseband/acc/acc_common.h static inline uint32_t hq_index(uint32_t offset)

Quoted 10 lines
drivers/baseband/acc/acc_common.h +10 -0
+	uint16_t k = (ldpc_enc->basegraph == 1 ? 22 : 10) * ldpc_enc->z_c
+		- ldpc_enc->n_filler;
+	uint8_t cbs_in_tb = 0;
+	int32_t length;
+
+	length = ldpc_enc->input.length;
+	r = ldpc_enc->tb_params.r;
+	c = ldpc_enc->tb_params.c;
+	crc24_bits = 0;
+	if (check_bit(ldpc_enc->op_flags,

RTE_BBDEV_LDPC_CRC_24B_ATTACH))

Review

Quoted 11 lines
drivers/baseband/acc/acc_common.h +9 -0
+		crc24_bits = 24;
+	while (length > 0 && r < c) {
+		length -= (k - crc24_bits) >> 3;
+		r++;
+		cbs_in_tb++;
+	}
+	return cbs_in_tb;
+}
+
   #endif /* _ACC_COMMON_H_ */
(quoted diff) +0 -0

b/drivers/baseband/acc/rte_acc200_pmd.c

drivers/baseband/acc/rte_acc200_pmd.c line 558

Quoted 9 lines

index 355cf8e..1c59559 100644

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
@@ -554,15 +554,50 @@
   	return 0;
   }
 
+static inline void
+acc200_print_op(struct rte_bbdev_dec_op *op, enum rte_bbdev_op_type

op_type,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		uint16_t index)
+{
+	if (op == NULL)
+		return;
+	if (op_type == RTE_BBDEV_OP_LDPC_DEC)
+		rte_bbdev_log(INFO,
+			"  Op 5GUL %d %d %d %d %d %d %d %d %d %d %d

%d",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			index,
+			op->ldpc_dec.basegraph, op->ldpc_dec.z_c,
+			op->ldpc_dec.n_cb, op->ldpc_dec.q_m,
+			op->ldpc_dec.n_filler, op->ldpc_dec.cb_params.e,
+			op->ldpc_dec.op_flags, op->ldpc_dec.rv_index,
+			op->ldpc_dec.iter_max, op->ldpc_dec.iter_count,
+			op->ldpc_dec.harq_combined_input.length
+			);
+	else if (op_type == RTE_BBDEV_OP_LDPC_ENC) {
+		struct rte_bbdev_enc_op *op_dl = (struct rte_bbdev_enc_op

*) op;

Quoted 30 lines
drivers/baseband/acc/rte_acc200_pmd.c +16 -0
+		rte_bbdev_log(INFO,
+			"  Op 5GDL %d %d %d %d %d %d %d %d %d",
+			index,
+			op_dl->ldpc_enc.basegraph, op_dl->ldpc_enc.z_c,
+			op_dl->ldpc_enc.n_cb, op_dl->ldpc_enc.q_m,
+			op_dl->ldpc_enc.n_filler, op_dl-
 ldpc_enc.cb_params.e,
+			op_dl->ldpc_enc.op_flags, op_dl->ldpc_enc.rv_index
+			);
+	}
+}
 
   static int
   acc_queue_stop(struct rte_bbdev *dev, uint16_t queue_id)
   {
   	struct acc_queue *q;
+	struct rte_bbdev_dec_op *op;
+	uint16_t i;
   	q = dev->data->queues[queue_id].queue_private;
   	rte_bbdev_log(INFO, "Queue Stop %d H/T/D %d %d %x OpType %d",
   			queue_id, q->sw_ring_head, q->sw_ring_tail,
   			q->sw_ring_depth, q->op_type);
+	for (i = 0; i < q->sw_ring_depth; ++i) {
+		op = (q->ring_addr + i)->req.op_addr;
+		acc200_print_op(op, q->op_type, i);
+	}
   	/* ignore all operations in flight and clear counters */
   	q->sw_ring_tail = q->sw_ring_head;
   	q->aq_enqueued = 0;

drivers/baseband/acc/rte_acc200_pmd.c line 648

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
@@ -605,6 +640,43 @@
   	struct acc_device *d = dev->data->dev_private;
   	int i;
   	static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
+		{
+			.type   = RTE_BBDEV_OP_LDPC_ENC,
+			.cap.ldpc_enc = {
+				.capability_flags =
+					RTE_BBDEV_LDPC_RATE_MATCH |
+
	RTE_BBDEV_LDPC_CRC_24B_ATTACH |

drivers/baseband/acc/rte_acc200_pmd.c line 649

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_LDPC_INTERLEAVER_BYPASS,

drivers/baseband/acc/rte_acc200_pmd.c line 651

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_src =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 653

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_dst =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+			}
+		},
+		{
+			.type   = RTE_BBDEV_OP_LDPC_DEC,
+			.cap.ldpc_dec = {
+			.capability_flags =
+				RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK |
+				RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP |
+				RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK |
+				RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK |
+

RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE |

drivers/baseband/acc/rte_acc200_pmd.c line 665

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE |

drivers/baseband/acc/rte_acc200_pmd.c line 666

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE |

drivers/baseband/acc/rte_acc200_pmd.c line 667

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+				RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS

|

drivers/baseband/acc/rte_acc200_pmd.c line 669

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER |
+

RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION |

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+				RTE_BBDEV_LDPC_LLR_COMPRESSION,
+			.llr_size = 8,
+			.llr_decimals = 1,
+			.num_buffers_src =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 676

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+			.num_buffers_hard_out =
+

RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,

Quoted 31 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -2
+			.num_buffers_soft_out = 0,
+			}
+		},
   		RTE_BBDEV_END_OF_CAPABILITIES_LIST()
   	};
 
@@ -621,13 +693,15 @@
   	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;
   	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = 0;
   	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = d-

acc_conf.q_ul_5g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+			d->acc_conf.q_ul_5g.num_qgroups;
+	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d-

acc_conf.q_dl_5g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +2 -2
+			d->acc_conf.q_dl_5g.num_qgroups;
   	dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
   	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 0;
   	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d-

acc_conf.q_ul_5g.num_qgroups;

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d-
acc_conf.q_dl_5g.num_qgroups;
   	dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0;
   	dev_info->max_num_queues = 0;
   	for (i = RTE_BBDEV_OP_NONE; i <= RTE_BBDEV_OP_FFT; i++)

drivers/baseband/acc/rte_acc200_pmd.c line 752

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
@@ -670,6 +744,1446 @@
   	{.device_id = 0},
   };
 
+/* Fill in a frame control word for LDPC decoding. */
+static inline void
+acc200_fcw_ld_fill(struct rte_bbdev_dec_op *op, struct acc_fcw_ld *fcw,
+		union acc_harq_layout_data *harq_layout)
+{
+	uint16_t harq_out_length, harq_in_length, ncb_p, k0_p,

parity_offset;

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+	uint32_t harq_index;
+	uint32_t l;
+
+	fcw->qm = op->ldpc_dec.q_m;
+	fcw->nfiller = op->ldpc_dec.n_filler;
+	fcw->BG = (op->ldpc_dec.basegraph - 1);
+	fcw->Zc = op->ldpc_dec.z_c;
+	fcw->ncb = op->ldpc_dec.n_cb;
+	fcw->k0 = get_k0(fcw->ncb, fcw->Zc, op->ldpc_dec.basegraph,
+			op->ldpc_dec.rv_index);
+	if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
+		fcw->rm_e = op->ldpc_dec.cb_params.e;
+	else
+		fcw->rm_e = (op->ldpc_dec.tb_params.r <

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				op->ldpc_dec.tb_params.cab) ?
+						op->ldpc_dec.tb_params.ea :
+						op->ldpc_dec.tb_params.eb;
+
+	if (unlikely(check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE) &&
+			(op->ldpc_dec.harq_combined_input.length == 0))) {
+		rte_bbdev_log(WARNING, "Null HARQ input size provided");
+		/* Disable HARQ input in that case to carry forward */
+		op->ldpc_dec.op_flags ^=

RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE;

Quoted 65 lines
drivers/baseband/acc/rte_acc200_pmd.c +32 -0
+	}
+	if (unlikely(fcw->rm_e == 0)) {
+		rte_bbdev_log(WARNING, "Null E input provided");
+		fcw->rm_e = 2;
+	}
+
+	fcw->hcin_en = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE);
+	fcw->hcout_en = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
+	fcw->crc_select = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK);
+	fcw->bypass_dec = 0;
+	fcw->bypass_intlv = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS);
+	if (op->ldpc_dec.q_m == 1) {
+		fcw->bypass_intlv = 1;
+		fcw->qm = 2;
+	}
+	fcw->hcin_decomp_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+	fcw->hcout_comp_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+	fcw->llr_pack_mode = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_LLR_COMPRESSION);
+	harq_index = hq_index(op->ldpc_dec.harq_combined_output.offset);
+
+	if (fcw->hcin_en > 0) {
+		harq_in_length = op->ldpc_dec.harq_combined_input.length;
+		if (fcw->hcin_decomp_mode > 0)
+			harq_in_length = harq_in_length * 8 / 6;
+		harq_in_length = RTE_MIN(harq_in_length, op-

ldpc_dec.n_cb

drivers/baseband/acc/rte_acc200_pmd.c +32 -0
+				- op->ldpc_dec.n_filler);
+		harq_in_length = RTE_ALIGN_CEIL(harq_in_length, 64);
+		fcw->hcin_size0 = harq_in_length;
+		fcw->hcin_offset = 0;
+		fcw->hcin_size1 = 0;
+	} else {
+		fcw->hcin_size0 = 0;
+		fcw->hcin_offset = 0;
+		fcw->hcin_size1 = 0;
+	}
+
+	fcw->itmax = op->ldpc_dec.iter_max;
+	fcw->itstop = check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE);
+	fcw->cnu_algo = ACC_ALGO_MSA;
+	fcw->synd_precoder = fcw->itstop;
+	/*
+	 * These are all implicitly set
+	 * fcw->synd_post = 0;
+	 * fcw->so_en = 0;
+	 * fcw->so_bypass_rm = 0;
+	 * fcw->so_bypass_intlv = 0;
+	 * fcw->dec_convllr = 0;
+	 * fcw->hcout_convllr = 0;
+	 * fcw->hcout_size1 = 0;
+	 * fcw->so_it = 0;
+	 * fcw->hcout_offset = 0;
+	 * fcw->negstop_th = 0;
+	 * fcw->negstop_it = 0;
+	 * fcw->negstop_en = 0;
+	 * fcw->gain_i = 1;
+	 * fcw->gain_h = 1;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	 */
+	if (fcw->hcout_en > 0) {
+		parity_offset = (op->ldpc_dec.basegraph == 1 ? 20 : 8)
+			* op->ldpc_dec.z_c - op->ldpc_dec.n_filler;
+		k0_p = (fcw->k0 > parity_offset) ?
+				fcw->k0 - op->ldpc_dec.n_filler : fcw->k0;
+		ncb_p = fcw->ncb - op->ldpc_dec.n_filler;
+		l = k0_p + fcw->rm_e;
+		harq_out_length = (uint16_t) fcw->hcin_size0;
+		harq_out_length = RTE_MIN(RTE_MAX(harq_out_length, l),

ncb_p);

Quoted 27 lines
drivers/baseband/acc/rte_acc200_pmd.c +27 -0
+		harq_out_length = RTE_ALIGN_CEIL(harq_out_length, 64);
+		fcw->hcout_size0 = harq_out_length;
+		fcw->hcout_size1 = 0;
+		fcw->hcout_offset = 0;
+		harq_layout[harq_index].offset = fcw->hcout_offset;
+		harq_layout[harq_index].size0 = fcw->hcout_size0;
+	} else {
+		fcw->hcout_size0 = 0;
+		fcw->hcout_size1 = 0;
+		fcw->hcout_offset = 0;
+	}
+
+	fcw->tb_crc_select = 0;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK))
+		fcw->tb_crc_select = 2;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK))
+		fcw->tb_crc_select = 1;
+}
+
+static inline int
+acc200_dma_desc_le_fill(struct rte_bbdev_enc_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *output, uint32_t *in_offset,
+		uint32_t *out_offset, uint32_t *out_length,
+		uint32_t *mbuf_total_left, uint32_t *seg_total_left)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+{
+	int next_triplet = 1; /* FCW already done */
+	uint16_t K, in_length_in_bits, in_length_in_bytes;
+	struct rte_bbdev_op_ldpc_enc *enc = &op->ldpc_enc;
+
+	acc_header_init(desc);
+	K = (enc->basegraph == 1 ? 22 : 10) * enc->z_c;
+	in_length_in_bits = K - enc->n_filler;
+	if ((enc->op_flags & RTE_BBDEV_LDPC_CRC_24A_ATTACH) ||
+			(enc->op_flags &

RTE_BBDEV_LDPC_CRC_24B_ATTACH))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		in_length_in_bits -= 24;
+	in_length_in_bytes = in_length_in_bits >> 3;
+
+	if (unlikely((*mbuf_total_left == 0) ||
+			(*mbuf_total_left < in_length_in_bytes))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and

included CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+				*mbuf_total_left, in_length_in_bytes);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset,
+			in_length_in_bytes,
+			seg_total_left, next_triplet,
+			check_bit(op->ldpc_enc.op_flags,
+			RTE_BBDEV_LDPC_ENC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and

mbuf data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= in_length_in_bytes;
+
+	/* Set output length */
+	/* Integer round up division by 8 */
+	*out_length = (enc->cb_params.e + 7) >> 3;
+
+	next_triplet = acc_dma_fill_blk_type(desc, output, *out_offset,
+			*out_length, next_triplet,

ACC_DMA_BLKID_OUT_ENC);

Quoted 37 lines
drivers/baseband/acc/rte_acc200_pmd.c +37 -0
+	op->ldpc_enc.output.length += *out_length;
+	*out_offset += *out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->data_ptrs[next_triplet - 1].dma_ext = 0;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
+acc200_dma_desc_ld_fill(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf **input, struct rte_mbuf *h_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,
+		uint32_t *h_out_length, uint32_t *mbuf_total_left,
+		uint32_t *seg_total_left,
+		struct acc_fcw_ld *fcw)
+{
+	struct rte_bbdev_op_ldpc_dec *dec = &op->ldpc_dec;
+	int next_triplet = 1; /* FCW already done */
+	uint32_t input_length;
+	uint16_t output_length, crc24_overlap = 0;
+	uint16_t sys_cols, K, h_p_size, h_np_size;
+	bool h_comp = check_bit(dec->op_flags,
+			RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION);
+
+	acc_header_init(desc);
+
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP))
+		crc24_overlap = 24;
+
+	/* Compute some LDPC BG lengths */
+	input_length = fcw->rm_e;
+	if (check_bit(op->ldpc_dec.op_flags,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			RTE_BBDEV_LDPC_LLR_COMPRESSION))
+		input_length = (input_length * 3 + 3) / 4;
+	sys_cols = (dec->basegraph == 1) ? 22 : 10;
+	K = sys_cols * dec->z_c;
+	output_length = K - dec->n_filler - crc24_overlap;
+
+	if (unlikely((*mbuf_total_left == 0) ||
+			(*mbuf_total_left < input_length))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and

included CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+				*mbuf_total_left, input_length);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input,
+			in_offset, input_length,
+			seg_total_left, next_triplet,
+			check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEC_SCATTER_GATHER));
+
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and

mbuf data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c line 953

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+				op);
+		return -1;
+	}
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) {
Quoted 21 lines
drivers/baseband/acc/rte_acc200_pmd.c +21 -0
+		if (op->ldpc_dec.harq_combined_input.data == 0) {
+			rte_bbdev_log(ERR, "HARQ input is not defined");
+			return -1;
+		}
+		h_p_size = fcw->hcin_size0 + fcw->hcin_size1;
+		if (h_comp)
+			h_p_size = (h_p_size * 3 + 3) / 4;
+		if (op->ldpc_dec.harq_combined_input.data == 0) {
+			rte_bbdev_log(ERR, "HARQ input is not defined");
+			return -1;
+		}
+		acc_dma_fill_blk_type(
+				desc,
+				op->ldpc_dec.harq_combined_input.data,
+				op->ldpc_dec.harq_combined_input.offset,
+				h_p_size,
+				next_triplet,
+				ACC_DMA_BLKID_IN_HARQ);
+		next_triplet++;
+	}
+

drivers/baseband/acc/rte_acc200_pmd.c line 1021

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= input_length;
+
+	next_triplet = acc_dma_fill_blk_type(desc, h_output,
+			*h_out_offset, output_length >> 3, next_triplet,
+			ACC_DMA_BLKID_OUT_HARD);
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) {
Quoted 43 lines
drivers/baseband/acc/rte_acc200_pmd.c +43 -0
+		if (op->ldpc_dec.harq_combined_output.data == 0) {
+			rte_bbdev_log(ERR, "HARQ output is not defined");
+			return -1;
+		}
+
+		/* Pruned size of the HARQ */
+		h_p_size = fcw->hcout_size0 + fcw->hcout_size1;
+		/* Non-Pruned size of the HARQ */
+		h_np_size = fcw->hcout_offset > 0 ?
+				fcw->hcout_offset + fcw->hcout_size1 :
+				h_p_size;
+		if (h_comp) {
+			h_np_size = (h_np_size * 3 + 3) / 4;
+			h_p_size = (h_p_size * 3 + 3) / 4;
+		}
+		dec->harq_combined_output.length = h_np_size;
+		acc_dma_fill_blk_type(
+				desc,
+				dec->harq_combined_output.data,
+				dec->harq_combined_output.offset,
+				h_p_size,
+				next_triplet,
+				ACC_DMA_BLKID_OUT_HARQ);
+
+		next_triplet++;
+	}
+
+	*h_out_length = output_length >> 3;
+	dec->hard_output.length += *h_out_length;
+	*h_out_offset += *h_out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline void
+acc200_dma_desc_ld_update(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc,
+		struct rte_mbuf *input, struct rte_mbuf *h_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,

drivers/baseband/acc/rte_acc200_pmd.c line 1075

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		uint32_t *h_out_length,
+		union acc_harq_layout_data *harq_layout)
+{
+	int next_triplet = 1; /* FCW already done */
+	desc->data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(input, *in_offset);
+	next_triplet++;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE)) {
Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		struct rte_bbdev_op_data hi = op-

ldpc_dec.harq_combined_input;

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+		desc->data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(hi.data, hi.offset);

drivers/baseband/acc/rte_acc200_pmd.c line 1098

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		next_triplet++;
+	}
+
+	desc->data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(h_output, *h_out_offset);
+	*h_out_length = desc->data_ptrs[next_triplet].blen;
+	next_triplet++;
+
+	if (check_bit(op->ldpc_dec.op_flags,
+
	RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE)) {
Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		/* Adjust based on previous operation */
+		struct rte_bbdev_dec_op *prev_op = desc->op_addr;
+		op->ldpc_dec.harq_combined_output.length =
+				prev_op-

ldpc_dec.harq_combined_output.length;

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+		uint32_t harq_idx = hq_index(
+				op-

ldpc_dec.harq_combined_output.offset);

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+		uint32_t prev_harq_idx = hq_index(
+				prev_op-

ldpc_dec.harq_combined_output.offset);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		harq_layout[harq_idx].val = harq_layout[prev_harq_idx].val;
+		struct rte_bbdev_op_data ho =
+				op->ldpc_dec.harq_combined_output;
+		desc->data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(ho.data,

ho.offset);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+		next_triplet++;
+	}
+
+	op->ldpc_dec.hard_output.length += *h_out_length;
+	desc->op_addr = op;
+}
+
+/* Enqueue one encode operations for ACC200 device in CB mode
+ * multiplexed on the same descriptor
+ */
+static inline int
+enqueue_ldpc_enc_n_op_cb(struct acc_queue *q, struct

rte_bbdev_enc_op **ops,

Quoted 33 lines
drivers/baseband/acc/rte_acc200_pmd.c +27 -0
+		uint16_t total_enqueued_descs, int16_t num)
+{
+	union acc_dma_desc *desc = NULL;
+	uint32_t out_length;
+	struct rte_mbuf *output_head, *output;
+	int i, next_triplet;
+	uint16_t  in_length_in_bytes;
+	struct rte_bbdev_op_ldpc_enc *enc = &ops[0]->ldpc_enc;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(ops[0], &desc->req.fcw_le, num, 0);
+
+	/** This could be done at polling */
+	acc_header_init(&desc->req);
+	desc->req.numCBs = num;
+
+	in_length_in_bytes = ops[0]->ldpc_enc.input.data->data_len;
+	out_length = (enc->cb_params.e + 7) >> 3;
+	desc->req.m2dlen = 1 + num;
+	desc->req.d2mlen = num;
+	next_triplet = 1;
+
+	for (i = 0; i < num; i++) {
+		desc->req.data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(ops[i]-

ldpc_enc.input.data, 0);

drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		desc->req.data_ptrs[next_triplet].blen = in_length_in_bytes;
+		next_triplet++;
+		desc->req.data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(
+				ops[i]->ldpc_enc.output.data, 0);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		desc->req.data_ptrs[next_triplet].blen = out_length;
+		next_triplet++;
+		ops[i]->ldpc_enc.output.length = out_length;
+		output_head = output = ops[i]->ldpc_enc.output.data;
+		mbuf_append(output_head, output, out_length);
+		output->data_len = out_length;
+	}
+
+	desc->req.op_addr = ops[0];
+	/* Keep track of pointers even when multiplexed in single descriptor

*/

Quoted 3 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	struct acc_ptrs *context_ptrs = q->companion_ring_addr + desc_idx;

Don't mix declarations & code.

OK

Quoted 13 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1160

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num; i++)
+		context_ptrs->ptr[i].op_addr = ops[i];
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+	/* One CB (one op) was successfully prepared to enqueue */

my understanding is that it is num CB, not one.

Thansk

Quoted 129 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	return num;
+}
+
+/* Enqueue one encode operations for ACC200 device for a partial TB
+ * all codes blocks have same configuration multiplexed on the same

descriptor

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines

+ */

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+static inline void
+enqueue_ldpc_enc_part_tb(struct acc_queue *q, struct

rte_bbdev_enc_op *op,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		uint16_t total_enqueued_descs, int16_t num_cbs, uint32_t

e,

Quoted 23 lines
drivers/baseband/acc/rte_acc200_pmd.c +23 -0
+		uint16_t in_len_B, uint32_t out_len_B, uint32_t *in_offset,
+		uint32_t *out_offset)
+{
+
+	union acc_dma_desc *desc = NULL;
+	struct rte_mbuf *output_head, *output;
+	int i, next_triplet;
+	struct rte_bbdev_op_ldpc_enc *enc = &op->ldpc_enc;
+
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(op, &desc->req.fcw_le, num_cbs, e);
+
+	/** This could be done at polling */
+	acc_header_init(&desc->req);
+	desc->req.numCBs = num_cbs;
+
+	desc->req.m2dlen = 1 + num_cbs;
+	desc->req.d2mlen = num_cbs;
+	next_triplet = 1;
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num_cbs; i++) {
+		desc->req.data_ptrs[next_triplet].address =
+			rte_pktmbuf_iova_offset(enc->input.data,
+					*in_offset);
+		*in_offset += in_len_B;
+		desc->req.data_ptrs[next_triplet].blen = in_len_B;
+		next_triplet++;
+		desc->req.data_ptrs[next_triplet].address =
+				rte_pktmbuf_iova_offset(
+						enc->output.data,

*out_offset);

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+		*out_offset += out_len_B;
+		desc->req.data_ptrs[next_triplet].blen = out_len_B;
+		next_triplet++;
+		enc->output.length += out_len_B;
+		output_head = output = enc->output.data;
+		mbuf_append(output_head, output, out_len_B);
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+
+}
+
+/* Enqueue one encode operations for ACC200 device in CB mode */
+static inline int
+enqueue_ldpc_enc_one_op_cb(struct acc_queue *q, struct

rte_bbdev_enc_op *op,

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_le_fill(op, &desc->req.fcw_le, 1, 0);
+
+	input = op->ldpc_enc.input.data;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	output_head = output = op->ldpc_enc.output.data;
+	in_offset = op->ldpc_enc.input.offset;
+	out_offset = op->ldpc_enc.output.offset;
+	out_length = 0;
+	mbuf_total_left = op->ldpc_enc.input.length;
+	seg_total_left = rte_pktmbuf_data_len(op->ldpc_enc.input.data)
+			- in_offset;
+
+	ret = acc200_dma_desc_le_fill(op, &desc->req, &input, output,
+			&in_offset, &out_offset, &out_length,

&mbuf_total_left,

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +14 -0
+			&seg_total_left);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	mbuf_append(output_head, output, out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_le,
+			sizeof(desc->req.fcw_le) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+#endif
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+/* Enqueue one encode operations for ACC200 device in TB mode.
+ * returns the number of descs used
+ */
+static inline int
+enqueue_ldpc_enc_one_op_tb(struct acc_queue *q, struct

rte_bbdev_enc_op *op,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+		uint16_t enq_descs, uint8_t cbs_in_tb)
+{
+	uint8_t num_a, num_b;
+	uint16_t desc_idx;
+	uint8_t r = op->ldpc_enc.tb_params.r;
+	uint8_t cab =  op->ldpc_enc.tb_params.cab;
+	union acc_dma_desc *desc;
+	uint16_t init_enq_descs = enq_descs;
+	uint16_t input_len_B = ((op->ldpc_enc.basegraph == 1 ? 22 : 10) *
+			op->ldpc_enc.z_c) >> 3;
+	if (check_bit(op->ldpc_enc.op_flags,

RTE_BBDEV_LDPC_CRC_24B_ATTACH))

Quoted 12 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1290

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		input_len_B -= 3;
+
+	if (r < cab) {
+		num_a = cab - r;
+		num_b = cbs_in_tb - cab;
+	} else {
+		num_a = 0;
+		num_b = cbs_in_tb - r;
+	}
+	uint32_t in_offset = 0, out_offset = 0;

Don't mix declarations & code.

OK

Quoted 19 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+	while (num_a > 0) {
+		uint32_t e = op->ldpc_enc.tb_params.ea;
+		uint32_t out_len_B = (e + 7) >> 3;
+		uint8_t enq = RTE_MIN(num_a, ACC_MUX_5GDL_DESC);
+		num_a -= enq;
+		enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e,

input_len_B,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+				out_len_B, &in_offset, &out_offset);
+		enq_descs++;
+	}
+	while (num_b > 0) {
+		uint32_t e = op->ldpc_enc.tb_params.eb;
+		uint32_t out_len_B = (e + 7) >> 3;
+		uint8_t enq = RTE_MIN(num_b, ACC_MUX_5GDL_DESC);
+		num_b -= enq;
+		enqueue_ldpc_enc_part_tb(q, op, enq_descs, enq, e,

input_len_B,

Quoted 7 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1311

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+				out_len_B, &in_offset, &out_offset);
+		enq_descs++;
+	}
+
+	uint16_t return_descs = enq_descs - init_enq_descs;

Don't mix declarations & code.

OK

Quoted 23 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	/* Keep total number of CBs in first TB */
+	desc_idx = ((q->sw_ring_head + init_enq_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	desc->req.cbs_in_tb = return_descs; /** Actual number of

descriptors */

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	desc->req.op_addr = op;
+
+	/* Set SDone on last CB descriptor for TB mode. */
+	desc_idx = ((q->sw_ring_head + enq_descs - 1)
+			& q->sw_ring_wrap_mask);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	desc = q->ring_addr + desc_idx;
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+	desc->req.op_addr = op;
+	return return_descs;
+}
+
+/** Enqueue one decode operations for ACC200 device in CB mode */
+static inline int
+enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct

rte_bbdev_dec_op *op,

Quoted 7 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1336

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		uint16_t total_enqueued_cbs, bool same_op)
+{
+	int ret, hq_len;
+	if (op->ldpc_dec.cb_params.e == 0)
+		return -EINVAL;

Don't mix declarations & code.

OK

Quoted 9 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1342

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	union acc_dma_desc *desc;
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	struct rte_mbuf *input, *h_output_head, *h_output;

Don't mix declarations & code.

Quoted 15 lines
Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	uint32_t in_offset, h_out_offset, mbuf_total_left, h_out_length = 0;
+	input = op->ldpc_dec.input.data;
+	h_output_head = h_output = op->ldpc_dec.hard_output.data;

drivers/baseband/acc/rte_acc200_pmd.c line 1355

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	in_offset = op->ldpc_dec.input.offset;
+	h_out_offset = op->ldpc_dec.hard_output.offset;
+	mbuf_total_left = op->ldpc_dec.input.length;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(input == NULL)) {
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif
+	union acc_harq_layout_data *harq_layout = q->d->harq_layout;

Don't mix declarations & code.

OK

Quoted 209 lines
Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+	if (same_op) {
+		union acc_dma_desc *prev_desc;
+		desc_idx = ((q->sw_ring_head + total_enqueued_cbs - 1)
+				& q->sw_ring_wrap_mask);
+		prev_desc = q->ring_addr + desc_idx;
+		uint8_t *prev_ptr = (uint8_t *) prev_desc;
+		uint8_t *new_ptr = (uint8_t *) desc;
+		/* Copy first 4 words and BDESCs */

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		rte_memcpy(new_ptr, prev_ptr, ACC_5GUL_SIZE_0);
+		rte_memcpy(new_ptr + ACC_5GUL_OFFSET_0,
+				prev_ptr + ACC_5GUL_OFFSET_0,
+				ACC_5GUL_SIZE_1);
+		desc->req.op_addr = prev_desc->req.op_addr;
+		/* Copy FCW */
+		rte_memcpy(new_ptr + ACC_DESC_FCW_OFFSET,
+				prev_ptr + ACC_DESC_FCW_OFFSET,
+				ACC_FCW_LD_BLEN);
+		acc200_dma_desc_ld_update(op, &desc->req, input,

h_output,

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+				&in_offset, &h_out_offset,
+				&h_out_length, harq_layout);
+	} else {
+		struct acc_fcw_ld *fcw;
+		uint32_t seg_total_left;
+		fcw = &desc->req.fcw_ld;
+		acc200_fcw_ld_fill(op, fcw, harq_layout);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+		/* Special handling when using mbuf or not */
+		if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))
+			seg_total_left = rte_pktmbuf_data_len(input)
+					- in_offset;
+		else
+			seg_total_left = fcw->rm_e;
+
+		ret = acc200_dma_desc_ld_fill(op, &desc->req, &input,

h_output,

Quoted 14 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+				&in_offset, &h_out_offset,
+				&h_out_length, &mbuf_total_left,
+				&seg_total_left, fcw);
+		if (unlikely(ret < 0))
+			return ret;
+	}
+
+	/* Hard output */
+	mbuf_append(h_output_head, h_output, h_out_length);
+	if (op->ldpc_dec.harq_combined_output.length > 0) {
+		/* Push the HARQ output into host memory */
+		struct rte_mbuf *hq_output_head, *hq_output;
+		hq_output_head = op-

ldpc_dec.harq_combined_output.data;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		hq_output = op->ldpc_dec.harq_combined_output.data;
+		hq_len = op->ldpc_dec.harq_combined_output.length;
+		if (unlikely(!mbuf_append(hq_output_head, hq_output,
+				hq_len))) {
+			rte_bbdev_log(ERR, "HARQ output mbuf issue %d

%d\n",

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+					hq_output->buf_len,
+					hq_len);
+			return -1;
+		}
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
+			sizeof(desc->req.fcw_ld) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+#endif
+
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+
+/* Enqueue one decode operations for ACC200 device in TB mode */
+static inline int
+enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct

rte_bbdev_dec_op *op,

Quoted 118 lines
drivers/baseband/acc/rte_acc200_pmd.c +118 -0
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb)
+{
+	union acc_dma_desc *desc = NULL;
+	union acc_dma_desc *desc_first = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, h_out_offset,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output;
+	uint16_t current_enqueued_cbs = 0;
+	uint16_t sys_cols, trail_len = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	desc_first = desc;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	union acc_harq_layout_data *harq_layout = q->d->harq_layout;
+	acc200_fcw_ld_fill(op, &desc->req.fcw_ld, harq_layout);
+
+	input = op->ldpc_dec.input.data;
+	h_output_head = h_output = op->ldpc_dec.hard_output.data;
+	in_offset = op->ldpc_dec.input.offset;
+	h_out_offset = op->ldpc_dec.hard_output.offset;
+	h_out_length = 0;
+	mbuf_total_left = op->ldpc_dec.input.length;
+	c = op->ldpc_dec.tb_params.c;
+	r = op->ldpc_dec.tb_params.r;
+	if (check_bit(op->ldpc_dec.op_flags,
+			RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK)) {
+		sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10;
+		trail_len = sys_cols * op->ldpc_dec.z_c -
+				op->ldpc_dec.n_filler - 24;
+	}
+
+	while (mbuf_total_left > 0 && r < c) {
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))
+			seg_total_left = rte_pktmbuf_data_len(input)
+					- in_offset;
+		else
+			seg_total_left = op->ldpc_dec.input.length;
+		/* Set up DMA descriptor */
+		desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+				& q->sw_ring_wrap_mask);
+		desc = q->ring_addr + desc_idx;
+		fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +
+				fcw_offset;
+		desc->req.data_ptrs[0].blen = ACC_FCW_LD_BLEN;
+		rte_memcpy(&desc->req.fcw_ld, &desc_first->req.fcw_ld,
+				ACC_FCW_LD_BLEN);
+		desc->req.fcw_ld.tb_trailer_size = (c - r - 1) * trail_len;
+
+		ret = acc200_dma_desc_ld_fill(op, &desc->req, &input,
+				h_output, &in_offset, &h_out_offset,
+				&h_out_length,
+				&mbuf_total_left, &seg_total_left,
+				&desc->req.fcw_ld);
+
+		if (unlikely(ret < 0))
+			return ret;
+
+		/* Hard output */
+		mbuf_append(h_output_head, h_output, h_out_length);
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_td,
+				sizeof(desc->req.fcw_td) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+#endif
+		if (check_bit(op->ldpc_dec.op_flags,
+				RTE_BBDEV_LDPC_DEC_SCATTER_GATHER)
+				&& (seg_total_left == 0)) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			h_output = h_output->next;
+			h_out_offset = 0;
+		}
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+	/* Set SDone on last CB descriptor for TB mode */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
+/** Enqueue encode operations for ACC200 device in CB mode. */
+static inline uint16_t
+acc200_enqueue_ldpc_enc_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i = 0;
+	union acc_dma_desc *desc;
+	int ret, desc_idx = 0;
+	int16_t enq, left = num;
+
+	while (left > 0) {
+		if (unlikely(avail < 1)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail--;
+		enq = RTE_MIN(left, ACC_MUX_5GDL_DESC);
+		enq = check_mux(&ops[i], enq);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		if (enq > 1) {
+			ret = enqueue_ldpc_enc_n_op_cb(q, &ops[i],
+					desc_idx, enq);
+			if (ret < 0) {
+				acc_enqueue_invalid(q_data);
+				break;
+			}
+			i += enq;
+		} else {
+			ret = enqueue_ldpc_enc_one_op_cb(q, ops[i],

desc_idx);

Quoted 8 lines

Looking at the code of enqueue_ldpc_enc_one_op_cb and enqueue_ldpc_enc_n_op_cb, there should not be much performance difference by only using enqueue_ldpc_enc_n_op_cb even for single enc.

It even looks like enqueue_ldpc_enc_one_op_cb is heavier, could you explain the difference?

It would make maintainance easier to have a single function.

That's a good point. Thanks.

Quoted 97 lines
Quoted 63 lines
drivers/baseband/acc/rte_acc200_pmd.c +41 -0
+			if (ret < 0) {
+				acc_enqueue_invalid(q_data);
+				break;
+			}
+			i++;
+		}
+		desc_idx++;
+		left = num - i;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + desc_idx - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, desc_idx, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}
+
+/* Enqueue LDPC encode operations for ACC200 device in TB mode. */
+static uint16_t
+acc200_enqueue_ldpc_enc_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_descs = 0;
+	uint8_t cbs_in_tb;
+	int descs_used;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_ldpc_enc(&ops[i]-

ldpc_enc);

drivers/baseband/acc/rte_acc200_pmd.c +20 -0
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+
+		descs_used = enqueue_ldpc_enc_one_op_tb(q, ops[i],
+				enqueued_descs, cbs_in_tb);
+		if (descs_used < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_descs += descs_used;
+		avail -= descs_used;
+	}
+	if (unlikely(enqueued_descs == 0))
+		return 0; /* Nothing to enqueue */
+
+	acc_dma_enqueue(q, enqueued_descs, &q_data->queue_stats);
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}
+
+/* Check room in AQ for the enqueues batches into Qmgr */
+static int32_t
+acc200_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t

num_ops)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = q->aq_depth -
+			((q->aq_enqueued - q->aq_dequeued +
+			ACC_MAX_QUEUE_DEPTH) %

ACC_MAX_QUEUE_DEPTH)

drivers/baseband/acc/rte_acc200_pmd.c line 1646

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+			- (num_ops >> 7);
+	if (aq_avail <= 0)
+		acc_enqueue_queue_full(q_data);
+	return aq_avail;
+}
+
+/* Enqueue encode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t aq_avail = acc_ring_avail_enq(q);

Introducing new line here and after the return 0 would not hurt and improve readability.

Quoted 2 lines

This is a general comment for the series, which lacks consistency on this point.

Well is there any general recommendation we could put on DPDK on that?
This is quite subjective really but happy to follow any guidelines if we can capture them. For small functions like these I am not sure it helps readability.

Quoted 71 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->ldpc_enc.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 52 lines
drivers/baseband/acc/rte_acc200_pmd.c +18 -0
+		return acc200_enqueue_ldpc_enc_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_ldpc_enc_cb(q_data, ops, num);
+}
+
+/* Enqueue decode operations for ACC200 device in TB mode */
+static uint16_t
+acc200_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_ldpc_dec(&ops[i]-

ldpc_dec);

drivers/baseband/acc/rte_acc200_pmd.c +33 -0
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) ||
+				(cbs_in_tb == 0)))
+			break;
+		avail -= cbs_in_tb;
+
+		ret = enqueue_ldpc_dec_one_op_tb(q, ops[i],
+				enqueued_cbs, cbs_in_tb);
+		if (ret <= 0)
+			break;
+		enqueued_cbs += ret;
+	}
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+/* Enqueue decode operations for ACC200 device in CB mode */
+static uint16_t
+acc200_enqueue_ldpc_dec_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+	bool same_op = false;
+	for (i = 0; i < num; ++i) {

drivers/baseband/acc/rte_acc200_pmd.c line 1710

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		/* Check if there are available space for further processing */
+		if (unlikely(avail < 1)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= 1;
+#ifdef ACC200_DESC_OPTIMIZATION
+		if (i > 0)
+			same_op = cmp_ldpc_dec_op(&ops[i-1]);
+#endif

I think I made same comment on the series about ACC100 changes for v22.11.

Quoted 8 lines

Such optimizations under #ifdefs are not welcome, as either we need to multiply the number of build tests to cover all the code in CI, or we never compile test this code.

Can you ellaborate when you need it, and when you don't? Is it safe to have this optimization by default, if not why?

If not safe, then just remove it, if safe, make it the default.

Agreed, will take out.

Quoted 20 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		rte_bbdev_log(INFO, "Op %d %d %d %d %d %d %d %d %d %d

%d %d\n",

Quoted 17 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			i, ops[i]->ldpc_dec.op_flags, ops[i]-

ldpc_dec.rv_index,

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			ops[i]->ldpc_dec.iter_max, ops[i]-

ldpc_dec.iter_count,

drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+			ops[i]->ldpc_dec.basegraph, ops[i]->ldpc_dec.z_c,
+			ops[i]->ldpc_dec.n_cb, ops[i]->ldpc_dec.q_m,
+			ops[i]->ldpc_dec.n_filler, ops[i]-

ldpc_dec.cb_params.e,

drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+			same_op);
+		ret = enqueue_ldpc_dec_one_op_cb(q, ops[i], i, same_op);
+		if (ret < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+	}
+
+	if (unlikely(i == 0))
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1730

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);

I think having helpers to fetch descriptors would make the code easier to read and also would ease maintainance.

This can be looked at post 22.11 I believe. But noted.

Quoted 438 lines
Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+/* Enqueue decode operations for ACC200 device. */
+static uint16_t
+acc200_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num)
+{
+	int32_t aq_avail = acc200_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->ldpc_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		return acc200_enqueue_ldpc_dec_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_ldpc_dec_cb(q_data, ops, num);
+}
+
+
+/* Dequeue one encode operations from ACC200 device in CB mode
+ */
+static inline int
+dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op

**ref_op,

Quoted 45 lines
drivers/baseband/acc/rte_acc200_pmd.c +45 -0
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued,
+		uint16_t *dequeued_descs)
+{
+	union acc_dma_desc *desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_enc_op *op;
+	int i;
+	int desc_idx = ((q->sw_ring_tail + *dequeued_descs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	rsp.val = atom_desc.rsp.val;
+	rte_bbdev_log_debug("Resp. desc %p: %x", desc, rsp.val);
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	op->status |= ((rsp.input_err)
+			? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+	op->status |= ((rsp.dma_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+	op->status |= ((rsp.fcw_err) ? (1 << RTE_BBDEV_DRV_ERROR) : 0);
+
+	if (desc->req.last_desc_in_batch) {
+		(*aq_dequeued)++;
+		desc->req.last_desc_in_batch = 0;
+	}
+	desc->rsp.val = ACC_DMA_DESC_TYPE;
+	desc->rsp.add_info_0 = 0; /*Reserved bits */
+	desc->rsp.add_info_1 = 0; /*Reserved bits */
+
+	ref_op[0] = op;
+	struct acc_ptrs *context_ptrs = q->companion_ring_addr + desc_idx;
+	for (i = 1 ; i < desc->req.numCBs; i++)
+		ref_op[i] = context_ptrs->ptr[i].op_addr;
+
+	/* One op was successfully dequeued */

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	(*dequeued_descs)++;
+	*dequeued_ops += desc->req.numCBs;
+	return desc->req.numCBs;
+}
+
+/* Dequeue one LDPC encode operations from ACC200 device in TB mode
+ * That operation may cover multiple descriptors
+ */
+static inline int
+dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op

**ref_op,

Quoted 41 lines
drivers/baseband/acc/rte_acc200_pmd.c +41 -0
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued,
+		uint16_t *dequeued_descs)
+{
+	union acc_dma_desc *desc, *last_desc, atom_desc;
+	union acc_dma_rsp_desc rsp;
+	struct rte_bbdev_enc_op *op;
+	uint8_t i = 0;
+	uint16_t current_dequeued_descs = 0, descs_in_tb;
+
+	desc = q->ring_addr + ((q->sw_ring_tail + *dequeued_descs)
+			& q->sw_ring_wrap_mask);
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+			__ATOMIC_RELAXED);
+
+	/* Check fdone bit */
+	if (!(atom_desc.rsp.val & ACC_FDONE))
+		return -1;
+
+	/* Get number of CBs in dequeued TB */
+	descs_in_tb = desc->req.cbs_in_tb;
+	/* Get last CB */
+	last_desc = q->ring_addr + ((q->sw_ring_tail
+			+ *dequeued_descs + descs_in_tb - 1)
+			& q->sw_ring_wrap_mask);
+	/* Check if last CB in TB is ready to dequeue (and thus
+	 * the whole TB) - checking sdone bit. If not return.
+	 */
+	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)last_desc,
+			__ATOMIC_RELAXED);
+	if (!(atom_desc.rsp.val & ACC_SDONE))
+		return -1;
+
+	/* Dequeue */
+	op = desc->req.op_addr;
+
+	/* Clearing status, it will be set based on response */
+	op->status = 0;
+
+	while (i < descs_in_tb) {
+		desc = q->ring_addr + ((q->sw_ring_tail
+				+ *dequeued_descs)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				& q->sw_ring_wrap_mask);
+		atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc,
+				__ATOMIC_RELAXED);
+		rsp.val = atom_desc.rsp.val;
+		rte_bbdev_log_debug("Resp. desc %p: %x", desc,
+				rsp.val);
+
+		op->status |= ((rsp.input_err)
+				? (1 << RTE_BBDEV_DATA_ERROR) : 0);
+		op->status |= ((rsp.dma_err) ? (1 <<

RTE_BBDEV_DRV_ERROR) : 0);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		op->status |= ((rsp.fcw_err) ? (1 <<

RTE_BBDEV_DRV_ERROR) : 0);

292 lines not shown · raw message

Quoted 8 lines

7 lines not shown · raw message

Quoted 1 line

1 line not shown · raw message

54 lines not shown · raw message

Part of this message is not shown here. View the raw message.

#27 lore raw

Re: [PATCH v4 09/14] baseband/acc: add LTE processing functions

In reply to Chautru, Nicolas
Quoted 608 lines · Nicolas

Hi Maxime,

Quoted 597 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 2:00 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 09/14] baseband/acc: add LTE processing functions

Quoted 5 lines · Nic Chautru

Add functions and capability for 4G FEC

---
   drivers/baseband/acc/rte_acc200_pmd.c | 894

+++++++++++++++++++++++++++++++++-

Quoted 8 lines
   1 file changed, 874 insertions(+), 20 deletions(-)
drivers/baseband/acc/rte_acc200_pmd.c +0 -0
index 1c59559..35ea0fe 100644

drivers/baseband/acc/rte_acc200_pmd.c line 647

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
@@ -641,6 +641,46 @@
   	int i;
   	static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
   		{
+			.type = RTE_BBDEV_OP_TURBO_DEC,
+			.cap.turbo_dec = {
+				.capability_flags =
+

RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+					RTE_BBDEV_TURBO_CRC_TYPE_24B |
+					RTE_BBDEV_TURBO_EQUALIZER |
+

RTE_BBDEV_TURBO_SOFT_OUT_SATURATE |

drivers/baseband/acc/rte_acc200_pmd.c line 651

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_HALF_ITERATION_EVEN |

drivers/baseband/acc/rte_acc200_pmd.c line 652

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH |

drivers/baseband/acc/rte_acc200_pmd.c line 654

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+					RTE_BBDEV_TURBO_SOFT_OUTPUT |
+

RTE_BBDEV_TURBO_EARLY_TERMINATION |

drivers/baseband/acc/rte_acc200_pmd.c line 655

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+
	RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN |

drivers/baseband/acc/rte_acc200_pmd.c line 656

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT |

drivers/baseband/acc/rte_acc200_pmd.c line 658

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+					RTE_BBDEV_TURBO_MAP_DEC |
+
	RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP |

drivers/baseband/acc/rte_acc200_pmd.c line 659

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_DEC_SCATTER_GATHER,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+				.max_llr_modulus = INT8_MAX,
+				.num_buffers_src =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 664

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_hard_out =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 666

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_soft_out =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+			}
+		},
+		{
+			.type = RTE_BBDEV_OP_TURBO_ENC,
+			.cap.turbo_enc = {
+				.capability_flags =
+

RTE_BBDEV_TURBO_CRC_24B_ATTACH |

drivers/baseband/acc/rte_acc200_pmd.c line 674

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+

RTE_BBDEV_TURBO_RV_INDEX_BYPASS |

drivers/baseband/acc/rte_acc200_pmd.c line 676

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+					RTE_BBDEV_TURBO_RATE_MATCH |
+

RTE_BBDEV_TURBO_ENC_SCATTER_GATHER,

drivers/baseband/acc/rte_acc200_pmd.c line 678

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_src =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

drivers/baseband/acc/rte_acc200_pmd.c line 680

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				.num_buffers_dst =
+

RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,

Quoted 32 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -2
+			}
+		},
+		{
   			.type   = RTE_BBDEV_OP_LDPC_ENC,
   			.cap.ldpc_enc = {
   				.capability_flags =
@@ -691,15 +731,17 @@
 
   	/* Exposed number of queues */
   	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = 0;
-	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
+	dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = d-

acc_conf.q_ul_4g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+			d->acc_conf.q_ul_4g.num_qgroups;
+	dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = d-

acc_conf.q_dl_4g.num_aqs_per_groups *

drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			d->acc_conf.q_dl_4g.num_qgroups;
   	dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = d-

acc_conf.q_ul_5g.num_aqs_per_groups *

   			d->acc_conf.q_ul_5g.num_qgroups;
   	dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = d-
acc_conf.q_dl_5g.num_aqs_per_groups *
   			d->acc_conf.q_dl_5g.num_qgroups;
   	dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
drivers/baseband/acc/rte_acc200_pmd.c +1 -2
-	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 0;
-	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 0;
+	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = d-

acc_conf.q_ul_4g.num_qgroups;

drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+	dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] =
+d->acc_conf.q_dl_4g.num_qgroups;
   	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = d-
Quoted 4 lines
acc_conf.q_ul_5g.num_qgroups;
   	dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = d-
acc_conf.q_dl_5g.num_qgroups;
   	dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0; @@ -744,6

+786,70

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines

@@
{.device_id = 0},
};

drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+/* Fill in a frame control word for turbo decoding. */ static inline
+void acc200_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct
+acc_fcw_td *fcw) {
+	fcw->fcw_ver = 1;
+	fcw->num_maps = ACC_FCW_TD_AUTOMAP;
+	fcw->bypass_sb_deint = !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE);
+	if (op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK) {

drivers/baseband/acc/rte_acc200_pmd.c line 814

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		/* FIXME for TB block */
+		fcw->k_pos = op->turbo_dec.tb_params.k_pos;
+		fcw->k_neg = op->turbo_dec.tb_params.k_neg;
+	} else {
+		fcw->k_pos = op->turbo_dec.cb_params.k;
+		fcw->k_neg = op->turbo_dec.cb_params.k;
+	}
+	fcw->c = 1;
+	fcw->c_neg = 1;
+	if (check_bit(op->turbo_dec.op_flags,

RTE_BBDEV_TURBO_SOFT_OUTPUT)) {

drivers/baseband/acc/rte_acc200_pmd.c line 836

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		fcw->soft_output_en = 1;
+		fcw->sw_soft_out_dis = 0;
+		fcw->sw_et_cont = check_bit(op->turbo_dec.op_flags,
+
	RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH);
Quoted 50 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+		fcw->sw_soft_out_saturation = check_bit(op-

turbo_dec.op_flags,

drivers/baseband/acc/rte_acc200_pmd.c +37 -0
+				RTE_BBDEV_TURBO_SOFT_OUT_SATURATE);
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_EQUALIZER)) {
+			fcw->bypass_teq = 0;
+			fcw->ea = op->turbo_dec.cb_params.e;
+			fcw->eb = op->turbo_dec.cb_params.e;
+			if (op->turbo_dec.rv_index == 0)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_0;
+			else if (op->turbo_dec.rv_index == 1)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_1;
+			else if (op->turbo_dec.rv_index == 2)
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_2;
+			else
+				fcw->k0_start_col = ACC_FCW_TD_RVIDX_3;
+		} else {
+			fcw->bypass_teq = 1;
+			fcw->eb = 64; /* avoid undefined value */
+		}
+	} else {
+		fcw->soft_output_en = 0;
+		fcw->sw_soft_out_dis = 1;
+		fcw->bypass_teq = 0;
+	}
+
+	fcw->code_block_mode = 1; /* FIXME */
+	fcw->turbo_crc_type = check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_CRC_TYPE_24B);
+
+	fcw->ext_td_cold_reg_en = 1;
+	fcw->raw_decoder_input_on = 0;
+	fcw->max_iter = RTE_MAX((uint8_t) op->turbo_dec.iter_max, 2);
+	fcw->min_iter = 2;
+	fcw->half_iter_on = !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_HALF_ITERATION_EVEN);
+
+	fcw->early_stop_en = check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_EARLY_TERMINATION) & !fcw-

soft_output_en;

drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	fcw->ext_scale = 0xF;
+}
+
   /* Fill in a frame control word for LDPC decoding. */
   static inline void
   acc200_fcw_ld_fill(struct rte_bbdev_dec_op *op, struct acc_fcw_ld

*fcw, @@ -870,6 +976,89 @@
}

static inline int

drivers/baseband/acc/rte_acc200_pmd.c line 983

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+acc200_dma_desc_te_fill(struct rte_bbdev_enc_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *output, uint32_t *in_offset,
+		uint32_t *out_offset, uint32_t *out_length,
+		uint32_t *mbuf_total_left, uint32_t *seg_total_left, uint8_t r)

{

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+	int next_triplet = 1; /* FCW already done */
+	uint32_t e, ea, eb, length;
+	uint16_t k, k_neg, k_pos;
+	uint8_t cab, c_neg;
+
+	desc->word0 = ACC_DMA_DESC_TYPE;
+	desc->word1 = 0; /**< Timestamp could be disabled */
+	desc->word2 = 0;
+	desc->word3 = 0;
+	desc->numCBs = 1;
+
+	if (op->turbo_enc.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK) {

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		ea = op->turbo_enc.tb_params.ea;
+		eb = op->turbo_enc.tb_params.eb;
+		cab = op->turbo_enc.tb_params.cab;
+		k_neg = op->turbo_enc.tb_params.k_neg;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+		k_pos = op->turbo_enc.tb_params.k_pos;
+		c_neg = op->turbo_enc.tb_params.c_neg;
+		e = (r < cab) ? ea : eb;
+		k = (r < c_neg) ? k_neg : k_pos;
+	} else {
+		e = op->turbo_enc.cb_params.e;
+		k = op->turbo_enc.cb_params.k;
+	}
+
+	if (check_bit(op->turbo_enc.op_flags,

RTE_BBDEV_TURBO_CRC_24B_ATTACH))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		length = (k - 24) >> 3;
+	else
+		length = k >> 3;
+
+	if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < length))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included

CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+				*mbuf_total_left, length);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset,
+			length, seg_total_left, next_triplet,
+			check_bit(op->turbo_enc.op_flags,
+			RTE_BBDEV_TURBO_ENC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= length;
+
+	/* Set output length */
+	if (check_bit(op->turbo_enc.op_flags,

RTE_BBDEV_TURBO_RATE_MATCH))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+		/* Integer round up division by 8 */
+		*out_length = (e + 7) >> 3;
+	else
+		*out_length = (k >> 3) * 3 + 2;
+
+	next_triplet = acc_dma_fill_blk_type(desc, output, *out_offset,
+			*out_length, next_triplet,

ACC_DMA_BLKID_OUT_ENC);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+				op);
+		return -1;
+	}
+	op->turbo_enc.output.length += *out_length;
+	*out_offset += *out_length;
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
   acc200_dma_desc_le_fill(struct rte_bbdev_enc_op *op,
   		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
   		struct rte_mbuf *output, uint32_t *in_offset, @@ -929,6

+1118,122

Quoted 13 lines

@@
}

static inline int

drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+acc200_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
+		struct acc_dma_req_desc *desc, struct rte_mbuf **input,
+		struct rte_mbuf *h_output, struct rte_mbuf *s_output,
+		uint32_t *in_offset, uint32_t *h_out_offset,
+		uint32_t *s_out_offset, uint32_t *h_out_length,
+		uint32_t *s_out_length, uint32_t *mbuf_total_left,
+		uint32_t *seg_total_left, uint8_t r) {
+	int next_triplet = 1; /* FCW already done */
+	uint16_t k;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	uint16_t crc24_overlap = 0;
+	uint32_t e, kw;
+
+	desc->word0 = ACC_DMA_DESC_TYPE;
+	desc->word1 = 0; /**< Timestamp could be disabled */
+	desc->word2 = 0;
+	desc->word3 = 0;
+	desc->numCBs = 1;
+
+	if (op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK) {

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+		k = (r < op->turbo_dec.tb_params.c_neg)
+			? op->turbo_dec.tb_params.k_neg
+			: op->turbo_dec.tb_params.k_pos;
+		e = (r < op->turbo_dec.tb_params.cab)
+			? op->turbo_dec.tb_params.ea
+			: op->turbo_dec.tb_params.eb;
+	} else {
+		k = op->turbo_dec.cb_params.k;
+		e = op->turbo_dec.cb_params.e;
+	}
+
+	if ((op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+		&& !check_bit(op->turbo_dec.op_flags,
+		RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
+		crc24_overlap = 24;
+
+	/* Calculates circular buffer size.
+	 * According to 3gpp 36.212 section 5.1.4.2
+	 *   Kw = 3 * Kpi,
+	 * where:

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	 *   Kpi = nCol * nRow
+	 * where nCol is 32 and nRow can be calculated from:
+	 *   D =< nCol * nRow
+	 * where D is the size of each output from turbo encoder block (k + 4).
+	 */
+	kw = RTE_ALIGN_CEIL(k + 4, 32) * 3;
+
+	if (unlikely((*mbuf_total_left == 0) || (*mbuf_total_left < kw))) {
+		rte_bbdev_log(ERR,
+				"Mismatch between mbuf length and included

CB sizes: mbuf len %u, cb len %u",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 11 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
+				*mbuf_total_left, kw);
+		return -1;
+	}
+
+	next_triplet = acc_dma_fill_blk_type_in(desc, input, in_offset, kw,
+			seg_total_left, next_triplet,
+			check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_SCATTER_GATHER));
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+				op);
+		return -1;
+	}
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->m2dlen = next_triplet;
+	*mbuf_total_left -= kw;
+	*h_out_length = ((k - crc24_overlap) >> 3);
+	next_triplet = acc_dma_fill_blk_type(
+			desc, h_output, *h_out_offset,
+			*h_out_length, next_triplet,

ACC_DMA_BLKID_OUT_HARD);

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	if (unlikely(next_triplet < 0)) {
+		rte_bbdev_log(ERR,
+				"Mismatch between data to process and mbuf

data length in bbdev_op: %p",

drivers/baseband/acc/rte_acc200_pmd.c line 1208

Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+				op);
+		return -1;
+	}
+
+	op->turbo_dec.hard_output.length += *h_out_length;
+	*h_out_offset += *h_out_length;
+
+	/* Soft output */
+	if (check_bit(op->turbo_dec.op_flags,

RTE_BBDEV_TURBO_SOFT_OUTPUT)) {

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+		if (op->turbo_dec.soft_output.data == 0) {
+			rte_bbdev_log(ERR, "Soft output is not defined");
+			return -1;
+		}
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_EQUALIZER))

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			*s_out_length = e;
+		else
+			*s_out_length = (k * 3) + 12;
+
+		next_triplet = acc_dma_fill_blk_type(desc, s_output,
+				*s_out_offset, *s_out_length, next_triplet,
+				ACC_DMA_BLKID_OUT_SOFT);
+		if (unlikely(next_triplet < 0)) {
+			rte_bbdev_log(ERR,
+					"Mismatch between data to process

and mbuf data length in bbdev_op: %p",

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+					op);
+			return -1;
+		}
+
+		op->turbo_dec.soft_output.length += *s_out_length;
+		*s_out_offset += *s_out_length;
+	}
+
+	desc->data_ptrs[next_triplet - 1].last = 1;
+	desc->d2mlen = next_triplet - desc->m2dlen;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+	desc->op_addr = op;
+
+	return 0;
+}
+
+static inline int
   acc200_dma_desc_ld_fill(struct rte_bbdev_dec_op *op,
   		struct acc_dma_req_desc *desc,
   		struct rte_mbuf **input, struct rte_mbuf *h_output, @@ -

1100,6

Quoted 21 lines

+1405,51 @@

   	desc->op_addr = op;
   }
drivers/baseband/acc/rte_acc200_pmd.c +17 -0
+/* Enqueue one encode operations for ACC200 device in CB mode */
+static inline int enqueue_enc_one_op_cb(struct acc_queue *q, struct
+rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc_fcw_te_fill(op, &desc->req.fcw_te);
+
+	input = op->turbo_enc.input.data;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	output_head = output = op->turbo_enc.output.data;
+	in_offset = op->turbo_enc.input.offset;
+	out_offset = op->turbo_enc.output.offset;
+	out_length = 0;
+	mbuf_total_left = op->turbo_enc.input.length;
+	seg_total_left = rte_pktmbuf_data_len(op->turbo_enc.input.data)
+			- in_offset;
+
+	ret = acc200_dma_desc_te_fill(op, &desc->req, &input, output,
+			&in_offset, &out_offset, &out_length,

&mbuf_total_left,

Quoted 48 lines
drivers/baseband/acc/rte_acc200_pmd.c +41 -0
+			&seg_total_left, 0);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	mbuf_append(output_head, output, out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_te,
+			sizeof(desc->req.fcw_te) - 8);
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc));
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
   /* Enqueue one encode operations for ACC200 device in CB mode
    * multiplexed on the same descriptor
    */
@@ -1262,6 +1612,84 @@
   	return 1;
   }
 
+
+/* Enqueue one encode operations for ACC200 device in TB mode. */
+static inline int enqueue_enc_one_op_tb(struct acc_queue *q, struct
+rte_bbdev_enc_op *op,
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb) {
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, out_offset, out_length, mbuf_total_left,
+		seg_total_left;
+	struct rte_mbuf *input, *output_head, *output;
+	uint16_t current_enqueued_cbs = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	acc_fcw_te_fill(op, &desc->req.fcw_te);
+
+	input = op->turbo_enc.input.data;
+	output_head = output = op->turbo_enc.output.data;
+	in_offset = op->turbo_enc.input.offset;
+	out_offset = op->turbo_enc.output.offset;

drivers/baseband/acc/rte_acc200_pmd.c line 1647

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	out_length = 0;
+	mbuf_total_left = op->turbo_enc.input.length;
+
+	c = op->turbo_enc.tb_params.c;
+	r = op->turbo_enc.tb_params.r;
+
+	while (mbuf_total_left > 0 && r < c) {
+		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+		/* Set up DMA descriptor */
+		desc = q->ring_addr + ((q->sw_ring_head +

total_enqueued_cbs)

drivers/baseband/acc/rte_acc200_pmd.c line 1649

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				& q->sw_ring_wrap_mask);
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +

fcw_offset;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		desc->req.data_ptrs[0].blen = ACC_FCW_TE_BLEN;
+
+		ret = acc200_dma_desc_te_fill(op, &desc->req, &input,

output,

Quoted 42 lines
drivers/baseband/acc/rte_acc200_pmd.c +38 -0
+				&in_offset, &out_offset, &out_length,
+				&mbuf_total_left, &seg_total_left, r);
+		if (unlikely(ret < 0))
+			return ret;
+		mbuf_append(output_head, output, out_length);
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_te,
+				sizeof(desc->req.fcw_te) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); #endif
+
+		if (seg_total_left == 0) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			output = output->next;
+			out_offset = 0;
+		}
+
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif
+
+	/* Set SDone on last CB descriptor for TB mode. */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
   /* Enqueue one encode operations for ACC200 device in TB mode.
    * returns the number of descs used
    */

drivers/baseband/acc/rte_acc200_pmd.c line 1759

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
@@ -1328,6 +1756,69 @@
 
   /** Enqueue one decode operations for ACC200 device in CB mode */
   static inline int
+enqueue_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op

*op,

Quoted 26 lines
drivers/baseband/acc/rte_acc200_pmd.c +26 -0
+		uint16_t total_enqueued_cbs)
+{
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint32_t in_offset, h_out_offset, s_out_offset, s_out_length,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output,
+		*s_output_head, *s_output;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+	desc = q->ring_addr + desc_idx;
+	acc200_fcw_td_fill(op, &desc->req.fcw_td);
+
+	input = op->turbo_dec.input.data;
+	h_output_head = h_output = op->turbo_dec.hard_output.data;
+	s_output_head = s_output = op->turbo_dec.soft_output.data;
+	in_offset = op->turbo_dec.input.offset;
+	h_out_offset = op->turbo_dec.hard_output.offset;
+	s_out_offset = op->turbo_dec.soft_output.offset;
+	h_out_length = s_out_length = 0;
+	mbuf_total_left = op->turbo_dec.input.length;
+	seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(input == NULL)) {
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 1789

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		rte_bbdev_log(ERR, "Invalid mbuf pointer");
+		return -EFAULT;
+	}
+#endif

It makes sense to have this check present unconditionnally.
Also, putting it here is useless since rte_pktmbuf_data_len() dereference it just before. So if NULL, it will crash before being checked.

Quoted 1 line

We would not want to do comprehensive check on input parameter in production.

Why? If for performance reasons, I highly doubt it would be noticeable.

Quoted 2 lines

We had been expecting this kind of check to only happen in debug mode for user to troubleshoot their code more easily. I can take out for now but would be good to review further the usecase of debug build.

Well, where it is currently it is just useless since if input == NULL, it will crash before the check.

But overall yes, we need to review all the code under debug build to see
if it makes sense. On patch 8, for example, the production build will
crash while the debug build will detect the issue but returns silently
(no logs are emitted). So it makes production build more fragile but easier to debug in the end (a coredump would be generated).

Quoted 146 lines
Quoted 60 lines
Quoted 9 lines
drivers/baseband/acc/rte_acc200_pmd.c +8 -0
+
+	/* Set up DMA descriptor */
+	desc = q->ring_addr + ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
+
+	ret = acc200_dma_desc_td_fill(op, &desc->req, &input, h_output,
+			s_output, &in_offset, &h_out_offset, &s_out_offset,
+			&h_out_length, &s_out_length, &mbuf_total_left,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+			&seg_total_left, 0);
+
+	if (unlikely(ret < 0))
+		return ret;
+
+	/* Hard output */
+	mbuf_append(h_output_head, h_output, h_out_length);
+
+	/* Soft output */
+	if (check_bit(op->turbo_dec.op_flags,

RTE_BBDEV_TURBO_SOFT_OUTPUT))

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+		mbuf_append(s_output_head, s_output, s_out_length);
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	rte_memdump(stderr, "FCW", &desc->req.fcw_td,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +9 -0
+			sizeof(desc->req.fcw_td));
+	rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); #endif
+
+	/* One CB (one op) was successfully prepared to enqueue */
+	return 1;
+}
+
+/** Enqueue one decode operations for ACC200 device in CB mode */
+static inline int
   enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct

rte_bbdev_dec_op *op,

Quoted 25 lines
drivers/baseband/acc/rte_acc200_pmd.c +15 -3
   		uint16_t total_enqueued_cbs, bool same_op)
   {
@@ -1525,10 +2016,147 @@
   	return current_enqueued_cbs;
   }
 
-/** Enqueue encode operations for ACC200 device in CB mode. */
-static inline uint16_t -acc200_enqueue_ldpc_enc_cb(struct
 rte_bbdev_queue_data *q_data,
-		struct rte_bbdev_enc_op **ops, uint16_t num)
+/* Enqueue one decode operations for ACC200 device in TB mode */
+static inline int enqueue_dec_one_op_tb(struct acc_queue *q, struct
+rte_bbdev_dec_op *op,
+		uint16_t total_enqueued_cbs, uint8_t cbs_in_tb) {
+	union acc_dma_desc *desc = NULL;
+	int ret;
+	uint8_t r, c;
+	uint32_t in_offset, h_out_offset, s_out_offset, s_out_length,
+		h_out_length, mbuf_total_left, seg_total_left;
+	struct rte_mbuf *input, *h_output_head, *h_output,
+		*s_output_head, *s_output;
+	uint16_t current_enqueued_cbs = 0;
+
+	uint16_t desc_idx = ((q->sw_ring_head + total_enqueued_cbs)
+			& q->sw_ring_wrap_mask);
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2039

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	desc = q->ring_addr + desc_idx;
+	uint64_t fcw_offset = (desc_idx << 8) + ACC_DESC_FCW_OFFSET;
+	acc200_fcw_td_fill(op, &desc->req.fcw_td);
+
+	input = op->turbo_dec.input.data;

Here you may want to check if not NULL, at least for consistency with enqueue_dec_one_op_cb()

Noted above this is taken out.

Quoted 58 lines
Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+	h_output_head = h_output = op->turbo_dec.hard_output.data;
+	s_output_head = s_output = op->turbo_dec.soft_output.data;
+	in_offset = op->turbo_dec.input.offset;
+	h_out_offset = op->turbo_dec.hard_output.offset;
+	s_out_offset = op->turbo_dec.soft_output.offset;
+	h_out_length = s_out_length = 0;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	mbuf_total_left = op->turbo_dec.input.length;
+	c = op->turbo_dec.tb_params.c;
+	r = op->turbo_dec.tb_params.r;
+
+	while (mbuf_total_left > 0 && r < c) {
+
+		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
+
+		/* Set up DMA descriptor */
+		desc = q->ring_addr + ((q->sw_ring_head +

total_enqueued_cbs)

drivers/baseband/acc/rte_acc200_pmd.c line 2057

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +2 -0
+				& q->sw_ring_wrap_mask);
+		desc->req.data_ptrs[0].address = q->ring_addr_iova +

fcw_offset;

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		desc->req.data_ptrs[0].blen = ACC_FCW_TD_BLEN;
+		ret = acc200_dma_desc_td_fill(op, &desc->req, &input,
+				h_output, s_output, &in_offset,

&h_out_offset,

drivers/baseband/acc/rte_acc200_pmd.c line 2061

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+				&s_out_offset, &h_out_length,

&s_out_length,

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +12 -0
+				&mbuf_total_left, &seg_total_left, r);
+
+		if (unlikely(ret < 0))
+			return ret;
+
+		/* Hard output */
+		mbuf_append(h_output_head, h_output, h_out_length);
+
+		/* Soft output */
+		if (check_bit(op->turbo_dec.op_flags,
+				RTE_BBDEV_TURBO_SOFT_OUTPUT))
+			mbuf_append(s_output_head, s_output,

s_out_length);

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+
+		/* Set total number of CBs in TB */
+		desc->req.cbs_in_tb = cbs_in_tb;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+		rte_memdump(stderr, "FCW", &desc->req.fcw_td,
+				sizeof(desc->req.fcw_td) - 8);
+		rte_memdump(stderr, "Req Desc.", desc, sizeof(*desc)); #endif

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+		if (seg_total_left == 0) {
+			/* Go to the next mbuf */
+			input = input->next;
+			in_offset = 0;
+			h_output = h_output->next;
+			h_out_offset = 0;
+
+			if (check_bit(op->turbo_dec.op_flags,
+					RTE_BBDEV_TURBO_SOFT_OUTPUT))

{

Quoted 16 lines
Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+				s_output = s_output->next;
+				s_out_offset = 0;
+			}
+		}

drivers/baseband/acc/rte_acc200_pmd.c line 2105

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+
+		total_enqueued_cbs++;
+		current_enqueued_cbs++;
+		r++;
+	}
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (check_mbuf_total_left(mbuf_total_left) != 0)
+		return -EINVAL;
+#endif

If it can happen, then it should alway be present.

Quoted 1 line

Same comment as above, not meant for production code.

Ok, then just remove it?

Quoted 102 lines
Quoted 93 lines
Quoted 69 lines
drivers/baseband/acc/rte_acc200_pmd.c +61 -0
+	/* Set SDone on last CB descriptor for TB mode */
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	return current_enqueued_cbs;
+}
+
+/* Enqueue encode operations for ACC200 device in CB mode. */ static
+uint16_t acc200_enqueue_enc_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail - 1 < 0)) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= 1;
+
+		ret = enqueue_enc_one_op_cb(q, ops[i], i);
+		if (ret < 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+	return i;
+}
+
+/** Enqueue encode operations for ACC200 device in CB mode. */ static
+inline uint16_t acc200_enqueue_ldpc_enc_cb(struct
+rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
   {
   	struct acc_queue *q = q_data->queue_private;
   	int32_t avail = acc_ring_avail_enq(q); @@ -1583,6 +2211,45 @@
   	return i;
   }
 
+/* Enqueue encode operations for ACC200 device in TB mode. */ static
+uint16_t acc200_enqueue_enc_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_enc(&ops[i]->turbo_enc);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= cbs_in_tb;
+
+		ret = enqueue_enc_one_op_tb(q, ops[i], enqueued_cbs,

cbs_in_tb);

Quoted 13 lines
drivers/baseband/acc/rte_acc200_pmd.c +13 -0
+		if (ret <= 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_cbs += ret;
+	}
+	if (unlikely(enqueued_cbs == 0))
+		return 0; /* Nothing to enqueue */
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2251

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_enc_tb(), it should be shared.

Quoted 1 line

Actually these and/or the underlying functions have differences. (or will be different once ACC100 PMDs changed are applied).

Ok.
Once ACC100 series is applied, we can revisit the two drivers and see if we can increase shared code.

Quoted 296 lines
Quoted 73 lines
Quoted 12 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -2
+
   /* Enqueue LDPC encode operations for ACC200 device in TB mode. */
   static uint16_t
   acc200_enqueue_ldpc_enc_tb(struct rte_bbdev_queue_data *q_data, @@
-1623,18 +2290,18 @@
   	return i;
   }
 
-/* Check room in AQ for the enqueues batches into Qmgr */ -static

int32_t -acc200_aq_avail(struct rte_bbdev_queue_data *q_data, uint16_t num_ops)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -4
+/* Enqueue encode operations for ACC200 device. */ static uint16_t
+acc200_enqueue_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num)
   {
-	struct acc_queue *q = q_data->queue_private;
-	int32_t aq_avail = q->aq_depth -
-			((q->aq_enqueued - q->aq_dequeued +
-			ACC_MAX_QUEUE_DEPTH) %

ACC_MAX_QUEUE_DEPTH)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 8 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -4
-			- (num_ops >> 7);
-	if (aq_avail <= 0)
-		acc_enqueue_queue_full(q_data);
-	return aq_avail;
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->turbo_enc.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 43 lines
drivers/baseband/acc/rte_acc200_pmd.c +37 -0
+		return acc200_enqueue_enc_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_enc_cb(q_data, ops, num);
   }
 
   /* Enqueue encode operations for ACC200 device. */ @@ -1652,6
+2319,47 @@
   		return acc200_enqueue_ldpc_enc_cb(q_data, ops, num);
   }
 
+
+/* Enqueue decode operations for ACC200 device in CB mode */ static
+uint16_t acc200_enqueue_dec_cb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i;
+	union acc_dma_desc *desc;
+	int ret;
+
+	for (i = 0; i < num; ++i) {
+		/* Check if there are available space for further processing */
+		if (unlikely(avail - 1 < 0))
+			break;
+		avail -= 1;
+
+		ret = enqueue_dec_one_op_cb(q, ops[i], i);
+		if (ret < 0)
+			break;
+	}
+
+	if (unlikely(i == 0))
+		return 0; /* Nothing to enqueue */
+
+	/* Set SDone in last CB in enqueued ops for CB mode*/
+	desc = q->ring_addr + ((q->sw_ring_head + i - 1)
+			& q->sw_ring_wrap_mask);
+	desc->req.sdone_enable = 1;
+	desc->req.irq_enable = q->irq_enable;
+
+	acc_dma_enqueue(q, i, &q_data->queue_stats);
+
+	/* Update stats */
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2251

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_dec_cb(), it should be shared.

Same comment as above

Quoted 89 lines
Quoted 19 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -1
+
   /* Enqueue decode operations for ACC200 device in TB mode */
   static uint16_t
   acc200_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data, @@
-1740,12 +2448,64 @@
   	return i;
   }
 
+
+/* Enqueue decode operations for ACC200 device in TB mode */ static
+uint16_t acc200_enqueue_dec_tb(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	int32_t avail = acc_ring_avail_enq(q);
+	uint16_t i, enqueued_cbs = 0;
+	uint8_t cbs_in_tb;
+	int ret;
+

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	for (i = 0; i < num; ++i) {
+		cbs_in_tb = get_num_cbs_in_tb_dec(&ops[i]->turbo_dec);
+		/* Check if there are available space for further processing */
+		if (unlikely((avail - cbs_in_tb < 0) || (cbs_in_tb == 0))) {
+			acc_enqueue_ring_full(q_data);
+			break;
+		}
+		avail -= cbs_in_tb;
+
+		ret = enqueue_dec_one_op_tb(q, ops[i], enqueued_cbs,

cbs_in_tb);

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+		if (ret <= 0) {
+			acc_enqueue_invalid(q_data);
+			break;
+		}
+		enqueued_cbs += ret;

drivers/baseband/acc/rte_acc200_pmd.c line 2251

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	}
+
+	acc_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);
+
+	/* Update stats */
+	q_data->queue_stats.enqueued_count += i;
+	q_data->queue_stats.enqueue_err_count += num - i;
+
+	return i;
+}

This function is strictly identical to acc100_enqueue_dec_tb(), it should be shared.

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 7 lines
drivers/baseband/acc/rte_acc200_pmd.c +7 -0
+/* Enqueue decode operations for ACC200 device. */ static uint16_t
+acc200_enqueue_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	int32_t aq_avail = acc_aq_avail(q_data, num);
+	if (unlikely((aq_avail <= 0) || (num == 0)))
+		return 0;
+	if (ops[0]->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 3 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+		return acc200_enqueue_dec_tb(q_data, ops, num);
+	else
+		return acc200_enqueue_dec_cb(q_data, ops, num); }

Ditto

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines

/* Enqueue decode operations for ACC200 device. */ static uint16_t
acc200_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
struct rte_bbdev_dec_op **ops, uint16_t num)
{

drivers/baseband/acc/rte_acc200_pmd.c +1 -1
-	int32_t aq_avail = acc200_aq_avail(q_data, num);
+	int32_t aq_avail = acc_aq_avail(q_data, num);
   	if (unlikely((aq_avail <= 0) || (num == 0)))
   		return 0;
   	if (ops[0]->ldpc_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

Quoted 15 lines
drivers/baseband/acc/rte_acc200_pmd.c +11 -0
@@ -2093,6 +2853,51 @@
   	return cb_idx;
   }
 
+/* Dequeue encode operations from ACC200 device. */ static uint16_t
+acc200_dequeue_enc(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_enc_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i, dequeued_ops = 0, dequeued_descs = 0;
+	int ret;
+	struct rte_bbdev_enc_op *op;
+	if (avail == 0)
+		return 0;
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2874

Quoted 6 lines
drivers/baseband/acc/rte_acc200_pmd.c +6 -0
+	op = (q->ring_addr + (q->sw_ring_tail &
+			q->sw_ring_wrap_mask))->req.op_addr;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+	if (unlikely(ops == NULL || q == NULL || op == NULL))
+		return 0;
+#endif

q is dereferenced before it is checked.

Thanks. Taking out.

Quoted 4 lines

drivers/baseband/acc/rte_acc200_pmd.c line 2875

Quoted 2 lines
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+	int cbm = op->turbo_enc.code_block_mode;

Dont mix declarations & code.

OK

Quoted 97 lines

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +3 -0
+	for (i = 0; i < num; i++) {
+		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
+			ret = dequeue_enc_one_op_tb(q,

&ops[dequeued_ops],

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 4 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		else
+			ret = dequeue_enc_one_op_cb(q,

&ops[dequeued_ops],

Quoted 36 lines
drivers/baseband/acc/rte_acc200_pmd.c +29 -1
+					&dequeued_ops, &aq_dequeued,
+					&dequeued_descs);
+		if (ret < 0)
+			break;
+		if (dequeued_ops >= num)
+			break;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_descs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += dequeued_ops;
+
+	return dequeued_ops;
+}
+
   /* Dequeue LDPC encode operations from ACC200 device. */
   static uint16_t
   acc200_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data, @@
-2140,6 +2945,51 @@
 
   /* Dequeue decode operations from ACC200 device. */
   static uint16_t
+acc200_dequeue_dec(struct rte_bbdev_queue_data *q_data,
+		struct rte_bbdev_dec_op **ops, uint16_t num) {
+	struct acc_queue *q = q_data->queue_private;
+	uint16_t dequeue_num;
+	uint32_t avail = acc_ring_avail_deq(q);
+	uint32_t aq_dequeued = 0;
+	uint16_t i;
+	uint16_t dequeued_cbs = 0;
+	struct rte_bbdev_dec_op *op;
+	int ret;
+
+#ifdef RTE_LIBRTE_BBDEV_DEBUG

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +10 -0
+	if (unlikely(ops == 0 && q == NULL))
+		return 0;
+#endif
+
+	dequeue_num = (avail < num) ? avail : num;
+
+	for (i = 0; i < dequeue_num; ++i) {
+		op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
+			& q->sw_ring_wrap_mask))->req.op_addr;
+		if (op->turbo_dec.code_block_mode ==

RTE_BBDEV_TRANSPORT_BLOCK)

drivers/baseband/acc/rte_acc200_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_acc200_pmd.c +1 -0
+			ret = dequeue_dec_one_op_tb(q, &ops[i],

dequeued_cbs,

Quoted 24 lines
drivers/baseband/acc/rte_acc200_pmd.c +20 -0
+					&aq_dequeued);
+		else
+			ret = dequeue_dec_one_op_cb(q_data, q, &ops[i],
+					dequeued_cbs, &aq_dequeued);
+
+		if (ret <= 0)
+			break;
+		dequeued_cbs += ret;
+	}
+
+	q->aq_dequeued += aq_dequeued;
+	q->sw_ring_tail += dequeued_cbs;
+
+	/* Update enqueue stats */
+	q_data->queue_stats.dequeued_count += i;
+
+	return i;
+}
+
+/* Dequeue decode operations from ACC200 device. */ static uint16_t
   acc200_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
   		struct rte_bbdev_dec_op **ops, uint16_t num)
   {

drivers/baseband/acc/rte_acc200_pmd.c line 3050

Quoted 10 lines
drivers/baseband/acc/rte_acc200_pmd.c +4 -0
@@ -2191,6 +3041,10 @@
   	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
 
   	dev->dev_ops = &acc200_bbdev_ops;
+	dev->enqueue_enc_ops = acc200_enqueue_enc;
+	dev->enqueue_dec_ops = acc200_enqueue_dec;
+	dev->dequeue_enc_ops = acc200_dequeue_enc;
+	dev->dequeue_dec_ops = acc200_dequeue_dec;
   	dev->enqueue_ldpc_enc_ops = acc200_enqueue_ldpc_enc;
   	dev->enqueue_ldpc_dec_ops = acc200_enqueue_ldpc_dec;
   	dev->dequeue_ldpc_enc_ops = acc200_dequeue_ldpc_enc;

Overall, there are functions that are stricly identical to ACC100, they should be shared and not duplicated.

Quoted 2 lines

If at some point they need to diverge, let's have device specific ones, but only when it becomes needed.

Actually the ones that are not in acc_common.h end up having differences notably due to SW mitigations/workaround specific to ACC100.

Quoted 2 lines

Maxime

#40 lore raw

Re: [PATCH v4 13/14] baseband/acc: add PF configure companion function

In reply to Chautru, Nicolas
Quoted 277 lines · Nicolas

Hi Maxime,
Thanks will send an updated serie now. Much appreciated.

Quoted 265 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 23, 2022 2:26 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v4 13/14] baseband/acc: add PF configure companion function

Quoted 9 lines · Nic Chautru

Add configure function notably to configure the device from the PF within DPDK and bbdev-test (without external dependency).

---
   app/test-bbdev/test_bbdev_perf.c      |  71 ++++++
   drivers/baseband/acc/meson.build      |   2 +-
   drivers/baseband/acc/rte_acc200_cfg.h |  48 ++++
   drivers/baseband/acc/rte_acc200_pmd.c | 453

++++++++++++++++++++++++++++++++++

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct

Quoted 26 lines
   drivers/baseband/acc/version.map      |   1 +
   5 files changed, 574 insertions(+), 1 deletion(-)

create mode 100644 drivers/baseband/acc/rte_acc200_cfg.h

app/test-bbdev/test_bbdev_perf.c +9 -0
index 41c78de..ec6ee2a 100644
@@ -62,6 +62,15 @@
   #define ACC100_QMGR_INVALID_IDX -1
   #define ACC100_QMGR_RR 1
   #define ACC100_QOS_GBR 0
+#include <rte_acc200_cfg.h>
+#define ACC200PF_DRIVER_NAME   ("intel_acc200_pf")
+#define ACC200VF_DRIVER_NAME   ("intel_acc200_vf")
+#define ACC200_QMGR_NUM_AQS 16
+#define ACC200_QMGR_NUM_QGS 2
+#define ACC200_QMGR_AQ_DEPTH 5
+#define ACC200_QMGR_INVALID_IDX -1
+#define ACC200_QMGR_RR 1
+#define ACC200_QOS_GBR 0
   #endif
 
   #define OPS_CACHE_SIZE 256U
@@ -761,6 +770,68 @@ typedef int (test_case_function)(struct

active_device *ad,

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 770

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +0 -0
   				"Failed to configure ACC100 PF for bbdev

%s",

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 4 lines
app/test-bbdev/test_bbdev_perf.c +2 -0
   				info->dev_name);
   	}
+	if ((get_init_device() == true) &&
+		(!strcmp(info->drv.driver_name, ACC200PF_DRIVER_NAME)))

{

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 4 lines
app/test-bbdev/test_bbdev_perf.c +4 -0
+		struct rte_acc_conf conf;
+		unsigned int i;
+
+		printf("Configure ACC200 FEC Driver %s with default

values\n",

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 9 lines
app/test-bbdev/test_bbdev_perf.c +9 -0
+				info->drv.driver_name);
+
+		/* clear default configuration before initialization */
+		memset(&conf, 0, sizeof(struct rte_acc_conf));
+
+		/* Always set in PF mode for built-in configuration */
+		conf.pf_mode_en = true;
+		for (i = 0; i < RTE_ACC_NUM_VFS; ++i) {
+			conf.arb_dl_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 788

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 789

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_4g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 790

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 791

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_4g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 792

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_4g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 793

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 794

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 795

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_dl_5g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 796

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 797

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_5g[i].gbr_threshold1 =

ACC200_QOS_GBR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 798

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+			conf.arb_ul_5g[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+			conf.arb_fft[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_fft[i].gbr_threshold1 = ACC200_QOS_GBR;
+			conf.arb_fft[i].round_robin_weight =

ACC200_QMGR_RR;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 5 lines
app/test-bbdev/test_bbdev_perf.c +5 -0
+		}
+
+		conf.input_pos_llr_1_bit = true;
+		conf.output_pos_llr_1_bit = true;
+		conf.num_vf_bundles = 1; /**< Number of VF bundles to

setup */

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+
+		conf.q_ul_4g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_ul_4g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 810

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_ul_4g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_ul_4g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_dl_4g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_dl_4g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 814

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_dl_4g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_dl_4g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_ul_5g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_ul_5g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 818

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_ul_5g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_ul_5g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_dl_5g.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_dl_5g.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 822

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_dl_5g.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 3 lines
app/test-bbdev/test_bbdev_perf.c +3 -0
+		conf.q_dl_5g.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+		conf.q_fft.num_qgroups = ACC200_QMGR_NUM_QGS;
+		conf.q_fft.first_qgroup_index =

ACC200_QMGR_INVALID_IDX;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct · line 826

Quoted 1 line
app/test-bbdev/test_bbdev_perf.c +1 -0
+		conf.q_fft.num_aqs_per_groups =

ACC200_QMGR_NUM_AQS;

app/test-bbdev/test_bbdev_perf.c typedef int (test_case_function)(struct active_device *ad,

Quoted 6 lines
app/test-bbdev/test_bbdev_perf.c +6 -0
+		conf.q_fft.aq_depth_log2 = ACC200_QMGR_AQ_DEPTH;
+
+		/* setup PF with configuration information */
+		ret = rte_acc200_configure(info->dev_name, &conf);
+		TEST_ASSERT_SUCCESS(ret,
+				"Failed to configure ACC200 PF for bbdev

%s",

Quoted 44 lines
app/test-bbdev/test_bbdev_perf.c +2 -0
+				info->dev_name);
+	}
   #endif
   	/* Let's refresh this now this is configured */
   	rte_bbdev_info_get(dev_id, info);
drivers/baseband/acc/meson.build +0 -0
index 63912f0..7ae162a 100644
@@ -5,4 +5,4 @@ deps += ['bbdev', 'bus_vdev', 'ring', 'pci',

'bus_pci']

   sources = files('rte_acc100_pmd.c', 'rte_acc200_pmd.c')
drivers/baseband/acc/meson.build +1 -1
-headers = files('rte_acc100_cfg.h')
+headers = files('rte_acc100_cfg.h', 'rte_acc200_cfg.h')
drivers/baseband/acc/rte_acc200_cfg.h new file +20 -0
new file mode 100644
index 0000000..8bd9b20
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation  */
+
+#ifndef _RTE_ACC200_CFG_H_
+#define _RTE_ACC200_CFG_H_
+
+/**
+ * @file rte_acc200_cfg.h
+ *
+ * Functions for configuring ACC200 HW, exposed directly to applications.
+ * Configuration related to encoding/decoding is done through the
+ * librte_bbdev library.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice  */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "rte_acc_common_cfg.h"
+

drivers/baseband/acc/rte_acc200_cfg.h line 30

Quoted 10 lines
drivers/baseband/acc/rte_acc200_cfg.h new file +10 -0
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Configure a ACC200 device
+ *
+ * @param dev_name
+ *   The name of the device. This is the short form of PCI BDF, e.g. 00:01.0.
+ *   It can also be retrieved for a bbdev device from the dev_name field in

the

Quoted 67 lines
drivers/baseband/acc/rte_acc200_cfg.h new file +17 -0
+ *   rte_bbdev_info structure returned by rte_bbdev_info_get().
+ * @param conf
+ *   Configuration to apply to ACC200 HW.
+ *
+ * @return
+ *   Zero on success, negative value on failure.
+ */
+__rte_experimental
+int
+rte_acc200_configure(const char *dev_name, struct rte_acc_conf
+*conf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_ACC200_CFG_H_ */
drivers/baseband/acc/rte_acc200_pmd.c +34 -1
index 3c2931b..21d614d 100644
@@ -43,6 +43,27 @@
 
   enum {UL_4G = 0, UL_5G, DL_4G, DL_5G, FFT, NUM_ACC};
 
+/* Return the accelerator enum for a Queue Group Index */ static
+inline int accFromQgid(int qg_idx, const struct rte_acc_conf
+*acc_conf) {
+	int accQg[ACC200_NUM_QGRPS];
+	int NumQGroupsPerFn[NUM_ACC];
+	int acc, qgIdx, qgIndex = 0;
+	for (qgIdx = 0; qgIdx < ACC200_NUM_QGRPS; qgIdx++)
+		accQg[qgIdx] = 0;
+	NumQGroupsPerFn[UL_4G] = acc_conf->q_ul_4g.num_qgroups;
+	NumQGroupsPerFn[UL_5G] = acc_conf->q_ul_5g.num_qgroups;
+	NumQGroupsPerFn[DL_4G] = acc_conf->q_dl_4g.num_qgroups;
+	NumQGroupsPerFn[DL_5G] = acc_conf->q_dl_5g.num_qgroups;
+	NumQGroupsPerFn[FFT] = acc_conf->q_fft.num_qgroups;
+	for (acc = UL_4G;  acc < NUM_ACC; acc++)
+		for (qgIdx = 0; qgIdx < NumQGroupsPerFn[acc]; qgIdx++)
+			accQg[qgIndex++] = acc;
+	acc = accQg[qg_idx];
+	return acc;
+}
+
   /* Return the queue topology for a Queue Group Index */
   static inline void
   qtopFromAcc(struct rte_acc_queue_topology **qtop, int acc_enum, @@
-75,6 +96,30 @@
   	*qtop = p_qtop;
   }
 
+/* Return the AQ depth for a Queue Group Index */ static inline int
+aqDepth(int qg_idx, struct rte_acc_conf *acc_conf) {
+	struct rte_acc_queue_topology *q_top = NULL;
+	int acc_enum = accFromQgid(qg_idx, acc_conf);
+	qtopFromAcc(&q_top, acc_enum, acc_conf);
+	if (unlikely(q_top == NULL))
+		return 0;
+	return q_top->aq_depth_log2;
+}
+
+/* Return the AQ depth for a Queue Group Index */ static inline int
+aqNum(int qg_idx, struct rte_acc_conf *acc_conf) {
+	struct rte_acc_queue_topology *q_top = NULL;
+	int acc_enum = accFromQgid(qg_idx, acc_conf);
Quoted 8 lines

drivers/baseband/acc/rte_acc200_pmd.c line 121

Quoted 5 lines
drivers/baseband/acc/rte_acc200_pmd.c +5 -0
+	qtopFromAcc(&q_top, acc_enum, acc_conf);
+	if (unlikely(q_top == NULL))
+		return 0;
+	return q_top->num_aqs_per_groups;
+}

For the 3 functions above, please add new lines for clarity.

Quoted 2 lines

OK, guidelines would be good, as I am not fully convinced. But updating in new series.

I have not checked whether it is in the contribution guidelines, but having new lines between the variables declarations and code is a common rules that makes the code more readable. So is having new lines
before the returns.