Skip to contentSkip to conversation

baseband/acc: VRB PMD fixes

PATCH Superseded Nicolas Chautru 2 participants 37 messages Feb 9, 2023 – Feb 23, 2023

lore
Share & tools
lore
#0 lore raw

cover baseband/acc: VRB PMD fixes

Hi,

Series of mainly fixes for corner-cases and protection in the VRB PMD.
The last 2 commits are not fixes but add support for missing minor capability, as well as a request to remove printf from code (function called from bbdev-test).

Thanks
Nic

Nicolas Chautru (9):
baseband/acc: protection for TB negative scenario baseband/acc: add support for 4GUL with SO and TB baseband/acc: remove interrupt support on VRB1 baseband/acc: add explicit mbuf apend for soft output baseband/acc: prevent to dequeue more than requested baseband/acc: fix iteration counter in TB mode baseband/acc: fix potential arithmetic overflow Fix potential issue of
overflow causing coverity warning.
baseband/acc: add support for 4GUL CRC drop in VRB PMD baseband/acc: remove printf from PMD function

 drivers/baseband/acc/rte_acc100_pmd.c |  18 ++---
 drivers/baseband/acc/rte_vrb_pmd.c    | 103 ++++++++++++++++++--------
 drivers/baseband/acc/vrb_pmd.h        |   1 +
 3 files changed, 84 insertions(+), 38 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/9 baseband/acc: protection for TB negative scenario

Adding handling of negative scenario for malformed Transport Block mode operations.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +20 -0
index 34e42d1f6e..797330a5dd 100644
@@ -1820,6 +1820,9 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
 	r = op->turbo_enc.tb_params.r;
 
 	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (output == NULL)))
+			return -1;
+
 		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 		/* Set up DMA descriptor */
 		desc = acc_desc(q, total_enqueued_cbs);
@@ -1854,6 +1857,10 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
 		r++;
 	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (current_enqueued_cbs != cbs_in_tb)
+		return -1;
+
 	/* Set SDone on last CB descriptor for TB mode. */
 	desc->req.sdone_enable = 1;
 
@@ -2100,6 +2107,9 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 	}
 
 	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
+
 		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
@@ -2145,6 +2155,10 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		r++;
 	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (current_enqueued_cbs != cbs_in_tb)
+		return -1;
+
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 	if (check_mbuf_total_left(mbuf_total_left) != 0)
 		return -EINVAL;
@@ -2187,6 +2201,8 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 	r = op->turbo_dec.tb_params.r;
 
 	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
 
 		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 
@@ -2237,6 +2253,10 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		r++;
 	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (current_enqueued_cbs != cbs_in_tb)
+		return -1;
+
 	/* Set SDone on last CB descriptor for TB mode */
 	desc->req.sdone_enable = 1;
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/9
#2 lore raw

Re: [PATCH v1 1/9] baseband/acc: protection for TB negative scenario

Quoted 26 lines · Nicolas Chautru

Adding handling of negative scenario for malformed Transport Block mode operations.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
index 34e42d1f6e..797330a5dd 100644
@@ -1820,6 +1820,9 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
  	r = op->turbo_enc.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (output == NULL)))
+			return -1;
+
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
  		/* Set up DMA descriptor */
  		desc = acc_desc(q, total_enqueued_cbs);

drivers/baseband/acc/rte_vrb_pmd.c enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op, · line 1861

Quoted 5 lines
drivers/baseband/acc/rte_vrb_pmd.c +2 -0
@@ -1854,6 +1857,10 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (current_enqueued_cbs != cbs_in_tb)

Maybe wrap it with unlikely()?

Quoted 36 lines
drivers/baseband/acc/rte_vrb_pmd.c +11 -0
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode. */
  	desc->req.sdone_enable = 1;
 
@@ -2100,6 +2107,9 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  	}
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
+
  		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
@@ -2145,6 +2155,10 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (current_enqueued_cbs != cbs_in_tb)
+		return -1;
+
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	if (check_mbuf_total_left(mbuf_total_left) != 0)
  		return -EINVAL;
@@ -2187,6 +2201,8 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  	r = op->turbo_dec.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
 
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, · line 2262

Quoted 10 lines
drivers/baseband/acc/rte_vrb_pmd.c +4 -0
@@ -2237,6 +2253,10 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (current_enqueued_cbs != cbs_in_tb)
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode */
  	desc->req.sdone_enable = 1;
 

Thanks,
Maxime

#3 lore raw

RE: [PATCH v1 1/9] baseband/acc: protection for TB negative scenario

Hi Maxime,
Thanks, will do in v2.

Quoted 108 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, February 10, 2023 12:17 AM
To: Chautru, Nicolas <[email protected]>; [email protected]
Cc: Vargas, Hernan <[email protected]>; [email protected]
Subject: Re: [PATCH v1 1/9] baseband/acc: protection for TB negative scenario

drivers/baseband/acc/rte_vrb_pmd.c enqueue_enc_one_op_tb(struct acc_queue *q,

Quoted 17 lines · Nicolas Chautru

Adding handling of negative scenario for malformed Transport Block mode operations.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
index 34e42d1f6e..797330a5dd 100644
@@ -1820,6 +1820,9 @@ enqueue_enc_one_op_tb(struct acc_queue *q,

struct rte_bbdev_enc_op *op,

drivers/baseband/acc/rte_vrb_pmd.c enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,

Quoted 9 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
  	r = op->turbo_enc.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (output == NULL)))
+			return -1;
+
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
  		/* Set up DMA descriptor */
  		desc = acc_desc(q, total_enqueued_cbs); @@ -1854,6

+1857,10 @@

Quoted 1 line

enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op

*op,

drivers/baseband/acc/rte_vrb_pmd.c

Quoted 4 lines
  		r++;
  	}
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
+	/* In case the number of CB doesn't match, the configuration was

invalid. */

drivers/baseband/acc/rte_vrb_pmd.c

Quoted 1 line
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
+	if (current_enqueued_cbs != cbs_in_tb)

Maybe wrap it with unlikely()?

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct

Quoted 6 lines
drivers/baseband/acc/rte_vrb_pmd.c +2 -0
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode. */
  	desc->req.sdone_enable = 1;
@@ -2100,6 +2107,9 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct

acc_queue *q, struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,

Quoted 7 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
  	}
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
+
  		if (check_bit(op->ldpc_dec.op_flags,

RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct · line 2114

Quoted 1 line
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
  			seg_total_left = rte_pktmbuf_data_len(input) -

in_offset;

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct

Quoted 2 lines
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
  		else
@@ -2145,6 +2155,10 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct

acc_queue *q, struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct · line 2158

Quoted 4 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was

invalid. */

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q,

Quoted 7 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
+	if (current_enqueued_cbs != cbs_in_tb)
+		return -1;
+
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	if (check_mbuf_total_left(mbuf_total_left) != 0)
  		return -EINVAL;
@@ -2187,6 +2201,8 @@ enqueue_dec_one_op_tb(struct acc_queue *q,

struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q,

Quoted 9 lines
drivers/baseband/acc/rte_vrb_pmd.c +2 -0
  	r = op->turbo_dec.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
 
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 
@@ -2237,6 +2253,10 @@ enqueue_dec_one_op_tb(struct acc_queue *q,

struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q, · line 2256

Quoted 4 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was

invalid. */

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op, · line 2262

Quoted 6 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
+	if (current_enqueued_cbs != cbs_in_tb)
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode */
  	desc->req.sdone_enable = 1;
 

Thanks,
Maxime

#4 lore raw

v2 cover baseband/acc: VRB PMD fixes

In reply to Nicolas Chautru

Hi,

v2: updated based on Maxime's review (commit messages and adding unlikely statement). Thanks. Let me know if further change is required.

Series of mainly fixes for corner-cases and protection in the VRB PMD.
The last 2 commits are not fixes but add support for missing minor capability, as well as a request to remove printf from code (function called from bbdev-test).

Thanks
Nic

Nicolas Chautru (9):
baseband/acc: protection for TB negative scenario baseband/acc: remove interrupt support on VRB1 baseband/acc: add explicit mbuf append for soft output baseband/acc: prevent to dequeue more than requested baseband/acc: fix iteration counter in TB mode baseband/acc: fix potential arithmetic overflow baseband/acc: add support for 4GUL CRC drop in VRB PMD baseband/acc: add support for 4GUL with SO and TB baseband/acc: remove printf from PMD function

 drivers/baseband/acc/rte_acc100_pmd.c |  18 ++---
 drivers/baseband/acc/rte_vrb_pmd.c    | 103 ++++++++++++++++++--------
 drivers/baseband/acc/vrb_pmd.h        |   1 +
 3 files changed, 84 insertions(+), 38 deletions(-)
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 1/9 baseband/acc: protection for TB negative scenario

Adding handling of negative scenario for malformed Transport Block mode operations.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +20 -0
index 34e42d1f6e..3afaea71a3 100644
@@ -1820,6 +1820,9 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
 	r = op->turbo_enc.tb_params.r;
 
 	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (output == NULL)))
+			return -1;
+
 		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 		/* Set up DMA descriptor */
 		desc = acc_desc(q, total_enqueued_cbs);
@@ -1854,6 +1857,10 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
 		r++;
 	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
 	/* Set SDone on last CB descriptor for TB mode. */
 	desc->req.sdone_enable = 1;
 
@@ -2100,6 +2107,9 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 	}
 
 	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
+
 		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
@@ -2145,6 +2155,10 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		r++;
 	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 	if (check_mbuf_total_left(mbuf_total_left) != 0)
 		return -EINVAL;
@@ -2187,6 +2201,8 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 	r = op->turbo_dec.tb_params.r;
 
 	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
 
 		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 
@@ -2237,6 +2253,10 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		r++;
 	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
 	/* Set SDone on last CB descriptor for TB mode */
 	desc->req.sdone_enable = 1;
 
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH v2 1/9] baseband/acc: protection for TB negative scenario

