3 * Linux MegaRAID device driver
5 * Copyright (c) 2003-2004 LSI Logic Corporation.
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.
12 * FILE : megaraid_ioctl.h
14 * Definitions to interface with user level applications
17 #ifndef _MEGARAID_IOCTL_H_
18 #define _MEGARAID_IOCTL_H_
20 #include <linux/types.h>
21 #include <linux/semaphore.h>
22 #include <linux/timer.h>
24 #include "mbox_defs.h"
27 * console messages debug levels
29 #define CL_ANN 0 /* print unconditionally, announcements */
30 #define CL_DLEVEL1 1 /* debug level 1, informative */
31 #define CL_DLEVEL2 2 /* debug level 2, verbose */
32 #define CL_DLEVEL3 3 /* debug level 3, very verbose */
35 * con_log() - console log routine
36 * @level : indicates the severity of the message.
37 * @fmt : format string
39 * con_log displays the error messages on the console based on the current
40 * debug level. Also it attaches the appropriate kernel severity level with
43 #define con_log(level, fmt) if (LSI_DBGLVL >= level) printk fmt;
46 * Definitions & Declarations needed to use common management module
49 #define MEGAIOC_MAGIC 'm'
50 #define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, mimd_t)
52 #define MEGAIOC_QNADAP 'm' /* Query # of adapters */
53 #define MEGAIOC_QDRVRVER 'e' /* Query driver version */
54 #define MEGAIOC_QADAPINFO 'g' /* Query adapter information */
57 #define UIOC_RD 0x00001
58 #define UIOC_WR 0x00002
60 #define MBOX_CMD 0x00000
61 #define GET_DRIVER_VER 0x10000
62 #define GET_N_ADAP 0x20000
63 #define GET_ADAP_INFO 0x30000
64 #define GET_CAP 0x40000
65 #define GET_STATS 0x50000
66 #define GET_IOCTL_VERSION 0x01
68 #define EXT_IOCTL_SIGN_SZ 16
69 #define EXT_IOCTL_SIGN "$$_EXTD_IOCTL_$$"
71 #define MBOX_LEGACY 0x00 /* ioctl has legacy mbox*/
72 #define MBOX_HPE 0x01 /* ioctl has hpe mbox */
74 #define APPTYPE_MIMD 0x00 /* old existing apps */
75 #define APPTYPE_UIOC 0x01 /* new apps using uioc */
77 #define IOCTL_ISSUE 0x00000001 /* Issue ioctl */
78 #define IOCTL_ABORT 0x00000002 /* Abort previous ioctl */
80 #define DRVRTYPE_MBOX 0x00000001 /* regular mbox driver */
81 #define DRVRTYPE_HPE 0x00000002 /* new hpe driver */
83 #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) )
84 #define GETADAP(mkadap) ((mkadap) ^ MEGAIOC_MAGIC << 8)
86 #define MAX_DMA_POOLS 5 /* 4k, 8k, 16k, 32k, 64k*/
90 * struct uioc_t - the common ioctl packet structure
92 * @signature : Must be "$$_EXTD_IOCTL_$$"
93 * @mb_type : Type of the mail box (MB_LEGACY or MB_HPE)
94 * @app_type : Type of the issuing application (existing or new)
95 * @opcode : Opcode of the command
96 * @adapno : Adapter number
97 * @cmdbuf : Pointer to buffer - can point to mbox or plain data buffer
98 * @xferlen : xferlen for DCMD and non mailbox commands
99 * @data_dir : Direction of the data transfer
100 * @status : Status from the driver
101 * @reserved : reserved bytes for future expansion
103 * @user_data : user data transfer address is saved in this
104 * @user_data_len: length of the data buffer sent by user app
105 * @user_pthru : user passthru address is saves in this (null if DCMD)
106 * @pthru32 : kernel address passthru (allocated per kioc)
107 * @pthru32_h : physicall address of @pthru32
108 * @list : for kioc free pool list maintenance
109 * @done : call back routine for llds to call when kioc is completed
110 * @buf_vaddr : dma pool buffer attached to kioc for data transfer
111 * @buf_paddr : physical address of the dma pool buffer
112 * @pool_index : index of the dma pool that @buf_vaddr is taken from
113 * @free_buf : indicates if buffer needs to be freed after kioc completes
115 * Note : All LSI drivers understand only this packet. Any other
116 * : format sent by applications would be converted to this.
118 typedef struct uioc
{
122 uint8_t signature
[EXT_IOCTL_SIGN_SZ
];
131 uint8_t reserved
[128];
134 void __user
* user_data
;
135 uint32_t user_data_len
;
137 /* 64bit alignment */
138 uint32_t pad_for_64bit_align
;
140 mraid_passthru_t __user
*user_pthru
;
142 mraid_passthru_t
*pthru32
;
143 dma_addr_t pthru32_h
;
145 struct list_head list
;
146 void (*done
)(struct uioc
*);
149 dma_addr_t buf_paddr
;
155 } __attribute__ ((aligned(1024),packed
)) uioc_t
;
157 /* For on-stack uioc timers. */
158 struct uioc_timeout
{
159 struct timer_list timer
;
164 * struct mraid_hba_info - information about the controller
166 * @pci_vendor_id : PCI vendor id
167 * @pci_device_id : PCI device id
168 * @subsystem_vendor_id : PCI subsystem vendor id
169 * @subsystem_device_id : PCI subsystem device id
170 * @baseport : base port of hba memory
172 * @pci_dev_fn : PCI device/function values
173 * @irq : interrupt vector for the device
175 * Extended information of 256 bytes about the controller. Align on the single
176 * byte boundary so that 32-bit applications can be run on 64-bit platform
177 * drivers withoug re-compilation.
178 * NOTE: reduce the number of reserved bytes whenever new field are added, so
179 * that total size of the structure remains 256 bytes.
181 typedef struct mraid_hba_info
{
183 uint16_t pci_vendor_id
;
184 uint16_t pci_device_id
;
185 uint16_t subsys_vendor_id
;
186 uint16_t subsys_device_id
;
198 } __attribute__ ((aligned(256), packed
)) mraid_hba_info_t
;
202 * mcontroller : adapter info structure for old mimd_t apps
204 * @base : base address
206 * @numldrv : number of logical drives
208 * @pcidev : pci device
209 * @pcifun : pci function
211 * @pcivendor : vendor id
212 * @pcislot : slot number
215 typedef struct mcontroller
{
228 } __attribute__ ((packed
)) mcontroller_t
;
232 * mm_dmapool_t : Represents one dma pool with just one buffer
234 * @vaddr : Virtual address
235 * @paddr : DMA physicall address
236 * @bufsize : In KB - 4 = 4k, 8 = 8k etc.
237 * @handle : Handle to the dma pool
238 * @lock : lock to synchronize access to the pool
239 * @in_use : If pool already in use, attach new block
241 typedef struct mm_dmapool
{
245 struct dma_pool
*handle
;
252 * mraid_mmadp_t: Structure that drivers pass during (un)registration
254 * @unique_id : Any unique id (usually PCI bus+dev+fn)
255 * @drvr_type : megaraid or hpe (DRVRTYPE_MBOX or DRVRTYPE_HPE)
256 * @drv_data : Driver specific; not touched by the common module
257 * @timeout : timeout for issued kiocs
258 * @max_kioc : Maximum ioctl packets acceptable by the lld
259 * @pdev : pci dev; used for allocating dma'ble memory
260 * @issue_uioc : Driver supplied routine to issue uioc_t commands
261 * : issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done)
262 * @quiescent : flag to indicate if ioctl can be issued to this adp
263 * @list : attach with the global list of adapters
264 * @kioc_list : block of mem for @max_kioc number of kiocs
265 * @kioc_pool : pool of free kiocs
266 * @kioc_pool_lock : protection for free pool
267 * @kioc_semaphore : so as not to exceed @max_kioc parallel ioctls
268 * @mbox_list : block of mem for @max_kioc number of mboxes
269 * @pthru_dma_pool : DMA pool to allocate passthru packets
270 * @dma_pool_list : array of dma pools
273 typedef struct mraid_mmadp
{
275 /* Filled by driver */
279 unsigned long drvr_data
;
283 struct pci_dev
*pdev
;
285 int(*issue_uioc
)(unsigned long, uioc_t
*, uint32_t);
287 /* Maintained by common module */
290 struct list_head list
;
292 struct list_head kioc_pool
;
293 spinlock_t kioc_pool_lock
;
294 struct semaphore kioc_semaphore
;
297 struct dma_pool
*pthru_dma_pool
;
298 mm_dmapool_t dma_pool_list
[MAX_DMA_POOLS
];
302 int mraid_mm_register_adp(mraid_mmadp_t
*);
303 int mraid_mm_unregister_adp(uint32_t);
304 uint32_t mraid_mm_adapter_app_handle(uint32_t);
306 #endif /* _MEGARAID_IOCTL_H_ */