ccp-dev.h (1cbc99dfe5d7d686fd022647f4e489b5eb8e9068) ccp-dev.h (bc197b2a9c7e0129fa0ec1961881e2a0b3bef967)
1/*
2 * AMD Cryptographic Coprocessor (CCP) driver
3 *
4 * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
5 *
6 * Author: Tom Lendacky <thomas.lendacky@amd.com>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 8 unchanged lines hidden (view full) ---

17#include <linux/pci.h>
18#include <linux/spinlock.h>
19#include <linux/mutex.h>
20#include <linux/list.h>
21#include <linux/wait.h>
22#include <linux/dmapool.h>
23#include <linux/hw_random.h>
24#include <linux/bitops.h>
1/*
2 * AMD Cryptographic Coprocessor (CCP) driver
3 *
4 * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
5 *
6 * Author: Tom Lendacky <thomas.lendacky@amd.com>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 8 unchanged lines hidden (view full) ---

17#include <linux/pci.h>
18#include <linux/spinlock.h>
19#include <linux/mutex.h>
20#include <linux/list.h>
21#include <linux/wait.h>
22#include <linux/dmapool.h>
23#include <linux/hw_random.h>
24#include <linux/bitops.h>
25#include <linux/interrupt.h>
26#include <linux/irqreturn.h>
27#include <linux/dmaengine.h>
25
26#define MAX_CCP_NAME_LEN 16
27#define MAX_DMAPOOL_NAME_LEN 32
28
29#define MAX_HW_QUEUES 5
30#define MAX_CMD_QLEN 100
31
32#define TRNG_RETRIES 10

--- 121 unchanged lines hidden (view full) ---

154 int (*init)(struct ccp_device *);
155 void (*destroy)(struct ccp_device *);
156 irqreturn_t (*irqhandler)(int, void *);
157};
158
159/* Structure to hold CCP version-specific values */
160struct ccp_vdata {
161 unsigned int version;
28
29#define MAX_CCP_NAME_LEN 16
30#define MAX_DMAPOOL_NAME_LEN 32
31
32#define MAX_HW_QUEUES 5
33#define MAX_CMD_QLEN 100
34
35#define TRNG_RETRIES 10

--- 121 unchanged lines hidden (view full) ---

157 int (*init)(struct ccp_device *);
158 void (*destroy)(struct ccp_device *);
159 irqreturn_t (*irqhandler)(int, void *);
160};
161
162/* Structure to hold CCP version-specific values */
163struct ccp_vdata {
164 unsigned int version;
162 struct ccp_actions *perform;
165 const struct ccp_actions *perform;
163};
164
165extern struct ccp_vdata ccpv3;
166
167struct ccp_device;
168struct ccp_cmd;
169
166};
167
168extern struct ccp_vdata ccpv3;
169
170struct ccp_device;
171struct ccp_cmd;
172
173struct ccp_dma_cmd {
174 struct list_head entry;
175
176 struct ccp_cmd ccp_cmd;
177};
178
179struct ccp_dma_desc {
180 struct list_head entry;
181
182 struct ccp_device *ccp;
183
184 struct list_head pending;
185 struct list_head active;
186
187 enum dma_status status;
188 struct dma_async_tx_descriptor tx_desc;
189 size_t len;
190};
191
192struct ccp_dma_chan {
193 struct ccp_device *ccp;
194
195 spinlock_t lock;
196 struct list_head pending;
197 struct list_head active;
198 struct list_head complete;
199
200 struct tasklet_struct cleanup_tasklet;
201
202 enum dma_status status;
203 struct dma_chan dma_chan;
204};
205
170struct ccp_cmd_queue {
171 struct ccp_device *ccp;
172
173 /* Queue identifier */
174 u32 id;
175
176 /* Queue dma pool */
177 struct dma_pool *dma_pool;

--- 78 unchanged lines hidden (view full) ---

256
257 /*
258 * Support for the CCP True RNG
259 */
260 struct hwrng hwrng;
261 unsigned int hwrng_retries;
262
263 /*
206struct ccp_cmd_queue {
207 struct ccp_device *ccp;
208
209 /* Queue identifier */
210 u32 id;
211
212 /* Queue dma pool */
213 struct dma_pool *dma_pool;

--- 78 unchanged lines hidden (view full) ---

292
293 /*
294 * Support for the CCP True RNG
295 */
296 struct hwrng hwrng;
297 unsigned int hwrng_retries;
298
299 /*
300 * Support for the CCP DMA capabilities
301 */
302 struct dma_device dma_dev;
303 struct ccp_dma_chan *ccp_dma_chan;
304 struct kmem_cache *dma_cmd_cache;
305 struct kmem_cache *dma_desc_cache;
306
307 /*
264 * A counter used to generate job-ids for cmds submitted to the CCP
265 */
266 atomic_t current_id ____cacheline_aligned;
267
268 /*
269 * The CCP uses key storage blocks (KSB) to maintain context for certain
270 * operations. To prevent multiple cmds from using the same KSB range
271 * a command queue reserves a KSB range for the duration of the cmd.

--- 141 unchanged lines hidden (view full) ---

413void ccp_del_device(struct ccp_device *ccp);
414
415struct ccp_device *ccp_alloc_struct(struct device *dev);
416bool ccp_queues_suspended(struct ccp_device *ccp);
417int ccp_cmd_queue_thread(void *data);
418
419int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
420
308 * A counter used to generate job-ids for cmds submitted to the CCP
309 */
310 atomic_t current_id ____cacheline_aligned;
311
312 /*
313 * The CCP uses key storage blocks (KSB) to maintain context for certain
314 * operations. To prevent multiple cmds from using the same KSB range
315 * a command queue reserves a KSB range for the duration of the cmd.

--- 141 unchanged lines hidden (view full) ---

457void ccp_del_device(struct ccp_device *ccp);
458
459struct ccp_device *ccp_alloc_struct(struct device *dev);
460bool ccp_queues_suspended(struct ccp_device *ccp);
461int ccp_cmd_queue_thread(void *data);
462
463int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
464
465int ccp_dmaengine_register(struct ccp_device *ccp);
466void ccp_dmaengine_unregister(struct ccp_device *ccp);
467
421#endif
468#endif