Quoted 4 lines · Nicolas Chautru

Adding handling of negative scenario for malformed Transport Block mode operations.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")

The format is invalid, the sha-1 should be 12B long, checkpatch complains about it:

WARNING:BAD_FIXES_TAG: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: bec597b78a0e ("baseband/acc200: add LTE processing")' #9:

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")

I will fix it here and in other patches.
To avoid such issues, you can add an alias in your git global config file (e.g. ~/.gitconfig):

[alias]

	fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

With this, to generate a Fixes tag, you just have to do:

$ git fixline bec597b78a0e347f7a82a0d51e4a9fc61dea0a16
Fixes: bec597b78a0e ("baseband/acc200: add LTE processing")
Cc: [email protected]

Hernan, this issue is also present in "baseband/acc: fix check after deref and dead code", I will also fix it while applying, but please consider adding the git alias.

Thanks,
Maxime

Quoted 74 lines
---
  drivers/baseband/acc/rte_vrb_pmd.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +20 -0
index 34e42d1f6e..3afaea71a3 100644
@@ -1820,6 +1820,9 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
  	r = op->turbo_enc.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (output == NULL)))
+			return -1;
+
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
  		/* Set up DMA descriptor */
  		desc = acc_desc(q, total_enqueued_cbs);
@@ -1854,6 +1857,10 @@ enqueue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op *op,
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode. */
  	desc->req.sdone_enable = 1;
 
@@ -2100,6 +2107,9 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  	}
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
+
  		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
@@ -2145,6 +2155,10 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	if (check_mbuf_total_left(mbuf_total_left) != 0)
  		return -EINVAL;
@@ -2187,6 +2201,8 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  	r = op->turbo_dec.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
 
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 
@@ -2237,6 +2253,10 @@ enqueue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was invalid. */
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode */
  	desc->req.sdone_enable = 1;
 
#7 lore raw

RE: [PATCH v2 1/9] baseband/acc: protection for TB negative scenario

Thanks Maxime.

Quoted 132 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Thursday, February 23, 2023 12:57 AM
To: Chautru, Nicolas <[email protected]>; Vargas, Hernan <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v2 1/9] baseband/acc: protection for TB negative scenario

Quoted 4 lines · Nicolas Chautru

Adding handling of negative scenario for malformed Transport Block mode operations.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")

The format is invalid, the sha-1 should be 12B long, checkpatch complains about it:

