cissvar.h revision 1.9 1 /* $NetBSD: cissvar.h,v 1.9 2020/07/14 10:37:30 jdolecek Exp $ */
2 /* $OpenBSD: cissvar.h,v 1.15 2013/05/30 16:15:02 deraadt Exp $ */
3
4 /*
5 * Copyright (c) 2005,2006 Michael Shalayeff
6 * All rights reserved.
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
17 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
18 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21 #include <sys/mutex.h>
22 #include <sys/condvar.h>
23
24 #include <dev/sysmon/sysmonvar.h>
25 #include <sys/envsys.h>
26
27 #include "opt_ciss.h"
28
29 struct ciss_ld {
30 struct ciss_blink bling; /* a copy of blink state */
31 char xname[16]; /* copy of the sdN name */
32 int ndrives;
33 u_int8_t tgts[1];
34 };
35
36 struct ciss_softc {
37 /* Generic device info. */
38 device_t sc_dev;
39 kmutex_t sc_mutex;
40 kmutex_t sc_mutex_scratch;
41 bus_space_handle_t sc_ioh;
42 bus_space_tag_t sc_iot;
43 bus_dma_tag_t sc_dmat;
44 void *sc_ih;
45 void *sc_sh; /* shutdown hook */
46 struct proc *sc_thread;
47 int sc_flush;
48 #ifdef CISS_NO_INTERRUPT_HACK
49 struct callout sc_interrupt_hack;
50 #endif
51
52 struct scsipi_channel sc_channel;
53 struct scsipi_channel *sc_channel_raw;
54 struct scsipi_adapter sc_adapter;
55 struct scsipi_adapter *sc_adapter_raw;
56 struct callout sc_hb;
57
58 u_int sc_flags;
59 int ccblen, maxcmd, maxsg, nbus, ndrives, maxunits;
60 ciss_queue_head sc_free_ccb;
61 kcondvar_t sc_condvar;
62
63 bus_dmamap_t cmdmap;
64 bus_dma_segment_t cmdseg[1];
65 void * ccbs;
66 void *scratch;
67 u_int sc_waitflag;
68
69 bus_space_handle_t cfg_ioh;
70
71 struct ciss_perf_config perfcfg;
72 bus_dmamap_t replymap;
73 bus_dma_segment_t replyseg[1];
74 uint64_t *perf_reply;
75 int perf_rqidx, perf_cycle;
76 #define CISS_IS_PERF(sc) ((sc)->perf_reply != NULL)
77
78 int fibrillation;
79 struct ciss_config cfg;
80 #define CISS_PERF_SUPPORTED(sc) ((sc)->cfg.methods & CISS_METH_PERF)
81 int cfgoff;
82 u_int32_t iem;
83 u_int32_t heartbeat;
84 struct ciss_ld **sc_lds;
85
86 /* scsi ioctl from sd device */
87 int (*sc_ioctl)(device_t, u_long, void *);
88
89 struct sysmon_envsys *sc_sme;
90 envsys_data_t *sc_sensor;
91 };
92
93 struct ciss_rawsoftc {
94 struct ciss_softc *sc_softc;
95 u_int8_t sc_channel;
96 };
97
98 int ciss_attach(struct ciss_softc *sc);
99 int ciss_intr_simple_intx(void *v);
100 int ciss_intr_perf_intx(void *v);
101 int ciss_intr_perf_msi(void *v);
102