wdvar.h revision 1.51 1 1.51 riastrad /* $NetBSD: wdvar.h,v 1.51 2021/12/28 13:27:32 riastradh Exp $ */
2 1.2 bouyer
3 1.2 bouyer /*
4 1.10 bouyer * Copyright (c) 1998, 2001 Manuel Bouyer.
5 1.2 bouyer *
6 1.2 bouyer * Redistribution and use in source and binary forms, with or without
7 1.2 bouyer * modification, are permitted provided that the following conditions
8 1.2 bouyer * are met:
9 1.2 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.2 bouyer * notice, this list of conditions and the following disclaimer.
11 1.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.2 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.2 bouyer * documentation and/or other materials provided with the distribution.
14 1.2 bouyer *
15 1.6 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 1.6 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 1.6 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 1.29 perry * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 1.6 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 1.6 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 1.6 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 1.6 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 1.6 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 1.6 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 1.8 bouyer */
26 1.13 thorpej
27 1.25 thorpej #ifndef _DEV_ATA_WDVAR_H_
28 1.25 thorpej #define _DEV_ATA_WDVAR_H_
29 1.13 thorpej
30 1.27 drochner #ifdef _KERNEL_OPT
31 1.44 jdolecek #include "opt_wd.h"
32 1.27 drochner #endif
33 1.27 drochner
34 1.51 riastrad #include <sys/types.h>
35 1.51 riastrad
36 1.51 riastrad #include <sys/callout.h>
37 1.51 riastrad #include <sys/condvar.h>
38 1.51 riastrad #include <sys/disk.h>
39 1.51 riastrad #include <sys/mutex.h>
40 1.51 riastrad #include <sys/sysctl.h>
41 1.51 riastrad #include <sys/queue.h>
42 1.51 riastrad
43 1.51 riastrad #include <dev/ata/atareg.h>
44 1.51 riastrad #include <dev/ata/atavar.h>
45 1.45 mlelstv #include <dev/dkvar.h>
46 1.51 riastrad
47 1.51 riastrad struct sysctllog;
48 1.40 tls
49 1.13 thorpej struct wd_softc {
50 1.13 thorpej /* General disk infos */
51 1.45 mlelstv struct dk_softc sc_dksc;
52 1.44 jdolecek kmutex_t sc_lock;
53 1.14 thorpej int sc_quirks; /* any quirks drive might have */
54 1.44 jdolecek
55 1.13 thorpej /* IDE disk soft states */
56 1.13 thorpej struct ata_drive_datas *drvp; /* Our controller's infos */
57 1.13 thorpej const struct ata_bustype *atabus;
58 1.20 wiz struct ataparams sc_params;/* drive characteristics found */
59 1.29 perry int sc_flags;
60 1.13 thorpej /*
61 1.13 thorpej * XXX Nothing resets this yet, but disk change sensing will when ATA-4 is
62 1.13 thorpej * more fully implemented.
63 1.13 thorpej */
64 1.13 thorpej #define WDF_LOADED 0x010 /* parameters loaded */
65 1.13 thorpej #define WDF_WAIT 0x020 /* waiting for resources */
66 1.13 thorpej #define WDF_LBA 0x040 /* using LBA mode */
67 1.13 thorpej #define WDF_LBA48 0x100 /* using 48-bit LBA mode */
68 1.49 bouyer #define WDF_DIRTY 0x200 /* disk cache dirty */
69 1.46 mlelstv #define WDF_OPEN 0x400 /* device is open */
70 1.41 matt uint64_t sc_capacity; /* full capacity of the device */
71 1.43 jakllsch uint64_t sc_capacity512; /* ... in DEV_BSIZE blocks */
72 1.41 matt uint32_t sc_capacity28; /* capacity accessible with LBA28 commands */
73 1.43 jakllsch uint32_t sc_blksize; /* logical block size, in bytes */
74 1.50 riastrad struct disk_sectoralign sc_sectoralign; /* sector alignment */
75 1.30 drochner
76 1.27 drochner #ifdef WD_SOFTBADSECT
77 1.16 darrenr SLIST_HEAD(, disk_badsectors) sc_bslist;
78 1.17 darrenr u_int sc_bscount;
79 1.51 riastrad kcondvar_t sc_bslist_cv;
80 1.51 riastrad u_int sc_bslist_inuse;
81 1.27 drochner #endif
82 1.44 jdolecek
83 1.47 jdolecek /* Retry/requeue failed transfers */
84 1.47 jdolecek SLIST_HEAD(, ata_xfer) sc_retry_list;
85 1.47 jdolecek struct callout sc_retry_callout; /* retry callout handle */
86 1.47 jdolecek struct callout sc_restart_diskqueue; /* restart queue processing */
87 1.47 jdolecek
88 1.47 jdolecek SLIST_HEAD(, ata_xfer) sc_requeue_list;
89 1.47 jdolecek struct callout sc_requeue_callout; /* requeue callout handle */
90 1.47 jdolecek
91 1.47 jdolecek struct ata_xfer dump_xfer;
92 1.47 jdolecek
93 1.44 jdolecek /* Sysctl nodes specific for the disk */
94 1.44 jdolecek struct sysctllog *nodelog;
95 1.44 jdolecek bool drv_ncq;
96 1.44 jdolecek #define WD_USE_NCQ(wd) \
97 1.44 jdolecek ((wd)->drv_ncq && ((wd)->drvp->drive_flags & ATA_DRIVE_NCQ))
98 1.44 jdolecek bool drv_ncq_prio;
99 1.44 jdolecek #define WD_USE_NCQ_PRIO(wd) \
100 1.44 jdolecek ((wd)->drv_ncq_prio && ((wd)->drvp->drive_flags & ATA_DRIVE_NCQ_PRIO))
101 1.44 jdolecek #ifdef WD_CHAOS_MONKEY
102 1.44 jdolecek int drv_chaos_freq; /* frequency of simulated bio errors */
103 1.44 jdolecek int drv_chaos_cnt; /* count of processed bio read xfers */
104 1.44 jdolecek #endif
105 1.48 mlelstv unsigned inflight;
106 1.48 mlelstv char *sc_typename;
107 1.13 thorpej };
108 1.13 thorpej
109 1.25 thorpej #endif /* _DEV_ATA_WDVAR_H_ */
110