WARNING:BAD_FIXES_TAG: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: bec597b78a0e ("baseband/acc200:
add LTE processing")'
#9:

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")

I will fix it here and in other patches.
To avoid such issues, you can add an alias in your git global config file (e.g. ~/.gitconfig):

[alias]

	fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

With this, to generate a Fixes tag, you just have to do:

$ git fixline bec597b78a0e347f7a82a0d51e4a9fc61dea0a16
Fixes: bec597b78a0e ("baseband/acc200: add LTE processing")
Cc: [email protected]

Hernan, this issue is also present in "baseband/acc: fix check after deref and dead code", I will also fix it while applying, but please consider adding the git alias.

Thanks,
Maxime

Review

Quoted 9 lines
---
  drivers/baseband/acc/rte_vrb_pmd.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
(quoted diff) +0 -0

b/drivers/baseband/acc/rte_vrb_pmd.c

drivers/baseband/acc/rte_vrb_pmd.c enqueue_enc_one_op_tb(struct acc_queue *q,

Quoted 4 lines

index 34e42d1f6e..3afaea71a3 100644

drivers/baseband/acc/rte_vrb_pmd.c +0 -0
@@ -1820,6 +1820,9 @@ enqueue_enc_one_op_tb(struct acc_queue *q,

struct rte_bbdev_enc_op *op,

drivers/baseband/acc/rte_vrb_pmd.c enqueue_enc_one_op_tb(struct acc_queue *q,

Quoted 10 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
  	r = op->turbo_enc.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (output == NULL)))
+			return -1;
+
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
  		/* Set up DMA descriptor */
  		desc = acc_desc(q, total_enqueued_cbs);
@@ -1854,6 +1857,10 @@ enqueue_enc_one_op_tb(struct acc_queue *q,

struct rte_bbdev_enc_op *op,

drivers/baseband/acc/rte_vrb_pmd.c enqueue_enc_one_op_tb(struct acc_queue *q, · line 1860

Quoted 4 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was

invalid. */

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct

Quoted 7 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode. */
  	desc->req.sdone_enable = 1;
 
@@ -2100,6 +2107,9 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct

acc_queue *q, struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op *op,

Quoted 7 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
  	}
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
+
  		if (check_bit(op->ldpc_dec.op_flags,

RTE_BBDEV_LDPC_DEC_SCATTER_GATHER))

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct · line 2114

Quoted 1 line
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
  			seg_total_left = rte_pktmbuf_data_len(input) -

in_offset;

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct

Quoted 2 lines
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
  		else
@@ -2145,6 +2155,10 @@ vrb_enqueue_ldpc_dec_one_op_tb(struct

acc_queue *q, struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_tb(struct · line 2158

Quoted 4 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was

invalid. */

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q,

Quoted 7 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	if (check_mbuf_total_left(mbuf_total_left) != 0)
  		return -EINVAL;
@@ -2187,6 +2201,8 @@ enqueue_dec_one_op_tb(struct acc_queue *q,

struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q,

Quoted 9 lines
drivers/baseband/acc/rte_vrb_pmd.c +2 -0
  	r = op->turbo_dec.tb_params.r;
 
  	while (mbuf_total_left > 0 && r < c) {
+		if (unlikely((input == NULL) || (h_output == NULL)))
+			return -1;
 
  		seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
 
@@ -2237,6 +2253,10 @@ enqueue_dec_one_op_tb(struct acc_queue *q,

struct rte_bbdev_dec_op *op,

drivers/baseband/acc/rte_vrb_pmd.c enqueue_dec_one_op_tb(struct acc_queue *q, · line 2256

Quoted 4 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
  		r++;
  	}
 
+	/* In case the number of CB doesn't match, the configuration was

invalid. */

Quoted 6 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
+	if (unlikely(current_enqueued_cbs != cbs_in_tb))
+		return -1;
+
  	/* Set SDone on last CB descriptor for TB mode */
  	desc->req.sdone_enable = 1;
 
#8 lore raw

PATCH v2 2/9 baseband/acc: remove interrupt support on VRB1

In reply to Nicolas Chautru

Not enabling interrupt in VRB1 PMD variant to avoid potential corner case.

Fixes 3cabc8eaf524 ("baseband/acc200: support interrupt")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +8 -0
index 3afaea71a3..fc68f47ca6 100644
@@ -586,6 +586,14 @@ vrb_intr_enable(struct rte_bbdev *dev)
 {
 	int ret;
 	struct acc_device *d = dev->data->dev_private;
+
+	if (d->device_variant == VRB1_VARIANT) {
+		/* On VRB1: cannot enable MSI/IR to avoid potential back-pressure corner case. */
+		rte_bbdev_log(ERR, "VRB1 (%s) doesn't support any MSI/MSI-X interrupt\n",
+				dev->data->name);
+		return -ENOTSUP;
+	}
+
 	/*
 	 * MSI/MSI-X are supported.
 	 * Option controlled by vfio-intr through EAL parameter.
Signature · 1 line
2.34.1
#9 lore raw

PATCH v2 3/9 baseband/acc: add explicit mbuf append for soft output

In reply to Nicolas Chautru

Adding an explicit mbuf append in the case of soft output mbuf being provided.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +4 -0
index fc68f47ca6..b1134f244d 100644
@@ -2066,6 +2066,10 @@ vrb_enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		}
 	}
 
+	if (op->ldpc_dec.soft_output.length > 0)
+		mbuf_append(op->ldpc_dec.soft_output.data, op->ldpc_dec.soft_output.data,
+				op->ldpc_dec.soft_output.length);
+
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
 			sizeof(desc->req.fcw_ld) - 8);
Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH v2 3/9] baseband/acc: add explicit mbuf append for soft output

Quoted 8 lines · Nicolas Chautru

Adding an explicit mbuf append in the case of soft output mbuf being provided.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")

I don't remember having put my R-by on this patch.

As I suggested to Hernan, one way to avoid such mistakes is to start the next revision by applying the patchwork version. Just get the series link from patchwork and apply it.

E.g. for this specific case:

$ curl http://patches.dpdk.org/series/26933/mbox/ | git am -3

There may be other ways, but that's how I do it.

The patch looks good to me, based on your explanation on V1, so don't remove it in next revision (if any).

Maxime

Quoted 19 lines
---
  drivers/baseband/acc/rte_vrb_pmd.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +4 -0
index fc68f47ca6..b1134f244d 100644
@@ -2066,6 +2066,10 @@ vrb_enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  		}
  	}
 
+	if (op->ldpc_dec.soft_output.length > 0)
+		mbuf_append(op->ldpc_dec.soft_output.data, op->ldpc_dec.soft_output.data,
+				op->ldpc_dec.soft_output.length);
+
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
  			sizeof(desc->req.fcw_ld) - 8);
#11 lore raw

PATCH v2 4/9 baseband/acc: prevent to dequeue more than requested

In reply to Nicolas Chautru

Add support for corner-case when more operations are requested than expected, in the case of encoder muxing operations.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +15 -12
index b1134f244d..a7d0b1e33c 100644
@@ -2640,7 +2640,8 @@ vrb_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
 /* Dequeue one encode operations from device in CB mode. */
 static inline int
 vrb_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)
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued, uint16_t *dequeued_descs,
+		uint16_t max_requested_ops)
 {
 	union acc_dma_desc *desc, atom_desc;
 	union acc_dma_rsp_desc rsp;
@@ -2653,6 +2654,9 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 	desc = q->ring_addr + desc_idx;
 	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + desc->req.numCBs > max_requested_ops)
+		return -1;
+
 	/* Check fdone bit. */
 	if (!(atom_desc.rsp.val & ACC_FDONE))
 		return -1;
@@ -2694,7 +2698,7 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 static inline int
 vrb_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)
+		uint16_t *dequeued_descs, uint16_t max_requested_ops)
 {
 	union acc_dma_desc *desc, *last_desc, atom_desc;
 	union acc_dma_rsp_desc rsp;
@@ -2705,6 +2709,9 @@ vrb_dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 	desc = acc_desc_tail(q, *dequeued_descs);
 	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + 1 > max_requested_ops)
+		return -1;
+
 	/* Check fdone bit. */
 	if (!(atom_desc.rsp.val & ACC_FDONE))
 		return -1;
@@ -2965,25 +2972,23 @@ vrb_dequeue_enc(struct rte_bbdev_queue_data *q_data,
 
 	cbm = op->turbo_enc.code_block_mode;
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < avail; i++) {
 		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
 			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		else
 			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		if (ret < 0)
 			break;
-		if (dequeued_ops >= num)
-			break;
 	}
 
 	q->aq_dequeued += aq_dequeued;
 	q->sw_ring_tail += dequeued_descs;
 
-	/* Update enqueue stats */
+	/* Update enqueue stats. */
 	q_data->queue_stats.dequeued_count += dequeued_ops;
 
 	return dequeued_ops;
@@ -3009,15 +3014,13 @@ vrb_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
 		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
 			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		else
 			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		if (ret < 0)
 			break;
-		if (dequeued_ops >= num)
-			break;
 	}
 
 	q->aq_dequeued += aq_dequeued;
Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 5/9 baseband/acc: fix iteration counter in TB mode

In reply to Nicolas Chautru

The iteration count was not using correct structure (4G vs 5G) in TB mode.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +7 -3
index a7d0b1e33c..ccd3adaf93 100644
@@ -2875,7 +2875,7 @@ vrb_dequeue_ldpc_dec_one_op_cb(struct rte_bbdev_queue_data *q_data,
 	return 1;
 }
 
-/* Dequeue one decode operations from device in TB mode. */
+/* Dequeue one decode operations from device in TB mode for 4G or 5G. */
 static inline int
 vrb_dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
 		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
@@ -2929,8 +2929,12 @@ vrb_dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
 		/* 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);
+		if (q->op_type == RTE_BBDEV_OP_LDPC_DEC)
+			op->ldpc_dec.iter_count = RTE_MAX((uint8_t) rsp.iter_cnt,
+					op->ldpc_dec.iter_count);
+		else
+			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) {
Signature · 1 line
2.34.1
#13 lore raw

PATCH v2 6/9 baseband/acc: fix potential arithmetic overflow

In reply to Nicolas Chautru

Fix potential issue of overflow causing coverity warning.

Coverity issue: 383154

Fixes 8e16839937 ("baseband/acc: extension of the device structure")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 2 +-
 drivers/baseband/acc/vrb_pmd.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
index ccd3adaf93..82dbfcaa53 100644
@@ -518,7 +518,7 @@ vrb_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
 	if (d->tail_ptrs == NULL)
 		d->tail_ptrs = rte_zmalloc_socket(
 				dev->device->driver->name,
-				d->num_qgroups * d->num_aqs * sizeof(uint32_t),
+				VRB_MAX_QGRPS * VRB_MAX_AQS * sizeof(uint32_t),
 				RTE_CACHE_LINE_SIZE, socket_id);
 	if (d->tail_ptrs == NULL) {
 		rte_bbdev_log(ERR, "Failed to allocate tail ptr for %s:%u",
drivers/baseband/acc/vrb_pmd.h +1 -0
index f3c9239881..01028273e7 100644
@@ -36,6 +36,7 @@
 
 #define VRB_NUM_ACCS                 6
 #define VRB_MAX_QGRPS                32
+#define VRB_MAX_AQS                  32
 
 #define ACC_STATUS_WAIT      10
 #define ACC_STATUS_TO        100
Signature · 1 line
2.34.1
#14 lore raw

PATCH v2 7/9 baseband/acc: add support for 4GUL CRC drop in VRB PMD

In reply to Nicolas Chautru

Adding support for the capability to drop the CRC24B when using the turbo-decoder.

---
 drivers/baseband/acc/rte_vrb_pmd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +7 -2
index 82dbfcaa53..5d385ce1a5 100644
@@ -996,6 +996,7 @@ vrb_dev_info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
 				.capability_flags =
 					RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |
 					RTE_BBDEV_TURBO_CRC_TYPE_24B |
+					RTE_BBDEV_TURBO_DEC_CRC_24B_DROP |
 					RTE_BBDEV_TURBO_EQUALIZER |
 					RTE_BBDEV_TURBO_SOFT_OUT_SATURATE |
 					RTE_BBDEV_TURBO_HALF_ITERATION_EVEN |
@@ -1407,8 +1408,12 @@ vrb_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
 	}
 
 	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))
+			&& !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
+		crc24_overlap = 24;
+	if ((op->turbo_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
+			&& check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_CRC_24B_DROP))
 		crc24_overlap = 24;
 
 	/* Calculates circular buffer size.
Signature · 1 line
2.34.1
#15 lore raw

PATCH v2 8/9 baseband/acc: add support for 4GUL with SO and TB

In reply to Nicolas Chautru

Implementation to support the case when using LTE decoder with soft output and transport block mode.

---
 drivers/baseband/acc/rte_vrb_pmd.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +11 -10
index 5d385ce1a5..236f21dca3 100644
@@ -1199,15 +1199,12 @@ vrb_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct acc_fcw_td *fcw)
 	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->c = op->turbo_dec.tb_params.c;
 		fcw->k_pos = op->turbo_dec.tb_params.k_pos;
-		fcw->k_neg = op->turbo_dec.tb_params.k_neg;
 	} else {
+		fcw->c = 1;
 		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;
@@ -1218,8 +1215,14 @@ vrb_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct acc_fcw_td *fcw)
 		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.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
+				fcw->cab = op->turbo_dec.tb_params.cab;
+				fcw->ea = op->turbo_dec.tb_params.ea;
+				fcw->eb = op->turbo_dec.tb_params.eb;
+			} else {
+				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)
@@ -1396,9 +1399,7 @@ vrb_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
 	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;
+		k = 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;
Signature · 1 line
2.34.1
#16 lore raw

PATCH v2 9/9 baseband/acc: remove printf from PMD function

In reply to Nicolas Chautru

Replacing usage of printf in companion function for bbdev-test by rte_log.

---
 drivers/baseband/acc/rte_acc100_pmd.c | 18 +++++++++---------
 drivers/baseband/acc/rte_vrb_pmd.c    |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +9 -9
index 36f6fec5ad..40b5eaf089 100644
@@ -4347,7 +4347,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 {
 	int i, template_idx, qg_idx;
 	uint32_t address, status, value;
-	printf("Need to clear power-on 5GUL status in internal memory\n");
+	rte_bbdev_log(WARNING, "Need to clear power-on 5GUL status in internal memory");
 	/* Reset LDPC Cores */
 	for (i = 0; i < ACC100_ENGINES_MAX; i++)
 		acc_reg_write(d, HWPfFecUl5gCntrlReg +
@@ -4421,7 +4421,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 	/* Force each engine which is in unspecified state */
 	for (i = 0; i < num_failed_engine; i++) {
 		int failed_engine = engines_to_restart[i];
-		printf("Force engine %d\n", failed_engine);
+		rte_bbdev_log(WARNING, "Force engine %d", failed_engine);
 		for (template_idx = ACC100_SIG_UL_5G;
 				template_idx <= ACC100_SIG_UL_5G_LAST;
 				template_idx++) {
@@ -4450,7 +4450,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 		acc_reg_write(d, HWPfQmgrIngressAq + 0x100, enq_req.val);
 		usleep(ACC_LONG_WAIT * 100);
 		if (desc->req.word0 != 2)
-			printf("DMA Response %#"PRIx32"\n", desc->req.word0);
+			rte_bbdev_log(WARNING, "DMA Response %#"PRIx32"\n", desc->req.word0);
 	}
 
 	/* Reset LDPC Cores */
@@ -4482,7 +4482,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 
 	rte_free(d->sw_rings_base);
 	usleep(ACC_LONG_WAIT);
@@ -4671,7 +4671,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 	/* 4GDL */
 	numQqsAcc += numQgs;
 	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -4801,7 +4801,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
 		version += acc_reg_read(d,
 				HWPfDdrPhyIdtmFwVersion + 4 * i) << (8 * i);
 	if (version != ACC100_PRQ_DDR_VER) {
-		printf("* Note: Not on DDR PRQ version %8x != %08x\n",
+		rte_bbdev_log(ERR, "* Note: Not on DDR PRQ version %8x != %08x",
 				version, ACC100_PRQ_DDR_VER);
 	} else if (firstCfg) {
 		/* ---- DDR configuration at boot up --- */
@@ -4871,7 +4871,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
 			if (value & 1)
 				break;
 		}
-		printf("DDR Training completed in %d ms", i);
+		rte_bbdev_log(INFO, "DDR Training completed in %d ms", i);
 		/* Enable Memory Controller */
 		acc_reg_write(d, HWPfDdrUmmcCtrl, 0x401);
 		/* Release AXI interface reset */
@@ -5047,7 +5047,7 @@ acc101_configure(const char *dev_name, struct rte_acc_conf *conf)
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 	/* 4GDL */
 	numQqsAcc += numQgs;
 	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -5185,7 +5185,7 @@ rte_acc_configure(const char *dev_name, struct rte_acc_conf *conf)
 		return -ENODEV;
 	}
 	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(bbdev->device);
-	printf("Configure dev id %x\n", pci_dev->id.device_id);
+	rte_bbdev_log(INFO, "Configure dev id %x", pci_dev->id.device_id);
 	if (pci_dev->id.device_id == ACC100_PF_DEVICE_ID)
 		return acc100_configure(dev_name, conf);
 	else if (pci_dev->id.device_id == ACC101_PF_DEVICE_ID)
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
index 236f21dca3..9e5a73c9c7 100644
@@ -3633,7 +3633,7 @@ vrb1_configure(const char *dev_name, struct rte_acc_conf *conf)
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 	/* 4GDL */
 	numQqsAcc += numQgs;
 	numQgs	= conf->q_dl_4g.num_qgroups;
Signature · 1 line
2.34.1
#17 lore raw
In reply to Nicolas Chautru
Quoted 26 lines · Nicolas Chautru

Hi,

v2: updated based on Maxime's review (commit messages and adding unlikely statement). Thanks. Let me know if further change is required.

Series of mainly fixes for corner-cases and protection in the VRB PMD.
The last 2 commits are not fixes but add support for missing minor capability, as well as a request to remove printf from code (function called from bbdev-test).

Thanks
Nic

Nicolas Chautru (9):
baseband/acc: protection for TB negative scenario baseband/acc: remove interrupt support on VRB1 baseband/acc: add explicit mbuf append for soft output baseband/acc: prevent to dequeue more than requested baseband/acc: fix iteration counter in TB mode baseband/acc: fix potential arithmetic overflow baseband/acc: add support for 4GUL CRC drop in VRB PMD baseband/acc: add support for 4GUL with SO and TB baseband/acc: remove printf from PMD function

Quoted 5 lines
  drivers/baseband/acc/rte_acc100_pmd.c |  18 ++---
  drivers/baseband/acc/rte_vrb_pmd.c    | 103 ++++++++++++++++++--------
  drivers/baseband/acc/vrb_pmd.h        |   1 +
  3 files changed, 84 insertions(+), 38 deletions(-)

Applied to dpdk-next-baseband/for-main.

Thanks,
Maxime
11

#18 lore raw

PATCH 2/9 baseband/acc: add support for 4GUL with SO and TB

In reply to Nicolas Chautru

Implementation to support the case when using LTE decoder with soft output and transport block mode.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +11 -10
index 797330a5dd..c43c08afe8 100644
@@ -1190,15 +1190,12 @@ vrb_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct acc_fcw_td *fcw)
 	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->c = op->turbo_dec.tb_params.c;
 		fcw->k_pos = op->turbo_dec.tb_params.k_pos;
-		fcw->k_neg = op->turbo_dec.tb_params.k_neg;
 	} else {
+		fcw->c = 1;
 		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;
@@ -1209,8 +1206,14 @@ vrb_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct acc_fcw_td *fcw)
 		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.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
+				fcw->cab = op->turbo_dec.tb_params.cab;
+				fcw->ea = op->turbo_dec.tb_params.ea;
+				fcw->eb = op->turbo_dec.tb_params.eb;
+			} else {
+				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)
@@ -1387,9 +1390,7 @@ vrb_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
 	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;
+		k = 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;
Signature · 1 line
2.34.1
#19 lore raw

Re: [PATCH v1 2/9] baseband/acc: add support for 4GUL with SO and TB

Quoted 5 lines · Nicolas Chautru

Implementation to support the case when using LTE decoder with soft output and transport block mode.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")

Should it really be a fix and be backported?
It looks like a new feature.

Quoted 6 lines
---
  drivers/baseband/acc/rte_vrb_pmd.c | 21 +++++++++++----------
  1 file changed, 11 insertions(+), 10 deletions(-)

Thanks,
Maxime

#20 lore raw

RE: [PATCH v1 2/9] baseband/acc: add support for 4GUL with SO and TB

Hi Maxime,

Quoted 11 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, February 10, 2023 12:31 AM
To: Chautru, Nicolas <[email protected]>; [email protected]
Cc: Vargas, Hernan <[email protected]>; [email protected]
Subject: Re: [PATCH v1 2/9] baseband/acc: add support for 4GUL with SO and TB

On 2/9/23 23:19, Nicolas Chautru wrote:

Quoted 8 lines
Quoted 5 lines

Implementation to support the case when using LTE decoder with soft output and transport block mode.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")

Should it really be a fix and be backported?
It looks like a new feature.

I was on a fence. The capability exposed would imply this should be supported already, but indeed no need to backport. I will remove the Fixes in v2, and reorder accordingly the series.

Quoted 10 lines
Quoted 7 lines
---
  drivers/baseband/acc/rte_vrb_pmd.c | 21 +++++++++++----------
  1 file changed, 11 insertions(+), 10 deletions(-)

Thanks,
Maxime

#21 lore raw

PATCH 3/9 baseband/acc: remove interrupt support on VRB1

In reply to Nicolas Chautru

Not enabling interrupt in VRB1 PMD variant to avoid potential corner case.

Fixes 3cabc8eaf524 ("baseband/acc200: support interrupt")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +8 -0
index c43c08afe8..a111836e51 100644
@@ -586,6 +586,14 @@ vrb_intr_enable(struct rte_bbdev *dev)
 {
 	int ret;
 	struct acc_device *d = dev->data->dev_private;
+
+	if (d->device_variant == VRB1_VARIANT) {
+		/* On VRB1: cannot enable MSI/IR to avoid potential back-pressure corner case. */
+		rte_bbdev_log(ERR, "VRB1 (%s) doesn't support any MSI/MSI-X interrupt\n",
+				dev->data->name);
+		return -ENOTSUP;
+	}
+
 	/*
 	 * MSI/MSI-X are supported.
 	 * Option controlled by vfio-intr through EAL parameter.
Signature · 1 line
2.34.1
Reviewed-by on v1 3/9
#22 lore raw

Re: [PATCH v1 3/9] baseband/acc: remove interrupt support on VRB1

Quoted 20 lines · Nicolas Chautru

Not enabling interrupt in VRB1 PMD variant to avoid potential corner case.

Fixes 3cabc8eaf524 ("baseband/acc200: support interrupt")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
index c43c08afe8..a111836e51 100644
@@ -586,6 +586,14 @@ vrb_intr_enable(struct rte_bbdev *dev)
  {
  	int ret;
  	struct acc_device *d = dev->data->dev_private;
+

drivers/baseband/acc/rte_vrb_pmd.c vrb_intr_enable(struct rte_bbdev *dev) · line 599

Quoted 10 lines
drivers/baseband/acc/rte_vrb_pmd.c +7 -0
+	if (d->device_variant == VRB1_VARIANT) {
+		/* On VRB1: cannot enable MSI/IR to avoid potential back-pressure corner case. */
+		rte_bbdev_log(ERR, "VRB1 (%s) doesn't support any MSI/MSI-X interrupt\n",
+				dev->data->name);
+		return -ENOTSUP;
+	}
+
  	/*
  	 * MSI/MSI-X are supported.
  	 * Option controlled by vfio-intr through EAL parameter.

Thanks,
Maxime

#23 lore raw

PATCH 4/9 baseband/acc: add explicit mbuf apend for soft output

In reply to Nicolas Chautru

Adding an explicit mbuf append in the case of soft output mbuf being provided.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +4 -0
index a111836e51..8540e3d31c 100644
@@ -2067,6 +2067,10 @@ vrb_enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
 		}
 	}
 
+	if (op->ldpc_dec.soft_output.length > 0)
+		mbuf_append(op->ldpc_dec.soft_output.data, op->ldpc_dec.soft_output.data,
+				op->ldpc_dec.soft_output.length);
+
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
 			sizeof(desc->req.fcw_ld) - 8);
Signature · 1 line
2.34.1
#24 lore raw

Re: [PATCH v1 4/9] baseband/acc: add explicit mbuf apend for soft output

Quoted 16 lines · Nicolas Chautru

Adding an explicit mbuf append in the case of soft output mbuf being provided.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
index a111836e51..8540e3d31c 100644

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op, · line 2072

Quoted 6 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
@@ -2067,6 +2067,10 @@ vrb_enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op,
  		}
  	}
 
+	if (op->ldpc_dec.soft_output.length > 0)
+		mbuf_append(op->ldpc_dec.soft_output.data, op->ldpc_dec.soft_output.data,
+				op->ldpc_dec.soft_output.length);

No need to check the return value?
IOW, are we sure the buffer we try to append fits into the mbuf?

Quoted 4 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
+
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
  			sizeof(desc->req.fcw_ld) - 8);
#25 lore raw

RE: [PATCH v1 4/9] baseband/acc: add explicit mbuf apend for soft output

Hi Maxime,

Quoted 32 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, February 10, 2023 12:41 AM
To: Chautru, Nicolas <[email protected]>; [email protected]
Cc: Vargas, Hernan <[email protected]>; [email protected]
Subject: Re: [PATCH v1 4/9] baseband/acc: add explicit mbuf apend for soft output

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_cb(struct

Quoted 17 lines · Nicolas Chautru

Adding an explicit mbuf append in the case of soft output mbuf being provided.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
index a111836e51..8540e3d31c 100644
@@ -2067,6 +2067,10 @@ vrb_enqueue_ldpc_dec_one_op_cb(struct

acc_queue *q, struct rte_bbdev_dec_op *op,

Quoted 3 lines
drivers/baseband/acc/rte_vrb_pmd.c +0 -0
  		}
  	}
 
Quoted 7 lines

drivers/baseband/acc/rte_vrb_pmd.c vrb_enqueue_ldpc_dec_one_op_cb(struct acc_queue *q, struct rte_bbdev_dec_op *op, · line 2072

Quoted 4 lines
drivers/baseband/acc/rte_vrb_pmd.c +3 -0
+	if (op->ldpc_dec.soft_output.length > 0)
+		mbuf_append(op->ldpc_dec.soft_output.data, op-
 ldpc_dec.soft_output.data,
+				op->ldpc_dec.soft_output.length);

No need to check the return value?
IOW, are we sure the buffer we try to append fits into the mbuf?

There are many places we currently do not check on mbuf _append() return. Notably as there are many cases where the mbuf structure may not be a genuine mbuf. Ie. when the size may actually not be compatible with mbuf structure (much larger than max supported size). In the case when we know the size is bounded in a way that it would be implemented as true mbuf (HARQ circular buffer whose max size is 66 x 384) then we can do an explicit check.
For other case we manipulate them as mbuf when relevant but still don’t impose the assumption and limitation to have an underlying real mbuf. Keep in mind we do not process packets but perform signal processing (some memory can be extremely large).

Quoted 5 lines
Quoted 5 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -0
+
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	rte_memdump(stderr, "FCW", &desc->req.fcw_ld,
  			sizeof(desc->req.fcw_ld) - 8);
#26 lore raw

PATCH 5/9 baseband/acc: prevent to dequeue more than requested

In reply to Nicolas Chautru

Add support for corner-case when more operations are requested than expected, in the case of encoder muxing operations.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +15 -12
index 8540e3d31c..b251ad25c6 100644
@@ -2641,7 +2641,8 @@ vrb_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
 /* Dequeue one encode operations from device in CB mode. */
 static inline int
 vrb_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)
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued, uint16_t *dequeued_descs,
+		uint16_t max_requested_ops)
 {
 	union acc_dma_desc *desc, atom_desc;
 	union acc_dma_rsp_desc rsp;
@@ -2654,6 +2655,9 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 	desc = q->ring_addr + desc_idx;
 	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + desc->req.numCBs > max_requested_ops)
+		return -1;
+
 	/* Check fdone bit. */
 	if (!(atom_desc.rsp.val & ACC_FDONE))
 		return -1;
@@ -2695,7 +2699,7 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 static inline int
 vrb_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)
