cryptodev: move IV parameters to session
[dpdk.git] / drivers / crypto / kasumi / rte_kasumi_pmd.c
index 290f670..810699f 100644 (file)
@@ -116,6 +116,13 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
                /* Only KASUMI F8 supported */
                if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_KASUMI_F8)
                        return -EINVAL;
+
+               sess->iv_offset = cipher_xform->cipher.iv.offset;
+               if (cipher_xform->cipher.iv.length != KASUMI_IV_LENGTH) {
+                       KASUMI_LOG_ERR("Wrong IV length");
+                       return -EINVAL;
+               }
+
                /* Initialize key */
                sso_kasumi_init_f8_key_sched(cipher_xform->cipher.key.data,
                                &sess->pKeySched_cipher);
@@ -179,13 +186,6 @@ process_kasumi_cipher_op(struct rte_crypto_op **ops,
        uint32_t num_bytes[num_ops];
 
        for (i = 0; i < num_ops; i++) {
-               /* Sanity checks. */
-               if (ops[i]->sym->cipher.iv.length != KASUMI_IV_LENGTH) {
-                       ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-                       KASUMI_LOG_ERR("iv");
-                       break;
-               }
-
                src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
                                (ops[i]->sym->cipher.data.offset >> 3);
                dst[i] = ops[i]->sym->m_dst ?
@@ -194,7 +194,7 @@ process_kasumi_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_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
-                               ops[i]->sym->cipher.iv.offset);
+                               session->iv_offset);
                iv[i] = *((uint64_t *)(iv_ptr));
                num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
 
@@ -218,13 +218,6 @@ process_kasumi_cipher_op_bit(struct rte_crypto_op *op,
        uint64_t iv;
        uint32_t length_in_bits, offset_in_bits;
 
-       /* Sanity checks. */
-       if (unlikely(op->sym->cipher.iv.length != KASUMI_IV_LENGTH)) {
-               op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-               KASUMI_LOG_ERR("iv");
-               return 0;
-       }
-
        offset_in_bits = op->sym->cipher.data.offset;
        src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
        if (op->sym->m_dst == NULL) {
@@ -234,7 +227,7 @@ process_kasumi_cipher_op_bit(struct rte_crypto_op *op,
        }
        dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
        iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
-                       op->sym->cipher.iv.offset);
+                       session->iv_offset);
        iv = *((uint64_t *)(iv_ptr));
        length_in_bits = op->sym->cipher.data.length;