bfa_cb_ioim_macros.h 3.8 KB

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