Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions | Variables
libata-scsi.c File Reference
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/spinlock.h>
#include <linux/export.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsi_transport.h>
#include <linux/libata.h>
#include <linux/hdreg.h>
#include <linux/uaccess.h>
#include <linux/suspend.h>
#include <asm/unaligned.h>
#include "libata.h"
#include "libata-transport.h"

Go to the source code of this file.

Macros

#define ATA_SCSI_RBUF_SIZE   4096
 
#define RW_RECOVERY_MPAGE   0x1
 
#define RW_RECOVERY_MPAGE_LEN   12
 
#define CACHE_MPAGE   0x8
 
#define CACHE_MPAGE_LEN   20
 
#define CONTROL_MPAGE   0xa
 
#define CONTROL_MPAGE_LEN   12
 
#define ALL_MPAGES   0x3f
 
#define ALL_SUB_MPAGES   0xff
 

Typedefs

typedef unsigned int(* ata_xlat_func_t )(struct ata_queued_cmd *qc)
 

Functions

 DEVICE_ATTR (link_power_management_policy, S_IRUGO|S_IWUSR, ata_scsi_lpm_show, ata_scsi_lpm_store)
 
 EXPORT_SYMBOL_GPL (dev_attr_link_power_management_policy)
 
 DEVICE_ATTR (unload_heads, S_IRUGO|S_IWUSR, ata_scsi_park_show, ata_scsi_park_store)
 
 EXPORT_SYMBOL_GPL (dev_attr_unload_heads)
 
 DEVICE_ATTR (em_message, S_IRUGO|S_IWUSR, ata_scsi_em_message_show, ata_scsi_em_message_store)
 
 EXPORT_SYMBOL_GPL (dev_attr_em_message)
 
 DEVICE_ATTR (em_message_type, S_IRUGO, ata_scsi_em_message_type_show, NULL)
 
 EXPORT_SYMBOL_GPL (dev_attr_em_message_type)
 
 DEVICE_ATTR (sw_activity, S_IWUSR|S_IRUGO, ata_scsi_activity_show, ata_scsi_activity_store)
 
 EXPORT_SYMBOL_GPL (dev_attr_sw_activity)
 
 EXPORT_SYMBOL_GPL (ata_common_sdev_attrs)
 
int ata_std_bios_param (struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[])
 
void ata_scsi_unlock_native_capacity (struct scsi_device *sdev)
 
int ata_cmd_ioctl (struct scsi_device *scsidev, void __user *arg)
 
int ata_task_ioctl (struct scsi_device *scsidev, void __user *arg)
 
int ata_sas_scsi_ioctl (struct ata_port *ap, struct scsi_device *scsidev, int cmd, void __user *arg)
 
 EXPORT_SYMBOL_GPL (ata_sas_scsi_ioctl)
 
int ata_scsi_ioctl (struct scsi_device *scsidev, int cmd, void __user *arg)
 
 EXPORT_SYMBOL_GPL (ata_scsi_ioctl)
 
int ata_scsi_slave_config (struct scsi_device *sdev)
 
void ata_scsi_slave_destroy (struct scsi_device *sdev)
 
int __ata_change_queue_depth (struct ata_port *ap, struct scsi_device *sdev, int queue_depth, int reason)
 
int ata_scsi_change_queue_depth (struct scsi_device *sdev, int queue_depth, int reason)
 
int ata_scsi_queuecmd (struct Scsi_Host *shost, struct scsi_cmnd *cmd)
 
void ata_scsi_simulate (struct ata_device *dev, struct scsi_cmnd *cmd)
 
int ata_scsi_add_hosts (struct ata_host *host, struct scsi_host_template *sht)
 
void ata_scsi_scan_host (struct ata_port *ap, int sync)
 
int ata_scsi_offline_dev (struct ata_device *dev)
 
void ata_scsi_media_change_notify (struct ata_device *dev)
 
void ata_scsi_hotplug (struct work_struct *work)
 
int ata_scsi_user_scan (struct Scsi_Host *shost, unsigned int channel, unsigned int id, unsigned int lun)
 
void ata_scsi_dev_rescan (struct work_struct *work)
 
struct ata_portata_sas_port_alloc (struct ata_host *host, struct ata_port_info *port_info, struct Scsi_Host *shost)
 
 EXPORT_SYMBOL_GPL (ata_sas_port_alloc)
 
int ata_sas_port_start (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_port_start)
 
void ata_sas_port_stop (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_port_stop)
 
void ata_sas_async_probe (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_async_probe)
 
int ata_sas_sync_probe (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_sync_probe)
 
