aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/crypto/algapi.h3
-rw-r--r--include/crypto/hash.h2
-rw-r--r--include/crypto/pka_4xx.h897
-rw-r--r--include/crypto/trng4xx.h131
-rw-r--r--include/linux/async_tx.h3
-rw-r--r--include/linux/crypto.h13
-rw-r--r--include/linux/cryptodev.h85
-rw-r--r--include/linux/dmaengine.h7
-rw-r--r--include/linux/if_ether.h1
-rw-r--r--include/linux/leds.h10
-rw-r--r--include/linux/mtd/partitions.h5
-rw-r--r--include/linux/netdevice.h22
-rw-r--r--include/linux/pagemap.h5
-rw-r--r--include/linux/pipe_fs_i.h2
-rw-r--r--include/linux/sockios.h4
-rw-r--r--include/linux/splice.h34
-rwxr-xr-xinclude/linux/trustees.h108
-rw-r--r--include/net/ah.h8
-rw-r--r--include/net/esp.h9
-rw-r--r--include/net/macsec.h55
-rw-r--r--include/net/xfrm.h5
21 files changed, 1403 insertions, 6 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 1ffb53f74d3..6a0bbc0c9ab 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -12,6 +12,7 @@
#ifndef _CRYPTO_ALGAPI_H
#define _CRYPTO_ALGAPI_H
+#include <crypto/hash.h>
#include <linux/crypto.h>
#include <linux/list.h>
#include <linux/kernel.h>
@@ -344,5 +345,7 @@ static inline int crypto_requires_sync(u32 type, u32 mask)
return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC;
}
+
+
#endif /* _CRYPTO_ALGAPI_H */
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 26cb1eb16f4..ddd7f63a4d0 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -63,6 +63,7 @@ struct shash_alg {
int (*update)(struct shash_desc *desc, const u8 *data,
unsigned int len);
int (*final)(struct shash_desc *desc, u8 *out);
+ int (*partial)(struct shash_desc *desc, u8 *out);
int (*finup)(struct shash_desc *desc, const u8 *data,
unsigned int len, u8 *out);
int (*digest)(struct shash_desc *desc, const u8 *data,
@@ -73,6 +74,7 @@ struct shash_alg {
unsigned int keylen);
unsigned int descsize;
+ unsigned int partialsize;
/* These fields must match hash_alg_common. */
unsigned int digestsize
diff --git a/include/crypto/pka_4xx.h b/include/crypto/pka_4xx.h
new file mode 100644
index 00000000000..41663fd7d9a
--- /dev/null
+++ b/include/crypto/pka_4xx.h
@@ -0,0 +1,897 @@
+/*******************************************************************************
+ *
+ * Copyright (c) 2008 Loc Ho <lho@amcc.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *
+ * Detail Description:
+ * This file defines ioctl structures for the Linux CryptoAPI interface. It
+ * provides user space applications accesss into the Linux CryptoAPI
+ * functionalities.
+ *
+ * @file pka4xx.h
+ *
+ * This file provides helper to the AMCC SoC PKA hardware.
+ *
+ *******************************************************************************
+ */
+#ifndef __PKA4XX_H__
+#define __PKA4XX_H__
+
+#define PKA4XX_RAM_SIZE (8*1024)
+/* Reserve last 72 bytes for used by sequencer firmware and round down
+ to 8-bytes align */
+#define PKA4XX_RAM_FREE_SIZE (((8*1024)-72)&~0x7)
+#define PKA4XX_PROGRAM_SIZE (2*1024)
+
+/**
+ * PKA Register and bit Definitions
+ *
+ */
+
+/* Register PKT_FUNCTION bit definition */
+#define PKA_FUNCTION_MUL 0x00000001
+#define PKA_FUNCTION_ADDSUB 0x00000002
+#define PKA_FUNCTION_RSVD 0x00000004
+#define PKA_FUNCTION_MSONE 0x00000008
+#define PKA_FUNCTION_ADD 0x00000010
+#define PKA_FUNCTION_SUB 0x00000020
+#define PKA_FUNCTION_RSHIFT 0x00000040
+#define PKA_FUNCTION_LSHIFT 0x00000080
+#define PKA_FUNCTION_DIV 0x00000100
+#define PKA_FUNCTION_MOD 0x00000200
+#define PKA_FUNCTION_COMPARE 0x00000400
+#define PKA_FUNCTION_COPY 0x00000800
+#define PKA_FUNCTION_SEQOP_MASK (7 << 12)
+#define PKA_FUNCTION_SEQOP_EXPMOD_CRT (1 << 12)
+#define PKA_FUNCTION_SEQOP_EXPMOD_ACT4 (2 << 12)
+#define PKA_FUNCTION_SEQOP_ECC_ADD (3 << 12)
+#define PKA_FUNCTION_SEQOP_EXPMOD_ACT2 (4 << 12)
+#define PKA_FUNCTION_SEQOP_ECC_MUL (5 << 12)
+#define PKA_FUNCTION_SEQOP_EXPMOD_VAR (6 << 12)
+#define PKA_FUNCTION_SEQOP_MODINV (7 << 12)
+#define PKA_FUNCTION_RUN (1 << 15)
+#define PKA_FUNCTION_STALL (1 << 24)
+
+/* Register PKA_COMPARE bit definition */
+#define PKA_COMPARE_EQUAL 0x00000001
+#define PKA_COMPARE_LESSTHAN 0x00000002
+#define PKA_COMPARE_GREATHERTHAN 0x00000004
+
+/* Register PKA_MSW bit definition */
+#define PKA_MSW_ADDR_MASK 0x000007FF
+#define PKA_MSW_RESULT_ZERO (1 << 15)
+
+/* Register PKA_DIVMSW bit definition */
+#define PKA_DIVMSW_ADDR_MASK 0x000007FF
+#define PKA_DIVMSW_RESULT_ZERO (1 << 15)
+
+/* Register PKA_SEQ_CTRL bit definition */
+#define PKA_SEQ_CTRL_SW_CTRL_TRIGGER_MASK 0x000000FF
+#define PKA_SEQ_CTRL_SEQ_STATUS_MASK 0x0000FF00
+#define PKA_SEQ_CTRL_RESET 0x80000000
+
+/* PKA Registers definitions */
+#define PKA_APTR_ADDR 0x0000
+#define PKA_BPTR_ADDR 0x0004
+#define PKA_CPTR_ADDR 0x0008
+#define PKA_DPTR_ADDR 0x000C
+#define PKA_ALENGTH_ADDR 0x0010
+#define PKA_BLENGTH_ADDR 0x0014
+#define PKA_SHIFT_ADDR 0x0018
+#define PKA_FUNCTION_ADDR 0x001C
+#define PKA_COMPARE_ADDR 0x0020
+#define PKA_MSW_ADDR 0x0024
+#define PKA_DIVMSW_ADDR 0x0028
+#define PKA_SEQ_CTRL_ADDR 0x00C8
+#define PKA_RAM_ADDR 0x2000
+#define PKA_PROGRAM_ADDR 0x2000 /* PKA Program area is shared
+ with PKA_RAM. To access,
+ put the Sequencer into reset.
+ See PKA_SEQ_CTRL. */
+
+/* # of operation can be queued */
+#define PKA4XX_PENDING_OP_MAX 256
+#define MAX_FREE_DESC_AVAIL_TRY 10
+
+typedef void (*pka4xx_cb)(void *ctx, int status);
+
+/** Structure definitions used for asynchronous PKA operations */
+struct pka4xx_async_pkcp_op {
+ u32 vecA_cnt;
+ u32 *vecA;
+ u32 vecB_cnt;
+ u32 *vecB;
+ u32 *vec_addsub_C;
+ u8 shift_val;
+};
+
+struct pka4xx_async_expmod_op {
+ u32 *base;
+ u32 *exp;
+ u32 *modulus;
+ u32 exp_cnt;
+ u32 base_mod_cnt;
+};
+
+struct pka4xx_async_expmod_crt_op {
+ u32 *expP;
+ u32 *expQ;
+ u32 exp_len;
+ u32 *modP;
+ u32 *modQ;
+ u32 mod_inverse_len;
+ u32 *inverseQ;
+ u32 *input;
+};
+
+#define async_pkcp async_op.pkcp_op
+#define async_expmod async_op.expmod_op
+#define async_expmod_crt async_op.expmod_crt_op
+
+struct pka4xx_op
+{
+ u8 id;
+ u32 opcode; /* Encoded as PKA_FUNCTION register */
+ pka4xx_cb cb; /* Callback function */
+ void *ctx; /* Context for callback function */
+ u16 resultC_cnt; /* # of DWORD for result C */
+ u16 resultD_cnt; /* # of DWORD for result D */
+ u32 *resultC_addr; /* Address for result C */
+ u32 *resultD_addr; /* Address for result C */
+ u32 ramC_addr; /* PKA RAM Address for result C in DWORD unit */
+ u32 ramD_addr; /* PKA RAM Address for result D in DWORD unit */
+ u32 ram_addr_start; /* PKA RAM Address start */
+ u16 ram_addr_size; /* PKA RAM Address size */
+ struct list_head next;
+ int status;
+ union {
+ struct pka4xx_async_expmod_crt_op expmod_crt_op;
+ struct pka4xx_async_expmod_op expmod_op;
+ struct pka4xx_async_pkcp_op pkcp_op;
+ } async_op;
+};
+
+/** Context for async operations */
+struct pka4xx_ctx
+{
+ s16 ram_blk2use;
+ struct {
+ u8 usable;
+ s16 sizeDW;
+ u32 addrDW;
+ } ram_blk[2];
+ u16 op_head;
+ u16 op_tail;
+ struct pka4xx_op op[PKA4XX_PENDING_OP_MAX];
+ u32 csr_paddr;
+ u32 pka_ram_paddr;
+ volatile char *csr;
+ volatile char *pka_ram;
+ int irq;
+ struct list_head completed_event_queue;
+
+ spinlock_t lock;
+ struct tasklet_struct tasklet;
+};
+
+struct hal_config;
+
+/**
+ * @brief IRQ Handler for PKA Interrupts
+ * @return Success/Failure
+ */
+irqreturn_t pka4xx_irq_handler(int irq, void *id);
+
+/**
+ * @brief Tasklet for post-processing of result of PKA operstaions
+ */
+void pka4xx_tasklet_cb (unsigned long data);
+
+/**
+ * @brief Process completed events
+ */
+void pka4xx_process_completed_event (struct pka4xx_op *op);
+
+/**
+ * @brief Retrieve the PKA context (OS neutral)
+ * @return A pointer to PKA context
+ * @note New layer of the device musts returns a pointer to this variables.
+ *
+ *
+ */
+struct pka4xx_ctx *pka_get_ctx(void);
+
+/**
+ * @brief This function MUSTs be called to initialize the HW
+ * access function.
+ * @param amcc_hal_cfg HW access configuration. If NULL,
+ * default will be used.
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ * @note To load all access functions from HAL with default initial
+ * map address, pass a NULL as its parameter.
+ * @n To load all access functions from HAL with default runtime
+ * map address, initialize an amcc_hal_config_t struct
+ * with valid HAL signature and set
+ * amcc_hal_config->flags |= HAL_FLAG_LOADINIT;
+ *
+ *******************************************************************************
+ */
+int pka4xx_config_set(struct hal_config *cfg);
+
+/**
+ * @brief This function MUSTs be called to de-initialize the HW
+ * access function.
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ *
+ *
+ */
+int pka4xx_config_clear(void);
+
+/**
+ * @brief This functions reads from the PKA registers.
+ * @param reg_addr Device register offset
+ * @param data_val An DWORD pointer to store the returned value
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ *
+ *
+ */
+int pka4xx_csr_hw_read32(u32 reg_addr, u32 *data_val);
+
+/**
+ * @brief This functions writes to the PKA registers.
+ * @param reg_addr Device register offset
+ * @param data_val An DWORD value to write
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ *
+ *
+ */
+int pka4xx_csr_hw_write32(u32 reg_addr, u32 data_val);
+
+/**
+ * @brief This functions reads from the PKA RAM.
+ * @param reg_addr ram addr
+ * @param data_val An DWORD pointer to store the returned value
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ *
+ *
+ */
+int pka4xx_ram_hw_read32(u32 reg_addr, u32 *data_val);
+
+/**
+ * @brief This functions writes to the PKA RAM.
+ * @param reg_addr ram addr
+ * @param data_val An DWORD value to write
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ *
+ *
+ */
+int pka4xx_ram_hw_write32(u32 reg_addr, u32 data_val);
+/**
+ * @brief Initiaize PKA hardware
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ *
+ *
+ */
+int pka4xx_hw_init(void);
+
+/**
+ * @brief De-Initiaize PKA hardware
+ * @return PPRO_RC_OK or PPRO_RC_FATAL
+ *
+ *
+ */
+int pka4xx_hw_deinit(void);
+
+/**< PKA input vector max count */
+#define PKA4XX_VECTOR_MAXSIZE 256
+
+/**
+ * @brief Performs large vector multiplication (A * B = C)
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param multiplicand_len Length of multiplicand in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param multiplicand Multiplicand vector pointer of the operation - input A
+ * @param multiplier_len Length of multiplier in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param multiplier Multiplier vector pointer of the operation - input B
+ * @param product Result product vector - output C. Length is
+ * multiplicand_len * multiplier_len in DWORD unit
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_mul(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 multiplicand_len,
+ u32 *multiplicand,
+ u32 multiplier_len,
+ u32 *multiplier,
+ u32 *product);
+
+/**
+ * @brief Performs vector division (A / B = D and A % B = C)
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param dividend_len Length of dividend in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param dividend Dividend vector pointer of the operation - input A
+ * @param divisor_len Length of divisor in DWORD unit (<= dividend_len <=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param divisor Divisor vector pointer of the operation - input B -
+ * where most significant 32 bits != 0
+ * @param remainder Result reminder vector pointer of the operation -
+ * output C. Length is divisor_len + 1 in DWORD unit
+ * @param quotient Result integer vector pointer of the operation -
+ * output D. Length is dividend_len - divisor_len + 1
+ * in DWORD unit
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_div(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 dividend_len,
+ u32 *dividend,
+ u32 divisor_len,
+ u32 *divisor,
+ u32 *remainder,
+ u32 *quotient);
+
+/**
+ * @brief Performs vector modulo (A % B = C) where B != 0
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param dividend_len Length of dividend in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param dividend Dividend vector pointer of the operation - input A
+ * @param divisor_len Length of divisor in DWORD unit (<= dividend_len <=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param divisor Divisor vector pointer of the operation - input B
+ * @param remainder Result reminder vector pointer of the operation -
+ * output C. Length is divisor_len + 1 in DWORD unit
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_mod(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 dividend_len,
+ u32 *dividend,
+ u32 divisor_len,
+ u32 *divisor,
+ u32 *remainder);
+
+/**
+ * @brief Performs vector addition (A + B = C)
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param addendA_len Length of addendA in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param addendA Addend vector pointer of the operation - input A
+ * @param addendB_len Length of addendB in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param addendB Addend vector pointer of the operation - input B
+ * @param sum Result sum vector pointer of the operation - output C.
+ * Length is MAX(addendA_len, addendB_len) + 1 in DWORD
+ * unit
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_add(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 addendA_len,
+ u32 *addendA,
+ u32 addendB_len,
+ u32 *addendB,
+ u32 *sum);
+
+/**
+ * @brief Performs vector substraction (A - B = C) where A >= B
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param minuend_len Length of minuend in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param minuend Minuendnd vector pointer of the operation - input A
+ * @param subtrahend_len Length of minuend in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param subtrahend Subtrahend vector pointer of the operation - input B
+ * @param difference Result difference vector pointer of the operation -
+ * output C. Length is MAX(minuend_len, subtrahend_len)
+ * in DWORD unit.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_sub(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 minuend_len,
+ u32 *minuend,
+ u32 subtrahend_len,
+ u32 *subtrahend,
+ u32 *difference);
+
+/**
+ * @brief Performs vector addition and then substraction (A + C - B = D) where
+ * A + C >= B.
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param input_cnt Length of all inputs in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param addendA Addend vector pointer of the operation - input A
+ * @param addendC Addend vector pointer of the operation - input C
+ * @param subtrahend Subtrahend vector pointer of the operation - input B
+ * @param result Result vector pointer of the operation - output D.
+ * Length is input_cnt + 1 in DWORD unit.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_addsub(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 input_cnt,
+ u32 *addendA,
+ u32 *addendC,
+ u32 *subtrahend,
+ u32 *result);
+
+/**
+ * @brief Performs vector right shift (A >> X = C)
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param input_cnt Length of input in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param input Input vector pointer of the operation - input A
+ * @param shift Shift value of the operation - input X. 0 <= shift <= 31
+ * @param result Result vector pointer of the operation - output C
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_rshift(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 input_cnt,
+ u32 *input,
+ u8 shift,
+ u32 *result);
+
+/**
+ * @brief Performs vector left shift (A << X = C)
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param input_cnt Length of input in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param input Input vector pointer of the operation - input A
+ * @param shift Shift value of the operation - input X. 0 <= shift <= 31
+ * @param result Result vector pointer of the operation - output C
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_lshift(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 input_cnt,
+ u32 *input,
+ u8 shift,
+ u32 *result);
+
+/**
+ * @brief Performs vector comparsion (A < B, A == B, or A > B)
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param input1_cnt Length of input1 in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param input1 Input vector pointer of the operation - input A
+ * @param input2_cnt Length of input2 in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param input2 Input vector pointer of the operation - input B
+ * @param result Single result pointer to an unsigned char to store
+ * the result. 0 = A=B; -1 = A<B; 1 = A>B.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_compare(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 input1_cnt,
+ u32 *input1,
+ u32 input2_cnt,
+ u32 *input2,
+ int *result);
+
+/**
+ * @brief Performs vector modular exponentiation operation - C^A % B = D where B
+ * is odd integer and > 2^32 and C < B
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complext operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param odd_pwr_cnt # of pre-calculated 'odd power'. For value of:
+ * 2 = ExpMod-ACT2
+ * 8 = ExpMod-ACT4
+ * 1,3,4,5,6,7,9..16 = ExpMod-variable
+ * 17...MAX = invalid parameter
+ * @param base_mod_cnt Length of base and modulus in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param base Base vector pointer of the operation - input C
+ * @param modulus Modulus vector pointer of the operation - input B
+ * @param exponent_cnt Length of exponent in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param exponent Exponent vector pointer of the operation - input A
+ * @param result Result vector pointer of the operation. Length is
+ * base_mod_cnt in DWORD unit.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ * @note Use of odd power > 8 is not advisable as the speed advantage for
+ * each extra odd power decreases rapidly (and even become negative for
+ * short exponent vector lengths due to the extra pre-processsing
+ * required). More odd power requires more PKA RAM which will decrease
+ * queue (setup) of pending operation for asynchronous operation.
+ *
+ *
+ */
+extern int pka4xx_expmod(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u8 odd_pwr_cnt,
+ u32 base_mod_cnt,
+ u32 *base,
+ u32 *modulus,
+ u32 exponent_cnt,
+ u32 *exponent,
+ u32 *result);
+
+/**
+ * @brief Performs vector modular exponentiation with CRT operation (RSA-CRT)
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complex operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param odd_pwr_cnt # of pre-calculated 'odd power' (1-16)
+ * @param exp_len Length of exponent(s) in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param expP Exponent P vector pointer of the operation - input expP
+ * @param expQ Exponent Q vector pointer of the operation - input expQ
+ * @param mod_inverse_len Length of modulus(es), inverse in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param modP Modulus P vector pointer of the operation - input modP
+ * @param modQ Modulus Q vector pointer of the operation - input modQ
+ * @param inverseQ Inverse Q vector pointer of the operation - input
+ * inverseQ
+ * @param input Input vector pointer of the operation - input
+ * 'Input'. Input is 2*mod_inverse_len.
+ * @param result Result vector of the operation. Result is
+ * 2*mod_inverse_len.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ * @note CRT Formula Rewritten:
+ *
+ * X = (Input % modP)^expP % modP
+ * Y = (Input % modQ)^expQ % modP
+ * Z = (((X-Y) % modP) * inverseQ % modP) * modQ
+ * R = Y + Z
+ * inverseQ = modQ^-1 % modP
+ * expP = d^-1 % (modP - 1)
+ * expQ = d^-1 % (modQ - 1)
+ *
+ * where modP and modQ is odd and co-prime (GCD=1), modP > 2^32,
+ * modQ > 2^32, 0 < expP < modP - 1, 0 < expQ < modQ - 1,
+ * inverseQ * modP = 1, Input < (modP * modQ), and d is decrypt
+ * exponent. d can be calculated by d = e^-1 % (p - 1)(q - 1) where
+ * e is the encrypt exponent chosen such that it is prime and
+ * GCD(p - 1, q - 1) != e.
+ *
+ *
+ */
+int pka4xx_expmod_crt(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u8 odd_pwr_cnt,
+ u32 exp_len,
+ u32 *expP,
+ u32 *expQ,
+ u32 mod_inverse_len,
+ u32 *modP,
+ u32 *modQ,
+ u32 *inverseQ,
+ u32 *input,
+ u32 *result);
+
+/**
+ * @brief Performs vector modular inversion operation - 1/A % B = D where B
+ * is odd integer and not 1.
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complext operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param inverse_len Length of inverse in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param inverse Inverse vector pointer of the operation - input A
+ * @param modulus_len Length of modulus in DWORD unit (<=
+ * PKA4XX_VECTOR_MAXSIZE)
+ * @param modulus Modulus vector pointer of the operation - input B
+ * @param result Result vector pointer of the operation - output B.
+ * Length is modulus_len in DWORD unit.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_HWERROR - no inverse [GCD(A,B)=1] or modulus (B) even
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *
+ */
+int pka4xx_modinv(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 inverse_len,
+ u32 *inverse,
+ u32 modulus_len,
+ u32 *modulus,
+ u32 *result);
+
+/**
+ * @brief Performs vector ECC add operation (Point addition/doubling on elliptic
+ * curve) - y^2 = x^3 + a * x + b % p
+ * pntA + pntC = pntD
+ * where p is prime and > 2^63, a < p, b < p and pntA and pntC on curve
+ *
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complext operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param input_len Length of points, p, and a in DWORD unit
+ * (<= 24)
+ * @param pntAx Point Ax vector pointer of the operation - input pntAx
+ * @param pntAy Point Ay vector pointer of the operation - input pntAy
+ * @param p Curve parameter p pointer vector of the operation -
+ * input p
+ * @param a Constant a vector pointer of the operation - input a
+ * @param pntCx Point Cx vector pointer of the operation - input pntCx
+ * @param pntCy Point Cy vector pointer of the operation - input pntCy
+ * @param pntDx Result pointer Dx vector pointer of the operation.
+ * Length is input_len + 2 + (input_len % 2) in
+ * DWORD unit.
+ * @param pntDy Result pointer Dy vector pointer of the operation.
+ * Length is input_len + 2 + (input_len % 2) in
+ * DWORD unit.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_HWERROR - result is "point-at-infinity" or p not odd,
+ * p too short, or etc
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *******************************************************************************
+ */
+int pka4xx_ecc_add(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 input_len,
+ u32 *pntAx,
+ u32 *pntAy,
+ u32 *p,
+ u32 *a,
+ u32 *pntCx,
+ u32 *pntCy,
+ u32 *pntDx,
+ u32 *pntDy);
+
+/**
+ * @brief Performs vector ECC multiply operation (Point multiplicatio on
+ * elliptic curve) - y^2 = x^3 + a * x + b % p
+ * k * pntC = pntD
+ * where p is prime and > 2^63, a < p, b < p and pntA and pntC on curve
+ *
+ * @param cb Callback function of asynchronous operation. If this
+ * parameter is NULL, then it will block until operation
+ * completed. As this function is called from interrupt
+ * context, it should defer complext operation and
+ * return as soon as possible. When there is pending
+ * operation, this parameter can not be NULL.
+ * @param ctx A void context pointer passed in cb function
+ * @param op_id An integer identifier pointer for asynchronous
+ * operation. It can be used to cancel pending operation.
+ * Can be NULL.
+ * @param k_len Length of k constant in DWORD unit (<= 24)
+ * @param k Constant k vector pointer of the operation - input k
+ * @param p_len Length of p in DWORD unit (p_len + a_len + b_len <= 24)
+ * @param p Curve parameter p vector of the operation - input p
+ * @param a_len Length of a in DWORD unit (p_len + a_len + b_len <= 24)
+ * @param a Constant a vector of the operation - input a
+ * @param b_len Length of b in DWORD unit (p_len + a_len + b_len <= 24)
+ * @param b Constant b vector of the operation - input b
+ * @param pntCx Point Cx vector pointer of the operation - input pntCx.
+ * Length is p_len + a_len + b_len in DWORD unit.
+ * @param pntCy Point Cy vector pointer of the operation - input pntCy.
+ * Length is p_len + a_len + b_len in DWORD unit.
+ * @param result Result vector pointer of the operation. Length is
+ * 2 * (p_len + a_len + 2 + ((p_len+a_len) % 2)) in
+ * DWORD unit. The first one for pntDx and second for
+ * pntDy.
+ * @return PPRO_RC_INVALID_PARM - any invalid parameters (< 0)
+ * PPRO_RC_EBUSY - If cb ia NULL and there is pending operation
+ * (< 0). Or, hardware buffer is full.
+ * PPRO_RC_HWERROR - result is "point-at-infinity" or p not odd,
+ * p too short, or etc
+ * PPRO_RC_EINPROGRESS - operation is pending (< 0)
+ * PPRO_RC_OK - operation completed successfully (= 0)
+ *
+ *******************************************************************************
+ */
+int pka4xx_ecc_mul(pka4xx_cb cb,
+ void *ctx,
+ u32 *op_id,
+ u32 k_len,
+ u32 *k,
+ u32 p_a_pnt_len,
+ u32 *p,
+ u32 *a,
+ u32 *b,
+ u32 *pntCx,
+ u32 *pntCy,
+ u32 *pntDx,
+ u32 *pntDy);
+
+#endif
diff --git a/include/crypto/trng4xx.h b/include/crypto/trng4xx.h
new file mode 100644
index 00000000000..d14f632701a
--- /dev/null
+++ b/include/crypto/trng4xx.h
@@ -0,0 +1,131 @@
+/**
+ *
+ * Copyright (c) 2008 Loc Ho <spulijala@amcc.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *
+ * @file trng4xx.h
+ *
+ * This file provides access to the AMCC SoC TRNG.
+ *
+ *
+ */
+#ifndef __TRNG4XX_H__
+#define __TRNG4XX_H__
+
+/**
+ * TRNG Register and bit Definitions
+ *
+ */
+
+/* Register TRNG4XX_STATUS bit definition */
+#define TRNG4XX_STATUS_BUSY 0x00000001
+
+/* Register TRNG4XX_CNTL bit definition */
+#define TRNG4XX_CNTL_TST_RING_OUT 0x00000001
+#define TRNG4XX_CNTL_TST_MODE 0x00000002
+#define TRNG4XX_CNTL_TST_RUN 0x00000004
+#define TRNG4XX_CNTL_TST_EN1 0x00000008
+#define TRNG4XX_CNTL_TST_EN2 0x00000010
+#define TRNG4XX_CNTL_DISABLE_ALARM 0x00000020
+#define TRNG4XX_CNTL_CLOCK_ON 0x00000040
+#define TRNG4XX_CNTL_SHORT_CYCLE 0x00000080
+#define TRNG4XX_CNTL_TST_ALARM 0x00000100
+#define TRNG4XX_CNTL_TST_LFSR 0x00000200
+#define TRNG4XX_CNTL_RESET_LFSR 0x00000400
+#define TRNG4XX_CNTL_BYPASS_TRNG 0x00000800
+#define TRNG4XX_CNTL_POST_PROC_EN 0x00001000
+
+/* Register TRNG4XX_CFG bit definition */
+#define TRNG4XX_CFG_RING1_DELAY_SEL_SHIFT 0
+#define TRNG4XX_CFG_RING1_DELAY_SEL_MASK (7)
+#define TRNG4XX_CFG_RING2_DELAY_SEL_SHIFT 3
+#define TRNG4XX_CFG_RING2_DELAY_SEL_MASK \
+ (7 << TRNG4XX_CFG_RING2_DELAY_SEL_SHIFT)
+#define TRNG4XX_CFG_RESET_CNT_SHIFT 6
+#define TRNG4XX_CFG_RESET_CNT_SHIFT_MASK \
+ (0x3F << TRNG4XX_CFG_RING2_DELAY_SEL_SHIFT)
+
+/* TRNG Register definition */
+#define TRNG4XX_OUTPUT_ADDR 0x0000
+#define TRNG4XX_STATUS_ADDR 0x0004
+#define TRNG4XX_CNTL_ADDR 0x0008
+#define TRNG4XX_CFG_ADDR 0x000C
+#define TRNG4XX_ALARMCNT_ADDR 0x0010
+#define TRNG4XX_AREG_ADDR 0x0014
+#define TRNG4XX_BREG_ADDR 0x0018
+#define TRNG4XX_XREG_0_ADDR 0x001C
+#define TRNG4XX_XREG_1_ADDR 0x0020
+#define TRNG4XX_XREG_2_ADDR 0x0024
+#define TRNG4XX_LFSR1_L_ADDR 0x0028
+#define TRNG4XX_LFSR1_H_ADDR 0x002C
+#define TRNG4XX_LFSR2_L_ADDR 0x0030
+#define TRNG4XX_LFSR2_H_ADDR 0x0034
+#define TRNG4XX_KEY0_L_ADDR 0x0038
+#define TRNG4XX_KEY0_H_ADDR 0x003C
+#define TRNG4XX_KEY1_L_ADDR 0x0040
+#define TRNG4XX_KEY1_H_ADDR 0x0044
+#define TRNG4XX_IV_L_ADDR 0x0048
+#define TRNG4XX_IV_H_ADDR 0x004C
+
+struct hal_config;
+
+/**
+ * @brief This function MUSTs be called to initialize the HW
+ * access function.
+ * @param hal_cfg HW access configuration. If NULL,
+ * default will be used.
+ * @note To load all access functions from HAL with default initial
+ * map address, pass a NULL as its parameter.
+ */
+int trng4xx_config_set(struct hal_config *cfg);
+
+/**
+ * @brief This function MUSTs be called to de-initialize the HW
+ * access function.
+ */
+int trng4xx_config_clear(void);
+
+/**
+ * @brief This functions reads from the TRNG registers.
+ * @param reg_addr Device register offset
+ * @param data_val An DWORD pointer to store the returned value
+ */
+inline int trng4xx_hw_read32(u32 reg_addr, u32 *data_val);
+
+/**
+ * @brief This functions writes to the TRNG registers.
+ * @param reg_addr Device register offset
+ * @param data_val An DWORD value to write
+ */
+inline int trng4xx_hw_write32(u32 reg_addr, u32 data_val);
+
+/**
+ * @brief This functions initializes the TRNG for operation.
+ * @return 0
+ */
+int trng4xx_hw_init(void);
+
+/**
+ * @brief This functions de-initializes the TRNG.
+ */
+int trng4xx_hw_deinit(void);
+
+/**
+ * @brief This functions retrieves an true random number.
+ * @param rand_val A pointer to a DWORD to store the value
+ * @return 0 if successfull. -EINPROGRESS if failed. This
+ * should not happen as this means the hardware still busy.
+ */
+int trng4xx_random(u32 *rand_val);
+
+#endif
diff --git a/include/linux/async_tx.h b/include/linux/async_tx.h
index a1c486a88e8..1a615ee3159 100644
--- a/include/linux/async_tx.h
+++ b/include/linux/async_tx.h
@@ -66,6 +66,9 @@ enum async_tx_flags {
ASYNC_TX_XOR_DROP_DST = (1 << 1),
ASYNC_TX_ACK = (1 << 2),
ASYNC_TX_FENCE = (1 << 3),
+ ASYNC_TX_PQ_ZERO_P = (1 << 4),
+ ASYNC_TX_PQ_ZERO_Q = (1 << 5),
+ ASYNC_TX_ASYNC_ONLY = (1 << 6),
};
/**
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index fd929889e8d..54f7d11c2a5 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -269,7 +269,6 @@ struct hash_alg {
unsigned int nbytes, u8 *out);
int (*setkey)(struct crypto_hash *tfm, const u8 *key,
unsigned int keylen);
-
unsigned int digestsize;
};
@@ -406,6 +405,8 @@ struct hash_tfm {
int (*setkey)(struct crypto_hash *tfm, const u8 *key,
unsigned int keylen);
unsigned int digestsize;
+ int (*partial)(struct hash_desc *desc, u8 *out);
+ unsigned int partialsize;
};
struct compress_tfm {
@@ -1197,6 +1198,11 @@ static inline unsigned int crypto_hash_digestsize(struct crypto_hash *tfm)
return crypto_hash_crt(tfm)->digestsize;
}
+static inline int crypto_hash_partialsize(struct crypto_hash *tfm)
+{
+ return crypto_hash_crt(tfm)->partialsize;
+}
+
static inline u32 crypto_hash_get_flags(struct crypto_hash *tfm)
{
return crypto_tfm_get_flags(crypto_hash_tfm(tfm));
@@ -1236,6 +1242,11 @@ static inline int crypto_hash_digest(struct hash_desc *desc,
return crypto_hash_crt(desc->tfm)->digest(desc, sg, nbytes, out);
}
+static inline int crypto_hash_partial(struct hash_desc *desc, u8 *out)
+{
+ return crypto_hash_crt(desc->tfm)->partial(desc, out);
+}
+
static inline int crypto_hash_setkey(struct crypto_hash *hash,
const u8 *key, unsigned int keylen)
{
diff --git a/include/linux/cryptodev.h b/include/linux/cryptodev.h
new file mode 100644
index 00000000000..8925bb8c6d8
--- /dev/null
+++ b/include/linux/cryptodev.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * cryptodev.h
+ *
+ * Linux CryptoAPI user space interface module
+ *
+ * Copyright (c) 2008 Shasi Pulijala <spulijala@amcc.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *
+ * Detail Description:
+ * This file defines ioctl structures for the Linux CryptoAPI interface. It
+ * provides user space applications accesss into the Linux CryptoAPI
+ * functionalities.
+ *
+ ****************************************************************************
+ */
+
+#ifndef __CRYPTODEV_H__
+#define __CRYPTODEV_H__
+
+/**
+ * @struct session_op
+ * @brief ioctl parameter to create a session
+ *
+ *
+ */
+struct session_op {
+ __u16 algo_size;
+ __u16 key_size; /* cipher key length*/
+ __u16 hmackey_size; /* mac key length*/
+ __u16 icv_size; /* authsize (ccm, gcm)*/
+ __u8 data[0];
+};
+
+struct pka_op {
+ __u8 pka_alg;
+ struct iovec iov[5];
+ __u16 num_iovecs;
+};
+/**
+ * @struct key_op
+ * @brief ioctl parameter to change the session key
+ *
+ */
+struct key_op {
+ __u16 ksize;
+ __u8 data[0];
+};
+
+/**
+ * @struct crypt_op
+ * @brief ioctl parameter to request a crypt/decrypt operation
+ * against a session
+ *
+ *
+ */
+#define CRYPTO_MAX_DATA_LEN (64*1024 - 1)
+struct crypt_op {
+#define COP_NONE 0
+#define COP_ENCRYPT 1
+#define COP_DECRYPT 2
+ __u16 op; /* i.e. COP_ENCRYPT */
+ __u16 flags;
+ __u16 iv_size;
+ __u16 assoc_size;
+ __u8 data[0]; /* must be big enough for chosen MAC */
+};
+
+/* create crypto session */
+#define CIOCGSESSION _IOWR('c', 101, struct session_op)
+/* change crypto key */
+#define CIOCKEY _IOWR('c', 102, struct key_op)
+#define CIOCFINAL _IOWR('c', 105, int)
+
+#define CIOCPKA _IOWR('c', 107, struct pka_op)
+#endif
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 2b9f2ac7ed6..fa56a19e8fd 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -102,6 +102,11 @@ enum dma_ctrl_flags {
DMA_PREP_PQ_DISABLE_Q = (1 << 7),
DMA_PREP_CONTINUE = (1 << 8),
DMA_PREP_FENCE = (1 << 9),
+
+ DMA_PREP_HAVE_P = (1 << 10),
+ DMA_PREP_HAVE_Q = (1 << 11),
+ DMA_PREP_ZERO_P = (1 << 12),
+ DMA_PREP_ZERO_Q = (1 << 13),
};
/**
@@ -121,6 +126,8 @@ enum sum_check_flags {
SUM_CHECK_P_RESULT = (1 << SUM_CHECK_P),
SUM_CHECK_Q_RESULT = (1 << SUM_CHECK_Q),
};
+#define DMA_PCHECK_FAILED (1 << 0)
+#define DMA_QCHECK_FAILED (1 << 1)
/**
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 580b6004d00..0791f76ac45 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -82,6 +82,7 @@
#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
#define ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */
#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_MACSEC 0x88C5 /* MACSEC Hdr Type */
/*
* Non DIX types. Won't clash for 1500 types.
diff --git a/include/linux/leds.h b/include/linux/leds.h
index d8bf9665e70..709b7ad3607 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -32,12 +32,19 @@ struct led_classdev {
int brightness;
int max_brightness;
int flags;
+ int color;
+ int blink;
/* Lower 16 bits reflect status */
#define LED_SUSPENDED (1 << 0)
/* Upper 16 bits reflect control information */
#define LED_CORE_SUSPENDRESUME (1 << 16)
+ void (*color_set)(struct led_classdev *led_cdev,
+ enum led_brightness color);
+ /* Get LED brightness level */
+ enum led_brightness (*color_get)(struct led_classdev *led_cdev);
+
/* Set LED brightness level */
/* Must not sleep, use a workqueue if needed */
void (*brightness_set)(struct led_classdev *led_cdev,
@@ -53,6 +60,9 @@ struct led_classdev {
unsigned long *delay_on,
unsigned long *delay_off);
+ int (*blink_set_3g)(struct led_classdev *led_cdev, int value );
+ int (*blink_get_3g)(struct led_classdev *led_cdev);
+
struct device *dev;
struct list_head node; /* LED Device list */
const char *default_trigger; /* Trigger to use */
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 274b6196091..f0e188a2aa6 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -63,6 +63,9 @@ struct mtd_part_parser {
int (*parse_fn)(struct mtd_info *, struct mtd_partition **, unsigned long);
};
+struct device;
+struct device_node;
+
extern int register_mtd_parser(struct mtd_part_parser *parser);
extern int deregister_mtd_parser(struct mtd_part_parser *parser);
extern int parse_mtd_partitions(struct mtd_info *master, const char **types,
@@ -70,8 +73,6 @@ extern int parse_mtd_partitions(struct mtd_info *master, const char **types,
#define put_partition_parser(p) do { module_put((p)->owner); } while(0)
-struct device;
-struct device_node;
int __devinit of_mtd_parse_partitions(struct device *dev,
struct device_node *node,
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 812a5f3c2ab..0e0c8491e8b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -916,6 +916,13 @@ struct net_device
/* max exchange id for FCoE LRO by ddp */
unsigned int fcoe_ddp_xid;
#endif
+
+#ifdef CONFIG_NET_MACSEC
+ void *macsec_priv;
+ int (*macsec_output_hw) (struct sk_buff *skb,
+ struct net_device *dev);
+ int (*macsec_input_hw) (struct sk_buff *skb);
+#endif
};
#define to_net_dev(d) container_of(d, struct net_device, dev)
@@ -993,6 +1000,21 @@ static inline void *netdev_priv(const struct net_device *dev)
return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
}
+/**
+ * macsec_priv - access network device macsec private data
+ * @dev: network device
+ *
+ * Get network device macsec private data
+ */
+
+static inline void *netdev_macsec_priv(const struct net_device *dev)
+{
+#ifdef CONFIG_NET_MACSEC
+ return dev->macsec_priv;
+#endif
+ return NULL;
+}
+
/* Set the sysfs physical device reference for the network logical device
* if set prior to registration will cause a symlink during initialization.
*/
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 3c62ed40849..207d61ef202 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -213,6 +213,11 @@ static inline struct page *page_cache_alloc(struct address_space *x)
return __page_cache_alloc(mapping_gfp_mask(x));
}
+static inline struct page *page_cache_alloc_pages(struct address_space *x, int order)
+{
+ return alloc_pages(mapping_gfp_mask(x), order);
+}
+
static inline struct page *page_cache_alloc_cold(struct address_space *x)
{
return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD);
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index b43a9e03905..bea0a976e6d 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -3,7 +3,7 @@
#define PIPEFS_MAGIC 0x50495045
-#define PIPE_BUFFERS (16)
+#define PIPE_BUFFERS (128)
#define PIPE_BUF_FLAG_LRU 0x01 /* page is on the LRU */
#define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */
diff --git a/include/linux/sockios.h b/include/linux/sockios.h
index 241f179347d..fd89fa75868 100644
--- a/include/linux/sockios.h
+++ b/include/linux/sockios.h
@@ -122,6 +122,10 @@
#define SIOCBRADDIF 0x89a2 /* add interface to bridge */
#define SIOCBRDELIF 0x89a3 /* remove interface from bridge */
+/* Macsec calls */
+#define SIOCSETMACSEC 0x89a4 /* Enable macsec on this Interface */
+#define SIOCUNSETMACSEC 0x89a5 /* disable macsec on this Interface */
+
/* hardware time stamping: parameters in linux/net_tstamp.h */
#define SIOCSHWTSTAMP 0x89b0
diff --git a/include/linux/splice.h b/include/linux/splice.h
index 18e7c7c0cae..465e83483c1 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -10,6 +10,8 @@
#include <linux/pipe_fs_i.h>
+#define PIPE_MAX_BUFS 64
+#define PIPE_MAX_DMA_BUFS 256
/*
* Flags passed in from splice/tee/vmsplice
*/
@@ -57,6 +59,38 @@ struct splice_pipe_desc {
void (*spd_release)(struct splice_pipe_desc *, unsigned int);
};
+struct splice_dma_desc {
+ struct page *page;
+ unsigned int page_offset;
+ unsigned long src_addrs[PIPE_MAX_DMA_BUFS];
+ unsigned long dst_addrs[PIPE_MAX_DMA_BUFS];
+ unsigned int xfr_size[PIPE_MAX_DMA_BUFS];
+ int n_elems;
+};
+
+struct splice_dma_desc_defer {
+ int valid;
+ struct splice_desc sd;
+ struct page *page;
+ struct pipe_inode_info *pipe;
+ void *fsdata;
+ unsigned long f_offset;
+ unsigned long src_addrs[PIPE_MAX_BUFS];
+ unsigned long dst_addrs[PIPE_MAX_BUFS];
+ unsigned int xfr_size[PIPE_MAX_BUFS];
+ unsigned long pipe_addr_map[PIPE_MAX_BUFS];
+ int n_elems;
+ int bufmap_count;
+ int pipe_curbuf;
+ int pipe_nrbufs;
+};
+
+struct splice_pipe_defer {
+ int available;
+ struct pipe_inode_info *pipe;
+};
+
+
typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,
struct splice_desc *);
typedef int (splice_direct_actor)(struct pipe_inode_info *,
diff --git a/include/linux/trustees.h b/include/linux/trustees.h
new file mode 100755
index 00000000000..b3e9e1aa18c
--- /dev/null
+++ b/include/linux/trustees.h
@@ -0,0 +1,108 @@
+/*
+ * Trustees ACL Project
+ *
+ * Copyright (c) 1999-2000 Vyacheslav Zavadsky
+ * Copyright (c) 2004 Andrew Ruder (aeruder@ksu.edu)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ *
+ * Structs, defines and function definitions intended for export
+ *
+ */
+
+#ifndef _LINUX_TRUSTEE_STRUCT_H
+
+#define _LINUX_TRUSTEE_STRUCT_H
+#include <linux/types.h>
+
+#define TRUSTEES_APIVERSION 2
+#define TRUSTEES_APIVERSION_STR "2"
+
+#define TRUSTEE_EXECUTE_BIT 0
+#define TRUSTEE_READ_BIT 1
+#define TRUSTEE_WRITE_BIT 2
+#define TRUSTEE_BROWSE_BIT 3
+#define TRUSTEE_READ_DIR_BIT 4
+#define TRUSTEE_USE_UNIX_BIT 5
+#define TRUSTEE_NUM_ACL_BITS (TRUSTEE_USE_UNIX_BIT+1)
+#define TRUSTEE_EXECUTE_MASK (1 << TRUSTEE_EXECUTE_BIT)
+#define TRUSTEE_READ_MASK (1 << TRUSTEE_READ_BIT)
+#define TRUSTEE_WRITE_MASK (1 << TRUSTEE_WRITE_BIT)
+#define TRUSTEE_BROWSE_MASK (1 << TRUSTEE_BROWSE_BIT)
+#define TRUSTEE_READ_DIR_MASK (1 << TRUSTEE_READ_DIR_BIT)
+#define TRUSTEE_USE_UNIX_MASK (1 << TRUSTEE_USE_UNIX_BIT)
+#define TRUSTEE_ACL_MASK ((1 << TRUSTEE_NUM_ACL_BITS)-1)
+
+#define TRUSTEE_ALLOW_DENY_BIT 7
+#define TRUSTEE_IS_GROUP_BIT 6
+#define TRUSTEE_CLEAR_SET_BIT 8
+#define TRUSTEE_ONE_LEVEL_BIT 9
+#define TRUSTEE_NOT_BIT 10
+#define TRUSTEE_ALL_BIT 11
+#define TRUSTEE_ALLOW_DENY_MASK (1 << TRUSTEE_ALLOW_DENY_BIT) /* set if deny */
+#define TRUSTEE_IS_GROUP_MASK (1 << TRUSTEE_IS_GROUP_BIT)
+#define TRUSTEE_CLEAR_SET_MASK (1 << TRUSTEE_CLEAR_SET_BIT) /* set if clear */
+#define TRUSTEE_ONE_LEVEL_MASK (1 << TRUSTEE_ONE_LEVEL_BIT)
+#define TRUSTEE_NOT_MASK (1 << TRUSTEE_NOT_BIT)
+#define TRUSTEE_ALL_MASK (1 << TRUSTEE_ALL_BIT)
+
+#define trustee_acl __u16
+#define trustee_default_acl TRUSTEE_USE_UNIX_MASK
+
+struct trustee_permission {
+ trustee_acl mask;
+ union {
+ __kernel_uid32_t uid;
+ __kernel_gid32_t gid;
+ } u;
+};
+
+#ifndef __KERNEL__
+#ifndef __user
+#define __user
+#endif
+#endif
+
+struct trustee_command {
+ unsigned command;
+ unsigned numargs;
+};
+
+/* Most arguments that any command will take */
+
+#define TRUSTEE_MAX_ARGS 6
+
+/* Starts a table
+ * No arguments
+ */
+#define TRUSTEE_COMMAND_TABLE_START 1
+
+/* Ends a table successfully.
+ * No arguments
+ */
+#define TRUSTEE_COMMAND_TABLE_STOP 2
+
+/* Adds a trustee
+ * Arguments:
+ * filename (char [])
+ * struct trustee_permission
+ * device-name (char [])
+ * device number (u32)
+ */
+#define TRUSTEE_COMMAND_ADD 3
+
+/* Removes all trustees
+ * No arguments
+ */
+#define TRUSTEE_COMMAND_REMOVE_ALL 2
+
+/* Makes a filesystem ignorecase
+ * Arguments:
+ * device-name (char [])
+ * device number (u32)
+ */
+#define TRUSTEE_COMMAND_MAKE_IC 5
+
+#endif /* _LINUX_TRUSTEE_STRUCT_H */
diff --git a/include/net/ah.h b/include/net/ah.h
index ae1c322f424..5761a0dfd88 100644
--- a/include/net/ah.h
+++ b/include/net/ah.h
@@ -13,7 +13,11 @@ struct ah_data
int icv_full_len;
int icv_trunc_len;
- struct crypto_hash *tfm;
+ union {
+ struct crypto_hash *tfm;
+ struct crypto_ahash *atfm;
+ struct crypto_aead *aeadtfm;
+ } utfm;
};
static inline int ah_mac_digest(struct ah_data *ahp, struct sk_buff *skb,
@@ -22,7 +26,7 @@ static inline int ah_mac_digest(struct ah_data *ahp, struct sk_buff *skb,
struct hash_desc desc;
int err;
- desc.tfm = ahp->tfm;
+ desc.tfm = ahp->utfm.tfm;
desc.flags = 0;
memset(auth_data, 0, ahp->icv_trunc_len);
diff --git a/include/net/esp.h b/include/net/esp.h
index d58451331db..9a07fdccb11 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -11,6 +11,15 @@ struct esp_data {
/* Confidentiality & Integrity */
struct crypto_aead *aead;
+#if CONFIG_INET_ESP_NR_REQ_CACHE > 0
+#define ESP_NFRAGS_CACHE 10 /* total number of frag for cache */
+#define ESP_REQ_CACHE_MAX CONFIG_INET_ESP_NR_REQ_CACHE
+ void *req_cache[ESP_REQ_CACHE_MAX];
+ atomic_t req_cache_cnt;
+ int req_cache_head;
+ int req_cache_tail;
+#endif
+ int req_cache_size; /* request size without frag sg */
};
extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
diff --git a/include/net/macsec.h b/include/net/macsec.h
new file mode 100644
index 00000000000..378aa412579
--- /dev/null
+++ b/include/net/macsec.h
@@ -0,0 +1,55 @@
+#ifndef _NET_MACSEC_H
+#define _NET_MACSEC_H
+
+#include <linux/skbuff.h>
+
+#define DEBUG_MACSEC
+#ifdef DEBUG_MACSEC
+# define MACSEC_DUMP_PKT print_hex_dump
+#else
+# define MACSEC_DUMP_PKT(arg...)
+#endif
+
+#define CONFIG_INET_MACSEC_NR_REQ_CACHE 1
+
+struct crypto_aead;
+
+struct macsec_dev_ctx
+{
+ struct crypto_aead *aead;
+#define MACSEC_NFRAGS_CACHE 4
+#define MACSEC_REQ_CACHE_MAX 256
+ void *req_cache[MACSEC_REQ_CACHE_MAX];
+ atomic_t req_cache_cnt;
+ int req_cache_size;
+ int req_cache_head;
+ int req_cache_tail;
+};
+
+struct macsec_skb_cb {
+ void *req_ctx;
+ struct macsec_dev_ctx *ctx;
+ int flags;
+};
+
+struct macsec_hdr_t {
+ __be16 macsec_type;
+ unsigned int flags :8;
+ unsigned int short_len :8;
+}__attribute__((packed));
+
+struct macsec_ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ struct macsec_hdr_t hdr; /* Macsec Tag */
+ __be32 h_pn; /* Macsec Packet Number */
+ __be16 h_proto; /* Ethernet packet type ID field */
+} __attribute__((packed));
+
+extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
+__be16 macsec_type_trans(struct sk_buff *skb);
+extern int macsec_netif_receive_skb(struct sk_buff *skb, __be16 type);
+extern int macsec_init_state(struct net_device *dev);
+void macsec_destroy(struct net_device *dev);
+
+#endif
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 223e90a4482..645f3956b32 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -164,6 +164,11 @@ struct xfrm_state
struct xfrm_algo *ealg;
struct xfrm_algo *calg;
struct xfrm_algo_aead *aead;
+ #define XFRM_ALGO_FLAGS_OFFLOAD_TRANPORT 0x0001
+ #define XFRM_ALGO_FLAGS_OFFLOAD_TUNNEL 0x0002
+ #define XFRM_ALGO_FLAGS_OFFLOAD_ESP 0x0004
+ #define XFRM_ALGO_FLAGS_OFFLOAD_AH 0x0008
+ u32 alg_flags;
/* Data for encapsulator */
struct xfrm_encap_tmpl *encap;