mptsas.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef MPTSAS_H
  2. #define MPTSAS_H
  3. #include "mpi.h"
  4. #define MPTSAS_NUM_PORTS 8
  5. #define MPTSAS_MAX_FRAMES 2048 /* Firmware limit at 65535 */
  6. #define MPTSAS_REQUEST_QUEUE_DEPTH 128
  7. #define MPTSAS_REPLY_QUEUE_DEPTH 128
  8. #define MPTSAS_MAXIMUM_CHAIN_DEPTH 0x22
  9. typedef struct MPTSASState MPTSASState;
  10. typedef struct MPTSASRequest MPTSASRequest;
  11. enum {
  12. DOORBELL_NONE,
  13. DOORBELL_WRITE,
  14. DOORBELL_READ
  15. };
  16. struct MPTSASState {
  17. PCIDevice dev;
  18. MemoryRegion mmio_io;
  19. MemoryRegion port_io;
  20. MemoryRegion diag_io;
  21. QEMUBH *request_bh;
  22. /* properties */
  23. OnOffAuto msi;
  24. uint64_t sas_addr;
  25. bool msi_in_use;
  26. /* Doorbell register */
  27. uint32_t state;
  28. uint8_t who_init;
  29. uint8_t doorbell_state;
  30. /* Buffer for requests that are sent through the doorbell register. */
  31. uint32_t doorbell_msg[256];
  32. int doorbell_idx;
  33. int doorbell_cnt;
  34. uint16_t doorbell_reply[256];
  35. int doorbell_reply_idx;
  36. int doorbell_reply_size;
  37. /* Other registers */
  38. uint8_t diagnostic_idx;
  39. uint32_t diagnostic;
  40. uint32_t intr_mask;
  41. uint32_t intr_status;
  42. /* Request queues */
  43. uint32_t request_post[MPTSAS_REQUEST_QUEUE_DEPTH + 1];
  44. uint16_t request_post_head;
  45. uint16_t request_post_tail;
  46. uint32_t reply_post[MPTSAS_REPLY_QUEUE_DEPTH + 1];
  47. uint16_t reply_post_head;
  48. uint16_t reply_post_tail;
  49. uint32_t reply_free[MPTSAS_REPLY_QUEUE_DEPTH + 1];
  50. uint16_t reply_free_head;
  51. uint16_t reply_free_tail;
  52. /* IOC Facts */
  53. hwaddr host_mfa_high_addr;
  54. hwaddr sense_buffer_high_addr;
  55. uint16_t max_devices;
  56. uint16_t max_buses;
  57. uint16_t reply_frame_size;
  58. SCSIBus bus;
  59. QTAILQ_HEAD(, MPTSASRequest) pending;
  60. };
  61. void mptsas_fix_scsi_io_endianness(MPIMsgSCSIIORequest *req);
  62. void mptsas_fix_scsi_io_reply_endianness(MPIMsgSCSIIOReply *reply);
  63. void mptsas_fix_scsi_task_mgmt_endianness(MPIMsgSCSITaskMgmt *req);
  64. void mptsas_fix_scsi_task_mgmt_reply_endianness(MPIMsgSCSITaskMgmtReply *reply);
  65. void mptsas_fix_ioc_init_endianness(MPIMsgIOCInit *req);
  66. void mptsas_fix_ioc_init_reply_endianness(MPIMsgIOCInitReply *reply);
  67. void mptsas_fix_ioc_facts_endianness(MPIMsgIOCFacts *req);
  68. void mptsas_fix_ioc_facts_reply_endianness(MPIMsgIOCFactsReply *reply);
  69. void mptsas_fix_config_endianness(MPIMsgConfig *req);
  70. void mptsas_fix_config_reply_endianness(MPIMsgConfigReply *reply);
  71. void mptsas_fix_port_facts_endianness(MPIMsgPortFacts *req);
  72. void mptsas_fix_port_facts_reply_endianness(MPIMsgPortFactsReply *reply);
  73. void mptsas_fix_port_enable_endianness(MPIMsgPortEnable *req);
  74. void mptsas_fix_port_enable_reply_endianness(MPIMsgPortEnableReply *reply);
  75. void mptsas_fix_event_notification_endianness(MPIMsgEventNotify *req);
  76. void mptsas_fix_event_notification_reply_endianness(MPIMsgEventNotifyReply *reply);
  77. void mptsas_reply(MPTSASState *s, MPIDefaultReply *reply);
  78. void mptsas_process_config(MPTSASState *s, MPIMsgConfig *req);
  79. #endif /* MPTSAS_H */