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