17 #define MASK(n) DMA_BIT_MASK(n)
18 #define MN_WIN(addr) (((addr & 0x1fc0000) >> 1) | ((addr >> 25) & 0x3ff))
19 #define OCM_WIN(addr) (((addr & 0x1ff0000) >> 1) | ((addr >> 25) & 0x3ff))
20 #define MS_WIN(addr) (addr & 0x0ffc0000)
21 #define QLA82XX_PCI_MN_2M (0)
22 #define QLA82XX_PCI_MS_2M (0x80000)
23 #define QLA82XX_PCI_OCM0_2M (0xc0000)
24 #define VALID_OCM_ADDR(addr) (((addr) & 0x3f800) != 0x3f800)
25 #define GET_MEM_OFFS_2M(addr) (addr & MASK(18))
28 #define CRB_BLK(off) ((off >> 20) & 0x3f)
29 #define CRB_SUBBLK(off) ((off >> 16) & 0xf)
30 #define CRB_WINDOW_2M (0x130060)
31 #define CRB_HI(off) ((qla4_82xx_crb_hub_agt[CRB_BLK(off)] << 20) | \
33 #define QLA82XX_PCI_CAMQM_2M_END (0x04800800UL)
34 #define QLA82XX_PCI_CAMQM_2M_BASE (0x000ff800UL)
35 #define CRB_INDIRECT_2M (0x1e0000UL)
38 qla4_8xxx_pci_base_offsetfset(
struct scsi_qla_host *ha,
unsigned long off)
40 if ((off < ha->first_page_group_end) &&
47 #define MAX_CRB_XFORM 60
49 static int qla4_8xxx_crb_table_initialized;
51 #define qla4_8xxx_crb_addr_transform(name) \
52 (crb_addr_xform[QLA82XX_HW_PX_MAP_CRB_##name] = \
53 QLA82XX_HW_CRB_HUB_AGT_ADR_##name << 20)
55 qla4_82xx_crb_addr_transform_setup(
void)
109 qla4_8xxx_crb_table_initialized = 1;
114 {{{1, 0x0100000, 0x0102000, 0x120000},
115 {1, 0x0110000, 0x0120000, 0x130000},
116 {1, 0x0120000, 0x0122000, 0x124000},
117 {1, 0x0130000, 0x0132000, 0x126000},
118 {1, 0x0140000, 0x0142000, 0x128000},
119 {1, 0x0150000, 0x0152000, 0x12a000},
120 {1, 0x0160000, 0x0170000, 0x110000},
121 {1, 0x0170000, 0x0172000, 0x12e000},
122 {0, 0x0000000, 0x0000000, 0x000000},
123 {0, 0x0000000, 0x0000000, 0x000000},
124 {0, 0x0000000, 0x0000000, 0x000000},
125 {0, 0x0000000, 0x0000000, 0x000000},
126 {0, 0x0000000, 0x0000000, 0x000000},
127 {0, 0x0000000, 0x0000000, 0x000000},
128 {1, 0x01e0000, 0x01e0800, 0x122000},
129 {0, 0x0000000, 0x0000000, 0x000000} } },
130 {{{1, 0x0200000, 0x0210000, 0x180000} } },
132 {{{1, 0x0400000, 0x0401000, 0x169000} } },
133 {{{1, 0x0500000, 0x0510000, 0x140000} } },
134 {{{1, 0x0600000, 0x0610000, 0x1c0000} } },
135 {{{1, 0x0700000, 0x0704000, 0x1b8000} } },
136 {{{1, 0x0800000, 0x0802000, 0x170000},
137 {0, 0x0000000, 0x0000000, 0x000000},
138 {0, 0x0000000, 0x0000000, 0x000000},
139 {0, 0x0000000, 0x0000000, 0x000000},
140 {0, 0x0000000, 0x0000000, 0x000000},
141 {0, 0x0000000, 0x0000000, 0x000000},
142 {0, 0x0000000, 0x0000000, 0x000000},
143 {0, 0x0000000, 0x0000000, 0x000000},
144 {0, 0x0000000, 0x0000000, 0x000000},
145 {0, 0x0000000, 0x0000000, 0x000000},
146 {0, 0x0000000, 0x0000000, 0x000000},
147 {0, 0x0000000, 0x0000000, 0x000000},
148 {0, 0x0000000, 0x0000000, 0x000000},
149 {0, 0x0000000, 0x0000000, 0x000000},
150 {0, 0x0000000, 0x0000000, 0x000000},
151 {1, 0x08f0000, 0x08f2000, 0x172000} } },
152 {{{1, 0x0900000, 0x0902000, 0x174000},
153 {0, 0x0000000, 0x0000000, 0x000000},
154 {0, 0x0000000, 0x0000000, 0x000000},
155 {0, 0x0000000, 0x0000000, 0x000000},
156 {0, 0x0000000, 0x0000000, 0x000000},
157 {0, 0x0000000, 0x0000000, 0x000000},
158 {0, 0x0000000, 0x0000000, 0x000000},
159 {0, 0x0000000, 0x0000000, 0x000000},
160 {0, 0x0000000, 0x0000000, 0x000000},
161 {0, 0x0000000, 0x0000000, 0x000000},
162 {0, 0x0000000, 0x0000000, 0x000000},
163 {0, 0x0000000, 0x0000000, 0x000000},
164 {0, 0x0000000, 0x0000000, 0x000000},
165 {0, 0x0000000, 0x0000000, 0x000000},
166 {0, 0x0000000, 0x0000000, 0x000000},
167 {1, 0x09f0000, 0x09f2000, 0x176000} } },
168 {{{0, 0x0a00000, 0x0a02000, 0x178000},
169 {0, 0x0000000, 0x0000000, 0x000000},
170 {0, 0x0000000, 0x0000000, 0x000000},
171 {0, 0x0000000, 0x0000000, 0x000000},
172 {0, 0x0000000, 0x0000000, 0x000000},
173 {0, 0x0000000, 0x0000000, 0x000000},
174 {0, 0x0000000, 0x0000000, 0x000000},
175 {0, 0x0000000, 0x0000000, 0x000000},
176 {0, 0x0000000, 0x0000000, 0x000000},
177 {0, 0x0000000, 0x0000000, 0x000000},
178 {0, 0x0000000, 0x0000000, 0x000000},
179 {0, 0x0000000, 0x0000000, 0x000000},
180 {0, 0x0000000, 0x0000000, 0x000000},
181 {0, 0x0000000, 0x0000000, 0x000000},
182 {0, 0x0000000, 0x0000000, 0x000000},
183 {1, 0x0af0000, 0x0af2000, 0x17a000} } },
184 {{{0, 0x0b00000, 0x0b02000, 0x17c000},
185 {0, 0x0000000, 0x0000000, 0x000000},
186 {0, 0x0000000, 0x0000000, 0x000000},
187 {0, 0x0000000, 0x0000000, 0x000000},
188 {0, 0x0000000, 0x0000000, 0x000000},
189 {0, 0x0000000, 0x0000000, 0x000000},
190 {0, 0x0000000, 0x0000000, 0x000000},
191 {0, 0x0000000, 0x0000000, 0x000000},
192 {0, 0x0000000, 0x0000000, 0x000000},
193 {0, 0x0000000, 0x0000000, 0x000000},
194 {0, 0x0000000, 0x0000000, 0x000000},
195 {0, 0x0000000, 0x0000000, 0x000000},
196 {0, 0x0000000, 0x0000000, 0x000000},
197 {0, 0x0000000, 0x0000000, 0x000000},
198 {0, 0x0000000, 0x0000000, 0x000000},
199 {1, 0x0bf0000, 0x0bf2000, 0x17e000} } },
200 {{{1, 0x0c00000, 0x0c04000, 0x1d4000} } },
201 {{{1, 0x0d00000, 0x0d04000, 0x1a4000} } },
202 {{{1, 0x0e00000, 0x0e04000, 0x1a0000} } },
203 {{{1, 0x0f00000, 0x0f01000, 0x164000} } },
204 {{{0, 0x1000000, 0x1004000, 0x1a8000} } },
205 {{{1, 0x1100000, 0x1101000, 0x160000} } },
206 {{{1, 0x1200000, 0x1201000, 0x161000} } },
207 {{{1, 0x1300000, 0x1301000, 0x162000} } },
208 {{{1, 0x1400000, 0x1401000, 0x163000} } },
209 {{{1, 0x1500000, 0x1501000, 0x165000} } },
210 {{{1, 0x1600000, 0x1601000, 0x166000} } },
217 {{{1, 0x1d00000, 0x1d10000, 0x190000} } },
218 {{{1, 0x1e00000, 0x1e01000, 0x16a000} } },
219 {{{1, 0x1f00000, 0x1f10000, 0x150000} } },
221 {{{1, 0x2100000, 0x2102000, 0x120000},
222 {1, 0x2110000, 0x2120000, 0x130000},
223 {1, 0x2120000, 0x2122000, 0x124000},
224 {1, 0x2130000, 0x2132000, 0x126000},
225 {1, 0x2140000, 0x2142000, 0x128000},
226 {1, 0x2150000, 0x2152000, 0x12a000},
227 {1, 0x2160000, 0x2170000, 0x110000},
228 {1, 0x2170000, 0x2172000, 0x12e000},
229 {0, 0x0000000, 0x0000000, 0x000000},
230 {0, 0x0000000, 0x0000000, 0x000000},
231 {0, 0x0000000, 0x0000000, 0x000000},
232 {0, 0x0000000, 0x0000000, 0x000000},
233 {0, 0x0000000, 0x0000000, 0x000000},
234 {0, 0x0000000, 0x0000000, 0x000000},
235 {0, 0x0000000, 0x0000000, 0x000000},
236 {0, 0x0000000, 0x0000000, 0x000000} } },
237 {{{1, 0x2200000, 0x2204000, 0x1b0000} } },
243 {{{1, 0x2800000, 0x2804000, 0x1a4000} } },
244 {{{1, 0x2900000, 0x2901000, 0x16b000} } },
245 {{{1, 0x2a00000, 0x2a00400, 0x1ac400} } },
246 {{{1, 0x2b00000, 0x2b00400, 0x1ac800} } },
247 {{{1, 0x2c00000, 0x2c00400, 0x1acc00} } },
248 {{{1, 0x2d00000, 0x2d00400, 0x1ad000} } },
249 {{{1, 0x2e00000, 0x2e00400, 0x1ad400} } },
250 {{{1, 0x2f00000, 0x2f00400, 0x1ad800} } },
251 {{{1, 0x3000000, 0x3000400, 0x1adc00} } },
252 {{{0, 0x3100000, 0x3104000, 0x1a8000} } },
253 {{{1, 0x3200000, 0x3204000, 0x1d4000} } },
254 {{{1, 0x3300000, 0x3304000, 0x1a0000} } },
256 {{{1, 0x3500000, 0x3500400, 0x1ac000} } },
257 {{{1, 0x3600000, 0x3600400, 0x1ae000} } },
258 {{{1, 0x3700000, 0x3700400, 0x1ae400} } },
259 {{{1, 0x3800000, 0x3804000, 0x1d0000} } },
260 {{{1, 0x3900000, 0x3904000, 0x1b4000} } },
261 {{{1, 0x3a00000, 0x3a04000, 0x1d8000} } },
264 {{{1, 0x3d00000, 0x3d04000, 0x1dc000} } },
265 {{{1, 0x3e00000, 0x3e01000, 0x167000} } },
266 {{{1, 0x3f00000, 0x3f01000, 0x168000} } }
272 static unsigned qla4_82xx_crb_hub_agt[64] = {
340 static char *qdev_state[] = {
370 "%s: Written crbwin (0x%x) != Read crbwin (0x%x),"
371 " off=0x%lx\n", __func__, ha->
crb_win, win_read, *off));
379 unsigned long flags = 0;
389 qla4_82xx_pci_set_crbwindow_2M(ha, &off);
402 unsigned long flags = 0;
413 qla4_82xx_pci_set_crbwindow_2M(ha, &off);
430 off_value = off & 0xFFFF0000;
438 if (win_read != off_value) {
440 "%s: Written (0x%x) != Read (0x%x), off=0x%x\n",
441 __func__, off_value, win_read, off));
444 off_value = off & 0x0000FFFF;
456 off_value = off & 0xFFFF0000;
463 if (win_read != off_value) {
465 "%s: Written (0x%x) != Read (0x%x), off=0x%x\n",
466 __func__, off_value, win_read, off));
469 off_value = off & 0x0000FFFF;
476 #define CRB_WIN_LOCK_TIMEOUT 100000000
497 for (i = 0; i < 20; i++)
510 #define IDC_LOCK_TIMEOUT 100000000
538 for (i = 0; i < 20; i++)
597 ((size != 1) && (size != 2) && (size != 4) && (size != 8))) {
603 static int qla4_82xx_pci_set_window_warning_count;
606 qla4_82xx_pci_set_window(
struct scsi_qla_host *ha,
unsigned long long addr)
620 if ((win_read << 17) != window) {
622 "%s: Written MNwin (0x%x) != Read MNwin (0x%x)\n",
623 __func__, window, win_read);
630 if ((addr & 0x00ff800) == 0xff800) {
631 printk(
"%s: QM access not handled.\n", __func__);
641 temp1 = ((window & 0x1FF) << 7) |
642 ((window & 0x0FFFE0000) >> 17);
643 if (win_read != temp1) {
644 printk(
"%s: Written OCMwin (0x%x) != Read"
645 " OCMwin (0x%x)\n", __func__, temp1, win_read);
658 if (win_read != window) {
659 printk(
"%s: Written MSwin (0x%x) != Read "
660 "MSwin (0x%x)\n", __func__, window, win_read);
669 if ((qla4_82xx_pci_set_window_warning_count++ < 8) ||
670 (qla4_82xx_pci_set_window_warning_count%64 == 0)) {
671 printk(
"%s: Warning:%s Unknown address range!\n",
680 static int qla4_82xx_pci_is_same_window(
struct scsi_qla_host *ha,
681 unsigned long long addr)
684 unsigned long long qdr_max;
709 static int qla4_82xx_pci_mem_read_direct(
struct scsi_qla_host *ha,
718 unsigned long mem_page;
726 start = qla4_82xx_pci_set_window(ha, off);
727 if ((start == -1
UL) ||
728 (qla4_82xx_pci_is_same_window(ha, off + size - 1) == 0)) {
735 addr = qla4_8xxx_pci_base_offsetfset(ha, start);
743 if (mem_page != ((start + size - 1) & PAGE_MASK))
748 if (mem_ptr ==
NULL) {
783 void *data,
int size)
791 unsigned long mem_page;
799 start = qla4_82xx_pci_set_window(ha, off);
800 if ((start == -1
UL) ||
801 (qla4_82xx_pci_is_same_window(ha, off + size - 1) == 0)) {
808 addr = qla4_8xxx_pci_base_offsetfset(ha, start);
816 if (mem_page != ((start + size - 1) & PAGE_MASK))
851 #define MTU_FUDGE_FACTOR 100
854 qla4_82xx_decode_crb_addr(
unsigned long addr)
857 unsigned long base_addr,
offset, pci_base;
859 if (!qla4_8xxx_crb_table_initialized)
860 qla4_82xx_crb_addr_transform_setup();
863 base_addr = addr & 0xfff00000;
864 offset = addr & 0x000fffff;
867 if (crb_addr_xform[i] == base_addr) {
878 static long rom_max_timeout = 100;
879 static long qla4_82xx_rom_lock_timeout = 100;
893 if (timeout >= qla4_82xx_rom_lock_timeout)
902 for (i = 0; i < 20; i++)
926 if (timeout >= rom_max_timeout) {
927 printk(
"%s: Timeout reached waiting for rom done",
936 qla4_82xx_do_rom_fast_read(
struct scsi_qla_host *ha,
int addr,
int *valp)
942 if (qla4_82xx_wait_rom_done(ha)) {
956 qla4_82xx_rom_fast_read(
struct scsi_qla_host *ha,
int addr,
int *valp)
960 while ((qla4_82xx_rom_lock(ha) != 0) && (loops < 50000)) {
964 if (loops >= 50000) {
969 ret = qla4_82xx_do_rom_fast_read(ha, addr, valp);
970 qla4_82xx_rom_unlock(ha);
993 qla4_82xx_rom_lock(ha);
1046 qla4_82xx_rom_unlock(ha);
1053 if (qla4_82xx_rom_fast_read(ha, 0, &n) != 0 || n != 0xcafecafeUL ||
1054 qla4_82xx_rom_fast_read(ha, 4, &n) != 0) {
1056 "[ERROR] Reading crb_init area: n: %08x\n", n);
1063 offset = n & 0xffff
U;
1064 n = (n >> 16) & 0xffffU;
1069 "%s: %s:n=0x%x [ERROR] Card flash not initialized.\n",
1075 "%s: %d CRB init values found in ROM.\n",
DRIVER_NAME, n);
1080 "%s: [ERROR] Unable to malloc memory.\n",
DRIVER_NAME);
1084 for (i = 0; i <
n; i++) {
1085 if (qla4_82xx_rom_fast_read(ha, 8*i + 4*offset, &val) != 0 ||
1086 qla4_82xx_rom_fast_read(ha, 8*i + 4*offset + 4, &addr) !=
1096 for (i = 0; i <
n; i++) {
1100 off = qla4_82xx_decode_crb_addr((
unsigned long)buf[i].addr) +
1109 "Skip CRB init replay for offset = 0x%lx\n", off));
1140 "%s: [ERROR] Unknown addr: 0x%08lx\n",
1188 flashaddr = memaddr = ha->
hw.flt_region_bootload;
1189 size = (image_start - flashaddr) / 8;
1191 DEBUG2(
printk(
"scsi%ld: %s: bootldr=0x%lx, fw_image=0x%x\n",
1192 ha->
host_no, __func__, flashaddr, image_start));
1194 for (i = 0; i <
size; i++) {
1195 if ((qla4_82xx_rom_fast_read(ha, flashaddr, (
int *)&low)) ||
1196 (qla4_82xx_rom_fast_read(ha, flashaddr + 4,
1199 goto exit_load_from_flash;
1201 data = ((
u64)high << 32) |
low ;
1204 goto exit_load_from_flash;
1209 if (i % 0x1000 == 0)
1221 exit_load_from_flash:
1230 if (qla4_82xx_pinit_from_rom(ha, 0) !=
QLA_SUCCESS) {
1248 if (qla4_82xx_load_from_flash(ha, image_start)) {
1249 printk(
"%s: Error trying to load fw from flash!\n", __func__);
1258 u64 off,
void *data,
int size)
1260 int i,
j = 0,
k,
start,
end, loop, sz[2], off0[2];
1273 if (qla4_82xx_pci_mem_bound_check(ha, off, size) == 0)
1274 return qla4_82xx_pci_mem_read_direct(ha,
1279 off8 = off & 0xfffffff0;
1280 off0[0] = off & 0xf;
1281 sz[0] = (size < (16 - off0[0])) ? size : (16 - off0[0]);
1284 loop = ((off0[0] + size - 1) >> shift_amount) + 1;
1286 sz[1] = size - sz[0];
1288 for (i = 0; i < loop; i++) {
1289 temp = off8 + (i << shift_amount);
1304 if (j >= MAX_CTL_CHECK) {
1306 "%s: failed to read through agent\n",
1311 start = off0[
i] >> 2;
1312 end = (off0[
i] + sz[
i] - 1) >> 2;
1313 for (
k = start;
k <=
end;
k++) {
1316 word[
i] |= ((
uint64_t)temp << (32 * (
k & 1)));
1323 if ((off0[0] & 7) == 0) {
1326 val = ((word[0] >> (off0[0] * 8)) & (~(~0ULL << (sz[0] * 8)))) |
1327 ((word[1] & (~(~0ULL << (sz[1] * 8)))) << (sz[0] * 8));
1349 u64 off,
void *data,
int size)
1351 int i,
j, ret = 0, loop, sz[2], off0;
1352 int scale, shift_amount, startword;
1363 if (qla4_82xx_pci_mem_bound_check(ha, off, size) == 0)
1364 return qla4_82xx_pci_mem_write_direct(ha,
1369 sz[0] = (size < (8 - off0)) ? size : (8 - off0);
1370 sz[1] = size - sz[0];
1372 off8 = off & 0xfffffff0;
1373 loop = (((off & 0xf) + size - 1) >> 4) + 1;
1376 startword = (off & 0xf)/8;
1378 for (i = 0; i < loop; i++) {
1380 (i << shift_amount), &word[i * scale], 8))
1401 word[startword] = tmpw;
1404 ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8));
1405 word[startword] |= tmpw << (off0 * 8);
1409 word[startword+1] &= ~(~0ULL << (sz[1] * 8));
1410 word[startword+1] |= tmpw >> (sz[0] * 8);
1413 for (i = 0; i < loop; i++) {
1414 temp = off8 + (i << shift_amount);
1418 temp = word[i * scale] & 0xffffffff;
1420 temp = (word[i * scale] >> 32) & 0xffffffff;
1422 temp = word[i*scale + 1] & 0xffffffff;
1425 temp = (word[i*scale + 1] >> 32) & 0xffffffff;
1440 if (j >= MAX_CTL_CHECK) {
1441 if (printk_ratelimit())
1443 "%s: failed to read through agent\n",
1453 static int qla4_82xx_cmdpeg_ready(
struct scsi_qla_host *ha,
int pegtune_val)
1467 }
while (--retries);
1473 "pegtune_val = %x\n", __func__, pegtune_val);
1500 if (loops >= 30000) {
1502 "Receive Peg initialization not complete: 0x%x.\n", state));
1524 drv_active |= (1 << (ha->
func_num * 4));
1527 __func__, ha->
host_no, drv_active);
1544 drv_active &= ~(1 << (ha->
func_num));
1546 drv_active &= ~(1 << (ha->
func_num * 4));
1549 __func__, ha->
host_no, drv_active);
1567 rval = drv_state & (1 << ha->
func_num);
1569 rval = drv_state & (1 << (ha->
func_num * 4));
1591 drv_state |= (1 << (ha->
func_num * 4));
1594 __func__, ha->
host_no, drv_state);
1612 drv_state &= ~(1 << (ha->
func_num * 4));
1615 __func__, ha->
host_no, drv_state);
1634 qsnt_state |= (2 << (ha->
func_num * 4));
1654 if (qla4_82xx_load_fw(ha, image_start) !=
QLA_SUCCESS) {
1655 printk(
"%s: Error trying to start fw!\n", __func__);
1660 if (qla4_82xx_cmdpeg_ready(ha, 0) !=
QLA_SUCCESS) {
1661 printk(
"%s: Error during card handshake!\n", __func__);
1670 return qla4_82xx_rcvpeg_ready(ha);
1684 "FW: Retrieving flash offsets from FLT/FDT ...\n");
1690 "FW: Attempting to load firmware from flash...\n");
1691 rval = qla4_82xx_start_firmware(ha, ha->
hw.flt_region_fw);
1704 if (qla4_82xx_rom_lock(ha)) {
1714 qla4_82xx_rom_unlock(ha);
1717 static void qla4_8xxx_minidump_process_rdcrb(
struct scsi_qla_host *ha,
1727 r_addr = crb_hdr->
addr;
1728 r_stride = crb_hdr->
crb_strd.addr_stride;
1731 for (i = 0; i < loop_cnt; i++) {
1732 ha->
isp_ops->rd_reg_indirect(ha, r_addr, &r_value);
1740 static int qla4_8xxx_minidump_process_l2tag(
struct scsi_qla_host *ha,
1745 uint32_t i,
k, loop_count, t_value, r_cnt, r_value;
1746 unsigned long p_wait, w_time, p_mask;
1758 c_value_w = cache_hdr->
cache_ctrl.write_value;
1761 t_value = cache_hdr->
addr_ctrl.init_tag_value;
1762 r_cnt = cache_hdr->
read_ctrl.read_addr_cnt;
1766 for (i = 0; i < loop_count; i++) {
1767 ha->
isp_ops->wr_reg_indirect(ha, t_r_addr, t_value);
1770 ha->
isp_ops->wr_reg_indirect(ha, c_addr, c_value_w);
1775 ha->
isp_ops->rd_reg_indirect(ha, c_addr,
1777 if ((c_value_r & p_mask) == 0) {
1787 for (k = 0; k < r_cnt; k++) {
1788 ha->
isp_ops->rd_reg_indirect(ha, addr, &r_value);
1790 addr += cache_hdr->
read_ctrl.read_addr_stride;
1793 t_value += cache_hdr->
addr_ctrl.tag_value_stride;
1799 static int qla4_8xxx_minidump_process_control(
struct scsi_qla_host *ha,
1805 unsigned long wtime;
1814 crb_addr = crb_entry->
addr;
1815 for (i = 0; i < crb_entry->
op_count; i++) {
1816 opcode = crb_entry->
crb_ctrl.opcode;
1818 ha->
isp_ops->wr_reg_indirect(ha, crb_addr,
1820 opcode &= ~QLA8XXX_DBG_OPCODE_WR;
1823 ha->
isp_ops->rd_reg_indirect(ha, crb_addr, &read_value);
1824 ha->
isp_ops->wr_reg_indirect(ha, crb_addr, read_value);
1825 opcode &= ~QLA8XXX_DBG_OPCODE_RW;
1828 ha->
isp_ops->rd_reg_indirect(ha, crb_addr, &read_value);
1829 read_value &= crb_entry->
value_2;
1830 opcode &= ~QLA8XXX_DBG_OPCODE_AND;
1832 read_value |= crb_entry->
value_3;
1833 opcode &= ~QLA8XXX_DBG_OPCODE_OR;
1835 ha->
isp_ops->wr_reg_indirect(ha, crb_addr, read_value);
1837 if (opcode & QLA8XXX_DBG_OPCODE_OR) {
1838 ha->
isp_ops->rd_reg_indirect(ha, crb_addr, &read_value);
1839 read_value |= crb_entry->
value_3;
1840 ha->
isp_ops->wr_reg_indirect(ha, crb_addr, read_value);
1841 opcode &= ~QLA8XXX_DBG_OPCODE_OR;
1844 poll_time = crb_entry->
crb_strd.poll_timeout;
1846 ha->
isp_ops->rd_reg_indirect(ha, crb_addr, &read_value);
1849 if ((read_value & crb_entry->
value_2) ==
1857 ha->
isp_ops->rd_reg_indirect(ha,
1858 crb_addr, &read_value);
1861 opcode &= ~QLA8XXX_DBG_OPCODE_POLL;
1865 if (crb_entry->
crb_strd.state_index_a) {
1866 index = crb_entry->
crb_strd.state_index_a;
1872 ha->
isp_ops->rd_reg_indirect(ha, addr, &read_value);
1873 index = crb_entry->
crb_ctrl.state_index_v;
1875 opcode &= ~QLA8XXX_DBG_OPCODE_RDSTATE;
1879 if (crb_entry->
crb_strd.state_index_a) {
1880 index = crb_entry->
crb_strd.state_index_a;
1886 if (crb_entry->
crb_ctrl.state_index_v) {
1887 index = crb_entry->
crb_ctrl.state_index_v;
1891 read_value = crb_entry->
value_1;
1894 ha->
isp_ops->wr_reg_indirect(ha, addr, read_value);
1895 opcode &= ~QLA8XXX_DBG_OPCODE_WRSTATE;
1899 index = crb_entry->
crb_ctrl.state_index_v;
1901 read_value <<= crb_entry->
crb_ctrl.shl;
1902 read_value >>= crb_entry->
crb_ctrl.shr;
1904 read_value &= crb_entry->
value_2;
1905 read_value |= crb_entry->
value_3;
1906 read_value += crb_entry->
value_1;
1908 opcode &= ~QLA8XXX_DBG_OPCODE_MDSTATE;
1910 crb_addr += crb_entry->
crb_strd.addr_stride;
1916 static void qla4_8xxx_minidump_process_rdocm(
struct scsi_qla_host *ha,
1931 "[%s]: r_addr: 0x%x, r_stride: 0x%x, loop_cnt: 0x%x\n",
1932 __func__, r_addr, r_stride, loop_cnt));
1934 for (i = 0; i < loop_cnt; i++) {
1940 __func__, (
long unsigned int) (loop_cnt *
sizeof(
uint32_t))));
1944 static void qla4_8xxx_minidump_process_rdmux(
struct scsi_qla_host *ha,
1960 for (i = 0; i < loop_cnt; i++) {
1961 ha->
isp_ops->wr_reg_indirect(ha, s_addr, s_value);
1962 ha->
isp_ops->rd_reg_indirect(ha, r_addr, &r_value);
1965 s_value += s_stride;
1970 static void qla4_8xxx_minidump_process_l1cache(
struct scsi_qla_host *ha,
1975 uint32_t i,
k, loop_count, t_value, r_cnt, r_value;
1984 c_value_w = cache_hdr->
cache_ctrl.write_value;
1987 t_value = cache_hdr->
addr_ctrl.init_tag_value;
1988 r_cnt = cache_hdr->
read_ctrl.read_addr_cnt;
1990 for (i = 0; i < loop_count; i++) {
1991 ha->
isp_ops->wr_reg_indirect(ha, t_r_addr, t_value);
1992 ha->
isp_ops->wr_reg_indirect(ha, c_addr, c_value_w);
1994 for (k = 0; k < r_cnt; k++) {
1995 ha->
isp_ops->rd_reg_indirect(ha, addr, &r_value);
1997 addr += cache_hdr->
read_ctrl.read_addr_stride;
1999 t_value += cache_hdr->
addr_ctrl.tag_value_stride;
2004 static void qla4_8xxx_minidump_process_queue(
struct scsi_qla_host *ha,
2017 r_cnt = q_hdr->
rd_strd.read_addr_cnt;
2018 r_stride = q_hdr->
rd_strd.read_addr_stride;
2021 for (i = 0; i < loop_cnt; i++) {
2022 ha->
isp_ops->wr_reg_indirect(ha, s_addr, qid);
2024 for (k = 0; k < r_cnt; k++) {
2025 ha->
isp_ops->rd_reg_indirect(ha, r_addr, &r_value);
2029 qid += q_hdr->
q_strd.queue_id_stride;
2034 #define MD_DIRECT_ROM_WINDOW 0x42110030
2035 #define MD_DIRECT_ROM_READ_BASE 0x42150000
2037 static void qla4_82xx_minidump_process_rdrom(
struct scsi_qla_host *ha,
2052 "[%s]: flash_addr: 0x%x, read_data_size: 0x%x\n",
2053 __func__, r_addr, loop_cnt));
2055 for (i = 0; i < loop_cnt; i++) {
2057 (r_addr & 0xFFFF0000));
2058 ha->
isp_ops->rd_reg_indirect(ha,
2067 #define MD_MIU_TEST_AGT_CTRL 0x41000090
2068 #define MD_MIU_TEST_AGT_ADDR_LO 0x41000094
2069 #define MD_MIU_TEST_AGT_ADDR_HI 0x41000098
2071 static int qla4_8xxx_minidump_process_rdmem(
struct scsi_qla_host *ha,
2078 unsigned long flags;
2087 "[%s]: Read addr: 0x%x, read_data_size: 0x%x\n",
2092 "[%s]: Read addr 0x%x not 16 bytes alligned\n",
2099 "[%s]: Read data[0x%x] not multiple of 16 bytes\n",
2105 "[%s]: rdmem_addr: 0x%x, read_data_size: 0x%x, loop_cnt: 0x%x\n",
2109 for (i = 0; i < loop_cnt; i++) {
2127 if (j >= MAX_CTL_CHECK) {
2129 "%s: failed to read through agent\n",
2135 for (j = 0; j < 4; j++) {
2136 ha->
isp_ops->rd_reg_indirect(ha,
2137 MD_MIU_TEST_AGT_RDDATA[j],
2147 __func__, (loop_cnt * 16)));
2153 static void qla4_8xxx_mark_entry_skipped(
struct scsi_qla_host *ha,
2159 "scsi(%ld): Skipping entry[%d]: ETYPE[0x%x]-ELEVEL[0x%x]\n",
2161 entry_hdr->
d_ctrl.entry_capture_mask));
2185 ha->
isp_ops->wr_reg_indirect(ha, s_addr, s_value);
2188 ha->
isp_ops->rd_reg_indirect(ha, s_addr, &r_value);
2190 if ((r_value & poll_mask) != 0) {
2194 if (--poll_wait == 0) {
2198 goto exit_process_pollrd;
2202 ha->
isp_ops->rd_reg_indirect(ha, r_addr, &r_value);
2205 s_value += s_stride;
2210 exit_process_pollrd:
2214 static void qla83xx_minidump_process_rdmux2(
struct scsi_qla_host *ha,
2231 for (i = 0; i < rdmux2_hdr->
op_count; i++) {
2232 ha->
isp_ops->wr_reg_indirect(ha, sel_addr1, sel_val1);
2233 t_sel_val = sel_val1 & sel_val_mask;
2236 ha->
isp_ops->wr_reg_indirect(ha, sel_addr2, t_sel_val);
2237 ha->
isp_ops->rd_reg_indirect(ha, read_addr, &data);
2241 ha->
isp_ops->wr_reg_indirect(ha, sel_addr1, sel_val2);
2242 t_sel_val = sel_val2 & sel_val_mask;
2245 ha->
isp_ops->wr_reg_indirect(ha, sel_addr2, t_sel_val);
2246 ha->
isp_ops->rd_reg_indirect(ha, read_addr, &data);
2262 uint32_t addr_1, addr_2, value_1, value_2;
2274 ha->
isp_ops->wr_reg_indirect(ha, addr_1, value_1);
2278 ha->
isp_ops->rd_reg_indirect(ha, addr_1, &r_value);
2280 if ((r_value & poll_mask) != 0) {
2284 if (--poll_wait == 0) {
2288 goto exit_process_pollrdmwr;
2293 ha->
isp_ops->rd_reg_indirect(ha, addr_2, &data);
2295 ha->
isp_ops->wr_reg_indirect(ha, addr_2, data);
2296 ha->
isp_ops->wr_reg_indirect(ha, addr_1, value_2);
2300 ha->
isp_ops->rd_reg_indirect(ha, addr_1, &r_value);
2302 if ((r_value & poll_mask) != 0) {
2306 if (--poll_wait == 0) {
2310 goto exit_process_pollrdmwr;
2319 exit_process_pollrdmwr:
2336 __func__, fl_addr, u32_count));
2339 (
u8 *)(data_ptr), u32_count);
2343 __func__, u32_count);
2344 goto exit_process_rdrom;
2347 data_ptr += u32_count;
2358 static int qla4_8xxx_collect_md_data(
struct scsi_qla_host *ha)
2360 int num_entry_hdr = 0;
2383 __func__, data_ptr);
2385 "[%s]: no of entry headers in Template: 0x%x\n",
2386 __func__, num_entry_hdr);
2406 for (i = 0; i < num_entry_hdr; i++) {
2409 "Data collected: [0x%x], Total Dump size: [0x%x]\n",
2414 if (!(entry_hdr->
d_ctrl.entry_capture_mask &
2416 entry_hdr->
d_ctrl.driver_flags |=
2418 goto skip_nxt_entry;
2422 "Data collected: [0x%x], Dump size left:[0x%x]\n",
2431 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2434 rval = qla4_8xxx_minidump_process_control(ha,
2437 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2442 qla4_8xxx_minidump_process_rdcrb(ha, entry_hdr,
2446 rval = qla4_8xxx_minidump_process_rdmem(ha, entry_hdr,
2449 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2455 if (is_qla8022(ha)) {
2456 qla4_82xx_minidump_process_rdrom(ha, entry_hdr,
2458 }
else if (is_qla8032(ha)) {
2459 rval = qla4_83xx_minidump_process_rdrom(ha,
2463 qla4_8xxx_mark_entry_skipped(ha,
2472 rval = qla4_8xxx_minidump_process_l2tag(ha, entry_hdr,
2475 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2483 qla4_8xxx_minidump_process_l1cache(ha, entry_hdr,
2487 qla4_8xxx_minidump_process_rdocm(ha, entry_hdr,
2491 qla4_8xxx_minidump_process_rdmux(ha, entry_hdr,
2495 qla4_8xxx_minidump_process_queue(ha, entry_hdr,
2499 if (!is_qla8032(ha)) {
2500 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2503 rval = qla83xx_minidump_process_pollrd(ha, entry_hdr,
2506 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2509 if (!is_qla8032(ha)) {
2510 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2513 qla83xx_minidump_process_rdmux2(ha, entry_hdr,
2517 if (!is_qla8032(ha)) {
2518 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2521 rval = qla83xx_minidump_process_pollrdmwr(ha, entry_hdr,
2524 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2528 qla4_8xxx_mark_entry_skipped(ha, entry_hdr, i);
2532 data_collected = (
uint8_t *)data_ptr -
2544 "Dump data mismatch: Data collected: [0x%x], total_data_size:[0x%x]\n",
2561 char event_string[40];
2562 char *envp[] = { event_string,
NULL };
2566 snprintf(event_string,
sizeof(event_string),
"FW_DUMP=%ld",
2581 if (!qla4_8xxx_collect_md_data(ha)) {
2602 int need_reset = 0, peg_stuck = 1;
2604 need_reset = ha->
isp_ops->need_reset(ha);
2607 for (i = 0; i < 10; i++) {
2616 if (count != old_count)
2623 ha->
isp_ops->rom_lock_recovery(ha);
2624 goto dev_initialize;
2629 ha->
isp_ops->rom_lock_recovery(ha);
2630 goto dev_initialize;
2648 if (is_qla8032(ha)) {
2652 (idc_ctrl & ~GRACEFUL_RESET_BIT1));
2662 rval = ha->
isp_ops->restart_firmware(ha);
2691 unsigned long reset_timeout;
2694 "Performing ISP error recovery\n");
2698 ha->
isp_ops->disable_intrs(ha);
2704 "%s(%ld): reset acknowledged\n",
2708 active_mask = (~(1 << (ha->
func_num * 4)));
2718 "%s(%ld): drv_state = 0x%x, drv_active = 0x%x\n",
2719 __func__, ha->
host_no, drv_state, drv_active);
2721 while (drv_state != (drv_active & active_mask)) {
2724 "%s: RESET TIMEOUT! drv_state: 0x%08x, drv_active: 0x%08x\n",
2735 "%s(%ld): drv_state = 0x%x, drv_active = 0x%x\n",
2736 __func__, ha->
host_no, drv_state,
2752 dev_state <
MAX_STATES ? qdev_state[dev_state] :
"Unknown");
2770 qla4_8xxx_set_qsnt_ready(ha);
2780 if (drv_active == (1 << (ha->
func_num * 4))) {
2784 "%s: IDC version updated to %d\n", __func__,
2790 "%s: qla4xxx driver IDC version %d is not compatible with IDC version %d of other drivers!\n",
2803 if (drv_active == (1 << ha->
func_num)) {
2809 "%s: IDC version updated to %d\n", __func__,
2816 "%s: qla4xxx driver IDC version %d is not compatible with IDC version %d of other drivers!\n",
2820 goto exit_set_idc_ver;
2826 idc_ver &= ~(0x03 << (ha->
func_num * 2));
2840 goto exit_update_idc_reg;
2849 if (is_qla8032(ha)) {
2855 if (is_qla8022(ha)) {
2856 qla4_82xx_set_idc_ver(ha);
2857 }
else if (is_qla8032(ha)) {
2858 rval = qla4_83xx_set_idc_ver(ha);
2865 exit_update_idc_reg:
2879 unsigned long dev_init_timeout;
2883 goto exit_state_handler;
2888 qdev_state[dev_state] :
"Unknown"));
2898 "%s: Device Init Failed 0x%x = %s\n",
2901 qdev_state[dev_state] :
"Unknown");
2909 qdev_state[dev_state] :
"Unknown");
2912 switch (dev_state) {
2929 if (is_qla8032(ha)) {
2931 }
else if (is_qla8022(ha)) {
2933 qla4_82xx_need_reset_handler(ha);
2979 if (is_qla8032(ha)) {
2982 }
else if (is_qla8022(ha)) {
2999 #define OPTROM_BURST_SIZE 0x1000
3000 #define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4)
3002 #define FARX_DATA_FLAG BIT_31
3003 #define FARX_ACCESS_FLASH_CONF 0x7FFD0000
3004 #define FARX_ACCESS_FLASH_DATA 0x7FF00000
3025 while ((qla4_82xx_rom_lock(ha) != 0) && (loops < 50000)) {
3030 if (loops >= 50000) {
3036 for (i = 0; i < length/4; i++, faddr += 4) {
3037 if (qla4_82xx_do_rom_fast_read(ha, faddr, &val)) {
3039 "Do ROM fast read failed\n");
3046 qla4_82xx_rom_unlock(ha);
3057 qla4_82xx_read_flash_data(ha, (
uint32_t *)buf, offset, length);
3064 const char *
loc, *locations[] = {
"DEF",
"PCI" };
3081 const char *
loc, *locations[] = {
"DEF",
"FLT" };
3094 if (is_qla8022(ha)) {
3097 }
else if (is_qla8032(ha)) {
3109 "version=0x%x length=0x%x checksum=0x%x.\n",
3116 for (chksum = 0;
cnt; cnt--)
3120 "version=0x%x length=0x%x checksum=0x%x.\n",
3128 for ( ;
cnt; cnt--, region++) {
3182 #define FLASH_BLK_SIZE_4K 0x1000
3183 #define FLASH_BLK_SIZE_32K 0x8000
3184 #define FLASH_BLK_SIZE_64K 0x10000
3185 const char *
loc, *locations[] = {
"MID",
"FDT" };
3204 if (fdt->
sig[0] !=
'Q' || fdt->
sig[1] !=
'L' || fdt->
sig[2] !=
'I' ||
3208 for (cnt = 0, chksum = 0; cnt < sizeof(struct qla_fdt_layout) >> 1;
3214 "checksum=0x%x id=%c version=0x%x.\n", chksum, fdt->
sig[0],
3231 flash_conf_addr(hw, 0x0336);
3240 "pro=%x upro=%x wrtd=0x%x blk=0x%x.\n", loc, mid, fid,
3249 #define QLA82XX_IDC_PARAM_ADDR 0x003e885c
3252 if (!is_qla8022(ha))
3279 for (i = 1; i < in_count; i++)
3297 ha->
isp_ops->interrupt_service_routine(ha, intr_status);
3312 ret = qla4_8xxx_find_flt_start(ha, &flt_addr);
3316 qla4_8xxx_get_flt_info(ha, flt_addr);
3317 if (is_qla8022(ha)) {
3318 qla4_82xx_get_fdt_info(ha);
3319 qla4_82xx_get_idc_param(ha);
3320 }
else if (is_qla8032(ha)) {
3343 memset(&mbox_cmd, 0,
sizeof(mbox_cmd));
3344 memset(&mbox_sts, 0,
sizeof(mbox_sts));
3348 &mbox_cmd[0], &mbox_sts[0]);
3407 if (sys_info ==
NULL) {
3408 DEBUG2(
printk(
"scsi%ld: %s: Unable to allocate dma buffer.\n",
3413 memset(sys_info, 0,
sizeof(*sys_info));
3414 memset(&mbox_cmd, 0,
sizeof(mbox_cmd));
3415 memset(&mbox_sts, 0,
sizeof(mbox_sts));
3418 mbox_cmd[1] =
LSDW(sys_info_dma);
3419 mbox_cmd[2] =
MSDW(sys_info_dma);
3420 mbox_cmd[4] =
sizeof(*sys_info);
3426 goto exit_validate_mac82;
3432 " error (%x)\n", ha->
host_no, __func__, mbox_sts[4]));
3433 goto exit_validate_mac82;
3450 "mac %02x:%02x:%02x:%02x:%02x:%02x "
3451 "serial %s\n", ha->
host_no, __func__,
3458 exit_validate_mac82:
3473 memset(&mbox_cmd, 0,
sizeof(mbox_cmd));
3474 memset(&mbox_sts, 0,
sizeof(mbox_sts));
3480 "%s: MBOX_CMD_ENABLE_INTRS failed (0x%04x)\n",
3481 __func__, mbox_sts[0]));
3494 memset(&mbox_cmd, 0,
sizeof(mbox_cmd));
3495 memset(&mbox_sts, 0,
sizeof(mbox_sts));
3501 "%s: MBOX_CMD_ENABLE_INTRS failed (0x%04x)\n",
3502 __func__, mbox_sts[0]));
3514 spin_lock_irq(&ha->hardware_lock);
3517 spin_unlock_irq(&ha->hardware_lock);
3527 spin_lock_irq(&ha->hardware_lock);
3530 spin_unlock_irq(&ha->hardware_lock);
3542 "qla4xxx (default)",
3559 __func__, qla4_8xxx_msix_entries[i].
name));
3570 struct msix_entry entries[QLA_MSIX_ENTRIES];
3574 entries[i].
entry = qla4_8xxx_msix_entries[i].
entry;
3579 "MSI-X: Failed to enable support -- %d/%d\n",
3580 QLA_MSIX_ENTRIES, ret);
3591 qla4_8xxx_msix_entries[i].
handler, 0,
3592 qla4_8xxx_msix_entries[i].
name, ha);
3595 "MSI-X: Unable to register handler -- %x/%d.\n",
3596 qla4_8xxx_msix_entries[i].index, ret);
3602 __func__, qla4_8xxx_msix_entries[i].
name));