libsrp.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef __LIBSRP_H__
  2. #define __LIBSRP_H__
  3. #include <linux/list.h>
  4. #include <linux/kfifo.h>
  5. #include <scsi/srp.h>
  6. enum srp_valid {
  7. INVALIDATE_CMD_RESP_EL = 0,
  8. VALID_CMD_RESP_EL = 0x80,
  9. VALID_INIT_MSG = 0xC0,
  10. VALID_TRANS_EVENT = 0xFF
  11. };
  12. enum srp_format {
  13. SRP_FORMAT = 1,
  14. MAD_FORMAT = 2,
  15. OS400_FORMAT = 3,
  16. AIX_FORMAT = 4,
  17. LINUX_FORMAT = 5,
  18. MESSAGE_IN_CRQ = 6
  19. };
  20. enum srp_init_msg {
  21. INIT_MSG = 1,
  22. INIT_COMPLETE_MSG = 2
  23. };
  24. enum srp_trans_event {
  25. UNUSED_FORMAT = 0,
  26. PARTNER_FAILED = 1,
  27. PARTNER_DEREGISTER = 2,
  28. MIGRATED = 6
  29. };
  30. enum srp_status {
  31. HEADER_DESCRIPTOR = 0xF1,
  32. PING = 0xF5,
  33. PING_RESPONSE = 0xF6
  34. };
  35. enum srp_mad_version {
  36. MAD_VERSION_1 = 1
  37. };
  38. enum srp_os_type {
  39. OS400 = 1,
  40. LINUX = 2,
  41. AIX = 3,
  42. OFW = 4
  43. };
  44. enum srp_task_attributes {
  45. SRP_SIMPLE_TASK = 0,
  46. SRP_HEAD_TASK = 1,
  47. SRP_ORDERED_TASK = 2,
  48. SRP_ACA_TASK = 4
  49. };
  50. enum {
  51. SRP_TASK_MANAGEMENT_FUNCTION_COMPLETE = 0,
  52. SRP_REQUEST_FIELDS_INVALID = 2,
  53. SRP_TASK_MANAGEMENT_FUNCTION_NOT_SUPPORTED = 4,
  54. SRP_TASK_MANAGEMENT_FUNCTION_FAILED = 5
  55. };
  56. struct srp_buf {
  57. dma_addr_t dma;
  58. void *buf;
  59. };
  60. struct srp_queue {
  61. void *pool;
  62. void *items;
  63. struct kfifo queue;
  64. spinlock_t lock;
  65. };
  66. struct srp_target {
  67. struct device *dev;
  68. spinlock_t lock;
  69. struct list_head cmd_queue;
  70. size_t srp_iu_size;
  71. struct srp_queue iu_queue;
  72. size_t rx_ring_size;
  73. struct srp_buf **rx_ring;
  74. void *ldata;
  75. };
  76. struct iu_entry {
  77. struct srp_target *target;
  78. struct list_head ilist;
  79. dma_addr_t remote_token;
  80. unsigned long flags;
  81. struct srp_buf *sbuf;
  82. u16 iu_len;
  83. };
  84. struct ibmvscsis_cmd;
  85. typedef int (srp_rdma_t)(struct ibmvscsis_cmd *, struct scatterlist *, int,
  86. struct srp_direct_buf *, int,
  87. enum dma_data_direction, unsigned int);
  88. int srp_target_alloc(struct srp_target *, struct device *, size_t, size_t);
  89. void srp_target_free(struct srp_target *);
  90. struct iu_entry *srp_iu_get(struct srp_target *);
  91. void srp_iu_put(struct iu_entry *);
  92. int srp_transfer_data(struct ibmvscsis_cmd *, struct srp_cmd *,
  93. srp_rdma_t, int, int);
  94. u64 srp_data_length(struct srp_cmd *cmd, enum dma_data_direction dir);
  95. int srp_get_desc_table(struct srp_cmd *srp_cmd, enum dma_data_direction *dir,
  96. u64 *data_len);
  97. static inline int srp_cmd_direction(struct srp_cmd *cmd)
  98. {
  99. return (cmd->buf_fmt >> 4) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
  100. }
  101. #endif