23 qla2x00_get_cmd_direction(
srb_t *
sp)
34 vha->
qla_stats.output_bytes += scsi_bufflen(cmd);
37 vha->
qla_stats.input_bytes += scsi_bufflen(cmd);
57 iocbs += (dsds - 3) / 7;
79 iocbs += (dsds - 2) / 5;
145 qla24xx_configure_prot_mode(
srb_t *sp,
uint16_t *fw_prot_opts)
154 switch (scsi_get_prot_op(cmd)) {
179 return scsi_prot_sg_count(cmd);
224 if (avail_dsds == 0) {
229 cont_pkt = qla2x00_prep_cont_type0_iocb(vha);
283 if (avail_dsds == 0) {
288 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->
req);
354 if (handle == MAX_OUTSTANDING_COMMANDS)
359 if (index == MAX_OUTSTANDING_COMMANDS)
363 if (scsi_sg_count(cmd)) {
374 req_cnt = ha->
isp_ops->calc_req_entries(tot_dsds);
375 if (req->
cnt < (req_cnt + 2)) {
383 if (req->
cnt < (req_cnt + 2))
406 if (scsi_populate_tag_msg(cmd, tag)) {
428 ha->
isp_ops->build_iocbs(sp, cmd_pkt, tot_dsds);
449 if (vha->
flags.process_response_queue &&
453 spin_unlock_irqrestore(&ha->hardware_lock, flags);
460 spin_unlock_irqrestore(&ha->hardware_lock, flags);
526 "Failed to allocate Marker IOCB.\n");
539 host_to_fcp_swap(mrk24->
lun,
sizeof(mrk24->
lun));
560 unsigned long flags = 0;
563 ret = __qla2x00_marker(vha, req, rsp, loop_id, lun, type);
564 spin_unlock_irqrestore(&vha->
hw->hardware_lock, flags);
579 if (__qla2x00_marker(vha, vha->
req, vha->
req->rsp, 0, 0,
607 iocbs += (dsds - 1) / 5;
650 vha->
qla_stats.output_bytes += scsi_bufflen(cmd);
654 vha->
qla_stats.input_bytes += scsi_bufflen(cmd);
657 cur_seg = scsi_sglist(cmd);
663 tot_dsds -= avail_dsds;
766 vha->
qla_stats.output_bytes += scsi_bufflen(cmd);
770 vha->
qla_stats.input_bytes += scsi_bufflen(cmd);
784 if (avail_dsds == 0) {
789 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->
req);
815 unsigned int protcnt)
819 switch (scsi_get_prot_type(cmd)) {
826 (0xffffffff & scsi_get_lba(cmd)));
828 if (!qla2x00_hba_err_chk_enabled(sp))
847 (0xffffffff & scsi_get_lba(cmd)));
849 if (!qla2x00_hba_err_chk_enabled(sp))
872 (0xffffffff & scsi_get_lba(cmd)));
877 if (!qla2x00_hba_err_chk_enabled(sp))
911 uint32_t cumulative_partial, sg_len;
925 if ((cumulative_partial + (sg_len - sgx->
bytes_consumed)) >= blk_sz) {
926 sgx->
dma_len = (blk_sz - cumulative_partial);
964 uint32_t sle_dma_len, tot_prot_dma_len = 0;
967 prot_int = cmd->
device->sector_size;
971 sgx.
cur_sg = scsi_sglist(cmd);
974 sg_prot = scsi_prot_sglist(cmd);
976 while (qla24xx_get_one_block_sg(prot_int, &sgx, &partial)) {
982 if (avail_dsds == 0) {
985 dsd_list_len = (avail_dsds + 1) * 12;
986 used_dsds -= avail_dsds;
1015 *cur_dsd++ = dsd_list_len;
1028 tot_prot_dma_len += sle_dma_len;
1029 if (tot_prot_dma_len ==
sg_dma_len(sg_prot)) {
1030 tot_prot_dma_len = 0;
1035 goto alloc_and_fill;
1063 if (avail_dsds == 0) {
1066 dsd_list_len = (avail_dsds + 1) * 12;
1067 used_dsds -= avail_dsds;
1096 *cur_dsd++ = dsd_list_len;
1134 if (avail_dsds == 0) {
1137 dsd_list_len = (avail_dsds + 1) * 12;
1138 used_dsds -= avail_dsds;
1167 *cur_dsd++ = dsd_list_len;
1210 uint8_t additional_fcpcdb_len;
1227 data_bytes = scsi_bufflen(cmd);
1251 crc_ctx_pkt = sp->
u.
scmd.ctx =
1255 goto crc_queuing_error;
1258 clr_ptr = (
uint8_t *)crc_ctx_pkt;
1259 memset(clr_ptr, 0,
sizeof(*crc_ctx_pkt));
1268 INIT_LIST_HEAD(&crc_ctx_pkt->
dsd_list);
1271 &crc_ctx_pkt->
ref_tag, tot_prot_dsds);
1279 additional_fcpcdb_len = cmd->
cmd_len - 16;
1280 if ((cmd->
cmd_len % 4) != 0) {
1282 goto crc_queuing_error;
1284 fcp_cmnd_len = 12 + cmd->
cmd_len + 4;
1286 additional_fcpcdb_len = 0;
1287 fcp_cmnd_len = 12 + 16 + 4;
1310 if (scsi_populate_tag_msg(cmd, tag)) {
1330 blk_size = cmd->
device->sector_size;
1331 dif_bytes = (data_bytes /
blk_size) * 8;
1336 total_bytes = data_bytes;
1337 data_bytes += dif_bytes;
1344 total_bytes = data_bytes + dif_bytes;
1350 if (!qla2x00_hba_err_chk_enabled(sp))
1351 fw_prot_opts |= 0x10;
1358 else if (scsi_get_prot_type(
GET_CMD_SP(sp)) ==
1385 additional_fcpcdb_len);
1386 *fcp_dl =
htonl(total_bytes);
1397 if (!bundling && tot_prot_dsds) {
1398 if (qla24xx_walk_and_build_sglist_no_difb(ha, sp,
1400 goto crc_queuing_error;
1401 }
else if (qla24xx_walk_and_build_sglist(ha, sp, cur_dsd,
1402 (tot_dsds - tot_prot_dsds)))
1403 goto crc_queuing_error;
1405 if (bundling && tot_prot_dsds) {
1407 cur_seg = scsi_prot_sglist(cmd);
1411 if (qla24xx_walk_and_build_prot_sglist(ha, sp, cur_dsd,
1413 goto crc_queuing_error;
1433 unsigned long flags;
1451 qla25xx_set_que(sp, &rsp);
1472 if (handle == MAX_OUTSTANDING_COMMANDS)
1477 if (index == MAX_OUTSTANDING_COMMANDS) {
1482 if (scsi_sg_count(cmd)) {
1492 if (req->
cnt < (req_cnt + 2)) {
1500 if (req->
cnt < (req_cnt + 2))
1509 req->
cnt -= req_cnt;
1528 host_to_fcp_swap((
uint8_t *)&cmd_pkt->
lun,
sizeof(cmd_pkt->
lun));
1531 if (scsi_populate_tag_msg(cmd, tag)) {
1571 if (vha->
flags.process_response_queue &&
1575 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1582 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1598 unsigned long flags;
1615 #define QDSS_GOT_Q_SPACE BIT_0
1625 qla25xx_set_que(sp, &rsp);
1646 if (handle == MAX_OUTSTANDING_COMMANDS)
1652 if (index == MAX_OUTSTANDING_COMMANDS)
1657 if (scsi_sg_count(cmd)) {
1672 sgx.
cur_sg = scsi_sglist(cmd);
1676 while (qla24xx_get_one_block_sg(
1677 cmd->
device->sector_size, &sgx, &partial))
1687 if (qla24xx_configure_prot_mode(sp, &fw_prot_opts)) {
1697 nseg = scsi_bufflen(cmd) / cmd->
device->sector_size;
1705 tot_prot_dsds = nseg;
1707 if (req->
cnt < (req_cnt + 2)) {
1715 if (req->
cnt < (req_cnt + 2))
1726 req->
cnt -= req_cnt;
1742 host_to_fcp_swap((
uint8_t *)&cmd_pkt->
lun,
sizeof(cmd_pkt->
lun));
1749 req->
ring_ptr, tot_dsds, tot_prot_dsds, fw_prot_opts) !=
1772 if (vha->
flags.process_response_queue &&
1776 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1783 req->
cnt += req_cnt;
1787 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1792 static void qla25xx_set_que(
srb_t *sp,
struct rsp_que **rsp)
1798 if (ha->
flags.cpu_affinity_enabled && affinity >= 0 &&
1821 goto skip_cmd_array;
1827 if (handle == MAX_OUTSTANDING_COMMANDS)
1832 if (index == MAX_OUTSTANDING_COMMANDS) {
1834 "No room on outstanding cmd array.\n");
1845 req_cnt = sp->
iocbs;
1849 if (req->
cnt < req_cnt) {
1857 cnt = qla2x00_debounce_register(
1866 if (req->
cnt < req_cnt)
1870 req->
cnt -= req_cnt;
1918 sp->
fcport->d_id.b.al_pa);
1948 sp->
fcport->d_id.b.al_pa);
1994 flags = iocb->
u.
tmf.flags;
1995 lun = iocb->
u.
tmf.lun;
2033 bsg_job->
request->rqst_data.r_els.els_code :
2034 bsg_job->
request->rqst_data.h_els.command_code;
2070 int loop_iterartion = 0;
2071 int cont_iocb_prsnt = 0;
2113 if (avail_dsds == 0) {
2118 cont_pkt = qla2x00_prep_cont_type1_iocb(vha,
2119 vha->
hw->req_q_map[0]);
2122 cont_iocb_prsnt = 1;
2147 int loop_iterartion = 0;
2148 int cont_iocb_prsnt = 0;
2149 int entry_count = 1;
2186 if (avail_dsds == 0) {
2191 cont_pkt = qla2x00_prep_cont_type1_iocb(vha,
2195 cont_iocb_prsnt = 1;
2219 unsigned long flags;
2248 dbval = 0x04 | (ha->
portnum << 5);
2255 "qla2x00_marker failed for cmd=%p.\n", cmd);
2268 if (handle == MAX_OUTSTANDING_COMMANDS)
2273 if (index == MAX_OUTSTANDING_COMMANDS)
2277 if (scsi_sg_count(cmd)) {
2296 "Num of DSD list %d is than %d for cmd=%p.\n",
2302 if (more_dsd_lists <= ha->gbl_dsd_avail)
2303 goto sufficient_dsds;
2307 for (i = 0; i < more_dsd_lists; i++) {
2311 "Failed to allocate memory for dsd_dma "
2312 "for cmd=%p.\n", cmd);
2321 "Failed to allocate memory for dsd_addr "
2322 "for cmd=%p.\n", cmd);
2332 if (req->
cnt < (req_cnt + 2)) {
2340 if (req->
cnt < (req_cnt + 2))
2344 ctx = sp->
u.
scmd.ctx =
2348 "Failed to allocate ctx for cmd=%p.\n", cmd);
2357 "Failed to allocate fcp_cmnd for cmd=%p.\n", cmd);
2366 additional_cdb_len = cmd->
cmd_len - 16;
2367 if ((cmd->
cmd_len % 4) != 0) {
2372 "scsi cmd len %d not multiple of 4 "
2373 "for cmd=%p.\n", cmd->
cmd_len, cmd);
2374 goto queuing_error_fcp_cmnd;
2378 additional_cdb_len = 0;
2399 if (qla24xx_build_scsi_type_6_iocbs(sp, cmd_pkt, tot_dsds))
2400 goto queuing_error_fcp_cmnd;
2403 host_to_fcp_swap((
uint8_t *)&cmd_pkt->
lun,
sizeof(cmd_pkt->
lun));
2411 ctx->
fcp_cmnd->additional_cdb_len |= 1;
2413 ctx->
fcp_cmnd->additional_cdb_len |= 2;
2418 if (scsi_populate_tag_msg(cmd, tag)) {
2432 if (ha->
flags.fcp_prio_enabled)
2434 sp->
fcport->fcp_prio << 3;
2439 additional_cdb_len);
2459 if (req->
cnt < (req_cnt + 2)) {
2468 if (req->
cnt < (req_cnt + 2))
2489 sizeof(cmd_pkt->
lun));
2494 if (scsi_populate_tag_msg(cmd, tag)) {
2506 if (ha->
flags.fcp_prio_enabled)
2531 req->
cnt -= req_cnt;
2546 dbval = dbval | (req->
id << 8) | (req->
ring_index << 16);
2563 if (vha->
flags.process_response_queue &&
2567 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2570 queuing_error_fcp_cmnd:
2576 if (sp->
u.
scmd.ctx) {
2580 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2591 unsigned long flags;
2598 "qla2x00_alloc_iocbs failed.\n");
2606 qla24xx_login_iocb(sp, pkt) :
2607 qla2x00_login_iocb(sp, pkt);
2611 qla24xx_logout_iocb(sp, pkt) :
2612 qla2x00_logout_iocb(sp, pkt);
2616 qla24xx_els_iocb(sp, pkt);
2620 qla24xx_ct_iocb(sp, pkt) :
2621 qla2x00_ct_iocb(sp, pkt);
2625 qla24xx_adisc_iocb(sp, pkt) :
2626 qla2x00_adisc_iocb(sp, pkt);
2629 qla24xx_tm_iocb(sp, pkt);
2638 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2652 int entry_count = 1;
2674 vha->
bidi_stats.transfer_bytes += req_data_len;
2691 if (avail_dsds == 0) {
2695 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->
req);
2717 if (avail_dsds == 0) {
2721 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->
req);
2741 unsigned long flags;
2773 if (handle == MAX_OUTSTANDING_COMMANDS)
2779 if (index == MAX_OUTSTANDING_COMMANDS) {
2788 if (req->
cnt < req_cnt + 2) {
2796 cnt = qla2x00_debounce_register(
2805 if (req->
cnt < req_cnt + 2) {
2824 qla25xx_build_bidir_iocb(sp, vha, cmd_pkt, tot_dsds);
2830 req->
cnt -= req_cnt;
2836 spin_unlock_irqrestore(&ha->hardware_lock, flags);