bfa_cb_ioim.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  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. #ifndef __BFA_HCB_IOIM_H__
  18. #define __BFA_HCB_IOIM_H__
  19. #include "bfa_os_inc.h"
  20. /*
  21. * task attribute values in FCP-2 FCP_CMND IU
  22. */
  23. #define SIMPLE_Q 0
  24. #define HEAD_OF_Q 1
  25. #define ORDERED_Q 2
  26. #define ACA_Q 4
  27. #define UNTAGGED 5
  28. static inline lun_t
  29. bfad_int_to_lun(u32 luno)
  30. {
  31. union {
  32. u16 scsi_lun[4];
  33. lun_t bfa_lun;
  34. } lun;
  35. lun.bfa_lun = 0;
  36. lun.scsi_lun[0] = bfa_os_htons(luno);
  37. return lun.bfa_lun;
  38. }
  39. /**
  40. * Get LUN for the I/O request
  41. */
  42. #define bfa_cb_ioim_get_lun(__dio) \
  43. bfad_int_to_lun(((struct scsi_cmnd *)__dio)->device->lun)
  44. /**
  45. * Get CDB for the I/O request
  46. */
  47. static inline u8 *
  48. bfa_cb_ioim_get_cdb(struct bfad_ioim_s *dio)
  49. {
  50. struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
  51. return (u8 *) cmnd->cmnd;
  52. }
  53. /**
  54. * Get I/O direction (read/write) for the I/O request
  55. */
  56. static inline enum fcp_iodir
  57. bfa_cb_ioim_get_iodir(struct bfad_ioim_s *dio)
  58. {
  59. struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
  60. enum dma_data_direction dmadir;
  61. dmadir = cmnd->sc_data_direction;
  62. if (dmadir == DMA_TO_DEVICE)
  63. return FCP_IODIR_WRITE;
  64. else if (dmadir == DMA_FROM_DEVICE)
  65. return FCP_IODIR_READ;
  66. else
  67. return FCP_IODIR_NONE;
  68. }
  69. /**
  70. * Get IO size in bytes for the I/O request
  71. */
  72. static inline u32
  73. bfa_cb_ioim_get_size(struct bfad_ioim_s *dio)
  74. {
  75. struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
  76. return scsi_bufflen(cmnd);
  77. }
  78. /**
  79. * Get timeout for the I/O request
  80. */
  81. static inline u8
  82. bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio)
  83. {
  84. struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
  85. /*
  86. * TBD: need a timeout for scsi passthru
  87. */
  88. if (cmnd->device->host == NULL)
  89. return 4;
  90. return 0;
  91. }
  92. /**
  93. * Get Command Reference Number for the I/O request. 0 if none.
  94. */
  95. static inline u8
  96. bfa_cb_ioim_get_crn(struct bfad_ioim_s *dio)
  97. {
  98. return 0;
  99. }
  100. /**
  101. * Get SAM-3 priority for the I/O request. 0 is default.
  102. */
  103. static inline u8
  104. bfa_cb_ioim_get_priority(struct bfad_ioim_s *dio)
  105. {
  106. return 0;
  107. }
  108. /**
  109. * Get task attributes for the I/O request. Default is FCP_TASK_ATTR_SIMPLE(0).
  110. */
  111. static inline u8
  112. bfa_cb_ioim_get_taskattr(struct bfad_ioim_s *dio)
  113. {
  114. struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
  115. u8 task_attr = UNTAGGED;
  116. if (cmnd->device->tagged_supported) {
  117. switch (cmnd->tag) {
  118. case HEAD_OF_QUEUE_TAG:
  119. task_attr = HEAD_OF_Q;
  120. break;
  121. case ORDERED_QUEUE_TAG:
  122. task_attr = ORDERED_Q;
  123. break;
  124. default:
  125. task_attr = SIMPLE_Q;
  126. break;
  127. }
  128. }
  129. return task_attr;
  130. }
  131. /**
  132. * Get CDB length in bytes for the I/O request. Default is FCP_CMND_CDB_LEN(16).
  133. */
  134. static inline u8
  135. bfa_cb_ioim_get_cdblen(struct bfad_ioim_s *dio)
  136. {
  137. struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
  138. return cmnd->cmd_len;
  139. }
  140. /**
  141. * Assign queue to be used for the I/O request. This value depends on whether
  142. * the driver wants to use the queues via any specific algorithm. Currently,
  143. * this is not supported.
  144. */
  145. #define bfa_cb_ioim_get_reqq(__dio) BFA_FALSE
  146. #endif /* __BFA_HCB_IOIM_H__ */