![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * 0004 * Linux MegaRAID device driver 0005 * 0006 * Copyright (c) 2003-2004 LSI Logic Corporation. 0007 * 0008 * FILE : megaraid_ioctl.h 0009 * 0010 * Definitions to interface with user level applications 0011 */ 0012 0013 #ifndef _MEGARAID_IOCTL_H_ 0014 #define _MEGARAID_IOCTL_H_ 0015 0016 #include <linux/types.h> 0017 #include <linux/semaphore.h> 0018 #include <linux/timer.h> 0019 0020 #include "mbox_defs.h" 0021 0022 /* 0023 * console messages debug levels 0024 */ 0025 #define CL_ANN 0 /* print unconditionally, announcements */ 0026 #define CL_DLEVEL1 1 /* debug level 1, informative */ 0027 #define CL_DLEVEL2 2 /* debug level 2, verbose */ 0028 #define CL_DLEVEL3 3 /* debug level 3, very verbose */ 0029 0030 /** 0031 * con_log() - console log routine 0032 * @level : indicates the severity of the message. 0033 * @fmt : format string 0034 * 0035 * con_log displays the error messages on the console based on the current 0036 * debug level. Also it attaches the appropriate kernel severity level with 0037 * the message. 0038 */ 0039 #define con_log(level, fmt) if (LSI_DBGLVL >= level) printk fmt; 0040 0041 /* 0042 * Definitions & Declarations needed to use common management module 0043 */ 0044 0045 #define MEGAIOC_MAGIC 'm' 0046 #define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, mimd_t) 0047 0048 #define MEGAIOC_QNADAP 'm' /* Query # of adapters */ 0049 #define MEGAIOC_QDRVRVER 'e' /* Query driver version */ 0050 #define MEGAIOC_QADAPINFO 'g' /* Query adapter information */ 0051 0052 #define USCSICMD 0x80 0053 #define UIOC_RD 0x00001 0054 #define UIOC_WR 0x00002 0055 0056 #define MBOX_CMD 0x00000 0057 #define GET_DRIVER_VER 0x10000 0058 #define GET_N_ADAP 0x20000 0059 #define GET_ADAP_INFO 0x30000 0060 #define GET_CAP 0x40000 0061 #define GET_STATS 0x50000 0062 #define GET_IOCTL_VERSION 0x01 0063 0064 #define EXT_IOCTL_SIGN_SZ 16 0065 #define EXT_IOCTL_SIGN "$$_EXTD_IOCTL_$$" 0066 0067 #define MBOX_LEGACY 0x00 /* ioctl has legacy mbox*/ 0068 #define MBOX_HPE 0x01 /* ioctl has hpe mbox */ 0069 0070 #define APPTYPE_MIMD 0x00 /* old existing apps */ 0071 #define APPTYPE_UIOC 0x01 /* new apps using uioc */ 0072 0073 #define IOCTL_ISSUE 0x00000001 /* Issue ioctl */ 0074 #define IOCTL_ABORT 0x00000002 /* Abort previous ioctl */ 0075 0076 #define DRVRTYPE_MBOX 0x00000001 /* regular mbox driver */ 0077 #define DRVRTYPE_HPE 0x00000002 /* new hpe driver */ 0078 0079 #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) ) 0080 #define GETADAP(mkadap) ((mkadap) ^ MEGAIOC_MAGIC << 8) 0081 0082 #define MAX_DMA_POOLS 5 /* 4k, 8k, 16k, 32k, 64k*/ 0083 0084 0085 /** 0086 * struct uioc_t - the common ioctl packet structure 0087 * 0088 * @signature : Must be "$$_EXTD_IOCTL_$$" 0089 * @mb_type : Type of the mail box (MB_LEGACY or MB_HPE) 0090 * @app_type : Type of the issuing application (existing or new) 0091 * @opcode : Opcode of the command 0092 * @adapno : Adapter number 0093 * @cmdbuf : Pointer to buffer - can point to mbox or plain data buffer 0094 * @xferlen : xferlen for DCMD and non mailbox commands 0095 * @data_dir : Direction of the data transfer 0096 * @status : Status from the driver 0097 * @reserved : reserved bytes for future expansion 0098 * 0099 * @user_data : user data transfer address is saved in this 0100 * @user_data_len: length of the data buffer sent by user app 0101 * @user_pthru : user passthru address is saves in this (null if DCMD) 0102 * @pthru32 : kernel address passthru (allocated per kioc) 0103 * @pthru32_h : physicall address of @pthru32 0104 * @list : for kioc free pool list maintenance 0105 * @done : call back routine for llds to call when kioc is completed 0106 * @buf_vaddr : dma pool buffer attached to kioc for data transfer 0107 * @buf_paddr : physical address of the dma pool buffer 0108 * @pool_index : index of the dma pool that @buf_vaddr is taken from 0109 * @free_buf : indicates if buffer needs to be freed after kioc completes 0110 * 0111 * Note : All LSI drivers understand only this packet. Any other 0112 * : format sent by applications would be converted to this. 0113 */ 0114 typedef struct uioc { 0115 0116 /* User Apps: */ 0117 0118 uint8_t signature[EXT_IOCTL_SIGN_SZ]; 0119 uint16_t mb_type; 0120 uint16_t app_type; 0121 uint32_t opcode; 0122 uint32_t adapno; 0123 uint64_t cmdbuf; 0124 uint32_t xferlen; 0125 uint32_t data_dir; 0126 int32_t status; 0127 uint8_t reserved[128]; 0128 0129 /* Driver Data: */ 0130 void __user * user_data; 0131 uint32_t user_data_len; 0132 0133 /* 64bit alignment */ 0134 uint32_t pad_for_64bit_align; 0135 0136 mraid_passthru_t __user *user_pthru; 0137 0138 mraid_passthru_t *pthru32; 0139 dma_addr_t pthru32_h; 0140 0141 struct list_head list; 0142 void (*done)(struct uioc*); 0143 0144 caddr_t buf_vaddr; 0145 dma_addr_t buf_paddr; 0146 int8_t pool_index; 0147 uint8_t free_buf; 0148 0149 uint8_t timedout; 0150 0151 } __attribute__ ((aligned(1024),packed)) uioc_t; 0152 0153 /* For on-stack uioc timers. */ 0154 struct uioc_timeout { 0155 struct timer_list timer; 0156 uioc_t *uioc; 0157 }; 0158 0159 /** 0160 * struct mraid_hba_info - information about the controller 0161 * 0162 * @pci_vendor_id : PCI vendor id 0163 * @pci_device_id : PCI device id 0164 * @subsystem_vendor_id : PCI subsystem vendor id 0165 * @subsystem_device_id : PCI subsystem device id 0166 * @baseport : base port of hba memory 0167 * @pci_bus : PCI bus 0168 * @pci_dev_fn : PCI device/function values 0169 * @irq : interrupt vector for the device 0170 * 0171 * Extended information of 256 bytes about the controller. Align on the single 0172 * byte boundary so that 32-bit applications can be run on 64-bit platform 0173 * drivers withoug re-compilation. 0174 * NOTE: reduce the number of reserved bytes whenever new field are added, so 0175 * that total size of the structure remains 256 bytes. 0176 */ 0177 typedef struct mraid_hba_info { 0178 0179 uint16_t pci_vendor_id; 0180 uint16_t pci_device_id; 0181 uint16_t subsys_vendor_id; 0182 uint16_t subsys_device_id; 0183 0184 uint64_t baseport; 0185 uint8_t pci_bus; 0186 uint8_t pci_dev_fn; 0187 uint8_t pci_slot; 0188 uint8_t irq; 0189 0190 uint32_t unique_id; 0191 uint32_t host_no; 0192 0193 uint8_t num_ldrv; 0194 } __attribute__ ((aligned(256), packed)) mraid_hba_info_t; 0195 0196 0197 /** 0198 * mcontroller : adapter info structure for old mimd_t apps 0199 * 0200 * @base : base address 0201 * @irq : irq number 0202 * @numldrv : number of logical drives 0203 * @pcibus : pci bus 0204 * @pcidev : pci device 0205 * @pcifun : pci function 0206 * @pciid : pci id 0207 * @pcivendor : vendor id 0208 * @pcislot : slot number 0209 * @uid : unique id 0210 */ 0211 typedef struct mcontroller { 0212 0213 uint64_t base; 0214 uint8_t irq; 0215 uint8_t numldrv; 0216 uint8_t pcibus; 0217 uint16_t pcidev; 0218 uint8_t pcifun; 0219 uint16_t pciid; 0220 uint16_t pcivendor; 0221 uint8_t pcislot; 0222 uint32_t uid; 0223 0224 } __attribute__ ((packed)) mcontroller_t; 0225 0226 0227 /** 0228 * mm_dmapool_t : Represents one dma pool with just one buffer 0229 * 0230 * @vaddr : Virtual address 0231 * @paddr : DMA physicall address 0232 * @bufsize : In KB - 4 = 4k, 8 = 8k etc. 0233 * @handle : Handle to the dma pool 0234 * @lock : lock to synchronize access to the pool 0235 * @in_use : If pool already in use, attach new block 0236 */ 0237 typedef struct mm_dmapool { 0238 caddr_t vaddr; 0239 dma_addr_t paddr; 0240 uint32_t buf_size; 0241 struct dma_pool *handle; 0242 spinlock_t lock; 0243 uint8_t in_use; 0244 } mm_dmapool_t; 0245 0246 0247 /** 0248 * mraid_mmadp_t: Structure that drivers pass during (un)registration 0249 * 0250 * @unique_id : Any unique id (usually PCI bus+dev+fn) 0251 * @drvr_type : megaraid or hpe (DRVRTYPE_MBOX or DRVRTYPE_HPE) 0252 * @drv_data : Driver specific; not touched by the common module 0253 * @timeout : timeout for issued kiocs 0254 * @max_kioc : Maximum ioctl packets acceptable by the lld 0255 * @pdev : pci dev; used for allocating dma'ble memory 0256 * @issue_uioc : Driver supplied routine to issue uioc_t commands 0257 * : issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done) 0258 * @quiescent : flag to indicate if ioctl can be issued to this adp 0259 * @list : attach with the global list of adapters 0260 * @kioc_list : block of mem for @max_kioc number of kiocs 0261 * @kioc_pool : pool of free kiocs 0262 * @kioc_pool_lock : protection for free pool 0263 * @kioc_semaphore : so as not to exceed @max_kioc parallel ioctls 0264 * @mbox_list : block of mem for @max_kioc number of mboxes 0265 * @pthru_dma_pool : DMA pool to allocate passthru packets 0266 * @dma_pool_list : array of dma pools 0267 */ 0268 0269 typedef struct mraid_mmadp { 0270 0271 /* Filled by driver */ 0272 0273 uint32_t unique_id; 0274 uint32_t drvr_type; 0275 unsigned long drvr_data; 0276 uint16_t timeout; 0277 uint8_t max_kioc; 0278 0279 struct pci_dev *pdev; 0280 0281 int(*issue_uioc)(unsigned long, uioc_t *, uint32_t); 0282 0283 /* Maintained by common module */ 0284 uint32_t quiescent; 0285 0286 struct list_head list; 0287 uioc_t *kioc_list; 0288 struct list_head kioc_pool; 0289 spinlock_t kioc_pool_lock; 0290 struct semaphore kioc_semaphore; 0291 0292 mbox64_t *mbox_list; 0293 struct dma_pool *pthru_dma_pool; 0294 mm_dmapool_t dma_pool_list[MAX_DMA_POOLS]; 0295 0296 } mraid_mmadp_t; 0297 0298 int mraid_mm_register_adp(mraid_mmadp_t *); 0299 int mraid_mm_unregister_adp(uint32_t); 0300 uint32_t mraid_mm_adapter_app_handle(uint32_t); 0301 0302 #endif /* _MEGARAID_IOCTL_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |