linux/drivers/crypto/cavium/cpt/cptvf_algs.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/*
   3 * Copyright (C) 2016 Cavium, Inc.
   4 */
   5
   6#ifndef _CPTVF_ALGS_H_
   7#define _CPTVF_ALGS_H_
   8
   9#include "request_manager.h"
  10
  11#define MAX_DEVICES 16
  12#define MAJOR_OP_FC 0x33
  13#define MAX_ENC_KEY_SIZE 32
  14#define MAX_HASH_KEY_SIZE 64
  15#define MAX_KEY_SIZE (MAX_ENC_KEY_SIZE + MAX_HASH_KEY_SIZE)
  16#define CONTROL_WORD_LEN 8
  17#define KEY2_OFFSET 48
  18
  19#define DMA_MODE_FLAG(dma_mode) \
  20        (((dma_mode) == DMA_GATHER_SCATTER) ? (1 << 7) : 0)
  21
  22enum req_type {
  23        AE_CORE_REQ,
  24        SE_CORE_REQ,
  25};
  26
  27enum cipher_type {
  28        DES3_CBC = 0x1,
  29        DES3_ECB = 0x2,
  30        AES_CBC = 0x3,
  31        AES_ECB = 0x4,
  32        AES_CFB = 0x5,
  33        AES_CTR = 0x6,
  34        AES_GCM = 0x7,
  35        AES_XTS = 0x8
  36};
  37
  38enum aes_type {
  39        AES_128_BIT = 0x1,
  40        AES_192_BIT = 0x2,
  41        AES_256_BIT = 0x3
  42};
  43
  44union encr_ctrl {
  45        u64 flags;
  46        struct {
  47#if defined(__BIG_ENDIAN_BITFIELD)
  48                u64 enc_cipher:4;
  49                u64 reserved1:1;
  50                u64 aes_key:2;
  51                u64 iv_source:1;
  52                u64 hash_type:4;
  53                u64 reserved2:3;
  54                u64 auth_input_type:1;
  55                u64 mac_len:8;
  56                u64 reserved3:8;
  57                u64 encr_offset:16;
  58                u64 iv_offset:8;
  59                u64 auth_offset:8;
  60#else
  61                u64 auth_offset:8;
  62                u64 iv_offset:8;
  63                u64 encr_offset:16;
  64                u64 reserved3:8;
  65                u64 mac_len:8;
  66                u64 auth_input_type:1;
  67                u64 reserved2:3;
  68                u64 hash_type:4;
  69                u64 iv_source:1;
  70                u64 aes_key:2;
  71                u64 reserved1:1;
  72                u64 enc_cipher:4;
  73#endif
  74        } e;
  75};
  76
  77struct cvm_cipher {
  78        const char *name;
  79        u8 value;
  80};
  81
  82struct enc_context {
  83        union encr_ctrl enc_ctrl;
  84        u8 encr_key[32];
  85        u8 encr_iv[16];
  86};
  87
  88struct fchmac_context {
  89        u8 ipad[64];
  90        u8 opad[64]; /* or OPAD */
  91};
  92
  93struct fc_context {
  94        struct enc_context enc;
  95        struct fchmac_context hmac;
  96};
  97
  98struct cvm_enc_ctx {
  99        u32 key_len;
 100        u8 enc_key[MAX_KEY_SIZE];
 101        u8 cipher_type:4;
 102        u8 key_type:2;
 103};
 104
 105struct cvm_des3_ctx {
 106        u32 key_len;
 107        u8 des3_key[MAX_KEY_SIZE];
 108};
 109
 110struct cvm_req_ctx {
 111        struct cpt_request_info cpt_req;
 112        u64 control_word;
 113        struct fc_context fctx;
 114};
 115
 116int cptvf_do_request(void *cptvf, struct cpt_request_info *req);
 117#endif /*_CPTVF_ALGS_H_*/
 118