1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * This file is part of the Chelsio T4 support code.
14 *
15 * Copyright (C) 2011-2013 Chelsio Communications. All rights reserved.
16 *
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file included in this
20 * release for licensing terms and conditions.
21 */
22
23 #include <sys/ddi.h>
24 #include <sys/sunddi.h>
25 #include <sys/queue.h>
26
27 #include "t4nex.h"
28 #include "common/common.h"
29 #include "common/t4_regs.h"
30 #include "cudbg.h"
31
32 /* helpers */
33 static int pci_rw(struct adapter *sc, void *data, int flags, int write);
34 static int reg_rw(struct adapter *sc, void *data, int flags, int write);
35 static void reg_block_dump(struct adapter *sc, uint8_t *buf, unsigned int start,
36 unsigned int end);
37 static int regdump(struct adapter *sc, void *data, int flags);
38 static int get_sge_context(struct adapter *sc, void *data, int flags);
39 static int get_devlog(struct adapter *sc, void *data, int flags);
40 static int validate_mem_range(struct adapter *, uint32_t, int);
41 static int read_card_mem(struct adapter *sc, void *data, int flags);
42 static int read_tid_tab(struct adapter *sc, void *data, int flags);
43 static int read_mbox(struct adapter *sc, void *data, int flags);
44 static int read_cim_la(struct adapter *sc, void *data, int flags);
45 static int read_cim_qcfg(struct adapter *sc, void *data, int flags);
46 static int read_cim_ibq(struct adapter *sc, void *data, int flags);
47 static int read_edc(struct adapter *sc, void *data, int flags);
48 static int flash_fw(struct adapter *, void *, int);
49 static int get_cudbg(struct adapter *, void *, int);
50
51 int
t4_ioctl(struct adapter * sc,int cmd,void * data,int mode)52 t4_ioctl(struct adapter *sc, int cmd, void *data, int mode)
53 {
54 int rc = ENOTSUP;
55
56 switch (cmd) {
57 case T4_IOCTL_PCIGET32:
58 case T4_IOCTL_PCIPUT32:
59 rc = pci_rw(sc, data, mode, cmd == T4_IOCTL_PCIPUT32);
60 break;
61 case T4_IOCTL_GET32:
62 case T4_IOCTL_PUT32:
63 rc = reg_rw(sc, data, mode, cmd == T4_IOCTL_PUT32);
64 break;
65 case T4_IOCTL_REGDUMP:
66 rc = regdump(sc, data, mode);
67 break;
68 case T4_IOCTL_SGE_CONTEXT:
69 rc = get_sge_context(sc, data, mode);
70 break;
71 case T4_IOCTL_DEVLOG:
72 rc = get_devlog(sc, data, mode);
73 break;
74 case T4_IOCTL_GET_MEM:
75 rc = read_card_mem(sc, data, mode);
76 break;
77 case T4_IOCTL_GET_TID_TAB:
78 rc = read_tid_tab(sc, data, mode);
79 break;
80 case T4_IOCTL_GET_MBOX:
81 rc = read_mbox(sc, data, mode);
82 break;
83 case T4_IOCTL_GET_CIM_LA:
84 rc = read_cim_la(sc, data, mode);
85 break;
86 case T4_IOCTL_GET_CIM_QCFG:
87 rc = read_cim_qcfg(sc, data, mode);
88 break;
89 case T4_IOCTL_GET_CIM_IBQ:
90 rc = read_cim_ibq(sc, data, mode);
91 break;
92 case T4_IOCTL_GET_EDC:
93 rc = read_edc(sc, data, mode);
94 break;
95 case T4_IOCTL_LOAD_FW:
96 rc = flash_fw(sc, data, mode);
97 break;
98 case T4_IOCTL_GET_CUDBG:
99 rc = get_cudbg(sc, data, mode);
100 break;
101 default:
102 return (EINVAL);
103 }
104
105 return (rc);
106 }
107
108 static int
pci_rw(struct adapter * sc,void * data,int flags,int write)109 pci_rw(struct adapter *sc, void *data, int flags, int write)
110 {
111 struct t4_reg32_cmd r;
112
113 if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
114 return (EFAULT);
115
116 /* address must be 32 bit aligned */
117 r.reg &= ~0x3;
118
119 if (write != 0)
120 t4_os_pci_write_cfg4(sc, r.reg, r.value);
121 else {
122 t4_os_pci_read_cfg4(sc, r.reg, &r.value);
123 if (ddi_copyout(&r, data, sizeof (r), flags) < 0)
124 return (EFAULT);
125 }
126
127 return (0);
128 }
129
130 static int
reg_rw(struct adapter * sc,void * data,int flags,int write)131 reg_rw(struct adapter *sc, void *data, int flags, int write)
132 {
133 struct t4_reg32_cmd r;
134
135 if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
136 return (EFAULT);
137
138 /* Register address must be 32 bit aligned */
139 r.reg &= ~0x3;
140
141 if (write != 0)
142 t4_write_reg(sc, r.reg, r.value);
143 else {
144 r.value = t4_read_reg(sc, r.reg);
145 if (ddi_copyout(&r, data, sizeof (r), flags) < 0)
146 return (EFAULT);
147 }
148
149 return (0);
150 }
151
152 static void
reg_block_dump(struct adapter * sc,uint8_t * buf,unsigned int start,unsigned int end)153 reg_block_dump(struct adapter *sc, uint8_t *buf, unsigned int start,
154 unsigned int end)
155 {
156 /* LINTED: E_BAD_PTR_CAST_ALIGN */
157 uint32_t *p = (uint32_t *)(buf + start);
158
159 for (/* */; start <= end; start += sizeof (uint32_t))
160 *p++ = t4_read_reg(sc, start);
161 }
162
163 /*
164 * Return a version number to identify the type of adapter. The scheme is:
165 * - bits 0..9: chip version
166 * - bits 10..15: chip revision
167 * - bits 16..23: register dump version
168 */
169 static inline
mk_adap_vers(const struct adapter * sc)170 unsigned int mk_adap_vers(const struct adapter *sc)
171 {
172 return CHELSIO_CHIP_VERSION(sc->params.chip) |
173 (CHELSIO_CHIP_RELEASE(sc->params.chip) << 10) | (1 << 16);
174 }
175
176 static int
regdump(struct adapter * sc,void * data,int flags)177 regdump(struct adapter *sc, void *data, int flags)
178 {
179 struct t4_regdump r;
180 uint8_t *buf;
181 static const unsigned int *reg_ranges;
182 int rc = 0, arr_size = 0, buf_size = 0, i;
183 static const unsigned int t4_reg_ranges[] = {
184 0x1008, 0x1108,
185 0x1180, 0x11b4,
186 0x11fc, 0x123c,
187 0x1300, 0x173c,
188 0x1800, 0x18fc,
189 0x3000, 0x30d8,
190 0x30e0, 0x5924,
191 0x5960, 0x59d4,
192 0x5a00, 0x5af8,
193 0x6000, 0x6098,
194 0x6100, 0x6150,
195 0x6200, 0x6208,
196 0x6240, 0x6248,
197 0x6280, 0x6338,
198 0x6370, 0x638c,
199 0x6400, 0x643c,
200 0x6500, 0x6524,
201 0x6a00, 0x6a38,
202 0x6a60, 0x6a78,
203 0x6b00, 0x6b84,
204 0x6bf0, 0x6c84,
205 0x6cf0, 0x6d84,
206 0x6df0, 0x6e84,
207 0x6ef0, 0x6f84,
208 0x6ff0, 0x7084,
209 0x70f0, 0x7184,
210 0x71f0, 0x7284,
211 0x72f0, 0x7384,
212 0x73f0, 0x7450,
213 0x7500, 0x7530,
214 0x7600, 0x761c,
215 0x7680, 0x76cc,
216 0x7700, 0x7798,
217 0x77c0, 0x77fc,
218 0x7900, 0x79fc,
219 0x7b00, 0x7c38,
220 0x7d00, 0x7efc,
221 0x8dc0, 0x8e1c,
222 0x8e30, 0x8e78,
223 0x8ea0, 0x8f6c,
224 0x8fc0, 0x9074,
225 0x90fc, 0x90fc,
226 0x9400, 0x9458,
227 0x9600, 0x96bc,
228 0x9800, 0x9808,
229 0x9820, 0x983c,
230 0x9850, 0x9864,
231 0x9c00, 0x9c6c,
232 0x9c80, 0x9cec,
233 0x9d00, 0x9d6c,
234 0x9d80, 0x9dec,
235 0x9e00, 0x9e6c,
236 0x9e80, 0x9eec,
237 0x9f00, 0x9f6c,
238 0x9f80, 0x9fec,
239 0xd004, 0xd03c,
240 0xdfc0, 0xdfe0,
241 0xe000, 0xea7c,
242 0xf000, 0x11190,
243 0x19040, 0x19124,
244 0x19150, 0x191b0,
245 0x191d0, 0x191e8,
246 0x19238, 0x1924c,
247 0x193f8, 0x19474,
248 0x19490, 0x194f8,
249 0x19800, 0x19f30,
250 0x1a000, 0x1a06c,
251 0x1a0b0, 0x1a120,
252 0x1a128, 0x1a138,
253 0x1a190, 0x1a1c4,
254 0x1a1fc, 0x1a1fc,
255 0x1e040, 0x1e04c,
256 0x1e240, 0x1e28c,
257 0x1e2c0, 0x1e2c0,
258 0x1e2e0, 0x1e2e0,
259 0x1e300, 0x1e384,
260 0x1e3c0, 0x1e3c8,
261 0x1e440, 0x1e44c,
262 0x1e640, 0x1e68c,
263 0x1e6c0, 0x1e6c0,
264 0x1e6e0, 0x1e6e0,
265 0x1e700, 0x1e784,
266 0x1e7c0, 0x1e7c8,
267 0x1e840, 0x1e84c,
268 0x1ea40, 0x1ea8c,
269 0x1eac0, 0x1eac0,
270 0x1eae0, 0x1eae0,
271 0x1eb00, 0x1eb84,
272 0x1ebc0, 0x1ebc8,
273 0x1ec40, 0x1ec4c,
274 0x1ee40, 0x1ee8c,
275 0x1eec0, 0x1eec0,
276 0x1eee0, 0x1eee0,
277 0x1ef00, 0x1ef84,
278 0x1efc0, 0x1efc8,
279 0x1f040, 0x1f04c,
280 0x1f240, 0x1f28c,
281 0x1f2c0, 0x1f2c0,
282 0x1f2e0, 0x1f2e0,
283 0x1f300, 0x1f384,
284 0x1f3c0, 0x1f3c8,
285 0x1f440, 0x1f44c,
286 0x1f640, 0x1f68c,
287 0x1f6c0, 0x1f6c0,
288 0x1f6e0, 0x1f6e0,
289 0x1f700, 0x1f784,
290 0x1f7c0, 0x1f7c8,
291 0x1f840, 0x1f84c,
292 0x1fa40, 0x1fa8c,
293 0x1fac0, 0x1fac0,
294 0x1fae0, 0x1fae0,
295 0x1fb00, 0x1fb84,
296 0x1fbc0, 0x1fbc8,
297 0x1fc40, 0x1fc4c,
298 0x1fe40, 0x1fe8c,
299 0x1fec0, 0x1fec0,
300 0x1fee0, 0x1fee0,
301 0x1ff00, 0x1ff84,
302 0x1ffc0, 0x1ffc8,
303 0x20000, 0x2002c,
304 0x20100, 0x2013c,
305 0x20190, 0x201c8,
306 0x20200, 0x20318,
307 0x20400, 0x20528,
308 0x20540, 0x20614,
309 0x21000, 0x21040,
310 0x2104c, 0x21060,
311 0x210c0, 0x210ec,
312 0x21200, 0x21268,
313 0x21270, 0x21284,
314 0x212fc, 0x21388,
315 0x21400, 0x21404,
316 0x21500, 0x21518,
317 0x2152c, 0x2153c,
318 0x21550, 0x21554,
319 0x21600, 0x21600,
320 0x21608, 0x21628,
321 0x21630, 0x2163c,
322 0x21700, 0x2171c,
323 0x21780, 0x2178c,
324 0x21800, 0x21c38,
325 0x21c80, 0x21d7c,
326 0x21e00, 0x21e04,
327 0x22000, 0x2202c,
328 0x22100, 0x2213c,
329 0x22190, 0x221c8,
330 0x22200, 0x22318,
331 0x22400, 0x22528,
332 0x22540, 0x22614,
333 0x23000, 0x23040,
334 0x2304c, 0x23060,
335 0x230c0, 0x230ec,
336 0x23200, 0x23268,
337 0x23270, 0x23284,
338 0x232fc, 0x23388,
339 0x23400, 0x23404,
340 0x23500, 0x23518,
341 0x2352c, 0x2353c,
342 0x23550, 0x23554,
343 0x23600, 0x23600,
344 0x23608, 0x23628,
345 0x23630, 0x2363c,
346 0x23700, 0x2371c,
347 0x23780, 0x2378c,
348 0x23800, 0x23c38,
349 0x23c80, 0x23d7c,
350 0x23e00, 0x23e04,
351 0x24000, 0x2402c,
352 0x24100, 0x2413c,
353 0x24190, 0x241c8,
354 0x24200, 0x24318,
355 0x24400, 0x24528,
356 0x24540, 0x24614,
357 0x25000, 0x25040,
358 0x2504c, 0x25060,
359 0x250c0, 0x250ec,
360 0x25200, 0x25268,
361 0x25270, 0x25284,
362 0x252fc, 0x25388,
363 0x25400, 0x25404,
364 0x25500, 0x25518,
365 0x2552c, 0x2553c,
366 0x25550, 0x25554,
367 0x25600, 0x25600,
368 0x25608, 0x25628,
369 0x25630, 0x2563c,
370 0x25700, 0x2571c,
371 0x25780, 0x2578c,
372 0x25800, 0x25c38,
373 0x25c80, 0x25d7c,
374 0x25e00, 0x25e04,
375 0x26000, 0x2602c,
376 0x26100, 0x2613c,
377 0x26190, 0x261c8,
378 0x26200, 0x26318,
379 0x26400, 0x26528,
380 0x26540, 0x26614,
381 0x27000, 0x27040,
382 0x2704c, 0x27060,
383 0x270c0, 0x270ec,
384 0x27200, 0x27268,
385 0x27270, 0x27284,
386 0x272fc, 0x27388,
387 0x27400, 0x27404,
388 0x27500, 0x27518,
389 0x2752c, 0x2753c,
390 0x27550, 0x27554,
391 0x27600, 0x27600,
392 0x27608, 0x27628,
393 0x27630, 0x2763c,
394 0x27700, 0x2771c,
395 0x27780, 0x2778c,
396 0x27800, 0x27c38,
397 0x27c80, 0x27d7c,
398 0x27e00, 0x27e04,
399 };
400
401 static const unsigned int t5_reg_ranges[] = {
402 0x1008, 0x10c0,
403 0x10cc, 0x10f8,
404 0x1100, 0x1100,
405 0x110c, 0x1148,
406 0x1180, 0x1184,
407 0x1190, 0x1194,
408 0x11a0, 0x11a4,
409 0x11b0, 0x11b4,
410 0x11fc, 0x123c,
411 0x1280, 0x173c,
412 0x1800, 0x18fc,
413 0x3000, 0x3028,
414 0x3060, 0x30b0,
415 0x30b8, 0x30d8,
416 0x30e0, 0x30fc,
417 0x3140, 0x357c,
418 0x35a8, 0x35cc,
419 0x35ec, 0x35ec,
420 0x3600, 0x5624,
421 0x56cc, 0x56ec,
422 0x56f4, 0x5720,
423 0x5728, 0x575c,
424 0x580c, 0x5814,
425 0x5890, 0x589c,
426 0x58a4, 0x58ac,
427 0x58b8, 0x58bc,
428 0x5940, 0x59c8,
429 0x59d0, 0x59dc,
430 0x59fc, 0x5a18,
431 0x5a60, 0x5a70,
432 0x5a80, 0x5a9c,
433 0x5b94, 0x5bfc,
434 0x6000, 0x6020,
435 0x6028, 0x6040,
436 0x6058, 0x609c,
437 0x60a8, 0x614c,
438 0x7700, 0x7798,
439 0x77c0, 0x78fc,
440 0x7b00, 0x7b58,
441 0x7b60, 0x7b84,
442 0x7b8c, 0x7c54,
443 0x7d00, 0x7d38,
444 0x7d40, 0x7d80,
445 0x7d8c, 0x7ddc,
446 0x7de4, 0x7e04,
447 0x7e10, 0x7e1c,
448 0x7e24, 0x7e38,
449 0x7e40, 0x7e44,
450 0x7e4c, 0x7e78,
451 0x7e80, 0x7edc,
452 0x7ee8, 0x7efc,
453 0x8dc0, 0x8de0,
454 0x8df8, 0x8e04,
455 0x8e10, 0x8e84,
456 0x8ea0, 0x8f84,
457 0x8fc0, 0x9058,
458 0x9060, 0x9060,
459 0x9068, 0x90f8,
460 0x9400, 0x9408,
461 0x9410, 0x9470,
462 0x9600, 0x9600,
463 0x9608, 0x9638,
464 0x9640, 0x96f4,
465 0x9800, 0x9808,
466 0x9820, 0x983c,
467 0x9850, 0x9864,
468 0x9c00, 0x9c6c,
469 0x9c80, 0x9cec,
470 0x9d00, 0x9d6c,
471 0x9d80, 0x9dec,
472 0x9e00, 0x9e6c,
473 0x9e80, 0x9eec,
474 0x9f00, 0x9f6c,
475 0x9f80, 0xa020,
476 0xd004, 0xd004,
477 0xd010, 0xd03c,
478 0xdfc0, 0xdfe0,
479 0xe000, 0x1106c,
480 0x11074, 0x11088,
481 0x1109c, 0x1117c,
482 0x11190, 0x11204,
483 0x19040, 0x1906c,
484 0x19078, 0x19080,
485 0x1908c, 0x190e8,
486 0x190f0, 0x190f8,
487 0x19100, 0x19110,
488 0x19120, 0x19124,
489 0x19150, 0x19194,
490 0x1919c, 0x191b0,
491 0x191d0, 0x191e8,
492 0x19238, 0x19290,
493 0x193f8, 0x19428,
494 0x19430, 0x19444,
495 0x1944c, 0x1946c,
496 0x19474, 0x19474,
497 0x19490, 0x194cc,
498 0x194f0, 0x194f8,
499 0x19c00, 0x19c08,
500 0x19c10, 0x19c60,
501 0x19c94, 0x19ce4,
502 0x19cf0, 0x19d40,
503 0x19d50, 0x19d94,
504 0x19da0, 0x19de8,
505 0x19df0, 0x19e10,
506 0x19e50, 0x19e90,
507 0x19ea0, 0x19f24,
508 0x19f34, 0x19f34,
509 0x19f40, 0x19f50,
510 0x19f90, 0x19fb4,
511 0x19fc4, 0x19fe4,
512 0x1a000, 0x1a004,
513 0x1a010, 0x1a06c,
514 0x1a0b0, 0x1a0e4,
515 0x1a0ec, 0x1a0f8,
516 0x1a100, 0x1a108,
517 0x1a114, 0x1a120,
518 0x1a128, 0x1a130,
519 0x1a138, 0x1a138,
520 0x1a190, 0x1a1c4,
521 0x1a1fc, 0x1a1fc,
522 0x1e008, 0x1e00c,
523 0x1e040, 0x1e044,
524 0x1e04c, 0x1e04c,
525 0x1e284, 0x1e290,
526 0x1e2c0, 0x1e2c0,
527 0x1e2e0, 0x1e2e0,
528 0x1e300, 0x1e384,
529 0x1e3c0, 0x1e3c8,
530 0x1e408, 0x1e40c,
531 0x1e440, 0x1e444,
532 0x1e44c, 0x1e44c,
533 0x1e684, 0x1e690,
534 0x1e6c0, 0x1e6c0,
535 0x1e6e0, 0x1e6e0,
536 0x1e700, 0x1e784,
537 0x1e7c0, 0x1e7c8,
538 0x1e808, 0x1e80c,
539 0x1e840, 0x1e844,
540 0x1e84c, 0x1e84c,
541 0x1ea84, 0x1ea90,
542 0x1eac0, 0x1eac0,
543 0x1eae0, 0x1eae0,
544 0x1eb00, 0x1eb84,
545 0x1ebc0, 0x1ebc8,
546 0x1ec08, 0x1ec0c,
547 0x1ec40, 0x1ec44,
548 0x1ec4c, 0x1ec4c,
549 0x1ee84, 0x1ee90,
550 0x1eec0, 0x1eec0,
551 0x1eee0, 0x1eee0,
552 0x1ef00, 0x1ef84,
553 0x1efc0, 0x1efc8,
554 0x1f008, 0x1f00c,
555 0x1f040, 0x1f044,
556 0x1f04c, 0x1f04c,
557 0x1f284, 0x1f290,
558 0x1f2c0, 0x1f2c0,
559 0x1f2e0, 0x1f2e0,
560 0x1f300, 0x1f384,
561 0x1f3c0, 0x1f3c8,
562 0x1f408, 0x1f40c,
563 0x1f440, 0x1f444,
564 0x1f44c, 0x1f44c,
565 0x1f684, 0x1f690,
566 0x1f6c0, 0x1f6c0,
567 0x1f6e0, 0x1f6e0,
568 0x1f700, 0x1f784,
569 0x1f7c0, 0x1f7c8,
570 0x1f808, 0x1f80c,
571 0x1f840, 0x1f844,
572 0x1f84c, 0x1f84c,
573 0x1fa84, 0x1fa90,
574 0x1fac0, 0x1fac0,
575 0x1fae0, 0x1fae0,
576 0x1fb00, 0x1fb84,
577 0x1fbc0, 0x1fbc8,
578 0x1fc08, 0x1fc0c,
579 0x1fc40, 0x1fc44,
580 0x1fc4c, 0x1fc4c,
581 0x1fe84, 0x1fe90,
582 0x1fec0, 0x1fec0,
583 0x1fee0, 0x1fee0,
584 0x1ff00, 0x1ff84,
585 0x1ffc0, 0x1ffc8,
586 0x30000, 0x30030,
587 0x30038, 0x30038,
588 0x30040, 0x30040,
589 0x30100, 0x30144,
590 0x30190, 0x301a0,
591 0x301a8, 0x301b8,
592 0x301c4, 0x301c8,
593 0x301d0, 0x301d0,
594 0x30200, 0x30318,
595 0x30400, 0x304b4,
596 0x304c0, 0x3052c,
597 0x30540, 0x3061c,
598 0x30800, 0x30828,
599 0x30834, 0x30834,
600 0x308c0, 0x30908,
601 0x30910, 0x309ac,
602 0x30a00, 0x30a14,
603 0x30a1c, 0x30a2c,
604 0x30a44, 0x30a50,
605 0x30a74, 0x30a74,
606 0x30a7c, 0x30afc,
607 0x30b08, 0x30c24,
608 0x30d00, 0x30d00,
609 0x30d08, 0x30d14,
610 0x30d1c, 0x30d20,
611 0x30d3c, 0x30d3c,
612 0x30d48, 0x30d50,
613 0x31200, 0x3120c,
614 0x31220, 0x31220,
615 0x31240, 0x31240,
616 0x31600, 0x3160c,
617 0x31a00, 0x31a1c,
618 0x31e00, 0x31e20,
619 0x31e38, 0x31e3c,
620 0x31e80, 0x31e80,
621 0x31e88, 0x31ea8,
622 0x31eb0, 0x31eb4,
623 0x31ec8, 0x31ed4,
624 0x31fb8, 0x32004,
625 0x32200, 0x32200,
626 0x32208, 0x32240,
627 0x32248, 0x32280,
628 0x32288, 0x322c0,
629 0x322c8, 0x322fc,
630 0x32600, 0x32630,
631 0x32a00, 0x32abc,
632 0x32b00, 0x32b10,
633 0x32b20, 0x32b30,
634 0x32b40, 0x32b50,
635 0x32b60, 0x32b70,
636 0x33000, 0x33028,
637 0x33030, 0x33048,
638 0x33060, 0x33068,
639 0x33070, 0x3309c,
640 0x330f0, 0x33128,
641 0x33130, 0x33148,
642 0x33160, 0x33168,
643 0x33170, 0x3319c,
644 0x331f0, 0x33238,
645 0x33240, 0x33240,
646 0x33248, 0x33250,
647 0x3325c, 0x33264,
648 0x33270, 0x332b8,
649 0x332c0, 0x332e4,
650 0x332f8, 0x33338,
651 0x33340, 0x33340,
652 0x33348, 0x33350,
653 0x3335c, 0x33364,
654 0x33370, 0x333b8,
655 0x333c0, 0x333e4,
656 0x333f8, 0x33428,
657 0x33430, 0x33448,
658 0x33460, 0x33468,
659 0x33470, 0x3349c,
660 0x334f0, 0x33528,
661 0x33530, 0x33548,
662 0x33560, 0x33568,
663 0x33570, 0x3359c,
664 0x335f0, 0x33638,
665 0x33640, 0x33640,
666 0x33648, 0x33650,
667 0x3365c, 0x33664,
668 0x33670, 0x336b8,
669 0x336c0, 0x336e4,
670 0x336f8, 0x33738,
671 0x33740, 0x33740,
672 0x33748, 0x33750,
673 0x3375c, 0x33764,
674 0x33770, 0x337b8,
675 0x337c0, 0x337e4,
676 0x337f8, 0x337fc,
677 0x33814, 0x33814,
678 0x3382c, 0x3382c,
679 0x33880, 0x3388c,
680 0x338e8, 0x338ec,
681 0x33900, 0x33928,
682 0x33930, 0x33948,
683 0x33960, 0x33968,
684 0x33970, 0x3399c,
685 0x339f0, 0x33a38,
686 0x33a40, 0x33a40,
687 0x33a48, 0x33a50,
688 0x33a5c, 0x33a64,
689 0x33a70, 0x33ab8,
690 0x33ac0, 0x33ae4,
691 0x33af8, 0x33b10,
692 0x33b28, 0x33b28,
693 0x33b3c, 0x33b50,
694 0x33bf0, 0x33c10,
695 0x33c28, 0x33c28,
696 0x33c3c, 0x33c50,
697 0x33cf0, 0x33cfc,
698 0x34000, 0x34030,
699 0x34038, 0x34038,
700 0x34040, 0x34040,
701 0x34100, 0x34144,
702 0x34190, 0x341a0,
703 0x341a8, 0x341b8,
704 0x341c4, 0x341c8,
705 0x341d0, 0x341d0,
706 0x34200, 0x34318,
707 0x34400, 0x344b4,
708 0x344c0, 0x3452c,
709 0x34540, 0x3461c,
710 0x34800, 0x34828,
711 0x34834, 0x34834,
712 0x348c0, 0x34908,
713 0x34910, 0x349ac,
714 0x34a00, 0x34a14,
715 0x34a1c, 0x34a2c,
716 0x34a44, 0x34a50,
717 0x34a74, 0x34a74,
718 0x34a7c, 0x34afc,
719 0x34b08, 0x34c24,
720 0x34d00, 0x34d00,
721 0x34d08, 0x34d14,
722 0x34d1c, 0x34d20,
723 0x34d3c, 0x34d3c,
724 0x34d48, 0x34d50,
725 0x35200, 0x3520c,
726 0x35220, 0x35220,
727 0x35240, 0x35240,
728 0x35600, 0x3560c,
729 0x35a00, 0x35a1c,
730 0x35e00, 0x35e20,
731 0x35e38, 0x35e3c,
732 0x35e80, 0x35e80,
733 0x35e88, 0x35ea8,
734 0x35eb0, 0x35eb4,
735 0x35ec8, 0x35ed4,
736 0x35fb8, 0x36004,
737 0x36200, 0x36200,
738 0x36208, 0x36240,
739 0x36248, 0x36280,
740 0x36288, 0x362c0,
741 0x362c8, 0x362fc,
742 0x36600, 0x36630,
743 0x36a00, 0x36abc,
744 0x36b00, 0x36b10,
745 0x36b20, 0x36b30,
746 0x36b40, 0x36b50,
747 0x36b60, 0x36b70,
748 0x37000, 0x37028,
749 0x37030, 0x37048,
750 0x37060, 0x37068,
751 0x37070, 0x3709c,
752 0x370f0, 0x37128,
753 0x37130, 0x37148,
754 0x37160, 0x37168,
755 0x37170, 0x3719c,
756 0x371f0, 0x37238,
757 0x37240, 0x37240,
758 0x37248, 0x37250,
759 0x3725c, 0x37264,
760 0x37270, 0x372b8,
761 0x372c0, 0x372e4,
762 0x372f8, 0x37338,
763 0x37340, 0x37340,
764 0x37348, 0x37350,
765 0x3735c, 0x37364,
766 0x37370, 0x373b8,
767 0x373c0, 0x373e4,
768 0x373f8, 0x37428,
769 0x37430, 0x37448,
770 0x37460, 0x37468,
771 0x37470, 0x3749c,
772 0x374f0, 0x37528,
773 0x37530, 0x37548,
774 0x37560, 0x37568,
775 0x37570, 0x3759c,
776 0x375f0, 0x37638,
777 0x37640, 0x37640,
778 0x37648, 0x37650,
779 0x3765c, 0x37664,
780 0x37670, 0x376b8,
781 0x376c0, 0x376e4,
782 0x376f8, 0x37738,
783 0x37740, 0x37740,
784 0x37748, 0x37750,
785 0x3775c, 0x37764,
786 0x37770, 0x377b8,
787 0x377c0, 0x377e4,
788 0x377f8, 0x377fc,
789 0x37814, 0x37814,
790 0x3782c, 0x3782c,
791 0x37880, 0x3788c,
792 0x378e8, 0x378ec,
793 0x37900, 0x37928,
794 0x37930, 0x37948,
795 0x37960, 0x37968,
796 0x37970, 0x3799c,
797 0x379f0, 0x37a38,
798 0x37a40, 0x37a40,
799 0x37a48, 0x37a50,
800 0x37a5c, 0x37a64,
801 0x37a70, 0x37ab8,
802 0x37ac0, 0x37ae4,
803 0x37af8, 0x37b10,
804 0x37b28, 0x37b28,
805 0x37b3c, 0x37b50,
806 0x37bf0, 0x37c10,
807 0x37c28, 0x37c28,
808 0x37c3c, 0x37c50,
809 0x37cf0, 0x37cfc,
810 0x38000, 0x38030,
811 0x38038, 0x38038,
812 0x38040, 0x38040,
813 0x38100, 0x38144,
814 0x38190, 0x381a0,
815 0x381a8, 0x381b8,
816 0x381c4, 0x381c8,
817 0x381d0, 0x381d0,
818 0x38200, 0x38318,
819 0x38400, 0x384b4,
820 0x384c0, 0x3852c,
821 0x38540, 0x3861c,
822 0x38800, 0x38828,
823 0x38834, 0x38834,
824 0x388c0, 0x38908,
825 0x38910, 0x389ac,
826 0x38a00, 0x38a14,
827 0x38a1c, 0x38a2c,
828 0x38a44, 0x38a50,
829 0x38a74, 0x38a74,
830 0x38a7c, 0x38afc,
831 0x38b08, 0x38c24,
832 0x38d00, 0x38d00,
833 0x38d08, 0x38d14,
834 0x38d1c, 0x38d20,
835 0x38d3c, 0x38d3c,
836 0x38d48, 0x38d50,
837 0x39200, 0x3920c,
838 0x39220, 0x39220,
839 0x39240, 0x39240,
840 0x39600, 0x3960c,
841 0x39a00, 0x39a1c,
842 0x39e00, 0x39e20,
843 0x39e38, 0x39e3c,
844 0x39e80, 0x39e80,
845 0x39e88, 0x39ea8,
846 0x39eb0, 0x39eb4,
847 0x39ec8, 0x39ed4,
848 0x39fb8, 0x3a004,
849 0x3a200, 0x3a200,
850 0x3a208, 0x3a240,
851 0x3a248, 0x3a280,
852 0x3a288, 0x3a2c0,
853 0x3a2c8, 0x3a2fc,
854 0x3a600, 0x3a630,
855 0x3aa00, 0x3aabc,
856 0x3ab00, 0x3ab10,
857 0x3ab20, 0x3ab30,
858 0x3ab40, 0x3ab50,
859 0x3ab60, 0x3ab70,
860 0x3b000, 0x3b028,
861 0x3b030, 0x3b048,
862 0x3b060, 0x3b068,
863 0x3b070, 0x3b09c,
864 0x3b0f0, 0x3b128,
865 0x3b130, 0x3b148,
866 0x3b160, 0x3b168,
867 0x3b170, 0x3b19c,
868 0x3b1f0, 0x3b238,
869 0x3b240, 0x3b240,
870 0x3b248, 0x3b250,
871 0x3b25c, 0x3b264,
872 0x3b270, 0x3b2b8,
873 0x3b2c0, 0x3b2e4,
874 0x3b2f8, 0x3b338,
875 0x3b340, 0x3b340,
876 0x3b348, 0x3b350,
877 0x3b35c, 0x3b364,
878 0x3b370, 0x3b3b8,
879 0x3b3c0, 0x3b3e4,
880 0x3b3f8, 0x3b428,
881 0x3b430, 0x3b448,
882 0x3b460, 0x3b468,
883 0x3b470, 0x3b49c,
884 0x3b4f0, 0x3b528,
885 0x3b530, 0x3b548,
886 0x3b560, 0x3b568,
887 0x3b570, 0x3b59c,
888 0x3b5f0, 0x3b638,
889 0x3b640, 0x3b640,
890 0x3b648, 0x3b650,
891 0x3b65c, 0x3b664,
892 0x3b670, 0x3b6b8,
893 0x3b6c0, 0x3b6e4,
894 0x3b6f8, 0x3b738,
895 0x3b740, 0x3b740,
896 0x3b748, 0x3b750,
897 0x3b75c, 0x3b764,
898 0x3b770, 0x3b7b8,
899 0x3b7c0, 0x3b7e4,
900 0x3b7f8, 0x3b7fc,
901 0x3b814, 0x3b814,
902 0x3b82c, 0x3b82c,
903 0x3b880, 0x3b88c,
904 0x3b8e8, 0x3b8ec,
905 0x3b900, 0x3b928,
906 0x3b930, 0x3b948,
907 0x3b960, 0x3b968,
908 0x3b970, 0x3b99c,
909 0x3b9f0, 0x3ba38,
910 0x3ba40, 0x3ba40,
911 0x3ba48, 0x3ba50,
912 0x3ba5c, 0x3ba64,
913 0x3ba70, 0x3bab8,
914 0x3bac0, 0x3bae4,
915 0x3baf8, 0x3bb10,
916 0x3bb28, 0x3bb28,
917 0x3bb3c, 0x3bb50,
918 0x3bbf0, 0x3bc10,
919 0x3bc28, 0x3bc28,
920 0x3bc3c, 0x3bc50,
921 0x3bcf0, 0x3bcfc,
922 0x3c000, 0x3c030,
923 0x3c038, 0x3c038,
924 0x3c040, 0x3c040,
925 0x3c100, 0x3c144,
926 0x3c190, 0x3c1a0,
927 0x3c1a8, 0x3c1b8,
928 0x3c1c4, 0x3c1c8,
929 0x3c1d0, 0x3c1d0,
930 0x3c200, 0x3c318,
931 0x3c400, 0x3c4b4,
932 0x3c4c0, 0x3c52c,
933 0x3c540, 0x3c61c,
934 0x3c800, 0x3c828,
935 0x3c834, 0x3c834,
936 0x3c8c0, 0x3c908,
937 0x3c910, 0x3c9ac,
938 0x3ca00, 0x3ca14,
939 0x3ca1c, 0x3ca2c,
940 0x3ca44, 0x3ca50,
941 0x3ca74, 0x3ca74,
942 0x3ca7c, 0x3cafc,
943 0x3cb08, 0x3cc24,
944 0x3cd00, 0x3cd00,
945 0x3cd08, 0x3cd14,
946 0x3cd1c, 0x3cd20,
947 0x3cd3c, 0x3cd3c,
948 0x3cd48, 0x3cd50,
949 0x3d200, 0x3d20c,
950 0x3d220, 0x3d220,
951 0x3d240, 0x3d240,
952 0x3d600, 0x3d60c,
953 0x3da00, 0x3da1c,
954 0x3de00, 0x3de20,
955 0x3de38, 0x3de3c,
956 0x3de80, 0x3de80,
957 0x3de88, 0x3dea8,
958 0x3deb0, 0x3deb4,
959 0x3dec8, 0x3ded4,
960 0x3dfb8, 0x3e004,
961 0x3e200, 0x3e200,
962 0x3e208, 0x3e240,
963 0x3e248, 0x3e280,
964 0x3e288, 0x3e2c0,
965 0x3e2c8, 0x3e2fc,
966 0x3e600, 0x3e630,
967 0x3ea00, 0x3eabc,
968 0x3eb00, 0x3eb10,
969 0x3eb20, 0x3eb30,
970 0x3eb40, 0x3eb50,
971 0x3eb60, 0x3eb70,
972 0x3f000, 0x3f028,
973 0x3f030, 0x3f048,
974 0x3f060, 0x3f068,
975 0x3f070, 0x3f09c,
976 0x3f0f0, 0x3f128,
977 0x3f130, 0x3f148,
978 0x3f160, 0x3f168,
979 0x3f170, 0x3f19c,
980 0x3f1f0, 0x3f238,
981 0x3f240, 0x3f240,
982 0x3f248, 0x3f250,
983 0x3f25c, 0x3f264,
984 0x3f270, 0x3f2b8,
985 0x3f2c0, 0x3f2e4,
986 0x3f2f8, 0x3f338,
987 0x3f340, 0x3f340,
988 0x3f348, 0x3f350,
989 0x3f35c, 0x3f364,
990 0x3f370, 0x3f3b8,
991 0x3f3c0, 0x3f3e4,
992 0x3f3f8, 0x3f428,
993 0x3f430, 0x3f448,
994 0x3f460, 0x3f468,
995 0x3f470, 0x3f49c,
996 0x3f4f0, 0x3f528,
997 0x3f530, 0x3f548,
998 0x3f560, 0x3f568,
999 0x3f570, 0x3f59c,
1000 0x3f5f0, 0x3f638,
1001 0x3f640, 0x3f640,
1002 0x3f648, 0x3f650,
1003 0x3f65c, 0x3f664,
1004 0x3f670, 0x3f6b8,
1005 0x3f6c0, 0x3f6e4,
1006 0x3f6f8, 0x3f738,
1007 0x3f740, 0x3f740,
1008 0x3f748, 0x3f750,
1009 0x3f75c, 0x3f764,
1010 0x3f770, 0x3f7b8,
1011 0x3f7c0, 0x3f7e4,
1012 0x3f7f8, 0x3f7fc,
1013 0x3f814, 0x3f814,
1014 0x3f82c, 0x3f82c,
1015 0x3f880, 0x3f88c,
1016 0x3f8e8, 0x3f8ec,
1017 0x3f900, 0x3f928,
1018 0x3f930, 0x3f948,
1019 0x3f960, 0x3f968,
1020 0x3f970, 0x3f99c,
1021 0x3f9f0, 0x3fa38,
1022 0x3fa40, 0x3fa40,
1023 0x3fa48, 0x3fa50,
1024 0x3fa5c, 0x3fa64,
1025 0x3fa70, 0x3fab8,
1026 0x3fac0, 0x3fae4,
1027 0x3faf8, 0x3fb10,
1028 0x3fb28, 0x3fb28,
1029 0x3fb3c, 0x3fb50,
1030 0x3fbf0, 0x3fc10,
1031 0x3fc28, 0x3fc28,
1032 0x3fc3c, 0x3fc50,
1033 0x3fcf0, 0x3fcfc,
1034 0x40000, 0x4000c,
1035 0x40040, 0x40050,
1036 0x40060, 0x40068,
1037 0x4007c, 0x4008c,
1038 0x40094, 0x400b0,
1039 0x400c0, 0x40144,
1040 0x40180, 0x4018c,
1041 0x40200, 0x40254,
1042 0x40260, 0x40264,
1043 0x40270, 0x40288,
1044 0x40290, 0x40298,
1045 0x402ac, 0x402c8,
1046 0x402d0, 0x402e0,
1047 0x402f0, 0x402f0,
1048 0x40300, 0x4033c,
1049 0x403f8, 0x403fc,
1050 0x41304, 0x413c4,
1051 0x41400, 0x4140c,
1052 0x41414, 0x4141c,
1053 0x41480, 0x414d0,
1054 0x44000, 0x44054,
1055 0x4405c, 0x44078,
1056 0x440c0, 0x44174,
1057 0x44180, 0x441ac,
1058 0x441b4, 0x441b8,
1059 0x441c0, 0x44254,
1060 0x4425c, 0x44278,
1061 0x442c0, 0x44374,
1062 0x44380, 0x443ac,
1063 0x443b4, 0x443b8,
1064 0x443c0, 0x44454,
1065 0x4445c, 0x44478,
1066 0x444c0, 0x44574,
1067 0x44580, 0x445ac,
1068 0x445b4, 0x445b8,
1069 0x445c0, 0x44654,
1070 0x4465c, 0x44678,
1071 0x446c0, 0x44774,
1072 0x44780, 0x447ac,
1073 0x447b4, 0x447b8,
1074 0x447c0, 0x44854,
1075 0x4485c, 0x44878,
1076 0x448c0, 0x44974,
1077 0x44980, 0x449ac,
1078 0x449b4, 0x449b8,
1079 0x449c0, 0x449fc,
1080 0x45000, 0x45004,
1081 0x45010, 0x45030,
1082 0x45040, 0x45060,
1083 0x45068, 0x45068,
1084 0x45080, 0x45084,
1085 0x450a0, 0x450b0,
1086 0x45200, 0x45204,
1087 0x45210, 0x45230,
1088 0x45240, 0x45260,
1089 0x45268, 0x45268,
1090 0x45280, 0x45284,
1091 0x452a0, 0x452b0,
1092 0x460c0, 0x460e4,
1093 0x47000, 0x4703c,
1094 0x47044, 0x4708c,
1095 0x47200, 0x47250,
1096 0x47400, 0x47408,
1097 0x47414, 0x47420,
1098 0x47600, 0x47618,
1099 0x47800, 0x47814,
1100 0x48000, 0x4800c,
1101 0x48040, 0x48050,
1102 0x48060, 0x48068,
1103 0x4807c, 0x4808c,
1104 0x48094, 0x480b0,
1105 0x480c0, 0x48144,
1106 0x48180, 0x4818c,
1107 0x48200, 0x48254,
1108 0x48260, 0x48264,
1109 0x48270, 0x48288,
1110 0x48290, 0x48298,
1111 0x482ac, 0x482c8,
1112 0x482d0, 0x482e0,
1113 0x482f0, 0x482f0,
1114 0x48300, 0x4833c,
1115 0x483f8, 0x483fc,
1116 0x49304, 0x493c4,
1117 0x49400, 0x4940c,
1118 0x49414, 0x4941c,
1119 0x49480, 0x494d0,
1120 0x4c000, 0x4c054,
1121 0x4c05c, 0x4c078,
1122 0x4c0c0, 0x4c174,
1123 0x4c180, 0x4c1ac,
1124 0x4c1b4, 0x4c1b8,
1125 0x4c1c0, 0x4c254,
1126 0x4c25c, 0x4c278,
1127 0x4c2c0, 0x4c374,
1128 0x4c380, 0x4c3ac,
1129 0x4c3b4, 0x4c3b8,
1130 0x4c3c0, 0x4c454,
1131 0x4c45c, 0x4c478,
1132 0x4c4c0, 0x4c574,
1133 0x4c580, 0x4c5ac,
1134 0x4c5b4, 0x4c5b8,
1135 0x4c5c0, 0x4c654,
1136 0x4c65c, 0x4c678,
1137 0x4c6c0, 0x4c774,
1138 0x4c780, 0x4c7ac,
1139 0x4c7b4, 0x4c7b8,
1140 0x4c7c0, 0x4c854,
1141 0x4c85c, 0x4c878,
1142 0x4c8c0, 0x4c974,
1143 0x4c980, 0x4c9ac,
1144 0x4c9b4, 0x4c9b8,
1145 0x4c9c0, 0x4c9fc,
1146 0x4d000, 0x4d004,
1147 0x4d010, 0x4d030,
1148 0x4d040, 0x4d060,
1149 0x4d068, 0x4d068,
1150 0x4d080, 0x4d084,
1151 0x4d0a0, 0x4d0b0,
1152 0x4d200, 0x4d204,
1153 0x4d210, 0x4d230,
1154 0x4d240, 0x4d260,
1155 0x4d268, 0x4d268,
1156 0x4d280, 0x4d284,
1157 0x4d2a0, 0x4d2b0,
1158 0x4e0c0, 0x4e0e4,
1159 0x4f000, 0x4f03c,
1160 0x4f044, 0x4f08c,
1161 0x4f200, 0x4f250,
1162 0x4f400, 0x4f408,
1163 0x4f414, 0x4f420,
1164 0x4f600, 0x4f618,
1165 0x4f800, 0x4f814,
1166 0x50000, 0x50084,
1167 0x50090, 0x500cc,
1168 0x50400, 0x50400,
1169 0x50800, 0x50884,
1170 0x50890, 0x508cc,
1171 0x50c00, 0x50c00,
1172 0x51000, 0x5101c,
1173 0x51300, 0x51308,
1174 };
1175
1176 static const unsigned int t6_reg_ranges[] = {
1177 0x1008, 0x101c,
1178 0x1024, 0x10a8,
1179 0x10b4, 0x10f8,
1180 0x1100, 0x1114,
1181 0x111c, 0x112c,
1182 0x1138, 0x113c,
1183 0x1144, 0x114c,
1184 0x1180, 0x1184,
1185 0x1190, 0x1194,
1186 0x11a0, 0x11a4,
1187 0x11b0, 0x11c4,
1188 0x11fc, 0x123c,
1189 0x1254, 0x1274,
1190 0x1280, 0x133c,
1191 0x1800, 0x18fc,
1192 0x3000, 0x302c,
1193 0x3060, 0x30b0,
1194 0x30b8, 0x30d8,
1195 0x30e0, 0x30fc,
1196 0x3140, 0x357c,
1197 0x35a8, 0x35cc,
1198 0x35ec, 0x35ec,
1199 0x3600, 0x5624,
1200 0x56cc, 0x56ec,
1201 0x56f4, 0x5720,
1202 0x5728, 0x575c,
1203 0x580c, 0x5814,
1204 0x5890, 0x589c,
1205 0x58a4, 0x58ac,
1206 0x58b8, 0x58bc,
1207 0x5940, 0x595c,
1208 0x5980, 0x598c,
1209 0x59b0, 0x59c8,
1210 0x59d0, 0x59dc,
1211 0x59fc, 0x5a18,
1212 0x5a60, 0x5a6c,
1213 0x5a80, 0x5a8c,
1214 0x5a94, 0x5a9c,
1215 0x5b94, 0x5bfc,
1216 0x5c10, 0x5e48,
1217 0x5e50, 0x5e94,
1218 0x5ea0, 0x5eb0,
1219 0x5ec0, 0x5ec0,
1220 0x5ec8, 0x5ed0,
1221 0x5ee0, 0x5ee0,
1222 0x5ef0, 0x5ef0,
1223 0x5f00, 0x5f00,
1224 0x6000, 0x6020,
1225 0x6028, 0x6040,
1226 0x6058, 0x609c,
1227 0x60a8, 0x619c,
1228 0x7700, 0x7798,
1229 0x77c0, 0x7880,
1230 0x78cc, 0x78fc,
1231 0x7b00, 0x7b58,
1232 0x7b60, 0x7b84,
1233 0x7b8c, 0x7c54,
1234 0x7d00, 0x7d38,
1235 0x7d40, 0x7d84,
1236 0x7d8c, 0x7ddc,
1237 0x7de4, 0x7e04,
1238 0x7e10, 0x7e1c,
1239 0x7e24, 0x7e38,
1240 0x7e40, 0x7e44,
1241 0x7e4c, 0x7e78,
1242 0x7e80, 0x7edc,
1243 0x7ee8, 0x7efc,
1244 0x8dc0, 0x8de0,
1245 0x8df8, 0x8e04,
1246 0x8e10, 0x8e84,
1247 0x8ea0, 0x8f88,
1248 0x8fb8, 0x9058,
1249 0x9060, 0x9060,
1250 0x9068, 0x90f8,
1251 0x9100, 0x9124,
1252 0x9400, 0x9470,
1253 0x9600, 0x9600,
1254 0x9608, 0x9638,
1255 0x9640, 0x9704,
1256 0x9710, 0x971c,
1257 0x9800, 0x9808,
1258 0x9810, 0x9864,
1259 0x9c00, 0x9c6c,
1260 0x9c80, 0x9cec,
1261 0x9d00, 0x9d6c,
1262 0x9d80, 0x9dec,
1263 0x9e00, 0x9e6c,
1264 0x9e80, 0x9eec,
1265 0x9f00, 0x9f6c,
1266 0x9f80, 0xa020,
1267 0xd000, 0xd03c,
1268 0xd100, 0xd118,
1269 0xd200, 0xd214,
1270 0xd220, 0xd234,
1271 0xd240, 0xd254,
1272 0xd260, 0xd274,
1273 0xd280, 0xd294,
1274 0xd2a0, 0xd2b4,
1275 0xd2c0, 0xd2d4,
1276 0xd2e0, 0xd2f4,
1277 0xd300, 0xd31c,
1278 0xdfc0, 0xdfe0,
1279 0xe000, 0xf008,
1280 0xf010, 0xf018,
1281 0xf020, 0xf028,
1282 0x11000, 0x11014,
1283 0x11048, 0x1106c,
1284 0x11074, 0x11088,
1285 0x11098, 0x11120,
1286 0x1112c, 0x1117c,
1287 0x11190, 0x112e0,
1288 0x11300, 0x1130c,
1289 0x12000, 0x1206c,
1290 0x19040, 0x1906c,
1291 0x19078, 0x19080,
1292 0x1908c, 0x190e8,
1293 0x190f0, 0x190f8,
1294 0x19100, 0x19110,
1295 0x19120, 0x19124,
1296 0x19150, 0x19194,
1297 0x1919c, 0x191b0,
1298 0x191d0, 0x191e8,
1299 0x19238, 0x19290,
1300 0x192a4, 0x192b0,
1301 0x19348, 0x1934c,
1302 0x193f8, 0x19418,
1303 0x19420, 0x19428,
1304 0x19430, 0x19444,
1305 0x1944c, 0x1946c,
1306 0x19474, 0x19474,
1307 0x19490, 0x194cc,
1308 0x194f0, 0x194f8,
1309 0x19c00, 0x19c48,
1310 0x19c50, 0x19c80,
1311 0x19c94, 0x19c98,
1312 0x19ca0, 0x19cbc,
1313 0x19ce4, 0x19ce4,
1314 0x19cf0, 0x19cf8,
1315 0x19d00, 0x19d28,
1316 0x19d50, 0x19d78,
1317 0x19d94, 0x19d98,
1318 0x19da0, 0x19de0,
1319 0x19df0, 0x19e10,
1320 0x19e50, 0x19e6c,
1321 0x19ea0, 0x19ebc,
1322 0x19ec4, 0x19ef4,
1323 0x19f04, 0x19f2c,
1324 0x19f34, 0x19f34,
1325 0x19f40, 0x19f50,
1326 0x19f90, 0x19fac,
1327 0x19fc4, 0x19fc8,
1328 0x19fd0, 0x19fe4,
1329 0x1a000, 0x1a004,
1330 0x1a010, 0x1a06c,
1331 0x1a0b0, 0x1a0e4,
1332 0x1a0ec, 0x1a0f8,
1333 0x1a100, 0x1a108,
1334 0x1a114, 0x1a130,
1335 0x1a138, 0x1a1c4,
1336 0x1a1fc, 0x1a1fc,
1337 0x1e008, 0x1e00c,
1338 0x1e040, 0x1e044,
1339 0x1e04c, 0x1e04c,
1340 0x1e284, 0x1e290,
1341 0x1e2c0, 0x1e2c0,
1342 0x1e2e0, 0x1e2e0,
1343 0x1e300, 0x1e384,
1344 0x1e3c0, 0x1e3c8,
1345 0x1e408, 0x1e40c,
1346 0x1e440, 0x1e444,
1347 0x1e44c, 0x1e44c,
1348 0x1e684, 0x1e690,
1349 0x1e6c0, 0x1e6c0,
1350 0x1e6e0, 0x1e6e0,
1351 0x1e700, 0x1e784,
1352 0x1e7c0, 0x1e7c8,
1353 0x1e808, 0x1e80c,
1354 0x1e840, 0x1e844,
1355 0x1e84c, 0x1e84c,
1356 0x1ea84, 0x1ea90,
1357 0x1eac0, 0x1eac0,
1358 0x1eae0, 0x1eae0,
1359 0x1eb00, 0x1eb84,
1360 0x1ebc0, 0x1ebc8,
1361 0x1ec08, 0x1ec0c,
1362 0x1ec40, 0x1ec44,
1363 0x1ec4c, 0x1ec4c,
1364 0x1ee84, 0x1ee90,
1365 0x1eec0, 0x1eec0,
1366 0x1eee0, 0x1eee0,
1367 0x1ef00, 0x1ef84,
1368 0x1efc0, 0x1efc8,
1369 0x1f008, 0x1f00c,
1370 0x1f040, 0x1f044,
1371 0x1f04c, 0x1f04c,
1372 0x1f284, 0x1f290,
1373 0x1f2c0, 0x1f2c0,
1374 0x1f2e0, 0x1f2e0,
1375 0x1f300, 0x1f384,
1376 0x1f3c0, 0x1f3c8,
1377 0x1f408, 0x1f40c,
1378 0x1f440, 0x1f444,
1379 0x1f44c, 0x1f44c,
1380 0x1f684, 0x1f690,
1381 0x1f6c0, 0x1f6c0,
1382 0x1f6e0, 0x1f6e0,
1383 0x1f700, 0x1f784,
1384 0x1f7c0, 0x1f7c8,
1385 0x1f808, 0x1f80c,
1386 0x1f840, 0x1f844,
1387 0x1f84c, 0x1f84c,
1388 0x1fa84, 0x1fa90,
1389 0x1fac0, 0x1fac0,
1390 0x1fae0, 0x1fae0,
1391 0x1fb00, 0x1fb84,
1392 0x1fbc0, 0x1fbc8,
1393 0x1fc08, 0x1fc0c,
1394 0x1fc40, 0x1fc44,
1395 0x1fc4c, 0x1fc4c,
1396 0x1fe84, 0x1fe90,
1397 0x1fec0, 0x1fec0,
1398 0x1fee0, 0x1fee0,
1399 0x1ff00, 0x1ff84,
1400 0x1ffc0, 0x1ffc8,
1401 0x30000, 0x30030,
1402 0x30100, 0x30168,
1403 0x30190, 0x301a0,
1404 0x301a8, 0x301b8,
1405 0x301c4, 0x301c8,
1406 0x301d0, 0x301d0,
1407 0x30200, 0x30320,
1408 0x30400, 0x304b4,
1409 0x304c0, 0x3052c,
1410 0x30540, 0x3061c,
1411 0x30800, 0x308a0,
1412 0x308c0, 0x30908,
1413 0x30910, 0x309b8,
1414 0x30a00, 0x30a04,
1415 0x30a0c, 0x30a14,
1416 0x30a1c, 0x30a2c,
1417 0x30a44, 0x30a50,
1418 0x30a74, 0x30a74,
1419 0x30a7c, 0x30afc,
1420 0x30b08, 0x30c24,
1421 0x30d00, 0x30d14,
1422 0x30d1c, 0x30d3c,
1423 0x30d44, 0x30d4c,
1424 0x30d54, 0x30d74,
1425 0x30d7c, 0x30d7c,
1426 0x30de0, 0x30de0,
1427 0x30e00, 0x30ed4,
1428 0x30f00, 0x30fa4,
1429 0x30fc0, 0x30fc4,
1430 0x31000, 0x31004,
1431 0x31080, 0x310fc,
1432 0x31208, 0x31220,
1433 0x3123c, 0x31254,
1434 0x31300, 0x31300,
1435 0x31308, 0x3131c,
1436 0x31338, 0x3133c,
1437 0x31380, 0x31380,
1438 0x31388, 0x313a8,
1439 0x313b4, 0x313b4,
1440 0x31400, 0x31420,
1441 0x31438, 0x3143c,
1442 0x31480, 0x31480,
1443 0x314a8, 0x314a8,
1444 0x314b0, 0x314b4,
1445 0x314c8, 0x314d4,
1446 0x31a40, 0x31a4c,
1447 0x31af0, 0x31b20,
1448 0x31b38, 0x31b3c,
1449 0x31b80, 0x31b80,
1450 0x31ba8, 0x31ba8,
1451 0x31bb0, 0x31bb4,
1452 0x31bc8, 0x31bd4,
1453 0x32140, 0x3218c,
1454 0x321f0, 0x321f4,
1455 0x32200, 0x32200,
1456 0x32218, 0x32218,
1457 0x32400, 0x32400,
1458 0x32408, 0x3241c,
1459 0x32618, 0x32620,
1460 0x32664, 0x32664,
1461 0x326a8, 0x326a8,
1462 0x326ec, 0x326ec,
1463 0x32a00, 0x32abc,
1464 0x32b00, 0x32b18,
1465 0x32b20, 0x32b38,
1466 0x32b40, 0x32b58,
1467 0x32b60, 0x32b78,
1468 0x32c00, 0x32c00,
1469 0x32c08, 0x32c3c,
1470 0x33000, 0x3302c,
1471 0x33034, 0x33050,
1472 0x33058, 0x33058,
1473 0x33060, 0x3308c,
1474 0x3309c, 0x330ac,
1475 0x330c0, 0x330c0,
1476 0x330c8, 0x330d0,
1477 0x330d8, 0x330e0,
1478 0x330ec, 0x3312c,
1479 0x33134, 0x33150,
1480 0x33158, 0x33158,
1481 0x33160, 0x3318c,
1482 0x3319c, 0x331ac,
1483 0x331c0, 0x331c0,
1484 0x331c8, 0x331d0,
1485 0x331d8, 0x331e0,
1486 0x331ec, 0x33290,
1487 0x33298, 0x332c4,
1488 0x332e4, 0x33390,
1489 0x33398, 0x333c4,
1490 0x333e4, 0x3342c,
1491 0x33434, 0x33450,
1492 0x33458, 0x33458,
1493 0x33460, 0x3348c,
1494 0x3349c, 0x334ac,
1495 0x334c0, 0x334c0,
1496 0x334c8, 0x334d0,
1497 0x334d8, 0x334e0,
1498 0x334ec, 0x3352c,
1499 0x33534, 0x33550,
1500 0x33558, 0x33558,
1501 0x33560, 0x3358c,
1502 0x3359c, 0x335ac,
1503 0x335c0, 0x335c0,
1504 0x335c8, 0x335d0,
1505 0x335d8, 0x335e0,
1506 0x335ec, 0x33690,
1507 0x33698, 0x336c4,
1508 0x336e4, 0x33790,
1509 0x33798, 0x337c4,
1510 0x337e4, 0x337fc,
1511 0x33814, 0x33814,
1512 0x33854, 0x33868,
1513 0x33880, 0x3388c,
1514 0x338c0, 0x338d0,
1515 0x338e8, 0x338ec,
1516 0x33900, 0x3392c,
1517 0x33934, 0x33950,
1518 0x33958, 0x33958,
1519 0x33960, 0x3398c,
1520 0x3399c, 0x339ac,
1521 0x339c0, 0x339c0,
1522 0x339c8, 0x339d0,
1523 0x339d8, 0x339e0,
1524 0x339ec, 0x33a90,
1525 0x33a98, 0x33ac4,
1526 0x33ae4, 0x33b10,
1527 0x33b24, 0x33b28,
1528 0x33b38, 0x33b50,
1529 0x33bf0, 0x33c10,
1530 0x33c24, 0x33c28,
1531 0x33c38, 0x33c50,
1532 0x33cf0, 0x33cfc,
1533 0x34000, 0x34030,
1534 0x34100, 0x34168,
1535 0x34190, 0x341a0,
1536 0x341a8, 0x341b8,
1537 0x341c4, 0x341c8,
1538 0x341d0, 0x341d0,
1539 0x34200, 0x34320,
1540 0x34400, 0x344b4,
1541 0x344c0, 0x3452c,
1542 0x34540, 0x3461c,
1543 0x34800, 0x348a0,
1544 0x348c0, 0x34908,
1545 0x34910, 0x349b8,
1546 0x34a00, 0x34a04,
1547 0x34a0c, 0x34a14,
1548 0x34a1c, 0x34a2c,
1549 0x34a44, 0x34a50,
1550 0x34a74, 0x34a74,
1551 0x34a7c, 0x34afc,
1552 0x34b08, 0x34c24,
1553 0x34d00, 0x34d14,
1554 0x34d1c, 0x34d3c,
1555 0x34d44, 0x34d4c,
1556 0x34d54, 0x34d74,
1557 0x34d7c, 0x34d7c,
1558 0x34de0, 0x34de0,
1559 0x34e00, 0x34ed4,
1560 0x34f00, 0x34fa4,
1561 0x34fc0, 0x34fc4,
1562 0x35000, 0x35004,
1563 0x35080, 0x350fc,
1564 0x35208, 0x35220,
1565 0x3523c, 0x35254,
1566 0x35300, 0x35300,
1567 0x35308, 0x3531c,
1568 0x35338, 0x3533c,
1569 0x35380, 0x35380,
1570 0x35388, 0x353a8,
1571 0x353b4, 0x353b4,
1572 0x35400, 0x35420,
1573 0x35438, 0x3543c,
1574 0x35480, 0x35480,
1575 0x354a8, 0x354a8,
1576 0x354b0, 0x354b4,
1577 0x354c8, 0x354d4,
1578 0x35a40, 0x35a4c,
1579 0x35af0, 0x35b20,
1580 0x35b38, 0x35b3c,
1581 0x35b80, 0x35b80,
1582 0x35ba8, 0x35ba8,
1583 0x35bb0, 0x35bb4,
1584 0x35bc8, 0x35bd4,
1585 0x36140, 0x3618c,
1586 0x361f0, 0x361f4,
1587 0x36200, 0x36200,
1588 0x36218, 0x36218,
1589 0x36400, 0x36400,
1590 0x36408, 0x3641c,
1591 0x36618, 0x36620,
1592 0x36664, 0x36664,
1593 0x366a8, 0x366a8,
1594 0x366ec, 0x366ec,
1595 0x36a00, 0x36abc,
1596 0x36b00, 0x36b18,
1597 0x36b20, 0x36b38,
1598 0x36b40, 0x36b58,
1599 0x36b60, 0x36b78,
1600 0x36c00, 0x36c00,
1601 0x36c08, 0x36c3c,
1602 0x37000, 0x3702c,
1603 0x37034, 0x37050,
1604 0x37058, 0x37058,
1605 0x37060, 0x3708c,
1606 0x3709c, 0x370ac,
1607 0x370c0, 0x370c0,
1608 0x370c8, 0x370d0,
1609 0x370d8, 0x370e0,
1610 0x370ec, 0x3712c,
1611 0x37134, 0x37150,
1612 0x37158, 0x37158,
1613 0x37160, 0x3718c,
1614 0x3719c, 0x371ac,
1615 0x371c0, 0x371c0,
1616 0x371c8, 0x371d0,
1617 0x371d8, 0x371e0,
1618 0x371ec, 0x37290,
1619 0x37298, 0x372c4,
1620 0x372e4, 0x37390,
1621 0x37398, 0x373c4,
1622 0x373e4, 0x3742c,
1623 0x37434, 0x37450,
1624 0x37458, 0x37458,
1625 0x37460, 0x3748c,
1626 0x3749c, 0x374ac,
1627 0x374c0, 0x374c0,
1628 0x374c8, 0x374d0,
1629 0x374d8, 0x374e0,
1630 0x374ec, 0x3752c,
1631 0x37534, 0x37550,
1632 0x37558, 0x37558,
1633 0x37560, 0x3758c,
1634 0x3759c, 0x375ac,
1635 0x375c0, 0x375c0,
1636 0x375c8, 0x375d0,
1637 0x375d8, 0x375e0,
1638 0x375ec, 0x37690,
1639 0x37698, 0x376c4,
1640 0x376e4, 0x37790,
1641 0x37798, 0x377c4,
1642 0x377e4, 0x377fc,
1643 0x37814, 0x37814,
1644 0x37854, 0x37868,
1645 0x37880, 0x3788c,
1646 0x378c0, 0x378d0,
1647 0x378e8, 0x378ec,
1648 0x37900, 0x3792c,
1649 0x37934, 0x37950,
1650 0x37958, 0x37958,
1651 0x37960, 0x3798c,
1652 0x3799c, 0x379ac,
1653 0x379c0, 0x379c0,
1654 0x379c8, 0x379d0,
1655 0x379d8, 0x379e0,
1656 0x379ec, 0x37a90,
1657 0x37a98, 0x37ac4,
1658 0x37ae4, 0x37b10,
1659 0x37b24, 0x37b28,
1660 0x37b38, 0x37b50,
1661 0x37bf0, 0x37c10,
1662 0x37c24, 0x37c28,
1663 0x37c38, 0x37c50,
1664 0x37cf0, 0x37cfc,
1665 0x40040, 0x40040,
1666 0x40080, 0x40084,
1667 0x40100, 0x40100,
1668 0x40140, 0x401bc,
1669 0x40200, 0x40214,
1670 0x40228, 0x40228,
1671 0x40240, 0x40258,
1672 0x40280, 0x40280,
1673 0x40304, 0x40304,
1674 0x40330, 0x4033c,
1675 0x41304, 0x413c8,
1676 0x413d0, 0x413dc,
1677 0x413f0, 0x413f0,
1678 0x41400, 0x4140c,
1679 0x41414, 0x4141c,
1680 0x41480, 0x414d0,
1681 0x44000, 0x4407c,
1682 0x440c0, 0x441ac,
1683 0x441b4, 0x4427c,
1684 0x442c0, 0x443ac,
1685 0x443b4, 0x4447c,
1686 0x444c0, 0x445ac,
1687 0x445b4, 0x4467c,
1688 0x446c0, 0x447ac,
1689 0x447b4, 0x4487c,
1690 0x448c0, 0x449ac,
1691 0x449b4, 0x44a7c,
1692 0x44ac0, 0x44bac,
1693 0x44bb4, 0x44c7c,
1694 0x44cc0, 0x44dac,
1695 0x44db4, 0x44e7c,
1696 0x44ec0, 0x44fac,
1697 0x44fb4, 0x4507c,
1698 0x450c0, 0x451ac,
1699 0x451b4, 0x451fc,
1700 0x45800, 0x45804,
1701 0x45810, 0x45830,
1702 0x45840, 0x45860,
1703 0x45868, 0x45868,
1704 0x45880, 0x45884,
1705 0x458a0, 0x458b0,
1706 0x45a00, 0x45a04,
1707 0x45a10, 0x45a30,
1708 0x45a40, 0x45a60,
1709 0x45a68, 0x45a68,
1710 0x45a80, 0x45a84,
1711 0x45aa0, 0x45ab0,
1712 0x460c0, 0x460e4,
1713 0x47000, 0x4703c,
1714 0x47044, 0x4708c,
1715 0x47200, 0x47250,
1716 0x47400, 0x47408,
1717 0x47414, 0x47420,
1718 0x47600, 0x47618,
1719 0x47800, 0x47814,
1720 0x47820, 0x4782c,
1721 0x50000, 0x50084,
1722 0x50090, 0x500cc,
1723 0x50300, 0x50384,
1724 0x50400, 0x50400,
1725 0x50800, 0x50884,
1726 0x50890, 0x508cc,
1727 0x50b00, 0x50b84,
1728 0x50c00, 0x50c00,
1729 0x51000, 0x51020,
1730 0x51028, 0x510b0,
1731 0x51300, 0x51324,
1732 };
1733
1734 if (ddi_copyin(data, &r, sizeof (r), flags) < 0)
1735 return (EFAULT);
1736
1737 if (is_t4(sc->params.chip)) {
1738 if (r.len > T4_REGDUMP_SIZE)
1739 r.len = T4_REGDUMP_SIZE;
1740 else if (r.len < T4_REGDUMP_SIZE)
1741 return (ENOBUFS);
1742 } else {
1743 /* Regdump size is same for both T5 and T6 */
1744 if (r.len > T5_REGDUMP_SIZE)
1745 r.len = T5_REGDUMP_SIZE;
1746 else if (r.len < T5_REGDUMP_SIZE)
1747 return (ENOBUFS);
1748 }
1749
1750 r.version = mk_adap_vers(sc);
1751
1752 if (is_t4(sc->params.chip)) {
1753 reg_ranges = &t4_reg_ranges[0];
1754 arr_size = ARRAY_SIZE(t4_reg_ranges);
1755 buf_size = T4_REGDUMP_SIZE;
1756 } else if (is_t5(sc->params.chip)) {
1757 reg_ranges = &t5_reg_ranges[0];
1758 arr_size = ARRAY_SIZE(t5_reg_ranges);
1759 buf_size = T5_REGDUMP_SIZE;
1760 } else {
1761 reg_ranges = &t6_reg_ranges[0];
1762 arr_size = ARRAY_SIZE(t6_reg_ranges);
1763 buf_size = T6_REGDUMP_SIZE;
1764 }
1765
1766 buf = kmem_zalloc(buf_size, KM_SLEEP);
1767 if (buf == NULL)
1768 return (ENOMEM);
1769
1770 for (i = 0; i < arr_size; i += 2)
1771 reg_block_dump(sc, buf, reg_ranges[i], reg_ranges[i + 1]);
1772
1773 /* Copyout device log buffer and then carrier buffer */
1774 if (ddi_copyout(buf, (void *)((uintptr_t)data + sizeof(r)), r.len,
1775 flags) < 0) {
1776 rc = EFAULT;
1777 goto free;
1778 }
1779
1780 if (ddi_copyout(&r, data, sizeof(r), flags) < 0)
1781 rc = EFAULT;
1782 free:
1783 kmem_free(buf, buf_size);
1784 return (rc);
1785 }
1786
1787 static int
get_sge_context(struct adapter * sc,void * data,int flags)1788 get_sge_context(struct adapter *sc, void *data, int flags)
1789 {
1790 struct t4_sge_context sgec;
1791 uint32_t buff[SGE_CTXT_SIZE / 4];
1792 int rc = 0;
1793
1794 if (ddi_copyin(data, &sgec, sizeof (sgec), flags) < 0) {
1795 rc = EFAULT;
1796 goto _exit;
1797 }
1798
1799 if (sgec.len < SGE_CTXT_SIZE || sgec.addr > M_CTXTQID) {
1800 rc = EINVAL;
1801 goto _exit;
1802 }
1803
1804 if ((sgec.mem_id != T4_CTXT_EGRESS) && (sgec.mem_id != T4_CTXT_FLM) &&
1805 (sgec.mem_id != T4_CTXT_INGRESS)) {
1806 rc = EINVAL;
1807 goto _exit;
1808 }
1809
1810 rc = (sc->flags & FW_OK) ?
1811 -t4_sge_ctxt_rd(sc, sc->mbox, sgec.addr, sgec.mem_id, buff) :
1812 -t4_sge_ctxt_rd_bd(sc, sgec.addr, sgec.mem_id, buff);
1813 if (rc != 0)
1814 goto _exit;
1815
1816 sgec.version = 4 | (sc->params.chip << 10);
1817
1818 /* copyout data and then t4_sge_context */
1819 rc = ddi_copyout(buff, sgec.data, sgec.len, flags);
1820 if (rc == 0)
1821 rc = ddi_copyout(&sgec, data, sizeof (sgec), flags);
1822 /* if ddi_copyout fails, return EFAULT - for either of the two */
1823 if (rc != 0)
1824 rc = EFAULT;
1825
1826 _exit:
1827 return (rc);
1828 }
1829
1830 static int
read_tid_tab(struct adapter * sc,void * data,int flags)1831 read_tid_tab(struct adapter *sc, void *data, int flags)
1832 {
1833 struct t4_tid_info t4tid;
1834 uint32_t *buf, *b;
1835 struct tid_info *t = &sc->tids;
1836 int rc = 0;
1837
1838 if (ddi_copyin(data, &t4tid, sizeof (t4tid), flags) < 0) {
1839 rc = EFAULT;
1840 goto _exit;
1841 }
1842
1843 buf = b = kmem_zalloc(t4tid.len, KM_NOSLEEP);
1844 if (buf == NULL) {
1845 rc = ENOMEM;
1846 goto _exit;
1847 }
1848
1849 *b++ = t->tids_in_use;
1850 *b++ = t->atids_in_use;
1851 *b = t->stids_in_use;
1852
1853 if (ddi_copyout(buf, t4tid.data, t4tid.len, flags) < 0)
1854 rc = EFAULT;
1855
1856 kmem_free(buf, t4tid.len);
1857
1858 _exit:
1859 return (rc);
1860 }
1861
1862 /*
1863 * Verify that the memory range specified by the addr/len pair is valid and lies
1864 * entirely within a single region (EDCx or MCx).
1865 */
1866 static int
validate_mem_range(struct adapter * sc,uint32_t addr,int len)1867 validate_mem_range(struct adapter *sc, uint32_t addr, int len)
1868 {
1869 uint32_t em, addr_len, maddr, mlen;
1870
1871 /* Memory can only be accessed in naturally aligned 4 byte units */
1872 if (addr & 3 || len & 3 || len == 0)
1873 return (EINVAL);
1874
1875 /* Enabled memories */
1876 em = t4_read_reg(sc, A_MA_TARGET_MEM_ENABLE);
1877 if (em & F_EDRAM0_ENABLE) {
1878 addr_len = t4_read_reg(sc, A_MA_EDRAM0_BAR);
1879 maddr = G_EDRAM0_BASE(addr_len) << 20;
1880 mlen = G_EDRAM0_SIZE(addr_len) << 20;
1881 if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1882 addr + len <= maddr + mlen)
1883 return (0);
1884 }
1885 if (em & F_EDRAM1_ENABLE) {
1886 addr_len = t4_read_reg(sc, A_MA_EDRAM1_BAR);
1887 maddr = G_EDRAM1_BASE(addr_len) << 20;
1888 mlen = G_EDRAM1_SIZE(addr_len) << 20;
1889 if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1890 addr + len <= maddr + mlen)
1891 return (0);
1892 }
1893 if (em & F_EXT_MEM_ENABLE) {
1894 addr_len = t4_read_reg(sc, A_MA_EXT_MEMORY_BAR);
1895 maddr = G_EXT_MEM_BASE(addr_len) << 20;
1896 mlen = G_EXT_MEM_SIZE(addr_len) << 20;
1897 if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1898 addr + len <= maddr + mlen)
1899 return (0);
1900 }
1901 if (!is_t4(sc->params.chip) && em & F_EXT_MEM1_ENABLE) {
1902 addr_len = t4_read_reg(sc, A_MA_EXT_MEMORY1_BAR);
1903 maddr = G_EXT_MEM1_BASE(addr_len) << 20;
1904 mlen = G_EXT_MEM1_SIZE(addr_len) << 20;
1905 if (mlen > 0 && addr >= maddr && addr < maddr + mlen &&
1906 addr + len <= maddr + mlen)
1907 return (0);
1908 }
1909
1910 return (EFAULT);
1911 }
1912
1913 static int
read_card_mem(struct adapter * sc,void * data,int flags)1914 read_card_mem(struct adapter *sc, void *data, int flags)
1915 {
1916 struct t4_mem_range mr;
1917 uint32_t addr, off, remaining, i, n;
1918 uint32_t *buf, *b;
1919 int rc = 0;
1920 uint32_t mw_base, mw_aperture;
1921 uint8_t *dst;
1922
1923 if (ddi_copyin(data, &mr, sizeof (mr), flags) < 0) {
1924 rc = EFAULT;
1925 goto _exit;
1926 }
1927
1928 rc = validate_mem_range(sc, mr.addr, mr.len);
1929 if (rc != 0)
1930 return (rc);
1931
1932 memwin_info(sc, 2, &mw_base, &mw_aperture);
1933 buf = b = kmem_zalloc(min(mr.len, mw_aperture), KM_NOSLEEP);
1934 if (buf == NULL) {
1935 rc = ENOMEM;
1936 goto _exit;
1937 }
1938
1939 addr = mr.addr;
1940 remaining = mr.len;
1941 dst = (void *)mr.data;
1942
1943 while (remaining) {
1944 off = position_memwin(sc, 2, addr);
1945
1946 /* number of bytes that we'll copy in the inner loop */
1947 n = min(remaining, mw_aperture - off);
1948
1949 for (i = 0; i < n; i += 4)
1950 *b++ = t4_read_reg(sc, mw_base + off + i);
1951 rc = ddi_copyout(buf, dst, n, flags);
1952 if (rc != 0) {
1953 rc = EFAULT;
1954 break;
1955 }
1956
1957 b = buf;
1958 dst += n;
1959 remaining -= n;
1960 addr += n;
1961 }
1962
1963 kmem_free(buf, min(mr.len, mw_aperture));
1964 _exit:
1965 return (rc);
1966 }
1967
1968 static int
get_devlog(struct adapter * sc,void * data,int flags)1969 get_devlog(struct adapter *sc, void *data, int flags)
1970 {
1971 struct devlog_params *dparams = &sc->params.devlog;
1972 struct fw_devlog_e *buf;
1973 struct t4_devlog dl;
1974 int rc = 0;
1975
1976 if (ddi_copyin(data, &dl, sizeof (dl), flags) < 0) {
1977 rc = EFAULT;
1978 goto done;
1979 }
1980
1981 if (dparams->start == 0) {
1982 dparams->memtype = 0;
1983 dparams->start = 0x84000;
1984 dparams->size = 32768;
1985 }
1986
1987 if (dl.len < dparams->size) {
1988 dl.len = dparams->size;
1989 rc = ddi_copyout(&dl, data, sizeof (dl), flags);
1990 /*
1991 * rc = 0 indicates copyout was successful, then return ENOBUFS
1992 * to indicate that the buffer size was not enough. Return of
1993 * EFAULT indicates that the copyout was not successful.
1994 */
1995 rc = (rc == 0) ? ENOBUFS : EFAULT;
1996 goto done;
1997 }
1998
1999 buf = kmem_zalloc(dparams->size, KM_NOSLEEP);
2000 if (buf == NULL) {
2001 rc = ENOMEM;
2002 goto done;
2003 }
2004
2005 rc = -t4_memory_rw(sc, sc->params.drv_memwin, dparams->memtype,
2006 dparams->start, dparams->size, (void *)buf,
2007 T4_MEMORY_READ);
2008 if (rc != 0)
2009 goto done1;
2010
2011 /* Copyout device log buffer and then carrier buffer */
2012 if (ddi_copyout(buf, (void *)((uintptr_t)data + sizeof(dl)), dl.len,
2013 flags) < 0)
2014 rc = EFAULT;
2015
2016 if (ddi_copyout(&dl, data, sizeof(dl), flags) < 0)
2017 rc = EFAULT;
2018
2019 done1:
2020 kmem_free(buf, dparams->size);
2021
2022 done:
2023 return (rc);
2024 }
2025
2026 static int
read_cim_qcfg(struct adapter * sc,void * data,int flags)2027 read_cim_qcfg(struct adapter *sc, void *data, int flags)
2028 {
2029 struct t4_cim_qcfg t4cimqcfg;
2030 int rc = 0;
2031 unsigned int ibq_rdaddr, obq_rdaddr, nq;
2032
2033 if (ddi_copyin(data, &t4cimqcfg, sizeof (t4cimqcfg), flags) < 0) {
2034 rc = EFAULT;
2035 goto _exit;
2036 }
2037
2038 if (is_t4(sc->params.chip)) {
2039 t4cimqcfg.num_obq = CIM_NUM_OBQ;
2040 ibq_rdaddr = A_UP_IBQ_0_RDADDR;
2041 obq_rdaddr = A_UP_OBQ_0_REALADDR;
2042 } else {
2043 t4cimqcfg.num_obq = CIM_NUM_OBQ_T5;
2044 ibq_rdaddr = A_UP_IBQ_0_SHADOW_RDADDR;
2045 obq_rdaddr = A_UP_OBQ_0_SHADOW_REALADDR;
2046 }
2047 nq = CIM_NUM_IBQ + t4cimqcfg.num_obq;
2048
2049 rc = -t4_cim_read(sc, ibq_rdaddr, 4 * nq, t4cimqcfg.stat);
2050 if (rc == 0)
2051 rc = -t4_cim_read(sc, obq_rdaddr, 2 * t4cimqcfg.num_obq,
2052 t4cimqcfg.obq_wr);
2053 if (rc != 0)
2054 return (rc);
2055
2056 t4_read_cimq_cfg(sc, t4cimqcfg.base, t4cimqcfg.size, t4cimqcfg.thres);
2057
2058 if (ddi_copyout(&t4cimqcfg, data, sizeof (t4cimqcfg), flags) < 0)
2059 rc = EFAULT;
2060
2061 _exit:
2062 return (rc);
2063 }
2064
2065 static int
read_edc(struct adapter * sc,void * data,int flags)2066 read_edc(struct adapter *sc, void *data, int flags)
2067 {
2068 struct t4_edc t4edc;
2069 int rc = 0;
2070 u32 count, pos = 0;
2071 u32 memoffset;
2072 __be32 *edc = NULL;
2073
2074 if (ddi_copyin(data, &t4edc, sizeof (t4edc), flags) < 0) {
2075 rc = EFAULT;
2076 goto _exit;
2077 }
2078
2079 if (t4edc.mem > 2)
2080 goto _exit;
2081
2082 edc = kmem_zalloc(t4edc.len, KM_NOSLEEP);
2083 if (edc == NULL) {
2084 rc = ENOMEM;
2085 goto _exit;
2086 }
2087 /*
2088 * Offset into the region of memory which is being accessed
2089 * MEM_EDC0 = 0
2090 * MEM_EDC1 = 1
2091 * MEM_MC = 2
2092 */
2093 memoffset = (t4edc.mem * (5 * 1024 * 1024));
2094 count = t4edc.len;
2095 pos = t4edc.pos;
2096
2097 while (count) {
2098 u32 len;
2099
2100 rc = t4_memory_rw(sc, sc->params.drv_memwin, memoffset, pos,
2101 count, edc, T4_MEMORY_READ);
2102 if (rc != 0) {
2103 kmem_free(edc, t4edc.len);
2104 goto _exit;
2105 }
2106
2107 len = MEMWIN0_APERTURE;
2108 pos += len;
2109 count -= len;
2110 }
2111
2112 if (ddi_copyout(edc, t4edc.data, t4edc.len, flags) < 0)
2113 rc = EFAULT;
2114
2115 kmem_free(edc, t4edc.len);
2116 _exit:
2117 return (rc);
2118 }
2119
2120 static int
read_cim_ibq(struct adapter * sc,void * data,int flags)2121 read_cim_ibq(struct adapter *sc, void *data, int flags)
2122 {
2123 struct t4_ibq t4ibq;
2124 int rc = 0;
2125 __be64 *buf;
2126
2127 if (ddi_copyin(data, &t4ibq, sizeof (t4ibq), flags) < 0) {
2128 rc = EFAULT;
2129 goto _exit;
2130 }
2131
2132 buf = kmem_zalloc(t4ibq.len, KM_NOSLEEP);
2133 if (buf == NULL) {
2134 rc = ENOMEM;
2135 goto _exit;
2136 }
2137
2138 rc = t4_read_cim_ibq(sc, 3, (u32 *)buf, CIM_IBQ_SIZE * 4);
2139 if (rc < 0) {
2140 kmem_free(buf, t4ibq.len);
2141 return (rc);
2142 } else
2143 rc = 0;
2144
2145 if (ddi_copyout(buf, t4ibq.data, t4ibq.len, flags) < 0)
2146 rc = EFAULT;
2147
2148 kmem_free(buf, t4ibq.len);
2149
2150 _exit:
2151 return (rc);
2152 }
2153
2154 static int
read_cim_la(struct adapter * sc,void * data,int flags)2155 read_cim_la(struct adapter *sc, void *data, int flags)
2156 {
2157 struct t4_cim_la t4cimla;
2158 int rc = 0;
2159 unsigned int cfg;
2160 __be64 *buf;
2161
2162 rc = t4_cim_read(sc, A_UP_UP_DBG_LA_CFG, 1, &cfg);
2163 if (rc != 0)
2164 return (rc);
2165
2166 if (ddi_copyin(data, &t4cimla, sizeof (t4cimla), flags) < 0) {
2167 rc = EFAULT;
2168 goto _exit;
2169 }
2170
2171 buf = kmem_zalloc(t4cimla.len, KM_NOSLEEP);
2172 if (buf == NULL) {
2173 rc = ENOMEM;
2174 goto _exit;
2175 }
2176
2177 rc = t4_cim_read_la(sc, (u32 *)buf, NULL);
2178 if (rc != 0) {
2179 kmem_free(buf, t4cimla.len);
2180 return (rc);
2181 }
2182
2183 if (ddi_copyout(buf, t4cimla.data, t4cimla.len, flags) < 0)
2184 rc = EFAULT;
2185
2186 kmem_free(buf, t4cimla.len);
2187
2188 _exit:
2189 return (rc);
2190 }
2191
2192 static int
read_mbox(struct adapter * sc,void * data,int flags)2193 read_mbox(struct adapter *sc, void *data, int flags)
2194 {
2195 struct t4_mbox t4mbox;
2196 int rc = 0, i;
2197 __be64 *p, *buf;
2198
2199 u32 data_reg = PF_REG(4, A_CIM_PF_MAILBOX_DATA);
2200
2201 if (ddi_copyin(data, &t4mbox, sizeof (t4mbox), flags) < 0) {
2202 rc = EFAULT;
2203 goto _exit;
2204 }
2205
2206 buf = p = kmem_zalloc(t4mbox.len, KM_NOSLEEP);
2207 if (buf == NULL) {
2208 rc = ENOMEM;
2209 goto _exit;
2210 }
2211
2212 for (i = 0; i < t4mbox.len; i += 8, p++)
2213 *p = t4_read_reg64(sc, data_reg + i);
2214
2215 if (ddi_copyout(buf, t4mbox.data, t4mbox.len, flags) < 0)
2216 rc = EFAULT;
2217
2218 kmem_free(buf, t4mbox.len);
2219
2220 _exit:
2221 return (rc);
2222 }
2223
2224 static int
flash_fw(struct adapter * sc,void * data,int flags)2225 flash_fw(struct adapter *sc, void *data, int flags)
2226 {
2227 unsigned int mbox = M_PCIE_FW_MASTER + 1;
2228 struct t4_ldfw fw;
2229 u8 *ptr = NULL;
2230 int rc = 0;
2231
2232 if (ddi_copyin(data, &fw, sizeof(struct t4_ldfw), flags) < 0)
2233 return EFAULT;
2234
2235 if (!fw.len)
2236 return EINVAL;
2237
2238 ptr = (u8 *)kmem_zalloc(fw.len, KM_NOSLEEP);
2239 if (ptr == NULL)
2240 return ENOMEM;
2241
2242 if (ddi_copyin((void *)((uintptr_t)data + sizeof(fw)), ptr, fw.len,
2243 flags) < 0) {
2244 kmem_free(ptr, fw.len);
2245 return EFAULT;
2246 }
2247
2248 if (sc->flags & FULL_INIT_DONE)
2249 mbox = sc->mbox;
2250
2251 rc = -t4_fw_upgrade(sc, mbox, ptr, fw.len, true);
2252 ddi_ufm_update(sc->ufm_hdl);
2253
2254 kmem_free(ptr, fw.len);
2255
2256 return (rc);
2257 }
2258
2259 static int
get_cudbg(struct adapter * sc,void * data,int flags)2260 get_cudbg(struct adapter *sc, void *data, int flags)
2261 {
2262 struct t4_cudbg_dump dump;
2263 struct cudbg_init *cudbg;
2264 void *handle, *buf;
2265 int size;
2266 int rc = 0;
2267
2268 if (ddi_copyin(data, &dump, sizeof(struct t4_cudbg_dump), flags) < 0)
2269 return EFAULT;
2270
2271 size = dump.len;
2272 buf = (u8 *)kmem_zalloc(dump.len, KM_NOSLEEP);
2273 if (buf == NULL)
2274 return ENOMEM;
2275
2276 handle = cudbg_alloc_handle();
2277 if (handle == NULL) {
2278 rc = ENOMEM;
2279 goto free;
2280 }
2281
2282 cudbg = cudbg_get_init(handle);
2283 cudbg->adap = sc;
2284 cudbg->print = cxgb_printf;
2285
2286 memcpy(cudbg->dbg_bitmap, dump.bitmap, sizeof(cudbg->dbg_bitmap));
2287
2288 rc = cudbg_collect(handle, buf, &dump.len);
2289 if (rc != 0) {
2290 cxgb_printf(sc->dip, CE_WARN, "cudbg collect failed\n");
2291 goto exit;
2292 }
2293
2294 if(ddi_copyout(buf, (void *)((uintptr_t)data + sizeof(dump)),
2295 dump.len, flags) < 0){
2296 rc = EFAULT;
2297 }
2298
2299 if (ddi_copyout(&dump, data, sizeof(dump), flags) < 0){
2300 rc = EFAULT;
2301 }
2302 exit:
2303 cudbg_free_handle(handle);
2304 free:
2305 kmem_free(buf, size);
2306
2307 return rc;
2308 }
2309