summaryrefslogtreecommitdiff
path: root/usr/src/man/man1m/th_define.1m
blob: 9d47e1a66219a27057104baacb1c42a1e9acbfad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
'\" te
.\" Copyright (c) 2001 Sun Microsystems, Inc. All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH TH_DEFINE 1M "April 9, 2016"
.SH NAME
th_define \- create fault injection test harness error specifications
.SH SYNOPSIS
.LP
.nf
\fBth_define\fR [\fB-n\fR \fIname\fR \fB-i\fR \fIinstance\fR| \fB-P\fR \fIpath\fR] [\fB-a\fR \fIacc_types\fR]
     [\fB-r\fR \fIreg_number\fR] [\fB-l\fR \fIoffset\fR [\fIlength\fR]]
     [\fB-c\fR \fIcount\fR [\fIfailcount\fR]] [\fB-o\fR \fIoperator\fR [\fIoperand\fR]]
     [\fB-f\fR \fIacc_chk\fR] [\fB-w\fR \fImax_wait_period\fR [\fIreport_interval\fR]]
.fi

.LP
.nf
\fBor\fR
.fi

.LP
.nf
\fBth_define\fR [\fB-n\fR \fIname\fR \fB-i\fR \fIinstance\fR| \fB-P\fR \fIpath\fR]
     [\fB-a\fR log [\fIacc_types\fR] [\fB-r\fR \fIreg_number\fR] [\fB-l\fR \fIoffset\fR [\fIlength\fR]]]
     [\fB-c\fR \fIcount\fR [\fIfailcount\fR]] [\fB-s\fR \fIcollect_time\fR] [\fB-p\fR \fIpolicy\fR]
     [\fB-x\fR \fIflags\fR] [\fB-C\fR \fIcomment_string\fR]
     [\fB-e\fR \fIfixup_script\fR [\fIargs\fR]]
.fi

.LP
.nf
\fBor\fR
.fi

.LP
.nf
\fBth_define\fR [\fB-h\fR]
.fi

