scsi_transport_sas.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef SCSI_TRANSPORT_SAS_H
  2. #define SCSI_TRANSPORT_SAS_H
  3. #include <linux/transport_class.h>
  4. #include <linux/types.h>
  5. struct scsi_transport_template;
  6. struct sas_rphy;
  7. enum sas_device_type {
  8. SAS_PHY_UNUSED,
  9. SAS_END_DEVICE,
  10. SAS_EDGE_EXPANDER_DEVICE,
  11. SAS_FANOUT_EXPANDER_DEVICE,
  12. };
  13. enum sas_protocol {
  14. SAS_PROTOCOL_SATA = 0x01,
  15. SAS_PROTOCOL_SMP = 0x02,
  16. SAS_PROTOCOL_STP = 0x04,
  17. SAS_PROTOCOL_SSP = 0x08,
  18. };
  19. enum sas_linkrate {
  20. SAS_LINK_RATE_UNKNOWN,
  21. SAS_PHY_DISABLED,
  22. SAS_LINK_RATE_FAILED,
  23. SAS_SATA_SPINUP_HOLD,
  24. SAS_SATA_PORT_SELECTOR,
  25. SAS_LINK_RATE_1_5_GBPS,
  26. SAS_LINK_RATE_3_0_GBPS,
  27. SAS_LINK_VIRTUAL,
  28. };
  29. struct sas_identify {
  30. enum sas_device_type device_type;
  31. enum sas_protocol initiator_port_protocols;
  32. enum sas_protocol target_port_protocols;
  33. u64 sas_address;
  34. u8 phy_identifier;
  35. };
  36. struct sas_phy {
  37. struct device dev;
  38. int number;
  39. /* phy identification */
  40. struct sas_identify identify;
  41. /* phy attributes */
  42. enum sas_linkrate negotiated_linkrate;
  43. enum sas_linkrate minimum_linkrate_hw;
  44. enum sas_linkrate minimum_linkrate;
  45. enum sas_linkrate maximum_linkrate_hw;
  46. enum sas_linkrate maximum_linkrate;
  47. u8 port_identifier;
  48. /* internal state */
  49. unsigned int local_attached : 1;
  50. /* link error statistics */
  51. u32 invalid_dword_count;
  52. u32 running_disparity_error_count;
  53. u32 loss_of_dword_sync_count;
  54. u32 phy_reset_problem_count;
  55. /* the other end of the link */
  56. struct sas_rphy *rphy;
  57. };
  58. #define dev_to_phy(d) \
  59. container_of((d), struct sas_phy, dev)
  60. #define transport_class_to_phy(cdev) \
  61. dev_to_phy((cdev)->dev)
  62. #define phy_to_shost(phy) \
  63. dev_to_shost((phy)->dev.parent)
  64. struct sas_rphy {
  65. struct device dev;
  66. struct sas_identify identify;
  67. struct list_head list;
  68. u32 scsi_target_id;
  69. };
  70. #define dev_to_rphy(d) \
  71. container_of((d), struct sas_rphy, dev)
  72. #define transport_class_to_rphy(cdev) \
  73. dev_to_rphy((cdev)->dev)
  74. #define rphy_to_shost(rphy) \
  75. dev_to_shost((rphy)->dev.parent)
  76. /* The functions by which the transport class and the driver communicate */
  77. struct sas_function_template {
  78. int (*get_linkerrors)(struct sas_phy *);
  79. int (*phy_reset)(struct sas_phy *, int);
  80. };
  81. extern void sas_remove_host(struct Scsi_Host *);
  82. extern struct sas_phy *sas_phy_alloc(struct device *, int);
  83. extern void sas_phy_free(struct sas_phy *);
  84. extern int sas_phy_add(struct sas_phy *);
  85. extern void sas_phy_delete(struct sas_phy *);
  86. extern int scsi_is_sas_phy(const struct device *);
  87. extern struct sas_rphy *sas_rphy_alloc(struct sas_phy *);
  88. void sas_rphy_free(struct sas_rphy *);
  89. extern int sas_rphy_add(struct sas_rphy *);
  90. extern void sas_rphy_delete(struct sas_rphy *);
  91. extern int scsi_is_sas_rphy(const struct device *);
  92. extern struct scsi_transport_template *
  93. sas_attach_transport(struct sas_function_template *);
  94. extern void sas_release_transport(struct scsi_transport_template *);
  95. #endif /* SCSI_TRANSPORT_SAS_H */