diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.c | 177 |
1 files changed, 35 insertions, 142 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index e9fa6762044a..32f8dac6abfe 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -116,6 +116,27 @@ lpfc_debug_save_dif(struct scsi_cmnd *cmnd) | |||
116 | } | 116 | } |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * lpfc_sli4_set_rsp_sgl_last - Set the last bit in the response sge. | ||
120 | * @phba: Pointer to HBA object. | ||
121 | * @lpfc_cmd: lpfc scsi command object pointer. | ||
122 | * | ||
123 | * This function is called from the lpfc_prep_task_mgmt_cmd function to | ||
124 | * set the last bit in the response sge entry. | ||
125 | **/ | ||
126 | static void | ||
127 | lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba, | ||
128 | struct lpfc_scsi_buf *lpfc_cmd) | ||
129 | { | ||
130 | struct sli4_sge *sgl = (struct sli4_sge *)lpfc_cmd->fcp_bpl; | ||
131 | if (sgl) { | ||
132 | sgl += 1; | ||
133 | sgl->word2 = le32_to_cpu(sgl->word2); | ||
134 | bf_set(lpfc_sli4_sge_last, sgl, 1); | ||
135 | sgl->word2 = cpu_to_le32(sgl->word2); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /** | ||
119 | * lpfc_update_stats - Update statistical data for the command completion | 140 | * lpfc_update_stats - Update statistical data for the command completion |
120 | * @phba: Pointer to HBA object. | 141 | * @phba: Pointer to HBA object. |
121 | * @lpfc_cmd: lpfc scsi command object pointer. | 142 | * @lpfc_cmd: lpfc scsi command object pointer. |
@@ -1978,7 +1999,7 @@ lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport, | |||
1978 | } | 1999 | } |
1979 | 2000 | ||
1980 | /** | 2001 | /** |
1981 | * lpfc_scsi_unprep_dma_buf_s3 - Un-map DMA mapping of SG-list for SLI3 dev | 2002 | * lpfc_scsi_unprep_dma_buf - Un-map DMA mapping of SG-list for dev |
1982 | * @phba: The HBA for which this call is being executed. | 2003 | * @phba: The HBA for which this call is being executed. |
1983 | * @psb: The scsi buffer which is going to be un-mapped. | 2004 | * @psb: The scsi buffer which is going to be un-mapped. |
1984 | * | 2005 | * |
@@ -1986,7 +2007,7 @@ lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport, | |||
1986 | * field of @lpfc_cmd for device with SLI-3 interface spec. | 2007 | * field of @lpfc_cmd for device with SLI-3 interface spec. |
1987 | **/ | 2008 | **/ |
1988 | static void | 2009 | static void |
1989 | lpfc_scsi_unprep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) | 2010 | lpfc_scsi_unprep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) |
1990 | { | 2011 | { |
1991 | /* | 2012 | /* |
1992 | * There are only two special cases to consider. (1) the scsi command | 2013 | * There are only two special cases to consider. (1) the scsi command |
@@ -2003,36 +2024,6 @@ lpfc_scsi_unprep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) | |||
2003 | } | 2024 | } |
2004 | 2025 | ||
2005 | /** | 2026 | /** |
2006 | * lpfc_scsi_unprep_dma_buf_s4 - Un-map DMA mapping of SG-list for SLI4 dev | ||
2007 | * @phba: The Hba for which this call is being executed. | ||
2008 | * @psb: The scsi buffer which is going to be un-mapped. | ||
2009 | * | ||
2010 | * This routine does DMA un-mapping of scatter gather list of scsi command | ||
2011 | * field of @lpfc_cmd for device with SLI-4 interface spec. If we have to | ||
2012 | * remove the sgl for this scsi buffer then we will do it here. For now | ||
2013 | * we should be able to just call the sli3 unprep routine. | ||
2014 | **/ | ||
2015 | static void | ||
2016 | lpfc_scsi_unprep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) | ||
2017 | { | ||
2018 | lpfc_scsi_unprep_dma_buf_s3(phba, psb); | ||
2019 | } | ||
2020 | |||
2021 | /** | ||
2022 | * lpfc_scsi_unprep_dma_buf - Wrapper function for unmap DMA mapping of SG-list | ||
2023 | * @phba: The Hba for which this call is being executed. | ||
2024 | * @psb: The scsi buffer which is going to be un-mapped. | ||
2025 | * | ||
2026 | * This routine does DMA un-mapping of scatter gather list of scsi command | ||
2027 | * field of @lpfc_cmd for device with SLI-4 interface spec. | ||
2028 | **/ | ||
2029 | static void | ||
2030 | lpfc_scsi_unprep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) | ||
2031 | { | ||
2032 | phba->lpfc_scsi_unprep_dma_buf(phba, psb); | ||
2033 | } | ||
2034 | |||
2035 | /** | ||
2036 | * lpfc_handler_fcp_err - FCP response handler | 2027 | * lpfc_handler_fcp_err - FCP response handler |
2037 | * @vport: The virtual port for which this call is being executed. | 2028 | * @vport: The virtual port for which this call is being executed. |
2038 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. | 2029 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. |
@@ -2461,7 +2452,7 @@ lpfc_fcpcmd_to_iocb(uint8_t *data, struct fcp_cmnd *fcp_cmnd) | |||
2461 | } | 2452 | } |
2462 | 2453 | ||
2463 | /** | 2454 | /** |
2464 | * lpfc_scsi_prep_cmnd_s3 - Convert scsi cmnd to FCP infor unit for SLI3 dev | 2455 | * lpfc_scsi_prep_cmnd - Wrapper func for convert scsi cmnd to FCP info unit |
2465 | * @vport: The virtual port for which this call is being executed. | 2456 | * @vport: The virtual port for which this call is being executed. |
2466 | * @lpfc_cmd: The scsi command which needs to send. | 2457 | * @lpfc_cmd: The scsi command which needs to send. |
2467 | * @pnode: Pointer to lpfc_nodelist. | 2458 | * @pnode: Pointer to lpfc_nodelist. |
@@ -2470,7 +2461,7 @@ lpfc_fcpcmd_to_iocb(uint8_t *data, struct fcp_cmnd *fcp_cmnd) | |||
2470 | * to transfer for device with SLI3 interface spec. | 2461 | * to transfer for device with SLI3 interface spec. |
2471 | **/ | 2462 | **/ |
2472 | static void | 2463 | static void |
2473 | lpfc_scsi_prep_cmnd_s3(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | 2464 | lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, |
2474 | struct lpfc_nodelist *pnode) | 2465 | struct lpfc_nodelist *pnode) |
2475 | { | 2466 | { |
2476 | struct lpfc_hba *phba = vport->phba; | 2467 | struct lpfc_hba *phba = vport->phba; |
@@ -2558,46 +2549,7 @@ lpfc_scsi_prep_cmnd_s3(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |||
2558 | } | 2549 | } |
2559 | 2550 | ||
2560 | /** | 2551 | /** |
2561 | * lpfc_scsi_prep_cmnd_s4 - Convert scsi cmnd to FCP infor unit for SLI4 dev | 2552 | * lpfc_scsi_prep_task_mgmt_cmnd - Convert SLI3 scsi TM cmd to FCP info unit |
2562 | * @vport: The virtual port for which this call is being executed. | ||
2563 | * @lpfc_cmd: The scsi command which needs to send. | ||
2564 | * @pnode: Pointer to lpfc_nodelist. | ||
2565 | * | ||
2566 | * This routine initializes fcp_cmnd and iocb data structure from scsi command | ||
2567 | * to transfer for device with SLI4 interface spec. | ||
2568 | **/ | ||
2569 | static void | ||
2570 | lpfc_scsi_prep_cmnd_s4(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | ||
2571 | struct lpfc_nodelist *pnode) | ||
2572 | { | ||
2573 | /* | ||
2574 | * The prep cmnd routines do not touch the sgl or its | ||
2575 | * entries. We may not have to do anything different. | ||
2576 | * I will leave this function in place until we can | ||
2577 | * run some IO through the driver and determine if changes | ||
2578 | * are needed. | ||
2579 | */ | ||
2580 | return lpfc_scsi_prep_cmnd_s3(vport, lpfc_cmd, pnode); | ||
2581 | } | ||
2582 | |||
2583 | /** | ||
2584 | * lpfc_scsi_prep_cmnd - Wrapper func for convert scsi cmnd to FCP info unit | ||
2585 | * @vport: The virtual port for which this call is being executed. | ||
2586 | * @lpfc_cmd: The scsi command which needs to send. | ||
2587 | * @pnode: Pointer to lpfc_nodelist. | ||
2588 | * | ||
2589 | * This routine wraps the actual convert SCSI cmnd function pointer from | ||
2590 | * the lpfc_hba struct. | ||
2591 | **/ | ||
2592 | static inline void | ||
2593 | lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | ||
2594 | struct lpfc_nodelist *pnode) | ||
2595 | { | ||
2596 | vport->phba->lpfc_scsi_prep_cmnd(vport, lpfc_cmd, pnode); | ||
2597 | } | ||
2598 | |||
2599 | /** | ||
2600 | * lpfc_scsi_prep_task_mgmt_cmnd_s3 - Convert SLI3 scsi TM cmd to FCP info unit | ||
2601 | * @vport: The virtual port for which this call is being executed. | 2553 | * @vport: The virtual port for which this call is being executed. |
2602 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. | 2554 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. |
2603 | * @lun: Logical unit number. | 2555 | * @lun: Logical unit number. |
@@ -2611,7 +2563,7 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |||
2611 | * 1 - Success | 2563 | * 1 - Success |
2612 | **/ | 2564 | **/ |
2613 | static int | 2565 | static int |
2614 | lpfc_scsi_prep_task_mgmt_cmd_s3(struct lpfc_vport *vport, | 2566 | lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport, |
2615 | struct lpfc_scsi_buf *lpfc_cmd, | 2567 | struct lpfc_scsi_buf *lpfc_cmd, |
2616 | unsigned int lun, | 2568 | unsigned int lun, |
2617 | uint8_t task_mgmt_cmd) | 2569 | uint8_t task_mgmt_cmd) |
@@ -2653,68 +2605,13 @@ lpfc_scsi_prep_task_mgmt_cmd_s3(struct lpfc_vport *vport, | |||
2653 | * The driver will provide the timeout mechanism. | 2605 | * The driver will provide the timeout mechanism. |
2654 | */ | 2606 | */ |
2655 | piocb->ulpTimeout = 0; | 2607 | piocb->ulpTimeout = 0; |
2656 | } else { | 2608 | } else |
2657 | piocb->ulpTimeout = lpfc_cmd->timeout; | 2609 | piocb->ulpTimeout = lpfc_cmd->timeout; |
2658 | } | ||
2659 | |||
2660 | return 1; | ||
2661 | } | ||
2662 | |||
2663 | /** | ||
2664 | * lpfc_scsi_prep_task_mgmt_cmnd_s4 - Convert SLI4 scsi TM cmd to FCP info unit | ||
2665 | * @vport: The virtual port for which this call is being executed. | ||
2666 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. | ||
2667 | * @lun: Logical unit number. | ||
2668 | * @task_mgmt_cmd: SCSI task management command. | ||
2669 | * | ||
2670 | * This routine creates FCP information unit corresponding to @task_mgmt_cmd | ||
2671 | * for device with SLI-4 interface spec. | ||
2672 | * | ||
2673 | * Return codes: | ||
2674 | * 0 - Error | ||
2675 | * 1 - Success | ||
2676 | **/ | ||
2677 | static int | ||
2678 | lpfc_scsi_prep_task_mgmt_cmd_s4(struct lpfc_vport *vport, | ||
2679 | struct lpfc_scsi_buf *lpfc_cmd, | ||
2680 | unsigned int lun, | ||
2681 | uint8_t task_mgmt_cmd) | ||
2682 | { | ||
2683 | /* | ||
2684 | * The prep cmnd routines do not touch the sgl or its | ||
2685 | * entries. We may not have to do anything different. | ||
2686 | * I will leave this function in place until we can | ||
2687 | * run some IO through the driver and determine if changes | ||
2688 | * are needed. | ||
2689 | */ | ||
2690 | return lpfc_scsi_prep_task_mgmt_cmd_s3(vport, lpfc_cmd, lun, | ||
2691 | task_mgmt_cmd); | ||
2692 | } | ||
2693 | 2610 | ||
2694 | /** | 2611 | if (vport->phba->sli_rev == LPFC_SLI_REV4) |
2695 | * lpfc_scsi_prep_task_mgmt_cmnd - Wrapper func convert scsi TM cmd to FCP info | 2612 | lpfc_sli4_set_rsp_sgl_last(vport->phba, lpfc_cmd); |
2696 | * @vport: The virtual port for which this call is being executed. | ||
2697 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. | ||
2698 | * @lun: Logical unit number. | ||
2699 | * @task_mgmt_cmd: SCSI task management command. | ||
2700 | * | ||
2701 | * This routine wraps the actual convert SCSI TM to FCP information unit | ||
2702 | * function pointer from the lpfc_hba struct. | ||
2703 | * | ||
2704 | * Return codes: | ||
2705 | * 0 - Error | ||
2706 | * 1 - Success | ||
2707 | **/ | ||
2708 | static inline int | ||
2709 | lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport, | ||
2710 | struct lpfc_scsi_buf *lpfc_cmd, | ||
2711 | unsigned int lun, | ||
2712 | uint8_t task_mgmt_cmd) | ||
2713 | { | ||
2714 | struct lpfc_hba *phba = vport->phba; | ||
2715 | 2613 | ||
2716 | return phba->lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun, | 2614 | return 1; |
2717 | task_mgmt_cmd); | ||
2718 | } | 2615 | } |
2719 | 2616 | ||
2720 | /** | 2617 | /** |
@@ -2730,23 +2627,19 @@ int | |||
2730 | lpfc_scsi_api_table_setup(struct lpfc_hba *phba, uint8_t dev_grp) | 2627 | lpfc_scsi_api_table_setup(struct lpfc_hba *phba, uint8_t dev_grp) |
2731 | { | 2628 | { |
2732 | 2629 | ||
2630 | phba->lpfc_scsi_unprep_dma_buf = lpfc_scsi_unprep_dma_buf; | ||
2631 | phba->lpfc_scsi_prep_cmnd = lpfc_scsi_prep_cmnd; | ||
2632 | phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf; | ||
2633 | |||
2733 | switch (dev_grp) { | 2634 | switch (dev_grp) { |
2734 | case LPFC_PCI_DEV_LP: | 2635 | case LPFC_PCI_DEV_LP: |
2735 | phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s3; | 2636 | phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s3; |
2736 | phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s3; | 2637 | phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s3; |
2737 | phba->lpfc_scsi_prep_cmnd = lpfc_scsi_prep_cmnd_s3; | ||
2738 | phba->lpfc_scsi_unprep_dma_buf = lpfc_scsi_unprep_dma_buf_s3; | ||
2739 | phba->lpfc_scsi_prep_task_mgmt_cmd = | ||
2740 | lpfc_scsi_prep_task_mgmt_cmd_s3; | ||
2741 | phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s3; | 2638 | phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s3; |
2742 | break; | 2639 | break; |
2743 | case LPFC_PCI_DEV_OC: | 2640 | case LPFC_PCI_DEV_OC: |
2744 | phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s4; | 2641 | phba->lpfc_new_scsi_buf = lpfc_new_scsi_buf_s4; |
2745 | phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s4; | 2642 | phba->lpfc_scsi_prep_dma_buf = lpfc_scsi_prep_dma_buf_s4; |
2746 | phba->lpfc_scsi_prep_cmnd = lpfc_scsi_prep_cmnd_s4; | ||
2747 | phba->lpfc_scsi_unprep_dma_buf = lpfc_scsi_unprep_dma_buf_s4; | ||
2748 | phba->lpfc_scsi_prep_task_mgmt_cmd = | ||
2749 | lpfc_scsi_prep_task_mgmt_cmd_s4; | ||
2750 | phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s4; | 2643 | phba->lpfc_release_scsi_buf = lpfc_release_scsi_buf_s4; |
2751 | break; | 2644 | break; |
2752 | default: | 2645 | default: |