Path: blob/master/include/scsi/scsi_transport_sas.h
10820 views
#ifndef SCSI_TRANSPORT_SAS_H1#define SCSI_TRANSPORT_SAS_H23#include <linux/transport_class.h>4#include <linux/types.h>5#include <linux/mutex.h>6#include <scsi/sas.h>78struct scsi_transport_template;9struct sas_rphy;10struct request;1112enum sas_device_type {13SAS_PHY_UNUSED = 0,14SAS_END_DEVICE = 1,15SAS_EDGE_EXPANDER_DEVICE = 2,16SAS_FANOUT_EXPANDER_DEVICE = 3,17};1819static inline int sas_protocol_ata(enum sas_protocol proto)20{21return ((proto & SAS_PROTOCOL_SATA) ||22(proto & SAS_PROTOCOL_STP))? 1 : 0;23}2425enum sas_linkrate {26/* These Values are defined in the SAS standard */27SAS_LINK_RATE_UNKNOWN = 0,28SAS_PHY_DISABLED = 1,29SAS_PHY_RESET_PROBLEM = 2,30SAS_SATA_SPINUP_HOLD = 3,31SAS_SATA_PORT_SELECTOR = 4,32SAS_PHY_RESET_IN_PROGRESS = 5,33SAS_LINK_RATE_1_5_GBPS = 8,34SAS_LINK_RATE_G1 = SAS_LINK_RATE_1_5_GBPS,35SAS_LINK_RATE_3_0_GBPS = 9,36SAS_LINK_RATE_G2 = SAS_LINK_RATE_3_0_GBPS,37SAS_LINK_RATE_6_0_GBPS = 10,38/* These are virtual to the transport class and may never39* be signalled normally since the standard defined field40* is only 4 bits */41SAS_LINK_RATE_FAILED = 0x10,42SAS_PHY_VIRTUAL = 0x11,43};4445struct sas_identify {46enum sas_device_type device_type;47enum sas_protocol initiator_port_protocols;48enum sas_protocol target_port_protocols;49u64 sas_address;50u8 phy_identifier;51};5253struct sas_phy {54struct device dev;55int number;56int enabled;5758/* phy identification */59struct sas_identify identify;6061/* phy attributes */62enum sas_linkrate negotiated_linkrate;63enum sas_linkrate minimum_linkrate_hw;64enum sas_linkrate minimum_linkrate;65enum sas_linkrate maximum_linkrate_hw;66enum sas_linkrate maximum_linkrate;6768/* link error statistics */69u32 invalid_dword_count;70u32 running_disparity_error_count;71u32 loss_of_dword_sync_count;72u32 phy_reset_problem_count;7374/* for the list of phys belonging to a port */75struct list_head port_siblings;7677struct work_struct reset_work;78};7980#define dev_to_phy(d) \81container_of((d), struct sas_phy, dev)82#define transport_class_to_phy(dev) \83dev_to_phy((dev)->parent)84#define phy_to_shost(phy) \85dev_to_shost((phy)->dev.parent)8687struct request_queue;88struct sas_rphy {89struct device dev;90struct sas_identify identify;91struct list_head list;92struct request_queue *q;93u32 scsi_target_id;94};9596#define dev_to_rphy(d) \97container_of((d), struct sas_rphy, dev)98#define transport_class_to_rphy(dev) \99dev_to_rphy((dev)->parent)100#define rphy_to_shost(rphy) \101dev_to_shost((rphy)->dev.parent)102#define target_to_rphy(targ) \103dev_to_rphy((targ)->dev.parent)104105struct sas_end_device {106struct sas_rphy rphy;107/* flags */108unsigned ready_led_meaning:1;109unsigned tlr_supported:1;110unsigned tlr_enabled:1;111/* parameters */112u16 I_T_nexus_loss_timeout;113u16 initiator_response_timeout;114};115#define rphy_to_end_device(r) \116container_of((r), struct sas_end_device, rphy)117118struct sas_expander_device {119int level;120int next_port_id;121122#define SAS_EXPANDER_VENDOR_ID_LEN 8123char vendor_id[SAS_EXPANDER_VENDOR_ID_LEN+1];124#define SAS_EXPANDER_PRODUCT_ID_LEN 16125char product_id[SAS_EXPANDER_PRODUCT_ID_LEN+1];126#define SAS_EXPANDER_PRODUCT_REV_LEN 4127char product_rev[SAS_EXPANDER_PRODUCT_REV_LEN+1];128#define SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN 8129char component_vendor_id[SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN+1];130u16 component_id;131u8 component_revision_id;132133struct sas_rphy rphy;134135};136#define rphy_to_expander_device(r) \137container_of((r), struct sas_expander_device, rphy)138139struct sas_port {140struct device dev;141142int port_identifier;143int num_phys;144/* port flags */145unsigned int is_backlink:1;146147/* the other end of the link */148struct sas_rphy *rphy;149150struct mutex phy_list_mutex;151struct list_head phy_list;152};153154#define dev_to_sas_port(d) \155container_of((d), struct sas_port, dev)156#define transport_class_to_sas_port(dev) \157dev_to_sas_port((dev)->parent)158159struct sas_phy_linkrates {160enum sas_linkrate maximum_linkrate;161enum sas_linkrate minimum_linkrate;162};163164/* The functions by which the transport class and the driver communicate */165struct sas_function_template {166int (*get_linkerrors)(struct sas_phy *);167int (*get_enclosure_identifier)(struct sas_rphy *, u64 *);168int (*get_bay_identifier)(struct sas_rphy *);169int (*phy_reset)(struct sas_phy *, int);170int (*phy_enable)(struct sas_phy *, int);171int (*set_phy_speed)(struct sas_phy *, struct sas_phy_linkrates *);172int (*smp_handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);173};174175176void sas_remove_children(struct device *);177extern void sas_remove_host(struct Scsi_Host *);178179extern struct sas_phy *sas_phy_alloc(struct device *, int);180extern void sas_phy_free(struct sas_phy *);181extern int sas_phy_add(struct sas_phy *);182extern void sas_phy_delete(struct sas_phy *);183extern int scsi_is_sas_phy(const struct device *);184185unsigned int sas_tlr_supported(struct scsi_device *);186unsigned int sas_is_tlr_enabled(struct scsi_device *);187void sas_disable_tlr(struct scsi_device *);188void sas_enable_tlr(struct scsi_device *);189190extern struct sas_rphy *sas_end_device_alloc(struct sas_port *);191extern struct sas_rphy *sas_expander_alloc(struct sas_port *, enum sas_device_type);192void sas_rphy_free(struct sas_rphy *);193extern int sas_rphy_add(struct sas_rphy *);194extern void sas_rphy_remove(struct sas_rphy *);195extern void sas_rphy_delete(struct sas_rphy *);196extern int scsi_is_sas_rphy(const struct device *);197198struct sas_port *sas_port_alloc(struct device *, int);199struct sas_port *sas_port_alloc_num(struct device *);200int sas_port_add(struct sas_port *);201void sas_port_free(struct sas_port *);202void sas_port_delete(struct sas_port *);203void sas_port_add_phy(struct sas_port *, struct sas_phy *);204void sas_port_delete_phy(struct sas_port *, struct sas_phy *);205void sas_port_mark_backlink(struct sas_port *);206int scsi_is_sas_port(const struct device *);207208extern struct scsi_transport_template *209sas_attach_transport(struct sas_function_template *);210extern void sas_release_transport(struct scsi_transport_template *);211int sas_read_port_mode_page(struct scsi_device *);212213static inline int214scsi_is_sas_expander_device(struct device *dev)215{216struct sas_rphy *rphy;217if (!scsi_is_sas_rphy(dev))218return 0;219rphy = dev_to_rphy(dev);220return rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE ||221rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE;222}223224#define scsi_is_sas_phy_local(phy) scsi_is_host_device((phy)->dev.parent)225226#endif /* SCSI_TRANSPORT_SAS_H */227228229