int ata_sas_port_init (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_port_init)
 
void ata_sas_port_destroy (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_port_destroy)
 
int ata_sas_slave_configure (struct scsi_device *sdev, struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_slave_configure)
 
int ata_sas_queuecmd (struct scsi_cmnd *cmd, struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_sas_queuecmd)
 

Variables

struct device_attributeata_common_sdev_attrs []
 

Macro Definition Documentation

#define ALL_MPAGES   0x3f

Definition at line 75 of file libata-scsi.c.

#define ALL_SUB_MPAGES   0xff

Definition at line 76 of file libata-scsi.c.

#define ATA_SCSI_RBUF_SIZE   4096

Definition at line 57 of file libata-scsi.c.

#define CACHE_MPAGE   0x8

Definition at line 71 of file libata-scsi.c.

#define CACHE_MPAGE_LEN   20

Definition at line 72 of file libata-scsi.c.

#define CONTROL_MPAGE   0xa

Definition at line 73 of file libata-scsi.c.

#define CONTROL_MPAGE_LEN   12

Definition at line 74 of file libata-scsi.c.

#define RW_RECOVERY_MPAGE   0x1

Definition at line 69 of file libata-scsi.c.

#define RW_RECOVERY_MPAGE_LEN   12

Definition at line 70 of file libata-scsi.c.

Typedef Documentation

typedef unsigned int(* ata_xlat_func_t)(struct ata_queued_cmd *qc)

Definition at line 62 of file libata-scsi.c.

Function Documentation

int __ata_change_queue_depth ( struct ata_port ap,
struct scsi_device sdev,
int  queue_depth,
int  reason 
)

__ata_change_queue_depth - helper for ata_scsi_change_queue_depth : ATA port to which the device change the queue depth : SCSI device to configure queue depth for : new queue depth : calling context

libsas and libata have different approaches for associating a sdev to its ata_port.

Definition at line 1231 of file libata-scsi.c.

int ata_cmd_ioctl ( struct scsi_device scsidev,
void __user arg 
)

ata_cmd_ioctl - Handler for HDIO_DRIVE_CMD ioctl : Device to which we are issuing command

  • : User provided data for issuing command

LOCKING: Defined by the SCSI layer. We don't really care.

RETURNS: Zero on success, negative errno on error.

Definition at line 466 of file libata-scsi.c.

void ata_sas_async_probe ( struct ata_port ap)

ata_sas_async_probe - simply schedule probing and return : Port to probe

For batch scheduling of probe for sas attached ata devices, assumes the port has already been through ata_sas_port_init()

Definition at line 4063 of file libata-scsi.c.

struct ata_port* ata_sas_port_alloc ( struct ata_host host,
struct ata_port_info port_info,
struct Scsi_Host shost 
)
read

ata_sas_port_alloc - Allocate port for a SAS attached SATA device : ATA host container for all SAS ports : Information from low-level host driver : SCSI host that the scsi device is attached to

LOCKING: PCI/etc. bus probe sem.

RETURNS: ata_port pointer on success / NULL on failure.

Definition at line 3994 of file libata-scsi.c.

void ata_sas_port_destroy ( struct ata_port ap)

ata_sas_port_destroy - Destroy a SATA port allocated by ata_sas_port_alloc : SATA port to destroy

Definition at line 4104 of file libata-scsi.c.

int ata_sas_port_init ( struct ata_port ap)

ata_sas_port_init - Initialize a SATA device : SATA port to initialize

LOCKING: PCI/etc. bus probe sem.

RETURNS: Zero on success, non-zero on error.

Definition at line 4087 of file libata-scsi.c.

int ata_sas_port_start ( struct ata_port ap)

ata_sas_port_start - Set port up for dma. : Port to initialize

Called just after data structures for each port are initialized.

May be used as the port_start() entry in ata_port_operations.

LOCKING: Inherited from caller.

Definition at line 4029 of file libata-scsi.c.

void ata_sas_port_stop ( struct ata_port ap)

ata_port_stop - Undo ata_sas_port_start() : Port to shut down

May be used as the port_stop() entry in ata_port_operations.

LOCKING: Inherited from caller.

Definition at line 4051 of file libata-scsi.c.

int ata_sas_queuecmd ( struct scsi_cmnd cmd,
struct ata_port ap 
)

ata_sas_queuecmd - Issue SCSI cdb to libata-managed device : SCSI command to be sent : ATA port to which the command is being sent

RETURNS: Return value from __ata_scsi_queuecmd() if can be queued, 0 otherwise.

Definition at line 4139 of file libata-scsi.c.