+		uint16_t *dequeued_descs, uint16_t max_requested_ops)
 {
 	union acc_dma_desc *desc, *last_desc, atom_desc;
 	union acc_dma_rsp_desc rsp;
@@ -2706,6 +2710,9 @@ vrb_dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
 	desc = acc_desc_tail(q, *dequeued_descs);
 	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + 1 > max_requested_ops)
+		return -1;
+
 	/* Check fdone bit. */
 	if (!(atom_desc.rsp.val & ACC_FDONE))
 		return -1;
@@ -2966,25 +2973,23 @@ vrb_dequeue_enc(struct rte_bbdev_queue_data *q_data,
 
 	cbm = op->turbo_enc.code_block_mode;
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < avail; i++) {
 		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
 			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		else
 			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		if (ret < 0)
 			break;
-		if (dequeued_ops >= num)
-			break;
 	}
 
 	q->aq_dequeued += aq_dequeued;
 	q->sw_ring_tail += dequeued_descs;
 
-	/* Update enqueue stats */
+	/* Update enqueue stats. */
 	q_data->queue_stats.dequeued_count += dequeued_ops;
 
 	return dequeued_ops;
@@ -3010,15 +3015,13 @@ vrb_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
 		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
 			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		else
 			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
 					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
 		if (ret < 0)
 			break;
