linux/include/scsi/libsas.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * SAS host prototypes and structures header file
 *
 * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
 * Copyright (C) 2005 Luben Tuikov <[email protected]>
 */

#ifndef _LIBSAS_H_
#define _LIBSAS_H_


#include <linux/timer.h>
#include <linux/pci.h>
#include <scsi/sas.h>
#include <linux/libata.h>
#include <linux/list.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_transport_sas.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>

struct block_device;

enum sas_phy_role {};

/* The events are mnemonically described in sas_dump.c
 * so when updating/adding events here, please also
 * update the other file too.
 */
enum port_event {};

enum phy_event {};

enum discover_event {};

/* ---------- Expander Devices ---------- */

#define to_dom_device(_obj)
#define to_dev_attr(_attr)

enum routing_attribute {};

enum ex_phy_state {};

struct ex_phy {};

struct expander_device {};

/* ---------- SATA device ---------- */
#define ATA_RESP_FIS_SIZE

struct sata_device {};

struct ssp_device {};

enum {};

struct domain_device {};

struct sas_work {};

static inline bool dev_is_expander(enum sas_device_type type)
{}

static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
{}

struct sas_discovery_event {};

static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work)
{}

struct sas_discovery {};

/* The port struct is Class:RW, driver:RO */
struct asd_sas_port {};

struct asd_sas_event {};

static inline struct asd_sas_event *to_asd_sas_event(struct work_struct *work)
{}

static inline void INIT_SAS_EVENT(struct asd_sas_event *ev,
		void (*fn)(struct work_struct *),
		struct asd_sas_phy *phy, int event)
{}

#define SAS_PHY_SHUTDOWN_THRES

/* The phy pretty much is controlled by the LLDD.
 * The class only reads those fields.
 */
struct asd_sas_phy {};

enum sas_ha_state {};

struct sas_ha_struct {};

#define SHOST_TO_SAS_HA(_shost)

static inline struct domain_device *
starget_to_domain_dev(struct scsi_target *starget) {}

static inline struct domain_device *
sdev_to_domain_dev(struct scsi_device *sdev) {}

static inline struct ata_device *sas_to_ata_dev(struct domain_device *dev)
{}

static inline struct domain_device *
cmd_to_domain_dev(struct scsi_cmnd *cmd)
{}

/* Before calling a notify event, LLDD should use this function
 * when the link is severed (possibly from its tasklet).
 * The idea is that the Class only reads those, while the LLDD,
 * can R/W these (thus avoiding a race).
 */
static inline void sas_phy_disconnected(struct asd_sas_phy *phy)
{}

static inline unsigned int to_sas_gpio_od(int device, int bit)
{}

static inline void sas_put_local_phy(struct sas_phy *phy)
{}

#ifdef CONFIG_SCSI_SAS_HOST_SMP
int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count);
#else
static inline int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count)
{
	return -1;
}
#endif

/* ---------- Tasks ---------- */
/*
      service_response |  SAS_TASK_COMPLETE  |  SAS_TASK_UNDELIVERED |
  exec_status          |                     |                       |
  ---------------------+---------------------+-----------------------+
       SAM_...         |         X           |                       |
       DEV_NO_RESPONSE |         X           |           X           |
       INTERRUPTED     |         X           |                       |
       QUEUE_FULL      |                     |           X           |
       DEVICE_UNKNOWN  |                     |           X           |
       SG_ERR          |                     |           X           |
  ---------------------+---------------------+-----------------------+
 */

enum service_response {};

enum exec_status {};

/* When a task finishes with a response, the LLDD examines the
 * response:
 *	- For an ATA task task_status_struct::stat is set to
 * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the
 * contents of struct ata_task_resp.
 *	- For SSP tasks, if no data is present or status/TMF response
 * is valid, task_status_struct::stat is set.  If data is present
 * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets
 * task_status_struct::buf_valid_size, and task_status_struct::stat is
 * set to SAM_CHECK_COND.
 *
 * "buf" has format SCSI Sense for SSP task, or struct ata_task_resp
 * for ATA task.
 *
 * "frame_len" is the total frame length, which could be more or less
 * than actually copied.
 *
 * Tasks ending with response, always set the residual field.
 */
