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