-		if (dequeued_ops >= num)
-			break;
 	}
 
 	q->aq_dequeued += aq_dequeued;
Signature · 1 line
2.34.1
Reviewed-by on v1 5/9
#27 lore raw

Re: [PATCH v1 5/9] baseband/acc: prevent to dequeue more than requested

Quoted 93 lines · Nicolas Chautru

Add support for corner-case when more operations are requested than expected, in the case of encoder muxing operations.

Fixes e640f6cdfa84 ("baseband/acc200: add LDPC processing")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 27 +++++++++++++++------------
  1 file changed, 15 insertions(+), 12 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +14 -9
index 8540e3d31c..b251ad25c6 100644
@@ -2641,7 +2641,8 @@ vrb_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
  /* Dequeue one encode operations from device in CB mode. */
  static inline int
  vrb_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)
+		uint16_t *dequeued_ops, uint32_t *aq_dequeued, uint16_t *dequeued_descs,
+		uint16_t max_requested_ops)
  {
  	union acc_dma_desc *desc, atom_desc;
  	union acc_dma_rsp_desc rsp;
@@ -2654,6 +2655,9 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
  	desc = q->ring_addr + desc_idx;
  	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + desc->req.numCBs > max_requested_ops)
+		return -1;
+
  	/* Check fdone bit. */
  	if (!(atom_desc.rsp.val & ACC_FDONE))
  		return -1;
@@ -2695,7 +2699,7 @@ vrb_dequeue_enc_one_op_cb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
  static inline int
  vrb_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)
