mptsas.h 3.0 KB

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