lpfc_scsi.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2004-2005 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * *
  8. * This program is free software; you can redistribute it and/or *
  9. * modify it under the terms of version 2 of the GNU General *
  10. * Public License as published by the Free Software Foundation. *
  11. * This program is distributed in the hope that it will be useful. *
  12. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  13. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  14. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  15. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  16. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  17. * more details, a copy of which can be found in the file COPYING *
  18. * included with this package. *
  19. *******************************************************************/
  20. #include <asm/byteorder.h>
  21. struct lpfc_hba;
  22. #define list_remove_head(list, entry, type, member) \
  23. if (!list_empty(list)) { \
  24. entry = list_entry((list)->next, type, member); \
  25. list_del_init(&entry->member); \
  26. }
  27. #define list_get_first(list, type, member) \
  28. (list_empty(list)) ? NULL : \
  29. list_entry((list)->next, type, member)
  30. /* per-port data that is allocated in the FC transport for us */
  31. struct lpfc_rport_data {
  32. struct lpfc_nodelist *pnode; /* Pointer to the node structure. */
  33. };
  34. struct fcp_rsp {
  35. uint32_t rspRsvd1; /* FC Word 0, byte 0:3 */
  36. uint32_t rspRsvd2; /* FC Word 1, byte 0:3 */
  37. uint8_t rspStatus0; /* FCP_STATUS byte 0 (reserved) */
  38. uint8_t rspStatus1; /* FCP_STATUS byte 1 (reserved) */
  39. uint8_t rspStatus2; /* FCP_STATUS byte 2 field validity */
  40. #define RSP_LEN_VALID 0x01 /* bit 0 */
  41. #define SNS_LEN_VALID 0x02 /* bit 1 */
  42. #define RESID_OVER 0x04 /* bit 2 */
  43. #define RESID_UNDER 0x08 /* bit 3 */
  44. uint8_t rspStatus3; /* FCP_STATUS byte 3 SCSI status byte */
  45. uint32_t rspResId; /* Residual xfer if residual count field set in
  46. fcpStatus2 */
  47. /* Received in Big Endian format */
  48. uint32_t rspSnsLen; /* Length of sense data in fcpSnsInfo */
  49. /* Received in Big Endian format */
  50. uint32_t rspRspLen; /* Length of FCP response data in fcpRspInfo */
  51. /* Received in Big Endian format */
  52. uint8_t rspInfo0; /* FCP_RSP_INFO byte 0 (reserved) */
  53. uint8_t rspInfo1; /* FCP_RSP_INFO byte 1 (reserved) */
  54. uint8_t rspInfo2; /* FCP_RSP_INFO byte 2 (reserved) */
  55. uint8_t rspInfo3; /* FCP_RSP_INFO RSP_CODE byte 3 */
  56. #define RSP_NO_FAILURE 0x00
  57. #define RSP_DATA_BURST_ERR 0x01
  58. #define RSP_CMD_FIELD_ERR 0x02
  59. #define RSP_RO_MISMATCH_ERR 0x03
  60. #define RSP_TM_NOT_SUPPORTED 0x04 /* Task mgmt function not supported */
  61. #define RSP_TM_NOT_COMPLETED 0x05 /* Task mgmt function not performed */
  62. uint32_t rspInfoRsvd; /* FCP_RSP_INFO bytes 4-7 (reserved) */
  63. uint8_t rspSnsInfo[128];
  64. #define SNS_ILLEGAL_REQ 0x05 /* sense key is byte 3 ([2]) */
  65. #define SNSCOD_BADCMD 0x20 /* sense code is byte 13 ([12]) */
  66. };
  67. struct fcp_cmnd {
  68. struct scsi_lun fcp_lun;
  69. uint8_t fcpCntl0; /* FCP_CNTL byte 0 (reserved) */
  70. uint8_t fcpCntl1; /* FCP_CNTL byte 1 task codes */
  71. #define SIMPLE_Q 0x00
  72. #define HEAD_OF_Q 0x01
  73. #define ORDERED_Q 0x02
  74. #define ACA_Q 0x04
  75. #define UNTAGGED 0x05
  76. uint8_t fcpCntl2; /* FCP_CTL byte 2 task management codes */
  77. #define FCP_ABORT_TASK_SET 0x02 /* Bit 1 */
  78. #define FCP_CLEAR_TASK_SET 0x04 /* bit 2 */
  79. #define FCP_BUS_RESET 0x08 /* bit 3 */
  80. #define FCP_LUN_RESET 0x10 /* bit 4 */
  81. #define FCP_TARGET_RESET 0x20 /* bit 5 */
  82. #define FCP_CLEAR_ACA 0x40 /* bit 6 */
  83. #define FCP_TERMINATE_TASK 0x80 /* bit 7 */
  84. uint8_t fcpCntl3;
  85. #define WRITE_DATA 0x01 /* Bit 0 */
  86. #define READ_DATA 0x02 /* Bit 1 */
  87. uint8_t fcpCdb[16]; /* SRB cdb field is copied here */
  88. uint32_t fcpDl; /* Total transfer length */
  89. };
  90. struct lpfc_scsi_buf {
  91. struct list_head list;
  92. struct scsi_cmnd *pCmd;
  93. struct lpfc_hba *scsi_hba;
  94. struct lpfc_rport_data *rdata;
  95. uint32_t timeout;
  96. uint16_t status; /* From IOCB Word 7- ulpStatus */
  97. uint32_t result; /* From IOCB Word 4. */
  98. uint32_t seg_cnt; /* Number of scatter-gather segments returned by
  99. * dma_map_sg. The driver needs this for calls
  100. * to dma_unmap_sg. */
  101. dma_addr_t nonsg_phys; /* Non scatter-gather physical address. */
  102. /*
  103. * data and dma_handle are the kernel virutal and bus address of the
  104. * dma-able buffer containing the fcp_cmd, fcp_rsp and a scatter
  105. * gather bde list that supports the sg_tablesize value.
  106. */
  107. void *data;
  108. dma_addr_t dma_handle;
  109. struct fcp_cmnd *fcp_cmnd;
  110. struct fcp_rsp *fcp_rsp;
  111. struct ulp_bde64 *fcp_bpl;
  112. /* cur_iocbq has phys of the dma-able buffer.
  113. * Iotag is in here
  114. */
  115. struct lpfc_iocbq cur_iocbq;
  116. };
  117. #define LPFC_SCSI_DMA_EXT_SIZE 264
  118. #define LPFC_BPL_SIZE 1024
  119. #define MDAC_DIRECT_CMD 0x22