.SH DESCRIPTION
.LP
The \fBth_define\fR utility provides an interface to the \fBbus_ops\fR fault
injection \fBbofi\fR device driver for defining error injection specifications
(referred to as errdefs). An errdef corresponds to a specification of how to
corrupt a device driver's accesses to its hardware. The command line arguments
determine the precise nature of the fault to be injected. If the supplied
arguments define a consistent errdef, the \fBth_define\fR process will store
the errdef with the \fBbofi\fR driver and suspend itself until the criteria
given by the errdef become satisfied (in practice, this will occur when the
access counts go to zero).
.sp
.LP
You use the \fBth_manage\fR(1M) command with the \fBstart\fR option to activate
the resulting errdef. The effect of \fBth_manage\fR with the \fBstart\fR option
is that the \fBbofi\fR driver acts upon the errdef by matching the number of
hardware accesses\(emspecified in \fIcount\fR, that are of the type specified
in \fIacc_types\fR, made by instance number \fIinstance\fR\(emof the driver
whose name is \fIname\fR, (or by the driver instance specified by \fIpath\fR)
to the register set (or DMA handle) specified by \fIreg_number\fR, that lie
within the range \fIoffset\fR to \fIoffset\fR +\fI length\fR from the beginning
of the register set or DMA handle. It then applies \fIoperator\fR and
\fIoperand\fR to the next \fIfailcount\fR matching accesses.
.sp
.LP
If \fIacc_types\fR includes \fBlog\fR, \fBth_define\fR runs in automatic test
script generation mode, and a set of test scripts (written in the Korn shell)
is created and placed in a sub-directory of the current directory with the name
\fB\fI<driver>\fR\&.test.\fI<id>\fR\fR (for example, \fBglm.test.978177106\fR).
A separate, executable script is generated for each access handle that matches
the logging criteria. The log of accesses is placed at the top of each script
as a record of the session. If the current directory is not writable, file
output is written to standard output. The base name of each test file is the
driver name, and the extension is a number that discriminates between different
access handles. A control script (with the same name as the created test
directory) is generated that will run all the test scripts sequentially.
.sp
.LP
Executing the scripts will install, and then activate, the resulting error
definitions. Error definitions are activated sequentially and the driver
instance under test is taken offline and brought back online before each test
(refer to the \fB-e\fR option for more information). By default, logging
applies to all \fBPIO\fR accesses, all interrupts, and all DMA accesses to and
from areas mapped for both reading and writing. You can constrain logging by
specifying additional \fIacc_types\fR, \fIreg_number\fR, \fIoffset\fR and
\fIlength\fR. Logging will continue for \fIcount\fR matching accesses, with an
optional time limit of \fIcollect_time\fR seconds.
.sp
.LP
Either the \fB-n\fR or \fB-P\fR option must be provided. The other options are
optional. If an option (other than \fB-a\fR) is specified multiple times, only
the final value for the option is used. If an option is not specified, its
associated value is set to an appropriate default, which will provide maximal
error coverage as described below.
.SH OPTIONS
.LP
The following options are available:
.sp
.ne 2
.na
\fB\fB-n\fR \fIname\fR \fR
.ad
.sp .6
.RS 4n
Specify the name of the driver to test. (String)
.RE

.sp
.ne 2
.na
\fB\fB-i\fR\fI instance\fR \fR
.ad
.sp .6
.RS 4n
Test only the specified driver instance (-1 matches all instances of driver).
(Numeric)
.RE

.sp
.ne 2
.na
\fB\fB-P\fR\fI path\fR \fR
.ad
.sp .6
.RS 4n
Specify the full device path of the driver to test. (String)
.RE

.sp
.ne 2
.na
\fB\fB-r\fR \fIreg_number\fR \fR
.ad
.sp .6
.RS 4n
Test only the given register set or DMA handle (-1 matches all register sets
and DMA handles). (Numeric)
.RE

.sp
.ne 2
.na
\fB\fB-a\fR\fI acc_types\fR \fR
.ad
.sp .6
.RS 4n
Only the specified access types will be matched. Valid values for the
\fIacc_types\fR argument are \fBlog\fR, \fBpio\fR, \fBpio_r\fR, \fBpio_w\fR,
\fBdma\fR, \fBdma_r\fR, \fBdma_w\fR and \fBintr\fR. Multiple access types,
separated by spaces, can be specified. The default is to match all hardware
accesses.
.sp
If \fIacc_types\fR is set to \fBlog\fR, logging will match all \fBPIO\fR
accesses, interrupts and DMA accesses to and from areas mapped for both reading
and writing. \fBlog\fR can be combined with other \fIacc_types\fR, in which
case the matching condition for logging will be restricted to the specified
additional \fIacc_types\fR. Note that \fBdma_r\fR will match only DMA handles
mapped for reading only; \fBdma_w\fR will match only DMA handles mapped for
writing only; \fBdma\fR will match only DMA handles mapped for both reading and
writing.
.RE

.sp
.ne 2
.na
\fB\fB-l\fR \fIoffset \fR\fB[\fR\fIlength\fR\fB]\fR\fR
.ad
.sp .6
.RS 4n
Constrain the range of qualifying accesses. The \fIoffset\fR and \fIlength\fR
arguments indicate that any access of the type specified with the \fB-a\fR
option, to the register set or DMA handle specified with the \fB-r\fR option,
lie at least \fIoffset\fR bytes into the register set or DMA handle and at most
\fIoffset\fR + \fIlength\fR bytes into it. The default for \fIoffset\fR is 0.
The default for \fIlength\fR is the maximum value that can be placed in an
\fBoffset_t\fR C data type (see \fBtypes.h\fR). Negative values are converted
into unsigned quantities. Thus, \fB\fR\fBth_define\fR\fB \fR\fB-l\fR 0 \fB-1\fR
is maximal.
.RE

.sp
.ne 2
.na
\fB\fB-c\fR \fIcount\fR\fB[\fR\fIfailcount\fR\fB]\fR \fR
.ad
.sp .6
.RS 4n
Wait for \fIcount\fR number of matching accesses, then apply an operator and
operand (see the \fB-o\fR option) to the next \fIfailcount\fR number of
matching accesses. If the access type (see the \fB-a\fR option) includes
logging, the number of logged accesses is given by \fIcount\fR +
\fIfailcount\fR - 1. The -1 is required because the last access coincides with
the first faulting access.
.sp
Note that access logging may be combined with error injection if
\fIfailcount\fR and \fIoperator\fR are nonzero and if the access type includes
logging and any of the other access types (\fBpio\fR, \fBdma\fR and \fBintr\fR)
See the description of access types in the definition of the \fB-a\fR option,
above.
.sp
When the \fIcount\fR and \fIfailcount\fR fields reach zero, the status of the
errdef is reported to standard output. When all active errdefs created by the
\fBth_define\fR process complete, the process exits. If \fIacc_types\fR
includes \fBlog\fR, \fIcount\fR determines how many accesses to log. If
\fIcount\fR is not specified, a default value is used. If \fIfailcount\fR is
set in this mode, it will simply increase the number of accesses logged by a
further \fIfailcount\fR - 1.
.RE

.sp
.ne 2
.na
\fB\fB-o\fR\fI operator \fR\fB[\fR\fIoperand\fR\fB]\fR \fR
.ad
.sp .6
.RS 4n
For qualifying PIO read and write accesses, the value read from or written to
the hardware is corrupted according to the value of \fIoperator\fR:
.sp
.ne 2
.na
\fB\fBEQ\fR\fR
.ad
.RS 7n
\fIoperand\fR is returned to the driver.
.RE

.sp
.ne 2
.na
\fB\fBOR\fR\fR
.ad
.RS 7n
\fIoperand\fR is bitwise ORed with the real value.
.RE

.sp
.ne 2
.na
\fB\fBAND\fR\fR
.ad
.RS 7n
\fIoperand\fR is bitwise ANDed with the real value.
.RE

.sp
.ne 2
.na
\fB\fBXOR\fR\fR
.ad
.RS 7n
\fIoperand\fR is bitwise XORed with the real value.
.RE

For PIO write accesses, the following operator is allowed:
.sp
.ne 2
.na
\fB\fBNO\fR\fR
.ad
.RS 6n
Simply ignore the driver's attempt to write to the hardware.
.RE

Note that a driver performs PIO via the \fBddi_get\fIX\fR()\fR,
\fBddi_put\fIX\fR()\fR, \fBddi_rep_get\fIX\fR()\fR and
\fBddi_rep_put\fIX\fR()\fR routines (where \fIX\fR is 8, 16, 32 or 64).
Accesses made using \fBddi_get\fIX\fR()\fR and \fBddi_put\fIX\fR()\fR are
treated as a single access, whereas an access made using the
\fBddi_rep_*\fR(9F) routines are broken down into their respective number of
accesses, as given by the \fIrepcount\fR parameter to these DDI calls. If the
access is performed via a DMA handle, \fIoperator\fR and \fIvalue\fR are
applied to every access that comprises the DMA request. If interference with
interrupts has been requested then the operator may take any of the following
values:
.sp
.ne 2
.na
\fB\fBDELAY\fR\fR
.ad
.RS 9n
After \fIcount\fR accesses (see the \fB-c\fR option), delay delivery of the
next \fIfailcount\fR number of interrupts for \fIoperand\fR number of
microseconds.
.RE

.sp
.ne 2
.na
\fB\fBLOSE\fR\fR
.ad
.RS 9n
After \fIcount\fR number of interrupts, fail to deliver the next
\fIfailcount\fR number of real interrupts to the driver.
.RE

.sp
.ne 2
.na
\fB\fBEXTRA\fR\fR
.ad
.RS 9n
After \fIcount\fR number of interrupts, start delivering \fIoperand\fR number
of extra interrupts for the next \fIfailcount\fR number of real interrupts.
.RE

The default value for \fIoperand\fR and \fIoperator\fR is to corrupt the data
access by flipping each bit (XOR with -1).
.RE

.sp
.ne 2
.na
\fB\fB-f\fR \fIacc_chk\fR\fR
.ad
.sp .6
.RS 4n
If the \fIacc_chk\fR parameter is set to 1 or \fBpio\fR, then the driver's
calls to \fBddi_check_acc_handle\fR(9F) return \fBDDI_FAILURE\fR when the
access count goes to 1. If the \fIacc_chk\fR parameter is set to 2 or
\fBdma\fR, then the driver's calls to \fBddi_check_dma_handle\fR(9F) return
\fBDDI_FAILURE\fR when the access count goes to 1.
.RE

.sp
.ne 2
.na
\fB\fB-w\fR \fImax_wait_period\fR\fB [\fR\fIreport_interval\fR\fB]\fR \fR
.ad
.sp .6
.RS 4n
Constrain the period for which an error definition will remain active. The
option applies only to non-logging errdefs. If an error definition remains
active for \fImax_wait_period\fR seconds, the test will be aborted. If
\fIreport_interval\fR is set to a nonzero value, the current status of the
error definition is reported to standard output every \fIreport_interval\fR
seconds. The default value is zero. The status of the errdef is reported in
parsable format (eight fields, each separated by a colon (\fB:\fR) character,
the last of which is a string enclosed by double quotes and the remaining seven
fields are integers):
.sp
\fIft\fR:\fImt\fR:\fIac\fR:\fIfc\fR:\fIchk\fR:\fIec\fR:\fIs\fR:\fI"message"\fR
which are defined as follows:
.sp
.ne 2
.na
\fB\fIft\fR\fR
.ad
.RS 13n
The UTC time when the fault was injected.
.RE

.sp
.ne 2
.na
\fB\fImt\fR\fR
.ad
.RS 13n
The UTC time when the driver reported the fault.
.RE

.sp
.ne 2
.na
\fB\fIac\fR\fR
.ad
.RS 13n
The number of remaining non-faulting accesses.
.RE

.sp
.ne 2
.na
\fB\fIfc\fR\fR
.ad
.RS 13n
The number of remaining faulting accesses.
.RE

.sp
.ne 2
.na
\fB\fIchk\fR\fR
.ad
.RS 13n
The value of the \fIacc_chk\fR field of the errdef.
.RE

.sp
.ne 2
.na
\fB\fIec\fR\fR
.ad
.RS 13n
The number of fault reports issued by the driver against this errdef (\fImt\fR
holds the time of the initial report).
.RE

.sp
.ne 2
.na
\fB\fIs\fR\fR
.ad
.RS 13n
The severity level reported by the driver.
.RE

.sp
.ne 2
.na
\fB\fI"message"\fR\fR
.ad
.RS 13n
Textual reason why the driver has reported a fault.
.RE

.RE

.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.sp .6
.RS 4n
Display the command usage string.
.RE

.sp
.ne 2
.na
\fB\fB-s\fR \fIcollect_time\fR \fR
.ad
.sp .6
.RS 4n
If \fIacc_types\fR is given with the \fB-a\fR option and includes \fBlog\fR,
the errdef will log accesses for \fIcollect_time\fR seconds (the default is to
log until the log becomes full). Note that, if the errdef specification matches
multiple driver handles, multiple logging errdefs are registered with the
\fBbofi\fR driver and logging terminates when all logs become full or when
\fIcollect_time\fR expires or when the associated errdefs are cleared. The
current state of the log can be checked with the \fBth_manage\fR(1M) command,
using the \fBbroadcast\fR parameter. A log can be terminated by running
\fBth_manage\fR(1M) with the \fBclear_errdefs\fR option or by sending a
\fBSIGALRM\fR signal to the \fBth_define\fR process. See \fBalarm\fR(2) for the
semantics of \fBSIGALRM\fR.
.RE

.sp
.ne 2
.na
\fB\fB-p\fR \fIpolicy\fR\fR
.ad
.sp .6
.RS 4n
Applicable when the \fIacc_types\fR option includes \fBlog\fR. The parameter
modifies the policy used for converting from logged accesses to errdefs. All
policies are inclusive:
.RS +4
.TP
.ie t \(bu
.el o
Use \fBrare\fR to bias error definitions toward rare accesses (default).
.RE
.RS +4
.TP
.ie t \(bu
.el o
Use \fBoperator\fR to produce a separate error definition for each operator
type (default).
.RE
.RS +4
.TP
.ie t \(bu
.el o
Use \fBcommon\fR to bias error definitions toward common accesses.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Use \fBmedian\fR to bias error definitions toward median accesses.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Use \fBmaximal\fR to produce multiple error definitions for duplicate accesses.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Use \fBunbiased\fR to create unbiased error definitions.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Use \fBonebyte\fR, \fBtwobyte\fR, \fBfourbyte\fR, or \fBeightbyte\fR to select
errdefs corresponding to 1, 2, 4 or 8 byte accesses (if chosen, the
\fB-x\fR\fBr\fR option is enforced in order to ensure that \fBddi_rep_*()\fR
calls are decomposed into \fBmultiple single accesses\fR).
.RE
.RS +4
.TP
.ie t \(bu
.el o
Use \fBmultibyte\fR to create error definitions for multibyte accesses
performed using \fBddi_rep_get*()\fR and \fBddi_rep_put*()\fR.
.RE
Policies can be combined by adding together these options. See the NOTES
section for further information.
.RE

.sp
.ne 2
.na
\fB\fB-x\fR \fIflags\fR\fR
.ad
.sp .6
.RS 4n
Applicable when the \fIacc_types\fR option includes \fBlog\fR. The \fIflags\fR
parameter modifies the way in which the \fBbofi\fR driver logs accesses. It is
specified as a string containing any combination of the following letters:
.sp
.ne 2
.na
\fB\fBw\fR\fR
.ad
.RS 5n
Continuous logging (that is, the log will wrap when full).
.RE

.sp
.ne 2
.na
\fB\fBt\fR\fR
.ad
.RS 5n
Timestamp each log entry (access times are in seconds).
.RE

.sp
.ne 2
.na
\fB\fBr\fR\fR
.ad
.RS 5n
Log repeated I/O as individual accesses (for example, a \fBddi_rep_get16\fR(9F)
call which has a repcount of \fIN\fR is logged \fIN\fR times with each
transaction logged as size 2 bytes. Without this option, the default logging
behavior is to log this access once only, with a transaction size of twice the
\fIrepcount\fR).
.RE

.RE

.sp
.ne 2
.na
\fB\fB-C\fR \fIcomment_string\fR\fR
.ad
.sp .6
.RS 4n
Applicable when the \fIacc_types\fR option includes \fBlog\fR. It provides a
comment string to be placed in any generated test scripts. The string must be
enclosed in double quotes.
.RE

.sp
.ne 2
.na
\fB\fB-e\fR \fIfixup_script\fR \fB[\fR\fIargs\fR\fB]\fR \fR
.ad
.sp .6
.RS 4n
Applicable when the \fIacc_types\fR option includes \fBlog\fR. The output of a
logging errdefs is to generate a test script for each driver access handle. Use
this option to embed a command in the resulting script before the errors are
injected. The generated test scripts will take an instance offline and bring it
back online before injecting errors in order to bring the instance into a known
fault-free state. The executable \fIfixup_script\fR will be called twice with
the set of optional \fIargs\fR\(em once just before the instance is taken
offline and again after the instance has been brought online. The following
variables are passed into the environment of the called executable:
.sp
.ne 2
.na
\fB\fBDRIVER_PATH\fR\fR
.ad
.RS 22n
Identifies the device path of the instance.
.RE

.sp
.ne 2
.na
\fB\fBDRIVER_INSTANCE\fR\fR
.ad
.RS 22n
Identifies the instance number of the device.
.RE

.sp
.ne 2
.na
\fB\fBDRIVER_UNCONFIGURE\fR\fR
.ad
.RS 22n
Has the value 1 when the instance is about to be taken offline.
.RE

.sp
.ne 2
.na
\fB\fBDRIVER_CONFIGURE\fR\fR
.ad
.RS 22n
Has the value 1 when the instance has just been brought online.
.RE

Typically, the executable ensures that the device under test is in a suitable
state to be taken offline (unconfigured) or in a suitable state for error
injection (for example configured, error free and servicing a workload). A
minimal script for a network driver could be:
.sp
.in +2
.nf
#!/bin/ksh

driver=xyznetdriver
ifnum=$driver$DRIVER_INSTANCE

if [[ $DRIVER_CONFIGURE = 1 ]]; then
	ifconfig $ifnum plumb
	ifconfig $ifnum ...
	ifworkload start $ifnum
elif [[ $DRIVER_UNCONFIGURE = 1 ]]; then
	ifworkload stop $ifnum
	ifconfig $ifnum down
	ifconfig $ifnum unplumb
fi
exit $?
.fi
.in -2
.sp

The \fB-e\fR option must be the last option on the command line.
.RE

.sp
.LP
If the \fB-a\fR \fBlog\fR option is selected but the \fB-e\fR option is not
given, a default script is used. This script repeatedly attempts to detach and
then re-attach the device instance under test.
.SH EXAMPLES
.SS "Examples of Error Definitions"
.LP
\fBth_define -n foo -i 1 -a log\fR
.sp
.LP
Logs all accesses to all handles used by instance 1 of the \fBfoo\fR driver
while running the default workload (attaching and detaching the instance). Then
generates a set of test scripts to inject appropriate errdefs while running
that default workload.
.sp
.LP
\fBth_define -n foo -i 1 -a log pio\fR
.sp
.LP
Logs PIO accesses to each PIO handle used by instance 1 of the \fBfoo\fR driver
while running the default workload (attaching and detaching the instance). Then
generates a set of test scripts to inject appropriate errdefs while running
that default workload.
.sp
.LP
\fBth_define -n foo -i 1 -p onebyte median -e fixup arg -now\fR
.sp
.LP
Logs all accesses to all handles used by instance 1 of the \fBfoo\fR driver
while running the workload defined in the fixup script \fBfixup\fR with
arguments \fBarg\fR and \fB-now\fR. Then generates a set of test scripts to
inject appropriate errdefs while running that workload. The resulting error
definitions are requested to focus upon single byte accesses to locations that
are accessed a \fBmedian\fR number of times with respect to frequency of access
to I/O addresses.
.sp
.LP
\fBth_define -n se -l 0x20 1 -a pio_r -o OR 0x4 -c 10 1000\fR
.sp
.LP
Simulates a stuck serial chip command by forcing 1000 consecutive read accesses
made by any instance of the \fBse\fR driver to its command status register,
thereby returning status busy.
.sp
.LP
\fBth_define -n foo -i 3 -r 1 -a pio_r -c 0 1 -f 1 -o OR 0x100\fR
.sp
.LP
Causes 0x100 to be ORed into the next physical I/O read access from any
register in register set 1 of instance 3 of the \fBfoo\fR driver. Subsequent
calls in the driver to \fBddi_check_acc_handle()\fR return \fBDDI_FAILURE\fR.
.sp
.LP
\fBth_define -n foo -i 3 -r 1 -a pio_r -c 0 1 -o OR 0x0\fR
.sp
.LP
Causes 0x0 to be ORed into the next physical I/O read access from any register
in register set 1 of instance 3 of the \fBfoo\fR driver. This is of course a
no-op.
.sp
.LP
\fBth_define -n foo -i 3 -r 1 -l 0x8100 1 -a pio_r -c 0 10 -o EQ 0x70003\fR
.sp
.LP
Causes the next ten next physical I/O reads from the register at offset 0x8100
in register set 1 of instance 3 of the \fBfoo\fR driver to return 0x70003.
.sp
.LP
\fBth_define -n foo -i 3 -r 1 -l 0x8100 1 -a pio_w -c 100 3 -o AND
0xffffffffffffefff\fR
.sp
.LP
The next 100 physical I/O writes to the register at offset 0x8100 in register
set 1 of instance 3 of the \fBfoo\fR driver take place as normal. However, on
each of the three subsequent accesses, the 0x1000 bit will be cleared.
.sp
.LP
\fBth_define -n foo -i 3 -r 1 -l 0x8100 0x10 -a pio_r -c 0 1 -f 1 -o XOR 7\fR
.sp
.LP
Causes the bottom three bits to have their values toggled for the next physical
I/O read access to registers with offsets in the range 0x8100 to 0x8110 in
register set 1 of instance 3 of the \fBfoo\fR driver. Subsequent calls in the
driver to \fBddi_check_acc_handle()\fR return \fBDDI_FAILURE\fR.
.sp
.LP
\fBth_define -n foo -i 3 -a pio_w -c 0 1 -o NO 0\fR
.sp
.LP
Prevents the next physical I/O write access to any register in any register set
of instance 3 of the \fBfoo\fR driver from going out on the bus.
.sp
.LP
\fBth_define -n foo -i 3 -l 0 8192 -a dma_r -c 0 1 -o OR 7\fR
.sp
.LP
Causes 0x7 to be ORed into each \fBlong long\fR in the first 8192 bytes of the
next DMA read, using any DMA handle for instance 3 of the \fBfoo\fR driver.
.sp
.LP
\fBth_define -n foo -i 3 -r 2 -l 0 8 -a dma_r -c 0 1 -o OR
0x7070707070707070\fR
.sp
.LP
Causes 0x70 to be ORed into each byte of the first \fBlong long\fR of the next
DMA read, using the DMA handle with sequential allocation number 2 for instance
3 of the \fBfoo\fR driver.
.sp
.LP
\fBth_define -n foo -i 3 -l 256 256 -a dma_w -c 0 1 -f 2 -o OR 7\fR
.sp
.LP
Causes 0x7 to be ORed into each \fBlong long\fR in the range from offset 256 to
offset 512 of the next DMA write, using any DMA handle for instance 3 of the
\fBfoo\fR driver. Subsequent calls in the driver to
\fBddi_check_dma_handle()\fR return \fBDDI_FAILURE\fR.
.sp
.LP
\fBth_define -n foo -i 3 -r 0 -l 0 8 -a dma_w -c 100 3 -o AND
0xffffffffffffefff\fR
.sp
.LP
The next 100 DMA writes using the DMA handle with sequential allocation number
0 for instance 3 of the \fBfoo\fR driver take place as normal. However, on each
of the three subsequent accesses, the 0x1000 bit will be cleared in the first
\fBlong long\fR of the transfer.
.sp
.LP
\fBth_define -n foo -i 3 -a intr -c 0 6 -o LOSE 0\fR
.sp
.LP
Causes the next six interrupts for instance 3 of the \fBfoo\fR driver to be
lost.
.sp
.LP
\fBth_define -n foo -i 3 -a intr -c 30 1 -o EXTRA 10\fR
.sp
.LP
When the thirty-first subsequent interrupt for instance 3 of the \fBfoo\fR
driver occurs, a further ten interrupts are also generated.
.sp
.LP
\fBth_define -n foo -i 3 -a intr -c 0 1 -o DELAY 1024\fR
.sp
.LP
Causes the next interrupt for instance 3 of the \fBfoo\fR driver to be delayed
by 1024 microseconds.
.SH NOTES
.LP
The policy option in the \fBth_define\fR \fB-p\fR syntax determines how a set
of logged accesses will be converted into the set of error definitions. Each
logged access will be matched against the chosen policies to determine whether
an error definition should be created based on the access.
.sp
.LP
Any number of policy options can be combined to modify the generated error
definitions.
.SS "Bytewise Policies"
.LP
These select particular I/O transfer sizes. Specifying a byte policy will
exclude other byte policies that have not been chosen. If none of the byte type
policies is selected, all transfer sizes are treated equally. Otherwise, only
those specified transfer sizes will be selected.
.sp
.ne 2
.na
\fB\fBonebyte\fR\fR
.ad
.RS 13n
Create errdefs for one byte accesses (\fBddi_get8()\fR)
.RE

.sp
.ne 2
.na
\fB\fBtwobyte\fR\fR
.ad
.RS 13n
Create errdefs for two byte accesses (\fBddi_get16()\fR)
.RE

.sp
.ne 2
.na
\fB\fBfourbyte\fR\fR
.ad
.RS 13n
Create errdefs for four byte accesses (\fBddi_get32()\fR)
.RE

.sp
.ne 2
.na
\fB\fBeightbyte\fR\fR
.ad
.RS 13n
Create errdefs for eight byte accesses (\fBddi_get64()\fR)
.RE

.sp
.ne 2
.na
\fB\fBmultibyte\fR\fR
.ad
.RS 13n
Create errdefs for repeated byte accesses (\fBddi_rep_get*()\fR)
.RE

.SS "Frequency of Access Policies"
.LP
The frequency of access to a location is determined according to the access
type, location and transfer size (for example, a two-byte read access to
address A is considered distinct from a four-byte read access to address A).
The algorithm is to count the number of accesses (of a given type and size) to
a given location, and find the locations that were most and least accessed (let
\fImaxa\fR and \fImina\fR be the number of times these locations were accessed,
and \fImean\fR the total number of accesses divided by total number of
locations that were accessed). Then a rare access is a location that was
accessed less than
.sp
.LP
\fI(mean - mina) / 3 + mina\fR
.sp
.LP
times. Similarly for the definition of common accesses:
.sp
.LP
\fImaxa - (maxa - mean) / 3\fR
.sp
.LP
A location whose access patterns lies within these cutoffs is regarded as a
location that is accessed with median frequency.
.sp
.ne 2
.na
\fB\fBrare\fR\fR
.ad
.RS 10n
Create errdefs for locations that are rarely accessed.
.RE

.sp
.ne 2
.na
\fB\fBcommon\fR\fR
.ad
.RS 10n
Create errdefs for locations that are commonly accessed.
.RE

.sp
.ne 2
.na
\fB\fBmedian\fR\fR
.ad
.RS 10n
Create errdefs for locations that are accessed a median frequency.
.RE

.SS "Policies for Minimizing errdefs"
.LP
If a transaction is duplicated, either a single or multiple errdefs will be
written to the test scripts, depending upon the following two policies:
.sp
.ne 2
.na
\fB\fBmaximal\fR\fR
.ad
.RS 13n
Create multiple errdefs for locations that are repeatedly accessed.
.RE

.sp
.ne 2
.na
\fB\fBunbiased\fR\fR
.ad
.RS 13n
Create a single errdef for locations that are repeatedly accessed.
.RE

.sp
.ne 2
.na
\fB\fBoperators\fR\fR
.ad
.RS 13n
For each location, a default operator and operand is typically applied. For
maximal test coverage, this default may be modified using the \fBoperators\fR
policy so that a separate errdef is created for each of the possible corruption
operators.
.RE

.SH SEE ALSO
.LP
\fBkill\fR(1), \fBth_manage\fR(1M), \fBalarm\fR(2),
\fBddi_check_acc_handle\fR(9F), \fBddi_check_dma_handle\fR(9F)