brintos

brintos / linux-shallow public Read only

0
0
Text · 23.6 KiB · e3ddcfb Raw
561 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3=================4SCSI FC Transport5=================6 7Date:  11/18/20088 9Kernel Revisions for features::10 11  rports : <<TBS>>12  vports : 2.6.2213  bsg support : 2.6.30 (?TBD?)14 15 16Introduction17============18This file documents the features and components of the SCSI FC Transport.19It also provides documents the API between the transport and FC LLDDs.20 21The FC transport can be found at::22 23  drivers/scsi/scsi_transport_fc.c24  include/scsi/scsi_transport_fc.h25  include/scsi/scsi_netlink_fc.h26  include/scsi/scsi_bsg_fc.h27 28This file is found at Documentation/scsi/scsi_fc_transport.rst29 30 31FC Remote Ports (rports)32========================33<< To Be Supplied >>34 35 36FC Virtual Ports (vports)37=========================38 39Overview40--------41 42  New FC standards have defined mechanisms which allows for a single physical43  port to appear on as multiple communication ports. Using the N_Port Id44  Virtualization (NPIV) mechanism, a point-to-point connection to a Fabric45  can be assigned more than 1 N_Port_ID.  Each N_Port_ID appears as a46  separate port to other endpoints on the fabric, even though it shares one47  physical link to the switch for communication. Each N_Port_ID can have a48  unique view of the fabric based on fabric zoning and array lun-masking49  (just like a normal non-NPIV adapter).  Using the Virtual Fabric (VF)50  mechanism, adding a fabric header to each frame allows the port to51  interact with the Fabric Port to join multiple fabrics. The port will52  obtain an N_Port_ID on each fabric it joins. Each fabric will have its53  own unique view of endpoints and configuration parameters.  NPIV may be54  used together with VF so that the port can obtain multiple N_Port_IDs55  on each virtual fabric.56 57  The FC transport is now recognizing a new object - a vport.  A vport is58  an entity that has a world-wide unique World Wide Port Name (wwpn) and59  World Wide Node Name (wwnn). The transport also allows for the FC4's to60  be specified for the vport, with FCP_Initiator being the primary role61  expected. Once instantiated by one of the above methods, it will have a62  distinct N_Port_ID and view of fabric endpoints and storage entities.63  The fc_host associated with the physical adapter will export the ability64  to create vports. The transport will create the vport object within the65  Linux device tree, and instruct the fc_host's driver to instantiate the66  virtual port. Typically, the driver will create a new scsi_host instance67  on the vport, resulting in a unique <H,C,T,L> namespace for the vport.68  Thus, whether a FC port is based on a physical port or on a virtual port,69  each will appear as a unique scsi_host with its own target and lun space.70 71  .. Note::72    At this time, the transport is written to create only NPIV-based73    vports. However, consideration was given to VF-based vports and it74    should be a minor change to add support if needed.  The remaining75    discussion will concentrate on NPIV.76 77  .. Note::78    World Wide Name assignment (and uniqueness guarantees) are left79    up to an administrative entity controlling the vport. For example,80    if vports are to be associated with virtual machines, a XEN mgmt81    utility would be responsible for creating wwpn/wwnn's for the vport,82    using its own naming authority and OUI. (Note: it already does this83    for virtual MAC addresses).84 85 86Device Trees and Vport Objects:87-------------------------------88 89  Today, the device tree typically contains the scsi_host object,90  with rports and scsi target objects underneath it. Currently the FC91  transport creates the vport object and places it under the scsi_host92  object corresponding to the physical adapter.  The LLDD will allocate93  a new scsi_host for the vport and link its object under the vport.94  The remainder of the tree under the vports scsi_host is the same95  as the non-NPIV case. The transport is written currently to easily96  allow the parent of the vport to be something other than the scsi_host.97  This could be used in the future to link the object onto a vm-specific98  device tree. If the vport's parent is not the physical port's scsi_host,99  a symbolic link to the vport object will be placed in the physical100  port's scsi_host.101 102  Here's what to expect in the device tree :103 104   The typical Physical Port's Scsi_Host::105 106     /sys/devices/.../host17/107 108   and it has the typical descendant tree::109 110     /sys/devices/.../host17/rport-17:0-0/target17:0:0/17:0:0:0:111 112   and then the vport is created on the Physical Port::113 114     /sys/devices/.../host17/vport-17:0-0115 116   and the vport's Scsi_Host is then created::117 118     /sys/devices/.../host17/vport-17:0-0/host18119 120   and then the rest of the tree progresses, such as::121 122     /sys/devices/.../host17/vport-17:0-0/host18/rport-18:0-0/target18:0:0/18:0:0:0:123 124  Here's what to expect in the sysfs tree::125 126   scsi_hosts:127     /sys/class/scsi_host/host17                physical port's scsi_host128     /sys/class/scsi_host/host18                vport's scsi_host129   fc_hosts:130     /sys/class/fc_host/host17                  physical port's fc_host131     /sys/class/fc_host/host18                  vport's fc_host132   fc_vports:133     /sys/class/fc_vports/vport-17:0-0          the vport's fc_vport134   fc_rports:135     /sys/class/fc_remote_ports/rport-17:0-0    rport on the physical port136     /sys/class/fc_remote_ports/rport-18:0-0    rport on the vport137 138 139Vport Attributes140----------------141 142  The new fc_vport class object has the following attributes143 144     node_name:                                                 Read_Only145       The WWNN of the vport146 147     port_name:                                                 Read_Only148       The WWPN of the vport149 150     roles:                                                     Read_Only151       Indicates the FC4 roles enabled on the vport.152 153     symbolic_name:                                             Read_Write154       A string, appended to the driver's symbolic port name string, which155       is registered with the switch to identify the vport. For example,156       a hypervisor could set this string to "Xen Domain 2 VM 5 Vport 2",157       and this set of identifiers can be seen on switch management screens158       to identify the port.159 160     vport_delete:                                              Write_Only161       When written with a "1", will tear down the vport.162 163     vport_disable:                                             Write_Only164       When written with a "1", will transition the vport to a disabled.165       state.  The vport will still be instantiated with the Linux kernel,166       but it will not be active on the FC link.167       When written with a "0", will enable the vport.168 169     vport_last_state:                                          Read_Only170       Indicates the previous state of the vport.  See the section below on171       "Vport States".172 173     vport_state:                                               Read_Only174       Indicates the state of the vport.  See the section below on175       "Vport States".176 177     vport_type:                                                Read_Only178       Reflects the FC mechanism used to create the virtual port.179       Only NPIV is supported currently.180 181 182  For the fc_host class object, the following attributes are added for vports:183 184     max_npiv_vports:                                           Read_Only185       Indicates the maximum number of NPIV-based vports that the186       driver/adapter can support on the fc_host.187 188     npiv_vports_inuse:                                         Read_Only189       Indicates how many NPIV-based vports have been instantiated on the190       fc_host.191 192     vport_create:                                              Write_Only193       A "simple" create interface to instantiate a vport on an fc_host.194       A "<WWPN>:<WWNN>" string is written to the attribute. The transport195       then instantiates the vport object and calls the LLDD to create the196       vport with the role of FCP_Initiator.  Each WWN is specified as 16197       hex characters and may *not* contain any prefixes (e.g. 0x, x, etc).198 199     vport_delete:                                              Write_Only200        A "simple" delete interface to teardown a vport. A "<WWPN>:<WWNN>"201        string is written to the attribute. The transport will locate the202        vport on the fc_host with the same WWNs and tear it down.  Each WWN203        is specified as 16 hex characters and may *not* contain any prefixes204        (e.g. 0x, x, etc).205 206 207Vport States208------------209 210  Vport instantiation consists of two parts:211 212    - Creation with the kernel and LLDD. This means all transport and213      driver data structures are built up, and device objects created.214      This is equivalent to a driver "attach" on an adapter, which is215      independent of the adapter's link state.216    - Instantiation of the vport on the FC link via ELS traffic, etc.217      This is equivalent to a "link up" and successful link initialization.218 219  Further information can be found in the interfaces section below for220  Vport Creation.221 222  Once a vport has been instantiated with the kernel/LLDD, a vport state223  can be reported via the sysfs attribute. The following states exist:224 225    FC_VPORT_UNKNOWN            - Unknown226      An temporary state, typically set only while the vport is being227      instantiated with the kernel and LLDD.228 229    FC_VPORT_ACTIVE             - Active230      The vport has been successfully been created on the FC link.231      It is fully functional.232 233    FC_VPORT_DISABLED           - Disabled234      The vport instantiated, but "disabled". The vport is not instantiated235      on the FC link. This is equivalent to a physical port with the236      link "down".237 238    FC_VPORT_LINKDOWN           - Linkdown239      The vport is not operational as the physical link is not operational.240 241    FC_VPORT_INITIALIZING       - Initializing242      The vport is in the process of instantiating on the FC link.243      The LLDD will set this state just prior to starting the ELS traffic244      to create the vport. This state will persist until the vport is245      successfully created (state becomes FC_VPORT_ACTIVE) or it fails246      (state is one of the values below).  As this state is transitory,247      it will not be preserved in the "vport_last_state".248 249    FC_VPORT_NO_FABRIC_SUPP     - No Fabric Support250      The vport is not operational. One of the following conditions were251      encountered:252 253       - The FC topology is not Point-to-Point254       - The FC port is not connected to an F_Port255       - The F_Port has indicated that NPIV is not supported.256 257    FC_VPORT_NO_FABRIC_RSCS     - No Fabric Resources258      The vport is not operational. The Fabric failed FDISC with a status259      indicating that it does not have sufficient resources to complete260      the operation.261 262    FC_VPORT_FABRIC_LOGOUT      - Fabric Logout263      The vport is not operational. The Fabric has LOGO'd the N_Port_ID264      associated with the vport.265 266    FC_VPORT_FABRIC_REJ_WWN     - Fabric Rejected WWN267      The vport is not operational. The Fabric failed FDISC with a status268      indicating that the WWN's are not valid.269 270    FC_VPORT_FAILED             - VPort Failed271      The vport is not operational. This is a catchall for all other272      error conditions.273 274 275  The following state table indicates the different state transitions:276 277   +------------------+--------------------------------+---------------------+278   | State            | Event                          | New State           |279   +==================+================================+=====================+280   | n/a              | Initialization                 | Unknown             |281   +------------------+--------------------------------+---------------------+282   | Unknown:         | Link Down                      | Linkdown            |283   |                  +--------------------------------+---------------------+284   |                  | Link Up & Loop                 | No Fabric Support   |285   |                  +--------------------------------+---------------------+286   |                  | Link Up & no Fabric            | No Fabric Support   |287   |                  +--------------------------------+---------------------+288   |                  | Link Up & FLOGI response       | No Fabric Support   |289   |                  | indicates no NPIV support      |                     |290   |                  +--------------------------------+---------------------+291   |                  | Link Up & FDISC being sent     | Initializing        |292   |                  +--------------------------------+---------------------+293   |                  | Disable request                | Disable             |294   +------------------+--------------------------------+---------------------+295   | Linkdown:        | Link Up                        | Unknown             |296   +------------------+--------------------------------+---------------------+297   | Initializing:    | FDISC ACC                      | Active              |298   |                  +--------------------------------+---------------------+299   |                  | FDISC LS_RJT w/ no resources   | No Fabric Resources |300   |                  +--------------------------------+---------------------+301   |                  | FDISC LS_RJT w/ invalid        | Fabric Rejected WWN |302   |		      | pname or invalid nport_id      |                     |303   |                  +--------------------------------+---------------------+304   |                  | FDISC LS_RJT failed for        | Vport Failed        |305   |                  | other reasons                  |                     |306   |                  +--------------------------------+---------------------+307   |                  | Link Down                      | Linkdown            |308   |                  +--------------------------------+---------------------+309   |                  | Disable request                | Disable             |310   +------------------+--------------------------------+---------------------+311   | Disable:         | Enable request                 | Unknown             |312   +------------------+--------------------------------+---------------------+313   | Active:          | LOGO received from fabric      | Fabric Logout       |314   |                  +--------------------------------+---------------------+315   |                  | Link Down                      | Linkdown            |316   |                  +--------------------------------+---------------------+317   |                  | Disable request                | Disable             |318   +------------------+--------------------------------+---------------------+319   | Fabric Logout:   | Link still up                  | Unknown             |320   +------------------+--------------------------------+---------------------+321 322The following 4 error states all have the same transitions::323 324    No Fabric Support:325    No Fabric Resources:326    Fabric Rejected WWN:327    Vport Failed:328                        Disable request                 Disable329                        Link goes down                  Linkdown330 331 332Transport <-> LLDD Interfaces333-----------------------------334 335Vport support by LLDD:336 337  The LLDD indicates support for vports by supplying a vport_create()338  function in the transport template.  The presence of this function will339  cause the creation of the new attributes on the fc_host.  As part of340  the physical port completing its initialization relative to the341  transport, it should set the max_npiv_vports attribute to indicate the342  maximum number of vports the driver and/or adapter supports.343 344 345Vport Creation:346 347  The LLDD vport_create() syntax is::348 349      int vport_create(struct fc_vport *vport, bool disable)350 351  where:352 353      =======   ===========================================================354      vport     Is the newly allocated vport object355      disable   If "true", the vport is to be created in a disabled stated.356                If "false", the vport is to be enabled upon creation.357      =======   ===========================================================358 359  When a request is made to create a new vport (via sgio/netlink, or the360  vport_create fc_host attribute), the transport will validate that the LLDD361  can support another vport (e.g. max_npiv_vports > npiv_vports_inuse).362  If not, the create request will be failed.  If space remains, the transport363  will increment the vport count, create the vport object, and then call the364  LLDD's vport_create() function with the newly allocated vport object.365 366  As mentioned above, vport creation is divided into two parts:367 368    - Creation with the kernel and LLDD. This means all transport and369      driver data structures are built up, and device objects created.370      This is equivalent to a driver "attach" on an adapter, which is371      independent of the adapter's link state.372    - Instantiation of the vport on the FC link via ELS traffic, etc.373      This is equivalent to a "link up" and successful link initialization.374 375  The LLDD's vport_create() function will not synchronously wait for both376  parts to be fully completed before returning. It must validate that the377  infrastructure exists to support NPIV, and complete the first part of378  vport creation (data structure build up) before returning.  We do not379  hinge vport_create() on the link-side operation mainly because:380 381    - The link may be down. It is not a failure if it is. It simply382      means the vport is in an inoperable state until the link comes up.383      This is consistent with the link bouncing post vport creation.384    - The vport may be created in a disabled state.385    - This is consistent with a model where:  the vport equates to a386      FC adapter. The vport_create is synonymous with driver attachment387      to the adapter, which is independent of link state.388 389  .. Note::390 391      special error codes have been defined to delineate infrastructure392      failure cases for quicker resolution.393 394  The expected behavior for the LLDD's vport_create() function is:395 396    - Validate Infrastructure:397 398        - If the driver or adapter cannot support another vport, whether399            due to improper firmware, (a lie about) max_npiv, or a lack of400            some other resource - return VPCERR_UNSUPPORTED.401        - If the driver validates the WWN's against those already active on402            the adapter and detects an overlap - return VPCERR_BAD_WWN.403        - If the driver detects the topology is loop, non-fabric, or the404            FLOGI did not support NPIV - return VPCERR_NO_FABRIC_SUPP.405 406    - Allocate data structures. If errors are encountered, such as out407        of memory conditions, return the respective negative Exxx error code.408    - If the role is FCP Initiator, the LLDD is to :409 410        - Call scsi_host_alloc() to allocate a scsi_host for the vport.411        - Call scsi_add_host(new_shost, &vport->dev) to start the scsi_host412          and bind it as a child of the vport device.413        - Initializes the fc_host attribute values.414 415    - Kick of further vport state transitions based on the disable flag and416        link state - and return success (zero).417 418  LLDD Implementers Notes:419 420  - It is suggested that there be a different fc_function_templates for421    the physical port and the virtual port.  The physical port's template422    would have the vport_create, vport_delete, and vport_disable functions,423    while the vports would not.424  - It is suggested that there be different scsi_host_templates425    for the physical port and virtual port. Likely, there are driver426    attributes, embedded into the scsi_host_template, that are applicable427    for the physical port only (link speed, topology setting, etc). This428    ensures that the attributes are applicable to the respective scsi_host.429 430 431Vport Disable/Enable:432 433  The LLDD vport_disable() syntax is::434 435      int vport_disable(struct fc_vport *vport, bool disable)436 437  where:438 439      =======   =======================================440      vport     Is vport to be enabled or disabled441      disable   If "true", the vport is to be disabled.442                If "false", the vport is to be enabled.443      =======   =======================================444 445  When a request is made to change the disabled state on a vport, the446  transport will validate the request against the existing vport state.447  If the request is to disable and the vport is already disabled, the448  request will fail. Similarly, if the request is to enable, and the449  vport is not in a disabled state, the request will fail.  If the request450  is valid for the vport state, the transport will call the LLDD to451  change the vport's state.452 453  Within the LLDD, if a vport is disabled, it remains instantiated with454  the kernel and LLDD, but it is not active or visible on the FC link in455  any way. (see Vport Creation and the 2 part instantiation discussion).456  The vport will remain in this state until it is deleted or re-enabled.457  When enabling a vport, the LLDD reinstantiates the vport on the FC458  link - essentially restarting the LLDD statemachine (see Vport States459  above).460 461 462Vport Deletion:463 464  The LLDD vport_delete() syntax is::465 466      int vport_delete(struct fc_vport *vport)467 468  where:469 470      vport:    Is vport to delete471 472  When a request is made to delete a vport (via sgio/netlink, or via the473  fc_host or fc_vport vport_delete attributes), the transport will call474  the LLDD to terminate the vport on the FC link, and teardown all other475  datastructures and references.  If the LLDD completes successfully,476  the transport will teardown the vport objects and complete the vport477  removal.  If the LLDD delete request fails, the vport object will remain,478  but will be in an indeterminate state.479 480  Within the LLDD, the normal code paths for a scsi_host teardown should481  be followed. E.g. If the vport has a FCP Initiator role, the LLDD482  will call fc_remove_host() for the vports scsi_host, followed by483  scsi_remove_host() and scsi_host_put() for the vports scsi_host.484 485 486Other:487  fc_host port_type attribute:488    There is a new fc_host port_type value - FC_PORTTYPE_NPIV. This value489    must be set on all vport-based fc_hosts.  Normally, on a physical port,490    the port_type attribute would be set to NPORT, NLPORT, etc based on the491    topology type and existence of the fabric. As this is not applicable to492    a vport, it makes more sense to report the FC mechanism used to create493    the vport.494 495  Driver unload:496    FC drivers are required to call fc_remove_host() prior to calling497    scsi_remove_host().  This allows the fc_host to tear down all remote498    ports prior the scsi_host being torn down.  The fc_remove_host() call499    was updated to remove all vports for the fc_host as well.500 501 502Transport supplied functions503----------------------------504 505The following functions are supplied by the FC-transport for use by LLDs.506 507   ==================   =========================508   fc_vport_create      create a vport509   fc_vport_terminate   detach and remove a vport510   ==================   =========================511 512Details::513 514    /**515    * fc_vport_create - Admin App or LLDD requests creation of a vport516    * @shost:     scsi host the virtual port is connected to.517    * @ids:       The world wide names, FC4 port roles, etc for518    *              the virtual port.519    *520    * Notes:521    *     This routine assumes no locks are held on entry.522    */523    struct fc_vport *524    fc_vport_create(struct Scsi_Host *shost, struct fc_vport_identifiers *ids)525 526    /**527    * fc_vport_terminate - Admin App or LLDD requests termination of a vport528    * @vport:      fc_vport to be terminated529    *530    * Calls the LLDD vport_delete() function, then deallocates and removes531    * the vport from the shost and object tree.532    *533    * Notes:534    *      This routine assumes no locks are held on entry.535    */536    int537    fc_vport_terminate(struct fc_vport *vport)538 539 540FC BSG support (CT & ELS passthru, and more)541============================================542 543<< To Be Supplied >>544 545 546 547 548 549Credits550=======551The following people have contributed to this document:552 553 554 555 556 557 558James Smart559james.smart@broadcom.com560 561