replace unused attributes
[dpdk.git] / drivers / crypto / dpaa2_sec / dpaa2_sec_dpseci.c
index 173ec80..6caa760 100644 (file)
@@ -1433,7 +1433,7 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
        uint32_t loop;
        int32_t ret;
        struct qbman_fd fd_arr[MAX_TX_RING_SLOTS];
-       uint32_t frames_to_send;
+       uint32_t frames_to_send, retry_count;
        struct qbman_eq_desc eqdesc;
        struct dpaa2_sec_qp *dpaa2_qp = (struct dpaa2_sec_qp *)qp;
        struct qbman_swp *swp;
@@ -1491,16 +1491,29 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
                        }
                        ops++;
                }
+
                loop = 0;
+               retry_count = 0;
                while (loop < frames_to_send) {
-                       loop += qbman_swp_enqueue_multiple(swp, &eqdesc,
-                                                       &fd_arr[loop],
-                                                       &flags[loop],
-                                                       frames_to_send - loop);
+                       ret = qbman_swp_enqueue_multiple(swp, &eqdesc,
+                                                        &fd_arr[loop],
+                                                        &flags[loop],
+                                                        frames_to_send - loop);
+                       if (unlikely(ret < 0)) {
+                               retry_count++;
+                               if (retry_count > DPAA2_MAX_TX_RETRY_COUNT) {
+                                       num_tx += loop;
+                                       nb_ops -= loop;
+                                       goto skip_tx;
+                               }
+                       } else {
+                               loop += ret;
+                               retry_count = 0;
+                       }
                }
 
-               num_tx += frames_to_send;
-               nb_ops -= frames_to_send;
+               num_tx += loop;
+               nb_ops -= loop;
        }
 skip_tx:
        dpaa2_qp->tx_vq.tx_pkts += num_tx;
@@ -1582,18 +1595,13 @@ sec_fd_to_mbuf(const struct qbman_fd *fd)
 
 #ifdef RTE_LIBRTE_SECURITY
        if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
-               dpaa2_sec_session *sess = (dpaa2_sec_session *)
-                       get_sec_session_private_data(op->sym->sec_session);
-               if (sess->ctxt_type == DPAA2_SEC_IPSEC ||
-                               sess->ctxt_type == DPAA2_SEC_PDCP) {
-                       uint16_t len = DPAA2_GET_FD_LEN(fd);
-                       dst->pkt_len = len;
-                       while (dst->next != NULL) {
-                               len -= dst->data_len;
-                               dst = dst->next;
-                       }
-                       dst->data_len = len;
+               uint16_t len = DPAA2_GET_FD_LEN(fd);
+               dst->pkt_len = len;
+               while (dst->next != NULL) {
+                       len -= dst->data_len;
+                       dst = dst->next;
                }
+               dst->data_len = len;
        }
 #endif
        DPAA2_SEC_DP_DEBUG("mbuf %p BMAN buf addr %p,"
@@ -1790,15 +1798,6 @@ dpaa2_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
        return retcode;
 }
 
-/** Return the number of allocated queue pairs */
-static uint32_t
-dpaa2_sec_queue_pair_count(struct rte_cryptodev *dev)
-{
-       PMD_INIT_FUNC_TRACE();
-
-       return dev->data->nb_queue_pairs;
-}
-
 /** Returns the size of the aesni gcm session structure */
 static unsigned int
 dpaa2_sec_sym_session_get_size(struct rte_cryptodev *dev __rte_unused)
@@ -1863,7 +1862,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
                cipherdata.algmode = OP_ALG_AAI_CBC;
                session->cipher_alg = RTE_CRYPTO_CIPHER_AES_CBC;
                bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0,
-                                               SHR_NEVER, &cipherdata, NULL,
+                                               SHR_NEVER, &cipherdata,
                                                session->iv.length,
                                                session->dir);
                break;
@@ -1872,7 +1871,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
                cipherdata.algmode = OP_ALG_AAI_CBC;
                session->cipher_alg = RTE_CRYPTO_CIPHER_3DES_CBC;
                bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0,
-                                               SHR_NEVER, &cipherdata, NULL,
+                                               SHR_NEVER, &cipherdata,
                                                session->iv.length,
                                                session->dir);
                break;
@@ -1881,7 +1880,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
                cipherdata.algmode = OP_ALG_AAI_CTR;
                session->cipher_alg = RTE_CRYPTO_CIPHER_AES_CTR;
                bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0,
-                                               SHR_NEVER, &cipherdata, NULL,
+                                               SHR_NEVER, &cipherdata,
                                                session->iv.length,
                                                session->dir);
                break;
