diff options
Diffstat (limited to 'drivers/scsi/bnx2i/bnx2i_hwi.c')
-rw-r--r-- | drivers/scsi/bnx2i/bnx2i_hwi.c | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index 5c8d7630c13e..18352ff82101 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c | |||
@@ -11,6 +11,7 @@ | |||
11 | * Written by: Anil Veerabhadrappa (anilgv@broadcom.com) | 11 | * Written by: Anil Veerabhadrappa (anilgv@broadcom.com) |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/gfp.h> | ||
14 | #include <scsi/scsi_tcq.h> | 15 | #include <scsi/scsi_tcq.h> |
15 | #include <scsi/libiscsi.h> | 16 | #include <scsi/libiscsi.h> |
16 | #include "bnx2i.h" | 17 | #include "bnx2i.h" |
@@ -133,20 +134,38 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action) | |||
133 | { | 134 | { |
134 | struct bnx2i_5771x_cq_db *cq_db; | 135 | struct bnx2i_5771x_cq_db *cq_db; |
135 | u16 cq_index; | 136 | u16 cq_index; |
137 | u16 next_index; | ||
138 | u32 num_active_cmds; | ||
136 | 139 | ||
140 | |||
141 | /* Coalesce CQ entries only on 10G devices */ | ||
137 | if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) | 142 | if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) |
138 | return; | 143 | return; |
139 | 144 | ||
145 | /* Do not update CQ DB multiple times before firmware writes | ||
146 | * '0xFFFF' to CQDB->SQN field. Deviation may cause spurious | ||
147 | * interrupts and other unwanted results | ||
148 | */ | ||
149 | cq_db = (struct bnx2i_5771x_cq_db *) ep->qp.cq_pgtbl_virt; | ||
150 | if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF) | ||
151 | return; | ||
152 | |||
140 | if (action == CNIC_ARM_CQE) { | 153 | if (action == CNIC_ARM_CQE) { |
141 | cq_index = ep->qp.cqe_exp_seq_sn + | 154 | num_active_cmds = ep->num_active_cmds; |
142 | ep->num_active_cmds / event_coal_div; | 155 | if (num_active_cmds <= event_coal_min) |
143 | cq_index %= (ep->qp.cqe_size * 2 + 1); | 156 | next_index = 1; |
144 | if (!cq_index) { | 157 | else |
158 | next_index = event_coal_min + | ||
159 | (num_active_cmds - event_coal_min) / event_coal_div; | ||
160 | if (!next_index) | ||
161 | next_index = 1; | ||
162 | cq_index = ep->qp.cqe_exp_seq_sn + next_index - 1; | ||
163 | if (cq_index > ep->qp.cqe_size * 2) | ||
164 | cq_index -= ep->qp.cqe_size * 2; | ||
165 | if (!cq_index) | ||
145 | cq_index = 1; | 166 | cq_index = 1; |
146 | cq_db = (struct bnx2i_5771x_cq_db *) | 167 | |
147 | ep->qp.cq_pgtbl_virt; | 168 | cq_db->sqn[0] = cq_index; |
148 | cq_db->sqn[0] = cq_index; | ||
149 | } | ||
150 | } | 169 | } |
151 | } | 170 | } |
152 | 171 | ||
@@ -366,6 +385,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, | |||
366 | struct bnx2i_cmd *bnx2i_cmd; | 385 | struct bnx2i_cmd *bnx2i_cmd; |
367 | struct bnx2i_tmf_request *tmfabort_wqe; | 386 | struct bnx2i_tmf_request *tmfabort_wqe; |
368 | u32 dword; | 387 | u32 dword; |
388 | u32 scsi_lun[2]; | ||
369 | 389 | ||
370 | bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data; | 390 | bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data; |
371 | tmfabort_hdr = (struct iscsi_tm *)mtask->hdr; | 391 | tmfabort_hdr = (struct iscsi_tm *)mtask->hdr; |
@@ -376,27 +396,35 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn, | |||
376 | tmfabort_wqe->op_attr = 0; | 396 | tmfabort_wqe->op_attr = 0; |
377 | tmfabort_wqe->op_attr = | 397 | tmfabort_wqe->op_attr = |
378 | ISCSI_TMF_REQUEST_ALWAYS_ONE | ISCSI_TM_FUNC_ABORT_TASK; | 398 | ISCSI_TMF_REQUEST_ALWAYS_ONE | ISCSI_TM_FUNC_ABORT_TASK; |
379 | tmfabort_wqe->lun[0] = be32_to_cpu(tmfabort_hdr->lun[0]); | ||
380 | tmfabort_wqe->lun[1] = be32_to_cpu(tmfabort_hdr->lun[1]); | ||
381 | 399 | ||
382 | tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14)); | 400 | tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14)); |
383 | tmfabort_wqe->reserved2 = 0; | 401 | tmfabort_wqe->reserved2 = 0; |
384 | tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn); | 402 | tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn); |
385 | 403 | ||
386 | ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt); | 404 | ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt); |
387 | if (!ctask || ctask->sc) | 405 | if (!ctask || !ctask->sc) |
388 | /* | 406 | /* |
389 | * the iscsi layer must have completed the cmd while this | 407 | * the iscsi layer must have completed the cmd while this |
390 | * was starting up. | 408 | * was starting up. |
409 | * | ||
410 | * Note: In the case of a SCSI cmd timeout, the task's sc | ||
411 | * is still active; hence ctask->sc != 0 | ||
412 | * In this case, the task must be aborted | ||
391 | */ | 413 | */ |
392 | return 0; | 414 | return 0; |
415 | |||
393 | ref_sc = ctask->sc; | 416 | ref_sc = ctask->sc; |
394 | 417 | ||
418 | /* Retrieve LUN directly from the ref_sc */ | ||
419 | int_to_scsilun(ref_sc->device->lun, (struct scsi_lun *) scsi_lun); | ||
420 | tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]); | ||
421 | tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]); | ||
422 | |||
395 | if (ref_sc->sc_data_direction == DMA_TO_DEVICE) | 423 | if (ref_sc->sc_data_direction == DMA_TO_DEVICE) |
396 | dword = (ISCSI_TASK_TYPE_WRITE << ISCSI_CMD_REQUEST_TYPE_SHIFT); | 424 | dword = (ISCSI_TASK_TYPE_WRITE << ISCSI_CMD_REQUEST_TYPE_SHIFT); |
397 | else | 425 | else |
398 | dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT); | 426 | dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT); |
399 | tmfabort_wqe->ref_itt = (dword | tmfabort_hdr->rtt); | 427 | tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK)); |
400 | tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn); | 428 | tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn); |
401 | 429 | ||
402 | tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma; | 430 | tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma; |