intern.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * CAAM/SEC 4.x driver backend
  3. * Private/internal definitions between modules
  4. *
  5. * Copyright 2008-2011 Freescale Semiconductor, Inc.
  6. *
  7. */
  8. #ifndef INTERN_H
  9. #define INTERN_H
  10. #define JOBR_UNASSIGNED 0
  11. #define JOBR_ASSIGNED 1
  12. /* Currently comes from Kconfig param as a ^2 (driver-required) */
  13. #define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
  14. /* Kconfig params for interrupt coalescing if selected (else zero) */
  15. #ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
  16. #define JOBR_INTC JRCFG_ICEN
  17. #define JOBR_INTC_TIME_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_TIME_THLD
  18. #define JOBR_INTC_COUNT_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_COUNT_THLD
  19. #else
  20. #define JOBR_INTC 0
  21. #define JOBR_INTC_TIME_THLD 0
  22. #define JOBR_INTC_COUNT_THLD 0
  23. #endif
  24. /*
  25. * Storage for tracking each in-process entry moving across a ring
  26. * Each entry on an output ring needs one of these
  27. */
  28. struct caam_jrentry_info {
  29. void (*callbk)(struct device *dev, u32 *desc, u32 status, void *arg);
  30. void *cbkarg; /* Argument per ring entry */
  31. u32 *desc_addr_virt; /* Stored virt addr for postprocessing */
  32. dma_addr_t desc_addr_dma; /* Stored bus addr for done matching */
  33. u32 desc_size; /* Stored size for postprocessing, header derived */
  34. };
  35. /* Private sub-storage for a single JobR */
  36. struct caam_drv_private_jr {
  37. struct device *parentdev; /* points back to controller dev */
  38. int ridx;
  39. struct caam_job_ring __iomem *rregs; /* JobR's register space */
  40. struct tasklet_struct irqtask[NR_CPUS];
  41. int irq; /* One per queue */
  42. int assign; /* busy/free */
  43. /* Job ring info */
  44. int ringsize; /* Size of rings (assume input = output) */
  45. struct caam_jrentry_info *entinfo; /* Alloc'ed 1 per ring entry */
  46. spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */
  47. int inp_ring_write_index; /* Input index "tail" */
  48. int head; /* entinfo (s/w ring) head index */
  49. dma_addr_t *inpring; /* Base of input ring, alloc DMA-safe */
  50. spinlock_t outlock ____cacheline_aligned; /* Output ring index lock */
  51. int out_ring_read_index; /* Output index "tail" */
  52. int tail; /* entinfo (s/w ring) tail index */
  53. struct jr_outentry *outring; /* Base of output ring, DMA-safe */
  54. };
  55. /*
  56. * Driver-private storage for a single CAAM block instance
  57. */
  58. struct caam_drv_private {
  59. struct device *dev;
  60. struct device **jrdev; /* Alloc'ed array per sub-device */
  61. spinlock_t jr_alloc_lock;
  62. struct platform_device *pdev;
  63. /* Physical-presence section */
  64. struct caam_ctrl *ctrl; /* controller region */
  65. struct caam_deco **deco; /* DECO/CCB views */
  66. struct caam_assurance *ac;
  67. struct caam_queue_if *qi; /* QI control region */
  68. /*
  69. * Detected geometry block. Filled in from device tree if powerpc,
  70. * or from register-based version detection code
  71. */
  72. u8 total_jobrs; /* Total Job Rings in device */
  73. u8 qi_present; /* Nonzero if QI present in device */
  74. int secvio_irq; /* Security violation interrupt number */
  75. /* which jr allocated to scatterlist crypto */
  76. atomic_t tfm_count ____cacheline_aligned;
  77. int num_jrs_for_algapi;
  78. struct device **algapi_jr;
  79. /* list of registered crypto algorithms (mk generic context handle?) */
  80. struct list_head alg_list;
  81. /*
  82. * debugfs entries for developer view into driver/device
  83. * variables at runtime.
  84. */
  85. #ifdef CONFIG_DEBUG_FS
  86. struct dentry *dfs_root;
  87. struct dentry *ctl; /* controller dir */
  88. struct dentry *ctl_rq_dequeued, *ctl_ob_enc_req, *ctl_ib_dec_req;
  89. struct dentry *ctl_ob_enc_bytes, *ctl_ob_prot_bytes;
  90. struct dentry *ctl_ib_dec_bytes, *ctl_ib_valid_bytes;
  91. struct dentry *ctl_faultaddr, *ctl_faultdetail, *ctl_faultstatus;
  92. struct debugfs_blob_wrapper ctl_kek_wrap, ctl_tkek_wrap, ctl_tdsk_wrap;
  93. struct dentry *ctl_kek, *ctl_tkek, *ctl_tdsk;
  94. #endif
  95. };
  96. void caam_jr_algapi_init(struct device *dev);
  97. void caam_jr_algapi_remove(struct device *dev);
  98. #endif /* INTERN_H */