net/virtio: fix incorrect cast of void *
[dpdk.git] / drivers / crypto / dpaa2_sec / hw / desc / ipsec.h
index 2bfe553..cc63736 100644 (file)
@@ -1,7 +1,41 @@
-/*
- * Copyright 2008-2016 Freescale Semiconductor, Inc.
+/*-
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ *   BSD LICENSE
+ *
+ * Copyright 2008-2016 Freescale Semiconductor Inc.
+ * Copyright 2016 NXP.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
  *
- * SPDX-License-Identifier: BSD-3-Clause or GPL-2.0+
+ *   GPL LICENSE SUMMARY
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef __DESC_IPSEC_H__
@@ -1277,8 +1311,11 @@ cnstr_shdsc_ipsec_new_decap(uint32_t *descbuf, bool ps,
  * @descbuf: pointer to buffer used for descriptor construction
  * @ps: if 36/40bit addressing is desired, this parameter must be true
  * @swap: if true, perform descriptor byte swapping on a 4-byte boundary
- * @cipherdata: ointer to block cipher transform definitions.
+ * @cipherdata: pointer to block cipher transform definitions.
  *              Valid algorithm values one of OP_ALG_ALGSEL_* {DES, 3DES, AES}
+ *              Valid modes for:
+ *                  AES: OP_ALG_AAI_* {CBC, CTR}
+ *                  DES, 3DES: OP_ALG_AAI_CBC
  * @authdata: pointer to authentication transform definitions.
  *            Valid algorithm values - one of OP_ALG_ALGSEL_* {MD5, SHA1,
  *            SHA224, SHA256, SHA384, SHA512}
@@ -1345,8 +1382,9 @@ cnstr_shdsc_authenc(uint32_t *descbuf, bool ps, bool swap,
 {
        struct program prg;
        struct program *p = &prg;
-       const bool is_aes_dec = (dir == DIR_DEC) &&
-                               (cipherdata->algtype == OP_ALG_ALGSEL_AES);
+       const bool need_dk = (dir == DIR_DEC) &&
+                            (cipherdata->algtype == OP_ALG_ALGSEL_AES) &&
+                            (cipherdata->algmode == OP_ALG_AAI_CBC);
 
        LABEL(skip_patch_len);
        LABEL(keyjmp);
@@ -1432,7 +1470,7 @@ cnstr_shdsc_authenc(uint32_t *descbuf, bool ps, bool swap,
                      dir == DIR_ENC ? ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,
                      dir);
 
-       if (is_aes_dec)
+       if (need_dk)
                ALG_OPERATION(p, OP_ALG_ALGSEL_AES, cipherdata->algmode,
                              OP_ALG_AS_INITFINAL, ICV_CHECK_DISABLE, dir);
        pskipkeys = JUMP(p, skipkeys, LOCAL_JUMP, ALL_TRUE, 0);
@@ -1444,7 +1482,7 @@ cnstr_shdsc_authenc(uint32_t *descbuf, bool ps, bool swap,
                      dir == DIR_ENC ? ICV_CHECK_DISABLE : ICV_CHECK_ENABLE,
                      dir);
 
-       if (is_aes_dec) {
+       if (need_dk) {
                ALG_OPERATION(p, OP_ALG_ALGSEL_AES, cipherdata->algmode |
                              OP_ALG_AAI_DK, OP_ALG_AS_INITFINAL,
                              ICV_CHECK_DISABLE, dir);
@@ -1469,7 +1507,10 @@ cnstr_shdsc_authenc(uint32_t *descbuf, bool ps, bool swap,
        SET_LABEL(p, aonly_len_offset);
 
        /* Read IV */
-       SEQLOAD(p, CONTEXT1, 0, ivlen, 0);
+       if (cipherdata->algmode == OP_ALG_AAI_CTR)
+               SEQLOAD(p, CONTEXT1, 16, ivlen, 0);
+       else
+               SEQLOAD(p, CONTEXT1, 0, ivlen, 0);
 
        /*
         * Read data needed only for authentication. This is overwritten above