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/xen/interface/io/blkif.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  * blkif.h
    3  *
    4  * Unified block-device I/O interface for Xen guest OSes.
    5  *
    6  * Permission is hereby granted, free of charge, to any person obtaining a copy
    7  * of this software and associated documentation files (the "Software"), to
    8  * deal in the Software without restriction, including without limitation the
    9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   10  * sell copies of the Software, and to permit persons to whom the Software is
   11  * furnished to do so, subject to the following conditions:
   12  *
   13  * The above copyright notice and this permission notice shall be included in
   14  * all copies or substantial portions of the Software.
   15  *
   16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   22  * DEALINGS IN THE SOFTWARE.
   23  *
   24  * Copyright (c) 2003-2004, Keir Fraser
   25  * Copyright (c) 2012, Spectra Logic Corporation
   26  */
   27 
   28 #ifndef __XEN_PUBLIC_IO_BLKIF_H__
   29 #define __XEN_PUBLIC_IO_BLKIF_H__
   30 
   31 #include "ring.h"
   32 #include "../grant_table.h"
   33 
   34 /*
   35  * Front->back notifications: When enqueuing a new request, sending a
   36  * notification can be made conditional on req_event (i.e., the generic
   37  * hold-off mechanism provided by the ring macros). Backends must set
   38  * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
   39  *
   40  * Back->front notifications: When enqueuing a new response, sending a
   41  * notification can be made conditional on rsp_event (i.e., the generic
   42  * hold-off mechanism provided by the ring macros). Frontends must set
   43  * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
   44  */
   45 
   46 #ifndef blkif_vdev_t
   47 #define blkif_vdev_t   uint16_t
   48 #endif
   49 #define blkif_sector_t uint64_t
   50 
   51 /*
   52  * Feature and Parameter Negotiation
   53  * =================================
   54  * The two halves of a Xen block driver utilize nodes within the XenStore to
   55  * communicate capabilities and to negotiate operating parameters.  This
   56  * section enumerates these nodes which reside in the respective front and
   57  * backend portions of the XenStore, following the XenBus convention.
   58  *
   59  * All data in the XenStore is stored as strings.  Nodes specifying numeric
   60  * values are encoded in decimal.  Integer value ranges listed below are
   61  * expressed as fixed sized integer types capable of storing the conversion
   62  * of a properly formated node string, without loss of information.
   63  *
   64  * Any specified default value is in effect if the corresponding XenBus node
   65  * is not present in the XenStore.
   66  *
   67  * XenStore nodes in sections marked "PRIVATE" are solely for use by the
   68  * driver side whose XenBus tree contains them.
   69  *
   70  * XenStore nodes marked "DEPRECATED" in their notes section should only be
   71  * used to provide interoperability with legacy implementations.
   72  *
   73  * See the XenBus state transition diagram below for details on when XenBus
   74  * nodes must be published and when they can be queried.
   75  *
   76  *****************************************************************************
   77  *                            Backend XenBus Nodes
   78  *****************************************************************************
   79  *
   80  *------------------ Backend Device Identification (PRIVATE) ------------------
   81  *
   82  * mode
   83  *      Values:         "r" (read only), "w" (writable)
   84  *
   85  *      The read or write access permissions to the backing store to be
   86  *      granted to the frontend.
   87  *
   88  * params
   89  *      Values:         string
   90  *
   91  *      A free formatted string providing sufficient information for the
   92  *      backend driver to open the backing device.  (e.g. the path to the
   93  *      file or block device representing the backing store.)
   94  *
   95  * physical-device
   96  *      Values:         "MAJOR:MINOR"
   97  *
   98  *      MAJOR and MINOR are the major number and minor number of the
   99  *      backing device respectively.
  100  *
  101  * type
  102  *      Values:         "file", "phy", "tap"
  103  *
  104  *      The type of the backing device/object.
  105  *
  106  *
  107  * direct-io-safe
  108  *      Values:         0/1 (boolean)
  109  *      Default Value:  0
  110  *
  111  *      The underlying storage is not affected by the direct IO memory
  112  *      lifetime bug.  See:
  113  *        http://lists.xen.org/archives/html/xen-devel/2012-12/msg01154.html
  114  *
  115  *      Therefore this option gives the backend permission to use
  116  *      O_DIRECT, notwithstanding that bug.
  117  *
  118  *      That is, if this option is enabled, use of O_DIRECT is safe,
  119  *      in circumstances where we would normally have avoided it as a
  120  *      workaround for that bug.  This option is not relevant for all
  121  *      backends, and even not necessarily supported for those for
  122  *      which it is relevant.  A backend which knows that it is not
  123  *      affected by the bug can ignore this option.
  124  *
  125  *      This option doesn't require a backend to use O_DIRECT, so it
  126  *      should not be used to try to control the caching behaviour.
  127  *
  128  *--------------------------------- Features ---------------------------------
  129  *
  130  * feature-barrier
  131  *      Values:         0/1 (boolean)
  132  *      Default Value:  0
  133  *
  134  *      A value of "1" indicates that the backend can process requests
  135  *      containing the BLKIF_OP_WRITE_BARRIER request opcode.  Requests
  136  *      of this type may still be returned at any time with the
  137  *      BLKIF_RSP_EOPNOTSUPP result code.
  138  *
  139  * feature-flush-cache
  140  *      Values:         0/1 (boolean)
  141  *      Default Value:  0
  142  *
  143  *      A value of "1" indicates that the backend can process requests
  144  *      containing the BLKIF_OP_FLUSH_DISKCACHE request opcode.  Requests
  145  *      of this type may still be returned at any time with the
  146  *      BLKIF_RSP_EOPNOTSUPP result code.
  147  *
  148  * feature-discard
  149  *      Values:         0/1 (boolean)
  150  *      Default Value:  0
  151  *
  152  *      A value of "1" indicates that the backend can process requests
  153  *      containing the BLKIF_OP_DISCARD request opcode.  Requests
  154  *      of this type may still be returned at any time with the
  155  *      BLKIF_RSP_EOPNOTSUPP result code.
  156  *
  157  * feature-persistent
  158  *      Values:         0/1 (boolean)
  159  *      Default Value:  0
  160  *      Notes: 7
  161  *
  162  *      A value of "1" indicates that the backend can keep the grants used
  163  *      by the frontend driver mapped, so the same set of grants should be
  164  *      used in all transactions. The maximum number of grants the backend
  165  *      can map persistently depends on the implementation, but ideally it
  166  *      should be RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. Using this
  167  *      feature the backend doesn't need to unmap each grant, preventing
  168  *      costly TLB flushes. The backend driver should only map grants
  169  *      persistently if the frontend supports it. If a backend driver chooses
  170  *      to use the persistent protocol when the frontend doesn't support it,
  171  *      it will probably hit the maximum number of persistently mapped grants
  172  *      (due to the fact that the frontend won't be reusing the same grants),
  173  *      and fall back to non-persistent mode. Backend implementations may
  174  *      shrink or expand the number of persistently mapped grants without
  175  *      notifying the frontend depending on memory constraints (this might
  176  *      cause a performance degradation).
  177  *
  178  *      If a backend driver wants to limit the maximum number of persistently
  179  *      mapped grants to a value less than RING_SIZE *
  180  *      BLKIF_MAX_SEGMENTS_PER_REQUEST a LRU strategy should be used to
  181  *      discard the grants that are less commonly used. Using a LRU in the
  182  *      backend driver paired with a LIFO queue in the frontend will
  183  *      allow us to have better performance in this scenario.
  184  *
  185  *----------------------- Request Transport Parameters ------------------------
  186  *
  187  * max-ring-page-order
  188  *      Values:         <uint32_t>
  189  *      Default Value:  0
  190  *      Notes:          1, 3
  191  *
  192  *      The maximum supported size of the request ring buffer in units of
  193  *      lb(machine pages). (e.g. 0 == 1 page,  1 = 2 pages, 2 == 4 pages,
  194  *      etc.).
  195  *
  196  * max-ring-pages
  197  *      Values:         <uint32_t>
  198  *      Default Value:  1
  199  *      Notes:          DEPRECATED, 2, 3
  200  *
  201  *      The maximum supported size of the request ring buffer in units of
  202  *      machine pages.  The value must be a power of 2.
  203  *
  204  *------------------------- Backend Device Properties -------------------------
  205  *
  206  * discard-enable
  207  *      Values:         0/1 (boolean)
  208  *      Default Value:  1
  209  *
  210  *      This optional property, set by the toolstack, instructs the backend
  211  *      to offer discard to the frontend. If the property is missing the
  212  *      backend should offer discard if the backing storage actually supports
  213  *      it. This optional property, set by the toolstack, requests that the
  214  *      backend offer, or not offer, discard to the frontend.
  215  *
  216  * discard-alignment
  217  *      Values:         <uint32_t>
  218  *      Default Value:  0
  219  *      Notes:          4, 5
  220  *
  221  *      The offset, in bytes from the beginning of the virtual block device,
  222  *      to the first, addressable, discard extent on the underlying device.
  223  *
  224  * discard-granularity
  225  *      Values:         <uint32_t>
  226  *      Default Value:  <"sector-size">
  227  *      Notes:          4
  228  *
  229  *      The size, in bytes, of the individually addressable discard extents
  230  *      of the underlying device.
  231  *
  232  * discard-secure
  233  *      Values:         0/1 (boolean)
  234  *      Default Value:  0
  235  *      Notes:          10
  236  *
  237  *      A value of "1" indicates that the backend can process BLKIF_OP_DISCARD
  238  *      requests with the BLKIF_DISCARD_SECURE flag set.
  239  *
  240  * info
  241  *      Values:         <uint32_t> (bitmap)
  242  *
  243  *      A collection of bit flags describing attributes of the backing
  244  *      device.  The VDISK_* macros define the meaning of each bit
  245  *      location.
  246  *
  247  * sector-size
  248  *      Values:         <uint32_t>
  249  *
  250  *      The logical sector size, in bytes, of the backend device.
  251  *
  252  * physical-sector-size
  253  *      Values:         <uint32_t>
  254  *
  255  *      The physical sector size, in bytes, of the backend device.
  256  *
  257  * sectors
  258  *      Values:         <uint64_t>
  259  *
  260  *      The size of the backend device, expressed in units of its logical
  261  *      sector size ("sector-size").
  262  *
  263  *****************************************************************************
  264  *                            Frontend XenBus Nodes
  265  *****************************************************************************
  266  *
  267  *----------------------- Request Transport Parameters -----------------------
  268  *
  269  * event-channel
  270  *      Values:         <uint32_t>
  271  *
  272  *      The identifier of the Xen event channel used to signal activity
  273  *      in the ring buffer.
  274  *
  275  * ring-ref
  276  *      Values:         <uint32_t>
  277  *      Notes:          6
  278  *
  279  *      The Xen grant reference granting permission for the backend to map
  280  *      the sole page in a single page sized ring buffer.
  281  *
  282  * ring-ref%u
  283  *      Values:         <uint32_t>
  284  *      Notes:          6
  285  *
  286  *      For a frontend providing a multi-page ring, a "number of ring pages"
  287  *      sized list of nodes, each containing a Xen grant reference granting
  288  *      permission for the backend to map the page of the ring located
  289  *      at page index "%u".  Page indexes are zero based.
  290  *
  291  * protocol
  292  *      Values:         string (XEN_IO_PROTO_ABI_*)
  293  *      Default Value:  XEN_IO_PROTO_ABI_NATIVE
  294  *
  295  *      The machine ABI rules governing the format of all ring request and
  296  *      response structures.
  297  *
  298  * ring-page-order
  299  *      Values:         <uint32_t>
  300  *      Default Value:  0
  301  *      Maximum Value:  MAX(ffs(max-ring-pages) - 1, max-ring-page-order)
  302  *      Notes:          1, 3
  303  *
  304  *      The size of the frontend allocated request ring buffer in units
  305  *      of lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages,
  306  *      etc.).
  307  *
  308  * num-ring-pages
  309  *      Values:         <uint32_t>
  310  *      Default Value:  1
  311  *      Maximum Value:  MAX(max-ring-pages,(0x1 << max-ring-page-order))
  312  *      Notes:          DEPRECATED, 2, 3
  313  *
  314  *      The size of the frontend allocated request ring buffer in units of
  315  *      machine pages.  The value must be a power of 2.
  316  *
  317  * feature-persistent
  318  *      Values:         0/1 (boolean)
  319  *      Default Value:  0
  320  *      Notes: 7, 8, 9
  321  *
  322  *      A value of "1" indicates that the frontend will reuse the same grants
  323  *      for all transactions, allowing the backend to map them with write
  324  *      access (even when it should be read-only). If the frontend hits the
  325  *      maximum number of allowed persistently mapped grants, it can fallback
  326  *      to non persistent mode. This will cause a performance degradation,
  327  *      since the backend driver will still try to map those grants
  328  *      persistently. Since the persistent grants protocol is compatible with
  329  *      the previous protocol, a frontend driver can choose to work in
  330  *      persistent mode even when the backend doesn't support it.
  331  *
  332  *      It is recommended that the frontend driver stores the persistently
  333  *      mapped grants in a LIFO queue, so a subset of all persistently mapped
  334  *      grants gets used commonly. This is done in case the backend driver
  335  *      decides to limit the maximum number of persistently mapped grants
  336  *      to a value less than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
  337  *
  338  *------------------------- Virtual Device Properties -------------------------
  339  *
  340  * device-type
  341  *      Values:         "disk", "cdrom", "floppy", etc.
  342  *
  343  * virtual-device
  344  *      Values:         <uint32_t>
  345  *
  346  *      A value indicating the physical device to virtualize within the
  347  *      frontend's domain.  (e.g. "The first ATA disk", "The third SCSI
  348  *      disk", etc.)
  349  *
  350  *      See docs/misc/vbd-interface.txt for details on the format of this
  351  *      value.
  352  *
  353  * Notes
  354  * -----
  355  * (1) Multi-page ring buffer scheme first developed in the Citrix XenServer
  356  *     PV drivers.
  357  * (2) Multi-page ring buffer scheme first used in some RedHat distributions
  358  *     including a distribution deployed on certain nodes of the Amazon
  359  *     EC2 cluster.
  360  * (3) Support for multi-page ring buffers was implemented independently,
  361  *     in slightly different forms, by both Citrix and RedHat/Amazon.
  362  *     For full interoperability, block front and backends should publish
  363  *     identical ring parameters, adjusted for unit differences, to the
  364  *     XenStore nodes used in both schemes.
  365  * (4) Devices that support discard functionality may internally allocate space
  366  *     (discardable extents) in units that are larger than the exported logical
  367  *     block size. If the backing device has such discardable extents the
  368  *     backend should provide both discard-granularity and discard-alignment.
  369  *     Providing just one of the two may be considered an error by the frontend.
  370  *     Backends supporting discard should include discard-granularity and
  371  *     discard-alignment even if it supports discarding individual sectors.
  372  *     Frontends should assume discard-alignment == 0 and discard-granularity
  373  *     == sector size if these keys are missing.
  374  * (5) The discard-alignment parameter allows a physical device to be
  375  *     partitioned into virtual devices that do not necessarily begin or
  376  *     end on a discardable extent boundary.
  377  * (6) When there is only a single page allocated to the request ring,
  378  *     'ring-ref' is used to communicate the grant reference for this
  379  *     page to the backend.  When using a multi-page ring, the 'ring-ref'
  380  *     node is not created.  Instead 'ring-ref0' - 'ring-refN' are used.
  381  * (7) When using persistent grants data has to be copied from/to the page
  382  *     where the grant is currently mapped. The overhead of doing this copy
  383  *     however doesn't suppress the speed improvement of not having to unmap
  384  *     the grants.
  385  * (8) The frontend driver has to allow the backend driver to map all grants
  386  *     with write access, even when they should be mapped read-only, since
  387  *     further requests may reuse these grants and require write permissions.
  388  * (9) Linux implementation doesn't have a limit on the maximum number of
  389  *     grants that can be persistently mapped in the frontend driver, but
  390  *     due to the frontent driver implementation it should never be bigger
  391  *     than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
  392  *(10) The discard-secure property may be present and will be set to 1 if the
  393  *     backing device supports secure discard.
  394  */
  395 
  396 /*
  397  * STATE DIAGRAMS
  398  *
  399  *****************************************************************************
  400  *                                   Startup                                 *
  401  *****************************************************************************
  402  *
  403  * Tool stack creates front and back nodes with state XenbusStateInitialising.
  404  *
  405  * Front                                Back
  406  * =================================    =====================================
  407  * XenbusStateInitialising              XenbusStateInitialising
  408  *  o Query virtual device               o Query backend device identification
  409  *    properties.                          data.
  410  *  o Setup OS device instance.          o Open and validate backend device.
  411  *                                       o Publish backend features and
  412  *                                         transport parameters.
  413  *                                                      |
  414  *                                                      |
  415  *                                                      V
  416  *                                      XenbusStateInitWait
  417  *
  418  * o Query backend features and
  419  *   transport parameters.
  420  * o Allocate and initialize the
  421  *   request ring.
  422  * o Publish transport parameters
  423  *   that will be in effect during
  424  *   this connection.
  425  *              |
  426  *              |
  427  *              V
  428  * XenbusStateInitialised
  429  *
  430  *                                       o Query frontend transport parameters.
  431  *                                       o Connect to the request ring and
  432  *                                         event channel.
  433  *                                       o Publish backend device properties.
  434  *                                                      |
  435  *                                                      |
  436  *                                                      V
  437  *                                      XenbusStateConnected
  438  *
  439  *  o Query backend device properties.
  440  *  o Finalize OS virtual device
  441  *    instance.
  442  *              |
  443  *              |
  444  *              V
  445  * XenbusStateConnected
  446  *
  447  * Note: Drivers that do not support any optional features, or the negotiation
  448  *       of transport parameters, can skip certain states in the state machine:
  449  *
  450  *       o A frontend may transition to XenbusStateInitialised without
  451  *         waiting for the backend to enter XenbusStateInitWait.  In this
  452  *         case, default transport parameters are in effect and any
  453  *         transport parameters published by the frontend must contain
  454  *         their default values.
  455  *
  456  *       o A backend may transition to XenbusStateInitialised, bypassing
  457  *         XenbusStateInitWait, without waiting for the frontend to first
  458  *         enter the XenbusStateInitialised state.  In this case, default
  459  *         transport parameters are in effect and any transport parameters
  460  *         published by the backend must contain their default values.
  461  *
  462  *       Drivers that support optional features and/or transport parameter
  463  *       negotiation must tolerate these additional state transition paths.
  464  *       In general this means performing the work of any skipped state
  465  *       transition, if it has not already been performed, in addition to the
  466  *       work associated with entry into the current state.
  467  */
  468 
  469 /*
  470  * REQUEST CODES.
  471  */
  472 #define BLKIF_OP_READ              0
  473 #define BLKIF_OP_WRITE             1
  474 /*
  475  * All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER
  476  * operation code ("barrier request") must be completed prior to the
  477  * execution of the barrier request.  All writes issued after the barrier
  478  * request must not execute until after the completion of the barrier request.
  479  *
  480  * Optional.  See "feature-barrier" XenBus node documentation above.
  481  */
  482 #define BLKIF_OP_WRITE_BARRIER     2
  483 /*
  484  * Commit any uncommitted contents of the backing device's volatile cache
  485  * to stable storage.
  486  *
  487  * Optional.  See "feature-flush-cache" XenBus node documentation above.
  488  */
  489 #define BLKIF_OP_FLUSH_DISKCACHE   3
  490 /*
  491  * Used in SLES sources for device specific command packet
  492  * contained within the request. Reserved for that purpose.
  493  */
  494 #define BLKIF_OP_RESERVED_1        4
  495 /*
  496  * Indicate to the backend device that a region of storage is no longer in
  497  * use, and may be discarded at any time without impact to the client.  If
  498  * the BLKIF_DISCARD_SECURE flag is set on the request, all copies of the
  499  * discarded region on the device must be rendered unrecoverable before the
  500  * command returns.
  501  *
  502  * This operation is analogous to performing a trim (ATA) or unamp (SCSI),
  503  * command on a native device.
  504  *
  505  * More information about trim/unmap operations can be found at:
  506  * http://t13.org/Documents/UploadedDocuments/docs2008/
  507  *     e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc
  508  * http://www.seagate.com/staticfiles/support/disc/manuals/
  509  *     Interface%20manuals/100293068c.pdf
  510  *
  511  * Optional.  See "feature-discard", "discard-alignment",
  512  * "discard-granularity", and "discard-secure" in the XenBus node
  513  * documentation above.
  514  */
  515 #define BLKIF_OP_DISCARD           5
  516 
  517 /*
  518  * Recognized if "feature-max-indirect-segments" in present in the backend
  519  * xenbus info. The "feature-max-indirect-segments" node contains the maximum
  520  * number of segments allowed by the backend per request. If the node is
  521  * present, the frontend might use blkif_request_indirect structs in order to
  522  * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The
  523  * maximum number of indirect segments is fixed by the backend, but the
  524  * frontend can issue requests with any number of indirect segments as long as
  525  * it's less than the number provided by the backend. The indirect_grefs field
  526  * in blkif_request_indirect should be filled by the frontend with the
  527  * grant references of the pages that are holding the indirect segments.
  528  * These pages are filled with an array of blkif_request_segment that hold the
  529  * information about the segments. The number of indirect pages to use is
  530  * determined by the number of segments an indirect request contains. Every
  531  * indirect page can contain a maximum of
  532  * (PAGE_SIZE / sizeof(struct blkif_request_segment)) segments, so to
  533  * calculate the number of indirect pages to use we have to do
  534  * ceil(indirect_segments / (PAGE_SIZE / sizeof(struct blkif_request_segment))).
  535  *
  536  * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not*
  537  * create the "feature-max-indirect-segments" node!
  538  */
  539 #define BLKIF_OP_INDIRECT          6
  540 
  541 /*
  542  * Maximum scatter/gather segments per request.
  543  * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
  544  * NB. This could be 12 if the ring indexes weren't stored in the same page.
  545  */
  546 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
  547 
  548 /*
  549  * Maximum number of indirect pages to use per request.
  550  */
  551 #define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8
  552 
  553 /*
  554  * NB. first_sect and last_sect in blkif_request_segment, as well as
  555  * sector_number in blkif_request, are always expressed in 512-byte units.
  556  * However they must be properly aligned to the real sector size of the
  557  * physical disk, which is reported in the "physical-sector-size" node in
  558  * the backend xenbus info. Also the xenbus "sectors" node is expressed in
  559  * 512-byte units.
  560  */
  561 struct blkif_request_segment {
  562     grant_ref_t gref;        /* reference to I/O buffer frame        */
  563     /* @first_sect: first sector in frame to transfer (inclusive).   */
  564     /* @last_sect: last sector in frame to transfer (inclusive).     */
  565     uint8_t     first_sect, last_sect;
  566 };
  567 
  568 /*
  569  * Starting ring element for any I/O request.
  570  */
  571 struct blkif_request {
  572     uint8_t        operation;    /* BLKIF_OP_???                         */
  573     uint8_t        nr_segments;  /* number of segments                   */
  574     blkif_vdev_t   handle;       /* only for read/write requests         */
  575     uint64_t       id;           /* private guest value, echoed in resp  */
  576     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
  577     struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
  578 };
  579 typedef struct blkif_request blkif_request_t;
  580 
  581 /*
  582  * Cast to this structure when blkif_request.operation == BLKIF_OP_DISCARD
  583  * sizeof(struct blkif_request_discard) <= sizeof(struct blkif_request)
  584  */
  585 struct blkif_request_discard {
  586     uint8_t        operation;    /* BLKIF_OP_DISCARD                     */
  587     uint8_t        flag;         /* BLKIF_DISCARD_SECURE or zero         */
  588 #define BLKIF_DISCARD_SECURE (1<<0)  /* ignored if discard-secure=0      */
  589     blkif_vdev_t   handle;       /* same as for read/write requests      */
  590     uint64_t       id;           /* private guest value, echoed in resp  */
  591     blkif_sector_t sector_number;/* start sector idx on disk             */
  592     uint64_t       nr_sectors;   /* number of contiguous sectors to discard*/
  593 };
  594 typedef struct blkif_request_discard blkif_request_discard_t;
  595 
  596 struct blkif_request_indirect {
  597     uint8_t        operation;    /* BLKIF_OP_INDIRECT                    */
  598     uint8_t        indirect_op;  /* BLKIF_OP_{READ/WRITE}                */
  599     uint16_t       nr_segments;  /* number of segments                   */
  600     uint64_t       id;           /* private guest value, echoed in resp  */
  601     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
  602     blkif_vdev_t   handle;       /* same as for read/write requests      */
  603     grant_ref_t    indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
  604 #ifdef __i386__
  605     uint64_t       pad;          /* Make it 64 byte aligned on i386      */
  606 #endif
  607 };
  608 typedef struct blkif_request_indirect blkif_request_indirect_t;
  609 
  610 struct blkif_response {
  611     uint64_t        id;              /* copied from request */
  612     uint8_t         operation;       /* copied from request */
  613     int16_t         status;          /* BLKIF_RSP_???       */
  614 };
  615 typedef struct blkif_response blkif_response_t;
  616 
  617 /*
  618  * STATUS RETURN CODES.
  619  */
  620  /* Operation not supported (only happens on barrier writes). */
  621 #define BLKIF_RSP_EOPNOTSUPP  -2
  622  /* Operation failed for some unspecified reason (-EIO). */
  623 #define BLKIF_RSP_ERROR       -1
  624  /* Operation completed successfully. */
  625 #define BLKIF_RSP_OKAY         0
  626 
  627 /*
  628  * Generate blkif ring structures and types.
  629  */
  630 DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
  631 
  632 #define VDISK_CDROM        0x1
  633 #define VDISK_REMOVABLE    0x2
  634 #define VDISK_READONLY     0x4
  635 
  636 #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
  637 
  638 /*
  639  * Local variables:
  640  * mode: C
  641  * c-file-style: "BSD"
  642  * c-basic-offset: 4
  643  * tab-width: 4
  644  * indent-tabs-mode: nil
  645  * End:
  646  */

Cache object: d9f106da04882dd85f06b6a4b7be251d


[ 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.