xref: /illumos-gate/usr/src/man/man9f/scsi_hba_tgtmap_create.9f (revision c2af9d806aba2e4f6d513af9b700509b9ed978f0)
13385b472SRobert Mustacchi.\"
23385b472SRobert Mustacchi.\" This file and its contents are supplied under the terms of the
33385b472SRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0.
43385b472SRobert Mustacchi.\" You may only use this file in accordance with the terms of version
53385b472SRobert Mustacchi.\" 1.0 of the CDDL.
63385b472SRobert Mustacchi.\"
73385b472SRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this
83385b472SRobert Mustacchi.\" source.  A copy of the CDDL is also available via the Internet at
93385b472SRobert Mustacchi.\" http://www.illumos.org/license/CDDL.
103385b472SRobert Mustacchi.\"
113385b472SRobert Mustacchi.\"
12*c2af9d80SRobert Mustacchi.\" Copyright 2019, Joyent, Inc.
133385b472SRobert Mustacchi.\"
14*c2af9d80SRobert Mustacchi.Dd April 22, 2019
153385b472SRobert Mustacchi.Dt SCSI_HBA_TGTMAP_CREATE 9F
163385b472SRobert Mustacchi.Os
173385b472SRobert Mustacchi.Sh NAME
183385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_create ,
193385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_destroy ,
203385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_set_begin ,
213385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_set_add ,
223385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_set_end ,
233385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_set_flush ,
243385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_tgt_add ,
253385b472SRobert Mustacchi.Nm scsi_hba_tgtmap_tgt_remove
263385b472SRobert Mustacchi.Nd SCSI target map functions
273385b472SRobert Mustacchi.Sh SYNOPSIS
283385b472SRobert Mustacchi.In sys/scsi/scsi.h
293385b472SRobert Mustacchi.Ft int
303385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_create
313385b472SRobert Mustacchi.Fa "dev_info_t *dip"
323385b472SRobert Mustacchi.Fa "scsi_tgtmap_mode_t mode"
333385b472SRobert Mustacchi.Fa "int csync_usec"
343385b472SRobert Mustacchi.Fa "int settle_usec"
353385b472SRobert Mustacchi.Fa "void *tgtmap_priv"
363385b472SRobert Mustacchi.Fa "scsi_tgt_activate_cb_t activate_cb"
373385b472SRobert Mustacchi.Fa "scsi_tgt_deactivate_cb_t deactivate_cb"
383385b472SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmapout"
393385b472SRobert Mustacchi.Fc
403385b472SRobert Mustacchi.Ft void
413385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_destroy
423385b472SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmap"
433385b472SRobert Mustacchi.Fc
443385b472SRobert Mustacchi.Ft void
453385b472SRobert Mustacchi.Fo (*scsi_tgt_activate_cb_t)
463385b472SRobert Mustacchi.Fa "void *tgtmap_priv"
473385b472SRobert Mustacchi.Fa "char *tgt_addr"
483385b472SRobert Mustacchi.Fa "scsi_tgtmap_tgt_type_t type"
493385b472SRobert Mustacchi.Fa "void **tgt_privp"
503385b472SRobert Mustacchi.Fc
513385b472SRobert Mustacchi.Ft boolean_t
523385b472SRobert Mustacchi.Fo (*scsi_tgt_deactivate_cb_t)
533385b472SRobert Mustacchi.Fa "void *tgtmap_priv"
543385b472SRobert Mustacchi.Fa "char *tgt_addr"
553385b472SRobert Mustacchi.Fa "scsi_tgtmap_tgt_type_t type"
563385b472SRobert Mustacchi.Fa "void *tgt_priv"
573385b472SRobert Mustacchi.Fa "scsi_tgtmap_deact_rsn_t deact"
583385b472SRobert Mustacchi.Fc
593385b472SRobert Mustacchi.Ft int
603385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_set_begin
61*c2af9d80SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmap"
623385b472SRobert Mustacchi.Fc
633385b472SRobert Mustacchi.Ft int
643385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_set_add
653385b472SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmap"
663385b472SRobert Mustacchi.Fa "scsi_tgtmap_tgt_type_t type"
673385b472SRobert Mustacchi.Fa "char *tgt_addr"
683385b472SRobert Mustacchi.Fa "void *tgt_priv"
693385b472SRobert Mustacchi.Fc
703385b472SRobert Mustacchi.Ft int
713385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_set_end
72*c2af9d80SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmap"
73*c2af9d80SRobert Mustacchi.Fa "uint_t flags"
743385b472SRobert Mustacchi.Fc
753385b472SRobert Mustacchi.Ft int
763385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_set_flush
77*c2af9d80SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmap"
783385b472SRobert Mustacchi.Fc
793385b472SRobert Mustacchi.Ft int
803385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_tgt_add
813385b472SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmap"
823385b472SRobert Mustacchi.Fa "scsi_tgtmap_tgt_type_t type"
833385b472SRobert Mustacchi.Fa "char *tgt_addr"
843385b472SRobert Mustacchi.Fa "void *tgt_priv"
853385b472SRobert Mustacchi.Fc
863385b472SRobert Mustacchi.Ft int
873385b472SRobert Mustacchi.Fo scsi_hba_tgtmap_tgt_remove
883385b472SRobert Mustacchi.Fa "scsi_hba_tgtmap_t *tgtmap"
893385b472SRobert Mustacchi.Fa "scsi_tgtmap_tgt_type_t type"
903385b472SRobert Mustacchi.Fa "char *tgt_addr"
913385b472SRobert Mustacchi.Fc
923385b472SRobert Mustacchi.Sh INTERFACE LEVEL
933385b472SRobert Mustacchi.Sy Evolving -
943385b472SRobert MustacchiThis interface is still evolving in illumos.
953385b472SRobert MustacchiAPI and ABI stability is
963385b472SRobert Mustacchinot guaranteed.
973385b472SRobert Mustacchi.Sh PARAMETERS
983385b472SRobert Mustacchi.Bl -tag -width Fa
993385b472SRobert Mustacchi.It Fa dip
1003385b472SRobert MustacchiPointer to
1013385b472SRobert Mustacchi.Vt dev_info
1023385b472SRobert Mustacchistructure.
1033385b472SRobert Mustacchi.It Fa mode
1043385b472SRobert MustacchiOne of the following values:
1053385b472SRobert Mustacchi.Bl -tag -width Dv
1063385b472SRobert Mustacchi.It Dv SCSI_TM_FULLSET
1073385b472SRobert MustacchiThe target map operates by full-set reporting.
1083385b472SRobert Mustacchi.It Dv SCSI_TM_PERADDR
1093385b472SRobert MustacchiThe target map operates by per-address reporting.
1103385b472SRobert Mustacchi.El
1113385b472SRobert Mustacchi.It Fa csync_usec
1123385b472SRobert MustacchiA time in microseconds.
1133385b472SRobert Mustacchi.It Fa settle_usec
1143385b472SRobert MustacchiA time in microseconds.
1153385b472SRobert Mustacchi.It Fa tgtmap_priv
1163385b472SRobert MustacchiA private value to be passed to callback functions.
1173385b472SRobert Mustacchi.It Fa activate_cb
1183385b472SRobert MustacchiAn optional callback that will be called when a new device is being
1193385b472SRobert Mustacchiadded to the system.
1203385b472SRobert Mustacchi.It Fa deactivate_cb
1213385b472SRobert MustacchiAn optional callback that will be called when an existing devices is
1223385b472SRobert Mustacchiremoved from the system.
1233385b472SRobert Mustacchi.It Fa tgtmapout
1243385b472SRobert MustacchiPointer where the target map is stored.
1253385b472SRobert Mustacchi.It Fa tgtmap
1263385b472SRobert MustacchiPointer to an allocated target map.
127*c2af9d80SRobert Mustacchi.It Fa flags
128*c2af9d80SRobert MustacchiFlags that modify the behavior of the function.
129*c2af9d80SRobert MustacchiCurrently reserved and should be passed as
130*c2af9d80SRobert Mustacchi.Sy 0 .
1313385b472SRobert Mustacchi.It Fa tgt_addr
1323385b472SRobert MustacchiThe address of the target map entry the callback is acting upon.
1333385b472SRobert Mustacchi.It Fa type
1343385b472SRobert MustacchiOne of the following values, indicating the type of the target:
1353385b472SRobert Mustacchi.Bl -tag -width Dv
1363385b472SRobert Mustacchi.It Dv SCSI_TGT_SCSI_DEVICE
1373385b472SRobert MustacchiThe target is some form of SCSI device such as a parallel SCSI, SATA,
1383385b472SRobert MustacchiSAS, SES, etc.
1393385b472SRobert Mustacchi.It Dv SCSI_TGT_SMP_DEVICE
1403385b472SRobert MustacchiThe target is a SCSI Management Protocol device.
1413385b472SRobert Mustacchi.El
1423385b472SRobert Mustacchi.It Fa deact
1433385b472SRobert MustacchiOne of the following values, indicating why the target is being removed:
1443385b472SRobert Mustacchi.Bl -tag -width Dv
1453385b472SRobert Mustacchi.It Dv SCSI_TGT_DEACT_RSN_GONE
1463385b472SRobert MustacchiThe device is being deactivated because it is gone.
1473385b472SRobert Mustacchi.It Dv SCSI_TGT_DEACT_RSN_CFG_FAIL
1483385b472SRobert MustacchiThe device is being deactivated because the configuration callback
1493385b472SRobert Mustacchifailed.
1503385b472SRobert Mustacchi.It Dv SCSI_TGT_DEACT_RSN_UNSTBL
1513385b472SRobert MustacchiThe device is being deactivated because it was added and removed during
1523385b472SRobert Mustacchithe stabilization period and therefore is considered unstable.
1533385b472SRobert Mustacchi.El
1543385b472SRobert Mustacchi.El
1553385b472SRobert Mustacchi.Sh DESCRIPTION
1563385b472SRobert MustacchiThe
1573385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_create
1583385b472SRobert Mustacchiand
1593385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_destroy
1603385b472SRobert Mustacchifunctions are used to create and destroy target maps.
1613385b472SRobert MustacchiA target map is used to manage SCSI and SMP (SCSI Management Protocol)
1623385b472SRobert Mustacchidevices.
1633385b472SRobert MustacchiFor more background on target maps, see
1643385b472SRobert Mustacchi.Xr tgtmap 9 .
1653385b472SRobert Mustacchi.Pp
1663385b472SRobert MustacchiTo create a target map, the driver should call the
1673385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_create
1683385b472SRobert Mustacchifunction.
1693385b472SRobert MustacchiUpon successful completion, a pointer to the target map will be placed
1703385b472SRobert Mustacchiin the
1713385b472SRobert Mustacchi.Fa tgtmapout
1723385b472SRobert Mustacchiargument.
1733385b472SRobert Mustacchi.Pp
1743385b472SRobert MustacchiThe
1753385b472SRobert Mustacchi.Fa dip
1763385b472SRobert Mustacchiargument should correspond to the HBA driver's device node or one of its
1773385b472SRobert Mustacchiiports.
1783385b472SRobert Mustacchi.Pp
1793385b472SRobert MustacchiThe
1803385b472SRobert Mustacchi.Fa mode
1813385b472SRobert Mustacchiargument describes how addresses are reported into the target map and
1823385b472SRobert Mustacchithe functions used to add and remove devices.
1833385b472SRobert MustacchiIf
1843385b472SRobert Mustacchi.Fa mode
1853385b472SRobert Mustacchiis
1863385b472SRobert Mustacchi.Dv SCSI_TM_FULLSET
1873385b472SRobert Mustacchithen the driver must always report all the devices that are in the set
1883385b472SRobert Mustacchiand will be told when the corresponding devices have been removed.
1893385b472SRobert MustacchiSee
1903385b472SRobert Mustacchithe section
1913385b472SRobert Mustacchi.Sx Full-Set Reporting
1923385b472SRobert Mustacchifor more information.
1933385b472SRobert Mustacchi.Pp
1943385b472SRobert MustacchiOtherwise, the driver should set the
1953385b472SRobert Mustacchi.Fa mode
1963385b472SRobert Mustacchiargument to
1973385b472SRobert Mustacchi.Dv SCSI_TM_PERADDR
1983385b472SRobert Mustacchiand use the
1993385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_add
2003385b472SRobert Mustacchiand
2013385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_destroy
2023385b472SRobert Mustacchifunctions.
2033385b472SRobert MustacchiSee the section
2043385b472SRobert Mustacchi.Sx Per-Address Reporting
2053385b472SRobert Mustacchifor more information.
2063385b472SRobert Mustacchi.Pp
2073385b472SRobert MustacchiThe
2083385b472SRobert Mustacchi.Fa csync_usec
2093385b472SRobert Mustacchiand
2103385b472SRobert Mustacchi.Fa settle_usec
2113385b472SRobert Mustacchiare both times measured in microseconds that control two different
2123385b472SRobert Mustacchiproperties of the target map and how it behaves.
2133385b472SRobert MustacchiThe value in
2143385b472SRobert Mustacchi.Fa settle_usec
2153385b472SRobert Mustacchiindicates the amount of time that the system should wait to quiesce all
2163385b472SRobert Mustacchichanges and consider the resulting system stable.
2173385b472SRobert MustacchiChanges will not be reported until after
2183385b472SRobert Mustacchi.Fa settle_usec
2193385b472SRobert Mustacchihave passed.
2203385b472SRobert Mustacchi.Fa csync_usec
2213385b472SRobert Mustacchiindicates how much time needs to elapse after creation before an initial
2223385b472SRobert Mustacchienumeration has been completed.
2233385b472SRobert Mustacchi.Pp
2243385b472SRobert MustacchiThe
2253385b472SRobert Mustacchi.Fa activate_cb
2263385b472SRobert Mustacchiand
2273385b472SRobert Mustacchi.Fa deactivate_cb
2283385b472SRobert Mustacchiarguments are optional function pointers that will be run in the context
2293385b472SRobert Mustacchiof devices being added and removed from the system.
2303385b472SRobert MustacchiThis allows the HBA driver to perform any required operations prior to
2313385b472SRobert Mustacchithe system attaching a target driver such as
2323385b472SRobert Mustacchi.Xr sd 7D
2333385b472SRobert Mustacchior
2343385b472SRobert Mustacchi.Xr ses 7D
2353385b472SRobert Mustacchiin the activate case and after the system has detached the driver, in
2363385b472SRobert Mustacchithe removal case.
2373385b472SRobert Mustacchi.Pp
2383385b472SRobert MustacchiTo destroy a target map, a caller should use the
2393385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_destroy
2403385b472SRobert Mustacchifunction.
2413385b472SRobert MustacchiDestroying a target map causes all currently present devices
2423385b472SRobert Mustacchito be deactivated, as though they were removed, prior to the
2433385b472SRobert Mustacchifinal destruction of the target map.
2443385b472SRobert Mustacchi.Ss Callbacks
2453385b472SRobert MustacchiTarget maps allow for callbacks to be registered and called when
2463385b472SRobert Mustacchidevices are being added and removed from the system.
2473385b472SRobert MustacchiA driver specifies these when the target map is created by passing in
2483385b472SRobert Mustacchifunction pointers to
2493385b472SRobert Mustacchithe
2503385b472SRobert Mustacchi.Fn activate_cb
2513385b472SRobert Mustacchiand
2523385b472SRobert Mustacchi.Fn deactivate_cb
2533385b472SRobert Mustacchiarguments.
2543385b472SRobert Mustacchi.Pp
2553385b472SRobert MustacchiWhen a new address is registered in a target map and the driver has
2563385b472SRobert Mustacchispecified a function in the
2573385b472SRobert Mustacchi.Fa activate_cb
2583385b472SRobert Mustacchiargument, the driver will eventually have their activation function
2593385b472SRobert Mustacchicalled.
2603385b472SRobert MustacchiThis call will be asynchronous with respect to the adding and
2613385b472SRobert Mustacchiremoving of entries, regardless of whether the target map is using
2623385b472SRobert Mustacchiper-address or full-set reporting.
2633385b472SRobert MustacchiThis call will occur before any driver is bound to the discovered
2643385b472SRobert Mustacchiaddress.
2653385b472SRobert Mustacchi.Pp
2663385b472SRobert MustacchiThe
2673385b472SRobert Mustacchi.Fa tgtmap_priv
2683385b472SRobert Mustacchiargument will point to the optional, private argument that was passed
2693385b472SRobert Mustacchito the
2703385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_create
2713385b472SRobert Mustacchifunction when the target map was created.
2723385b472SRobert MustacchiThe
2733385b472SRobert Mustacchi.Fa tgt_addr
2743385b472SRobert Mustacchiand
2753385b472SRobert Mustacchi.Fa tgt_type
2763385b472SRobert Mustacchiwill describe the address and type of the new device and will correspond
2773385b472SRobert Mustacchiwith the values passed into either the
2783385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_add
2793385b472SRobert Mustacchior
2803385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_add
2813385b472SRobert Mustacchifunctions.
2823385b472SRobert Mustacchi.Pp
2833385b472SRobert MustacchiThe
2843385b472SRobert Mustacchi.Fa tgt_privp
2853385b472SRobert Mustacchiargument is a modifiable private value.
2863385b472SRobert MustacchiInitially,
2873385b472SRobert Mustacchi.Fa tgt_privp
2883385b472SRobert Mustacchipoints to the value passed in as
2893385b472SRobert Mustacchi.Fa tgt_priv
2903385b472SRobert Mustacchito either the
2913385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_add
2923385b472SRobert Mustacchior
2933385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_add
2943385b472SRobert Mustacchifunctions.
2953385b472SRobert MustacchiThe driver may change the value as needed.
2963385b472SRobert MustacchiIt will receive the value stored in
2973385b472SRobert Mustacchi.Fa tgt_privp
2983385b472SRobert Mustacchiduring the deactivate callback.
2993385b472SRobert Mustacchi.Pp
3003385b472SRobert MustacchiWhen a target map has been updated to indicate that a device has been
3013385b472SRobert Mustacchiremoved, then the driver will receive a deactivation callback if it
3023385b472SRobert Mustacchiregistered one.
3033385b472SRobert MustacchiThe deactivate callback will occur after a driver has
3043385b472SRobert Mustacchibeen detached from the corresponding device.
3053385b472SRobert Mustacchi.Pp
3063385b472SRobert MustacchiThe
3073385b472SRobert Mustacchi.Fa tgtmap_priv ,
3083385b472SRobert Mustacchi.Fa tgt_addr ,
3093385b472SRobert Mustacchiand
3103385b472SRobert Mustacchi.Fa type
3113385b472SRobert Mustacchiarguments to the callback function are the same as for the activate
3123385b472SRobert Mustacchicase.
3133385b472SRobert MustacchiThe
3143385b472SRobert Mustacchi.Fa tgt_priv
3153385b472SRobert Mustacchipointer will be set to the value that was passed when the device was
3163385b472SRobert Mustacchiadded and will reflect any updates made during an activate callback, if
3173385b472SRobert Mustacchipresent.
3183385b472SRobert Mustacchi.Pp
3193385b472SRobert MustacchiThe
3203385b472SRobert Mustacchi.Fa deact
3213385b472SRobert Mustacchiargument gives the driver some amount of information as to why device
3223385b472SRobert Mustacchiwas being removed.
3233385b472SRobert MustacchiThe deactivation reason provides the driver
3243385b472SRobert Mustacchimore information about why the address was being removed from the target
3253385b472SRobert Mustacchimap which can be useful in the cases that it itself did not issue it.
3263385b472SRobert Mustacchi.Pp
3273385b472SRobert MustacchiThe return value indicates whether or not some amount of rediscovery of
3283385b472SRobert Mustacchithe address is desired or not.
3293385b472SRobert MustacchiThis is only meaningful in the case where the
3303385b472SRobert Mustacchi.Fa deact
3313385b472SRobert Mustacchiargument was
3323385b472SRobert Mustacchi.Dv SCSI_TGT_DEACT_RSN_CFG_FAIL .
3333385b472SRobert MustacchiIf the driver does wish to attempt rediscovery, then it should return
3343385b472SRobert Mustacchi.Dv B_TRUE .
3353385b472SRobert MustacchiOtherwise, the driver should return
3363385b472SRobert Mustacchi.Dv B_FALSE .
3373385b472SRobert MustacchiIf in doubt, use the return value
3383385b472SRobert Mustacchi.Dv B_FALSE .
3393385b472SRobert MustacchiNote, even if the driver returns
3403385b472SRobert Mustacchi.Dv B_TRUE ,
3413385b472SRobert Mustacchino action may be taken by the system.
3423385b472SRobert Mustacchi.Ss Full-Set Reporting
3433385b472SRobert MustacchiFull-Set reporting is one way of managing a target map.
3443385b472SRobert MustacchiIn full-set reporting, whenever an update is being made, the entire data
3453385b472SRobert Mustacchiset is reported to the target map.
3463385b472SRobert MustacchiThe target map then determines which
3473385b472SRobert Mustacchiaddresses are new, which have been removed, and which have stayed the
3483385b472SRobert Mustacchisame and updates the system state appropriately.
3493385b472SRobert MustacchiIf devices have been added or removed from the system, then any activate
3503385b472SRobert Mustacchiand deactivate endpoints will be called.
3513385b472SRobert Mustacchi.Pp
3523385b472SRobert MustacchiTo begin a new report, the driver should call the
3533385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_begin
3543385b472SRobert Mustacchifunction.
3553385b472SRobert MustacchiOnce the report has begun, the driver should add devices by calling the
3563385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_add
3573385b472SRobert Mustacchifunction.
3583385b472SRobert MustacchiOnce all devices have been added, the driver should call the
3593385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_end
3603385b472SRobert Mustacchifunction to indicate that the target map processing has ended.
3613385b472SRobert MustacchiIf driver wishes to discard a report that has begun, but not yet
3623385b472SRobert Mustacchiterminated, then the driver should call the
3633385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_flush
3643385b472SRobert Mustacchifunction.
3653385b472SRobert Mustacchi.Pp
3663385b472SRobert MustacchiWhen adding entries, the driver should indicate the address of the
3673385b472SRobert Mustacchidevice in
3683385b472SRobert Mustacchi.Fa tgt_addr .
3693385b472SRobert MustacchiThis will generally be a world wide number (WWN) in a unit-addressable
3703385b472SRobert Mustacchiform.
3713385b472SRobert MustacchiHowever, the driver may use its own synthetic numbering.
3723385b472SRobert MustacchiThis address will be passed to the activate callbacks and will also be
3733385b472SRobert Mustacchiused as the address of the
3743385b472SRobert Mustacchi.Xr scsi_device 9S
3753385b472SRobert Mustacchiin the
3763385b472SRobert Mustacchi.Xr tran_start 9E
3773385b472SRobert Mustacchientry point.
3783385b472SRobert Mustacchi.Pp
3793385b472SRobert MustacchiThe
3803385b472SRobert Mustacchi.Fa type
3813385b472SRobert Mustacchiargument indicates how the kernel will interpret the type of device.
3823385b472SRobert MustacchiAt this time, devices are broken into two broad categories.
3833385b472SRobert MustacchiThings which are some kind of SCSI device, whether parallel, SCSI, SATA
3843385b472SRobert Mustacchibehind a SATL, SES, etc. should use the type
3853385b472SRobert Mustacchi.Dv SCSI_TGT_SCSI_DEVICE .
3863385b472SRobert MustacchiThe other group,
3873385b472SRobert Mustacchi.Dv SCSI_TGT_SMP_DEVICE ,
3883385b472SRobert Mustacchiis for SCSI Management Protocol (SMP) devices.
3893385b472SRobert Mustacchi.Pp
3903385b472SRobert MustacchiThe
3913385b472SRobert Mustacchi.Fa tgt_priv
3923385b472SRobert Mustacchiargument will be passed to the activate and deactivate callbacks,
3933385b472SRobert Mustacchiallowing the driver to pass around data corresponding to this address.
3943385b472SRobert Mustacchi.Ss Per-Address Reporting
3953385b472SRobert MustacchiWhen using a target map with per-address reporting, the driver is
3963385b472SRobert Mustacchiresponsible for indicating what devices have been added and removed.
3973385b472SRobert MustacchiThis is useful for various hardware configurations where all entries and
3983385b472SRobert Mustacchiremovals are processes in a highly-reliable fashion where hardware
3993385b472SRobert Mustacchicannot drop entries.
4003385b472SRobert Mustacchi.Pp
4013385b472SRobert MustacchiTo add a new device, the driver should call the
4023385b472SRobert Mustacchi.Fa scsi_hba_tgtmap_tgt_add
4033385b472SRobert Mustacchifunction.
4043385b472SRobert MustacchiThe
4053385b472SRobert Mustacchi.Fa tgt_addr
4063385b472SRobert Mustacchiand
4073385b472SRobert Mustacchi.Fa type
4083385b472SRobert Mustacchiarguments describe the address and what kind of device the address
4093385b472SRobert Mustacchicorresponds to.
4103385b472SRobert MustacchiFor more information, see the previous section,
4113385b472SRobert Mustacchi.Sx Full-Address Reporting .
4123385b472SRobert MustacchiThe
4133385b472SRobert Mustacchi.Fa tgt_priv
4143385b472SRobert Mustacchiargument will be passed along to the activate and deactivate functions,
4153385b472SRobert Mustacchiallowing the driver to associate a value with the address in question.
4163385b472SRobert Mustacchi.Pp
4173385b472SRobert MustacchiWhen a device has been removed, the driver should call the
4183385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_remove
4193385b472SRobert Mustacchifunction, ensuring that both the
4203385b472SRobert Mustacchi.Fa tgt_addr
4213385b472SRobert Mustacchiand
4223385b472SRobert Mustacchi.Fa type
4233385b472SRobert Mustacchiarguments match those that were used when calling the
4243385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_add
4253385b472SRobert Mustacchifunction.
4263385b472SRobert Mustacchi.Sh CONTEXT
4273385b472SRobert MustacchiThe
4283385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_create
4293385b472SRobert Mustacchiand
4303385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_destroy
4313385b472SRobert Mustacchifunctions are generally called from the context of the
4323385b472SRobert Mustacchi.Xr attach 9E
4333385b472SRobert Mustacchiand
4343385b472SRobert Mustacchi.Xr detach 9E
4353385b472SRobert Mustacchientry points of HBA drivers and their iports, though may also be called
4363385b472SRobert Mustacchifrom
4373385b472SRobert Mustacchi.Sy user
4383385b472SRobert Mustacchior
4393385b472SRobert Mustacchi.Sy kernel
4403385b472SRobert Mustacchicontext.
4413385b472SRobert Mustacchi.Pp
4423385b472SRobert MustacchiThe optional
4433385b472SRobert Mustacchi.Fn activate_cb
4443385b472SRobert Mustacchiand
4453385b472SRobert Mustacchi.Fn deactivate_cb
4463385b472SRobert Mustacchifunctions for a target map will be called into the driver from
4473385b472SRobert Mustacchi.Sy kernel
4483385b472SRobert Mustacchicontext.
4493385b472SRobert Mustacchi.Pp
4503385b472SRobert MustacchiThe
4513385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_begin ,
4523385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_add ,
4533385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_end ,
4543385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_flush ,
4553385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_add ,
4563385b472SRobert Mustacchiand
4573385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_remove
4583385b472SRobert Mustacchifunctions may be called from
4593385b472SRobert Mustacchi.Sy user
4603385b472SRobert Mustacchior
4613385b472SRobert Mustacchi.Sy kernel
4623385b472SRobert Mustacchicontext.
4633385b472SRobert MustacchiIt is recommended that device drivers do not call these functions from
4643385b472SRobert Mustacchi.Sy interrupt
4653385b472SRobert Mustacchicontext and instead should schedule deferred work with a task queue
4663385b472SRobert Mustacchior with
4673385b472SRobert Mustacchi.Xr timeout 9F
4683385b472SRobert Mustacchiif they receive notifications during an interrupt that causes them to
4693385b472SRobert Mustacchineed to call these functions.
4703385b472SRobert Mustacchi.Sh RETURN VALUES
4713385b472SRobert MustacchiUpon successful completion, the
4723385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_create ,
4733385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_destroy ,
4743385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_begin ,
4753385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_add ,
4763385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_end ,
4773385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_set_flush ,
4783385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_add ,
4793385b472SRobert Mustacchiand
4803385b472SRobert Mustacchi.Fn scsi_hba_tgtmap_tgt_remove
4813385b472SRobert Mustacchifunctions return
4823385b472SRobert Mustacchi.Dv DDI_SUCCESS .
4833385b472SRobert MustacchiOtherwise,
4843385b472SRobert Mustacchi.Dv DDI_FAILURE
4853385b472SRobert Mustacchiis returned.
4863385b472SRobert Mustacchi.Sh SEE ALSO
4873385b472SRobert Mustacchi.Xr sd 7D ,
4883385b472SRobert Mustacchi.Xr ses 7D ,
4893385b472SRobert Mustacchi.Xr tgtmap 9 ,
4903385b472SRobert Mustacchi.Xr attach 9E ,
4913385b472SRobert Mustacchi.Xr detach 9E ,
4923385b472SRobert Mustacchi.Xr tran_start 9E ,
4933385b472SRobert Mustacchi.Xr timeout 9F ,
4943385b472SRobert Mustacchi.Xr scsi_device 9S
495