xref: /illumos-gate/usr/src/man/man9/iport.9 (revision 74bc43b0515c1d5245354261e501b8923daba127)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright (c) 2017, Joyent, Inc.
13.\"
14.Dd Apr 18, 2017
15.Dt IPORT 9
16.Os
17.Sh NAME
18.Nm iport ,
19.Nm iportmap ,
20.Nm phymap ,
21.Nm tgtmap
22.Nd SCSI Device Management Concepts
23.Sh DESCRIPTION
24The
25.Sy iport ,
26.Sy iportmap ,
27.Sy phymap ,
28and
29.Sy tgtmap
30abstractions enable host bus adapter (HBA) drivers to represent the
31devices that they are responsible for enumerating, as well as the
32relationships between these devices.
33These interfaces simplify device drivers by taking care of the creation
34and destruction of device nodes in the devices tree for enumerated
35devices as well as performing some amount of hysteresis.
36.Pp
37These abstractions are used in tandem with SCSI complex addressing.
38A device driver that uses these interfaces generally passes both the
39.Dv SCSI_HBA_HBA
40flag and the
41.Dv SCSI_HBA_ADDR_COMPLEX
42in the
43.Fa hba_flags
44argument to
45.Xr scsi_hba_attach_setup 9F .
46.Ss iport
47The
48.Sy iport ,
49or initiator port, abstracts a collection of attached devices.
50One way to view an iport is that each iport maps to a phy on the HBA.
51A phy refers to a physical connector between the HBA and devices.
52A phy may be made up of individual lanes.
53A lane is connected to a device, for example a disk driver.
54Multiple lanes maybe plugged into the same device, for example, an
55expander.
56When a phy connects to a device with a single lane, this is often
57called a
58.Em narrow phy .
59When a phy connects to a device with multiple lanes, this is often
60called a
61.Em wide phy .
62.Pp
63Consider a device that has two physical ports, and thus two phys.
64Each phy has four lanes, thus we describe the phy as having a mask of
650xf.
66Each bit in the mask corresponds to a specific lane.
67In this example, each phy would be represented in the system by an iport
68and may enumerate a different device for each lane of the phy.
69If an expander is attached to one or more of the lanes of a phy, then
70additional devices will be enumerated under the expander and be added to
71that phy's iport.
72.Pp
73Another example to consider is when each lane of a phy is directly
74connected to a single disk through a passive backplane.
75In this case, each lane may represent its own iport, since the
76management of each is independent, basically there are many devices each
77with a mask of 0x1.
78.Pp
79iports do not need to map to a physical phy.
80Some HBAs support a combination of both physical and virtual devices.
81In that case, the driver may create two different iports, one for the
82physical devices and one for the virtual devices.
83.Pp
84One property of iports is that they're attached separately from the main
85device and therefore have their own
86.Xr scsi_hba_tran 9S
87structure.
88As a result, that means that a driver can provide different
89entry points for each iport, especially if they represent different
90classes of resources, for example one iport for all physical devices and
91one for all virtual devices.
92This allows for a driver to return different capabilities, among other
93behaviors and entry points, for these different iports.
94One specific case of this is that while physical devices may provide a
95means to get to a SCSI WWN, virtual devices may not have a WWN and
96instead must use a different addressing format.
97.Pp
98iports are considered children of the device driver that attach them,
99but they are bound to the same driver.
100This means that when an iport is created, the
101.Xr attach 9E
102and
103.Xr probe 9E
104entry points of the parent driver (usually indicated by passing a
105.Vt dev_info
106structure) will be called.
107Similarly, when an iport is removed from the system, then the driver's
108.Xr detach 9E
109entry point will be called.
110A driver can determine whether an iport is being attached or not by
111calling the
112.Xr scsi_hba_iport_unit_address 9F
113function.
114The value will return
115.Dv NULL
116if the attaching device represents the driver.
117.Pp
118To manage iports, drivers have two different options.
119If the set of iport an HBA supports are static, then they should use the
120.Xr scsi_hba_iport_register 9F
121function to register an iport.
122.Pp
123If instead, the set of iports are dynamic and map to the coming and
124going of phys discovered by the driver (or some other dynamic source),
125then the driver should use the iportmap set of functions.
126See the section
127.Sx phymap and iportmap
128for more information.
129.Ss tgtmap
130The target map represents a set of devices that have been enumerated
131under an iport.
132Each device is represented by a string, which is an address of some
133kind.
134Usually a physical device's WWN is used.
135.Pp
136By using a target map, the operating system will take
137responsibility for notifying the driver when devices have come and gone
138from a target map, once it has settled, and it will also take
139responsibility for having device nodes come and go, meaning that the
140device driver does not need to know anything about the devices tree or
141worry about other parts of being a nexus driver.
142.Pp
143Target maps come in two forms which change how the HBA driver is
144responsible for reporting changes:
145.Bl -enum
146.It
147Full-set
148.It
149Per-address
150.El
151.Pp
152In the full-set mode, the driver always reports the full set of current
153devices that it sees.
154When the driver finishes the report, the operating system will inform
155the driver of addresses that were added and addresses that were removed.
156These addresses correspond to newly found devices and recently removed
157devices, respectively.
158The full-set mode allows for a simpler device driver, particularly if
159addition and removal notifications may be dropped by the hardware.
160.Pp
161When using the per-address mode of a target map, the HBA driver is
162responsible for indicating which addresses have come and gone from the
163system.
164.Pp
165In either mode, the driver will receive two callbacks, if they have been
166registered when the target map was created.
167The first callback fires before a target driver like sd, ses, etc. is
168attached.
169The second callback fires after the corresponding driver has been
170attached.
171These allow the HBA driver to perform any operations that are
172required on the devices.
173.Pp
174Each target map has two different sets of devices that it manages in
175this form.
176The devices are separated into the following groups:
177.Bl -enum
178.It
179SCSI Devices
180.It
181SMP (SCSI Management Protocol) devices
182.El
183.Pp
184All SATA, SCSI, SAS, SES, etc. devices all are considered part of the
185first category.
186.Pp
187Target maps can be created and destroyed with the
188.Xr scsi_hba_tgtmap_create 9F
189and
190.Xr scsi_hba_tgtmap_destroy 9F
191functions.
192.Pp
193The following functions are used to manage target maps operating in
194full-set mode:
195.Bl -dash
196.It
197.Xr scsi_hba_tgtmap_set_begin 9F
198.It
199.Xr scsi_hba_tgtmap_set_add 9F
200.It
201.Xr scsi_hba_tgtmap_set_end 9F
202.It
203.Xr scsi_hba_tgtmap_set_flush 9F
204.El
205.Pp
206The following functions are used to manage target maps operating in
207per-address mode:
208.Bl -dash
209.It
210.Xr scsi_hba_tgtmap_tgt_add 9F
211.It
212.Xr scsi_hba_tgtmap_tgt_remove 9F
213.El
214.Ss phymap and iportmap
215The phymap and iportmap are often used together to represent complex SAS
216topologies.
217The phymap provides a way to see what phys have been grouped together
218under the same SAS port.
219The SAS port is represented by the
220.Dq local
221and
222.Dq remote
223WWNs.
224When additional phys come online, if they end up referring to the
225same WWNs, then they'll map to the same port.
226.Pp
227The iportmap is used to maintain a dynamic set of iports related to a
228device.
229The iports are each identified by an address, which is generally
230a unit address string.
231For example, when a new phy is added to the phymap which represents a
232new SAS port being used, then a corresponding iport will be created and
233associated with that entry from the phymap.
234Once the iport has been created, a normal target map can be created on
235top of it to handle detected SCSI and SMP devices.
236.Pp
237Both the phymap and iportmap operate in a similar fashion to the
238per-address mode of a tgtmap.
239Entries can be added and removed through direct functions.
240The phymap provides callbacks similar to the tgtmap; however, the
241iportmap does not.
242This is because when an iport is added or removed, a new node is added
243to the devices tree and the driver's
244.Xr attach 9E
245entry point is called with a new
246.Vt dev_info_t
247structure representing the iport.
248.Pp
249During the phymap callback, the HBA driver should create a new iport
250with the unit address passed in from the callback function.
251This relationship is important when taking advantage of the ability to
252map between an iport and the set of phys that it represents.
253.Pp
254The following functions are used to manage iportmaps:
255.Bl -dash
256.It
257.Xr scsi_hba_iportmap_create 9F
258.It
259.Xr scsi_hba_iportmap_iport_add 9F
260.It
261.Xr scsi_hba_iportmap_iport_remove 9F
262.It
263.Xr scsi_hba_iportmap_destroy 9F
264.El
265.Pp
266The following functions are used to manage phymaps:
267.Bl -dash
268.It
269.Xr sas_phymap_create 9F
270.It
271.Xr sas_phymap_destroy 9F
272.It
273.Xr sas_phymap_phy_add 9F
274.It
275.Xr sas_phymap_phy_rem 9F
276.El
277.Ss SCSI Complex Addressing
278Traditionally, SCSI devices were represented by a simple structure, the
279.Xr scsi_address 9S .
280This represented devices by a simple target and lun number.
281While this interface is useful for simple devices and traditional
282parallel SCSI devices, it is not as useful for SAS-era devices where the
283SCSI bus is now a fabric.
284A driver may opt into such a complex addressing mode by setting the
285.Dv SCSI_HBA_ADDR_COMPLEX
286flag.
287.Pp
288When this flag is set, the HBA driver must treat the SCSI address
289as an opaque structure.
290Once in this mode, the driver may get and set a private data structure
291on the SCSI device.
292This is facilitated by the
293.Xr scsi_device_hba_private_set 9F
294and
295.Xr scsi_device_hba_private_get 9F
296functions.
297In addition, the system provides a means to map between the
298.Xr scsi_address 9S
299structure and the corresponding
300.Xr scsi_device 9S
301structure.
302This is performed by the
303.Xr scsi_device_unit_address 9F
304function.
305.Sh SEE ALSO
306.Xr attach 9E ,
307.Xr detach 9E ,
308.Xr sas_phymap_create 9F ,
309.Xr sas_phymap_destroy 9F ,
310.Xr sas_phymap_phy_add 9F ,
311.Xr sas_phymap_phy_rem 9F ,
312.Xr scsi_device_hba_private_get 9F ,
313.Xr scsi_device_hba_private_set 9F ,
314.Xr scsi_device_unit_address 9F ,
315.Xr scsi_hba_attach_setup 9F ,
316.Xr scsi_hba_iport_register 9F ,
317.Xr scsi_hba_iport_unit_address 9F ,
318.Xr scsi_hba_iportmap_create 9F ,
319.Xr scsi_hba_iportmap_destroy 9F ,
320.Xr scsi_hba_iportmap_iport_add 9F ,
321.Xr scsi_hba_iportmap_iport_remove 9F ,
322.Xr scsi_hba_tgtmap_create 9F ,
323.Xr scsi_hba_tgtmap_destroy 9F ,
324.Xr scsi_hba_tgtmap_set_add 9F ,
325.Xr scsi_hba_tgtmap_set_begin 9F ,
326.Xr scsi_hba_tgtmap_set_end 9F ,
327.Xr scsi_hba_tgtmap_set_flush 9F ,
328.Xr scsi_hba_tgtmap_tgt_add 9F ,
329.Xr scsi_hba_tgtmap_tgt_remove 9F ,
330.Xr scsi_address 9S ,
331.Xr scsi_device 9S ,
332.Xr scsi_hba_tran 9S
333