scsi_tgt_if.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * SCSI target kernel/user interface
  3. *
  4. * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
  5. * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #ifndef __SCSI_TARGET_IF_H
  23. #define __SCSI_TARGET_IF_H
  24. /* user -> kernel */
  25. #define TGT_UEVENT_CMD_RSP 0x0001
  26. #define TGT_UEVENT_IT_NEXUS_RSP 0x0002
  27. #define TGT_UEVENT_TSK_MGMT_RSP 0x0003
  28. /* kernel -> user */
  29. #define TGT_KEVENT_CMD_REQ 0x1001
  30. #define TGT_KEVENT_CMD_DONE 0x1002
  31. #define TGT_KEVENT_IT_NEXUS_REQ 0x1003
  32. #define TGT_KEVENT_TSK_MGMT_REQ 0x1004
  33. struct tgt_event_hdr {
  34. uint16_t version;
  35. uint16_t status;
  36. uint16_t type;
  37. uint16_t len;
  38. } __attribute__ ((aligned (sizeof(uint64_t))));
  39. struct tgt_event {
  40. struct tgt_event_hdr hdr;
  41. union {
  42. /* user-> kernel */
  43. struct {
  44. int host_no;
  45. int result;
  46. aligned_u64 itn_id;
  47. aligned_u64 tag;
  48. aligned_u64 uaddr;
  49. aligned_u64 sense_uaddr;
  50. uint32_t len;
  51. uint32_t sense_len;
  52. uint8_t rw;
  53. } cmd_rsp;
  54. struct {
  55. int host_no;
  56. int result;
  57. aligned_u64 itn_id;
  58. aligned_u64 mid;
  59. } tsk_mgmt_rsp;
  60. struct {
  61. __s32 host_no;
  62. __s32 result;
  63. aligned_u64 itn_id;
  64. __u32 function;
  65. } it_nexus_rsp;
  66. /* kernel -> user */
  67. struct {
  68. int host_no;
  69. uint32_t data_len;
  70. aligned_u64 itn_id;
  71. uint8_t scb[16];
  72. uint8_t lun[8];
  73. int attribute;
  74. aligned_u64 tag;
  75. } cmd_req;
  76. struct {
  77. int host_no;
  78. int result;
  79. aligned_u64 itn_id;
  80. aligned_u64 tag;
  81. } cmd_done;
  82. struct {
  83. int host_no;
  84. int function;
  85. aligned_u64 itn_id;
  86. aligned_u64 tag;
  87. uint8_t lun[8];
  88. aligned_u64 mid;
  89. } tsk_mgmt_req;
  90. struct {
  91. __s32 host_no;
  92. __u32 function;
  93. aligned_u64 itn_id;
  94. __u32 max_cmds;
  95. __u8 initiator_id[16];
  96. } it_nexus_req;
  97. } p;
  98. } __attribute__ ((aligned (sizeof(uint64_t))));
  99. #define TGT_RING_SIZE (1UL << 16)
  100. #endif