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