1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  24  */
  25 
  26 #ifndef _SYS_SCSI_IMPL_TRANSPORT_H
  27 #define _SYS_SCSI_IMPL_TRANSPORT_H
  28 
  29 /*
  30  * Include the loadable module wrapper.
  31  */
  32 #include <sys/modctl.h>
  33 #include <sys/note.h>
  34 
  35 #ifdef  __cplusplus
  36 extern "C" {
  37 #endif
  38 
  39 #ifdef  _KERNEL
  40 
  41 /*
  42  * Opaque  handles to address maps
  43  */
  44 typedef struct __scsi_iportmap  scsi_hba_iportmap_t;
  45 typedef struct __scsi_tgtmap    scsi_hba_tgtmap_t;
  46 
  47 /*
  48  * SCSI transport structures
  49  *
  50  *      As each Host Adapter makes itself known to the system,
  51  *      it will create and register with the library the structure
  52  *      described below. This is so that the library knows how to route
  53  *      packets, resource control requests, and capability requests
  54  *      for any particular host adapter. The 'a_hba_tran' field of a
  55  *      scsi_address structure made known to a Target driver will
  56  *      point to one of these transport structures.
  57  */
  58 
  59 typedef struct scsi_hba_tran    scsi_hba_tran_t;
  60 
  61 struct scsi_hba_tran {
  62         /*
  63          * Ptr to the device info structure for this particular HBA. If a SCSA
  64          * HBA driver separates initiator port function from HBA function,
  65          * this field still refers to the HBA and is used to manage DMA.
  66          */
  67         dev_info_t      *tran_hba_dip;
  68 
  69         /*
  70          * Private fields for use by the HBA itself.
  71          */
  72         void            *tran_hba_private;      /* HBA softstate */
  73 
  74         /*
  75          * The following two fields are only used in the deprecated
  76          * SCSI_HBA_TRAN_CLONE case. Use SCSI_HBA_ADDR_COMPLEX instead.
  77          */
  78         void                    *tran_tgt_private;
  79         struct scsi_device      *tran_sd;
  80 
  81         /*
  82          * Vectors to point to specific HBA entry points
  83          */
  84         int             (*tran_tgt_init)(
  85                                 dev_info_t              *hba_dip,
  86                                 dev_info_t              *tgt_dip,
  87                                 scsi_hba_tran_t         *tran,
  88                                 struct scsi_device      *sd);
  89 
  90         int             (*tran_tgt_probe)(
  91                                 struct scsi_device      *sd,
  92                                 int                     (*callback)(
  93                                                                 void));
  94         void            (*tran_tgt_free)(
  95                                 dev_info_t              *hba_dip,
  96                                 dev_info_t              *tgt_dip,
  97                                 scsi_hba_tran_t         *tran,
  98                                 struct scsi_device      *sd);
  99 
 100         int             (*tran_start)(
 101                                 struct scsi_address     *ap,
 102                                 struct scsi_pkt         *pkt);
 103 
 104         int             (*tran_reset)(
 105                                 struct scsi_address     *ap,
 106                                 int                     level);
 107 
 108         int             (*tran_abort)(
 109                                 struct scsi_address     *ap,
 110                                 struct scsi_pkt         *pkt);
 111 
 112         int             (*tran_getcap)(
 113                                 struct scsi_address     *ap,
 114                                 char                    *cap,
 115                                 int                     whom);
 116 
 117         int             (*tran_setcap)(
 118                                 struct scsi_address     *ap,
 119                                 char                    *cap,
 120                                 int                     value,
 121                                 int                     whom);
 122 
 123         struct scsi_pkt *(*tran_init_pkt)(
 124                                 struct scsi_address     *ap,
 125                                 struct scsi_pkt         *pkt,
 126                                 struct buf              *bp,
 127                                 int                     cmdlen,
 128                                 int                     statuslen,
 129                                 int                     tgtlen,
 130                                 int                     flags,
 131                                 int                     (*callback)(
 132                                                                 caddr_t arg),
 133                                 caddr_t                 callback_arg);
 134 
 135         void            (*tran_destroy_pkt)(
 136                                 struct scsi_address     *ap,
 137                                 struct scsi_pkt         *pkt);
 138 
 139         void            (*tran_dmafree)(
 140                                 struct scsi_address     *ap,
 141                                 struct scsi_pkt         *pkt);
 142 
 143         void            (*tran_sync_pkt)(
 144                                 struct scsi_address     *ap,
 145                                 struct scsi_pkt         *pkt);
 146 
 147         int             (*tran_reset_notify)(
 148                                 struct scsi_address     *ap,
 149                                 int                     flag,
 150                                 void                    (*callback)(caddr_t),
 151                                 caddr_t                 arg);
 152 
 153         int             (*tran_get_bus_addr)(
 154                                 struct scsi_device      *sd,
 155                                 char                    *name,
 156                                 int                     len);
 157 
 158         int             (*tran_get_name)(
 159                                 struct scsi_device      *sd,
 160                                 char                    *name,
 161                                 int                     len);
 162 
 163         int             (*tran_clear_aca)(
 164                                 struct scsi_address     *ap);
 165 
 166         int             (*tran_clear_task_set)(
 167                                 struct scsi_address     *ap);
 168 
 169         int             (*tran_terminate_task)(
 170                                 struct scsi_address     *ap,
 171                                 struct scsi_pkt         *pkt);
 172 
 173         int             (*tran_get_eventcookie)(
 174                                 dev_info_t              *hba_dip,
 175                                 dev_info_t              *tgt_dip,
 176                                 char                    *name,
 177                                 ddi_eventcookie_t       *eventp);
 178 
 179         int             (*tran_add_eventcall)(
 180                                 dev_info_t              *hba_dip,
 181                                 dev_info_t              *tgt_dip,
 182                                 ddi_eventcookie_t       event,
 183                                 void                    (*callback)(
 184                                                 dev_info_t *tgt_dip,
 185                                                 ddi_eventcookie_t event,
 186                                                 void *arg,
 187                                                 void *bus_impldata),
 188                                 void                    *arg,
 189                                 ddi_callback_id_t *cb_id);
 190 
 191         int             (*tran_remove_eventcall)(dev_info_t *devi,
 192                         ddi_callback_id_t cb_id);
 193 
 194         int             (*tran_post_event)(
 195                                 dev_info_t              *hba_dip,
 196                                 dev_info_t              *tgt_dip,
 197                                 ddi_eventcookie_t       event,
 198                                 void                    *bus_impldata);
 199 
 200         int             (*tran_quiesce)(
 201                                 dev_info_t              *hba_dip);
 202 
 203         int             (*tran_unquiesce)(
 204                                 dev_info_t              *hba_dip);
 205 
 206         int             (*tran_bus_reset)(
 207                                 dev_info_t              *hba_dip,
 208                                 int                     level);
 209 
 210         /*
 211          * Implementation-private specifics.
 212          * No HBA should refer to any of the fields below.
 213          * This information can and will change.
 214          */
 215         int                     tran_hba_flags;         /* flag options */
 216 
 217         uint_t                  tran_obs1;
 218         uchar_t                 tran_obs2;
 219         uchar_t                 tran_obs3;
 220 
 221         /*
 222          * open_lock: protect tran_minor_isopen
 223          * open_flag: bit field indicating which minor nodes are open.
 224          *      0 = closed, 1 = shared open, all bits 1 = excl open.
 225          *
 226          * NOTE: Unused if HBA driver implements its own open(9e) entry point.
 227          */
 228         kmutex_t                tran_open_lock;
 229         uint64_t                tran_open_flag;
 230 
 231         /*
 232          * bus_config vectors - ON Consolidation Private
 233          * These interfaces are subject to change.
 234          */
 235         int             (*tran_bus_config)(
 236                                 dev_info_t              *hba_dip,
 237                                 uint_t                  flag,
 238                                 ddi_bus_config_op_t     op,
 239                                 void                    *arg,
 240                                 dev_info_t              **tgt_dipp);
 241 
 242         int             (*tran_bus_unconfig)(
 243                                 dev_info_t              *hba_dip,
 244                                 uint_t                  flag,
 245                                 ddi_bus_config_op_t     op,
 246                                 void                    *arg);
 247 
 248         int             (*tran_bus_power)(
 249                                 dev_info_t              *dip,
 250                                 void                    *impl_arg,
 251                                 pm_bus_power_op_t       op,
 252                                 void                    *arg,
 253                                 void                    *result);
 254 
 255         /*
 256          * Inter-Connect type of transport as defined in
 257          * usr/src/uts/common/sys/scsi/impl/services.h
 258          */
 259         int             tran_interconnect_type;
 260 
 261         /* tran_setup_pkt(9E) related scsi_pkt fields */
 262         int             (*tran_pkt_constructor)(
 263                                 struct scsi_pkt         *pkt,
 264                                 scsi_hba_tran_t         *tran,
 265                                 int                     kmflag);
 266         void            (*tran_pkt_destructor)(
 267                                 struct scsi_pkt         *pkt,
 268                                 scsi_hba_tran_t         *tran);
 269         kmem_cache_t    *tran_pkt_cache_ptr;
 270         uint_t          tran_hba_len;
 271         int             (*tran_setup_pkt)(
 272                                 struct scsi_pkt         *pkt,
 273                                 int                     (*callback)(
 274                                                                 caddr_t arg),
 275                                 caddr_t                 callback_arg);
 276         void            (*tran_teardown_pkt)(
 277                                 struct scsi_pkt         *pkt);
 278         ddi_dma_attr_t  tran_dma_attr;
 279 
 280         void            *tran_extension;
 281 
 282         /*
 283          * An fm_capable HBA driver can set tran_fm_capable prior to
 284          * scsi_hba_attach_setup(). If not set, SCSA provides a default
 285          * implementation.
 286          */
 287         int             tran_fm_capable;
 288 
 289         /*
 290          * Ptr to the device info structure for initiator port. If a SCSA HBA
 291          * driver separates initiator port function from HBA function, this
 292          * field still refers to the initiator port.
 293          */
 294         dev_info_t      *tran_iport_dip;
 295 
 296         /*
 297          * map of initiator ports below HBA
 298          */
 299         scsi_hba_iportmap_t     *tran_iportmap;
 300 
 301         /*
 302          * map of targets below initiator
 303          */
 304         scsi_hba_tgtmap_t       *tran_tgtmap;
 305 
 306 #ifdef  SCSI_SIZE_CLEAN_VERIFY
 307         /*
 308          * Must be last: Building a driver with-and-without
 309          * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for
 310          * differences with a tools like 'wsdiff' allows a developer to verify
 311          * that their driver has no dependencies on scsi*(9S) size.
 312          */
 313         int             _pad[8];
 314 #endif  /* SCSI_SIZE_CLEAN_VERIFY */
 315 };
 316 size_t  scsi_hba_tran_size();                   /* private */
 317 
 318 #ifdef __lock_lint
 319 _NOTE(SCHEME_PROTECTS_DATA("stable data",
 320         scsi_hba_tran::tran_sd
 321         scsi_hba_tran::tran_hba_dip
 322         scsi_hba_tran::tran_hba_flags
 323         scsi_hba_tran::tran_open_flag
 324         scsi_hba_tran::tran_pkt_cache_ptr))
 325 /*
 326  * we only modify the dma attributes (like dma_attr_granular) upon
 327  * attach and in response to a setcap. It is also up to the target
 328  * driver to not have any outstanding I/Os when it is changing the
 329  * capabilities of the transport.
 330  */
 331 _NOTE(SCHEME_PROTECTS_DATA("serialized by target driver", \
 332         scsi_hba_tran::tran_dma_attr.dma_attr_granular))
 333 #endif
 334 
 335 /*
 336  * Prototypes for SCSI HBA interface functions
 337  *
 338  * All these functions are public interfaces, with the
 339  * exception of:
 340  *      interface                               called by
 341  *      scsi_initialize_hba_interface()         _init() of scsi module
 342  *      scsi_uninitialize_hba_interface()       _fini() of scsi module
 343  */
 344 
 345 void            scsi_initialize_hba_interface(void);
 346 
 347 #ifdef  NO_SCSI_FINI_YET
 348 void            scsi_uninitialize_hba_interface(void);
 349 #endif  /* NO_SCSI_FINI_YET */
 350 
 351 int             scsi_hba_init(
 352                                 struct modlinkage       *modlp);
 353 
 354 void            scsi_hba_fini(
 355                                 struct modlinkage       *modlp);
 356 
 357 int             scsi_hba_attach_setup(
 358                                 dev_info_t              *hba_dip,
 359                                 ddi_dma_attr_t          *hba_dma_attr,
 360                                 scsi_hba_tran_t         *tran,
 361                                 int                     flags);
 362 
 363 int             scsi_hba_detach(
 364                                 dev_info_t              *hba_dip);
 365 
 366 scsi_hba_tran_t *scsi_hba_tran_alloc(
 367                                 dev_info_t              *hba_dip,
 368                                 int                     flags);
 369 
 370 int             scsi_tran_ext_alloc(
 371                                 scsi_hba_tran_t         *tran,
 372                                 size_t                  length,
 373                                 int                     flags);
 374 
 375 void            scsi_tran_ext_free(
 376                                 scsi_hba_tran_t         *tran,
 377                                 size_t                  length);
 378 
 379 void            scsi_hba_tran_free(
 380                                 scsi_hba_tran_t         *tran);
 381 
 382 int             scsi_hba_probe(
 383                                 struct scsi_device      *sd,
 384                                 int                     (*callback)(void));
 385 
 386 int             scsi_hba_probe_pi(
 387                                 struct scsi_device      *sd,
 388                                 int                     (*callback)(void),
 389                                 int                     pi);
 390 
 391 int             scsi_hba_ua_get_reportdev(
 392                                 struct scsi_device      *sd,
 393                                 char                    *ba,
 394                                 int                     len);
 395 
 396 int             scsi_hba_ua_get(
 397                                 struct scsi_device      *sd,
 398                                 char                    *ua,
 399                                 int                     len);
 400 
 401 char            *scsi_get_device_type_string(
 402                                 char                    *prop_name,
 403                                 dev_info_t              *hba_dip,
 404                                 struct scsi_device      *sd);
 405 
 406 int             scsi_get_scsi_maxluns(
 407                                 struct scsi_device      *sd);
 408 
 409 int             scsi_get_scsi_options(
 410                                 struct scsi_device      *sd,
 411                                 int                     default_scsi_options);
 412 
 413 int             scsi_get_device_type_scsi_options(
 414                                 dev_info_t              *hba_dip,
 415                                 struct scsi_device      *sd,
 416                                 int                     default_scsi_options);
 417 
 418 struct scsi_pkt *scsi_hba_pkt_alloc(
 419                                 dev_info_t              *hba_dip,
 420                                 struct scsi_address     *ap,
 421                                 int                     cmdlen,
 422                                 int                     statuslen,
 423                                 int                     tgtlen,
 424                                 int                     hbalen,
 425                                 int                     (*callback)(caddr_t),
 426                                 caddr_t                 arg);
 427 
 428 void            scsi_hba_pkt_free(
 429                                 struct scsi_address     *ap,
 430                                 struct scsi_pkt         *pkt);
 431 
 432 
 433 int             scsi_hba_lookup_capstr(
 434                                 char                    *capstr);
 435 
 436 int             scsi_hba_in_panic(void);
 437 
 438 int             scsi_hba_open(
 439                                 dev_t                   *devp,
 440                                 int                     flags,
 441                                 int                     otyp,
 442                                 cred_t                  *credp);
 443 
 444 int             scsi_hba_close(
 445                                 dev_t                   dev,
 446                                 int                     flag,
 447                                 int                     otyp,
 448                                 cred_t                  *credp);
 449 
 450 int             scsi_hba_ioctl(
 451                                 dev_t                   dev,
 452                                 int                     cmd,
 453                                 intptr_t                arg,
 454                                 int                     mode,
 455                                 cred_t                  *credp,
 456                                 int                     *rvalp);
 457 
 458 void            scsi_hba_nodename_compatible_get(
 459                                 struct scsi_inquiry     *inq,
 460                                 char                    *binding_set,
 461                                 int                     dtype_node,
 462                                 char                    *compat0,
 463                                 char                    **nodenamep,
 464                                 char                    ***compatiblep,
 465                                 int                     *ncompatiblep);
 466 
 467 void            scsi_hba_nodename_compatible_free(
 468                                 char                    *nodename,
 469                                 char                    **compatible);
 470 
 471 int             scsi_device_prop_update_inqstring(
 472                                 struct scsi_device      *sd,
 473                                 char                    *name,
 474                                 char                    *data,
 475                                 size_t                  len);
 476 
 477 void            scsi_hba_pkt_comp(
 478                                 struct scsi_pkt         *pkt);
 479 
 480 int             scsi_device_identity(
 481                                 struct scsi_device      *sd,
 482                                 int                     (*callback)(void));
 483 
 484 char            *scsi_hba_iport_unit_address(
 485                                 dev_info_t              *dip);
 486 
 487 int             scsi_hba_iport_register(
 488                                 dev_info_t              *dip,
 489                                 char                    *port);
 490 
 491 int             scsi_hba_iport_exist(
 492                                 dev_info_t              *dip);
 493 
 494 dev_info_t      *scsi_hba_iport_find(
 495                                 dev_info_t              *pdip,
 496                                 char                    *portnm);
 497 
 498 
 499 /*
 500  * Flags for scsi_hba_attach
 501  *
 502  * SCSI_HBA_ADDR_SPI            The host adapter driver wants the
 503  *                              scsi_address(9S) structure to be maintained
 504  *                              in legacy SPI 'a_target'/'a_lun' form (default).
 505  *
 506  * SCSI_HBA_ADDR_COMPLEX        The host adapter has a complex unit-address
 507  *                              space, and the HBA driver wants to maintain
 508  *                              per-scsi_device(9S) HBA private data using
 509  *                              scsi_address_device(9F) and
 510  *                              scsi_device_hba_private_[gs]et(9F).  The HBA
 511  *                              driver must maintain a private representation
 512  *                              of the scsi_device(9S) unit-address - typically
 513  *                              established during tran_tgt_init(9F) based on
 514  *                              property values.
 515  *
 516  * SCSI_HBA_TRAN_PHCI           The host adapter is an mpxio/scsi_vhci pHCI.
 517  *                              The framework should take care of
 518  *                              mdi_phci_register() stuff.
 519  *
 520  * SCSI_HBA_HBA                 The host adapter node (associated with a PCI
 521  *                              function) is just an HBA, all SCSI initiator
 522  *                              port function is provided by separate 'iport'
 523  *                              children of the host adapter node.  These iport
 524  *                              children bind to the same driver as the host
 525  *                              adapter node. Both nodes are managed by the
 526  *                              same driver. The driver can distinguish context
 527  *                              by calling scsi_hba_iport_unit_address().
 528  *
 529  * ::SCSI_HBA_TRAN_CLONE        Deprecated: use SCSI_HBA_ADDR_COMPLEX instead.
 530  *                              SCSI_HBA_TRAN_CLONE was a KLUDGE to address
 531  *                              limitations of the scsi_address(9S) structure
 532  *                              via duplication of scsi_hba_tran(9S) and
 533  *                              use of tran_tgt_private.
 534  *
 535  */
 536 #define SCSI_HBA_TRAN_CLONE     0x01    /* Deprecated */
 537 #define SCSI_HBA_TRAN_PHCI      0x02    /* treat HBA as mpxio 'pHCI' */
 538 #define SCSI_HBA_TRAN_CDB       0x04    /* allocate cdb */
 539 #define SCSI_HBA_TRAN_SCB       0x08    /* allocate sense */
 540 #define SCSI_HBA_HBA            0x10    /* all HBA children are iports */
 541 
 542 #define SCSI_HBA_ADDR_SPI       0x20    /* scsi_address in SPI form */
 543 #define SCSI_HBA_ADDR_COMPLEX   0x40    /* scsi_address is COMPLEX */
 544 
 545 /* upper bits used to record SCSA configuration state */
 546 #define SCSI_HBA_SCSA_PHCI      0x10000 /* need mdi_phci_unregister */
 547 #define SCSI_HBA_SCSA_TA        0x20000 /* scsi_hba_tran_alloc used */
 548 #define SCSI_HBA_SCSA_FM        0x40000 /* using common ddi_fm_* */
 549 
 550 /*
 551  * Flags for scsi_hba allocation functions
 552  */
 553 #define SCSI_HBA_CANSLEEP       0x01            /* can sleep */
 554 
 555 /*
 556  * Support extra flavors for SCSA children
 557  */
 558 #define SCSA_FLAVOR_SCSI_DEVICE NDI_FLAVOR_VANILLA
 559 #define SCSA_FLAVOR_SMP         1
 560 #define SCSA_FLAVOR_IPORT       2
 561 #define SCSA_NFLAVORS           3
 562 
 563 /*
 564  * Maximum number of iport nodes under PCI function
 565  */
 566 #define SCSI_HBA_MAX_IPORTS     32
 567 
 568 /*
 569  * SCSI iport map interfaces
 570  */
 571 int     scsi_hba_iportmap_create(
 572                                 dev_info_t              *hba_dip,
 573                                 int                     csync_usec,
 574                                 int                     stable_usec,
 575                                 scsi_hba_iportmap_t     **iportmapp);
 576 
 577 int     scsi_hba_iportmap_iport_add(
 578                                 scsi_hba_iportmap_t     *iportmap,
 579                                 char                    *iport_addr,
 580                                 void                    *iport_priv);
 581 
 582 int     scsi_hba_iportmap_iport_remove(
 583                                 scsi_hba_iportmap_t     *iportmap,
 584                                 char                    *iport_addr);
 585 
 586 void    scsi_hba_iportmap_destroy(scsi_hba_iportmap_t   *iportmap);
 587 
 588 /*
 589  * SCSI target map interfaces
 590  */
 591 typedef enum {
 592         SCSI_TM_FULLSET = 0,
 593         SCSI_TM_PERADDR
 594 } scsi_tgtmap_mode_t;
 595 
 596 typedef enum {
 597         SCSI_TGT_SCSI_DEVICE = 0,
 598         SCSI_TGT_SMP_DEVICE,
 599         SCSI_TGT_NTYPES
 600 } scsi_tgtmap_tgt_type_t;
 601 
 602 typedef enum {
 603         SCSI_TGT_DEACT_RSN_GONE = 0,
 604         SCSI_TGT_DEACT_RSN_CFG_FAIL,
 605         SCSI_TGT_DEACT_RSN_UNSTBL
 606 } scsi_tgtmap_deact_rsn_t;
 607 
 608 typedef void    (*scsi_tgt_activate_cb_t)(
 609                                 void                    *tgtmap_priv,
 610                                 char                    *tgt_addr,
 611                                 scsi_tgtmap_tgt_type_t  tgt_type,
 612                                 void                    **tgt_privp);
 613 typedef boolean_t       (*scsi_tgt_deactivate_cb_t)(
 614                                 void                    *tgtmap_priv,
 615                                 char                    *tgt_addr,
 616                                 scsi_tgtmap_tgt_type_t  tgt_type,
 617                                 void                    *tgt_priv,
 618                                 scsi_tgtmap_deact_rsn_t tgt_deact_rsn);
 619 int     scsi_hba_tgtmap_create(
 620                                 dev_info_t              *iport_dip,
 621                                 scsi_tgtmap_mode_t      rpt_mode,
 622                                 int                     csync_usec,
 623                                 int                     stable_usec,
 624                                 void                    *tgtmap_priv,
 625                                 scsi_tgt_activate_cb_t  activate_cb,
 626                                 scsi_tgt_deactivate_cb_t deactivate_cb,
 627                                 scsi_hba_tgtmap_t       **tgtmapp);
 628 
 629 int     scsi_hba_tgtmap_set_begin(scsi_hba_tgtmap_t     *tgtmap);
 630 
 631 int     scsi_hba_tgtmap_set_add(
 632                                 scsi_hba_tgtmap_t       *tgtmap,
 633                                 scsi_tgtmap_tgt_type_t  tgt_type,
 634                                 char                    *tgt_addr,
 635                                 void                    *tgt_priv);
 636 
 637 int     scsi_hba_tgtmap_set_end(
 638                                 scsi_hba_tgtmap_t       *tgtmap,
 639                                 uint_t                  flags);
 640 
 641 int     scsi_hba_tgtmap_set_flush(scsi_hba_tgtmap_t     *tgtmap);
 642 
 643 int     scsi_hba_tgtmap_tgt_add(
 644                                 scsi_hba_tgtmap_t       *tgtmap,
 645                                 scsi_tgtmap_tgt_type_t  tgt_type,
 646                                 char                    *tgt_addr,
 647                                 void                    *tgt_priv);
 648 
 649 int     scsi_hba_tgtmap_tgt_remove(
 650                                 scsi_hba_tgtmap_t       *tgtmap,
 651                                 scsi_tgtmap_tgt_type_t  tgt_type,
 652                                 char                    *tgt_addr);
 653 
 654 void    scsi_hba_tgtmap_destroy(scsi_hba_tgtmap_t       *tgt_map);
 655 
 656 
 657 /*
 658  * For minor nodes created by the SCSA framework, minor numbers are
 659  * formed by left-shifting instance by INST_MINOR_SHIFT and OR in a
 660  * number less than 64.
 661  *
 662  * - Numbers 0 - 31 are reserved by the framework, part of the range are
 663  *      in use, as defined below.
 664  *
 665  * - Numbers 32 - 63 are available for HBA driver use.
 666  */
 667 #define INST_MINOR_SHIFT        6
 668 #define TRAN_MINOR_MASK         ((1 << INST_MINOR_SHIFT) - 1)
 669 #define TRAN_OPEN_EXCL          (uint64_t)-1
 670 
 671 #define DEVCTL_MINOR            0
 672 #define SCSI_MINOR              1
 673 
 674 #define INST2DEVCTL(x)          (((x) << INST_MINOR_SHIFT) | DEVCTL_MINOR)
 675 #define INST2SCSI(x)            (((x) << INST_MINOR_SHIFT) | SCSI_MINOR)
 676 #define MINOR2INST(x)           ((x) >> INST_MINOR_SHIFT)
 677 
 678 #define SCSI_HBA_PROP_RECEPTACLE_LABEL  "receptacle-label"
 679 
 680 #endif  /* _KERNEL */
 681 
 682 #ifdef  __cplusplus
 683 }
 684 #endif
 685 
 686 #endif  /* _SYS_SCSI_IMPL_TRANSPORT_H */