Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

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