linux/drivers/crypto/cavium/nitrox/nitrox_req.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NITROX_REQ_H
#define __NITROX_REQ_H

#include <linux/dma-mapping.h>
#include <crypto/aes.h>

#include "nitrox_dev.h"

#define PENDING_SIG
#define PRIO

sereq_completion_t;

/**
 * struct gphdr - General purpose Header
 * @param0: first parameter.
 * @param1: second parameter.
 * @param2: third parameter.
 * @param3: fourth parameter.
 *
 * Params tell the iv and enc/dec data offsets.
 */
struct gphdr {};

/**
 * struct se_req_ctrl - SE request information.
 * @arg: Minor number of the opcode
 * @ctxc: Context control.
 * @unca: Uncertainity enabled.
 * @info: Additional information for SE cores.
 * @ctxl: Context length in bytes.
 * @uddl: User defined data length
 */
se_req_ctrl;

#define MAX_IV_LEN

/**
 * struct se_crypto_request - SE crypto request structure.
 * @opcode: Request opcode (enc/dec)
 * @flags: flags from crypto subsystem
 * @ctx_handle: Crypto context handle.
 * @gph: GP Header
 * @ctrl: Request Information.
 * @orh: ORH address
 * @comp: completion address
 * @src: Input sglist
 * @dst: Output sglist
 */
struct se_crypto_request {};

/* Crypto opcodes */
#define FLEXI_CRYPTO_ENCRYPT_HMAC
#define ENCRYPT
#define DECRYPT

/* IV from context */
#define IV_FROM_CTX
/* IV from Input data */
#define IV_FROM_DPTR

/**
 * cipher opcodes for firmware
 */
enum flexi_cipher {};

enum flexi_auth {};

/**
 * struct crypto_keys - Crypto keys
 * @key: Encryption key or KEY1 for AES-XTS
 * @iv: Encryption IV or Tweak for AES-XTS
 */
struct crypto_keys {};

/**
 * struct auth_keys - Authentication keys
 * @ipad: IPAD or KEY2 for AES-XTS
 * @opad: OPAD or AUTH KEY if auth_input_type = 1
 */
struct auth_keys {};

fc_ctx_flags;
/**
 * struct flexi_crypto_context - Crypto context
 * @cipher_type: Encryption cipher type
 * @aes_keylen: AES key length
 * @iv_source: Encryption IV source
 * @hash_type: Authentication type
 * @auth_input_type: Authentication input type
 *   1 - Authentication IV and KEY, microcode calculates OPAD/IPAD
 *   0 - Authentication OPAD/IPAD
 * @mac_len: mac length
 * @crypto: Crypto keys
 * @auth: Authentication keys
 */
struct flexi_crypto_context {};

struct crypto_ctx_hdr {};

struct nitrox_crypto_ctx {};

struct nitrox_kcrypt_request {};

/**
 * struct nitrox_aead_rctx - AEAD request context
 * @nkreq: Base request context
 * @cryptlen: Encryption/Decryption data length
 * @assoclen: AAD length
 * @srclen: Input buffer length
 * @dstlen: Output buffer length
 * @iv: IV data
 * @ivsize: IV data length
 * @flags: AEAD req flags
 * @ctx_handle: Device context handle
 * @src: Source sglist
 * @dst: Destination sglist
 * @ctrl_arg: Identifies the request type (ENCRYPT/DECRYPT)
 */
struct nitrox_aead_rctx {};

/**
 * struct nitrox_rfc4106_rctx - rfc4106 cipher request context
 * @base: AEAD request context
 * @src: Source sglist
 * @dst: Destination sglist
 * @assoc: AAD
 */
struct nitrox_rfc4106_rctx {};

/**
 * struct pkt_instr_hdr - Packet Instruction Header
 * @g: Gather used
 *   When [G] is set and [GSZ] != 0, the instruction is
 *   indirect gather instruction.
 *   When [G] is set and [GSZ] = 0, the instruction is
 *   direct gather instruction.
 * @gsz: Number of pointers in the indirect gather list
 * @ihi: When set hardware duplicates the 1st 8 bytes of pkt_instr_hdr
 *   and adds them to the packet after the pkt_instr_hdr but before any UDD
 * @ssz: Not used by the input hardware. But can become slc_store_int[SSZ]
 *   when [IHI] is set.
 * @fsz: The number of front data bytes directly included in the
 *   PCIe instruction.
 * @tlen: The length of the input packet in bytes, include:
 *   - 16B pkt_hdr
 *   - Inline context bytes if any,
 *   - UDD if any,
 *   - packet payload bytes
 */
pkt_instr_hdr;

/**
 * struct pkt_hdr - Packet Input Header
 * @opcode: Request opcode (Major)
 * @arg: Request opcode (Minor)
 * @ctxc: Context control.
 * @unca: When set [UNC] is the uncertainty count for an input packet.
 *        The hardware uses uncertainty counts to predict
 *        output buffer use and avoid deadlock.
 * @info: Not used by input hardware. Available for use
 *        during SE processing.
 * @destport: The expected destination port/ring/channel for the packet.
 * @unc: Uncertainty count for an input packet.
 * @grp: SE group that will process the input packet.
 * @ctxl: Context Length in 64-bit words.
 * @uddl: User-defined data (UDD) length in bytes.
 * @ctxp: Context pointer. CTXP<63,2:0> must be zero in all cases.
 */
pkt_hdr;