+		uint16_t *dequeued_descs, uint16_t max_requested_ops)
  {
  	union acc_dma_desc *desc, *last_desc, atom_desc;
  	union acc_dma_rsp_desc rsp;
@@ -2706,6 +2710,9 @@ vrb_dequeue_enc_one_op_tb(struct acc_queue *q, struct rte_bbdev_enc_op **ref_op,
  	desc = acc_desc_tail(q, *dequeued_descs);
  	atom_desc.atom_hdr = __atomic_load_n((uint64_t *)desc, __ATOMIC_RELAXED);
 
+	if (*dequeued_ops + 1 > max_requested_ops)
+		return -1;
+
  	/* Check fdone bit. */
  	if (!(atom_desc.rsp.val & ACC_FDONE))
  		return -1;
@@ -2966,25 +2973,23 @@ vrb_dequeue_enc(struct rte_bbdev_queue_data *q_data,
 
  	cbm = op->turbo_enc.code_block_mode;
 
-	for (i = 0; i < num; i++) {
+	for (i = 0; i < avail; i++) {
  		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
  			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
  					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
  		else
  			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],
  					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
  		if (ret < 0)
  			break;
-		if (dequeued_ops >= num)
-			break;
  	}
 
  	q->aq_dequeued += aq_dequeued;
  	q->sw_ring_tail += dequeued_descs;
 
-	/* Update enqueue stats */
+	/* Update enqueue stats. */
  	q_data->queue_stats.dequeued_count += dequeued_ops;
 
  	return dequeued_ops;
@@ -3010,15 +3015,13 @@ vrb_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
  		if (cbm == RTE_BBDEV_TRANSPORT_BLOCK)
  			ret = vrb_dequeue_enc_one_op_tb(q, &ops[dequeued_ops],
  					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
  		else
  			ret = vrb_dequeue_enc_one_op_cb(q, &ops[dequeued_ops],

drivers/baseband/acc/rte_vrb_pmd.c vrb_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data, · line 3027

Quoted 10 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -3
  					&dequeued_ops, &aq_dequeued,
-					&dequeued_descs);
+					&dequeued_descs, num);
  		if (ret < 0)
  			break;
-		if (dequeued_ops >= num)
-			break;
  	}
 
  	q->aq_dequeued += aq_dequeued;

Thanks,
Maxime

#28 lore raw

PATCH 6/9 baseband/acc: fix iteration counter in TB mode

In reply to Nicolas Chautru

The iteration count was not using correct structure (4G vs 5G) in TB mode.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +7 -3
index b251ad25c6..0bd5c65177 100644
@@ -2876,7 +2876,7 @@ vrb_dequeue_ldpc_dec_one_op_cb(struct rte_bbdev_queue_data *q_data,
 	return 1;
 }
 
-/* Dequeue one decode operations from device in TB mode. */
+/* Dequeue one decode operations from device in TB mode for 4G or 5G. */
 static inline int
 vrb_dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
 		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
@@ -2930,8 +2930,12 @@ vrb_dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
 		/* 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);
+		if (q->op_type == RTE_BBDEV_OP_LDPC_DEC)
+			op->ldpc_dec.iter_count = RTE_MAX((uint8_t) rsp.iter_cnt,
+					op->ldpc_dec.iter_count);
+		else
+			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) {
Signature · 1 line
2.34.1
Reviewed-by on v1 6/9
#29 lore raw

Re: [PATCH v1 6/9] baseband/acc: fix iteration counter in TB mode

Quoted 29 lines · Nicolas Chautru

The iteration count was not using correct structure (4G vs 5G) in TB mode.

Fixes bec597b78a0 ("baseband/acc200: add LTE processing")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +1 -2
index b251ad25c6..0bd5c65177 100644
@@ -2876,7 +2876,7 @@ vrb_dequeue_ldpc_dec_one_op_cb(struct rte_bbdev_queue_data *q_data,
  	return 1;
  }
 
-/* Dequeue one decode operations from device in TB mode. */
+/* Dequeue one decode operations from device in TB mode for 4G or 5G. */
  static inline int
  vrb_dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
  		uint16_t dequeued_cbs, uint32_t *aq_dequeued)
@@ -2930,8 +2930,12 @@ vrb_dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op,
  		/* 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,

drivers/baseband/acc/rte_vrb_pmd.c vrb_dequeue_dec_one_op_tb(struct acc_queue *q, struct rte_bbdev_dec_op **ref_op, · line 2941

Quoted 10 lines
drivers/baseband/acc/rte_vrb_pmd.c +6 -1
-				op->turbo_dec.iter_count);
+		if (q->op_type == RTE_BBDEV_OP_LDPC_DEC)
+			op->ldpc_dec.iter_count = RTE_MAX((uint8_t) rsp.iter_cnt,
+					op->ldpc_dec.iter_count);
+		else
+			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) {

Thanks,
Maxime

#30 lore raw

PATCH 7/9 baseband/acc: fix potential arithmetic overflow Fix potential issue of overflow causing coverity warning.

In reply to Nicolas Chautru

Coverity issue: 383154

Fixes 8e16839937 ("baseband/acc: extension of the device structure")
---
 drivers/baseband/acc/rte_vrb_pmd.c | 2 +-
 drivers/baseband/acc/vrb_pmd.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
index 0bd5c65177..8fcb06b4ff 100644
@@ -518,7 +518,7 @@ vrb_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
 	if (d->tail_ptrs == NULL)
 		d->tail_ptrs = rte_zmalloc_socket(
 				dev->device->driver->name,
-				d->num_qgroups * d->num_aqs * sizeof(uint32_t),
+				VRB_MAX_QGRPS * VRB_MAX_AQS * sizeof(uint32_t),
 				RTE_CACHE_LINE_SIZE, socket_id);
 	if (d->tail_ptrs == NULL) {
 		rte_bbdev_log(ERR, "Failed to allocate tail ptr for %s:%u",
drivers/baseband/acc/vrb_pmd.h +1 -0
index f3c9239881..01028273e7 100644
@@ -36,6 +36,7 @@
 
 #define VRB_NUM_ACCS                 6
 #define VRB_MAX_QGRPS                32
+#define VRB_MAX_AQS                  32
 
 #define ACC_STATUS_WAIT      10
 #define ACC_STATUS_TO        100
Signature · 1 line
2.34.1
Reviewed-by on v1 7/9
#31 lore raw

Re: [PATCH v1 7/9] baseband/acc: fix potential arithmetic overflow Fix potential issue of overflow causing coverity warning.

There seems to be formatting issue of the commit log, the commit message is appended to the title.

Quoted 9 lines · Nicolas Chautru

Coverity issue: 383154

Fixes 8e16839937 ("baseband/acc: extension of the device structure")
---
  drivers/baseband/acc/rte_vrb_pmd.c | 2 +-
  drivers/baseband/acc/vrb_pmd.h     | 1 +
  2 files changed, 2 insertions(+), 1 deletion(-)

With commit log fixed:

Thanks,
Maxime

Quoted 25 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
index 0bd5c65177..8fcb06b4ff 100644
@@ -518,7 +518,7 @@ vrb_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
  	if (d->tail_ptrs == NULL)
  		d->tail_ptrs = rte_zmalloc_socket(
  				dev->device->driver->name,
-				d->num_qgroups * d->num_aqs * sizeof(uint32_t),
+				VRB_MAX_QGRPS * VRB_MAX_AQS * sizeof(uint32_t),
  				RTE_CACHE_LINE_SIZE, socket_id);
  	if (d->tail_ptrs == NULL) {
  		rte_bbdev_log(ERR, "Failed to allocate tail ptr for %s:%u",
drivers/baseband/acc/vrb_pmd.h +1 -0
index f3c9239881..01028273e7 100644
@@ -36,6 +36,7 @@
 
  #define VRB_NUM_ACCS                 6
  #define VRB_MAX_QGRPS                32
+#define VRB_MAX_AQS                  32
 
  #define ACC_STATUS_WAIT      10
  #define ACC_STATUS_TO        100
#32 lore raw

PATCH 8/9 baseband/acc: add support for 4GUL CRC drop in VRB PMD

In reply to Nicolas Chautru

Adding support for the capability to drop the CRC24B when using the turbo-decoder.

---
 drivers/baseband/acc/rte_vrb_pmd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +7 -2
index 8fcb06b4ff..18b5dab25f 100644
@@ -996,6 +996,7 @@ vrb_dev_info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
 				.capability_flags =
 					RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |
 					RTE_BBDEV_TURBO_CRC_TYPE_24B |
+					RTE_BBDEV_TURBO_DEC_CRC_24B_DROP |
 					RTE_BBDEV_TURBO_EQUALIZER |
 					RTE_BBDEV_TURBO_SOFT_OUT_SATURATE |
 					RTE_BBDEV_TURBO_HALF_ITERATION_EVEN |
@@ -1408,8 +1409,12 @@ vrb_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
 	}
 
 	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))
+			&& !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
+		crc24_overlap = 24;
+	if ((op->turbo_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
+			&& check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_CRC_24B_DROP))
 		crc24_overlap = 24;
 
 	/* Calculates circular buffer size.
Signature · 1 line
2.34.1
Reviewed-by on v1 8/9
#33 lore raw

Re: [PATCH v1 8/9] baseband/acc: add support for 4GUL CRC drop in VRB PMD

Quoted 25 lines · Nicolas Chautru

Adding support for the capability to drop the CRC24B when using the turbo-decoder.

---
  drivers/baseband/acc/rte_vrb_pmd.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
index 8fcb06b4ff..18b5dab25f 100644
@@ -996,6 +996,7 @@ vrb_dev_info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
  				.capability_flags =
  					RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |
  					RTE_BBDEV_TURBO_CRC_TYPE_24B |
+					RTE_BBDEV_TURBO_DEC_CRC_24B_DROP |
  					RTE_BBDEV_TURBO_EQUALIZER |
  					RTE_BBDEV_TURBO_SOFT_OUT_SATURATE |
  					RTE_BBDEV_TURBO_HALF_ITERATION_EVEN |
@@ -1408,8 +1409,12 @@ vrb_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
  	}
 
  	if ((op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
-		&& !check_bit(op->turbo_dec.op_flags,

drivers/baseband/acc/rte_vrb_pmd.c vrb_dma_desc_td_fill(struct rte_bbdev_dec_op *op, · line 1420

Quoted 10 lines
drivers/baseband/acc/rte_vrb_pmd.c +6 -1
-		RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
+			&& !check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
+		crc24_overlap = 24;
+	if ((op->turbo_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
+			&& check_bit(op->turbo_dec.op_flags,
+			RTE_BBDEV_TURBO_DEC_CRC_24B_DROP))
  		crc24_overlap = 24;
 
  	/* Calculates circular buffer size.

Normally only fixes should be proposed at this stage, but this is small enough:

Thanks,
Maxime

#34 lore raw

PATCH 9/9 baseband/acc: remove printf from PMD function

In reply to Nicolas Chautru

Replacing usage of printf in companion function for bbdev-test by rte_log.

---
 drivers/baseband/acc/rte_acc100_pmd.c | 18 +++++++++---------
 drivers/baseband/acc/rte_vrb_pmd.c    |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +9 -9
index 36f6fec5ad..40b5eaf089 100644
@@ -4347,7 +4347,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 {
 	int i, template_idx, qg_idx;
 	uint32_t address, status, value;
-	printf("Need to clear power-on 5GUL status in internal memory\n");
+	rte_bbdev_log(WARNING, "Need to clear power-on 5GUL status in internal memory");
 	/* Reset LDPC Cores */
 	for (i = 0; i < ACC100_ENGINES_MAX; i++)
 		acc_reg_write(d, HWPfFecUl5gCntrlReg +
@@ -4421,7 +4421,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 	/* Force each engine which is in unspecified state */
 	for (i = 0; i < num_failed_engine; i++) {
 		int failed_engine = engines_to_restart[i];
-		printf("Force engine %d\n", failed_engine);
+		rte_bbdev_log(WARNING, "Force engine %d", failed_engine);
 		for (template_idx = ACC100_SIG_UL_5G;
 				template_idx <= ACC100_SIG_UL_5G_LAST;
 				template_idx++) {
@@ -4450,7 +4450,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 		acc_reg_write(d, HWPfQmgrIngressAq + 0x100, enq_req.val);
 		usleep(ACC_LONG_WAIT * 100);
 		if (desc->req.word0 != 2)
-			printf("DMA Response %#"PRIx32"\n", desc->req.word0);
+			rte_bbdev_log(WARNING, "DMA Response %#"PRIx32"\n", desc->req.word0);
 	}
 
 	/* Reset LDPC Cores */
@@ -4482,7 +4482,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 
 	rte_free(d->sw_rings_base);
 	usleep(ACC_LONG_WAIT);
@@ -4671,7 +4671,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 	/* 4GDL */
 	numQqsAcc += numQgs;
 	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -4801,7 +4801,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
 		version += acc_reg_read(d,
 				HWPfDdrPhyIdtmFwVersion + 4 * i) << (8 * i);
 	if (version != ACC100_PRQ_DDR_VER) {
-		printf("* Note: Not on DDR PRQ version %8x != %08x\n",
+		rte_bbdev_log(ERR, "* Note: Not on DDR PRQ version %8x != %08x",
 				version, ACC100_PRQ_DDR_VER);
 	} else if (firstCfg) {
 		/* ---- DDR configuration at boot up --- */
@@ -4871,7 +4871,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
 			if (value & 1)
 				break;
 		}
-		printf("DDR Training completed in %d ms", i);
+		rte_bbdev_log(INFO, "DDR Training completed in %d ms", i);
 		/* Enable Memory Controller */
 		acc_reg_write(d, HWPfDdrUmmcCtrl, 0x401);
 		/* Release AXI interface reset */
@@ -5047,7 +5047,7 @@ acc101_configure(const char *dev_name, struct rte_acc_conf *conf)
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 	/* 4GDL */
 	numQqsAcc += numQgs;
 	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -5185,7 +5185,7 @@ rte_acc_configure(const char *dev_name, struct rte_acc_conf *conf)
 		return -ENODEV;
 	}
 	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(bbdev->device);
-	printf("Configure dev id %x\n", pci_dev->id.device_id);
+	rte_bbdev_log(INFO, "Configure dev id %x", pci_dev->id.device_id);
 	if (pci_dev->id.device_id == ACC100_PF_DEVICE_ID)
 		return acc100_configure(dev_name, conf);
 	else if (pci_dev->id.device_id == ACC101_PF_DEVICE_ID)
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
index 18b5dab25f..c37f725415 100644
@@ -3633,7 +3633,7 @@ vrb1_configure(const char *dev_name, struct rte_acc_conf *conf)
 		} else
 			acc_reg_write(d, address, 0);
 	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 	/* 4GDL */
 	numQqsAcc += numQgs;
 	numQgs	= conf->q_dl_4g.num_qgroups;
Signature · 1 line
2.34.1
Reviewed-by on v1 9/9
#35 lore raw

Re: [PATCH v1 9/9] baseband/acc: remove printf from PMD function

Quoted 2 lines · Nicolas Chautru

Replacing usage of printf in companion function for bbdev-test by rte_log.

I think it could be backported. If you agree please add Fixes tag and Cc stable.

Quoted 5 lines
---
  drivers/baseband/acc/rte_acc100_pmd.c | 18 +++++++++---------
  drivers/baseband/acc/rte_vrb_pmd.c    |  2 +-
  2 files changed, 10 insertions(+), 10 deletions(-)

For the patch itself:

Thanks,
Maxime

Quoted 98 lines
drivers/baseband/acc/rte_acc100_pmd.c +9 -9
index 36f6fec5ad..40b5eaf089 100644
@@ -4347,7 +4347,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
  {
  	int i, template_idx, qg_idx;
  	uint32_t address, status, value;
-	printf("Need to clear power-on 5GUL status in internal memory\n");
+	rte_bbdev_log(WARNING, "Need to clear power-on 5GUL status in internal memory");
  	/* Reset LDPC Cores */
  	for (i = 0; i < ACC100_ENGINES_MAX; i++)
  		acc_reg_write(d, HWPfFecUl5gCntrlReg +
@@ -4421,7 +4421,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
  	/* Force each engine which is in unspecified state */
  	for (i = 0; i < num_failed_engine; i++) {
  		int failed_engine = engines_to_restart[i];
-		printf("Force engine %d\n", failed_engine);
+		rte_bbdev_log(WARNING, "Force engine %d", failed_engine);
  		for (template_idx = ACC100_SIG_UL_5G;
  				template_idx <= ACC100_SIG_UL_5G_LAST;
  				template_idx++) {
@@ -4450,7 +4450,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
  		acc_reg_write(d, HWPfQmgrIngressAq + 0x100, enq_req.val);
  		usleep(ACC_LONG_WAIT * 100);
  		if (desc->req.word0 != 2)
-			printf("DMA Response %#"PRIx32"\n", desc->req.word0);
+			rte_bbdev_log(WARNING, "DMA Response %#"PRIx32"\n", desc->req.word0);
  	}
 
  	/* Reset LDPC Cores */
@@ -4482,7 +4482,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 
  	rte_free(d->sw_rings_base);
  	usleep(ACC_LONG_WAIT);
@@ -4671,7 +4671,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
  	/* 4GDL */
  	numQqsAcc += numQgs;
  	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -4801,7 +4801,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
  		version += acc_reg_read(d,
  				HWPfDdrPhyIdtmFwVersion + 4 * i) << (8 * i);
  	if (version != ACC100_PRQ_DDR_VER) {
-		printf("* Note: Not on DDR PRQ version %8x != %08x\n",
+		rte_bbdev_log(ERR, "* Note: Not on DDR PRQ version %8x != %08x",
  				version, ACC100_PRQ_DDR_VER);
  	} else if (firstCfg) {
  		/* ---- DDR configuration at boot up --- */
@@ -4871,7 +4871,7 @@ acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
  			if (value & 1)
  				break;
  		}
-		printf("DDR Training completed in %d ms", i);
+		rte_bbdev_log(INFO, "DDR Training completed in %d ms", i);
  		/* Enable Memory Controller */
  		acc_reg_write(d, HWPfDdrUmmcCtrl, 0x401);
  		/* Release AXI interface reset */
@@ -5047,7 +5047,7 @@ acc101_configure(const char *dev_name, struct rte_acc_conf *conf)
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
  	/* 4GDL */
  	numQqsAcc += numQgs;
  	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -5185,7 +5185,7 @@ rte_acc_configure(const char *dev_name, struct rte_acc_conf *conf)
  		return -ENODEV;
  	}
  	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(bbdev->device);
-	printf("Configure dev id %x\n", pci_dev->id.device_id);
+	rte_bbdev_log(INFO, "Configure dev id %x", pci_dev->id.device_id);
  	if (pci_dev->id.device_id == ACC100_PF_DEVICE_ID)
  		return acc100_configure(dev_name, conf);
  	else if (pci_dev->id.device_id == ACC101_PF_DEVICE_ID)
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
index 18b5dab25f..c37f725415 100644
@@ -3633,7 +3633,7 @@ vrb1_configure(const char *dev_name, struct rte_acc_conf *conf)
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
  	/* 4GDL */
  	numQqsAcc += numQgs;
  	numQgs	= conf->q_dl_4g.num_qgroups;
#36 lore raw

RE: [PATCH v1 9/9] baseband/acc: remove printf from PMD function

Hi Maxime,

Quoted 9 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, February 10, 2023 1:45 AM
To: Chautru, Nicolas <[email protected]>; [email protected]
Cc: Vargas, Hernan <[email protected]>
Subject: Re: [PATCH v1 9/9] baseband/acc: remove printf from PMD function

Quoted 5 lines
Quoted 2 lines · Nicolas Chautru

Replacing usage of printf in companion function for bbdev-test by rte_log.

I think it could be backported. If you agree please add Fixes tag and Cc stable.

That function is only used for bbdev-test so would not really fix anything.
We are changing this mainly to help imposing a rule moving forward for no printf in that PMD directory. Based on this I don’t think we have to backport. But if you are convinced this is required, ok as well.

Quoted 129 lines
Quoted 6 lines
---
  drivers/baseband/acc/rte_acc100_pmd.c | 18 +++++++++---------
  drivers/baseband/acc/rte_vrb_pmd.c    |  2 +-
  2 files changed, 10 insertions(+), 10 deletions(-)

For the patch itself:

Thanks,
Maxime

drivers/baseband/acc/rte_acc100_pmd.c poweron_cleanup(struct rte_bbdev *bbdev, struct

Quoted 6 lines
drivers/baseband/acc/rte_acc100_pmd.c +0 -0
index 36f6fec5ad..40b5eaf089 100644
@@ -4347,7 +4347,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct

acc_device *d,

drivers/baseband/acc/rte_acc100_pmd.c poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,

Quoted 9 lines
drivers/baseband/acc/rte_acc100_pmd.c +2 -1
  {
  	int i, template_idx, qg_idx;
  	uint32_t address, status, value;
-	printf("Need to clear power-on 5GUL status in internal memory\n");
+	rte_bbdev_log(WARNING, "Need to clear power-on 5GUL status in
+internal memory");
  	/* Reset LDPC Cores */
  	for (i = 0; i < ACC100_ENGINES_MAX; i++)
  		acc_reg_write(d, HWPfFecUl5gCntrlReg + @@ -4421,7

+4421,7 @@

drivers/baseband/acc/rte_acc100_pmd.c poweron_cleanup(struct rte_bbdev *bbdev, struct

Quoted 10 lines

poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,
/* Force each engine which is in unspecified state */ for (i = 0; i < num_failed_engine; i++) {
int failed_engine = engines_to_restart[i];

drivers/baseband/acc/rte_acc100_pmd.c +1 -1
-		printf("Force engine %d\n", failed_engine);
+		rte_bbdev_log(WARNING, "Force engine %d", failed_engine);
  		for (template_idx = ACC100_SIG_UL_5G;
  				template_idx <= ACC100_SIG_UL_5G_LAST;
  				template_idx++) {
@@ -4450,7 +4450,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct

acc_device *d,

drivers/baseband/acc/rte_acc100_pmd.c poweron_cleanup(struct rte_bbdev *bbdev, struct acc_device *d,

Quoted 6 lines
drivers/baseband/acc/rte_acc100_pmd.c +1 -1
  		acc_reg_write(d, HWPfQmgrIngressAq + 0x100, enq_req.val);
  		usleep(ACC_LONG_WAIT * 100);
  		if (desc->req.word0 != 2)
-			printf("DMA Response %#"PRIx32"\n", desc-
 req.word0);
+			rte_bbdev_log(WARNING, "DMA Response

%#"PRIx32"\n",

drivers/baseband/acc/rte_acc100_pmd.c poweron_cleanup(struct rte_bbdev *bbdev, struct

Quoted 5 lines
drivers/baseband/acc/rte_acc100_pmd.c +1 -0
+desc->req.word0);
  	}
 
  	/* Reset LDPC Cores */
@@ -4482,7 +4482,7 @@ poweron_cleanup(struct rte_bbdev *bbdev, struct

acc_device *d,

drivers/baseband/acc/rte_acc100_pmd.c acc100_configure(const char *dev_name, struct

Quoted 9 lines
drivers/baseband/acc/rte_acc100_pmd.c +1 -1
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
 
  	rte_free(d->sw_rings_base);
  	usleep(ACC_LONG_WAIT);
@@ -4671,7 +4671,7 @@ acc100_configure(const char *dev_name, struct

rte_acc_conf *conf)

drivers/baseband/acc/rte_acc100_pmd.c acc100_configure(const char *dev_name, struct

Quoted 9 lines
drivers/baseband/acc/rte_acc100_pmd.c +1 -1
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
  	/* 4GDL */
  	numQqsAcc += numQgs;
  	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -4801,7 +4801,7 @@ acc100_configure(const char *dev_name, struct

rte_acc_conf *conf)

drivers/baseband/acc/rte_acc100_pmd.c acc100_configure(const char *dev_name, struct rte_acc_conf *conf)

Quoted 5 lines
drivers/baseband/acc/rte_acc100_pmd.c +1 -1
  		version += acc_reg_read(d,
  				HWPfDdrPhyIdtmFwVersion + 4 * i) << (8 * i);
  	if (version != ACC100_PRQ_DDR_VER) {
-		printf("* Note: Not on DDR PRQ version %8x != %08x\n",
+		rte_bbdev_log(ERR, "* Note: Not on DDR PRQ version %8x !=

%08x",

drivers/baseband/acc/rte_acc100_pmd.c acc100_configure(const char *dev_name, struct rte_acc_conf *conf)

Quoted 3 lines
drivers/baseband/acc/rte_acc100_pmd.c +0 -0
  				version, ACC100_PRQ_DDR_VER);
  	} else if (firstCfg) {
  		/* ---- DDR configuration at boot up --- */ @@ -4871,7 +4871,7

@@

drivers/baseband/acc/rte_acc100_pmd.c acc101_configure(const char *dev_name, struct

Quoted 10 lines

acc100_configure(const char *dev_name, struct rte_acc_conf *conf)
if (value & 1)
break;
}

drivers/baseband/acc/rte_acc100_pmd.c +1 -1
-		printf("DDR Training completed in %d ms", i);
+		rte_bbdev_log(INFO, "DDR Training completed in %d ms", i);
  		/* Enable Memory Controller */
  		acc_reg_write(d, HWPfDdrUmmcCtrl, 0x401);
  		/* Release AXI interface reset */
@@ -5047,7 +5047,7 @@ acc101_configure(const char *dev_name, struct

rte_acc_conf *conf)

drivers/baseband/acc/rte_acc100_pmd.c rte_acc_configure(const char *dev_name, struct

Quoted 9 lines
drivers/baseband/acc/rte_acc100_pmd.c +1 -1
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
  	/* 4GDL */
  	numQqsAcc += numQgs;
  	numQgs	= conf->q_dl_4g.num_qgroups;
@@ -5185,7 +5185,7 @@ rte_acc_configure(const char *dev_name, struct

rte_acc_conf *conf)

drivers/baseband/acc/rte_vrb_pmd.c vrb1_configure(const char *dev_name, struct

Quoted 14 lines
drivers/baseband/acc/rte_acc100_pmd.c +1 -1
  		return -ENODEV;
  	}
  	struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(bbdev->device);
-	printf("Configure dev id %x\n", pci_dev->id.device_id);
+	rte_bbdev_log(INFO, "Configure dev id %x", pci_dev->id.device_id);
  	if (pci_dev->id.device_id == ACC100_PF_DEVICE_ID)
  		return acc100_configure(dev_name, conf);
  	else if (pci_dev->id.device_id == ACC101_PF_DEVICE_ID) diff --git

a/drivers/baseband/acc/rte_vrb_pmd.c
b/drivers/baseband/acc/rte_vrb_pmd.c
index 18b5dab25f..c37f725415 100644

drivers/baseband/acc/rte_vrb_pmd.c +0 -0
@@ -3633,7 +3633,7 @@ vrb1_configure(const char *dev_name, struct

rte_acc_conf *conf)

Quoted 8 lines
drivers/baseband/acc/rte_vrb_pmd.c +1 -1
  		} else
  			acc_reg_write(d, address, 0);
  	}
-	printf("Number of 5GUL engines %d\n", numEngines);
+	rte_bbdev_log(INFO, "Number of 5GUL engines %d", numEngines);
  	/* 4GDL */
  	numQqsAcc += numQgs;
  	numQgs	= conf->q_dl_4g.num_qgroups;