ccp-dev.h (64282ea2d2a90437c0739ce016b80a1dec16507e) | ccp-dev.h (68cc652f83b9a4f79471db6c79ae0bfe5175eda3) |
---|---|
1/* 2 * AMD Cryptographic Coprocessor (CCP) driver 3 * | 1/* 2 * AMD Cryptographic Coprocessor (CCP) driver 3 * |
4 * Copyright (C) 2013,2016 Advanced Micro Devices, Inc. | 4 * Copyright (C) 2013,2017 Advanced Micro Devices, Inc. |
5 * 6 * Author: Tom Lendacky <thomas.lendacky@amd.com> 7 * Author: Gary R Hook <gary.hook@amd.com> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 */ --- 9 unchanged lines hidden (view full) --- 22#include <linux/wait.h> 23#include <linux/dmapool.h> 24#include <linux/hw_random.h> 25#include <linux/bitops.h> 26#include <linux/interrupt.h> 27#include <linux/irqreturn.h> 28#include <linux/dmaengine.h> 29 | 5 * 6 * Author: Tom Lendacky <thomas.lendacky@amd.com> 7 * Author: Gary R Hook <gary.hook@amd.com> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 */ --- 9 unchanged lines hidden (view full) --- 22#include <linux/wait.h> 23#include <linux/dmapool.h> 24#include <linux/hw_random.h> 25#include <linux/bitops.h> 26#include <linux/interrupt.h> 27#include <linux/irqreturn.h> 28#include <linux/dmaengine.h> 29 |
30#include "sp-dev.h" 31 |
|
30#define MAX_CCP_NAME_LEN 16 31#define MAX_DMAPOOL_NAME_LEN 32 32 33#define MAX_HW_QUEUES 5 34#define MAX_CMD_QLEN 100 35 36#define TRNG_RETRIES 10 37 --- 301 unchanged lines hidden (view full) --- 339 struct list_head entry; 340 341 struct ccp_vdata *vdata; 342 unsigned int ord; 343 char name[MAX_CCP_NAME_LEN]; 344 char rngname[MAX_CCP_NAME_LEN]; 345 346 struct device *dev; | 32#define MAX_CCP_NAME_LEN 16 33#define MAX_DMAPOOL_NAME_LEN 32 34 35#define MAX_HW_QUEUES 5 36#define MAX_CMD_QLEN 100 37 38#define TRNG_RETRIES 10 39 --- 301 unchanged lines hidden (view full) --- 341 struct list_head entry; 342 343 struct ccp_vdata *vdata; 344 unsigned int ord; 345 char name[MAX_CCP_NAME_LEN]; 346 char rngname[MAX_CCP_NAME_LEN]; 347 348 struct device *dev; |
349 struct sp_device *sp; |
|
347 348 /* Bus specific device information 349 */ 350 void *dev_specific; | 350 351 /* Bus specific device information 352 */ 353 void *dev_specific; |
351 int (*get_irq)(struct ccp_device *ccp); 352 void (*free_irq)(struct ccp_device *ccp); | |
353 unsigned int qim; 354 unsigned int irq; 355 bool use_tasklet; 356 struct tasklet_struct irq_tasklet; 357 358 /* I/O area used for device communication. The register mapping 359 * starts at an offset into the mapped bar. 360 * The CMD_REQx registers and the Delete_Cmd_Queue_Job register 361 * need to be protected while a command queue thread is accessing 362 * them. 363 */ 364 struct mutex req_mutex ____cacheline_aligned; | 354 unsigned int qim; 355 unsigned int irq; 356 bool use_tasklet; 357 struct tasklet_struct irq_tasklet; 358 359 /* I/O area used for device communication. The register mapping 360 * starts at an offset into the mapped bar. 361 * The CMD_REQx registers and the Delete_Cmd_Queue_Job register 362 * need to be protected while a command queue thread is accessing 363 * them. 364 */ 365 struct mutex req_mutex ____cacheline_aligned; |
365 void __iomem *io_map; | |
366 void __iomem *io_regs; 367 368 /* Master lists that all cmds are queued on. Because there can be 369 * more than one CCP command queue that can process a cmd a separate 370 * backlog list is neeeded so that the backlog completion call 371 * completes before the cmd is available for execution. 372 */ 373 spinlock_t cmd_lock ____cacheline_aligned; --- 247 unchanged lines hidden (view full) --- 621 __le32 src_lo; 622 struct dword3 dw3; 623 union dword4 dw4; 624 union dword5 dw5; 625 __le32 key_lo; 626 struct dword7 dw7; 627}; 628 | 366 void __iomem *io_regs; 367 368 /* Master lists that all cmds are queued on. Because there can be 369 * more than one CCP command queue that can process a cmd a separate 370 * backlog list is neeeded so that the backlog completion call 371 * completes before the cmd is available for execution. 372 */ 373 spinlock_t cmd_lock ____cacheline_aligned; --- 247 unchanged lines hidden (view full) --- 621 __le32 src_lo; 622 struct dword3 dw3; 623 union dword4 dw4; 624 union dword5 dw5; 625 __le32 key_lo; 626 struct dword7 dw7; 627}; 628 |
629int ccp_pci_init(void); 630void ccp_pci_exit(void); 631 632int ccp_platform_init(void); 633void ccp_platform_exit(void); 634 | |
635void ccp_add_device(struct ccp_device *ccp); 636void ccp_del_device(struct ccp_device *ccp); 637 638extern void ccp_log_error(struct ccp_device *, int); 639 | 629void ccp_add_device(struct ccp_device *ccp); 630void ccp_del_device(struct ccp_device *ccp); 631 632extern void ccp_log_error(struct ccp_device *, int); 633 |
640struct ccp_device *ccp_alloc_struct(struct device *dev); | 634struct ccp_device *ccp_alloc_struct(struct sp_device *sp); |
641bool ccp_queues_suspended(struct ccp_device *ccp); 642int ccp_cmd_queue_thread(void *data); 643int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait); 644 645int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd); 646 647int ccp_register_rng(struct ccp_device *ccp); 648void ccp_unregister_rng(struct ccp_device *ccp); --- 15 unchanged lines hidden (view full) --- 664 u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int); 665 void (*sbfree)(struct ccp_cmd_queue *, unsigned int, unsigned int); 666 unsigned int (*get_free_slots)(struct ccp_cmd_queue *); 667 int (*init)(struct ccp_device *); 668 void (*destroy)(struct ccp_device *); 669 irqreturn_t (*irqhandler)(int, void *); 670}; 671 | 635bool ccp_queues_suspended(struct ccp_device *ccp); 636int ccp_cmd_queue_thread(void *data); 637int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait); 638 639int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd); 640 641int ccp_register_rng(struct ccp_device *ccp); 642void ccp_unregister_rng(struct ccp_device *ccp); --- 15 unchanged lines hidden (view full) --- 658 u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int); 659 void (*sbfree)(struct ccp_cmd_queue *, unsigned int, unsigned int); 660 unsigned int (*get_free_slots)(struct ccp_cmd_queue *); 661 int (*init)(struct ccp_device *); 662 void (*destroy)(struct ccp_device *); 663 irqreturn_t (*irqhandler)(int, void *); 664}; 665 |
672/* Structure to hold CCP version-specific values */ 673struct ccp_vdata { 674 const unsigned int version; 675 const unsigned int dma_chan_attr; 676 void (*setup)(struct ccp_device *); 677 const struct ccp_actions *perform; 678 const unsigned int bar; 679 const unsigned int offset; 680}; 681 | 666extern const struct ccp_vdata ccpv3_platform; |
682extern const struct ccp_vdata ccpv3; 683extern const struct ccp_vdata ccpv5a; 684extern const struct ccp_vdata ccpv5b; 685 686#endif | 667extern const struct ccp_vdata ccpv3; 668extern const struct ccp_vdata ccpv5a; 669extern const struct ccp_vdata ccpv5b; 670 671#endif |