2 * Copyright (c) 2010, LSI Corp.
4 * Author : Manjunath Ranganathaiah
5 * Support: freebsdraid@lsi.com
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of the <ORGANIZATION> nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * $FreeBSD: src/sys/dev/tws/tws.h,v 1.3 2007/05/09 04:16:32 mrangana Exp $
37 #include <sys/param.h> /* defines used in kernel.h */
38 #include <sys/module.h>
39 #include <sys/systm.h>
41 #include <sys/errno.h>
42 #include <sys/kernel.h> /* types used in module initialization */
43 #include <sys/conf.h> /* cdevsw struct */
44 #include <sys/uio.h> /* uio struct */
45 #include <sys/malloc.h>
46 #include <sys/bus.h> /* structs, prototypes for pci bus stuff */
49 #include <sys/device.h>
50 #include <machine/clock.h>
52 #include <bus/pci/pcivar.h> /* For pci_get macros! */
53 #include <bus/pci/pcireg.h>
55 #include <sys/types.h>
56 #include <sys/sysctl.h>
60 #define TWS_PULL_MODE_ENABLE 1
62 MALLOC_DECLARE(M_TWS
);
64 extern int tws_queue_depth
;
67 #define TWS_DRIVER_VERSION_STRING "10.80.00.001"
68 #define TWS_MAX_NUM_UNITS 65
69 #define TWS_MAX_NUM_LUNS 16
70 #define TWS_MAX_IRQS 2
71 #define TWS_SCSI_INITIATOR_ID 66
72 #define TWS_MAX_IO_SIZE 0x20000 /* 128kB */
73 #define TWS_SECTOR_SIZE 0x200
74 #define TWS_POLL_TIMEOUT 60
75 #define TWS_IO_TIMEOUT 60
76 #define TWS_RESET_TIMEOUT 60
78 #define TWS_PCI_BAR0 0x10
79 #define TWS_PCI_BAR1 0x14
80 #define TWS_PCI_BAR2 0x1C
82 #define TWS_VENDOR_ID 0x13C1
83 #define TWS_DEVICE_ID 0x1010
85 #define TWS_INVALID_REQID 0xFFFF
88 #define TWS_ALIGNMENT 4
89 #define TWS_IN_MF_ALIGNMENT 16
90 #define TWS_OUT_MF_ALIGNMENT 4
92 #define TWS_MAX_32BIT_SG_ELEMENTS 93 /* max 32-bit sg elements */
93 #define TWS_MAX_64BIT_SG_ELEMENTS 46 /* max 64-bit sg elements */
96 #define TWS_MAX_REQS 256
97 #define TWS_RESERVED_REQS 4
100 #define TWS_REQ_STATE_TRAN 0
101 #define TWS_REQ_STATE_FREE 1
102 #define TWS_REQ_STATE_PENDING 2
103 #define TWS_REQ_STATE_BUSY 3
104 #define TWS_REQ_STATE_COMPLETE 4
107 #define TWS_INTERNAL_CMD_REQ 0x0
108 #define TWS_AEN_FETCH_REQ 0x1
109 #define TWS_PASSTHRU_REQ 0x2
110 #define TWS_GETSET_PARAM_REQ 0x3
111 #define TWS_SCSI_IO_REQ 0x4
135 TWS_DIR_UNKNOWN
= 0x1,
147 struct tws_msix_info
{
149 bus_space_tag_t tbl_tag
;
150 bus_space_handle_t tbl_handle
;
151 struct resource
*tbl_res
;
154 struct tws_ioctl_lock
{
160 #define TWS_TRACE_FNAME_LEN 10
161 #define TWS_TRACE_FUNC_LEN 15
162 #define TWS_TRACE_DESC_LEN 10
163 struct tws_trace_rec
{
165 char fname
[TWS_TRACE_FNAME_LEN
];
166 char func
[TWS_TRACE_FUNC_LEN
];
168 char desc
[TWS_TRACE_DESC_LEN
];
173 struct tws_circular_q
{
174 volatile int16_t head
;
175 volatile int16_t tail
;
186 u_int64_t reqs_errored
;
187 u_int64_t spurios_intrs
;
194 struct tws_init_connect_info
{
195 u_int16_t working_srl
;
196 u_int16_t working_branch
;
197 u_int16_t working_build
;
198 u_int16_t fw_on_ctlr_srl
;
199 u_int16_t fw_on_ctlr_branch
;
200 u_int16_t fw_on_ctlr_build
;
205 /* ------------ boolean types ------------------- */
207 /* typedef enum _boolean { false, true } boolean; */
208 #define boolean _Bool
209 enum err
{ SUCCESS
, FAILURE
};
211 /* ----------- per instance data ---------------- */
213 /* The softc holds our per-instance data. */
215 device_t tws_dev
; /* bus device */
216 struct cdev
*tws_cdev
; /* controller device */
217 u_int32_t device_id
; /* device id */
218 u_int32_t subvendor_id
; /* device id */
219 u_int32_t subdevice_id
; /* device id */
220 u_int8_t tws_state
; /* driver state */
221 u_int8_t tws_prev_state
; /* driver prev state */
222 struct sysctl_ctx_list tws_clist
; /* sysctl context */
223 struct sysctl_oid
*tws_oidp
; /* sysctl context */
224 struct resource
*reg_res
; /* register interface window */
225 struct resource
*mfa_res
; /* mfa interface window */
226 int reg_res_id
; /* register resource id */
227 int mfa_res_id
; /* register resource id */
228 bus_space_handle_t bus_handle
; /* bus space handle */
229 bus_space_handle_t bus_mfa_handle
; /* bus space handle */
230 bus_space_tag_t bus_tag
; /* bus space tag */
231 bus_space_tag_t bus_mfa_tag
; /* bus space tag for mfa's */
232 u_int64_t mfa_base
; /* mfa base address */
233 struct resource
*irq_res
; /* interrupt resource */
234 int irq_res_id
; /* intr resource id */
235 void *intr_handle
; /* interrupt handle */
236 struct tws_msix_info msix
; /* msix info */
237 struct cam_sim
*sim
; /* sim for this controller */
238 struct cam_path
*path
; /* Ctlr path to CAM */
239 struct lock q_lock
; /* queue lock */
240 struct lock sim_lock
; /* sim lock */
241 struct lock gen_lock
; /* general driver lock */
242 struct lock io_lock
; /* IO lock */
243 struct tws_ioctl_lock ioctl_lock
; /* ioctl lock */
244 u_int32_t seq_id
; /* Sequence id */
245 int chan
; /* wait channel */
246 struct tws_circular_q aen_q
; /* aen q */
247 struct tws_circular_q trace_q
; /* trace q */
248 struct tws_stats stats
; /* I/O stats */
249 struct tws_init_connect_info cinfo
; /* compatibility info */
250 boolean is64bit
; /* True - 64bit else 32bit */
251 int intr_type
; /* Interrupt type used */
252 bus_dma_tag_t parent_tag
; /* parent DMA tag */
253 bus_dma_tag_t cmd_tag
; /* command DMA tag */
254 bus_dmamap_t cmd_map
; /* command map */
255 void *dma_mem
; /* pointer to dmable memory */
256 u_int64_t dma_mem_phys
; /* phy addr */
257 bus_dma_tag_t data_tag
; /* data DMA tag */
258 struct tws_request
*reqs
; /* pointer to requests */
259 struct tws_sense
*sense_bufs
; /* pointer to sense buffers */
260 boolean obfl_q_overrun
; /* OBFL overrun flag */
261 union ccb
*scan_ccb
; /* pointer to a ccb */
262 struct tws_request
*q_head
[TWS_MAX_QS
]; /* head pointers to q's */
263 struct tws_request
*q_tail
[TWS_MAX_QS
]; /* tail pointers to q's */
265 struct callout print_stats_handle
;
266 struct callout reset_cb_handle
;
267 struct callout reinit_handle
;