summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/cavium/cpt/request_manager.h
blob: 8d40e4ba3af168b4b7372ceefd9d991c15d4927b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2016 Cavium, Inc.
 */

#ifndef __REQUEST_MANAGER_H
#define __REQUEST_MANAGER_H

#include "cpt_common.h"

#define TIME_IN_RESET_COUNT  5
#define COMPLETION_CODE_SIZE 8
#define COMPLETION_CODE_INIT 0
#define PENDING_THOLD  100
#define MAX_SG_IN_CNT 12
#define MAX_SG_OUT_CNT 13
#define SG_LIST_HDR_SIZE  8
#define MAX_BUF_CNT	16

union ctrl_info {
	u32 flags;
	struct {
#if defined(__BIG_ENDIAN_BITFIELD)
		u32 reserved0:26;
		u32 grp:3; /* Group bits */
		u32 dma_mode:2; /* DMA mode */
		u32 se_req:1;/* To SE core */
#else
		u32 se_req:1; /* To SE core */
		u32 dma_mode:2; /* DMA mode */
		u32 grp:3; /* Group bits */
		u32 reserved0:26;
#endif
	} s;
};

union opcode_info {
	u16 flags;
	struct {
		u8 major;
		u8 minor;
	} s;
};

struct cptvf_request {
	union opcode_info opcode;
	u16 param1;
	u16 param2;
	u16 dlen;
};

struct buf_ptr {
	u8 *vptr;
	dma_addr_t dma_addr;
	u16 size;
};

struct cpt_request_info {
	u8 incnt; /* Number of input buffers */
	u8 outcnt; /* Number of output buffers */
	u16 rlen; /* Output length */
	union ctrl_info ctrl; /* User control information */
	struct cptvf_request req; /* Request Information (Core specific) */

	bool may_sleep;

	struct buf_ptr in[MAX_BUF_CNT];
	struct buf_ptr out[MAX_BUF_CNT];

	void (*callback)(int, void *); /* Kernel ASYNC request callabck */
	void *callback_arg; /* Kernel ASYNC request callabck arg */
};

struct sglist_component {
	union {
		u64 len;
		struct {
			__be16 len0;
			__be16 len1;
			__be16 len2;
			__be16 len3;
		} s;
	} u;
	__be64 ptr0;
	__be64 ptr1;
	__be64 ptr2;
	__be64 ptr3;
};

struct cpt_info_buffer {
	struct cpt_vf *cptvf;
	unsigned long time_in;
	u8 extra_time;

	struct cpt_request_info *req;
	dma_addr_t dptr_baddr;
	u32 dlen;
	dma_addr_t rptr_baddr;
	dma_addr_t comp_baddr;
	u8 *in_buffer;
	u8 *out_buffer;
	u8 *gather_components;
	u8 *scatter_components;

	struct pending_entry *pentry;
	volatile u64 *completion_addr;
	volatile u64 *alternate_caddr;
};

/*
 * CPT_INST_S software command definitions
 * Words EI (0-3)
 */
union vq_cmd_word0 {
	u64 u64;
	struct {
		__be16 opcode;
		__be16 param1;
		__be16 param2;
		__be16 dlen;
	} s;
};

union vq_cmd_word3 {
	u64 u64;
	struct {
#if defined(__BIG_ENDIAN_BITFIELD)
		u64 grp:3;
		u64 cptr:61;
#else
		u64 cptr:61;
		u64 grp:3;
#endif
	} s;
};

struct cpt_vq_command {
	union vq_cmd_word0 cmd;
	u64 dptr;
	u64 rptr;
	union vq_cmd_word3 cptr;
};

void vq_post_process(struct cpt_vf *cptvf, u32 qno);
int process_request(struct cpt_vf *cptvf, struct cpt_request_info *req);
#endif /* __REQUEST_MANAGER_H */