From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id C314A7CF6; Thu, 19 Apr 2018 16:22:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2018 07:22:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,469,1517904000"; d="scan'208";a="49172914" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga001.jf.intel.com with ESMTP; 19 Apr 2018 07:22:33 -0700 Received: from irsmsx111.ger.corp.intel.com (10.108.20.4) by irsmsx110.ger.corp.intel.com (163.33.3.25) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 19 Apr 2018 15:22:32 +0100 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.176]) by irsmsx111.ger.corp.intel.com ([169.254.2.167]) with mapi id 14.03.0319.002; Thu, 19 Apr 2018 15:22:32 +0100 From: "Trahe, Fiona" To: "De Lara Guarch, Pablo" , "dev@dpdk.org" CC: "De Lara Guarch, Pablo" , "stable@dpdk.org" , "Trahe, Fiona" Thread-Topic: [dpdk-dev] [PATCH 3/3] crypto/zuc: batch ops with same transform Thread-Index: AQHTx3aVSUMOql9xbUSQMlCkvLBg/6QIQJxQ Date: Thu, 19 Apr 2018 14:22:32 +0000 Message-ID: <348A99DA5F5B7549AA880327E580B43589377167@IRSMSX101.ger.corp.intel.com> References: <20180329155621.29619-1-pablo.de.lara.guarch@intel.com> <20180329155621.29619-4-pablo.de.lara.guarch@intel.com> In-Reply-To: <20180329155621.29619-4-pablo.de.lara.guarch@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGZlZjNlZjgtYzg2Yy00MjQ2LWFkYTEtNzRkNmFmOTAxYjRmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Im1NaUxmZFp5eUd0VGk2eElVU0U1ZTFqY2NoeXlqbTFvQ0piWUJRWlU4WDA9In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 3/3] crypto/zuc: batch ops with same transform X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Apr 2018 14:22:37 -0000 Hi Pablo, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara > Sent: Thursday, March 29, 2018 4:56 PM > To: dev@dpdk.org > Cc: De Lara Guarch, Pablo ; stable@dpdk.o= rg > Subject: [dpdk-dev] [PATCH 3/3] crypto/zuc: batch ops with same transform >=20 > The ZUC API to encrypt packets does not require the operations > to share the same key. Currently, the operations were being > batched only when they shared the same key, but this is not needed. >=20 > Instead, now operations will be batched based on the transform > (cipher only, auth only...). >=20 > Fixes: cf7685d68f00 ("crypto/zuc: add driver for ZUC library") > Cc: stable@dpdk.org >=20 > Signed-off-by: Pablo de Lara [Fiona] A couple of comments need updating - see below Apart from that=20 Acked-by: Fiona Trahe > --- > drivers/crypto/zuc/rte_zuc_pmd.c | 97 +++++++++++++++++++++++++---------= ------ > 1 file changed, 60 insertions(+), 37 deletions(-) >=20 > diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zu= c_pmd.c > index 568c593ae..ea0efcf6b 100644 > --- a/drivers/crypto/zuc/rte_zuc_pmd.c > +++ b/drivers/crypto/zuc/rte_zuc_pmd.c > @@ -12,7 +12,7 @@ >=20 > #include "rte_zuc_pmd_private.h" >=20 > -#define ZUC_MAX_BURST 8 > +#define ZUC_MAX_BURST 4 > #define BYTE_LEN 8 >=20 > static uint8_t cryptodev_driver_id; > @@ -171,7 +171,7 @@ zuc_get_session(struct zuc_qp *qp, struct rte_crypto_= op *op) > /** Encrypt/decrypt mbufs with same cipher key. */ [Fiona] Not necessarily same key > static uint8_t > process_zuc_cipher_op(struct rte_crypto_op **ops, > - struct zuc_session *session, > + struct zuc_session **sessions, > uint8_t num_ops) > { > unsigned i; > @@ -180,6 +180,7 @@ process_zuc_cipher_op(struct rte_crypto_op **ops, > uint8_t *iv[ZUC_MAX_BURST]; > uint32_t num_bytes[ZUC_MAX_BURST]; > uint8_t *cipher_keys[ZUC_MAX_BURST]; > + struct zuc_session *sess; >=20 > for (i =3D 0; i < num_ops; i++) { > if (((ops[i]->sym->cipher.data.length % BYTE_LEN) !=3D 0) > @@ -190,6 +191,8 @@ process_zuc_cipher_op(struct rte_crypto_op **ops, > break; > } >=20 > + sess =3D sessions[i]; > + > #ifdef RTE_LIBRTE_PMD_ZUC_DEBUG > if (!rte_pktmbuf_is_contiguous(ops[i]->sym->m_src) || > (ops[i]->sym->m_dst !=3D NULL && > @@ -211,10 +214,10 @@ process_zuc_cipher_op(struct rte_crypto_op **ops, > rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + > (ops[i]->sym->cipher.data.offset >> 3); > iv[i] =3D rte_crypto_op_ctod_offset(ops[i], uint8_t *, > - session->cipher_iv_offset); > + sess->cipher_iv_offset); > num_bytes[i] =3D ops[i]->sym->cipher.data.length >> 3; >=20 > - cipher_keys[i] =3D session->pKey_cipher; > + cipher_keys[i] =3D sess->pKey_cipher; >=20 > processed_ops++; > } > @@ -228,7 +231,7 @@ process_zuc_cipher_op(struct rte_crypto_op **ops, > /** Generate/verify hash from mbufs with same hash key. */ [Fiona] Not necessarily same key > static int > process_zuc_hash_op(struct zuc_qp *qp, struct rte_crypto_op **ops, > - struct zuc_session *session, > + struct zuc_session **sessions, > uint8_t num_ops) > { > unsigned i; > @@ -237,6 +240,7 @@ process_zuc_hash_op(struct zuc_qp *qp, struct rte_cry= pto_op **ops, > uint32_t *dst; > uint32_t length_in_bits; > uint8_t *iv; > + struct zuc_session *sess; >=20 > for (i =3D 0; i < num_ops; i++) { > /* Data must be byte aligned */ > @@ -246,17 +250,19 @@ process_zuc_hash_op(struct zuc_qp *qp, struct rte_c= rypto_op **ops, > break; > } >=20 > + sess =3D sessions[i]; > + > length_in_bits =3D ops[i]->sym->auth.data.length; >=20 > src =3D rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + > (ops[i]->sym->auth.data.offset >> 3); > iv =3D rte_crypto_op_ctod_offset(ops[i], uint8_t *, > - session->auth_iv_offset); > + sess->auth_iv_offset); >=20 > - if (session->auth_op =3D=3D RTE_CRYPTO_AUTH_OP_VERIFY) { > + if (sess->auth_op =3D=3D RTE_CRYPTO_AUTH_OP_VERIFY) { > dst =3D (uint32_t *)qp->temp_digest; >=20 > - sso_zuc_eia3_1_buffer(session->pKey_hash, > + sso_zuc_eia3_1_buffer(sess->pKey_hash, > iv, src, > length_in_bits, dst); > /* Verify digest. */ > @@ -266,7 +272,7 @@ process_zuc_hash_op(struct zuc_qp *qp, struct rte_cry= pto_op **ops, > } else { > dst =3D (uint32_t *)ops[i]->sym->auth.digest.data; >=20 > - sso_zuc_eia3_1_buffer(session->pKey_hash, > + sso_zuc_eia3_1_buffer(sess->pKey_hash, > iv, src, > length_in_bits, dst); > } > @@ -278,31 +284,32 @@ process_zuc_hash_op(struct zuc_qp *qp, struct rte_c= rypto_op **ops, >=20 > /** Process a batch of crypto ops which shares the same session. */ [Fiona] same type, not same session > static int > -process_ops(struct rte_crypto_op **ops, struct zuc_session *session, > +process_ops(struct rte_crypto_op **ops, enum zuc_operation op_type, > + struct zuc_session **sessions, > struct zuc_qp *qp, uint8_t num_ops, > uint16_t *accumulated_enqueued_ops) > { > unsigned i; > unsigned enqueued_ops, processed_ops; >=20 > - switch (session->op) { > + switch (op_type) { > case ZUC_OP_ONLY_CIPHER: > processed_ops =3D process_zuc_cipher_op(ops, > - session, num_ops); > + sessions, num_ops); > break; > case ZUC_OP_ONLY_AUTH: > - processed_ops =3D process_zuc_hash_op(qp, ops, session, > + processed_ops =3D process_zuc_hash_op(qp, ops, sessions, > num_ops); > break; > case ZUC_OP_CIPHER_AUTH: > - processed_ops =3D process_zuc_cipher_op(ops, session, > + processed_ops =3D process_zuc_cipher_op(ops, sessions, > num_ops); > - process_zuc_hash_op(qp, ops, session, processed_ops); > + process_zuc_hash_op(qp, ops, sessions, processed_ops); > break; > case ZUC_OP_AUTH_CIPHER: > - processed_ops =3D process_zuc_hash_op(qp, ops, session, > + processed_ops =3D process_zuc_hash_op(qp, ops, sessions, > num_ops); > - process_zuc_cipher_op(ops, session, processed_ops); > + process_zuc_cipher_op(ops, sessions, processed_ops); > break; > default: > /* Operation not supported. */ > @@ -318,10 +325,10 @@ process_ops(struct rte_crypto_op **ops, struct zuc_= session *session, > ops[i]->status =3D RTE_CRYPTO_OP_STATUS_SUCCESS; > /* Free session if a session-less crypto op. */ > if (ops[i]->sess_type =3D=3D RTE_CRYPTO_OP_SESSIONLESS) { > - memset(session, 0, sizeof(struct zuc_session)); > + memset(sessions[i], 0, sizeof(struct zuc_session)); > memset(ops[i]->sym->session, 0, > rte_cryptodev_get_header_session_size()); > - rte_mempool_put(qp->sess_mp, session); > + rte_mempool_put(qp->sess_mp, sessions[i]); > rte_mempool_put(qp->sess_mp, ops[i]->sym->session); > ops[i]->sym->session =3D NULL; > } > @@ -342,7 +349,10 @@ zuc_pmd_enqueue_burst(void *queue_pair, struct rte_c= rypto_op **ops, > struct rte_crypto_op *c_ops[ZUC_MAX_BURST]; > struct rte_crypto_op *curr_c_op; >=20 > - struct zuc_session *prev_sess =3D NULL, *curr_sess =3D NULL; > + struct zuc_session *curr_sess; > + struct zuc_session *sessions[ZUC_MAX_BURST]; > + enum zuc_operation prev_zuc_op =3D ZUC_OP_NOT_SUPPORTED; > + enum zuc_operation curr_zuc_op; > struct zuc_qp *qp =3D queue_pair; > unsigned i; > uint8_t burst_size =3D 0; > @@ -359,50 +369,63 @@ zuc_pmd_enqueue_burst(void *queue_pair, struct rte_= crypto_op **ops, > break; > } >=20 > - /* Batch ops that share the same session. */ > - if (prev_sess =3D=3D NULL) { > - prev_sess =3D curr_sess; > - c_ops[burst_size++] =3D curr_c_op; > - } else if (curr_sess =3D=3D prev_sess) { > - c_ops[burst_size++] =3D curr_c_op; > + curr_zuc_op =3D curr_sess->op; > + > + /* > + * Batch ops that share the same operation type > + * (cipher only, auth only...). > + */ > + if (burst_size =3D=3D 0) { > + prev_zuc_op =3D curr_zuc_op; > + c_ops[0] =3D curr_c_op; > + sessions[0] =3D curr_sess; > + burst_size++; > + } else if (curr_zuc_op =3D=3D prev_zuc_op) { > + c_ops[burst_size] =3D curr_c_op; > + sessions[burst_size] =3D curr_sess; > + burst_size++; > /* > * When there are enough ops to process in a batch, > * process them, and start a new batch. > */ > if (burst_size =3D=3D ZUC_MAX_BURST) { > - processed_ops =3D process_ops(c_ops, prev_sess, > - qp, burst_size, &enqueued_ops); > + processed_ops =3D process_ops(c_ops, curr_zuc_op, > + sessions, qp, burst_size, > + &enqueued_ops); > if (processed_ops < burst_size) { > burst_size =3D 0; > break; > } >=20 > burst_size =3D 0; > - prev_sess =3D NULL; > } > } else { > /* > - * Different session, process the ops > - * of the previous session. > + * Different operation type, process the ops > + * of the previous type. > */ > - processed_ops =3D process_ops(c_ops, prev_sess, > - qp, burst_size, &enqueued_ops); > + processed_ops =3D process_ops(c_ops, prev_zuc_op, > + sessions, qp, burst_size, > + &enqueued_ops); > if (processed_ops < burst_size) { > burst_size =3D 0; > break; > } >=20 > burst_size =3D 0; > - prev_sess =3D curr_sess; > + prev_zuc_op =3D curr_zuc_op; >=20 > - c_ops[burst_size++] =3D curr_c_op; > + c_ops[0] =3D curr_c_op; > + sessions[0] =3D curr_sess; > + burst_size++; > } > } >=20 > if (burst_size !=3D 0) { > /* Process the crypto ops of the last session. */ [Fiona] ...of the last op_type > - processed_ops =3D process_ops(c_ops, prev_sess, > - qp, burst_size, &enqueued_ops); > + processed_ops =3D process_ops(c_ops, prev_zuc_op, > + sessions, qp, burst_size, > + &enqueued_ops); > } >=20 > qp->qp_stats.enqueue_err_count +=3D nb_ops - enqueued_ops; > -- > 2.14.3