megaraid_ioctl.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*
  2. *
  3. * Linux MegaRAID device driver
  4. *
  5. * Copyright (c) 2003-2004 LSI Logic Corporation.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. * FILE : megaraid_ioctl.h
  13. *
  14. * Definitions to interface with user level applications
  15. */
  16. #ifndef _MEGARAID_IOCTL_H_
  17. #define _MEGARAID_IOCTL_H_
  18. #include <linux/types.h>
  19. #include <linux/semaphore.h>
  20. #include "mbox_defs.h"
  21. /*
  22. * console messages debug levels
  23. */
  24. #define CL_ANN 0 /* print unconditionally, announcements */
  25. #define CL_DLEVEL1 1 /* debug level 1, informative */
  26. #define CL_DLEVEL2 2 /* debug level 2, verbose */
  27. #define CL_DLEVEL3 3 /* debug level 3, very verbose */
  28. /**
  29. * con_log() - console log routine
  30. * @level : indicates the severity of the message.
  31. * @fmt : format string
  32. *
  33. * con_log displays the error messages on the console based on the current
  34. * debug level. Also it attaches the appropriate kernel severity level with
  35. * the message.
  36. */
  37. #define con_log(level, fmt) if (LSI_DBGLVL >= level) printk fmt;
  38. /*
  39. * Definitions & Declarations needed to use common management module
  40. */
  41. #define MEGAIOC_MAGIC 'm'
  42. #define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, mimd_t)
  43. #define MEGAIOC_QNADAP 'm' /* Query # of adapters */
  44. #define MEGAIOC_QDRVRVER 'e' /* Query driver version */
  45. #define MEGAIOC_QADAPINFO 'g' /* Query adapter information */
  46. #define USCSICMD 0x80
  47. #define UIOC_RD 0x00001
  48. #define UIOC_WR 0x00002
  49. #define MBOX_CMD 0x00000
  50. #define GET_DRIVER_VER 0x10000
  51. #define GET_N_ADAP 0x20000
  52. #define GET_ADAP_INFO 0x30000
  53. #define GET_CAP 0x40000
  54. #define GET_STATS 0x50000
  55. #define GET_IOCTL_VERSION 0x01
  56. #define EXT_IOCTL_SIGN_SZ 16
  57. #define EXT_IOCTL_SIGN "$$_EXTD_IOCTL_$$"
  58. #define MBOX_LEGACY 0x00 /* ioctl has legacy mbox*/
  59. #define MBOX_HPE 0x01 /* ioctl has hpe mbox */
  60. #define APPTYPE_MIMD 0x00 /* old existing apps */
  61. #define APPTYPE_UIOC 0x01 /* new apps using uioc */
  62. #define IOCTL_ISSUE 0x00000001 /* Issue ioctl */
  63. #define IOCTL_ABORT 0x00000002 /* Abort previous ioctl */
  64. #define DRVRTYPE_MBOX 0x00000001 /* regular mbox driver */
  65. #define DRVRTYPE_HPE 0x00000002 /* new hpe driver */
  66. #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) )
  67. #define GETADAP(mkadap) ((mkadap) ^ MEGAIOC_MAGIC << 8)
  68. #define MAX_DMA_POOLS 5 /* 4k, 8k, 16k, 32k, 64k*/
  69. /**
  70. * struct uioc_t - the common ioctl packet structure
  71. *
  72. * @signature : Must be "$$_EXTD_IOCTL_$$"
  73. * @mb_type : Type of the mail box (MB_LEGACY or MB_HPE)
  74. * @app_type : Type of the issuing application (existing or new)
  75. * @opcode : Opcode of the command
  76. * @adapno : Adapter number
  77. * @cmdbuf : Pointer to buffer - can point to mbox or plain data buffer
  78. * @xferlen : xferlen for DCMD and non mailbox commands
  79. * @data_dir : Direction of the data transfer
  80. * @status : Status from the driver
  81. * @reserved : reserved bytes for future expansion
  82. *
  83. * @user_data : user data transfer address is saved in this
  84. * @user_data_len: length of the data buffer sent by user app
  85. * @user_pthru : user passthru address is saves in this (null if DCMD)
  86. * @pthru32 : kernel address passthru (allocated per kioc)
  87. * @pthru32_h : physicall address of @pthru32
  88. * @list : for kioc free pool list maintenance
  89. * @done : call back routine for llds to call when kioc is completed
  90. * @buf_vaddr : dma pool buffer attached to kioc for data transfer
  91. * @buf_paddr : physical address of the dma pool buffer
  92. * @pool_index : index of the dma pool that @buf_vaddr is taken from
  93. * @free_buf : indicates if buffer needs to be freed after kioc completes
  94. *
  95. * Note : All LSI drivers understand only this packet. Any other
  96. * : format sent by applications would be converted to this.
  97. */
  98. typedef struct uioc {
  99. /* User Apps: */
  100. uint8_t signature[EXT_IOCTL_SIGN_SZ];
  101. uint16_t mb_type;
  102. uint16_t app_type;
  103. uint32_t opcode;
  104. uint32_t adapno;
  105. uint64_t cmdbuf;
  106. uint32_t xferlen;
  107. uint32_t data_dir;
  108. int32_t status;
  109. uint8_t reserved[128];
  110. /* Driver Data: */
  111. void __user * user_data;
  112. uint32_t user_data_len;
  113. /* 64bit alignment */
  114. uint32_t pad_for_64bit_align;
  115. mraid_passthru_t __user *user_pthru;
  116. mraid_passthru_t *pthru32;
  117. dma_addr_t pthru32_h;
  118. struct list_head list;
  119. void (*done)(struct uioc*);
  120. caddr_t buf_vaddr;
  121. dma_addr_t buf_paddr;
  122. int8_t pool_index;
  123. uint8_t free_buf;
  124. uint8_t timedout;
  125. } __attribute__ ((aligned(1024),packed)) uioc_t;
  126. /**
  127. * struct mraid_hba_info - information about the controller
  128. *
  129. * @pci_vendor_id : PCI vendor id
  130. * @pci_device_id : PCI device id
  131. * @subsystem_vendor_id : PCI subsystem vendor id
  132. * @subsystem_device_id : PCI subsystem device id
  133. * @baseport : base port of hba memory
  134. * @pci_bus : PCI bus
  135. * @pci_dev_fn : PCI device/function values
  136. * @irq : interrupt vector for the device
  137. *
  138. * Extended information of 256 bytes about the controller. Align on the single
  139. * byte boundary so that 32-bit applications can be run on 64-bit platform
  140. * drivers withoug re-compilation.
  141. * NOTE: reduce the number of reserved bytes whenever new field are added, so
  142. * that total size of the structure remains 256 bytes.
  143. */
  144. typedef struct mraid_hba_info {
  145. uint16_t pci_vendor_id;
  146. uint16_t pci_device_id;
  147. uint16_t subsys_vendor_id;
  148. uint16_t subsys_device_id;
  149. uint64_t baseport;
  150. uint8_t pci_bus;
  151. uint8_t pci_dev_fn;
  152. uint8_t pci_slot;
  153. uint8_t irq;
  154. uint32_t unique_id;
  155. uint32_t host_no;
  156. uint8_t num_ldrv;
  157. } __attribute__ ((aligned(256), packed)) mraid_hba_info_t;
  158. /**
  159. * mcontroller : adapter info structure for old mimd_t apps
  160. *
  161. * @base : base address
  162. * @irq : irq number
  163. * @numldrv : number of logical drives
  164. * @pcibus : pci bus
  165. * @pcidev : pci device
  166. * @pcifun : pci function
  167. * @pciid : pci id
  168. * @pcivendor : vendor id
  169. * @pcislot : slot number
  170. * @uid : unique id
  171. */
  172. typedef struct mcontroller {
  173. uint64_t base;
  174. uint8_t irq;
  175. uint8_t numldrv;
  176. uint8_t pcibus;
  177. uint16_t pcidev;
  178. uint8_t pcifun;
  179. uint16_t pciid;
  180. uint16_t pcivendor;
  181. uint8_t pcislot;
  182. uint32_t uid;
  183. } __attribute__ ((packed)) mcontroller_t;
  184. /**
  185. * mm_dmapool_t : Represents one dma pool with just one buffer
  186. *
  187. * @vaddr : Virtual address
  188. * @paddr : DMA physicall address
  189. * @bufsize : In KB - 4 = 4k, 8 = 8k etc.
  190. * @handle : Handle to the dma pool
  191. * @lock : lock to synchronize access to the pool
  192. * @in_use : If pool already in use, attach new block
  193. */
  194. typedef struct mm_dmapool {
  195. caddr_t vaddr;
  196. dma_addr_t paddr;
  197. uint32_t buf_size;
  198. struct dma_pool *handle;
  199. spinlock_t lock;
  200. uint8_t in_use;
  201. } mm_dmapool_t;
  202. /**
  203. * mraid_mmadp_t: Structure that drivers pass during (un)registration
  204. *
  205. * @unique_id : Any unique id (usually PCI bus+dev+fn)
  206. * @drvr_type : megaraid or hpe (DRVRTYPE_MBOX or DRVRTYPE_HPE)
  207. * @drv_data : Driver specific; not touched by the common module
  208. * @timeout : timeout for issued kiocs
  209. * @max_kioc : Maximum ioctl packets acceptable by the lld
  210. * @pdev : pci dev; used for allocating dma'ble memory
  211. * @issue_uioc : Driver supplied routine to issue uioc_t commands
  212. * : issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done)
  213. * @quiescent : flag to indicate if ioctl can be issued to this adp
  214. * @list : attach with the global list of adapters
  215. * @kioc_list : block of mem for @max_kioc number of kiocs
  216. * @kioc_pool : pool of free kiocs
  217. * @kioc_pool_lock : protection for free pool
  218. * @kioc_semaphore : so as not to exceed @max_kioc parallel ioctls
  219. * @mbox_list : block of mem for @max_kioc number of mboxes
  220. * @pthru_dma_pool : DMA pool to allocate passthru packets
  221. * @dma_pool_list : array of dma pools
  222. */
  223. typedef struct mraid_mmadp {
  224. /* Filled by driver */
  225. uint32_t unique_id;
  226. uint32_t drvr_type;
  227. unsigned long drvr_data;
  228. uint16_t timeout;
  229. uint8_t max_kioc;
  230. struct pci_dev *pdev;
  231. int(*issue_uioc)(unsigned long, uioc_t *, uint32_t);
  232. /* Maintained by common module */
  233. uint32_t quiescent;
  234. struct list_head list;
  235. uioc_t *kioc_list;
  236. struct list_head kioc_pool;
  237. spinlock_t kioc_pool_lock;
  238. struct semaphore kioc_semaphore;
  239. mbox64_t *mbox_list;
  240. struct dma_pool *pthru_dma_pool;
  241. mm_dmapool_t dma_pool_list[MAX_DMA_POOLS];
  242. } mraid_mmadp_t;
  243. int mraid_mm_register_adp(mraid_mmadp_t *);
  244. int mraid_mm_unregister_adp(uint32_t);
  245. uint32_t mraid_mm_adapter_app_handle(uint32_t);
  246. #endif /* _MEGARAID_IOCTL_H_ */