struct ata_task_resp {};

#define SAS_STATUS_BUF_SIZE

struct task_status_struct {};

/* ATA and ATAPI task queuable to a SAS LLDD.
 */
struct sas_ata_task {};

/* LLDDs rely on these values */
enum sas_internal_abort {};

struct sas_internal_abort_task {};

struct sas_smp_task {};

enum task_attribute {};

struct sas_ssp_task {};

struct sas_tmf_task {};

struct sas_task {};

struct sas_task_slow {};

#define SAS_TASK_STATE_PENDING
#define SAS_TASK_STATE_DONE
#define SAS_TASK_STATE_ABORTED
#define SAS_TASK_NEED_DEV_RESET

static inline bool sas_is_internal_abort(struct sas_task *task)
{}

static inline struct request *sas_task_find_rq(struct sas_task *task)
{}

struct sas_domain_function_template {};

extern int sas_register_ha(struct sas_ha_struct *);
extern int sas_unregister_ha(struct sas_ha_struct *);
extern void sas_prep_resume_ha(struct sas_ha_struct *sas_ha);
extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
extern void sas_resume_ha_no_sync(struct sas_ha_struct *sas_ha);
extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);

int sas_phy_reset(struct sas_phy *phy, int hard_reset);
int sas_phy_enable(struct sas_phy *phy, int enable);
extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
extern int sas_target_alloc(struct scsi_target *);
int sas_device_configure(struct scsi_device *dev,
		struct queue_limits *lim);
extern int sas_change_queue_depth(struct scsi_device *, int new_depth);
extern int sas_bios_param(struct scsi_device *, struct block_device *,
			  sector_t capacity, int *hsc);
int sas_execute_internal_abort_single(struct domain_device *device,
				      u16 tag, unsigned int qid,
				      void *data);
int sas_execute_internal_abort_dev(struct domain_device *device,
				   unsigned int qid, void *data);
extern struct scsi_transport_template *
sas_domain_attach_transport(struct sas_domain_function_template *);
extern struct device_attribute dev_attr_phy_event_threshold;

void sas_task_abort(struct sas_task *);
int sas_eh_abort_handler(struct scsi_cmnd *cmd);
int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);

extern void sas_target_destroy(struct scsi_target *);
extern int sas_slave_alloc(struct scsi_device *);
extern int sas_ioctl(struct scsi_device *sdev, unsigned int cmd,
		     void __user *arg);
extern int sas_drain_work(struct sas_ha_struct *ha);

extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
				  struct ssp_response_iu *iu);
struct sas_phy *sas_get_local_phy(struct domain_device *dev);

int sas_request_addr(struct Scsi_Host *shost, u8 *addr);

int sas_abort_task_set(struct domain_device *dev, u8 *lun);
int sas_clear_task_set(struct domain_device *dev, u8 *lun);
int sas_lu_reset(struct domain_device *dev, u8 *lun);
int sas_query_task(struct sas_task *task, u16 tag);
int sas_abort_task(struct sas_task *task, u16 tag);
int sas_find_attached_phy_id(struct expander_device *ex_dev,
			     struct domain_device *dev);

void sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event,
			   gfp_t gfp_flags);
void sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event,
			   gfp_t gfp_flags);

#define __LIBSAS_SHT_BASE			\

#ifdef CONFIG_COMPAT
#define _LIBSAS_SHT_BASE
#else
#define _LIBSAS_SHT_BASE
#endif

#define LIBSAS_SHT_BASE		\

#define LIBSAS_SHT_BASE_NO_SLAVE_INIT


#endif /* _SASLIB_H_ */