Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * QLogic Fibre Channel HBA Driver |
Andrew Vasquez | 01e58d8 | 2008-04-03 13:13:13 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2008 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
| 6 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include "qla_def.h" |
| 8 | |
| 9 | #include <linux/blkdev.h> |
| 10 | #include <linux/delay.h> |
| 11 | |
| 12 | #include <scsi/scsi_tcq.h> |
| 13 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 14 | static request_t *qla2x00_req_pkt(struct scsi_qla_host *, struct req_que *, |
| 15 | struct rsp_que *rsp); |
| 16 | static void qla2x00_isp_cmd(struct scsi_qla_host *, struct req_que *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame^] | 18 | static void qla25xx_set_que(srb_t *, struct req_que **, struct rsp_que **); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | /** |
| 20 | * qla2x00_get_cmd_direction() - Determine control_flag data direction. |
| 21 | * @cmd: SCSI command |
| 22 | * |
| 23 | * Returns the proper CF_* direction based on CDB. |
| 24 | */ |
| 25 | static inline uint16_t |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 26 | qla2x00_get_cmd_direction(srb_t *sp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
| 28 | uint16_t cflags; |
| 29 | |
| 30 | cflags = 0; |
| 31 | |
| 32 | /* Set transfer direction */ |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 33 | if (sp->cmd->sc_data_direction == DMA_TO_DEVICE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | cflags = CF_WRITE; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 35 | sp->fcport->vha->hw->qla_stats.output_bytes += |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 36 | scsi_bufflen(sp->cmd); |
| 37 | } else if (sp->cmd->sc_data_direction == DMA_FROM_DEVICE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | cflags = CF_READ; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 39 | sp->fcport->vha->hw->qla_stats.input_bytes += |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 40 | scsi_bufflen(sp->cmd); |
| 41 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | return (cflags); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * qla2x00_calc_iocbs_32() - Determine number of Command Type 2 and |
| 47 | * Continuation Type 0 IOCBs to allocate. |
| 48 | * |
| 49 | * @dsds: number of data segment decriptors needed |
| 50 | * |
| 51 | * Returns the number of IOCB entries needed to store @dsds. |
| 52 | */ |
| 53 | uint16_t |
| 54 | qla2x00_calc_iocbs_32(uint16_t dsds) |
| 55 | { |
| 56 | uint16_t iocbs; |
| 57 | |
| 58 | iocbs = 1; |
| 59 | if (dsds > 3) { |
| 60 | iocbs += (dsds - 3) / 7; |
| 61 | if ((dsds - 3) % 7) |
| 62 | iocbs++; |
| 63 | } |
| 64 | return (iocbs); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * qla2x00_calc_iocbs_64() - Determine number of Command Type 3 and |
| 69 | * Continuation Type 1 IOCBs to allocate. |
| 70 | * |
| 71 | * @dsds: number of data segment decriptors needed |
| 72 | * |
| 73 | * Returns the number of IOCB entries needed to store @dsds. |
| 74 | */ |
| 75 | uint16_t |
| 76 | qla2x00_calc_iocbs_64(uint16_t dsds) |
| 77 | { |
| 78 | uint16_t iocbs; |
| 79 | |
| 80 | iocbs = 1; |
| 81 | if (dsds > 2) { |
| 82 | iocbs += (dsds - 2) / 5; |
| 83 | if ((dsds - 2) % 5) |
| 84 | iocbs++; |
| 85 | } |
| 86 | return (iocbs); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * qla2x00_prep_cont_type0_iocb() - Initialize a Continuation Type 0 IOCB. |
| 91 | * @ha: HA context |
| 92 | * |
| 93 | * Returns a pointer to the Continuation Type 0 IOCB packet. |
| 94 | */ |
| 95 | static inline cont_entry_t * |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 96 | qla2x00_prep_cont_type0_iocb(struct req_que *req, struct scsi_qla_host *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | { |
| 98 | cont_entry_t *cont_pkt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* Adjust ring index. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 100 | req->ring_index++; |
| 101 | if (req->ring_index == req->length) { |
| 102 | req->ring_index = 0; |
| 103 | req->ring_ptr = req->ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 105 | req->ring_ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 108 | cont_pkt = (cont_entry_t *)req->ring_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
| 110 | /* Load packet defaults. */ |
| 111 | *((uint32_t *)(&cont_pkt->entry_type)) = |
| 112 | __constant_cpu_to_le32(CONTINUE_TYPE); |
| 113 | |
| 114 | return (cont_pkt); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * qla2x00_prep_cont_type1_iocb() - Initialize a Continuation Type 1 IOCB. |
| 119 | * @ha: HA context |
| 120 | * |
| 121 | * Returns a pointer to the continuation type 1 IOCB packet. |
| 122 | */ |
| 123 | static inline cont_a64_entry_t * |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 124 | qla2x00_prep_cont_type1_iocb(struct req_que *req, scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | { |
| 126 | cont_a64_entry_t *cont_pkt; |
| 127 | |
| 128 | /* Adjust ring index. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 129 | req->ring_index++; |
| 130 | if (req->ring_index == req->length) { |
| 131 | req->ring_index = 0; |
| 132 | req->ring_ptr = req->ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 134 | req->ring_ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 137 | cont_pkt = (cont_a64_entry_t *)req->ring_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* Load packet defaults. */ |
| 140 | *((uint32_t *)(&cont_pkt->entry_type)) = |
| 141 | __constant_cpu_to_le32(CONTINUE_A64_TYPE); |
| 142 | |
| 143 | return (cont_pkt); |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * qla2x00_build_scsi_iocbs_32() - Build IOCB command utilizing 32bit |
| 148 | * capable IOCB types. |
| 149 | * |
| 150 | * @sp: SRB command to process |
| 151 | * @cmd_pkt: Command type 2 IOCB |
| 152 | * @tot_dsds: Total number of segments to transfer |
| 153 | */ |
| 154 | void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt, |
| 155 | uint16_t tot_dsds) |
| 156 | { |
| 157 | uint16_t avail_dsds; |
| 158 | uint32_t *cur_dsd; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 159 | scsi_qla_host_t *vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | struct scsi_cmnd *cmd; |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 161 | struct scatterlist *sg; |
| 162 | int i; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 163 | struct req_que *req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
| 165 | cmd = sp->cmd; |
| 166 | |
| 167 | /* Update entry type to indicate Command Type 2 IOCB */ |
| 168 | *((uint32_t *)(&cmd_pkt->entry_type)) = |
| 169 | __constant_cpu_to_le32(COMMAND_TYPE); |
| 170 | |
| 171 | /* No data transfer */ |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 172 | if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | cmd_pkt->byte_count = __constant_cpu_to_le32(0); |
| 174 | return; |
| 175 | } |
| 176 | |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 177 | vha = sp->fcport->vha; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 178 | req = sp->que; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 180 | cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
| 182 | /* Three DSDs are available in the Command Type 2 IOCB */ |
| 183 | avail_dsds = 3; |
| 184 | cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; |
| 185 | |
| 186 | /* Load data segments */ |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 187 | scsi_for_each_sg(cmd, sg, tot_dsds, i) { |
| 188 | cont_entry_t *cont_pkt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 190 | /* Allocate additional continuation packets? */ |
| 191 | if (avail_dsds == 0) { |
| 192 | /* |
| 193 | * Seven DSDs are available in the Continuation |
| 194 | * Type 0 IOCB. |
| 195 | */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 196 | cont_pkt = qla2x00_prep_cont_type0_iocb(req, vha); |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 197 | cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address; |
| 198 | avail_dsds = 7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 200 | |
| 201 | *cur_dsd++ = cpu_to_le32(sg_dma_address(sg)); |
| 202 | *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
| 203 | avail_dsds--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * qla2x00_build_scsi_iocbs_64() - Build IOCB command utilizing 64bit |
| 209 | * capable IOCB types. |
| 210 | * |
| 211 | * @sp: SRB command to process |
| 212 | * @cmd_pkt: Command type 3 IOCB |
| 213 | * @tot_dsds: Total number of segments to transfer |
| 214 | */ |
| 215 | void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt, |
| 216 | uint16_t tot_dsds) |
| 217 | { |
| 218 | uint16_t avail_dsds; |
| 219 | uint32_t *cur_dsd; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 220 | scsi_qla_host_t *vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | struct scsi_cmnd *cmd; |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 222 | struct scatterlist *sg; |
| 223 | int i; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 224 | struct req_que *req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
| 226 | cmd = sp->cmd; |
| 227 | |
| 228 | /* Update entry type to indicate Command Type 3 IOCB */ |
| 229 | *((uint32_t *)(&cmd_pkt->entry_type)) = |
| 230 | __constant_cpu_to_le32(COMMAND_A64_TYPE); |
| 231 | |
| 232 | /* No data transfer */ |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 233 | if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | cmd_pkt->byte_count = __constant_cpu_to_le32(0); |
| 235 | return; |
| 236 | } |
| 237 | |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 238 | vha = sp->fcport->vha; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 239 | req = sp->que; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 241 | cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | |
| 243 | /* Two DSDs are available in the Command Type 3 IOCB */ |
| 244 | avail_dsds = 2; |
| 245 | cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; |
| 246 | |
| 247 | /* Load data segments */ |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 248 | scsi_for_each_sg(cmd, sg, tot_dsds, i) { |
| 249 | dma_addr_t sle_dma; |
| 250 | cont_a64_entry_t *cont_pkt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 252 | /* Allocate additional continuation packets? */ |
| 253 | if (avail_dsds == 0) { |
| 254 | /* |
| 255 | * Five DSDs are available in the Continuation |
| 256 | * Type 1 IOCB. |
| 257 | */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 258 | cont_pkt = qla2x00_prep_cont_type1_iocb(req, vha); |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 259 | cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; |
| 260 | avail_dsds = 5; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | } |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 262 | |
| 263 | sle_dma = sg_dma_address(sg); |
| 264 | *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
| 265 | *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
| 266 | *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
| 267 | avail_dsds--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * qla2x00_start_scsi() - Send a SCSI command to the ISP |
| 273 | * @sp: command to send to the ISP |
| 274 | * |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 275 | * Returns non-zero if a failure occurred, else zero. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | */ |
| 277 | int |
| 278 | qla2x00_start_scsi(srb_t *sp) |
| 279 | { |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 280 | int ret, nseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 282 | scsi_qla_host_t *vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | struct scsi_cmnd *cmd; |
| 284 | uint32_t *clr_ptr; |
| 285 | uint32_t index; |
| 286 | uint32_t handle; |
| 287 | cmd_entry_t *cmd_pkt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | uint16_t cnt; |
| 289 | uint16_t req_cnt; |
| 290 | uint16_t tot_dsds; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 291 | struct device_reg_2xxx __iomem *reg; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 292 | struct qla_hw_data *ha; |
| 293 | struct req_que *req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 294 | struct rsp_que *rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | /* Setup device pointers. */ |
| 297 | ret = 0; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 298 | vha = sp->fcport->vha; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 299 | ha = vha->hw; |
Andrew Vasquez | 3d71644 | 2005-07-06 10:30:26 -0700 | [diff] [blame] | 300 | reg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | cmd = sp->cmd; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 302 | req = ha->req_q_map[0]; |
| 303 | rsp = ha->rsp_q_map[0]; |
| 8302192 | 2005-04-17 15:10:41 -0500 | [diff] [blame] | 304 | /* So we know we haven't pci_map'ed anything yet */ |
| 305 | tot_dsds = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
| 307 | /* Send marker if required */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 308 | if (vha->marker_needed != 0) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 309 | if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) |
| 310 | != QLA_SUCCESS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | return (QLA_FUNCTION_FAILED); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 312 | vha->marker_needed = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /* Acquire ring specific lock */ |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 316 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
| 318 | /* Check for room in outstanding command list. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 319 | handle = req->current_outstanding_cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { |
| 321 | handle++; |
| 322 | if (handle == MAX_OUTSTANDING_COMMANDS) |
| 323 | handle = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 324 | if (!req->outstanding_cmds[handle]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | break; |
| 326 | } |
| 327 | if (index == MAX_OUTSTANDING_COMMANDS) |
| 328 | goto queuing_error; |
| 329 | |
| 8302192 | 2005-04-17 15:10:41 -0500 | [diff] [blame] | 330 | /* Map the sg table so we have an accurate count of sg entries needed */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 331 | if (scsi_sg_count(cmd)) { |
| 332 | nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), |
| 333 | scsi_sg_count(cmd), cmd->sc_data_direction); |
| 334 | if (unlikely(!nseg)) |
| 335 | goto queuing_error; |
| 336 | } else |
| 337 | nseg = 0; |
| 338 | |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 339 | tot_dsds = nseg; |
| 8302192 | 2005-04-17 15:10:41 -0500 | [diff] [blame] | 340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | /* Calculate the number of request entries needed. */ |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 342 | req_cnt = ha->isp_ops->calc_req_entries(tot_dsds); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 343 | if (req->cnt < (req_cnt + 2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 345 | if (req->ring_index < cnt) |
| 346 | req->cnt = cnt - req->ring_index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 348 | req->cnt = req->length - |
| 349 | (req->ring_index - cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 351 | if (req->cnt < (req_cnt + 2)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | goto queuing_error; |
| 353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | /* Build command packet */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 355 | req->current_outstanding_cmd = handle; |
| 356 | req->outstanding_cmds[handle] = sp; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 357 | sp->que = req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 359 | req->cnt -= req_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 361 | cmd_pkt = (cmd_entry_t *)req->ring_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | cmd_pkt->handle = handle; |
| 363 | /* Zero out remaining portion of packet. */ |
| 364 | clr_ptr = (uint32_t *)cmd_pkt + 2; |
| 365 | memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); |
| 366 | cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); |
| 367 | |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 368 | /* Set target ID and LUN number*/ |
| 369 | SET_TARGET_ID(ha, cmd_pkt->target, sp->fcport->loop_id); |
| 370 | cmd_pkt->lun = cpu_to_le16(sp->cmd->device->lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
| 372 | /* Update tagged queuing modifier */ |
| 373 | cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | /* Load SCSI command packet. */ |
| 376 | memcpy(cmd_pkt->scsi_cdb, cmd->cmnd, cmd->cmd_len); |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 377 | cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
| 379 | /* Build IOCB segments */ |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 380 | ha->isp_ops->build_iocbs(sp, cmd_pkt, tot_dsds); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
| 382 | /* Set total data segment count. */ |
| 383 | cmd_pkt->entry_count = (uint8_t)req_cnt; |
| 384 | wmb(); |
| 385 | |
| 386 | /* Adjust ring index. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 387 | req->ring_index++; |
| 388 | if (req->ring_index == req->length) { |
| 389 | req->ring_index = 0; |
| 390 | req->ring_ptr = req->ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 392 | req->ring_ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | sp->flags |= SRB_DMA_VALID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
| 396 | /* Set chip new ring index. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 397 | WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), req->ring_index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, reg)); /* PCI Posting. */ |
| 399 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 400 | /* Manage unprocessed RIO/ZIO commands in response queue. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 401 | if (vha->flags.process_response_queue && |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 402 | rsp->ring_ptr->signature != RESPONSE_PROCESSED) |
| 403 | qla2x00_process_response_queue(rsp); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 404 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 405 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | return (QLA_SUCCESS); |
| 407 | |
| 408 | queuing_error: |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 409 | if (tot_dsds) |
| 410 | scsi_dma_unmap(cmd); |
| 411 | |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 412 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | |
| 414 | return (QLA_FUNCTION_FAILED); |
| 415 | } |
| 416 | |
| 417 | /** |
| 418 | * qla2x00_marker() - Send a marker IOCB to the firmware. |
| 419 | * @ha: HA context |
| 420 | * @loop_id: loop ID |
| 421 | * @lun: LUN |
| 422 | * @type: marker modifier |
| 423 | * |
| 424 | * Can be called from both normal and interrupt context. |
| 425 | * |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 426 | * Returns non-zero if a failure occurred, else zero. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 428 | int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 429 | __qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req, |
| 430 | struct rsp_que *rsp, uint16_t loop_id, |
| 431 | uint16_t lun, uint8_t type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | { |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 433 | mrk_entry_t *mrk; |
| 434 | struct mrk_entry_24xx *mrk24; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 435 | struct qla_hw_data *ha = vha->hw; |
| 436 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 438 | mrk24 = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 439 | mrk = (mrk_entry_t *)qla2x00_req_pkt(vha, req, rsp); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 440 | if (mrk == NULL) { |
| 441 | DEBUG2_3(printk("%s(%ld): failed to allocate Marker IOCB.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 442 | __func__, base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | |
| 444 | return (QLA_FUNCTION_FAILED); |
| 445 | } |
| 446 | |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 447 | mrk->entry_type = MARKER_TYPE; |
| 448 | mrk->modifier = type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | if (type != MK_SYNC_ALL) { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 450 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 451 | mrk24 = (struct mrk_entry_24xx *) mrk; |
| 452 | mrk24->nport_handle = cpu_to_le16(loop_id); |
| 453 | mrk24->lun[1] = LSB(lun); |
| 454 | mrk24->lun[2] = MSB(lun); |
Shyam Sundar | b797b6d | 2006-08-01 13:48:13 -0700 | [diff] [blame] | 455 | host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 456 | mrk24->vp_index = vha->vp_idx; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 457 | mrk24->handle = MAKE_HANDLE(req->id, mrk24->handle); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 458 | } else { |
| 459 | SET_TARGET_ID(ha, mrk->target, loop_id); |
| 460 | mrk->lun = cpu_to_le16(lun); |
| 461 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | } |
| 463 | wmb(); |
| 464 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 465 | qla2x00_isp_cmd(vha, req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
| 467 | return (QLA_SUCCESS); |
| 468 | } |
| 469 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 470 | int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 471 | qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req, |
| 472 | struct rsp_que *rsp, uint16_t loop_id, uint16_t lun, |
| 473 | uint8_t type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | { |
| 475 | int ret; |
| 476 | unsigned long flags = 0; |
| 477 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 478 | spin_lock_irqsave(&vha->hw->hardware_lock, flags); |
| 479 | ret = __qla2x00_marker(vha, req, rsp, loop_id, lun, type); |
| 480 | spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
| 482 | return (ret); |
| 483 | } |
| 484 | |
| 485 | /** |
| 486 | * qla2x00_req_pkt() - Retrieve a request packet from the request ring. |
| 487 | * @ha: HA context |
| 488 | * |
| 489 | * Note: The caller must hold the hardware lock before calling this routine. |
| 490 | * |
| 491 | * Returns NULL if function failed, else, a pointer to the request packet. |
| 492 | */ |
| 493 | static request_t * |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 494 | qla2x00_req_pkt(struct scsi_qla_host *vha, struct req_que *req, |
| 495 | struct rsp_que *rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 497 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 498 | device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | request_t *pkt = NULL; |
| 500 | uint16_t cnt; |
| 501 | uint32_t *dword_ptr; |
| 502 | uint32_t timer; |
| 503 | uint16_t req_cnt = 1; |
| 504 | |
| 505 | /* Wait 1 second for slot. */ |
| 506 | for (timer = HZ; timer; timer--) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 507 | if ((req_cnt + 2) >= req->cnt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | /* Calculate number of free request entries. */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 509 | if (ha->mqenable) |
| 510 | cnt = (uint16_t) |
| 511 | RD_REG_DWORD(®->isp25mq.req_q_out); |
| 512 | else { |
| 513 | if (IS_FWI2_CAPABLE(ha)) |
| 514 | cnt = (uint16_t)RD_REG_DWORD( |
| 515 | ®->isp24.req_q_out); |
| 516 | else |
| 517 | cnt = qla2x00_debounce_register( |
| 518 | ISP_REQ_Q_OUT(ha, ®->isp)); |
| 519 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 520 | if (req->ring_index < cnt) |
| 521 | req->cnt = cnt - req->ring_index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 523 | req->cnt = req->length - |
| 524 | (req->ring_index - cnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | } |
| 526 | /* If room for request in request ring. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 527 | if ((req_cnt + 2) < req->cnt) { |
| 528 | req->cnt--; |
| 529 | pkt = req->ring_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | |
| 531 | /* Zero out packet. */ |
| 532 | dword_ptr = (uint32_t *)pkt; |
| 533 | for (cnt = 0; cnt < REQUEST_ENTRY_SIZE / 4; cnt++) |
| 534 | *dword_ptr++ = 0; |
| 535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | /* Set entry count. */ |
| 537 | pkt->entry_count = 1; |
| 538 | |
| 539 | break; |
| 540 | } |
| 541 | |
| 542 | /* Release ring specific lock */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 543 | spin_unlock_irq(&ha->hardware_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | |
| 545 | udelay(2); /* 2 us */ |
| 546 | |
| 547 | /* Check for pending interrupts. */ |
| 548 | /* During init we issue marker directly */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 549 | if (!vha->marker_needed && !vha->flags.init_done) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 550 | qla2x00_poll(rsp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | spin_lock_irq(&ha->hardware_lock); |
| 552 | } |
| 553 | if (!pkt) { |
| 554 | DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); |
| 555 | } |
| 556 | |
| 557 | return (pkt); |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * qla2x00_isp_cmd() - Modify the request ring pointer. |
| 562 | * @ha: HA context |
| 563 | * |
| 564 | * Note: The caller must hold the hardware lock before calling this routine. |
| 565 | */ |
Adrian Bunk | 413975a | 2006-06-30 02:33:06 -0700 | [diff] [blame] | 566 | static void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 567 | qla2x00_isp_cmd(struct scsi_qla_host *vha, struct req_que *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 569 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 570 | device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 571 | struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | |
| 573 | DEBUG5(printk("%s(): IOCB data:\n", __func__)); |
| 574 | DEBUG5(qla2x00_dump_buffer( |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 575 | (uint8_t *)req->ring_ptr, REQUEST_ENTRY_SIZE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | |
| 577 | /* Adjust ring index. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 578 | req->ring_index++; |
| 579 | if (req->ring_index == req->length) { |
| 580 | req->ring_index = 0; |
| 581 | req->ring_ptr = req->ring; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 583 | req->ring_ptr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
| 585 | /* Set chip new ring index. */ |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 586 | if (ha->mqenable) { |
| 587 | WRT_REG_DWORD(®->isp25mq.req_q_in, req->ring_index); |
| 588 | RD_REG_DWORD(&ioreg->hccr); |
| 589 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 590 | else { |
| 591 | if (IS_FWI2_CAPABLE(ha)) { |
| 592 | WRT_REG_DWORD(®->isp24.req_q_in, req->ring_index); |
| 593 | RD_REG_DWORD_RELAXED(®->isp24.req_q_in); |
| 594 | } else { |
| 595 | WRT_REG_WORD(ISP_REQ_Q_IN(ha, ®->isp), |
| 596 | req->ring_index); |
| 597 | RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, ®->isp)); |
| 598 | } |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | } |
| 602 | |
| 603 | /** |
| 604 | * qla24xx_calc_iocbs() - Determine number of Command Type 3 and |
| 605 | * Continuation Type 1 IOCBs to allocate. |
| 606 | * |
| 607 | * @dsds: number of data segment decriptors needed |
| 608 | * |
| 609 | * Returns the number of IOCB entries needed to store @dsds. |
| 610 | */ |
| 611 | static inline uint16_t |
| 612 | qla24xx_calc_iocbs(uint16_t dsds) |
| 613 | { |
| 614 | uint16_t iocbs; |
| 615 | |
| 616 | iocbs = 1; |
| 617 | if (dsds > 1) { |
| 618 | iocbs += (dsds - 1) / 5; |
| 619 | if ((dsds - 1) % 5) |
| 620 | iocbs++; |
| 621 | } |
| 622 | return iocbs; |
| 623 | } |
| 624 | |
| 625 | /** |
| 626 | * qla24xx_build_scsi_iocbs() - Build IOCB command utilizing Command Type 7 |
| 627 | * IOCB types. |
| 628 | * |
| 629 | * @sp: SRB command to process |
| 630 | * @cmd_pkt: Command type 3 IOCB |
| 631 | * @tot_dsds: Total number of segments to transfer |
| 632 | */ |
| 633 | static inline void |
| 634 | qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt, |
| 635 | uint16_t tot_dsds) |
| 636 | { |
| 637 | uint16_t avail_dsds; |
| 638 | uint32_t *cur_dsd; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 639 | scsi_qla_host_t *vha; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 640 | struct scsi_cmnd *cmd; |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 641 | struct scatterlist *sg; |
| 642 | int i; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 643 | struct req_que *req; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 644 | |
| 645 | cmd = sp->cmd; |
| 646 | |
| 647 | /* Update entry type to indicate Command Type 3 IOCB */ |
| 648 | *((uint32_t *)(&cmd_pkt->entry_type)) = |
| 649 | __constant_cpu_to_le32(COMMAND_TYPE_7); |
| 650 | |
| 651 | /* No data transfer */ |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 652 | if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 653 | cmd_pkt->byte_count = __constant_cpu_to_le32(0); |
| 654 | return; |
| 655 | } |
| 656 | |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 657 | vha = sp->fcport->vha; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 658 | req = sp->que; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 659 | |
| 660 | /* Set transfer direction */ |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 661 | if (cmd->sc_data_direction == DMA_TO_DEVICE) { |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 662 | cmd_pkt->task_mgmt_flags = |
| 663 | __constant_cpu_to_le16(TMF_WRITE_DATA); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 664 | sp->fcport->vha->hw->qla_stats.output_bytes += |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 665 | scsi_bufflen(sp->cmd); |
| 666 | } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 667 | cmd_pkt->task_mgmt_flags = |
| 668 | __constant_cpu_to_le16(TMF_READ_DATA); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 669 | sp->fcport->vha->hw->qla_stats.input_bytes += |
Harish Zunjarrao | 49fd462 | 2008-09-11 21:22:47 -0700 | [diff] [blame] | 670 | scsi_bufflen(sp->cmd); |
| 671 | } |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 672 | |
| 673 | /* One DSD is available in the Command Type 3 IOCB */ |
| 674 | avail_dsds = 1; |
| 675 | cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; |
| 676 | |
| 677 | /* Load data segments */ |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 678 | |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 679 | scsi_for_each_sg(cmd, sg, tot_dsds, i) { |
| 680 | dma_addr_t sle_dma; |
| 681 | cont_a64_entry_t *cont_pkt; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 682 | |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 683 | /* Allocate additional continuation packets? */ |
| 684 | if (avail_dsds == 0) { |
| 685 | /* |
| 686 | * Five DSDs are available in the Continuation |
| 687 | * Type 1 IOCB. |
| 688 | */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 689 | cont_pkt = qla2x00_prep_cont_type1_iocb(req, vha); |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 690 | cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; |
| 691 | avail_dsds = 5; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 692 | } |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 693 | |
| 694 | sle_dma = sg_dma_address(sg); |
| 695 | *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
| 696 | *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
| 697 | *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
| 698 | avail_dsds--; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | |
| 702 | |
| 703 | /** |
| 704 | * qla24xx_start_scsi() - Send a SCSI command to the ISP |
| 705 | * @sp: command to send to the ISP |
| 706 | * |
Bjorn Helgaas | cc3ef7b | 2008-09-11 21:22:51 -0700 | [diff] [blame] | 707 | * Returns non-zero if a failure occurred, else zero. |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 708 | */ |
| 709 | int |
| 710 | qla24xx_start_scsi(srb_t *sp) |
| 711 | { |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 712 | int ret, nseg; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 713 | unsigned long flags; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 714 | uint32_t *clr_ptr; |
| 715 | uint32_t index; |
| 716 | uint32_t handle; |
| 717 | struct cmd_type_7 *cmd_pkt; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 718 | uint16_t cnt; |
| 719 | uint16_t req_cnt; |
| 720 | uint16_t tot_dsds; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 721 | struct req_que *req = NULL; |
| 722 | struct rsp_que *rsp = NULL; |
| 723 | struct scsi_cmnd *cmd = sp->cmd; |
Andrew Vasquez | 444786d | 2009-01-05 11:18:10 -0800 | [diff] [blame] | 724 | struct scsi_qla_host *vha = sp->fcport->vha; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 725 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 726 | |
| 727 | /* Setup device pointers. */ |
| 728 | ret = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 729 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame^] | 730 | qla25xx_set_que(sp, &req, &rsp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 731 | sp->que = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 732 | |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 733 | /* So we know we haven't pci_map'ed anything yet */ |
| 734 | tot_dsds = 0; |
| 735 | |
| 736 | /* Send marker if required */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 737 | if (vha->marker_needed != 0) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 738 | if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) |
| 739 | != QLA_SUCCESS) |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 740 | return QLA_FUNCTION_FAILED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 741 | vha->marker_needed = 0; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /* Acquire ring specific lock */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 745 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 746 | |
| 747 | /* Check for room in outstanding command list. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 748 | handle = req->current_outstanding_cmd; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 749 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { |
| 750 | handle++; |
| 751 | if (handle == MAX_OUTSTANDING_COMMANDS) |
| 752 | handle = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 753 | if (!req->outstanding_cmds[handle]) |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 754 | break; |
| 755 | } |
| 756 | if (index == MAX_OUTSTANDING_COMMANDS) |
| 757 | goto queuing_error; |
| 758 | |
| 759 | /* Map the sg table so we have an accurate count of sg entries needed */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 760 | if (scsi_sg_count(cmd)) { |
| 761 | nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), |
| 762 | scsi_sg_count(cmd), cmd->sc_data_direction); |
| 763 | if (unlikely(!nseg)) |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 764 | goto queuing_error; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 765 | } else |
| 766 | nseg = 0; |
| 767 | |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 768 | tot_dsds = nseg; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 769 | |
| 770 | req_cnt = qla24xx_calc_iocbs(tot_dsds); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 771 | if (req->cnt < (req_cnt + 2)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 772 | cnt = RD_REG_DWORD_RELAXED(req->req_q_out); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 773 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 774 | if (req->ring_index < cnt) |
| 775 | req->cnt = cnt - req->ring_index; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 776 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 777 | req->cnt = req->length - |
| 778 | (req->ring_index - cnt); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 779 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 780 | if (req->cnt < (req_cnt + 2)) |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 781 | goto queuing_error; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 782 | |
| 783 | /* Build command packet. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 784 | req->current_outstanding_cmd = handle; |
| 785 | req->outstanding_cmds[handle] = sp; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 786 | sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 787 | req->cnt -= req_cnt; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 788 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 789 | cmd_pkt = (struct cmd_type_7 *)req->ring_ptr; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 790 | cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 791 | |
| 792 | /* Zero out remaining portion of packet. */ |
James Bottomley | 72df832 | 2005-10-28 14:41:19 -0500 | [diff] [blame] | 793 | /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 794 | clr_ptr = (uint32_t *)cmd_pkt + 2; |
| 795 | memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); |
| 796 | cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); |
| 797 | |
| 798 | /* Set NPORT-ID and LUN number*/ |
| 799 | cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
| 800 | cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; |
| 801 | cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; |
| 802 | cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 803 | cmd_pkt->vp_index = sp->fcport->vp_idx; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 804 | |
Andrew Vasquez | 661c3f6 | 2005-10-27 11:09:58 -0700 | [diff] [blame] | 805 | int_to_scsilun(sp->cmd->device->lun, &cmd_pkt->lun); |
andrew.vasquez@qlogic.com | 0d4be12 | 2006-02-07 08:45:35 -0800 | [diff] [blame] | 806 | host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 807 | |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 808 | /* Load SCSI command packet. */ |
| 809 | memcpy(cmd_pkt->fcp_cdb, cmd->cmnd, cmd->cmd_len); |
| 810 | host_to_fcp_swap(cmd_pkt->fcp_cdb, sizeof(cmd_pkt->fcp_cdb)); |
| 811 | |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 812 | cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 813 | |
| 814 | /* Build IOCB segments */ |
| 815 | qla24xx_build_scsi_iocbs(sp, cmd_pkt, tot_dsds); |
| 816 | |
| 817 | /* Set total data segment count. */ |
| 818 | cmd_pkt->entry_count = (uint8_t)req_cnt; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 819 | /* Specify response queue number where completion should happen */ |
| 820 | cmd_pkt->entry_status = (uint8_t) rsp->id; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 821 | wmb(); |
| 822 | |
| 823 | /* Adjust ring index. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 824 | req->ring_index++; |
| 825 | if (req->ring_index == req->length) { |
| 826 | req->ring_index = 0; |
| 827 | req->ring_ptr = req->ring; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 828 | } else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 829 | req->ring_ptr++; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 830 | |
| 831 | sp->flags |= SRB_DMA_VALID; |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 832 | |
| 833 | /* Set chip new ring index. */ |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 834 | WRT_REG_DWORD(req->req_q_in, req->ring_index); |
| 835 | RD_REG_DWORD_RELAXED(&ha->iobase->isp24.hccr); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 836 | |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 837 | /* Manage unprocessed RIO/ZIO commands in response queue. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 838 | if (vha->flags.process_response_queue && |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 839 | rsp->ring_ptr->signature != RESPONSE_PROCESSED) |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 840 | qla24xx_process_response_queue(vha, rsp); |
Andrew Vasquez | 4fdfefe | 2005-10-27 11:09:48 -0700 | [diff] [blame] | 841 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 842 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 843 | return QLA_SUCCESS; |
| 844 | |
| 845 | queuing_error: |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 846 | if (tot_dsds) |
| 847 | scsi_dma_unmap(cmd); |
| 848 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 849 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 2b6c0ce | 2005-07-06 10:31:17 -0700 | [diff] [blame] | 850 | |
| 851 | return QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame^] | 853 | |
| 854 | static void qla25xx_set_que(srb_t *sp, struct req_que **req, |
| 855 | struct rsp_que **rsp) |
| 856 | { |
| 857 | struct scsi_cmnd *cmd = sp->cmd; |
| 858 | struct scsi_qla_host *vha = sp->fcport->vha; |
| 859 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 860 | int affinity = cmd->request->cpu; |
| 861 | |
| 862 | if (ql2xmultique_tag && affinity >= 0 && |
| 863 | affinity < ha->max_rsp_queues - 1) { |
| 864 | *rsp = ha->rsp_q_map[affinity + 1]; |
| 865 | *req = ha->req_q_map[1]; |
| 866 | } else { |
| 867 | *req = vha->req; |
| 868 | *rsp = ha->rsp_q_map[0]; |
| 869 | } |
| 870 | } |