Skip to content

Commit

Permalink
crypto/ipsec_mb: fix ZUC operation overwrite
Browse files Browse the repository at this point in the history
[ upstream commit 96d0dc2 ]

ZUC PMD batches crypto operations depending on their type
(encryption + tag generation, tag verification + decryption, etc),
to allow parallelization.
The array used to store the pointers to these operations was
always the same array provided by dequeue_burst() function,
and it was looping around the same positions (from 0 to ZUC_MAX_BURST - 1).

A new internal array is used to avoid overwriting the pointers
of the array provided by dequeue_burst() function.

Fixes: cf7685d ("crypto/zuc: add driver for ZUC library")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
  • Loading branch information
pablodelara authored and bluca committed Feb 28, 2022
1 parent 4bc8222 commit 92d7cb4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/crypto/zuc/rte_zuc_pmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ static uint16_t
zuc_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
uint16_t nb_ops)
{
struct rte_crypto_op *c_ops[ZUC_MAX_BURST];
struct rte_crypto_op *curr_c_op;

struct zuc_session *curr_sess;
struct zuc_session *sessions[ZUC_MAX_BURST];
struct rte_crypto_op *int_c_ops[ZUC_MAX_BURST];
enum zuc_operation prev_zuc_op = ZUC_OP_NOT_SUPPORTED;
enum zuc_operation curr_zuc_op;
struct zuc_qp *qp = queue_pair;
Expand All @@ -389,19 +389,19 @@ zuc_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
*/
if (burst_size == 0) {
prev_zuc_op = curr_zuc_op;
c_ops[0] = curr_c_op;
int_c_ops[0] = curr_c_op;
sessions[0] = curr_sess;
burst_size++;
} else if (curr_zuc_op == prev_zuc_op) {
c_ops[burst_size] = curr_c_op;
int_c_ops[burst_size] = curr_c_op;
sessions[burst_size] = curr_sess;
burst_size++;
/*
* When there are enough ops to process in a batch,
* process them, and start a new batch.
*/
if (burst_size == ZUC_MAX_BURST) {
processed_ops = process_ops(c_ops, curr_zuc_op,
processed_ops = process_ops(int_c_ops, curr_zuc_op,
sessions, qp, burst_size,
&enqueued_ops);
if (processed_ops < burst_size) {
Expand All @@ -416,7 +416,7 @@ zuc_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
* Different operation type, process the ops
* of the previous type.
*/
processed_ops = process_ops(c_ops, prev_zuc_op,
processed_ops = process_ops(int_c_ops, prev_zuc_op,
sessions, qp, burst_size,
&enqueued_ops);
if (processed_ops < burst_size) {
Expand All @@ -427,15 +427,15 @@ zuc_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
burst_size = 0;
prev_zuc_op = curr_zuc_op;

c_ops[0] = curr_c_op;
int_c_ops[0] = curr_c_op;
sessions[0] = curr_sess;
burst_size++;
}
}

if (burst_size != 0) {
/* Process the crypto ops of the last operation type. */
processed_ops = process_ops(c_ops, prev_zuc_op,
processed_ops = process_ops(int_c_ops, prev_zuc_op,
sessions, qp, burst_size,
&enqueued_ops);
}
Expand Down

0 comments on commit 92d7cb4

Please sign in to comment.