aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJayamohan Kallickal <jayamohank@gmail.com>2013-04-05 23:38:26 -0400
committerJames Bottomley <JBottomley@Parallels.com>2013-05-02 11:08:38 -0400
commit2c9dfd364929585e0685f4f69d10130f3ca7acdd (patch)
treebac479932a2834a8a9356833c802ebf16a8ffc72 /drivers/scsi
parent43f388b02e5c3a10a89f7163f38787a98638eb18 (diff)
[SCSI] be2iscsi: Fix MACRO for checking the adapter type
Fixed the code flow based on the MACRO defined to check for adapter. Signed-off-by: John Soni Jose <sony.john-n@emulex.com> Signed-off-by: Jayamohan Kallickal <jayamohan.kallickal@emulex.com> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.c28
-rw-r--r--drivers/scsi/be2iscsi/be_main.c123
-rw-r--r--drivers/scsi/be2iscsi/be_main.h4
3 files changed, 79 insertions, 76 deletions
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index dfbe7e43574a..db6c50bc8c02 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -855,20 +855,7 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
855 OPCODE_COMMON_CQ_CREATE, sizeof(*req)); 855 OPCODE_COMMON_CQ_CREATE, sizeof(*req));
856 856
857 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); 857 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
858 if (chip_skh_r(ctrl->pdev)) { 858 if (is_chip_be2_be3r(phba)) {
859 req->hdr.version = MBX_CMD_VER2;
860 req->page_size = 1;
861 AMAP_SET_BITS(struct amap_cq_context_v2, coalescwm,
862 ctxt, coalesce_wm);
863 AMAP_SET_BITS(struct amap_cq_context_v2, nodelay,
864 ctxt, no_delay);
865 AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt,
866 __ilog2_u32(cq->len / 256));
867 AMAP_SET_BITS(struct amap_cq_context_v2, valid, ctxt, 1);
868 AMAP_SET_BITS(struct amap_cq_context_v2, eventable, ctxt, 1);
869 AMAP_SET_BITS(struct amap_cq_context_v2, eqid, ctxt, eq->id);
870 AMAP_SET_BITS(struct amap_cq_context_v2, armed, ctxt, 1);
871 } else {
872 AMAP_SET_BITS(struct amap_cq_context, coalescwm, 859 AMAP_SET_BITS(struct amap_cq_context, coalescwm,
873 ctxt, coalesce_wm); 860 ctxt, coalesce_wm);
874 AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay); 861 AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay);
@@ -881,6 +868,19 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
881 AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); 868 AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
882 AMAP_SET_BITS(struct amap_cq_context, func, ctxt, 869 AMAP_SET_BITS(struct amap_cq_context, func, ctxt,
883 PCI_FUNC(ctrl->pdev->devfn)); 870 PCI_FUNC(ctrl->pdev->devfn));
871 } else {
872 req->hdr.version = MBX_CMD_VER2;
873 req->page_size = 1;
874 AMAP_SET_BITS(struct amap_cq_context_v2, coalescwm,
875 ctxt, coalesce_wm);
876 AMAP_SET_BITS(struct amap_cq_context_v2, nodelay,
877 ctxt, no_delay);
878 AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt,
879 __ilog2_u32(cq->len / 256));
880 AMAP_SET_BITS(struct amap_cq_context_v2, valid, ctxt, 1);
881 AMAP_SET_BITS(struct amap_cq_context_v2, eventable, ctxt, 1);
882 AMAP_SET_BITS(struct amap_cq_context_v2, eqid, ctxt, eq->id);
883 AMAP_SET_BITS(struct amap_cq_context_v2, armed, ctxt, 1);
884 } 884 }
885 885
886 be_dws_cpu_to_le(ctxt, sizeof(req->context)); 886 be_dws_cpu_to_le(ctxt, sizeof(req->context));
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 75d7186723c1..6be5e296c3c1 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1368,15 +1368,15 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn,
1368 uint16_t wrb_index, cid; 1368 uint16_t wrb_index, cid;
1369 1369
1370 phwi_ctrlr = phba->phwi_ctrlr; 1370 phwi_ctrlr = phba->phwi_ctrlr;
1371 if (chip_skh_r(phba->pcidev)) { 1371 if (is_chip_be2_be3r(phba)) {
1372 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2, 1372 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe,
1373 wrb_idx, psol); 1373 wrb_idx, psol);
1374 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2, 1374 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe,
1375 cid, psol); 1375 cid, psol);
1376 } else { 1376 } else {
1377 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe, 1377 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2,
1378 wrb_idx, psol); 1378 wrb_idx, psol);
1379 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe, 1379 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2,
1380 cid, psol); 1380 cid, psol);
1381 } 1381 }
1382 1382
@@ -1418,7 +1418,26 @@ static void adapter_get_sol_cqe(struct beiscsi_hba *phba,
1418 struct sol_cqe *psol, 1418 struct sol_cqe *psol,
1419 struct common_sol_cqe *csol_cqe) 1419 struct common_sol_cqe *csol_cqe)
1420{ 1420{
1421 if (chip_skh_r(phba->pcidev)) { 1421 if (is_chip_be2_be3r(phba)) {
1422 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe,
1423 i_exp_cmd_sn, psol);
1424 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe,
1425 i_res_cnt, psol);
1426 csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe,
1427 i_cmd_wnd, psol);
1428 csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe,
1429 wrb_index, psol);
1430 csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe,
1431 cid, psol);
1432 csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe,
1433 hw_sts, psol);
1434 csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe,
1435 i_resp, psol);
1436 csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe,
1437 i_sts, psol);
1438 csol_cqe->i_flags = AMAP_GET_BITS(struct amap_sol_cqe,
1439 i_flags, psol);
1440 } else {
1422 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1441 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1423 i_exp_cmd_sn, psol); 1442 i_exp_cmd_sn, psol);
1424 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1443 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe_v2,
@@ -1445,25 +1464,6 @@ static void adapter_get_sol_cqe(struct beiscsi_hba *phba,
1445 if (AMAP_GET_BITS(struct amap_sol_cqe_v2, 1464 if (AMAP_GET_BITS(struct amap_sol_cqe_v2,
1446 o, psol)) 1465 o, psol))
1447 csol_cqe->i_flags |= ISCSI_FLAG_CMD_OVERFLOW; 1466 csol_cqe->i_flags |= ISCSI_FLAG_CMD_OVERFLOW;
1448 } else {
1449 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe,
1450 i_exp_cmd_sn, psol);
1451 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe,
1452 i_res_cnt, psol);
1453 csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe,
1454 i_cmd_wnd, psol);
1455 csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe,
1456 wrb_index, psol);
1457 csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe,
1458 cid, psol);
1459 csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe,
1460 hw_sts, psol);
1461 csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe,
1462 i_resp, psol);
1463 csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe,
1464 i_sts, psol);
1465 csol_cqe->i_flags = AMAP_GET_BITS(struct amap_sol_cqe,
1466 i_flags, psol);
1467 } 1467 }
1468} 1468}
1469 1469
@@ -1561,15 +1561,15 @@ hwi_get_async_handle(struct beiscsi_hba *phba,
1561 unsigned char is_header = 0; 1561 unsigned char is_header = 0;
1562 unsigned int index, dpl; 1562 unsigned int index, dpl;
1563 1563
1564 if (chip_skh_r(phba->pcidev)) { 1564 if (is_chip_be2_be3r(phba)) {
1565 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2, 1565 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe,
1566 dpl, pdpdu_cqe); 1566 dpl, pdpdu_cqe);
1567 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2, 1567 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe,
1568 index, pdpdu_cqe); 1568 index, pdpdu_cqe);
1569 } else { 1569 } else {
1570 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe, 1570 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2,
1571 dpl, pdpdu_cqe); 1571 dpl, pdpdu_cqe);
1572 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe, 1572 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2,
1573 index, pdpdu_cqe); 1573 index, pdpdu_cqe);
1574 } 1574 }
1575 1575
@@ -2028,7 +2028,9 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
2028 32] & CQE_CODE_MASK); 2028 32] & CQE_CODE_MASK);
2029 2029
2030 /* Get the CID */ 2030 /* Get the CID */
2031 if (chip_skh_r(phba->pcidev)) { 2031 if (is_chip_be2_be3r(phba)) {
2032 cid = AMAP_GET_BITS(struct amap_sol_cqe, cid, sol);
2033 } else {
2032 if ((code == DRIVERMSG_NOTIFY) || 2034 if ((code == DRIVERMSG_NOTIFY) ||
2033 (code == UNSOL_HDR_NOTIFY) || 2035 (code == UNSOL_HDR_NOTIFY) ||
2034 (code == UNSOL_DATA_NOTIFY)) 2036 (code == UNSOL_DATA_NOTIFY))
@@ -2038,8 +2040,7 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
2038 else 2040 else
2039 cid = AMAP_GET_BITS(struct amap_sol_cqe_v2, 2041 cid = AMAP_GET_BITS(struct amap_sol_cqe_v2,
2040 cid, sol); 2042 cid, sol);
2041 } else 2043 }
2042 cid = AMAP_GET_BITS(struct amap_sol_cqe, cid, sol);
2043 2044
2044 ep = phba->ep_array[cid - phba->fw_config.iscsi_cid_start]; 2045 ep = phba->ep_array[cid - phba->fw_config.iscsi_cid_start];
2045 beiscsi_ep = ep->dd_data; 2046 beiscsi_ep = ep->dd_data;
@@ -2416,11 +2417,11 @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task)
2416 /* Check for the data_count */ 2417 /* Check for the data_count */
2417 dsp_value = (task->data_count) ? 1 : 0; 2418 dsp_value = (task->data_count) ? 1 : 0;
2418 2419
2419 if (chip_skh_r(phba->pcidev)) 2420 if (is_chip_be2_be3r(phba))
2420 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, 2421 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp,
2421 pwrb, dsp_value); 2422 pwrb, dsp_value);
2422 else 2423 else
2423 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, 2424 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp,
2424 pwrb, dsp_value); 2425 pwrb, dsp_value);
2425 2426
2426 /* Map addr only if there is data_count */ 2427 /* Map addr only if there is data_count */
@@ -4175,11 +4176,11 @@ beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn,
4175 phba->fw_config.iscsi_cid_start)); 4176 phba->fw_config.iscsi_cid_start));
4176 4177
4177 /* Check for the adapter family */ 4178 /* Check for the adapter family */
4178 if (chip_skh_r(phba->pcidev)) 4179 if (is_chip_be2_be3r(phba))
4179 beiscsi_offload_cxn_v2(params, pwrb_handle);
4180 else
4181 beiscsi_offload_cxn_v0(params, pwrb_handle, 4180 beiscsi_offload_cxn_v0(params, pwrb_handle,
4182 phba->init_mem); 4181 phba->init_mem);
4182 else
4183 beiscsi_offload_cxn_v2(params, pwrb_handle);
4183 4184
4184 be_dws_le_to_cpu(pwrb_handle->pwrb, 4185 be_dws_le_to_cpu(pwrb_handle->pwrb,
4185 sizeof(struct iscsi_target_context_update_wrb)); 4186 sizeof(struct iscsi_target_context_update_wrb));
@@ -4490,19 +4491,7 @@ static int beiscsi_mtask(struct iscsi_task *task)
4490 pwrb = io_task->pwrb_handle->pwrb; 4491 pwrb = io_task->pwrb_handle->pwrb;
4491 memset(pwrb, 0, sizeof(*pwrb)); 4492 memset(pwrb, 0, sizeof(*pwrb));
4492 4493
4493 if (chip_skh_r(phba->pcidev)) { 4494 if (is_chip_be2_be3r(phba)) {
4494 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb,
4495 be32_to_cpu(task->cmdsn));
4496 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb,
4497 io_task->pwrb_handle->wrb_index);
4498 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb,
4499 io_task->psgl_handle->sgl_index);
4500 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb,
4501 task->data_count);
4502 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb,
4503 io_task->pwrb_handle->nxt_wrb_index);
4504 pwrb_typeoffset = SKH_WRB_TYPE_OFFSET;
4505 } else {
4506 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 4495 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb,
4507 be32_to_cpu(task->cmdsn)); 4496 be32_to_cpu(task->cmdsn));
4508 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, 4497 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb,
@@ -4514,6 +4503,18 @@ static int beiscsi_mtask(struct iscsi_task *task)
4514 AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb, 4503 AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb,
4515 io_task->pwrb_handle->nxt_wrb_index); 4504 io_task->pwrb_handle->nxt_wrb_index);
4516 pwrb_typeoffset = BE_WRB_TYPE_OFFSET; 4505 pwrb_typeoffset = BE_WRB_TYPE_OFFSET;
4506 } else {
4507 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb,
4508 be32_to_cpu(task->cmdsn));
4509 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb,
4510 io_task->pwrb_handle->wrb_index);
4511 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb,
4512 io_task->psgl_handle->sgl_index);
4513 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb,
4514 task->data_count);
4515 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb,
4516 io_task->pwrb_handle->nxt_wrb_index);
4517 pwrb_typeoffset = SKH_WRB_TYPE_OFFSET;
4517 } 4518 }
4518 4519
4519 4520
@@ -4526,19 +4527,19 @@ static int beiscsi_mtask(struct iscsi_task *task)
4526 case ISCSI_OP_NOOP_OUT: 4527 case ISCSI_OP_NOOP_OUT:
4527 if (task->hdr->ttt != ISCSI_RESERVED_TAG) { 4528 if (task->hdr->ttt != ISCSI_RESERVED_TAG) {
4528 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset); 4529 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset);
4529 if (chip_skh_r(phba->pcidev)) 4530 if (is_chip_be2_be3r(phba))
4530 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 4531 AMAP_SET_BITS(struct amap_iscsi_wrb,
4531 dmsg, pwrb, 1); 4532 dmsg, pwrb, 1);
4532 else 4533 else
4533 AMAP_SET_BITS(struct amap_iscsi_wrb, 4534 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
4534 dmsg, pwrb, 1); 4535 dmsg, pwrb, 1);
4535 } else { 4536 } else {
4536 ADAPTER_SET_WRB_TYPE(pwrb, INI_RD_CMD, pwrb_typeoffset); 4537 ADAPTER_SET_WRB_TYPE(pwrb, INI_RD_CMD, pwrb_typeoffset);
4537 if (chip_skh_r(phba->pcidev)) 4538 if (is_chip_be2_be3r(phba))
4538 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 4539 AMAP_SET_BITS(struct amap_iscsi_wrb,
4539 dmsg, pwrb, 0); 4540 dmsg, pwrb, 0);
4540 else 4541 else
4541 AMAP_SET_BITS(struct amap_iscsi_wrb, 4542 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
4542 dmsg, pwrb, 0); 4543 dmsg, pwrb, 0);
4543 } 4544 }
4544 hwi_write_buffer(pwrb, task); 4545 hwi_write_buffer(pwrb, task);
@@ -4565,9 +4566,9 @@ static int beiscsi_mtask(struct iscsi_task *task)
4565 } 4566 }
4566 4567
4567 /* Set the task type */ 4568 /* Set the task type */
4568 io_task->wrb_type = (chip_skh_r(phba->pcidev)) ? 4569 io_task->wrb_type = (is_chip_be2_be3r(phba)) ?
4569 AMAP_GET_BITS(struct amap_iscsi_wrb_v2, type, pwrb) : 4570 AMAP_GET_BITS(struct amap_iscsi_wrb, type, pwrb) :
4570 AMAP_GET_BITS(struct amap_iscsi_wrb, type, pwrb); 4571 AMAP_GET_BITS(struct amap_iscsi_wrb_v2, type, pwrb);
4571 4572
4572 doorbell |= cid & DB_WRB_POST_CID_MASK; 4573 doorbell |= cid & DB_WRB_POST_CID_MASK;
4573 doorbell |= (io_task->pwrb_handle->wrb_index & 4574 doorbell |= (io_task->pwrb_handle->wrb_index &
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index b098b5b7d188..77b13c3e463e 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -265,7 +265,9 @@ struct invalidate_command_table {
265 unsigned short cid; 265 unsigned short cid;
266} __packed; 266} __packed;
267 267
268#define chip_skh_r(pdev) (pdev->device == OC_SKH_ID1) 268#define chip_be2(phba) (phba->generation == BE_GEN2)
269#define chip_be3_r(phba) (phba->generation == BE_GEN3)
270#define is_chip_be2_be3r(phba) (chip_be3_r(phba) || (chip_be2(phba)))
269struct beiscsi_hba { 271struct beiscsi_hba {
270 struct hba_parameters params; 272 struct hba_parameters params;
271 struct hwi_controller *phwi_ctrlr; 273 struct hwi_controller *phwi_ctrlr;