aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/scsi_transport.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/scsi/scsi_transport.h')
-rw-r--r--include/scsi/scsi_transport.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
index 2dcee7a84752..a4f1837a33b1 100644
--- a/include/scsi/scsi_transport.h
+++ b/include/scsi/scsi_transport.h
@@ -21,6 +21,7 @@
21#define SCSI_TRANSPORT_H 21#define SCSI_TRANSPORT_H
22 22
23#include <linux/transport_class.h> 23#include <linux/transport_class.h>
24#include <scsi/scsi_host.h>
24 25
25struct scsi_transport_template { 26struct scsi_transport_template {
26 /* the attribute containers */ 27 /* the attribute containers */
@@ -32,8 +33,11 @@ struct scsi_transport_template {
32 * space of this size will be left at the end of the 33 * space of this size will be left at the end of the
33 * scsi_* structure */ 34 * scsi_* structure */
34 int device_size; 35 int device_size;
36 int device_private_offset;
35 int target_size; 37 int target_size;
38 int target_private_offset;
36 int host_size; 39 int host_size;
40 /* no private offset for the host; there's an alternative mechanism */
37 41
38 /* 42 /*
39 * True if the transport wants to use a host-based work-queue 43 * True if the transport wants to use a host-based work-queue
@@ -45,4 +49,38 @@ struct scsi_transport_template {
45 dev_to_shost((tc)->dev) 49 dev_to_shost((tc)->dev)
46 50
47 51
52/* Private area maintenance. The driver requested allocations come
53 * directly after the transport class allocations (if any). The idea
54 * is that you *must* call these only once. The code assumes that the
55 * initial values are the ones the transport specific code requires */
56static inline void
57scsi_transport_reserve_target(struct scsi_transport_template * t, int space)
58{
59 BUG_ON(t->target_private_offset != 0);
60 t->target_private_offset = ALIGN(t->target_size, sizeof(void *));
61 t->target_size = t->target_private_offset + space;
62}
63static inline void
64scsi_transport_reserve_device(struct scsi_transport_template * t, int space)
65{
66 BUG_ON(t->device_private_offset != 0);
67 t->device_private_offset = ALIGN(t->device_size, sizeof(void *));
68 t->device_size = t->device_private_offset + space;
69}
70static inline void *
71scsi_transport_target_data(struct scsi_target *starget)
72{
73 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
74 return (u8 *)starget->starget_data
75 + shost->transportt->target_private_offset;
76
77}
78static inline void *
79scsi_transport_device_data(struct scsi_device *sdev)
80{
81 struct Scsi_Host *shost = sdev->host;
82 return (u8 *)sdev->sdev_data
83 + shost->transportt->device_private_offset;
84}
85
48#endif /* SCSI_TRANSPORT_H */ 86#endif /* SCSI_TRANSPORT_H */