/**
 * struct slc_store_info - Solicited Paceket Output Store Information.
 * @ssz: The number of scatterlist pointers for the solicited output port
 *       packet.
 * @rptr: The result pointer for the solicited output port packet.
 *        If [SSZ]=0, [RPTR] must point directly to a buffer on the remote
 *        host that is large enough to hold the entire output packet.
 *        If [SSZ]!=0, [RPTR] must point to an array of ([SSZ]+3)/4
 *        sglist components at [RPTR] on the remote host.
 */
slc_store_info;

/**
 * struct nps_pkt_instr - NPS Packet Instruction of SE cores.
 * @dptr0 : Input pointer points to buffer in remote host.
 * @ih: Packet Instruction Header (8 bytes)
 * @irh: Packet Input Header (16 bytes)
 * @slc: Solicited Packet Output Store Information (16 bytes)
 * @fdata: Front data
 *
 * 64-Byte Instruction Format
 */
struct nps_pkt_instr {};

/**
 * struct aqmq_command_s - The 32 byte command for AE processing.
 * @opcode: Request opcode
 * @param1: Request control parameter 1
 * @param2: Request control parameter 2
 * @dlen: Input length
 * @dptr: Input pointer points to buffer in remote host
 * @rptr: Result pointer points to buffer in remote host
 * @grp: AQM Group (0..7)
 * @cptr: Context pointer
 */
struct aqmq_command_s {};

/**
 * struct ctx_hdr - Book keeping data about the crypto context
 * @pool: Pool used to allocate crypto context
 * @dma: Base DMA address of the crypto context
 * @ctx_dma: Actual usable crypto context for NITROX
 */
struct ctx_hdr {};

/*
 * struct sglist_component - SG list component format
 * @len0: The number of bytes at [PTR0] on the remote host.
 * @len1: The number of bytes at [PTR1] on the remote host.
 * @len2: The number of bytes at [PTR2] on the remote host.
 * @len3: The number of bytes at [PTR3] on the remote host.
 * @dma0: First pointer point to buffer in remote host.
 * @dma1: Second pointer point to buffer in remote host.
 * @dma2: Third pointer point to buffer in remote host.
 * @dma3: Fourth pointer point to buffer in remote host.
 */
struct nitrox_sgcomp {};

/*
 * strutct nitrox_sgtable - SG list information
 * @sgmap_cnt: Number of buffers mapped
 * @total_bytes: Total bytes in sglist.
 * @sgcomp_len: Total sglist components length.
 * @sgcomp_dma: DMA address of sglist component.
 * @sg: crypto request buffer.
 * @sgcomp: sglist component for NITROX.
 */
struct nitrox_sgtable {};

/* Response Header Length */
#define ORH_HLEN
/* Completion bytes Length */
#define COMP_HLEN

struct resp_hdr {};

completion_t;

/**
 * struct nitrox_softreq - Represents the NIROX Request.
 * @response: response list entry
 * @backlog: Backlog list entry
 * @ndev: Device used to submit the request
 * @cmdq: Command queue for submission
 * @resp: Response headers
 * @instr: 64B instruction
 * @in: SG table for input
 * @out SG table for output
 * @tstamp: Request submitted time in jiffies
 * @callback: callback after request completion/timeout
 * @cb_arg: callback argument
 */
struct nitrox_softreq {};

static inline int flexi_aes_keylen(int keylen)
{}

static inline void *alloc_req_buf(int nents, int extralen, gfp_t gfp)
{}

/**
 * create_single_sg - Point SG entry to the data
 * @sg:		Destination SG list
 * @buf:	Data
 * @buflen:	Data length
 *
 * Returns next free entry in the destination SG list
 **/
static inline struct scatterlist *create_single_sg(struct scatterlist *sg,
						   void *buf, int buflen)
{}

/**
 * create_multi_sg - Create multiple sg entries with buflen data length from
 *		     source sglist
 * @to_sg:	Destination SG list
 * @from_sg:	Source SG list
 * @buflen:	Data length
 *
 * Returns next free entry in the destination SG list
 **/
static inline struct scatterlist *create_multi_sg(struct scatterlist *to_sg,
						  struct scatterlist *from_sg,
						  int buflen)
{}

static inline void set_orh_value(u64 *orh)
{}

static inline void set_comp_value(u64 *comp)
{}

static inline int alloc_src_req_buf(struct nitrox_kcrypt_request *nkreq,
				    int nents, int ivsize)
{}

static inline void nitrox_creq_copy_iv(char *dst, char *src, int size)
{}

static inline struct scatterlist *nitrox_creq_src_sg(char *iv, int ivsize)
{}

static inline void nitrox_creq_set_src_sg(struct nitrox_kcrypt_request *nkreq,
					  int nents, int ivsize,
					  struct scatterlist *src, int buflen)
{}

static inline int alloc_dst_req_buf(struct nitrox_kcrypt_request *nkreq,
				    int nents)
{}

static inline void nitrox_creq_set_orh(struct nitrox_kcrypt_request *nkreq)
{}

static inline void nitrox_creq_set_comp(struct nitrox_kcrypt_request *nkreq)
{}

static inline struct scatterlist *nitrox_creq_dst_sg(char *dst)
{}

static inline void nitrox_creq_set_dst_sg(struct nitrox_kcrypt_request *nkreq,
					  int nents, int ivsize,
					  struct scatterlist *dst, int buflen)
{}

#endif /* __NITROX_REQ_H */