Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* 
0003  *  Transport specific attributes.
0004  *
0005  *  Copyright (c) 2003 Silicon Graphics, Inc.  All rights reserved.
0006  */
0007 #ifndef SCSI_TRANSPORT_H
0008 #define SCSI_TRANSPORT_H
0009 
0010 #include <linux/transport_class.h>
0011 #include <linux/blkdev.h>
0012 #include <linux/bug.h>
0013 #include <scsi/scsi_host.h>
0014 #include <scsi/scsi_device.h>
0015 
0016 struct scsi_transport_template {
0017     /* the attribute containers */
0018     struct transport_container host_attrs;
0019     struct transport_container target_attrs;
0020     struct transport_container device_attrs;
0021 
0022     /*
0023      * If set, called from sysfs and legacy procfs rescanning code.
0024      */
0025     int (*user_scan)(struct Scsi_Host *, uint, uint, u64);
0026 
0027     /* The size of the specific transport attribute structure (a
0028      * space of this size will be left at the end of the
0029      * scsi_* structure */
0030     int device_size;
0031     int device_private_offset;
0032     int target_size;
0033     int target_private_offset;
0034     int host_size;
0035     /* no private offset for the host; there's an alternative mechanism */
0036 
0037     /*
0038      * True if the transport wants to use a host-based work-queue
0039      */
0040     unsigned int create_work_queue : 1;
0041 
0042     /*
0043      * Allows a transport to override the default error handler.
0044      */
0045     void (* eh_strategy_handler)(struct Scsi_Host *);
0046 };
0047 
0048 #define transport_class_to_shost(tc) \
0049     dev_to_shost((tc)->parent)
0050 
0051 
0052 /* Private area maintenance. The driver requested allocations come
0053  * directly after the transport class allocations (if any).  The idea
0054  * is that you *must* call these only once.  The code assumes that the
0055  * initial values are the ones the transport specific code requires */
0056 static inline void
0057 scsi_transport_reserve_target(struct scsi_transport_template * t, int space)
0058 {
0059     BUG_ON(t->target_private_offset != 0);
0060     t->target_private_offset = ALIGN(t->target_size, sizeof(void *));
0061     t->target_size = t->target_private_offset + space;
0062 }
0063 static inline void
0064 scsi_transport_reserve_device(struct scsi_transport_template * t, int space)
0065 {
0066     BUG_ON(t->device_private_offset != 0);
0067     t->device_private_offset = ALIGN(t->device_size, sizeof(void *));
0068     t->device_size = t->device_private_offset + space;
0069 }
0070 static inline void *
0071 scsi_transport_target_data(struct scsi_target *starget)
0072 {
0073     struct Scsi_Host *shost = dev_to_shost(&starget->dev);
0074     return (u8 *)starget->starget_data
0075         + shost->transportt->target_private_offset;
0076 
0077 }
0078 static inline void *
0079 scsi_transport_device_data(struct scsi_device *sdev)
0080 {
0081     struct Scsi_Host *shost = sdev->host;
0082     return (u8 *)sdev->sdev_data
0083         + shost->transportt->device_private_offset;
0084 }
0085 
0086 void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q);
0087 
0088 #endif /* SCSI_TRANSPORT_H */