/*1* Transport specific attributes.2*3* Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/19#ifndef SCSI_TRANSPORT_H20#define SCSI_TRANSPORT_H2122#include <linux/transport_class.h>23#include <linux/blkdev.h>24#include <scsi/scsi_host.h>25#include <scsi/scsi_device.h>2627struct scsi_transport_template {28/* the attribute containers */29struct transport_container host_attrs;30struct transport_container target_attrs;31struct transport_container device_attrs;3233/*34* If set, called from sysfs and legacy procfs rescanning code.35*/36int (*user_scan)(struct Scsi_Host *, uint, uint, uint);3738/* The size of the specific transport attribute structure (a39* space of this size will be left at the end of the40* scsi_* structure */41int device_size;42int device_private_offset;43int target_size;44int target_private_offset;45int host_size;46/* no private offset for the host; there's an alternative mechanism */4748/*49* True if the transport wants to use a host-based work-queue50*/51unsigned int create_work_queue : 1;5253/*54* Allows a transport to override the default error handler.55*/56void (* eh_strategy_handler)(struct Scsi_Host *);5758/*59* This is an optional routine that allows the transport to become60* involved when a scsi io timer fires. The return value tells the61* timer routine how to finish the io timeout handling:62* EH_HANDLED: I fixed the error, please complete the command63* EH_RESET_TIMER: I need more time, reset the timer and64* begin counting again65* EH_NOT_HANDLED Begin normal error recovery66*/67enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *);6869/*70* Used as callback for the completion of i_t_nexus request71* for target drivers.72*/73int (* it_nexus_response)(struct Scsi_Host *, u64, int);7475/*76* Used as callback for the completion of task management77* request for target drivers.78*/79int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int);80};8182#define transport_class_to_shost(tc) \83dev_to_shost((tc)->parent)848586/* Private area maintenance. The driver requested allocations come87* directly after the transport class allocations (if any). The idea88* is that you *must* call these only once. The code assumes that the89* initial values are the ones the transport specific code requires */90static inline void91scsi_transport_reserve_target(struct scsi_transport_template * t, int space)92{93BUG_ON(t->target_private_offset != 0);94t->target_private_offset = ALIGN(t->target_size, sizeof(void *));95t->target_size = t->target_private_offset + space;96}97static inline void98scsi_transport_reserve_device(struct scsi_transport_template * t, int space)99{100BUG_ON(t->device_private_offset != 0);101t->device_private_offset = ALIGN(t->device_size, sizeof(void *));102t->device_size = t->device_private_offset + space;103}104static inline void *105scsi_transport_target_data(struct scsi_target *starget)106{107struct Scsi_Host *shost = dev_to_shost(&starget->dev);108return (u8 *)starget->starget_data109+ shost->transportt->target_private_offset;110111}112static inline void *113scsi_transport_device_data(struct scsi_device *sdev)114{115struct Scsi_Host *shost = sdev->host;116return (u8 *)sdev->sdev_data117+ shost->transportt->device_private_offset;118}119120#endif /* SCSI_TRANSPORT_H */121122123