int ata_sas_scsi_ioctl ( struct ata_port ap,
struct scsi_device scsidev,
int  cmd,
void __user arg 
)

Definition at line 658 of file libata-scsi.c.

int ata_sas_slave_configure ( struct scsi_device sdev,
struct ata_port ap 
)

ata_sas_slave_configure - Default slave_config routine for libata devices : SCSI device to configure : ATA port to which SCSI device is attached

RETURNS: Zero.

Definition at line 4121 of file libata-scsi.c.

int ata_sas_sync_probe ( struct ata_port ap)

Definition at line 4069 of file libata-scsi.c.

int ata_scsi_add_hosts ( struct ata_host host,
struct scsi_host_template sht 
)

Definition at line 3582 of file libata-scsi.c.

int ata_scsi_change_queue_depth ( struct scsi_device sdev,
int  queue_depth,
int  reason 
)

ata_scsi_change_queue_depth - SCSI callback for queue depth config : SCSI device to configure queue depth for : new queue depth : calling context

This is libata standard hostt->change_queue_depth callback. SCSI will call into this callback when user tries to set queue depth via sysfs.

LOCKING: SCSI layer (we don't care)

RETURNS: Newly configured queue depth.

Definition at line 1284 of file libata-scsi.c.

void ata_scsi_dev_rescan ( struct work_struct work)

ata_scsi_dev_rescan - initiate scsi_rescan_device() : Pointer to ATA port to perform scsi_rescan_device()

After ATA pass thru (SAT) commands are executed successfully, libata need to propagate the changes to SCSI layer.

LOCKING: Kernel thread context (may sleep).

Definition at line 3950 of file libata-scsi.c.

void ata_scsi_hotplug ( struct work_struct work)

ata_scsi_hotplug - SCSI part of hotplug : Pointer to ATA port to perform SCSI hotplug on

Perform SCSI part of hotplug. It's executed from a separate workqueue after EH completes. This is necessary because SCSI hot plugging requires working EH and hot unplugging is synchronized with hot plugging with a mutex.

LOCKING: Kernel thread context (may sleep).

Definition at line 3840 of file libata-scsi.c.

int ata_scsi_ioctl ( struct scsi_device scsidev,
int  cmd,
void __user arg 
)

Definition at line 711 of file libata-scsi.c.

void ata_scsi_media_change_notify ( struct ata_device dev)

ata_scsi_media_change_notify - send media change event : Pointer to the disk device with media change event

Tell the block layer to send a media change notification event.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 3821 of file libata-scsi.c.

int ata_scsi_offline_dev ( struct ata_device dev)

ata_scsi_offline_dev - offline attached SCSI device : ATA device to offline attached SCSI device for

This function is called from ata_eh_hotplug() and responsible for taking the SCSI device attached to offline. This function is called with host lock which protects dev->sdev against clearing.

LOCKING: spin_lock_irqsave(host lock)

RETURNS: 1 if attached SCSI device exists, 0 otherwise.

Definition at line 3722 of file libata-scsi.c.

int ata_scsi_queuecmd ( struct Scsi_Host shost,
struct scsi_cmnd cmd 
)

ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device : SCSI host of command to be sent : SCSI command to be sent

In some cases, this function translates SCSI commands into ATA taskfiles, and queues the taskfiles to be sent to hardware. In other cases, this function simulates a SCSI device by evaluating and responding to certain SCSI commands. This creates the overall effect of ATA and ATAPI devices appearing as SCSI devices.

LOCKING: ATA host lock

RETURNS: Return value from __ata_scsi_queuecmd() if can be queued, 0 otherwise.

Definition at line 3436 of file libata-scsi.c.

void ata_scsi_scan_host ( struct ata_port ap,
int  sync 
)

Definition at line 3633 of file libata-scsi.c.

void ata_scsi_simulate ( struct ata_device dev,
struct scsi_cmnd cmd 
)

ata_scsi_simulate - simulate SCSI command on ATA device : the target device : SCSI command being sent to device.

Interprets and directly executes a select list of SCSI commands that can be handled internally.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 3475 of file libata-scsi.c.

int ata_scsi_slave_config ( struct scsi_device sdev)

ata_scsi_slave_config - Set SCSI device attributes : SCSI device to examine

This is called before we actually start reading and writing to the device, to configure certain SCSI mid-layer behaviors.

LOCKING: Defined by SCSI layer. We don't really care.

Definition at line 1167 of file libata-scsi.c.

void ata_scsi_slave_destroy ( struct scsi_device sdev)

ata_scsi_slave_destroy - SCSI device is about to be destroyed : SCSI device to be destroyed

is about to be destroyed for hot/warm unplugging. If this unplugging was initiated by libata as indicated by NULL dev->sdev, this function doesn't have to do anything. Otherwise, SCSI layer initiated warm-unplug is in progress. Clear dev->sdev, schedule the device for ATA detach and invoke EH.

LOCKING: Defined by SCSI layer. We don't really care.

Definition at line 1195 of file libata-scsi.c.

void ata_scsi_unlock_native_capacity ( struct scsi_device sdev)

ata_scsi_unlock_native_capacity - unlock native capacity : SCSI device to adjust device capacity for

This function is called if a partition on extends beyond the end of the device. It requests EH to unlock HPA.

LOCKING: Defined by the SCSI layer. Might sleep.

Definition at line 396 of file libata-scsi.c.

int ata_scsi_user_scan ( struct Scsi_Host shost,
unsigned int  channel,
unsigned int  id,
unsigned int  lun 
)

ata_scsi_user_scan - indication for user-initiated bus scan : SCSI host to scan : Channel to scan : ID to scan : LUN to scan

This function is called when user explicitly requests bus scan. Set probe pending flag and invoke EH.

LOCKING: SCSI layer (we don't care)

RETURNS: Zero.

Definition at line 3886 of file libata-scsi.c.

int ata_std_bios_param ( struct scsi_device sdev,
struct block_device bdev,
sector_t  capacity,
int  geom[] 
)

ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd. : SCSI device for which BIOS geometry is to be determined : block device associated with : capacity of SCSI device : location to which geometry will be output

Generic bios head/sector/cylinder calculator used by sd. Most BIOSes nowadays expect a XXX/255/16 (CHS) mapping. Some situations may arise where the disk is not bootable if this is not used.

LOCKING: Defined by the SCSI layer. We don't really care.

RETURNS: Zero.

Definition at line 375 of file libata-scsi.c.

int ata_task_ioctl ( struct scsi_device scsidev,
void __user arg 
)

ata_task_ioctl - Handler for HDIO_DRIVE_TASK ioctl : Device to which we are issuing command

  • : User provided data for issuing command

LOCKING: Defined by the SCSI layer. We don't really care.

RETURNS: Zero on success, negative errno on error.

Definition at line 575 of file libata-scsi.c.

DEVICE_ATTR ( link_power_management_policy  ,
S_IRUGO S_IWUSR,
ata_scsi_lpm_show  ,
ata_scsi_lpm_store   
)
DEVICE_ATTR ( unload_heads  ,
S_IRUGO S_IWUSR,
ata_scsi_park_show  ,
ata_scsi_park_store   
)
DEVICE_ATTR ( em_message  ,
S_IRUGO S_IWUSR,
ata_scsi_em_message_show  ,
ata_scsi_em_message_store   
)
DEVICE_ATTR ( em_message_type  ,
S_IRUGO  ,
ata_scsi_em_message_type_show  ,
NULL   
)
DEVICE_ATTR ( sw_activity  ,
S_IWUSR S_IRUGO,
ata_scsi_activity_show  ,
ata_scsi_activity_store   
)
EXPORT_SYMBOL_GPL ( dev_attr_link_power_management_policy  )
EXPORT_SYMBOL_GPL ( dev_attr_unload_heads  )
EXPORT_SYMBOL_GPL ( dev_attr_em_message  )
EXPORT_SYMBOL_GPL ( dev_attr_em_message_type  )
EXPORT_SYMBOL_GPL ( dev_attr_sw_activity  )
EXPORT_SYMBOL_GPL ( ata_common_sdev_attrs  )
EXPORT_SYMBOL_GPL ( ata_sas_scsi_ioctl  )
EXPORT_SYMBOL_GPL ( ata_scsi_ioctl  )
EXPORT_SYMBOL_GPL ( ata_sas_port_alloc  )
EXPORT_SYMBOL_GPL ( ata_sas_port_start  )
EXPORT_SYMBOL_GPL ( ata_sas_port_stop  )
EXPORT_SYMBOL_GPL ( ata_sas_async_probe  )
EXPORT_SYMBOL_GPL ( ata_sas_sync_probe  )
EXPORT_SYMBOL_GPL ( ata_sas_port_init  )
EXPORT_SYMBOL_GPL ( ata_sas_port_destroy  )
EXPORT_SYMBOL_GPL ( ata_sas_slave_configure  )
EXPORT_SYMBOL_GPL ( ata_sas_queuecmd  )

Variable Documentation

struct device_attribute* ata_common_sdev_attrs[]
Initial value:

Definition at line 344 of file libata-scsi.c.