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