xref: /freebsd/sys/cam/ctl/ctl_ser_table.c (revision f2a20b166a1efde194b39d8fae5841b843819f4d)
1130f4520SKenneth D. Merry /*-
2130f4520SKenneth D. Merry  * Copyright (c) 2003 Silicon Graphics International Corp.
3130f4520SKenneth D. Merry  * All rights reserved.
4130f4520SKenneth D. Merry  *
5130f4520SKenneth D. Merry  * Redistribution and use in source and binary forms, with or without
6130f4520SKenneth D. Merry  * modification, are permitted provided that the following conditions
7130f4520SKenneth D. Merry  * are met:
8130f4520SKenneth D. Merry  * 1. Redistributions of source code must retain the above copyright
9130f4520SKenneth D. Merry  *    notice, this list of conditions, and the following disclaimer,
10130f4520SKenneth D. Merry  *    without modification.
11130f4520SKenneth D. Merry  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12130f4520SKenneth D. Merry  *    substantially similar to the "NO WARRANTY" disclaimer below
13130f4520SKenneth D. Merry  *    ("Disclaimer") and any redistribution must be conditioned upon
14130f4520SKenneth D. Merry  *    including a substantially similar Disclaimer requirement for further
15130f4520SKenneth D. Merry  *    binary redistribution.
16130f4520SKenneth D. Merry  *
17130f4520SKenneth D. Merry  * NO WARRANTY
18130f4520SKenneth D. Merry  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19130f4520SKenneth D. Merry  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20130f4520SKenneth D. Merry  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21130f4520SKenneth D. Merry  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22130f4520SKenneth D. Merry  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23130f4520SKenneth D. Merry  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24130f4520SKenneth D. Merry  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25130f4520SKenneth D. Merry  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26130f4520SKenneth D. Merry  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27130f4520SKenneth D. Merry  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28130f4520SKenneth D. Merry  * POSSIBILITY OF SUCH DAMAGES.
29130f4520SKenneth D. Merry  *
30130f4520SKenneth D. Merry  * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_ser_table.c#1 $
31130f4520SKenneth D. Merry  * $FreeBSD$
32130f4520SKenneth D. Merry  */
33130f4520SKenneth D. Merry 
34130f4520SKenneth D. Merry /*
35130f4520SKenneth D. Merry  * CAM Target Layer command serialization table.
36130f4520SKenneth D. Merry  *
37130f4520SKenneth D. Merry  * Author: Kim Le
38130f4520SKenneth D. Merry  */
39130f4520SKenneth D. Merry 
40130f4520SKenneth D. Merry /****************************************************************************/
41130f4520SKenneth D. Merry /* TABLE       ctlSerTbl                                                    */
42130f4520SKenneth D. Merry /*                                                                          */
43130f4520SKenneth D. Merry /*  The matrix which drives the serialization algorithm. The major index    */
44130f4520SKenneth D. Merry /*  (the first) into this table is the command being checked and the minor  */
45130f4520SKenneth D. Merry /*  index is the command against which the first command is being checked.  */
46130f4520SKenneth D. Merry /*  i.e., the major index (row) command is ahead of the minor index command */
47130f4520SKenneth D. Merry /*  (column) in the queue.  This allows the code to optimize by capturing   */
48130f4520SKenneth D. Merry /*  the result of the first indexing operation into a pointer.              */
49130f4520SKenneth D. Merry /*                                                                          */
50130f4520SKenneth D. Merry /*  Whenever a new value is added to the IDX_T type, this matrix must be    */
51130f4520SKenneth D. Merry /*  expanded by one row AND one column -- Because of this, some effort      */
52130f4520SKenneth D. Merry /*  should be made to re-use the indexes whenever possible.                 */
53130f4520SKenneth D. Merry /*                                                                          */
54130f4520SKenneth D. Merry /****************************************************************************/
55130f4520SKenneth D. Merry 
56130f4520SKenneth D. Merry #define	sK	CTL_SER_SKIP		/* Skip */
57ab55ae25SAlexander Motin #define	pS	CTL_SER_PASS		/* Pass */
58130f4520SKenneth D. Merry #define	bK	CTL_SER_BLOCK		/* Blocked */
59ab55ae25SAlexander Motin #define	bO	CTL_SER_BLOCKOPT	/* Optional block */
60130f4520SKenneth D. Merry #define	xT	CTL_SER_EXTENT		/* Extent check */
61ab55ae25SAlexander Motin #define	xO	CTL_SER_EXTENTOPT	/* Optional extent check */
62bfbfc4a3SAlexander Motin #define	xS	CTL_SER_EXTENTSEQ	/* Sequential extent check */
63130f4520SKenneth D. Merry 
64130f4520SKenneth D. Merry static ctl_serialize_action
65130f4520SKenneth D. Merry ctl_serialize_table[CTL_SERIDX_COUNT][CTL_SERIDX_COUNT] = {
66*f2a20b16SAlexander Motin /**>IDX_ :: 2nd:TUR RD  WRT UNM SYN MDSN MDSL RQSN INQ RDCP RES LSNS FMT STR*/
67*f2a20b16SAlexander Motin /*TUR     */{   pS, pS, pS, pS, pS, bK,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
68*f2a20b16SAlexander Motin /*READ    */{   pS, xS, xT, bO, pS, bK,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
69*f2a20b16SAlexander Motin /*WRITE   */{   pS, xT, xT, bO, bO, bK,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
70*f2a20b16SAlexander Motin /*UNMAP   */{   pS, xO, xO, pS, pS, bK,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
71*f2a20b16SAlexander Motin /*SYNC    */{   pS, pS, pS, pS, pS, bK,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
72*f2a20b16SAlexander Motin /*MD_SNS  */{   bK, bK, bK, bK, bK, pS,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
73*f2a20b16SAlexander Motin /*MD_SEL  */{   bK, bK, bK, bK, bK, bK,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
74*f2a20b16SAlexander Motin /*RQ_SNS  */{   pS, pS, pS, pS, pS, pS,  pS,  bK,  pS, pS,  bK, pS,  bK, bK},
75*f2a20b16SAlexander Motin /*INQ     */{   pS, pS, pS, pS, pS, pS,  pS,  bK,  pS, pS,  pS, pS,  bK, bK},
76*f2a20b16SAlexander Motin /*RD_CAP  */{   pS, pS, pS, pS, pS, pS,  pS,  bK,  pS, pS,  pS, pS,  bK, pS},
77*f2a20b16SAlexander Motin /*RES     */{   bK, bK, bK, bK, bK, bK,  bK,  bK,  pS, bK,  bK, bK,  bK, bK},
78*f2a20b16SAlexander Motin /*LOG_SNS */{   pS, pS, pS, pS, pS, pS,  bK,  bK,  pS, pS,  bK, pS,  bK, bK},
79*f2a20b16SAlexander Motin /*FORMAT  */{   pS, bK, bK, bK, bK, bK,  bK,  pS,  pS, bK,  bK, bK,  bK, bK},
80*f2a20b16SAlexander Motin /*START   */{   bK, bK, bK, bK, bK, bK,  bK,  bK,  pS, bK,  bK, bK,  bK, bK},
81130f4520SKenneth D. Merry };
82130f4520SKenneth D. Merry 
83