"Fossies" - the Fresh Open Source Software Archive

Member "open-fcoe-3.19/libhbalinux/fc_scsi.h" (15 Apr 2015, 14433 Bytes) of archive /linux/misc/open-fcoe-3.19.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "fc_scsi.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 2008, Intel Corporation.
    3  *
    4  * This program is free software; you can redistribute it and/or modify it
    5  * under the terms and conditions of the GNU Lesser General Public License,
    6  * version 2.1, as published by the Free Software Foundation.
    7  *
    8  * This program is distributed in the hope it will be useful, but WITHOUT
    9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
   11  * for more details.
   12  *
   13  * You should have received a copy of the GNU Lesser General Public License
   14  * along with this program; if not, write to the Free Software Foundation, Inc.,
   15  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
   16  *
   17  */
   18 
   19 #ifndef _FC_SCSI_H_
   20 #define _FC_SCSI_H_
   21 
   22 /*
   23  * SCSI definitions.
   24  * From T10 SBC-3.
   25  */
   26 
   27 /*
   28  * Block size.
   29  */
   30 #define SCSI_BSIZE  512
   31 
   32 /*
   33  * Operation codes.
   34  */
   35 enum scsi_op {
   36     SCSI_OP_TEST_UNIT_READY = 0,    /* test unit ready */
   37     SCSI_OP_REQ_SENSE = 0x03,   /* request sense */
   38     SCSI_OP_INQUIRY =   0x12,   /* inquiry */
   39     SCSI_OP_START_STOP =    0x1b,   /* start/stop unit command */
   40     SCSI_OP_READ_CAP10 =    0x25,   /* read capacity (32-bit blk address) */
   41     SCSI_OP_READ10 =    0x28,   /* read (32-bit block address) */
   42     SCSI_OP_WRITE10 =   0x2a,   /* write (32-bit block address) */
   43     SCSI_OP_READ16 =    0x88,   /* read (64-bit block address) */
   44     SCSI_OP_SA_IN_16 =  0x9e,   /* serivice action in (16) */
   45     SCSI_OP_SA_OUT_16 = 0x9f,   /* serivice action out (16) */
   46     SCSI_OP_REPORT_LUNS =   0xa0,   /* report LUNs */
   47 };
   48 
   49 /*
   50  * Name table initializer for SCSI opcodes.
   51  * Please keep this in sync with the enum above.
   52  */
   53 #define SCSI_OP_NAME_INIT {                 \
   54     [SCSI_OP_TEST_UNIT_READY] = "test unit ready",      \
   55     [SCSI_OP_REQ_SENSE] =   "request sense",        \
   56     [SCSI_OP_INQUIRY] = "inquiry",          \
   57     [SCSI_OP_START_STOP] =  "start/stop unit",      \
   58     [SCSI_OP_READ_CAP10] =  "read_cap(10)",         \
   59     [SCSI_OP_READ10] =  "read(10)",         \
   60     [SCSI_OP_WRITE10] = "write(10)",            \
   61     [SCSI_OP_READ16] =  "read(16)",         \
   62     [SCSI_OP_SA_IN_16] =    "sa_in(16)",            \
   63     [SCSI_OP_SA_OUT_16] =   "sa_out(16)",           \
   64     [SCSI_OP_REPORT_LUNS] = "report LUNs",          \
   65 }
   66 
   67 /*
   68  * Service action codes.
   69  * Codes for SCSI_OP_SA_IN_16 and SCSI_OP_SA_OUT_16.
   70  */
   71 enum scsi_sa_in_16 {
   72     SCSI_SA_READ_CAP16 =    0x10,   /* read capacity (16) (IN only) */
   73     SCSI_SA_RW_LONG =   0x11,   /* read/write long (16) */
   74 };
   75 
   76 /*
   77  * Status codes.
   78  */
   79 enum scsi_status {
   80     SCSI_ST_GOOD =      0x00,   /* good */
   81     SCSI_ST_CHECK =     0x02,   /* check condition */
   82     SCSI_ST_COND_MET =  0x04,   /* condition met */
   83     SCSI_ST_BUSY =      0x08,   /* busy */
   84     SCSI_ST_INTMED =    0x10,   /* intermediate */
   85     SCSI_ST_INTMED_MET =    0x14,   /* intermediate, condition met */
   86     SCSI_ST_RESERVED =  0x18,   /* reservation conflict */
   87     SCSI_ST_TS_FULL =   0x28,   /* task set full */
   88     SCSI_ST_ACA_ACTV =  0x30,   /* ACA active */
   89     SCSI_ST_ABORTED =   0x40,   /* task aborted */
   90 };
   91 
   92 /*
   93  * Control byte.
   94  */
   95 #define SCSI_CTL_LINK (1 << 0)  /* Task is linked accross multiple commands */
   96 #define SCSI_CTL_NACA (1 << 2)  /* Normal auto contingent allegiance (ACA)  */
   97 
   98 /*
   99  * Test Unit Ready command.
  100  */
  101 struct scsi_test_unit_ready {
  102     net8_t      tr_op;      /* opcode (0) */
  103     net8_t      _tr_resvd[4];   /* reserved */
  104     net8_t      tr_control; /* control bits */
  105 };
  106 
  107 /*
  108  * Request Sense command.
  109  */
  110 struct scsi_req_sense {
  111     net8_t      rs_op;      /* opcode (0x88) */
  112     net8_t      rs_flags;   /* LSB is descriptor sense bit */
  113     net8_t      _rs_resvd[2];
  114     net8_t      rs_alloc_len;   /* allocated reply length */
  115     net8_t      rs_control; /* control bits */
  116 };
  117 
  118 #define SCSI_REQ_SENSE_LEN  6   /* expected length of struct */
  119 
  120 #define SCSI_SENSE_LEN_MAX  252 /* maximum rs_alloc_len */
  121 
  122 /*
  123  * Start / stop command.
  124  */
  125 struct scsi_start {
  126     net8_t      ss_op;      /* opcode (0x88) */
  127     net8_t      ss_immed;   /* LSB is respond-immediately bit */
  128     net8_t      _ss_resvd[2];
  129     net8_t      ss_flags;   /* power condition, flags */
  130     net8_t      ss_control; /* control bits */
  131 };
  132 
  133 #define SCSI_START_LEN      6   /* expected length of struct */
  134 
  135 /*
  136  * ss_flags:
  137  */
  138 #define SCSI_SSF_START      0x01    /* start */
  139 #define SCSI_SSF_LOEJ       0x02    /* load or eject depending on start */
  140 
  141 #define SCSI_SSF_ACTIVE     0x10    /* set active power condition */
  142 #define SCSI_SSF_IDLE       0x20    /* set idle power condition */
  143 #define SCSI_SSF_STANDBY    0x30    /* set idle power condition */
  144 #define SCSI_SSF_LU_CONTROL 0x70    /* set local control of power */
  145 #define SCSI_SSF_IDLE_0     0xa0    /* force idle timer to zero */
  146 #define SCSI_SSF_STDBY_0    0xb0    /* force standby timer to zero */
  147 
  148 /*
  149  * Read Capacity (10) command.
  150  */
  151 struct scsi_rcap10 {
  152     net8_t      rc_op;      /* opcode */
  153     net8_t      _rc_resvd;
  154     ua_net32_t  rc_lba;     /* logical block address */
  155     net8_t      _rc_resvd1[2];
  156     net8_t      rc_flags;   /* flags (see below) */
  157     net8_t      rc_control; /* control */
  158 };
  159 
  160 #define SCSI_RCAP10_LEN 10      /* expected length of struct */
  161 
  162 #define SCSI_RCAPF_PMI  (1 << 0)    /* rc_flags: partial medium indicator */
  163 
  164 struct scsi_rcap10_resp {
  165     net32_t     rc_lba;     /* logical block address (size) */
  166     net32_t     rc_block_len;   /* block length in bytes */
  167 };
  168 
  169 /*
  170  * Read Capacity (16) command.
  171  */
  172 struct scsi_rcap16 {
  173     net8_t      rc_op;      /* opcode (0x9e) */
  174     net8_t      rc_sa;      /* serivce action sub-opcode (0x10) */
  175     ua_net64_t  rc_lba;     /* logical block address */
  176     ua_net32_t  rc_alloc_len;   /* allocation length */
  177     net8_t      rc_flags;   /* flags (see scsi_rcap10 rc_flags) */
  178     net8_t      rc_control; /* control */
  179 };
  180 
  181 #define SCSI_RCAP16_LEN 16      /* expected length of struct */
  182 
  183 struct scsi_rcap16_resp {
  184     net64_t     rc_lba;     /* logical block address (size) */
  185     net32_t     rc_block_len;   /* block length in bytes */
  186 };
  187 
  188 /*
  189  * Read(10) or write(10) command.
  190  */
  191 struct scsi_rw10 {
  192     net8_t      rd_op;      /* opcode */
  193     net8_t      rd_flags;
  194     ua_net32_t  rd_lba;     /* logical block address */
  195     net8_t      rd_group;   /* group number */
  196     ua_net16_t  rd_len;     /* transfer length */
  197     net8_t      rd_control; /* control */
  198 };
  199 
  200 #define SCSI_RW10_LEN   10      /* expected length of struct */
  201 
  202 /*
  203  * Read(16) or write(16) command.
  204  */
  205 struct scsi_rw16 {
  206     net8_t      rd_op;      /* opcode */
  207     net8_t      rd_flags;
  208     ua_net64_t  rd_lba;     /* logical block address */
  209     ua_net32_t  rd_len;     /* transfer length */
  210     net8_t      rd_group;   /* group number */
  211     net8_t      rd_control; /* control */
  212 };
  213 
  214 #define SCSI_RW16_LEN   16      /* expected length of struct */
  215 
  216 /*
  217  * Flags:
  218  */
  219 #define RDF_RWPROT_BIT  5       /* shift for RD/WRPROTECT field */
  220 #define RDF_DPO     0x10        /* disable page out - cache advisory */
  221 #define RDF_FUA     0x08        /* force unit access */
  222 #define RDF_FUA_NV  0x02        /* force unit access non-volatile */
  223 
  224 /*
  225  * REPORT LUNS.
  226  */
  227 struct scsi_report_luns {
  228     net8_t      rl_op;      /* opcode (0x88) */
  229     net8_t      _rl_resvd1;
  230     net8_t      rl_sel_report;  /* select report field */
  231     net8_t      _rl_resvd2[3];
  232     ua_net32_t  rl_alloc_len;   /* allocated length for reply */
  233     net8_t      _rl_resvd3;
  234     net8_t      rl_control; /* control */
  235 };
  236 
  237 #define SCSI_REPORT_LUNS_LEN 12 /* expected length of struct */
  238 
  239 /*
  240  * rl_sel_report.
  241  */
  242 #define SCSI_RLS_WKL    1       /* req. well known LUNs only */
  243 #define SCSI_RLS_ITL    2       /* req. LUNs accessible to I_T nexus */
  244 
  245 /*
  246  * REPORT LUNS repsonse.
  247  */
  248 struct scsi_report_luns_resp {
  249     net32_t     rl_len;     /* list length in bytes */
  250     net8_t      _rl_resvd[4];
  251     net64_t     rl_lun[1];  /* list of LUNs */
  252 };
  253 
  254 /*
  255  * Inquiry.
  256  */
  257 struct scsi_inquiry {
  258     net8_t      in_op;      /* opcode (0x12) */
  259     net8_t      in_flags;   /* LSB is EVPD */
  260     net8_t      in_page_code;   /* page code */
  261 
  262     /*
  263      * Note that the in_alloc_len field was widened to 16-bits between
  264      * SPC-2 and SPC-3, but some devices will ignore the upper 8 bits.
  265      * It makes sense to use lengths less than 256 where possible.
  266      */
  267     ua_net16_t  in_alloc_len;   /* allocated length for reply */
  268     net8_t      in_control; /* control */
  269 };
  270 
  271 #define SCSI_INQUIRY_LEN    6   /* expected length of struct */
  272 
  273 /*
  274  * Inquiry in_flags.
  275  */
  276 #define SCSI_INQF_EVPD  (1 << 0)    /* request vital product data (VPD) page */
  277 
  278 /*
  279  * SCSI Inquiry VPD Page Codes.
  280  */
  281 enum scsi_inq_page {
  282     SCSI_INQP_SUPP_VPD =    0,  /* supported VPD list */
  283     SCSI_INQP_UNIT_SN = 0x80,   /* Unit serial number */
  284     SCSI_INQP_DEV_ID =  0x83,   /* Device Identification */
  285     SCSI_INQP_SW_IF_ID =    0x84,   /* Software Interface Identification */
  286     SCSI_INQP_MGMT_ADDR =   0x85,   /* management network addresses */
  287     SCSI_INQP_EXT_DATA =    0x86,   /* Extended Inquiry Data */
  288     SCSI_INQP_MD_PAGE_POL = 0x87,   /* Mode Page Policy */
  289     SCSI_INQP_SCSI_PORTS =  0x88,   /* SCSI Ports */
  290 };
  291 
  292 /*
  293  * Inquiry - standard data format.
  294  */
  295 struct scsi_inquiry_std {
  296     net8_t      is_periph;  /* peripheral qualifier and type */
  297     net8_t      is_flags1;  /* flags (see below) */
  298     net8_t      is_version;
  299     net8_t      is_flags2;  /* flags / response data format */
  300 
  301     net8_t      is_addl_len;    /* additional length */
  302     net8_t      is_flags3;  /* flags (see below) */
  303     net8_t      is_flags4;
  304     net8_t      is_flags5;
  305 
  306     char        is_vendor_id[8]; /* ASCII T10 vendor identification */
  307     char        is_product[16]; /* ASCII product identification */
  308     char        is_rev_level[4]; /* ASCII revision level */
  309     char        is_vendor_spec[56 - 36]; /* vendor specific data */
  310 
  311     net8_t      is_clock_flags; /* clocking, QAS, IUS flags */
  312     net8_t      is_resvd;
  313     net16_t     is_vers_desc[8]; /* version descriptors */
  314 
  315     /* followed by vendor-specific fields */
  316 };
  317 
  318 #define SCSI_INQUIRY_STD_LEN    74  /* expected length of structure */
  319 
  320 /*
  321  * Peripheral qualifier in is_periph field.
  322  */
  323 #define SCSI_INQ_PQUAL_MASK 0xe0    /* mask for peripheral qualifier */
  324 #define SCSI_INQ_PTYPE_MASK 0x1f    /* mask for peripheral type */
  325 
  326 enum scsi_inq_pqual {
  327     SCSI_PQUAL_ATT =    0,      /* peripheral attached */
  328     SCSI_PQUAL_DET =    (1 << 5),   /* peripheral detached */
  329     SCSI_PQUAL_NC =     (3 << 5),   /* not capable of attachment */
  330 };
  331 
  332 enum scsi_inq_ptype {
  333     SCSI_PTYPE_DIR =    0x00,   /* direct acccess block device */
  334     SCSI_PTYPE_SEQ =    0x01,   /* sequential acccess block device */
  335     SCSI_PTYPE_PRINT =  0x02,   /* printer device (obsolete) */
  336     SCSI_PTYPE_PROC =   0x03,   /* processor device */
  337     SCSI_PTYPE_WORM =   0x04,   /* write-once device */
  338     SCSI_PTYPE_CDDVD =  0x05,   /* CD/DVD device */
  339     SCSI_PTYPE_SCANNER =    0x06,   /* scanner device (obsolete) */
  340     SCSI_PTYPE_OPTMEM = 0x07,   /* optical memory device */
  341     SCSI_PTYPE_CHANGER =    0x08,   /* medium changer device */
  342     SCSI_PTYPE_RAID =   0x0c,   /* storage array controoler (RAID) */
  343     SCSI_PTYPE_SES =    0x0d,   /* enclosure services device */
  344     SCSI_PTYPE_SDIR =   0x0e,   /* simplified direct acccess */
  345     SCSI_PTYPE_OCRW =   0x0f,   /* optical card reader/writer */
  346     SCSI_PTYPE_BCC =    0x10,   /* bridge controller commands */
  347     SCSI_PTYPE_OSD =    0x11,   /* object-based storage device */
  348     SCSI_PTYPE_ADC =    0x12,   /* automation/drive interface */
  349     SCSI_PTYPE_UNK =    0x1f,   /* unknown or no device type */
  350 };
  351 
  352 /*
  353  * is_flags[1-5] in the standard inquiry response.
  354  */
  355 #define SCSI_INQF1_RMB      (1 << 7) /* removable medium */
  356 
  357 #define SCSI_INQF2_NACA     (1 << 5) /* normal ACA */
  358 #define SCSI_INQF2_HISUP    (1 << 4) /* hierarchical LUN support */
  359 #define SCSI_INQF2_RDF_MASK 0xf /* response data format mask */
  360 #define SCSI_INQF2_RDF      2   /* this response data format */
  361 
  362 #define SCSI_INQF3_PROTECT  (1 << 0) /* supports protection information */
  363 #define SCSI_INQF3_3PC      (1 << 3) /* supports third-party copy */
  364 #define SCSI_INQF3_TPGS_IMPL    (1 << 4) /* supports REPORT TARGET PORT GRPS */
  365 #define SCSI_INQF3_TPGS_EXPL    (1 << 5) /* supports SET TARGET PORT GROUPS */
  366 #define SCSI_INQF3_ACC      (1 << 6) /* access controls coordinator */
  367 #define SCSI_INQF3_SCCS (1 << 7)    /* SCC supported (see SCC-2) */
  368 
  369 #define SCSI_INQF4_ADDR16   (1 << 0) /* parallel-SCSI only  */
  370 #define SCSI_INQF4_MULTIP   (1 << 4) /* multiport compliant */
  371 #define SCSI_INQF4_ENCSERV  (1 << 6) /* embedded enclosure services */
  372 #define SCSI_INQF4_BQUE     (1 << 7) /* basic task management model */
  373 
  374 #define SCSI_INQF5_CMDQUE   (1 << 1) /* full task management model */
  375 #define SCSI_INQF5_LINKED   (1 << 3) /* linked commands supported */
  376 #define SCSI_INQF5_SYNC     (1 << 4)    /* parallel-SCSI only  */
  377 #define SCSI_INQF5_WBUS16   (1 << 5)    /* parallel-SCSI only  */
  378 
  379 /*
  380  * Inquiry - page 0 - supported VPD pages.
  381  */
  382 struct scsi_inquiry_supp_vpd {
  383     net8_t      is_periph;  /* peripheral qualifier and type */
  384     net8_t      is_page_code;   /* page code (0x00) */
  385     net8_t      _is_resvd;  /* reserved */
  386     net8_t      is_list_len;    /* length of page list */
  387     net8_t      is_page_list[1]; /* supported page list - var. length */
  388 };
  389 
  390 /*
  391  * Inquiry - page 0x80 - unit serial number VPD page.
  392  */
  393 struct scsi_inquiry_unit_sn {
  394     net8_t      is_periph;  /* peripheral qualifier and type */
  395     net8_t      is_page_code;   /* page code (0x80) */
  396     net8_t      _is_resvd;  /* reserved */
  397     net8_t      is_page_len;    /* length of serial number */
  398     net8_t      is_serial[1];   /* ASCII serial number - var. length */
  399 };
  400 
  401 /*
  402  * Inquiry - page 0x83 - device identification.
  403  */
  404 struct scsi_inquiry_dev_id {
  405     net8_t      is_periph;  /* peripheral qualifier and type */
  406     net8_t      is_page_code;   /* page code (0x83) */
  407     net16_t     is_page_len;    /* len of designation descriptor list */
  408 
  409     /* descriptor list follows */
  410 };
  411 
  412 /*
  413  * Inquiry - page 0x83 designation descriptor list entry.
  414  */
  415 struct scsi_inquiry_desc {
  416     net8_t      id_proto_code;  /* protocol identifier and code set */
  417     net8_t      id_type_flags;  /* designator type and flags */
  418     net8_t      _id_resvd;  /* reserved */
  419     net8_t      id_designator_len; /* designator length */
  420     net8_t      id_designator[1]; /* designator - variable length */
  421 };
  422 
  423 /*
  424  * id_proto_code field.
  425  */
  426 #define SCSI_INQ_CODE_MASK  0xf /* mask for code set in id_proto_code */
  427 
  428 enum scsi_inq_code_set {
  429     SCSI_CS_BIN =   1,  /* designator contains binary values */
  430     SCSI_CS_ASCII = 2,  /* designator contains printable ASCII */
  431     SCSI_CS_UTF8 =  3,  /* designator contains UTF-8 codes */
  432 };
  433 
  434 /*
  435  * id_type_flags field.
  436  */
  437 #define SCSI_INQT_PIV       (1 << 7) /* protocol identifier field valid */
  438 #define SCSI_INQT_ASSOC_BIT 4   /* shift count for association */
  439 #define SCSI_INQT_ASSOC_MASK    0x3 /* mask for association */
  440 #define SCSI_INQT_TYPE_MASK 0xf /* mask for designator type */
  441 
  442 enum scsi_inq_assoc {
  443     SCSI_ASSOC_LUN =    0,  /* designator is for the LUN */
  444     SCSI_ASSOC_PORT =   1,  /* designator is for the target port */
  445     SCSI_ASSOC_TARG =   2,  /* designator is for the target dev */
  446 };
  447 
  448 /*
  449  * Designator type field values.
  450  */
  451 enum scsi_inq_dtype {
  452     SCSI_DTYPE_VENDOR = 0,  /* vendor specific */
  453     SCSI_DTYPE_T10_VENDOR = 1,  /* T10 vendor-ID based */
  454     SCSI_DTYPE_EUI_64 = 2,  /* EUI-64 based */
  455     SCSI_DTYPE_NAA =    3,  /* network address authority (WWN) */
  456     SCSI_DTYPE_RTPI =   4,  /* relative target port id */
  457     SCSI_DTYPE_TPORTG = 5,  /* target port group */
  458     SCSI_DTYPE_LPORTG = 6,  /* logical port group */
  459     SCSI_DTYPE_MD5_LUN =    7,  /* MD5 LU identifier */
  460     SCSI_DTYPE_SCSI_NAME =  8,  /* SCSI name string */
  461 };
  462 
  463 #endif /* _FC_SCSI_H_ */