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