scsi_tgt_if.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_TSK_MGMT_RSP 0x0002
  27. /* kernel -> user */
  28. #define TGT_KEVENT_CMD_REQ 0x1001
  29. #define TGT_KEVENT_CMD_DONE 0x1002
  30. #define TGT_KEVENT_TSK_MGMT_REQ 0x1003
  31. struct tgt_event_hdr {
  32. uint16_t version;
  33. uint16_t status;
  34. uint16_t type;
  35. uint16_t len;
  36. } __attribute__ ((aligned (sizeof(uint64_t))));
  37. struct tgt_event {
  38. struct tgt_event_hdr hdr;
  39. union {
  40. /* user-> kernel */
  41. struct {
  42. int host_no;
  43. int result;
  44. aligned_u64 tag;
  45. aligned_u64 uaddr;
  46. aligned_u64 sense_uaddr;
  47. uint32_t len;
  48. uint32_t sense_len;
  49. uint8_t rw;
  50. } cmd_rsp;
  51. struct {
  52. int host_no;
  53. aligned_u64 mid;
  54. int result;
  55. } tsk_mgmt_rsp;
  56. /* kernel -> user */
  57. struct {
  58. int host_no;
  59. uint32_t data_len;
  60. uint8_t scb[16];
  61. uint8_t lun[8];
  62. int attribute;
  63. aligned_u64 tag;
  64. } cmd_req;
  65. struct {
  66. int host_no;
  67. aligned_u64 tag;
  68. int result;
  69. } cmd_done;
  70. struct {
  71. int host_no;
  72. int function;
  73. aligned_u64 tag;
  74. uint8_t lun[8];
  75. aligned_u64 mid;
  76. } tsk_mgmt_req;
  77. } p;
  78. } __attribute__ ((aligned (sizeof(uint64_t))));
  79. #define TGT_RING_SIZE (1UL << 16)
  80. #endif