scsi_fc_transport.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. SCSI FC Tansport
  2. =============================================
  3. Date: 4/12/2007
  4. Kernel Revisions for features:
  5. rports : <<TBS>>
  6. vports : 2.6.22 (? TBD)
  7. Introduction
  8. ============
  9. This file documents the features and components of the SCSI FC Transport.
  10. It also provides documents the API between the transport and FC LLDDs.
  11. The FC transport can be found at:
  12. drivers/scsi/scsi_transport_fc.c
  13. include/scsi/scsi_transport_fc.h
  14. include/scsi/scsi_netlink_fc.h
  15. This file is found at Documentation/scsi/scsi_fc_transport.txt
  16. FC Remote Ports (rports)
  17. ========================================================================
  18. << To Be Supplied >>
  19. FC Virtual Ports (vports)
  20. ========================================================================
  21. Overview:
  22. -------------------------------
  23. New FC standards have defined mechanisms which allows for a single physical
  24. port to appear on as multiple communication ports. Using the N_Port Id
  25. Virtualization (NPIV) mechanism, a point-to-point connection to a Fabric
  26. can be assigned more than 1 N_Port_ID. Each N_Port_ID appears as a
  27. separate port to other endpoints on the fabric, even though it shares one
  28. physical link to the switch for communication. Each N_Port_ID can have a
  29. unique view of the fabric based on fabric zoning and array lun-masking
  30. (just like a normal non-NPIV adapter). Using the Virtual Fabric (VF)
  31. mechanism, adding a fabric header to each frame allows the port to
  32. interact with the Fabric Port to join multiple fabrics. The port will
  33. obtain an N_Port_ID on each fabric it joins. Each fabric will have its
  34. own unique view of endpoints and configuration parameters. NPIV may be
  35. used together with VF so that the port can obtain multiple N_Port_IDs
  36. on each virtual fabric.
  37. The FC transport is now recognizing a new object - a vport. A vport is
  38. an entity that has a world-wide unique World Wide Port Name (wwpn) and
  39. World Wide Node Name (wwnn). The transport also allows for the FC4's to
  40. be specified for the vport, with FCP_Initiator being the primary role
  41. expected. Once instantiated by one of the above methods, it will have a
  42. distinct N_Port_ID and view of fabric endpoints and storage entities.
  43. The fc_host associated with the physical adapter will export the ability
  44. to create vports. The transport will create the vport object within the
  45. Linux device tree, and instruct the fc_host's driver to instantiate the
  46. virtual port. Typically, the driver will create a new scsi_host instance
  47. on the vport, resulting in a unique <H,C,T,L> namespace for the vport.
  48. Thus, whether a FC port is based on a physical port or on a virtual port,
  49. each will appear as a unique scsi_host with its own target and lun space.
  50. Note: At this time, the transport is written to create only NPIV-based
  51. vports. However, consideration was given to VF-based vports and it
  52. should be a minor change to add support if needed. The remaining
  53. discussion will concentrate on NPIV.
  54. Note: World Wide Name assignment (and uniqueness guarantees) are left
  55. up to an administrative entity controling the vport. For example,
  56. if vports are to be associated with virtual machines, a XEN mgmt
  57. utility would be responsible for creating wwpn/wwnn's for the vport,
  58. using it's own naming authority and OUI. (Note: it already does this
  59. for virtual MAC addresses).
  60. Device Trees and Vport Objects:
  61. -------------------------------
  62. Today, the device tree typically contains the scsi_host object,
  63. with rports and scsi target objects underneath it. Currently the FC
  64. transport creates the vport object and places it under the scsi_host
  65. object corresponding to the physical adapter. The LLDD will allocate
  66. a new scsi_host for the vport and link it's object under the vport.
  67. The remainder of the tree under the vports scsi_host is the same
  68. as the non-NPIV case. The transport is written currently to easily
  69. allow the parent of the vport to be something other than the scsi_host.
  70. This could be used in the future to link the object onto a vm-specific
  71. device tree. If the vport's parent is not the physical port's scsi_host,
  72. a symbolic link to the vport object will be placed in the physical
  73. port's scsi_host.
  74. Here's what to expect in the device tree :
  75. The typical Physical Port's Scsi_Host:
  76. /sys/devices/.../host17/
  77. and it has the typical decendent tree:
  78. /sys/devices/.../host17/rport-17:0-0/target17:0:0/17:0:0:0:
  79. and then the vport is created on the Physical Port:
  80. /sys/devices/.../host17/vport-17:0-0
  81. and the vport's Scsi_Host is then created:
  82. /sys/devices/.../host17/vport-17:0-0/host18
  83. and then the rest of the tree progresses, such as:
  84. /sys/devices/.../host17/vport-17:0-0/host18/rport-18:0-0/target18:0:0/18:0:0:0:
  85. Here's what to expect in the sysfs tree :
  86. scsi_hosts:
  87. /sys/class/scsi_host/host17 physical port's scsi_host
  88. /sys/class/scsi_host/host18 vport's scsi_host
  89. fc_hosts:
  90. /sys/class/fc_host/host17 physical port's fc_host
  91. /sys/class/fc_host/host18 vport's fc_host
  92. fc_vports:
  93. /sys/class/fc_vports/vport-17:0-0 the vport's fc_vport
  94. fc_rports:
  95. /sys/class/fc_remote_ports/rport-17:0-0 rport on the physical port
  96. /sys/class/fc_remote_ports/rport-18:0-0 rport on the vport
  97. Vport Attributes:
  98. -------------------------------
  99. The new fc_vport class object has the following attributes
  100. node_name: Read_Only
  101. The WWNN of the vport
  102. port_name: Read_Only
  103. The WWPN of the vport
  104. roles: Read_Only
  105. Indicates the FC4 roles enabled on the vport.
  106. symbolic_name: Read_Write
  107. A string, appended to the driver's symbolic port name string, which
  108. is registered with the switch to identify the vport. For example,
  109. a hypervisor could set this string to "Xen Domain 2 VM 5 Vport 2",
  110. and this set of identifiers can be seen on switch management screens
  111. to identify the port.
  112. vport_delete: Write_Only
  113. When written with a "1", will tear down the vport.
  114. vport_disable: Write_Only
  115. When written with a "1", will transition the vport to a disabled.
  116. state. The vport will still be instantiated with the Linux kernel,
  117. but it will not be active on the FC link.
  118. When written with a "0", will enable the vport.
  119. vport_last_state: Read_Only
  120. Indicates the previous state of the vport. See the section below on
  121. "Vport States".
  122. vport_state: Read_Only
  123. Indicates the state of the vport. See the section below on
  124. "Vport States".
  125. vport_type: Read_Only
  126. Reflects the FC mechanism used to create the virtual port.
  127. Only NPIV is supported currently.
  128. For the fc_host class object, the following attributes are added for vports:
  129. max_npiv_vports: Read_Only
  130. Indicates the maximum number of NPIV-based vports that the
  131. driver/adapter can support on the fc_host.
  132. npiv_vports_inuse: Read_Only
  133. Indicates how many NPIV-based vports have been instantiated on the
  134. fc_host.
  135. vport_create: Write_Only
  136. A "simple" create interface to instantiate a vport on an fc_host.
  137. A "<WWPN>:<WWNN>" string is written to the attribute. The transport
  138. then instantiates the vport object and calls the LLDD to create the
  139. vport with the role of FCP_Initiator. Each WWN is specified as 16
  140. hex characters and may *not* contain any prefixes (e.g. 0x, x, etc).
  141. vport_delete: Write_Only
  142. A "simple" delete interface to teardown a vport. A "<WWPN>:<WWNN>"
  143. string is written to the attribute. The transport will locate the
  144. vport on the fc_host with the same WWNs and tear it down. Each WWN
  145. is specified as 16 hex characters and may *not* contain any prefixes
  146. (e.g. 0x, x, etc).
  147. Vport States:
  148. -------------------------------
  149. Vport instantiation consists of two parts:
  150. - Creation with the kernel and LLDD. This means all transport and
  151. driver data structures are built up, and device objects created.
  152. This is equivalent to a driver "attach" on an adapter, which is
  153. independent of the adapter's link state.
  154. - Instantiation of the vport on the FC link via ELS traffic, etc.
  155. This is equivalent to a "link up" and successfull link initialization.
  156. Futher information can be found in the interfaces section below for
  157. Vport Creation.
  158. Once a vport has been instantiated with the kernel/LLDD, a vport state
  159. can be reported via the sysfs attribute. The following states exist:
  160. FC_VPORT_UNKNOWN - Unknown
  161. An temporary state, typically set only while the vport is being
  162. instantiated with the kernel and LLDD.
  163. FC_VPORT_ACTIVE - Active
  164. The vport has been successfully been created on the FC link.
  165. It is fully functional.
  166. FC_VPORT_DISABLED - Disabled
  167. The vport instantiated, but "disabled". The vport is not instantiated
  168. on the FC link. This is equivalent to a physical port with the
  169. link "down".
  170. FC_VPORT_LINKDOWN - Linkdown
  171. The vport is not operational as the physical link is not operational.
  172. FC_VPORT_INITIALIZING - Initializing
  173. The vport is in the process of instantiating on the FC link.
  174. The LLDD will set this state just prior to starting the ELS traffic
  175. to create the vport. This state will persist until the vport is
  176. successfully created (state becomes FC_VPORT_ACTIVE) or it fails
  177. (state is one of the values below). As this state is transitory,
  178. it will not be preserved in the "vport_last_state".
  179. FC_VPORT_NO_FABRIC_SUPP - No Fabric Support
  180. The vport is not operational. One of the following conditions were
  181. encountered:
  182. - The FC topology is not Point-to-Point
  183. - The FC port is not connected to an F_Port
  184. - The F_Port has indicated that NPIV is not supported.
  185. FC_VPORT_NO_FABRIC_RSCS - No Fabric Resources
  186. The vport is not operational. The Fabric failed FDISC with a status
  187. indicating that it does not have sufficient resources to complete
  188. the operation.
  189. FC_VPORT_FABRIC_LOGOUT - Fabric Logout
  190. The vport is not operational. The Fabric has LOGO'd the N_Port_ID
  191. associated with the vport.
  192. FC_VPORT_FABRIC_REJ_WWN - Fabric Rejected WWN
  193. The vport is not operational. The Fabric failed FDISC with a status
  194. indicating that the WWN's are not valid.
  195. FC_VPORT_FAILED - VPort Failed
  196. The vport is not operational. This is a catchall for all other
  197. error conditions.
  198. The following state table indicates the different state transitions:
  199. State Event New State
  200. --------------------------------------------------------------------
  201. n/a Initialization Unknown
  202. Unknown: Link Down Linkdown
  203. Link Up & Loop No Fabric Support
  204. Link Up & no Fabric No Fabric Support
  205. Link Up & FLOGI response No Fabric Support
  206. indicates no NPIV support
  207. Link Up & FDISC being sent Initializing
  208. Disable request Disable
  209. Linkdown: Link Up Unknown
  210. Initializing: FDISC ACC Active
  211. FDISC LS_RJT w/ no resources No Fabric Resources
  212. FDISC LS_RJT w/ invalid Fabric Rejected WWN
  213. pname or invalid nport_id
  214. FDISC LS_RJT failed for Vport Failed
  215. other reasons
  216. Link Down Linkdown
  217. Disable request Disable
  218. Disable: Enable request Unknown
  219. Active: LOGO received from fabric Fabric Logout
  220. Link Down Linkdown
  221. Disable request Disable
  222. Fabric Logout: Link still up Unknown
  223. The following 4 error states all have the same transitions:
  224. No Fabric Support:
  225. No Fabric Resources:
  226. Fabric Rejected WWN:
  227. Vport Failed:
  228. Disable request Disable
  229. Link goes down Linkdown
  230. Transport <-> LLDD Interfaces :
  231. -------------------------------
  232. Vport support by LLDD:
  233. The LLDD indicates support for vports by supplying a vport_create()
  234. function in the transport template. The presense of this function will
  235. cause the creation of the new attributes on the fc_host. As part of
  236. the physical port completing its initialization relative to the
  237. transport, it should set the max_npiv_vports attribute to indicate the
  238. maximum number of vports the driver and/or adapter supports.
  239. Vport Creation:
  240. The LLDD vport_create() syntax is:
  241. int vport_create(struct fc_vport *vport, bool disable)
  242. where:
  243. vport: Is the newly allocated vport object
  244. disable: If "true", the vport is to be created in a disabled stated.
  245. If "false", the vport is to be enabled upon creation.
  246. When a request is made to create a new vport (via sgio/netlink, or the
  247. vport_create fc_host attribute), the transport will validate that the LLDD
  248. can support another vport (e.g. max_npiv_vports > npiv_vports_inuse).
  249. If not, the create request will be failed. If space remains, the transport
  250. will increment the vport count, create the vport object, and then call the
  251. LLDD's vport_create() function with the newly allocated vport object.
  252. As mentioned above, vport creation is divided into two parts:
  253. - Creation with the kernel and LLDD. This means all transport and
  254. driver data structures are built up, and device objects created.
  255. This is equivalent to a driver "attach" on an adapter, which is
  256. independent of the adapter's link state.
  257. - Instantiation of the vport on the FC link via ELS traffic, etc.
  258. This is equivalent to a "link up" and successfull link initialization.
  259. The LLDD's vport_create() function will not synchronously wait for both
  260. parts to be fully completed before returning. It must validate that the
  261. infrastructure exists to support NPIV, and complete the first part of
  262. vport creation (data structure build up) before returning. We do not
  263. hinge vport_create() on the link-side operation mainly because:
  264. - The link may be down. It is not a failure if it is. It simply
  265. means the vport is in an inoperable state until the link comes up.
  266. This is consistent with the link bouncing post vport creation.
  267. - The vport may be created in a disabled state.
  268. - This is consistent with a model where: the vport equates to a
  269. FC adapter. The vport_create is synonymous with driver attachment
  270. to the adapter, which is independent of link state.
  271. Note: special error codes have been defined to delineate infrastructure
  272. failure cases for quicker resolution.
  273. The expected behavior for the LLDD's vport_create() function is:
  274. - Validate Infrastructure:
  275. - If the driver or adapter cannot support another vport, whether
  276. due to improper firmware, (a lie about) max_npiv, or a lack of
  277. some other resource - return VPCERR_UNSUPPORTED.
  278. - If the driver validates the WWN's against those already active on
  279. the adapter and detects an overlap - return VPCERR_BAD_WWN.
  280. - If the driver detects the topology is loop, non-fabric, or the
  281. FLOGI did not support NPIV - return VPCERR_NO_FABRIC_SUPP.
  282. - Allocate data structures. If errors are encountered, such as out
  283. of memory conditions, return the respective negative Exxx error code.
  284. - If the role is FCP Initiator, the LLDD is to :
  285. - Call scsi_host_alloc() to allocate a scsi_host for the vport.
  286. - Call scsi_add_host(new_shost, &vport->dev) to start the scsi_host
  287. and bind it as a child of the vport device.
  288. - Initializes the fc_host attribute values.
  289. - Kick of further vport state transitions based on the disable flag and
  290. link state - and return success (zero).
  291. LLDD Implementers Notes:
  292. - It is suggested that there be a different fc_function_templates for
  293. the physical port and the virtual port. The physical port's template
  294. would have the vport_create, vport_delete, and vport_disable functions,
  295. while the vports would not.
  296. - It is suggested that there be different scsi_host_templates
  297. for the physical port and virtual port. Likely, there are driver
  298. attributes, embedded into the scsi_host_template, that are applicable
  299. for the physical port only (link speed, topology setting, etc). This
  300. ensures that the attributes are applicable to the respective scsi_host.
  301. Vport Disable/Enable:
  302. The LLDD vport_disable() syntax is:
  303. int vport_disable(struct fc_vport *vport, bool disable)
  304. where:
  305. vport: Is vport to to be enabled or disabled
  306. disable: If "true", the vport is to be disabled.
  307. If "false", the vport is to be enabled.
  308. When a request is made to change the disabled state on a vport, the
  309. transport will validate the request against the existing vport state.
  310. If the request is to disable and the vport is already disabled, the
  311. request will fail. Similarly, if the request is to enable, and the
  312. vport is not in a disabled state, the request will fail. If the request
  313. is valid for the vport state, the transport will call the LLDD to
  314. change the vport's state.
  315. Within the LLDD, if a vport is disabled, it remains instantiated with
  316. the kernel and LLDD, but it is not active or visible on the FC link in
  317. any way. (see Vport Creation and the 2 part instantiation discussion).
  318. The vport will remain in this state until it is deleted or re-enabled.
  319. When enabling a vport, the LLDD reinstantiates the vport on the FC
  320. link - essentially restarting the LLDD statemachine (see Vport States
  321. above).
  322. Vport Deletion:
  323. The LLDD vport_delete() syntax is:
  324. int vport_delete(struct fc_vport *vport)
  325. where:
  326. vport: Is vport to delete
  327. When a request is made to delete a vport (via sgio/netlink, or via the
  328. fc_host or fc_vport vport_delete attributes), the transport will call
  329. the LLDD to terminate the vport on the FC link, and teardown all other
  330. datastructures and references. If the LLDD completes successfully,
  331. the transport will teardown the vport objects and complete the vport
  332. removal. If the LLDD delete request fails, the vport object will remain,
  333. but will be in an indeterminate state.
  334. Within the LLDD, the normal code paths for a scsi_host teardown should
  335. be followed. E.g. If the vport has a FCP Initiator role, the LLDD
  336. will call fc_remove_host() for the vports scsi_host, followed by
  337. scsi_remove_host() and scsi_host_put() for the vports scsi_host.
  338. Other:
  339. fc_host port_type attribute:
  340. There is a new fc_host port_type value - FC_PORTTYPE_NPIV. This value
  341. must be set on all vport-based fc_hosts. Normally, on a physical port,
  342. the port_type attribute would be set to NPORT, NLPORT, etc based on the
  343. topology type and existence of the fabric. As this is not applicable to
  344. a vport, it makes more sense to report the FC mechanism used to create
  345. the vport.
  346. Driver unload:
  347. FC drivers are required to call fc_remove_host() prior to calling
  348. scsi_remove_host(). This allows the fc_host to tear down all remote
  349. ports prior the scsi_host being torn down. The fc_remove_host() call
  350. was updated to remove all vports for the fc_host as well.
  351. Credits
  352. =======
  353. The following people have contributed to this document:
  354. James Smart
  355. james.smart@emulex.com