The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/hyperv/storvsc/hv_vstorage.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2009-2012,2017 Microsoft Corp.
    5  * Copyright (c) 2012 NetApp Inc.
    6  * Copyright (c) 2012 Citrix Inc.
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice unmodified, this list of conditions, and the following
   14  *    disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   29  *
   30  * $FreeBSD$
   31  */
   32 
   33 #ifndef __HV_VSTORAGE_H__
   34 #define __HV_VSTORAGE_H__
   35 
   36 /*
   37  * Major/minor macros.  Minor version is in LSB, meaning that earlier flat
   38  * version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1).
   39  */
   40 
   41 #define VMSTOR_PROTOCOL_MAJOR(VERSION_)         (((VERSION_) >> 8) & 0xff)
   42 #define VMSTOR_PROTOCOL_MINOR(VERSION_)         (((VERSION_)     ) & 0xff)
   43 #define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \
   44                                                  (((MINOR_) & 0xff)     ))
   45 
   46 #define VMSTOR_PROTOCOL_VERSION_WIN6       VMSTOR_PROTOCOL_VERSION(2, 0)
   47 #define VMSTOR_PROTOCOL_VERSION_WIN7       VMSTOR_PROTOCOL_VERSION(4, 2)
   48 #define VMSTOR_PROTOCOL_VERSION_WIN8       VMSTOR_PROTOCOL_VERSION(5, 1)
   49 #define VMSTOR_PROTOCOL_VERSION_WIN8_1     VMSTOR_PROTOCOL_VERSION(6, 0)
   50 #define VMSTOR_PROTOCOL_VERSION_WIN10      VMSTOR_PROTOCOL_VERSION(6, 2)
   51 /*
   52  * Invalid version.
   53  */
   54 #define VMSTOR_INVALID_PROTOCOL_VERSION  -1
   55 
   56 /*
   57  * Version history:
   58  * V1 Beta                    0.1
   59  * V1 RC < 2008/1/31          1.0
   60  * V1 RC > 2008/1/31          2.0
   61  * Win7: 4.2
   62  * Win8: 5.1
   63  */
   64 
   65 #define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(5, 1)
   66 
   67 /**
   68  *  Packet structure ops describing virtual storage requests.
   69  */
   70 enum vstor_packet_ops {
   71         VSTOR_OPERATION_COMPLETEIO            = 1,
   72         VSTOR_OPERATION_REMOVEDEVICE          = 2,
   73         VSTOR_OPERATION_EXECUTESRB            = 3,
   74         VSTOR_OPERATION_RESETLUN              = 4,
   75         VSTOR_OPERATION_RESETADAPTER          = 5,
   76         VSTOR_OPERATION_RESETBUS              = 6,
   77         VSTOR_OPERATION_BEGININITIALIZATION   = 7,
   78         VSTOR_OPERATION_ENDINITIALIZATION     = 8,
   79         VSTOR_OPERATION_QUERYPROTOCOLVERSION  = 9,
   80         VSTOR_OPERATION_QUERYPROPERTIES       = 10,
   81         VSTOR_OPERATION_ENUMERATE_BUS         = 11,
   82         VSTOR_OPERATION_FCHBA_DATA            = 12,
   83         VSTOR_OPERATION_CREATE_MULTI_CHANNELS = 13,
   84         VSTOR_OPERATION_MAXIMUM               = 13
   85 };
   86 
   87 
   88 /*
   89  *  Platform neutral description of a scsi request -
   90  *  this remains the same across the write regardless of 32/64 bit
   91  *  note: it's patterned off the Windows DDK SCSI_PASS_THROUGH structure
   92  */
   93 
   94 #define CDB16GENERIC_LENGTH                     0x10
   95 #define SENSE_BUFFER_SIZE                       0x14
   96 #define MAX_DATA_BUFFER_LENGTH_WITH_PADDING     0x14
   97 
   98 #define POST_WIN7_STORVSC_SENSE_BUFFER_SIZE     0x14
   99 #define PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE      0x12
  100 
  101 
  102 struct vmscsi_win8_extension {
  103         /*
  104          * The following were added in Windows 8
  105          */
  106         uint16_t reserve;
  107         uint8_t  queue_tag;
  108         uint8_t  queue_action;
  109         uint32_t srb_flags;
  110         uint32_t time_out_value;
  111         uint32_t queue_sort_ey;
  112 } __packed;
  113 
  114 struct vmscsi_req {
  115         uint16_t length;
  116         uint8_t  srb_status;
  117         uint8_t  scsi_status;
  118 
  119         /* HBA number, set to the order number detected by initiator. */
  120         uint8_t  port;
  121         /* SCSI bus number or bus_id, different from CAM's path_id. */
  122         uint8_t  path_id;
  123 
  124         uint8_t  target_id;
  125         uint8_t  lun;
  126 
  127         uint8_t  cdb_len;
  128         uint8_t  sense_info_len;
  129         uint8_t  data_in;
  130         uint8_t  reserved;
  131 
  132         uint32_t transfer_len;
  133 
  134         union {
  135             uint8_t cdb[CDB16GENERIC_LENGTH];
  136 
  137             uint8_t sense_data[SENSE_BUFFER_SIZE];
  138 
  139             uint8_t reserved_array[MAX_DATA_BUFFER_LENGTH_WITH_PADDING];
  140         } u;
  141 
  142         /*
  143          * The following was added in win8.
  144          */
  145         struct vmscsi_win8_extension win8_extension;
  146 
  147 } __packed;
  148 
  149 /**
  150  *  This structure is sent during the initialization phase to get the different
  151  *  properties of the channel.
  152  */
  153 
  154 struct vmstor_chan_props {
  155         uint16_t proto_ver;
  156         uint8_t  path_id;
  157         uint8_t  target_id;
  158 
  159         uint16_t max_channel_cnt;
  160 
  161         /**
  162          * Note: port number is only really known on the client side
  163          */
  164         uint16_t port;
  165         uint32_t flags;
  166         uint32_t max_transfer_bytes;
  167 
  168         /**
  169          *  This id is unique for each channel and will correspond with
  170          *  vendor specific data in the inquiry_ata
  171          */
  172         uint64_t unique_id;
  173 
  174 } __packed;
  175 
  176 /**
  177  *  This structure is sent during the storage protocol negotiations.
  178  */
  179 
  180 struct vmstor_proto_ver
  181 {
  182         /**
  183          * Major (MSW) and minor (LSW) version numbers.
  184          */
  185         uint16_t major_minor;
  186 
  187         uint16_t revision;                      /* always zero */
  188 } __packed;
  189 
  190 /**
  191  * Channel Property Flags
  192  */
  193 
  194 #define STORAGE_CHANNEL_REMOVABLE_FLAG                  0x1
  195 #define STORAGE_CHANNEL_EMULATED_IDE_FLAG               0x2
  196 
  197 
  198 struct vstor_packet {
  199         /**
  200          * Requested operation type
  201          */
  202         enum vstor_packet_ops operation;
  203 
  204         /*
  205          * Flags - see below for values
  206          */
  207         uint32_t flags;
  208 
  209         /**
  210          * Status of the request returned from the server side.
  211          */
  212         uint32_t status;
  213 
  214         union
  215         {
  216             /**
  217              * Structure used to forward SCSI commands from the client to
  218              * the server.
  219              */
  220             struct vmscsi_req vm_srb;
  221 
  222             /**
  223              * Structure used to query channel properties.
  224              */
  225             struct vmstor_chan_props chan_props;
  226 
  227             /**
  228              * Used during version negotiations.
  229              */
  230             struct vmstor_proto_ver version;
  231 
  232             /**
  233              * Number of multichannels to create
  234              */
  235             uint16_t multi_channels_cnt;
  236         } u;
  237 
  238 } __packed;
  239 
  240 
  241 /**
  242  * SRB (SCSI Request Block) Status Codes
  243  */
  244 #define SRB_STATUS_PENDING                  0x00
  245 #define SRB_STATUS_SUCCESS                  0x01
  246 #define SRB_STATUS_ABORTED                  0x02
  247 #define SRB_STATUS_ABORT_FAILED             0x03
  248 #define SRB_STATUS_ERROR                    0x04
  249 #define SRB_STATUS_BUSY                     0x05
  250 #define SRB_STATUS_INVALID_REQUEST          0x06
  251 #define SRB_STATUS_INVALID_PATH_ID          0x07
  252 #define SRB_STATUS_NO_DEVICE                0x08
  253 #define SRB_STATUS_TIMEOUT                  0x09
  254 #define SRB_STATUS_SELECTION_TIMEOUT        0x0A
  255 #define SRB_STATUS_COMMAND_TIMEOUT          0x0B
  256 #define SRB_STATUS_MESSAGE_REJECTED         0x0D
  257 #define SRB_STATUS_BUS_RESET                0x0E
  258 #define SRB_STATUS_PARITY_ERROR             0x0F
  259 #define SRB_STATUS_REQUEST_SENSE_FAILED     0x10
  260 #define SRB_STATUS_NO_HBA                   0x11
  261 #define SRB_STATUS_DATA_OVERRUN             0x12
  262 #define SRB_STATUS_UNEXPECTED_BUS_FREE      0x13
  263 #define SRB_STATUS_PHASE_SEQUENCE_FAILURE   0x14
  264 #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH     0x15
  265 #define SRB_STATUS_REQUEST_FLUSHED          0x16
  266 #define SRB_STATUS_INVALID_LUN              0x20
  267 #define SRB_STATUS_INVALID_TARGET_ID        0x21
  268 #define SRB_STATUS_BAD_FUNCTION             0x22
  269 #define SRB_STATUS_ERROR_RECOVERY           0x23
  270 #define SRB_STATUS_NOT_POWERED              0x24
  271 #define SRB_STATUS_LINK_DOWN                0x25
  272 /**
  273  * SRB Status Masks (can be combined with above status codes)
  274  */
  275 #define SRB_STATUS_QUEUE_FROZEN         0x40
  276 #define SRB_STATUS_AUTOSENSE_VALID      0x80
  277 
  278 #define SRB_STATUS(status)      \
  279         ((status) & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN))
  280 /*
  281  * SRB Flag Bits
  282  */
  283 
  284 #define SRB_FLAGS_QUEUE_ACTION_ENABLE           0x00000002
  285 #define SRB_FLAGS_DISABLE_DISCONNECT            0x00000004
  286 #define SRB_FLAGS_DISABLE_SYNCH_TRANSFER        0x00000008
  287 #define SRB_FLAGS_BYPASS_FROZEN_QUEUE           0x00000010
  288 #define SRB_FLAGS_DISABLE_AUTOSENSE             0x00000020
  289 #define SRB_FLAGS_DATA_IN                       0x00000040
  290 #define SRB_FLAGS_DATA_OUT                      0x00000080
  291 #define SRB_FLAGS_NO_DATA_TRANSFER              0x00000000
  292 #define SRB_FLAGS_UNSPECIFIED_DIRECTION (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
  293 #define SRB_FLAGS_NO_QUEUE_FREEZE               0x00000100
  294 #define SRB_FLAGS_ADAPTER_CACHE_ENABLE          0x00000200
  295 #define SRB_FLAGS_FREE_SENSE_BUFFER             0x00000400
  296 /**
  297  *  Packet flags
  298  */
  299 
  300 /**
  301  *  This flag indicates that the server should send back a completion for this
  302  *  packet.
  303  */
  304 #define REQUEST_COMPLETION_FLAG 0x1
  305 
  306 /**
  307  *  This is the set of flags that the vsc can set in any packets it sends
  308  */
  309 #define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG)
  310 
  311 #endif /* __HV_VSTORAGE_H__ */

Cache object: 9a94a03527fd74f9267572d6a40a935f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.