diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_mbox.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_mbox.c | 93 |
1 files changed, 66 insertions, 27 deletions
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index 3423571dd1b..1ab405902a1 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |||
@@ -52,48 +52,85 @@ | |||
52 | * This routine prepares the mailbox command for dumping list of static | 52 | * This routine prepares the mailbox command for dumping list of static |
53 | * vports to be created. | 53 | * vports to be created. |
54 | **/ | 54 | **/ |
55 | void | 55 | int |
56 | lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, | 56 | lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, |
57 | uint16_t offset) | 57 | uint16_t offset) |
58 | { | 58 | { |
59 | MAILBOX_t *mb; | 59 | MAILBOX_t *mb; |
60 | void *ctx; | 60 | struct lpfc_dmabuf *mp; |
61 | 61 | ||
62 | mb = &pmb->u.mb; | 62 | mb = &pmb->u.mb; |
63 | ctx = pmb->context2; | ||
64 | 63 | ||
65 | /* Setup to dump vport info region */ | 64 | /* Setup to dump vport info region */ |
66 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | 65 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); |
67 | mb->mbxCommand = MBX_DUMP_MEMORY; | 66 | mb->mbxCommand = MBX_DUMP_MEMORY; |
68 | mb->un.varDmp.cv = 1; | ||
69 | mb->un.varDmp.type = DMP_NV_PARAMS; | 67 | mb->un.varDmp.type = DMP_NV_PARAMS; |
70 | mb->un.varDmp.entry_index = offset; | 68 | mb->un.varDmp.entry_index = offset; |
71 | mb->un.varDmp.region_id = DMP_REGION_VPORT; | 69 | mb->un.varDmp.region_id = DMP_REGION_VPORT; |
72 | mb->un.varDmp.word_cnt = DMP_RSP_SIZE/sizeof(uint32_t); | ||
73 | mb->un.varDmp.co = 0; | ||
74 | mb->un.varDmp.resp_offset = 0; | ||
75 | pmb->context2 = ctx; | ||
76 | mb->mbxOwner = OWN_HOST; | 70 | mb->mbxOwner = OWN_HOST; |
77 | 71 | ||
78 | return; | 72 | /* For SLI3 HBAs data is embedded in mailbox */ |
73 | if (phba->sli_rev != LPFC_SLI_REV4) { | ||
74 | mb->un.varDmp.cv = 1; | ||
75 | mb->un.varDmp.word_cnt = DMP_RSP_SIZE/sizeof(uint32_t); | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | /* For SLI4 HBAs driver need to allocate memory */ | ||
80 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); | ||
81 | if (mp) | ||
82 | mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); | ||
83 | |||
84 | if (!mp || !mp->virt) { | ||
85 | kfree(mp); | ||
86 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | ||
87 | "2605 lpfc_dump_static_vport: memory" | ||
88 | " allocation failed\n"); | ||
89 | return 1; | ||
90 | } | ||
91 | memset(mp->virt, 0, LPFC_BPL_SIZE); | ||
92 | INIT_LIST_HEAD(&mp->list); | ||
93 | /* save address for completion */ | ||
94 | pmb->context2 = (uint8_t *) mp; | ||
95 | mb->un.varWords[3] = putPaddrLow(mp->phys); | ||
96 | mb->un.varWords[4] = putPaddrHigh(mp->phys); | ||
97 | mb->un.varDmp.sli4_length = sizeof(struct static_vport_info); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * lpfc_down_link - Bring down HBAs link. | ||
104 | * @phba: pointer to lpfc hba data structure. | ||
105 | * @pmb: pointer to the driver internal queue element for mailbox command. | ||
106 | * | ||
107 | * This routine prepares a mailbox command to bring down HBA link. | ||
108 | **/ | ||
109 | void | ||
110 | lpfc_down_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | ||
111 | { | ||
112 | MAILBOX_t *mb; | ||
113 | memset(pmb, 0, sizeof(LPFC_MBOXQ_t)); | ||
114 | mb = &pmb->u.mb; | ||
115 | mb->mbxCommand = MBX_DOWN_LINK; | ||
116 | mb->mbxOwner = OWN_HOST; | ||
79 | } | 117 | } |
80 | 118 | ||
81 | /** | 119 | /** |
82 | * lpfc_dump_mem - Prepare a mailbox command for retrieving HBA's VPD memory | 120 | * lpfc_dump_mem - Prepare a mailbox command for reading a region. |
83 | * @phba: pointer to lpfc hba data structure. | 121 | * @phba: pointer to lpfc hba data structure. |
84 | * @pmb: pointer to the driver internal queue element for mailbox command. | 122 | * @pmb: pointer to the driver internal queue element for mailbox command. |
85 | * @offset: offset for dumping VPD memory mailbox command. | 123 | * @offset: offset into the region. |
124 | * @region_id: config region id. | ||
86 | * | 125 | * |
87 | * The dump mailbox command provides a method for the device driver to obtain | 126 | * The dump mailbox command provides a method for the device driver to obtain |
88 | * various types of information from the HBA device. | 127 | * various types of information from the HBA device. |
89 | * | 128 | * |
90 | * This routine prepares the mailbox command for dumping HBA Vital Product | 129 | * This routine prepares the mailbox command for dumping HBA's config region. |
91 | * Data (VPD) memory. This mailbox command is to be used for retrieving a | ||
92 | * portion (DMP_RSP_SIZE bytes) of a HBA's VPD from the HBA at an address | ||
93 | * offset specified by the offset parameter. | ||
94 | **/ | 130 | **/ |
95 | void | 131 | void |
96 | lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) | 132 | lpfc_dump_mem(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, uint16_t offset, |
133 | uint16_t region_id) | ||
97 | { | 134 | { |
98 | MAILBOX_t *mb; | 135 | MAILBOX_t *mb; |
99 | void *ctx; | 136 | void *ctx; |
@@ -107,7 +144,7 @@ lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) | |||
107 | mb->un.varDmp.cv = 1; | 144 | mb->un.varDmp.cv = 1; |
108 | mb->un.varDmp.type = DMP_NV_PARAMS; | 145 | mb->un.varDmp.type = DMP_NV_PARAMS; |
109 | mb->un.varDmp.entry_index = offset; | 146 | mb->un.varDmp.entry_index = offset; |
110 | mb->un.varDmp.region_id = DMP_REGION_VPD; | 147 | mb->un.varDmp.region_id = region_id; |
111 | mb->un.varDmp.word_cnt = (DMP_RSP_SIZE / sizeof (uint32_t)); | 148 | mb->un.varDmp.word_cnt = (DMP_RSP_SIZE / sizeof (uint32_t)); |
112 | mb->un.varDmp.co = 0; | 149 | mb->un.varDmp.co = 0; |
113 | mb->un.varDmp.resp_offset = 0; | 150 | mb->un.varDmp.resp_offset = 0; |
@@ -1789,6 +1826,7 @@ lpfc_reg_vfi(struct lpfcMboxq *mbox, struct lpfc_vport *vport, dma_addr_t phys) | |||
1789 | 1826 | ||
1790 | /** | 1827 | /** |
1791 | * lpfc_init_vpi - Initialize the INIT_VPI mailbox command | 1828 | * lpfc_init_vpi - Initialize the INIT_VPI mailbox command |
1829 | * @phba: pointer to the hba structure to init the VPI for. | ||
1792 | * @mbox: pointer to lpfc mbox command to initialize. | 1830 | * @mbox: pointer to lpfc mbox command to initialize. |
1793 | * @vpi: VPI to be initialized. | 1831 | * @vpi: VPI to be initialized. |
1794 | * | 1832 | * |
@@ -1799,11 +1837,14 @@ lpfc_reg_vfi(struct lpfcMboxq *mbox, struct lpfc_vport *vport, dma_addr_t phys) | |||
1799 | * successful virtual NPort login. | 1837 | * successful virtual NPort login. |
1800 | **/ | 1838 | **/ |
1801 | void | 1839 | void |
1802 | lpfc_init_vpi(struct lpfcMboxq *mbox, uint16_t vpi) | 1840 | lpfc_init_vpi(struct lpfc_hba *phba, struct lpfcMboxq *mbox, uint16_t vpi) |
1803 | { | 1841 | { |
1804 | memset(mbox, 0, sizeof(*mbox)); | 1842 | memset(mbox, 0, sizeof(*mbox)); |
1805 | bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_INIT_VPI); | 1843 | bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_INIT_VPI); |
1806 | bf_set(lpfc_init_vpi_vpi, &mbox->u.mqe.un.init_vpi, vpi); | 1844 | bf_set(lpfc_init_vpi_vpi, &mbox->u.mqe.un.init_vpi, |
1845 | vpi + phba->vpi_base); | ||
1846 | bf_set(lpfc_init_vpi_vfi, &mbox->u.mqe.un.init_vpi, | ||
1847 | phba->pport->vfi + phba->vfi_base); | ||
1807 | } | 1848 | } |
1808 | 1849 | ||
1809 | /** | 1850 | /** |
@@ -1852,7 +1893,7 @@ lpfc_dump_fcoe_param(struct lpfc_hba *phba, | |||
1852 | /* dump_fcoe_param failed to allocate memory */ | 1893 | /* dump_fcoe_param failed to allocate memory */ |
1853 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, | 1894 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, |
1854 | "2569 lpfc_dump_fcoe_param: memory" | 1895 | "2569 lpfc_dump_fcoe_param: memory" |
1855 | " allocation failed \n"); | 1896 | " allocation failed\n"); |
1856 | return 1; | 1897 | return 1; |
1857 | } | 1898 | } |
1858 | 1899 | ||
@@ -1864,8 +1905,8 @@ lpfc_dump_fcoe_param(struct lpfc_hba *phba, | |||
1864 | 1905 | ||
1865 | mb->mbxCommand = MBX_DUMP_MEMORY; | 1906 | mb->mbxCommand = MBX_DUMP_MEMORY; |
1866 | mb->un.varDmp.type = DMP_NV_PARAMS; | 1907 | mb->un.varDmp.type = DMP_NV_PARAMS; |
1867 | mb->un.varDmp.region_id = DMP_REGION_FCOEPARAM; | 1908 | mb->un.varDmp.region_id = DMP_REGION_23; |
1868 | mb->un.varDmp.sli4_length = DMP_FCOEPARAM_RGN_SIZE; | 1909 | mb->un.varDmp.sli4_length = DMP_RGN23_SIZE; |
1869 | mb->un.varWords[3] = putPaddrLow(mp->phys); | 1910 | mb->un.varWords[3] = putPaddrLow(mp->phys); |
1870 | mb->un.varWords[4] = putPaddrHigh(mp->phys); | 1911 | mb->un.varWords[4] = putPaddrHigh(mp->phys); |
1871 | return 0; | 1912 | return 0; |
@@ -1938,9 +1979,7 @@ lpfc_resume_rpi(struct lpfcMboxq *mbox, struct lpfc_nodelist *ndlp) | |||
1938 | memset(mbox, 0, sizeof(*mbox)); | 1979 | memset(mbox, 0, sizeof(*mbox)); |
1939 | resume_rpi = &mbox->u.mqe.un.resume_rpi; | 1980 | resume_rpi = &mbox->u.mqe.un.resume_rpi; |
1940 | bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_RESUME_RPI); | 1981 | bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_RESUME_RPI); |
1941 | bf_set(lpfc_resume_rpi_rpi, resume_rpi, ndlp->nlp_rpi); | 1982 | bf_set(lpfc_resume_rpi_index, resume_rpi, ndlp->nlp_rpi); |
1942 | bf_set(lpfc_resume_rpi_vpi, resume_rpi, | 1983 | bf_set(lpfc_resume_rpi_ii, resume_rpi, RESUME_INDEX_RPI); |
1943 | ndlp->vport->vpi + ndlp->vport->phba->vpi_base); | 1984 | resume_rpi->event_tag = ndlp->phba->fc_eventTag; |
1944 | bf_set(lpfc_resume_rpi_vfi, resume_rpi, | ||
1945 | ndlp->vport->vfi + ndlp->vport->phba->vfi_base); | ||
1946 | } | 1985 | } |