| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * QLogic Fibre Channel HBA Driver |
|---|
| 3 | 4 | * Copyright (c) 2003-2014 QLogic Corporation |
|---|
| 4 | | - * |
|---|
| 5 | | - * See LICENSE.qla2xxx for copyright and licensing details. |
|---|
| 6 | 5 | */ |
|---|
| 7 | 6 | #include "qla_def.h" |
|---|
| 8 | 7 | #include "qla_target.h" |
|---|
| .. | .. |
|---|
| 44 | 43 | * qla2x00_calc_iocbs_32() - Determine number of Command Type 2 and |
|---|
| 45 | 44 | * Continuation Type 0 IOCBs to allocate. |
|---|
| 46 | 45 | * |
|---|
| 47 | | - * @dsds: number of data segment decriptors needed |
|---|
| 46 | + * @dsds: number of data segment descriptors needed |
|---|
| 48 | 47 | * |
|---|
| 49 | 48 | * Returns the number of IOCB entries needed to store @dsds. |
|---|
| 50 | 49 | */ |
|---|
| .. | .. |
|---|
| 66 | 65 | * qla2x00_calc_iocbs_64() - Determine number of Command Type 3 and |
|---|
| 67 | 66 | * Continuation Type 1 IOCBs to allocate. |
|---|
| 68 | 67 | * |
|---|
| 69 | | - * @dsds: number of data segment decriptors needed |
|---|
| 68 | + * @dsds: number of data segment descriptors needed |
|---|
| 70 | 69 | * |
|---|
| 71 | 70 | * Returns the number of IOCB entries needed to store @dsds. |
|---|
| 72 | 71 | */ |
|---|
| .. | .. |
|---|
| 107 | 106 | cont_pkt = (cont_entry_t *)req->ring_ptr; |
|---|
| 108 | 107 | |
|---|
| 109 | 108 | /* Load packet defaults. */ |
|---|
| 110 | | - *((uint32_t *)(&cont_pkt->entry_type)) = cpu_to_le32(CONTINUE_TYPE); |
|---|
| 109 | + put_unaligned_le32(CONTINUE_TYPE, &cont_pkt->entry_type); |
|---|
| 111 | 110 | |
|---|
| 112 | 111 | return (cont_pkt); |
|---|
| 113 | 112 | } |
|---|
| .. | .. |
|---|
| 136 | 135 | cont_pkt = (cont_a64_entry_t *)req->ring_ptr; |
|---|
| 137 | 136 | |
|---|
| 138 | 137 | /* Load packet defaults. */ |
|---|
| 139 | | - *((uint32_t *)(&cont_pkt->entry_type)) = IS_QLAFX00(vha->hw) ? |
|---|
| 140 | | - cpu_to_le32(CONTINUE_A64_TYPE_FX00) : |
|---|
| 141 | | - cpu_to_le32(CONTINUE_A64_TYPE); |
|---|
| 138 | + put_unaligned_le32(IS_QLAFX00(vha->hw) ? CONTINUE_A64_TYPE_FX00 : |
|---|
| 139 | + CONTINUE_A64_TYPE, &cont_pkt->entry_type); |
|---|
| 142 | 140 | |
|---|
| 143 | 141 | return (cont_pkt); |
|---|
| 144 | 142 | } |
|---|
| .. | .. |
|---|
| 193 | 191 | uint16_t tot_dsds) |
|---|
| 194 | 192 | { |
|---|
| 195 | 193 | uint16_t avail_dsds; |
|---|
| 196 | | - uint32_t *cur_dsd; |
|---|
| 194 | + struct dsd32 *cur_dsd; |
|---|
| 197 | 195 | scsi_qla_host_t *vha; |
|---|
| 198 | 196 | struct scsi_cmnd *cmd; |
|---|
| 199 | 197 | struct scatterlist *sg; |
|---|
| .. | .. |
|---|
| 202 | 200 | cmd = GET_CMD_SP(sp); |
|---|
| 203 | 201 | |
|---|
| 204 | 202 | /* Update entry type to indicate Command Type 2 IOCB */ |
|---|
| 205 | | - *((uint32_t *)(&cmd_pkt->entry_type)) = |
|---|
| 206 | | - cpu_to_le32(COMMAND_TYPE); |
|---|
| 203 | + put_unaligned_le32(COMMAND_TYPE, &cmd_pkt->entry_type); |
|---|
| 207 | 204 | |
|---|
| 208 | 205 | /* No data transfer */ |
|---|
| 209 | 206 | if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { |
|---|
| .. | .. |
|---|
| 215 | 212 | cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); |
|---|
| 216 | 213 | |
|---|
| 217 | 214 | /* Three DSDs are available in the Command Type 2 IOCB */ |
|---|
| 218 | | - avail_dsds = 3; |
|---|
| 219 | | - cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; |
|---|
| 215 | + avail_dsds = ARRAY_SIZE(cmd_pkt->dsd32); |
|---|
| 216 | + cur_dsd = cmd_pkt->dsd32; |
|---|
| 220 | 217 | |
|---|
| 221 | 218 | /* Load data segments */ |
|---|
| 222 | 219 | scsi_for_each_sg(cmd, sg, tot_dsds, i) { |
|---|
| .. | .. |
|---|
| 229 | 226 | * Type 0 IOCB. |
|---|
| 230 | 227 | */ |
|---|
| 231 | 228 | cont_pkt = qla2x00_prep_cont_type0_iocb(vha); |
|---|
| 232 | | - cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address; |
|---|
| 233 | | - avail_dsds = 7; |
|---|
| 229 | + cur_dsd = cont_pkt->dsd; |
|---|
| 230 | + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); |
|---|
| 234 | 231 | } |
|---|
| 235 | 232 | |
|---|
| 236 | | - *cur_dsd++ = cpu_to_le32(sg_dma_address(sg)); |
|---|
| 237 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 233 | + append_dsd32(&cur_dsd, sg); |
|---|
| 238 | 234 | avail_dsds--; |
|---|
| 239 | 235 | } |
|---|
| 240 | 236 | } |
|---|
| .. | .. |
|---|
| 251 | 247 | uint16_t tot_dsds) |
|---|
| 252 | 248 | { |
|---|
| 253 | 249 | uint16_t avail_dsds; |
|---|
| 254 | | - uint32_t *cur_dsd; |
|---|
| 250 | + struct dsd64 *cur_dsd; |
|---|
| 255 | 251 | scsi_qla_host_t *vha; |
|---|
| 256 | 252 | struct scsi_cmnd *cmd; |
|---|
| 257 | 253 | struct scatterlist *sg; |
|---|
| .. | .. |
|---|
| 260 | 256 | cmd = GET_CMD_SP(sp); |
|---|
| 261 | 257 | |
|---|
| 262 | 258 | /* Update entry type to indicate Command Type 3 IOCB */ |
|---|
| 263 | | - *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_A64_TYPE); |
|---|
| 259 | + put_unaligned_le32(COMMAND_A64_TYPE, &cmd_pkt->entry_type); |
|---|
| 264 | 260 | |
|---|
| 265 | 261 | /* No data transfer */ |
|---|
| 266 | 262 | if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { |
|---|
| .. | .. |
|---|
| 272 | 268 | cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); |
|---|
| 273 | 269 | |
|---|
| 274 | 270 | /* Two DSDs are available in the Command Type 3 IOCB */ |
|---|
| 275 | | - avail_dsds = 2; |
|---|
| 276 | | - cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; |
|---|
| 271 | + avail_dsds = ARRAY_SIZE(cmd_pkt->dsd64); |
|---|
| 272 | + cur_dsd = cmd_pkt->dsd64; |
|---|
| 277 | 273 | |
|---|
| 278 | 274 | /* Load data segments */ |
|---|
| 279 | 275 | scsi_for_each_sg(cmd, sg, tot_dsds, i) { |
|---|
| 280 | | - dma_addr_t sle_dma; |
|---|
| 281 | 276 | cont_a64_entry_t *cont_pkt; |
|---|
| 282 | 277 | |
|---|
| 283 | 278 | /* Allocate additional continuation packets? */ |
|---|
| .. | .. |
|---|
| 287 | 282 | * Type 1 IOCB. |
|---|
| 288 | 283 | */ |
|---|
| 289 | 284 | cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); |
|---|
| 290 | | - cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; |
|---|
| 291 | | - avail_dsds = 5; |
|---|
| 285 | + cur_dsd = cont_pkt->dsd; |
|---|
| 286 | + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); |
|---|
| 292 | 287 | } |
|---|
| 293 | 288 | |
|---|
| 294 | | - sle_dma = sg_dma_address(sg); |
|---|
| 295 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 296 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 297 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 289 | + append_dsd64(&cur_dsd, sg); |
|---|
| 298 | 290 | avail_dsds--; |
|---|
| 299 | 291 | } |
|---|
| 292 | +} |
|---|
| 293 | + |
|---|
| 294 | +/* |
|---|
| 295 | + * Find the first handle that is not in use, starting from |
|---|
| 296 | + * req->current_outstanding_cmd + 1. The caller must hold the lock that is |
|---|
| 297 | + * associated with @req. |
|---|
| 298 | + */ |
|---|
| 299 | +uint32_t qla2xxx_get_next_handle(struct req_que *req) |
|---|
| 300 | +{ |
|---|
| 301 | + uint32_t index, handle = req->current_outstanding_cmd; |
|---|
| 302 | + |
|---|
| 303 | + for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 304 | + handle++; |
|---|
| 305 | + if (handle == req->num_outstanding_cmds) |
|---|
| 306 | + handle = 1; |
|---|
| 307 | + if (!req->outstanding_cmds[handle]) |
|---|
| 308 | + return handle; |
|---|
| 309 | + } |
|---|
| 310 | + |
|---|
| 311 | + return 0; |
|---|
| 300 | 312 | } |
|---|
| 301 | 313 | |
|---|
| 302 | 314 | /** |
|---|
| .. | .. |
|---|
| 313 | 325 | scsi_qla_host_t *vha; |
|---|
| 314 | 326 | struct scsi_cmnd *cmd; |
|---|
| 315 | 327 | uint32_t *clr_ptr; |
|---|
| 316 | | - uint32_t index; |
|---|
| 317 | 328 | uint32_t handle; |
|---|
| 318 | 329 | cmd_entry_t *cmd_pkt; |
|---|
| 319 | 330 | uint16_t cnt; |
|---|
| .. | .. |
|---|
| 336 | 347 | |
|---|
| 337 | 348 | /* Send marker if required */ |
|---|
| 338 | 349 | if (vha->marker_needed != 0) { |
|---|
| 339 | | - if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != |
|---|
| 350 | + if (qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL) != |
|---|
| 340 | 351 | QLA_SUCCESS) { |
|---|
| 341 | 352 | return (QLA_FUNCTION_FAILED); |
|---|
| 342 | 353 | } |
|---|
| .. | .. |
|---|
| 346 | 357 | /* Acquire ring specific lock */ |
|---|
| 347 | 358 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 348 | 359 | |
|---|
| 349 | | - /* Check for room in outstanding command list. */ |
|---|
| 350 | | - handle = req->current_outstanding_cmd; |
|---|
| 351 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 352 | | - handle++; |
|---|
| 353 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 354 | | - handle = 1; |
|---|
| 355 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 356 | | - break; |
|---|
| 357 | | - } |
|---|
| 358 | | - if (index == req->num_outstanding_cmds) |
|---|
| 360 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 361 | + if (handle == 0) |
|---|
| 359 | 362 | goto queuing_error; |
|---|
| 360 | 363 | |
|---|
| 361 | 364 | /* Map the sg table so we have an accurate count of sg entries needed */ |
|---|
| .. | .. |
|---|
| 372 | 375 | /* Calculate the number of request entries needed. */ |
|---|
| 373 | 376 | req_cnt = ha->isp_ops->calc_req_entries(tot_dsds); |
|---|
| 374 | 377 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 375 | | - cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg)); |
|---|
| 378 | + cnt = rd_reg_word_relaxed(ISP_REQ_Q_OUT(ha, reg)); |
|---|
| 376 | 379 | if (req->ring_index < cnt) |
|---|
| 377 | 380 | req->cnt = cnt - req->ring_index; |
|---|
| 378 | 381 | else |
|---|
| .. | .. |
|---|
| 424 | 427 | sp->flags |= SRB_DMA_VALID; |
|---|
| 425 | 428 | |
|---|
| 426 | 429 | /* Set chip new ring index. */ |
|---|
| 427 | | - WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), req->ring_index); |
|---|
| 428 | | - RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, reg)); /* PCI Posting. */ |
|---|
| 430 | + wrt_reg_word(ISP_REQ_Q_IN(ha, reg), req->ring_index); |
|---|
| 431 | + rd_reg_word_relaxed(ISP_REQ_Q_IN(ha, reg)); /* PCI Posting. */ |
|---|
| 429 | 432 | |
|---|
| 430 | 433 | /* Manage unprocessed RIO/ZIO commands in response queue. */ |
|---|
| 431 | 434 | if (vha->flags.process_response_queue && |
|---|
| .. | .. |
|---|
| 467 | 470 | req->ring_ptr++; |
|---|
| 468 | 471 | |
|---|
| 469 | 472 | /* Set chip new ring index. */ |
|---|
| 470 | | - if (ha->mqenable || IS_QLA27XX(ha)) { |
|---|
| 471 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
|---|
| 473 | + if (ha->mqenable || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { |
|---|
| 474 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
|---|
| 472 | 475 | } else if (IS_QLA83XX(ha)) { |
|---|
| 473 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
|---|
| 474 | | - RD_REG_DWORD_RELAXED(&ha->iobase->isp24.hccr); |
|---|
| 476 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
|---|
| 477 | + rd_reg_dword_relaxed(&ha->iobase->isp24.hccr); |
|---|
| 475 | 478 | } else if (IS_QLAFX00(ha)) { |
|---|
| 476 | | - WRT_REG_DWORD(®->ispfx00.req_q_in, req->ring_index); |
|---|
| 477 | | - RD_REG_DWORD_RELAXED(®->ispfx00.req_q_in); |
|---|
| 479 | + wrt_reg_dword(®->ispfx00.req_q_in, req->ring_index); |
|---|
| 480 | + rd_reg_dword_relaxed(®->ispfx00.req_q_in); |
|---|
| 478 | 481 | QLAFX00_SET_HST_INTR(ha, ha->rqstq_intr_code); |
|---|
| 479 | 482 | } else if (IS_FWI2_CAPABLE(ha)) { |
|---|
| 480 | | - WRT_REG_DWORD(®->isp24.req_q_in, req->ring_index); |
|---|
| 481 | | - RD_REG_DWORD_RELAXED(®->isp24.req_q_in); |
|---|
| 483 | + wrt_reg_dword(®->isp24.req_q_in, req->ring_index); |
|---|
| 484 | + rd_reg_dword_relaxed(®->isp24.req_q_in); |
|---|
| 482 | 485 | } else { |
|---|
| 483 | | - WRT_REG_WORD(ISP_REQ_Q_IN(ha, ®->isp), |
|---|
| 486 | + wrt_reg_word(ISP_REQ_Q_IN(ha, ®->isp), |
|---|
| 484 | 487 | req->ring_index); |
|---|
| 485 | | - RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, ®->isp)); |
|---|
| 488 | + rd_reg_word_relaxed(ISP_REQ_Q_IN(ha, ®->isp)); |
|---|
| 486 | 489 | } |
|---|
| 487 | 490 | } |
|---|
| 488 | 491 | } |
|---|
| .. | .. |
|---|
| 490 | 493 | /** |
|---|
| 491 | 494 | * qla2x00_marker() - Send a marker IOCB to the firmware. |
|---|
| 492 | 495 | * @vha: HA context |
|---|
| 493 | | - * @req: request queue |
|---|
| 494 | | - * @rsp: response queue |
|---|
| 496 | + * @qpair: queue pair pointer |
|---|
| 495 | 497 | * @loop_id: loop ID |
|---|
| 496 | 498 | * @lun: LUN |
|---|
| 497 | 499 | * @type: marker modifier |
|---|
| .. | .. |
|---|
| 501 | 503 | * Returns non-zero if a failure occurred, else zero. |
|---|
| 502 | 504 | */ |
|---|
| 503 | 505 | static int |
|---|
| 504 | | -__qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req, |
|---|
| 505 | | - struct rsp_que *rsp, uint16_t loop_id, |
|---|
| 506 | | - uint64_t lun, uint8_t type) |
|---|
| 506 | +__qla2x00_marker(struct scsi_qla_host *vha, struct qla_qpair *qpair, |
|---|
| 507 | + uint16_t loop_id, uint64_t lun, uint8_t type) |
|---|
| 507 | 508 | { |
|---|
| 508 | 509 | mrk_entry_t *mrk; |
|---|
| 509 | 510 | struct mrk_entry_24xx *mrk24 = NULL; |
|---|
| 510 | | - |
|---|
| 511 | + struct req_que *req = qpair->req; |
|---|
| 511 | 512 | struct qla_hw_data *ha = vha->hw; |
|---|
| 512 | 513 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
|---|
| 513 | 514 | |
|---|
| 514 | | - req = ha->req_q_map[0]; |
|---|
| 515 | | - mrk = (mrk_entry_t *)qla2x00_alloc_iocbs(vha, NULL); |
|---|
| 515 | + mrk = (mrk_entry_t *)__qla2x00_alloc_iocbs(qpair, NULL); |
|---|
| 516 | 516 | if (mrk == NULL) { |
|---|
| 517 | 517 | ql_log(ql_log_warn, base_vha, 0x3026, |
|---|
| 518 | 518 | "Failed to allocate Marker IOCB.\n"); |
|---|
| .. | .. |
|---|
| 529 | 529 | int_to_scsilun(lun, (struct scsi_lun *)&mrk24->lun); |
|---|
| 530 | 530 | host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun)); |
|---|
| 531 | 531 | mrk24->vp_index = vha->vp_idx; |
|---|
| 532 | | - mrk24->handle = MAKE_HANDLE(req->id, mrk24->handle); |
|---|
| 532 | + mrk24->handle = make_handle(req->id, mrk24->handle); |
|---|
| 533 | 533 | } else { |
|---|
| 534 | 534 | SET_TARGET_ID(ha, mrk->target, loop_id); |
|---|
| 535 | 535 | mrk->lun = cpu_to_le16((uint16_t)lun); |
|---|
| .. | .. |
|---|
| 543 | 543 | } |
|---|
| 544 | 544 | |
|---|
| 545 | 545 | int |
|---|
| 546 | | -qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req, |
|---|
| 547 | | - struct rsp_que *rsp, uint16_t loop_id, uint64_t lun, |
|---|
| 548 | | - uint8_t type) |
|---|
| 546 | +qla2x00_marker(struct scsi_qla_host *vha, struct qla_qpair *qpair, |
|---|
| 547 | + uint16_t loop_id, uint64_t lun, uint8_t type) |
|---|
| 549 | 548 | { |
|---|
| 550 | 549 | int ret; |
|---|
| 551 | 550 | unsigned long flags = 0; |
|---|
| 552 | 551 | |
|---|
| 553 | | - spin_lock_irqsave(&vha->hw->hardware_lock, flags); |
|---|
| 554 | | - ret = __qla2x00_marker(vha, req, rsp, loop_id, lun, type); |
|---|
| 555 | | - spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); |
|---|
| 552 | + spin_lock_irqsave(qpair->qp_lock_ptr, flags); |
|---|
| 553 | + ret = __qla2x00_marker(vha, qpair, loop_id, lun, type); |
|---|
| 554 | + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
|---|
| 556 | 555 | |
|---|
| 557 | 556 | return (ret); |
|---|
| 558 | 557 | } |
|---|
| .. | .. |
|---|
| 567 | 566 | int qla2x00_issue_marker(scsi_qla_host_t *vha, int ha_locked) |
|---|
| 568 | 567 | { |
|---|
| 569 | 568 | if (ha_locked) { |
|---|
| 570 | | - if (__qla2x00_marker(vha, vha->req, vha->req->rsp, 0, 0, |
|---|
| 569 | + if (__qla2x00_marker(vha, vha->hw->base_qpair, 0, 0, |
|---|
| 571 | 570 | MK_SYNC_ALL) != QLA_SUCCESS) |
|---|
| 572 | 571 | return QLA_FUNCTION_FAILED; |
|---|
| 573 | 572 | } else { |
|---|
| 574 | | - if (qla2x00_marker(vha, vha->req, vha->req->rsp, 0, 0, |
|---|
| 573 | + if (qla2x00_marker(vha, vha->hw->base_qpair, 0, 0, |
|---|
| 575 | 574 | MK_SYNC_ALL) != QLA_SUCCESS) |
|---|
| 576 | 575 | return QLA_FUNCTION_FAILED; |
|---|
| 577 | 576 | } |
|---|
| .. | .. |
|---|
| 584 | 583 | qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt, |
|---|
| 585 | 584 | uint16_t tot_dsds) |
|---|
| 586 | 585 | { |
|---|
| 587 | | - uint32_t *cur_dsd = NULL; |
|---|
| 586 | + struct dsd64 *cur_dsd = NULL, *next_dsd; |
|---|
| 588 | 587 | scsi_qla_host_t *vha; |
|---|
| 589 | 588 | struct qla_hw_data *ha; |
|---|
| 590 | 589 | struct scsi_cmnd *cmd; |
|---|
| 591 | 590 | struct scatterlist *cur_seg; |
|---|
| 592 | | - uint32_t *dsd_seg; |
|---|
| 593 | | - void *next_dsd; |
|---|
| 594 | 591 | uint8_t avail_dsds; |
|---|
| 595 | 592 | uint8_t first_iocb = 1; |
|---|
| 596 | 593 | uint32_t dsd_list_len; |
|---|
| 597 | 594 | struct dsd_dma *dsd_ptr; |
|---|
| 598 | 595 | struct ct6_dsd *ctx; |
|---|
| 596 | + struct qla_qpair *qpair = sp->qpair; |
|---|
| 599 | 597 | |
|---|
| 600 | 598 | cmd = GET_CMD_SP(sp); |
|---|
| 601 | 599 | |
|---|
| 602 | 600 | /* Update entry type to indicate Command Type 3 IOCB */ |
|---|
| 603 | | - *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_6); |
|---|
| 601 | + put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type); |
|---|
| 604 | 602 | |
|---|
| 605 | 603 | /* No data transfer */ |
|---|
| 606 | 604 | if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { |
|---|
| .. | .. |
|---|
| 614 | 612 | /* Set transfer direction */ |
|---|
| 615 | 613 | if (cmd->sc_data_direction == DMA_TO_DEVICE) { |
|---|
| 616 | 614 | cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA); |
|---|
| 617 | | - vha->qla_stats.output_bytes += scsi_bufflen(cmd); |
|---|
| 618 | | - vha->qla_stats.output_requests++; |
|---|
| 615 | + qpair->counters.output_bytes += scsi_bufflen(cmd); |
|---|
| 616 | + qpair->counters.output_requests++; |
|---|
| 619 | 617 | } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { |
|---|
| 620 | 618 | cmd_pkt->control_flags = cpu_to_le16(CF_READ_DATA); |
|---|
| 621 | | - vha->qla_stats.input_bytes += scsi_bufflen(cmd); |
|---|
| 622 | | - vha->qla_stats.input_requests++; |
|---|
| 619 | + qpair->counters.input_bytes += scsi_bufflen(cmd); |
|---|
| 620 | + qpair->counters.input_requests++; |
|---|
| 623 | 621 | } |
|---|
| 624 | 622 | |
|---|
| 625 | 623 | cur_seg = scsi_sglist(cmd); |
|---|
| 626 | | - ctx = GET_CMD_CTX_SP(sp); |
|---|
| 624 | + ctx = sp->u.scmd.ct6_ctx; |
|---|
| 627 | 625 | |
|---|
| 628 | 626 | while (tot_dsds) { |
|---|
| 629 | 627 | avail_dsds = (tot_dsds > QLA_DSDS_PER_IOCB) ? |
|---|
| .. | .. |
|---|
| 642 | 640 | |
|---|
| 643 | 641 | if (first_iocb) { |
|---|
| 644 | 642 | first_iocb = 0; |
|---|
| 645 | | - dsd_seg = (uint32_t *)&cmd_pkt->fcp_data_dseg_address; |
|---|
| 646 | | - *dsd_seg++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); |
|---|
| 647 | | - *dsd_seg++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); |
|---|
| 648 | | - cmd_pkt->fcp_data_dseg_len = cpu_to_le32(dsd_list_len); |
|---|
| 643 | + put_unaligned_le64(dsd_ptr->dsd_list_dma, |
|---|
| 644 | + &cmd_pkt->fcp_dsd.address); |
|---|
| 645 | + cmd_pkt->fcp_dsd.length = cpu_to_le32(dsd_list_len); |
|---|
| 649 | 646 | } else { |
|---|
| 650 | | - *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); |
|---|
| 651 | | - *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); |
|---|
| 652 | | - *cur_dsd++ = cpu_to_le32(dsd_list_len); |
|---|
| 647 | + put_unaligned_le64(dsd_ptr->dsd_list_dma, |
|---|
| 648 | + &cur_dsd->address); |
|---|
| 649 | + cur_dsd->length = cpu_to_le32(dsd_list_len); |
|---|
| 650 | + cur_dsd++; |
|---|
| 653 | 651 | } |
|---|
| 654 | | - cur_dsd = (uint32_t *)next_dsd; |
|---|
| 652 | + cur_dsd = next_dsd; |
|---|
| 655 | 653 | while (avail_dsds) { |
|---|
| 656 | | - dma_addr_t sle_dma; |
|---|
| 657 | | - |
|---|
| 658 | | - sle_dma = sg_dma_address(cur_seg); |
|---|
| 659 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 660 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 661 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(cur_seg)); |
|---|
| 654 | + append_dsd64(&cur_dsd, cur_seg); |
|---|
| 662 | 655 | cur_seg = sg_next(cur_seg); |
|---|
| 663 | 656 | avail_dsds--; |
|---|
| 664 | 657 | } |
|---|
| 665 | 658 | } |
|---|
| 666 | 659 | |
|---|
| 667 | 660 | /* Null termination */ |
|---|
| 668 | | - *cur_dsd++ = 0; |
|---|
| 669 | | - *cur_dsd++ = 0; |
|---|
| 670 | | - *cur_dsd++ = 0; |
|---|
| 671 | | - cmd_pkt->control_flags |= CF_DATA_SEG_DESCR_ENABLE; |
|---|
| 661 | + cur_dsd->address = 0; |
|---|
| 662 | + cur_dsd->length = 0; |
|---|
| 663 | + cur_dsd++; |
|---|
| 664 | + cmd_pkt->control_flags |= cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE); |
|---|
| 672 | 665 | return 0; |
|---|
| 673 | 666 | } |
|---|
| 674 | 667 | |
|---|
| .. | .. |
|---|
| 676 | 669 | * qla24xx_calc_dsd_lists() - Determine number of DSD list required |
|---|
| 677 | 670 | * for Command Type 6. |
|---|
| 678 | 671 | * |
|---|
| 679 | | - * @dsds: number of data segment decriptors needed |
|---|
| 672 | + * @dsds: number of data segment descriptors needed |
|---|
| 680 | 673 | * |
|---|
| 681 | 674 | * Returns the number of dsd list needed to store @dsds. |
|---|
| 682 | 675 | */ |
|---|
| .. | .. |
|---|
| 706 | 699 | uint16_t tot_dsds, struct req_que *req) |
|---|
| 707 | 700 | { |
|---|
| 708 | 701 | uint16_t avail_dsds; |
|---|
| 709 | | - uint32_t *cur_dsd; |
|---|
| 702 | + struct dsd64 *cur_dsd; |
|---|
| 710 | 703 | scsi_qla_host_t *vha; |
|---|
| 711 | 704 | struct scsi_cmnd *cmd; |
|---|
| 712 | 705 | struct scatterlist *sg; |
|---|
| 713 | 706 | int i; |
|---|
| 707 | + struct qla_qpair *qpair = sp->qpair; |
|---|
| 714 | 708 | |
|---|
| 715 | 709 | cmd = GET_CMD_SP(sp); |
|---|
| 716 | 710 | |
|---|
| 717 | 711 | /* Update entry type to indicate Command Type 3 IOCB */ |
|---|
| 718 | | - *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_7); |
|---|
| 712 | + put_unaligned_le32(COMMAND_TYPE_7, &cmd_pkt->entry_type); |
|---|
| 719 | 713 | |
|---|
| 720 | 714 | /* No data transfer */ |
|---|
| 721 | 715 | if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { |
|---|
| .. | .. |
|---|
| 728 | 722 | /* Set transfer direction */ |
|---|
| 729 | 723 | if (cmd->sc_data_direction == DMA_TO_DEVICE) { |
|---|
| 730 | 724 | cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_WRITE_DATA); |
|---|
| 731 | | - vha->qla_stats.output_bytes += scsi_bufflen(cmd); |
|---|
| 732 | | - vha->qla_stats.output_requests++; |
|---|
| 725 | + qpair->counters.output_bytes += scsi_bufflen(cmd); |
|---|
| 726 | + qpair->counters.output_requests++; |
|---|
| 733 | 727 | } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { |
|---|
| 734 | 728 | cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_READ_DATA); |
|---|
| 735 | | - vha->qla_stats.input_bytes += scsi_bufflen(cmd); |
|---|
| 736 | | - vha->qla_stats.input_requests++; |
|---|
| 729 | + qpair->counters.input_bytes += scsi_bufflen(cmd); |
|---|
| 730 | + qpair->counters.input_requests++; |
|---|
| 737 | 731 | } |
|---|
| 738 | 732 | |
|---|
| 739 | 733 | /* One DSD is available in the Command Type 3 IOCB */ |
|---|
| 740 | 734 | avail_dsds = 1; |
|---|
| 741 | | - cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; |
|---|
| 735 | + cur_dsd = &cmd_pkt->dsd; |
|---|
| 742 | 736 | |
|---|
| 743 | 737 | /* Load data segments */ |
|---|
| 744 | 738 | |
|---|
| 745 | 739 | scsi_for_each_sg(cmd, sg, tot_dsds, i) { |
|---|
| 746 | | - dma_addr_t sle_dma; |
|---|
| 747 | 740 | cont_a64_entry_t *cont_pkt; |
|---|
| 748 | 741 | |
|---|
| 749 | 742 | /* Allocate additional continuation packets? */ |
|---|
| .. | .. |
|---|
| 753 | 746 | * Type 1 IOCB. |
|---|
| 754 | 747 | */ |
|---|
| 755 | 748 | cont_pkt = qla2x00_prep_cont_type1_iocb(vha, req); |
|---|
| 756 | | - cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; |
|---|
| 757 | | - avail_dsds = 5; |
|---|
| 749 | + cur_dsd = cont_pkt->dsd; |
|---|
| 750 | + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); |
|---|
| 758 | 751 | } |
|---|
| 759 | 752 | |
|---|
| 760 | | - sle_dma = sg_dma_address(sg); |
|---|
| 761 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 762 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 763 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 753 | + append_dsd64(&cur_dsd, sg); |
|---|
| 764 | 754 | avail_dsds--; |
|---|
| 765 | 755 | } |
|---|
| 766 | 756 | } |
|---|
| 767 | 757 | |
|---|
| 768 | 758 | struct fw_dif_context { |
|---|
| 769 | | - uint32_t ref_tag; |
|---|
| 770 | | - uint16_t app_tag; |
|---|
| 759 | + __le32 ref_tag; |
|---|
| 760 | + __le16 app_tag; |
|---|
| 771 | 761 | uint8_t ref_tag_mask[4]; /* Validation/Replacement Mask*/ |
|---|
| 772 | 762 | uint8_t app_tag_mask[2]; /* Validation/Replacement Mask*/ |
|---|
| 773 | 763 | }; |
|---|
| .. | .. |
|---|
| 896 | 886 | |
|---|
| 897 | 887 | int |
|---|
| 898 | 888 | qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *ha, srb_t *sp, |
|---|
| 899 | | - uint32_t *dsd, uint16_t tot_dsds, struct qla_tc_param *tc) |
|---|
| 889 | + struct dsd64 *dsd, uint16_t tot_dsds, struct qla_tc_param *tc) |
|---|
| 900 | 890 | { |
|---|
| 901 | 891 | void *next_dsd; |
|---|
| 902 | 892 | uint8_t avail_dsds = 0; |
|---|
| 903 | 893 | uint32_t dsd_list_len; |
|---|
| 904 | 894 | struct dsd_dma *dsd_ptr; |
|---|
| 905 | 895 | struct scatterlist *sg_prot; |
|---|
| 906 | | - uint32_t *cur_dsd = dsd; |
|---|
| 896 | + struct dsd64 *cur_dsd = dsd; |
|---|
| 907 | 897 | uint16_t used_dsds = tot_dsds; |
|---|
| 908 | 898 | uint32_t prot_int; /* protection interval */ |
|---|
| 909 | 899 | uint32_t partial; |
|---|
| .. | .. |
|---|
| 965 | 955 | |
|---|
| 966 | 956 | if (sp) { |
|---|
| 967 | 957 | list_add_tail(&dsd_ptr->list, |
|---|
| 968 | | - &((struct crc_context *) |
|---|
| 969 | | - sp->u.scmd.ctx)->dsd_list); |
|---|
| 958 | + &sp->u.scmd.crc_ctx->dsd_list); |
|---|
| 970 | 959 | |
|---|
| 971 | 960 | sp->flags |= SRB_CRC_CTX_DSD_VALID; |
|---|
| 972 | 961 | } else { |
|---|
| .. | .. |
|---|
| 977 | 966 | |
|---|
| 978 | 967 | |
|---|
| 979 | 968 | /* add new list to cmd iocb or last list */ |
|---|
| 980 | | - *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); |
|---|
| 981 | | - *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); |
|---|
| 982 | | - *cur_dsd++ = dsd_list_len; |
|---|
| 983 | | - cur_dsd = (uint32_t *)next_dsd; |
|---|
| 969 | + put_unaligned_le64(dsd_ptr->dsd_list_dma, |
|---|
| 970 | + &cur_dsd->address); |
|---|
| 971 | + cur_dsd->length = cpu_to_le32(dsd_list_len); |
|---|
| 972 | + cur_dsd = next_dsd; |
|---|
| 984 | 973 | } |
|---|
| 985 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 986 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 987 | | - *cur_dsd++ = cpu_to_le32(sle_dma_len); |
|---|
| 974 | + put_unaligned_le64(sle_dma, &cur_dsd->address); |
|---|
| 975 | + cur_dsd->length = cpu_to_le32(sle_dma_len); |
|---|
| 976 | + cur_dsd++; |
|---|
| 988 | 977 | avail_dsds--; |
|---|
| 989 | 978 | |
|---|
| 990 | 979 | if (partial == 0) { |
|---|
| .. | .. |
|---|
| 1003 | 992 | } |
|---|
| 1004 | 993 | } |
|---|
| 1005 | 994 | /* Null termination */ |
|---|
| 1006 | | - *cur_dsd++ = 0; |
|---|
| 1007 | | - *cur_dsd++ = 0; |
|---|
| 1008 | | - *cur_dsd++ = 0; |
|---|
| 995 | + cur_dsd->address = 0; |
|---|
| 996 | + cur_dsd->length = 0; |
|---|
| 997 | + cur_dsd++; |
|---|
| 1009 | 998 | return 0; |
|---|
| 1010 | 999 | } |
|---|
| 1011 | 1000 | |
|---|
| 1012 | 1001 | int |
|---|
| 1013 | | -qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *dsd, |
|---|
| 1014 | | - uint16_t tot_dsds, struct qla_tc_param *tc) |
|---|
| 1002 | +qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, |
|---|
| 1003 | + struct dsd64 *dsd, uint16_t tot_dsds, struct qla_tc_param *tc) |
|---|
| 1015 | 1004 | { |
|---|
| 1016 | 1005 | void *next_dsd; |
|---|
| 1017 | 1006 | uint8_t avail_dsds = 0; |
|---|
| 1018 | 1007 | uint32_t dsd_list_len; |
|---|
| 1019 | 1008 | struct dsd_dma *dsd_ptr; |
|---|
| 1020 | 1009 | struct scatterlist *sg, *sgl; |
|---|
| 1021 | | - uint32_t *cur_dsd = dsd; |
|---|
| 1010 | + struct dsd64 *cur_dsd = dsd; |
|---|
| 1022 | 1011 | int i; |
|---|
| 1023 | 1012 | uint16_t used_dsds = tot_dsds; |
|---|
| 1024 | 1013 | struct scsi_cmnd *cmd; |
|---|
| .. | .. |
|---|
| 1035 | 1024 | |
|---|
| 1036 | 1025 | |
|---|
| 1037 | 1026 | for_each_sg(sgl, sg, tot_dsds, i) { |
|---|
| 1038 | | - dma_addr_t sle_dma; |
|---|
| 1039 | | - |
|---|
| 1040 | 1027 | /* Allocate additional continuation packets? */ |
|---|
| 1041 | 1028 | if (avail_dsds == 0) { |
|---|
| 1042 | 1029 | avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? |
|---|
| .. | .. |
|---|
| 1065 | 1052 | |
|---|
| 1066 | 1053 | if (sp) { |
|---|
| 1067 | 1054 | list_add_tail(&dsd_ptr->list, |
|---|
| 1068 | | - &((struct crc_context *) |
|---|
| 1069 | | - sp->u.scmd.ctx)->dsd_list); |
|---|
| 1055 | + &sp->u.scmd.crc_ctx->dsd_list); |
|---|
| 1070 | 1056 | |
|---|
| 1071 | 1057 | sp->flags |= SRB_CRC_CTX_DSD_VALID; |
|---|
| 1072 | 1058 | } else { |
|---|
| .. | .. |
|---|
| 1076 | 1062 | } |
|---|
| 1077 | 1063 | |
|---|
| 1078 | 1064 | /* add new list to cmd iocb or last list */ |
|---|
| 1079 | | - *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); |
|---|
| 1080 | | - *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); |
|---|
| 1081 | | - *cur_dsd++ = dsd_list_len; |
|---|
| 1082 | | - cur_dsd = (uint32_t *)next_dsd; |
|---|
| 1065 | + put_unaligned_le64(dsd_ptr->dsd_list_dma, |
|---|
| 1066 | + &cur_dsd->address); |
|---|
| 1067 | + cur_dsd->length = cpu_to_le32(dsd_list_len); |
|---|
| 1068 | + cur_dsd = next_dsd; |
|---|
| 1083 | 1069 | } |
|---|
| 1084 | | - sle_dma = sg_dma_address(sg); |
|---|
| 1085 | | - |
|---|
| 1086 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 1087 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 1088 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 1070 | + append_dsd64(&cur_dsd, sg); |
|---|
| 1089 | 1071 | avail_dsds--; |
|---|
| 1090 | 1072 | |
|---|
| 1091 | 1073 | } |
|---|
| 1092 | 1074 | /* Null termination */ |
|---|
| 1093 | | - *cur_dsd++ = 0; |
|---|
| 1094 | | - *cur_dsd++ = 0; |
|---|
| 1095 | | - *cur_dsd++ = 0; |
|---|
| 1075 | + cur_dsd->address = 0; |
|---|
| 1076 | + cur_dsd->length = 0; |
|---|
| 1077 | + cur_dsd++; |
|---|
| 1096 | 1078 | return 0; |
|---|
| 1097 | 1079 | } |
|---|
| 1098 | 1080 | |
|---|
| 1099 | 1081 | int |
|---|
| 1100 | 1082 | qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, |
|---|
| 1101 | | - uint32_t *dsd, uint16_t tot_dsds, struct qla_tc_param *tc) |
|---|
| 1083 | + struct dsd64 *cur_dsd, uint16_t tot_dsds, struct qla_tgt_cmd *tc) |
|---|
| 1102 | 1084 | { |
|---|
| 1103 | | - void *next_dsd; |
|---|
| 1104 | | - uint8_t avail_dsds = 0; |
|---|
| 1105 | | - uint32_t dsd_list_len; |
|---|
| 1106 | | - struct dsd_dma *dsd_ptr; |
|---|
| 1085 | + struct dsd_dma *dsd_ptr = NULL, *dif_dsd, *nxt_dsd; |
|---|
| 1107 | 1086 | struct scatterlist *sg, *sgl; |
|---|
| 1108 | | - int i; |
|---|
| 1109 | | - struct scsi_cmnd *cmd; |
|---|
| 1110 | | - uint32_t *cur_dsd = dsd; |
|---|
| 1111 | | - uint16_t used_dsds = tot_dsds; |
|---|
| 1087 | + struct crc_context *difctx = NULL; |
|---|
| 1112 | 1088 | struct scsi_qla_host *vha; |
|---|
| 1089 | + uint dsd_list_len; |
|---|
| 1090 | + uint avail_dsds = 0; |
|---|
| 1091 | + uint used_dsds = tot_dsds; |
|---|
| 1092 | + bool dif_local_dma_alloc = false; |
|---|
| 1093 | + bool direction_to_device = false; |
|---|
| 1094 | + int i; |
|---|
| 1113 | 1095 | |
|---|
| 1114 | 1096 | if (sp) { |
|---|
| 1115 | | - cmd = GET_CMD_SP(sp); |
|---|
| 1097 | + struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
|---|
| 1098 | + |
|---|
| 1116 | 1099 | sgl = scsi_prot_sglist(cmd); |
|---|
| 1117 | 1100 | vha = sp->vha; |
|---|
| 1101 | + difctx = sp->u.scmd.crc_ctx; |
|---|
| 1102 | + direction_to_device = cmd->sc_data_direction == DMA_TO_DEVICE; |
|---|
| 1103 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe021, |
|---|
| 1104 | + "%s: scsi_cmnd: %p, crc_ctx: %p, sp: %p\n", |
|---|
| 1105 | + __func__, cmd, difctx, sp); |
|---|
| 1118 | 1106 | } else if (tc) { |
|---|
| 1119 | 1107 | vha = tc->vha; |
|---|
| 1120 | 1108 | sgl = tc->prot_sg; |
|---|
| 1109 | + difctx = tc->ctx; |
|---|
| 1110 | + direction_to_device = tc->dma_data_direction == DMA_TO_DEVICE; |
|---|
| 1121 | 1111 | } else { |
|---|
| 1122 | 1112 | BUG(); |
|---|
| 1123 | 1113 | return 1; |
|---|
| 1124 | 1114 | } |
|---|
| 1125 | 1115 | |
|---|
| 1126 | | - ql_dbg(ql_dbg_tgt, vha, 0xe021, |
|---|
| 1127 | | - "%s: enter\n", __func__); |
|---|
| 1116 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe021, |
|---|
| 1117 | + "%s: enter (write=%u)\n", __func__, direction_to_device); |
|---|
| 1128 | 1118 | |
|---|
| 1129 | | - for_each_sg(sgl, sg, tot_dsds, i) { |
|---|
| 1130 | | - dma_addr_t sle_dma; |
|---|
| 1119 | + /* if initiator doing write or target doing read */ |
|---|
| 1120 | + if (direction_to_device) { |
|---|
| 1121 | + for_each_sg(sgl, sg, tot_dsds, i) { |
|---|
| 1122 | + u64 sle_phys = sg_phys(sg); |
|---|
| 1131 | 1123 | |
|---|
| 1132 | | - /* Allocate additional continuation packets? */ |
|---|
| 1133 | | - if (avail_dsds == 0) { |
|---|
| 1134 | | - avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? |
|---|
| 1135 | | - QLA_DSDS_PER_IOCB : used_dsds; |
|---|
| 1136 | | - dsd_list_len = (avail_dsds + 1) * 12; |
|---|
| 1137 | | - used_dsds -= avail_dsds; |
|---|
| 1124 | + /* If SGE addr + len flips bits in upper 32-bits */ |
|---|
| 1125 | + if (MSD(sle_phys + sg->length) ^ MSD(sle_phys)) { |
|---|
| 1126 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe022, |
|---|
| 1127 | + "%s: page boundary crossing (phys=%llx len=%x)\n", |
|---|
| 1128 | + __func__, sle_phys, sg->length); |
|---|
| 1138 | 1129 | |
|---|
| 1139 | | - /* allocate tracking DS */ |
|---|
| 1140 | | - dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC); |
|---|
| 1141 | | - if (!dsd_ptr) |
|---|
| 1142 | | - return 1; |
|---|
| 1143 | | - |
|---|
| 1144 | | - /* allocate new list */ |
|---|
| 1145 | | - dsd_ptr->dsd_addr = next_dsd = |
|---|
| 1146 | | - dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, |
|---|
| 1147 | | - &dsd_ptr->dsd_list_dma); |
|---|
| 1148 | | - |
|---|
| 1149 | | - if (!next_dsd) { |
|---|
| 1150 | | - /* |
|---|
| 1151 | | - * Need to cleanup only this dsd_ptr, rest |
|---|
| 1152 | | - * will be done by sp_free_dma() |
|---|
| 1153 | | - */ |
|---|
| 1154 | | - kfree(dsd_ptr); |
|---|
| 1155 | | - return 1; |
|---|
| 1130 | + if (difctx) { |
|---|
| 1131 | + ha->dif_bundle_crossed_pages++; |
|---|
| 1132 | + dif_local_dma_alloc = true; |
|---|
| 1133 | + } else { |
|---|
| 1134 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, |
|---|
| 1135 | + vha, 0xe022, |
|---|
| 1136 | + "%s: difctx pointer is NULL\n", |
|---|
| 1137 | + __func__); |
|---|
| 1138 | + } |
|---|
| 1139 | + break; |
|---|
| 1156 | 1140 | } |
|---|
| 1157 | | - |
|---|
| 1158 | | - if (sp) { |
|---|
| 1159 | | - list_add_tail(&dsd_ptr->list, |
|---|
| 1160 | | - &((struct crc_context *) |
|---|
| 1161 | | - sp->u.scmd.ctx)->dsd_list); |
|---|
| 1162 | | - |
|---|
| 1163 | | - sp->flags |= SRB_CRC_CTX_DSD_VALID; |
|---|
| 1164 | | - } else { |
|---|
| 1165 | | - list_add_tail(&dsd_ptr->list, |
|---|
| 1166 | | - &(tc->ctx->dsd_list)); |
|---|
| 1167 | | - *tc->ctx_dsd_alloced = 1; |
|---|
| 1168 | | - } |
|---|
| 1169 | | - |
|---|
| 1170 | | - /* add new list to cmd iocb or last list */ |
|---|
| 1171 | | - *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); |
|---|
| 1172 | | - *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); |
|---|
| 1173 | | - *cur_dsd++ = dsd_list_len; |
|---|
| 1174 | | - cur_dsd = (uint32_t *)next_dsd; |
|---|
| 1175 | 1141 | } |
|---|
| 1176 | | - sle_dma = sg_dma_address(sg); |
|---|
| 1142 | + ha->dif_bundle_writes++; |
|---|
| 1143 | + } else { |
|---|
| 1144 | + ha->dif_bundle_reads++; |
|---|
| 1145 | + } |
|---|
| 1177 | 1146 | |
|---|
| 1178 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 1179 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 1180 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 1147 | + if (ql2xdifbundlinginternalbuffers) |
|---|
| 1148 | + dif_local_dma_alloc = direction_to_device; |
|---|
| 1181 | 1149 | |
|---|
| 1182 | | - avail_dsds--; |
|---|
| 1150 | + if (dif_local_dma_alloc) { |
|---|
| 1151 | + u32 track_difbundl_buf = 0; |
|---|
| 1152 | + u32 ldma_sg_len = 0; |
|---|
| 1153 | + u8 ldma_needed = 1; |
|---|
| 1154 | + |
|---|
| 1155 | + difctx->no_dif_bundl = 0; |
|---|
| 1156 | + difctx->dif_bundl_len = 0; |
|---|
| 1157 | + |
|---|
| 1158 | + /* Track DSD buffers */ |
|---|
| 1159 | + INIT_LIST_HEAD(&difctx->ldif_dsd_list); |
|---|
| 1160 | + /* Track local DMA buffers */ |
|---|
| 1161 | + INIT_LIST_HEAD(&difctx->ldif_dma_hndl_list); |
|---|
| 1162 | + |
|---|
| 1163 | + for_each_sg(sgl, sg, tot_dsds, i) { |
|---|
| 1164 | + u32 sglen = sg_dma_len(sg); |
|---|
| 1165 | + |
|---|
| 1166 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe023, |
|---|
| 1167 | + "%s: sg[%x] (phys=%llx sglen=%x) ldma_sg_len: %x dif_bundl_len: %x ldma_needed: %x\n", |
|---|
| 1168 | + __func__, i, (u64)sg_phys(sg), sglen, ldma_sg_len, |
|---|
| 1169 | + difctx->dif_bundl_len, ldma_needed); |
|---|
| 1170 | + |
|---|
| 1171 | + while (sglen) { |
|---|
| 1172 | + u32 xfrlen = 0; |
|---|
| 1173 | + |
|---|
| 1174 | + if (ldma_needed) { |
|---|
| 1175 | + /* |
|---|
| 1176 | + * Allocate list item to store |
|---|
| 1177 | + * the DMA buffers |
|---|
| 1178 | + */ |
|---|
| 1179 | + dsd_ptr = kzalloc(sizeof(*dsd_ptr), |
|---|
| 1180 | + GFP_ATOMIC); |
|---|
| 1181 | + if (!dsd_ptr) { |
|---|
| 1182 | + ql_dbg(ql_dbg_tgt, vha, 0xe024, |
|---|
| 1183 | + "%s: failed alloc dsd_ptr\n", |
|---|
| 1184 | + __func__); |
|---|
| 1185 | + return 1; |
|---|
| 1186 | + } |
|---|
| 1187 | + ha->dif_bundle_kallocs++; |
|---|
| 1188 | + |
|---|
| 1189 | + /* allocate dma buffer */ |
|---|
| 1190 | + dsd_ptr->dsd_addr = dma_pool_alloc |
|---|
| 1191 | + (ha->dif_bundl_pool, GFP_ATOMIC, |
|---|
| 1192 | + &dsd_ptr->dsd_list_dma); |
|---|
| 1193 | + if (!dsd_ptr->dsd_addr) { |
|---|
| 1194 | + ql_dbg(ql_dbg_tgt, vha, 0xe024, |
|---|
| 1195 | + "%s: failed alloc ->dsd_ptr\n", |
|---|
| 1196 | + __func__); |
|---|
| 1197 | + /* |
|---|
| 1198 | + * need to cleanup only this |
|---|
| 1199 | + * dsd_ptr rest will be done |
|---|
| 1200 | + * by sp_free_dma() |
|---|
| 1201 | + */ |
|---|
| 1202 | + kfree(dsd_ptr); |
|---|
| 1203 | + ha->dif_bundle_kallocs--; |
|---|
| 1204 | + return 1; |
|---|
| 1205 | + } |
|---|
| 1206 | + ha->dif_bundle_dma_allocs++; |
|---|
| 1207 | + ldma_needed = 0; |
|---|
| 1208 | + difctx->no_dif_bundl++; |
|---|
| 1209 | + list_add_tail(&dsd_ptr->list, |
|---|
| 1210 | + &difctx->ldif_dma_hndl_list); |
|---|
| 1211 | + } |
|---|
| 1212 | + |
|---|
| 1213 | + /* xfrlen is min of dma pool size and sglen */ |
|---|
| 1214 | + xfrlen = (sglen > |
|---|
| 1215 | + (DIF_BUNDLING_DMA_POOL_SIZE - ldma_sg_len)) ? |
|---|
| 1216 | + DIF_BUNDLING_DMA_POOL_SIZE - ldma_sg_len : |
|---|
| 1217 | + sglen; |
|---|
| 1218 | + |
|---|
| 1219 | + /* replace with local allocated dma buffer */ |
|---|
| 1220 | + sg_pcopy_to_buffer(sgl, sg_nents(sgl), |
|---|
| 1221 | + dsd_ptr->dsd_addr + ldma_sg_len, xfrlen, |
|---|
| 1222 | + difctx->dif_bundl_len); |
|---|
| 1223 | + difctx->dif_bundl_len += xfrlen; |
|---|
| 1224 | + sglen -= xfrlen; |
|---|
| 1225 | + ldma_sg_len += xfrlen; |
|---|
| 1226 | + if (ldma_sg_len == DIF_BUNDLING_DMA_POOL_SIZE || |
|---|
| 1227 | + sg_is_last(sg)) { |
|---|
| 1228 | + ldma_needed = 1; |
|---|
| 1229 | + ldma_sg_len = 0; |
|---|
| 1230 | + } |
|---|
| 1231 | + } |
|---|
| 1232 | + } |
|---|
| 1233 | + |
|---|
| 1234 | + track_difbundl_buf = used_dsds = difctx->no_dif_bundl; |
|---|
| 1235 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe025, |
|---|
| 1236 | + "dif_bundl_len=%x, no_dif_bundl=%x track_difbundl_buf: %x\n", |
|---|
| 1237 | + difctx->dif_bundl_len, difctx->no_dif_bundl, |
|---|
| 1238 | + track_difbundl_buf); |
|---|
| 1239 | + |
|---|
| 1240 | + if (sp) |
|---|
| 1241 | + sp->flags |= SRB_DIF_BUNDL_DMA_VALID; |
|---|
| 1242 | + else |
|---|
| 1243 | + tc->prot_flags = DIF_BUNDL_DMA_VALID; |
|---|
| 1244 | + |
|---|
| 1245 | + list_for_each_entry_safe(dif_dsd, nxt_dsd, |
|---|
| 1246 | + &difctx->ldif_dma_hndl_list, list) { |
|---|
| 1247 | + u32 sglen = (difctx->dif_bundl_len > |
|---|
| 1248 | + DIF_BUNDLING_DMA_POOL_SIZE) ? |
|---|
| 1249 | + DIF_BUNDLING_DMA_POOL_SIZE : difctx->dif_bundl_len; |
|---|
| 1250 | + |
|---|
| 1251 | + BUG_ON(track_difbundl_buf == 0); |
|---|
| 1252 | + |
|---|
| 1253 | + /* Allocate additional continuation packets? */ |
|---|
| 1254 | + if (avail_dsds == 0) { |
|---|
| 1255 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, |
|---|
| 1256 | + 0xe024, |
|---|
| 1257 | + "%s: adding continuation iocb's\n", |
|---|
| 1258 | + __func__); |
|---|
| 1259 | + avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? |
|---|
| 1260 | + QLA_DSDS_PER_IOCB : used_dsds; |
|---|
| 1261 | + dsd_list_len = (avail_dsds + 1) * 12; |
|---|
| 1262 | + used_dsds -= avail_dsds; |
|---|
| 1263 | + |
|---|
| 1264 | + /* allocate tracking DS */ |
|---|
| 1265 | + dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC); |
|---|
| 1266 | + if (!dsd_ptr) { |
|---|
| 1267 | + ql_dbg(ql_dbg_tgt, vha, 0xe026, |
|---|
| 1268 | + "%s: failed alloc dsd_ptr\n", |
|---|
| 1269 | + __func__); |
|---|
| 1270 | + return 1; |
|---|
| 1271 | + } |
|---|
| 1272 | + ha->dif_bundle_kallocs++; |
|---|
| 1273 | + |
|---|
| 1274 | + difctx->no_ldif_dsd++; |
|---|
| 1275 | + /* allocate new list */ |
|---|
| 1276 | + dsd_ptr->dsd_addr = |
|---|
| 1277 | + dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, |
|---|
| 1278 | + &dsd_ptr->dsd_list_dma); |
|---|
| 1279 | + if (!dsd_ptr->dsd_addr) { |
|---|
| 1280 | + ql_dbg(ql_dbg_tgt, vha, 0xe026, |
|---|
| 1281 | + "%s: failed alloc ->dsd_addr\n", |
|---|
| 1282 | + __func__); |
|---|
| 1283 | + /* |
|---|
| 1284 | + * need to cleanup only this dsd_ptr |
|---|
| 1285 | + * rest will be done by sp_free_dma() |
|---|
| 1286 | + */ |
|---|
| 1287 | + kfree(dsd_ptr); |
|---|
| 1288 | + ha->dif_bundle_kallocs--; |
|---|
| 1289 | + return 1; |
|---|
| 1290 | + } |
|---|
| 1291 | + ha->dif_bundle_dma_allocs++; |
|---|
| 1292 | + |
|---|
| 1293 | + if (sp) { |
|---|
| 1294 | + list_add_tail(&dsd_ptr->list, |
|---|
| 1295 | + &difctx->ldif_dsd_list); |
|---|
| 1296 | + sp->flags |= SRB_CRC_CTX_DSD_VALID; |
|---|
| 1297 | + } else { |
|---|
| 1298 | + list_add_tail(&dsd_ptr->list, |
|---|
| 1299 | + &difctx->ldif_dsd_list); |
|---|
| 1300 | + tc->ctx_dsd_alloced = 1; |
|---|
| 1301 | + } |
|---|
| 1302 | + |
|---|
| 1303 | + /* add new list to cmd iocb or last list */ |
|---|
| 1304 | + put_unaligned_le64(dsd_ptr->dsd_list_dma, |
|---|
| 1305 | + &cur_dsd->address); |
|---|
| 1306 | + cur_dsd->length = cpu_to_le32(dsd_list_len); |
|---|
| 1307 | + cur_dsd = dsd_ptr->dsd_addr; |
|---|
| 1308 | + } |
|---|
| 1309 | + put_unaligned_le64(dif_dsd->dsd_list_dma, |
|---|
| 1310 | + &cur_dsd->address); |
|---|
| 1311 | + cur_dsd->length = cpu_to_le32(sglen); |
|---|
| 1312 | + cur_dsd++; |
|---|
| 1313 | + avail_dsds--; |
|---|
| 1314 | + difctx->dif_bundl_len -= sglen; |
|---|
| 1315 | + track_difbundl_buf--; |
|---|
| 1316 | + } |
|---|
| 1317 | + |
|---|
| 1318 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe026, |
|---|
| 1319 | + "%s: no_ldif_dsd:%x, no_dif_bundl:%x\n", __func__, |
|---|
| 1320 | + difctx->no_ldif_dsd, difctx->no_dif_bundl); |
|---|
| 1321 | + } else { |
|---|
| 1322 | + for_each_sg(sgl, sg, tot_dsds, i) { |
|---|
| 1323 | + /* Allocate additional continuation packets? */ |
|---|
| 1324 | + if (avail_dsds == 0) { |
|---|
| 1325 | + avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? |
|---|
| 1326 | + QLA_DSDS_PER_IOCB : used_dsds; |
|---|
| 1327 | + dsd_list_len = (avail_dsds + 1) * 12; |
|---|
| 1328 | + used_dsds -= avail_dsds; |
|---|
| 1329 | + |
|---|
| 1330 | + /* allocate tracking DS */ |
|---|
| 1331 | + dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC); |
|---|
| 1332 | + if (!dsd_ptr) { |
|---|
| 1333 | + ql_dbg(ql_dbg_tgt + ql_dbg_verbose, |
|---|
| 1334 | + vha, 0xe027, |
|---|
| 1335 | + "%s: failed alloc dsd_dma...\n", |
|---|
| 1336 | + __func__); |
|---|
| 1337 | + return 1; |
|---|
| 1338 | + } |
|---|
| 1339 | + |
|---|
| 1340 | + /* allocate new list */ |
|---|
| 1341 | + dsd_ptr->dsd_addr = |
|---|
| 1342 | + dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, |
|---|
| 1343 | + &dsd_ptr->dsd_list_dma); |
|---|
| 1344 | + if (!dsd_ptr->dsd_addr) { |
|---|
| 1345 | + /* need to cleanup only this dsd_ptr */ |
|---|
| 1346 | + /* rest will be done by sp_free_dma() */ |
|---|
| 1347 | + kfree(dsd_ptr); |
|---|
| 1348 | + return 1; |
|---|
| 1349 | + } |
|---|
| 1350 | + |
|---|
| 1351 | + if (sp) { |
|---|
| 1352 | + list_add_tail(&dsd_ptr->list, |
|---|
| 1353 | + &difctx->dsd_list); |
|---|
| 1354 | + sp->flags |= SRB_CRC_CTX_DSD_VALID; |
|---|
| 1355 | + } else { |
|---|
| 1356 | + list_add_tail(&dsd_ptr->list, |
|---|
| 1357 | + &difctx->dsd_list); |
|---|
| 1358 | + tc->ctx_dsd_alloced = 1; |
|---|
| 1359 | + } |
|---|
| 1360 | + |
|---|
| 1361 | + /* add new list to cmd iocb or last list */ |
|---|
| 1362 | + put_unaligned_le64(dsd_ptr->dsd_list_dma, |
|---|
| 1363 | + &cur_dsd->address); |
|---|
| 1364 | + cur_dsd->length = cpu_to_le32(dsd_list_len); |
|---|
| 1365 | + cur_dsd = dsd_ptr->dsd_addr; |
|---|
| 1366 | + } |
|---|
| 1367 | + append_dsd64(&cur_dsd, sg); |
|---|
| 1368 | + avail_dsds--; |
|---|
| 1369 | + } |
|---|
| 1183 | 1370 | } |
|---|
| 1184 | 1371 | /* Null termination */ |
|---|
| 1185 | | - *cur_dsd++ = 0; |
|---|
| 1186 | | - *cur_dsd++ = 0; |
|---|
| 1187 | | - *cur_dsd++ = 0; |
|---|
| 1372 | + cur_dsd->address = 0; |
|---|
| 1373 | + cur_dsd->length = 0; |
|---|
| 1374 | + cur_dsd++; |
|---|
| 1188 | 1375 | return 0; |
|---|
| 1189 | 1376 | } |
|---|
| 1190 | 1377 | |
|---|
| .. | .. |
|---|
| 1195 | 1382 | * @sp: SRB command to process |
|---|
| 1196 | 1383 | * @cmd_pkt: Command type 3 IOCB |
|---|
| 1197 | 1384 | * @tot_dsds: Total number of segments to transfer |
|---|
| 1198 | | - * @tot_prot_dsds: |
|---|
| 1199 | | - * @fw_prot_opts: |
|---|
| 1385 | + * @tot_prot_dsds: Total number of segments with protection information |
|---|
| 1386 | + * @fw_prot_opts: Protection options to be passed to firmware |
|---|
| 1200 | 1387 | */ |
|---|
| 1201 | | -inline int |
|---|
| 1388 | +static inline int |
|---|
| 1202 | 1389 | qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, |
|---|
| 1203 | 1390 | uint16_t tot_dsds, uint16_t tot_prot_dsds, uint16_t fw_prot_opts) |
|---|
| 1204 | 1391 | { |
|---|
| 1205 | | - uint32_t *cur_dsd, *fcp_dl; |
|---|
| 1392 | + struct dsd64 *cur_dsd; |
|---|
| 1393 | + __be32 *fcp_dl; |
|---|
| 1206 | 1394 | scsi_qla_host_t *vha; |
|---|
| 1207 | 1395 | struct scsi_cmnd *cmd; |
|---|
| 1208 | 1396 | uint32_t total_bytes = 0; |
|---|
| .. | .. |
|---|
| 1220 | 1408 | cmd = GET_CMD_SP(sp); |
|---|
| 1221 | 1409 | |
|---|
| 1222 | 1410 | /* Update entry type to indicate Command Type CRC_2 IOCB */ |
|---|
| 1223 | | - *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_CRC_2); |
|---|
| 1411 | + put_unaligned_le32(COMMAND_TYPE_CRC_2, &cmd_pkt->entry_type); |
|---|
| 1224 | 1412 | |
|---|
| 1225 | 1413 | vha = sp->vha; |
|---|
| 1226 | 1414 | ha = vha->hw; |
|---|
| .. | .. |
|---|
| 1250 | 1438 | bundling = 0; |
|---|
| 1251 | 1439 | |
|---|
| 1252 | 1440 | /* Allocate CRC context from global pool */ |
|---|
| 1253 | | - crc_ctx_pkt = sp->u.scmd.ctx = |
|---|
| 1441 | + crc_ctx_pkt = sp->u.scmd.crc_ctx = |
|---|
| 1254 | 1442 | dma_pool_zalloc(ha->dl_dma_pool, GFP_ATOMIC, &crc_ctx_dma); |
|---|
| 1255 | 1443 | |
|---|
| 1256 | 1444 | if (!crc_ctx_pkt) |
|---|
| .. | .. |
|---|
| 1268 | 1456 | qla24xx_set_t10dif_tags(sp, (struct fw_dif_context *) |
|---|
| 1269 | 1457 | &crc_ctx_pkt->ref_tag, tot_prot_dsds); |
|---|
| 1270 | 1458 | |
|---|
| 1271 | | - cmd_pkt->crc_context_address[0] = cpu_to_le32(LSD(crc_ctx_dma)); |
|---|
| 1272 | | - cmd_pkt->crc_context_address[1] = cpu_to_le32(MSD(crc_ctx_dma)); |
|---|
| 1273 | | - cmd_pkt->crc_context_len = CRC_CONTEXT_LEN_FW; |
|---|
| 1459 | + put_unaligned_le64(crc_ctx_dma, &cmd_pkt->crc_context_address); |
|---|
| 1460 | + cmd_pkt->crc_context_len = cpu_to_le16(CRC_CONTEXT_LEN_FW); |
|---|
| 1274 | 1461 | |
|---|
| 1275 | 1462 | /* Determine SCSI command length -- align to 4 byte boundary */ |
|---|
| 1276 | 1463 | if (cmd->cmd_len > 16) { |
|---|
| .. | .. |
|---|
| 1296 | 1483 | int_to_scsilun(cmd->device->lun, &fcp_cmnd->lun); |
|---|
| 1297 | 1484 | memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); |
|---|
| 1298 | 1485 | cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len); |
|---|
| 1299 | | - cmd_pkt->fcp_cmnd_dseg_address[0] = cpu_to_le32( |
|---|
| 1300 | | - LSD(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF)); |
|---|
| 1301 | | - cmd_pkt->fcp_cmnd_dseg_address[1] = cpu_to_le32( |
|---|
| 1302 | | - MSD(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF)); |
|---|
| 1486 | + put_unaligned_le64(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF, |
|---|
| 1487 | + &cmd_pkt->fcp_cmnd_dseg_address); |
|---|
| 1303 | 1488 | fcp_cmnd->task_management = 0; |
|---|
| 1304 | 1489 | fcp_cmnd->task_attribute = TSK_SIMPLE; |
|---|
| 1305 | 1490 | |
|---|
| .. | .. |
|---|
| 1313 | 1498 | switch (scsi_get_prot_op(GET_CMD_SP(sp))) { |
|---|
| 1314 | 1499 | case SCSI_PROT_READ_INSERT: |
|---|
| 1315 | 1500 | case SCSI_PROT_WRITE_STRIP: |
|---|
| 1316 | | - total_bytes = data_bytes; |
|---|
| 1317 | | - data_bytes += dif_bytes; |
|---|
| 1318 | | - break; |
|---|
| 1501 | + total_bytes = data_bytes; |
|---|
| 1502 | + data_bytes += dif_bytes; |
|---|
| 1503 | + break; |
|---|
| 1319 | 1504 | |
|---|
| 1320 | 1505 | case SCSI_PROT_READ_STRIP: |
|---|
| 1321 | 1506 | case SCSI_PROT_WRITE_INSERT: |
|---|
| 1322 | 1507 | case SCSI_PROT_READ_PASS: |
|---|
| 1323 | 1508 | case SCSI_PROT_WRITE_PASS: |
|---|
| 1324 | | - total_bytes = data_bytes + dif_bytes; |
|---|
| 1325 | | - break; |
|---|
| 1509 | + total_bytes = data_bytes + dif_bytes; |
|---|
| 1510 | + break; |
|---|
| 1326 | 1511 | default: |
|---|
| 1327 | | - BUG(); |
|---|
| 1512 | + BUG(); |
|---|
| 1328 | 1513 | } |
|---|
| 1329 | 1514 | |
|---|
| 1330 | 1515 | if (!qla2x00_hba_err_chk_enabled(sp)) |
|---|
| .. | .. |
|---|
| 1341 | 1526 | } |
|---|
| 1342 | 1527 | |
|---|
| 1343 | 1528 | if (!bundling) { |
|---|
| 1344 | | - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.nobundling.data_address; |
|---|
| 1529 | + cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd[0]; |
|---|
| 1345 | 1530 | } else { |
|---|
| 1346 | 1531 | /* |
|---|
| 1347 | 1532 | * Configure Bundling if we need to fetch interlaving |
|---|
| .. | .. |
|---|
| 1351 | 1536 | crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes); |
|---|
| 1352 | 1537 | crc_ctx_pkt->u.bundling.dseg_count = cpu_to_le16(tot_dsds - |
|---|
| 1353 | 1538 | tot_prot_dsds); |
|---|
| 1354 | | - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.data_address; |
|---|
| 1539 | + cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd[0]; |
|---|
| 1355 | 1540 | } |
|---|
| 1356 | 1541 | |
|---|
| 1357 | 1542 | /* Finish the common fields of CRC pkt */ |
|---|
| .. | .. |
|---|
| 1361 | 1546 | crc_ctx_pkt->guard_seed = cpu_to_le16(0); |
|---|
| 1362 | 1547 | /* Fibre channel byte count */ |
|---|
| 1363 | 1548 | cmd_pkt->byte_count = cpu_to_le32(total_bytes); |
|---|
| 1364 | | - fcp_dl = (uint32_t *)(crc_ctx_pkt->fcp_cmnd.cdb + 16 + |
|---|
| 1549 | + fcp_dl = (__be32 *)(crc_ctx_pkt->fcp_cmnd.cdb + 16 + |
|---|
| 1365 | 1550 | additional_fcpcdb_len); |
|---|
| 1366 | 1551 | *fcp_dl = htonl(total_bytes); |
|---|
| 1367 | 1552 | |
|---|
| .. | .. |
|---|
| 1384 | 1569 | if (bundling && tot_prot_dsds) { |
|---|
| 1385 | 1570 | /* Walks dif segments */ |
|---|
| 1386 | 1571 | cmd_pkt->control_flags |= cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); |
|---|
| 1387 | | - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; |
|---|
| 1572 | + cur_dsd = &crc_ctx_pkt->u.bundling.dif_dsd; |
|---|
| 1388 | 1573 | if (qla24xx_walk_and_build_prot_sglist(ha, sp, cur_dsd, |
|---|
| 1389 | 1574 | tot_prot_dsds, NULL)) |
|---|
| 1390 | 1575 | goto crc_queuing_error; |
|---|
| .. | .. |
|---|
| 1409 | 1594 | int nseg; |
|---|
| 1410 | 1595 | unsigned long flags; |
|---|
| 1411 | 1596 | uint32_t *clr_ptr; |
|---|
| 1412 | | - uint32_t index; |
|---|
| 1413 | 1597 | uint32_t handle; |
|---|
| 1414 | 1598 | struct cmd_type_7 *cmd_pkt; |
|---|
| 1415 | 1599 | uint16_t cnt; |
|---|
| 1416 | 1600 | uint16_t req_cnt; |
|---|
| 1417 | 1601 | uint16_t tot_dsds; |
|---|
| 1418 | 1602 | struct req_que *req = NULL; |
|---|
| 1419 | | - struct rsp_que *rsp = NULL; |
|---|
| 1420 | 1603 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
|---|
| 1421 | 1604 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 1422 | 1605 | struct qla_hw_data *ha = vha->hw; |
|---|
| 1423 | 1606 | |
|---|
| 1424 | 1607 | /* Setup device pointers. */ |
|---|
| 1425 | 1608 | req = vha->req; |
|---|
| 1426 | | - rsp = req->rsp; |
|---|
| 1427 | 1609 | |
|---|
| 1428 | 1610 | /* So we know we haven't pci_map'ed anything yet */ |
|---|
| 1429 | 1611 | tot_dsds = 0; |
|---|
| 1430 | 1612 | |
|---|
| 1431 | 1613 | /* Send marker if required */ |
|---|
| 1432 | 1614 | if (vha->marker_needed != 0) { |
|---|
| 1433 | | - if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != |
|---|
| 1615 | + if (qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL) != |
|---|
| 1434 | 1616 | QLA_SUCCESS) |
|---|
| 1435 | 1617 | return QLA_FUNCTION_FAILED; |
|---|
| 1436 | 1618 | vha->marker_needed = 0; |
|---|
| .. | .. |
|---|
| 1439 | 1621 | /* Acquire ring specific lock */ |
|---|
| 1440 | 1622 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 1441 | 1623 | |
|---|
| 1442 | | - /* Check for room in outstanding command list. */ |
|---|
| 1443 | | - handle = req->current_outstanding_cmd; |
|---|
| 1444 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 1445 | | - handle++; |
|---|
| 1446 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 1447 | | - handle = 1; |
|---|
| 1448 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 1449 | | - break; |
|---|
| 1450 | | - } |
|---|
| 1451 | | - if (index == req->num_outstanding_cmds) |
|---|
| 1624 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 1625 | + if (handle == 0) |
|---|
| 1452 | 1626 | goto queuing_error; |
|---|
| 1453 | 1627 | |
|---|
| 1454 | 1628 | /* Map the sg table so we have an accurate count of sg entries needed */ |
|---|
| .. | .. |
|---|
| 1462 | 1636 | |
|---|
| 1463 | 1637 | tot_dsds = nseg; |
|---|
| 1464 | 1638 | req_cnt = qla24xx_calc_iocbs(vha, tot_dsds); |
|---|
| 1639 | + |
|---|
| 1640 | + sp->iores.res_type = RESOURCE_INI; |
|---|
| 1641 | + sp->iores.iocb_cnt = req_cnt; |
|---|
| 1642 | + if (qla_get_iocbs(sp->qpair, &sp->iores)) |
|---|
| 1643 | + goto queuing_error; |
|---|
| 1644 | + |
|---|
| 1465 | 1645 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 1466 | 1646 | cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr : |
|---|
| 1467 | | - RD_REG_DWORD_RELAXED(req->req_q_out); |
|---|
| 1647 | + rd_reg_dword_relaxed(req->req_q_out); |
|---|
| 1468 | 1648 | if (req->ring_index < cnt) |
|---|
| 1469 | 1649 | req->cnt = cnt - req->ring_index; |
|---|
| 1470 | 1650 | else |
|---|
| .. | .. |
|---|
| 1482 | 1662 | req->cnt -= req_cnt; |
|---|
| 1483 | 1663 | |
|---|
| 1484 | 1664 | cmd_pkt = (struct cmd_type_7 *)req->ring_ptr; |
|---|
| 1485 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 1665 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 1486 | 1666 | |
|---|
| 1487 | 1667 | /* Zero out remaining portion of packet. */ |
|---|
| 1488 | 1668 | /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ |
|---|
| .. | .. |
|---|
| 1525 | 1705 | sp->flags |= SRB_DMA_VALID; |
|---|
| 1526 | 1706 | |
|---|
| 1527 | 1707 | /* Set chip new ring index. */ |
|---|
| 1528 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
|---|
| 1708 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
|---|
| 1529 | 1709 | |
|---|
| 1530 | 1710 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 1531 | 1711 | return QLA_SUCCESS; |
|---|
| .. | .. |
|---|
| 1534 | 1714 | if (tot_dsds) |
|---|
| 1535 | 1715 | scsi_dma_unmap(cmd); |
|---|
| 1536 | 1716 | |
|---|
| 1717 | + qla_put_iocbs(sp->qpair, &sp->iores); |
|---|
| 1537 | 1718 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 1538 | 1719 | |
|---|
| 1539 | 1720 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 1551 | 1732 | int nseg; |
|---|
| 1552 | 1733 | unsigned long flags; |
|---|
| 1553 | 1734 | uint32_t *clr_ptr; |
|---|
| 1554 | | - uint32_t index; |
|---|
| 1555 | 1735 | uint32_t handle; |
|---|
| 1556 | 1736 | uint16_t cnt; |
|---|
| 1557 | 1737 | uint16_t req_cnt = 0; |
|---|
| .. | .. |
|---|
| 1583 | 1763 | |
|---|
| 1584 | 1764 | /* Send marker if required */ |
|---|
| 1585 | 1765 | if (vha->marker_needed != 0) { |
|---|
| 1586 | | - if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != |
|---|
| 1766 | + if (qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL) != |
|---|
| 1587 | 1767 | QLA_SUCCESS) |
|---|
| 1588 | 1768 | return QLA_FUNCTION_FAILED; |
|---|
| 1589 | 1769 | vha->marker_needed = 0; |
|---|
| .. | .. |
|---|
| 1592 | 1772 | /* Acquire ring specific lock */ |
|---|
| 1593 | 1773 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 1594 | 1774 | |
|---|
| 1595 | | - /* Check for room in outstanding command list. */ |
|---|
| 1596 | | - handle = req->current_outstanding_cmd; |
|---|
| 1597 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 1598 | | - handle++; |
|---|
| 1599 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 1600 | | - handle = 1; |
|---|
| 1601 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 1602 | | - break; |
|---|
| 1603 | | - } |
|---|
| 1604 | | - |
|---|
| 1605 | | - if (index == req->num_outstanding_cmds) |
|---|
| 1775 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 1776 | + if (handle == 0) |
|---|
| 1606 | 1777 | goto queuing_error; |
|---|
| 1607 | 1778 | |
|---|
| 1608 | 1779 | /* Compute number of required data segments */ |
|---|
| .. | .. |
|---|
| 1657 | 1828 | /* Total Data and protection sg segment(s) */ |
|---|
| 1658 | 1829 | tot_prot_dsds = nseg; |
|---|
| 1659 | 1830 | tot_dsds += nseg; |
|---|
| 1831 | + |
|---|
| 1832 | + sp->iores.res_type = RESOURCE_INI; |
|---|
| 1833 | + sp->iores.iocb_cnt = qla24xx_calc_iocbs(vha, tot_dsds); |
|---|
| 1834 | + if (qla_get_iocbs(sp->qpair, &sp->iores)) |
|---|
| 1835 | + goto queuing_error; |
|---|
| 1836 | + |
|---|
| 1660 | 1837 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 1661 | 1838 | cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr : |
|---|
| 1662 | | - RD_REG_DWORD_RELAXED(req->req_q_out); |
|---|
| 1839 | + rd_reg_dword_relaxed(req->req_q_out); |
|---|
| 1663 | 1840 | if (req->ring_index < cnt) |
|---|
| 1664 | 1841 | req->cnt = cnt - req->ring_index; |
|---|
| 1665 | 1842 | else |
|---|
| .. | .. |
|---|
| 1680 | 1857 | |
|---|
| 1681 | 1858 | /* Fill-in common area */ |
|---|
| 1682 | 1859 | cmd_pkt = (struct cmd_type_crc_2 *)req->ring_ptr; |
|---|
| 1683 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 1860 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 1684 | 1861 | |
|---|
| 1685 | 1862 | clr_ptr = (uint32_t *)cmd_pkt + 2; |
|---|
| 1686 | 1863 | memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); |
|---|
| .. | .. |
|---|
| 1718 | 1895 | req->ring_ptr++; |
|---|
| 1719 | 1896 | |
|---|
| 1720 | 1897 | /* Set chip new ring index. */ |
|---|
| 1721 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
|---|
| 1898 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
|---|
| 1722 | 1899 | |
|---|
| 1723 | 1900 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 1724 | 1901 | |
|---|
| .. | .. |
|---|
| 1731 | 1908 | } |
|---|
| 1732 | 1909 | /* Cleanup will be performed by the caller (queuecommand) */ |
|---|
| 1733 | 1910 | |
|---|
| 1911 | + qla_put_iocbs(sp->qpair, &sp->iores); |
|---|
| 1734 | 1912 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 1735 | 1913 | return QLA_FUNCTION_FAILED; |
|---|
| 1736 | 1914 | } |
|---|
| .. | .. |
|---|
| 1747 | 1925 | int nseg; |
|---|
| 1748 | 1926 | unsigned long flags; |
|---|
| 1749 | 1927 | uint32_t *clr_ptr; |
|---|
| 1750 | | - uint32_t index; |
|---|
| 1751 | 1928 | uint32_t handle; |
|---|
| 1752 | 1929 | struct cmd_type_7 *cmd_pkt; |
|---|
| 1753 | 1930 | uint16_t cnt; |
|---|
| 1754 | 1931 | uint16_t req_cnt; |
|---|
| 1755 | 1932 | uint16_t tot_dsds; |
|---|
| 1756 | 1933 | struct req_que *req = NULL; |
|---|
| 1757 | | - struct rsp_que *rsp = NULL; |
|---|
| 1758 | 1934 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
|---|
| 1759 | 1935 | struct scsi_qla_host *vha = sp->fcport->vha; |
|---|
| 1760 | 1936 | struct qla_hw_data *ha = vha->hw; |
|---|
| .. | .. |
|---|
| 1764 | 1940 | spin_lock_irqsave(&qpair->qp_lock, flags); |
|---|
| 1765 | 1941 | |
|---|
| 1766 | 1942 | /* Setup qpair pointers */ |
|---|
| 1767 | | - rsp = qpair->rsp; |
|---|
| 1768 | 1943 | req = qpair->req; |
|---|
| 1769 | 1944 | |
|---|
| 1770 | 1945 | /* So we know we haven't pci_map'ed anything yet */ |
|---|
| .. | .. |
|---|
| 1772 | 1947 | |
|---|
| 1773 | 1948 | /* Send marker if required */ |
|---|
| 1774 | 1949 | if (vha->marker_needed != 0) { |
|---|
| 1775 | | - if (__qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != |
|---|
| 1950 | + if (__qla2x00_marker(vha, qpair, 0, 0, MK_SYNC_ALL) != |
|---|
| 1776 | 1951 | QLA_SUCCESS) { |
|---|
| 1777 | 1952 | spin_unlock_irqrestore(&qpair->qp_lock, flags); |
|---|
| 1778 | 1953 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 1780 | 1955 | vha->marker_needed = 0; |
|---|
| 1781 | 1956 | } |
|---|
| 1782 | 1957 | |
|---|
| 1783 | | - /* Check for room in outstanding command list. */ |
|---|
| 1784 | | - handle = req->current_outstanding_cmd; |
|---|
| 1785 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 1786 | | - handle++; |
|---|
| 1787 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 1788 | | - handle = 1; |
|---|
| 1789 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 1790 | | - break; |
|---|
| 1791 | | - } |
|---|
| 1792 | | - if (index == req->num_outstanding_cmds) |
|---|
| 1958 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 1959 | + if (handle == 0) |
|---|
| 1793 | 1960 | goto queuing_error; |
|---|
| 1794 | 1961 | |
|---|
| 1795 | 1962 | /* Map the sg table so we have an accurate count of sg entries needed */ |
|---|
| .. | .. |
|---|
| 1803 | 1970 | |
|---|
| 1804 | 1971 | tot_dsds = nseg; |
|---|
| 1805 | 1972 | req_cnt = qla24xx_calc_iocbs(vha, tot_dsds); |
|---|
| 1973 | + |
|---|
| 1974 | + sp->iores.res_type = RESOURCE_INI; |
|---|
| 1975 | + sp->iores.iocb_cnt = req_cnt; |
|---|
| 1976 | + if (qla_get_iocbs(sp->qpair, &sp->iores)) |
|---|
| 1977 | + goto queuing_error; |
|---|
| 1978 | + |
|---|
| 1806 | 1979 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 1807 | 1980 | cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr : |
|---|
| 1808 | | - RD_REG_DWORD_RELAXED(req->req_q_out); |
|---|
| 1981 | + rd_reg_dword_relaxed(req->req_q_out); |
|---|
| 1809 | 1982 | if (req->ring_index < cnt) |
|---|
| 1810 | 1983 | req->cnt = cnt - req->ring_index; |
|---|
| 1811 | 1984 | else |
|---|
| .. | .. |
|---|
| 1823 | 1996 | req->cnt -= req_cnt; |
|---|
| 1824 | 1997 | |
|---|
| 1825 | 1998 | cmd_pkt = (struct cmd_type_7 *)req->ring_ptr; |
|---|
| 1826 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 1999 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 1827 | 2000 | |
|---|
| 1828 | 2001 | /* Zero out remaining portion of packet. */ |
|---|
| 1829 | 2002 | /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ |
|---|
| .. | .. |
|---|
| 1866 | 2039 | sp->flags |= SRB_DMA_VALID; |
|---|
| 1867 | 2040 | |
|---|
| 1868 | 2041 | /* Set chip new ring index. */ |
|---|
| 1869 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
|---|
| 2042 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
|---|
| 1870 | 2043 | |
|---|
| 1871 | 2044 | spin_unlock_irqrestore(&qpair->qp_lock, flags); |
|---|
| 1872 | 2045 | return QLA_SUCCESS; |
|---|
| .. | .. |
|---|
| 1875 | 2048 | if (tot_dsds) |
|---|
| 1876 | 2049 | scsi_dma_unmap(cmd); |
|---|
| 1877 | 2050 | |
|---|
| 2051 | + qla_put_iocbs(sp->qpair, &sp->iores); |
|---|
| 1878 | 2052 | spin_unlock_irqrestore(&qpair->qp_lock, flags); |
|---|
| 1879 | 2053 | |
|---|
| 1880 | 2054 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 1893 | 2067 | int nseg; |
|---|
| 1894 | 2068 | unsigned long flags; |
|---|
| 1895 | 2069 | uint32_t *clr_ptr; |
|---|
| 1896 | | - uint32_t index; |
|---|
| 1897 | 2070 | uint32_t handle; |
|---|
| 1898 | 2071 | uint16_t cnt; |
|---|
| 1899 | 2072 | uint16_t req_cnt = 0; |
|---|
| .. | .. |
|---|
| 1940 | 2113 | |
|---|
| 1941 | 2114 | /* Send marker if required */ |
|---|
| 1942 | 2115 | if (vha->marker_needed != 0) { |
|---|
| 1943 | | - if (__qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != |
|---|
| 2116 | + if (__qla2x00_marker(vha, qpair, 0, 0, MK_SYNC_ALL) != |
|---|
| 1944 | 2117 | QLA_SUCCESS) { |
|---|
| 1945 | 2118 | spin_unlock_irqrestore(&qpair->qp_lock, flags); |
|---|
| 1946 | 2119 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 1948 | 2121 | vha->marker_needed = 0; |
|---|
| 1949 | 2122 | } |
|---|
| 1950 | 2123 | |
|---|
| 1951 | | - /* Check for room in outstanding command list. */ |
|---|
| 1952 | | - handle = req->current_outstanding_cmd; |
|---|
| 1953 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 1954 | | - handle++; |
|---|
| 1955 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 1956 | | - handle = 1; |
|---|
| 1957 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 1958 | | - break; |
|---|
| 1959 | | - } |
|---|
| 1960 | | - |
|---|
| 1961 | | - if (index == req->num_outstanding_cmds) |
|---|
| 2124 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 2125 | + if (handle == 0) |
|---|
| 1962 | 2126 | goto queuing_error; |
|---|
| 1963 | 2127 | |
|---|
| 1964 | 2128 | /* Compute number of required data segments */ |
|---|
| .. | .. |
|---|
| 2013 | 2177 | /* Total Data and protection sg segment(s) */ |
|---|
| 2014 | 2178 | tot_prot_dsds = nseg; |
|---|
| 2015 | 2179 | tot_dsds += nseg; |
|---|
| 2180 | + |
|---|
| 2181 | + sp->iores.res_type = RESOURCE_INI; |
|---|
| 2182 | + sp->iores.iocb_cnt = qla24xx_calc_iocbs(vha, tot_dsds); |
|---|
| 2183 | + if (qla_get_iocbs(sp->qpair, &sp->iores)) |
|---|
| 2184 | + goto queuing_error; |
|---|
| 2185 | + |
|---|
| 2016 | 2186 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 2017 | 2187 | cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr : |
|---|
| 2018 | | - RD_REG_DWORD_RELAXED(req->req_q_out); |
|---|
| 2188 | + rd_reg_dword_relaxed(req->req_q_out); |
|---|
| 2019 | 2189 | if (req->ring_index < cnt) |
|---|
| 2020 | 2190 | req->cnt = cnt - req->ring_index; |
|---|
| 2021 | 2191 | else |
|---|
| .. | .. |
|---|
| 2036 | 2206 | |
|---|
| 2037 | 2207 | /* Fill-in common area */ |
|---|
| 2038 | 2208 | cmd_pkt = (struct cmd_type_crc_2 *)req->ring_ptr; |
|---|
| 2039 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 2209 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 2040 | 2210 | |
|---|
| 2041 | 2211 | clr_ptr = (uint32_t *)cmd_pkt + 2; |
|---|
| 2042 | 2212 | memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); |
|---|
| .. | .. |
|---|
| 2072 | 2242 | req->ring_ptr++; |
|---|
| 2073 | 2243 | |
|---|
| 2074 | 2244 | /* Set chip new ring index. */ |
|---|
| 2075 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
|---|
| 2245 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
|---|
| 2076 | 2246 | |
|---|
| 2077 | 2247 | /* Manage unprocessed RIO/ZIO commands in response queue. */ |
|---|
| 2078 | 2248 | if (vha->flags.process_response_queue && |
|---|
| .. | .. |
|---|
| 2090 | 2260 | } |
|---|
| 2091 | 2261 | /* Cleanup will be performed by the caller (queuecommand) */ |
|---|
| 2092 | 2262 | |
|---|
| 2263 | + qla_put_iocbs(sp->qpair, &sp->iores); |
|---|
| 2093 | 2264 | spin_unlock_irqrestore(&qpair->qp_lock, flags); |
|---|
| 2094 | 2265 | return QLA_FUNCTION_FAILED; |
|---|
| 2095 | 2266 | } |
|---|
| .. | .. |
|---|
| 2105 | 2276 | struct qla_hw_data *ha = vha->hw; |
|---|
| 2106 | 2277 | struct req_que *req = qpair->req; |
|---|
| 2107 | 2278 | device_reg_t *reg = ISP_QUE_REG(ha, req->id); |
|---|
| 2108 | | - uint32_t index, handle; |
|---|
| 2279 | + uint32_t handle; |
|---|
| 2109 | 2280 | request_t *pkt; |
|---|
| 2110 | 2281 | uint16_t cnt, req_cnt; |
|---|
| 2111 | 2282 | |
|---|
| .. | .. |
|---|
| 2122 | 2293 | if (req->cnt < req_cnt + 2) { |
|---|
| 2123 | 2294 | if (qpair->use_shadow_reg) |
|---|
| 2124 | 2295 | cnt = *req->out_ptr; |
|---|
| 2125 | | - else if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
|---|
| 2126 | | - cnt = RD_REG_DWORD(®->isp25mq.req_q_out); |
|---|
| 2296 | + else if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
|---|
| 2297 | + IS_QLA28XX(ha)) |
|---|
| 2298 | + cnt = rd_reg_dword(®->isp25mq.req_q_out); |
|---|
| 2127 | 2299 | else if (IS_P3P_TYPE(ha)) |
|---|
| 2128 | | - cnt = RD_REG_DWORD(®->isp82.req_q_out); |
|---|
| 2300 | + cnt = rd_reg_dword(reg->isp82.req_q_out); |
|---|
| 2129 | 2301 | else if (IS_FWI2_CAPABLE(ha)) |
|---|
| 2130 | | - cnt = RD_REG_DWORD(®->isp24.req_q_out); |
|---|
| 2302 | + cnt = rd_reg_dword(®->isp24.req_q_out); |
|---|
| 2131 | 2303 | else if (IS_QLAFX00(ha)) |
|---|
| 2132 | | - cnt = RD_REG_DWORD(®->ispfx00.req_q_out); |
|---|
| 2304 | + cnt = rd_reg_dword(®->ispfx00.req_q_out); |
|---|
| 2133 | 2305 | else |
|---|
| 2134 | 2306 | cnt = qla2x00_debounce_register( |
|---|
| 2135 | 2307 | ISP_REQ_Q_OUT(ha, ®->isp)); |
|---|
| .. | .. |
|---|
| 2144 | 2316 | goto queuing_error; |
|---|
| 2145 | 2317 | |
|---|
| 2146 | 2318 | if (sp) { |
|---|
| 2147 | | - /* Check for room in outstanding command list. */ |
|---|
| 2148 | | - handle = req->current_outstanding_cmd; |
|---|
| 2149 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 2150 | | - handle++; |
|---|
| 2151 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 2152 | | - handle = 1; |
|---|
| 2153 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 2154 | | - break; |
|---|
| 2155 | | - } |
|---|
| 2156 | | - if (index == req->num_outstanding_cmds) { |
|---|
| 2319 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 2320 | + if (handle == 0) { |
|---|
| 2157 | 2321 | ql_log(ql_log_warn, vha, 0x700b, |
|---|
| 2158 | 2322 | "No room on outstanding cmd array.\n"); |
|---|
| 2159 | 2323 | goto queuing_error; |
|---|
| .. | .. |
|---|
| 2170 | 2334 | pkt = req->ring_ptr; |
|---|
| 2171 | 2335 | memset(pkt, 0, REQUEST_ENTRY_SIZE); |
|---|
| 2172 | 2336 | if (IS_QLAFX00(ha)) { |
|---|
| 2173 | | - WRT_REG_BYTE((void __iomem *)&pkt->entry_count, req_cnt); |
|---|
| 2174 | | - WRT_REG_WORD((void __iomem *)&pkt->handle, handle); |
|---|
| 2337 | + wrt_reg_byte((u8 __force __iomem *)&pkt->entry_count, req_cnt); |
|---|
| 2338 | + wrt_reg_dword((__le32 __force __iomem *)&pkt->handle, handle); |
|---|
| 2175 | 2339 | } else { |
|---|
| 2176 | 2340 | pkt->entry_count = req_cnt; |
|---|
| 2177 | 2341 | pkt->handle = handle; |
|---|
| .. | .. |
|---|
| 2208 | 2372 | |
|---|
| 2209 | 2373 | logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
|---|
| 2210 | 2374 | logio->control_flags = cpu_to_le16(LCF_COMMAND_PRLI); |
|---|
| 2211 | | - if (lio->u.logio.flags & SRB_LOGIN_NVME_PRLI) |
|---|
| 2212 | | - logio->control_flags |= LCF_NVME_PRLI; |
|---|
| 2375 | + if (lio->u.logio.flags & SRB_LOGIN_NVME_PRLI) { |
|---|
| 2376 | + logio->control_flags |= cpu_to_le16(LCF_NVME_PRLI); |
|---|
| 2377 | + if (sp->vha->flags.nvme_first_burst) |
|---|
| 2378 | + logio->io_parameter[0] = |
|---|
| 2379 | + cpu_to_le32(NVME_PRLI_SP_FIRST_BURST); |
|---|
| 2380 | + if (sp->vha->flags.nvme2_enabled) { |
|---|
| 2381 | + /* Set service parameter BIT_8 for SLER support */ |
|---|
| 2382 | + logio->io_parameter[0] |= |
|---|
| 2383 | + cpu_to_le32(NVME_PRLI_SP_SLER); |
|---|
| 2384 | + /* Set service parameter BIT_9 for PI control support */ |
|---|
| 2385 | + logio->io_parameter[0] |= |
|---|
| 2386 | + cpu_to_le32(NVME_PRLI_SP_PI_CTRL); |
|---|
| 2387 | + } |
|---|
| 2388 | + } |
|---|
| 2213 | 2389 | |
|---|
| 2214 | 2390 | logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
|---|
| 2215 | 2391 | logio->port_id[0] = sp->fcport->d_id.b.al_pa; |
|---|
| .. | .. |
|---|
| 2224 | 2400 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| 2225 | 2401 | |
|---|
| 2226 | 2402 | logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
|---|
| 2403 | + logio->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); |
|---|
| 2404 | + |
|---|
| 2227 | 2405 | if (lio->u.logio.flags & SRB_LOGIN_PRLI_ONLY) { |
|---|
| 2228 | 2406 | logio->control_flags = cpu_to_le16(LCF_COMMAND_PRLI); |
|---|
| 2229 | 2407 | } else { |
|---|
| .. | .. |
|---|
| 2267 | 2445 | static void |
|---|
| 2268 | 2446 | qla24xx_logout_iocb(srb_t *sp, struct logio_entry_24xx *logio) |
|---|
| 2269 | 2447 | { |
|---|
| 2448 | + u16 control_flags = LCF_COMMAND_LOGO; |
|---|
| 2270 | 2449 | logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; |
|---|
| 2271 | | - logio->control_flags = |
|---|
| 2272 | | - cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO); |
|---|
| 2273 | | - if (!sp->fcport->se_sess || |
|---|
| 2274 | | - !sp->fcport->keep_nport_handle) |
|---|
| 2275 | | - logio->control_flags |= cpu_to_le16(LCF_FREE_NPORT); |
|---|
| 2450 | + |
|---|
| 2451 | + if (sp->fcport->explicit_logout) { |
|---|
| 2452 | + control_flags |= LCF_EXPL_LOGO|LCF_FREE_NPORT; |
|---|
| 2453 | + } else { |
|---|
| 2454 | + control_flags |= LCF_IMPL_LOGO; |
|---|
| 2455 | + |
|---|
| 2456 | + if (!sp->fcport->keep_nport_handle) |
|---|
| 2457 | + control_flags |= LCF_FREE_NPORT; |
|---|
| 2458 | + } |
|---|
| 2459 | + |
|---|
| 2460 | + logio->control_flags = cpu_to_le16(control_flags); |
|---|
| 2276 | 2461 | logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
|---|
| 2277 | 2462 | logio->port_id[0] = sp->fcport->d_id.b.al_pa; |
|---|
| 2278 | 2463 | logio->port_id[1] = sp->fcport->d_id.b.area; |
|---|
| .. | .. |
|---|
| 2289 | 2474 | SET_TARGET_ID(ha, mbx->loop_id, sp->fcport->loop_id); |
|---|
| 2290 | 2475 | mbx->mb0 = cpu_to_le16(MBC_LOGOUT_FABRIC_PORT); |
|---|
| 2291 | 2476 | mbx->mb1 = HAS_EXTENDED_IDS(ha) ? |
|---|
| 2292 | | - cpu_to_le16(sp->fcport->loop_id): |
|---|
| 2477 | + cpu_to_le16(sp->fcport->loop_id) : |
|---|
| 2293 | 2478 | cpu_to_le16(sp->fcport->loop_id << 8); |
|---|
| 2294 | 2479 | mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain); |
|---|
| 2295 | 2480 | mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 | |
|---|
| .. | .. |
|---|
| 2344 | 2529 | |
|---|
| 2345 | 2530 | tsk->entry_type = TSK_MGMT_IOCB_TYPE; |
|---|
| 2346 | 2531 | tsk->entry_count = 1; |
|---|
| 2347 | | - tsk->handle = MAKE_HANDLE(req->id, tsk->handle); |
|---|
| 2532 | + tsk->handle = make_handle(req->id, tsk->handle); |
|---|
| 2348 | 2533 | tsk->nport_handle = cpu_to_le16(fcport->loop_id); |
|---|
| 2349 | 2534 | tsk->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
|---|
| 2350 | 2535 | tsk->control_flags = cpu_to_le32(flags); |
|---|
| .. | .. |
|---|
| 2360 | 2545 | } |
|---|
| 2361 | 2546 | } |
|---|
| 2362 | 2547 | |
|---|
| 2363 | | -static void |
|---|
| 2364 | | -qla2x00_els_dcmd_sp_free(void *data) |
|---|
| 2548 | +void qla2x00_init_timer(srb_t *sp, unsigned long tmo) |
|---|
| 2365 | 2549 | { |
|---|
| 2366 | | - srb_t *sp = data; |
|---|
| 2550 | + timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0); |
|---|
| 2551 | + sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; |
|---|
| 2552 | + sp->free = qla2x00_sp_free; |
|---|
| 2553 | + if (IS_QLAFX00(sp->vha->hw) && sp->type == SRB_FXIOCB_DCMD) |
|---|
| 2554 | + init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); |
|---|
| 2555 | + sp->start_timer = 1; |
|---|
| 2556 | +} |
|---|
| 2557 | + |
|---|
| 2558 | +static void qla2x00_els_dcmd_sp_free(srb_t *sp) |
|---|
| 2559 | +{ |
|---|
| 2367 | 2560 | struct srb_iocb *elsio = &sp->u.iocb_cmd; |
|---|
| 2368 | 2561 | |
|---|
| 2369 | 2562 | kfree(sp->fcport); |
|---|
| .. | .. |
|---|
| 2384 | 2577 | fc_port_t *fcport = sp->fcport; |
|---|
| 2385 | 2578 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 2386 | 2579 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| 2580 | + unsigned long flags = 0; |
|---|
| 2581 | + int res, h; |
|---|
| 2387 | 2582 | |
|---|
| 2388 | 2583 | ql_dbg(ql_dbg_io, vha, 0x3069, |
|---|
| 2389 | 2584 | "%s Timeout, hdl=%x, portid=%02x%02x%02x\n", |
|---|
| 2390 | 2585 | sp->name, sp->handle, fcport->d_id.b.domain, fcport->d_id.b.area, |
|---|
| 2391 | 2586 | fcport->d_id.b.al_pa); |
|---|
| 2392 | 2587 | |
|---|
| 2393 | | - complete(&lio->u.els_logo.comp); |
|---|
| 2588 | + /* Abort the exchange */ |
|---|
| 2589 | + res = qla24xx_async_abort_cmd(sp, false); |
|---|
| 2590 | + if (res) { |
|---|
| 2591 | + ql_dbg(ql_dbg_io, vha, 0x3070, |
|---|
| 2592 | + "mbx abort_command failed.\n"); |
|---|
| 2593 | + spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); |
|---|
| 2594 | + for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { |
|---|
| 2595 | + if (sp->qpair->req->outstanding_cmds[h] == sp) { |
|---|
| 2596 | + sp->qpair->req->outstanding_cmds[h] = NULL; |
|---|
| 2597 | + break; |
|---|
| 2598 | + } |
|---|
| 2599 | + } |
|---|
| 2600 | + spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); |
|---|
| 2601 | + complete(&lio->u.els_logo.comp); |
|---|
| 2602 | + } else { |
|---|
| 2603 | + ql_dbg(ql_dbg_io, vha, 0x3071, |
|---|
| 2604 | + "mbx abort_command success.\n"); |
|---|
| 2605 | + } |
|---|
| 2394 | 2606 | } |
|---|
| 2395 | 2607 | |
|---|
| 2396 | | -static void |
|---|
| 2397 | | -qla2x00_els_dcmd_sp_done(void *ptr, int res) |
|---|
| 2608 | +static void qla2x00_els_dcmd_sp_done(srb_t *sp, int res) |
|---|
| 2398 | 2609 | { |
|---|
| 2399 | | - srb_t *sp = ptr; |
|---|
| 2400 | 2610 | fc_port_t *fcport = sp->fcport; |
|---|
| 2401 | 2611 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| 2402 | 2612 | struct scsi_qla_host *vha = sp->vha; |
|---|
| .. | .. |
|---|
| 2474 | 2684 | |
|---|
| 2475 | 2685 | memcpy(elsio->u.els_logo.els_logo_pyld, &logo_pyld, |
|---|
| 2476 | 2686 | sizeof(struct els_logo_payload)); |
|---|
| 2687 | + ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x3075, "LOGO buffer:"); |
|---|
| 2688 | + ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x010a, |
|---|
| 2689 | + elsio->u.els_logo.els_logo_pyld, |
|---|
| 2690 | + sizeof(*elsio->u.els_logo.els_logo_pyld)); |
|---|
| 2477 | 2691 | |
|---|
| 2478 | 2692 | rval = qla2x00_start_sp(sp); |
|---|
| 2479 | 2693 | if (rval != QLA_SUCCESS) { |
|---|
| .. | .. |
|---|
| 2504 | 2718 | els_iocb->entry_status = 0; |
|---|
| 2505 | 2719 | els_iocb->handle = sp->handle; |
|---|
| 2506 | 2720 | els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
|---|
| 2507 | | - els_iocb->tx_dsd_count = 1; |
|---|
| 2721 | + els_iocb->tx_dsd_count = cpu_to_le16(1); |
|---|
| 2508 | 2722 | els_iocb->vp_index = vha->vp_idx; |
|---|
| 2509 | 2723 | els_iocb->sof_type = EST_SOFI3; |
|---|
| 2510 | 2724 | els_iocb->rx_dsd_count = 0; |
|---|
| 2511 | 2725 | els_iocb->opcode = elsio->u.els_logo.els_cmd; |
|---|
| 2512 | 2726 | |
|---|
| 2513 | | - els_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; |
|---|
| 2514 | | - els_iocb->port_id[1] = sp->fcport->d_id.b.area; |
|---|
| 2515 | | - els_iocb->port_id[2] = sp->fcport->d_id.b.domain; |
|---|
| 2516 | | - els_iocb->s_id[0] = vha->d_id.b.al_pa; |
|---|
| 2517 | | - els_iocb->s_id[1] = vha->d_id.b.area; |
|---|
| 2518 | | - els_iocb->s_id[2] = vha->d_id.b.domain; |
|---|
| 2519 | | - els_iocb->control_flags = 0; |
|---|
| 2727 | + els_iocb->d_id[0] = sp->fcport->d_id.b.al_pa; |
|---|
| 2728 | + els_iocb->d_id[1] = sp->fcport->d_id.b.area; |
|---|
| 2729 | + els_iocb->d_id[2] = sp->fcport->d_id.b.domain; |
|---|
| 2730 | + /* For SID the byte order is different than DID */ |
|---|
| 2731 | + els_iocb->s_id[1] = vha->d_id.b.al_pa; |
|---|
| 2732 | + els_iocb->s_id[2] = vha->d_id.b.area; |
|---|
| 2733 | + els_iocb->s_id[0] = vha->d_id.b.domain; |
|---|
| 2520 | 2734 | |
|---|
| 2521 | 2735 | if (elsio->u.els_logo.els_cmd == ELS_DCMD_PLOGI) { |
|---|
| 2736 | + els_iocb->control_flags = 0; |
|---|
| 2522 | 2737 | els_iocb->tx_byte_count = els_iocb->tx_len = |
|---|
| 2523 | | - sizeof(struct els_plogi_payload); |
|---|
| 2524 | | - els_iocb->tx_address[0] = |
|---|
| 2525 | | - cpu_to_le32(LSD(elsio->u.els_plogi.els_plogi_pyld_dma)); |
|---|
| 2526 | | - els_iocb->tx_address[1] = |
|---|
| 2527 | | - cpu_to_le32(MSD(elsio->u.els_plogi.els_plogi_pyld_dma)); |
|---|
| 2528 | | - |
|---|
| 2529 | | - els_iocb->rx_dsd_count = 1; |
|---|
| 2738 | + cpu_to_le32(sizeof(struct els_plogi_payload)); |
|---|
| 2739 | + put_unaligned_le64(elsio->u.els_plogi.els_plogi_pyld_dma, |
|---|
| 2740 | + &els_iocb->tx_address); |
|---|
| 2741 | + els_iocb->rx_dsd_count = cpu_to_le16(1); |
|---|
| 2530 | 2742 | els_iocb->rx_byte_count = els_iocb->rx_len = |
|---|
| 2531 | | - sizeof(struct els_plogi_payload); |
|---|
| 2532 | | - els_iocb->rx_address[0] = |
|---|
| 2533 | | - cpu_to_le32(LSD(elsio->u.els_plogi.els_resp_pyld_dma)); |
|---|
| 2534 | | - els_iocb->rx_address[1] = |
|---|
| 2535 | | - cpu_to_le32(MSD(elsio->u.els_plogi.els_resp_pyld_dma)); |
|---|
| 2743 | + cpu_to_le32(sizeof(struct els_plogi_payload)); |
|---|
| 2744 | + put_unaligned_le64(elsio->u.els_plogi.els_resp_pyld_dma, |
|---|
| 2745 | + &els_iocb->rx_address); |
|---|
| 2536 | 2746 | |
|---|
| 2537 | 2747 | ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x3073, |
|---|
| 2538 | 2748 | "PLOGI ELS IOCB:\n"); |
|---|
| .. | .. |
|---|
| 2540 | 2750 | (uint8_t *)els_iocb, |
|---|
| 2541 | 2751 | sizeof(*els_iocb)); |
|---|
| 2542 | 2752 | } else { |
|---|
| 2543 | | - els_iocb->tx_byte_count = sizeof(struct els_logo_payload); |
|---|
| 2544 | | - els_iocb->tx_address[0] = |
|---|
| 2545 | | - cpu_to_le32(LSD(elsio->u.els_logo.els_logo_pyld_dma)); |
|---|
| 2546 | | - els_iocb->tx_address[1] = |
|---|
| 2547 | | - cpu_to_le32(MSD(elsio->u.els_logo.els_logo_pyld_dma)); |
|---|
| 2753 | + els_iocb->control_flags = cpu_to_le16(1 << 13); |
|---|
| 2754 | + els_iocb->tx_byte_count = |
|---|
| 2755 | + cpu_to_le32(sizeof(struct els_logo_payload)); |
|---|
| 2756 | + put_unaligned_le64(elsio->u.els_logo.els_logo_pyld_dma, |
|---|
| 2757 | + &els_iocb->tx_address); |
|---|
| 2548 | 2758 | els_iocb->tx_len = cpu_to_le32(sizeof(struct els_logo_payload)); |
|---|
| 2549 | 2759 | |
|---|
| 2550 | 2760 | els_iocb->rx_byte_count = 0; |
|---|
| 2551 | | - els_iocb->rx_address[0] = 0; |
|---|
| 2552 | | - els_iocb->rx_address[1] = 0; |
|---|
| 2761 | + els_iocb->rx_address = 0; |
|---|
| 2553 | 2762 | els_iocb->rx_len = 0; |
|---|
| 2763 | + ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x3076, |
|---|
| 2764 | + "LOGO ELS IOCB:"); |
|---|
| 2765 | + ql_dump_buffer(ql_log_info, vha, 0x010b, |
|---|
| 2766 | + els_iocb, |
|---|
| 2767 | + sizeof(*els_iocb)); |
|---|
| 2554 | 2768 | } |
|---|
| 2555 | 2769 | |
|---|
| 2556 | 2770 | sp->vha->qla_stats.control_requests++; |
|---|
| .. | .. |
|---|
| 2562 | 2776 | srb_t *sp = data; |
|---|
| 2563 | 2777 | fc_port_t *fcport = sp->fcport; |
|---|
| 2564 | 2778 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 2565 | | - struct qla_hw_data *ha = vha->hw; |
|---|
| 2566 | 2779 | unsigned long flags = 0; |
|---|
| 2567 | | - int res; |
|---|
| 2780 | + int res, h; |
|---|
| 2568 | 2781 | |
|---|
| 2569 | 2782 | ql_dbg(ql_dbg_io + ql_dbg_disc, vha, 0x3069, |
|---|
| 2570 | 2783 | "%s hdl=%x ELS Timeout, %8phC portid=%06x\n", |
|---|
| 2571 | 2784 | sp->name, sp->handle, fcport->port_name, fcport->d_id.b24); |
|---|
| 2572 | 2785 | |
|---|
| 2573 | 2786 | /* Abort the exchange */ |
|---|
| 2574 | | - spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 2575 | | - res = ha->isp_ops->abort_command(sp); |
|---|
| 2787 | + res = qla24xx_async_abort_cmd(sp, false); |
|---|
| 2576 | 2788 | ql_dbg(ql_dbg_io, vha, 0x3070, |
|---|
| 2577 | 2789 | "mbx abort_command %s\n", |
|---|
| 2578 | 2790 | (res == QLA_SUCCESS) ? "successful" : "failed"); |
|---|
| 2579 | | - spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 2580 | | - |
|---|
| 2581 | | - sp->done(sp, QLA_FUNCTION_TIMEOUT); |
|---|
| 2791 | + if (res) { |
|---|
| 2792 | + spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); |
|---|
| 2793 | + for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { |
|---|
| 2794 | + if (sp->qpair->req->outstanding_cmds[h] == sp) { |
|---|
| 2795 | + sp->qpair->req->outstanding_cmds[h] = NULL; |
|---|
| 2796 | + break; |
|---|
| 2797 | + } |
|---|
| 2798 | + } |
|---|
| 2799 | + spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); |
|---|
| 2800 | + sp->done(sp, QLA_FUNCTION_TIMEOUT); |
|---|
| 2801 | + } |
|---|
| 2582 | 2802 | } |
|---|
| 2583 | 2803 | |
|---|
| 2584 | | -static void |
|---|
| 2585 | | -qla2x00_els_dcmd2_sp_done(void *ptr, int res) |
|---|
| 2804 | +void qla2x00_els_dcmd2_free(scsi_qla_host_t *vha, struct els_plogi *els_plogi) |
|---|
| 2586 | 2805 | { |
|---|
| 2587 | | - srb_t *sp = ptr; |
|---|
| 2806 | + if (els_plogi->els_plogi_pyld) |
|---|
| 2807 | + dma_free_coherent(&vha->hw->pdev->dev, |
|---|
| 2808 | + els_plogi->tx_size, |
|---|
| 2809 | + els_plogi->els_plogi_pyld, |
|---|
| 2810 | + els_plogi->els_plogi_pyld_dma); |
|---|
| 2811 | + |
|---|
| 2812 | + if (els_plogi->els_resp_pyld) |
|---|
| 2813 | + dma_free_coherent(&vha->hw->pdev->dev, |
|---|
| 2814 | + els_plogi->rx_size, |
|---|
| 2815 | + els_plogi->els_resp_pyld, |
|---|
| 2816 | + els_plogi->els_resp_pyld_dma); |
|---|
| 2817 | +} |
|---|
| 2818 | + |
|---|
| 2819 | +static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res) |
|---|
| 2820 | +{ |
|---|
| 2588 | 2821 | fc_port_t *fcport = sp->fcport; |
|---|
| 2589 | 2822 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
|---|
| 2590 | 2823 | struct scsi_qla_host *vha = sp->vha; |
|---|
| 2591 | 2824 | struct event_arg ea; |
|---|
| 2592 | 2825 | struct qla_work_evt *e; |
|---|
| 2826 | + struct fc_port *conflict_fcport; |
|---|
| 2827 | + port_id_t cid; /* conflict Nport id */ |
|---|
| 2828 | + const __le32 *fw_status = sp->u.iocb_cmd.u.els_plogi.fw_status; |
|---|
| 2829 | + u16 lid; |
|---|
| 2593 | 2830 | |
|---|
| 2594 | 2831 | ql_dbg(ql_dbg_disc, vha, 0x3072, |
|---|
| 2595 | 2832 | "%s ELS done rc %d hdl=%x, portid=%06x %8phC\n", |
|---|
| .. | .. |
|---|
| 2601 | 2838 | if (sp->flags & SRB_WAKEUP_ON_COMP) |
|---|
| 2602 | 2839 | complete(&lio->u.els_plogi.comp); |
|---|
| 2603 | 2840 | else { |
|---|
| 2604 | | - if (res) { |
|---|
| 2605 | | - set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
|---|
| 2606 | | - } else { |
|---|
| 2841 | + switch (le32_to_cpu(fw_status[0])) { |
|---|
| 2842 | + case CS_DATA_UNDERRUN: |
|---|
| 2843 | + case CS_COMPLETE: |
|---|
| 2607 | 2844 | memset(&ea, 0, sizeof(ea)); |
|---|
| 2608 | 2845 | ea.fcport = fcport; |
|---|
| 2609 | 2846 | ea.rc = res; |
|---|
| 2610 | | - ea.event = FCME_ELS_PLOGI_DONE; |
|---|
| 2611 | | - qla2x00_fcport_event_handler(vha, &ea); |
|---|
| 2847 | + qla_handle_els_plogi_done(vha, &ea); |
|---|
| 2848 | + break; |
|---|
| 2849 | + |
|---|
| 2850 | + case CS_IOCB_ERROR: |
|---|
| 2851 | + switch (le32_to_cpu(fw_status[1])) { |
|---|
| 2852 | + case LSC_SCODE_PORTID_USED: |
|---|
| 2853 | + lid = le32_to_cpu(fw_status[2]) & 0xffff; |
|---|
| 2854 | + qlt_find_sess_invalidate_other(vha, |
|---|
| 2855 | + wwn_to_u64(fcport->port_name), |
|---|
| 2856 | + fcport->d_id, lid, &conflict_fcport); |
|---|
| 2857 | + if (conflict_fcport) { |
|---|
| 2858 | + /* |
|---|
| 2859 | + * Another fcport shares the same |
|---|
| 2860 | + * loop_id & nport id; conflict |
|---|
| 2861 | + * fcport needs to finish cleanup |
|---|
| 2862 | + * before this fcport can proceed |
|---|
| 2863 | + * to login. |
|---|
| 2864 | + */ |
|---|
| 2865 | + conflict_fcport->conflict = fcport; |
|---|
| 2866 | + fcport->login_pause = 1; |
|---|
| 2867 | + ql_dbg(ql_dbg_disc, vha, 0x20ed, |
|---|
| 2868 | + "%s %d %8phC pid %06x inuse with lid %#x post gidpn\n", |
|---|
| 2869 | + __func__, __LINE__, |
|---|
| 2870 | + fcport->port_name, |
|---|
| 2871 | + fcport->d_id.b24, lid); |
|---|
| 2872 | + } else { |
|---|
| 2873 | + ql_dbg(ql_dbg_disc, vha, 0x20ed, |
|---|
| 2874 | + "%s %d %8phC pid %06x inuse with lid %#x sched del\n", |
|---|
| 2875 | + __func__, __LINE__, |
|---|
| 2876 | + fcport->port_name, |
|---|
| 2877 | + fcport->d_id.b24, lid); |
|---|
| 2878 | + qla2x00_clear_loop_id(fcport); |
|---|
| 2879 | + set_bit(lid, vha->hw->loop_id_map); |
|---|
| 2880 | + fcport->loop_id = lid; |
|---|
| 2881 | + fcport->keep_nport_handle = 0; |
|---|
| 2882 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 2883 | + } |
|---|
| 2884 | + break; |
|---|
| 2885 | + |
|---|
| 2886 | + case LSC_SCODE_NPORT_USED: |
|---|
| 2887 | + cid.b.domain = (le32_to_cpu(fw_status[2]) >> 16) |
|---|
| 2888 | + & 0xff; |
|---|
| 2889 | + cid.b.area = (le32_to_cpu(fw_status[2]) >> 8) |
|---|
| 2890 | + & 0xff; |
|---|
| 2891 | + cid.b.al_pa = le32_to_cpu(fw_status[2]) & 0xff; |
|---|
| 2892 | + cid.b.rsvd_1 = 0; |
|---|
| 2893 | + |
|---|
| 2894 | + ql_dbg(ql_dbg_disc, vha, 0x20ec, |
|---|
| 2895 | + "%s %d %8phC lid %#x in use with pid %06x post gnl\n", |
|---|
| 2896 | + __func__, __LINE__, fcport->port_name, |
|---|
| 2897 | + fcport->loop_id, cid.b24); |
|---|
| 2898 | + set_bit(fcport->loop_id, |
|---|
| 2899 | + vha->hw->loop_id_map); |
|---|
| 2900 | + fcport->loop_id = FC_NO_LOOP_ID; |
|---|
| 2901 | + qla24xx_post_gnl_work(vha, fcport); |
|---|
| 2902 | + break; |
|---|
| 2903 | + |
|---|
| 2904 | + case LSC_SCODE_NOXCB: |
|---|
| 2905 | + vha->hw->exch_starvation++; |
|---|
| 2906 | + if (vha->hw->exch_starvation > 5) { |
|---|
| 2907 | + ql_log(ql_log_warn, vha, 0xd046, |
|---|
| 2908 | + "Exchange starvation. Resetting RISC\n"); |
|---|
| 2909 | + vha->hw->exch_starvation = 0; |
|---|
| 2910 | + set_bit(ISP_ABORT_NEEDED, |
|---|
| 2911 | + &vha->dpc_flags); |
|---|
| 2912 | + qla2xxx_wake_dpc(vha); |
|---|
| 2913 | + break; |
|---|
| 2914 | + } |
|---|
| 2915 | + fallthrough; |
|---|
| 2916 | + default: |
|---|
| 2917 | + ql_dbg(ql_dbg_disc, vha, 0x20eb, |
|---|
| 2918 | + "%s %8phC cmd error fw_status 0x%x 0x%x 0x%x\n", |
|---|
| 2919 | + __func__, sp->fcport->port_name, |
|---|
| 2920 | + fw_status[0], fw_status[1], fw_status[2]); |
|---|
| 2921 | + |
|---|
| 2922 | + fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 2923 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 2924 | + break; |
|---|
| 2925 | + } |
|---|
| 2926 | + break; |
|---|
| 2927 | + |
|---|
| 2928 | + default: |
|---|
| 2929 | + ql_dbg(ql_dbg_disc, vha, 0x20eb, |
|---|
| 2930 | + "%s %8phC cmd error 2 fw_status 0x%x 0x%x 0x%x\n", |
|---|
| 2931 | + __func__, sp->fcport->port_name, |
|---|
| 2932 | + fw_status[0], fw_status[1], fw_status[2]); |
|---|
| 2933 | + |
|---|
| 2934 | + sp->fcport->flags &= ~FCF_ASYNC_SENT; |
|---|
| 2935 | + qlt_schedule_sess_for_deletion(fcport); |
|---|
| 2936 | + break; |
|---|
| 2612 | 2937 | } |
|---|
| 2613 | 2938 | |
|---|
| 2614 | 2939 | e = qla2x00_alloc_work(vha, QLA_EVT_UNMAP); |
|---|
| 2615 | 2940 | if (!e) { |
|---|
| 2616 | 2941 | struct srb_iocb *elsio = &sp->u.iocb_cmd; |
|---|
| 2617 | 2942 | |
|---|
| 2618 | | - if (elsio->u.els_plogi.els_plogi_pyld) |
|---|
| 2619 | | - dma_free_coherent(&sp->vha->hw->pdev->dev, |
|---|
| 2620 | | - elsio->u.els_plogi.tx_size, |
|---|
| 2621 | | - elsio->u.els_plogi.els_plogi_pyld, |
|---|
| 2622 | | - elsio->u.els_plogi.els_plogi_pyld_dma); |
|---|
| 2623 | | - |
|---|
| 2624 | | - if (elsio->u.els_plogi.els_resp_pyld) |
|---|
| 2625 | | - dma_free_coherent(&sp->vha->hw->pdev->dev, |
|---|
| 2626 | | - elsio->u.els_plogi.rx_size, |
|---|
| 2627 | | - elsio->u.els_plogi.els_resp_pyld, |
|---|
| 2628 | | - elsio->u.els_plogi.els_resp_pyld_dma); |
|---|
| 2943 | + qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi); |
|---|
| 2629 | 2944 | sp->free(sp); |
|---|
| 2630 | 2945 | return; |
|---|
| 2631 | 2946 | } |
|---|
| .. | .. |
|---|
| 2643 | 2958 | struct qla_hw_data *ha = vha->hw; |
|---|
| 2644 | 2959 | int rval = QLA_SUCCESS; |
|---|
| 2645 | 2960 | void *ptr, *resp_ptr; |
|---|
| 2646 | | - dma_addr_t ptr_dma; |
|---|
| 2647 | 2961 | |
|---|
| 2648 | 2962 | /* Alloc SRB structure */ |
|---|
| 2649 | 2963 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
|---|
| 2650 | 2964 | if (!sp) { |
|---|
| 2651 | 2965 | ql_log(ql_log_info, vha, 0x70e6, |
|---|
| 2652 | 2966 | "SRB allocation failed\n"); |
|---|
| 2967 | + fcport->flags &= ~FCF_ASYNC_ACTIVE; |
|---|
| 2653 | 2968 | return -ENOMEM; |
|---|
| 2654 | 2969 | } |
|---|
| 2655 | 2970 | |
|---|
| 2971 | + fcport->flags |= FCF_ASYNC_SENT; |
|---|
| 2972 | + qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_PEND); |
|---|
| 2656 | 2973 | elsio = &sp->u.iocb_cmd; |
|---|
| 2657 | 2974 | ql_dbg(ql_dbg_io, vha, 0x3073, |
|---|
| 2658 | 2975 | "Enter: PLOGI portid=%06x\n", fcport->d_id.b24); |
|---|
| 2659 | 2976 | |
|---|
| 2660 | | - fcport->flags |= FCF_ASYNC_SENT; |
|---|
| 2661 | 2977 | sp->type = SRB_ELS_DCMD; |
|---|
| 2662 | 2978 | sp->name = "ELS_DCMD"; |
|---|
| 2663 | 2979 | sp->fcport = fcport; |
|---|
| 2664 | 2980 | |
|---|
| 2665 | 2981 | elsio->timeout = qla2x00_els_dcmd2_iocb_timeout; |
|---|
| 2666 | | - init_completion(&elsio->u.els_plogi.comp); |
|---|
| 2667 | 2982 | if (wait) |
|---|
| 2668 | 2983 | sp->flags = SRB_WAKEUP_ON_COMP; |
|---|
| 2669 | 2984 | |
|---|
| .. | .. |
|---|
| 2673 | 2988 | elsio->u.els_plogi.tx_size = elsio->u.els_plogi.rx_size = DMA_POOL_SIZE; |
|---|
| 2674 | 2989 | |
|---|
| 2675 | 2990 | ptr = elsio->u.els_plogi.els_plogi_pyld = |
|---|
| 2676 | | - dma_alloc_coherent(&ha->pdev->dev, DMA_POOL_SIZE, |
|---|
| 2991 | + dma_alloc_coherent(&ha->pdev->dev, elsio->u.els_plogi.tx_size, |
|---|
| 2677 | 2992 | &elsio->u.els_plogi.els_plogi_pyld_dma, GFP_KERNEL); |
|---|
| 2678 | | - ptr_dma = elsio->u.els_plogi.els_plogi_pyld_dma; |
|---|
| 2679 | 2993 | |
|---|
| 2680 | 2994 | if (!elsio->u.els_plogi.els_plogi_pyld) { |
|---|
| 2681 | 2995 | rval = QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 2683 | 2997 | } |
|---|
| 2684 | 2998 | |
|---|
| 2685 | 2999 | resp_ptr = elsio->u.els_plogi.els_resp_pyld = |
|---|
| 2686 | | - dma_alloc_coherent(&ha->pdev->dev, DMA_POOL_SIZE, |
|---|
| 3000 | + dma_alloc_coherent(&ha->pdev->dev, elsio->u.els_plogi.rx_size, |
|---|
| 2687 | 3001 | &elsio->u.els_plogi.els_resp_pyld_dma, GFP_KERNEL); |
|---|
| 2688 | 3002 | |
|---|
| 2689 | 3003 | if (!elsio->u.els_plogi.els_resp_pyld) { |
|---|
| .. | .. |
|---|
| 2696 | 3010 | memset(ptr, 0, sizeof(struct els_plogi_payload)); |
|---|
| 2697 | 3011 | memset(resp_ptr, 0, sizeof(struct els_plogi_payload)); |
|---|
| 2698 | 3012 | memcpy(elsio->u.els_plogi.els_plogi_pyld->data, |
|---|
| 2699 | | - &ha->plogi_els_payld.data, |
|---|
| 2700 | | - sizeof(elsio->u.els_plogi.els_plogi_pyld->data)); |
|---|
| 3013 | + &ha->plogi_els_payld.fl_csp, LOGIN_TEMPLATE_SIZE); |
|---|
| 2701 | 3014 | |
|---|
| 2702 | 3015 | elsio->u.els_plogi.els_cmd = els_opcode; |
|---|
| 2703 | 3016 | elsio->u.els_plogi.els_plogi_pyld->opcode = els_opcode; |
|---|
| .. | .. |
|---|
| 2707 | 3020 | (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, |
|---|
| 2708 | 3021 | sizeof(*elsio->u.els_plogi.els_plogi_pyld)); |
|---|
| 2709 | 3022 | |
|---|
| 3023 | + init_completion(&elsio->u.els_plogi.comp); |
|---|
| 2710 | 3024 | rval = qla2x00_start_sp(sp); |
|---|
| 2711 | 3025 | if (rval != QLA_SUCCESS) { |
|---|
| 2712 | 3026 | rval = QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 2727 | 3041 | } |
|---|
| 2728 | 3042 | |
|---|
| 2729 | 3043 | out: |
|---|
| 2730 | | - fcport->flags &= ~(FCF_ASYNC_SENT); |
|---|
| 2731 | | - if (elsio->u.els_plogi.els_plogi_pyld) |
|---|
| 2732 | | - dma_free_coherent(&sp->vha->hw->pdev->dev, |
|---|
| 2733 | | - elsio->u.els_plogi.tx_size, |
|---|
| 2734 | | - elsio->u.els_plogi.els_plogi_pyld, |
|---|
| 2735 | | - elsio->u.els_plogi.els_plogi_pyld_dma); |
|---|
| 2736 | | - |
|---|
| 2737 | | - if (elsio->u.els_plogi.els_resp_pyld) |
|---|
| 2738 | | - dma_free_coherent(&sp->vha->hw->pdev->dev, |
|---|
| 2739 | | - elsio->u.els_plogi.rx_size, |
|---|
| 2740 | | - elsio->u.els_plogi.els_resp_pyld, |
|---|
| 2741 | | - elsio->u.els_plogi.els_resp_pyld_dma); |
|---|
| 2742 | | - |
|---|
| 3044 | + fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); |
|---|
| 3045 | + qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi); |
|---|
| 2743 | 3046 | sp->free(sp); |
|---|
| 2744 | 3047 | done: |
|---|
| 2745 | 3048 | return rval; |
|---|
| .. | .. |
|---|
| 2756 | 3059 | els_iocb->sys_define = 0; |
|---|
| 2757 | 3060 | els_iocb->entry_status = 0; |
|---|
| 2758 | 3061 | els_iocb->handle = sp->handle; |
|---|
| 2759 | | - els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
|---|
| 3062 | + els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
|---|
| 2760 | 3063 | els_iocb->tx_dsd_count = cpu_to_le16(bsg_job->request_payload.sg_cnt); |
|---|
| 2761 | 3064 | els_iocb->vp_index = sp->vha->vp_idx; |
|---|
| 2762 | 3065 | els_iocb->sof_type = EST_SOFI3; |
|---|
| .. | .. |
|---|
| 2766 | 3069 | sp->type == SRB_ELS_CMD_RPT ? |
|---|
| 2767 | 3070 | bsg_request->rqst_data.r_els.els_code : |
|---|
| 2768 | 3071 | bsg_request->rqst_data.h_els.command_code; |
|---|
| 2769 | | - els_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; |
|---|
| 2770 | | - els_iocb->port_id[1] = sp->fcport->d_id.b.area; |
|---|
| 2771 | | - els_iocb->port_id[2] = sp->fcport->d_id.b.domain; |
|---|
| 3072 | + els_iocb->d_id[0] = sp->fcport->d_id.b.al_pa; |
|---|
| 3073 | + els_iocb->d_id[1] = sp->fcport->d_id.b.area; |
|---|
| 3074 | + els_iocb->d_id[2] = sp->fcport->d_id.b.domain; |
|---|
| 2772 | 3075 | els_iocb->control_flags = 0; |
|---|
| 2773 | 3076 | els_iocb->rx_byte_count = |
|---|
| 2774 | 3077 | cpu_to_le32(bsg_job->reply_payload.payload_len); |
|---|
| 2775 | 3078 | els_iocb->tx_byte_count = |
|---|
| 2776 | 3079 | cpu_to_le32(bsg_job->request_payload.payload_len); |
|---|
| 2777 | 3080 | |
|---|
| 2778 | | - els_iocb->tx_address[0] = cpu_to_le32(LSD(sg_dma_address |
|---|
| 2779 | | - (bsg_job->request_payload.sg_list))); |
|---|
| 2780 | | - els_iocb->tx_address[1] = cpu_to_le32(MSD(sg_dma_address |
|---|
| 2781 | | - (bsg_job->request_payload.sg_list))); |
|---|
| 3081 | + put_unaligned_le64(sg_dma_address(bsg_job->request_payload.sg_list), |
|---|
| 3082 | + &els_iocb->tx_address); |
|---|
| 2782 | 3083 | els_iocb->tx_len = cpu_to_le32(sg_dma_len |
|---|
| 2783 | 3084 | (bsg_job->request_payload.sg_list)); |
|---|
| 2784 | 3085 | |
|---|
| 2785 | | - els_iocb->rx_address[0] = cpu_to_le32(LSD(sg_dma_address |
|---|
| 2786 | | - (bsg_job->reply_payload.sg_list))); |
|---|
| 2787 | | - els_iocb->rx_address[1] = cpu_to_le32(MSD(sg_dma_address |
|---|
| 2788 | | - (bsg_job->reply_payload.sg_list))); |
|---|
| 3086 | + put_unaligned_le64(sg_dma_address(bsg_job->reply_payload.sg_list), |
|---|
| 3087 | + &els_iocb->rx_address); |
|---|
| 2789 | 3088 | els_iocb->rx_len = cpu_to_le32(sg_dma_len |
|---|
| 2790 | 3089 | (bsg_job->reply_payload.sg_list)); |
|---|
| 2791 | 3090 | |
|---|
| .. | .. |
|---|
| 2796 | 3095 | qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) |
|---|
| 2797 | 3096 | { |
|---|
| 2798 | 3097 | uint16_t avail_dsds; |
|---|
| 2799 | | - uint32_t *cur_dsd; |
|---|
| 3098 | + struct dsd64 *cur_dsd; |
|---|
| 2800 | 3099 | struct scatterlist *sg; |
|---|
| 2801 | 3100 | int index; |
|---|
| 2802 | 3101 | uint16_t tot_dsds; |
|---|
| 2803 | 3102 | scsi_qla_host_t *vha = sp->vha; |
|---|
| 2804 | 3103 | struct qla_hw_data *ha = vha->hw; |
|---|
| 2805 | 3104 | struct bsg_job *bsg_job = sp->u.bsg_job; |
|---|
| 2806 | | - int loop_iterartion = 0; |
|---|
| 2807 | 3105 | int entry_count = 1; |
|---|
| 2808 | 3106 | |
|---|
| 2809 | 3107 | memset(ct_iocb, 0, sizeof(ms_iocb_entry_t)); |
|---|
| .. | .. |
|---|
| 2823 | 3121 | ct_iocb->rsp_bytecount = |
|---|
| 2824 | 3122 | cpu_to_le32(bsg_job->reply_payload.payload_len); |
|---|
| 2825 | 3123 | |
|---|
| 2826 | | - ct_iocb->dseg_req_address[0] = cpu_to_le32(LSD(sg_dma_address |
|---|
| 2827 | | - (bsg_job->request_payload.sg_list))); |
|---|
| 2828 | | - ct_iocb->dseg_req_address[1] = cpu_to_le32(MSD(sg_dma_address |
|---|
| 2829 | | - (bsg_job->request_payload.sg_list))); |
|---|
| 2830 | | - ct_iocb->dseg_req_length = ct_iocb->req_bytecount; |
|---|
| 3124 | + put_unaligned_le64(sg_dma_address(bsg_job->request_payload.sg_list), |
|---|
| 3125 | + &ct_iocb->req_dsd.address); |
|---|
| 3126 | + ct_iocb->req_dsd.length = ct_iocb->req_bytecount; |
|---|
| 2831 | 3127 | |
|---|
| 2832 | | - ct_iocb->dseg_rsp_address[0] = cpu_to_le32(LSD(sg_dma_address |
|---|
| 2833 | | - (bsg_job->reply_payload.sg_list))); |
|---|
| 2834 | | - ct_iocb->dseg_rsp_address[1] = cpu_to_le32(MSD(sg_dma_address |
|---|
| 2835 | | - (bsg_job->reply_payload.sg_list))); |
|---|
| 2836 | | - ct_iocb->dseg_rsp_length = ct_iocb->rsp_bytecount; |
|---|
| 3128 | + put_unaligned_le64(sg_dma_address(bsg_job->reply_payload.sg_list), |
|---|
| 3129 | + &ct_iocb->rsp_dsd.address); |
|---|
| 3130 | + ct_iocb->rsp_dsd.length = ct_iocb->rsp_bytecount; |
|---|
| 2837 | 3131 | |
|---|
| 2838 | 3132 | avail_dsds = 1; |
|---|
| 2839 | | - cur_dsd = (uint32_t *)ct_iocb->dseg_rsp_address; |
|---|
| 3133 | + cur_dsd = &ct_iocb->rsp_dsd; |
|---|
| 2840 | 3134 | index = 0; |
|---|
| 2841 | 3135 | tot_dsds = bsg_job->reply_payload.sg_cnt; |
|---|
| 2842 | 3136 | |
|---|
| 2843 | 3137 | for_each_sg(bsg_job->reply_payload.sg_list, sg, tot_dsds, index) { |
|---|
| 2844 | | - dma_addr_t sle_dma; |
|---|
| 2845 | 3138 | cont_a64_entry_t *cont_pkt; |
|---|
| 2846 | 3139 | |
|---|
| 2847 | 3140 | /* Allocate additional continuation packets? */ |
|---|
| .. | .. |
|---|
| 2852 | 3145 | */ |
|---|
| 2853 | 3146 | cont_pkt = qla2x00_prep_cont_type1_iocb(vha, |
|---|
| 2854 | 3147 | vha->hw->req_q_map[0]); |
|---|
| 2855 | | - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; |
|---|
| 3148 | + cur_dsd = cont_pkt->dsd; |
|---|
| 2856 | 3149 | avail_dsds = 5; |
|---|
| 2857 | 3150 | entry_count++; |
|---|
| 2858 | 3151 | } |
|---|
| 2859 | 3152 | |
|---|
| 2860 | | - sle_dma = sg_dma_address(sg); |
|---|
| 2861 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 2862 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 2863 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 2864 | | - loop_iterartion++; |
|---|
| 3153 | + append_dsd64(&cur_dsd, sg); |
|---|
| 2865 | 3154 | avail_dsds--; |
|---|
| 2866 | 3155 | } |
|---|
| 2867 | 3156 | ct_iocb->entry_count = entry_count; |
|---|
| .. | .. |
|---|
| 2873 | 3162 | qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) |
|---|
| 2874 | 3163 | { |
|---|
| 2875 | 3164 | uint16_t avail_dsds; |
|---|
| 2876 | | - uint32_t *cur_dsd; |
|---|
| 3165 | + struct dsd64 *cur_dsd; |
|---|
| 2877 | 3166 | struct scatterlist *sg; |
|---|
| 2878 | 3167 | int index; |
|---|
| 2879 | 3168 | uint16_t cmd_dsds, rsp_dsds; |
|---|
| .. | .. |
|---|
| 2902 | 3191 | cpu_to_le32(bsg_job->request_payload.payload_len); |
|---|
| 2903 | 3192 | |
|---|
| 2904 | 3193 | avail_dsds = 2; |
|---|
| 2905 | | - cur_dsd = (uint32_t *)ct_iocb->dseg_0_address; |
|---|
| 3194 | + cur_dsd = ct_iocb->dsd; |
|---|
| 2906 | 3195 | index = 0; |
|---|
| 2907 | 3196 | |
|---|
| 2908 | 3197 | for_each_sg(bsg_job->request_payload.sg_list, sg, cmd_dsds, index) { |
|---|
| 2909 | | - dma_addr_t sle_dma; |
|---|
| 2910 | | - |
|---|
| 2911 | 3198 | /* Allocate additional continuation packets? */ |
|---|
| 2912 | 3199 | if (avail_dsds == 0) { |
|---|
| 2913 | 3200 | /* |
|---|
| .. | .. |
|---|
| 2916 | 3203 | */ |
|---|
| 2917 | 3204 | cont_pkt = qla2x00_prep_cont_type1_iocb( |
|---|
| 2918 | 3205 | vha, ha->req_q_map[0]); |
|---|
| 2919 | | - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; |
|---|
| 3206 | + cur_dsd = cont_pkt->dsd; |
|---|
| 2920 | 3207 | avail_dsds = 5; |
|---|
| 2921 | 3208 | entry_count++; |
|---|
| 2922 | 3209 | } |
|---|
| 2923 | 3210 | |
|---|
| 2924 | | - sle_dma = sg_dma_address(sg); |
|---|
| 2925 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 2926 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 2927 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 3211 | + append_dsd64(&cur_dsd, sg); |
|---|
| 2928 | 3212 | avail_dsds--; |
|---|
| 2929 | 3213 | } |
|---|
| 2930 | 3214 | |
|---|
| 2931 | 3215 | index = 0; |
|---|
| 2932 | 3216 | |
|---|
| 2933 | 3217 | for_each_sg(bsg_job->reply_payload.sg_list, sg, rsp_dsds, index) { |
|---|
| 2934 | | - dma_addr_t sle_dma; |
|---|
| 2935 | | - |
|---|
| 2936 | 3218 | /* Allocate additional continuation packets? */ |
|---|
| 2937 | 3219 | if (avail_dsds == 0) { |
|---|
| 2938 | 3220 | /* |
|---|
| .. | .. |
|---|
| 2941 | 3223 | */ |
|---|
| 2942 | 3224 | cont_pkt = qla2x00_prep_cont_type1_iocb(vha, |
|---|
| 2943 | 3225 | ha->req_q_map[0]); |
|---|
| 2944 | | - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; |
|---|
| 3226 | + cur_dsd = cont_pkt->dsd; |
|---|
| 2945 | 3227 | avail_dsds = 5; |
|---|
| 2946 | 3228 | entry_count++; |
|---|
| 2947 | 3229 | } |
|---|
| 2948 | 3230 | |
|---|
| 2949 | | - sle_dma = sg_dma_address(sg); |
|---|
| 2950 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 2951 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 2952 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 3231 | + append_dsd64(&cur_dsd, sg); |
|---|
| 2953 | 3232 | avail_dsds--; |
|---|
| 2954 | 3233 | } |
|---|
| 2955 | 3234 | ct_iocb->entry_count = entry_count; |
|---|
| .. | .. |
|---|
| 2968 | 3247 | unsigned long flags; |
|---|
| 2969 | 3248 | struct scsi_cmnd *cmd; |
|---|
| 2970 | 3249 | uint32_t *clr_ptr; |
|---|
| 2971 | | - uint32_t index; |
|---|
| 2972 | 3250 | uint32_t handle; |
|---|
| 2973 | 3251 | uint16_t cnt; |
|---|
| 2974 | 3252 | uint16_t req_cnt; |
|---|
| 2975 | 3253 | uint16_t tot_dsds; |
|---|
| 2976 | 3254 | struct device_reg_82xx __iomem *reg; |
|---|
| 2977 | 3255 | uint32_t dbval; |
|---|
| 2978 | | - uint32_t *fcp_dl; |
|---|
| 3256 | + __be32 *fcp_dl; |
|---|
| 2979 | 3257 | uint8_t additional_cdb_len; |
|---|
| 2980 | 3258 | struct ct6_dsd *ctx; |
|---|
| 2981 | 3259 | struct scsi_qla_host *vha = sp->vha; |
|---|
| .. | .. |
|---|
| 2996 | 3274 | |
|---|
| 2997 | 3275 | /* Send marker if required */ |
|---|
| 2998 | 3276 | if (vha->marker_needed != 0) { |
|---|
| 2999 | | - if (qla2x00_marker(vha, req, |
|---|
| 3000 | | - rsp, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) { |
|---|
| 3277 | + if (qla2x00_marker(vha, ha->base_qpair, |
|---|
| 3278 | + 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) { |
|---|
| 3001 | 3279 | ql_log(ql_log_warn, vha, 0x300c, |
|---|
| 3002 | 3280 | "qla2x00_marker failed for cmd=%p.\n", cmd); |
|---|
| 3003 | 3281 | return QLA_FUNCTION_FAILED; |
|---|
| .. | .. |
|---|
| 3008 | 3286 | /* Acquire ring specific lock */ |
|---|
| 3009 | 3287 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 3010 | 3288 | |
|---|
| 3011 | | - /* Check for room in outstanding command list. */ |
|---|
| 3012 | | - handle = req->current_outstanding_cmd; |
|---|
| 3013 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 3014 | | - handle++; |
|---|
| 3015 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 3016 | | - handle = 1; |
|---|
| 3017 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 3018 | | - break; |
|---|
| 3019 | | - } |
|---|
| 3020 | | - if (index == req->num_outstanding_cmds) |
|---|
| 3289 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 3290 | + if (handle == 0) |
|---|
| 3021 | 3291 | goto queuing_error; |
|---|
| 3022 | 3292 | |
|---|
| 3023 | 3293 | /* Map the sg table so we have an accurate count of sg entries needed */ |
|---|
| .. | .. |
|---|
| 3077 | 3347 | req_cnt = 1; |
|---|
| 3078 | 3348 | |
|---|
| 3079 | 3349 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 3080 | | - cnt = (uint16_t)RD_REG_DWORD_RELAXED( |
|---|
| 3350 | + cnt = (uint16_t)rd_reg_dword_relaxed( |
|---|
| 3081 | 3351 | ®->req_q_out[0]); |
|---|
| 3082 | 3352 | if (req->ring_index < cnt) |
|---|
| 3083 | 3353 | req->cnt = cnt - req->ring_index; |
|---|
| .. | .. |
|---|
| 3088 | 3358 | goto queuing_error; |
|---|
| 3089 | 3359 | } |
|---|
| 3090 | 3360 | |
|---|
| 3091 | | - ctx = sp->u.scmd.ctx = |
|---|
| 3361 | + ctx = sp->u.scmd.ct6_ctx = |
|---|
| 3092 | 3362 | mempool_alloc(ha->ctx_mempool, GFP_ATOMIC); |
|---|
| 3093 | 3363 | if (!ctx) { |
|---|
| 3094 | 3364 | ql_log(ql_log_fatal, vha, 0x3010, |
|---|
| .. | .. |
|---|
| 3127 | 3397 | } |
|---|
| 3128 | 3398 | |
|---|
| 3129 | 3399 | cmd_pkt = (struct cmd_type_6 *)req->ring_ptr; |
|---|
| 3130 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 3400 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 3131 | 3401 | |
|---|
| 3132 | 3402 | /* Zero out remaining portion of packet. */ |
|---|
| 3133 | 3403 | /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ |
|---|
| .. | .. |
|---|
| 3165 | 3435 | |
|---|
| 3166 | 3436 | memcpy(ctx->fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); |
|---|
| 3167 | 3437 | |
|---|
| 3168 | | - fcp_dl = (uint32_t *)(ctx->fcp_cmnd->cdb + 16 + |
|---|
| 3438 | + fcp_dl = (__be32 *)(ctx->fcp_cmnd->cdb + 16 + |
|---|
| 3169 | 3439 | additional_cdb_len); |
|---|
| 3170 | 3440 | *fcp_dl = htonl((uint32_t)scsi_bufflen(cmd)); |
|---|
| 3171 | 3441 | |
|---|
| 3172 | 3442 | cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(ctx->fcp_cmnd_len); |
|---|
| 3173 | | - cmd_pkt->fcp_cmnd_dseg_address[0] = |
|---|
| 3174 | | - cpu_to_le32(LSD(ctx->fcp_cmnd_dma)); |
|---|
| 3175 | | - cmd_pkt->fcp_cmnd_dseg_address[1] = |
|---|
| 3176 | | - cpu_to_le32(MSD(ctx->fcp_cmnd_dma)); |
|---|
| 3443 | + put_unaligned_le64(ctx->fcp_cmnd_dma, |
|---|
| 3444 | + &cmd_pkt->fcp_cmnd_dseg_address); |
|---|
| 3177 | 3445 | |
|---|
| 3178 | 3446 | sp->flags |= SRB_FCP_CMND_DMA_VALID; |
|---|
| 3179 | 3447 | cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); |
|---|
| .. | .. |
|---|
| 3185 | 3453 | cmd_pkt->entry_status = (uint8_t) rsp->id; |
|---|
| 3186 | 3454 | } else { |
|---|
| 3187 | 3455 | struct cmd_type_7 *cmd_pkt; |
|---|
| 3456 | + |
|---|
| 3188 | 3457 | req_cnt = qla24xx_calc_iocbs(vha, tot_dsds); |
|---|
| 3189 | 3458 | if (req->cnt < (req_cnt + 2)) { |
|---|
| 3190 | | - cnt = (uint16_t)RD_REG_DWORD_RELAXED( |
|---|
| 3459 | + cnt = (uint16_t)rd_reg_dword_relaxed( |
|---|
| 3191 | 3460 | ®->req_q_out[0]); |
|---|
| 3192 | 3461 | if (req->ring_index < cnt) |
|---|
| 3193 | 3462 | req->cnt = cnt - req->ring_index; |
|---|
| .. | .. |
|---|
| 3199 | 3468 | goto queuing_error; |
|---|
| 3200 | 3469 | |
|---|
| 3201 | 3470 | cmd_pkt = (struct cmd_type_7 *)req->ring_ptr; |
|---|
| 3202 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 3471 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 3203 | 3472 | |
|---|
| 3204 | 3473 | /* Zero out remaining portion of packet. */ |
|---|
| 3205 | 3474 | /* tagged queuing modifier -- default is TSK_SIMPLE (0).*/ |
|---|
| .. | .. |
|---|
| 3263 | 3532 | if (ql2xdbwr) |
|---|
| 3264 | 3533 | qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, dbval); |
|---|
| 3265 | 3534 | else { |
|---|
| 3266 | | - WRT_REG_DWORD(ha->nxdb_wr_ptr, dbval); |
|---|
| 3535 | + wrt_reg_dword(ha->nxdb_wr_ptr, dbval); |
|---|
| 3267 | 3536 | wmb(); |
|---|
| 3268 | | - while (RD_REG_DWORD(ha->nxdb_rd_ptr) != dbval) { |
|---|
| 3269 | | - WRT_REG_DWORD(ha->nxdb_wr_ptr, dbval); |
|---|
| 3537 | + while (rd_reg_dword(ha->nxdb_rd_ptr) != dbval) { |
|---|
| 3538 | + wrt_reg_dword(ha->nxdb_wr_ptr, dbval); |
|---|
| 3270 | 3539 | wmb(); |
|---|
| 3271 | 3540 | } |
|---|
| 3272 | 3541 | } |
|---|
| .. | .. |
|---|
| 3285 | 3554 | if (tot_dsds) |
|---|
| 3286 | 3555 | scsi_dma_unmap(cmd); |
|---|
| 3287 | 3556 | |
|---|
| 3288 | | - if (sp->u.scmd.ctx) { |
|---|
| 3289 | | - mempool_free(sp->u.scmd.ctx, ha->ctx_mempool); |
|---|
| 3290 | | - sp->u.scmd.ctx = NULL; |
|---|
| 3557 | + if (sp->u.scmd.crc_ctx) { |
|---|
| 3558 | + mempool_free(sp->u.scmd.crc_ctx, ha->ctx_mempool); |
|---|
| 3559 | + sp->u.scmd.crc_ctx = NULL; |
|---|
| 3291 | 3560 | } |
|---|
| 3292 | 3561 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 3293 | 3562 | |
|---|
| .. | .. |
|---|
| 3304 | 3573 | memset(abt_iocb, 0, sizeof(struct abort_entry_24xx)); |
|---|
| 3305 | 3574 | abt_iocb->entry_type = ABORT_IOCB_TYPE; |
|---|
| 3306 | 3575 | abt_iocb->entry_count = 1; |
|---|
| 3307 | | - abt_iocb->handle = cpu_to_le32(MAKE_HANDLE(req->id, sp->handle)); |
|---|
| 3576 | + abt_iocb->handle = make_handle(req->id, sp->handle); |
|---|
| 3308 | 3577 | if (sp->fcport) { |
|---|
| 3309 | 3578 | abt_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
|---|
| 3310 | 3579 | abt_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; |
|---|
| .. | .. |
|---|
| 3312 | 3581 | abt_iocb->port_id[2] = sp->fcport->d_id.b.domain; |
|---|
| 3313 | 3582 | } |
|---|
| 3314 | 3583 | abt_iocb->handle_to_abort = |
|---|
| 3315 | | - cpu_to_le32(MAKE_HANDLE(aio->u.abt.req_que_no, |
|---|
| 3316 | | - aio->u.abt.cmd_hndl)); |
|---|
| 3584 | + make_handle(le16_to_cpu(aio->u.abt.req_que_no), |
|---|
| 3585 | + aio->u.abt.cmd_hndl); |
|---|
| 3317 | 3586 | abt_iocb->vp_index = vha->vp_idx; |
|---|
| 3318 | | - abt_iocb->req_que_no = cpu_to_le16(aio->u.abt.req_que_no); |
|---|
| 3587 | + abt_iocb->req_que_no = aio->u.abt.req_que_no; |
|---|
| 3319 | 3588 | /* Send the command to the firmware */ |
|---|
| 3320 | 3589 | wmb(); |
|---|
| 3321 | 3590 | } |
|---|
| .. | .. |
|---|
| 3330 | 3599 | sz = min(ARRAY_SIZE(mbx->mb), ARRAY_SIZE(sp->u.iocb_cmd.u.mbx.out_mb)); |
|---|
| 3331 | 3600 | |
|---|
| 3332 | 3601 | for (i = 0; i < sz; i++) |
|---|
| 3333 | | - mbx->mb[i] = cpu_to_le16(sp->u.iocb_cmd.u.mbx.out_mb[i]); |
|---|
| 3602 | + mbx->mb[i] = sp->u.iocb_cmd.u.mbx.out_mb[i]; |
|---|
| 3334 | 3603 | } |
|---|
| 3335 | 3604 | |
|---|
| 3336 | 3605 | static void |
|---|
| .. | .. |
|---|
| 3354 | 3623 | nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle; |
|---|
| 3355 | 3624 | if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) { |
|---|
| 3356 | 3625 | nack->u.isp24.flags = ntfy->u.isp24.flags & |
|---|
| 3357 | | - cpu_to_le32(NOTIFY24XX_FLAGS_PUREX_IOCB); |
|---|
| 3626 | + cpu_to_le16(NOTIFY24XX_FLAGS_PUREX_IOCB); |
|---|
| 3358 | 3627 | } |
|---|
| 3359 | 3628 | nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id; |
|---|
| 3360 | 3629 | nack->u.isp24.status = ntfy->u.isp24.status; |
|---|
| .. | .. |
|---|
| 3372 | 3641 | /* |
|---|
| 3373 | 3642 | * Build NVME LS request |
|---|
| 3374 | 3643 | */ |
|---|
| 3375 | | -static int |
|---|
| 3644 | +static void |
|---|
| 3376 | 3645 | qla_nvme_ls(srb_t *sp, struct pt_ls4_request *cmd_pkt) |
|---|
| 3377 | 3646 | { |
|---|
| 3378 | 3647 | struct srb_iocb *nvme; |
|---|
| 3379 | | - int rval = QLA_SUCCESS; |
|---|
| 3380 | 3648 | |
|---|
| 3381 | 3649 | nvme = &sp->u.iocb_cmd; |
|---|
| 3382 | 3650 | cmd_pkt->entry_type = PT_LS4_REQUEST; |
|---|
| 3383 | 3651 | cmd_pkt->entry_count = 1; |
|---|
| 3384 | | - cmd_pkt->control_flags = CF_LS4_ORIGINATOR << CF_LS4_SHIFT; |
|---|
| 3652 | + cmd_pkt->control_flags = cpu_to_le16(CF_LS4_ORIGINATOR << CF_LS4_SHIFT); |
|---|
| 3385 | 3653 | |
|---|
| 3386 | 3654 | cmd_pkt->timeout = cpu_to_le16(nvme->u.nvme.timeout_sec); |
|---|
| 3387 | 3655 | cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); |
|---|
| 3388 | 3656 | cmd_pkt->vp_index = sp->fcport->vha->vp_idx; |
|---|
| 3389 | 3657 | |
|---|
| 3390 | | - cmd_pkt->tx_dseg_count = 1; |
|---|
| 3391 | | - cmd_pkt->tx_byte_count = nvme->u.nvme.cmd_len; |
|---|
| 3392 | | - cmd_pkt->dseg0_len = nvme->u.nvme.cmd_len; |
|---|
| 3393 | | - cmd_pkt->dseg0_address[0] = cpu_to_le32(LSD(nvme->u.nvme.cmd_dma)); |
|---|
| 3394 | | - cmd_pkt->dseg0_address[1] = cpu_to_le32(MSD(nvme->u.nvme.cmd_dma)); |
|---|
| 3658 | + cmd_pkt->tx_dseg_count = cpu_to_le16(1); |
|---|
| 3659 | + cmd_pkt->tx_byte_count = cpu_to_le32(nvme->u.nvme.cmd_len); |
|---|
| 3660 | + cmd_pkt->dsd[0].length = cpu_to_le32(nvme->u.nvme.cmd_len); |
|---|
| 3661 | + put_unaligned_le64(nvme->u.nvme.cmd_dma, &cmd_pkt->dsd[0].address); |
|---|
| 3395 | 3662 | |
|---|
| 3396 | | - cmd_pkt->rx_dseg_count = 1; |
|---|
| 3397 | | - cmd_pkt->rx_byte_count = nvme->u.nvme.rsp_len; |
|---|
| 3398 | | - cmd_pkt->dseg1_len = nvme->u.nvme.rsp_len; |
|---|
| 3399 | | - cmd_pkt->dseg1_address[0] = cpu_to_le32(LSD(nvme->u.nvme.rsp_dma)); |
|---|
| 3400 | | - cmd_pkt->dseg1_address[1] = cpu_to_le32(MSD(nvme->u.nvme.rsp_dma)); |
|---|
| 3401 | | - |
|---|
| 3402 | | - return rval; |
|---|
| 3663 | + cmd_pkt->rx_dseg_count = cpu_to_le16(1); |
|---|
| 3664 | + cmd_pkt->rx_byte_count = cpu_to_le32(nvme->u.nvme.rsp_len); |
|---|
| 3665 | + cmd_pkt->dsd[1].length = cpu_to_le32(nvme->u.nvme.rsp_len); |
|---|
| 3666 | + put_unaligned_le64(nvme->u.nvme.rsp_dma, &cmd_pkt->dsd[1].address); |
|---|
| 3403 | 3667 | } |
|---|
| 3404 | 3668 | |
|---|
| 3405 | 3669 | static void |
|---|
| .. | .. |
|---|
| 3439 | 3703 | int |
|---|
| 3440 | 3704 | qla2x00_start_sp(srb_t *sp) |
|---|
| 3441 | 3705 | { |
|---|
| 3442 | | - int rval; |
|---|
| 3706 | + int rval = QLA_SUCCESS; |
|---|
| 3443 | 3707 | scsi_qla_host_t *vha = sp->vha; |
|---|
| 3444 | 3708 | struct qla_hw_data *ha = vha->hw; |
|---|
| 3709 | + struct qla_qpair *qp = sp->qpair; |
|---|
| 3445 | 3710 | void *pkt; |
|---|
| 3446 | 3711 | unsigned long flags; |
|---|
| 3447 | 3712 | |
|---|
| 3448 | | - rval = QLA_FUNCTION_FAILED; |
|---|
| 3449 | | - spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 3450 | | - pkt = qla2x00_alloc_iocbs(vha, sp); |
|---|
| 3713 | + spin_lock_irqsave(qp->qp_lock_ptr, flags); |
|---|
| 3714 | + pkt = __qla2x00_alloc_iocbs(sp->qpair, sp); |
|---|
| 3451 | 3715 | if (!pkt) { |
|---|
| 3716 | + rval = EAGAIN; |
|---|
| 3452 | 3717 | ql_log(ql_log_warn, vha, 0x700c, |
|---|
| 3453 | 3718 | "qla2x00_alloc_iocbs failed.\n"); |
|---|
| 3454 | 3719 | goto done; |
|---|
| 3455 | 3720 | } |
|---|
| 3456 | 3721 | |
|---|
| 3457 | | - rval = QLA_SUCCESS; |
|---|
| 3458 | 3722 | switch (sp->type) { |
|---|
| 3459 | 3723 | case SRB_LOGIN_CMD: |
|---|
| 3460 | 3724 | IS_FWI2_CAPABLE(ha) ? |
|---|
| .. | .. |
|---|
| 3524 | 3788 | break; |
|---|
| 3525 | 3789 | } |
|---|
| 3526 | 3790 | |
|---|
| 3791 | + if (sp->start_timer) |
|---|
| 3792 | + add_timer(&sp->u.iocb_cmd.timer); |
|---|
| 3793 | + |
|---|
| 3527 | 3794 | wmb(); |
|---|
| 3528 | | - qla2x00_start_iocbs(vha, ha->req_q_map[0]); |
|---|
| 3795 | + qla2x00_start_iocbs(vha, qp->req); |
|---|
| 3529 | 3796 | done: |
|---|
| 3530 | | - spin_unlock_irqrestore(&ha->hardware_lock, flags); |
|---|
| 3797 | + spin_unlock_irqrestore(qp->qp_lock_ptr, flags); |
|---|
| 3531 | 3798 | return rval; |
|---|
| 3532 | 3799 | } |
|---|
| 3533 | 3800 | |
|---|
| .. | .. |
|---|
| 3536 | 3803 | struct cmd_bidir *cmd_pkt, uint32_t tot_dsds) |
|---|
| 3537 | 3804 | { |
|---|
| 3538 | 3805 | uint16_t avail_dsds; |
|---|
| 3539 | | - uint32_t *cur_dsd; |
|---|
| 3806 | + struct dsd64 *cur_dsd; |
|---|
| 3540 | 3807 | uint32_t req_data_len = 0; |
|---|
| 3541 | 3808 | uint32_t rsp_data_len = 0; |
|---|
| 3542 | 3809 | struct scatterlist *sg; |
|---|
| .. | .. |
|---|
| 3545 | 3812 | struct bsg_job *bsg_job = sp->u.bsg_job; |
|---|
| 3546 | 3813 | |
|---|
| 3547 | 3814 | /*Update entry type to indicate bidir command */ |
|---|
| 3548 | | - *((uint32_t *)(&cmd_pkt->entry_type)) = |
|---|
| 3549 | | - cpu_to_le32(COMMAND_BIDIRECTIONAL); |
|---|
| 3815 | + put_unaligned_le32(COMMAND_BIDIRECTIONAL, &cmd_pkt->entry_type); |
|---|
| 3550 | 3816 | |
|---|
| 3551 | 3817 | /* Set the transfer direction, in this set both flags |
|---|
| 3552 | 3818 | * Also set the BD_WRAP_BACK flag, firmware will take care |
|---|
| .. | .. |
|---|
| 3572 | 3838 | * are bundled in continuation iocb |
|---|
| 3573 | 3839 | */ |
|---|
| 3574 | 3840 | avail_dsds = 1; |
|---|
| 3575 | | - cur_dsd = (uint32_t *)&cmd_pkt->fcp_data_dseg_address; |
|---|
| 3841 | + cur_dsd = &cmd_pkt->fcp_dsd; |
|---|
| 3576 | 3842 | |
|---|
| 3577 | 3843 | index = 0; |
|---|
| 3578 | 3844 | |
|---|
| 3579 | 3845 | for_each_sg(bsg_job->request_payload.sg_list, sg, |
|---|
| 3580 | 3846 | bsg_job->request_payload.sg_cnt, index) { |
|---|
| 3581 | | - dma_addr_t sle_dma; |
|---|
| 3582 | 3847 | cont_a64_entry_t *cont_pkt; |
|---|
| 3583 | 3848 | |
|---|
| 3584 | 3849 | /* Allocate additional continuation packets */ |
|---|
| .. | .. |
|---|
| 3587 | 3852 | * 5 DSDS |
|---|
| 3588 | 3853 | */ |
|---|
| 3589 | 3854 | cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); |
|---|
| 3590 | | - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; |
|---|
| 3855 | + cur_dsd = cont_pkt->dsd; |
|---|
| 3591 | 3856 | avail_dsds = 5; |
|---|
| 3592 | 3857 | entry_count++; |
|---|
| 3593 | 3858 | } |
|---|
| 3594 | | - sle_dma = sg_dma_address(sg); |
|---|
| 3595 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 3596 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 3597 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 3859 | + append_dsd64(&cur_dsd, sg); |
|---|
| 3598 | 3860 | avail_dsds--; |
|---|
| 3599 | 3861 | } |
|---|
| 3600 | 3862 | /* For read request DSD will always goes to continuation IOCB |
|---|
| .. | .. |
|---|
| 3604 | 3866 | */ |
|---|
| 3605 | 3867 | for_each_sg(bsg_job->reply_payload.sg_list, sg, |
|---|
| 3606 | 3868 | bsg_job->reply_payload.sg_cnt, index) { |
|---|
| 3607 | | - dma_addr_t sle_dma; |
|---|
| 3608 | 3869 | cont_a64_entry_t *cont_pkt; |
|---|
| 3609 | 3870 | |
|---|
| 3610 | 3871 | /* Allocate additional continuation packets */ |
|---|
| .. | .. |
|---|
| 3613 | 3874 | * 5 DSDS |
|---|
| 3614 | 3875 | */ |
|---|
| 3615 | 3876 | cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); |
|---|
| 3616 | | - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; |
|---|
| 3877 | + cur_dsd = cont_pkt->dsd; |
|---|
| 3617 | 3878 | avail_dsds = 5; |
|---|
| 3618 | 3879 | entry_count++; |
|---|
| 3619 | 3880 | } |
|---|
| 3620 | | - sle_dma = sg_dma_address(sg); |
|---|
| 3621 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
|---|
| 3622 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
|---|
| 3623 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
|---|
| 3881 | + append_dsd64(&cur_dsd, sg); |
|---|
| 3624 | 3882 | avail_dsds--; |
|---|
| 3625 | 3883 | } |
|---|
| 3626 | 3884 | /* This value should be same as number of IOCB required for this cmd */ |
|---|
| .. | .. |
|---|
| 3634 | 3892 | struct qla_hw_data *ha = vha->hw; |
|---|
| 3635 | 3893 | unsigned long flags; |
|---|
| 3636 | 3894 | uint32_t handle; |
|---|
| 3637 | | - uint32_t index; |
|---|
| 3638 | 3895 | uint16_t req_cnt; |
|---|
| 3639 | 3896 | uint16_t cnt; |
|---|
| 3640 | 3897 | uint32_t *clr_ptr; |
|---|
| .. | .. |
|---|
| 3650 | 3907 | |
|---|
| 3651 | 3908 | /* Send marker if required */ |
|---|
| 3652 | 3909 | if (vha->marker_needed != 0) { |
|---|
| 3653 | | - if (qla2x00_marker(vha, req, |
|---|
| 3654 | | - rsp, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) |
|---|
| 3910 | + if (qla2x00_marker(vha, ha->base_qpair, |
|---|
| 3911 | + 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) |
|---|
| 3655 | 3912 | return EXT_STATUS_MAILBOX; |
|---|
| 3656 | 3913 | vha->marker_needed = 0; |
|---|
| 3657 | 3914 | } |
|---|
| .. | .. |
|---|
| 3659 | 3916 | /* Acquire ring specific lock */ |
|---|
| 3660 | 3917 | spin_lock_irqsave(&ha->hardware_lock, flags); |
|---|
| 3661 | 3918 | |
|---|
| 3662 | | - /* Check for room in outstanding command list. */ |
|---|
| 3663 | | - handle = req->current_outstanding_cmd; |
|---|
| 3664 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
|---|
| 3665 | | - handle++; |
|---|
| 3666 | | - if (handle == req->num_outstanding_cmds) |
|---|
| 3667 | | - handle = 1; |
|---|
| 3668 | | - if (!req->outstanding_cmds[handle]) |
|---|
| 3669 | | - break; |
|---|
| 3670 | | - } |
|---|
| 3671 | | - |
|---|
| 3672 | | - if (index == req->num_outstanding_cmds) { |
|---|
| 3919 | + handle = qla2xxx_get_next_handle(req); |
|---|
| 3920 | + if (handle == 0) { |
|---|
| 3673 | 3921 | rval = EXT_STATUS_BUSY; |
|---|
| 3674 | 3922 | goto queuing_error; |
|---|
| 3675 | 3923 | } |
|---|
| .. | .. |
|---|
| 3680 | 3928 | /* Check for room on request queue. */ |
|---|
| 3681 | 3929 | if (req->cnt < req_cnt + 2) { |
|---|
| 3682 | 3930 | cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr : |
|---|
| 3683 | | - RD_REG_DWORD_RELAXED(req->req_q_out); |
|---|
| 3931 | + rd_reg_dword_relaxed(req->req_q_out); |
|---|
| 3684 | 3932 | if (req->ring_index < cnt) |
|---|
| 3685 | 3933 | req->cnt = cnt - req->ring_index; |
|---|
| 3686 | 3934 | else |
|---|
| .. | .. |
|---|
| 3693 | 3941 | } |
|---|
| 3694 | 3942 | |
|---|
| 3695 | 3943 | cmd_pkt = (struct cmd_bidir *)req->ring_ptr; |
|---|
| 3696 | | - cmd_pkt->handle = MAKE_HANDLE(req->id, handle); |
|---|
| 3944 | + cmd_pkt->handle = make_handle(req->id, handle); |
|---|
| 3697 | 3945 | |
|---|
| 3698 | 3946 | /* Zero out remaining portion of packet. */ |
|---|
| 3699 | 3947 | /* tagged queuing modifier -- default is TSK_SIMPLE (0).*/ |
|---|