aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJitendra Bhivare <jitendra.bhivare@broadcom.com>2016-02-04 05:19:11 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2016-02-23 21:27:02 -0500
commit2e4e8f6574ab14937ca6aac9c9551876e744154d (patch)
treea81f89d8ae8d2a73afcee47c3fa6a29af495da3d
parent67296ad92d2f4cba04d49f0bef1a67229ec06170 (diff)
be2iscsi: Remove redundant MCC processing code
be_mcc_compl_process_isr is removed. MCC CQ processing is done only in beiscsi_process_mcc_cq and MCC CQE processing is done only in beiscsi_process_mcc_compl. Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.c165
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.h7
-rw-r--r--drivers/scsi/be2iscsi/be_main.c8
-rw-r--r--drivers/scsi/be2iscsi/be_main.h1
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.c3
5 files changed, 68 insertions, 116 deletions
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index c5e77394b101..f59dbdf465f5 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -328,76 +328,6 @@ static int be_mcc_compl_process(struct be_ctrl_info *ctrl,
328 return 0; 328 return 0;
329} 329}
330 330
331int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
332 struct be_mcc_compl *compl)
333{
334 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
335 u16 compl_status, extd_status;
336 struct be_dma_mem *tag_mem;
337 unsigned int tag, wrb_idx;
338
339 be_dws_le_to_cpu(compl, 4);
340 tag = (compl->tag0 & MCC_Q_CMD_TAG_MASK);
341 wrb_idx = (compl->tag0 & CQE_STATUS_WRB_MASK) >> CQE_STATUS_WRB_SHIFT;
342
343 if (!test_bit(MCC_TAG_STATE_RUNNING,
344 &ctrl->ptag_state[tag].tag_state)) {
345 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_MBOX |
346 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
347 "BC_%d : MBX cmd completed but not posted\n");
348 return 0;
349 }
350
351 if (test_bit(MCC_TAG_STATE_TIMEOUT,
352 &ctrl->ptag_state[tag].tag_state)) {
353 beiscsi_log(phba, KERN_WARNING,
354 BEISCSI_LOG_MBOX | BEISCSI_LOG_INIT |
355 BEISCSI_LOG_CONFIG,
356 "BC_%d : MBX Completion for timeout Command from FW\n");
357 /**
358 * Check for the size before freeing resource.
359 * Only for non-embedded cmd, PCI resource is allocated.
360 **/
361 tag_mem = &ctrl->ptag_state[tag].tag_mem_state;
362 if (tag_mem->size)
363 pci_free_consistent(ctrl->pdev, tag_mem->size,
364 tag_mem->va, tag_mem->dma);
365 free_mcc_tag(ctrl, tag);
366 return 0;
367 }
368
369 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &
370 CQE_STATUS_COMPL_MASK;
371 extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) &
372 CQE_STATUS_EXTD_MASK;
373 /* The ctrl.mcc_tag_status[tag] is filled with
374 * [31] = valid, [30:24] = Rsvd, [23:16] = wrb, [15:8] = extd_status,
375 * [7:0] = compl_status
376 */
377 ctrl->mcc_tag_status[tag] = CQE_VALID_MASK;
378 ctrl->mcc_tag_status[tag] |= (wrb_idx << CQE_STATUS_WRB_SHIFT);
379 ctrl->mcc_tag_status[tag] |= (extd_status << CQE_STATUS_ADDL_SHIFT) &
380 CQE_STATUS_ADDL_MASK;
381 ctrl->mcc_tag_status[tag] |= (compl_status & CQE_STATUS_MASK);
382
383 /* write ordering implied in wake_up_interruptible */
384 clear_bit(MCC_TAG_STATE_RUNNING, &ctrl->ptag_state[tag].tag_state);
385 wake_up_interruptible(&ctrl->mcc_wait[tag]);
386 return 0;
387}
388
389static struct be_mcc_compl *be_mcc_compl_get(struct beiscsi_hba *phba)
390{
391 struct be_queue_info *mcc_cq = &phba->ctrl.mcc_obj.cq;
392 struct be_mcc_compl *compl = queue_tail_node(mcc_cq);
393
394 if (be_mcc_compl_is_new(compl)) {
395 queue_tail_inc(mcc_cq);
396 return compl;
397 }
398 return NULL;
399}
400
401/** 331/**
402 * beiscsi_fail_session(): Closing session with appropriate error 332 * beiscsi_fail_session(): Closing session with appropriate error
403 * @cls_session: ptr to session 333 * @cls_session: ptr to session
@@ -528,27 +458,65 @@ void beiscsi_process_async_event(struct beiscsi_hba *phba,
528 evt_code, compl->status, compl->flags); 458 evt_code, compl->status, compl->flags);
529} 459}
530 460
531int beiscsi_process_mcc(struct beiscsi_hba *phba) 461int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
462 struct be_mcc_compl *compl)
532{ 463{
533 struct be_mcc_compl *compl; 464 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
534 int num = 0, status = 0; 465 u16 compl_status, extd_status;
535 struct be_ctrl_info *ctrl = &phba->ctrl; 466 struct be_dma_mem *tag_mem;
467 unsigned int tag, wrb_idx;
536 468
537 while ((compl = be_mcc_compl_get(phba))) { 469 /**
538 if (compl->flags & CQE_FLAGS_ASYNC_MASK) { 470 * Just swap the status to host endian; mcc tag is opaquely copied
539 beiscsi_process_async_event(phba, compl); 471 * from mcc_wrb
540 } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { 472 */
541 status = be_mcc_compl_process(ctrl, compl); 473 be_dws_le_to_cpu(compl, 4);
542 atomic_dec(&phba->ctrl.mcc_obj.q.used); 474 tag = (compl->tag0 & MCC_Q_CMD_TAG_MASK);
543 } 475 wrb_idx = (compl->tag0 & CQE_STATUS_WRB_MASK) >> CQE_STATUS_WRB_SHIFT;
544 be_mcc_compl_use(compl); 476
545 num++; 477 if (!test_bit(MCC_TAG_STATE_RUNNING,
478 &ctrl->ptag_state[tag].tag_state)) {
479 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_MBOX |
480 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
481 "BC_%d : MBX cmd completed but not posted\n");
482 return 0;
546 } 483 }
547 484
548 if (num) 485 if (test_bit(MCC_TAG_STATE_TIMEOUT, &ctrl->ptag_state[tag].tag_state)) {
549 hwi_ring_cq_db(phba, phba->ctrl.mcc_obj.cq.id, num, 1); 486 beiscsi_log(phba, KERN_WARNING,
487 BEISCSI_LOG_MBOX | BEISCSI_LOG_INIT |
488 BEISCSI_LOG_CONFIG,
489 "BC_%d : MBX Completion for timeout Command from FW\n");
490 /**
491 * Check for the size before freeing resource.
492 * Only for non-embedded cmd, PCI resource is allocated.
493 **/
494 tag_mem = &ctrl->ptag_state[tag].tag_mem_state;
495 if (tag_mem->size)
496 pci_free_consistent(ctrl->pdev, tag_mem->size,
497 tag_mem->va, tag_mem->dma);
498 free_mcc_tag(ctrl, tag);
499 return 0;
500 }
550 501
551 return status; 502 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &
503 CQE_STATUS_COMPL_MASK;
504 extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) &
505 CQE_STATUS_EXTD_MASK;
506 /* The ctrl.mcc_tag_status[tag] is filled with
507 * [31] = valid, [30:24] = Rsvd, [23:16] = wrb, [15:8] = extd_status,
508 * [7:0] = compl_status
509 */
510 ctrl->mcc_tag_status[tag] = CQE_VALID_MASK;
511 ctrl->mcc_tag_status[tag] |= (wrb_idx << CQE_STATUS_WRB_SHIFT);
512 ctrl->mcc_tag_status[tag] |= (extd_status << CQE_STATUS_ADDL_SHIFT) &
513 CQE_STATUS_ADDL_MASK;
514 ctrl->mcc_tag_status[tag] |= (compl_status & CQE_STATUS_MASK);
515
516 /* write ordering forced in wake_up_interruptible */
517 clear_bit(MCC_TAG_STATE_RUNNING, &ctrl->ptag_state[tag].tag_state);
518 wake_up_interruptible(&ctrl->mcc_wait[tag]);
519 return 0;
552} 520}
553 521
554/* 522/*
@@ -562,16 +530,15 @@ int beiscsi_process_mcc(struct beiscsi_hba *phba)
562 * Failure: Non-Zero 530 * Failure: Non-Zero
563 * 531 *
564 **/ 532 **/
565static int be_mcc_wait_compl(struct beiscsi_hba *phba) 533int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag)
566{ 534{
567 int i, status; 535 int i;
536
568 for (i = 0; i < mcc_timeout; i++) { 537 for (i = 0; i < mcc_timeout; i++) {
569 if (beiscsi_error(phba)) 538 if (beiscsi_error(phba))
570 return -EIO; 539 return -EIO;
571 540
572 status = beiscsi_process_mcc(phba); 541 beiscsi_process_mcc_cq(phba);
573 if (status)
574 return status;
575 542
576 if (atomic_read(&phba->ctrl.mcc_obj.q.used) == 0) 543 if (atomic_read(&phba->ctrl.mcc_obj.q.used) == 0)
577 break; 544 break;
@@ -589,22 +556,6 @@ static int be_mcc_wait_compl(struct beiscsi_hba *phba)
589} 556}
590 557
591/* 558/*
592 * be_mcc_notify_wait()- Notify and wait for Compl
593 * @phba: driver private structure
594 *
595 * Notify MCC requests and wait for completion
596 *
597 * return
598 * Success: 0
599 * Failure: Non-Zero
600 **/
601int be_mcc_notify_wait(struct beiscsi_hba *phba, unsigned int tag)
602{
603 be_mcc_notify(phba, tag);
604 return be_mcc_wait_compl(phba);
605}
606
607/*
608 * be_mbox_db_ready_wait()- Check ready status 559 * be_mbox_db_ready_wait()- Check ready status
609 * @ctrl: Function specific MBX data structure 560 * @ctrl: Function specific MBX data structure
610 * 561 *
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index adafd9ca3e3e..f50b32ac72ee 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -741,13 +741,14 @@ int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
741 741
742struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem); 742struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
743struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba); 743struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
744int be_mcc_notify_wait(struct beiscsi_hba *phba, unsigned int tag); 744int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag);
745void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag); 745void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
746unsigned int alloc_mcc_tag(struct beiscsi_hba *phba); 746unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
747void beiscsi_process_async_event(struct beiscsi_hba *phba, 747void beiscsi_process_async_event(struct beiscsi_hba *phba,
748 struct be_mcc_compl *compl); 748 struct be_mcc_compl *compl);
749int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl, 749int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
750 struct be_mcc_compl *compl); 750 struct be_mcc_compl *compl);
751
751 752
752int be_mbox_notify(struct be_ctrl_info *ctrl); 753int be_mbox_notify(struct be_ctrl_info *ctrl);
753 754
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index aaf39d4dfe81..8b9d01a765fc 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -2028,7 +2028,7 @@ static void hwi_process_default_pdu_ring(struct beiscsi_conn *beiscsi_conn,
2028 phwi_ctrlr, cri_index)); 2028 phwi_ctrlr, cri_index));
2029} 2029}
2030 2030
2031static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba) 2031void beiscsi_process_mcc_cq(struct beiscsi_hba *phba)
2032{ 2032{
2033 struct be_queue_info *mcc_cq; 2033 struct be_queue_info *mcc_cq;
2034 struct be_mcc_compl *mcc_compl; 2034 struct be_mcc_compl *mcc_compl;
@@ -2038,7 +2038,6 @@ static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba)
2038 mcc_compl = queue_tail_node(mcc_cq); 2038 mcc_compl = queue_tail_node(mcc_cq);
2039 mcc_compl->flags = le32_to_cpu(mcc_compl->flags); 2039 mcc_compl->flags = le32_to_cpu(mcc_compl->flags);
2040 while (mcc_compl->flags & CQE_FLAGS_VALID_MASK) { 2040 while (mcc_compl->flags & CQE_FLAGS_VALID_MASK) {
2041
2042 if (num_processed >= 32) { 2041 if (num_processed >= 32) {
2043 hwi_ring_cq_db(phba, mcc_cq->id, 2042 hwi_ring_cq_db(phba, mcc_cq->id,
2044 num_processed, 0); 2043 num_processed, 0);
@@ -2047,7 +2046,7 @@ static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba)
2047 if (mcc_compl->flags & CQE_FLAGS_ASYNC_MASK) { 2046 if (mcc_compl->flags & CQE_FLAGS_ASYNC_MASK) {
2048 beiscsi_process_async_event(phba, mcc_compl); 2047 beiscsi_process_async_event(phba, mcc_compl);
2049 } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) { 2048 } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) {
2050 be_mcc_compl_process_isr(&phba->ctrl, mcc_compl); 2049 beiscsi_process_mcc_compl(&phba->ctrl, mcc_compl);
2051 atomic_dec(&phba->ctrl.mcc_obj.q.used); 2050 atomic_dec(&phba->ctrl.mcc_obj.q.used);
2052 } 2051 }
2053 2052
@@ -2060,7 +2059,6 @@ static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba)
2060 2059
2061 if (num_processed > 0) 2060 if (num_processed > 0)
2062 hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1); 2061 hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1);
2063
2064} 2062}
2065 2063
2066/** 2064/**
@@ -2269,7 +2267,7 @@ void beiscsi_process_all_cqs(struct work_struct *work)
2269 spin_lock_irqsave(&phba->isr_lock, flags); 2267 spin_lock_irqsave(&phba->isr_lock, flags);
2270 pbe_eq->todo_mcc_cq = false; 2268 pbe_eq->todo_mcc_cq = false;
2271 spin_unlock_irqrestore(&phba->isr_lock, flags); 2269 spin_unlock_irqrestore(&phba->isr_lock, flags);
2272 beiscsi_process_mcc_isr(phba); 2270 beiscsi_process_mcc_cq(phba);
2273 } 2271 }
2274 2272
2275 if (pbe_eq->todo_cq) { 2273 if (pbe_eq->todo_cq) {
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 16a6fd05c6b2..5ded3fabc942 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -853,6 +853,7 @@ void hwi_ring_cq_db(struct beiscsi_hba *phba,
853 unsigned char rearm); 853 unsigned char rearm);
854 854
855unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget); 855unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget);
856void beiscsi_process_mcc_cq(struct beiscsi_hba *phba);
856 857
857static inline bool beiscsi_error(struct beiscsi_hba *phba) 858static inline bool beiscsi_error(struct beiscsi_hba *phba)
858{ 859{
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index da040e79cbd0..a88e63666b1f 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -678,7 +678,8 @@ int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short ulp_num)
678 req->hdr_ring_id = cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba, ulp_num)); 678 req->hdr_ring_id = cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba, ulp_num));
679 req->data_ring_id = cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba, ulp_num)); 679 req->data_ring_id = cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba, ulp_num));
680 680
681 status = be_mcc_notify_wait(phba, tag); 681 be_mcc_notify(phba, tag);
682 status = be_mcc_compl_poll(phba, tag);
682 if (status) 683 if (status)
683 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, 684 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
684 "BG_%d : mgmt_epfw_cleanup , FAILED\n"); 685 "BG_%d : mgmt_epfw_cleanup , FAILED\n");