@@ -1890,7 +1889,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
                cipherdata.algmode = OP_ALG_AAI_CTR;
                session->cipher_alg = RTE_CRYPTO_CIPHER_3DES_CTR;
                bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0,
-                                               SHR_NEVER, &cipherdata, NULL,
+                                               SHR_NEVER, &cipherdata,
                                                session->iv.length,
                                                session->dir);
                break;
@@ -2635,6 +2634,7 @@ dpaa2_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform,
                memcpy(session->auth_key.data, auth_xform->key.data,
                                auth_xform->key.length);
                session->auth_alg = auth_xform->algo;
+               session->digest_length = auth_xform->digest_length;
        } else {
                session->auth_key.data = NULL;
                session->auth_key.length = 0;
@@ -2657,6 +2657,10 @@ dpaa2_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform,
        case RTE_CRYPTO_AUTH_SHA256_HMAC:
                authdata->algtype = OP_PCL_IPSEC_HMAC_SHA2_256_128;
                authdata->algmode = OP_ALG_AAI_HMAC;
+               if (session->digest_length != 16)
+                       DPAA2_SEC_WARN(
+                       "+++Using sha256-hmac truncated len is non-standard,"
+                       "it will not work with lookaside proto");
                break;
        case RTE_CRYPTO_AUTH_SHA384_HMAC:
                authdata->algtype = OP_PCL_IPSEC_HMAC_SHA2_384_192;
@@ -2812,6 +2816,10 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
 
                /* copy algo specific data to PDB */
                switch (cipherdata.algtype) {
+               case OP_PCL_IPSEC_AES_CTR:
+                       encap_pdb.ctr.ctr_initial = 0x00000001;
+                       encap_pdb.ctr.ctr_nonce = ipsec_xform->salt;
+                       break;
                case OP_PCL_IPSEC_AES_GCM8:
                case OP_PCL_IPSEC_AES_GCM12:
                case OP_PCL_IPSEC_AES_GCM16:
@@ -2882,6 +2890,10 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
                memset(&decap_pdb, 0, sizeof(struct ipsec_decap_pdb));
                /* copy algo specific data to PDB */
                switch (cipherdata.algtype) {
+               case OP_PCL_IPSEC_AES_CTR:
+                       decap_pdb.ctr.ctr_initial = 0x00000001;
+                       decap_pdb.ctr.ctr_nonce = ipsec_xform->salt;
+                       break;
                case OP_PCL_IPSEC_AES_GCM8:
                case OP_PCL_IPSEC_AES_GCM12:
                case OP_PCL_IPSEC_AES_GCM16:
@@ -2896,6 +2908,27 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
                                sizeof(struct rte_ipv6_hdr) << 16;
                if (ipsec_xform->options.esn)
                        decap_pdb.options |= PDBOPTS_ESP_ESN;
+
+               if (ipsec_xform->replay_win_sz) {
+                       uint32_t win_sz;
+                       win_sz = rte_align32pow2(ipsec_xform->replay_win_sz);
+
+                       switch (win_sz) {
+                       case 1:
+                       case 2:
+                       case 4:
+                       case 8:
+                       case 16:
+                       case 32:
+                               decap_pdb.options |= PDBOPTS_ESP_ARS32;
+                               break;
+                       case 64:
+                               decap_pdb.options |= PDBOPTS_ESP_ARS64;
+                               break;
+                       default:
+                               decap_pdb.options |= PDBOPTS_ESP_ARS128;
+                       }
+               }
                session->dir = DIR_DEC;
                bufsize = cnstr_shdsc_ipsec_new_decap(priv->flc_desc[0].desc,
                                1, 0, SHR_SERIAL,
@@ -3523,7 +3556,7 @@ dpaa2_sec_process_parallel_event(struct qbman_swp *swp,
        qbman_swp_dqrr_consume(swp, dq);
 }
 static void
-dpaa2_sec_process_atomic_event(struct qbman_swp *swp __attribute__((unused)),
+dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused,
                                 const struct qbman_fd *fd,
                                 const struct qbman_result *dq,
                                 struct dpaa2_queue *rxq,
@@ -3632,7 +3665,6 @@ static struct rte_cryptodev_ops crypto_ops = {
        .stats_reset          = dpaa2_sec_stats_reset,
        .queue_pair_setup     = dpaa2_sec_queue_pair_setup,
        .queue_pair_release   = dpaa2_sec_queue_pair_release,
-       .queue_pair_count     = dpaa2_sec_queue_pair_count,
        .sym_session_get_size     = dpaa2_sec_sym_session_get_size,
        .sym_session_configure    = dpaa2_sec_sym_session_configure,
        .sym_session_clear        = dpaa2_sec_sym_session_clear,